I have come across a puzzling behavior when trying to use the content of a 
field as parametres in a function, and I am trying to understand why.

I put the following in a field called «test»: 1,2,3,4,5

When I then call the function like this:  
                answer testFunction(field «test»), the paramCount() returns 1

If I use the values directly in the script: 
                answer testFunction(1,2,3,4,5), the paramCount() returns 5 as 
expected

I will also get the expected result if a do the following:

                put "answer testFunction(" & field «test»  & ")" into tScript
                do tScript

I guess the reason for this is that in the last example, LiveCode compiles the 
content of the variable tScript before execution, and that this turns what is 
first treated as a single block of text into a list of parametres. 

The reason why I want to understand what is happening is that I am about to 
teach my students how to write reusable code that will behave correctly for any 
number of parametres. 

So my question is if I am on the right track?

Best regards
Tore Nilsen
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to