1. Rob, bug fix/suggestion
Rob, if you have some time, can you consider this request...
What I'm trying to do is put() data to either the screen or a file, without
having to use if and then statements. IE puts(output,"BLAH"). I want to add
one more output mode, which is none, but still refrain from using the if and
then statements. I was wondering if you could make puts(-1,"Blah") go
nowhere. In other words, if puts() sees -1, it will just end the procedure
right there. This could be a good bug fix too. If someone is opening a file
and printing to it (like moi), then this would avoid crashing the program if
the file doesn't open for some reason. I could say "unable to open file
ABC.XYZ", then when it tries to print to the file handle (-1), the program
will still work.
Or, if you don't like that, could you make 0 the code for nowhere?
Thanks,
Derek Brown
2. Re: Rob, bug fix/suggestion
On Mon, 6 Sep 1999 09:09:35 EDT, Derek Brown <Cyrusbrown at AOL.COM> wrote:
>then statements. I was wondering if you could make puts(-1,"Blah") go
>nowhere. In other words, if puts() sees -1, it will just end the procedure
>right there. This could be a good bug fix too. If someone is opening a
Derek:
Why can't you do this:
While handle != -1 do
puts(handle, "Blah")
end while
Bernie
3. Re: Rob, bug fix/suggestion
<< Derek:
Why can't you do this:
While handle != -1 do
puts(handle, "Blah")
end while
Bernie >>
I could, very easily. But, I have about 100 different puts() commands
spread out in different places in the code. I'm trying hard to avoid using
if and while statements.
I have already figured out the solution though. DOH! All I had to do was
make a custom puts command, PUTS(handle,"blah")...
global procedure PUTS(integer mode, sequence stuff)
if mode != -1 then
puts(mode,stuff)
end if
end procedure
DOH! that was pretty easy. I still think that would be a pretty nice
feature to the language though. One tiny stability improvement.
Derek Brown
4. Re: Rob, bug fix/suggestion
Derek Brown writes:
> I have already figured out the solution though. DOH!
> All I had to do was make a custom puts command,
> PUTS(handle,"blah")...
Under DOS and Windows everything you
write to the NUL device is quietly discarded.
e.g.
integer nowhere
nowhere = open("NUL", "w")
puts(nowhere, "Hello?\n")
If you can't open a particular file, you could set the file
handle to nowhere, and the output would be discarded.
On Linux you can open "/dev/null" for the same purpose.
You can also redirect standard output into NUL,
e.g. on system commands:
system("del temp.dat > NUL", 2)
Your solution (using an alternate routine for puts)
is probably just as good.
Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com