Page 1 of 1

forcase loop

Posted: December 11th, 2019, 3:55 pm
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

Re: forcase loop

Posted: December 11th, 2019, 4:21 pm
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?

Re: forcase loop

Posted: December 11th, 2019, 4:30 pm
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.

Re: forcase loop

Posted: December 12th, 2019, 7:51 am
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.

Re: forcase loop

Posted: December 13th, 2019, 5:14 pm
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?