English Amiga Board


Go Back   English Amiga Board > Support > support.Other

 
 
Thread Tools
Old 14 February 2016, 08:02   #1
gulliver
BoingBagged
 
gulliver's Avatar
 
Join Date: Aug 2007
Location: The South of nowhere
Age: 46
Posts: 2,358
ARexx help for a workbench menu action

Hi, I have set a workbench menu item with Toolsdaemon, and I want it to open the current workbench selected file with c:ed. I know this can be done with an ARexx script, but I dont know how

I would really apreciate if someone could help me, as ARexx is chinese for me
gulliver is offline  
Old 14 February 2016, 14:48   #2
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
That should be feasible with GETATTR command (have a look at ARexx.doc) if OS version ist 3.9 (or 3.5?). WINDOW.ICONS.SELECTED if you want to get selected icons.

I don`t know Toolsdaemon but maybe it has already a function that can parse selected files? Similar to DOpus its {f} for example. Would be the better solution.
daxb is offline  
Old 14 February 2016, 16:11   #3
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
3.9 or earlier? In 3.9 you can do this without ToolsDaemon.
idrougge is offline  
Old 14 February 2016, 16:46   #4
Korodny
Zone Friend
 
Join Date: Sep 2001
Location: Germany
Posts: 812
Quote:
Originally Posted by gulliver View Post
Hi, I have set a workbench menu item with Toolsdaemon
With 3.9, you don't need Toolsdaemon anymore, you can add a menu item to the tools menu using simple ARexx scripts:

Code:
/* This script will add a menu item to the Workbench's "Tools" menu */

ADDRESS workbench
MENU ADD NAME '"<SOME_INTERNAL_REFERRER>"' TITLE '"<TITLE_THAT_APPEARS_IN_MENU>"' CMD "<COMMAND_TO_EXECUTE>"
The text in angled brackets needs replacing with your own values, obviously, and you can add as menu "MENU ADD..." lines to the above script as you want, then create an icon for it and put it in WBStartup.

Quote:
and I want it to open the current workbench selected file with c:ed. I know this can be done with an ARexx script, but I dont know how
The following is completely untested, as I don't have a 3.9 setup to test right now. Maybe some of the people who do and have have some ARexx experience can help debugging this - experience tells me it won't work out of the box

Code:
/* not tested at all */

options results
address "WORKBENCH"

getattr windows.active
ActiveWin = result

getattr window.icons.selected name ActiveWin stem ActiveWinIcons

SourceFile = ActiveWin
if right(SourceFile,1) ~= ":" then SourceFile = SourceFile || "/"
SourceFile = SourceFile || ActiveWinIcons.0.name

address command 'C:ed "'SourceFile'"'
No error checking at all, it simply tries to open the first selected file (and only that) with C:ed.
Korodny is offline  
Old 14 February 2016, 19:19   #5
gulliver
BoingBagged
 
gulliver's Avatar
 
Join Date: Aug 2007
Location: The South of nowhere
Age: 46
Posts: 2,358
@Korodny

Thank you very much, the script works beautifully!

It does not check for errors, but certainly works

@daxb

I now have an easy working example from which I can start learning ARexx little by little.

Thanks

@idrougge

On 3.9 I use T.H.E. instead of ToolsDaemon
gulliver is offline  
Old 15 February 2016, 01:52   #6
Minuous
Coder/webmaster/gamer
 
Minuous's Avatar
 
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,630
BB4 actually has something similar already ("Tools|Edit text file..." command), the main difference being that it asks for a filename (via ASL). Maybe I should change this so that it automatically operates on the selected file.
Minuous is offline  
Old 15 February 2016, 04:31   #7
gulliver
BoingBagged
 
gulliver's Avatar
 
Join Date: Aug 2007
Location: The South of nowhere
Age: 46
Posts: 2,358
Quote:
Originally Posted by Minuous View Post
BB4 actually has something similar already ("Tools|Edit text file..." command), the main difference being that it asks for a filename (via ASL). Maybe I should change this so that it automatically operates on the selected file.
Yes, I just checked. To tell you the truth it is better this way (and it works just as it is), but I would only add to it, the missing error handling.
gulliver is offline  
Old 15 February 2016, 09:22   #8
Minuous
Coder/webmaster/gamer
 
Minuous's Avatar
 
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,630
Here's a new version of the above script that will just open with a blank file if nothing is selected.

Code:
/* "Tools|Edit Text File..." command */

OPTIONS RESULTS
ADDRESS "WORKBENCH"

GETATTR WINDOWS.ACTIVE
SourceFile = RESULT
IF SourceFile = "" THEN DO
    ADDRESS COMMAND 'SYS:Tools/EditPad'
    EXIT
END

GETATTR WINDOW.ICONS.SELECTED.COUNT NAME SourceFile
IF RESULT = 0 THEN DO
    ADDRESS COMMAND 'SYS:Tools/EditPad'
    EXIT
END

GETATTR WINDOW.ICONS.SELECTED NAME SourceFile STEM ActiveWinIcons
IF RIGHT(SourceFile,1) ~= ":" THEN SourceFile = SourceFile || "/"
SourceFile = SourceFile || ActiveWinIcons.0.NAME
ADDRESS COMMAND 'SYS:Tools/EditPad "'SourceFile'"'

Last edited by Minuous; 17 February 2016 at 05:47.
Minuous is offline  
Old 12 May 2023, 11:40   #9
fgh
Registered User
 
Join Date: Dec 2010
Location: Norway
Posts: 817
Quote:
Originally Posted by Minuous View Post
Here's a new version of the above script that will just open with a blank file if nothing is selected.

Code:
/* "Tools|Edit Text File..." command */

OPTIONS RESULTS
ADDRESS "WORKBENCH"

GETATTR WINDOWS.ACTIVE
SourceFile = RESULT
IF SourceFile = "" THEN DO
    ADDRESS COMMAND 'SYS:Tools/EditPad'
    EXIT
END

GETATTR WINDOW.ICONS.SELECTED.COUNT NAME SourceFile
IF RESULT = 0 THEN DO
    ADDRESS COMMAND 'SYS:Tools/EditPad'
    EXIT
END

GETATTR WINDOW.ICONS.SELECTED NAME SourceFile STEM ActiveWinIcons
IF RIGHT(SourceFile,1) ~= ":" THEN SourceFile = SourceFile || "/"
SourceFile = SourceFile || ActiveWinIcons.0.NAME
ADDRESS COMMAND 'SYS:Tools/EditPad "'SourceFile'"'
Hey there. It's been a few years, but I see you're still active here..

Just found this script of yours and started using it with MenuTools for textedit and multiview on my new 3.2.2.1 install.
It works great!

The only tiny issue is with multiview. If multiview is started without any flile selected and multiview is then closed without selecting a file, the script throws the DOS message that multiview failed with returncode 20.

I added Options failat 21, and the arexx part of the error message went away (showing line numbers etc) but there is still a popup window with the dos error message which does not appear if I do the same manually from shell. (Open multiview then quit without choosing a file)

Any ideas how to ignore the returncode from multiview entirely?

Anyway - a very useful script. Thanks!
fgh is offline  
Old 13 May 2023, 21:57   #10
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 666
Glad this post surfaced because I was not aware of the menu function and it's great!

However, I cannot get an AmigaDOS executable to be started by a menu entry. I tried some combination of these:

PHP Code:
CMD "ADDRESS COMMAND 'work:utils/ced'" 
with no luck. Is it possible, at all?

Thanks!
KONEY is offline  
Old 14 May 2023, 03:20   #11
Minuous
Coder/webmaster/gamer
 
Minuous's Avatar
 
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,630
It works here if I use:

Code:
ADDRESS COMMAND 'work:utils/ced'
Minuous is offline  
Old 15 May 2023, 18:19   #12
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 666
Thanks, you mean like this?

PHP Code:
MENU ADD NAME CED TITLE "CED" ADDRESS COMMAND "work:utils/ced" 
...which is not working for me. Menu entry appears but program is not executed and SnoopDOS says this:

PHP Code:
Count Process Name          Action  Target Name                 Options Res.
----- ------------          ------  -----------                 ------- ----
1     Workbench Rexx Handle ChangeD Ram Disk:                               
2     Workbench Rexx Handle Open    CON:0/10/568/124/Output win Write   OK  
3     Workbench Rexx Handle Open    CONSOLE
:                    Write   OK  
4     ARexx                 Open    
*                           Write   OK  
5     Workbench Rexx Handle ChangeD SYS

KONEY is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
AREXX Help Zetr0 support.Other 2 26 January 2011 23:09
arexx help jimbobrocks92 Coders. General 4 19 January 2011 12:50
Arexx redblade request.Apps 2 30 August 2006 11:51
[Amiga Action 63 disk 1] Valhalla: And The Lord Of Action amigarulez request.Old Rare Games 13 25 June 2006 14:36
Arexx Seti Coders. General 2 05 August 2003 18:59

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 14:42.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08418 seconds with 15 queries