Go to the first, previous, next, last section, table of contents.


queryForString

Function: queryForInt { what was -> result }
file: 10-C-utils.t
package: muf
status: alpha

This function prompts the user for a string value via @$s.queryOutput and then reads it via @$s.queryInput. It loops until it obtains a nonempty string (after stripping leading and trailing whitespace) and then returns that value.

It is currently implemented as:

: queryForString { $ $ -> $ }   -> was -> what 
    was length 0 > if
        [ "The '%s' was '%s'.\n" what was
        | ]print @$s.queryOutput writeStream
    fi
    do{
        [ "Please enter new string value for '%s'.\n" what
        | ]print @$s.queryOutput writeStream

        @$s.queryInput readStreamLine pop trimString -> result
        result length 0 > if result return fi

        [ "Sorry, the '%s' value must not be blank.\n" what
        | ]print @$s.queryOutput writeStream
    }
;
'queryForString export


Go to the first, previous, next, last section, table of contents.