Tech Tip: How to compare version numbers between Server and Client
PRODUCT: 4D Server | VERSION: 11.5 | PLATFORM: Mac & Win
Published On: February 26, 2010
With 4D v11 SQL it is important that the version number of your 4D Server be the same of the 4D remote application that is connecting remotely. The two methods included in this Tech Tip provide the ability to compare the Server and Remote version numbers and thus give you the decision point as to continue with the connection or to terminate the remote connection.
This first method contains the Method Property of Execute on Server and retrieves the server version information. Do not forget to turn on Execute on Server for this method.
If (True) If (False) `***************************************************************************** `// `// OnSVR_GetApplicationVersion `// `// Purpose: To retriever the version number of 4D Server `// `// $0 - TEXT - Returned version string `// $1 - POINTER - Pointer to an integer variable for build number `// $2 - BOOLEAN - TRUE for long version, FALSE for short version `// `***************************************************************************** End if C_TEXT($MethodName_T) $MethodName_T:=Current method name `===================== Declare Variables ================================== `method_parameters_declarations C_TEXT($0;$Result_T) C_POINTER($BuildNo_P;$1) C_BOOLEAN($GetLongVers_B;$2) `-------------------------------------------------------------------------------- `method_wide_constants_declarations `-------------------------------------------------------------------------------- `local_variable_declarations C_LONGINT($Ndx;$SOA;$RIS;$Params_L) End if `====================== Initialize and Setup ================================ $Params_L:=Count parameters `======================== Method Actions ================================== If ($Params_L>0) $BuildNo_P:=$1 If ($Params_L=1) $Result_T:=Application version($BuildNo_P->) Else $GetLongVers_B:=$2 If ($GetLongVers_B) $Result_T:=Application version($BuildNo_P->;*) Else $Result_T:=Application version($BuildNo_P->) End if End if Else $Result_T:=Application version End if `======================== Clean up and Exit ================================= $0:=$Result_T |
This second method executes on the remote 4D application and retrieves the local application version information, calls the above method, compares the results and returns TRUE or FALSE based on agreement of the version strings. Other values can be retrieved for more detailed comparisons, such as build numbers.
If (True) If (False) `***************************************************************************** `// `// UTIL_CompareAppVersions `// `// Purpose: To compare the version number between Server and Client `// `// $0 - BOOLEAN - Result the comparison of returned strings `// $1 - BOOLEAN - Long version or short version `// $2 - POINTER - Pointer to the Server Application Version String Var `// $3 - POINTER - Pointer to the Local Application Version String Var `// $4 - POINTER - Pointer to the Server Application Build Number Int Var `// $5 - POINTER - Pointer to the Local Application Build Number Int Var `// `***************************************************************************** End if C_TEXT($MethodName_T) $MethodName_T:=Current method name `===================== Declare Variables ================================== `method_parameters_declarations C_BOOLEAN($0;$Result_B) C_BOOLEAN($LongVers_B;$1) C_POINTER($SvrVers_P;$2) C_POINTER($LocalVers_P;$3) C_POINTER($SVR_Build_P;$4) C_POINTER($LOC_Build_P;$5) `-------------------------------------------------------------------------------- `method_wide_constants_declarations `-------------------------------------------------------------------------------- `local_variable_declarations C_LONGINT($Ndx;$SOA;$RIS;$Params_L;$SVR_Short_L) C_LONGINT($LOC_Short_L;$SVR_Long_L;$LOC_Long_L) C_TEXT($SvrVers_T;$LocalVers_T;$SvrVers__T;$LocalVers_T) End if `====================== Initialize and Setup ================================ $Params_L:=Count parameters `======================== Method Actions ================================== Case of : ($Params_L=0) $SvrVers_T:=OnSVR_GetApplicationVersion ($SVR_Build_P;True) $LocalVers_T:=Application version($LOC_Build_P->;*) : ($Params_L=3) $LongVers_B:=$1 $SvrVers_P:=$2 $LocalVers_P:=$3 If ($LongVers_B) $SvrVers_T:=OnSVR_GetApplicationVersion ($SVR_Long_L;True) $LocalVers_T:=Application version($LOC_Long_L;*) Else $SvrVers_T:=OnSVR_GetApplicationVersion $LocalVers_T:=Application version End if $SvrVers_P->:=$SvrVers_T $LocalVers_P->:=$LocalVers_T : ($Params_L=5) $LongVers_B:=$1 $SvrVers_P:=$2 $LocalVers_P:=$3 $SVR_Build_P:=$4 $LOC_Build_P:=$5 If ($LongVers_B) $SvrVers_T:=OnSVR_GetApplicationVersion ($SVR_Build_P;True) $LocalVers_T:=Application version($LOC_Build_P->;*) Else $SvrVers_T:=OnSVR_GetApplicationVersion ($SVR_Build_P) $LocalVers_T:=Application version($LOC_Build_P->) End if $SvrVers_P->:=$SvrVers_T $LocalVers_P->:=$LocalVers_T Else ALERT("Bad parameter count: "+String($Params_L)+" must be 0, 3, or 5!" End case `======================== Clean up and Exit ================================= $0:=($SvrVers_T=$LocalVers_T) |