This should work and is the correct syntax:
if Script.Function("Start", 10)
This may “work”, but is not the correct syntax for a function call:
If Script.Function ("Start"), (10)
The second example is demonstrably incorrect and would work only in special situations, if at all. I created the following function:
function doIt
put "the parameterList is:" && the parameterlist
put "param 2 is:" && param(2)
return the number of characters in param(1) is param(2)
end doIt
When it is called using the correct syntax:
put doIt ("parakeet", 8)
The output from the script is:
Thu, 10/7/10 6:32:53 AM START Running funcTest.script
the parameterList is: (parakeet,8)
param 2 is: 8
true
Thu, 10/7/10 6:32:53 AM SUCCESS Execution Time 0:00:00 funcTest.script
When I run it using this syntax:
put doIt ("parakeet"),(8)
the output is:
Thu, 10/7/10 6:39:39 AM START Running funcTest.script
the parameterList is: (parakeet)
param 2 is:
false
8
Thu, 10/7/10 6:39:40 AM SUCCESS Execution Time 0:00:00 funcTest.script
This only works at all because it’s treating the comma as the concatenation operator and doing a put of the return value of the function with a single argument with the value 8 concatenated to that output. As the above demonstrates, only the first value is being passed to the function. If I use the same syntax in an “if” statement it doesn’t even parse. Declaring the function parameters makes no difference.
On the question of incrementing and decrementing counters, I think eggPlant goes most languages one better – it has a built-in counter function: repeatIndex() (or “the repeatIndex”). This code:
repeat 2 times
put "outer loop:" && repeatIndex()
repeat 3 times
put "inner loop:" && the repeatIndex
end repeat
end repeat
produces the following output:
Thu, 10/7/10 7:01:08 AM START Running Selection from funcTest.script
outer loop: 1
inner loop: 1
inner loop: 2
inner loop: 3
outer loop: 2
inner loop: 1
inner loop: 2
inner loop: 3
Selection Executed in 0:00:00
So in most instances you don’t need to create or increment your own counter. There is no decrement equivalent, although you could always subtract the repeatIndex from a starting value:
put 239 into theCount
repeat
// do something
if theCount minus the repeatIndex is 0 then exit repeat
end repeat
You are correct that there is no increment or decrement shorthand; we would generally handle that with the following code:
add 1 to theCount
subtract 1 from theCount
//the following would also work
add -1 to theCount
I hope this information is helpful to you.