Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LABEL = True OR False

Status
Not open for further replies.

Oak

Programmer
Aug 6, 2000
77
CA

This is a simple question:
Should we avoid the use of LABEL?

Oak
 
Yop, but what about:

IF trueOrFalse THEN GOTO labelName
END
labelName:
...
RETURN

OR

looping:
varInput$ = INKEY$
IF varInput$ <> &quot;&quot; THEN
PRINT &quot;Label&quot;
END
END IF
GOTO looping

The instruction GOTO if you prefer..

Oak

 
If you fear the labels - avoid them. But there is no need to use'em. Yes, we don't need in all language possibilities (for example, ELSE) - but they give as comfort and straight logic in program flow. Labels are come from the old translators and they WAS comfortable and satisfy the needs of the past times. Today, their role - allow compatibility with old programs and language standards.
If your write a program for your own - it's your choice to use labels or not. But keep in mind - that labels is very hard in understanding for others (and they are slowing down program execution on modern CPU's).
 
QBASIC is a structured programming language, and for decision making (IF ... ELSE ... END IF) statements, you can either put the code you want to execute right in the IF statement, or put it in a separate SUB that you call. The labels, like NOPIK said, were from the older languages that weren't structured, and that were used with computers that had more severe memory limitation than ours today have.
 
You should strive to avoid using GOTO and GOSUB altogether. Without them, the only labels or line numbers you will need are for [tt]RESTORE/tt] statements to use prior to [tt]READ[/tt]ing from [tt]DATA[/tt] statements. :)
 
I never used to code them personaly. Thanks for your opinions!!

Oak
 
This revives a 20 year old arguement. For every rule I can probably find 10 exceptions that would mandate the opposite.
Probably of more importance is clean logic flow and documentation.
There is nothing worse that trying to remember why you did somthing a certain way 5 years after you did it. Especially after you've been exposed to other methods and you thinking has been re-ordered. Ed Fair
unixstuff@juno.com
Any advice I give is my best judgement based on my interpretation of the facts you supply. Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top