\* -----------------------------------------------------------------------
\* Name: STN Express command file: getenums.sc
\* Function: Remembering the first and last E-Number after SELECT command
\* and executing search in target file
\* The script:
\* - asks for full SELECT statement (L-number, terms and answer
\* numbers to select from), e.g. sel l12 pn apps 1-
\* - carries out SELECT in current file
\* - assumes that the user has capture on and queries the user to
\* reset capture on after a temporary cappture file, seltemp.trn
\* is opened and closed to process the select statement
\* - asks for the name of the target database in which to search
\* the selected e-numbers
\* - assigns final L-number as line _lgetenums
\* Author: Thomas E. Wolff, Wolff Information Consulting LLC, Lisle, IL USA
\* http://www.wolffinfo.com
\* Based on: selenum.sc by Andreas Litscher, InfoLit, CH-Bern (23.4.04)
\* http://stn-scripts.ch/index.php/scripts/33
\* Source: http://stn-scripts.ch/
\* -----------------------------------------------------------------------
\* USER SPECIFIC VARIABLES
_startenum = ""
_endenum = ""
_lgetenums = ""
\* Path and file name of the message memory:
_selectfile = "c:\\stnexp\\trnscrpt\\SELtemp.trn"
echo ""
echo "Script GETENUMS.SC is being run"
echo "Enter full select statement (L-number, terms and answer numbers"
echo "to select from), e.g. sel l12 pn apps 1-"
get _selstatement
echo ""
capture off <>
capture on <_selectfile>
=>_selstatement
capture off <>
capture on <>
open <_selectfile>
@start
read _line
if (_$filerror = 0)
begin
if (SUBSTR(_line,1,5) = "FIELD") GOTO @failedbadselect
if (SUBSTR(_line,8,5) = "FOUND") GOTO @failednoanswers
if (SUBSTR(_line,9,5) = "FOUND") GOTO @failednoanswers
if (SUBSTR(_line,10,5) = "FOUND") GOTO @failednoanswers
if (SUBSTR(_line,4,7) = "THROUGH")
begin
if (SUBSTR(_line,15,8) = "ASSIGNED")
begin
_startenum = SUBSTR(_line,1,2)
_endenum = SUBSTR(_line,12,2)
goto @continue
end
else if (SUBSTR(_line,16,8) = "ASSIGNED")
begin
_startenum = SUBSTR(_line,1,2)
_endenum = SUBSTR(_line,12,3)
goto @continue
end
else if (SUBSTR(_line,17,8) = "ASSIGNED")
begin
_startenum = SUBSTR(_line,1,2)
_endenum = SUBSTR(_line,12,4)
if _endenum = "E999" goto @failed999
end
end
else if (SUBSTR(_line,5,7) = "THROUGH")
begin
if (SUBSTR(_line,16,8) = "ASSIGNED")
begin
_startenum = SUBSTR(_line,1,3)
_endenum = SUBSTR(_line,13,2)
goto @continue
end
else if (SUBSTR(_line,17,8) = "ASSIGNED")
begin
_startenum = SUBSTR(_line,1,3)
_endenum = SUBSTR(_line,13,3)
goto @continue
end
else if (SUBSTR(_line,18,8) = "ASSIGNED")
begin
_startenum = SUBSTR(_line,1,3)
_endenum = SUBSTR(_line,13,4)
if _endenum = "E999" goto @failed999
end
end
else if (SUBSTR(_line,6,7) = "THROUGH") begin
if (SUBSTR(_line,17,8) = "ASSIGNED")
begin
_startenum = SUBSTR(_line,1,4)
_endenum = SUBSTR(_line,14,2)
goto @continue
end
else if (SUBSTR(_line,18,8) = "ASSIGNED")
begin
_startenum = SUBSTR(_line,1,4)
_endenum = SUBSTR(_line,14,3)
goto @continue
end
else if (SUBSTR(_line,19,8) = "ASSIGNED")
begin
_startenum = SUBSTR(_line,1,4)
_endenum = SUBSTR(_line,14,4)
if _endenum = "E999" goto @failed999
end
end
goto @start
end
close
@continue
echo ""
ECHO "=>_selstatement"
ECHO "_startenum THROUGH _endenum ASSIGNED"
ECHO "Enter name of file to search these E-numbers"
get _newfilename
echo ""
=>file _newfilename
=>s _startenum-_endenum \> _lgetenums
goto @end
@failed999
echo ""
echo "***** Stop GETENUMS.SC: Limit E999 exceeded *****"
echo ""
goto @end
@failednoanswers
echo ""
echo "***** Stop GETENUMS.SC: No E-numbers selected *****"
echo ""
goto @end
@failedbadselect
echo ""
echo "***** Stop GETENUMS.SC: Bad SELECT command entered *****"
echo ""
goto @end
@nodocs
echo ""
echo "***** Stop GETENUMS.SC: No answers found *****"
echo ""
@end
exit
\* -----------------------------------------------------------------------