-
Notifications
You must be signed in to change notification settings - Fork 3
/
xpl.ado
executable file
·121 lines (103 loc) · 3.02 KB
/
xpl.ado
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
/*
xpl: stata based browser
Nov 19 2006,
Mikhail Bontch-Osmolovski
*/
#delimit;
version 9;
cap program drop xpl;
program define xpl;
args type name;
global EXCELDIR = "C:\Program Files\Microsoft Office\Office11\excel.exe";
global WORDDIR = "C:\Program Files\Microsoft Office\Office11\WINWORD.EXE";
global PDFDIR = "C:\Program Files\adobe\acrobat 7.0\reader\acrord32.exe";
/* Select what to do after a click */
if ("`type'" == "dir") {;
cd `"`name'"';
xpl;
exit;
};
if ("`type'" == "ado" | "`type'" == "do") {;
do "`name'";
xpl;
exit;
};
if ("`type'" == "dta") {;
use "`name'", clear;
exit;
};
if ("`type'" == "log") {;
view "`name'";
exit;
};
if ("`type'" == "txt") {;
view "`name'";
exit;
};
if ("`type'" == "xml" | "`type'"=="xls") {;
winexec "$EXCELDIR" "`name'";
exit;
};
if ("`type'" == "doc") {;
winexec "$WORDDIR" "`name'";
exit;
};
if ("`type'" == "pdf") {;
winexec "$PDFDIR" "`name'";
exit;
};
/* if no arguments - analyze and display files*/
local cur_dir `c(pwd)';
di "Current directory `cur_dir'";
local dirs : dir . dirs "*";
local all_files : dir . files "*";
local adofiles : dir . files "*.ado";
local dofiles : dir . files "*.do";
local dtafiles : dir . files "*.dta";
local docfiles : dir . files "*.doc";
local xlsfiles : dir . files "*.xls";
local xmlfiles : dir . files "*.xml";
local logfiles : dir . files "*.log";
local txtfiles : dir . files "*.txt";
local hlpfiles : dir . files "*.hlp";
local pdffiles : dir . files "*.pdf";
local other : dir . other "*";
/*Directories*/
noi di "Directories";
noi di `"{stata `"xpl dir .."' : <..> }"';
foreach dir of local dirs {;
local cmd "xpl dir `"`c(pwd)'/`dir'"'";
noi di `"{stata `"`cmd'"' : <`dir'> }"';
};
/*Files*/
local n : word count `all_files';
if (`n'>0) {;
noi di "Files:";
//local dofiles; local adofiles; local wordfiles; local xlfiles; local dtafiles; local
//local txtfiles `"`adofiles'"' `"`dofiles'"' `"`txtfiles'"';
//local txtfiles `" `adofiles' "' `" `dofiles' "' `" `txtfiles' "';
local txtfiles `"`adofiles' `dofiles' `hlpfiles' `txtfiles'"' ;
foreach ext in ado do dta log pdf doc xls xml txt {;
// noi di `"``ext'files'"';
local n : word count ``ext'files';
if (`n'>0) {; //``ext'files''"!="") {;
noi di ".`ext'";
foreach file of local `ext'files{;
//local cmd "xpl `ext' `file'";
local cmd "xpl `ext' `"`c(pwd)'/`file'"'";
noi di `"{stata `"`cmd'"' : `file' }"';
local all_files : subinstr local all_files "`file'" ".";
}; // end foreach file;
}; // end if n >0
}; // end foreach ext
foreach file of local all_files{;
if "`file'"~="." {;noi di "`file'";};
}; // end if foreach of files
noi di `other';
foreach file of local other{;
noi di "`file'";
}; // end if foreach of other
}; // end if n of all files > 0
//"local a: dir ["]dirname["] {files|dirs|other} ["]pattern["] [, nofail ]"
end; // prog xpl