English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 22 November 2011, 02:10   #1
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
AmigaDOS scripting resources

Post your tips, manual links, and above all examples here. It would also be nice with an overview guide regarding how it all hangs together (Thomas? )
Photon is offline  
Old 22 November 2011, 09:07   #2
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
I don't know very much about this stuff but there is this manual:

http://amiga-manuals.xiik.net/ebooks...0eBook-ENG.rar

It has a whole chapter (Chapter 5) on Command Sequence Files (scripts) for AmigaDOS.
pmc is offline  
Old 22 November 2011, 19:20   #3
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Looks like a good entry book even for those who don't yet grasp RAD PIPEs!

Thanks pmc
Photon is offline  
Old 24 December 2017, 10:33   #4
kolla
Banned
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
Not much here

I am sometimes asked how one can put user input into a variable, well, this is one way:

Code:
Echo noline "What is your name? "
Set >NIL: answer ?
Echo "Hello, $answer"
kolla is offline  
Old 24 December 2017, 14:41   #5
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
Is that somewhere documented? The magic with "?".
daxb is offline  
Old 24 December 2017, 16:40   #6
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
I am quite sure that one of the very first things explained in the AmigaDOS manual is that you get a template of the command's parameters if you enter a question mark and it then waits for input so you can enter only the missing/wrong arguments and don't have to re-enter the whole command.

Hiding the template and using the input in a script is a nice trick but surely no magic.
thomas is offline  
Old 24 December 2017, 17:19   #7
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
I wasn't sure if the "?" does something special in this case or it is "just" the command template thing. Yes, the trick is nice but I would never find this solution by myself without documentation. I don't know if an other way is described in AmigaDOS manual.
daxb is offline  
Old 25 December 2017, 03:24   #8
kolla
Banned
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
Sure there are others ways, like the shell internal "ask" command, which I'm sure is documented...
Code:
Ask "What is your name? " string to answer
Echo "Hello, $answer"
but it is either buggy, or at least very quirky, as it doesn't accept multiple words in the answer.
kolla is offline  
Old 25 December 2017, 14:49   #9
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,303
Yes, "Ask" is more or less for Yes/No questions.

I think it is well known but the backtick "trick"/function is sometimes nice:
Code:
Set file `RequestFile`
Echo "Your choice: $file"
First, RequestFile is evaluated then "Set file".

The char in front of and after RequestFile must be backticks. I pressed Shift + '`-key then Space. On my german pc keyboard it is the key right of ß key. I don't know if that is correct.
daxb is offline  
Old 25 December 2017, 15:38   #10
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
Quote:
Originally Posted by kolla View Post
but it is either buggy, or at least very quirky, as it doesn't accept multiple words in the answer.
This must be a custom version of the Ask command. The one which comes with the OS does not have these options.

Code:
1> ask ?
PROMPT/A:
thomas is offline  
Old 25 December 2017, 15:50   #11
kolla
Banned
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
Quote:
Originally Posted by thomas View Post
This must be a custom version of the Ask command. The one which comes with the OS does not have these options.

Code:
1> ask ?
PROMPT/A:
This is shell 45.39, I always use the latest version from ThoR
kolla is offline  
Old 25 December 2017, 15:55   #12
kolla
Banned
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
Quote:
Originally Posted by daxb View Post
Yes, "Ask" is more or less for Yes/No questions.
Yes, it is rather primitive, room for improvements (a "HIDDEN/S" option, or "STAR/S" option, for passwords, for example).

Quote:
I think it is well known but the backtick "trick"/function is sometimes nice:
Code:
Set file `RequestFile`
Echo "Your choice: $file"
First, RequestFile is evaluated then "Set file".

The char in front of and after RequestFile must be backticks. I pressed Shift + '`-key then Space. On my german pc keyboard it is the key right of ß key. I don't know if that is correct.
Yup, the Request#? commands are very useful for adding simple GUI to scripts.
kolla is offline  
Old 25 December 2017, 16:18   #13
kolla
Banned
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
Must have shell extension tools from Aminet:

http://aminet.net/package/util/shell/Pipe-1.5
http://aminet.net/package/util/shell/EArg

Makes it possible to, for example, do things like...
Code:
List all files p=#?.info lformat "%p%m" | earg "ProcessIcon MWB2CI"
(convert all icons in current directory from magicwb to ColorIcon format (OS3.5+), using ProcessIcon - which also is on aminet)

Last edited by kolla; 25 December 2017 at 16:33.
kolla is offline  
Old 26 December 2017, 12:21   #14
jPV
Registered User
 
jPV's Avatar
 
Join Date: Feb 2008
Location: RNO
Posts: 1,006
Quote:
Originally Posted by kolla View Post
Code:
List all files p=#?.info lformat "%p%m" | earg "ProcessIcon MWB2CI"
(convert all icons in current directory from magicwb to ColorIcon format (OS3.5+), using ProcessIcon - which also is on aminet)
This will probably fail with filenames containing spaces, so I'd add quotation marks there in the lformat string (you'll have to escape them with *):
Code:
List all files p=#?.info lformat "*"%p%m*""
But all this can be done without any external utils (or two!) with just by standard AmigaDOS commands. Let's first create a script/batch file with the List command and then execute it with the Execute command. This way you can also check the contents of the created script file that it all looks good before executing it for real (you usually make mistakes at first try):

So, here's a modified version using just the standard commands, and I'd prefer doing it this way:
Code:
List all files p=#?.info lformat "ProcessIcon MWB2CI *"%p%m*"" > T:MyBatchConvertScript
Execute T:MyBatchConvertScript
The standard List command is just great for doing automated script files! Too bad its powerfulness is ofter overlooked... and in worst case people write custom 3rd party commands just for the same.


About the original question about manuals or resources, I think the best starting point is just read the official Amiga manuals which you either got with the machine or on CD (3.5/9). I've learned all I know about Amiga Shell and its scripts just by reading that single AmigaDOS manual The official OS3.9 HTML manual is just fine to keep open on a browser when writing scripts. You don't practically need anything else to understand what you can do.
jPV is offline  
Old 26 December 2017, 16:46   #15
kolla
Banned
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
Yes, hehe, as expected. I kinda knew using List output as example was a bad choice, since it already does text formatting using LFORMAT, that wasn't really what I wanted to illustrate
kolla is offline  
Old 26 December 2017, 17:15   #16
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Andy Finkel (ex-Commodore) has made a useful "for each in" command: http://aminet.net/package/util/cli/finkelshelltoo

There is also an alternative here: http://aminet.net/package/util/cli/foreach
idrougge is offline  
Old 26 December 2017, 17:19   #17
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Aside of the fact the above script removes ".info" from the file names, it could be done with standard SPat script present in "S" dir :
Code:
s:spat ProcessIcon #?.info MWB2CI
meynaf is offline  
Old 26 December 2017, 20:04   #18
kolla
Banned
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
Quote:
Originally Posted by meynaf View Post
Aside of the fact the above script removes ".info" from the file name
Intentionally

Quote:
it could be done with standard SPat script present in "S" dir :
Code:
s:spat ProcessIcon #?.info MWB2CI
Except that I think ProcessIcon only takes the "mother file", and not the .info file as argument, from what I remember. Anyhow - it was merely a SIMPLE example, next time I will make sure to use an very complicated example.

Here is a challenge - make a commandline that uses processicon _only_ on directories, and _not_ files.
kolla is offline  
Old 26 December 2017, 20:32   #19
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by kolla View Post
Intentionally
Of course, else i wouldn't have told about it.


Quote:
Originally Posted by kolla View Post
Except that I think ProcessIcon only takes the "mother file", and not the .info file as argument, from what I remember. Anyhow - it was merely a SIMPLE example, next time I will make sure to use an very complicated example.
I don't think this is the place for complex scripting challenges.
I just told about SPat, specifying the difference would be it does not remove the ".info". Please don't take it as a criticism of what you wrote, it wasn't the intent at all


Quote:
Originally Posted by kolla View Post
Here is a challenge - make a commandline that uses processicon _only_ on directories, and _not_ files.
Single line command, nope - would do it with a two-liner script.
meynaf is offline  
Old 26 December 2017, 20:57   #20
kolla
Banned
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
Quote:
Originally Posted by meynaf View Post
I don't think this is the place for complex scripting challenges.
I just told about SPat, specifying the difference would be it does not remove the ".info". Please don't take it as a criticism of what you wrote, it wasn't the intent at all
No worries, no offence taken, I just forgot to add a smiley, was on my phone

My idea was to give a hint about a nice tool that can build and run lines from stdin

Quote:
Single line command, nope - would do it with a two-liner script.
You would think, right? Just a list dirs with lformat, and voila?
Except, there are a few dragons:
- only dirs with corresponding .info files are wanted
- %p expands to a string with trailing /

Thre latter may explain why there sometimes are files named just ".info" here and there

Last edited by kolla; 26 December 2017 at 21:05.
kolla 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
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
AmigaDOS 1.3 Scripting Language redblade Coders. General 10 16 August 2008 12:58
Resources?? DDNI project.WHDLoad 5 25 April 2007 20:42

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 00:18.

Top

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