LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

DEFined function syntax error?

Root / Programming Questions / [.]

tomrowCreated:
I've been trying to make a program that renders clickable buttons to the screen and I've wrote some tests to see if it works. Here's what I've got:
DEF CaptionButton(Top,Left,Wide)
DRAWBTN 0,Left,Top,Wide,"Test String"
RETURN 1
END
the DRAWBTN command is also a DEFined function that basically just draws a button to the screen, however CaptionButton will incorporate the click sensing capabilities in it too. However, running CaptionButton(32,32,32) reports a syntax error. This seems to be in line with the documentation included with SmileBASIC as far as I can see, so am I missing something?

DRAWBTN is clearly the issue here, so can we see the code for that?

You can't call a function without getting it's return value.
PRINT CaptionButton(32,32,32)
'or
VAR K=CaptionButton(32,32,32)

You can't call a function without getting it's return value.
PRINT CaptionButton(32,32,32)
'or
VAR K=CaptionButton(32,32,32)
You may have the answer here. Also, I forgot to say DRAWBTN is not the issue, I tested it seperately and it works. EDIT:Thank you for your help! I put DUMMY= in front of it and it works just fine!

If you don't want to return anything, you have to define and call the function without parentheses
DEF CaptionButton Top,Left,Wide
 DRAWBTN 0,Left,Top,Wide,"Test String"
END

CaptionButton 32,32,32