Micro­power

  

Volume 2, Number 4 – September 1982

Page 4 of 36

statement.) Any syntax errors are dealt with by the original code. I have also patched most of the other BASIC routines which use line numbers to make things nice and simple.

The characters of the label are then counted and a pointer to the first character kept for a search. The routine then searches the entire program, starting at the beginning, for an identical label. Both labels must be the same length for the search to be successful, and any embedded keywords in the label, such as ON, PRINT etc. will not affect the routine. Blanks within the label are significant. There is no limit to the length of a label, but Xtal wild restrict the maximum number of characters in a line to 90+. If the label cannot be found, then this is taken to be an error, similar to a GOTO to a line which does not exist.

When a label is found, the relevant line number is returned, and the line is searched for in the normal way. This method has the great advantage of simplicity, although the program text is searched twice. I did this to make the patches to Xtal as simple as possible, and to allow other commands which use line numbers to use the code. The reduction in speed for finding a label instead of a line number in a large program is appox. 60%. In a small program, or where the line is near the beginning of a program, less. This does not seem to be a significant amount, since the label can always be replaced by the equivalent line number in speed-critical sections of code, (with some loss of clarity). The routine for skipping over labels slows the interpreter by only 1 – 2 % so that program with no labels will not seem slower than normal.

The only statement which will not work correctly with this modification is READ. A DATA statement after a label will be ignored by the interpreter, so that the data cannot be accessed. However, using the format 100'LABEL':DATA will fix this.

Now for the payoff. A list of the commands which work with the new label

  1. GOTO 'LABEL'
  2. GOSUB 'LABEL'
  3. RUN 'LABEL'
  4. ON X GOTO 'LABEL'
  5. ON X GOSUB 'LABEL'
  6. LIST 'LABEL'
  7. EDIT 'LABEL'
Page 4 of 36