$TURBO directive

Purpose: The $TURBO directive allows the number of temporary string buffers that BCX uses to be changed from the default number of 2048.


Syntax:

 $TURBO ArraySize%

 Parameters:

  • ArraySize% [OPTIONAL] Specifies the number of temporary string buffers used by BCX. The ArraySize% must be a power of 2, that is, 4, 8, 16, 32, 64 etc. If an argument is not supplied for this parameter, the default size is 512.

Remarks: This directive can be specified on the command line using the flag -t:ArraySize%

NOTE WELL! Safe programming practices need to be given special attention here. Consider this example.


 $TURBO 16
 DIM str1$, str2$
 
 str1$ = " Still here and counting"
 
 CALL CheckMatch(LEFT$(str1$, 24))
 
 SUB CheckMatch(Mystr$)
 
 FOR INTEGER i = 1 TO 32
 
   str2$ = RIGHT$(str1$, 9)
 
   'After 16 iterations Mystr$ will no longer be valid
     ' because the RIGHT$ function would overwrite it.
 
   IF Mystr$ = str1$ THEN
     PRINT i,str1$
   END IF
 
   IF Mystr$ <> str1$ THEN
     PRINT i, " You have been wiped out and don't even know it"
   END IF
 
 NEXT
 
 END SUB

Remarks: Mystr$ is being overwritten because the argument in the calling procedure is stored in a temporary buffer. This value, subsequently, is overwritten by the RIGHT$ function which, like many BCX procedures, also uses the temporary buffers.


 CALL CheckMatch(LEFT$(str1$, 24))

This problem can be prevented by using a variable as the argument, str3$ in the following example.


 $TURBO 16
 DIM str1$, str2$, str3$
 
 str1$ = " Still here and counting"
 
 str3$ = LEFT$(str1$, 24)
 
 CALL CheckMatch(str3$)
 
 SUB CheckMatch(Mystr$)
 
 FOR INTEGER i = 1 TO 32
 
   str2$ = RIGHT$(str1$, 9)
 
   IF Mystr$ = str1$ THEN
     PRINT i,str1$
   END IF
 
   IF Mystr$ <> str1$ THEN
     PRINT i, " You have been wiped out and don't even know it"
   END IF
 
 NEXT
 
 END SUB