Avoiding Common Programming Errors

The most common programming error when you are using SQR is misspelling variable names. Because SQR does not require variables to be declared, it does not issue an error message when variable names are misspelled. Instead, SQR considers the misspelled variable as if it is another variable.

For example:

let #customer_access_code = 55
print #customer_acess_code ()

This example does not print 55 because the variable name is misspelled. One c in access in the PRINT command is missing.

A related problem involves global versus local variables. If you refer to a global variable in a local procedure without preceding it with an underscore, SQR does not issue an error message. Instead, it is taken as a new local variable name. For example:

begin-procedure main
   let $area = 'North'
   do proc
end-procedure ! main
begin-procedure proc local
   print $area ()  ! Should be $_area
end-procedure

In this example, the proc local procedure prints the value of the local $area variable and not the global $area variable. It prints nothing because the local $area variable did not receive a value. To refer to the global variable, use $_area.

Such small errors are difficult to detect because SQR considers #customer_acess_code as just another variable with a value of zero.