forcase loop

Discussions about editing and cleaning data
Forum rules
New release: CSPro 8.0
Post Reply
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

forcase loop

Post 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?
Best
Ari
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: forcase loop

Post 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;
Post Reply