KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Finding the product and build version of Mac OSX
PRODUCT: 4D | VERSION: 15.x | PLATFORM: Mac OS X
Published On: December 16, 2016

The following utility method will find the product and build version of the Mac OSX machine:

// --------------------------------------------------------------------------------
// Name: PRODUCT_BUILD_VERSION_OSX
// Description: Method will extract the product and build version numbers
// from the Mac OSX platform using LEP.
// Input:
//
// $1 (POINTER) - Pointer to product version number (e.g. 10.10.5)
// $2 (POINTER) - Pointer to build version number (e.g. 14F1021)
// --------------------------------------------------------------------------------
C_POINTER($1;$productVersion)
C_POINTER($2;$buildVersion)
C_TEXT($cmd;$input;$output;$error)
C_LONGINT($posProduct;$posBuild;$posCR)

If (Count parameters=2)

   $productVersion:=$1
   $buildVersion:=$2
   $cmd:="sw_vers"
   $input:=""

   LAUNCH EXTERNAL PROCESS($cmd;$input;$output;$error)

   $posProduct:=Position("ProductVersion:";$output;1)+16
   $posCR:=Position(Char(Line feed);$output;$posProduct;*)
   $productVersion->:=Substring($output;$posProduct;$posCR-$posProduct)

   $posBuild:=Position("BuildVersion:";$output;1)+14
   $posCR:=Position(Char(Line feed);$output;$posBuild;*)
   $buildVersion->:=Substring($output;$posBuild;$posCR-$posBuild)
End If


Here is an example of using the command:

C_TEXT($product;$build)

PRODUCT_BUILD_VERSION_OSX (->$product;->$build)
// $product - 10.10.5 $build - 14F1021