[comp.sys.amiga] window help

hbit@pbhya.PacBell.COM (Henry Bitter) (02/15/89)

I am trying to get a small C program working that is using both Intuition and
DOS. My problem is after creating my own screen and window the output that is
created using printf commands still goes to the workbench screen and window.
I have been unable to figure out how to point STDIN,STDOUT to the new 
window.  The Lattice 5.0 compiler will not allow a simple assignment such as
stdin = input(). The compiler says "not assignable Lvalue". Any help would
be appreciated. I just want all I/O to talk to my new screen and window.

Thanks


Henry Bitter

* Pacific Bell  *         (415) 823-2836
San Ramon, Calif.
{ }!pacbell!pbhya!hbit

If I had a disclaimer I wouldn't give it away !

mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) (02/16/89)

In article <23793@pbhya.PacBell.COM> hbit@pbhya.PacBell.COM (Henry Bitter) writes:
<I am trying to get a small C program working that is using both Intuition and
<DOS. My problem is after creating my own screen and window the output that is
<created using printf commands still goes to the workbench screen and window.

This is a pretty common request. As far as I can tell, the answer is
"you can't get there from here." At least not with what is provided by
CBM.

First thing: you're almost certainly never going to be able to use
printf itself. fprintf is doable, under certain conditions. If your C
compiler supports dup() fdup(), or something similar, you might be
able to go from fprintf to printf. It's not clear you want to, though.

The canonical answer is "use sprintf() and Text()." You call sprintf
instead of printf, giving it a charater buffer to output to, then use
Text() to print the characters in your window.

As an alternative, you can use conman. It's shareware, and on one of
the Fish disks. Using it, you can fopen() a CON: (if you've isntalled
it as CON:) or CNC: (if you wish to leave the standard console handler
in place) window, giving it the address of a window structure to
attach itself to. The result of that fopen will be a FILE * you can
hand to fprintf

Now, if someone knows of a way supported by CBM of getting a
FileHandle pointing to a window after you've opened a file, that would
very usefull. I'd like to see it if you know how.

	<mike
--
So this is where the future lies			Mike Meyer
In a beer gut belly; In an open fly			mwm@berkeley.edu
Brilcreamed, acrylic, mindless boys			ucbvax!mwm
Punching, kicking, making noise				mwm@ucbjade.BITNET

andy@cbmvax.UUCP (Andy Finkel) (02/16/89)

In article <20428@agate.BERKELEY.EDU> mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) writes:
>In article <23793@pbhya.PacBell.COM> hbit@pbhya.PacBell.COM (Henry Bitter) writes:
><I am trying to get a small C program working that is using both Intuition and
><DOS. My problem is after creating my own screen and window the output that is
><created using printf commands still goes to the workbench screen and window.
>
>This is a pretty common request. As far as I can tell, the answer is
>"you can't get there from here." At least not with what is provided by
>CBM.
>

Actually, I did an example that did this a long time ago.  You open an
Intuition window; the example shows how to start a console handler
using it.  I posted it here, on BIX, and its on Fish disk 38.
Once you make your window a con: window you can printf, or whatever
to it.  The example uses only one cheap trick, and I promise to
rewrite it without the trick after 1.4 :-)

>Now, if someone knows of a way supported by CBM of getting a
>FileHandle pointing to a window after you've opened a file, that would
>very usefull. I'd like to see it if you know how.

You can also find the Intuition window pointer of a window
opened as a CON: window, by sending the con-handler a
DISKINFO packet.  That example was by Carolyn Scheppner, and
appeared on Fish disk 56.
-- 
andy finkel		{uunet|rutgers|amiga}!cbmvax!andy
Commodore-Amiga, Inc.

"Possibly this is a new usage of the word 'compatible' with which
 I was previously unfamiliar"

Any expressed opinions are mine; but feel free to share.
I disclaim all responsibilities, all shapes, all sizes, all colors.

ins_ajsk@jhunix.HCF.JHU.EDU (Jon Kay) (02/17/89)

In article <20428@agate.BERKELEY.EDU> mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) writes:
>In article <23793@pbhya.PacBell.COM> hbit@pbhya.PacBell.COM (Henry Bitter) writes:
><I am trying to get a small C program working that is using both Intuition and
><DOS. My problem is after creating my own screen and window the output that is
><created using printf commands still goes to the workbench screen and window.
>
>	...
>
>Now, if someone knows of a way supported by CBM of getting a
>FileHandle pointing to a window after you've opened a file, that would
>very usefull. I'd like to see it if you know how.
>
>	<mike
>--
There is one.  Unfortunately, I am not within reach of my manuals at
the moment, so I cannot be as specific as I would like, but here goes:

If you do a FileInfo or an Info on a CON: window, one of the fields
DOES return a pointer to the Window structure of that particular CON:.
Unfortunately, I don't remember which field it is.  It's in either the
AmigaDOS Reference Manual or the Amiga Technical Manual, in the
descriptions of DOS calls or DOS packet types, respectively.

It is also possible, using BeginIO/SendIO type calls, to set up a
console around a Window of your creation.  But you can't perform
printf's on it, but have to stick with write()-type calls (unless you
happen to have _doprnt() - type code sitting around...).

Hope this helps.  If you don't have the manuals mentioned above, write
me and I'll send specifics, or post if the amount of desperation out
there seems to warrant it.


					Jon Kay

mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) (02/25/89)

<><I am trying to get a small C program working that is using both Intuition and
<><DOS. My problem is after creating my own screen and window the output that is
<><created using printf commands still goes to the workbench screen and window.
<
<Actually, I did an example that did this a long time ago.  You open an
<Intuition window; the example shows how to start a console handler
<using it.  I posted it here, on BIX, and its on Fish disk 38.

I missed it - but I'm glad to know that it exists. I'll look at it
when I get home.

<Once you make your window a con: window you can printf, or whatever
<to it.  The example uses only one cheap trick, and I promise to
<rewrite it without the trick after 1.4 :-)

I assume the cheap trick is how you get from the console handler to a
con: device?

<>Now, if someone knows of a way supported by CBM of getting a
<>FileHandle pointing to a window after you've opened a file, that would
<>very usefull. I'd like to see it if you know how.
<
<You can also find the Intuition window pointer of a window
<opened as a CON: window, by sending the con-handler a
<DISKINFO packet.  That example was by Carolyn Scheppner, and
<appeared on Fish disk 56.

I phrased that badly - I want to go the other way. Given an intuition
window with an attached console handler, I want a con: file name I can
use. I know about Carolyns code; I used it in my emulation of the Unix
plot() library so that unix code would port directly.

	<mike
--
That time we slept together				Mike Meyer
That's as far as it went				mwm@berkeley.edu
Yet though we're not quite lovers			ucbvax!mwm
You're more than a friend				mwm@ucbjade.BITNET