forked from economic-research/open-ado
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.ado
More file actions
71 lines (58 loc) · 1.86 KB
/
init.ado
File metadata and controls
71 lines (58 loc) · 1.86 KB
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
program define init , rclass
version 14
// Check dependencies
capture findfile project.ado
if "`r(fn)'" == "" {
di as txt "user-written package project needs to be installed first;"
di as txt "use -ssc install project- to do that"
exit 498
}
capture findfile pexit.ado
if "`r(fn)'" == "" {
di as txt "user-written package pexit needs to be installed first;"
di as txt "use -ssc install pexit- to do that"
exit 498
}
capture macro drop debug
syntax [, debug debroute(string) double hard ignorefold logfile(string) omit proj(string) route(string)]
// Clean session
clear all
discard
// Check that user parameters are correct
if "`hard'" == "hard" & ("`debug'" == "debug" | "`omit'" == "omit"){
di "Cannot use option 'hard' with either 'debug' or 'omit'"
error 184
}
// Define global debug and omit
gl deb = "`debug'"
gl omit = "`omit'"
// Optionally set type double
if "`double'" == "double"{
set type double
}
// Set working directory
if ("$deb" == "debug" & "`proj'" != "") { // In debug mode change to route if specified
project `proj' , cd
if "`debroute'" != ""{ // If debroute specified change WD with respect to root directory
cd `debroute'
}
}
else if "`route'" != "" & "$deb" == ""{
cd `route'
}
// If log option set and not in debug mode open logile
if ("$deb" == "" & "`logfile'" != "") {
cap log close
mata : st_numscalar("LogExists", direxists("./log/")) //check if a log directory exists
local LogFolderSpecified = strpos("`logfile'", "log/") + strpos("`logfile'", "log\")
// If directory exists, but wasn't specified by user, then store logfile there
if LogExists == 1 & `LogFolderSpecified' == 0 & "`ignorefold'" == ""{
local logfile = "./log/" + "`logfile'"
}
log using "`logfile'" , replace
}
// Optionally drop all macros
if "`hard'" == "hard"{
macro drop _all
}
end