[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Local procedure debugging script
- Subject: Local procedure debugging script
- From: John Milardovic <milardj@SX.COM>
- Date: Thu, 21 Oct 1999 16:20:19 -0400
In case anyone is interested (and they have perl on their system):
I've created a simple perl script which flags all SQR reserved variables in
local procedures that do not have a leading underscore and provides a count
of the number of times each local variable appears in the procedure.
Assuming that everyone initializes their variables within the local
procedure any variable with an occurrence of 1 might indicate that a global
non-reserved variable has been mis-referenced or that a local variable has
not been initialized.
My script defines reserved variables as variables that begin with $ or # and
contain a hyphen (-). $username would therefore not be picked up while a
non reserved variable with a hyphen (shame on you) would be considered a
reserved variable. This was done this way to save me from having to throw
the reserved variables into a hash and comparing my matched patterns against
the hash.
The only modification necessary is for UNIX users to put the preprocessor
shebang in line 1 (ie.#!/usr/local/bin/perl or #!/usr/bin/perl or whatever
it is on your system). To run the program type '[perl] local_scan.pl
report_name > output_file' at the command line. The word perl can be
omitted if the shebang was typed in for UNIX users.
If anyone does attempt to use this and they have any questions/problems feel
free to contact me.
The output goes to standard output and looks like this :
-------------------------------------------------------------
Summary for Procedure : error_local
Warning: #sql-error1 - possible incorrect reference to global reserved
variable?
Warning: $sql-error1 - possible incorrect reference to global reserved
variable?
Local variable count
A count of one might indicate an incorrectly referenced non-reserved
global variable or an uninitialized local variable.
2 #x1
1 #y1
-------------------------------------------------------------
Summary for Procedure : error_args
Warning: #sql-error2 - possible incorrect reference to global reserved
variable?
Warning: $sql-error2 - possible incorrect reference to global reserved
variable?
Local variable count
A count of one might indicate an incorrectly referenced non-reserved
global variable or an uninitialized local variable.
2 #x2
1 #y2
-------------------------------------------------------------
Based on an SQR that looks like this:
begin-procedure okay
#sql-error1
$sql-string1
#x=0
let #x=y
end-procedure
begin-procedure error_local local
let #sql-error1='x'
show $sql-error1
show $_sql-error1
let #x1=0
let #x1=1
let #y1=1
end-procedure
begin-procedure error_args($var)
let #sql-error2='x'
show $sql-error2
show $_sql-error2
let #x2=0
let #x2=1
let #y2=1
end-procedure
John Milardovic
<<local_scan.pl>>
local_scan.pl