Tech Tip: Utility to retrieve an object variable name from point in a List Box
PRODUCT: 4D | VERSION: 13.0 | PLATFORM: Mac & Win
Published On: July 13, 2012
When working in an object or form method in a 4D v13 List Box it is common to get a pointer to the current object within the List Box using the command OBJECT Get pointer(Object current). This is very handy since the command OBJECT Get name does not return names of objects contained within a List Box.
If (True) If (False) // LSTFRM_Pointer_to_VarName ($LB_P;$Obj_P) -> $Name_T // // Purpose: Return a pointer to an object within a List Box // // $1 - Pointer - Pointer to a List Box object // $2 - Pointer - Pointer to an object contained within the List Box End if C_TEXT($MethodName_T) $MethodName_T:=Current method name //===================== Declare Variables ================================== //method_parameters_declarations C_TEXT($0;$Name_T) C_POINTER($LB_P;$1) C_POINTER($Obj_P;$2) //-------------------------------------------------------------------------- //method_wide_constants_declarations //-------------------------------------------------------------------------- //local_variable_declarations C_LONGINT($Ndx;$SOA;$RIS;$Params_L) ARRAY TEXT($colNames_aT;0) ARRAY TEXT($headerNames_aT;0) ARRAY POINTER($colVars_aP;0) ARRAY POINTER($headerVars_aP;0) ARRAY BOOLEAN($colsVisible_aB;0) ARRAY POINTER($styles_aP;0) ARRAY TEXT($FooterNames_aT;0) ARRAY POINTER($FooterVars_aP;0) End if //====================== Initialize and Setup ================================ $LB_P:=$1 $Obj_P:=$2 //======================== Method Actions ================================== LISTBOX GET ARRAYS($LB_P->;\ $colNames_aT;\ $headerNames_aT;\ $colVars_aP;\ $headerVars_aP;\ $colsVisible_aB;\ $styles_aP;\ $FooterNames_aT;\ $FooterVars_aP) $Obj_P:=$2 $Name_T:="" $Ndx:=Find in array($colVars_aP;$Obj_P) If ($Ndx>0) $Name_T:=$colNames_aT{$Ndx} Else $Ndx:=Find in array($headerVars_aP;$Obj_P) If ($Ndx>0) $Name_T:=$headerNames_aT{$Ndx} Else $Ndx:=Find in array($FooterVars_aP;$Obj_P) If ($Ndx>0) $Name_T:=$FooterNames_aT{$Ndx} End if End if End if //======================== Clean up and Exit ================================= $0:=$Name_T |