View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

asking for user input in a cl script

morrisonss wrote on Oct 18, 2010

Does anyone have any clue how to ask for a user input in a cl script? I have it so it will print the question, but I am unable to figure out how to get it to allow the user to input a response.

Mike Fitzpatrick wrote on Oct 18, 2010


procedure foo ()

begin

        printf ("prompt> ")
        scan (s1)

        printf ("You said '%s'\n", s1)
end


This would be to prompt for e.g. filenames, although in that case using query parameters would do the same thing. If what you want is something like a keystroke command you would use the 'ukey' CL parameter. E.g.

nextcmd:
        printf ("\nCommand? ")
        summary = no

        ch = cl.ukey
        if (substr(ch,1,4) == "\\015") {
            goto nextcmd
        }

        switch (ch) {
        case "?":                    
                   {  ....print help info
                   }
        case "t":                       # Record
            {   printf ("\nService Type? ")
                n = scan (stype)
                if (n == 0)
                    stype = ""
                goto submit
            }
        }


Note this ignores a <cr> and prints the prompt again, but defines a '?' and 't' keystroke command similar to what you see in graphics tasks.

Last post on Oct 18, 2010