Hi,
Newbie just being a newbie.. could someone please tell me the difference of using a gosub rather than just a function ?
From what I understand, both can do the same thing.
Really starting to relax and enjoy this program, I'm quite a reasonable programmer.. and I'm impressed with what I've played with so far. (Just needs some good examples/demos - hopefully I can help out once I've found my feet)
Knew keeping those old spectrum basic programming books would come in handy ;)
Thanks.
Just forget about Gosub, use functions. Gosub can't handle the passing of parameters but takes just as long to call so there is no real reason for gosub other than backwards compatibility with older basics.
thought so.. cant seem to work out how to pass a return for more than one variable though ?
return x,y
doesnt seem to work.
Thats where you use BYREF to modify the passed variable.
Thanks. will have a play
Quote from: Gerfy on 2009-Aug-18
thought so.. cant seem to work out how to pass a return for more than one variable though ?
return x,y
doesnt seem to work.
Sorry for bad English ;)
You can use Type.
Example:
GLOBAL giveme AS Tgivemore
giveme = f_givemore()
PRINT giveme.a$,10,10
PRINT giveme.b#,10,30
PRINT giveme.c%,10,50
SHOWSCREEN
KEYWAIT
//-----------------------------
FUNCTION f_givemore AS Tgivemore :
LOCAL temp AS Tgivemore
temp.a$ = "Hello"
temp.b# = 12.0012
temp.c% = 999
RETURN temp
ENDFUNCTION
TYPE Tgivemore
a$
b#
c%
ENDTYPE