[ Calibre ] 菜单如何集成到 Virtuoso 中
https://www.cnblogs.com/yeungchie/
脚本位置
$MGC_HOME/shared/pkgs/icv/tools/queryskl/calibre.skl
# $MGC_HOME 为 Calibre 的安装路径
使用方法
- 在 .cdsinit 中增加一行:
loadi(strcat(getShellEnvVar("MGC_HOME") "/shared/pkgs/icv/tools/queryskl/calibre.skl"))
强烈推荐使用上面这种方式。
脚本内容
/*******************************************************************************
*
* calibre.skl
*
*******************************************************************************/
; ==============================================================================
; = @brief Get Calibre version string based on MGC home environment variable.
; ==============================================================================
procedure( mgc_get_calibre_version(@optional (mgcHomeEnvName "MGC_HOME") "t")
let( (mgc_home vfile version vfilep)
mgc_home = getShellEnvVar(mgcHomeEnvName)
version = ""
if( mgc_home then
vfile = strcat(mgc_home "/pkgs/icv/dependencies/version")
when( isFile(vfile) && isReadable(vfile)
vfilep = infile(vfile)
fscanf(vfilep "%s" version)
close(vfilep)
) ; when
else
warn("Invalid or undefined mgc_home environment variable %L!\n" mgcHomeEnvName)
) ; if
version
) ; let
) ; end
; ==============================================================================
; = @brief Compare two Calibre version strings.
; = @return 1/0/-1 return 1 if tVersion1 is newer than tVersion2, -1 otherwise,
; = 0 for same version.
; ==============================================================================
procedure( mgc_compare_calibre_versions(tVersion1 tVersion2 "tt")
prog( (nYear1 nYear2 nQuarter1 nQuarter2 tPattern nBld1 nBld2 nPch1 nPch2 nTotal1 nTotal2)
;; tVersion = "v2014.3_0.30" "v2014.2_12.0012"
nYear1 = 0
nYear2 = 0
nQuarter1 = 0
nQuarter2 = 0
nBld1 = 0
nBld2 = 0
nPch1 = 0
nPch2 = 0
tPattern = "\\([0-9]+\\).\\([1-4]+\\).\\([0-9]+\\).\\([0-9]+\\)"
when( rexMatchp(tPattern tVersion1)
nYear1 = evalstring(rexSubstitute("\\1"))
nQuarter1 = evalstring(rexSubstitute("\\2"))
nBld1 = evalstring(rexSubstitute("\\3"))
nPch1 = evalstring(rexSubstitute("\\4"))
) ; when
when( rexMatchp(tPattern tVersion2)
nYear2 = evalstring(rexSubstitute("\\1"))
nQuarter2 = evalstring(rexSubstitute("\\2"))
nBld2 = evalstring(rexSubstitute("\\3"))
nPch2 = evalstring(rexSubstitute("\\4"))
) ; when
nTotal1 = nYear1*100 + nQuarter1
nTotal2 = nYear2*100 + nQuarter2
if( nTotal1>nTotal2 then
return(1)
else if( nTotal1nBld2 then
return(1)
else if( nBld1nPch2 then
return(1)
else if( nPch1