05 August 2015, 11:54 | #1 |
Registered User
Join Date: Jan 2014
Location: BO/Italy
Posts: 711
|
AmigaDos script help
Hello all!
Inspired by this thread where Retrofan adds a nice "tool" for RealAmikit users, I decided to create a small script to do the same (pick a game randomly and execute it through WHDLoad) for a "standard" Workbench. Once obtained the list of my games (to be precise the list of my .slave files) and "formatted" it the way I needed (actually Retrofan did the difficult part ) I had to find some programs able to execute randomly a line from a file. I found two programs that do this quiet efficiently: pickfile and randome . So the script was quite easy (please, keep in mind that I am a beginner in AmigaDos scripting) and it works very well when launched from CLI: Code:
; Play Random Game .KEY PRG IF NOT EXISTS RAM:prg.list list Data:WHDLoad/#?/#?/#?.slave >RAM:prg.list lformat="cd *"%p*" && WHDLoad *"%n*" PRELOAD" C:pickfile F=RAM:prg.list ;C:RandomE RAM:prg.list Times=1 ELSE C:pickfile F=RAM:prg.list ;C:RandomE RAM:prg.list Times=1 ENDIF Code:
(...) cd "Data:WHDLoad/R/RevengeOfDefender/" && WHDLoad "RevengeOfDefender.slave" PRELOAD cd "Data:WHDLoad/R/RickDangerous2/" && WHDLoad "RickDangerous2.slave" PRELOAD cd "Data:WHDLoad/R/RiseOfTheDragon/" && WHDLoad "RiseOfTheDragon.Slave" PRELOAD cd "Data:WHDLoad/R/RiskyWoods/" && WHDLoad "RiskyWoods.Slave" PRELOAD cd "Data:WHDLoad/R/Rockford/" && WHDLoad "Rockford.slave" PRELOAD cd "Data:WHDLoad/R/RainbowWarrior/" && WHDLoad "RainbowWarrior.Slave" PRELOAD cd "Data:WHDLoad/R/RickDangerous/" && WHDLoad "RickDangerous.Slave" PRELOAD (...) The problem arises when I want to execute this script from Workbench. I created a .info file for the script and modified it in order to execute the script with "C:IconX" but I always receive an error. The creation of the list works well but when the script tries to execute a line it gives me the following errors: Using randome Code:
Error executing cd "Data:WHDLoad/R/Rockford/" && WHDLoad "Rockford.slave" PRELOAD Code:
cd "Data:WHDLoad/R/Rockford/" && WHDLoad "Rockford.slave" PRELOAD Wrong Number of Arguments cd failed return code 20 Any help would be very appreciated! Thanks in advance! PS: This is the original script from Retrofan: Code:
list >ram:startgame "`randomfile Work:Games/#?/#?/#?.slave Sys:Utilities/EXPANSION/Opus5/Sounds/BootSounds/Trackingfile2`" lformat="cd *"%p*"*nWHDLOAD *"%n*" PRELOAD" execute ram:startgame |
05 August 2015, 22:01 | #2 |
R.I.P Smudge 18-08-16
Join Date: Aug 2005
Location: Leicester/UK
Age: 66
Posts: 3,968
|
Can you drop the 'lformat="cd' from the scrpt?
|
05 August 2015, 22:22 | #3 |
Registered User
Join Date: Jan 2014
Location: BO/Italy
Posts: 711
|
|
05 August 2015, 23:49 | #4 |
Registered User
Join Date: Jan 2014
Location: BO/Italy
Posts: 711
|
No luck...
I modified the script this way: Code:
list Data:WHDLoad/#?/#?/#?.slave >RAM:prg.list lformat="C:WHDLoad %p*%n* PRELOAD" Code:
C:WHDLoad Data:WHDLoad/R/RiseOfTheDragon/RiseOfTheDragon.Slave PRELOAD Code:
WHDLoad 18.1 DOS ERROR 205 Object Not Found: Last edited by liviux76; 06 August 2015 at 00:18. |
06 August 2015, 09:44 | #5 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,033
|
Check your s:shell-startup file, it probably contains something like
set _mchar "&&" You have to put this at the beginning of your script, too. Otherwise it is not possible to execute two commands from one line. And if you want to share your script with others, you have to tell them that they need the Pipe command. http://aminet.net/package/util/shell/Pipe-1.5 |
06 August 2015, 11:02 | #6 |
Registered User
Join Date: Jan 2014
Location: BO/Italy
Posts: 711
|
@thomas
hey man! You did it! Yes, I did install pipe a few days ago but I didn't know that the "&&" was working in the shell for that reason. Adding the string you suggested at the top of the script (just after .KEY PRG) did the trick and now it works even when run through iconx. I haven't decide yet if using randome or pickfile, both seem to work well. |
26 January 2017, 19:53 | #7 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Help!!!
Rather than open a new thread, can someone please remind me how to use the CONTENTS of a file as a pointer... To explain I have a file located at RAM:somedata.dat That file contains the following string DH0:PROJECTS/someproject.prj In my script I want to do something like... IF EXISTS RAM:somedata.dat someapp.exe (the contents of)RAM:somedata.dat EndIF with the end result being .. someapp.exe DH0:PROJECTS/someproject.prj someapp.exe is an application which needs someproject.prj to work with. In the 90's I would have sorted this in seconds, but time & alcohol has taken it's toll on my grey matter. TIA for any help |
26 January 2017, 20:05 | #8 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,033
|
If you put the file into ENV: rather than RAM: you could use
someapp.exe ${somedata.dat} For a general file containing just one line you could use Type: someapp.exe `type RAM:somedata.dat` `is a left-directed accent (French "accent grave"). |
09 November 2017, 16:20 | #9 |
Banned
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,893
|
Also known as "back-tick".
I have been wanting to ask ThoR if he may consider an alternative to back-ticking, since it so often is confusion with the trio of `'ยด. Posix shells has since long now used $(command), which is so much easier to communicate |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
RebootStart script help! | Overkill | support.Other | 43 | 23 April 2013 17:52 |
Execute a script | frikilokooo | project.ClassicWB | 6 | 20 November 2007 11:36 |
AmigaDos script file help. | T_hairy_bootson | support.Apps | 0 | 07 March 2006 10:15 |
The zone script | fairchild | project.EAB | 3 | 21 April 2005 20:28 |
New Installer Script | BenniP | request.UAE Wishlist | 16 | 22 June 2004 09:55 |
|
|