DataMuseum.dk

Presents historical artifacts from the history of:

Jet Computer Jet80

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Jet Computer Jet80

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦d4e337769⟧ TextFile

    Length: 3712 (0xe80)
    Types: TextFile
    Names: »GETNUMS.P«

Derivation

└─⟦dd59903ef⟧ Bits:30005887 Klub diskette for udveksling af software
    └─ ⟦this⟧ »GETNUMS.P« 

TextFile

  PROCEDURE getnums(VAR wrd: wrdarray; nwrds: byte; VAR nmbr: numarray; 
                     VAR n: byte);
æ        +------------------------------------------------------------+
         øWRITTEN FOR ZUG USE.                  PASCAL Z, version 4.0 ø
         øBY       Clif Kinne                   DATE:  12/15/82       ø
         ø                                                            ø
         øPURPOSE  This procedure will convert an array of numeric    ø
         ø         strings into an array of integers.  It was designedø
         ø         as an adjunct to the procedure, READCMD.           ø
         ø                                                            ø
         øCALL:    Getnums(name,nargs,num,numct);   - typical         ø
         ø                                                            ø
         øACCEPTS: 1.  An array, WRD, of strings, such as the output  ø
         ø             array returned by  READCMD.                    ø
         ø         2.  The number, NWRDS, of non-dummy members of WRD.ø
         ø                                                            ø
         øRETURNS: 1.  A new array, NMBR, of the integer values of allø
         ø             input strings which begin with a digit or a    ø
         ø             minus sign.                                    ø
         ø         2.  The number, N, of members of this array, NMBR. ø
         ø                                                            ø
         øGLOBALS  CONST maxword  = max digits allowed in WRDÆiÅ      ø
         øREQUIRED TYPE  wrdtype  = string maxword;                   ø
         ø               wrdarray = ARRAYÆ1..maxargsÅ OF wrdtype;     ø
         ø               numarray = ARRAYÆ1..maxargsÅ OF INTEGER;     ø
         ø               byte     = 0..255;                           ø
         ø         FUNCTION ctoi (buf: wrdtype; i: INTEGER): INTEGER; ø
         +------------------------------------------------------------+
.paå
    VAR   i : byte;

    FUNCTION ctoi ( buf: wrdtype; i: INTEGER ): INTEGER;
æ$R-å
      LABEL 1;
      VAR    ch : char;
          sign,       æ for signed number å
            val :INTEGER;
  
      BEGIN æ------------------------------ctoi-------------------------------å
        val := 0;
        sign := 1;
        IF bufÆiÅ = '-' THEN
          BEGIN
            sign := -1; i := i + 1
          END;
        ch := bufÆiÅ;
        WHILE ch IN Æ'0'..'9'Å DO
          BEGIN                æ CHECK INTEGER WILL BE WITHIN RANGE 0..MAXINT å
            IF ( val<3276 ) OR ((val=3276) AND (ch<'8')) 
              THEN val := val * 10 + ORD(ch) - 48  æord('0')å
              ELSE 
                BEGIN
                  val := maxint; æ overflow å
                  WRITELN(' ':5,'Numeric arguments may not exceed +/- 32767.');
                  WRITELN;
                  æEXITå GOTO 1
                END;
            i := i + 1;
            ch := bufÆiÅ      æTHIS CAN GIVE "OUT OF RANGE" ERRORS IF "$R-" ISå
          ENDæwhileå;         æ                                        OMITTEDå
  1:    ctoi := val * sign
  æ$R+å
      END;  æ------------------------------ctoi-------------------------------å
  
    BEGIN æ-----------------------------getnums-------------------------------å

      n := 0;
      FOR i := 1 TO nwrds DO 
        IF wrdÆi,1Å IN Æ'-','0'..'9'Å THEN 
          BEGIN
            n := n + 1;
            nmbrÆnÅ := ctoi(wrdÆiÅ,1);
          END;

    END;  æ-----------------------------getnums-------------------------------å

«eof»