[[https://www.revelation.com/|Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community]] ==== How to use RBASIC SELECT into cursor ? (AREV Specific) ==== === At 13 OCT 2000 04:47:35PM Larry Sweet wrote: === {{tag>"AREV Specific"}} I am trying to do something very simple but AREV is not my primary language, so please bear with me. I want to select a list of records, then loop through the list and print a MERGE form to a file for each one. I need to loop through the list so I can name each file with the key from each record. Problem is when I execute the MERGE statement, the SAVELIST is lost. If I do another GETLIST, I am back at the 1st record. I am using the TCL SELECT and SAVELIST/GETLIST to make the list. I have tried but not had any luck with the RBASIC "SELECT BY sortfield SETTING cursor" examples as shown in the RBASIC manual. The code snippets in the manual do not work for me. I am using AREV 3.1. Could somebody be so kind as to send me a code snippet that would accomplish the following: SELECT table WITH select_criteria LOOP through the records READ @ID each record recordkey=@ID PDISK recordkey.txt MERGE mergeform recordkey PDISK PRN REPEAT END THE LOOP Thanks in advance ---- === At 14 OCT 2000 12:39AM Curt Putnam wrote: === One way to do it is to do a SAVELIST after the select - and then read the list records yourself. Just remember the little funny about List record IDs. Record 1 is: LISTNAME Record 2 is: LISTNAME*2 Record 3 is: LISTNAME*3 Your loop ends when you fail to read a LISTNAME*n ---- === At 14 OCT 2000 04:09AM Cameron Christie wrote: === Curt's suggestion is probably the most efficient, but the loop control logic can get a little ugly. You might try using a couple of system subroutines to store the list as you go through your existing loop, minimising the programming effort! Perform "SELECT rows" (Or GETLIST name...) Done=False$ Loop Until Done Readnext Id Else Done=True$ Until Done Call Push.Select(A,B,C,D) Execute 'MERGE MergeName Id' (or whatever...) Call Pop.Select(A,B,C,D) Repeat ---- === At 14 OCT 2000 07:01AM Bill Titus wrote: === Replace every instance of PERFORM (which passes your list of active keys along to the called subroutine or process) with EXECUTE (which does not) and your code should run fine. ---- === At 16 OCT 2000 11:09AM Don Miller - C3 Inc. wrote: === The reason that your program is failing is that when you do subsequent performs after the first, the select list is exhausted. So: PERFORM "SELECT YOURFILE WITH WHATEVER CRITERIA YOU NEED" IF @RECCOUNT < 1 then .. error in select .. no records vound * you can do a SAVELIST, but it's not really necessary unless you * need to reprocess, but we'll do it for drill PERFORM "SAVLIST MYLIST" ;* this saves it for later PERFORM "GETLIST MYLIST" ;* and this gets it back * OPEN YOUR DATA FILES HERE ... * wamt to use OPEN DICT.YOURFILE TO @DICT for dictionary calls OPEN "YOURFILE" TO FILE_IN ELSE ... OPEN "DICT.YOURFILE" TO @DICT ELSE ... L0: READNEXT @ID THEN READ @RECORD FROM FILE_IN,@ID THEN EXECUTE "PDISK ---- === At 16 OCT 2000 11:56AM Michael Slack wrote: === As alluded to in other responses you can do one of two things. First and probably the easiest is to store your keys from the Select statement into a dynamic array by using a small LOOP/REPEAT statement. Second would be to use the PUSH and POP statements to store your active select list while you do another Perform statment, once you are done with that Perform statmen you can bring your acitve select list back. I hope this helps. Michael Slack ---- === At 16 OCT 2000 03:39PM Larry Sweet wrote: === Thanks guys. I ended up replacing the PERFORM with EXECUTE and got it to work, as the simplest thing to do. [[https://www.revelation.com/revweb/oecgi4p.php/O4W_HANDOFF?DESTN=O4W_RUN_FORM&INQID=NONWORKS_READ&SUMMARY=1&KEY=CD06E90B83CB17C18525697700723888|View this thread on the forum...]]