With PowerBasic, there are two ways to identify line lables:
(1) Use a standalong line number, such as 12345, which optionally
can be followed by a colon (

(2) Use a suitable name, similar to a variable name, but follow
it with a colon (

In general, there are three techniques for renumbering or renaming
lines in a BASIC source file for use in PowerBasic:
(1) Renumber every line, possibly with an incremental step, such
as 10, or 20, in case you want to add new statements in between,
This assumes that line numbers will be used or assigned in
sequece, from low to high, over the course of the program.
(2) Renumber only referenced lines, such as those that are
targeted with GOTO or GOSUB, and eliminating line numbers that
are not really needed to compile the program. This reduces the
size of the source code, show you where join points occur in
the code from other areas in the program, but reduces the value
of ERL if an error occurs and you are trying to trap for it.
(3) Rename line numbers making them names, such as taking 12345
and renaming it "L12345:", so as to get rid of line numbers in
the old BASIC style (BASICA, GWBASIC, and others). Again, if a
line number is not actually used, it is removed.
Typically, programs that do this for you might be called a
Renumber, Labler, ReLable, or one of the services provided by
a Format, ReFormat, or Convert program.
Another thing that a Format, Reformat, or Convert program might
do would to break up very dense lines where multiple statements
appear separated by colons. This may appear to make the program
much larger, but it also means you now have room to either add
new line numbers for every statement (for more specific trapping)
or you now have space per line for adding more comments to your
source. Neither change will make the resulting compiled program
any arger. And another advantage of a Format, ReFormat, or
Convert program is that it can standardize the source, apply
rules of capitalization, indentation, and other benefits.
I want to make sure that you know that the name "Format" is also
shared by a utility for reformatting disk drives, and we do not
want you formatting disk drives by accident. But it is one of
the names sometimes employed for modifying source code files.
I seem to recall a converter utility called QB2PB, which did a
pretty good job converting QBASIC and QuickBASIC ASCII source
files to PB/DOS. It could also handle GWBASIC and BASICA
source files and convert them over. There were some problems
with graphic statements because QBASIC and QuickBASIC use a
different graphical coordinate system than adopted by PowerBasic.
The thing about PowerBasic is that it can be configured to use
Conventional Memory, Expanded Memory, and Extended Memory, so
that you had far less reason to be concerned with the 640 kb
limits of DOS.
Of course you also have the option to convert over to PB/CC in
place of PB/DOS. PB/CC has evolved quite a bit from the earlier
versions of BASIC, which means a lot more built-in functionality,
but it is not so far from them that it also makes it too hard to
adapt the source code.
Towards this end, lets take a look at another piece of your code:
Code:
7920 ' - Select Hour wanted 7930 GOSUB 9440:IF TZ THEN GOSUB 10220 7940 PRINT KK$;:IF TZ THEN GOSUB 10310 7950 LINE INPUT Y2$:IF Y2$="E" OR Y2$="e" THEN 8080 7960 IF INSTR(Y2$,":")>0 OR LEN(Y2$)<5 OR LEN(Y2$)>6 THEN 7930 7970 IF RIGHT$(Y2$,1)="M" OR RIGHT$(Y2$,1)="m" THEN 7980 ELSE 7930 7980 ' - Wk hr 7990 IF LEN(Y2$)=5 AND VAL(LEFT$(Y2$,1))>=0 THEN Y2$="0"+Y2$ 8000 Y2$=LEFT$(Y2$,2)+":"+MID$(Y2$,3,4) 8010 HT=VAL(LEFT$(Y2$,2)):IF HT>24 THEN 7920 8020 IF HT<12 AND RIGHT$(Y2$,2)="PM" OR HT<12 AND RIGHT$(Y2$,2)="pm" THEN 8040 8030 GOTO 8050 8040 HT=HT+12:Y2$=RIGHT$(STR$(HT),2)+":00PM"
Code:
' - Select Hour wanted 7920 GOSUB 9440 7930 IF TZ THEN GOSUB 10220 PRINT KK$; IF TZ THEN GOSUB 10310 LINE INPUT Y2$ IF Y2$="E" OR Y2$="e" THEN 8080 IF INSTR(Y2$,":")>0 OR LEN(Y2$)<5 OR LEN(Y2$)>6 THEN 7930 IF RIGHT$(Y2$,1)="M" OR RIGHT$(Y2$,1)="m" THEN GOTO 7980 ELSE GOTO 7930 END IF 7980 ' - Wk hr IF LEN(Y2$)=5 AND VAL(LEFT$(Y2$,1))>=0 THEN Y2$="0"+Y2$ Y2$=LEFT$(Y2$,2)+":"+MID$(Y2$,3,4) HT=VAL(LEFT$(Y2$,2)):IF HT>24 THEN 7920 IF HT<12 AND RIGHT$(Y2$,2)="PM" OR HT<12 AND RIGHT$(Y2$,2)="pm" THEN 8040 GOTO 8050 8040 HT=HT+12 Y2$=RIGHT$(STR$(HT),2)+":00PM" 8050
made into lables, and the lables can have meaning. The GOSUB
and [some implied] GOTO commands can jump to labels that are
named to have some meaning in context, such as AM: and PM:.
Fact is, some GOSUB commands can be replaced with SUBs or
FUNCTIONs that are named for the tasks that they perform.
What you had to do with BASICA, GWBASIC, QBASIC, and QuickBASIC
were what you had to do at the time, but techniques and methods
can be refined over time. With earlier BASICS, you sometimes
could only perform one statement or multiple statements with
colon separators on a single line - there were no multi-line
IF structures with ELSEIF, ELSE, and END IF to help you. And
for structure, you did not have SELECT CASE, CASE, CASE ELSE, and
END SELECT, what you had was ON GOTO or ON GOSUB to contend with.
Things are so much better now that it is worth adapting. As to
adapting your code to use the new functionality, that is your
call. You can usually still use it as originally written, or you
may find value in at least a partial rewrite.
------------------
Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired
Leave a comment: