> Le 9 nov. 2016 à 00:43, John DeSoi <[email protected]> a écrit :
> 
> [...]
> Well, it is also bad design to if you have hundreds of boolean fields and you 
> have to add a script to every single one just to determine if a user changed 
> the value. And if I forget to add the object method, now I have a bug. Every 
> object that has data to change should support On Data Change.

As Miyako said, 4D is (was) not designed to managed everything in the method 
form. So we have to deal with a bunch of object methods, even if we feel that 
it's not logical to scatter pieces of code coming from ONE source, the form. 
Since 4D v12 introduced object names as an alternate to variables, my form 
coding is organized with "form manager" methods: each form has its manager. 
Schematically, everything coming from the form (including the form method 
itself) calls the manager. In other words, you still have to use method object, 
but they all do the same thing: call manager with no parameter. 

//form method myForm
myFormManager (Current form name)


//object method booleanField1
//same in all other objets in the form: listbox, fields, buttons, etc.
myFormManager


//project method myFormManager
c_text($1;$entryPoint)
c_text($2;$event)

$entryPoint:=OBJECT Get name  //default=object name of the current method object
$event:=event form  //default=event form of the current method object or form
if(count parameters>0)
 $entryPoint:=$1
 if(count parameters>1)
  $event:=$2
 end if
end if

case of
 :($entryPoint="myForm")
  case of
   :($event=On load)
    //...
   :($event=On etc.)
    //...
  end case
 :($entryPoint="booleanField@")
  //...
 :($entryPoint="name")
  //...
 :($entryPoint="firstname")
  //...
end case

-- 
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