How trim?

Wilhelm Sanke sanke at hrz.uni-kassel.de
Mon Oct 24 12:23:38 EDT 2005


On Sun, 23 Oct 2005, Jim Ault <JimAultWins at yahoo.com> wrote:

> snip)
> Rev is really designed to be a tool box for developers to refine their own
> solutions and the community shares these results.  On one hand, the task
> might be the occasional string to trim, or on the other, a massive 
> list from
> a network log file.  In your case, you would rather have the flexible
> version that allowed you to pass the ASII number(s), so you could roll 
> your
> own with the help of the list.
>
> After building what you want, decide if it is to be available every 
> time you
> run Rev, or only for your intended audience with your app.  If only 
> for your
> app, copy and paste the functions from a place you store them, into 
> the main
> stack script.  Now LTrim(ascii, ascii, ascii) will work every time the way
> you wish.
>
> Read about back scripts, which are available after messages pass the stack
> level.
> (snip)
> Hope this helps you understand a bit more about a development environment


I might add one aspect to this discussion, although rather late:

There is one type of applications where you urgently need a trim 
function, namely: educational software that requires text input from the 
learner.
It happens very often here that the user inadvertently hits the spacebar 
and creates leading and/or trailing spaces whereas the other portion of 
his input may be correct.
He then gets a "wrong" as a feedback and is very much puzzled about what 
he really did wrong.

One of the first XTalk languages - "HyperPad", the first DOS clone of 
Hypercard about 15 years ago - indeed possessed such a handy function, 
i.e. "trim()" was part of the language.

As in other XTalk languages like Toolbook, Metacard, and eventually 
Revolution such a function was missing, the solution "we" used here 
often was

 "repeat until first char of tInput <> space
    delete first char of tInput
  end repeat
  repeat until last char of tInput  <> space
    delete last char of tInput
  end repeat"

which scriptwise is rather simple and easy to understand. At least it is 
easier to understand and apply than Regex expressions, especially for 
Xtalk novices.

Regards,

Wilhelm Sanke
<http://www.sanke.org/MetaMedia>





More information about the use-livecode mailing list