SCP: Provide a way to gather input from a user into an environment variable
SET ENV -P "Prompt String" EnvVar=Default
This commit is contained in:
parent
7a46fcf17c
commit
7ae5015610
3 changed files with 91 additions and 49 deletions
93
README.md
93
README.md
|
@ -260,52 +260,53 @@ The EXPECT command now exists to provide a means of reacting to simulator output
|
|||
|
||||
#### New SCP Commands:
|
||||
|
||||
SCREENSHOT filename.bmp Save video window to the specified file
|
||||
SET ENVIRONMENT Name=Value Set Environment variable
|
||||
SET ASYNCH Enable Asynchronous I/O
|
||||
SET NOASYNCH Disable Asynchronous I/O
|
||||
SET VERIFY Enable commang display while processing DO command files
|
||||
SET NOVERIFY Enable commang display while processing DO command files
|
||||
SET MESSAGE Enable error message output when commands complete (default)
|
||||
SET NOMESSAGE Disable error message output when commands complete
|
||||
SET QUIET Set minimal output mode for command execution
|
||||
SET NOQUIET Set normal output mode for command execution
|
||||
SET PROMPT Change the prompt used by the simulator (defaulr sim>)
|
||||
SET THROTTLE x/t Throttle t ms every x cycles
|
||||
SET REMOTE TELNET=port Specify remote console telnet port
|
||||
SET REMOTE NOTELNET Disables remote console
|
||||
SET REMOTE CONNECTIONS=n Specify the number of concurrent remote console sessions
|
||||
SHOW FEATURES Displays the devices descriptions and features
|
||||
SHOW ASYNCH Display the current Asynchronous I/O status
|
||||
SHOW SERIAL Display the available and/or open serial ports
|
||||
SHOW ETHERNET Display the available and/or open ethernet connections
|
||||
SHOW MULTIPLEXER Display the details about open multiplexer devices
|
||||
SHOW CLOCKS Display the details about calibrated timers
|
||||
SHOW REMOTE Display the remote console configuration
|
||||
SHOW ON Display ON condition dispatch actions
|
||||
SET ON Enable ON condition error dispatching
|
||||
SET NOON Disable ON condition error dispatching
|
||||
GOTO Transfer to lable in the current DO command file
|
||||
CALL Call subroutine at indicated label
|
||||
RETURN Return from subroutine call
|
||||
SHIFT Slide argument parameters %1 thru %9 left 1
|
||||
NOOP A no-op command
|
||||
ON Establish or cancel an ON condition dispatch
|
||||
IF Test some simulator state and conditionally execute commands
|
||||
CD Change working directory
|
||||
SET DEFAULT Change working directory
|
||||
PWD Show working directory
|
||||
SHOW DEFAULT Show working directory
|
||||
DIR {path|file} Display file listing
|
||||
LS {path|file} Display file listing
|
||||
NEXT Step across a subroutine call or step a single instruction.
|
||||
EXPECT React to output produced by a simulated system
|
||||
SEND Inject input to a simulated system's console
|
||||
SCREENSHOT Snapshot the current video display window
|
||||
RUN UNTIL breakpoint Establish the breakpoiunt specified and run until it is encountered
|
||||
RUN UNTIL "output-string" ... Establish the specified "output-string" as an EXPECT and run until it is encountered.
|
||||
GO UNTIL breakpoint Establish the breakpoiunt specified and go until it is encountered
|
||||
GO UNTILE "output-string" ... Establish the specified "output-string" as an EXPECT and go until it is encountered.
|
||||
SCREENSHOT filename.bmp Save video window to the specified file
|
||||
SET ENV Name=Value Set Environment variable
|
||||
SET ENV -p "Prompt" Name=Default Gather User input into an Environment Variable
|
||||
SET ASYNCH Enable Asynchronous I/O
|
||||
SET NOASYNCH Disable Asynchronous I/O
|
||||
SET VERIFY Enable commang display while processing DO command files
|
||||
SET NOVERIFY Enable commang display while processing DO command files
|
||||
SET MESSAGE Enable error message output when commands complete (default)
|
||||
SET NOMESSAGE Disable error message output when commands complete
|
||||
SET QUIET Set minimal output mode for command execution
|
||||
SET NOQUIET Set normal output mode for command execution
|
||||
SET PROMPT Change the prompt used by the simulator (defaulr sim>)
|
||||
SET THROTTLE x/t Throttle t ms every x cycles
|
||||
SET REMOTE TELNET=port Specify remote console telnet port
|
||||
SET REMOTE NOTELNET Disables remote console
|
||||
SET REMOTE CONNECTIONS=n Specify the number of concurrent remote console sessions
|
||||
SHOW FEATURES Displays the devices descriptions and features
|
||||
SHOW ASYNCH Display the current Asynchronous I/O status
|
||||
SHOW SERIAL Display the available and/or open serial ports
|
||||
SHOW ETHERNET Display the available and/or open ethernet connections
|
||||
SHOW MULTIPLEXER Display the details about open multiplexer devices
|
||||
SHOW CLOCKS Display the details about calibrated timers
|
||||
SHOW REMOTE Display the remote console configuration
|
||||
SHOW ON Display ON condition dispatch actions
|
||||
SET ON Enable ON condition error dispatching
|
||||
SET NOON Disable ON condition error dispatching
|
||||
GOTO Transfer to lable in the current DO command file
|
||||
CALL Call subroutine at indicated label
|
||||
RETURN Return from subroutine call
|
||||
SHIFT Slide argument parameters %1 thru %9 left 1
|
||||
NOOP A no-op command
|
||||
ON Establish or cancel an ON condition dispatch
|
||||
IF Test some simulator state and conditionally execute commands
|
||||
CD Change working directory
|
||||
SET DEFAULT Change working directory
|
||||
PWD Show working directory
|
||||
SHOW DEFAULT Show working directory
|
||||
DIR {path|file} Display file listing
|
||||
LS {path|file} Display file listing
|
||||
NEXT Step across a subroutine call or step a single instruction.
|
||||
EXPECT React to output produced by a simulated system
|
||||
SEND Inject input to a simulated system's console
|
||||
SCREENSHOT Snapshot the current video display window
|
||||
RUN UNTIL breakpoint Establish the breakpoiunt specified and run until it is encountered
|
||||
RUN UNTIL "output-string" ... Establish the specified "output-string" as an EXPECT and run until it is encountered.
|
||||
GO UNTIL breakpoint Establish the breakpoiunt specified and go until it is encountered
|
||||
GO UNTILE "output-string" ... Establish the specified "output-string" as an EXPECT and go until it is encountered.
|
||||
|
||||
#### Command Processing Enhancements
|
||||
|
||||
|
|
BIN
doc/simh_doc.doc
BIN
doc/simh_doc.doc
Binary file not shown.
47
scp.c
47
scp.c
|
@ -1161,10 +1161,19 @@ static const char simh_help[] =
|
|||
"3Asynch\n"
|
||||
"+set asynch enable asynchronous I/O\n"
|
||||
"+set noasynch disable asynchronous I/O\n"
|
||||
#define HLP_SET_ENVIRON "*Commands SET Asynch"
|
||||
#define HLP_SET_ENVIRON "*Commands SET Environment"
|
||||
"3Environment\n"
|
||||
"4Explicitily Changing A Variable\n"
|
||||
"+set environment name=val set environment variable\n"
|
||||
"+set environment name clear environment variable\n"
|
||||
"4Gathering Input From A User\n"
|
||||
" Input from a user can be obtained by:\n\n"
|
||||
"+set environment -p \"Prompt String\" name=default\n\n"
|
||||
" The -p switch indicates that the user should be prompted\n"
|
||||
" with the indicated prompt string and the input provided\n"
|
||||
" will be saved in the environment variable 'name'. If no\n"
|
||||
" input is provided, the value specified as 'default' will be\n"
|
||||
" used.\n"
|
||||
#define HLP_SET_ON "*Commands SET Command_Status_Trap_Dispatching"
|
||||
"3Command Status Trap Dispatching\n"
|
||||
"+set on enables error checking after command\n"
|
||||
|
@ -3996,11 +4005,43 @@ return SCPE_OK;
|
|||
|
||||
t_stat sim_set_environment (int32 flag, CONST char *cptr)
|
||||
{
|
||||
char varname[CBUFSIZE];
|
||||
char varname[CBUFSIZE], prompt[CBUFSIZE];
|
||||
|
||||
if ((!cptr) || (*cptr == 0)) /* now eol? */
|
||||
return SCPE_2FARG;
|
||||
cptr = get_glyph (cptr, varname, '='); /* get environment variable name */
|
||||
if (sim_switches & SWMASK ('P')) {
|
||||
char cbuf[CBUFSIZE];
|
||||
CONST char *deflt = NULL;
|
||||
|
||||
cptr = get_glyph_quoted (cptr, prompt, 0); /* get prompt */
|
||||
if (prompt[0] == '\0')
|
||||
return sim_messagef (SCPE_2FARG, "Missing Prompt and Environment Variable Name\n");
|
||||
if ((prompt[0] == '"') || (prompt[0] == '\'')) {
|
||||
prompt[strlen (prompt) - 1] = '\0';
|
||||
memmove (prompt, prompt + 1, strlen (prompt));
|
||||
}
|
||||
deflt = get_glyph (cptr, varname, '='); /* get environment variable name */
|
||||
if (deflt == NULL)
|
||||
deflt = "";
|
||||
if (*deflt) {
|
||||
strlcat (prompt, " [", sizeof (prompt));
|
||||
strlcat (prompt, deflt, sizeof (prompt));
|
||||
strlcat (prompt, "] ", sizeof (prompt));
|
||||
}
|
||||
else
|
||||
strlcat (prompt, " ", sizeof (prompt));
|
||||
if (sim_rem_cmd_active_line == -1) {
|
||||
cptr = read_line_p (prompt, cbuf, sizeof(cbuf), stdin);
|
||||
if ((cptr == NULL) || (*cptr == 0))
|
||||
cptr = deflt;
|
||||
else
|
||||
cptr = cbuf;
|
||||
}
|
||||
else
|
||||
cptr = deflt;
|
||||
}
|
||||
else
|
||||
cptr = get_glyph (cptr, varname, '='); /* get environment variable name */
|
||||
setenv(varname, cptr, 1);
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue