amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator) (03/04/91)
Submitted-by: simpsonc@project4.computer-science.manchester.ac.uk Posting-number: Volume 91, Issue 043 Archive-name: utilities/buttonask/part01 [ includes uuencoded executables ...tad ] BUTTONASK --------- ButtonAsk is a replacement for the AmigaDOS ASK command. It takes a prompt string from the command line, echos it to standard output, and waits for either the left or right mouse button to be pressed. The program will then send a return code of either 5(WARN) or 0 to the system which can be interpreted by using the IF command. This program is mainly used in scripts. WAITBUTTONS ----------- This is a small program which is used to detect when no mouse buttons are down. If you intend to use buttonask more than once in the same script then you should use this command to check that a button is not already down before calling buttonask. #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: ButtonAsk.s ButtonAsk.uu ReadMe WaitButtons.s # WaitButtons.uu # Wrapped by tadguy@ab20 on Sun Mar 3 18:20:57 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'ButtonAsk.s' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ButtonAsk.s'\" else echo shar: Extracting \"'ButtonAsk.s'\" \(2579 characters\) sed "s/^X//" >'ButtonAsk.s' <<'END_OF_FILE' X************************************** X* * X* ButtonAsk v1.0 * X* * X* (c) 1990 Chris Simpson * X* * X* USAGE: ButtonAsk <prompt> * X* * X* This program is a replacement for * X* the AmigaDOS ASK command except * X* that the mouse buttons are used * X* rather than entering 'y' or 'n' * X* For this program to work, some * X* text for the prompt must be given * X* in the command line. This text is * X* echoed to stdout and then a mouse * X* button is waited for. Pressing the * X* left button returns a return code * X* of 5(WARN) and pressing the right * X* button returns a return code of 0. * X* * X************************************** X X SECTION ButtonAsk,code_c ; Put into chip ram X X INCDIR include: ; Read include files X INCLUDE exec/exec_lib.i X INCLUDE libraries/dos_lib.i X XLeftReg equ $bfe001 ; Set up button registers XRightReg equ $dff016 X X move.l d0,Length ; Store length of CLI line X move.l a0,Address ; Store address of CLI line X X move.l #100,ReturnCode ; Default return code X X lea DOSName,a1 ; Try to open dos library X clr.l d0 X CALLEXEC OpenLibrary X tst.l d0 ; Quit if not opened X beq Error X move.l d0,_DOSBase ; Else store dos base X X CALLDOS Output ; Find standard output X move.l d0,OutHandle ; Store handle address X X move.l Length,d0 ; Get back length X move.l Address,a0 ; Get back address X X cmp.l #1,Length ; Make sure not just linefeed X bgt GotPrompt X X move.l OutHandle,d1 ; Write USAGE text X move.l #Usage,d2 X move.l #UsageEnd-Usage,d3 X CALLDOS Write X bra CloseDOS X X XGotPrompt move.l OutHandle,d1 ; Write the prompt out X move.l a0,d2 X move.l d0,d3 X CALLDOS Write X XWaitForButton btst #6,$bfe001 X beq LeftPressed X X btst #10,$dff016 X beq RightPressed X X bra WaitForButton X XLeftPressed move.l #5,ReturnCode X bra CloseDOS X XRightPressed move.l #0,ReturnCode X XCloseDOS move.l _DOSBase,a1 ; Close dos library X CALLEXEC CloseLibrary X X move.l ReturnCode,d0 ; Exit with return code XError rts X X*** Data *** X XDOSName dc.b "dos.library",0 X even X_DOSBase dc.l 0 X XOutHandle dc.l 0 X XUsage dc.b "ButtonAsk v1.0 (c) 1990 Chris Simpson",13,10,13,10 X dc.b "USAGE: ButtonAsk <prompt>",13,10,13,10 X dc.b "Return code will be ... 5 if left button pressed",13,10 X dc.b " 0 if right button pressed",13,10,0 XUsageEnd even X XAddress dc.l 0 XLength dc.l 0 X XReturnCode dc.l 0 X END_OF_FILE if test 2579 -ne `wc -c <'ButtonAsk.s'`; then echo shar: \"'ButtonAsk.s'\" unpacked with wrong size! fi # end of 'ButtonAsk.s' fi if test -f 'ButtonAsk.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ButtonAsk.uu'\" else echo shar: Extracting \"'ButtonAsk.uu'\" \(811 characters\) sed "s/^X//" >'ButtonAsk.uu' <<'END_OF_FILE' Xbegin 644 ButtonAsk XM```#\P`````````!``````````!```!J0``#Z0```&HCP````9XCR````9HCB XM_````&0```&B0_D```#:0H`L>``$3J[]V$J`9P``KB/`````YBQY````YDZN# XM_\0CP````.H@.0```9X@>0```9H,N0````$```&>;@``(B(Y````ZB0\````6 XM[B8\````K"QY````YDZN_]!@``!*(CD```#J)`@F`"QY````YDZN_]`(.0`&P XM`+_@`6<``!((.0`*`-_P%F<``!1@`/_F(_P````%```!HF````PC_```````; XM``&B(GD```#F+'@`!$ZN_F(@.0```:).=61O<RYL:6)R87)Y````````````0 XM0G5T=&]N07-K('8Q+C`@(""I(#$Y.3`@0VAR:7,@4VEM<'-O;@T*#0I54T%'\ XM13H@0G5T=&]N07-K(#QP<F]M<'0^#0H-"E)E='5R;B!C;V1E('=I;&P@8F4@^ XM+BXN(#4@:68@;&5F="!B=71T;VX@<')E<W-E9`T*("`@("`@("`@("`@("`@B XM("`@("`@("`@,"!I9B!R:6=H="!B=71T;VX@<')E<W-E9`T*````````````F XM```````````#[````!,``````````@````@````2````&````"X````T````8 XM/@```$0```!*````5````%X```!D````<````'X```"(````L@```,````#&0 X,````U`````````/R) X`` Xend Xsize 552 END_OF_FILE if test 811 -ne `wc -c <'ButtonAsk.uu'`; then echo shar: \"'ButtonAsk.uu'\" unpacked with wrong size! fi # end of 'ButtonAsk.uu' fi if test -f 'ReadMe' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ReadMe'\" else echo shar: Extracting \"'ReadMe'\" \(1175 characters\) sed "s/^X//" >'ReadMe' <<'END_OF_FILE' XBUTTONASK X--------- X X ButtonAsk is a replacement for the AmigaDOS ASK command. It takes a prompt Xstring from the command line, echos it to standard output, and waits for Xeither the left or right mouse button to be pressed. The program will then Xsend a return code of either 5(WARN) or 0 to the system which can be Xinterpreted by using the IF command. This program is mainly used in scripts. X XEXAMPLE: X X BUTTONASK Press a mouse button X IF WARN X ECHO "Hello" X ELSE X ECHO "GoodBye" X ENDIF X X This script will print out the message "Press a mouse button", and then Xwait for mouse button to be pressed. Then either the Hello or GoodBye Xmessage will be output depending which button was pressed. See the source Xfile for more details X XWAITBUTTONS X----------- X X This is a small program which is used to detect when no mouse buttons are Xdown. If you intend to use buttonask more than once in the same script then Xyou should use this command to check that a button is not already down Xbefore calling buttonask. X XDISTRIBUTION: X X ButtonAsk is copyright 1990 Chris Simpson but may be distributed in any Xway as long as this file, WaitButtons, and both source files are included. END_OF_FILE if test 1175 -ne `wc -c <'ReadMe'`; then echo shar: \"'ReadMe'\" unpacked with wrong size! fi # end of 'ReadMe' fi if test -f 'WaitButtons.s' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'WaitButtons.s'\" else echo shar: Extracting \"'WaitButtons.s'\" \(172 characters\) sed "s/^X//" >'WaitButtons.s' <<'END_OF_FILE' XLeftReg equ $bfe001 ; Set up button registers XRightReg equ $dff016 X XWaitForButton btst #6,$bfe001 X beq WaitForButton X X btst #10,$dff016 X beq WaitForButton X X rts X X END_OF_FILE if test 172 -ne `wc -c <'WaitButtons.s'`; then echo shar: \"'WaitButtons.s'\" unpacked with wrong size! fi # end of 'WaitButtons.s' fi if test -f 'WaitButtons.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'WaitButtons.uu'\" else echo shar: Extracting \"'WaitButtons.uu'\" \(131 characters\) sed "s/^X//" >'WaitButtons.uu' <<'END_OF_FILE' Xbegin 644 WaitButtons XM```#\P`````````!```````````````'```#Z0````<(.0`&`+_@`6<`__8(\ X3.0`*`-_P%F<`_^I.=0`````#\@``P X`` Xend Xsize 64 END_OF_FILE if test 131 -ne `wc -c <'WaitButtons.uu'`; then echo shar: \"'WaitButtons.uu'\" unpacked with wrong size! fi # end of 'WaitButtons.uu' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>. Mail comments to the moderator at <amiga-request@uunet.uu.net>. Post requests for sources, and general discussion to comp.sys.amiga.misc.