ecco
PooP MonkeeH
Posts: 1
|
Post by ecco on Jan 1, 2018 14:25:22 GMT -5
Hi everyone! This is my first post. I am new to BasiEgaXorz but not new to programing. I usally do C# and javascript. By reading the documentations, looking at examples and the forum I learned that I can call a function like this: emptyFunction
declare sub emptyFunction()
print "just an empty function"
end sub
or with an argument, like this: print mySubFunction&("hello!")
declare sub mySubFunction(mystring as string)
print "the string is: ";mystring$; end sub But is there any other way to call a function with an agrument other than print? I seen gosub or goto, but I get errors when I try the following: someFunction&(99) 'Error: Cannot identify instruction/Subroutine!
goto someFunction&(99) 'Error: Label does not exist!
gusub someFunction&(99) 'Error: Label does not exist!
declare sub someFunction(value as integer)
print value
end sub Thank you
|
|
pico
PooP MonkeeH
Posts: 8
|
Post by pico on Jan 1, 2018 19:17:10 GMT -5
You can call a subroutine that uses parameters like this:
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 2, 2018 7:03:02 GMT -5
Remember, there's a difference between a function and a subroutine. What Pico shows you is a subroutine - a routine that doesn't return a value. Functions work very similar: b = MyFunction(2) print b ' Should be 4
declare function MyFunction (arg as integer) as integer a = arg * 2 return arg end function
Exit Sub and Exit Function aren't needed unless you have logic branches that need to return a value and/or exit the function/sub before reaching the end, otherwise it doesn't do anything useful
|
|