home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: SysTools
/
SysTools.zip
/
spm2.zip
/
spmapp02.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-10-20
|
13KB
|
619 lines
/**/
arg state
if Pop() <> 0 then exit 9902
if state = 'START'
then
do
say GetMsg(8,'02')
rc = prologue()
return rc
end
if state = 'FINISH'
then
do
rc = epilogue()
say GetMsg(9,'02')
return rc
end
if state = 'CLEANUP'
then
do
rc = cleanup()
say GetMsg(9,'02')
return rc
end
oldq = rxqueue('SET','spmapp_q')
ord = ''
select
when LVL_2_SEQ = 0 then /* file header */
do
queue 'version = '''SPMVERSN','OS2VERSN','SFTWNME','PRGMNME''''
queue 'pvwseq = ""'
queue 'spmseq = ""'
say GetMsg(16)
rc = 1
end
when LVL_3_SEQ = 0 then /* new group */
do
rc = CheckGroup()
x = PutDot() /* say ' ' GROUPNME 'group' GROUPORD */
queue 'pvw.'GROUPORD' = '''GROUPNME''''
queue 'pvw.'GROUPORD'.1 = '''GROUPDSC''''
queue 'pvw.'GROUPORD'.2 = 'LVL_2_SEQ
queue 'spm.'LVL_2_SEQ' = '''GROUPTAG''''
queue 'spm.'LVL_2_SEQ'.1 = 'GROUPORD
queue 'spm.'LVL_2_SEQ'.2 = 'GROUPSRC
queue 'spm.'LVL_2_SEQ'.3 = 'GROUPTYP
queue 'spm.'LVL_2_SEQ'.4 = 0'
queue 'spmseq = spmseq||" "||'LVL_2_SEQ
ord = GROUPORD
end
otherwise /* new field */
if ALIASNME <> '' /* or alias */
then
do
rc = CheckAlias()
x = PutDot() /* say ' ' ALIASNME 'group' ALIASORD ', alias of group' GROUPORD */
queue 'pvw.'ALIASORD' = '''ALIASNME''''
queue 'pvw.'ALIASORD'.1 = '''ALIASDSC''''
queue 'pvw.'ALIASORD'.2 = 'LVL_2_SEQ
ord = ALIASORD
end
else
do
rc = CheckField()
queue 'spm.'LVL_2_SEQ'.4 = spm.'LVL_2_SEQ'.4 + 1'
queue 'spm.'LVL_2_SEQ'.4.'LVL_3_SEQ' = 'FIELDTYP
queue 'spm.'LVL_2_SEQ'.4.'LVL_3_SEQ'.1 = '''FIELDNME''''
queue 'spm.'LVL_2_SEQ'.4.'LVL_3_SEQ'.2 = '''FIELDTAG''''
queue 'spm.'LVL_2_SEQ'.4.'LVL_3_SEQ'.3 = '''FIELDDSC''''
end
end /* select */
if rc = 0
then
do
if ord <> ''
then
do
queue 'pvwseq = pvwseq||" "||'ord
if ord = 'defaultord'
then queue 'defaultord = defaultord + 1'
end
x = rxqueue('SET',oldq)
end
else
if rc = 1 then rc = 0
return rc
/* - - - - */
prologue:
x = rxqueue('DELETE','spmapp_q')
x = rxqueue('CREATE','spmapp_q')
return 0
/* - - - - */
epilogue:
say ' '
say GetMsg(17)
x = Version()
x = Groups()
x = Types('groupsrc')
x = Types('grouptyp')
x = Types('fieldtyp',0)
cTypeFld = TypeCount
TypeFld = TypeDesc
x = Types('DEFS')
x = PutDot()
oldq = rxqueue('SET','spmapp_q')
do while queued() <> 0
parse pull setvar
interpret setvar
/* rc = lineout("SPMAPP.TRC",setvar) */
end
x = PutDot()
do q = 1 to words(OrdList)
i = word(OrdList,q)
if datatype(i,'N')
then
do
do p = 1 to words(pvwseq) until i = j
j = word(pvwseq,p)
end
if i <> j then pvwseq = pvwseq||' '||i
else rc = PutDot()
end
end
pvwseq = SortSeq(pvwseq)
spmseq = SortSeq(spmseq)
x = rxqueue('DELETE','spmapp_q')
x = rxqueue('SET',oldq)
x = PutDot(',')
NULL = x2c('00')
Names = ''
szNP = 0
Desc = ''
szDP = 0
do q = 1 to words(pvwseq)
i = word(pvwseq,q)
j = pvw.i.2
if datatype(j,'N')
then
base = spm.j.1
else
do
base = substr(j,2)
if i <> base & datatype(pvw.base.2,'N')
then
do
say ' '
say GetMsg(19,k)
drop pvw.k.
iterate
end
end
do p = 1 to q - 1
o = word(pvwseq,p)
if pvw.i = pvw.o
then
do
say ' '
say GetMsg(21,pvw.i,base,o)
leave
end
end
cb = length(pvw.i)
ofNm = szNP
Names = Names||d2c(cb)||pvw.i||NULL
szNP = szNP + cb + 2
cb = length(pvw.i.1)
ofDs = szDP
Desc = Desc||d2c(cb)||pvw.i.1||NULL
szDP = szDP + cb + 2
pvw.i.0 = d2s(i)||d2s(base)||d2s(ofNm)||d2s(ofDs)
/* say 'PGD' c2x(pvw.i.0) */
end /* do q = 1 to words(pvwseq) */
pvw.0.1 = Names||NULL
pvw.0.2 = Desc||NULL
szPN = szNP + 1
szPD = szDP + 1
/* say 'PName' szPN c2x(pvw.0.1) */
/* say 'PDesc' szPD c2x(pvw.0.3) */
do q = 1 to words(spmseq)
j = word(spmseq,q)
rc = Verify(spm.j.1)
x = PutDot() /* say ' ' spm.j 'group' spm.j.1 rc */
cb = length(spm.j)
Names = d2c(cb)||spm.j||NULL
szNP = cb + 2
Tags = Names
szTP = szNP
Desc = ''
szDP = 0
szGP = 0
szPT = szPT + szTP
do k = 1 to spm.j.4
l = c2d(substr(TypeFld,(spm.j.4.k*4)+3,1))
szGP = szGP + l
spm.j.4.k.0 = d2c(l)||d2c(spm.j.4.k)||,
d2s(szNP)||d2s(szTP)||d2s(szDP)
cb = length(spm.j.4.k.1)
Names = Names||d2c(cb)||spm.j.4.k.1||NULL
szNP = szNP + cb + 2
cb = length(spm.j.4.k.2)
Tags = Tags||d2c(cb)||spm.j.4.k.2||NULL
szTP = szTP + cb + 2
cb = length(spm.j.4.k.3)
Desc = Desc||d2c(cb)||spm.j.4.k.3||NULL
szDP = szDP + cb + 2
/* say 'SED' c2x(spm.j.4.k.0) */
end /* do k = 1 to spm.j.4 */
spm.j.0.1 = Names||NULL
spm.j.0.2 = Tags||NULL
spm.j.0.3 = Desc||NULL
szNP = szNP + 1
szTP = szTP + 1
szDP = szDP + 1
mxGP = max(mxGP,szGP)
/* say 'SName' szNP c2x(spm.j.0.1) */
/* say 'STags' szTP c2x(spm.j.0.2) */
/* say 'SDesc' szDP c2x(spm.j.0.3) */
spm.j.0 = d2c(spm.j.2)||d2c(spm.j.3)||,
d2s(szNP)||d2s(szTP)||d2s(szDP)||,
d2s(spm.j.4)
/* say 'SGD' c2x(spm.j.0) */
ctGS = ctGS + 1
ctEL = ctEL + spm.j.4
szSN = szSN + szNP
szST = szST + szTP
szSD = szSD + szDP
end /* do q = 1 to words(spmseq) */
PGD = ''
ctGP = 0
do q = 1 to words(pvwseq)
i = word(pvwseq,q)
if symbol('pvw.i') = 'VAR'
then
do
PGD = PGD||pvw.i.0
ctGP = ctGP + 1
hiGP = max(hiGP,i)
loGP = min(loGP,i)
end
end
/* say 'PGD' c2x(PGD) */
/* say '.. number of ordinals =' ctGP */
/* say '.. low ordinal =' loGP */
/* say '.. high ordinal =' hiGP */
/* say '.. number of base ordinals =' ctGS */
/* say '.. number of elements =' ctEL */
/* say '.. largest counter group size =' mxGP */
Ver = d2s(ctGP)||d2s(ctGS)||d2s(ctEL)||,
d2s(loGP)||d2s(hiGP)||,
d2s(szPN)||d2s(szPT)||d2s(szPD)||,
d2s(szSN)||d2s(szST)||d2s(szSD)||,
d2s(cTypeFld)||d2s(mxGP)||,
version||NULL
/* say 'VER' c2x(Ver) */
say ' '
say GetMsg(18)
x = Update('SPM', 'VERSION', "Ver")
x = Update('SPM', 'ELEMENTS', "PGD")
x = Update('SPM', 'NAMES', "pvw.0.1")
x = Update('SPM', 'DESC', "pvw.0.2")
do q = 1 to words(spmseq)
j = word(spmseq,q)
App = '_'||spm.j.1
SGD = spm.j.0
do k = 1 to spm.j.4
SGD = SGD||spm.j.4.k.0
end
x = Update(App, 'ELEMENTS', "SGD")
x = Update(App, 'NAMES', "spm.j.0.1")
x = Update(App, 'TAGS', "spm.j.0.2")
x = Update(App, 'DESC', "spm.j.0.3")
/* say 'SGD' c2x(SGD) */
end
x = Retrieve('DCL','DEFS',"item")
item = substr(item,1,4)||d2s(defaultord)||substr(item,7)
x = Update('DCL','DEFS',"item")
say ' '
return 0
/* - - - - */
cleanup:
say ' '
x = rxqueue('DELETE','spmapp_q')
return 0
/* * * * * */
Types:
parse arg Key,seq
x = Retrieve('DCL',Key,"item")
TypeCount = s2d(substr(item,1,2))
TypeDesc = substr(item,3,TypeCount*4)
TypeNames = substr(item,3+length(TypeDesc))
j = 4 * TypeCount
do i = 1 to j by 4
var = szstr(TypeNames,s2d(substr(TypeDesc,i,2))+2)
if seq = ''
then
interpret var '=' s2d(substr(TypeDesc,i+2,2))
else
do
interpret var '=' seq
seq = seq + 1
end
end
return 0
/* * * * * */
Groups:
OrdList = ''
if Retrieve('SPM','ELEMENTS',"item",'opt') <> 0 then return 0
x = Retrieve('SPM','NAMES',"name")
x = Retrieve('SPM','DESC',"desc")
j = length(item)
do i = 1 to j by 8
grp = s2d(substr(item,i,2))
pvw.grp = szstr(name,s2d(substr(item,i+4,2))+2)
pvw.grp.1 = szstr(desc,s2d(substr(item,i+6,2))+2)
pvw.grp.2 = '_'||s2d(substr(item,i+2,2))
if substr(item,i,2) = substr(item,i+2,2) then t = 'b'
else t = 'a'
OrdList = OrdList||grp||' '||t||' '
end
return 0
/* * * * * */
Version:
if Retrieve('SPM','VERSION',"item",'opt') <> 0
then
do
ctGS = 0
ctEL = 0
loGP = 99999
hiGP = 0
szPT = 1
szSN = 0
szST = 0
szSD = 0
mxGP = 0
end
else
do
ctGS = s2d(substr(item,3,2))
ctEL = s2d(substr(item,5,2))
loGP = s2d(substr(item,7,2))
hiGP = s2d(substr(item,9,2))
szPT = s2d(substr(item,13,2))
szSN = s2d(substr(item,17,2))
szST = s2d(substr(item,19,2))
szSD = s2d(substr(item,21,2))
mxGP = s2d(substr(item,25,2))
end
return 0
/* * * * * */
Verify:
arg grp
p = wordpos(grp,OrdList)
if p = 0 then return ' '
if Retrieve('_'||grp, 'ELEMENTS',"item",'opt') <> 0 then return 0
ctGS = ctGS - 1
szSN = szSN - s2d(substr(item,3,2))
szST = szST - s2d(substr(item,5,2))
szSD = szSD - s2d(substr(item,7,2))
ctEL = ctEL - s2d(substr(item,9,2))
szPT = szPT - s2d(substr(item,13,2))
say ' '
say GetMsg(20,grp)
return ' '
/* * * * * */
Retrieve:
parse arg _app,_key,_item,_opt
_data = SysIni(INIFILE,_app,_key)
if _data = 'ERROR:'
then
do
if _opt = ''
then
do
say GetMsg(14,_app,_key)
exit 14
end
else
do
/* say '.. item' _app'/'_key 'not retrieved' */
return 4
end
end
else
do
interpret _item '= _data'
return 0
end
Update:
parse arg _app,_key,_item
interpret 'x = SysIni(INIFILE,_app,_key,'_item')'
if x = ''
then
do
x = PutDot() /* say '.. item' _app'/'_key 'updated' */
return 0
end
else
do
say GetMsg(15,_app,_Key)
return 8
end
/*
pvw.i = PVW group name
pvw.i.1 = description
pvw.i.2 = j = link to spm.
spm.j = SPM group tag
spm.j.1 = ordinal
spm.j.2 = source
spm.j.3 = type
spm.j.4 = k = count of fields
spm.j.4.k = field type
spm.j.4.k.1 = PVW field name
spm.j.4.k.2 = SPM field tag
pvw.0.1 = PGD names pool
pvw.0.2 = PGD description pool
pvw.i.0 = PGD item
spm.j.0 = SGD item
spm.j.0.1 = SGD names pool
spm.j.0.2 = SGD tags pool
spm.j.0.3 = SGD description pool
*/
CheckGroup:
x = Require(GROUPNME,'groupnme')
x = Require(GROUPTAG,'grouptag')
if GROUPORD = '' then GROUPORD = 'defaultord'
if GROUPSRC = '' then GROUPSRC = 'defaultsrc'
if GROUPTYP = '' then GROUPTYP = 'defaulttyp'
if GROUPDSC = '' then GROUPDSC = GROUPNME
return 0
CheckAlias:
x = Require(ALIASNME,'groupnme')
if ALIASORD = '' then ALIASORD = 'defaultord'
if ALIASDSC = '' then ALIASDSC = ALIASNME
return 0
CheckField:
x = Require(FIELDNME,'fieldnme')
x = Require(FIELDTAG,'fieldtag')
x = Require(FIELDTYP,'fieldtyp')
if FIELDDSC = '' then FIELDDSC = FIELDNME
return 0
Require:
if arg(1) <> ''
then
return 0
else
do
say GetMsg(13,INPUT_SEQ,arg(2))
exit 13
end
SortSeq:
arg istr
ostr = word(istr,1)
istr = subword(istr,2)
do p = 1 to words(istr)
wd = word(istr,p)
wc = words(ostr)
do q = 1 to wc while q > 0
if wd = word(ostr,q)
then
do
q = 0
leave
end
if wd < word(ostr,q)
then
do
ostr = subword(ostr,1,q-1)||' '||wd||' '||subword(ostr,q)
q = 0
leave
end
end
if q > 0 then ostr = ostr||' '||wd
end
return ostr