|
David, et al "position to" in our shop is performed by a binary halving of the subfile and changing the top record number. We also set an indicator for positioning the cursor on the record for a match. I've included a code snippet, hopefully it's self explanatory. XGTOP# = the subfile beginning record number XGBTM# = the subfile last record number XGSFL# = the subfile current record number XGPSN$ = the requested "position to" XGKEY = the subfile value (index ordered) @XGGET = a subroutine that does a chain to the subfile by record number (and other stuff not related to "position to") FMT * ..... *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 0043.00 C* ------------------------------------------------------------------ 0044.00 C @XGSET BEGSR 0045.00 C* 0046.00 C *LIKE DEFN XGTOP# BHTOP# 0047.00 C *LIKE DEFN XGBTM# BHBTM# 0048.00 C *LIKE DEFN XGSFL# BHSPAN 0049.00 C Z-ADD1 BHTOP# Set SFL Top 0050.00 C* At this point the search arguement must be within the subfile 0051.00 C* range of values, so perform binary halving to locate entry. 0052.00 C Z-ADDXGBTM# BHBTM# Set SFL Bottom 0053.00 C BHBTM# SUB BHTOP# BHSPAN Find spread 0054.00 C BHSPAN DIV 2 BHSPAN Split spread 0055.00 C BHTOP# ADD BHSPAN XGSFL# Position cursor 0056.00 C* Find the page which contains the record requested 0057.00 C SETOF 90 0058.00 C BHSPAN DOWGEXGPGSZ Until page size 0059.00 C EXSR @XGGET GET SFL RECORD 0060.00 C* IF you happen to hit right on, set the subfile cursor 0061.00 C XGPSN$ IFEQ XGKEY 0062.00 C Z-ADDXGSFL# XGTOP# 0063.00 C LEAVE 0064.00 C END 0065.00 C* ELSE Determine which way to look 0066.00 C XGPSN$ IFLT XGKEY Too low 0067.00 C Z-ADDXGSFL# BHBTM# In top half 0068.00 C ELSE 0069.00 C Z-ADDXGSFL# BHTOP# In bottom half 0070.00 C END 0071.00 C* Slice the section in half again 0072.00 C BHBTM# SUB BHTOP# BHSPAN Find spread 0073.00 C BHSPAN DIV 2 BHSPAN Slit spread 0074.00 C BHTOP# ADD BHSPAN XGSFL# Position cursor 0075.00 C ENDDO 0076.00 C* Once the section is located, perform loop to find requested entry 0077.00 C XGPSN$ IFNE XGKEY 0078.00 C* Position file cursor 0079.00 C Z-ADDBHTOP# XGSFL# 0080.00 C EXSR @XGGET 0081.00 C* Loop through page 0082.00 C XGKEY DOWLTXGPSN$ 0083.00 C ADD 1 XGSFL# 0084.00 C EXSR @XGGET 0085.00 C N90 ENDDO 0086.00 C 90 SUB 1 XGSFL# 0087.00 C* 0088.00 C Z-ADDXGSFL# XGTOP# 0089.00 C END 0090.00 C* 0091.00 C ENDSR FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 0175.00 A* -----------------------------------------------------------------------* 0176.00 A R XGWRKSFL SFL 0177.00 A TEXT('"Work with" Subfile') 0178.00 A 70 SFLNXTCHG 0179.00 A XGOPT$ 1A B 10 3TEXT('OPTION') 0180.00 A VALUES(' ' '2' '4' '8') 0181.00 A N70 DSPATR(CS UL) 0182.00 A 70 DSPATR(RI) 0183.00 A XGGLNO R O 10 7DSPATR(HI) 0184.00 A XGSTAT R O 10 15 0185.00 A XGNAME R O 10 19DSPATR(HI) 0186.00 A XGABBR R O 10 52 0187.00 A XGTYPE R O 10 71 0188.00 A XGRSET R O 10 78 0189.00 A* -----------------------------------------------------------------------* 0190.00 A R XGWRKCTL SFLCTL(XGWRKSFL) 0191.00 A TEXT('"Work with" Control') 0192.00 A SFLSIZ(12) SFLPAG(11) 0193.00 A OVERLAY 0194.00 A N99 SFLEND(*MORE) 0195.00 A 98 SFLCLR 0196.00 A 97 SFLDSPCTL 0197.00 A 96 SFLDSP 0198.00 A XGTOP# 4S 0H SFLRCDNBR(CURSOR *TOP) 0199.00 A* 0200.00 A 4 2'Type options, press ENTER.' 0201.00 A COLOR(BLU) 0202.00 A 4 51'Position list to. .:' 0203.00 A XGPSN$ R A B 4 72REFFLD(XGGLNO) 0204.00 A CHECK(RZ ER) 0205.00 A DSPATR(CS UL) 0206.00 A* 0207.00 A 5 3'1=Create' 0208.00 A COLOR(BLU) 0209.00 A 5 16'2=Edit' 0210.00 A COLOR(BLU) 0211.00 A 5 25'4=Delete' 0212.00 A COLOR(BLU) 0213.00 A 5 36'8=Display' 0214.00 A COLOR(BLU) 0215.00 A* 0216.00 A 7 2' - 0217.00 A - 0218.00 A ' 0219.00 A DSPATR(HI UL) 0220.00 A 8 2'Opt ACCT# Sts Full description - 0221.00 A Abbreviated desc T- 0222.00 A ype Reset' 0223.00 A DSPATR(HI UL) 0224.00 A WSOPT$ R B 9 3REFFLD(XGOPT$ *SRC) 0225.00 A VALUES(' ' '1' '2' '4' '8') 0226.00 A N74 DSPATR(CS UL) 0227.00 A 74 DSPATR(RI PC) 0228.00 A WSGLNO R B 9 7REFFLD(XGGLNO) 0229.00 A COMP(GE 0) 0230.00 A N73 DSPATR(CS UL) 0231.00 A 73 DSPATR(RI PC) "Kahn, David [JNJFR]" wrote: > >if you want "Position to:" functionality, you need SFLPAG=SFLSIZ > > My standard template, refined over the years, is SFLSIZ>SFLPAG loaded page > at a time, and it has "position to". You simply clear the subfile and reload > the first page starting from the positioned to record, enabling roll down if > this is not also the first record in the file. Roll down is processed by > locating the new top record and treating this like another position to. It's > efficient and slick apart from one big hole. The big hole is that any > pending selections are lost when rolling past the current start of the > subfile. BRMS incidentally has this same "feature" in its subfiles. > +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.