Re: Stumped by open("PRN","w")

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sun, 21 Jan 2001, Dan B Moyer wrote:
>> cense,
>>
>> From the Euphoria refmanual, on "open",
>>
>> <begin quote>
>> Some typical devices that you can open are:
>>
>> "CON" - the console (screen)
>> "AUX" - the serial auxiliary port
>> "COM1" - serial port 1
>> "COM2" - serial port 2
>> "PRN" - the printer on the parallel port
>> "NUL" - a non-existent device that accepts and discards output
>>
>> <end quote>
>>
>> So, "PRN" is a device definition of the printer on the parallel port.

I was talking about the quotes, sorry, i was not specific enough

>> Dan Moyer
>>
>>
>> ----- Original Message -----
>> From: "cEnsE" <cense at MAIL.RU>
>> To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
>> Sent: Sunday, January 21, 2001 7:15 PM
>> Subject: Re: Stumped by open("PRN","w")
>>
>>
>> > On Sun, 21 Jan 2001, Jim wrote:
>> > >> The following code snippet is from a Windows program using Win32Lib.ew.
>> If I run it with exw.exe, on a machine with no
>> > >> printer (or anything else) attached to the parallel port, it executes
>> the open("PRN","w") statement and assigns a valid
>> > >> file handle (4), where  I would have expected a -1.  It also continues
>> to the puts(ThePrinter,line) and executes that.
>> > >> In fact, under exw, the program runs to normal completion, when I would
>> have expected an abnormal termination.
>> > >>
>> > >> The very same code, copied to an .ex file, and run under ex.exe
>> executes in the same way, but then crashes with a DOS
>> > >> Critical Error when it hits the puts(ThePrinter,line) statement. In
>> both versions, I would have expected a -1 on the
>> > >> open for the non-existent printer.
>> > >>
>> > >> Can someone help me understand what I'm doing wrong here?
>> > >>
>> > >> Thanks.
>> > >>
>> > >> Totally perplexed.
>> > >>
>> > >> Jim
>> > >>
>> > >> ------------------- <begin code >
>> > >> object  line
>> > >> integer Patterns,ThePrinter,result
>> > >>
>> > >>           Patterns=open( "PATTERNS.TXT","rb" )        -- any text file
>> of 80 or more char.
>> > >>           if Patterns = -1  then
>> > >>              result = message_box( "Open Patterns.txt FAILED in
>> OnClick_ButtonPrint. Aborting. ","ERROR!", {} ) abort(1)
>> > >>
>> > >>           end if
>> > >>
>> > >>           ThePrinter = open("PRN","w")
>> >
>> > What exactly is this "PRN" ? the way you have it coded, if im not
>> mistaken,
>> > the open call will open a file in the current directory called PRN. I may
>> > very well be mistaked but from a quick look over this "PRN" stands out as
>> a
>> > possible  source of your problem.
>> >
>> >
>> > >>           if ThePrinter = -1  then
>> > >>              result = message_box( "Unable to find a printer;
>> skipping.", "ERROR!", {} )   -- never executed, although
>> > >> no printer
>> > >>           else
>> > >>              while 1 do
>> > >>                    line=gets(Patterns)
>> > >>                    if atom(line) then
>> > >>                       close(Patterns)
>> > >>                       close(ThePrinter)
>> > >>                       exit
>> > >>                    end if
>> > >>                    line=line[1..80]&"\n"
>> > >>                    puts(ThePrinter,line)    --   processed OK under
>> exw.exw ; crashes to DOS under ex.exe
>> > >>              end while
>> > >>           end if
>> > >> ---------< end code >
>> >
>> > I hope that helps, but if not, i tried.
>> >
>> > --
>> > evil, corruption and bad taste
>> > ^[cense]
--
evil, corruption and bad taste
^[cense]

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu