|
Calls IDMSCALC to get target page for given page range and key. IDMS
loadlib must be in loadlib search chain or you need to copy IDMSCALC
to a loadlib that is. Don't worry about IDMSCALC changing - this is
one routine that can't (think about it).
The panel is not shown here. Both routines are in the downloadable
sample zip.
/* REXX */
trace off
/**********************************************************************/
/* Initialisation */
/**********************************************************************/
Msg = ""
Lo = ""
Hi = ""
Len = ""
Key = ""
KeyH = " "
PKey = " "
Target = ""
/**********************************************************************/
/* Main processing loop */
/**********************************************************************/
DO forever
"ISPEXEC DISPLAY PANEL (@MGPCALC"
IF rc = 8 then leave
Msg = ""
IF Lo = 0 then Msg = Msg "**Lo**"
IF Hi = 0 then Msg = Msg "**Hi**"
IF Hi ¬> Lo then Msg = Msg "**Lo/Hi**"
IF Len = 0 ³ Len > 256 then Msg = Msg "**Len**"
IF Msg ¬= "" then iterate
PTarget = D2C(0,4)
PHi = D2C(Hi,4)
PLo = D2C(Lo,4)
PLen = D2C(Len,2)
IF KeyH ¬= C2X(PKey) & length(KeyH) > 0 then do
call HexKey
Key = ""
end
ELSE do
PKey = substr(Key,1,Len," ")
KeyH = C2X(PKey)
end
IF Msg ¬= "" then iterate
Parm = PTarget³³PHi³³PLo³³PLen³³PKey
address linkpgm "IDMSCALC Parm"
Target = C2D(substr(Parm,1,4),4)
end
exit
HexKey:
IF Len ¬= length(KeyH) / 2 then do
Msg = "**HEX length**"
return
end
PKey = ""
DO i = 1 to length(KeyH) by 2
HexHi = substr(KeyH,i,1)
HexLo = substr(KeyH,i+1,1)
call ValHex
PKey = Pkey³³D2C(HexVal,1)
end
return
ValHex:
HexVal = 0
HiNum = 256
IF HexHi = "0" then HiNum = 0
IF HexHi = "1" then HiNum = 16
IF HexHi = "2" then HiNum = 32
IF HexHi = "3" then HiNum = 48
IF HexHi = "4" then HiNum = 64
IF HexHi = "5" then HiNum = 80
IF HexHi = "6" then HiNum = 96
IF HexHi = "7" then HiNum = 112
IF HexHi = "8" then HiNum = 128
IF HexHi = "9" then HiNum = 144
IF HexHi = "A" then HiNum = 160
IF HexHi = "B" then HiNum = 176
IF HexHi = "C" then HiNum = 192
IF HexHi = "D" then HiNum = 208
IF HexHi = "E" then HiNum = 224
IF HexHi = "F" then HiNum = 240
LoNum = 256
IF HexLo = "0" then LoNum = 0
IF HexLo = "1" then LoNum = 1
IF HexLo = "2" then LoNum = 2
IF HexLo = "3" then LoNum = 3
IF HexLo = "4" then LoNum = 4
IF HexLo = "5" then LoNum = 5
IF HexLo = "6" then LoNum = 6
IF HexLo = "7" then LoNum = 7
IF HexLo = "8" then LoNum = 8
IF HexLo = "9" then LoNum = 9
IF HexLo = "A" then LoNum = 10
IF HexLo = "B" then LoNum = 11
IF HexLo = "C" then LoNum = 12
IF HexLo = "D" then LoNum = 13
IF HexLo = "E" then LoNum = 14
IF HexLo = "F" then LoNum = 15
IF HiNum = 256 ³ LoNum = 256 then do
Msg = "**Not HEX**"
return
end
HexVal = HiNum + LoNum
return
|