|
Post by ragnjerr on Sept 6, 2022 2:42:12 GMT -6
This is kinda of a new thing in BASIC, using functions as well as sub routines (classical BASIC never had functions, they had only sub routines, which call for GOSUB and when that sub routine was done, you RETURN back to the line number after that GOSUB was called). So, as I take it, functions, like in C, return a value, let's say, like using cursor keys to move a sprite? And subroutines doesn't return a value, like a piecing the mosiac of a tile map for the game itself? Is that the jist? Oh and from experience, never GOTO in a subroutine in classical BASIC
|
|
|
Post by johnno56 on Sept 6, 2022 3:34:08 GMT -6
rcbasic.online/doc/rcbasic_manual.html"Functions and Subroutines" should give you the answers you may be looking for. Explains the difference between Functions and Subroutines... I think you have the gist of subroutines... " Sub Routines cannot return values and cannot be used in expressions. So why would you want to use a Sub Routine over a function? Well Sub Routines have less over head since it does not have to internally push a value onto the stack like a function does. So in cases where you do not need to return a value you should use a Sub Routine." In reference to "goto-ing a subroutine"... RCBasic does not use GOTO... But, you are correct.... I have fallen into 'that' particular black-hole way back in the dark ages of Line Numbers... Moo Ha Ha... Hang on... I still use Basics that have line numbers... Oh well... Not that long ago... lol
|
|
|
Post by ragnjerr on Sept 6, 2022 4:28:57 GMT -6
RCBasic does not use GOTO... Awesome!!! I always abhorred GOTO, due it leads to spaghetti code real easily, although ZIL (Zork Interpreted Language) uses GOTO, it meant for moving the player to a room with all the routines necessary to make it functional. In that case, GOTO does not lead to spaghetti code like BASIC or even C GOTO can. n00b's vision of excluding GOTO makes this definitely a BASIC I want to learn.
|
|
|
Post by rosy on Sept 7, 2022 10:51:56 GMT -6
You may not know, so I inform you that it is not obligatory to use all the language commands, including GOTO, WHICH CAN BE USEFUL.
|
|
|
Post by johnno56 on Sept 7, 2022 12:28:56 GMT -6
Agreed. There are times that I wish there was a GOTO... Then there are times, particularly when converting from a Basic that uses GOTO, when a GOTO is executed 'within' a subroutine... If the GOTO points to, say a 'game over', I can deal with that. But all the other times... grrrr.... Ah. Basic. Ya gotta love it... lol
|
|