[ 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( nTotal1<nTotal2 then return(-1) else if( nBld1>nBld2 then return(1) else if( nBld1<nBld2 then return(-1) else if( nPch1>nPch2 then return(1) else if( nPch1<nPch2 then return(-1) else return(0) )))) )) ; if return(0) ) ; prog ) ; end ; ============================================================================== ; = @brief Load Calibre SKILL files ; ============================================================================== if( !boundp('mgcCadenceVersion4_3) then mgcCadenceVersion4_3 = nil ) mgcCadenceVersionOA = nil if( !mgcCadenceVersion4_3 then when( dbGetDatabaseType()=="OpenAccess" mgcCadenceVersionOA = t ) ) /* Check for MGC_HOME */ let( (mgc_home calibre_home realtime_home script_path calibre_realtime_file tVersion1 tVersion2) ; ER1054490: Add mechanism in calibre.skl to prevent double load if( boundp('MGC_CALIBRE_GLOBALS_SKL_LOADED) && MGC_CALIBRE_GLOBALS_SKL_LOADED then fprintf(stderr "// Calibre Error: Calibre SKILL code has been loaded, new code will not be loaded!\n") else MGC_CALIBRE_GLOBALS_SKL_LOADED = t ; DR602690: When User use CALIBRE_HOME without MGC_HOME , Virtuoso can not display Calibre button . calibre_home = getShellEnvVar("CALIBRE_HOME") when( calibre_home && isDir(calibre_home) && isReadable(calibre_home) setShellEnvVar(sprintf(nil "MGC_HOME=%s" calibre_home)) ) ; when mgc_home = getShellEnvVar("MGC_HOME") realtime_home = getShellEnvVar("MGC_REALTIME_HOME") when( realtime_home && realtime_home!=mgc_home && isReadable(realtime_home) && getShellEnvVar("MGC_CALIBRE_REALTIME_VIRTUOSO_ENABLED") && dbGetDatabaseType()=="OpenAccess" ; ER1054482: Issue warning message to customer if MGC_REALTIME_HOME is older than MGC_HOME ; ER1094216: An MGC_REALTIME_HOME older than MGC_HOME should be a fatal error tVersion1 = mgc_get_calibre_version("MGC_HOME") tVersion2 = mgc_get_calibre_version("MGC_REALTIME_HOME") if( mgc_compare_calibre_versions(tVersion2 tVersion1)<0 then error("// Calibre RealTime: MGC_REALTIME_HOME = %L, MGC_HOME = %L; MGC_REALTIME_HOME is older than MGC_HOME! Please correct your settings!" tVersion2 tVersion1) when( isCallable('unsetShellEnvVar) unsetShellEnvVar("MGC_REALTIME_HOME") ) else printf("//\n") printf("// Calibre RealTime: MGC_HOME = %L, MGC_HOME is different with MGC_REALTIME_HOME.\n" mgc_home) printf("// Calibre RealTime: MGC_REALTIME_HOME = %L, SKILL code in MGC_REALTIME_HOME will be used!\n" realtime_home) mgc_home = realtime_home ) ; if ) ; when if( mgc_home!=nil && isReadable(mgc_home) then script_path = strcat(mgc_home "/shared/pkgs/icv/tools/queryskl/") load( strcat(script_path "mgc_calibre_menu.skl") ) load( strcat(script_path "mgc_rve.skl") ) load( strcat(script_path "mgc_export.skl") ) load( strcat(script_path "mgc_utility.skl") ) when( getShellEnvVar("MGC_CALIBRE_REALTIME_VIRTUOSO_ENABLED") && dbGetDatabaseType()=="OpenAccess" calibre_realtime_file = strcat( strcat(script_path "mgc_calibre_realtime.enc_skl") ) if( isReadable(calibre_realtime_file) then load(calibre_realtime_file) else fprintf(stderr "// Calibre Error: %L is not readable\n" calibre_realtime_file) ) ; if ) ; when if( !mgcCadenceVersion4_3 then load( strcat(script_path "mgc_extview.skl") ) ) else ; MGC_HOME is not set correctly. Report the problem. fprintf(stderr "// Calibre Error: Environment variable ") if( mgc_home==nil || mgc_home=="" then fprintf(stderr "CALIBRE_HOME or MGC_HOME is not set.") else if( !isDir(mgc_home) then fprintf(stderr "CALIBRE_HOME or MGC_HOME does not point to a directory.") else unless( isReadable(mgc_home) fprintf(stderr "CALIBRE_HOME or MGC_HOME points to an unreadable directory.") ) ) ) fprintf(stderr " Calibre Skill Interface not loaded.\n") ) ; if ) ; if ) ; let
本文作者:YEUNGCHIE
本文链接:https://www.cnblogs.com/yeungchie/p/13420268.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
分类:
标签:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步