LoginLogin
Might make SBS readonly: thread

Functions allowing extra arguments

Root / SmileBASIC Bug Reports / [.]

12Me21Created:
Some functions allow extra inputs, which are ignored:
VSYNC 1,2,3,4,5,6,7,8,9,10
WAIT 1,2,3,4,5,6,7,8,9,10
And others also allow unlimited outputs (which are all null):
PCMCONT 1,2,3,4,5,6,7,8,9,10 OUT ,,,,,,,,,,,,,,
'(and all other PCM functions)

This also means that there are a few more "ignore" functions:
X=POP(A) 'fastest (only works with one type)
PCMSTOP POP(A) 'requires DLC
IF POP(A) THEN ENDIF 'only works with integers and strings
WAIT 0,POP(A)
PLEASE POP(A) 'slowest
(Obviously you shouldn't actually use those since this is a bug that might be fixed) And a function that returns null:
PCMSTOP()

DIM X
X=PCMSTOP
> OK
DIM X
X=PCMSTOP()
> Uninitialized variable used in 0:2

DIM X
X=PCMSTOP
> OK
DIM X
X=PCMSTOP()
> Uninitialized variable used in 0:2
I don't think this has anything to do with this thread but okay

Well, it's an odd behavior. Edit: also, not sure if any other function can do this, but
PCMCONT OUT
PCMCONT 0 OUT
> OK
OUT with no outputs normally gives an error. Also, during my testing of this:
DEF T OUT
END
> Out of code memory in 0:1
Haven't seen that one before.

"Uninitialized variable used" is the error you get when trying to assign null to a variable. X= isn't a syntax error, it's actually X=(null). When SB expects a value but gets nothing, you get null. That's how functions with "empty" arguments work. LOCATE X, is just LOCATE X,(null), or LOCATE X,PCMSTOP() ("null" isn't an official name, it's just what we've been calling it) X=PCMSTOP is just treating PCMSTOP as a variable (variables and functions in SB can have the same names, and whether something is a variable or a function depends on context) Any function can be called as FUNCTION args OUT outputs, even if there are 0 outputs. For some reason DEF doesn't let you do that, though.

Somewhat news to me, do we have a page on it? (Edit: on the any Function arg Out opts) Also, looks like you just can't define a function like that.
DEF T END
T OUT
> OK
Ah, looks like I'm redundant here sadface