No Line Continuation in Macintosh QuickBASIC; Break Long FIELD (39240)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
  • Microsoft BASIC Interpreter for Apple Macintosh 1.0
  • Microsoft BASIC Interpreter for Apple Macintosh 1.01
  • Microsoft BASIC Interpreter for Apple Macintosh 2.0
  • Microsoft BASIC Interpreter for Apple Macintosh 2.1
  • Microsoft BASIC Interpreter for Apple Macintosh 3.0

This article was previously published under Q39240

SUMMARY

Line continuation is not implemented for Macintosh QuickBASIC Version 1.00, or the earlier BASIC Compiler Version 1.00, or the earlier BASIC Interpreter (Versions 1.00, 1.01, 2.00, 2.10, or 3.00) for Apple Macintosh.

You might want a line continuation for better LIST window visibility for very long, single-line IF...THEN statements. To improve the structure of long IF statements, we recommend using a multi-line, block IF ... THEN ... ELSEIF ... END IF structure, or a SELECT CASE statement.

Another reason you might want to continue a line is to make a FIELD statement that is wider than the LIST window completely visible on multiple lines. Below are some suggestions for improving the readability of long FIELD statements.

MORE INFORMATION

The following information describes several methods for handling long FIELD statements:
  1. To pack as many fields as possible on the FIELD statement line, do the following:

    1. Use one-character variable names for the fields.
    2. Use DEFSTR, so you don't have to specify a '$' after the string variable names.
    These steps make your program less readable, however. There are several better and easier alternatives below.
  2. You can FIELD the entire buffer as one string and extract pieces of the string using the MID$ function, as in the following:
       OPEN "TEST" AS #1  'Assume data file TEST already has data in it.
       FIELD #1, 512 AS buffer$   'fields entire buffer in one string
       GET#1,2   ' Get record number 2 (written by some other program).
       'extract the 8 bytes beginning at byte 500:
       component1# = CVD(MID$(buffer$,500,8))
       'extract a long integer beginning at byte 508:
       component2& = CVL(MID$(buffer$,508,4))
    						
    You could also write a function to extract the fields, such as the following:
       ' This is a function to extract a long integer from buffer$.
       ' FieldOffset% is the byte offset where the data starts.
       ' Note that buffer$ doesn't have to be a fielded string, it
       ' just has to be a minimum of FieldOffset% + 4 bytes long.
       DEF FNL&(FieldOffset%) = CVL(MID$(buffer$, FieldOffset%,4))
  3. The easiest method is to break up the FIELD statement into more than one FIELD statement for the same file number, using a dummy placeholder string to account for the data previously fielded in that same buffer, as in the following:
       FIELD #1, 4 AS partNof$, 96 AS pricef$   '4+96=100 total bytes
       FIELD #1, 100 AS dummy1$, 4 AS sizef$, 2 AS partTypef$
       FIELD #1, 106 AS dummy2$, 10 as x$

Modification Type:MajorLast Reviewed:12/12/2003
Keywords:KB39240 kbAudDeveloper