📄 gs_fileinfo.ado
字号:
*! version 1.1.0 14nov2002
program gs_fileinfo, rclass
version 8
local 0 `"using `0'"'
syntax using/ [, SUFFIX]
gs_filetype `"`using'"', `suffix'
return add
if return(ft) != "live" {
exit
}
tempname h
file open `h' using `"`return(fn)'"', read text
file read `h' line // StataFileTM line
file read `h' line // .gph line
while (1) {
file read `h' line
gettoken h1 line : line
gettoken h2 line : line
if "`h1'" != "*!" {
exit
}
if ("`h2'"=="end") {
exit
}
else if "`h2'"=="family:" {
ret local family `line'
}
else if "`h2'"=="command:" {
ret local command `line'
}
else if "`h2'"=="command_date:" {
ret local command_date `line'
}
else if "`h2'"=="command_time:" {
ret local command_time `line'
}
else if "`h2'"=="datafile:" {
ret local dtafile `line'
}
else if "`h2'"=="datafile_date:" {
ret local dtafile_date `line'
}
else if "`h2'"=="scheme:" {
ret local scheme `line'
}
else if "`h2'"=="ysize:" {
ret local ysize `line'
}
else if "`h2'"=="xsize:" {
ret local xsize `line'
}
}
end
exit
if substr(`"`line'"',1,12) != "StataFileTM:" {
NotGph `"`using'"'
}
local 0 `"`line'"'
gettoken tok 0 : 0, parse(": ") // StataFileTm
gettoken tok 0 : 0, parse(": ") // :
gettoken tok 0 : 0, parse(": ") // <#_format>
if "`tok'"== "00001" {
gettoken tok 0 : 0, parse(": ") // :
gettoken tok 0 : 0, parse(": ") // <#_ft>
if "`tok'" != "01000" {
NotGph `"`using'"'
}
// Read gph line
file read `h' line
gettoken tok line : line, parse(": ") // vernum
capture confirm number `tok'
if _rc {
NotGph `"`using'"'
}
if `tok'<`live_minfmt' {
TooOld `"`using'"'
}
if `tok'>`live_maxfmt' {
TooNew `"`using'"'
}
ret scalar fversion = `tok'
gettoken tok line : line, parse(": ") /* : */
gettoken tok line : line, parse(": ") /* codever */
capture confirm number `tok'
if _rc {
NotGph `"`using'"'
}
if `tok'<`live_mincode' {
TooOld `"`using'"'
}
if `tok'>`live_maxcode' {
TooNew `"`using'"'
}
ret scalar cversion = `tok'
ret local ft "live"
exit
}
TooNew `"`using'"'
end
program NotGph
args using lookingfor
di as err "{p}"
di as err `"file `using' not a Stata .gph file"'
di as err "{p_end}"
exit 610
end
program TooNew
args using
di as err "{p}"
di as err `"file `using' is a new format that this version of Stata"'
di as err "does not know how to read"
di as err "{p_end}"
di as err `" suggestion: type -update query-"'
exit 610
end
program TooOld
args using
di as err "{p}"
di as err `"file `using' is an old format that Stata"
di as err "no longer knows how to read"
di as err "{p_end}"
exit 610
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -