-
Notifications
You must be signed in to change notification settings - Fork 0
/
Thor_Tool_wlc_ProjectFolders.PRG
285 lines (234 loc) · 9.02 KB
/
Thor_Tool_wlc_ProjectFolders.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
******************************************************************************************
* PROGRAM: Thor_Tool_ProjectFolders.prg
*
* AUTHOR: Richard A. Schummer, November 2014
*
* COPYRIGHT © 2014-2015 All Rights Reserved.
* White Light Computing, Inc.
* Rick Schummer
* 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 checks to see if the data in tables can be cleanly opened.
*
* CALLING SYNTAX:
* DO Thor_Tool_ProjectFolders.prg
* Thor_Tool_ProjectFolders()
*
* INPUT PARAMETERS:
* lxParam1 = unknown data type, typically the standard Thor object passed to register
* the tool with Thor and appear on the Thor menu.
*
* OUTPUT PARAMETERS:
* None
*
* DATABASES ACCESSED:
* None
*
* GLOBAL PROCEDURES REQUIRED:
* None
*
* CODING STANDARDS:
* Version 5.2 compliant with no exceptions
*
* TEST INFORMATION:
* None
*
* SPECIAL REQUIREMENTS/DEVICES:
* None
*
* FUTURE ENHANCEMENTS:
* None
*
* LANGUAGE/VERSION:
* Visual FoxPro 09.00.0000.7423 or higher
*
******************************************************************************************
* C H A N G E L O G
*
* Date Developer Version Description
* ---------- ---------------------- ------- ---------------------------------
* 11/19/2014 Richard A. Schummer 1.0 Created Program
* ----------------------------------------------------------------------------------------
* 09/20/2015 Richard A. Schummer 1.1 Updated Thor registration information and
* general code cleanup
* ----------------------------------------------------------------------------------------
*
******************************************************************************************
LPARAMETERS lxParam1
IF PCOUNT() = 1 AND 'O' = VARTYPE(lxParam1) AND 'thorinfo' == LOWER(lxParam1.Class)
WITH lxParam1
* Required
.Prompt = 'List Project Paths' && used in menus
* Optional
TEXT TO .Description NOSHOW PRETEXT 1+2 && a description for the tool
This program opens up a project and lists the paths found in the project, along with the number of base source files in each folder.
You can select either full paths or relative paths via message box question. If one project is available in the current directory, it is automatically selected, otherwise you can select a project via the open dialog.
Additionally, a CSV file is created in the VFP Temp folder (SYS(2023)) with the project name and '_ProjectFolders' as the file name in case you need the information for other purposes.
ENDTEXT
.StatusBarText = 'Display all the paths from a VFP project file.'
.CanRunAtStartUp = .F.
* 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 1.1, September 20, 2015" && e.g., 'Version 7, May 18, 2011'
.Author = "Rick Schummer"
.Link = "https://github.com/rschummer/ThorTools" && link to a page for this tool
.VideoLink = SPACE(0) && link to a video for this tool
ENDWITH
RETURN lxParam1
ENDIF
IF PCOUNT() = 0
DO ToolCode
ELSE
DO ToolCode WITH lxParam1
ENDIF
RETURN
****************************************************************
****************************************************************
* Normal processing for this tool begins here.
PROCEDURE ToolCode
LPARAMETERS tcProjectName
LOCAL lnProjectFilesAvailable, ;
lcOldSafety, ;
lnResult, ;
llFullPath, ;
lcExportFile
#DEFINE ccCRLF CHR(13) + CHR(10)
SET ASSERTS ON
* Make sure that the proper parameter(s) are passed
IF PCOUNT() = 1 AND VARTYPE(tcProjectName) = "C" AND NOT EMPTY(tcProjectName)
ASSERT FILE(FORCEEXT(tcProjectName,"PJX")) MESSAGE "Can't find specified project"
ELSE
lnProjectFilesAvailable = ADIR(laPjx, "*.pjx")
IF lnProjectFilesAvailable # 1
tcProjectName = GETFILE("PJX", "Pick the project")
ELSE
tcProjectName = laPjx[1,1]
ENDIF
IF EMPTY(tcProjectName)
RETURN
ENDIF
ENDIF
TRY
lcOldExclusive = SET("Exclusive")
lcOldDeleted = SET("Deleted")
lcOldTalk = SET("Talk")
lcOldEscape = SET("Escape")
SET EXCLUSIVE OFF
SET DELETED ON
SET TALK OFF
SET ESCAPE ON
CloseCursors()
lnResult = MESSAGEBOX("Do you want full paths included in the directory summary?", ;
0+4+32 , ;
_screen.Caption)
llFullPath = lnResult = 6 && Yes
USE (tcProjectName) IN 0 SHARED AGAIN ALIAS curProject
lcExportFile = ADDBS(SYS(2023)) + FORCEEXT(JUSTSTEM(DBF("curProject")) + "_ProjectFolders", "csv")
IF llFullPath
SELECT CAST(LOWER(FULLPATH(JUSTPATH(name), ADDBS(JUSTPATH(DBF("curProject"))))) AS C(250)) AS cDirectories,;
COUNT(*) AS nFiles ;
FROM curProject ;
ORDER BY 1 ;
GROUP BY 1 ;
INTO CURSOR curDirectories
ELSE
SELECT CAST(JUSTPATH(name) AS C(250)) AS cDirectories,;
COUNT(*) AS nFiles ;
FROM curProject ;
ORDER BY 1 ;
GROUP BY 1 ;
INTO CURSOR curDirectories
ENDIF
SELECT curDirectories
lcOldSafety = SET("Safety")
SET SAFETY OFF
COPY TO (lcExportFile) TYPE CSV
SET SAFETY &lcOldSafety
GO TOP IN curDirectories
BROWSE LAST NOCAPTIONS NOWAIT
* Inform developer of file to use later if they like
WAIT WINDOW "Files exported to: " + LOWER(lcExportFile) + "..." NOWAIT
* Allow the project to be opened after the process is run
CloseProjectCursor()
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
SET EXCLUSIVE &lcOldExclusive
SET DELETED &lcOldDeleted
SET TALK &lcOldTalk
SET ESCAPE &lcOldEscape
ENDTRY
* Reset the message
SET MESSAGE TO
RETURN
ENDPROC
********************************************************************************
* METHOD NAME: CloseCursors
*
* AUTHOR: Richard A. Schummer, November 2014
*
* METHOD DESCRIPTION:
* This method is called to close the cursors opened by the tool.
*
* INPUT PARAMETERS:
* None
*
* OUTPUT PARAMETERS:
* None
*
********************************************************************************
PROCEDURE CloseCursors()
USE IN (SELECT("curDirectories"))
CloseProjectCursor()
RETURN
********************************************************************************
* METHOD NAME: CloseProjectCursor
*
* AUTHOR: Richard A. Schummer, December 2014
*
* METHOD DESCRIPTION:
* This method is called to close the project cursor opened by the tool.
*
* INPUT PARAMETERS:
* None
*
* OUTPUT PARAMETERS:
* None
*
********************************************************************************
PROCEDURE CloseProjectCursor()
USE IN (SELECT("curProject"))
RETURN
*: EOF :*