c'est du format iCal
CREATED donne la date de création de l'événement qui a "LAST_MODIFIED"
DSTART/DEND c'est le début/fin, ici le 19/05/2016 et 09h00 à 10h00
Version imprimable
Merci Paul.
Voici un premier essai de lecture du fichier .ics.
À tester sur le vrai fichier. ;)Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 { Free Pascal } program ReadICS_01; {$APPTYPE CONSOLE} {$IFDEF FPC}{$MODE DELPHI}{$ENDIF} uses SysUtils, Classes, RegExpr; const PATTERN = 'DTSTART;TZID="[ \w]+":(\d{8})\w+\s+' + 'LAST-MODIFIED:\w+\s+' + 'SEQUENCE:\w+\s+' + 'SUMMARY:([ \w]+)'; var list: TStringList; expr: TRegExpr; begin list := TStringList.Create; list.LoadFromFile('cal.ics'); expr := TRegExpr.Create; expr.Expression := PATTERN; if expr.Exec(list.Text) then repeat //WriteLn(expr.Match[0]); WriteLn(expr.Match[1]); WriteLn(expr.Match[2]); until not expr.ExecNext; expr.Free; list.Free; end.
Voici ce que ça donne avec le fichier de test :
Code:
1
2
3
4
5
6
7
8 20160519 roland juju 20160601 Laurent Bebe 20160528 Bernard Tutu 20160603 Gerard Lili
Si ce premier essai fonctionne, on peut améliorer le programme afin qu'il fabrique l'unité en Pascal, ce qui éviterait d'avoir à remplir l'unité à la main.
Voici le programme qui fabrique l'unité en Pascal. ;)
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 { Free Pascal } program ReadICS_02; {$APPTYPE CONSOLE} {$IFDEF FPC}{$MODE DELPHI}{$ENDIF} uses SysUtils, Classes, RegExpr; const PATTERN = 'DTSTART;TZID="[ \w]+":\d{4}(\d{2})(\d{2})\w+\s+' + 'LAST-MODIFIED:\w+\s+' + 'SEQUENCE:\w+\s+' + 'SUMMARY:([ \w]+)'; var list: TStringList; expr: TRegExpr; month, day: integer; data: array[1..12, 1..31] of string; fichier: TextFile; begin list := TStringList.Create; list.LoadFromFile('cal.ics'); expr := TRegExpr.Create; expr.Expression := PATTERN; if expr.Exec(list.Text) then repeat month := StrToInt(expr.Match[1]); day := StrToInt(expr.Match[2]); data[month, day] := expr.Match[3]; until not expr.ExecNext; expr.Free; list.Free; AssignFile(fichier, 'Unit1.pas'); Rewrite(fichier); WriteLn(fichier); WriteLn(fichier, 'unit Unit1;'); WriteLn(fichier); WriteLn(fichier, 'interface'); WriteLn(fichier); WriteLn(fichier, 'const'); WriteLn(fichier, ' DATA: array[1..12, 1..31] of string = ('); for month := 1 to 12 do begin WriteLn(fichier, ' ('); for day := 1 to 31 do begin Write(fichier, Format(' {%0.2d/%0.2d} "%s"', [day, month, data[month, day]])); if day < 31 then Write(fichier, ','); WriteLn(fichier); end; Write(fichier, ' )'); if month < 12 then WriteLn(fichier, ',') else WriteLn(fichier); end; WriteLn(fichier, ' );'); WriteLn(fichier); WriteLn(fichier, 'implementation'); WriteLn(fichier); WriteLn(fichier, 'end.'); CloseFile(fichier); end.
Votre code pour lire le fichier .ics doit etre monter avec delphi en fichier .DPROJ pour servir d'extracteur ???
J'ai essayer de pencher sur delphi7 qui a l'air plus complexe que flashpascal.
Le code que j'ai posté plus haut doit être compilé avec Free Pascal. Vous pouvez aussi le compiler avec Delphi 7, mais alors il faut vous procurer l'unité RegExpr.
ok je peux avoir 2 ou 3 astuces pour compiler sous free pascal ou peut être lien pour comprendre le fonctionnement de celui ci.
Ce que je peux vous proposer, c'est un programme déjà compilé. Il faut l'exécuter au moyen de la commande suivante :
Ou faire glisser le fichier .ics, avec la souris, sur le fichier .exe.Code:ReadICS_03.exe "votre fichier.ics"
Merci Roland et en terme de format d écriture si je veux faire un retour à la ligne dans votre fichier .pas qu'elle est l écriture a adopter ???