Simply save this html file (as an html, NOT an html stripped file), then
cutout the IQ command and test files at the cut lines.
---- begin cut for IQ command -- and/or -- whole (IQ w/test files) -----
/* IQ command SYNTAX: IQ.rexx TO FROM WORD SUBS... */
/* Copyright 1998 Timothy Rue - VIC IQ command: version 0.2-arexx */
/* Uses rexxtricks.library (available on Aminet) for ADOS style pattern */
/* matching */
/* check for and addlib rexxtricks.library */
IF ~ SHOW('L',"rexxtricks.library") THEN
IF ~ ADDLIB("rexxtricks.library",0,-30,0) THEN DO
SAY 'rexxtricks.library not available, exiting'
EXIT 10
END
/* parse command line arguements */
PARSE ARG to_port from word subs
/* help options */
IF to_port == ? | to_port == '-?' | to_port == '-h' | to_port == 'help' THEN DO
SAY "IQ.rexx [word|pattern] {}"
EXIT 0
END
/* check port argument and if valid set output to port*/
IF ~ SHOW('p',to_port) THEN DO
SAY "WARNING: Cannot find named port" to_port "->Default to STDOUT"
END
ELSE ADDRESS VALUE to_port
/* Sets compound variable by reading the first line of IQ file
and checks for the first word to = contents of the 'key' variable */
key = 'filekey'
key.1 = 'word:'
key.2 = 'sub:'
key.3 = 'file:'
key.4 = 1
iqsu = 0
iqsc = 0
/* test for valid file arguement */
IF ~ OPEN(iqfile,from,'R') THEN DO
SAY 'IQfile> 'from' not found!'
EXIT 10
END
/* if valid file, check for key in files first line and read */
ELSE DO
inline = READLN(iqfile)
ln = 1
IF MATCHPATTERN(inline,key || #?) THEN DO i = 1 to 3
key.i = WORD(inline,i+1)
END
ELSE i = -1
END /* end of checking for and reading filekey */
/* calculate # of sub words given */
subn=WORDS(subs)
/* DO IT */
DO FOREVER
/* if we have a filekey read next line */
IF i ~= -1 THEN DO
inline = READLN(iqfile)
ln = ln + 1
END
/* test line for key */
DO i = 1 to 3
key.i.result = 0
IF MATCHPATTERN(inline,key.i || #?) THEN key.i.result = 1
END
linetest = key.1.result+key.2.result+key.3.result
SELECT
/* output when line not a key line */
WHEN linetest == 0 & key.4 == 1 THEN
IF ADDRESS() == to_port THEN inline
ELSE say inline
/* Skip word/sub non-key line if not within matching word/sub key */
WHEN linetest == 0 & key.4 == 0 THEN NOP
/* when file */
WHEN key.3.result & key.4 == 1 THEN DO
fromt = STRIP(inline,'L',key.3)
/* check if file is self recursive */
IF from == fromt THEN
BREAK /* break from Select */
/* set/reset IQ_stacks position and break variable */
position = 0
/* check if in used stack */
IF iqsu > 0 THEN DO i = 1 to iqsu
IF IQ_stacku.i == fromt THEN position = i
END
IF position > 0 THEN BREAK /* break from select */
/* check if file exists */
IF ~ EXISTS(fromt) THEN DO
SAY 'NOTIFY: IQ file> "'fromt'" not found! Pointed to in>"'from'<@Line#>'ln'"'
position = -1
END
IF position == -1 THEN BREAK /* break from select */
/* check if in current stack - if so save current settings,
read in previous settings, sort stack, seek to cp */
IF iqsc > 0 THEN DO i = 1 to iqsc
IF WORD(IQ_stack.i,1) == fromt THEN position = i
END
IF position > 0 THEN DO
cp = SEEK(iqfile,0)
IQ_stackt = from key.1 key.2 key.3 key.4 key.4.level ln cp
PARSE VAR IQ_stack.position from key.1 key.2 key.3 key.4 key.4.level ln cp
Do i = position to iqsc
j = i + 1
IQ_stack.i = IQ_stack.j
END
IQ_stack.iqsc = IQ_stackt
CLOSE(iqfile)
OPEN(iqfile, from,'R')
SEEK(iqfile,cp,'BEGIN')
position = -1
END
IF position == -1 THEN BREAK /* break from select */
/* if not in either stack - save current settings and
read in key of new file if exist */
IF position == 0 THEN DO
cp = SEEK(iqfile,0)
iqsc = iqsc + 1
IQ_stack.iqsc = from key.1 key.2 key.3 key.4 key.4.level ln cp
from = fromt
CLOSE(iqfile)
OPEN(iqfile, from,'R')
inline = READLN(iqfile)
ln = 1
key.4.level = 0
IF MATCHPATTERN(inline,key || #?) THEN DO i = 1 to 3
key.i = WORD(inline,i+1)
END
ELSE i = -1
END
END
/* when sub from sub level */
WHEN key.2.result & key.4.level == 2 THEN DO
key.4 = 0
key.4.level = 1
/* test arg sub match (within matching word)*/
DO sn = 1 to subn
subpattern = key.2 || WORD(subs,sn)
IF MATCHPATTERN(inline,subpattern) THEN DO
key.4.level = 2
key.4 = 1
BREAK
END
END
/* if exiting sub w/blank sub */
IF inline == key.2 & key.4.level == 1 THEN key.4 = 1
END
/* when sub from word level */
WHEN key.2.result & key.4.level == 1 THEN DO
key.4 = 0
/* if arg sub match (within matching word)*/
DO sn = 1 to subn
subpattern = key.2 || WORD(subs,sn)
IF MATCHPATTERN(inline,subpattern) THEN DO
key.4.level = 2
key.4 = 1
BREAK
END
END
/* if w/blank sub */
IF inline == key.2 & key.4.level == 1 THEN key.4 = 1
END
/* when word */
WHEN key.1.result THEN DO
key.4.level = 0
key.4 = 0
/* if arg word match */
IF MATCHPATTERN(inline,key.1 || word) THEN DO
key.4.level = 1
key.4 = 1
END
/* if exiting word w/blank word */
IF inline == key.1 THEN key.4 = 1
END
/* ??? can this ever happen ??? */
OTHERWISE say 'Error in IQ file at linenumber> 'ln
END
/* **** begin multi-file test/IQ_stacks output. UNCOMMENT to use */
/*
IF iqsc > 0 THEN DO
result = WORD(IQ_stack.1,1)'@Line#'WORD(IQ_stack.1,7)
DO test = 2 to iqsc
result = result WORD(IQ_stack.test,1)'@Line#'WORD(IQ_stack.test,7)
END
SAY 'IQ Stack>'result from'@Line#'ln /* This is the PK files IQ stack*/
END
ELSE SAY 'IQ Stack>'from'@Line#'ln /* This is the PK files IQ stack*/
IF iqsu > 0 THEN DO
result = IQ_stacku.1
DO test = 2 to iqsu
result = result IQ_stacku.test
END
SAY 'IQ completely scanned file list> 'result
END
*/
/* **** end of multi-file test output */
/* handle EOF and IQ stacks*/
IF EOF(iqfile) THEN
IF iqsc > 0 THEN DO
CLOSE(iqfile)
iqsu = iqsu + 1
IQ_stacku.iqsu = from
PARSE VAR IQ_stack.iqsc from key.1 key.2 key.3 key.4 key.4.level ln cp
iqsc = iqsc -1
OPEN(iqfile,from,'R')
SEEK(iqfile,cp,'BEGIN')
END
ELSE BREAK /* from do forever */
END
/*
---- test1.iq ----- begin cut ----------
filekey : :: :::
test1.iq - no word definition { Beginning
:word1
test1.iq - definition of word1
:word2
test1.iq - definition of word2
::sub1
test1.iq - definition of sub1
at word2
::sub2
test1.iq - definition of sub2
at word2
:::file1
::
test1.iq - definition of nosub
at word2
:::file2
test1.iq - definition of nosub (after :::file2)
at word2
::sub3
test1.iq - definition of sub3
at word2
:
test1.iq - definition of noword } End
----- end cut for test.iq -- begin cut for file1 --------
filekey : :: :::
file1 - no word definition { Beginning
:word1
file1 - definition of word1
:word2
file1 - definition of word2
::sub1
file1 - definition of sub1
at word2
::sub2
file1 - definition of sub2
at word2
:::file1
::
file1 - definition of nosub
at word2
:::file2
file1 - definition of nosub (after :::file2)
at word2
:::file3
file1 - definition of nosub (after :::file3)
at word2
::sub3
file1 - definition of sub3
at word2
:
file1 - definition of noword } End
----- end cut for file1 -- begin cut for file2 --------
filekey : :: :::
file2 - no word definition { Begining
:word1
file2 - definition of word1
:word2
file2 - definition of word2
::sub1
file2 - definition of sub1
at word2
::sub2
file2 - definition of sub2
at word2
:::file1
::
file2 - definition of nosub
at word2
:::file2
file2 - definition of nosub (after :::file2)
at word2
:::file3
file2 - definition of nosub (after :::file3)
at word2
::sub3
file2 - definition of sub3
at word2
:
file2 - definition of noword } End
----- end cut for file2 -- begin cut for file3 --------
filekey : :: :::
file3 - no word definition { Begining
:word1
file3 - definition of word1
:word2
file3 - definition of word2
::sub1
file3 - definition of sub1
at word2
::sub2
file3 - definition of sub2
at word2
:::file1
::
file3 - definition of nosub
at word2
:::file2
file3 - definition of nosub (after :::file2)
at word2
:::file3
file3 - definition of nosub (after :::file3)
at word2
::sub3
file3 - definition of sub3
at word2
:
file3 - definition of noword } End
----- end cut for file3 --------
*/
----- end cut for whole --------