Page 1 of 2

LeaveOut & PutAway CLI commands

Posted: Fri Dec 06, 2013 8:10 pm
by JosDuchIt
I have been hunting for CLI commands that would point to the path of an icon and leave it out or put it away.
Has anybody ever seen such commands.

Re: LeaveOut & PutAway CLI commands

Posted: Fri Dec 06, 2013 10:18 pm
by thomasrapp
I don't see any such function in the OS, therefore I doubt that such CLI commands can be made.

You could perhaps build something with ARexx using the ICON SELECT and MENU INVOKE commands.

Re: LeaveOut & PutAway CLI commands

Posted: Sat Dec 07, 2013 2:54 am
by xenic
JosDuchIt wrote:I have been hunting for CLI commands that would point to the path of an icon and leave it out or put it away.
Has anybody ever seen such commands.
I've never seen any CLI commands that will move icons. However, it can be done with an ARexx script through the Workbench ARexx port. I modified an old script that I have and posted it below. Check that the "sysname" variable is the name of your system partition. Close all windows, open a shell and run the script. It should move your SYS:Utilities/Clock icon to the Workbench screen, open a requester and then put the icon back when you close the requester. However, if your clock is "snapshotted" the script might leave it "unsnapshotted". It's probably O.K. to use a similar script on your own system but you never know what another user will do while a script or command is moving icons around. A user might delete/rmove the icon after it's moved etc. I'm not sure if the script will work if you cut'n-paste it into a text editor.

Code: Select all

/* WorkBench ARexx script that demonstrates moving icons */

OPTIONS results

sysname = System
syspath = sysname||":"

ADDRESS workbench

ACTIVATEWINDOW ROOT

ICON WINDOW ROOT sysname OPEN

ICON WINDOW syspath NAMES Utilities OPEN

MENU WINDOW syspath||Utilities INVOKE WINDOW.CLEARSELECTION

ICON WINDOW syspath||Utilities NAMES Clock SELECT

GETATTR WINDOW.ICONS.SELECTED.0.LEFT NAME syspath||Utilities
xpos = result
GETATTR WINDOW.ICONS.SELECTED.0.TOP NAME syspath||Utilities
ypos = result

MENU WINDOW ROOT INVOKE ICONS.LEAVEOUT

ADDRESS COMMAND 'RequestChoice "PutAway" "Put Icon Away?" "OK" >NIL:'

MENU WINDOW ROOT INVOKE WINDOW.CLEARSELECTION

ICON WINDOW ROOT NAMES Clock SELECT

MENU WINDOW ROOT INVOKE ICONS.PUTAWAY

ICON WINDOW syspath||Utilities NAMES Clock X xpos Y ypos

/* MENU WINDOW ROOT INVOKE ICONS.SNAPSHOT */

EXIT 0

Re: LeaveOut & PutAway CLI commands

Posted: Sat Dec 07, 2013 9:11 am
by JosDuchIt
@thomasrapp thanks for the arexx suggestion
@xenix thanks for the example

I don't see however why a CLI command couldn't copy the arexx functionality.

Do you ?
I believe such 2 commands would be a usefull addition to the set of simple CLI commands that can be used in scripts.

Re: LeaveOut & PutAway CLI commands

Posted: Sat Dec 07, 2013 11:58 am
by thomasrapp
Yes, I do. You can check the autodocs yourself. There is no function to leave out icons or to invoke menu selections. The most logical place to implement such would be WorkbenchControl(), but no tags exist to do the desired actions.

If you think otherwise, then just do it. I'd be happy to see your solution.

Re: LeaveOut & PutAway CLI commands

Posted: Sat Dec 07, 2013 4:03 pm
by xenic
JosDuchIt wrote:@thomasrapp thanks for the arexx suggestion
@xenix thanks for the example
I don't see however why a CLI command couldn't copy the arexx functionality.
A script can be a CLI command and called from an AmigaDOS script. As long as the ARexx script has an ARexx comment at the top (e.g. /* ARexx Script */ ) and the Script protection bit is set ( -S--RW-D ), the script will be run the same as a binary command. It doesn't even need to have a " .rexx " extension. If you copy the example to a text editor, save it as "WBmove" and set the Script protection bit, you can enter "WBmove" in a shell and it will execute just like a binary CLI command. A script has the advantage of being easily modified and fixed.

If you enter "Help Avail" in a shell then you should see the documentation for the "Avail" command in the shell window. Can you tell if the Help command is a binary command or script command? It's actually an ARexx script in the SYS:S/ARexx directory. I don't think the Help command would work any better if it were a binary command.

Re: LeaveOut & PutAway CLI commands

Posted: Sun Dec 08, 2013 2:41 pm
by jaokim
You can simply echo the filename to the hidden ".backdrop" file, and reboot. F.i., if you wish to leave out the file DH1:drawer/LeaveMeOut:

Code: Select all

echo ":drawer/LeaveMeOut" >> DH1:.backdrop
It requires a reboot; menu option "Restart Workbench" doesn't work, and neither does updating preferences. Perhaps there's some other function that will restart only Workbench?

Re: LeaveOut & PutAway CLI commands

Posted: Thu Dec 19, 2013 3:31 pm
by JosDuchIt
@all
thanks for clarifications

i tried from xenix example (& from Arexx:Opendrawer.rexx) to get closer to what i want

What is wrong however with the command
ICON WINDOW path NAMES icon SELECT

in the script LeaveOut.rexx below ?

17.Amiga OS 4:> getenv .path
BareEd:
17.Amiga OS 4:> getenv .name
StKlsDuch.htm
17.Amiga OS 4:> list BareEd:StKlsDuch.htm#?
Répertoire « BareEd: » le Mercredi 18-Déc-13
StKlsDuch.htm 17606 ----rwed Lundi 18:29:52
StKlsDuch.htm.info 9528 ----rw-d Aujourd'hui 21:37:45
2 fichiers - 26K octets - 30 blocs utilisés
17.Amiga OS 4:> RX REXX:LeaveOut.rexx
StKlsDuch.htm
26 *-* ICON WINDOW path NAMES icon SELECT;
+++ Command returned 10

Code: Select all

/* LeaveOut.rexx Leave out an icon on the Workbench defined by its path  */
OPTIONS results


id='getnv'pragma('id')
address command 'rxset' id '`getenv ".path"`'
if rc=5 then exit
path=getclip(id)
call setclip(id,'')

id='gtnv'pragma('id')
address command 'rxset' id '`getenv ".name"`'
if rc=5 then exit
icon=getclip(id)
call setclip(id,'')

ADDRESS workbench
WINDOW WINDOWS path OPEN
MENU WINDOW path INVOKE WINDOW.CLEARSELECTION
say icon
ICON WINDOW path NAMES icon SELECT
MENU WINDOW ROOT INVOKE ICONS.LEAVEOUT
The idea is to implement a kind of "project manager" that according to preset selections of iconpaths leaves them on the WB globally and puts them away globally too (to be replaced by an other selection°)
I started with Joakim's idea, but rebooting is out of the question.
A command 'reiniialising the .backdrop' is just a special case of the 'project manager'

@thomasrapp
i am not much of a C programmer .
Some weeks ago I brought the Gui4CLi source to a state where compiling generated no complainits about obsolete or deprecated calls.anymore. But that was rather easy. It does not mean i know my way into the system libraries, and i have still much to discover.
The arexx Workbench scripts may be rather slow beacuse you have to open & draw the window before selecting what you want. If you have tools & application output say in 3 winows, one of them with say 100 icons, the reaction will not be snappy, as we like our Amigas to behave.
The basic idea, is that all info to do what arexx WB scripts (LeaveOut.rexx) can, is available in the system lists. Arexx accesses them and uses the needed info, i guess, in the given "selecting & activationg) sequence
The intermediate opening, (redrawing on the screen) and closing is not 'really' needed.
So one could think of improved WB arexx command that have a "sneeky/hidden" argument, avoiding the unneeded drawing. A C coded equivalent then might not have much speed gain anymore.
Just trying to think, i think

Re: LeaveOut & PutAway CLI commands

Posted: Fri Dec 20, 2013 12:10 am
by nbache
JosDuchIt wrote:
What is wrong however with the command
ICON WINDOW path NAMES icon SELECT

in the script LeaveOut.rexx below ?
I'm not sure (haven't tested it). But I have two suggestions for you to make it easier to debug.

First, change all your variable names to some that you can be sure do not clash with any command or parameter names. E.g. avoid the variable name "icon", as there is also an ICON command. Call it e.g. "myiconname" instead.

Second, try putting some temporary debug output into your script. E.g. add the line "say 'icon = ' || icon" after the line "icon = getclip(id)", so you can see that you get the expected, or even any at all, content into the variable.

Best regards,

Niels

Re: LeaveOut & PutAway CLI commands

Posted: Fri Dec 20, 2013 5:26 pm
by xenic
@JosDuchIt
Niels is right. Although C language is case sensitive, ARexx in most cases is not. ARexx will see icon as the same as ICON and consider it a command. Does Niels suggestion solve your problem?