1 /*****************************************************************************
2
3 GetNmA()
4
5 This function "gets the numeric argument". When a command which takes
6 a numeric argument is executed, it checks whether the expression stack is
7 empty. If the expression stack is not empty, this function is called to get
8 the numeric argument on the expression stack into global variable Number.
9
10 It is assumed that the calling function checked that the expression
11 stack is non-empty (i.e. that EStTop > EStBot). This function checks that
12 the expression stack contains an operand (not an operator). If it does, the
13 operand is removed from the stack and placed in NArgmt.
14
15 *****************************************************************************/
16
17 #include "zport.h" /* define portability identifiers */
18 #include "tecoc.h" /* define general identifiers */
19 #include "defext.h" /* define external global variables */
20 #include "deferr.h" /* define identifiers for error messages */
21
GetNmA()22 DEFAULT GetNmA() /* get numeric argument */
23 {
24 DBGFEN(2,"GetNmA",NULL);
25
26 if (EStack[EStTop].ElType == OPERAND) { /* it's an operand */
27 NArgmt = EStack[EStTop].Elemnt;
28 --EStTop;
29 #if DEBUGGING
30 sprintf(DbgSBf,"SUCCESS, NArgmt = %ld",NArgmt);
31 DbgFEx(2,DbgFNm,DbgSBf);
32 #endif
33 return SUCCESS;
34 }
35
36 #if DEBUGGING
37 sprintf(DbgSBf,"dying with IFE, EstBot = %ld, stack =",(LONG)EStBot);
38 DbgFMs(2,DbgFNm,DbgSBf);
39 while (EStTop > 0) {
40 printf("EStack[%ld].ElType = ", (LONG)EStTop);
41 if (EStack[EStTop].ElType == OPERATOR) {
42 printf("OPERATOR, EStack[%ld].Elemnt = '%c'\r\n",
43 (LONG)EStTop, (char)EStack[EStTop].Elemnt);
44 } else {
45 printf("OPERAND, EStack[%ld].Elemnt = %ld\r\n",
46 (LONG)EStTop, (LONG)EStack[EStTop].Elemnt);
47 }
48 EStTop--;
49 }
50 #endif
51
52 ErrMsg(ERR_IFE); /* ill-formed numeric expression */
53
54 DBGFEX(2,DbgFNm,"FAILURE, unterminated command");
55
56 return FAILURE;
57 }
58