1
/*===========================================================================
2
Copyright (C) 1995-2010 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/*++++++++++++++++++++++++ MIDAS monitor module PREPC1 +++++++++++++++++++++
30
.IDENTIFICATION Module PREPC1
31
.AUTHOR K. Banse ESO - Garching
35
holds ishostcom, break_line, MYBATCH
36
.VERSION [1.00] 870722: initial version built on FORTRAN version 4.40
39
-----------------------------------------------------------------------------*/
59
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
61
test, if command is Midas or Host command
63
if 1. non-blank char. is `$' it's a Host com.
64
else try to translate + see if it's a Midas command
65
if not recognized return Host com
69
------------------------------------------------------------------*/
71
char *string; /* IN: line to be checked */
74
int defset, n, m, nbra;
76
char *mypntr, *kpntr, mybuf[16];
77
char command[6], qualif[4], defqual[4];
84
while ((cc = *mypntr)) /* '\0' => 0 or false */
86
if ((cc != ' ') && (cc != '\t'))
88
if (cc == '$') return 1; /* Yes, it's a Host command */
90
if ((cc == '@') || (cc == '-'))
91
return 0; /* No, Midas procedure, Midas-host cmnd */
97
if ((kk == '\0') || (kk == ' ') || (kk == '\t'))
98
{ /* end of token reached */
99
(void) memcpy(mybuf,mypntr,(size_t)m);
101
EXTRACOM(mybuf,command,qualif);
102
if (command[0] != '\0')
104
if (FINDCOM(command,qualif,defqual,&defset,&nbra,&mypntr,&n) < 2)
105
{ /* Yes, valid Midas command found */
106
if ((nbra < 0) || (*mypntr != '$')) return 0;
109
return 1; /* not recognized as Midas command */
115
mypntr ++; /* skip over white space */
125
int break_line(more_flag,rmaind)
126
int *more_flag; /* IN/OUT: indicates if we have several commands
128
char *rmaind; /* IN/OUT: buffer holding the remainder (if any)
129
of the command line */
130
/* return -1 if only comment line, else return value > 0 */
134
int ist, apo_mode, apo_off, kk, iwb;
135
static int pipeflag = 0;
138
static char pipo[12] = "1234567890";
139
static char Mpipe[12] = "Mid Pipe "; /* length = 11 */
143
if (*more_flag != 0) /* get next command from saved remainder */
148
LINE.LEN = CGN_COPY(LINE.STR,rmaind+1);
151
LINE.LEN = CGN_COPY(LINE.STR,rmaind);
158
/* process double quotes " ... " */
161
apo_mode = 0; /* after first '"' apo_mode = 1 */
165
for (nr=apo_off; nr<LINE.LEN; nr++)
170
{ /* switch between 0 and 1 */
171
if (apo_mode == 0) apo_off = nr;
172
apo_mode ^= 1; /* XOR with 1: 0 => 1, 1 => 0 */
175
else if ((apo_mode != 0) || (sngc == ' '))
178
else if (sngc == '\t')
184
else if (sngc == '!')
186
if (iwb > 0) /* then nr > 0 ! */
189
if (LINE.STR[kk] == ' ') /* cut off at comments */
197
return (iwb); /* only comments ... */
200
else if (sngc == ';')
205
LINE.LEN -= ist; /* omit very 1. `;' */
206
(void) memcpy(LINE.STR,&LINE.STR[ist],(size_t)(LINE.LEN+1));
210
register int mr, pa, pb;
215
for (mr=kk; mr>-1; mr--)
223
if (pa > pb) continue; /* ignore ';' in (..) */
225
if (LINE.STR[kk] == '\\')
227
CGN_strcpy(&LINE.STR[kk],&LINE.STR[nr]);
229
apo_off = nr; /* start here in next run */
231
else /* single `;' found */
232
{ /* save remaining part */
233
(void) strcpy(rmaind,&LINE.STR[nr+1]);
240
goto loop1; /* start again */
243
else if (sngc == '|') /* also, look for | (pipe) */
245
if (LINE.STR[nr+1] == ' ') /* YES */
247
Mpipe[3] = FRONT.DAZUNIT[0];
248
Mpipe[4] = FRONT.DAZUNIT[1];
249
Mpipe[5] = pipo[pipeflag];
250
ist = ishostcom(LINE.STR);
251
kk = ishostcom(&LINE.STR[nr+2]);
252
if (ist == 0) /* Midascom `|' Hostcom/Midascom */
254
rmaind[0] = '^'; /* indicate <MidasPipe ... */
255
(void) strcpy(&rmaind[1],&LINE.STR[nr+2]); /* add last part */
256
LINE.STR[nr++] = '>';
257
(void) memcpy(&LINE.STR[nr],Mpipe,(size_t)12);
258
LINE.LEN = (int)strlen(LINE.STR);
263
if (kk == 0) /* Hostcom `|' Midascom */
265
rmaind[0] = '^'; /* indicate <MidasPipe ... */
266
(void) strcpy(&rmaind[1],&LINE.STR[nr+2]); /* add last part */
267
LINE.STR[nr++] = '>';
268
(void) memcpy(&LINE.STR[nr],Mpipe,(size_t)12);
269
LINE.LEN = (int)strlen(LINE.STR);
274
/* final check is for: Hostcom `|' Hostcom */
277
{ /* insert input file before `|' */
278
(void) strcpy(rmaind,&LINE.STR[nr]);
279
LINE.STR[nr++] = ' ';
280
LINE.STR[nr++] = '<';
281
Mpipe[5] = pipo[pipeflag-1];
282
(void) memcpy(&LINE.STR[nr],Mpipe,(size_t)12);
283
(void) strcat(LINE.STR,rmaind);
284
LINE.LEN = (int)strlen(LINE.STR);
287
else if (LINE.STR[nr+2] == '$')
288
LINE.STR[nr+2] = ' '; /* remove the `$' char. */
292
iwb = 1; /* all "normal" chars. end up here */
295
if (apo_mode != 0) /* = 1, so was just a single '"' */
298
apo_mode = 0; /* avoid infinite loop, if `"' very last char.! */
305
Mpipe[5] = pipo[pipeflag-1]; /* pipe from last time */
306
for (nr=LINE.LEN-2; nr>0; nr--) /* omit trailing blank */
308
if (LINE.STR[nr] == ' ')
310
if (LINE.STR[nr+1] == '>')
312
if (LINE.STR[nr+2] == '>')
313
sngc = CGN_UPPER(LINE.STR[nr+3]);
315
sngc = CGN_UPPER(LINE.STR[nr+2]);
316
if ((sngc >= 'A') && (sngc <= 'Z'))
320
(void) strcpy(savbuf,&LINE.STR[nr]);
321
LINE.STR[nr++] = ' ';
322
LINE.STR[nr++] = '<';
323
(void) memcpy(&LINE.STR[nr],Mpipe,(size_t)12);
324
(void) strcat(LINE.STR,savbuf);
325
LINE.LEN = (int) strlen(LINE.STR);
334
LINE.STR[nr++] = ' ';
335
LINE.STR[nr++] = '<';
336
(void) memcpy(&LINE.STR[nr],Mpipe,(size_t)12);
337
LINE.LEN += 13; /* 2 + 11 (= size of Mpipe) */
338
LINE.STR[LINE.LEN] = '\0'; /* just for safety */
346
void MYBATCH(cmd,procedu)
348
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
350
1) compile program - @ (@@) or # command
351
2) get next command line in "program" mode - NX command
352
3) execute a "batch" command (like *GO, *INC) - N* command
354
store program/batch file internally + execute it
355
save procedure level also in key MODE(7)
358
-------------------------------------------------------------------------*/
360
char *cmd; /* IN: @ or @% or @@ or #A, #C, #S or NX, N* ... */
361
char *procedu; /* IN: name of procedure, if needed */
365
int ibuf[20], ikey, lstep, looplim;
366
int lengthCode, m, mm, n, nn, offset, offset1, off_limit;
367
int prcnt, stat, reclen, igoto, lcount, slen;
368
int iwa, iwb, echo=0, fp=0;
369
int xt, mdebug=0, more_cmnds, unit, iav, nullo;
371
static int Mbreak[5] = {-1,-1,-1,-1,-1};
372
static int Mbreaklabl[5] = {-1,-1,-1,-1,-1};
373
static int Mdbindx, Mdbcount = -1, *Mdbline, *Mdbptr, Mdbstep;
375
char save[MAX_LINE], *cptr, string[MAX_LINE], keyname[18];
376
char label[24], compile_flag[2], k_type[12];
378
register char *tptr, *sptr, firstch, cc;
379
static char asci[9] = {'0','1','2','3','4','5','6','7','8'};
389
/* find out what to do */
395
if (KIWORDS[OFF_PRSTAT] > 0) /* test key PROGSTAT(1) */
397
iwa = KIWORDS[OFF_ERROR+2];
399
( (iwa != -1) && (iwa != KIWORDS[OFF_PRSTAT]) ) )
401
MONIT.LEVEL = 1; /* if PROGSTAT != 0 */
402
goto sect_3300; /* abort procedure...! */
405
goto execute; /* jump to execute section */
409
/* ........................................................................ */
411
/* compilation of MIDAS procedure */
413
/* ........................................................................ */
417
compile_flag[0] = *cmd; /* save @, @@ or #A or #S */
418
compile_flag[1] = *(cmd+1);
421
if (compile_flag[0] == '#')
423
if (compile_flag[1] != 'C')
424
(void) strcpy(trans_name,TOKEN[1].STR);
425
if (compile_flag[1] == 'S')
427
MONIT.COMPILED = 0; /* force it back to not-compiled */
428
CGN_UPSTR(TOKEN[2].STR);
429
if (TOKEN[2].STR[0] == 'X')
431
if ((TOKEN[2].STR[1] == ',') && (TOKEN[2].STR[2] == 'S'))
438
lcount = 0; /* clear line count */
440
iwa = ++ MONIT.LEVEL; /* MONIT.LEVEL now in [1,10] */
441
if (iwa > MAX_LEVEL) /* max. MAX_LEVEL levels of are supported */
447
MONIT.MXT[iwa] = MONIT.MXT[iwa-1]; /* inherit timeout */
448
if (MONIT.MXT[iwa] > 0)
454
MONIT.ENDT[iwa] = MONIT.ENDT[iwa-1]; /* and end time */
456
if ((ltime=oshtime()) >= MONIT.ENDT[iwa])
457
{ /* already timed out ... */
458
(void) sprintf(string,
459
"(ERR) Midas procedure %s timed out (%d seconds)",
460
PROC.FNAME,MONIT.MAXTIME);
462
KIWORDS[OFF_PRSTAT] = 998;
463
KIWORDS[OFF_PRSTAT+1] = 10;
464
MONIT.LEVEL = 1; /* force return to interactive level */
469
MONIT.ENDT[iwa] = oshtime() + MONIT.MXT[iwa]; /* calculate end time */
472
stat = CODE_ALLOC(0); /* create with default size */
473
off_limit = CODE.LEN - 2; /* hi limit of code */
481
/* check, if we use same code again */
483
if (MONIT.LEVEL <= MONIT.TOPLEVL)
486
iwa = strcmp(PROC.FNAME,&CODE.CODE[m]);
489
if (strncmp(PROC.ENTRY,&CODE.CODE[CODE_PRNAME],8) == 0)
499
*(CODE.CODE+CODE_START) = '\r'; /* set first char. of code to '\r' */
502
/* open procedure file or get already compiled code from internal.cod */
504
if (MONIT.COMPILED == 0)
507
fp = osaopen(procedu,0); /* means reading only */
509
{ /* try to open in CPATH directories */
510
if (compile_flag[1] != '@')
511
goto badcompile; /* but only for @@ command */
513
for (nr=0; nr<4; nr++)
515
if (CPATH[nr].STR[0] != '\0')
517
(void) strcpy(string,CPATH[nr].STR);
518
(void) strcat(string,procedu);
519
fp = osaopen(string,0);
520
if (fp != -1) goto open_ok;
523
if (fp == -1) goto badcompile; /* now it's really bad ... */
527
if (PROC.ENTRY[0] != ' ')
529
for (nr=7; nr>0; nr--)
531
if (PROC.ENTRY[nr] != ' ')
535
iwa = slen + 6; /* length of "ENTRY name" */
539
reclen = osaread(fp,string,MAX_LINE); /* look for: ENTRY proc_entry */
545
ERRORS.SYS = 18; /* procedure entry couldn't be found */
549
for (nr=0; nr<=(reclen-iwa); nr++)
551
if ( (string[nr] != '\t') && (string[nr] != ' ') )
553
if ( (strncmp(&string[nr],"ENTRY",5) != 0) &&
554
(strncmp(&string[nr],"entry",5) != 0) ) goto ent_loop;
556
nr += 6; /* skip over `ENTRY' + following blanks */
557
while ( (string[nr] == '\t') || (string[nr] == ' ') ) nr++;
559
CGN_UPCOPY(save,&string[nr],8);
560
if ( (strncmp(save,PROC.ENTRY,slen) == 0) ||
561
(save[0] == '*') ) /* matching or wild card entry */
564
break; /* get out of loop */
567
goto ent_loop; /* catch blank line ... */
573
stat = INTERNAL(save,TOKEN[1].STR,&lengthCode); /* get compiled code */
574
if (unlikely(stat != 0))
577
if (stat == 2) /* internal.cod not opened */
579
(void)printf("MID_PROC:internal.cod could not be opened...\n");
580
(void)printf("do '@ compile.all' to create a new internal.cod\n");
581
MONIT.LEVEL = 1; /* force exit */
587
if (unlikely(lengthCode >= off_limit))
588
{ /* for compiled code no overflow! */
599
if (MONIT.PDEBUG[MONIT.LEVEL] == 2)
600
MONIT.PDEBUG[MONIT.LEVEL] = 1; /* reset debugging flag */
602
for (nn=MONIT.COUNT; nn>2; nn--)
604
nr = nn - 1; /* move to C-indexing */
605
if ((TOKEN[nr].STR[0] != '?')
607
(TOKEN[nr].STR[1] != '\0'))
613
*CODE.CODE = asci[MONIT.COUNT-2]; /* save no. of actual pars in proc. */
614
CROSS_PARM(); /* store passed parameters in crossref table */
615
/* hold this line until we SAVE_PARM */
616
(void) memcpy(save,LINE.STR,(size_t)(LINE.LEN+1));
619
/* initialize default area */
622
memcpy((CODE.CODE+CODE_DEFS),"?\r?\r?\r?\r?\r?\r?\r?\r\r",(size_t)17);
623
nn = MONIT.LEVEL * 15;
625
memcpy(&PROC.FORMAT[nn],"4.4 15.5 15.5 ",(size_t)15); /* init FORMATs */
627
if (MONIT.COMPILED == 1)
628
goto final_save; /* if compiled code, we're already done */
631
/* check for individually compiled procedure */
633
offset = CODE_START; /* code starts at position CODE_START */
635
nn = (int) strlen(procedu);
637
{ /* look for name.prg_o */
639
if ((procedu[nn-1] == 'O') &&
640
(procedu[nn-2] == '_') &&
641
(procedu[nn-3] == 'G'))
643
if ((procedu[nn-1] == 'o') &&
644
(procedu[nn-2] == '_') &&
645
(procedu[nn-3] == 'g'))
647
{ /* Yes, we already have the compiled code */
648
reclen = osaread(fp,string,MAX_LINE); /* get size of code */
649
if (reclen < 1) goto badcompile_1;
653
if (iwa < 1) goto badcompile_1;
656
if (iwa >= off_limit) /* CODE overflow? */
658
nn = CODE.LEN + CODE.LEN; /* take twice the current size */
659
if (CODE_ALLOC(nn) == 0)
660
{ /* also updates CODE.LEN */
661
off_limit = CODE.LEN - 2; /* new high limit of code */
662
(void) memcpy((CODE.CODE+CODE_DEFS), /* CODE_ALLOC() clears! */
663
"?\r?\r?\r?\r?\r?\r?\r?\r\r",(size_t)17);
666
ERRORS.SYS = 25; /* problems with malloc ... */
671
reclen = osaread(fp,&CODE.CODE[offset],MAX_LINE);
674
CODE.CODE[offset++] = '\r';
675
CODE.CODE[offset] = '\0';
683
CODE.CODE[offset++] = '\r';
690
(void) COMPILE(8,&iwa); /* init COMPILER ... */
691
more_cmnds = 0; /* indicates, if more commands on a line */
693
rd_init: /* now work line by line... */
697
mm = break_line(&more_cmnds,string);
698
if (mm != -1) goto start_parser; /* drop comment line */
703
reclen = osaread(fp,string,MAX_LINE); /* read a record from file */
708
goto eof_found; /* EOF encountered */
710
goto rd_loop; /* empty line */
713
if ( (string[0] == '!') && (nn == 0) )
714
goto rd_loop; /* catch comments already here */
716
if ((reclen + nn) >= MAX_LINE)
717
{ /* check length of combined input line */
722
(void) memcpy(&LINE.STR[nn],string,(size_t)(reclen+1));
723
LINE.LEN = reclen + nn;
724
if (string[reclen-1] == '-') /* continuation lines? */
726
for (nr=0; nr<reclen-1; nr++) /* test for " !" first... */
728
if (string[nr] == '!')
735
if ((string[iwa] == ' ') ||
736
(string[iwa] == '\t')) /* tab instead of blank */
742
nn = LINE.LEN - 1; /* drop continuation character */
747
LINE.STR[LINE.LEN] = '\0';
749
mm = break_line(&more_cmnds,string);
750
if (mm == -1) goto rd_init; /* drop comment line */
753
/* now parse command line stored in LINE.STR */
756
ERRORS.SYS = PARSE(0,0,0); /* raw parsing */
757
if (unlikely(ERRORS.SYS != 0))
763
if (MONIT.COUNT < 1) goto rd_init; /* nothing there */
766
/* look for commands which have to be compiled */
771
if ( (firstch != '$') && /* avoid Host + immediate commands */
772
((TOKEN[1].STR[0] != '=') || (TOKEN[1].LEN != 1)) )
776
if (TOKEN[0].STR[TOKEN[0].LEN-1] == ':') /* first, test for labels */
778
if (unlikely ((firstch >= '0') && (firstch <= '9')) )
784
MONIT.COUNT = 1; /* ignore trailing stuff */
785
iwa = offset + TOKEN[0].LEN + 1;
789
if (strcmp(tptr,"END") == 0) /* look for END IF, END DO */
791
CGN_UPCOPY(KAUX.STR,TOKEN[1].STR,3);
792
if (KAUX.STR[2] == '\0')
794
if ((KAUX.STR[0] == 'D') && (KAUX.STR[1] == 'O'))
799
else if ((KAUX.STR[0] == 'I') && (KAUX.STR[1] == 'F'))
808
for (n=0; n<MAX_BATCH; n++)
810
if (strcmp(tptr,BATCH[n].CMND) == 0)
812
iwa = offset; /* check for CODE overflow */
813
for (nr=0; nr<MONIT.COUNT; nr++)
814
iwa += TOKEN[nr].LEN;
815
iwa += 64; /* add space for expansion */
816
if (iwa >= off_limit) /* in COMPILE */
819
ERRORS.SYS = COMPILE(n,&offset);
820
if (ERRORS.SYS == 0) /* check for syntax errors */
821
goto rd_init; /* all o.k. - get next line */
823
perror = 0; /* something wrong... */
829
/* if first token is ENTRY, treat it like an EOF */
831
if (strcmp(tptr,"ENTRY") == 0)
835
/* look for GOTO, PAUSE, BRANCH, CROSSREF, RETURN + preprocess it */
837
if ( (strcmp(tptr,"GOTO") == 0) ||
838
(strcmp(tptr,"BRANCH") == 0) ||
839
(strcmp(tptr,"CROSSREF") == 0) )
842
if (strcmp(tptr,"PAUSE") == 0)
846
nn = CGN_COPY(tempy,"move/local out^*PA^^");
848
if (iwa >= off_limit) /* CODE overflow? */
851
for (nr=0; nr<nn; nr++)
853
if (tempy[nr] == '^') tempy[nr] = '\r';
855
(void) strcpy(&CODE.CODE[offset],tempy);
860
if (strncmp(tptr,"RETURN",6) == 0)
862
if ( (*(tptr+6) == '/') && (*(tptr+7) == 'E') )
863
*(tptr+1) = 'X'; /* take care of RETURN/EXIT */
866
*(tptr+2) = *(tptr+1);
874
/* now fill CODE with command string */
877
for (nr=0; nr<MONIT.COUNT; nr++) iwa += TOKEN[nr].LEN;
878
iwa += MONIT.COUNT; /* we also need that many blanks */
881
if (iwa >= off_limit) /* CODE overflow? */
883
nn = 2 * CODE.LEN; /* take twice the current size */
884
stat = CODE_ALLOC(nn);
885
off_limit = CODE.LEN - 2; /* hi limit of code */
886
if (unlikely(stat != 0))
893
LINE.LEN = CGN_COPY(LINE.STR,save); /* get back original */
894
(void) PARSE(1,0,0); /* line ... */
898
for (nr=0; nr<MONIT.COUNT; nr++)
901
(void) memcpy(&CODE.CODE[offset],TOKEN[nr].STR,(size_t)mm);
903
CODE.CODE[offset++] = ' ';
906
CODE.CODE[offset-1] = '\r';
907
CODE.CODE[offset] = '\r';
908
CODE.CODE[offset+1] = '\0';
912
/* EOF encountered */
917
stat = COMPILE(9,&offset); /* check nesting levels... */
924
lengthCode = offset + 1; /* get length of code */
927
/* save final parameters in keys P1 ... P8 */
929
final_save: /* save program counters */
930
ERRORS.SYS = SAVE_PARM(1,&nn);
933
(void) strncpy(LINE.STR,save,80);
935
LINE.STR[LINE.LEN] = '\0';
940
/* set ProgCounter for higher level to start of code */
942
MONIT.PCODE[MONIT.LEVEL-1] = nn;
945
/* now check for debug mode */
947
if ((MONIT.PDEBUG[MONIT.LEVEL] > 0) && (compile_flag[0] != '#'))
949
MONIT.PDEBUG[MONIT.LEVEL] = 1; /* force to stepwise mode */
951
{ /* allocate space for */
952
char *pbuf; /* Mdb line count */
954
pbuf = malloc((size_t)CODE.LEN);
955
if (pbuf == (char *) NULL)
957
(void) printf("could not allocate memory for Mdbline ...\n");
958
MONIT.PDEBUG[MONIT.LEVEL] = 0; /* reset switch */
961
Mdbptr = (int *) pbuf; /* points to allocated space */
964
/* fill array Mdbline with offsets (in CODE.CODE) for each line */
966
Mdbstep = 0; /* no. of steps in `step' command */
968
Mdbcount = 0; /* reset the line counter */
971
if (strncmp(&CODE.CODE[iwa],"*CR",3) == 0) /* check, if CROSSREF cmnd */
973
nn = CGN_INDEXC(&CODE.CODE[iwa],'\r'); /* Yes, so skip it */
978
nn = CGN_INDEXC(&CODE.CODE[iwa],'\r');
981
*Mdbline++ = iwa; /* save offset of CODE.CODE */
987
for (nr=0; nr<5; nr++) /* clear breakpoints */
989
if (Mbreak[nr] >= MONIT.LEVEL)
990
Mbreak[nr] = -1; /* reset it */
993
printf("\nMidas debugger (Mdb) running procedure `%s' with %d lines\n\n",
998
/* if we compile, call INTERNAL with A(dd) option */
1001
if (compile_flag[0] != '#')
1003
KIWORDS[OFF_MODE+6] = MONIT.LEVEL; /* update MODE(7) for local keys */
1004
(void) strncpy(&CODE.CODE[CODE_PRNAME],PROC.ENTRY,8); /* save entry */
1005
m = CODE_PRNAME + 8;
1006
(void) memcpy(&CODE.CODE[m],PROC.FNAME,(size_t)80); /* and procedure name */
1007
CODE.CODE[m+80] = '\0'; /* limit to 80 chars. */
1013
if (compile_flag[1] == 'S') /* handle TRANSLATE/SHOW */
1018
offset = CODE_START;
1019
tokovf = 0; /* TOKEN overflow flag */
1020
iwb = 0; /* error count */
1022
show_loop: /* find end of current command line */
1023
mm = CGN_INDEXC(&CODE.CODE[offset],'\r');
1024
if (mm < 1) /* end of procedure */
1030
SCTPUT("----------------");
1031
(void) sprintf(LINE.STR,"total length = %d chars",offset);
1035
CGN_CLEANF(trans_name,6,KAUX.STR,64,&nn,&nn);
1038
(void) sprintf(LINE.STR,"%s: %d warnings encountered ...",
1044
(void) sprintf(LINE.STR,"%s: %d severe warnings encountered ...",
1048
warn[0] = iwb + tokovf;
1050
if ((warn[0] == 0) && (xt != 2))
1052
(void) sprintf(LINE.STR,"%s: all o.k. ",KAUX.STR);
1056
(void) SCKWRI("MID$INFO",warn,1,2,&unit);
1057
goto sect_2300; /* move back up */
1061
/* now check the comm/qualif string */
1063
(void) strncpy(LINE.STR,&CODE.CODE[offset],mm);
1064
LINE.STR[mm] = '\0';
1067
nn = PARSE(-1,0,0); /* parse again to get TOKEN structure filled */
1069
{ /* suspicious ... */
1070
if ( ((TOKEN[1].STR[0] == '=') && (TOKEN[1].LEN == 1))
1071
|| (TOKEN[0].STR[0] == '$') )
1076
(void) strcpy(string,"----- more than 10 TOKEN in line: ");
1099
m = CGN_INDEXS(cptr,type);
1100
if ((m > 0) && (*(cptr+m-1) != ' ') && (*(cptr+m-1) != '{') )
1102
n = CGN_INDEXC(cptr,'}');
1103
if ((n > m) && (*(cptr+n+1) == '"'))
1105
int sbytelem, snoelem;
1108
(void) strncpy(string,cptr+nn,n-nn);
1109
string[n-nn] = '\0';
1110
if ( (CGN_INDEXC(string,',') > 0) ||
1111
(CGN_INDEXC(string,'[') > 0) ) goto do_show_loop;
1113
nn = MID_FNDKEY(string,type,&sbytelem,&snoelem,&unit);
1114
if ( ((nn == -1) || (type[0] == 'C')) ||
1115
(CGN_INDEXS(cptr,"M$") > 0) )
1124
SCTPUT("----- bad coding style");
1127
(void) strcpy(string,cptr);
1128
(void) strcpy(&string[m],cptr+m+2);
1129
if (*(cptr+n+2) == '\0')
1132
(void) strcpy(&string[n-2],cptr+n+2);
1133
(void) strcpy(LINE.STR,string);
1143
(void) strcpy(string,"----- should be: "); /* length = 17 */
1144
(void) strcpy(&string[17],cptr);
1150
if ((*cptr == '$') || (*cptr == '-') ||
1151
(*cptr == '@') || (*cptr == '*') || (*(cptr+1) == ','))
1152
goto do_show_loop; /* skip special commands */
1154
nn = CGN_INDEXC(cptr,' ');
1156
{ /* check for immediate commands */
1157
if ((*(cptr+nn+1) == '=') && (*(cptr+nn+2) == ' '))
1163
if (*(cptr+nn-1) == ':') goto do_show_loop; /* avoid labels */
1165
(void) strncpy(string,cptr,nn);
1167
EXTRACOM(string,save,label);
1168
(void) strncpy(&save[10],save,6);
1169
(void) strncpy(&label[10],label,4);
1170
if (label[10] == ' ')
1172
for (nr=0; nr<6; nr++)
1174
if (save[nr] == '{') goto do_show_loop;
1176
if ((strncmp(save,"RUN ",4) != 0) /* if it's not RUN */
1178
(strncmp(save,"HELP",4) != 0) /* nor HELP */
1180
(strncmp(save,"BYE ",4) != 0)) /* nor BYE */
1186
SCTPUT("----- command without qualifier");
1192
m = FINDCOM(save,label,&string[100],&n,&n,&cptr,&nn);
1193
if (m > 1) goto do_show_loop; /* command not found */
1195
for (nr=0; nr<6; nr++)
1197
if (save[nr] != save[10+nr])
1203
SCTPUT("----- incomplete command");
1208
for (nr=0; nr<4; nr++)
1210
if (label[nr] != label[10+nr])
1216
SCTPUT("----- incomplete qualifier");
1221
if ((strncmp(save,"COMPUT",6) != 0) /* check for COMPUTE/KEYW */
1223
(strncmp(label,"KEYW",4) != 0)) goto do_show_loop;
1226
nn = CGN_INDEXS(cptr," = ");
1227
m = CGN_INDEXC(cptr,'{');
1228
if ( (m > 0) && (*(cptr+m+1) != '{') ) /* avoid nested substitutions */
1232
kptr = cptr + nn + 3; /* point to expression */
1233
(void)strcpy(ops,"+-*/");
1234
for (nr=0; nr<4; nr++)
1236
if (CGN_INDEXC(kptr,ops[nr]) > 0)
1238
n = CGN_INDEXC(cptr,'}');
1241
int unit, sbytelem, snoelem;
1244
(void) strncpy(string,cptr+nn,n-nn);
1245
string[n-nn] = '\0';
1246
if ( (CGN_INDEXC(string,',') > 0) ||
1247
(CGN_INDEXC(string,'[') > 0) ) goto do_show_loop;
1249
nn = MID_FNDKEY(string,type,&sbytelem,&snoelem,&unit);
1250
if ((nn == -1) || (type[0] != 'C'))
1259
SCTPUT("----- bad coding style");
1262
(void) strcpy(string,cptr);
1263
(void) strcpy(&string[m],cptr+m+1);
1264
if (*(cptr+n+1) == '\0')
1267
(void) strcpy(&string[n-1],cptr+n+1);
1268
(void) strcpy(LINE.STR,string);
1275
if ( (bad == 1) && (xt == 1) )
1277
(void) strcpy(string,"----- should be: "); /* length = 17 */
1278
(void) strcpy(&string[17],cptr);
1287
else if (compile_flag[1] == 'C') /* handle TRANSLATE/PROC */
1291
n = KIWORDS[OFF_MONPAR+10]; /* MONITPAR(11) = debug flag */
1292
if (opti_code(&lengthCode,1,n) != 0)
1294
ERRORS.SYS = 25; /* optimized code => output0.cprg */
1295
(void)sprintf(string,"problems in code optimzation...");
1297
MONIT.LEVEL = 1; /* force exit */
1301
fp = osaopen("output0.cprg",0);
1302
if (fp < 1) goto badcompile_1;
1304
(void) strcpy(string,procedu); /* build procedu_o name */
1305
(void) strcat(string,"_o");
1306
gp = osaopen(string,1);
1307
if (gp < 1) goto badcompile_1;
1308
nn = sprintf(string,"%d",lengthCode); /* first line = size of code */
1309
(void) osawrite(gp,string,nn);
1312
reclen = osaread(fp,string,MAX_LINE);
1315
(void) osawrite(gp,string,reclen);
1318
(void) osaclose(fp);
1319
(void) osaclose(gp);
1320
(void) sprintf(string,"procedure %s: total length = %d chars. ",
1321
procedu,lengthCode);
1322
SCTPUT(string); /* show total length */
1326
{ /* store compiled code */
1327
stat = INTERNAL(&compile_flag[1],trans_name,&lengthCode);
1331
if (stat == 2) /* internal.cod not opened */
1333
(void)printf("MID_PROC:internal.cod could not be opened...\n");
1334
(void)printf("do '@ compile.all' to create a new internal.cod\n");
1335
MONIT.LEVEL = 1; /* force exit */
1341
(void) sprintf(string,"procedure %s: total length = %d chars. ",
1342
trans_name,lengthCode);
1343
SCTPUT(string); /* show total length */
1347
/* MONIT.LEVEL has to be reset ... */
1351
if (MONIT.LEVEL > 0) /* if we are inside a procedure, */
1353
nr = MONIT.LEVEL - 1;
1354
CODE.CODE = TRANSLATE[nr].PNTR[0];
1355
CODE.LEN = TRANSLATE[nr].LEN[0];
1365
if (ERRORS.INDEX == -1)
1366
PREPERR("MIDAS",LINE.STR," ");
1368
PREPERR("MIDAS",LINE.STR,TOKEN[ERRORS.INDEX].STR);
1370
if (KIWORDS[OFF_ERROR+3] != 0)
1372
(void) sprintf(string,"In Midas procedure: %s, line %d",PROC.FNAME,lcount);
1373
SCTMES(M_RED_COLOR,string);
1378
if (MONIT.LEVEL > 0) /* if we are inside a procedure, */
1380
nn = MONIT.LEVEL - 1;
1381
CODE.CODE = TRANSLATE[nn].PNTR[0];
1382
CODE.LEN = TRANSLATE[nn].LEN[0];
1389
/*..............................................................*/
1391
/* execution of MIDAS procedures */
1393
/*..............................................................*/
1398
offset = MONIT.PCODE[MONIT.LEVEL-1]; /* get program counter */
1399
echo = MONIT.ECKO[MONIT.LEVEL];
1400
mdebug = MONIT.PDEBUG[MONIT.LEVEL];
1401
if ((mdebug == 1) && (echo < 1))
1402
echo = 1; /* force echo for stepwise debugging */
1404
if (*(cmd+1) == '*')
1406
*(cmd+1) = 'X'; /* reset the command to NX */
1407
goto test_line; /* and go execute the stuff stored in TOKEN */
1411
/* in debugging mode continue only after (some) key is hit */
1415
tptr = &CODE.CODE[offset];
1418
{ /* find end of comline */
1423
if (LINE.LEN < 1) goto sect_3300; /* check for end of program */
1432
prcnt = offset + LINE.LEN + 1; /* update ProgCounter */
1434
offset = prcnt; /* let 'offset' point to next command */
1436
ERRORS.SYS = PARSE(2,echo,MONIT.LEVEL); /* parse command string */
1437
if (ERRORS.SYS != 0) /* error in parsing the string */
1446
Mdbline = Mdbptr; /* reset to begin of array */
1448
for (nr=0; nr<Mdbcount; nr++)
1453
Mdbindx = nr + 1; /* line count starts at 1 */
1460
printf("problems with Midas debugger - please, report it to ESO...\n");
1465
MONIT.PDEBUG[MONIT.LEVEL] = 1; /* enable stepwise debugging */
1466
(void) strcpy(TOKEN[0].STR,"*PA");
1471
if (mdebug > 1) /* test for break point */
1473
for (nr=0; nr<5; nr++)
1475
if ( (Mbreak[nr] == MONIT.LEVEL) &&
1476
(Mbreaklabl[nr] == Mdbindx) )
1478
(void) printf("breakpoint: %4.4d %s\n\r",Mdbindx,LINE.STR);
1482
goto test_line; /* no breakpoint matches */
1485
if (Mdbstep > 1) /* step count */
1487
for (nr=0; nr<5; nr++)
1489
if ( (Mbreak[nr] == MONIT.LEVEL) &&
1490
(Mbreaklabl[nr] == Mdbindx) )
1492
(void) printf("breakpoint: %4.4d %s\n\r",Mdbindx,LINE.STR);
1497
goto test_line; /* continue */
1502
if (MONIT.CTRLC == 1)
1504
MONIT.LEVEL = 1; /* if Cntrl/C */
1505
MONIT.CTRLC = 0; /* clear flag again */
1506
goto sect_3300; /* and abort procedure ! */
1509
(void) printf("Mdb (%4.4d) > ",Mdbindx); /* get input the standard way */
1510
CGN_GETLINE(string,40);
1512
if (string[0] == '\0') /* RETURN */
1516
MONIT.PDEBUG[MONIT.LEVEL] = 1; /* enable stepwise debugging */
1517
mdebug = MONIT.PDEBUG[MONIT.LEVEL];
1520
else if (string[0] == 'c') /* continue */
1522
MONIT.PDEBUG[MONIT.LEVEL] = 2; /* disable stepwise debugging */
1523
mdebug = MONIT.PDEBUG[MONIT.LEVEL];
1525
else if ((string[0] == 'r') && (string[1] == 'e')) /* rerun */
1527
offset = CODE_START;
1528
CLEAR_LOCAL(MONIT.LEVEL); /* clear local keyw.at curr. level */
1531
else if (string[0] == 'q') /* quit */
1533
MONIT.LEVEL = 1; /* return to interactive level */
1536
else if ((string[0] == 'p') && (string[1] == 'a')) /* pause */
1538
prcnt = offset1; /* reset to begin of current command line */
1539
MONIT.PDEBUG[MONIT.LEVEL] = 77; /* indicate `PAUSE' for next round */
1540
LINE.LEN = CGN_COPY(LINE.STR,"move/local out"); /* save local keys */
1541
(void) PARSE(2,0,0); /* in this round */
1543
else if (string[0] == 'p') /* print keyword */
1545
iwa = MID_DSPKEY(&string[2],'x');
1546
if (iwa != ERR_NORMAL) (void) printf("invalid keyname...\n\r");
1549
else if (string[0] == 's') /* step `nostp' */
1552
if (string[1] != '\0')
1554
(void) CGN_CNVT(&string[2],1,1,&mm,&rwa,&dwa);
1559
else if (string[0] == 'l') /* list */
1561
mm = 20; /* no. of lines to show */
1562
if (string[1] != '\0')
1564
ibuf[0] = ibuf[1] = -1;
1565
(void) CGN_CNVT(&string[2],1,2,ibuf,&rwa,&dwa);
1568
else if (ibuf[0] > Mdbcount) ibuf[0] = Mdbcount;
1569
if (ibuf[1] < ibuf[0]) ibuf[1] = ibuf[0] + mm - 1;
1570
mm = ibuf[1] - ibuf[0] + 1;
1572
if (ibuf[0] == Mdbindx)
1576
Mdbline = Mdbptr; /* reset to begin of array */
1583
for (nr=0; nr<iwb; nr++)
1585
nn = CGN_INDEXC(&CODE.CODE[iwa],'\r');
1593
for (nr=0; nr<mm; nr++)
1595
nn = CGN_INDEXC(&CODE.CODE[iwa],'\r');
1598
(void) sprintf(string,"%4.4d ",Mdbindx);
1599
(void) strncpy(&string[5],&CODE.CODE[iwa],nn);
1600
string[nn+5] = '\0';
1601
(void) printf("%s\n\r",string);
1606
break; /* end of procedure */
1610
else if (string[0] == 'b') /* breakpoint handling */
1612
if (string[1] == 's') /* bs(how) */
1614
for (nr=0; nr<5; nr++)
1616
if (Mbreak[nr] != -1)
1618
(void) printf("breakpoint at line %4.4d for level = %d\n\r",
1619
Mbreaklabl[nr],Mbreak[nr]);
1623
else if (string[1] == 'c') /* bc(ancel) */
1625
n = CGN_CNVT(&string[3],1,1,ibuf,&rwa,&dwa);
1628
if (string[3] == 'a')
1630
for (nr=0; nr<5; nr++)
1634
(void) printf("invalid breakpoint...\n\r");
1638
for (nr=0; nr<5; nr++)
1640
if (Mbreaklabl[nr] == ibuf[0])
1650
n = CGN_CNVT(&string[2],1,1,ibuf,&rwa,&dwa);
1652
(void) printf("invalid breakpoint...\n\r");
1655
for (nr=0; nr<5; nr++)
1657
if (Mbreak[nr] == -1)
1659
Mbreak[nr] = MONIT.LEVEL;
1660
Mbreaklabl[nr] = ibuf[0];
1668
else if ((string[0] == 'h') || (string[0] == '?'))
1670
(void) printf("RETURN - execute displayed command\n");
1671
(void) printf("s count - step through (execute) `count' commands\n");
1673
("c - continue until end of current procedure or next breakpoint\n");
1675
(void) printf("rerun - restart procedure again\n");
1676
printf("quit - stop debugging + return to interactive level\n");
1678
("l la,lb - list the procedure from line `la' to `lb'\n");
1680
("b bp - set breakpoint at line `bp' of current proc.\n");
1681
(void) printf("bs - show current breakpoints \n");
1682
(void) printf("bc bp - cancel breakpoint at line `bp' \n");
1684
("pause - interrupt debugging + return to interactive level\n");
1685
(void) printf(" there you can execute any MIDAS command\n");
1686
(void) printf(" to resume debugging enter CONTINUE ...\n");
1688
("p keyname - print (display) contents of keyword 'keyname'\n");
1689
(void) printf("h (or ?) - display this help\n");
1696
/* test, if special command,
1697
i.e. label:, *IF, *JF, *INC, *JNC, *BR, *GO, *JO, *RE, *PA */
1704
if (TOKEN[0].STR[TOKEN[0].LEN-1] == ':') goto get_line; /* skip */
1707
/* only check for '*' as first char. */
1709
if (TOKEN[0].STR[0] != '*')
1710
{ /* update program flags + bye, bye */
1711
MONIT.PCODE[MONIT.LEVEL-1] = prcnt; /* save Program Counter */
1715
firstch = TOKEN[0].STR[1];
1724
if (TOKEN[0].STR[2] == 'N')
1727
KEY_PARSE(TOKEN[1].STR,keyname,k_type,&iwb,&iwa,&n,&n);
1728
if (k_type[0] != 'I') goto badinc; /* has to be integer key */
1730
stat = SCKRDI(keyname,iwa,1,&iav,&ikey,&unit,&nullo);
1731
if (stat != 0) goto badinc;
1733
n = CGN_CNVT(TOKEN[2].STR,1,1,&lstep,&rwa,&dwa);
1737
(void) memcpy(save," ",(size_t)9); /* include the '\0' */
1738
KEY_PARSE(TOKEN[2].STR,save,k_type,&iwb,&mm,&n,&n);
1739
if (k_type[0] != 'I') goto badinc; /* has to be integer key */
1741
stat = SCKRDI(save,mm,1,&iav,&lstep,&unit,&nullo);
1742
if (stat != 0) goto badinc;
1745
n = CGN_CNVT(TOKEN[3].STR,1,1,&looplim,&rwa,&dwa);
1749
(void) memcpy(save," ",(size_t)9); /* include the '\0' */
1750
KEY_PARSE(TOKEN[3].STR,save,k_type,&iwb,&mm,&n,&n);
1751
if (k_type[0] != 'I') goto badinc; /* has to be integer key */
1753
stat = SCKRDI(save,mm,1,&iav,&looplim,&unit,&nullo);
1754
if (stat != 0) goto badinc;
1757
ikey += lstep; /* in/decrement loop variable */
1760
if (ikey < looplim) goto get_line;
1764
if (ikey > looplim) goto get_line;
1767
stat = SCKWRI(keyname,&ikey,iwa,1,&unit); /* only now update */
1775
nn = 4; /* emulate goto TOKEN[4].STR: */
1776
offset = CODE_START+1;
1777
igoto = 1; /* we start at the top */
1778
goto sect_2800; /* continue like normal goto command */
1782
(void) strcpy(LINE.STR,"DO "); /* rebuild original DO command */
1783
(void) strcat(LINE.STR,TOKEN[1].STR);
1785
(void) strcpy(&LINE.STR[n]," = ");
1787
(void) sprintf(save,"%d ",ikey);
1788
(void) strcpy(&LINE.STR[n],save);
1789
(void) strcat(LINE.STR,TOKEN[3].STR);
1790
n = (int) strlen(LINE.STR);
1791
LINE.STR[n++] = ' ';
1792
(void) strcpy(&LINE.STR[n],TOKEN[2].STR);
1802
mm = EVALU(1); /* evaluate logical expr. starting at TOKEN(2) */
1810
if (TOKEN[4].STR[0] == '*') /* IF a .xy. b *RE */
1814
nn = 4; /* .TRUE. */
1816
goto sect_2800; /* emulate a forward: GOTO TOKEN[4]: */
1820
goto get_line; /* .FALSE. => get next command line */
1829
GETOP(TOKEN[1].STR,TOKEN[1].LEN,&ikey,&rkey,save,&dkey,&sdum,
1830
k_type,82); /* get branch variable/constant... */
1832
if (k_type[0] == 'I')
1833
{ /* convert comparisons */
1834
m = CGN_CNVT(TOKEN[2].STR,1,20,ibuf,&rwa,&dwa);
1842
for (nr=0; nr<m; nr++)
1844
if (ikey == ibuf[nr])
1853
else if (k_type[0] == 'C')
1858
for (nr=0; nr<20; nr++)
1860
m = CGN_EXTRSS(TOKEN[2].STR,TOKEN[2].LEN,',',&iwa,string,40);
1861
if (m < 1) goto get_line; /* no match, goto next line */
1864
if (strcmp(save,string) == 0)
1874
ERRORS.SYS = 17; /* invalid type of branch variable */
1878
goto get_line; /* no match, goto next line */
1881
/* match found, now branch */
1886
for (nr=0; nr<=mm; nr++) /* extract corresponding label */
1888
m = CGN_EXTRSS(TOKEN[3].STR,TOKEN[3].LEN,',',&iwa,string,40);
1889
if (m < 0) goto get_line;
1891
(void) strcpy(TOKEN[4].STR,string);
1894
igoto = 0; /* first, try from here on */
1895
goto sect_2800; /* simulate a forward goto */
1903
nn = 1; /* TOKEN[1] holds label */
1904
igoto = 0; /* first try forward jump */
1909
CGN_UPCOPY(&label[1],TOKEN[nn].STR,nr);
1911
label[++nr] = '\r'; /* build search string */
1912
label[++nr] = '\0'; /* build search string */
1913
offset --; /* label may come right now...*/
1916
n = CGN_INDEXS(&CODE.CODE[offset],label);
1917
if (n >= 0) /* all o.k. */
1920
goto get_line; /* get next line ... */
1924
/* required label not found... */
1926
if (igoto == 0) /* try backward jump */
1929
offset = CODE_START;
1936
if ( strncmp(&CODE.CODE[offset],&label[1],n) == 0 )
1937
{ /* at beginning of code (no leading \r) */
1938
offset += n; /* offset was set to CODE_START */
1943
/* no. We really have no chance... */
1945
(void) strcpy(LINE.STR,"GOTO ");
1946
(void) strcat(LINE.STR,TOKEN[nn].STR);
1953
/* *JF, *JNC, *JO */
1957
cc = TOKEN[0].STR[2];
1958
if (cc == 'O') /* GO offset */
1961
nn = 4; /* *IF / *INC . . . offset */
1962
/* get new offset in CODE.CODE */
1963
n = CGN_CNVT(TOKEN[nn].STR,1,1,ibuf,&rwa,&dwa);
1971
if (cc == 'O') /* GO ... */
1977
else if (cc == 'F') /* IF ... */
1979
mm = EVALU(1); /* same stuff as in *IF section above */
1987
if (TOKEN[4].STR[0] == '*') /* IF a .xy. b *RE */
1992
goto get_line; /* .FALSE. => get next command line */
2003
if (firstch == 'R') /* RETURN q1 q2 q3 */
2005
if (TOKEN[0].STR[2] == 'X')
2006
MONIT.LEVEL = 1; /* RETURN/EXIT terminates everything... ! */
2008
{ /* for Q1, Q2, Q3 */
2009
for (nr=0; nr<3; nr++)
2011
nn = MONIT.POFF[8+nr];
2012
(void) memcpy(&KCWORDS[nn],TOKEN[nr+1].STR,(size_t)60);
2015
goto sect_3300; /* terminate this level (at least...) */
2023
if (MONIT.PAUSLEVL >= 0) /* avoid nested PAUSE commands */
2025
if (TOKEN[0].STR[2] == 'D') /* here from Mdb */
2026
(void) printf("Old PAUSEd procedure code is overwritten...\n");
2029
(void) strcpy(LINE.STR,"PAUSE ");
2036
MONIT.PCODE[MONIT.LEVEL-1] = prcnt; /* save the PC */
2037
for (nr=0; nr<MAX_LEVEL; nr++)
2039
MONIT.QDEBUG[nr+1] = MONIT.PDEBUG[nr+1];
2040
MONIT.QCODE[nr] = MONIT.PCODE[nr];
2041
TRANSLATE[nr].LEN[1] = TRANSLATE[nr].LEN[0];
2042
TRANSLATE[nr].LEN[0] = 0; /* we should not free that memory... */
2043
TRANSLATE[nr].PNTR[1] = TRANSLATE[nr].PNTR[0];
2046
(void) strcpy(PROC.QNAME,PROC.FNAME); /* save name of interrupted proc. */
2047
MONIT.PAUSLEVL = MONIT.LEVEL;
2048
MONIT.INTERRUPT = 1;
2050
if (TOKEN[0].STR[2] == 'D') /* here from Mdb */
2052
for (nr=1; nr<MAX_LEV1; nr++) /* to avoid nr<=MAX_LEVEL ... */
2053
MONIT.PDEBUG[nr] = 0; /* no debugging initially */
2056
MONIT.LEVEL = 1; /* like RETURN/EXIT */
2060
ERRORS.SYS = 5; /* all that remains is "wrong syntax" ...*/
2063
/* problems during compilation and execution */
2068
if (ERRORS.INDEX == -1)
2069
PREPERR("MIDAS",LINE.STR," ");
2071
PREPERR("MIDAS",LINE.STR,TOKEN[ERRORS.INDEX].STR);
2073
if (KIWORDS[OFF_ERROR+3] != 0)
2075
(void) sprintf(string,"In Midas procedure: %s",PROC.FNAME);
2076
SCTMES(M_RED_COLOR,string);
2079
if (KIWORDS[OFF_ERROR+6] == 0) /* error _flag for `batch' mode */
2080
MONIT.LEVEL = 1; /* force return to interactive level */
2088
/* ........................................................... */
2091
/* end of program - backup to higher level */
2093
/* ........................................................... */
2097
CLEAR_LOCAL(MONIT.LEVEL); /* clear any local keys... */
2100
/* if, next higher level still > 0, get back corresponding code */
2102
if (MONIT.LEVEL <= 1)
2106
KIWORDS[OFF_MODE+6] = 0;
2107
KIWORDS[OFF_LOG+3] = 0; /* make sure to enable display */
2109
(void) MID_CCLO(-1);
2110
if (MONIT.FRAME_USED != ' ') /* close all open images/tables */
2111
FRAMACC('X',KAUX.OUT,0,&iav);
2112
return; /* in interactive mode */
2116
if (MONIT.TOPLEVL < MONIT.LEVEL) /* follow highest level */
2117
MONIT.TOPLEVL = MONIT.LEVEL;
2119
KIWORDS[OFF_MODE+6] = -- MONIT.LEVEL; /* decrement procedure level */
2120
nn = MONIT.LEVEL - 1;
2121
CODE.CODE = TRANSLATE[nn].PNTR[0];
2122
CODE.LEN = TRANSLATE[nn].LEN[0];
2123
fixout(0,MONIT.LEVEL); /* try to close output file */
2124
(void) MID_CCLO(-1); /* close all catalogs */
2127
/* do not forget to reset the parameter keys also... */
2130
goto execute; /* fetch next instruction from higher level procedure */