Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : GoSub Help Please
Author | Message | ||||
Hans Senior Member Joined: 18/10/2022 Location: CanadaPosts: 116 |
Hi all; What am I missing about the GOSUB command? I get this weird error "Error : Invalid character:" when I use GOSUB Test, but if I just use the word test and leave out GOSUB, it executes the subroutine correctly???? I have supplied an example in its simplest form. Details; The program; Error; I don't understand how the GOSUB command is supposed to be used or why it works this way. TIA Hans ... |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
GOSUB doesn't call a SUB. 'My test GOSUB routine treaacle END routine: Print "This is a routine called by GOSUB" RETURN SUB treacle print "This is treacle" END SUB It's a bit misleading. GOSUB was short for GO SUBROUTINE originally. It's long in the tooth now but still has the occasional use for calling labels. Edited 2023-06-16 08:03 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6100 |
GOSUB is the old way of calling subroutines The manual has a good description of calling SUBs and FUNCTIONs Jim VK7JH MMedit MMBasic Help |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3804 |
I think GOSUB would work with a label (or line number) rather than a SUB name. New programs just don't need GOSUB. John |
||||
Hans Senior Member Joined: 18/10/2022 Location: CanadaPosts: 116 |
Thank you Jim and Mick! IMHO it's not very "basic". Now all I have to do is cleanup the giant pile of hair next to my desk. Again thanks; Hans ... |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
GOSUB is old school and should generally not be used for new code. It is useful to allow older programs which use it to continue to run. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 339 |
For the first thirty years or so of BASIC's life, programs had to have line numbers. There were no alphanumeric labels. GOSUB nnnn...RETURN (where nnnn is a line number) was the only way to perform a subroutine. There was no CALL...SUB pair. It wasn't until the ANSI X3 committee tried to update BASIC that newer constructs such as DO...LOOP, multiline IF...THEN...ELSE...END IF, FUNCTIONS and SUBs were made a part of the official language. |
||||
Pilot352 Newbie Joined: 12/08/2020 Location: United StatesPosts: 34 |
** POST REMOVED BY AUTHOR ** Edited 2023-06-16 21:34 by Pilot352 |
||||
Print this page |