![]() |
![]() |
#1 |
Registered User
Join Date: Aug 2020
Location: Germany
Posts: 18
|
AmigaDos 1.3 Ask with User Input into Variable
Hi,
i would like to code a Question asking about what Drive to use as source and the same as destination (df0: df1: etc..) I use a normal Workbench 1.3 Shell Script executed over IconX. My Problem is this Script won´t accept set or unset and requestchoice and my Workbench 1.3 Shell also. It´s a script for Disksalv to make it easy to use and more comfortable. In Picture i have the part of the code i coded to ask for Formatted Disk in Destination drive or not. But how to save the user input into a variable and Ask a Question without only y and n ? |
![]() |
![]() |
#2 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Code:
Echo "Which drive?" Set >nil: drive ? Echo $drive Edit: Or not as I missed the "1.3" requirement. |
![]() |
![]() |
#3 |
Registered User
Join Date: Jul 2008
Location: Boston, MA
Posts: 948
|
This isn’t a direct answer to your question, but I think DiskSalv can be controlled pretty well through project icons and tooltypes, so that might be another way to achieve what you’re trying to do.
|
![]() |
![]() |
#4 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 4,993
|
@starfox : Adapt, shorten, optimize, etc... it to you needs
![]() ![]() |
![]() |
![]() |
#5 |
Registered User
Join Date: Aug 2020
Location: Germany
Posts: 18
|
Thanks to all this helps me very much
![]() |
![]() |
![]() |
#6 |
Registered User
Join Date: Aug 2020
Location: Germany
Posts: 18
|
Additional Question:
Is there any way to Display 2 Variables in 1 Line or put 2 variables together ? My destination is to Display "diksalv var1 var2" |
![]() |
![]() |
#7 |
Registered User
Join Date: Aug 2020
Location: Germany
Posts: 18
|
I have created a solution for my Script.
Feel free to Optimize it. Code:
.key "" .bra { .ket } echo "***** Disksalv 1.42 Disketten Rettungs Tool ******" echo "" echo "** Disksalv rettet Daten von einer beschädigten **" echo "** Quell-Diskette und kopiert diese auf eine **" echo "** frisch formatierte Ziel-Diskette. **" IF NOT EXISTS Disksalv echo "Fehler Programm Disksalv nicht gefunden !" echo "Programm wird beendet." wait 1 ENDCLI ENDIF LAB Question echo "" echo "Bitte wählen Sie das Quell-Laufwerk und Ziel-Laufwerk" echo "1 = QUELLE df0: ZIEL df1:" echo "2 = QUELLE df1: ZIEL df0:" echo "3 = QUELLE df1: ZIEL df2:" echo "4 = QUELLE df2: ZIEL df1:" echo "5 = QUELLE df0: ZIEL df2:" echo "6 = QUELLE df2: ZIEL df0:" SETENV >NIL: choice ? IF $choice NOT VAL GT 0 echo "Falsche Eingabe bei der Auswahl des Quell und Ziel Laufwerks." wait 1 SKIP BACK Question ENDIF IF $choice GE 7 echo "Falsche Eingabe bei der Auswahl des Quell und Ziel Laufwerks." wait 1 SKIP BACK Question ENDIF IF $choice VAL EQ 1 ask "*N Die Ziel-Diskette vorher formatieren ? (y/n)" IF WARN disksalv df0: df1: FORMAT echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ELSE disksalv df0: df1: echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ENDIF ENDIF IF $choice VAL EQ 2 ask "*N Die Ziel-Diskette vorher formatieren ? (y/n)" IF WARN disksalv df1: df0: FORMAT echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ELSE disksalv df1: df0: echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ENDIF ENDIF IF $choice VAL EQ 3 ask "*N Die Ziel-Diskette vorher formatieren ? (y/n)" IF WARN disksalv df1: df2: FORMAT echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ELSE disksalv df1: df2: echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ENDIF ENDIF IF $choice VAL EQ 4 ask "*N Die Ziel-Diskette vorher formatieren ? (y/n)" IF WARN disksalv df2: df1: FORMAT echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ELSE disksalv df2: df1: echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ENDIF ENDIF IF $choice VAL EQ 5 ask "*N Die Ziel-Diskette vorher formatieren ? (y/n)" IF WARN disksalv df0: df2: FORMAT echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ELSE disksalv df0: df2: echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ENDIF ENDIF IF $choice VAL EQ 6 ask "*N Die Ziel-Diskette vorher formatieren ? (y/n)" IF WARN disksalv df2: df0: FORMAT echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ELSE disksalv df2: df0: echo "Rettung der Diskette abgeschlossen." echo "Programm wird geschlossen." wait 5 ENDCLI ENDIF ENDIF |
![]() |
![]() |
#8 | |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 4,993
|
Quote:
![]() Last edited by malko; 17 August 2020 at 01:08. Reason: typo |
|
![]() |
![]() |
#9 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 4,993
|
![]()
While browsing a folder containing some files I stumbled across an 'HD install' script I made (WB 1.3 - not using the 'Installer' scripting language, only WB 1.3 commands).
The script was small and worked but I remember not being really happy with it. Especially because I wasn't able to use wanted variables so the script kind of 'forced' some choices... It was of no importance but re-reading it made me think that a better solution could be found. Thus, I tried to rewrite it with the goal of being able to use variables on this WB 1.3 script. My main concern was to pass the variable to the 'copy' command. I tried some redirections, pipes but with no luck (maybe it's possible but my command was incorrect ?) So I began to think about a workaround. After some thinking, a strange idea came to my mind... and it worked ![]() Here is my summarized solution : Code:
[...] ;create the variable in ENV:SRC if [...] setenv SRC "DF0:" else if [...] setenv SRC [...] else if [...] setenv SRC [...] else if [...] setenv SRC [...] endif endif endif endif [...] ;the following line is part of the solution echo >t:cpdme "1CL//" ;create an intermediate script containing the 'copy' command which use the predefined variable echo >t:cpdm "copy " NOLINE getenv >>t:cpdm SRC echo >>t:cpdm " TO {DEVICE}{PATH} ALL CLONE QUIET" NOLINE ;calling edit in 'stealth' mode to remove the linefeed that has been added by the getenv concatenation edit FROM t:cpdm TO t:cpdm. WITH t:cpdme delete t:cpdm t:cpdme execute t:cpdm. [...] ![]() Last edited by malko; 11 October 2021 at 00:26. |
![]() |
![]() |
#10 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,302
|
Quote:
If you want argument substitution, then "execute" is your other candidate which does that on a primitive "text-substitution" basis of the "arguments" passed into a script. |
|
![]() |
![]() |
#11 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 4,993
|
Thank you Thomas for the precisions.
BitD I have learnt the hard way, with a lot of frustration, that the 1.3 Shell was not able to 'expand' the "$<variable_name>" but in the other hand I always found strange that the 'Execute' command that is used to launch a script didn't implement such a parser. Fortunately, BitD ARP for 1.3 addressed some of the 1.3 youth errors. |
![]() |
![]() |
#12 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,302
|
Well, argument substitution works with execute already in 1.3, just that the syntax is different, namely <variable name>, not with $variable name. Which nicely conflicts with I/O redirection, and is perfectly inconsistent with how "if" handles variables in 1.3.
The joy of Tripos, what else to say? |
![]() |
![]() |
#13 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 4,993
|
Argument substitution of the parameters provided to the script (".key"), yes. Regarding the I/O redirection conflicts, you know that even the Commodore manual recommended the use of the ".bra {" & ".ket }". So no problem here.
But, even, don't forget the default value that can be given with the $ sign "{argument$default_value}" ![]() No, here my point is that it is strange that even a "{variable_name}" was not handled natively (thus allowing, inside scripts, the use of variable created with the 'setenv' command (and stored in ENV: by the system - or created manually in ENV: )). But you are correct by saying that there is an inconsistency between the way "if" handle the $variable and the way "execute" handle the {argument}. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Variable injection? | solarmon | support.WinUAE | 12 | 20 January 2019 12:05 |
AmigaDOS wait for user input | Sinphaltimus | Coders. Scripting | 11 | 25 February 2018 02:47 |
WHDload 17.1 problem with user input | Fieldday | project.WHDLoad | 10 | 27 February 2013 08:54 |
getting a user to press a key via AmigaDOS | DeafDaz | Coders. System | 3 | 10 January 2012 17:37 |
Variable Master Clock | wiltshireguyuk | request.UAE Wishlist | 0 | 13 December 2004 16:40 |
|
|