Page 1 of 2

Iconifying a console window

Posted: Sat Mar 09, 2019 4:39 am
by redfox
Many of my ARexx scripts open console windows to ask for input or display output as the program progresses.
Some of my scripts use the CON: console and some use KCON: (KingCON). The new console with OS4.1 FE has
most of the features I liked about KingCON, such as vertical scroll bar and scroll buttons.

One nice feature of KingCON is that I can choose my own icon to be displayed when I iconify the console window.
I can choose a different icon for each window I open. For example, I use an icon that looks like an mail envelope for my listmailbox window script to list my emails.

call open(listmailconsole,"KCON:0/50//350/Listmailbox/IMAGEemail/NOMENUS/CLOSE")

By default, the icon image is located in envarc:sys. The IMAGE option specifies a file called email.info.

I was wondering if this feature was available for the console provided with OS4.1 FE.

---
redfox

Re: Iconifying a console window

Posted: Sat Mar 09, 2019 12:10 pm
by tonyw
There is no way to specify your own icon to be used when iconifying a console window. However, the console looks in these three places for an icon to use. Perhaps you could overwrite one of these. The console seizes on the first icon it finds, so the one in ENVARC: is checked first:

1) ENVARC:Sys/def_shell.info
2) SYS:System/Shell.info
3) Default Project icon

Re: Iconifying a console window

Posted: Sat Mar 09, 2019 1:06 pm
by nbache
Hmm ... if the first one had been ENV: instead of ENVARC:, it would be possible (disregarding concurrency, but otherwise) to let your script overwrite the icon just before opening the console, and resetting it from ENVARC: (or elsewhere) afterwards.

Doing it in ENVARC: is potentially a bit intrusive.

Best regards,

Niels

Re: Iconifying a console window

Posted: Sun Mar 10, 2019 12:01 am
by redfox
Thanks for the replies. I agree it would be a bit tricky to change the icon in ENVARC: each time I launch my program (and go back and reset the icon when done). I don't want to upset any "global" variables used by the Shell console or any system programs.

Thanks,
redfox

Re: Iconifying a console window

Posted: Sun Mar 10, 2019 5:57 pm
by xenic
redfox wrote:Thanks for the replies. I agree it would be a bit tricky to change the icon in ENVARC: each time I launch my program (and go back and reset the icon when done). I don't want to upset any "global" variables used by the Shell console or any system programs.
There is another possibility. ENVARC: is an assignable directory. You could create the directory and sub "myenv/sys" in RAM: and put your "def_shell.info" in the "RAM:myenv/sys" directory. Then before your open your console assign ENVARC: to "RAM:myenv/sys". Open your console and assign ENVARC: back to "SYS:Prefs/Env-Archive". I tried it with a DOS script and it worked. I'm haven't tested it from a program.

Re: Iconifying a console window

Posted: Sun Mar 10, 2019 6:31 pm
by nbache
xenic wrote:There is another possibility. ENVARC: is an assignable directory. You could create the directory and sub "myenv/sys" in RAM: and put your "def_shell.info" in the "RAM:myenv/sys" directory. Then before your open your console assign ENVARC: to "RAM:myenv/sys". Open your console and assign ENVARC: back to "SYS:Prefs/Env-Archive". I tried it with a DOS script and it worked. I'm haven't tested it from a program.
Interesting idea. You'd have to find out when the icon file is actually read - at Shell startup or when you iconify it? I haven't checked.

An alternative could be to use Assign ADD. You should first assign ENVARC: to the RAM: path, then Assign ADD the normal one (SYS:Prefs/EnvArc), this will make the system search in the temporary path first and find your custom icon. After using it, you'd do another Assign, this time only to the regular path.

It's still a bit of a kludge, because every other process needing ENVARC: will also search you temporary dir first, until you assign it back.

Best regards,

Niels

Re: Iconifying a console window

Posted: Mon Mar 11, 2019 12:01 am
by tonyw
If it helps, the icon is sought when the console is opening its (first) window. You could open a temp console first, perform the above kludge, open the second *actual* window you are going to use, then close the original temp window.

All rather messy. Sorry, but there was never any call for people to use their own icons before!

Re: Iconifying a console window

Posted: Mon Mar 11, 2019 1:33 am
by redfox
Thanks for all your help guys. Temporary assign works like a charm. :mrgreen:

My ARexx program assigns envarc: to ram:, opens a console window and assigns envarc: back to normal assignment.

address command 'assign envarc: ram:'

call open(console,'CON:60/50//320/AmigaMail/CLOSE')

address command 'assign ENVARC: AmigaOS4:Prefs/Env-Archive'

Thanks,
redfox :mrgreen:

Re: Iconifying a console window

Posted: Mon Mar 11, 2019 10:14 am
by Minuous
So is there a good reason it looks in ENVARC: rather than ENV: ? Seems contrary to the Style Guide.

Re: Iconifying a console window

Posted: Mon Mar 11, 2019 5:48 pm
by xenic
Minuous wrote:So is there a good reason it looks in ENVARC: rather than ENV: ? Seems contrary to the Style Guide.
My guess would be this:

The console.device is looking in several places for 'def_shell.info' before it finds one to use. ENVARC: is a directory assignment while ENV: is a device that's not supposed to be accessed as a media device. Locking or opening a file in ENV: to see if a file is present would violate the styleguide for environmental variables.