? GOSUB within functions? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

GOSUB within functions?

  • #1 ✎ 65 Gaelstrom_Valence Drawing I like to draw! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Month Joined in the very first month of SmileBASIC Source Website The manual says it can't be used, but it seems to work fine for me? Is it referring to something else, or is the wording there a bit messed up? Posted Edited by Gaelstrom_Valence
  • #2 ✎ 1626 12Me21 Head Admin Third Year My account is over 3 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself It originally wasn't possible but they fixed it in version 3.5.2 or something. Posted
  • #3 ✎ 87 seggiepants Even if it works now, your really shouldn't be mixing GOSUB and functions, just use functions. Posted
  • #4 ✎ 65 Gaelstrom_Valence Drawing I like to draw! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength First Month Joined in the very first month of SmileBASIC Source Website
    Even if it works now, your really shouldn't be mixing GOSUB and functions, just use functions.
    This came up because I wanted to see if I could use ON within functions. I ended up going with GOTO anyways, but in either case... Well, I'm not sure if my speed test thing is accurate... but as far as I know, both GOSUB and GOTO with the ON instruction are faster than: DEF THING CTRL IF CTRL==0 THEN FUNC1 IF CTRL==1 THEN FUNC2 IF CTRL==2 THEN FUNC3 IF CTRL==3 THEN FUNC4
    Posted Edited by Gaelstrom_Valence
  • #5 ✎ 1626 12Me21 Head Admin Third Year My account is over 3 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself You could use ELSEIF for that But ON/GOTO/GOSUB is slightly faster Even without GOSUB, you can use another GOTO instead of RETURN: DEF THING CTRL VAR X ON CTRL GOTO @0,@1,@2,@3 @RET PRINT X RETURN @0 X=0 GOTO @RET @1 ... END But you should only do this in extreme circumstances when you need a tiny bit more speed (the speed difference between this and ON GOSUB is very small) Posted