WintextCom Utilities > The Request Information Utility > Getting Text Input  >

Processing the Returned Information

Last updated: 09/11/2008 16:39:38 GMT
Print (Alt+1) Previous (Alt+P) Beginning of ChapterNext (Alt+N)

The information entered by the user when wtreqinfo displays a text input prompt is returned to the caller by passing it on the command line to another module, which can be the same as the calling process. Specify the module after the letter "T" or "T" in the prompt box switch. For example:

 

"wtreqinfo.exe /Tc:\windows\notepad.exe Filename?".

 

The above line causes wtreqinfo to display the prompt "Filename?", and when the user types in the name of a file, it is passed to Notepad and opened. Beware that wtreqinfo searches only in the current directory, both the module name supplied for execution and any file information supplied by the user must include full paths if they are not in the current directory.

 

The main purpose of wtreqinfo's prompt box capability is to allow user input to be processed by the calling command script (.cmd or batch file). For example, you might create a command script called "howold.cmd" that gets the user's age:

 

"wtreqinfo.exe /Tage.cmd "How old are you?"".

 

Notice that the user's response in this example is passed to a different command file. "age.cmd" accesses the user's information through the %1 command line argument, and is able to access any environment variable set by "howold.cmd" before the call to wtreqinfo. The calling command script should exit as soon as it has called wtreqinfo, since there is no point processing the errorlevel return. It can, however, perform additional tasks independently of "age.cmd" if required.

 

Alternatively, you can pass  the name of the calling command script to wtreqinfo:

 

"wtreqinfo.exe /Thowold.cmd "How old are you?"".

 

The user's response is passed back to the same command file, which is run separately from the calling instance. The command file must include some mechanism to test whether it is being run by wtreqinfo and is intended to process the command line information, or whether it is running for the first time and should make the call to wtreqinfo. One way of doing this is to check an environment variable at the top of the calling script, and if it does not exist, set it and call wtreqinfo; if the environment variable does exist, process the command line arguments. Note that using the command line arguments themselves as a way of testing the circumstances of the running instance of the script file is unsound, since there will be no command line information if the user did not type any text before pressing ENTER.

 

Unless the "/s" subswitch is specified, user input will be spread across multiple command line arguments if it contains spaces, %1, %2, etc. Write the command file to process as many command line arguments as you expect to be available, corresponding to the number of words in the user's input. Using "/s" enables you to get the entire input in just one command line argument, %1, see the next section.

 


Page url: http://wtcmanual.wintextware.com/index.html?wtri_processing_the_returned_inform.htm