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 »

Is there a way to execute a forcase more than once for the same file?
I´ve tried to close the file and open it again, but apparently it is not working, the second time it does not execute the loop.
What should I have to do?
Best
Best
Ari
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: forcase loop

Post by AriSilva »

I´ve found that the set first does the job, provided you do not close the file before hand.
By the way, what´s the reason to close an external file that you opened for reading?
Best
Ari
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: forcase loop

Post by josh »

You should not have to do anything. Forcase should automatically restart at the first case in the file. If you do something like:
    trace(on);
   
trace("Loop 1");
   
forcase MY_DICT do
        trace
("%s", key(MY_DICT));
   
enddo;
   
trace("Loop 2");
   
forcase MY_DICT do
        trace
("%s", key(MY_DICT));
   
enddo;
then you should get the all the cases in the file listed twice.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: forcase loop

Post by Gregory Martin »

There is rarely a reason to close an external file. Prior to CSPro 7.0, it could have been useful to close a text data file if you had two applications running because both couldn't access the file at the same time, but with .csdb, multiple applications can access the file at the same time (as external files) so there is little use for close.
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: forcase loop

Post by AriSilva »

Thank you, my fault.
Somewhere in the program I was closing the external file, and then it would not execute the forcase.
Is there a way to warn the user about that?
Best
Ari
Post Reply