summaryrefslogtreecommitdiff
path: root/packages/fv/src/validate.inc
blob: f93a91630af5b8e3158d93a0b96a2b5393eb8ccd (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
{********[ SOURCE FILE OF GRAPHICAL FREE VISION ]**********}
{                                                          }
{   System independent GRAPHICAL clone of VALIDATE.PAS     }
{                                                          }
{   Interface Copyright (c) 1992 Borland International     }
{                                                          }
{   Copyright (c) 1996, 1997, 1998, 1999 by Leon de Boer   }
{   ldeboer@ibm.net                                        }
{                                                          }
{****************[ THIS CODE IS FREEWARE ]*****************}
{                                                          }
{     This sourcecode is released for the purpose to       }
{   promote the pascal language on all platforms. You may  }
{   redistribute it and/or modify with the following       }
{   DISCLAIMER.                                            }
{                                                          }
{     This SOURCE CODE is distributed "AS IS" WITHOUT      }
{   WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR     }
{   ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED.     }
{                                                          }
{*****************[ SUPPORTED PLATFORMS ]******************}
{     16 and 32 Bit compilers                              }
{        DOS      - Turbo Pascal 7.0 +      (16 Bit)       }
{        DPMI     - Turbo Pascal 7.0 +      (16 Bit)       }
{                 - FPC 0.9912+ (GO32V2)    (32 Bit)       }
{        WINDOWS  - Turbo Pascal 7.0 +      (16 Bit)       }
{                 - Delphi 1.0+             (16 Bit)       }
{        WIN95/NT - Delphi 2.0+             (32 Bit)       }
{                 - Virtual Pascal 2.0+     (32 Bit)       }
{                 - Speedsoft Sybil 2.0+    (32 Bit)       }
{                 - FPC 0.9912+             (32 Bit)       }
{        OS2      - Virtual Pascal 1.0+     (32 Bit)       }
{                                                          }
{******************[ REVISION HISTORY ]********************}
{  Version  Date        Fix                                }
{  -------  ---------   ---------------------------------  }
{  1.00     12 Jun 96   Initial DOS/DPMI code released.    }
{  1.10     29 Aug 97   Platform.inc sort added.           }
{  1.20     13 Oct 97   Delphi3 32 bit code added.         }
{  1.30     11 May 98   Virtual pascal 2.0 code added.     }
{  1.40     10 Jul 99   Sybil 2.0 code added               }
{  1.41     03 Nov 99   FPC windows code added             }
{**********************************************************}

{$ifdef FV_UNICODE}
UNIT UValidate;
{$else FV_UNICODE}
UNIT Validate;
{$endif FV_UNICODE}

{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
                                  INTERFACE
{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}

{====Include file to sort compiler platform out =====================}
{$I platform.inc}
{====================================================================}

{==== Compiler directives ===========================================}

{$IFNDEF PPC_FPC}{ FPC doesn't support these switches }
  {$F-} { Short calls are okay }
  {$A+} { Word Align Data }
  {$B-} { Allow short circuit boolean evaluations }
  {$O+} { This unit may be overlaid }
  {$G+} { 286 Code optimization - if you're on an 8088 get a real computer }
  {$P-} { Normal string variables }
  {$N-} { No 80x87 code generation }
  {$E+} { Emulation is on }
{$ENDIF}

{$X+} { Extended syntax is ok }
{$R-} { Disable range checking }
{$S-} { Disable Stack Checking }
{$I-} { Disable IO Checking }
{$Q-} { Disable Overflow Checking }
{$V-} { Turn off strict VAR strings }
{====================================================================}

USES
{$ifdef FV_UNICODE}
  UFVCommon,
{$else FV_UNICODE}
  FVCommon,
{$endif FV_UNICODE}
  Objects, fvconsts;                      { GFV standard units }

{***************************************************************************}
{                              PUBLIC CONSTANTS                             }
{***************************************************************************}

{---------------------------------------------------------------------------}
{                         VALIDATOR STATUS CONSTANTS                        }
{---------------------------------------------------------------------------}
CONST
   vsOk     = 0;                                      { Validator ok }
   vsSyntax = 1;                                      { Validator sytax err }

{---------------------------------------------------------------------------}
{                           VALIDATOR OPTION MASKS                          }
{---------------------------------------------------------------------------}
CONST
   voFill     = $0001;                                { Validator fill }
   voTransfer = $0002;                                { Validator transfer }
   voOnAppend = $0004;                                { Validator append }
   voReserved = $00F8;                                { Clear above flags }

{***************************************************************************}
{                            RECORD DEFINITIONS                             }
{***************************************************************************}

{---------------------------------------------------------------------------}
{                        VALIDATOR TRANSFER CONSTANTS                       }
{---------------------------------------------------------------------------}
TYPE
   TVTransfer = (vtDataSize, vtSetData, vtGetData);   { Transfer states }

{---------------------------------------------------------------------------}
{                    PICTURE VALIDATOR RESULT CONSTANTS                     }
{---------------------------------------------------------------------------}
TYPE
   TPicResult = (prComplete, prIncomplete, prEmpty, prError, prSyntax,
     prAmbiguous, prIncompNoFill);

{***************************************************************************}
{                            OBJECT DEFINITIONS                             }
{***************************************************************************}

{---------------------------------------------------------------------------}
{                TValidator OBJECT - VALIDATOR ANCESTOR OBJECT              }
{---------------------------------------------------------------------------}
TYPE
   TValidator = OBJECT (TObject)
         Status : Word;                               { Validator status }
         Options: Word;                               { Validator options }
      CONSTRUCTOR Load (Var S: TStream);
      FUNCTION Valid(CONST S: Sw_String): Boolean;
      FUNCTION IsValid (CONST S: Sw_String): Boolean; Virtual;
      FUNCTION IsValidInput (Var S: Sw_String;
        SuppressFill: Boolean): Boolean; Virtual;
      FUNCTION Transfer (Var S: Sw_String; Buffer: Pointer;
        Flag: TVTransfer): Word; Virtual;
      PROCEDURE Error; Virtual;
      PROCEDURE Store (Var S: TStream);
   END;
   PValidator = ^TValidator;

{---------------------------------------------------------------------------}
{           TPictureValidator OBJECT - PICTURE VALIDATOR OBJECT             }
{---------------------------------------------------------------------------}
TYPE
   TPXPictureValidator = OBJECT (TValidator)
         Pic: Sw_PString;                             { Picture filename }
      CONSTRUCTOR Init (Const APic: Sw_String; AutoFill: Boolean);
      CONSTRUCTOR Load (Var S: TStream);
      DESTRUCTOR Done; Virtual;
      FUNCTION IsValid (Const S: Sw_String): Boolean; Virtual;
      FUNCTION IsValidInput (Var S: Sw_String;
        SuppressFill: Boolean): Boolean; Virtual;
      FUNCTION Picture (Var Input: Sw_String;
        AutoFill: Boolean): TPicResult; Virtual;
      PROCEDURE Error; Virtual;
      PROCEDURE Store (Var S: TStream);
   END;
   PPXPictureValidator = ^TPXPictureValidator;

TYPE CharSet = TCharSet;

{---------------------------------------------------------------------------}
{            TFilterValidator OBJECT - FILTER VALIDATOR OBJECT              }
{---------------------------------------------------------------------------}
TYPE
   TFilterValidator = OBJECT (TValidator)
         ValidChars: CharSet;                         { Valid char set }
      CONSTRUCTOR Init (AValidChars: CharSet);
      CONSTRUCTOR Load (Var S: TStream);
      FUNCTION IsValid (CONST S: Sw_String): Boolean; Virtual;
      FUNCTION IsValidInput (Var S: Sw_String;
        SuppressFill: Boolean): Boolean; Virtual;
      PROCEDURE Error; Virtual;
      PROCEDURE Store (Var S: TStream);
   END;
   PFilterValidator = ^TFilterValidator;

{---------------------------------------------------------------------------}
{             TRangeValidator OBJECT - RANGE VALIDATOR OBJECT               }
{---------------------------------------------------------------------------}
TYPE
   TRangeValidator = OBJECT (TFilterValidator)
         Min: LongInt;                                { Min valid value }
         Max: LongInt;                                { Max valid value }
      CONSTRUCTOR Init(AMin, AMax: LongInt);
      CONSTRUCTOR Load (Var S: TStream);
      FUNCTION IsValid (Const S: Sw_String): Boolean; Virtual;
      FUNCTION Transfer (Var S: Sw_String; Buffer: Pointer;
        Flag: TVTransfer): Word; Virtual;
      PROCEDURE Error; Virtual;
      PROCEDURE Store (Var S: TStream);
   END;
   PRangeValidator = ^TRangeValidator;

{---------------------------------------------------------------------------}
{            TLookUpValidator OBJECT - LOOKUP VALIDATOR OBJECT              }
{---------------------------------------------------------------------------}
TYPE
   TLookupValidator = OBJECT (TValidator)
      FUNCTION IsValid (Const S: Sw_String): Boolean;                   Virtual;
      FUNCTION Lookup (Const S: Sw_String): Boolean;                    Virtual;
   END;
   PLookupValidator = ^TLookupValidator;

{---------------------------------------------------------------------------}
{      TStringLookUpValidator OBJECT - STRING LOOKUP VALIDATOR OBJECT       }
{---------------------------------------------------------------------------}
TYPE
   TStringLookupValidator = OBJECT (TLookupValidator)
         Strings: PStringCollection;
      CONSTRUCTOR Init (AStrings: PStringCollection);
      CONSTRUCTOR Load (Var S: TStream);
      DESTRUCTOR Done;                                               Virtual;
      FUNCTION Lookup (Const S: Sw_String): Boolean;                    Virtual;
      PROCEDURE Error;                                               Virtual;
      PROCEDURE NewStringList (AStrings: PStringCollection);
      PROCEDURE Store (Var S: TStream);
   END;
   PStringLookupValidator = ^TStringLookupValidator;

{***************************************************************************}
{                            INTERFACE ROUTINES                             }
{***************************************************************************}

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{                           OBJECT REGISTER ROUTINES                        }
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{-RegisterValidate---------------------------------------------------
Calls RegisterType for each of the object types defined in this unit.
18May98 LdB
---------------------------------------------------------------------}
PROCEDURE RegisterValidate;

{***************************************************************************}
{                           OBJECT REGISTRATION                             }
{***************************************************************************}

{---------------------------------------------------------------------------}
{                 TPXPictureValidator STREAM REGISTRATION                   }
{---------------------------------------------------------------------------}
CONST
   RPXPictureValidator: TStreamRec = (
     ObjType: idPXPictureValidator;                   { Register id = 80 }
     {$IFDEF BP_VMTLink}                              { BP style VMT link }
     VmtLink: Ofs(TypeOf(TPXPictureValidator)^);
     {$ELSE}                                          { Alt style VMT link }
     VmtLink: TypeOf(TPXPictureValidator);
     {$ENDIF}
     Load: @TPXPictureValidator.Load;                 { Object load method }
     Store: @TPXPictureValidator.Store                { Object store method }
   );

{---------------------------------------------------------------------------}
{                  TFilterValidator STREAM REGISTRATION                     }
{---------------------------------------------------------------------------}
CONST
   RFilterValidator: TStreamRec = (
     ObjType: idFilterValidator;                      { Register id = 81 }
     {$IFDEF BP_VMTLink}                              { BP style VMT link }
     VmtLink: Ofs(TypeOf(TFilterValidator)^);
     {$ELSE}                                          { Alt style VMT link }
     VmtLink: TypeOf(TFilterValidator);
     {$ENDIF}
     Load: @TFilterValidator.Load;                    { Object load method }
     Store: @TFilterValidator.Store                   { Object store method }
   );

{---------------------------------------------------------------------------}
{                   TRangeValidator STREAM REGISTRATION                     }
{---------------------------------------------------------------------------}
CONST
   RRangeValidator: TStreamRec = (
     ObjType: idRangeValidator;                       { Register id = 82 }
     {$IFDEF BP_VMTLink}                              { BP style VMT link }
     VmtLink: Ofs(TypeOf(TRangeValidator)^);
     {$ELSE}                                          { Alt style VMT link }
     VmtLink: TypeOf(TRangeValidator);
     {$ENDIF}
     Load: @TRangeValidator.Load;                     { Object load method }
     Store: @TRangeValidator.Store                    { Object store method }
   );

{---------------------------------------------------------------------------}
{                TStringLookupValidator STREAM REGISTRATION                 }
{---------------------------------------------------------------------------}
CONST
   RStringLookupValidator: TStreamRec = (
     ObjType: idStringLookupValidator;                { Register id = 83 }
     {$IFDEF BP_VMTLink}                              { BP style VMT link }
     VmtLink: Ofs(TypeOf(TStringLookupValidator)^);
     {$ELSE}                                          { Alt style VMT link }
     VmtLink: TypeOf(TStringLookupValidator);
     {$ENDIF}
     Load: @TStringLookupValidator.Load;              { Object load method }
     Store: @TStringLookupValidator.Store             { Object store method }
   );

{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
                                IMPLEMENTATION
{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}

{$ifdef FV_UNICODE}
USES UMsgBox;                                         { GFV standard unit }
{$else FV_UNICODE}
USES MsgBox;                                          { GFV standard unit }
{$endif FV_UNICODE}

{***************************************************************************}
{                              PRIVATE ROUTINES                             }
{***************************************************************************}

{---------------------------------------------------------------------------}
{  IsLetter -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB          }
{---------------------------------------------------------------------------}
FUNCTION IsLetter (Chr: Char): Boolean;
BEGIN
   Chr := Char(Ord(Chr) AND $DF);                     { Lower to upper case }
   If (Chr >= 'A') AND (Chr <='Z') Then               { Check if A..Z }
     IsLetter := True Else IsLetter := False;         { Return result }
END;

{---------------------------------------------------------------------------}
{  IsComplete -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB        }
{---------------------------------------------------------------------------}
FUNCTION IsComplete (Rslt: TPicResult): Boolean;
BEGIN
   IsComplete := Rslt IN [prComplete, prAmbiguous];   { Return if complete }
END;

{---------------------------------------------------------------------------}
{  IsInComplete -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB      }
{---------------------------------------------------------------------------}
FUNCTION IsIncomplete (Rslt: TPicResult): Boolean;
BEGIN
   IsIncomplete := Rslt IN
     [prIncomplete, prIncompNoFill];                  { Return if incomplete }
END;

{---------------------------------------------------------------------------}
{  NumChar -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB           }
{---------------------------------------------------------------------------}
FUNCTION NumChar (Chr: Char; Const S: String): Byte;
VAR I, Total: Byte;
BEGIN
   Total := 0;                                        { Zero total }
   For I := 1 To Length(S) Do                         { For entire string }
     If (S[I] = Chr) Then Inc(Total);                 { Count matches of Chr }
   NumChar := Total;                                  { Return char count }
END;

{---------------------------------------------------------------------------}
{  IsSpecial -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB         }
{---------------------------------------------------------------------------}
FUNCTION IsSpecial (Chr: Char; Const Special: String): Boolean;
VAR Rslt: Boolean; I: Byte;
BEGIN
   Rslt := False;                                     { Preset false result }
   For I := 1 To Length(Special) Do
     If (Special[I] = Chr) Then Rslt := True;         { Character found }
   IsSpecial := Rslt;                                 { Return result }
END;

{***************************************************************************}
{                               OBJECT METHODS                              }
{***************************************************************************}

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{                         TValidator OBJECT METHODS                         }
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

{--TValidator---------------------------------------------------------------}
{  Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
CONSTRUCTOR TValidator.Load (Var S:TStream);
BEGIN
   Inherited Init;                                    { Call ancestor }
   S.Read(Options, SizeOf(Options));                  { Read option masks }
END;

{--TValidator---------------------------------------------------------------}
{  Valid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
FUNCTION TValidator.Valid (Const S: Sw_String): Boolean;
BEGIN
   Valid := False;                                    { Preset false result }
   If Not IsValid(S) Then Error                       { Check for error }
     Else Valid := True;                              { Return valid result }
END;

{--TValidator---------------------------------------------------------------}
{  IsValid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB           }
{---------------------------------------------------------------------------}
FUNCTION TValidator.IsValid (Const S: Sw_String): Boolean;
BEGIN
   IsValid := True;                                   { Default return valid }
END;

{--TValidator---------------------------------------------------------------}
{  IsValidInput -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB      }
{---------------------------------------------------------------------------}
FUNCTION TValidator.IsValidInput (Var S: Sw_String; SuppressFill: Boolean): Boolean;
BEGIN
   IsValidInput := True;                              { Default return true }
END;

{--TValidator---------------------------------------------------------------}
{  Transfer -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB          }
{---------------------------------------------------------------------------}
FUNCTION TValidator.Transfer (Var S: Sw_String; Buffer: Pointer;
  Flag: TVTransfer): Word;
BEGIN
   Transfer := 0;                                     { Default return zero }
END;

{--TValidator---------------------------------------------------------------}
{  Error -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TValidator.Error;
BEGIN                                                 { Abstract method }
END;

{--TValidator---------------------------------------------------------------}
{  Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TValidator.Store (Var S: TStream);
BEGIN
   S.Write(Options, SizeOf(Options));                 { Write options }
END;

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{                    TPXPictureValidator OBJECT METHODS                     }
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

{--TPXPictureValidator------------------------------------------------------}
{  Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
CONSTRUCTOR TPXPictureValidator.Init (Const APic: Sw_String; AutoFill: Boolean);
VAR S: Sw_String;
BEGIN
   Inherited Init;                                    { Call ancestor }
   Pic := Sw_NewStr(APic);                            { Hold filename }
   Options := voOnAppend;                             { Preset option mask }
   If AutoFill Then Options := Options OR voFill;     { Check/set fill mask }
   S := '';                                           { Create empty string }
   If (Picture(S, False) <> prEmpty) Then             { Check for empty }
     Status := vsSyntax;                              { Set error mask }
END;

{--TPXPictureValidator------------------------------------------------------}
{  Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
CONSTRUCTOR TPXPictureValidator.Load (Var S: TStream);
BEGIN
   Inherited Load(S);                                 { Call ancestor }
{$ifdef FV_UNICODE}
   Pic := S.ReadUnicodeString;                        { Read filename }
{$else FV_UNICODE}
   Pic := S.ReadStr;                                  { Read filename }
{$endif FV_UNICODE}
END;

{--TPXPictureValidator------------------------------------------------------}
{  Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
DESTRUCTOR TPXPictureValidator.Done;
BEGIN
{$ifndef FV_UNICODE}
   If (Pic <> Nil) Then DisposeStr(Pic);              { Dispose of filename }
{$endif FV_UNICODE}
   Inherited Done;                                    { Call ancestor }
END;

{--TPXPictureValidator------------------------------------------------------}
{  IsValid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB           }
{---------------------------------------------------------------------------}
FUNCTION TPXPictureValidator.IsValid (Const S: Sw_String): Boolean;
VAR Str: Sw_String; Rslt: TPicResult;
BEGIN
   Str := S;                                          { Transfer string }
   Rslt := Picture(Str, False);                       { Check for picture }
   IsValid := (Pic = Sw_PString_Empty) OR (Rslt = prComplete) OR
     (Rslt = prEmpty);                                { Return result }
END;

{--TPXPictureValidator------------------------------------------------------}
{  IsValidInput -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB      }
{---------------------------------------------------------------------------}
FUNCTION TPXPictureValidator.IsValidInput (Var S: Sw_String;
  SuppressFill: Boolean): Boolean;
BEGIN
   IsValidInput := (Pic = Sw_PString_Empty) OR (Picture(S,
    (Options AND voFill <> 0)  AND NOT SuppressFill)
     <> prError);                                     { Return input result }
END;

{--TPXPictureValidator------------------------------------------------------}
{  Picture -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB           }
{---------------------------------------------------------------------------}
FUNCTION TPXPictureValidator.Picture (Var Input: Sw_String; AutoFill: Boolean): TPicResult;
VAR I, J: Byte; Rslt: TPicResult; Reprocess: Boolean;

   FUNCTION Process (TermCh: Byte): TPicResult;
   VAR Rslt: TPicResult; Incomp: Boolean; OldI, OldJ, IncompJ, IncompI: Byte;

     PROCEDURE Consume (Ch: Char);
     BEGIN
       Input[J] := Ch;                                { Return character }
       Inc(J);                                        { Inc count J }
       Inc(I);                                        { Inc count I }
     END;

     PROCEDURE ToGroupEnd (Var I: Byte);
     VAR BrkLevel, BrcLevel: SmallInt;
     BEGIN
       BrkLevel := 0;                                 { Zero bracket level }
       BrcLevel := 0;                                 { Zero bracket level }
       Repeat
         If (I <> TermCh) Then Begin                  { Not end }
           Case Pic Sw_PString_DeRef[I] Of
             '[': Inc(BrkLevel);                      { Inc bracket level }
             ']': Dec(BrkLevel);                      { Dec bracket level }
             '{': Inc(BrcLevel);                      { Inc bracket level }
             '}': Dec(BrcLevel);                      { Dec bracket level }
             ';': Inc(I);                             { Next character }
             '*': Begin
                 Inc(I);                              { Next character }
                 While Pic Sw_PString_DeRef[I] in ['0'..'9'] Do Inc(I);   { Search for text }
                 ToGroupEnd(I);                       { Move to group end }
                 Continue;                            { Now continue }
               End;
           End;
           Inc(I);                                    { Next character }
         End;
       Until ((BrkLevel = 0) AND (BrcLevel = 0)) OR   { Both levels must be 0 }
       (I = TermCh);                                  { Terminal character }
     END;

     FUNCTION SkipToComma: Boolean;
     BEGIN
       Repeat
         ToGroupEnd(I);                               { Find group end }
       Until (I = TermCh) OR (Pic Sw_PString_DeRef[I] = ',');         { Terminator found }
       If (Pic Sw_PString_DeRef[I] = ',') Then Inc(I);                { Comma so continue }
       SkipToComma := (I < TermCh);                   { Return result }
     END;

     FUNCTION CalcTerm: Byte;
     VAR K: Byte;
     BEGIN
       K := I;                                        { Hold count }
       ToGroupEnd(K);                                 { Find group end }
       CalcTerm := K;                                 { Return count }
     END;

     FUNCTION Iteration: TPicResult;
     VAR Itr, K, L: Byte; Rslt: TPicResult; NewTermCh: Byte;
     BEGIN
       Itr := 0;                                      { Zero iteration }
       Iteration := prError;                          { Preset error result }
       Inc(I);                                        { Skip '*' character }
       While Pic Sw_PString_DeRef[I] in ['0'..'9'] Do Begin           { Entry is a number }
         Itr := Itr * 10 + Byte(Pic Sw_PString_DeRef[I]) - Byte('0'); { Convert to number }
         Inc(I);                                      { Next character }
       End;
       If (I <= TermCh) Then Begin                    { Not end of name }
         K := I;                                      { Hold count }
         NewTermCh := CalcTerm;                       { Calc next terminator }
         If (Itr <> 0) Then Begin
           For L := 1 To Itr Do Begin                 { For each character }
             I := K;                                  { Reset count }
             Rslt := Process(NewTermCh);              { Process new entry }
             If (NOT IsComplete(Rslt)) Then Begin     { Not empty }
               If (Rslt = prEmpty) Then               { Check result }
                 Rslt := prIncomplete;                { Return incomplete }
               Iteration := Rslt;                     { Return result }
               Exit;                                  { Now exit }
             End;
           End;
         End Else Begin
           Repeat
             I := K;                                  { Hold count }
             Rslt := Process(NewTermCh);              { Process new entry }
           Until (NOT IsComplete(Rslt));              { Until complete }
           If (Rslt = prEmpty) OR (Rslt = prError)    { Check for any error }
           Then Begin
             Inc(I);                                  { Next character }
             Rslt := prAmbiguous;                     { Return result }
           End;
         End;
         I := NewTermCh;                              { Find next name }
       End Else Rslt := prSyntax;                     { Completed }
       Iteration := Rslt;                             { Return result }
     END;

     FUNCTION Group: TPicResult;
     VAR Rslt: TPicResult; TermCh: Byte;
     BEGIN
       TermCh := CalcTerm;                            { Calc new term }
       Inc(I);                                        { Next character }
       Rslt := Process(TermCh - 1);                   { Process the name }
       If (NOT IsIncomplete(Rslt)) Then I := TermCh;  { Did not complete }
       Group := Rslt;                                 { Return result }
     END;

     FUNCTION CheckComplete (Rslt: TPicResult): TPicResult;
     VAR J: Byte;
     BEGIN
       J := I;                                        { Hold count }
       If IsIncomplete(Rslt) Then Begin               { Check if complete }
         While True Do
           Case Pic Sw_PString_DeRef[J] Of
             '[': ToGroupEnd(J);                      { Find name end }
             '*': If not(Pic Sw_PString_DeRef[J + 1] in ['0'..'9'])
               Then Begin
                 Inc(J);                              { Next name }
                 ToGroupEnd(J);                       { Find name end }
               End Else Break;
             Else Break;
           End;
         If (J = TermCh) Then Rslt := prAmbiguous;    { End of name }
       End;
       CheckComplete := Rslt;                         { Return result }
     END;

     FUNCTION Scan: TPicResult;
     VAR Ch: Char; Rslt: TPicResult;
     BEGIN
       Scan := prError;                               { Preset return error }
       Rslt := prEmpty;                               { Preset empty result }
       While (I <> TermCh) AND (Pic Sw_PString_DeRef[I] <> ',')       { For each entry }
       Do Begin
         If (J > Length(Input)) Then Begin            { Move beyond length }
           Scan := CheckComplete(Rslt);               { Return result }
           Exit;                                      { Now exit }
         End;
         Ch := Input[J];                              { Fetch character }
         Case Pic Sw_PString_DeRef[I] of
           '#': If NOT (Ch in ['0'..'9']) Then Exit   { Check is a number }
               Else Consume(Ch);                      { Transfer number }
           '?': If (NOT IsLetter(Ch)) Then Exit       { Check is a letter }
               Else Consume(Ch);                      { Transfer character }
           '&': If (NOT IsLetter(Ch)) Then Exit       { Check is a letter }
               Else Consume(UpCase(Ch));              { Transfer character }
           '!': Consume(UpCase(Ch));                  { Transfer character }
           '@': Consume(Ch);                          { Transfer character }
           '*': Begin
             Rslt := Iteration;                       { Now re-iterate }
             If (NOT IsComplete(Rslt)) Then Begin     { Check not complete }
               Scan := Rslt;                          { Return result }
               Exit;                                  { Now exit }
             End;
             If (Rslt = prError) Then                 { Check for error }
               Rslt := prAmbiguous;                   { Return ambiguous }
           End;
           '{': Begin
             Rslt := Group;                           { Return group }
             If (NOT IsComplete(Rslt)) Then Begin     { Not incomplete check }
               Scan := Rslt;                          { Return result }
               Exit;                                  { Now exit }
             End;
           End;
           '[': Begin
             Rslt := Group;                           { Return group }
             If IsIncomplete(Rslt) Then Begin         { Incomplete check }
               Scan := Rslt;                          { Return result }
               Exit;                                  { Now exit }
             End;
             If (Rslt = prError) Then                 { Check for error }
               Rslt := prAmbiguous;                   { Return ambiguous }
           End;
           Else If Pic Sw_PString_DeRef[I] = ';' Then Inc(I);         { Move fwd for follow }
           If (UpCase(Pic Sw_PString_DeRef[I]) <> UpCase(Ch)) Then    { Characters differ }
             If (Ch = ' ') Then Ch := Pic Sw_PString_DeRef[I]         { Ignore space }
             Else Exit;
           Consume(Pic Sw_PString_DeRef[I]);                          { Consume character }
         End; { Case }
         If (Rslt = prAmbiguous) Then                 { If ambiguous result }
           Rslt := prIncompNoFill                     { Set incomplete fill }
           Else Rslt := prIncomplete;                 { Set incomplete }
       End;{ While}
       If (Rslt = prIncompNoFill) Then                { Check incomp fill }
         Scan := prAmbiguous Else                     { Return ambiguous }
         Scan := prComplete;                          { Return completed }
     END;

   BEGIN
     Incomp := False;                                 { Clear incomplete }
     InCompJ:=0;                                      { set to avoid a warning }
     OldI := I;                                       { Hold I count }
     OldJ := J;                                       { Hold J count }
     Repeat
       Rslt := Scan;                                  { Scan names }
       If (Rslt IN [prComplete, prAmbiguous]) AND
       Incomp AND (J < IncompJ) Then Begin            { Check if complete }
         Rslt := prIncomplete;                        { Return result }
         J := IncompJ;                                { Return position }
       End;
       If ((Rslt = prError) OR (Rslt = prIncomplete)) { Check no errors }
       Then Begin
         Process := Rslt;                             { Hold result }
         If ((NOT Incomp) AND (Rslt = prIncomplete))  { Check complete }
         Then Begin
           Incomp := True;                            { Set incomplete }
           IncompI := I;                              { Set current position }
           IncompJ := J;                              { Set current position }
         End;
         I := OldI;                                   { Restore held value }
         J := OldJ;                                   { Restore held value }
         If (NOT SkipToComma) Then Begin              { Check not comma }
           If Incomp Then Begin                       { Check incomplete }
             Process := prIncomplete;                 { Set incomplete mask }
             I := IncompI;                            { Hold incomp position }
             J := IncompJ;                            { Hold incomp position }
           End;
           Exit;                                      { Now exit }
         End;
         OldI := I;                                   { Hold position }
       End;
     Until (Rslt <> prError) AND                      { Check for error }
       (Rslt <> prIncomplete);                        { Incomplete load }
     If (Rslt = prComplete) AND Incomp Then           { Complete load }
       Process := prAmbiguous Else                    { Return completed }
       Process := Rslt;                               { Return result }
   END;

   FUNCTION SyntaxCheck: Boolean;
   VAR I, BrkLevel, BrcLevel: SmallInt;
   Begin
     SyntaxCheck := False;                            { Preset false result }
     If (Pic Sw_PString_DeRef <> '') AND (Pic Sw_PString_DeRef[Length(Pic Sw_PString_DeRef)] <> ';')  { Name is valid }
     AND ((Pic Sw_PString_DeRef[Length(Pic Sw_PString_DeRef)] = '*') AND
     (Pic Sw_PString_DeRef[Length(Pic Sw_PString_DeRef) - 1] <> ';') = False)         { Not wildcard list }
     Then Begin
       I := 1;                                        { Set count to 1 }
       BrkLevel := 0;                                 { Zero bracket level }
       BrcLevel := 0;                                 { Zero bracket level }
       While (I <= Length(Pic Sw_PString_DeRef)) Do Begin             { For each character }
         Case Pic Sw_PString_DeRef[I] Of
           '[': Inc(BrkLevel);                        { Inc bracket level }
           ']': Dec(BrkLevel);                        { Dec bracket level }
           '{': Inc(BrcLevel);                        { Inc bracket level }
           '}': Dec(BrcLevel);                        { Dec bracket level }
           ';': Inc(I);                               { Next character }
         End;
         Inc(I);                                      { Next character }
       End;
       If (BrkLevel = 0) AND (BrcLevel = 0) Then      { Check both levels 0 }
         SyntaxCheck := True;                         { Return true syntax }
     End;
   End;

BEGIN
   Picture := prSyntax;                               { Preset error default }
   If SyntaxCheck Then Begin                          { Check syntax }
     Picture := prEmpty;                              { Preset picture empty }
     If (Input <> '') Then Begin                      { We have an input }
       J := 1;                                        { Set J count to 1 }
       I := 1;                                        { Set I count to 1 }
       Rslt := Process(Length(Pic Sw_PString_DeRef) + 1);             { Set end of name }
       If (Rslt <> prError) AND (Rslt <> prSyntax) AND
        (J <= Length(Input)) Then Rslt := prError;    { Check for any error }
       If (Rslt = prIncomplete) AND AutoFill          { Check autofill flags }
       Then Begin
         Reprocess := False;                          { Set reprocess false }
         while (I <= Length(Pic Sw_PString_DeRef)) AND (NOT           { Not at end of name }
         IsSpecial(Pic Sw_PString_DeRef[I], '#?&!@*{}[],'#0))         { No special chars }
         DO Begin
           If Pic Sw_PString_DeRef[I] = ';' Then Inc(I);              { Check for next mark }
           Input := Input + Pic Sw_PString_DeRef[I];                  { Move to that name }
           Inc(I);                                    { Inc count }
           Reprocess := True;                         { Set reprocess flag }
         End;
         J := 1;                                      { Set J count to 1 }
         I := 1;                                      { Set I count to 1 }
         If Reprocess Then                            { Check for reprocess }
           Rslt := Process(Length(Pic Sw_PString_DeRef) + 1);         { Move to next name }
       End;
       If (Rslt = prAmbiguous) Then                   { Result ambiguous }
         Picture := prComplete Else                   { Return completed }
         If (Rslt = prInCompNoFill) Then              { Result incomplete }
           Picture := prIncomplete Else               { Return incomplete }
             Picture := Rslt;                         { Return result }
     End;
   End;
END;

{--TPXPictureValidator------------------------------------------------------}
{  Error -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TPXPictureValidator.Error;
CONST PXErrMsg = 'Input does not conform to picture:';
VAR S: Sw_String;
BEGIN
   If Pic <> Sw_PString_Empty Then S := Pic Sw_PString_DeRef Else S := 'No name';{ Transfer filename }
   MessageBox(PxErrMsg + #13' %s', @S,  mfError OR
     mfOKButton);                                     { Message box }
END;

{--TPXPictureValidator------------------------------------------------------}
{  Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TPXPictureValidator.Store (Var S: TStream);
BEGIN
  TValidator.Store(S);                                { TValidator.store call }
{$ifdef FV_UNICODE}
  S.WriteUnicodeString(Pic);                          { Write filename }
{$else FV_UNICODE}
  S.WriteStr(Pic);                                    { Write filename }
{$endif FV_UNICODE}
END;

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{                     TFilterValidator OBJECT METHODS                       }
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

{--TFilterValidator---------------------------------------------------------}
{  Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
CONSTRUCTOR TFilterValidator.Init (AValidChars: CharSet);
BEGIN
   Inherited Init;                                    { Call ancestor }
   ValidChars := AValidChars;                         { Hold valid char set }
END;

{--TFilterValidator---------------------------------------------------------}
{  Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
CONSTRUCTOR TFilterValidator.Load (Var S: TStream);
BEGIN
   Inherited Load(S);                                 { Call ancestor }
   S.Read(ValidChars, SizeOf(ValidChars));            { Read valid char set }
END;

{--TFilterValidator---------------------------------------------------------}
{  IsValid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB           }
{---------------------------------------------------------------------------}
FUNCTION TFilterValidator.IsValid (Const S: Sw_String): Boolean;
VAR I: SmallInt;
BEGIN
   I := 1;                                            { Start at position 1 }
   While S[I] In ValidChars Do Inc(I);                { Check each char }
   If (I > Length(S)) Then IsValid := True Else       { All characters valid }
     IsValid := False;                                { Invalid characters }
END;

{--TFilterValidator---------------------------------------------------------}
{  IsValidInput -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB      }
{---------------------------------------------------------------------------}
FUNCTION TFilterValidator.IsValidInput (Var S: Sw_String; SuppressFill: Boolean): Boolean;
VAR I: SmallInt;
BEGIN
   I := 1;                                            { Start at position 1 }
   While S[I] In ValidChars Do Inc(I);                { Check each char }
   If (I > Length(S)) Then IsValidInput := True       { All characters valid }
     Else IsValidInput := False;                      { Invalid characters }
END;

{--TFilterValidator---------------------------------------------------------}
{  Error -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TFilterValidator.Error;
CONST PXErrMsg = 'Invalid character in input';
BEGIN
   MessageBox(PXErrMsg, Nil, mfError OR mfOKButton);  { Show error message }
END;

{--TFilterValidator---------------------------------------------------------}
{  Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TFilterValidator.Store (Var S: TStream);
BEGIN
   TValidator.Store(S);                               { TValidator.Store call }
   S.Write(ValidChars, SizeOf(ValidChars));           { Write valid char set }
END;

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{                      TRangeValidator OBJECT METHODS                       }
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

{--TRangeValidator----------------------------------------------------------}
{  Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
CONSTRUCTOR TRangeValidator.Init (AMin, AMax: LongInt);
BEGIN
   Inherited Init(['0'..'9','+','-']);                { Call ancestor }
   If (AMin >= 0) Then                                { Check min value > 0 }
     ValidChars := ValidChars - ['-'];                { Is so no negatives }
   Min := AMin;                                       { Hold min value }
   Max := AMax;                                       { Hold max value }
END;

{--TRangeValidator----------------------------------------------------------}
{  Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
CONSTRUCTOR TRangeValidator.Load (Var S: TStream);
BEGIN
   Inherited Load(S);                                 { Call ancestor }
   S.Read(Min, SizeOf(Min));                          { Read min value }
   S.Read(Max, SizeOf(Max));                          { Read max value }
END;

{--TRangeValidator----------------------------------------------------------}
{  IsValid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB           }
{---------------------------------------------------------------------------}
FUNCTION TRangeValidator.IsValid (Const S: Sw_String): Boolean;
VAR Value: LongInt; Code: Sw_Integer;
BEGIN
   IsValid := False;                                  { Preset false result }
   If Inherited IsValid(S) Then Begin                 { Call ancestor }
     Val(S, Value, Code);                             { Convert to number }
     If (Value >= Min) AND (Value <= Max)             { With valid range }
       AND (Code = 0) Then IsValid := True;           { No illegal chars }
   End;
END;

{--TRangeValidator----------------------------------------------------------}
{  Transfer -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB          }
{---------------------------------------------------------------------------}
FUNCTION TRangeValidator.Transfer (Var S: Sw_String; Buffer: Pointer; Flag: TVTransfer): Word;
VAR Value: LongInt; Code: Sw_Integer;
BEGIN
   If (Options AND voTransfer <> 0) Then Begin        { Tranfer mask set }
     Transfer := SizeOf(Value);                       { Transfer a longint }
     Case Flag Of
       vtGetData: Begin
         Val(S, Value, Code);                         { Convert s to number }
         LongInt(Buffer^) := Value;                   { Transfer result }
       End;
       vtSetData: Str(LongInt(Buffer^), S);           { Convert to string s }
     End;
   End Else Transfer := 0;                            { No transfer = zero }
END;

{--TRangeValidator----------------------------------------------------------}
{  Error -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TRangeValidator.Error;
CONST PXErrMsg = 'Value not in the range';
VAR Params: Array[0..1] Of PtrInt;
BEGIN
   Params[0] := Min;                                  { Transfer min value }
   Params[1] := Max;                                  { Transfer max value }
   MessageBox(PXErrMsg+' %d to %d', @Params,
     mfError OR mfOKButton);                          { Display message }
END;

{--TRangeValidator----------------------------------------------------------}
{  Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TRangeValidator.Store (Var S: TStream);
BEGIN
   TFilterValidator.Store(S);                         { TFilterValidator.Store }
   S.Write(Min, SizeOf(Min));                         { Write min value }
   S.Write(Max, SizeOf(Max));                         { Write max value }
END;

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{                      TLookUpValidator OBJECT METHODS                      }
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

{--TLookUpValidator---------------------------------------------------------}
{  IsValid -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB           }
{---------------------------------------------------------------------------}
FUNCTION TLookUpValidator.IsValid (Const S: Sw_String): Boolean;
BEGIN
   IsValid := LookUp(S);                              { Check for string }
END;

{--TLookUpValidator---------------------------------------------------------}
{  LookUp -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB            }
{---------------------------------------------------------------------------}
FUNCTION TLookupValidator.Lookup (Const S: Sw_String): Boolean;
BEGIN
   Lookup := True;                                    { Default return true }
END;

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{                   TStringLookUpValidator OBJECT METHODS                   }
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

{--TStringLookUpValidator---------------------------------------------------}
{  Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
CONSTRUCTOR TStringLookUpValidator.Init (AStrings: PStringCollection);
BEGIN
   Inherited Init;                                    { Call ancestor }
   Strings := AStrings;                               { Hold string list }
END;

{--TStringLookUpValidator---------------------------------------------------}
{  Load -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
CONSTRUCTOR TStringLookUpValidator.Load (Var S: TStream);
BEGIN
   Inherited Load(S);                                 { Call ancestor }
   Strings := PStringCollection(S.Get);               { Fecth string list }
END;

{--TStringLookUpValidator---------------------------------------------------}
{  Done -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB              }
{---------------------------------------------------------------------------}
DESTRUCTOR TStringLookUpValidator.Done;
BEGIN
   NewStringList(Nil);                                { Dispsoe string list }
   Inherited Done;                                    { Call ancestor }
END;

{--TStringLookUpValidator---------------------------------------------------}
{  Lookup -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB            }
{---------------------------------------------------------------------------}
FUNCTION TStringLookUpValidator.Lookup (Const S: Sw_String): Boolean;
{$IFDEF PPC_VIRTUAL} VAR Index: LongInt; {$ELSE} VAR Index: sw_Integer; {$ENDIF}
BEGIN
   Lookup := False;                                   { Preset false return }
   If (Strings <> Nil) Then
     Lookup := Strings^.Search(@S, Index);            { Search for string }
END;

{--TStringLookUpValidator---------------------------------------------------}
{  Error -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TStringLookUpValidator.Error;
CONST PXErrMsg = 'Input not in valid-list';
BEGIN
   MessageBox(PXErrMsg, Nil, mfError OR mfOKButton);  { Display message }
END;

{--TStringLookUpValidator---------------------------------------------------}
{  NewStringList -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB     }
{---------------------------------------------------------------------------}
PROCEDURE TStringLookUpValidator.NewStringList (AStrings: PStringCollection);
BEGIN
   If (Strings <> Nil) Then Dispose(Strings, Done);   { Free old string list }
   Strings := AStrings;                               { Hold new string list }
END;

{--TStringLookUpValidator---------------------------------------------------}
{  Store -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB             }
{---------------------------------------------------------------------------}
PROCEDURE TStringLookUpValidator.Store (Var S: TStream);
BEGIN
   TLookupValidator.Store(S);                         { TlookupValidator call }
   S.Put(Strings);                                    { Now store strings }
END;

{***************************************************************************}
{                            INTERFACE ROUTINES                             }
{***************************************************************************}

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
{                           OBJECT REGISTER ROUTINES                        }
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

{---------------------------------------------------------------------------}
{  RegisterValidate -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 18May98 LdB  }
{---------------------------------------------------------------------------}
PROCEDURE RegisterValidate;
BEGIN
   RegisterType(RPXPictureValidator);                 { Register viewer }
   RegisterType(RFilterValidator);                    { Register filter }
   RegisterType(RRangeValidator);                     { Register validator }
   RegisterType(RStringLookupValidator);              { Register str lookup }
END;

END.