English Amiga Board


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

 
 
Thread Tools
Old 20 December 2023, 06:55   #101
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,041
That's how Rexx works. Every value without context is sent to the current ARexx host. If it encounters a function call without context, it executes the function and sends the result to the host. If you don't want the result to be processed as a host command, you have to put it into a context.

For example assign the return value to a variable
Code:
x = Delay(15)
or use the CALL keyword
Code:
call Delay(15)
thomas is online now  
Old 20 December 2023, 08:18   #102
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 198
Thank you Thomas, now it works

And thanks for the explanation, too. Although I've red the ARexx manual this information passed me by.
thyslo is online now  
Old 20 December 2023, 14:07   #103
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,315
IMHO it would be better to use "waitforport" instead of the delay() loop. You also get shorter code. See ARexxGuide2 for an how to use example.
daxb is online now  
Old 21 December 2023, 06:14   #104
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 198
Thanks, daxb, I'll have a look at that. I'm always interested in better readable code.
thyslo is online now  
Old Today, 12:26   #105
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 198
While creating some scripts for GoldED I encountered some questions about ARexx strings & parsing. Maybe somebody here can help.

1) Is there a operation to access the character of a string by index? For example I tried
Code:
    s = 'Abc'
    char = s[0]
I expected that after this line 'char' contains the value 'A'. But the [] operation is not supported by ARexx. Is there a way to achieve this?

2) If char would contain 'A' is there a way/function to get the ascii code of it? Something like
Code:
    say asc(char)
    65
3) I try to parse a line that looks like this:
Code:
 '*** 	CALLxxDOS PutStr'
Note: After the 3 asterisks there is 1 space and 1 TAB character. I only want the 'CALLxxDOS PutStr' stored into a variable, err_context.

Tried it with:
Code:
    parse var line '*** ' err_context
    err_context = STRIP(err_context)
With this, err_context still containes the TAB character at the beginning.

So, how can the TAB character be parsed?
thyslo is online now  
Old Today, 12:30   #106
TCD
HOL/FTP busy bee
 
TCD's Avatar
 
Join Date: Sep 2006
Location: Germany
Age: 46
Posts: 32,286
Quote:
Originally Posted by thyslo View Post
1) Is there a operation to access the character of a string by index? For example I tried
Code:
    s = 'Abc'
    char = s[0]
I expected that after this line 'char' contains the value 'A'. But the [] operation is not supported by ARexx. Is there a way to achieve this?
https://wiki.amigaos.net/wiki/AmigaO...s#SUBSTR.28.29
TCD is offline  
Old Today, 13:52   #107
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,041
Quote:
Originally Posted by thyslo View Post
is there a way/function to get the ascii code of it?
Try c2d(char) or c2x(char) as you like.

Quote:
After the 3 asterisks there is 1 space and 1 TAB character.
try
Code:
parse value translate(line,' ','09'x) with '***' err_context

Quote:
So, how can the TAB character be parsed?
That's not what you want. You don't want to parse the tab character, you want to treat the tab as a space. If you want to parse the tab you can just put the tab in to the parse string. If order to treat it as a space you have to translate it into a space.
thomas is online now  
Old Today, 17:14   #108
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 198
Thank you, thomas, this works great:-)
thyslo is online now  
 


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 19:17.

Top

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