08 July 2018, 12:44 | #1 |
Registered User
Join Date: Oct 2012
Location: South Shields
Posts: 812
|
Script help
I'm trying to make a startup system which checks the value of something before deciding which script to execute next.
How can I write and store a string somewhere on disk from within a script and then read the string from the file to determine which choice has been stored. I know I can use something as simple as c:echo choice1 >s:choice.txt to store it but then how would I go about reading the string in the file so my script knows what it is and then perform the appropriate action that I have set out? I spent last night looking through the script tools on Aminet but nothing seemed to be what I was looking for. Can someone point me in the right direction please? |
08 July 2018, 13:48 | #2 |
Registered User
Join Date: Oct 2009
Location: Germany
Posts: 3,303
|
Have a look into AmigaDOS manual. If you need it at runtime (local) you can use the commands SET and GET. If not (i.e. global) you can use SETENV and GETENV.
Code:
; example works only local: set mychoice 1 IF $mychoice EQ 1 echo "1" ELSE echo "not 1" ENDIF |
08 July 2018, 19:11 | #3 | |
Registered User
Join Date: Oct 2012
Location: South Shields
Posts: 812
|
Quote:
|
|
08 July 2018, 19:30 | #4 |
Registered User
Join Date: Feb 2008
Location: RNO
Posts: 1,006
|
Remove the "set mychoice 1" line from the previous script and then do:
Echo "1" > ENVARC:mychoice This works if you're not going to use the script before ENV: has been set. If you want to change the value in runtime before reboot, then do the same to ENV: too. |
09 July 2018, 15:02 | #5 |
Registered User
Join Date: Oct 2009
Location: Germany
Posts: 3,303
|
If you using OS3.1 then what jPV wrote. If you use OS3.9 then you can use SETENV/GETENV with its SAVE argument to save the variable in ENVARC:. Of course needs to be there what might not the case at boot time.
|
09 July 2018, 19:44 | #6 |
Amigan
Join Date: Feb 2012
Location: London
Posts: 1,309
|
Another possible solution is to use the SEARCH cli command. IIRC it sets the return code depending if the match was found.
|
09 July 2018, 20:34 | #7 |
Registered User
Join Date: Oct 2012
Location: South Shields
Posts: 812
|
I've managed to achieve what I was looking for with a combination of the advice given earlier in the thread
I store my string in a text file on disk called boot which I can change using the echo command from a menu. Then on start up assign env: to ram and then copy my file to it before anything else. Then use If $boot EQ example1 delete env:boot assign env: remove execute something SKIP end Else SKIP item2 EndIF LAB item2 If $boot EQ example2 delete env:boot assign env: remove execute something SKIP end Else SKIP item3 EndIF LAB end QUIT You get the idea.... thanks to those who gave suggestions. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AmigaDos script help | liviux76 | Coders. Scripting | 8 | 09 November 2017 16:20 |
RebootStart script help! | Overkill | support.Other | 43 | 23 April 2013 17:52 |
Execute a script | frikilokooo | project.ClassicWB | 6 | 20 November 2007 11:36 |
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 |
|
|