forked from haghish/rcall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rcall_counter.ado
39 lines (26 loc) · 1.04 KB
/
Rcall_counter.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
program Rcall_counter, rclass
local openbrackets 0
// Remove string quotation to avoid open brackets that appear in quotations
// ------------------------------------------------------------------------
local line `"`macval(0)'"'
// Count open brackets
// ------------------------------------------------------------------------
while strpos(`"`macval(line)'"',"{") != 0 {
local br = strpos(`"`macval(line)'"',"{")
local l1 = substr(`"`macval(line)'"',1, `br')
local l2 = substr(`"`macval(line)'"',`br'+1,.)
local openbrackets `++openbrackets'
local line `"`macval(l2)'"'
}
// count closed brackets
// ------------------------------------------------------------------------
while strpos(`"`macval(0)'"',"}") != 0 {
local br = strpos(`"`macval(l2)'"',"}")
local l1 = substr(`"`macval(l2)'"',1, `br'+1)
local l2 = substr(`"`macval(l2)'"',`br'+2,.)
local openbrackets `--openbrackets'
local 0 `"`macval(l2)'"'
}
return scalar Rcall_counter = `openbrackets'
end
*Rcall_counter this is a line {} whatever comes next { {