HP 3000 Manuals

HP C/XL SCANU Function: Scan Until [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation


SPL to HP C/XL Migration Guide

HP C/XL SCANU Function:  Scan Until 

     /*******************************************************************
       SCANU              SPL SCAN UNTIL

       This emulates the SCAN until statement in SPL, for example:
               NUM := (SCAN B1 UNTIL TEST, 0);
               T := TOS;  <<test word -- unchanged>>
               @S1 := TOS;
       This may be converted to C with:
               LEN := SCANU(B1,TEST,0,&S1);

       The parameters to SCANU are:
         ba         --  The address to be scanned.
         test       --  The testword, two bytes.  The first is the
                       terminate character, the second is the
                       test character, either of which will
                       cause the scanning to continue.
         sdec       --  The SPL stack decrement.  In this context, the
                       value of this parameter will determine if the
                       function accesses the last parameter,
                       as follows:
                       sdec = 2  -- Ignore the last parameter.  This
                                   parameter need not be present.
                       sdec = 1  -- Expect one parameter after this:
                                   scan_addr.
                       sdec = 0  -- Same as 1.  In SPL, an sdec of 1
                                   or 2 deletes the test word from
                                   the stack, which is always unchanged
                                   after the SCAN operation.
         scan_addr  --  The address of the char which stopped the SCAN
                       operation.  This equals either the terminal or
                       the test character.

       The return value of this function is the number of bytes moved.

     ********************************************************************/

     short int SCANU(ba,test,sdec,scan_addr)
       char *ba, **scan_addr;
       unsigned short test;
       int sdec;
     {
       char termc, testc, *temp;
       temp = ba;
       termc = (char)test >> 8;
       testc = (char)test & OxFF;
       while ((*ba != testc) && (*ba != testc)) ba++;
       switch (sdec) {
         case 0:  ;  /* fall through to case 1 */
         case 1:  *scan_addr = ba;
         case 2:  ;  /* nil */
       }
       return(ba-temp);
     }



MPE/iX 5.0 Documentation