FACTS Extended BASIC FAQs

Q. My program runs for a while then stops and prints the error message ‘CONTROL STACK OVERFLOW’. It doesn’t always stop at the same line number and it may run for a long time or a very short time.

A. This error is caused when one of the following control structures is abnormally exited (usually with a GOTO statement)in your program (normal exit shown in paranthesis): FOR-NEXT (Specified number of loops executed) DO-WHILE (WHILE relational expression becomes FALSE) DO-UNTIL (UNTIL relational expression becomes TRUE) GOSUB (RETURN – Return from Subroutine) ONPLC, ONTIME, ONPORT (RETI – Return from Interrupt) Each one of these control structure uses the Control Stack and some use an Argument stack. The stack space is not freed until the control structure is normally exited. When the maximum number of stacks is exceeded the ‘CONTROL STACK OVERFLOW’ error is generated.

Q. I have multiple strings in my program but when one string changes they all change, what’s wrong. This is my test program: 10 $(X)=”Start” 20 $(Y)=”End” 30 PRINT1 “$(X)=”,$(X) 40 PRINT1 “$(Y)=”,$(Y) >RUN $(X)=End $(Y)=End

A. String variables in FACTS Extended BASIC are represented by the dollar sign character and an expression enclosed in parantheses. The expression must be equal to a value between 0 and 254 (max value depends on your STRING statement).

In your example X and Y are interpreted as numeric variables and since they have not been intialized they will both be equal to 0 so your example is always operating on string 0 ($(0)). If you were to add the following line: 5 X=0 : Y=1 Then your program would work as expected.

Q. I need to write a communication program that requires a Checksum, LRC, or CRC16 is there a simple way to do this with FACTS Extended BASIC?

A. Yes, the ERRCHK statement can calculate these error checking values.

Q. I need to send a string to a device to request some information but a carriage return/line feed combination is always appended to my string. Is there a way to prevent this. Here is my test program: 10 $(0)=”Thisisatest” 20 PRINT1 $(0)

A. Yes, add a comma or semicolon at the end of the PRINT statement to suppress CR/LF. 10 $(0)=”Thisisatest” 20 PRINT1 $(0);

Q. I’m trying to build strings that contain ASCII 0 (NULL) and ASCII(13) (CR) the string handling functions don’t seem to be working correctly. Here is my test program: 10 $(0)=CHR$(0)+”Zero” 20 $(1)=CHR$(0)+”One” 30 $(2)=$(0)+$(1) 40 PRINT1 LEN($(2)),$(2) >RUN 0

PRM 0 READY >

A. All string handling functions except the ASC statement interpret NULL and CR as string terminators and operate accordingly. The example would need to be rewritten as follows to work as expected. 10 $(2)=CHR$(0)+”Zero” : L=5 20 ASC($(2),6)=0 : ASC($(2),7)=79: ASC($(2),8)=110 : L=L+3 30 ASC($(2),9)=101: L=L+1 40 PRINT1 L 50 PRINT1 USING(\L\),$(2) >RUN 9 Zero One

PRM 0 READY >

Q. When I try to PRINT a string, only part of the string gets sent. Here is my test program: 10 $(0)=”Start”+CHR(0)+”End” 20 PRINT1 $(0),

A. If your string contains an ASCII 0 (NULL) or ASCII 13 (CR) you need to use the PRINT USING(\n\) statement because the PRINT statement alone will interpret NULL or CR as the string terminator. You will need to change the program as follows: 10 $(0)=”Start”+CHR(0)+”End” 20 PRINT1 USING(\9\),$(0),

×