DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

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

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦34755de22⟧ TextFile

    Length: 2560 (0xa00)
    Types: TextFile
    Names: »SCORE.PAS«

Derivation

└─⟦08ea08c61⟧ Bits:30003924 PolyPascal programmer
    └─ ⟦this⟧ »SCORE.PAS« 
└─⟦09235ab48⟧ Bits:30003065 Demoprogrammer K-Z til Pascal bog
    └─ ⟦this⟧ »SCORE.PAS« 
└─⟦092727b26⟧ Bits:30005927 Demoprogrammer til Pascal bog (Jet-80)
    └─ ⟦this⟧ »SCORE.PAS« 

TextFile

PROGRAM score;

  TYPE
    scoretype = RECORD
                  points : INTEGER;
                  navn : STRING(.30.);
                END;
    scorefiltype = FILE OF scoretype;
  
  VAR
    score : scoretype;
    scorefil : scorefiltype;
    ch : CHAR;
  
  PROCEDURE opret;
  
    VAR
      i : INTEGER;
    
    BEGIN (* opret *)
      ASSIGN(scorefil, 'HISCORE.DAT');
      REWRITE(scorefil);
      WITH score DO
        BEGIN
          points := 0;
          navn := 'NN';
        END;
      FOR i := 1 TO 5 DO
        WRITE(scorefil, score);
      CLOSE(scorefil)
    END; (* opret *)
  
  PROCEDURE update(score : scoretype);
  
    TYPE
      listetype = ARRAY(.1 .. 6.) OF scoretype;
    
    VAR
      liste : listetype;
      byt : scoretype;
      i : INTEGER;
    
    BEGIN (* update *)
      ASSIGN(scorefil, 'HISCORE.DAT');
      RESET(scorefil);
      FOR i := 1 TO 5 DO
        READ(scorefil, liste(.i.));
      CLOSE(scorefil);
      liste(.6.) := score;
      i := 6;
      WHILE i > 1 DO
        BEGIN
          IF liste(.i.).points > liste(.i - 1.).points
            THEN
              BEGIN
                byt := liste(.i.);
                liste(.i.) := liste(.i - 1.);
                liste(.i - 1.) := byt;
              END;
          i := i - 1;
        END;
      REWRITE(scorefil);
      FOR i := 1 TO 5 DO
        WRITE(scorefil, liste(.i.));
      CLOSE(scorefil);
    END; (* update *)
  
  PROCEDURE laes;
    
    VAR
      i : INTEGER;
      score : scoretype;
      
    BEGIN (* laes *)
      ASSIGN(scorefil, 'HISCORE.DAT');
      RESET(scorefil);
      FOR i := 1 TO 5 DO
        BEGIN
          READ(scorefil, score);
          WRITELN(score.points : 4, '  ', score.navn);
        END;
      CLOSE(scorefil);
    END; (* laes *)
    
  BEGIN (* score *)
    WRITE(CLRHOM);
    WRITE('Skal highscore-listen oprettes (j/n): '); 
    REPEAT
      READ(KBD, ch);
    UNTIL (ch = 'j') OR (ch = 'n');
    WRITELN;
    IF ch = 'j' THEN opret;
    WRITE('Navn: (0 stopper): '); READLN(score.navn);
    WHILE score.navn <> '0' DO
      BEGIN
        WRITE('Points           : '); READLN(score.points);
        update(score);
        WRITE('Navn: (0 stopper): '); READLN(score.navn);
      END;
    WRITE('Skal highscore-listen læses (j/n): ');
    REPEAT
      READ(KBD, ch);
    UNTIL (ch = 'j') OR (ch = 'n');
    WRITELN;
    IF ch = 'j'
      THEN laes;
  END. (* score *)
«eof»