English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System > Coders. Scripting

 
 
Thread Tools
Old 23 February 2018, 21:15   #1
Sinphaltimus
Registered User

Sinphaltimus's Avatar
 
Join Date: Aug 2016
Location: Cresco, PA, USA
Age: 47
Posts: 1,072
AmigaDOS wait for user input

EDIT: Found it - here - http://www.amigawiki.de/doku.php?id=...commands_large

It's the ASK command.

Leaving topic for future ref in case someone else has same question otherwise, Please disregard the following:

I've read the AmigaDOS references and searched but cannot find an example to show me how a lot of ths should work.

I don't understand what this topic refers to, I downloaded the lha linked and don't know how to check it out..

http://eab.abime.net/showthread.php?t=69399

Basically, I want a script to run, prompt the user to press RETURN to continue.
As long as the user does not press enter, just sit there and wait for them to press enter.

As soon as they do press enter - finish running the rest of the script.

I don't understand how to use CON: or .KEY

Can someone explain this to me? And give a simple example?

Last edited by Sinphaltimus; 23 February 2018 at 21:27.
Sinphaltimus is offline  
AdSense AdSense  
Old 23 February 2018, 21:29   #2
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,911
There's the Ask command which sort-of does what you want. Just have this in a script:
Ask "Press Return to continue."

Ask is intended for Yes/No responses though. So it accepts either Y, yes, N, no or nothing (just press return). If the user types something else then presses Return, the prompt message is shown again.

Edit: Whoops, didn't see your edit in time.
mark_k is offline  
Old 23 February 2018, 21:40   #3
Sinphaltimus
Registered User

Sinphaltimus's Avatar
 
Join Date: Aug 2016
Location: Cresco, PA, USA
Age: 47
Posts: 1,072
Thanks Mark, I actually read your answer after posting this question so I guess it's a follow up question now.

OK, another question. I now do not understand how to use IF WARN to check for an answer.

If I ask a Yes or No questions.

If Yes continue script, if NO echo a msg then exit script.

Can you explain this to me? And give a simple example?
Sinphaltimus is offline  
Old 23 February 2018, 21:44   #4
Akira
Registered User

Akira's Avatar
 
Join Date: May 2001
Location: New York
Posts: 19,232
Code:
ask Would you please answer Sinphaltimus' question?

if warn
   echo this is how you use it
else 
   echo get out of here noob!
endif
For future reference:
http://wiki.amigaos.net/wiki/AmigaOS...mand_Reference
Akira is online now  
Old 23 February 2018, 21:44   #5
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 1,927
Try this in a shell:
Code:
requestchoice "title" "body" "ok"
Code:
echo >con:20/100/300/200/title/wait
For .key usage have a look at sys:s/spat or dpat.
daxb is offline  
Old 23 February 2018, 21:52   #6
Sinphaltimus
Registered User

Sinphaltimus's Avatar
 
Join Date: Aug 2016
Location: Cresco, PA, USA
Age: 47
Posts: 1,072
Quote:
Originally Posted by Akira View Post
Code:
ask Would you please answer Sinphaltimus' question?

if warn
   echo this is how you use it
else 
   echo get out of here noob!
endif
For future reference:
http://wiki.amigaos.net/wiki/AmigaOS...mand_Reference

I stayed away from that reference because it's not AmigaDOS 3.1 "Copyright (c) 2012-2016 Hyperion Entertainment and contributors." It contains commands that don't exist for me like DISMOUNT.

But thank you, your example works for me as intended. That's exactly what I needed.

For refs, I was using:
http://www.amigawiki.de/doku.php?id=...commands_large

But I was unable to formulate proper usage. so again, thanks for your example.
Sinphaltimus is offline  
Old 23 February 2018, 22:14   #7
kolla
Registered User
kolla's Avatar
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,043
What about this?

Code:
lab ask
set answer _x
echo noline "What is your name? "
set >NIL: answer ?
if "$answer" eq "_x"
  echo "Sorry, I demand an answer!"
  skip back ask
else
  echo "Hello $answer"
endif
As long as you don't answer that your name is _x of course - be creative
kolla is online now  
Old 23 February 2018, 22:29   #8
Sinphaltimus
Registered User

Sinphaltimus's Avatar
 
Join Date: Aug 2016
Location: Cresco, PA, USA
Age: 47
Posts: 1,072
Thanks kolla, I'm sure I'll need to know that at some point. Akira's answer pretty much nailed it.
Sinphaltimus is offline  
Old 24 February 2018, 19:15   #9
kolla
Registered User
kolla's Avatar
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,043
Quote:
Originally Posted by Sinphaltimus View Post
Thanks kolla, I'm sure I'll need to know that at some point. Akira's answer pretty much nailed it.


Let me come with a small update - as I wrote the previous, I was puzzling over what trick I would use to check if a variable is not set - and now it just dawned upon me

Code:
lab ask
unset answer
echo noline "What is your name? "
set >NIL: answer ?
if "$answer" eq "*$answer"
  echo "Sorry, I demand an answer!"
  skip back ask
else
  echo "Hello $answer"
endif
See that trick? Unlike "sensible" shells of other operating systems, Amiga shell will treat unset variables as literal strings, including the dollar sign. So the solution is of course to check if "$var" is the same as "*$var", where the latter is the actual string with the dollar sign explicitly escaped (using *).

So now you can go ahead and call yourself _x or whatever you like
kolla is online now  
Old 24 February 2018, 20:22   #10
Sinphaltimus
Registered User

Sinphaltimus's Avatar
 
Join Date: Aug 2016
Location: Cresco, PA, USA
Age: 47
Posts: 1,072
Quote:
Originally Posted by kolla View Post


Let me come with a small update - as I wrote the previous, I was puzzling over what trick I would use to check if a variable is not set - and now it just dawned upon me

Code:
lab ask
unset answer
echo noline "What is your name? "
set >NIL: answer ?
if "$answer" eq "*$answer"
  echo "Sorry, I demand an answer!"
  skip back ask
else
  echo "Hello $answer"
endif
See that trick? Unlike "sensible" shells of other operating systems, Amiga shell will treat unset variables as literal strings, including the dollar sign. So the solution is of course to check if "$var" is the same as "*$var", where the latter is the actual string with the dollar sign explicitly escaped (using *).

So now you can go ahead and call yourself _x or whatever you like
Wow, this trick made one fo my scripts so much better. Since assign dismount SD0: does not dismount the volume on SD0: (assuming only one volume), I was able to customize this to ask user for the name of the SD0: mounted volume and it will dismount both.

Thanks kolla!
Sinphaltimus is offline  
Old 25 February 2018, 00:44   #11
kolla
Registered User
kolla's Avatar
 
Join Date: Nov 2007
Location: Trondheim, Norway
Posts: 1,043
There are ways to get volume name via scripting, instead of user input, here is a script than can be named "unmount" for example...

Code:
.key DEV/A
.bra [
.ket ]

set fromdir "`cd`"
cd [DEV]
set VOL "`cd`"
cd "$fromdir"

assign [DEV] dismount
assign "$VOL" dismount
The dirty trick is that it enters into the device to get volume name using the cd command - there are times when entering the device is undesired (stale network drive f.eks). C:Info could do well with an update and LFORMAT option... something for the wish list

Anyways, here is a program you may be interested in

http://aminet.net/package/disk/misc/Dismount
kolla is online now  
Old 25 February 2018, 02:47   #12
Sinphaltimus
Registered User

Sinphaltimus's Avatar
 
Join Date: Aug 2016
Location: Cresco, PA, USA
Age: 47
Posts: 1,072
Thanks. I'll check it out.
Sinphaltimus is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wait() mritter0 Coders. C/C++ 2 17 May 2014 19:14
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
timed wait using CIAs jotd support.Other 3 23 March 2008 14:55
Wait a sec - what about Macs? Computolio Amiga scene 10 02 June 2004 07:23

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 00:51.


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