[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: how to create array and print output in header



Are you sure you want to break out of the while loop before printing the
array contents?

-----Original Message-----
From: Joe [mailto:jej1216@YAHOO.COM]
Sent: Monday, February 05, 2001 4:24 PM
To: SQR-USERS@list.iex.net
Subject: how to create array and print output in header


I am having trouble with printing the contents of an array to a header.

My rough (and I DO mean rough) code:

Begin-Setup
#Define Max_TRCs 100

Create-Array Name=TRCs Size= {MAX_TRCs}
 Field=TIME_RPTG_CD:Char -
 Field=TRC_DESCRSH:Char
End-Setup

BEGIN-PROGRAM
 let $First = 'Y'
 Let #i = 0
 DO Select_TRCs
END-PROGRAM

BEGIN-HEADING
  print 'TR Code Legend:' (+1, {col_30})
  let #i = 0
 While #i < {MAX_TRCs}
         Get $TIME_RPTG_CD $TRC_DESCRSH From TRCs (#i)
         Break
         Show '$TIME_RPTG_CD = ' $TIME_RPTG_CD
         Print $TIME_RPTG_CD (+1,{col_30})
         Show '$TRC_DESCRSH = ' $TRC_DESCRSH
         Print $TRC_DESCRSH  (0,{col_32})
 End-While
END_HEADING

BEGIN-PROCEDURE Select_TRCs
BEGIN-SELECT DISTINCT
TL.TIME_RPTG_CD
TL.DESCRSHORT
 add 1 to #i
 DO Update_Array
FROM PS_TL_WRKGPTRC_TBL TL
WHERE TL.TIME_RPTG_CD <> ''
AND TL.EFFDT = (SELECT MAX(TL2.EFFDT)
               FROM  PS_TL_WRKGPTRC_TBL TL2
               WHERE TL2.EFFDT = TL.EFFDT
               AND TL2.EFFDT <= '01/01/2001')
ORDER BY TL.TIME_RPTG_CD, TL.DESCRSHORT
END-SELECT

End-procedure

 BEGIN-PROCEDURE Update_Array

Let $Found = 'N'
Let #j = 0
While #j < {MAX_TRCs}
       Get $TIME_RPTG_CD From TRCs (#j)  TIME_RPTG_CD
         If  $TIME_RPTG_CD = ''
          Let #i=#j
           Put &TL.TIME_RPTG_CD into TRCs (#i)  TIME_RPTG_CD
          Let $Found = 'Y'
         Else
            If &TL.TIME_RPTG_CD = $TIME_RPTG_CD
              Let #i=#j
              Let $Found = 'Y'
              Break
            End-If
         End-If
         Let #j=#j+1
End-While

END-PROCEDURE