SCP: Add GOTO :EOF as a means of returning from a DO command

This commit is contained in:
Mark Pizzolato 2020-03-25 14:41:03 -07:00
parent 998f2a5254
commit 7d1a81b9f9

11
scp.c
View file

@ -1755,6 +1755,10 @@ static const char simh_help[] =
" in the current do command file which is encountered. Since labels\n"
" don't do anything else besides being the targets of goto's, they could\n"
" also be used to provide comments in do command files.\n\n"
"++GOTO :EOF\n\n"
" The target label of :EOF is explicitly defined to mean the end of the\n"
" DO command file. This will cause the execution to return from the current\n"
" command file.\n\n"
"4Examples\n\n"
"++:: This is a comment\n"
"++echo Some Message to Output\n"
@ -5049,6 +5053,13 @@ if ('\0' == gbuf1[0]) /* unspecified goto targ
fpos = ftell(sim_gotofile); /* Save start position */
if (fpos < 0)
return sim_messagef (SCPE_IERR, "goto ftell error: %s\n", strerror (errno));
if (strcasecmp(":EOF", gbuf1) == 0) {
if (fseek (sim_gotofile, 0, SEEK_END))
return sim_messagef (SCPE_IERR, "goto seek error: %s\n", strerror (errno));
sim_brk_clract (); /* goto defangs current actions */
sim_do_echo = saved_do_echo; /* restore echo mode */
return SCPE_OK;
}
rewind(sim_gotofile); /* start search for label */
sim_goto_line[sim_do_depth] = 0; /* reset line number */
sim_do_echo = 0; /* Don't echo while searching for label */