> Le 8 janv. 2017 à 04:08, Kirk Brooks <[email protected]> a écrit :
> 
> [...] My basic template is this:
> 
> C_TEXT($1;$2;$action;$errMsg)
> C_POINTER($ptrCurrent;$ptrObj)
> 
> $ptrCurrent:=OBJECT Get pointer(Object current)
> If (Count parameters=0)
>  $action:=OBJECT Get name(Object current)
> Else
>  $action:=$1
> End if

I do like this form manager (FM) concept and use something similar:
<http://screencast.com/t/g6UniM6Ri2ep>
I began to use that in v12, when "dynamic variables" came in. I'd prefer "form 
locales", BTW: they exist the time the form is running, and the way they are 
displayed at runtime sounds local: "$form.x.y". 

Some thoughts… 

• $1, $2…?
before v12, a friend of mine and I used form event as 1st entry point in our 
Form managers, and optional pointer on the source object as $2. 
We discussed a while about this when v12 came: event 1st, form object 1st? 
Optional, mandatory? 
$1=text. In a FM, the "main" code is based on a big Case of. When the event is 
used as 1st entry point, parts of code for the same object are spread in pieces 
at line x, y and z: bad, it is much more efficient on debug to start from the 
object than the event. 
$2=form event. The form event comes after and _must_ remain optional: very 
often I call an "action" in the FM, without any significant event as "source". 
$3=pointer. Discussed under… 

• FM calls
<https://www.screencast.com/t/g6UniM6Ri2ep>
All object method are the same: call the manager with no parameter. Passing the 
object name or event is not necessary. Form method is the only exception, I use 
Current form name (since v14). 
Line 67: the form manager can be used as its own launcher in a new process. 
Nice for conception/debug. 

• I use a pointer as $3. Nice in re entrance use/re use of part of code; for 
example:
  //Form_mng
  ...
  case of
   :($1=$formName_t)
    case of 
     :(on load)
      array text($myArray;0)
      Form_mng("getUsersList";0;->$myArray)
      ...
    end case
   :($1="buttonChangingTheArrayContent")
      array text($myArray;0)
      Form_mng("getUsersList";0;->$myArray)
      ...
   :($1="getUsersList")
     $myArray_p:=$3
     //do something and return $3 modified
  end case
Since v14, I tend to replace $3 pointer by $3 object. 

• reentrance
simpler to understand with an example:
<https://www.screencast.com/t/f2r1XuHW>

• Assignment operator with form locales:
  (OBJET Get pointer(named object;"myObjectname"))->:="something"
32 chars before writing the object name. Ouch. 
I use a wrapper, opwn = "object pointer with name":
  //Opwn (name_t {;subform_t) -> ptr
  C_POINTER($0)
  C_TEXT($1)
  C_LONGINT($params_l)
  //_
  $params_l:=Count parameters
  If (Asserted($params_l>0;Current method name+" $1 missing"))
        If ($params_l>1)
                $0:=OBJECT Get pointer(Object named;$1;$2)  //in subform
        Else
                $0:=OBJECT Get pointer(Object named;$1)  //in form
        End if
  End if
It's short and eliminates the parenthesis: 
  opwn("myObjectname")->:="something"
… except one situation were the @#$* parenthesis must come back, arrays index:
  opwn("arrayObject")->{$i}:=value  //wrong, it's the index of the array, not 
the value at that index
  (opwn("arrayObject"))->{$i}:=value  //right…

-- 
Arnaud de Montard 



**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to