Re: how to query standard input (e.g. Proceed (y/N)?)

Bram Moolenaar <[email protected]>
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
Scott Harrison wrote:

> When using A-A-P, how to query from standard input?
> For example, have main.aap ask the user "Proceed (y/N)?"

You can use the Python function raw_input():

	@ resp = raw_input("Proceed (y/N)? ")

You can use a loop to keep asking until a valid answer is given.  You
can find an example in the modules/d.aap recipe:

        @r = " " 
        @while not r == '1' and not r == '2': 
            :print 1. Become root/administrator and install in the Aap binaries
                        directory.
            :print 2. Specify another location to install ddepcheck.
            :print q. Quit
            @r = raw_input("Select an option: ")
            @if r == '1':
                :asroot $dc -O -of$bindir`os.sep`ddepcheck$EXESUF 
                            $toolsdir`os.sep`ddepcheck.d
            @elif r == '2':
                :print The path entered must be writable from your user.
                @bindir = raw_input("Enter install path for ddepcheck ")
                :sys $dc -O -of$bindir`os.sep`ddepcheck$EXESUF 
                        $toolsdir`os.sep`ddepcheck.d
                :print NOTE: It might be necessary to add $bindir to your PATH 
                        before the next execution of Aap.
                _top.DDEPCHECK = $bindir`os.sep`ddepcheck$EXESUF
            @elif r == 'q':
                :quit

-- 
hundred-and-one symptoms of being an internet addict:
249. You've forgotten what the outside looks like.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///


-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.