_  __   _  _         _ _     _      _           _           
  __| |/ /_ | || |     __| (_)___| | __ (_)_ __   __| | _____  __
 / _` | '_ \| || |_   / _` | / __| |/ / | | '_ \ / _` |/ _ \ \/ /
| (_| | (_) |__   _| | (_| | \__ \   <  | | | | | (_| |  __/>  < 
 \__,_|\___/   |_|    \__,_|_|___/_|\_\ |_|_| |_|\__,_|\___/_/\_\
                                                                 
            

PMODVAL

FILE INFORMATION

FILENAME(S): PMODVAL

FILE TYPE(S): SEQ

FILE SIZE: 1.1K

FIRST SEEN: 2025-11-02 16:30:33

APPEARS ON: 1 disk(s)

FILE HASH

a890ad9ae39a9ba8434616aa00d3a63fca40c2b9a6bf878127dd07f621c11110

FOUND ON DISKS (1 DISKS)

DISK TITLE FILENAME FILE TYPE COLLECTION TRACK SECTOR ACTIONS
UTILITIES 2 A PMODVAL SEQ Treasure Chest - OzzyC64 11 0 DOWNLOAD FILE

FILE CONTENT & ANALYSIS

00000000: 50 52 4F 47 52 41 4D 20  50 4D 4F 44 56 41 4C 28  |PROGRAM PMODVAL(|
00000010: 54 45 53 54 20 56 41 4C  55 45 20 46 55 4E 43 54  |TEST VALUE FUNCT|
00000020: 49 4F 4E 2C 31 31 2F 31  33 2F 38 32 29 3B 0D 28  |ION,11/13/82);.(|
00000030: 2A 20 46 52 4F 4D 20 4F  43 54 4F 42 45 52 2C 20  |* FROM OCTOBER, |
00000040: 31 39 38 32 20 43 4F 4D  50 55 54 45 20 4D 41 47  |1982 COMPUTE MAG|
00000050: 41 5A 49 4E 45 0D 20 20  20 4D 4F 44 49 46 49 45  |AZINE.   MODIFIE|
00000060: 44 20 46 4F 52 20 43 4C  41 52 49 54 59 20 2A 29  |D FOR CLARITY *)|
00000070: 0D 0D 56 41 52 20 49 4E  50 55 54 3A 20 53 54 52  |..VAR INPUT: STR|
00000080: 49 4E 47 3B 0D 0D 46 55  4E 43 54 49 4F 4E 20 56  |ING;..FUNCTION V|
00000090: 41 4C 28 53 3A 20 53 54  52 49 4E 47 29 3A 20 49  |AL(S: STRING): I|
000000A0: 4E 54 45 47 45 52 3B 0D  20 20 56 41 52 20 53 54  |NTEGER;.  VAR ST|
000000B0: 41 52 54 2C 20 49 2C 20  44 49 47 49 54 56 41 4C  |ART, I, DIGITVAL|
000000C0: 2C 20 54 45 4D 50 54 4F  54 41 4C 3A 20 49 4E 54  |, TEMPTOTAL: INT|
000000D0: 45 47 45 52 3B 0D 20 20  20 20 20 20 4E 45 47 41  |EGER;.      NEGA|
000000E0: 54 49 56 45 3A 20 42 4F  4F 4C 45 41 4E 3B 0D 20  |TIVE: BOOLEAN;. |
000000F0: 20 42 45 47 49 4E 0D 20  20 20 20 57 48 49 4C 45  | BEGIN.    WHILE|
00000100: 20 43 4F 50 59 28 53 2C  31 2C 31 29 3D 27 20 27  | COPY(S,1,1)=' '|
00000110: 0D 20 20 20 20 20 20 44  4F 20 53 3A 3D 43 4F 50  |.      DO S:=COP|
00000120: 59 28 53 2C 32 2C 4C 45  4E 47 54 48 28 53 29 2D  |Y(S,2,LENGTH(S)-|
00000130: 31 29 3B 0D 20 20 20 20  57 48 49 4C 45 20 43 4F  |1);.    WHILE CO|
00000140: 50 59 28 53 2C 4C 45 4E  47 54 48 28 53 29 2C 31  |PY(S,LENGTH(S),1|
00000150: 29 3D 27 20 27 0D 20 20  20 20 20 20 44 4F 20 53  |)=' '.      DO S|
00000160: 3A 3D 43 4F 50 59 28 53  2C 31 2C 4C 45 4E 47 54  |:=COPY(S,1,LENGT|
00000170: 48 28 53 29 2D 31 29 3B  0D 20 20 20 20 49 46 20  |H(S)-1);.    IF |
00000180: 43 4F 50 59 28 53 2C 31  2C 31 29 3D 27 2D 27 0D  |COPY(S,1,1)='-'.|
00000190: 20 20 20 20 20 20 20 20  54 48 45 4E 20 42 45 47  |        THEN BEG|
000001A0: 49 4E 0D 20 20 20 20 20  20 20 20 20 20 20 20 20  |IN.             |
000001B0: 20 20 53 54 41 52 54 3A  3D 32 3B 0D 20 20 20 20  |  START:=2;.    |
000001C0: 20 20 20 20 20 20 20 20  20 20 20 4E 45 47 41 54  |           NEGAT|
000001D0: 49 56 45 3A 3D 54 52 55  45 0D 20 20 20 20 20 20  |IVE:=TRUE.      |
000001E0: 20 20 20 20 20 20 20 45  4E 44 0D 20 20 20 20 20  |       END.     |
000001F0: 20 45 4C 53 45 20 42 45  47 49 4E 0D 20 20 20 20  | ELSE BEGIN.    |
00000200: 20 20 20 20 20 20 20 20  20 53 54 41 52 54 3A 3D  |         START:=|
00000210: 31 3B 0D 20 20 20 20 20  20 20 20 20 20 20 20 20  |1;.             |
00000220: 4E 45 47 41 54 49 56 45  3A 3D 46 41 4C 53 45 0D  |NEGATIVE:=FALSE.|
00000230: 20 20 20 20 20 20 20 20  20 20 20 45 4E 44 3B 0D  |           END;.|
00000240: 20 20 20 20 54 45 4D 50  54 4F 54 41 4C 3A 3D 30  |    TEMPTOTAL:=0|
00000250: 3B 0D 20 20 20 20 46 4F  52 20 49 3A 3D 53 54 41  |;.    FOR I:=STA|
00000260: 52 54 20 54 4F 20 4C 45  4E 47 54 48 28 53 29 0D  |RT TO LENGTH(S).|
00000270: 20 20 20 20 20 20 44 4F  20 42 45 47 49 4E 0D 20  |      DO BEGIN. |
00000280: 20 20 20 20 20 20 20 20  20 20 44 49 47 49 54 56  |          DIGITV|
00000290: 41 4C 3A 3D 4F 52 44 28  53 5B 49 5D 29 3B 0D 20  |AL:=ORD(S[I]);. |
000002A0: 20 20 20 20 20 20 20 20  20 20 49 46 20 28 44 49  |          IF (DI|
000002B0: 47 49 54 56 41 4C 3E 34  37 29 20 41 4E 44 20 28  |GITVAL>47) AND (|
000002C0: 44 49 47 49 54 56 41 4C  3C 35 38 29 0D 20 20 20  |DIGITVAL<58).   |
000002D0: 20 20 20 20 20 20 20 20  20 20 20 20 54 48 45 4E  |            THEN|
000002E0: 20 54 45 4D 50 54 4F 54  41 4C 3A 3D 31 30 2A 54  | TEMPTOTAL:=10*T|
000002F0: 45 4D 50 54 4F 54 41 4C  2B 28 44 49 47 49 54 56  |EMPTOTAL+(DIGITV|
00000300: 41 4C 2D 34 38 29 0D 20  20 20 20 20 20 20 20 20  |AL-48).         |
00000310: 20 20 20 20 20 20 20 20  20 20 20 28 2A 20 56 3A  |           (* V:|
00000320: 3D 56 2B 54 52 55 4E 43  28 50 57 52 4F 46 54 45  |=V+TRUNC(PWROFTE|
00000330: 4E 28 4C 45 4E 2D 49 29  29 2A 28 4F 2D 34 38 29  |N(LEN-I))*(O-48)|
00000340: 20 2A 29 0D 20 20 20 20  20 20 20 20 20 20 20 20  | *).            |
00000350: 20 45 4C 53 45 20 42 45  47 49 4E 0D 20 20 20 20  | ELSE BEGIN.    |
00000360: 20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000370: 56 41 4C 3A 3D 30 3B 0D  20 20 20 20 20 20 20 20  |VAL:=0;.        |
00000380: 20 20 20 20 20 20 20 20  20 20 20 20 45 58 49 54  |            EXIT|
00000390: 28 56 41 4C 29 0D 20 20  20 20 20 20 20 20 20 20  |(VAL).          |
000003A0: 20 20 20 20 20 20 20 20  45 4E 44 0D 20 20 20 20  |        END.    |
000003B0: 20 20 20 20 20 45 4E 44  3B 0D 20 20 20 20 49 46  |     END;.    IF|
000003C0: 20 4E 45 47 41 54 49 56  45 0D 20 20 20 20 20 20  | NEGATIVE.      |
000003D0: 20 20 54 48 45 4E 20 56  41 4C 3A 3D 2D 54 45 4D  |  THEN VAL:=-TEM|
000003E0: 50 54 4F 54 41 4C 0D 20  20 20 20 20 20 45 4C 53  |PTOTAL.      ELS|
000003F0: 45 20 56 41 4C 3A 3D 54  45 4D 50 54 4F 54 41 4C  |E VAL:=TEMPTOTAL|
00000400: 0D 20 20 45 4E 44 3B 0D  0D 42 45 47 49 4E 0D 20  |.  END;..BEGIN. |
00000410: 20 52 45 50 45 41 54 0D  20 20 20 20 57 52 49 54  | REPEAT.    WRIT|
00000420: 45 28 27 53 54 52 49 4E  47 3F 20 27 29 3B 0D 20  |E('STRING? ');. |
00000430: 20 20 20 52 45 41 44 4C  4E 28 49 4E 50 55 54 29  |   READLN(INPUT)|
00000440: 3B 0D 20 20 20 20 57 52  49 54 45 4C 4E 28 27 54  |;.    WRITELN('T|
00000450: 48 45 20 56 41 4C 55 45  20 4F 46 20 27 27 27 2C  |HE VALUE OF ''',|
00000460: 49 4E 50 55 54 2C 27 27  27 20 49 53 20 27 2C 56  |INPUT,''' IS ',V|
00000470: 41 4C 28 49 4E 50 55 54  29 29 0D 20 20 55 4E 54  |AL(INPUT)).  UNT|
00000480: 49 4C 20 49 4E 50 55 54  3D 27 27 0D 45 4E 44 2E  |IL INPUT=''.END.|
00000490: 0D 03 FF 00 FF 68 7E FF  FF                       |.....h~..       |
PROGRAM PMODVAL(TEST VALUE FUNCTION,11/1
3/82);.(* FROM OCTOBER, 1982 COMPUTE MAG
AZINE.   MODIFIED FOR CLARITY *)..VAR IN
PUT: STRING;..FUNCTION VAL(S: STRING): I
NTEGER;.  VAR START, I, DIGITVAL, TEMPTO
TAL: INTEGER;.      NEGATIVE: BOOLEAN;. 
 BEGIN.    WHILE COPY(S,1,1)=' '.      D
O S:=COPY(S,2,LENGTH(S)-1);.    WHILE CO
PY(S,LENGTH(S),1)=' '.      DO S:=COPY(S
,1,LENGTH(S)-1);.    IF COPY(S,1,1)='-'.
        THEN BEGIN.               START:
=2;.               NEGATIVE:=TRUE.      
       END.      ELSE BEGIN.            
 START:=1;.             NEGATIVE:=FALSE.
           END;.    TEMPTOTAL:=0;.    FO
R I:=START TO LENGTH(S).      DO BEGIN. 
          DIGITVAL:=ORD(S[I]);.         
  IF (DIGITVAL>47) AND (DIGITVAL<58).   
            THEN TEMPTOTAL:=10*TEMPTOTAL
+(DIGITVAL-48).                    (* V:
=V+TRUNC(PWROFTEN(LEN-I))*(O-48) *).    
         ELSE BEGIN.                    
VAL:=0;.                    EXIT(VAL).  
                END.         END;.    IF
 NEGATIVE.        THEN VAL:=-TEMPTOTAL. 
     ELSE VAL:=TEMPTOTAL.  END;..BEGIN. 
 REPEAT.    WRITE('STRING? ');.    READL
N(INPUT);.    WRITELN('THE VALUE OF ''',
INPUT,''' IS ',VAL(INPUT)).  UNTIL INPUT
=''.END......H~..
C64 Preview

> CLICK IMAGE PREVIEW FOR FULL MODAL