scp - Added expansion of %STATUS% and %TSTATUS% in do command

arguments.  STATUS is the numeric value of the last
        command error status and TSTATUS is the text message
        relating to the last command error status
This commit is contained in:
Mark Pizzolato 2011-04-20 11:11:22 -07:00
parent 7dfe732667
commit db99885bfe
2 changed files with 25 additions and 3 deletions

26
scp.c
View file

@ -23,6 +23,10 @@
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
20-Apr-11 MP Added expansion of %STATUS% and %TSTATUS% in do command
arguments. STATUS is the numeric value of the last
command error status and TSTATUS is the text message
relating to the last command error status
17-Apr-11 MP Changed sim_rest to defer attaching devices until after
device register contents have been restored since some
attach activities may reference register contained info.
@ -424,6 +428,8 @@ static int32 sim_do_depth = 0;
static int32 sim_on_check[MAX_DO_NEST_LVL+1];
static char *sim_on_actions[MAX_DO_NEST_LVL+1][SCPE_MAX_ERR+1];
static t_stat sim_last_cmd_stat; /* Command Status */
static SCHTAB sim_stab;
static UNIT sim_step_unit = { UDATA (&step_svc, 0, 0) };
@ -976,6 +982,12 @@ do {
else stat = cmdp->action (cmdp->arg, cptr); /* exec other cmd */
}
else stat = SCPE_UNK; /* bad cmd given */
if ((stat != SCPE_OK) ||
((cmdp->action != &return_cmd) &&
(cmdp->action != &goto_cmd) &&
(cmdp->action != &on_cmd) &&
(cmdp->action != &echo_cmd)))
sim_last_cmd_stat = stat; /* save command error status */
staying = (stat != SCPE_EXIT) && /* decide if staying */
(stat != SCPE_AFAIL) &&
(!errabort || (stat < SCPE_BASE) || (stat == SCPE_STEP));
@ -1090,6 +1102,14 @@ for (ip = instr, op = tmpbuf; *ip && (op < oend); ) {
rbuf[strlen (rbuf)-1] = '\0'; /* remove trailing \n */
ap = rbuf;
}
else if (!strcmp ("STATUS", gbuf)) {
sprintf (rbuf, "%08X", sim_last_cmd_stat);
ap = rbuf;
}
else if (!strcmp ("TSTATUS", gbuf)) {
sprintf (rbuf, "%s", sim_error_text (sim_last_cmd_stat));
ap = rbuf;
}
}
}
if (ap) { /* non-null arg? */
@ -2993,7 +3013,7 @@ printf ("\n");
fprint_stopped (stdout, r); /* print msg */
if (sim_log) /* log if enabled */
fprint_stopped (sim_log, r);
return SCPE_OK;
return r;
}
/* Common setup for RUN or BOOT */
@ -5036,11 +5056,13 @@ return;
/* Message Text */
char *sim_error_text (t_stat stat)
const char *sim_error_text (t_stat stat)
{
static char msgbuf[64];
stat &= ~(SCPE_KFLAG|SCPE_BREAK); /* remove any flags */
if (stat == SCPE_OK)
return "No Error";
if ((stat >= SCPE_BASE) && (stat <= SCPE_MAX_ERR))
return scp_errors[stat-SCPE_BASE].message;
sprintf(msgbuf, "Error %d", stat);

2
scp.h
View file

@ -117,7 +117,7 @@ BRKTAB *sim_brk_fnd (t_addr loc);
uint32 sim_brk_test (t_addr bloc, uint32 btyp);
void sim_brk_clrspc (uint32 spc);
char *match_ext (char *fnam, char *ext);
char *sim_error_text (t_stat stat);
const char *sim_error_text (t_stat stat);
t_stat sim_string_to_stat (char *cptr, t_stat *cond);
t_stat sim_cancel_step (void);
void sim_debug_u16 (uint32 dbits, DEVICE* dptr, const char* const* bitdefs,