* QueryAny v2.0 - make decisions from within scripts * by Mark W. Smith * * © 1987 Smithware * Cincinnati, OH * ------------------------------------------------------------------------------ * PROGRAM REVISIONS: * * v1.0 Lattice C - 15000+ bytes * v1.1 Lattice C - 15000+ bytes * v1.2 Aztec C - 5244 bytes * v2.0 Assembly - 352 bytes * * ------------------------------------------------------------------------------ * Version 1.0 would respond as follows: * * 1> QueryAny "Zing!" * Do you wish to install 'Zing!' (y/n) ? * 1> * ------------------------------------------------------------------------------ * Version 1.1 now allows you to phrase it yourself: * * 1> QueryAny "Do you wish to install 'Zing!'" * Do you wish to install 'Zing!' (y/n) ? y * 1> * ------------------------------------------------------------------------------ * Version 1.2 converted to Manx Aztec C. * ------------------------------------------------------------------------------ * Version 2.0 now in assembly, with "" delimeters removed: * * 1> QueryAny Do you wish to install 'Zing!' * Do you wish to install 'Zing!' (y/n) ? y * 1> * ------------------------------------------------------------------------------ * Included in this arc is an example of usage within the Startup-Sequence. * I have tried to make this program as generic as possible, so the user has * complete control over it, but kept the ' (y/n) ? ' at the end of the arg. * ------------------------------------------------------------------------------ XREF _AbsExecBase XREF _LVOOpenLibrary XREF _LVOInput XREF _LVOOutput XREF _LVORead XREF _LVOWrite * Read and Write MACROS WriteFile macro ;File, String, Len move.l \1,d1 move.l \2,d2 move.l \3,d3 jsr _LVOWrite(a6) endm ReadFile macro ;File, Buffer, Len move.l \1,d1 move.l \2,d2 move.l \3,d3 jsr _LVORead(a6) endm * Save cmd line arg pointers movem.l a0/d0,-(sp) * Open DOS library move.l _AbsExecBase,a6 move.l #DOS_Name,a1 clr.l d0 jsr _LVOOpenLibrary(a6) move.l d0,a6 tst.l d0 bne Continue ;branch if arg exists movem.l (sp)+,a0/d0 ;otherwise, restore stack & quit clr.l d0 bra Quit Continue: jsr _LVOInput(a6) ;get stdin move.l d0,StdIn beq Quit jsr _LVOOutput(a6) ;get stdout move.l d0,StdOut beq Quit movem.l (sp)+,a0/d0 ;pop args from stack subq.l #1,d0 ;remove lf from cmd line arg WriteFile StdOut,a0,d0 WriteFile StdOut,#Prompt,#Prompt_Len ReadFile StdIn,#Response,#2 move.b Response,d0 cmpi.b #'Y',d0 beq No_Warning cmpi.b #'y',d0 beq No_Warning move.l #5,d0 bra Quit No_Warning: clr.l d0 Quit: rts SECTION data,DATA DOS_Name: dc.b 'dos.library',0 Prompt: dc.b ' (y/n) ? ' Prompt_Len equ *-Prompt SECTION mem,BSS StdIn ds.l 1 ;input file handle StdOut ds.l 1 ;output file handle Response ds.l 1 end * REMEMBER to support NORML !! * the National Organization for the Reform of Marijuana Laws