Hi !
fn test a b c:333 =
(
format “a=% b=% c=%
” a b c
)And I call it:
test 111 222
–> a=111 b=222 c=333But if I decide to assign an another value than the default value, I obtain this:
test 111 222 999
– Argument count error: test wanted 2, got 3
you must explicitely supply the c variable when calling the function:
test 111 222 c:999
-> a=111 b=222 c=999
this enables you to override variables used in functions
Shorter version:
fn compare a b &bool = (
if a.count != b.count do (
bool = false
)
for i = 1 to a.count do (
-- Test for nested arrays
if classof a[i] == Array and classof b[i] == Array then (
compare a[i] b[i] &bool
) else (
-- Test for strings
if classof a[i] == String and classof b[i] == String do (
if (stricmp a[i] b[i]) != 0 then (
bool = false
) else (
continue
)
)
if a[i] != b[i] do (
bool = false
)
)
)
)
myVal = true
compare myArr1 myArr2 &myVal
print myVal
As was pointed out you don’t use c=333 but instead you should use c:333. This is just the same as creating a box lets say, box height:50 width:20 …
Thanks for the explanation, Zbuffer and ‘Ogre’ (Paul).
That will undoubtedly be useful for me !
Thank you also for writing this smaller version, FaceMn.
hrmm i just noticed i have an odd problem.
If i do
“print myarray.count” it prints out one of the items in the array, and not the array count(number of items).
Any Ideas?
Indeed it’s strange. Maybe if you insert myArray.count between ( ), that will be better ? or to use ‘as string’
But I prefer to use the command ‘format’:
myArray=#(1, 2, 3)
format “myArray.count=%
” myArray.count
I think that the result will be more reliable.
Hrmm that did not work either
Thats really freaky, is there any other way to get the count of an array?
Is this a bug? it happens on my home machine and also at work…
Max 8
Ya I have to see an example that will cause this as well. Never seen this happen.
I am almost certain that he uses the “.count” with a bitarray and not with an array.
If it is the case, That deserves a punishment. lol 😈
a=#{11,22,33}
a.numberset
a.count