1. Help With An Error
Hi All,
I have a small problem I need help with. I have a procedure that=
opens a file and
reads text from four separate lines. Example:
procedure int_command()
sequence command, port,arg1,arg2,arg3,temp
integer fn, message
command =3D "0"
arg1 =3D "0"
arg2 =3D "0"
arg3 =3D "0"
fn =3D0
fn =3D open("example.dat", "r")
if fn =3D -1
then
message =3D message_box( "Where is example.dat?\n"&"Program is=
shutting
down!","Missing Dat File" , MB_ICONHAND+MB_TASKMODAL )
closeWindow(MainWin)
else
temp =3D gets(fn)
command =3D temp[1..length(temp) - 1]
temp =3D gets(fn)
arg1 =3D temp[1..length(temp) - 1]
temp =3D gets(fn)
arg2 =3D temp[1..length(temp) - 1]
temp =3D gets(fn)
arg3 =3D temp[1..length(temp) - 1]
close(fn)
end if
end procedure
It works okay if there are four lines to read, but if the file=
only has three or less
lines I get an error: type_check failure, temp is -1
If I use:
if temp=3D-1 then =85ect..ect.... I get an error: true/false=
condition must be an
ATOM
Any suggestions from preventing the type_check error?
Thanks,
Chris
2. Help With An Error
Hi All,
I have a small problem I need help with. I have a procedure that=
opens a file and
reads text from four separate lines. Example:
procedure int_command()
sequence command, port,arg1,arg2,arg3,temp
integer fn, message
command = "0"
arg1 = "0"
arg2 = "0"
arg3 = "0"
fn =0
fn = open("example.dat", "r")
if fn = -1
then
message = message_box( "Where is example.dat?\n"&"Program is=
shutting
down!","Missing Dat File" , MB_ICONHAND+MB_TASKMODAL )
closeWindow(MainWin)
else
temp = gets(fn)
command = temp[1..length(temp) - 1]
temp = gets(fn)
arg1 = temp[1..length(temp) - 1]
temp = gets(fn)
arg2 = temp[1..length(temp) - 1]
temp = gets(fn)
arg3 = temp[1..length(temp) - 1]
close(fn)
end if
end procedure
It works okay if there are four lines to read, but if the file=
only has three or less
lines I get an error: type_check failure, temp is -1
If I use:
if temp=-1 then =85ect..ect.... I get an error: true/false=
condition must be an
ATOM
Any suggestions from preventing the type_check error?
Thanks,
Chris
3. Re: Help With An Error
Hi Chris!
Remember that gets() returns a sequence if a line is there, or an integer (-1)
if a line isn't there. So,
you need to declare temp as an object, then ...
if sequence(temp) then
-- There's the line!
else
-- Oh no, end of file! I'm doomed
end if
4. Re: Help With An Error
Thank you Travis,
I do not know how I overlooked that :)
Chris
-----------------------------------------------------------------=
--------------------------------------------------------------
On Wed, 26 Jun 2002 14:44:52 -0600, Travis Beaty wrote:
>
>Hi Chris!
>
>Remember that gets() returns a sequence if a line is there, or=
an
>integer (-1) if a line isn't there. =A0So,
>you need to declare temp as an object, then ...
>
>if sequence(temp) then
>=A0-- There's the line!
>else
>=A0-- Oh no, end of file! I'm doomed
>end if
>