Rev difficulty

Scott Rossi scott at tactilemedia.com
Fri May 27 23:18:40 EDT 2005


Recently, Richard Gaskin  wrote:

> Here'something to learn from:
> 
> This example will teach how to call a custom function, and how to use
> the built-in function "random" and "toUpper" to modify text.

Richard, your function is a good one, however, it is lacking the extended
ellipsis required for such a filter.  Below is your function with a minor
addition to address the missing characters.

Hope you find this a useful addition.



-- BENZFILTER
--
-- THIS text FILTER returns the text passed into it
-- after randomly TURNING ABOUT one-fourth of its
-- words to UPPER-CASE.
--
-- In keeping with the style WHICH inspired its
-- creation, noise WORDS (insignificant TO the
-- meaning of the sentence) ARE EXCLUDED.
--
function BenzFilter pText
  -- YOU can ADD other noise WORDS to THIS list
  -- BY JUST separating new words with spaces:
  put "A AN IS OF THE" into tNoiseWords
  --
  -- GET the NUMBER of words in the text passed in:
  PUT the number of words of pText into TNUMWORDS
  --
  -- Repeat loop runs ABOUT one-fourth AS many times
  -- as there are words in the TEXT:
  repeat (tNumWords div 4)
    --
    -- The random function RETURNS a random number:
    PUT random(tNumWords) into N
    ---
    --- We USE THAT number HERE to PULL a word out of the TEXT:
    GET WORD N of pText
    --
    -- First we check TO see if IT'S one of our noise WORDS,
    -- and IF it is we return to the TOP of this repeat block
    -- without DOING ANYTHING FURTHER:
    IF it is among the WORDS of tNoiseWords then next repeat
    --
    -- If IT'S not a noise WORD then we use the toUpper
    -- function to change it to all-caps, AND put it back
    -- into place in the text:
    put toUpper(it) into word N of PTEXT
  end repeat
  --
  -- ELLIPSIS ADDITION
  -- AN EXTENDED SET OF ELLIPSIS IS PLACED AFTER EVERY 7TH WORD.
  -- THEN 'REPLACE' IS USED TO ELIMINATE THE EXTRA SPACE THAT
  -- PRECEEDS THE NEXT WORD
  repeat with W = 1 to number of words of pText
    if "." is not in (W/7) then put "...." after word W of pText
  end repeat
  replace ".... " with "...." in pText
  --
  --
  -- Last we simply return the result:
  return PTEXT
END BenzFilter



Example output follows:

------------------------------------------------------------------

Just how FAMILIAR are you with HyperCard....IF you weren't aware that
HYPERCARD stacks....ALSO HAVE scripts?

HyperCard had TWO types....of objects compared to Rev's ten, one....type of
window to REV'S four, fewer....than a third as many messages, fewer....than
half as many functions, AND ultimately....was so limited THAT the only
WAY....
one could MAKE anything close to NORMAL....HIG-COMPLIANT software was to
load themselves up....with EXTERNALS, and even THEN you couldn't....EVEN
drag 
a window normally.

With features....comes learning.
WITH POWER comes responsibility.

KLAUS....WILL cover some of what you're asking....about tommorrow, and I'LL
follow up two....weeks later with a discussion of the....message PATH for
more.

------------------------------------------------------------------


Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com



More information about the use-livecode mailing list