Page 1 of 1

forcase loop

Posted: August 15th, 2019, 10:54 am
by AriSilva
When reading an external file with the forcase, the inputorder is sequential or indexed?
If it is indexed, is there a way to force it to read it sequentially?
Or the other way around, that is, if it is sequential, can we force it to be read indexed?

Re: forcase loop

Posted: August 15th, 2019, 11:52 am
by Gregory Martin
The current implementation only allows you to loop through cases in indexed order. You can change things to go in descending order:

https://www.csprousers.org/help/CSPro/s ... ement.html

If you really needed access to the sequential order, you can use the sqlquery function, but I wouldn't suggest creating an application where this was necessary. This, however, would get you what you want:
list string sequential_keys;
sqlquery(SECOND_DICT, sequential_keys, "SELECT `key` FROM `cases` ORDER BY `file_order`;");

do numeric counter = 1 while counter <= length(sequential_keys)
   
locate(SECOND_DICT, =, sequential_keys(counter));
   
loadcase(SECOND_DICT);
    // do something
enddo;