09 October 2021, 00:29 | #1 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 5,053
|
AmigaOS 1.3 'askL' & 'askM' commands
Now that I found a way to use variable(s) inside a script, the next step was to find a way to get some "real" input from the user by allowing him/her to type an answer (like asking the source/destination/a name/etc. - and not only a yes/no tests as with the original 'ask' command).
Honestly speaking, it was not a "keep it easy" task and it shook my mind in a lot of directions. Finally I came across a solution (my install is a WB 1.3.3 - other versions not tested). It is maybe not the most 'clean' idea but it does the job so ... The working solution requires to create two scripts. The "main" script (I called it AskL for "ask long") that the user execute and another script, a "stealth"* one (AskL2) that is called by the first one to 'do the job' of retrieving the user input and storing the variable. *see StingRay post #2 The 'command' ends when an answer is provided (otherwise it keeps asking). Here are the codes : Code:
AskL : .key question .bra { .ket } .def question "? " lab mlk ;(see below) echo "{question}" NOLINE execute >NIL: AskL2 reponse ? ;>NIL: to switch the execute to 'non visible' ; mode (stealth) ;'?' to force the 'template' mode (like when ; you don't remember the arguments/options ; of a command) and since it is invisible, we ; don't see we have switched to another ; command :p if EXISTS t:repondu delete t:repondu QUIET else ;skip mlk BACK ;not working. As I can see, the above 'execute' makes that ;the script looses the labels he knows... Grrrr... :( execute AskL "{question}" endif Code:
AskL2 : .key variable,a7_,b7_,c7_,d7_,e7_,f7_,g7_,h7_,i7_,j7_,k7_,l7_,m7_,n7_,o7_,p7_,q7_,r7_,s7_,t7_,u7_,v7_,w7_,x7_,y7_,z7_ ;adapt the amount of needed arguments (c.f. below) .bra { .ket } ;warning: At prompt, do not type the same value as the name of one of the ; argument. It will hang the execute command and thus also the script. if "{a7_}" EQ "" if EXISTS t:repondu delete t:repondu QUIET endif else setenv {variable} "{a7_} {b7_} {c7_} {d7_} {e7_} {f7_} {g7_} {h7_} {i7_} {j7_} {k7_} {l7_} {m7_} {n7_} {o7_} {p7_} {q7_} {r7_} {s7_} {t7_} {u7_} {v7_} {w7_} {x7_} {y7_} {z7_}" ;adapt to your needs (c.f. above) echo >t:repondu "" NOLINE endif Code:
protect AskL +s Code:
AskL or AskL "question ? " Code:
getenv reponse Any comment is welcome. Last edited by malko; 11 October 2021 at 00:27. |
10 October 2021, 01:31 | #2 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 5,053
|
for WB 34.(21|28|34)
I didn't mention it in my previous post but the AskL scripts accept answer from 1 word to up to 26 words separated by spaces (or more if you adapt the second script - but 26 words is already a long phrase and thus is more than enough I think).
A much simpler solution, made of only 1 script, would consist of accepting a only 1 word answer OR require the user to put in quotes multiple words answer : Code:
AskM : .key question .bra { .ket } .def question "? " lab mlk echo "{question}" NOLINE failat 21 setenv >NIL: reponse ? ;see 'AskL' for the comments regarding '>NIL:' & '?' if ERROR skip mlk BACK endif if "$reponse" EQ "" skip mlk BACK endif Code:
getenv reponse Last edited by malko; 11 October 2021 at 00:28. |
11 October 2021, 00:50 | #3 |
Ex nihilo nihil
Join Date: Oct 2017
Location: CH
Posts: 5,053
|
Quickly tested the scripts AskL/AskL2 & AskM under WB 1.3.2 (34.28), 1.3 (34.21). They are also working fine.
In the other hand, WB 1.2 (33.56), 1.1 (31.334) and 1.0 (30), have no 'setenv', 'getenv' commands. Neither have them the NOLINE argument for the 'echo' command or the T: and ENV: by default. Therefore the scripts won't work as is. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
XAD commands | npagonis73 | support.Other | 29 | 17 March 2022 15:15 |
AmigaOS 1.3 'tstdvc' , 'ctrflp' & 'ctrflpq' commands | malko | Coders. Scripting | 0 | 29 October 2021 01:30 |
uae-configuration commands | markpage | support.WinUAE | 18 | 02 May 2021 00:24 |
E-UAE for AmigaOS 4.1 help for commands | White | support.OtherUAE | 0 | 16 February 2018 15:55 |
Zip help commands | mickolite | support.Apps | 5 | 16 June 2011 21:00 |
|
|