-
Notifications
You must be signed in to change notification settings - Fork 7
/
intltool.prg
1340 lines (1171 loc) · 33.7 KB
/
intltool.prg
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
* Program...........: INTLTool.PRG
* Author............: Steven Black
* Project...........: INTL for Visual FoxPro
* Repository........: https://github.com/StevenBlack/intl/
* Project...........: INTL for Visual FoxPro
* Description.......: Ancilary tools for the INTL Toolkit for Visual FoxPro
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Calling Samples...:
* =>To update the Strings table
* SET PROC TO INTLTool
* oIterator = create( "CProjectIterator","C:\VFP\Samples\Tastrade\Tastrade" )
* oVisitor = create( "cIntlUpdateVisitor" )
* oIterator.Accept( oVisitor )
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#DEFINE ccBreakStr " .+-/\*$#@(){}^%!=<>,;"
*///////////////////////////////////
* A B S T R A C T I T E R A T O R
*
* Abstract iterator class
*///////////////////////////////////
DEFINE CLASS cAbstractIterator AS Custom
cType = "Abstract"
Abstract_ID = "Visual INTL Iterator" && Class signature, don't change.
*====================================
*-- cAbstractIterator::Accept( o)
*====================================
* Accept a visitor object
*
FUNCTION Accept( toPassed )
IF TYPE( "toPassed" ) = "O" AND PEMSTATUS( toPassed, "Visit", 5 )
RETURN toPassed.Visit( this )
ENDIF
RETURN
*====================================
*-- cAbstractIterator::Close()
*====================================
FUNCTION Close()
RETURN .NULL.
*====================================
*-- cAbstractIterator::First()
*====================================
FUNCTION First()
RETURN .NULL.
*====================================
*-- cAbstractIterator::GetAlias(c)
*====================================
FUNCTION GetAlias( x )
RETURN .NULL.
*====================================
*-- cAbstractIterator::GetCurrentSourceID(x)
*====================================
FUNCTION GetCurrentSourceID( x )
RETURN .NULL.
*====================================
*-- cAbstractIterator::GetStructure(x)
*====================================
FUNCTION GetStructure( x )
RETURN .NULL.
*====================================
*-- cAbstractIterator::GetType(x)
*====================================
FUNCTION GetType( x )
RETURN This.cType
*====================================
*-- cAbstractIterator::Init( x)
*====================================
FUNCTION Init( x )
RETURN
*====================================
*-- cAbstractIterator::Last()
*====================================
FUNCTION LastItem()
RETURN .NULL.
*====================================
*-- cAbstractIterator::Next()
*====================================
FUNCTION Next
RETURN .NULL.
*====================================
*-- cAbstractIterator::Open(xx)
*====================================
FUNCTION Open( x, y )
RETURN .NULL.
*====================================
*-- cAbstractIterator::Prior()
*====================================
FUNCTION Prior()
RETURN .NULL.
*====================================
*-- cAbstractIterator::ProgrammaticChange()
*====================================
PROTECTED FUNCTION ProgrammaticChange()
RETURN .NULL.
*====================================
*-- cAbstractIterator::Release()
*====================================
FUNCTION Release()
RELEASE this
RETURN
*====================================
*-- cAbstractIterator::SetAlias( c )
*====================================
FUNCTION SetAlias( x )
RETURN .NULL.
*====================================
*-- cAbstractIterator::SetStructure(x)
*====================================
FUNCTION SetStructure( x )
RETURN .NULL.
ENDDEFINE
*///////////////////////////////////
* T A B L E I T E R A T O R
*
* General purpose table iterator
*///////////////////////////////////
DEFINE CLASS cTableIterator AS cAbstractIterator
PROTECTED cType, cStructure, cAlias
cType = "Table"
cStructure = ''
cAlias = ''
cSuffix = ".DBF"
lTableOpened =.f.
*====================================
*-- cTableIterator::Close( )
*====================================
* Close the table
*
FUNCTION Close()
LOCAL llRetVal
IF USED( This.GetAlias())
LOCAL lcAlias
lcAlias = This.GetAlias()
USE IN ( lcAlias )
llRetVal = .T.
ENDIF
RETURN llRetVal
*====================================
*-- cTableIterator::Destroy( )
*====================================
FUNCTION Destroy()
IF This.lTableOpened
This.Close()
ENDIF
RETURN
*====================================
*-- cTableIterator::First()
*====================================
* Go to top of file
*
FUNCTION First
IF ! USED( This.GetAlias())
RETURN .F.
ENDIF
IF ! BOF( This.GetAlias())
LOCAL lcAlias
lcAlias = This.GetAlias()
GO TOP IN ( lcAlias )
ELSE
RETURN .F.
ENDIF
This.ProgrammaticChange()
RETURN
*====================================
*-- cTableIterator::GetAlias()
*====================================
* Return the alias of the table being iterated
*
FUNCTION GetAlias( )
RETURN This.cAlias
*====================================
*-- cTableIterator::GetStructure( )
*====================================
* Return the name of the table being iterated
*
FUNCTION GetStructure()
RETURN This.cStructure
*====================================
*-- cTableIterator::Init( c)
*====================================
FUNCTION Init( tcPassed )
IF ISNULL( tcPassed ) OR ;
EMPTY( tcPassed ) OR ;
TYPE( "tcPassed" ) <> "C"
RETURN .F.
ENDIF
*-- Parse the passed string
This.SetAlias( STRTRAN( TrimPath( tcPassed ),"." ))
This.SetStructure( FULLPATH( tcPassed + IIF( "." $ tcPassed, '', This.cSuffix )))
IF !USED( This.GetAlias())
IF ! This.Open( This.GetStructure(), This.GetAlias())
RETURN .F.
ENDIF
ELSE
*-- could have the same alias used, but a different file!
IF ! This.GetStructure() $ DBF( This.GetAlias())
RETURN .F.
ENDIF
ENDIF
RETURN
*====================================
*-- cTableIterator::Last()
*====================================
* Go to the last record in the table
*
FUNCTION Last
IF ! USED( This.GetAlias())
RETURN .F.
ENDIF
LOCAL lcAlias
lcAlias = This.GetAlias()
GO BOTTOM IN ( lcAlias )
This.ProgrammaticChange()
RETURN
*====================================
*-- cTableIterator::Next()
*====================================
* Go to the last next record in the table
*
FUNCTION Next
LOCAL lcAlias
lcAlias = This.GetAlias()
IF ! USED( lcAlias )
RETURN .F.
ENDIF
IF ! EOF( lcAlias )
SKIP IN ( lcAlias )
IF EOF( lcAlias )
GO BOTTOM IN ( lcAlias )
RETURN .F.
ENDIF
ELSE
RETURN .F.
ENDIF
This.ProgrammaticChange()
RETURN
*====================================
*-- cTableIterator::Open(cc)
*====================================
* Open the table to be iterated
*
FUNCTION Open( tcFilename, tcAlias )
IF ISNULL( tcFilename ) OR ISNULL( tcAlias )
RETURN .NULL.
ENDIF
IF EMPTY( tcFileName ) OR TYPE( "tcFileName" ) <> "C"
tcFileName = This.GetStructure()
IF EMPTY( tcFileName ) OR TYPE( "tcFileName" ) <> "C"
RETURN .F.
ENDIF
ENDIF
IF EMPTY( tcAlias )
tcAlias = This.GetAlias()
IF EMPTY( tcAlias )
tcAlias = TRIMPATH( tcFileName, .T.)
ENDIF
IF EMPTY( tcAlias )
RETURN .F.
ENDIF
ENDIF
IF ! ( "." $ tcFileName )
tcFileName = tcFileName+ This.cSuffix
ENDIF
IF ! FILE( tcFIleName )
RETURN .F.
ENDIF
LOCAL lnErrorFlag, lcOldError
lnErrorFlag = 0
lcOldError = ON( "Error" )
ON ERROR lnErrorFlag = 1
USE ( tcFilename ) ALIAS ( tcAlias ) AGAIN SHARED IN 0
IF ! EMPTY( lcOldError )
ON ERROR &lcOldError
ELSE
ON ERROR
ENDIF
IF lnErrorFlag = 0
This.ProgrammaticChange()
This.lTableOpened = .T.
ENDIF
RETURN lnErrorFlag = 0
*====================================
*-- cTableIterator::Prior()
*====================================
* Go to the previous record
*
FUNCTION Prior
LOCAL llRetVal, lcAlias
lcAlias = This.GetAlias()
IF ! USED( lcAlias )
RETURN .F.
ENDIF
IF ! BOF( lcAlias )
SKIP -1 IN ( lcAlias )
IF BOF( lcAlias )
LOCATE
RETURN .F.
ENDIF
ELSE
RETURN .F.
ENDIF
This.ProgrammaticChange()
RETURN
*====================================
*-- cTableIterator::SetAlias(c)
*====================================
* Set the alias of the file to iterate
*
FUNCTION SetAlias( tcPassed )
This.cAlias = PROPER( tcPassed )
RETURN
*====================================
*-- cTableIterator::SetStructure(c)
*====================================
* Set the table to iterate
*
FUNCTION SetStructure( tcPassed )
This.cStructure = UPPER( tcPassed )
RETURN
ENDDEFINE
*///////////////////////////////////
* C P R O J E C T I T E R A T O R
*
* A general purpose project iterator
*///////////////////////////////////
DEFINE CLASS cProjectIterator AS cTableIterator
PROTECTED cProjectHomeDir
cProjectHomeDir = ""
cType = "Project"
cSuffix = ".PJX"
*====================================
*-- cProjectIterator::Init(x)
*====================================
* Parameters:
* tcPassed: the .PJX file
*
FUNCTION Init( tcPassed )
IF TYPE( "tcPassed" ) <> "C"
RETURN .F.
ENDIF
LOCAL llRetVal
*-- Adjust for missing file name suffix
IF ! "." $ tcpassed
tcpassed = ALLTRIM( tcpassed+This.cSuffix )
ENDIF
*-- Open the table as usual
llRetVal = cTableIterator::Init( tcPassed )
*-- Set the project home directory property
IF llRetVal
LOCAL lcAliasHandle
lcAliasHandle = This.GetAlias()
This.SetProjectHomeDir( &lcAliasHandle..HomeDir )
ELSE
*? Raise an exception
ENDIF
RETURN llRetVal
*====================================
*-- cProjectIterator::GetCurrentSourceID()
*====================================
*-- Return the full path of the project element
*
FUNCTION GetCurrentSourceID()
LOCAL lcAlias
lcAlias = This.GetAlias()
RETURN FULLPATH( STRTRAN( ALLTRIM( &lcAlias..Name ), CHR( 0 )), This.GetHomeDir())
*====================================
*-- cProjectIterator::GetHomeDir()
*====================================
* Return the project home directory
*
FUNCTION GetHomeDir()
RETURN This.cProjectHomeDir
*====================================
*-- cProjectIterator::SetprojectHomeDir(c)
*====================================
* Set the project home directory property
*
PROTECTED FUNCTION SetProjectHomeDir( tcPath )
This.cProjectHomeDir = AddBs( STRTRAN( ALLTRIM( tcPath ), CHR( 0 )))
RETURN
ENDDEFINE
*///////////////////////////////////
* C S C X I T E R A T O R
*
* A general purpose .SCX iterator
*///////////////////////////////////
DEFINE CLASS cSCXIterator AS cTableIterator
cType = "Form"
cSuffix = ".SCX"
ENDDEFINE
*///////////////////////////////////
* V C X I T E R A T O R
*
* A general purpose .VCX iterator
*///////////////////////////////////
DEFINE CLASS cVCXIterator AS cTableIterator
cType = "Visual Class Library"
cSuffix = ".VCX"
ENDDEFINE
*///////////////////////////////////
* M N X I T E R A T O R
*
* A general purpose .MNX iterator
*///////////////////////////////////
DEFINE CLASS cMNXIterator AS cTableIterator
cType = "Menu"
cSuffix = ".MNX"
ENDDEFINE
*///////////////////////////////////
* C F R X I T E R A T O R
*
* A general purpose .FRX iterator
*///////////////////////////////////
DEFINE CLASS cFRXIterator AS cTableIterator
cType = "Report"
cSuffix = ".FRX"
ENDDEFINE
********************************************************************************
********************************************************************************
*///////////////////////////////////
* A B S T R A C T V I S I T O R
*///////////////////////////////////
DEFINE CLASS cAbstractVisitor AS Line
oVisitee = .NULL.
FUNCTION Visit( toObj )
RETURN .NULL.
FUNCTION GetCurrentSourceID( toObj )
RETURN .NULL.
ENDDEFINE
*///////////////////////////////////
* M E T A D A T A V I S I T O R
*///////////////////////////////////
DEFINE CLASS cMetaDataVisitor AS cAbstractVisitor
FUNCTION VisitCode( tcCode )
FUNCTION VisitCodeMemo( tcCode, tcFile )
FUNCTION VisitPropertiesMemo( tcCode, tcProperty )
FUNCTION VisitDBCRecord( loIterator )
FUNCTION VisitExpression( tcExpression )
FUNCTION VisitSCXRecord( loIterator )
FUNCTION VisitMNXRecord( loIterator )
FUNCTION VisitMetaTable( loIterator )
FUNCTION VisitPJX( toProject )
FUNCTION VisitFRXRecord( loIterator )
FUNCTION VisitFRX( loIterator )
FUNCTION VisitString( tcElement, tcOrigin )
*====================================
*-- MetaDataVisitor::PropSrch(ccn)
*====================================
*-- Search the properties memo
*
FUNCTION PropSrch( tcPropString, tcProperty, tnOccurence )
LOCAL lcRetVal, lnAtPos, lcMemoData, lcPropLine, loMemoWidth
lcRetVal = CHR( 0 )
lnOccurence = IIF( Empty( tnOccurence ),1,tnOccurence )
lcMemoData = tcPropString
lnAtPos = atc( tcProperty,lcMemoData,lnOccurence )
IF lnAtPos>0
loMemoWidth = CREATE( "SetMemoWidth", 1024 )
m.lcPropLine = mline( lcMemoData,1,lnAtPos-1 )
lnAtPos = at( "= ",m.lcPropLine,1 )
IF lnAtPos > 0
m.lcPropLine = ALLTRIM( SUBS( m.lcPropLine,lnAtPos+1 ))
ELSE
m.lcPropLine = ''
ENDIF
ENDIF
lcRetVal = IIF( EMPTY( lcPropLine ),lcRetVal, lcPropLine )
RETURN lcRetVal
ENDDEFINE
*///////////////////////////////////
* cINTLReportTransformVisitor
*
* This visitor is designed to audit the
* visitee for localizeable resources
*///////////////////////////////////
DEFINE CLASS cINTLReportTransformVisitor AS cMetaDataVisitor
*====================================
*-- cINTLReportTransformVisitor::Visit(o)
*====================================
FUNCTION VISIT( toIterator )
IF ISNULL( toIterator )
RETURN .NULL.
ENDIF
IF TYPE( "toIterator" ) <> "O"
RETURN .F.
ENDIF
This.oVisitee = toIterator
toIterator.First()
LOCAL lcType
lcType = toIterator.GetType()
DO CASE
CASE PROPER( lcType ) = "Project"
This.VisitPJX( toIterator )
CASE PROPER( lcType ) = "Report"
This.VisitFRX( toIterator )
ENDCASE
RETURN
*====================================
*-- cINTLReportTransformVisitor::VisitPJX(o)
*====================================
FUNCTION VisitPJX( toIterator )
LOCAL lcProjItem, nAtPos, lcExt, loEngine
DO WHILE .T.
* lcProjItem = This.GetCurrentSourceID( toIterator )
lcProjItem = toIterator.GetCurrentSourceID()
nAtPos = RAT( ".", lcProjItem )
IF nAtPos> 0
lcExt = LOWER( SUBS( lcProjItem, nAtPos ))
IF lcExt == ".frx"
loEngine = CREATEOBJECT( "cFRXIterator", lcProjItem )
This.Visit( loEngine )
ENDIF
ENDIF
IF toIterator.Next()
LOOP
ENDIF
EXIT
ENDDO
RETURN
*====================================
*-- cINTLReportTransformVisitor::VisitFRX(o)
*====================================
FUNCTION VisitFRX( toIterator )
LOCAL lnOldSelect, lcAlias
lnOldSelect = SELECT()
lcAlias = toIterator.GetAlias()
SELECT ( lcAlias )
DO WHILE .T.
IF ObjType = 5
WAIT WINDOW toIterator.getAlias() + " --- " + ALLTRIM( Expr ) NOWAIT
This.VisitFRXRecord( toIterator )
ENDIF
IF toIterator.Next()
LOOP
ENDIF
EXIT
ENDDO
SELECT ( lnOldSelect )
RETURN
*====================================
*-- cINTLReportTransformVisitor::VisitFRXRecord(o)
*====================================
FUNCTION VisitFRXRecord( toIterator )
REPLACE Expr WITH "I(" + ALLTRIM( Expr ) + ")", ObjType WITH 8
RETURN
ENDDEFINE
*///////////////////////////////////
* I N T L U p d a t e V i s i t o r
*
* This visitor is designed to audit the
* visitee for localizeable resources
*///////////////////////////////////
DEFINE CLASS cINTLUpdateVisitor AS cMetaDataVisitor
cOldINTLUpdate = .NULL.
cOldINTLLang = .NULL.
lINTLInstanced = .NULL.
*====================================
*-- cINTLUpdateVisitor::Init(o)
*====================================
FUNCTION INIT( toPassed )
*-- We'll need an INTL object to poke with
IF TYPE( "_SCREEN.oINTL" ) <> "U" AND ;
ISNULL( _SCREEN.oINTL )
_SCREEN.RemoveObject( "oINTL" )
ENDIF
IF TYPE( "_SCREEN.oINTL" ) = "U"
LOCAL lnError, lcError, lcConfigLang, lni
LOCAL ARRAY laLang[1]
lcError = ON( "Error" )
lnError = 0
ON ERROR lnError = -1
SET PROC TO INTL ADDITIVE
IF TYPE( "_SCREEN.oINTL" ) = "O"
_SCREEN.RemoveObject( "oINTL" )
ENDIF
_SCREEN.AddObject( "oINTL", "INTL" )
IF !EMPTY( lcError )
ON ERROR &lcError
ELSE
ON ERROR
ENDIF
IF lnError = -1
* Raise an exception
WAIT WIND "INTL Update Error:" + ;
CHR( 13 ) + ;
"Problem Instantiating INTL object"
RETURN .F.
ENDIF
This.lINTLInstanced = .T.
_SCREEN.oINTL.aLang( @laLang )
lcConfigLang =''
FOR lni = 1 TO ALEN( laLang )
IF LOWER( laLang[lni]) <>"original"
lcConfigLang = laLang[lni]
EXIT
ENDIF
ENDFOR
IF !EMPTY( lcConfigLang )
This.cOldINTLLang = _SCREEN.oINTL.GetLanguage()
This.cOldINTLUpdate = _SCREEN.oINTL.GetUpdateMode()
_SCREEN.oINTL.SetLanguage( lcConfigLang )
_SCREEN.oINTL.SetUpdateMode( .T.)
ENDIF
ENDIF
RETURN
*====================================
*-- cINTLUpdateVisitor::Destroy()
*====================================
FUNCTION Destroy
IF ! ISNULL( This.cOldINTLUpdate )
_SCREEN.oINTL.SetUpdateMode( This.cOldINTLUpdate )
ENDIF
IF ! ISNULL( This.cOldINTLLang )
_SCREEN.oINTL.SetLanguage( This.cOldINTLLang )
ENDIF
IF ! ISNULL( This.lINTLInstanced )
_SCREEN.RemoveObject( "oINTL" )
ENDIF
RETURN
*====================================
*-- cINTLUpdateVisitor::GetCurrentSourceID(o)
*====================================
* Return values suitable for the
* STRINGS.cWhere field
*
FUNCTION GetCurrentSourceID( toIterator )
LOCAL lcType, lcAlias
IF TYPE( "toIterator" ) <> "O"
IF TYPE( "This.oVisitee" ) <> "O"
RETURN ""
ELSE
toIterator = This.oVisitee
ENDIF
ENDIF
lcType = toIterator.GetType()
DO CASE
CASE lcType = "Project"
lcAlias = toIterator.GetAlias()
RETURN FULLPATH( STRTRAN( ALLTRIM( &lcAlias..Name ), CHR( 0 )), toIterator.GetHomeDir())
CASE lcType = "Form"
lcAlias = toIterator.GetAlias()
RETURN toIterator.GetStructure() + " -- " + ALLTRIM( &lcAlias..oBjName )
CASE lcType = "Visual Class Library"
LOCAL lcAlias, lnOldSelect, lcRetVal
lcAlias = toIterator.GetAlias()
*-- Kluge here: "PARENT" is a keyword, and also a field in the VCX :-\
lnOldSelect = SELECT()
SELECT ( lcAlias )
lcRetVal = toIterator.GetStructure() + " -- " + ;
IIF(!EMPTY( Parent ), ALLTRIM( Parent ) +" .", "" ) + ;
ALLTRIM( ObjName )
SELECT ( lnOldSelect )
RETURN lcRetVal
CASE lcType = "Report" OR ;
lcType = "Menu"
RETURN toIterator.GetStructure()
ENDCASE
RETURN
*====================================
*-- cINTLUpdateVisitor::Visit(o)
*====================================
FUNCTION VISIT( toIterator )
IF ISNULL( toIterator )
RETURN .NULL.
ENDIF
*-- Hook here to visit .PRG files
IF TYPE( "toIterator" ) = "C"
LOCAL lnPos, lcFName
lcFName = toIterator
lnPos = RAT( ".", lcFName )
IF lnPos>0
LOCAL lcExt
lcExt = UPPER( SUBSTR( lcFName, LnPos + 1 ))
IF INLIST( lcExt, "PRG", "MPR", "SPR", "H" )
RETURN This.VisitCode( lcFName )
ENDIF
ENDIF
RETURN .F.
ENDIF
IF TYPE( "toIterator" ) <> "O"
RETURN .F.
ENDIF
This.oVisitee = toIterator
toIterator.First()
LOCAL lcType
lcType = toIterator.GetType()
DO CASE
CASE PROPER( lcType ) = "Project"
This.VisitPJX( toIterator )
CASE PROPER( lcType ) = "Form"
This.VisitMetaTable( toIterator, "VisitSCXRecord" )
CASE PROPER( lcType ) = "Visual Class Library"
This.VisitMetaTable( toIterator, "VisitSCXRecord" )
CASE PROPER( lcType ) = "Menu"
This.VisitMetaTable( toIterator, "VisitMNXRecord" )
CASE PROPER( lcType ) = "Report"
This.VisitMetaTable( toIterator, "VisitFRXRecord" )
CASE PROPER( lcType ) = "Table"
WAIT WINDOW toIterator.GetStructure() NOWAIT
DO CASE
CASE ".dbc" $ LOWER( toIterator.GetStructure())
This.VisitMetaTable( toIterator, "VisitDBCRecord" )
ENDCASE
ENDCASE
WAIT CLEAR
RETURN
*====================================
*-- cINTLUpdateVisitor::VisitCode(c)
*====================================
FUNCTION VisitCode( tcFileName )
IF ISNULL( tcFileName )
RETURN .NULL.
ENDIF
IF TYPE( "tcFileName" ) <> "C"
RETURN .F.
ENDIF
LOCAL lcFileName, lcOldAlias, jnOldBlock
lcFileName = ALLTRIM( UPPER( tcFilename ))
*-- Thanks to Mark Giesen at >MHS:MARK@AGIS for
*-- the following fix for long file names with embedded spaces.
IF " " $ lcFileName
lcFileName = '"' + lcFilename+ '"'
ENDIF
IF !FILE( lcFileName )
WAIT WIND NOWAIT 'File ' + lcFileName + ' Not Found'
ENDIF
lcOldAlias = ALIAS()
WAIT WINDOW lcFileName NOWAIT
IF ! USED( "IntlTemp" )
*-- Create a cursor if it's not open
jnOldBlock = SET( "BLOCKSIZE" )
SET BLOCKSIZE TO 32
CREATE CURSOR IntlTemp ;
( mOld M )
SET BLOCKSIZE TO ( jnOldBlock )
APPEND BLANK
ELSE
SELECT IntlTemp
REPLACE mOld WITH ""
ENDIF
APPEND MEMO mOld FROM &lcFileName OVERWRITE
This.VisitCodeMemo( mOld, lcFileName )
USE IN IntlTemp
IF !EMPTY( lcOldAlias ) AND USED ( lcOldAlias )
SELECT ( lcOldAlias )
ENDIF
WAIT CLEAR
*====================================
*-- cINTLUpdateVisitor::VisitCodeMemo(mc)
*====================================
FUNCTION VisitCodeMemo( tmMemo, tcFileName )
PRIVATE ;
lcFirstChars, ;
lcLine, ;
llIsContin, ;
lni, ;
loMemoWidth
loMemoWidth = CREATE( "SetMemoWidth", 8000 )
*-- Line counters
STORE 0 TO lnOldLineCount, lnNewLineCount
*-- Process the memo
* _MLINE = 0
lcLine = ''
* FOR lni = 1 to MEMLINES( tmMemo )
FOR lni = 1 to ALINES( laLines, tmMemo )
*-- read the next line in the file
* lcLine = lcLine+ MLINE( tmMemo, 1, _MLINE )
lcLine = lcLine + laLines[lni]
*-- trim it
lcLine = ALLTRIM( lcLine )
*-- continuation maybe?
IF RIGHT( lcLine, 1 ) = CHR( 59 )
lcLine = LEFT( lcLine, LEN( lcLine ) -1 ) + " "
LOOP
ENDIF
*-- comment maybe?
lcFirstChars = LEFT( LTRIM( STRTRAN( lcLine,CHR( 9 ))), 2 )
IF EMPTY( lcLine ) OR lcFirstChars = "*"
*-- we're done... next line please.
lcLine = ''
LOOP
ENDIF
This.strproc( lcLine, "I(", "strings", tcFileName )
* This.strproc( lcSnipLine, "MSGSVC(", "msgsvc", lcFileName )
lcLine = ""
ENDFOR
RETURN
*====================================
*-- cINTLUpdateVisitor::VisitDBCRecord(o)
*====================================
FUNCTION VisitDBCRecord( loIterator )
*? Not supported as of yet
RETURN
LOCAL lnOldSelect
lnOldSelect = SELECT()
SELECT( loIterator.cAlias )
IF ObjectType = "Field"
? "DBC Field Record", RECNO( loIterator.cAlias )
ENDIF
SELECT ( lnOldSelect )
RETURN
*====================================
*-- cINTLUpdateVisitor::VisitExpression(c)
*====================================
FUNCTION VisitExpression( tcExpression )
IF tcExpression = "'" OR ;
tcExpression = '"' OR ;
tcExpression = "["
This.VisitString( TrimDelim( tcExpression ))
ENDIF
RETURN
*====================================
*-- cINTLUpdateVisitor::VisitSCXRecord(o)
*====================================
FUNCTION VisitSCXRecord( loIterator )
LOCAL lcAlias, lcProperties, lcMethods
lcAlias = loIterator.GetAlias()
lcProperties = ALLTRIM(&lcAlias..Properties )
IF ! EMPTY( lcProperties )
This.VisitPropertiesMemo( lcProperties,"Caption" )
This.VisitPropertiesMemo( lcProperties,"ToolTipText" )
This.VisitPropertiesMemo( lcProperties,"StatusBarText" )
ENDIF
lcProperties = ''
lcMethods = ALLTRIM(&lcAlias..Methods )
IF ! EMPTY( lcMethods )
This.VisitCodeMemo( lcMethods, loIterator.GetCurrentSourceId())
ENDIF
RETURN
*====================================
*-- cINTLUpdateVisitor::VisitPropertiesMemo(c)
*====================================
FUNCTION VisitPropertiesMemo( tcMemo, tcProperty )
LOCAL lnI, lcProp
lnI = 0
DO WHILE .T.
lni = lni+1
lcprop = TrimDelim( This.PropSrch( tcMemo, tcProperty, lni ))
IF lcProp = CHR( 0 )
EXIT
ENDIF
This.VisitString( lcProp )
ENDDO
RETURN
*====================================
*-- cINTLUpdateVisitor::VisitMNXRecord(o)
*====================================
FUNCTION VisitMNXRecord( loIterator )
* Message field, Prompt field
LOCAL lnOldSelect, lcAlias
lnOldSelect = SELECT()
lcAlias = loIterator.GetAlias()
SELECT ( lcAlias )
DO WHILE .T.
IF ! EMPTY( Prompt ) ;
AND ! "\-" $ Prompt
This.VisitString( TrimDelim( Prompt ))
IF ! EMPTY( Message )
jcMessage = TrimDelim( message )
*-- We could have embedded CR_LF or just LF
*-- ... another one of those gotchas <sigh>
IF RIGHT( message, 2 ) = CHR( 13 ) +CHR( 10 ) && CR+LF
jcMessage = LEFT( message, LEN( message ) - 2 )
ELSE
IF RIGHT( message, 1 ) = CHR( 10 ) && LF
jcMessage = LEFT( message, LEN( message ) - 1 )
ENDIF
ENDIF
This.VisitString( jcMessage )
ENDIF
ENDIF
IF loIterator.Next()
LOOP