English Amiga Board


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

 
 
Thread Tools
Old 17 July 2015, 14:21   #61
BigFan
Registered User

BigFan's Avatar
 
Join Date: Feb 2014
Location: Germany
Posts: 261
Exercise:

Above code translates characters 00 - 1f, but what happens when displaying
values bigger 128 ($80). Add a set of characters to be replaced to avoid unwanted line breaks.
BigFan is offline  
AdSense AdSense  
Old 01 August 2015, 22:17   #62
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 1,928
I guess you haven`t posted an example of how to get output of external commands using RXSET. Recently I tried this (works):
Code:
ADDRESS COMMAND
cmd = 'C:WHDLoad'

'RXSET' verstr '`Version' cmd'`'   /* Set version string to clip "verstr" */
str = GETCLIP(verstr)              /* Get the clip */
CALL SETCLIP(verstr)               /* Delete the clip else it will stay until a reboot */
The single quotation marks are a bit confusing for me.
daxb is offline  
Old 01 August 2015, 23:53   #63
BigFan
Registered User

BigFan's Avatar
 
Join Date: Feb 2014
Location: Germany
Posts: 261
That's a clever trick to store DOS results in global cliplist.
AmigaOS isn't case sensitive and you are allowed to use double quotes if readability is a problem.

Code:
/**/
ADDRESS COMMAND
cmd = 'C:lha'

rxset verstr "`"version cmd"`"   /* Set version string to clip "verstr" */
str = GETCLIP(verstr)              /* Get the clip */
say str
SETCLIP(verstr)               /* Delete the clip else it will stay until a reboot */
You don't need to reboot. Either call rxset (to clear one entry) or rxc (to close rexxmast) from shell. Remember Rexx is using upper case for symbols, so :> rxset VERSTR will kill the clip.

This might work with Requestfile as well.
BigFan is offline  
Old 02 August 2015, 01:05   #64
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 1,928
I forgot to mention that it is "only" an alternative to redirect to x, OPEN() x and read it, if you don`t want to use it for some reason.

It seems so that you havn`t to use the external command RXSET. Following works too:
Code:
CALL SETCLIP('verstr', '`version c:whdload`')
Next I forgot that is recommendable to use SHOW('C', 'clip') to check if the clip already exists. Else you could accidentally overwrite an existent clip what is used by other scripts. Probability is low but murphy...
daxb is offline  
Old 02 August 2015, 15:35   #65
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 1,928
From Shell this works (version string is in clip):
Code:
rx "cmd='`version c:lha`'; CALL SETCLIP('verstr', cmd); SAY GETCLIP('verstr')"
From inside script this doesn`t work:
Code:
cmd='`version c:lha`'
CALL SETCLIP('verstr', cmd)
SAY GETCLIP('verstr')
Output is just the string "`version c:lha`". Is there a way that it works? Maybe with interpret or something like that.
daxb is offline  
Old 02 August 2015, 16:34   #66
BigFan
Registered User

BigFan's Avatar
 
Join Date: Feb 2014
Location: Germany
Posts: 261
I doubt it will work any other way than calling or invoking with shell involved. The "`" is interpreted by cli not by Rexx. It forces command interpreter to use returned output.
In :>rx "cmd='`version c:lha`' .... the symbol is initialized with "lha 2.1" not with "version c:lha" as this is what cli reads and executes before rx is invoked with argument string.

This
Quote:
Originally Posted by daxb View Post
Code:
CALL SETCLIP('verstr', '`version c:whdload`')
will not work in a Rexx script because of those "slanted apostrophes". Rexx can't interprete this, you have to submit it using quotes or it is an unidentified token. If you do so, it is handled as a string, thus you don't get the result of version command but "version c:whdload" as cliplist entry.

Last edited by BigFan; 02 August 2015 at 16:50.
BigFan is offline  
Old 29 January 2018, 16:29   #67
Fjolsvith
Registered User

Fjolsvith's Avatar
 
Join Date: Jan 2018
Location: Norcatur, Kansas, USA
Posts: 7
So hey, I know this is an old post, but I'm having a problem with the Open() and ReadLN() ARexx commands. I'm getting the message

**** Error 13 in line #: Host Environment Not Found

on the line that has:

Open('infile',tempfile,'r')

Tempfile is set

tempfile='t:binkdstatus'

and the file 't:binkdstatus' exists and has about 40+ lines of text.

I'm running the AmiKit X version of WinUAE and its supposed to have DirectoryOpus installed.

Last edited by Fjolsvith; 29 January 2018 at 16:36.
Fjolsvith is offline  
Old 29 January 2018, 16:41   #68
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,546
total arexx noob here, but thinking about sys:system/rexxmast has to run?
if not, just ignore the above
emufan is offline  
Old 29 January 2018, 17:27   #69
Fjolsvith
Registered User

Fjolsvith's Avatar
 
Join Date: Jan 2018
Location: Norcatur, Kansas, USA
Posts: 7
What I'm trying to do is write a script that checks to see if binkd is running (using Status) and then relaunch it if not. Binkd shuts itself down on my system after a session, for some reason.

I was sending the output of Status to t:binkdstatus. Then I was going to ReadLN that file and look for the binkd program. If it was running, the script would wait 5 minutes and then repeat. If not, launch binkd and then wait 5 minutes and repeat.
Fjolsvith is offline  
Old 29 January 2018, 18:07   #70
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 1,928
Try "CALL Open('infile',tempfile,'r')" or "myRC = Open('infile',tempfile,'r')". Don't forget to close "infile" later.

Maybe it is better to use SETCLIP() and GETCLIP() instead, to avoid r/w to file.
daxb is offline  
Old 29 January 2018, 20:22   #71
Fjolsvith
Registered User

Fjolsvith's Avatar
 
Join Date: Jan 2018
Location: Norcatur, Kansas, USA
Posts: 7
Can you read just a line of text with GetClip()?
Fjolsvith is offline  
Old 29 January 2018, 20:26   #72
Fjolsvith
Registered User

Fjolsvith's Avatar
 
Join Date: Jan 2018
Location: Norcatur, Kansas, USA
Posts: 7
This is the code I'm trying to get to work:

Code:
Options RESULTS

address 'status >t:binkdstatus'
tempfile='t:binkdstatus'
CALL Open('infile',tempfile,'r')

foundbinkd='false'
do while ~EOF('infile')
  text=ReadLn('infile')
  text=SUBSTR(text, 30)
  if text='binkd' then found='true'
end
Close('infile')
Fjolsvith is offline  
Old 29 January 2018, 22:58   #73
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 1,928
Change
Code:
address 'status >t:binkdstatus'
to
Code:
address command 'status >t:binkdstatus'
and maybe better use "status com=binkd >t:binkdstatus". If binkd is active result is the process number, else nothing. So you get a one liner.
daxb is offline  
Old 30 January 2018, 02:02   #74
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,328
Quote:
Originally Posted by daxb View Post
Try "CALL Open('infile',tempfile,'r')" or "myRC = Open('infile',tempfile,'r')". Don't forget to close "infile" later.
No need to close files. ARexx does that automatically.
idrougge is offline  
Old 30 January 2018, 20:19   #75
Fjolsvith
Registered User

Fjolsvith's Avatar
 
Join Date: Jan 2018
Location: Norcatur, Kansas, USA
Posts: 7
Alright, it still doesn't open the file. Here is the code:

Code:
Options RESULTS
Address COMMAND 'status com=binkd >t:binkdstatus'

foundbinkd='false'
If OPEN('infile', 't:binkdstatus' 'READ') = 1 then 
	if LINES('infile') = 1 then foundbinkd='true'
say foundbinkd
Close('infile')
if foundbinkd = 'false' then Address COMMAND 'binkd -s mail:binkd/binkd.cfg'
It runs binkd every time, even though binkd is already running. It writes the CLI number to the file 'binkdstatus'. But OPEN doesn't ever return 1.
Fjolsvith is offline  
Old 30 January 2018, 23:09   #76
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 1,928
@idrougge:
Yes, I know and in this case it isn't needed but I didn't knew the script and if you do some more stuff it is necessary.

@Fjolsvith:
I think it can't work this way. First, make sure that the COM= string is correct. Type status in shell to see the correct one. E.g. it could be COM=C:binkd or something else. Depends on how it was started. Second you need to evaluate the contend of t:binkdstatus like you did before with READLN(). Maybe it is enough to check if it is empty (binkd not running) then launch it.
daxb is offline  
Old 30 January 2018, 23:22   #77
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,328
Code:
ADDRESS COMMAND 'Status COM=binkd >NIL:'
IF RC=5 THEN ADDRESS COMMAND 'binkd -s mail:binkd/binkd.cfg'
idrougge is offline  
Old 31 January 2018, 00:40   #78
Fjolsvith
Registered User

Fjolsvith's Avatar
 
Join Date: Jan 2018
Location: Norcatur, Kansas, USA
Posts: 7
Quote:
Originally Posted by idrougge View Post
Code:
ADDRESS COMMAND 'Status COM=binkd >NIL:'
IF RC=5 THEN ADDRESS COMMAND 'binkd -s mail:binkd/binkd.cfg'
I love you always! You can have my first born! It works!
Fjolsvith is offline  
Old 15 February 2018, 22:09   #79
Martijn
Registered User

 
Join Date: Jan 2018
Location: Utrecht, NL
Posts: 15
Hi, I've had an amiga for over 30 years, so I thought it's about time to write my first Arexx script... :-)

But seriously, I've dug out my Amiga again, and now I'm trying to write a little script for DirOpus (4) to replace an icon with another icon while preserving defaulttool and tooltypes (using rexxtricks.library functions). It's all working pretty well thanks to some hints in this thread. The only thing missing is that when I've deleted the destination icon, replaced it with the new icon and put back the properties, the destination window does not show the icon file until I manually refresh, ie. DirOpus does notice that I deleted a file (I do that with a diropus command) but doesn't notice I put it back (I call the CLI for that, because using the diropus copy command asks me if I want to replace, even though the file is already gone). A couple of questions:
- Is there a command to refresh the directory listing?
- Is there a way to let the copy command automatically overwrite?

Or maybe all of my questions could be answered by:
- Is there a list of commands, syntax and params for DirOpus Arexx commands?
Martijn is offline  
Old 15 February 2018, 22:19   #80
emufan
Registered User
 
Join Date: Feb 2012
Location: #DrainTheSwamp
Posts: 4,546
no idea, but there is a manual for 5.5 which lists arexx commands.
emufan is offline  
AdSense AdSense  
 


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 14:30.


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