[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

4220.0. "Need help writing a Script" by HPSCAD::GATULIS (Frank Gatulis 297-6770) Wed Oct 24 1990 00:27

    Help!
    
    I'd like to get a string from a user from within a script/execute file
    (interactively, NOT a passed parameter).  I simply want to ask for a
    directory path and have typed in.  Seems simple enough but I can't
    figure out how to do it.
    
    All of user dialogue examples I've come across so far seem to require 
    that the user input be text from a pre-defined set of possibilities.
    Any suggestions?
    
    Thanks,
    Frank 
T.RTitleUserPersonal
Name
DateLines
4220.1One techniqueTLE::RMEYERSRandy MeyersWed Oct 24 1990 14:068
Re: .0

This works if you CD to a certain directory:

echo "Please type name of the directory"
cd >NIL: ?

The CD command will read its argument from standard input.
4220.2Not exactly what I was trying to do7415::GATULISFrank Gatulis 297-6770Wed Oct 24 1990 17:4021
    re .-1
    
    Randy,
    
    I agree.  I found a similar example but the restriction is that
    "the name of the directory" is used immediately with the command.
    There's no "memory/storage" where I can find out what the user typed
    in so I can use his string more than once. 
    
    In the example you mentioned, ( CD >NIL: ? ) works because the users
    input is only used once.   How could implement something like:
    
       if exists <user-directory>
         cd <user-directory>
    
    but only ask for input once (without a passed parameter) ?
    
    Can it even be done?
    
    Frank
    
4220.3Get AREXXTENAYA::MWMWed Oct 24 1990 18:089
Since dos scripts don't have real variables per se, just return codes &
script parameters, you're using the wrong language. Try AREXX; it's cheap
now, and is bundled into 2.0.

If that won't work for some reason, try using one of the PD Unixoid shells
that are floating around (csh at least should be useable), or possibly
ScriptIt or something similar.

     <mike
4220.4Closer to what you need?TLE::RMEYERSRandy MeyersWed Oct 24 1990 19:0121
Re: .2

>    There's no "memory/storage" where I can find out what the user typed
>    in so I can use his string more than once. 

How about this hackful solution:

assign old-dir: ""
echo "Please type the name of the directory"
cd >NIL: ?
assign dir: ""
cd old-dir:

You can then use dir: everywhere you need the directory that was typed in.
(The AmigaDOS trivia in the above is that the filename "" is the a synonym
for the current directory.)

It's possible to improve on the above little script be using $$ to
make the CLI number part of the assign name, and thus the script
can multitask with itself.  See the 1.3 docs for details (I don't
remember them offhand).
4220.5Clean upTLE::RMEYERSRandy MeyersWed Oct 24 1990 19:068
More on .4:

Remember to cancel the assigns before ending your script:

assign old-dir:
assign dir:

That way you don't have dangling locks on directories.
4220.6HPSCAD::GATULISFrank Gatulis 297-6770Wed Oct 24 1990 19:2715
    
    Re -.3 & -.4
    
    Sounds obscure eough to work.  I'll probably give it a shot.  I have
    another weird idea about trying a kludge with environment variables 
    as a place to store a string.
    
    Re -.2
    
    ARexx! Naaaaaaa.  I'd sooner write real code to do the job.
    
    
    Thanks for the replies.
    Frank