Param() Oddity

J. Landman Gay jacque at hyperactivesw.com
Thu Sep 9 23:57:52 EDT 2004


On 9/9/04 8:42 PM, Arthur Urban wrote:
> I'm trying to use the param() function, but it is behaving "badly". Here is
> the meat of the issue. Consider this fragment, param(1) = 'card "CardName"
> verified in variable watcher':
> 
>   put fld "F" of param(1) is empty into x
> 
> The above code blows up stating that fld "F" cannot be found. However, if I
> add a line as follows:
> 
>   put param(1) into tCard
>   put fld "F" of tCard is empty into x
> 
> This works!(?) Why can't I just use param(1)? The "documentation" implies
> that I've used it correctly.

The parameter will be interpreted as a text string, and the engine will 
see it like this:

   put fld "F" of "card 'CardName'" is empty into x

This doesn't compile. By putting it into a variable first, you've forced 
the engine to evaluate it. You can also do evalution using the "do" 
command like this:

do "put fld" && quote & "F" & quote && "of" && param(1) && "is empty into x"

but that is not only hard to read, it requires that the script load the 
compiler every time that line runs. Your second way is cleaner.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the use-livecode mailing list