Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quick Basic Colon Line Separator

Tags:

qbasic

I am working on some old qbasic code. It's a mess with all the Goto statements. Am I correct that the following line will always return?

IF FLAG = 0 THEN TARGET = X: GOSUB 55000: TEMP = XI - TEMP2: RETURN 

So if I understand this correctly the colon separates statements on the same line. The if only pertains to TARGET = X. The GOSUB, TEMP =, and RETURN will always execute. Correct?

Part of my confusion is because the very next line reads

IF FLAG = 1 THEN STEP = X: GOSUB 115000

And since the label to the second statement is never used in a GOTO I can't see that it would ever get executed.

like image 745
Seth Hays Avatar asked Aug 08 '13 20:08

Seth Hays


1 Answers

Yes, I believe your assessment is correct. The colon is a statement separator that lets you have multiple statements on the same line. Assuming your subroutine at 55000 returns, this line should return as well.

I was wrong. Running this program:

if 1=2 then print "Never printed" : print "how about this?"
print "End of program"

on qb64.net prints only End of program. I assume that its grammar details are the same as Qbasic's, although it is a reverse-engineered effort.

As an aside, this code is written in a pre-QBasic style (e.g. using GOSUB and line numbers). There is a script that often came with QBasic (remline.bas, I believe it was called) that is supposed to help translate these kinds of programs to a newer style. I have never used it myself, though.

like image 95
Troy Avatar answered Oct 19 '22 10:10

Troy