![]() |
![]() HP OpenVMS Systemsask the wizard |
![]() |
The Question is: Hello, I previously wrote about how while using curses in a C program I couldn't get getch() and getc() to get keyboard characters. It has turned out to be a probelm at the command line. I invoked the exe file from within a DCL .com file. When I executed the commands manually getch and getc could read from the keyboard. x.com contains: $x:=$home:[myhome]x.exe $x data_in_parameter Executing the .com file, @x, caused x.exe to execute but couldn't read from the keyboard. Please let me know if you can help. THX, mitch The Answer is : While executing a command procedure, SYS$INPUT ("standard input") points to the command procedure itself, with the next line starting with "$" being seen as EOF (see the $DECK command to change the EOF marker). If you wish to read input from the terminal, from a program run within a procedure, you must redirect standard input. Use the command: $ DEFINE/USER SYS$INPUT SYS$COMMAND SYS$COMMAND is the terminal keyboard, so be redefining the logical name SYS$INPUT to SYS$COMMAND, input will be read from the terminal. The /USER makes this a user mode logical name definition. As such, it will automatically be deassigned at the next image exit. So, the sequence: $ DEFINE/USER SYS$INPUT SYS$COMMAND $ RUN PROGRAMA $ RUN PROGRAMB some input for PROGRAMB another line of input for PROGRAMB $ RUN PROGRAMC $ EXIT Input for PROGRAMA will be read from the terminal keyboard, while input for PROGRAMB will be read from the procedure itself. Since there are no lines after "$ RUN PROGRAMC" which don't start with "$", any attempt to read from standard input will result in an immediate EOF. Also note that you can replace your commands: $x:=$home:[myhome]x $x data_in_parameter with: $ MCR home:[myhome]x data_in_parameter Or, using DCL$PATH once (say in your login procedure) to include the directory home:[myhome]. For example: $ DEFINE DCL$PATH home:[myhome] From there on: $ x data_in_parameter and, any other programs or procedures in home:[myhome] can be executed by typing just its name (makes all those Unix and DOS folk feel at home).
|