Lance Leonard'; // Additional attribution, e.g. your source or what you based this on. $attrinfo = ""; // Your target audience: supported values are: // 0=All, 1=New, 2=Intermediate, 3=Expert, 4=Developers Only $audience = "2"; // Version information. Use complete display string, e.g. Applies to v9.0 $versions = "Applies to: Paradox 5.0 and later"; // Date Posted; should be current date. $postdate = "3 October 2000"; // Control the appearance of the area info block and manages the highlight // glyph. If 0, no block appears and no glyph is highlighted Supported values are // 0=Hides block, 1=About, 2=Paradox, 3=Delphi, 4=Assorted, 5=Web Stuff $pagearea = 2; // $navlinks = 'Paradox:'; // Define your META Keywords here $metakeys = "paradox corel borland objectpal edit region labelled field object properties attach"; // Define the META description here; should be a simple, short sentence $metadesc = "Shows how to access the properties of the edit region object used in labelled field objects."; ?>

Question: How can I attach a uiObject variable to the editRegion of a labelled field object?

Answer: The following is a custom method that shows one way to do this:

method getEditRegion( uiIn uiObject, var uiOut uiObject ) Logical
; ---------------------------------------------------------------
; When passed a labelled field object, this attaches to that
; object's EditRegion.  Please note that this is done through the
; uiOut parameter.  The return value is a logical indicating
; success or failure.   The lets you control any messages
; displayed to the end user.
; ---------------------------------------------------------------
var
   astrNames  Array[] String   ; holds names of child objects
   loResult   Logical          ; value returned to caller
   strEdtReg  String           ; possibly name of an edit region
   uiEdtReg   uiObject         ; Temporary placeholder
endVar

   loResult = FALSE;  ; assume failure to reduce code

   ; first, get the objects of input value...

   if uiIn.class = "Field" then
      uiIn.enumObjectNames( astrNames )

     ; observation revealed that the third element in the
     ; array is the editRegion, so...

     if ( astrNames.size() = 3 ) then
        if uiEdtReg.attach( astrNames[ 3 ] ) then
           loResult = ( uiEdtReg.class = "EditRegion" )
        endIf
     endIf
   endIf

   ; if it worked, then assign the placeholder to the output
   ; parameter.
   if loResult then
      uiOut.attach( uiEdtReg )
   endIf

   return loResult

endMethod

In this example, we count on behavior observed with Paradox 8. Specifically, when you view an array populated using enumUIObjects against a labelled field, the third element of that array contains the name of the edit region.

The following code, placed on a button with TabStop set to FALSE, shows how you might call this custom method:

method pushButton(var eventInfo Event)
var
   dstr  Dynarray[] String
   uio   UIObject
endVar

   if getEditRegion( active, uio ) then
      uio.enumUIObjectProperties( dstr )
      dstr.view( "Properties for " + uio.Name )
   else
      msgStop( "Unable to Find EditRegion", "Reason: The object " +
               "named " + Active.Name + " does not appear to be " +
               "a labelled field object." )
   endIf

An demonstration is available in our download section. Please note that it requires the Customer table provided with Paradox's sample files. If you do not have these installed or cannot find them, we have a copy in our download section.