I started using the c_object just recently and am finding more and more places
to adapt it’s use. I thought my latest revelation was interesting, at least to
me. I was creating a process that involves several levels of user interaction.
In other words the user is presented with a list with options that create a
different list with options that create a different list, etc. All when
completed returning back to the previous list.
I like to use local variables as much as possible and I soon found myself
creating too many local variables like $button, $button2, $button3, etc. I was
also stepping on local variables too often when I forgot to create a unique
variable for the list being displayed. At first blush I was going to just push
each list off to it’s own method. I hate doing this as too many methods in a
unique process just gets too messy.
Then it dawned on me to use c_object for the parameters and keep all the lists
in the same method. To me and my simple mind I thought this was pretty cool,
perhaps someone else might find the thought process interesting or even useful
so I have pasted a code snippet below….
John
--------------------------------------------
//Initial call from another method…
C_OBJECT($oParams)
$oParams:=New object("action";"DoProcedures";"date";$aDate{Size of
array($aDate)}) //plus other paams...
AptLenghtMigrate_Procedures ($oParams)
------------------------------------------
// *** Method: AptLenghtMigrate_Procedures ***
C_OBJECT($oParams)
ARRAY LONGINT($aProcedureSeq;0) //need this because the array will be put in a
c_object later
ARRAY LONGINT($aProcedureMIgrationLength;0) //need this because the array will
be put in a c_object later
$oParams:=$1
$action:=$oParams.action
$startDate:=Date($oParams.date)
Case of
: ($action="DoProcedures")
ALL RECORDS([Procedure])
SELECTION TO
ARRAY([Procedure]_Procedure_Sequence;$aProcedureSeq;[Procedure]Migration_Procedure_Length;$aProcedureMIgrationLength)
//plus more arrays…
Repeat
//Display the procedures to the user and provide options
Case of
: ($button=4) //user selected option 4 to list appointments
scheduled after $startDate
OB SET
ARRAY($oParams;"procedure_sequences";$aProcedureSeq)
OB SET
ARRAY($oParams;"procedure_m_lengths";$aProcedureMIgrationLength)
$oParams.action:="ListAppointments"
AptLenghtMigrate_Procedures ($oParams)
End case
Until ($Button=1)
: ($action="ListAppointments")
QUERY([Appointment];[Appointment]Appointment_Date>=$startDate)
SELECTION TO
ARRAY([Appointment]Appointment_Date;$aAppointmentDate;[Appointment]_Chair_Sequence;$aChairSequence)
//plus more arrays...
Repeat
//Display the scheduled appointments to the user and provide
options
If ($Button=1) //user selected option 1 to list appointments
scheduled on a selected date and chair with procedure lengths
$oParams.chair_date:=$aAppointmentDate{$line}
$oParams.chair_sequence:=$aChairSequence{$line}
$oParams.action:="ListChairAppointments"
AptLenghtMigrate_Procedures ($oParams)
End if
Until ($done)
: ($action="ListChairAppointments")
OB GET ARRAY($oParams;"procedure_sequences";$aProcedureSeq)
OB GET
ARRAY($oParams;"procedure_m_lengths";$aProcedureMIgrationLength)
//will use the 2 arrays created in the initial call to get migration
lengths for each scheduled procedure
QUERY([Appointment];[Appointment]Appointment_Date=Date($oParams.chair_date);*)
QUERY([Appointment]; &
;[Appointment]_Chair_Sequence=$oParams.chair_sequence)
SELECTION TO ARRAY(….
Repeat
//Display the chair appointments to the user and provide options
Case of
: ($Button=3) //etc...
End case
Until ($Done)
:($action=“etc….")
//etc…
:($action=“etc….")
//etc…
End case
John Baughman
Kailua, Hawaii
(808) 262-0328
[email protected]
**********************************************************************
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]
**********************************************************************