0 votes
by ProFrame (260 points)
Hello,
First an description of my problem:
1) a directory contains 200 data-files like: .......\PR1140-0265.fth
2) to process the data-files with the main program takes 20min.
    ( I use the command: "included" to read the data-files, afterwards I delete the file, also it takes 200 sessions,)
3) to process the data-files quicker, I start then main program (copies of it) separately 4 times and run it with  an interval with about 1 second. When no error occur, it takes now 8 min.
4) But there are moments that an error occurs like:  Err# -258 ERR: Failed to open requested file.
5) 1 of the 4, is busy (say 1)  to included a file, but not deleted it yet. (this is done direct after including)
6) Another (2 or 3 or 4) sees the file of 5) still exists (with use of command "fileexist?" ) and also try to include it.
7) That's the moment, in my opinion, the error occurs and the program crashed.
Question:
Unfortunately "included" gives no flag back, in that case the solution for me would than easier for me.
Can you give me a solution for this problem, or define a word like "included" which give a success-flag back?
with regards,
Hugo Overbeek

1 Answer

0 votes
by Stephen Pelc (3.4k points)

The source code for INCLUDED is in Kernel/Common/kernel62.fth.

I'm sorry that I cannot provide you with a tested answer, but I am in the middle of moving house for the next week or so.

What I suggest is that you use
  ['] included catch
which will return the error code to you, 0 for success.

by ProFrame (260 points)
Hello Stephen,

Thanks for your reply.

I  tried to  understand the mechanism catch and throw, also paste the example from chapter 29, page 323.
Unfortunately it gives an error:

Any idea?

with regards,
Hugo Overbeek

 ok
  ok
: could-fail \ -- char
  KEY DUP [CHAR] Q =
  IF 1 THROW THEN
;  ok
  ok
  ok
: do-it \ a b -- c
  2DROP could-fail
;  ok
  ok
  ok
  ok
  ok
: try-it \ --
  1 2 [’] do-it CATCH IF
Err# -13 ERR: Undefined word.
 ->   1 2 [’] do-it CATCH IF
                 ^
by Stephen Pelc (3.4k points)
Try using larger integers. Use the ERRDEF mechanism to give yourself unique numbers
...