Main Menu

Function returning values question

Started by LemonWizard, February 11, 2013, 04:45:24 PM

Previous topic - Next topic

LemonWizard

if a function returns a value to main like this

endfunction value


without the code that called it having the = sign like that, does it still get returned to main?

example:



myfunction(novalue)


function myfunction(novalue)

thisvalue=rndrange(0, 100)

endfunction thisvalue




So I tried the above code and printed it using the console. it resulted in zero.

Why then does this work?




Function MakeCodeArray(Code$)
     Dim code$(0)
     Code$=replace$(code$,chr$(10),"")
     Count=SplitToArray(code$,chr$(13),Code$())
EndFunction Code$()  





and the call to it?



Function NewScript(Code$)
     index=getfreecell(Scripts())

     if Index>0
        MakeCodeArray(Code$)
        Scripts(Index).CodeArrayHandle=MakeCodeArray(Code$)
     endif
     
EndFunction Index



wait I see this was used:   Scripts(Index).CodeArrayHandle=MakeCodeArray(Code$)
but then what about the call above it MakeCodeArray(Code$) is the value the function returns that time ignored?

kevin

Quotedoes it still get returned to main?

  Nope.

  You're question really should be in the original thread since it's related.