文章目录

第四十五章 Caché 变量大全 $ZVERSION 变量

包含一个字符串,描述do命令后面的InterSystems IRIS.line的当前版本。

大纲
$ZVERSION 
$ZV
描述

$ZVERSION包含一个字符串,该字符串显示当前运行的InterSystems IRIS®Data Platform实例的版本。

以下示例返回$ZVERSION字符串:

DHC-APP>WRITE $ZVERSION
Cache for Windows (x86-64) 2016.2 (Build 736U) Fri Sep 30 2016 11:46:02 EDT

此字符串包括InterSystems IRIS安装的类型(产品和平台,包括CPU类型)、版本号(2018.1)、该版本中的内部版本号(内部版本号中的“U”表示UNICODE以及创建此版本的InterSystems IRIS的日期和时间。“EST”是东部标准时间(美国东部的时区),“EDT”是东部夏令时

通过调用GetVersion()类方法可以返回相同的信息,如下所示:

DHC-APP>WRITE $SYSTEM.Version.GetVersion()
Cache for Windows (x86-64) 2016.2 (Build 736U) Fri Sep 30 2016 11:46:02 EDT

以通过调用其他%SYSTEM.Version方法来获取此版本字符串的组成部分,可以通过调用以下命令列出这些方法:

DHC-APP> DO $SYSTEM.Version.Help()
'Do $system.Version.Help(method)' 将显示单个方法的完整描述.
 
类的方法:%SYSTEM.Version
 
FeatureBits(bit)
     Return all the feature codes stored in $zversion(0)
 
Format(Format,zv)
     Formats the version info according to the following format types:
 
GetBuildDate(zv)
     Returns the date the product was built in $HOROLOG format.
 
GetBuildNumber(zv)
     Returns the build number for the product.
 
GetBuildOS(zv)
     Returns the operating system for which the product was built.
 
GetBuildTime(zv)
     Returns the time of day the product was built in $HOROLOG format.
 
GetCompBuild(component)
     Returns the build number for the specified component. (Deprecated)
...

通过转到InterSystems IRIS启动器并选择关于…,可以查看版本和内部版本号信息。

不能使用SET命令修改$ZVERSION特殊变量。尝试这样做会导致<SYNTAX>错误。

示例

以下示例从版本字符串中提取创建日期,以计算InterSystems IRIS的当前版本有多早(以天为单位)。请注意,此示例特定于Windows平台:


/// d ##class(PHA.TEST.SpecialVariables).ZVERSION()
ClassMethod ZVERSION()
{
	SET createdate=$PIECE($ZVERSION," ",9,11)
	WRITE !,"Creation date: ",createdate
	WRITE !,"Current date:  ",$ZDATE($HOROLOG,6)
	SET nowcount=$PIECE($HOROLOG,",")
	SET thencount=$ZDATEH(createdate,6)
	WRITE !,"This version is ",(nowcount-thencount)," days old"
}
DHC-APP>d ##class(PHA.TEST.SpecialVariables).ZVERSION()
 
Creation date: Sep 30 2016
Current date:  Feb 10 2021
This version is 1594 days old

下面的示例通过调用类方法执行相同的操作:

/// d ##class(PHA.TEST.SpecialVariables).ZVERSION1()
ClassMethod ZVERSION1()
{
	SET createdate=$SYSTEM.Version.GetBuildDate()
	WRITE !,"Creation date: ",$ZDATE(createdate,6)
	WRITE !,"Current date:  ",$ZDATE($HOROLOG,6)
	SET nowcount=$PIECE($HOROLOG,",")
	WRITE !,"This version is ",(nowcount-createdate)," days old"
}

DHC-APP>d ##class(PHA.TEST.SpecialVariables).ZVERSION1()
 
Creation date: Sep 30 2016
Current date:  Feb 10 2021
This version is 1594 days old