-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththor_tool_setpath3.prg
1495 lines (1203 loc) · 48.8 KB
/
thor_tool_setpath3.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: SetPath.prg
*
* AUTHOR: Richard A. Schummer, April 2001
*
* COPYRIGHT © 2001-2016 All Rights Reserved.
* Richard A. Schummer
* White Light Computing, Inc.
* PO Box 391
* Washington Twp., MI 48094
*
*
* EXPLICIT LICENSE:
* White Light Computing grants a perpetual, non-transferable, non-exclusive,
* royalty free, worldwide license to use and employ such materials within
* their business to other Visual FoxPro developers, with full derivative rights.
*
* DISCLAIMER OF WARRANTIES.
* The Software is provided "AS IS" and "WITH ALL FAULTS," without warranty of any kind,
* including without limitation the warranties of merchantability, fitness for a
* particular purpose and non-infringement. The Licensor makes no warranty that
* the Software is free of defects or is suitable for any particular purpose. In no
* event shall the Licensor be responsible for loss or damages arising from the installation
* or use of the Software, including but not limited to any indirect, punitive, special,
* incidental or consequential damages of any character including, without limitation,
* damages for loss of goodwill, work stoppage, computer failure or malfunction, or any
* and all other commercial damages or losses. The entire risk as to the quality and
* performance of the Software is borne by you. Should the Software prove defective, you
* and not the Licensor assume the entire cost of any service and repair.
*
* PROGRAM DESCRIPTION:
* This program opens up a project and sets the appropriate pathing
* to the files in the project. Allows forms to be run standalone
* and compiles to take place without worry if the paths are set correctly,
* or the files used by the project are in the project (if you take that approach),
* or have generic tools you use and have those is various directories.
*
* Instructions:
* - Copy PRG to subfolder of Thor: Thor\Thor\Tools\My Tools
* - Restart Thor.
* - Adds menu, Thor Tools > White Light Computing > Set Path to Project Paths
* - Set hotkey so I can run it quickly.
*
* If a project is open and active, the program prompts developer to see if they
* want to get pathing from the project.
* - If Yes, project is closed and paths are set.
* - If No, program checks current folder and sees how many projects are available.
* * If one, this project is opened without a prompt
* * If more than one or none, developer is prompted to pick the project.
*
* If the project is open in another VFP session, developer is notified the project
* cannot be opened and the pathing is not set.
*
* What paths are set?
* - The VFP folder is added to the path automatically, as are a couple of
* WLC development folders if they exist
* - The program checks for common developer subfolders to add to the path
* - Any other folder for a file in the project is added to the path
* - Paths are shortened to be relative to the project folder to avoid SET PATH limitation
*
* Programs are used to build SET PROCEDURE
* Class Libraries are used to build SET CLASSLIB
*
* A log file is created when you use the program. It logs when it starts and how long
* it takes to set things up. If there are problems with the files it will log those
* issues too. Optionally, you can log the settings of SET PATH, SET CLASSLIB and
* SET PROCEDURE to the log file. See clLOGPATHS constant in the beginning of the
* main procedure. You control the log file name and folder location using the two
* constants: ccSETPATHERRLOGPATH and ccSETPATHERRLOGFILE
*
* The same paths can be shown on the VFP Desktop when the program finishes figuring
* everything out. See clSHOWPATHS constant in the beginning of the ToolCode procedure.
*
* Extensibility:
* Since this program builds the paths generically, it is nice to have some hooks into
* customizing the program for your needs. To accomplish this, there are some procedures
* you can add code to customize the paths set up. Check out the following procs:
* SetPathDeveloperPreferenceDirectories(): add your folder preferences
* SetPathCommonProjectDirectories(): add standard project directories to the path.
* Preset to common ones. This boosts performance
* for bigger projects.
* AddCommonNonProjectClassLibs(): SET CLASSLIB to any non-project classlibs here
* AddCommonSetProcedures(): SET PROCEDURE TO any non-project classlibs here
*
* CALLING SYNTAX:
* DO SetPath WITH txParam1
* SetPath(txParam1)
*
* INPUT PARAMETERS:
* txParam1 = unknown type, optional, standard Thor object passed during startup
*
* OUTPUT PARAMETERS:
* None
*
* DATABASES ACCESSED:
* None
*
* GLOBAL PROCEDURES REQUIRED:
* None
*
* CODING STANDARDS:
* Version 5.0 compliant with no exceptions
*
* TEST INFORMATION:
* None
*
* SPECIAL REQUIREMENTS/DEVICES:
* None
*
* FUTURE ENHANCEMENTS:
* None
*
* LANGUAGE/VERSION:
* Visual FoxPro 09.00.0000 or higher
*
********************************************************************************
* C H A N G E L O G
*
* Date Developer Version Description
* ----------------------------------------------------------------------------------------
* 01/04/2001 Richard A. Schummer 1.0 Adopted program created at
* Kirtland Associates
* ----------------------------------------------------------------------------------------
* 04/04/2009 Richard A. Schummer 1.1 Cleanup and added local error handling for
* duplicate names in SET CLASSLIB
* ----------------------------------------------------------------------------------------
* 10/04/2014 Richard A. Schummer 2.0 Adopted for Thor integration
* ----------------------------------------------------------------------------------------
* 11/13/2014 Richard A. Schummer 2.1 Minor clean up of the code
* ----------------------------------------------------------------------------------------
* 06/17/2015 Richard A. Schummer 2.2 Clean up of the code, added ability to
* set path to the current opened project,
* show the paths collected, and better logging
* of the details. Added three methods to allow
* developers to configure extra pathing details
* before the project is scanned.
* ----------------------------------------------------------------------------------------
* 06/20/2015 Richard A. Schummer 2.3 Default location for log file now in VFP
* temp folder. New log entries are included
* at beginning of the log file. Also, temp
* log for current pass is deleted to
* Recycle Bin
* ----------------------------------------------------------------------------------------
* 07/03/2015 Richard A. Schummer 3.0 Options dialog with generic settings and
* developer preferences:
* display font name, size and attrib, log file
* name, whether you want logged, show the paths,
* and root project folder added to path.
* ----------------------------------------------------------------------------------------
* 08/29/2015 Richard A. Schummer 3.1 Refactored performance.
* ----------------------------------------------------------------------------------------
* 09/20/2015 Richard A. Schummer 3.2 Updated Thor registration information and
* general code cleanup
* ----------------------------------------------------------------------------------------
* 07/08/2016 Richard A. Schummer 3.3 Added new "AutoOpenProject" text file to
* force SetPath to open specific file. The use
* case is project folder that has several
* non-important or test projects that force
* open dialog to pick from each time. See
* constant ccAutoOpenProject to change name.
* If you don't want this, just skip creating
* the text file. Content of the file should
* be the project you want opened automatically.
* ----------------------------------------------------------------------------------------
* 09/19/2018 Richard A. Schummer 3.4 Fixed bug where crashed on error when project
* already open in another session of VFP. Also
* corrected so it does not twice display
* a message about file cannot be open.
* ----------------------------------------------------------------------------------------
*
******************************************************************************************
LPARAMETERS txParam1
* Used for Thor Registry Keys
#DEFINE ccTOOLNAME "WLC Path Setter 3"
* Default settings for Thor Registry Keys
#DEFINE ccSETPATHERRLOGPATH ADDBS(SYS(2023))
#DEFINE ccSETPATHERRLOGFILE [WLCSetPathErrorLog.txt]
#DEFINE clSHOWPATHS .F.
#DEFINE clLOGPATHS .F.
#DEFINE cnSHOWPATHSFONTSIZE 8
#DEFINE ccSHOWPATHSFONTNAME "Segoe UI"
#DEFINE ccSHOWPATHSFONTSTYLE "N"
#DEFINE ccROOTPROJECTFOLDER [J:\WLCProject]
* Default auto opening text file to tell tool which project to open
#DEFINE ccAutoOpenProject "wlcAutoOpenProject.txt"
* Extension class called at the end of the process
#DEFINE ccDEVHOOKPROGBASE [RAS]
#DEFINE ccDEVELOPERHOOKPROG [SetPathEnhancements"]
* Generic settings used in the process
#DEFINE cnSETMEMOWIDTFORSHOWPATH 225
#DEFINE cnSECONDSINDAY 24*60*60
#DEFINE ccCRLF CHR(13) + CHR(10)
IF PCOUNT() = 1 AND 'O' = VARTYPE(txParam1) AND 'thorinfo' == LOWER(txParam1.Class)
WITH txParam1
* Required
.Prompt = 'Set Path to Project Paths v3' && used in menus
* Optional
TEXT TO .Description NOSHOW PRETEXT 1+2 && a description for the tool
This program opens up a project and sets the appropriate pathing to the files in the project. This allows forms to be run standalone and compiles to take place without worry if the paths are set correctly.
If a project is open, you are asked if you want the paths to be set up for this project. Otherwsie, if there is only one project file in the current folder, the project is automatically opened, otherwise the developer is prompted for the PJX they want to open. You can also set paths for the currently opened project.
ENDTEXT
.StatusBarText = "Build FoxPro paths from project paths"
.CanRunAtStartUp = .T.
* Options Dialog settings
.OptionTool = ccTOOLNAME
.OptionClasses = "cusShowPaths, cusShowPathFontSize, cusShowPathFontName, cusShowPathFontStyle, cusLogFileName, cusRootProjectFolder"
* These are used to group and sort tools when they are displayed in menus or the Thor form
.Source = "WLC" && where did this tool come from? Your own initials, for instance
.Category = "WLC" && creates categorization of tools; defaults to .Source if empty
.Sort = 0 && the sort order for all items from the same Category
* For public tools, such as PEM Editor, etc.
.Version = "Version 3.2 - September 20, 2015" && e.g., 'Version 7, May 18, 2011'
.Author = "Rick Schummer and Steve Sawyer"
.Link = "http://www.whitelightcomputing.com/resourcesdeveloper.htm" && link to a page for this tool
.VideoLink = "" && link to a video for this tool
ENDWITH
RETURN txParam1
ENDIF
IF PCOUNT() = 0
DO ToolCode
ELSE
DO ToolCode WITH txParam1
ENDIF
RETURN
********************************************************************************
* METHOD NAME: ToolCode
*
* AUTHOR: Richard A. Schummer, November 2014
*
* METHOD DESCRIPTION:
* Core processing to open the project and set the paths for the various
* paths VFP keeps track of in the IDE.
*
* INPUT PARAMETERS:
* tcProjectName = character, really only useful for standalone run and not
* running through Thor. For instance:
*
* DO ToolCode in Thor_Tool_SetPath.PRG WITH "sos.pjx"
*
* OUTPUT PARAMETERS:
* None
*
********************************************************************************
PROCEDURE ToolCode(tcProjectName)
LOCAL lcAutoOpenFound
* Need these variables to survive the RELEASE ALL EXCEPT
PUBLIC gnProjectFilesAvailable, ;
glOpenAlready, ;
gcSetPathErrorLog
SET ASSERTS ON
* Make sure that the proper parameter(s) are passed
IF PCOUNT() = 1 AND VARTYPE(m.tcProjectName) = "C" AND NOT EMPTY(m.tcProjectName)
ASSERT FILE(FORCEEXT(m.tcProjectName,"PJX")) MESSAGE "Can't find specified project passed in!"
RETURN
ELSE
* RAS 17-Jun-2015, for Jody Meyer, added ability to set path for currently open and active project
glOpenAlready = .F.
llCanceled = .F.
TRY
loProject = application.ActiveProject
tcProjectName = LOWER(m.loProject.Name)
lnResult = MESSAGEBOX("Do you want to set path for " + m.tcProjectName + "?", ;
0+3+32+256, ;
_screen.Caption)
DO CASE
CASE m.lnResult = 6
* Yes
glOpenAlready = .T.
CASE m.lnResult = 7
* No
* Continue on so the developer can select the project to open
OTHERWISE
* Cancel
* Nothing to log at this time since we have not done anything.
llCanceled = .T.
ENDCASE
CATCH TO loException
* Nothing to do as there is real possibility that a project is not open at this time.
ENDTRY
IF m.llCanceled = .T.
RETURN
ENDIF
IF m.glOpenAlready
* No more selection of the project, continue on...
ELSE
lcAutoOpenFound = .F.
IF FILE(ccAutoOpenProject)
tcProjectName = FILETOSTR(ccAutoOpenProject)
tcProjectName = STRTRAN(m.tcProjectName, CHR(13), SPACE(0))
tcProjectName = STRTRAN(m.tcProjectName, CHR(10), SPACE(0))
tcProjectName = FORCEEXT(m.tcProjectName, "pjx")
IF FILE(m.tcProjectName)
lcAutoOpenFound = .T.
WAIT WINDOW "Using Auto Open Project file to determine the project to open..." NOWAIT
ELSE
tcProjectName = SPACE(0)
ENDIF
ENDIF
IF m.lcAutoOpenFound = .F.
gnProjectFilesAvailable = ADIR(laPjx, "*.pjx")
IF m.gnProjectFilesAvailable = 1
tcProjectName = laPjx[1,1]
ELSE
tcProjectName = GETFILE("PJX", "Pick the project")
ENDIF
ENDIF
ENDIF
IF EMPTY(m.tcProjectName)
RETURN
ENDIF
ENDIF
* Clean up and reset the environment
CLOSE ALL
RELEASE ALL EXCEPT tcProjectName
CLEAR
ON ERROR
ON SHUTDOWN
SET CLASSLIB TO
SET PROCEDURE TO
SET EXCLUSIVE OFF
SET DELETED ON
SET TALK OFF
SET ESCAPE ON
* Variable declarations.
LOCAL lcPath, ;
loException AS Exception, ;
lcProjDir, ;
lcToolsDir, ;
lcCurDir, ;
lcDeveloper, ;
lcProjectSetPathAdditional, ;
lcProjectFile, ;
lcNewPath, ;
lnFileCount, ;
lnCounter, ;
lnPercentage, ;
lcClassLib, ;
lcCode, ;
lcDeveloperHookProgram, ;
lcErrorLogInfo, ;
lcFile, ;
lcHomeDir, ;
lcType, ;
loFile, ;
loProject, ;
lnStartSeconds, ;
lnEndSeconds, ;
lnTimeToProcessProject, ;
lnFiles, ;
lcOldSafety
* Grab the developer from the login id.
lcDeveloper = RIGHT(SYS(0), RAT(SPACE(1), SYS(0)) -1)
lcCurDir = FULLPATH(CURDIR())
* Use Thor to get some settings for generic folders and error files
lcProjDir = EXECSCRIPT(_Screen.cThorDispatcher, "Get Option=", "Root Project Folder", ccTOOLNAME)
lcProjDir = IIF(ISNULL(m.lcProjDir), SPACE(0), ALLTRIM(m.lcProjDir))
lcToolsDir = IIF(ISNULL(m.lcProjDir) OR EMPTY(m.lcProjDir), SPACE(0), ADDBS(m.lcProjDir) + [Tools])
gcSetPathPermErrorLogFile = ALLTRIM(EXECSCRIPT(_Screen.cThorDispatcher, "Get Option=", "Log File Name", ccTOOLNAME))
gcSetPathPermErrorLogFile = IIF(ISNULL(m.gcSetPathPermErrorLogFile), SYS(2023), ALLTRIM(m.gcSetPathPermErrorLogFile))
gcSetPathPassErrorLogFile = FORCEEXT(JUSTPATH(m.gcSetPathPermErrorLogFile) + SYS(2015), "txt")
lnStartSeconds = 0
lnEndSeconds = 0
* If the permanent set path log file does not exist, initialize it to nothing.
IF FILE(m.gcSetPathPermErrorLogFile)
* Nothing to do
ELSE
STRTOFILE(SPACE(0), m.gcSetPathPermErrorLogFile)
ENDIF
* Start the path setting with non-project tool and add-on directories
* such as SDT, editors, browsers, etc. classes to the path.
* SAS - 09/28/01 - Changed to a full path so this will work
* when logged to a different directory other than main project folder
lcPath = SPACE(0)
IF NOT EMPTY(m.lcProjDir) AND DIRECTORY(m.lcProjDir)
lcPath = m.lcPath + IIF(EMPTY(m.lcPath), SPACE(0), [;]) + m.lcProjDir
ENDIF
IF NOT EMPTY(m.lcToolsDir) AND DIRECTORY(m.lcToolsDir)
lcPath = m.lcPath + IIF(EMPTY(m.lcPath), SPACE(0), [;]) + m.lcToolsDir
ENDIF
* Add VFP home directory, version independent
lcPath = m.lcPath + IIF(EMPTY(m.lcPath), SPACE(0), [;]) + HOME()
* First, add standard developer preference directories to the beginning of the path.
SetPathDeveloperPreferenceDirectories(m.lcPath)
* Add standard project directories to the path. This boosts performance for bigger projects.
SetPathCommonProjectDirectories()
* Get the path as it was built so far.
lcPath = SET("Path")
* SET CLASSLIB to any non-project classlibs here
AddCommonNonProjectClassLibs()
* SET PROCEDURE TO any non-project classlibs here
AddCommonSetProcedures()
* Assumption here is that you're working on a local drive, either
* in primary development or a source code controlled copy of the project
TRY
llOK = .T.
* Build some cursors to process folders faster
TRY
USE (m.tcProjectName) IN 0 SHARED AGAIN ALIAS _SetPathProj
* Build distinct list of folders in the project
SELECT DISTINCT ;
CAST(JUSTPATH(SYS(2014, LEFTC(name, 250))) AS C(250)) AS cFolder, ;
Type AS cType ;
FROM _setpathproj ;
INTO CURSOR curFolders
* Build list of files used for SET CLASSLIB and SET PROCEDURE (only class libraries and programs)
SELECT CAST(FULLPATH(LEFTC(name, 250)) AS C(250)) AS cClassLib, ;
Type AS cType ;
FROM _setpathproj ;
WHERE type = "V" ;
INTO CURSOR curClassLibs
SELECT CAST(FULLPATH(LEFTC(name, 250)) AS C(250)) AS cProgram, ;
Type AS cType ;
FROM _setpathproj ;
WHERE type = "P" ;
INTO CURSOR curPrograms
USE IN (SELECT("_SetPathProj"))
CATCH TO loException WHEN loException.ErrorNo = 1705
* Project is already open or you don't have proper permissions.
lcCode = "Access is denied to the project file ( " + m.tcProjectName + "). It is probably open already in different session of Visual FoxPro or you don't have proper permissions."
MESSAGEBOX(m.lcCode, ;
0+48, ;
_screen.Caption)
llOK = .F.
CATCH TO loException
* Project is most likely already open
lcCode = "Error: " + m.loException.Message + ;
" [" + TRANSFORM(m.loException.Details) + "] " + ;
" (" + TRANSFORM(m.loException.ErrorNo) + ")" + ;
" in " + m.loException.Procedure + ;
" on " + TRANSFORM(m.loException.LineNo)
MESSAGEBOX(m.lcCode, ;
0+48, ;
_screen.Caption)
llOK = .F.
ENDTRY
IF m.llOK
TRY
MODIFY PROJECT (m.tcProjectName) NOWAIT
CATCH TO loException WHEN loException.ErrorNo = 1705
* Project is already open or you don't have proper permissions.
lcCode = "Access is denied to the project file ( " + m.tcProjectName + "). It is probably open already in different session of Visual FoxPro or you don't have proper permissions."
MESSAGEBOX(m.lcCode, ;
0+48, ;
_screen.Caption)
llOK = .F.
CATCH TO loException
* Corruption of PJX or not a PJX file as is expected by Visual FoxPro
lcCode = "Error: " + m.loException.Message + ;
" [" + TRANSFORM(m.loException.Details) + "] " + ;
" (" + TRANSFORM(m.loException.ErrorNo) + ")" + ;
" in " + m.loException.Procedure + ;
" on " + TRANSFORM(m.loException.LineNo)
MESSAGEBOX(m.lcCode, ;
0+48, ;
_screen.Caption)
llOK = .F.
ENDTRY
IF m.llOK
loProject = application.ActiveProject
lcHomeDir = UPPER(m.loProject.HomeDir)
IF ADDBS(SET("Directory")) <> ADDBS(m.lcHomeDir)
CD (m.lcHomeDir)
ENDIF
LogIssue("Opened " + ALLTRIM(m.tcProjectName) + " in project manager - " + TRANSFORM(DATETIME()), "L")
* Extract all of the files, and use them to
* determine the path, and SET PROCEDURE to all
* PRG Files and SET CLASSLIB to all class libs
IF FILE("liblist.dbf") && For storing program elements
LOCAL lcOldSafety
USE liblist IN 0 EXCLUSIVE
lcOldSafety = SET("SAFETY")
SET SAFETY OFF
ZAP
SET SAFETY &lcOldSafety
ENDIF
lnCounter = 0
lnStartSeconds = SECONDS()
* SET PATH ------------------------------------------------------------
SELECT curFolders
WAIT WINDOW "Setting path from " + TRANSFORM(RECCOUNT("curClasslibs")) + " folders." NOWAIT
SCAN
lcNewPath = ALLTRIM(curFolders.cFolder)
IF NOT EMPTY(m.lcNewPath) AND (NOT (";" + m.lcNewPath) $ m.lcPath)
lcPath = ALLTRIM(m.lcPath) + ";" + m.lcNewPath
ENDIF
ENDSCAN
SET PATH TO &lcPath
LogIssue("Finished setting path from " + TRANSFORM(RECCOUNT("curFolders")) + " folders.", "L")
* SET CLASSLIB --------------------------------------------------------
SELECT curClassLibs
WAIT WINDOW "Setting classlib path from " + TRANSFORM(RECCOUNT("curClasslibs")) + " files."NOWAIT
SCAN
* Make sure we have a SET PROCEDURE TO this file
lcFile = ALLTRIM(curClassLibs.cClassLib)
lcType = ALLTRIM(curClassLibs.cType)
IF USED("liblist")
INSERT INTO liblist (mFileName, cType) VALUES (m.lcFile, m.lcType)
ENDIF
IF NOT m.lcFile $ SET("ClassLib")
TRY
SET CLASSLIB TO (m.lcFile) ADDITIVE
CATCH TO loException
lcErrorLogInfo = TRANSFORM(DATETIME()) + ;
": (form) " + ;
m.loException.Message + ;
" - " + ;
m.loException.Details + ;
ccCRLF
LogIssue(m.lcErrorLogInfo, "L")
ENDTRY
ENDIF
ENDSCAN
LogIssue("Finished setting classlib path from " + TRANSFORM(RECCOUNT("curClasslibs")) + " files.", "L")
* SET PROCEDURE -------------------------------------------------------
SELECT curPrograms
SCAN
* Make sure we have a SET PROCEDURE TO this file
lcFile = ALLTRIM(curPrograms.cProgram)
lcType = ALLTRIM(curPrograms.cType)
IF USED("liblist")
INSERT INTO liblist (mFileName, cType) VALUES (m.lcFile, m.lcType)
ENDIF
IF NOT m.lcFile $ SET("PROCEDURE")
TRY
SET PROCEDURE TO (m.lcFile) ADDITIVE
CATCH TO loException
lcErrorLogInfo = TRANSFORM(DATETIME()) + ;
": (procedure) " + ;
m.loException.Message + ;
" - " + ;
m.loException.Details + ;
ccCRLF
LogIssue(m.lcErrorLogInfo, "L")
ENDTRY
ENDIF
ENDSCAN
LogIssue("Finished setting procedure list from " + TRANSFORM(RECCOUNT("curPrograms")) + " files.", "L")
ENDIF
USE IN (SELECT("curFolders"))
USE IN (SELECT("curClassLibs"))
USE IN (SELECT("curPrograms"))
ENDIF
CATCH TO loException
lcCode = "Error: " + m.loException.Message + ;
" [" + TRANSFORM(m.loException.Details) + "] " + ;
" (" + TRANSFORM(m.loException.ErrorNo) + ")" + ;
" in " + m.loException.Procedure + ;
" on " + TRANSFORM(m.loException.LineNo)
MESSAGEBOX(lcCode, ;
0+48, ;
_screen.Caption)
FINALLY
lnEndSeconds = SECONDS()
ENDTRY
* RAS 17-Jun-2015, Added in the calculation of the time spent processing the project files, account for midnight project opening
IF lnStartSeconds = 0
lnTimeToProcessProject = 0
ELSE
lnTimeToProcessProject = IIF(m.lnEndSeconds > m.lnStartSeconds, m.lnEndSeconds - m.lnStartSeconds, cnSECONDSINDAY - m.lnStartSeconds + m.lnEndSeconds)
ENDIF
* RAS 10-Jan-2001 Added hook call to program so developers can customize their
* additions like SDT and hotkeys in their very own customized program.
lcDeveloperHookProgram = FORCEEXT(ccDEVHOOKPROGBASE + ccDEVELOPERHOOKPROG, "prg")
IF FILE(m.lcDeveloperHookProgram)
TRY
DO (m.lcDeveloperHookProgram)
CATCH TO loException
lcErrorLogInfo = TRANSFORM(DATETIME()) + ;
": (developerhook) " + ;
m.loException.Message + ;
" - " + ;
m.loException.Details + ;
ccCRLF
LogIssue(m.lcErrorLogInfo, "L")
ENDTRY
ELSE
* No hooks created, just execute base startup code
ENDIF
* Reset the message
SET MESSAGE TO
IF ExecScript(_Screen. cThorDispatcher, "Get Option=", "Show Paths", ccTOOLNAME)
ShowPaths()
ENDIF
IF ExecScript(_Screen. cThorDispatcher, "Get Option=", "Log Paths", ccTOOLNAME)
LogPaths()
ENDIF
lcTimeMessage = "Processed set paths for " + LOWER(m.tcProjectName) + " in " + TRANSFORM(m.lnTimeToProcessProject) + " seconds..."
WAIT WINDOW (m.lcTimeMessage) NOWAIT
IF m.llOK
lnFiles = application.ActiveProject.Files.Count
LogIssue(TRANSFORM(lnFiles) + " file" + IIF(lnFiles = 1, SPACE(0), "s") + " in the project", "L")
ENDIF
LogIssue(m.lcTimeMessage, "L")
LogIssue(REPLICATE("-", 80))
* RAS 20-Jun-2015, place the current log for this pass into the general log file along with the current contents.
lcOldSafety = SET("Safety")
SET SAFETY OFF
STRTOFILE(FILETOSTR(gcSetPathPassErrorLogFile) + ccCRLF + FILETOSTR(m.gcSetPathPermErrorLogFile), ;
m.gcSetPathPermErrorLogFile)
SET SAFETY &lcOldSafety
* Remove the temporary file created for this pass
DELETE FILE (m.gcSetPathPassErrorLogFile) RECYCLE
* Clean up the public variables.
RELEASE gnProjectFilesAvailable, gnOpenAlready, gcSetPathPassErrorLog, gcSetPathPermErrorLogFile
RETURN
********************************************************************************
* METHOD NAME: SetPathDeveloperPreferenceDirectories
*
* AUTHOR: Richard A. Schummer, June 2015
*
* METHOD DESCRIPTION:
* This method allows developer to add in their preferred paths to the
* beginning of the SET PATH. This is a perfect location to set paths up
* to their favorite tool folders.
*
* INPUT PARAMETERS:
* tcPath = character, not required, should be path to valid folders. No
* validation of the folders is done here.
*
* OUTPUT PARAMETERS:
* None
*
********************************************************************************
PROCEDURE SetPathDeveloperPreferenceDirectories(tcPath)
* If something is passed in and a character, set it to the path.
IF PCOUNT() = 1 AND VARTYPE(m.tcPath) = "C"
SET PATH TO &tcPath
ENDIF
*? Developers can add more here
RETURN
********************************************************************************
* METHOD NAME: SetPathCommonProjectDirectories
*
* AUTHOR: Richard A. Schummer, June 2015
*
* METHOD DESCRIPTION:
* Add native and standard project directories to the path first before checking
* the project for folders. This will speed up the process a little bit since it
* adds to the path once, not for each first file in the folder.
*
* Initial design incorporates many common named subfolders from the project
* folder and only if they exist. The reason for not incorporating all
* subfolders is so folders for things like Deployment or backup data folders
* are not included automatically.
*
* Initial testing shows this technique can save 33% of the time to open
* larger projects and set the path to the project folders for the files
* in the project.
*
* INPUT PARAMETERS:
* None
*
* OUTPUT PARAMETERS:
* None
*
********************************************************************************
PROCEDURE SetPathCommonProjectDirectories()
SET PATH TO "." ADDITIVE
IF DIRECTORY("programs")
SET PATH TO "programs" ADDITIVE
ENDIF
IF DIRECTORY("prgs")
SET PATH TO "prgs" ADDITIVE
ENDIF
IF DIRECTORY("progs")
SET PATH TO "progs" ADDITIVE
ENDIF
IF DIRECTORY("data")
SET PATH TO "data" ADDITIVE
ENDIF
IF DIRECTORY("libs")
SET PATH TO "libs" ADDITIVE
ENDIF
IF DIRECTORY("classes")
SET PATH TO "classes" ADDITIVE
ENDIF
IF DIRECTORY("vcx")
SET PATH TO "vcx" ADDITIVE
ENDIF
IF DIRECTORY("forms")
SET PATH TO "forms" ADDITIVE
ENDIF
IF DIRECTORY("reports")
SET PATH TO "reports" ADDITIVE
ENDIF
IF DIRECTORY("frx")
SET PATH TO "frx" ADDITIVE
ENDIF
IF DIRECTORY("labels")
SET PATH TO "labels" ADDITIVE
ENDIF
IF DIRECTORY("lbx")
SET PATH TO "lbx" ADDITIVE
ENDIF
IF DIRECTORY("graphics")
SET PATH TO "graphics" ADDITIVE
ENDIF
IF DIRECTORY("images")
SET PATH TO "images" ADDITIVE
ENDIF
IF DIRECTORY("bmp")
SET PATH TO "bmp" ADDITIVE
ENDIF
IF DIRECTORY("menus")
SET PATH TO "menus" ADDITIVE
ENDIF
IF DIRECTORY("includes")
SET PATH TO "includes" ADDITIVE
ENDIF
IF DIRECTORY("H")
SET PATH TO "H" ADDITIVE
ENDIF
IF DIRECTORY("text")
SET PATH TO "text" ADDITIVE
ENDIF
IF DIRECTORY("test")
SET PATH TO "test" ADDITIVE
ENDIF
IF DIRECTORY("help")
SET PATH TO "help" ADDITIVE
ENDIF
IF DIRECTORY("metadata")
SET PATH TO "metadata" ADDITIVE
ENDIF
IF DIRECTORY("docs")
SET PATH TO "docs" ADDITIVE
ENDIF
RETURN
********************************************************************************
* METHOD NAME:
*
* AUTHOR: Richard A. Schummer, June 2015
*
* METHOD DESCRIPTION:
* SET CLASSLIB to any non-project classlibs here.
*
* INPUT PARAMETERS:
* None
*
* OUTPUT PARAMETERS:
* None
*
********************************************************************************
PROCEDURE AddCommonNonProjectClassLibs()
*< SET CLASSLIB TO "" ADDITIVE
RETURN
********************************************************************************
* METHOD NAME: AddCommonSetProcedures
*
* AUTHOR: Richard A. Schummer, June 2015
*
* METHOD DESCRIPTION:
* SET PROCEDURE TO any non-project classlibs here.
*
* INPUT PARAMETERS:
* None
*
* OUTPUT PARAMETERS:
* None
*
********************************************************************************
*
PROCEDURE AddCommonSetProcedures()
*< SET PROCEDURE TO "" ADDITIVE
RETURN
********************************************************************************
* METHOD NAME: ShowPaths
*
* AUTHOR: Richard A. Schummer, June 2015
*
* METHOD DESCRIPTION:
* Display the different set paths created by this program. This creates
* quite a dump of information for larger projects. Font and Fontsize for
* the text can be set using #DEFINEs at the top of the ToolCode procedure.
*
* INPUT PARAMETERS:
* None
*
* OUTPUT PARAMETERS:
* None
*
********************************************************************************
PROCEDURE ShowPaths()
LOCAL lcOldScreenFontName, ;
lcFontAttrib, ;
llFontBold, ;
llFontItalic, ;
llOldScreenFontBold, ;
llOldScreenFontItalic, ;
lnOldMemoWidth, ;
lnOldScreenFontSize
lnOldMemoWidth = SET("Memowidth")
lnOldScreenFontSize = _screen.FontSize
lcOldScreenFontName = _screen.FontName
llOldScreenFontBold = _screen.FontBold
llOldScreenFontItalic = _screen.FontItalic
SET MEMOWIDTH TO cnSETMEMOWIDTFORSHOWPATH
lcFontAttrib = EXECSCRIPT(_Screen.cThorDispatcher, "Get Option=", "Show Path FontStyle", ccTOOLNAME)
lcFontAttrib = IIF(ISNULL(lcFontAttrib), "N", UPPER(lcFontAttrib))
llFontBold = IIF("B" $ lcFontAttrib, .T., .F.)
llFontItalic = IIF("I" $ lcFontAttrib, .T., .F.)
_screen.FontName = EXECSCRIPT(_Screen.cThorDispatcher, "Get Option=", "Show Path FontName", ccTOOLNAME)
_screen.FontSize = EXECSCRIPT(_Screen.cThorDispatcher, "Get Option=", "Show Path FontSize", ccTOOLNAME)
_screen.FontBold = llFontBold
_screen.FontItalic = llFontItalic
? "PATH:"
? SET("Path")
?
? "CLASS LIBRARIES:"
? SET("Classlib")
?
? "PROCEDURES:"
? SET("Procedure")
?
_screen.FontSize = m.lnOldScreenFontSize
_screen.FontName = m.lcOldScreenFontName
_screen.FontBold = m.llOldScreenFontBold
_screen.FontItalic = m.llOldScreenFontItalic
SET MEMOWIDTH TO lnOldMemoWidth
RETURN