KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Determine if a Object Property is a picture
PRODUCT: 4D | VERSION: 16R4 | PLATFORM: Mac & Win
Published On: January 5, 2018

Ever wanted to check if a property in a 4D object is a picture? Here is a utility to determine if it is:

// ----------------------------------------------------------------------
// Name: DETERMINE_OBJ_PROP_IS_PICTURE
// Description: Method will determine if a specific property in a 4D obejct
// is a picture.
//
// Parameters:
// $1 (PICTURE) - Input of a Object property that might be a picture.
//
// Output:
// $0 (BOOLEAN) - True - Property is a picture, False - It is not.
// ----------------------------------------------------------------------
C_PICTURE($1)
C_BOOLEAN($0)

If ($1=Null)
  $0:=False
Else
  $0:=True
End if


Example #1 Checking a picture property in object notation:

C_OBJECT($o;$Avatar)
C_PICTURE($img)
C_BOOLEAN($result)

READ PICTURE FILE("4D.png";$img;*)

OB SET NULL($o;"$Avatar")
$o.$Avatar:=$img // setting the picture with object notation

$result:=DETERMINE_OBJ_PROP_IS_PICTURE ($o.$Avatar) // True


Example #2: Checking a picture property with OB SET:

OB SET($o;"$Avatar";$img)

$result:=DETERMINE_OBJ_PROP_IS_PICTURE (OB Get($o;"$Avatar")) // True


Example #3: Checking a picture property that is not a picture in object notation:

$o.$Avatar:="Not Picture"

$result:=DETERMINE_OBJ_PROP_IS_PICTURE ($o.$Avatar) // False


Example #4: Checking a picture property that is not a picture with OB SET:

OB SET($o;"$Avatar";"Not Picture")

$result:=DETERMINE_OBJ_PROP_IS_PICTURE (OB Get($o;"$Avatar")) // False