[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
- Subject: Re: how to create array and print output in header
- From: Denise White <dewhite@VICR.COM>
- Date: Tue, 6 Feb 2001 09:38:24 -0500
Joe,
I agree with Stan. Also, you need to increment #i within the while loop. If
you just remove the break, it would go into an endless loop and just keep
retrieving the 0 occurence over and over again.
I also think that on your while loop in the Update_Array procedure, you might
want to make it:
While #j < {MAX_TRCs} and $Found = 'N'
I think that the way you have it now, the first time through it will load the
first value of &TL.TIME_RPTG_CD into every occurence of the array, since it
won't end the loop until it reaches {MAX_TRCs}. If you include the $Found
condition, you also won't need the break in the else clause, so the loop will
end in a more normal way (when it reaches the condition, rather than by a
break).
On an efficiency note, 'move' and 'add' are more efficient than 'let'. I
believe that 'add 1 to #j' executes something like three times faster than 'let
#j = #j + 1'. And to be really picky, there doesn't seem to be any point in
adding 1 to #i in the select, because you're just going to set it to #j anyway
(or 0 when it does the header).
HTH,
Denise White
Sr. Programmer/Analyst
Vicor
------------------------------
Date: Mon, 5 Feb 2001 16:25:21 -0800
From: Stan Quick <stanley.quick@BRIO.COM>
Subject: 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