Process All Database Record Types
Thursday, July 31, 2008 at 4:20PM Written by Tom Shriver to create globals for every record number in a database
Output: 4 globals: GREC1, GREC2, GREC3 and GREC4 (gotta use 4 cause SIR will only read up to a certain a length. databases with a lot of record types will go over the line length that SIR can read
program
. write ['Making Global Recs ' + dbname(0)]
. integer * 2 REC#C POS# MAXLEN# GLINE#
. string * 210 REC1 REC2 REC3 REC4
. set GLINE# (1) MAXLEN# (200) REC1 REC2 REC3 REC4 ('')
. REC#C = nrecs(0)
. for REC# = 1, REC#C
. ifthen (numrecs(REC#) > 0)
. REC1 to REC4(GLINE#) = REC1 to REC4(GLINE#) + format(REC#) + ','
. if (len(REC1 to REC4(GLINE#)) > MAXLEN#) GLINE# = GLINE# + 1
. endif
. end for
. REC1 to REC4(GLINE#) = sbst(REC1 to REC4(GLINE#),1,len(REC1 to REC4(GLINE#)) - 1)
. x = dglobal('GREC1')
. x = dglobal('GREC2')
. x = dglobal('GREC3')
. x = dglobal('GREC4')
. x = globals('GREC1',REC1)
. ifthen (len(REC2) > 0)
. x = globals('GREC2',REC2)
. ifthen (len(REC3) > 0)
. x = globals('GREC3',REC3)
. ifthen (len(REC4) > 0)
. x = globals('GREC4',REC4)
. endif
. endif
. endif
. x = globals('GCASE',trim(keyname(0,1)))
end program
and to call it (as a member)...
call DCCPROCF.SYSTEM.ALLRECS
retrieval
. process cases
. do repeat x = <GREC1>
<GREC2>
<GREC3>
<GREC4>
. write ["Case " + varget(varname(0,1)) + "has a " + trim(recname(!x)) + " record"]
. end rec
. end repeat
. exit case
. end cases
end retrieval


Reader Comments