C68 Window

Anything QL Software or Programming Related.
Post Reply
User avatar
Whopper
Over Heated PSU
Posts: 126
Joined: Tue Oct 24, 2017 4:04 pm

C68 Window

Post by Whopper »

Hi All,

Please could one (or more) or you C68 gurus out their show me some example code to define and use a window? I do not want the default sized window, but to use my own values.

I've looked at the documentation and, apart from a headache (and drinking problem) I've only achieved a remarkable amount of errors.


Thank you,

Whopper


You woke me for THAT!!!
User avatar
XorA
Site Admin
Posts: 1359
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: C68 Window

Post by XorA »

This?

viewtopic.php?f=3&t=1788&start=80#p16234

I asked a similar question ages ago!


User avatar
Whopper
Over Heated PSU
Posts: 126
Joined: Tue Oct 24, 2017 4:04 pm

Re: C68 Window

Post by Whopper »

XorA wrote:This?

viewtopic.php?f=3&t=1788&start=80#p16234

I asked a similar question ages ago!
XorA,

No, unfortunately not that. I've got that. I found the definition of the WINDOWDEF-t type and can create an instance of the type. But how to create the thing? That's my problem.

Thanks for answering,

Whopper


You woke me for THAT!!!
User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: C68 Window

Post by tofro »

The initial Window in a C68 program is called the console - It is normally opened by the startup code and defined by setting the _condetails structure.

If you want to open additional windows beyond the console, there are various ways to do that:

(

Code: Select all

chanid_t ut_con (WINDOWDEF_t *wdef)
is a low-level call to open a new window - It's not associated with C I/O in any way, and only prepared for unbuffered I/O, so your only way to use it is low-level calls like io_sstrg() and sd_... calls.

Code: Select all

chanid_t ut_window (char *name, char *details)
Is similar, with a device name like "con_512x256a0x0" and the same restrictions.

For C I/O, you need to open or fopen a device with a device name:

Code: Select all

FILE *handle;
handle = fopen (con_512x256a0x0","rw");
if (handle != NULL) {
	fprintf (handle, "%s\n", "Hello World");
}
will open a new window for C character I/O. You can use standard C I/O functions to communicate with that window. Note you will not get the nice C68 window title and border that you get on the console.

You close such a window in exactly the same way as you would close any other file.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
Whopper
Over Heated PSU
Posts: 126
Joined: Tue Oct 24, 2017 4:04 pm

Re: C68 Window

Post by Whopper »

tofro,

Thanks for your reply.

The last code example seems to be what I want. I tried this on Qemulator and Q68 and neither worked. They both compiled fine, but on executing the default console was was displayed with the usual end message "Press ENTER to continue."

Whopper


You woke me for THAT!!!
User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: C68 Window

Post by tofro »

Note if you actually want to see the window, you need to give the system some time to draw it - Your program seems to end prematurely and the window is closed again so fast (because the job is done), that you have no chance to see something. Send the program into a long loop after opening the window.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Post Reply