I'm not sure if everyone knows this method or if it is a bad method, but it just occurred to me this week and I thought I'd share it.
With AppGameKit (and DBPro) we are limited to a single output variable from any user defined function. For the most part I've been working around this by using globals and arrays. This becomes quite sloppy very quickly.
So the other day I thought "why not stuff all o fthe variables I want to be output into a delimited string?"
Sure it takes a little bit of work to delimit the output, but it's not that bad AND it means I can have a recursive function with multiple outputs.
Here's a basic example:
myString$ = "some string that is just an example"
for i = 1 to len(myString$)
a$ = ThisFunction( val(GetStringToken(a$, "," , 1) , myString$ )
Print( GetStringToken(a$, "," , 2)
next i
END
//-----------------------------------------------------
function ThisFunction(iRecurse, someOtherInput$)
inc iRecurse
someOtherInput$ = left(someOtherInput$ , iRecurse)
output$ = str(iRecurse) + "," + someOtherInput$
endfunction output$
While this example doesn't really illustrate the power of this, I hope that you can see the possibilities. You could have the function handle delimiting of the recursive parameters if you want and you can input an unlimited number of parameters as well as output an unlimited number of returns.
I know this is going to make my code a lot neater and more modular. I hope it helps someone else too!
EDIT:
Out of curiosity to see the impact of a large string on memory, and if there are any limits, I've been running a program for about an hour that simply continues to add a character to a string. So far I've not hit any limit and there is oddly no impact on the memory that the app is allocated in task manager. Just thought I'd share that.