1. Stumped by open("PRN","w")

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")

          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 >

new topic     » topic index » view message » categorize

2. 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]

new topic     » goto parent     » topic index » view message » categorize

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

Hi,cEnsE,

Thanks for trying to help. But, this is one of those very rare instances in
which I think  you may have missed the mark.

The code in question

                                        ThePrinter = open("PRN","w")

has been pretty much copied directly from an example given in the Euphoria
documentation (see "open" in the docs).

The only difference being that I named the receiving variable differently, i.e.,
ThePrinter instead of Rob's file_num.

I did, however, try open("LPT1","w")   and open("prn","w") and a few other
things before harrassing the list with my question.

As I said, thanks for taking the time to try to help.

Regards,

Jim

cEnsE wrote:

>
> 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.
>
> I hope that helps, but if not, i tried.
>
> --
> evil, corruption and bad taste
> ^[cense]

new topic     » goto parent     » topic index » view message » categorize

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

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.


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]

new topic     » goto parent     » topic index » view message » categorize

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

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 message » categorize

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

On Sun, 21 Jan 2001, Jim wrote:
>> Hi,cEnsE,
>>
>> Thanks for trying to help. But, this is one of those very rare instances in
>> which I think  you may have missed the mark.
>>
>> The code in question
>>
>>                                         ThePrinter = open("PRN","w")
>>
>> has been pretty much copied directly from an example given in the Euphoria
>> documentation (see "open" in the docs).
>>
>> The only difference being that I named the receiving variable differently,
>> i.e., ThePrinter instead of Rob's file_num.
>>
>> I did, however, try open("LPT1","w")   and open("prn","w") and a few other
>> things before harrassing the list with my question.
>>
>> As I said, thanks for taking the time to try to help.
>>
>> Regards,
>>
>> Jim

Am I really stupid and do not understand "open( )"? should it read:
 ThePrinter = open( PRN, "w" ) ? (note the no quotes). I think its just that
im stupid.

Is "PRN" a global variable or is it a special sequence? what if i wanted to
open a file called "PRN"?


>> cEnsE wrote:
>>
>> >
>> > 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.
>> >
>> > 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 message » categorize

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

Wow, i read the docs and now i understand. Sorry about all the confusion,
turns out im the one who needed help.

--
evil, corruption and bad taste
^[cense]

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu