mb_pop_operator

Previous  Next

 

status_t mb_pop_operator( mb_interpreter_t* s, void** l, char** strVal )

 


 

This function pops a parameter that is an operator and returns the string represenation of the operator

 

"+"            Addition

"-"            Subtract

"*"            Multiply

"/"            Division

"MOD"          Modulus

"^"            Power

"="            Equal

"<"            Less Than

">"            Greater Than

"<="           Less or Equal

">="           Greater or Equal

"<>"           Not Equal

"AND"          Logical And

"OR"           Logical Or

 

Example

 

/////////////////////////////////////////////////////////////////////////////

// Function to "pop" a wild array index.  If the parameter specified is '*'

// then the pop will return integer value -1, otherwise it will expect and

// return an integer

//

status_t mb_pop_wild( mb_interpreter_t* s, void** l, int* x )

  {

  if ( !mb_has_arg_type( s, l, MB_DT_INT ) )

     {

     char*    pStr;

 

     if ( mb_pop_operator( s, l, &pStr ) != MB_FUNC_OK )

        {

        mb_set_error( s, l, SE_RN_INTEGER_EXPECTED );

 

        return MB_FUNC_ERR;

        }

     endif

 

     if ( strcmp( pStr, "*" ) != 0 )

        {

        mb_set_error( s, l, SE_RN_INTEGER_EXPECTED );

 

        return MB_FUNC_ERR;

        }

     endif

 

     *x = -1;

     }

  else

     {

     return mb_pop_int( s, l, x );

     }

  endif

 

  return MB_FUNC_OK;

  }

endfunc