English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System > Coders. Scripting

 
 
Thread Tools
Old 16 February 2018, 15:09   #81
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
DOpusM2_ARexx.guide should be the newest? and is at least in http://aminet.net/package/util/dopus/Dopus5_91_os3

"lister refresh" is what are you looking for. DOpus 4 should do automatic refresh.

http://aminet.net/package/util/wb/CopyIcon44 (if I'm not wrong PeterK did a version of it too) maybe help you with copy icons.
daxb is offline  
Old 19 February 2018, 20:21   #82
Martijn
Registered User
 
Join Date: Jan 2018
Location: Utrecht, NL
Posts: 15
Thanks! Yes I found some icon copy tools too, there's one in MagicWB. And I might use that eventually, but for now I have set myself a challenge to write a working arexx script for DOpus. Just for fun.
Martijn is offline  
Old 20 February 2018, 10:29   #83
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
The DOpus 4 manual appears to have documentation on all the ARexx commands. If you don't have it in your install, it's available from Sourceforge here.

Apparently, the Rescan command should re-read the the specified window, so that might be worth checking out:
Quote:
Rescan [WIN]

WIN optional; window to rescan
(-1 = current window, 0=left or 1=right)
defaults to -1.

This causes the directory in the active window (or the specified window) to
be re-read. This has exactly the same effect as activating the directory
string field and pressing return, without modifying the directory name.

ARexx Results:

RC = 0

Result = undefined
Daedalus is offline  
Old 02 June 2021, 16:27   #84
Paperboy
Registered User
 
Paperboy's Avatar
 
Join Date: Aug 2019
Location: Germany
Posts: 19
Hello how can I check if a file exists and if it does it is aborted if not the script continues

IF Exists("c:ed") THEN
say "break"
Else Exit


say "ok install"

this does not work
Paperboy is offline  
Old 02 June 2021, 21:07   #85
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
Code:
IF Exists("c:ed") THEN DO
    say "break"
    EXIT
END
daxb is offline  
Old 03 June 2021, 18:01   #86
Paperboy
Registered User
 
Paperboy's Avatar
 
Join Date: Aug 2019
Location: Germany
Posts: 19
thank you
Paperboy is offline  
Old 12 September 2023, 14:28   #87
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
Is it possible with ARexx to create something like an Array of string, like ["Abc", "Def", ...] and then iterate trough it in a loop?
thyslo is offline  
Old 12 September 2023, 17:55   #88
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
If you search this thread for "array" you get an example how to create an array. Something like this (very simple example):
Code:
str = 'Abc Def'
DO i = 1 TO WORDS(str)
    var.i = WORD(str, i)
END

DO i = 1 TO WORDS(str)
    SAY var.i
END
It depends on the string but you perhaps create it in a loop instead of manual typing.
daxb is offline  
Old 13 September 2023, 09:18   #89
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
Thank you, that is what I was looking for:-)
thyslo is offline  
Old 13 September 2023, 10:23   #90
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
You should not call a function which always returns the same value in a loop. This only creates a lot of unnecessary overhead. Rather call the function once before the loop and store the returned value in a variable.

By convention you usually put the number of elements into the .0 entry of the stem.

So this would be better:
Code:
str = 'Abc Def'
n = WORDS(str)
DO i = 1 TO n
    var.i = WORD(str, i)
END
var.0 = n

DO i = 1 TO var.0
    SAY var.i
END
thomas is offline  
Old 17 September 2023, 13:35   #91
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
I stumbled across another question today.

I've created a function that creates a stem variable (entry_info) and returns it. But the caller doesn't receive the stem variable. Here's the code:

Code:
/** 
 * Program to read the contents of DOpus 5 source and destination 
 * listeners.
 * 
 * Will later be improved to do some processiong with the entries.
 */

options results
address 'DOPUS.1'

'LISTER QUERY SOURCE'
src_handle = RESULT

'LISTER QUERY DEST'
dst_handle = RESULT

src_entries = getListerEntryInfos(src_handle)
dst_entries = getListerEntryInfos(dst_handle)
say src_entries.count   /* Debug output */
exit


getListerEntryInfos: procedure
  arg handle

  'LISTER QUERY 'handle' ENTRIES STEM 'entries

  n = entries.count-1
  do i = 0 to n
    'LISTER QUERY 'handle' ENTRY "'entries.i'" STEM 'entry_info.i
  end

  entry_info.count = entries.count
  say entry_info.count  /* Debug output */
  return entry_info
When running the script it ouputs:

Code:
4
5
SRC_ENTRIES.COUNT
I would have expected it to print '4' again instead of 'SRC_ENTRIES.COUNT'.

Does anyone have any idea what the reason could be?
thyslo is offline  
Old 17 September 2023, 14:30   #92
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
"src_entries.count" is just a string, hence SAY will print it as a string in upper case. Use TCO to open a trace console and add "trace r" or "trace i" in front of your script to see what is going wrong.
daxb is offline  
Old 17 September 2023, 20:56   #93
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
Quote:
Originally Posted by daxb View Post
"src_entries.count" is just a string, hence SAY will print it as a string in upper case.
Does this mean that functions / procedures in ARexx always return string?

If so that would mean that something like this isn't possible:

Code:
/**/
p = createPersons()

Do i = 1 to Length(p)
  Say p.i.Name
End

exit


createPersons: procedure
  Person.1.Name = "Turanga Leela"
  Person.1.Postcode = 101

  Person.2.Name = "Bender Rodriguez"
  Person.2.Postcode = 823

  Person.3.Name = "Phillip J. Fry"
  Person.3.Postcode = 823

  return Person
Or would it somehow be possible?
thyslo is offline  
Old 17 September 2023, 22:44   #94
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
Quote:
Originally Posted by thyslo View Post
Does this mean that functions / procedures in ARexx always return string?
No. That only means that something went wrong because of programming mistake. So if you output a variable and the variable name is printed in upper case expecting something else you have to search for the error.
Quote:
If so that would mean that something like this isn't possible:
You can do this for example:
Code:
/**/
call createPersons()

Do i = 1 to Person.0
  Say Person.i.Name
End

exit


createPersons: procedure expose Person.
  Person.1.Name = "Turanga Leela"
  Person.1.Postcode = 101

  Person.2.Name = "Bender Rodriguez"
  Person.2.Postcode = 823

  Person.3.Name = "Phillip J. Fry"
  Person.3.Postcode = 823

  Person.0 = 3
  return
There are other methods doing this. ARexxGuide2 (Aminet) has a description of compound variables / stem variables that may help you for what you want to do.
daxb is offline  
Old 09 October 2023, 08:44   #95
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
Howto bring Workbench to front with ARexx

For a DOpus 5.82 ARexx script I need to explicitly bring the Workbench screen to front and switch back to DOpus after a while.

To bring DOpus to the foreground, there is a command in its ARexx port: 'dopus front'.

But what could I do to bring the Workbench screen to front?

(I have OS3.2 and could use its Workbench ARexx port for this. Unfortunately I have not found accurate documentation for it. But in the Workbench ARexx port for OS4 there seems to be no such function.)

Last edited by thyslo; 09 October 2023 at 13:37.
thyslo is offline  
Old 09 October 2023, 14:38   #96
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
I haven't tried but "WINDOWTOFRONT root" should do what you want: https://wiki.amigaos.net/wiki/Workbe...OFRONT_command
daxb is offline  
Old 09 October 2023, 19:43   #97
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
Yes this works! I had overlooked that in the api document.

Thank you
thyslo is offline  
Old 04 December 2023, 08:15   #98
blasterreal
Registered User
 
Join Date: Jan 2010
Location: turkey
Posts: 30
Hello, I don't know much about Arexx scripts, but there is something I want to ask. For example, I opened the "work: application/myprog/crate" drawer and is it possible to copy the path to this drawer and create a script?

Solved my solution

Code:
/* Get directory */


IF ~SHOW(LIBRARIES,'rexxtricks.library') THEN
     IF ~ADDLIB('rexxtricks.library',9,-30,38) THEN
        quit('Cannot open rexxtricks.library!',10)

OPTIONS RESULTS

ADDRESS WORKBENCH

GETATTR OBJECT WINDOWS.ACTIVE

ACTIVEWINDOW = RESULT

/*SAY 'Directory = ' RESULT*/

IF WRITECLIPBOARD(0, RESULT) THEN
    EXIT
ELSE
    SAY 'ERROR wirting to clipboard'

Last edited by blasterreal; 04 December 2023 at 11:42.
blasterreal is offline  
Old 04 December 2023, 14:11   #99
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
With "GETATTR OBJECT WINDOWS.ACTIVE" you get the name of the active window. Is the window name = full path? If yes and you want to save the result in a variable you can use this for example:

Code:
GETATTR OBJECT WINDOWS.ACTIVE VAR activewindowname
SAY activewindowname
Don't forget to check for "" (empty string") if no window is currently active.

WRITECLIPBOARD() is not needed. I guess the next thing you need is GETDIR() from rexxtricks.library.
daxb is offline  
Old 19 December 2023, 21:11   #100
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
I have a problem with an ARexx script that is started from inside GoldEd. Its purpose is to start BlitzBasic and display a success (or failure, or 'is already ruinning') message in GoldEds status bar. Here's the whole script, and it contains some GoldEd boilerplate code at the start and at the end. My script content starts after the INSERT YOUR CODE HERE comment:

Code:
/* Open BlitzBasic/TED from GoldED */

options results                             /* enable return codes     */
if (left(address(), 6) ~= "GOLDED") then    /* not started by editor ? */
  address 'GOLDED.1'

'LOCK CURRENT RELEASE=4'                    /* lock GUI, gain access   */
if (RC ~= 0) then
  exit

options failat 6                            /* ignore warnings         */
signal on syntax                            /* ensure clean exit       */


/* ------------------------ INSERT YOUR CODE HERE: ------------------- */
  cmd_start_ted = 'run >NIL: <NIL: SYS:DevTools/BlitzBasic2/Blitz2'
  status_msg = 'TED already running.'

  ted_port = 'TED_REXX1'
  resources_loaded = 1

  /* Open rexxsupport.library, needed for msg related functions */
  if ~Show('LIBRARIES', 'rexxsupport.library') then do
     if ~AddLib('rexxsupport.library', 0, -30) then do
        status_msg = 'Failed to open rexxsupport.library.'
        resources_loaded = 0
     end
  end

  if resources_loaded = 1 then do
    if ~Show('PORTS', ted_port) then do
      address command cmd_start_ted
      loaded=0
      do for 25 while loaded=0
        Delay(15)
        if Show('PORTS', ted_port) then do
          loaded=1
          status_msg = 'Sucessfully loaded TED.'
        end
      end

      if loaded=0 then do
        status_msg = 'Failed to load TED.'
      end
    end
  end

  'REQUEST STATUS="'status_msg'"'

/* ---------------------------- END OF YOUR CODE ----------------------- */

'UNLOCK' /* unlock user interface   */
exit
SYNTAX:
SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
'UNLOCK'
exit
It works so far, it opens Blitz, but afterwards there is an error requester opened in GoldEd with the message: "Unknown command or script".

The error request doesn't appear if I comment out the line with the Delay(15).

This tells me that GoldEd wants to process the Delay(15). But this function, Delay(), isn't for GoldEd - it's a function of the rexxsupport.library that is opened a few lines above the Delay() call.

How can I manage that GoldEd doesn't want to process the Delay() but rexxsupport.library does instead?

Last edited by thyslo; 19 December 2023 at 21:19.
thyslo 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
AmigaDOS scripting resources Photon Coders. System 26 19 March 2018 14:51
Very Basic Scripting. Confused. marduk_kurios Coders. System 5 06 February 2014 11:13
UAE Scripting Layer FrodeSolheim support.FS-UAE 15 26 January 2014 15:56
C= 64 BASIC as a Scripting Language Charlie Retrogaming General Discussion 2 17 November 2008 14:23

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 11:13.

Top

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