1. Redirection and Screen I/O

I have been trying to write a program that outputs directly to the
screen EVEN IF the user who invokes it happens to redirect output.

I noticed that the ed.ex program just uses standard out for all of
it's screen writes, so I thought I would modify it a little, and
instead of setting SCREEN = 1, I would set SCREEN = open("CON","w")
but if I do this, the screen is definitely messed up.

BTW -- if you type the following command 'ex ed.ex >test' with the
unhacked version of ed.ex it doesn't work right either...

So what is the problem ? Is there a way to do text-based screen I/O
without assuming that stdout is pointing there ?

(I have been trying to modify a Turbo-Pascal program I wrote a while
back that had to deal with the same issue -- not using stdout for
screen writes. In TP, though, opening the console worked correctly )

Any ideas ? Or is this possible a bug/feature of the interpreter
itself ?

-tim

new topic     » topic index » view message » categorize

2. Re: Redirection and Screen I/O

> I noticed that the ed.ex program just uses standard out for all of
> it's screen writes, so I thought I would modify it a little, and
> instead of setting SCREEN = 1, I would set SCREEN = open("CON","w")
> but if I do this, the screen is definitely messed up.
>
> So what is the problem ? Is there a way to do text-based screen I/O
> without assuming that stdout is pointing there ?
>
> (I have been trying to modify a Turbo-Pascal program I wrote a while
> back that had to deal with the same issue -- not using stdout for
> screen writes. In TP, though, opening the console worked correctly )
>
> Any ideas ? Or is this possible a bug/feature of the interpreter
> itself ?

well i'm not exactly sure what you're trying to do...  why don't you
want to use just normal output???

i do have ONE alternative, however...  you can write text directly to
video memory using poke...  video memory is linear, meaning that the
character one the right of another will follow it immediately in
memory...  the address are:

mono output: #B0000
colour output:  #B8000

when you poke into memory, you should actually poke two bytes...  the
first byte is the character itself and the second byte is the
colour..  now to figure out the ACTUAL value poked into memory for
colour, you can use an equation like this:

x = (128 * is_blinking) + (16 * background_colours) +
(foreground_colour)

well once again i'm not very clear on what you were trying to do...
but at least everyone knows how to poke text directly into video
memory now :>

anyway...  ttyl


 ...oooO        MikPos of MARTYR        Oooo...
..ooO  http://www.geocities.com/SoHo/9036  Ooo..
   ....oooO       mike burrell      OOooo....

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

3. Re: Redirection and Screen I/O

Tim Hansell writes:

> I have been trying to write a program that outputs directly to the
> screen EVEN IF the user who invokes it happens to redirect output.
> I noticed that the ed.ex program just uses standard out for all of
> it's screen writes, so I thought I would modify it a little, and
> instead of setting SCREEN = 1, I would set SCREEN = open("CON","w")
> but if I do this, the screen is definitely messed up.

Euphoria handles screen writes via standard output and screen writes
via "CON" a bit differently. It detects when writes to standard output
are really going to the screen, and it modifies the output a bit
by expanding tabs to blanks, and taking care of the line-wrap
on/off feature (see wrap()). If you write to CON these things are not
handled by Euphoria, you have to accept whatever DOS normally does.
Also, writes to the screen via standard output happen immediately.
Writes via CON are buffered until a '\n' comes along. e.g.

   integer f
   f = open("CON", "w")
   puts(f, "Hello")
   atom t
   t = time()
   while time() < t + 5 do
   end while
   puts(f, "\nWorld\n")

You won't see "Hello" until after the 5-second delay loop.

Regards,
  Rob Craig
  Rapid Deployment Software

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

Search



Quick Links

User menu

Not signed in.

Misc Menu