English Amiga Board


Go Back   English Amiga Board > Support > support.Other

 
 
Thread Tools
Old 08 July 2018, 12:44   #1
-Acid-
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?
-Acid- is offline  
Old 08 July 2018, 13:48   #2
daxb
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
There also exists the commands RequestChoice and RequestString if you need/want a requester.
daxb is offline  
Old 08 July 2018, 19:11   #3
-Acid-
Registered User
 
Join Date: Oct 2012
Location: South Shields
Posts: 812
Quote:
Originally Posted by daxb View Post
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
There also exists the commands RequestChoice and RequestString if you need/want a requester.
I need it stored in a file permanently so it can be checked every boot... temporary variables will not work.
-Acid- is offline  
Old 08 July 2018, 19:30   #4
jPV
Registered User
 
jPV's Avatar
 
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.
jPV is offline  
Old 09 July 2018, 15:02   #5
daxb
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.
daxb is offline  
Old 09 July 2018, 19:44   #6
nogginthenog
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.
nogginthenog is offline  
Old 09 July 2018, 20:34   #7
-Acid-
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.
-Acid- 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
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

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

Top

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