Main Menu

Returning array contents

Started by monkeybot, May 04, 2015, 04:50:20 AM

Previous topic - Next topic

monkeybot

I was trying to return a specific array element's contents from a function but found it wouldn't work,I had to copy the specific element to a string and it was fine,is this normal or am i being stupid?


This doesn't work...

; PROJECT : Project3
; AUTHOR  : PC
; CREATED : 04/05/2015
; ---------------------------------------------------------------------

explicit on
dim r$(50)
global ret$

ret$=makes("test")

PRINT "return is "+ret$
sync
waitkey
end


Function makes(s$)

r$(10)=s$
print "r$ "+r$(10)

EndFunction r$(10)



This works...



explicit on
dim r$(50)
global ret$

ret$=makes("test")

PRINT "return is "+ret$
sync
waitkey
end


Function makes(s$)
local rr$

r$(10)=s$
print "r$ "+r$(10)
rr$=r$(10)

EndFunction rr$




kevin



EndFunction r$(10)


   It might not look like much but r$(10) is actually an expression.   The prototype pass can't solve this in pass #1 as variables/arrays etc etc don't exist.   All it can do is guess the return type, as for where that data comes from, it won't be able to resolve it, so your getting an empty string.

monkeybot