Dim b(2)
b(0) = "hello"
b(1) = "world"
Foo (b)
Sub Foo(c)
MsgBox(c(0))
MsgBox(c(1))
End sub
For i = 0 to 1
MsgBox(i)
Next
Dim b(2)
b(0) = "Hello"
b(1) = "World"
Foo ("b")
sub Foo(a)
for i = 0 to GetTotalLen(a) - 1
MsgBox (GetItem (a, i))
next
end sub
Foo2()
Sub Foo2()
Dim b(2)
b(0) = "Hello"
b(1) = "World"
Foo ("b")
End Sub
sub Foo(a)
for i = 0 to GetTotalLen(a) - 1
MsgBox (GetItem (a, i))
next
end sub
You can't, and don't need to. Arrays must be declared as Globals in the outer scope but can be re-Dimmed in Subs if necessary. Have you read the "Variables" section in the B4Script.chm help file?How can you pass arrays to subs ?
The tokeniser needs to fill in a target line for the For statement to jump to on exit, a blank line is sufficient. I guess your Next was the last statement in the outer scope - hence the error message.Thanks !
I didn't intend that as a blanket statement of philosophy but meant that in this particular case you can always use a "scratch" global array as a local array . This script language almost exactly mirrors, very intentionally, that of the now obsolete Basic4ppc as it was originally written as a scripting library for Basic4ppc applications.But I tend to disagree that "you don't need to pass arrays to subs"
Foo("Hello world")
rem NOTICE THE SPACE BELOW between Foo and (
Sub Foo (b)
MsgBox (b)
End sub
Sub ShowMean
Msgbox("The mean of 20 and 30 is " & crlf & Mean(20,30))
End Sub
Sub Mean (a, b)
Return (a+b)/2
End Sub