Download AOS Library User`s Manual

Transcript
Library User's Manual
4.2.3
Programming Example
The following program is an example of a string comparison routine
which uses P_Match. The program reads two strings and prints the
result of the comparison; if requested, it also prints information
describing how the patterns matched.
Program Wild_Test;
Uses Pattern_Match;
Var
: String;
Ch
: Char;
Pat_Ptr
: P_Pat_Rec~P;
Want_Patterns
Boolean;
W, C
Procedure Print_Patterns (Pat_ptr
C, W
P_Pat_Rec_P;
: String);
Var Count: Integer;
Begin
Writeln ('Type <cr> for patterns');
Readln; Writeln;
Count := 1;
Repeat
Writeln ('Pattern " Count, I : ' ) ;
With Pat_Ptr A Do
Begin
Writeln (' Comp: I, C);
If Comp_Len <> 0 Then Write (,A,: (Comp_Pos + 9»;
If Comp_Len > 1 Then write (,A,: (Camp_Len - 1»;
Wri te1n;
Write1n (' Wild: " W);
Write (,AI: (Wi1d_Pos + 9»;
If Wild_Len > 1 Then Wr i te (' A, : Ct'1i1d_Len - l»;
Writeln; Writeln;
End;
Pat_Ptr := Pat_PtrA.Next;
Count := Count + 1;
Until Pat_Ptr = Nil;
End {of Print_Patterns};
Page
66