Subj : HW 100.2
To   : Finnigann
From : Amcleod
Date : Tue Oct 23 2001 11:16 pm

RE: HW 100.2
BY: Finnigann to All on Tue Oct 23 2001 10:20 pm

> !include FILE_IO.INC
>
> FOPEN file O_RDONLY "input.dat"
>
>  if_false
>      print "\r\n\r\nnError Loading Configuration File - Input.Dat"
>      return
>  end_if

This is cool, except I think you should declare the file handle (as an integer
first.  So, before the FOPEN you need something like

   INT file

> FOPEN file O_CREAT|O_TRUNC "output.dat"

This would work fine too, but there is a "gotcha" in there.  You are using back
the same file-handle, so you no longer have access to the INPUT file.  Better
declare separate file-handles:

   INT infh outfh
   FOPEN infh O_RDONLY "input.dat"
       .   .   .
   FOPEN outfh O_CREAT|O_TRUNC "output.dat"

From now on, you make all references to the INPUT file by way of the input
file-handle "infh" and reference the OUTPUT file via the output file-handle
"outfh".  BTW, you can use any old name for the handles as you see fit.  "in"
and "out", "ifh" and "ofh", "input_file_handle" and "output_file_handle" or
whatever, so long as it doesn't CLASH with the rest of the language, or
anything else in your program.

> if_false
>    print "\r\n\r\nnError Loading Configuration File - Output.Dat"
>         fclose Input.dat"
>      return
>    print "\r\n\r\nnDue to file error(s) All files closed at this time."
>                   end_if
> end

Okay, two things here.

Firstly, once you have opened a file, you refer to it by the file-handle, not
the name.  So it should be

   FCLOSE infh

(assuming the change in file-handles recommended above.)

Secondly, your code executes a RETURN which is followed by a PRINT.  The PRINT
is what is called "unreachable code".  You never get to do the PRINT because
you always RETURN just before you get to the PRINT.  Some compilers will warn
you about "unreachable code", but I don't know if BAJA.EXE does.

What you need to do is put the PRINT first and _then_ the RETURN.

Keep it up!  Work on the other steps now...

---
� Synchronet � Vertrauen � Home of Synchronet � telnet://vert.synchro.net