Search code examples
qbasic

What does ON do in QBasic?


I have been working on a project, in which I take an old program and create a new version of it .... The thing is that it is written in Quick Basic and it has a line of code that I don't understand

ON FLAG% GOTO 1730, 1900

Can anyone tell me what this is ??? By the way I'm working on VisualBasic


Solution

  • It is basically a shorthand syntax for this type of statement:

    IF FLAG% = 1 THEN GOTO 1730 ELSE IF FLAG% = 2 THEN GOTO 1900
    

    See this article for more information.

    For more options you would probably turn to a switch statement in more modern languages.