Re: Object notation bug?
On Feb 22, 2019, at 8:43 AM, Kirk Brooks wrote: > 2) if you need DIALOG just wrap it in another object. I like to use 'data'. > So you can do this: > > $obj:=New object("data";$oChildObject) > > DIALOG("myForm";$obj) > > It's simple to change the references on the form objects to > Form.data.whatever. I find it more robust not the least of which because it > allows you to have a null object without crashing your form. I ran into something related to this. If you just want to return data in the “Form” object — you are not passing any data into the form — you must create the object before you call DIALOG. So this fails: C_OBJECT($formData_o) DIALOG(“myForm”;$formData_o) // somewhere on myForm you do this “Form.result:=“Continue” // get values set in the myForm that were assigned to “Form” object if($formData_o.result=“Continue”) // this never executes end if But this works: C_OBJECT($formData_o) $formData_o:=New object DIALOG(“myForm”;$formData_o) // somewhere on myForm you do this “Form.result:=“Continue” // get values set in the myForm that were assigned to “Form” object if($formData_o.result=“Continue”) // this never executes end if $formData_o now has all the properties you set in myForm assigned to “Form” object. Like “Form.result:=“Continue” You have to get $formData_o instantiated — if that’s the right word — in the method before you pass it into the DIALOG command because it is passed by reference. Then when you use the “Form” function in myForm it will update the correct object that you created with the "$formData_o:=New object” line of code. Tim * Tim Nevels Innovative Solutions 785-749-3444 timnev...@mac.com * ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Object notation bug?
Drew, On Thu, Feb 21, 2019 at 10:27 AM Drew Waddell via 4D_Tech < 4d_tech@lists.4d.com> wrote: > I am unable to do $oChildObject:=null in my actual situation because I am > passing that object into a Dialog You run into this when passing the object to a new form using DIALOG. I use two approaches when i need to do this: 1) put the form into a subform on the parent form. You can hide it until needed. Make the subform object an object and you're all set. This way you avoid needing DIALOG. 2) if you need DIALOG just wrap it in another object. I like to use 'data'. So you can do this: $obj:=New object("data";$oChildObject) DIALOG("myForm";$obj) It's simple to change the references on the form objects to Form.data.whatever. I find it more robust not the least of which because it allows you to have a null object without crashing your form. -- Kirk Brooks San Francisco, CA === What can be said, can be said clearly, and what you can’t say, you should shut up about *Wittgenstein and the Computer * ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
RE: Object notation bug?
Just FYI for those following along, I tried the following in my test method even though I wouldn't be able to in my Form object scenario: $oChildObject:=Null // $oParentObject.ChildInformation = {FirstName:John,LastName:Smith} Drew -Original Message- From: 4D_Tech <4d_tech-boun...@lists.4d.com> On Behalf Of Drew Waddell via 4D_Tech Sent: Thursday, February 21, 2019 1:28 PM To: Olivier Deschanels ; 4D iNug Technical <4d_tech@lists.4d.com> Cc: Drew Waddell Subject: RE: Object notation bug? I am unable to do $oChildObject:=null in my actual situation because I am passing that object into a Dialog so in my situation $oParentObject is actually the Form object, I don't have the local variable for $oChildObject on the form. So is there another command to clear both references without having loop over all properties in the child and remove them individually? Drew -Original Message- From: Olivier Deschanels Sent: Thursday, February 21, 2019 1:21 PM To: 4D iNug Technical <4d_tech@lists.4d.com> Cc: Drew Waddell Subject: Re: Object notation bug? Hi, That’s not a bug. That’s normal. $oChildObject:=New object create a reference to a object store in $oChildObject OB SET($oParentObject;"ChildInformation";New object) push another reference into the $oParentObject but the old reference still exist because $oChildObject isn’t cleared. you try : $oParentObject.ChildInformation:=Null try this $oChildObject:=null and read $oParentObject Regards, Olivier Olivier Deschanels Consultant Expert 4D SAS 66 route de Sartrouville Parc Les Erables - Batiment 4 78230 Le Pecq France Téléphone : +33 1 30 53 92 75 Standard : +33 1 30 53 92 00 Fax : +33 1 30 53 92 01 Email : olivier.deschan...@4d.com Web : www.4D.com > Le 21 févr. 2019 à 18:59, Drew Waddell via 4D_Tech <4d_tech@lists.4D.com> a > écrit : > > I am trying to figure out if this is a bug or not. This is a watered down > version of something I am trying to do: > >C_OBJECT($oParentObject;$oChildObject) > >$oChildObject:=New object >$oParentObject:=New object >$oParentObject.ChildInformation:=$oChildObject >$oParentObject.ChildInformation.FirstName:="John" >$oParentObject.ChildInformation.LastName:="Smith" > > I want $oChildObject and $oParentObject.ChildInformation to remain the same > and should because of how the references work, so at this moment each are > {FirstName:John,LastName:Smith}. Let say something happens like maybe there > is a Clear button, how would one clear the child object? > > First, I wanted to do this: > >$oParentObject.ChildInformation:=Null // $oChildObject = > {FirstName:John,LastName:Smith} > > Okay, I thought that was the correct way to clear both objects but maybe > there is a different way so maybe this? > >OB SET($oParentObject;"ChildInformation";New object) // > $oChildObject = {FirstName:John,LastName:Smith} > > Nope, again the child object with $oParentObject is cleared but $oChildObject > remains {FirstName:John,LastName:Smith}. So do I really have to loop over > all properties and remove them individually? > >OB REMOVE($oParentObject.ChildInformation;"FirstName") >OB REMOVE($oParentObject.ChildInformation;"LastName") // > $oChildObject = {} > > Finally when I make a change in the $oParentObject.ChildInformation the > referenced object $oChildObject is also updated. > > Is this a bug? Shouldn't the :=Null work and also change the $oChildObject > variable? > > Thanks, > Drew > > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com ** ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
RE: Object notation bug?
I am unable to do $oChildObject:=null in my actual situation because I am passing that object into a Dialog so in my situation $oParentObject is actually the Form object, I don't have the local variable for $oChildObject on the form. So is there another command to clear both references without having loop over all properties in the child and remove them individually? Drew -Original Message- From: Olivier Deschanels Sent: Thursday, February 21, 2019 1:21 PM To: 4D iNug Technical <4d_tech@lists.4d.com> Cc: Drew Waddell Subject: Re: Object notation bug? Hi, That’s not a bug. That’s normal. $oChildObject:=New object create a reference to a object store in $oChildObject OB SET($oParentObject;"ChildInformation";New object) push another reference into the $oParentObject but the old reference still exist because $oChildObject isn’t cleared. you try : $oParentObject.ChildInformation:=Null try this $oChildObject:=null and read $oParentObject Regards, Olivier Olivier Deschanels Consultant Expert 4D SAS 66 route de Sartrouville Parc Les Erables - Batiment 4 78230 Le Pecq France Téléphone : +33 1 30 53 92 75 Standard : +33 1 30 53 92 00 Fax : +33 1 30 53 92 01 Email : olivier.deschan...@4d.com Web : www.4D.com > Le 21 févr. 2019 à 18:59, Drew Waddell via 4D_Tech <4d_tech@lists.4D.com> a > écrit : > > I am trying to figure out if this is a bug or not. This is a watered down > version of something I am trying to do: > >C_OBJECT($oParentObject;$oChildObject) > >$oChildObject:=New object >$oParentObject:=New object >$oParentObject.ChildInformation:=$oChildObject >$oParentObject.ChildInformation.FirstName:="John" >$oParentObject.ChildInformation.LastName:="Smith" > > I want $oChildObject and $oParentObject.ChildInformation to remain the same > and should because of how the references work, so at this moment each are > {FirstName:John,LastName:Smith}. Let say something happens like maybe there > is a Clear button, how would one clear the child object? > > First, I wanted to do this: > >$oParentObject.ChildInformation:=Null // $oChildObject = > {FirstName:John,LastName:Smith} > > Okay, I thought that was the correct way to clear both objects but maybe > there is a different way so maybe this? > >OB SET($oParentObject;"ChildInformation";New object) // > $oChildObject = {FirstName:John,LastName:Smith} > > Nope, again the child object with $oParentObject is cleared but $oChildObject > remains {FirstName:John,LastName:Smith}. So do I really have to loop over > all properties and remove them individually? > >OB REMOVE($oParentObject.ChildInformation;"FirstName") >OB REMOVE($oParentObject.ChildInformation;"LastName") // > $oChildObject = {} > > Finally when I make a change in the $oParentObject.ChildInformation the > referenced object $oChildObject is also updated. > > Is this a bug? Shouldn't the :=Null work and also change the $oChildObject > variable? > > Thanks, > Drew > > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Re: Object notation bug?
Hi, That’s not a bug. That’s normal. $oChildObject:=New object create a reference to a object store in $oChildObject OB SET($oParentObject;"ChildInformation";New object) push another reference into the $oParentObject but the old reference still exist because $oChildObject isn’t cleared. you try : $oParentObject.ChildInformation:=Null try this $oChildObject:=null and read $oParentObject Regards, Olivier > Le 21 févr. 2019 à 18:59, Drew Waddell via 4D_Tech <4d_tech@lists.4D.com> a > écrit : > > I am trying to figure out if this is a bug or not. This is a watered down > version of something I am trying to do: > >C_OBJECT($oParentObject;$oChildObject) > >$oChildObject:=New object >$oParentObject:=New object >$oParentObject.ChildInformation:=$oChildObject >$oParentObject.ChildInformation.FirstName:="John" >$oParentObject.ChildInformation.LastName:="Smith" > > I want $oChildObject and $oParentObject.ChildInformation to remain the same > and should because of how the references work, so at this moment each are > {FirstName:John,LastName:Smith}. Let say something happens like maybe there > is a Clear button, how would one clear the child object? > > First, I wanted to do this: > >$oParentObject.ChildInformation:=Null // $oChildObject = > {FirstName:John,LastName:Smith} > > Okay, I thought that was the correct way to clear both objects but maybe > there is a different way so maybe this? > >OB SET($oParentObject;"ChildInformation";New object) // > $oChildObject = {FirstName:John,LastName:Smith} > > Nope, again the child object with $oParentObject is cleared but $oChildObject > remains {FirstName:John,LastName:Smith}. So do I really have to loop over > all properties and remove them individually? > >OB REMOVE($oParentObject.ChildInformation;"FirstName") >OB REMOVE($oParentObject.ChildInformation;"LastName") // > $oChildObject = {} > > Finally when I make a change in the $oParentObject.ChildInformation the > referenced object $oChildObject is also updated. > > Is this a bug? Shouldn't the :=Null work and also change the $oChildObject > variable? > > Thanks, > Drew > > ** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ** ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **
Object notation bug?
I am trying to figure out if this is a bug or not. This is a watered down version of something I am trying to do: C_OBJECT($oParentObject;$oChildObject) $oChildObject:=New object $oParentObject:=New object $oParentObject.ChildInformation:=$oChildObject $oParentObject.ChildInformation.FirstName:="John" $oParentObject.ChildInformation.LastName:="Smith" I want $oChildObject and $oParentObject.ChildInformation to remain the same and should because of how the references work, so at this moment each are {FirstName:John,LastName:Smith}. Let say something happens like maybe there is a Clear button, how would one clear the child object? First, I wanted to do this: $oParentObject.ChildInformation:=Null // $oChildObject = {FirstName:John,LastName:Smith} Okay, I thought that was the correct way to clear both objects but maybe there is a different way so maybe this? OB SET($oParentObject;"ChildInformation";New object) // $oChildObject = {FirstName:John,LastName:Smith} Nope, again the child object with $oParentObject is cleared but $oChildObject remains {FirstName:John,LastName:Smith}. So do I really have to loop over all properties and remove them individually? OB REMOVE($oParentObject.ChildInformation;"FirstName") OB REMOVE($oParentObject.ChildInformation;"LastName") // $oChildObject = {} Finally when I make a change in the $oParentObject.ChildInformation the referenced object $oChildObject is also updated. Is this a bug? Shouldn't the :=Null work and also change the $oChildObject variable? Thanks, Drew ** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **