Closed Kroc closed 2 years ago
You are going to have to give us some better code.
First, it complains that input% name already used, and when I do set it up I get an incorrect number of arguments in the IF statements for return_some%.
I don't see this code working at all. Please post the actual code you are using instead of a hypothetical function.
Is this what you are trying to do?
` x% = return_some%(500) PRINT x%
FUNCTION return_some% (i%) p% = i% IF i% > 1 THEN p% = p% + 1 IF i% > 10 THEN p% = p% + 10 IF i% > 100 THEN p% = p% + 100 return_some% = p% END FUNCTION `
EDIT: For some reason the code tags aren't working for me.
Sorry, here's a piece of code that would compile in the past, but no longer does:
FUNCTION Tags_Find% (tag$)
FOR Tags_Find% = 1 TO UBOUND(Tags)
IF Tags(Tags_Find%) = tag$ THEN EXIT FUNCTION
NEXT
LET Tags_Find% = 0
END FUNCTION
This fails now because FOR Tags_Find%
is interpreted as a function call (to itself), and not as the return value
I'm still getting missing argument errors in the function. If tag$ is not a SHARED variable, then except for your last LET tags_find%=0 statement, each time you have Tags_Find% in your function, it becomes a recursive call, and requires you to pass a parameter to it.
You might be better off to post this on our forum, where you can post your entire source code there, as I still do not know what this function is supposed to be doing without the rest of the program to see.
That's the bug -- FOR Tags_Find% = 1
should set the return variable, not attempt a recursive call. That worked in the past, and that's how it works in QB's descendents like Visual Basic
It thinks it is a recursive call. That is the error I'm getting.
@Kroc what you get is the reason why we bumped version number to 2.0. You cannot use a function's name as a variable anymore. It's now always treated as a function call, to properly resemble QuickBASIC 4.5 - our end goal.
Relevant forum post from when it was fixed: https://www.qb64.org/forum/index.php?topic=4209.msg135786#msg135786
At some point this normal code pattern stopped working:
Basically, you can no longer read back the function's return variable because it is being confused for a function call and the parameter is considered missing. It is very useful to modify the return variable multiple times throughout a function because it avoids having to create a temporary 'result' variable which won't work with
exit function
used to 'return' the current value.