Tempo fa ho creato un calendario perpetuo:
si tratta di questo, di un programma che data una data (scusate il gioco di parole
) ti dice quale giorno della settima era (o sarà) purchè la data sia valida e compresa tra il 1857 e il 2036
praticamente è formato da 3 tabelle di dati e da un programma che vi accede secondo una certa logica
Le tabelle le vedi qui:
http://zanpakuto.altervista.org/perpetuo.pdf
Lo posto qui perchè non l'ho fatto in GM ma in pascal
il sorgente è questo:
Spoiler
Uses CRT;
Const MAX = 28+5; GIORNI :Array[1..7] Of String =
('Domenica','Lunedi','Martedi','Mercoledi',
'Giovedi','Venerdi','Sabato');
Var GIORNO2,MESE2 : shortint;
ANNO2 : Integer;
Q : Text;
K,K2,NUM : shortint;
ANNO : Array[1..7,1..MAX] Of Integer;
MESE : Array[1..12,1..MAX] Of Integer;
GIORNO : Array[1..2,1..MAX] Of Integer;
C : Char;
Begin;
Clrscr;
TextColor(White);
Repeat
Writeln('C A L E N D A R I O P E R P E T U O (1857-2036)');
Writeln('');
Writeln('Giorno=');
Readln(GIORNO2);
Writeln('Mese=');
Readln(MESE2);
Writeln('Anno=');
Readln(ANNO2);
Assign(Q,'anni.txt');
reset(Q);
For K2:=1 To MAX Do
Begin;
For K:=1 To 7 Do
Begin;
Readln(Q,ANNO[K,K2]);
(* Write(ANNO[K,K2],' '); *)
End;
End;
Close(Q);
Assign(Q,'mesi.txt');
reset(Q);
For K2:=1 To MAX Do
Begin;
For K:=1 To 12 Do
Begin;
Readln(Q,MESE[K,K2]);
(* Write(MESE[K,K2],' '); *)
End;
End;
Close(Q);
Assign(Q,'giorni.txt');
reset(Q);
For K2:=1 To MAX Do
Begin;
For K:=1 To 2 Do
Begin;
Readln(Q,GIORNO[K,K2]);
(* Write(GIORNO[K,K2],' '); *)
End;
End;
Close(Q);
K:=1; K2:=1;
Repeat
K:=K+1;
If K > 7 Then Begin; K:=1; K2:=K2+1; End;
Until ANNO[K,K2] = ANNO2;
Writeln;
(* Writeln(K,' ',K2); *)
(* Writeln(MESE2,' ',K2); *)
NUM:=MESE[MESE2,K2]+GIORNO2;
(* WriteLn('num= ',NUM,' '); *)
K:=1; K2:=1;
Repeat
K:=K+1;
If K > 2 Then Begin; K:=1; K2:=K2+1; End;
Until GIORNO[K,K2] = NUM;
Write(' ',(*K2,*)' il giorno Š ',GIORNI[K2 mod 7]);
if K2 mod 7 = 0 then Write('Sabato');
Writeln;
(* Write('ok'); *)
(* Readln; *)
Writeln('Vuoi uscire? S / N');
ReadLn(C);
C := UpCase(C);
Until C='S';
End.
Non posto screen perchè è inutile (e in modalità testuale "grezza")
Non so se può interessare qualcuno (anche perchè in internet c'è il database di calendari) comunque ormai che l'ho fatto eccolo qui!
per il download (exe+pas):
http://giochi3.altervista.org/software/calper.htm
edit:
[aprile 2015]
- ho fatto una conversione da pascal a GML, per poi sfruttare l'exporter HTML5 di GM:S. Ovvero, ora il soft è MULTIPIATTAFORMA e NON necessita di scaricare niente!