Re: can an array be added to a Form's object list i.e. Form.Array?
Keith, I agree with you about using Form in lieu of process vars. As a rule I like to keep 'the data' separate from 'all the other stuff' to make it easier to debug the data and to be able to encapsulate the various methods used to create those other things. thinking about I could see a rule of thumb for passing both a data object and various setup and choice options to a form to be as simple as: {"data":{... }, "options": {... }} This way I can easily manage the two aspects. Plus it would make it easier to setup form options in a consistent way. Hmm, I hadn't thought about that before. So a method to display a data object (which could be an entity too) might look like: $obj:=New object("data";$1;"options";new object) Get_some_inputOptions($obj.options) Get_some_choiceLists($obj.options) Get_some_formatStuff($obj.options) Dialog("myForm";$obj) Where each of the 'Get_some_@' methods assembles its material and writes it to the object. These would be very easy to test and reuse too. On Tue, Oct 2, 2018 at 2:47 PM Keith Culotta via 4D_Tech < 4d_tech@lists.4d.com> wrote: > I'm new enough with collections and entities not to have a good sense of > what techniques are most efficient. I have been thinking of Form as a > communication vehicle to be loaded and unloaded, and a way to avoid process > variables. > Arrays would need to be packed and unpacked, but Example 11 on page > http://doc.4d.com/4Dv17/4D/17/OB-SET.301-3730704.en.html makes me want to > try using Form.CollectionName[n] too. > > Keith > > > On Oct 2, 2018, at 4:03 PM, Kirk Brooks via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > > > > Keith, > > Sure, if having the choice list in the data object is relevant. Depends > on > > how the form is set up I think. Typically I would pass a data object to a > > form or subform to be populated with data or allow the user to edit it. I > > make the form for a particular kind of operation. Right now I'm working > on > > Payments so I've got a main Payment form and a few subforms that manage > > some aspect of a payment. Like credit card entry, manual entry, static > > display and so on. So things like popups or combo boxes are static or > > dynamic within a range and the content is determined by the kind of form. > > All I care about getting into the data object is whatever choice is made. > > > > It sounds like you're describing a situation where the data object > includes > > things like the choice lists. > > > > It's not a case of one being better than the other, more a case of > > different approaches to managing the form. > > > > On Tue, Oct 2, 2018 at 1:28 PM Keith Culotta via 4D_Tech < > > 4d_tech@lists.4d.com> wrote: > > > >> or for each value of ChoicesArray: OB > SET(Form;"ChoicesArray"+string($i); > >> ChoicesArray{$i}) ? > >> > >> Keith > >> > >>> On Oct 2, 2018, at 3:10 PM, Keith Culotta via 4D_Tech < > >> 4d_tech@lists.4d.com> wrote: > >>> > >>> You can save ChoicesArray to the Form object with OB SET > >> ARRAY(Form;"myarr";ChoicesArray). > >>> http://doc.4d.com/4Dv17/4D/17/OB-SET-ARRAY.301-3730702.en.html > >>> > >>> Also 'JSON Stringify array' will produce a string that can be > >> reconstituted with JSON PARSE ARRAY. > >>> FORM.myarr:=$stringifiedArray > >>> http://doc.4d.com/4Dv17/4D/17/JSON-PARSE-ARRAY.301-3730390.en.html > >>> > >>> Keith - CDI > >>> > On Oct 2, 2018, at 2:42 PM, Chris Belanger via 4D_Tech < > >> 4d_tech@lists.4d.com> wrote: > > I am trying to make a ComboBox object that is local to the Form. Hence > >> I need the Array to be a Form. object > > ARRAY TEXT(Form.ChoicesArray;0) does not work; > > Trying to get the data into a COLLECTION and then use COLLECTION TO > >> ARRAY (which should define the array easily) does not work: > > Form.col_UnitTypes:=ds.Unit_Type.all().orderBy("Name > >> asc").toCollection("Name";dk with primary key) > COLLECTION TO ARRAY(Form.col_UnitTypes;Form.box_Type_Unit;"Name") > >> > > does not work ("4D was expecting a Variable" error). > > > Is there now way to set up an ARRAY for Form.Array usage? > > Thanks for any observations, > > Chris > > > ** > 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 > ** -- Kirk Brooks San Francisco, CA === *We go vote - they go home* ** 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: can an array be added to a Form's object list i.e. Form.Array?
I'm new enough with collections and entities not to have a good sense of what techniques are most efficient. I have been thinking of Form as a communication vehicle to be loaded and unloaded, and a way to avoid process variables. Arrays would need to be packed and unpacked, but Example 11 on page http://doc.4d.com/4Dv17/4D/17/OB-SET.301-3730704.en.html makes me want to try using Form.CollectionName[n] too. Keith > On Oct 2, 2018, at 4:03 PM, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > Keith, > Sure, if having the choice list in the data object is relevant. Depends on > how the form is set up I think. Typically I would pass a data object to a > form or subform to be populated with data or allow the user to edit it. I > make the form for a particular kind of operation. Right now I'm working on > Payments so I've got a main Payment form and a few subforms that manage > some aspect of a payment. Like credit card entry, manual entry, static > display and so on. So things like popups or combo boxes are static or > dynamic within a range and the content is determined by the kind of form. > All I care about getting into the data object is whatever choice is made. > > It sounds like you're describing a situation where the data object includes > things like the choice lists. > > It's not a case of one being better than the other, more a case of > different approaches to managing the form. > > On Tue, Oct 2, 2018 at 1:28 PM Keith Culotta via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > >> or for each value of ChoicesArray: OB SET(Form;"ChoicesArray"+string($i); >> ChoicesArray{$i}) ? >> >> Keith >> >>> On Oct 2, 2018, at 3:10 PM, Keith Culotta via 4D_Tech < >> 4d_tech@lists.4d.com> wrote: >>> >>> You can save ChoicesArray to the Form object with OB SET >> ARRAY(Form;"myarr";ChoicesArray). >>> http://doc.4d.com/4Dv17/4D/17/OB-SET-ARRAY.301-3730702.en.html >>> >>> Also 'JSON Stringify array' will produce a string that can be >> reconstituted with JSON PARSE ARRAY. >>> FORM.myarr:=$stringifiedArray >>> http://doc.4d.com/4Dv17/4D/17/JSON-PARSE-ARRAY.301-3730390.en.html >>> >>> Keith - CDI >>> On Oct 2, 2018, at 2:42 PM, Chris Belanger via 4D_Tech < >> 4d_tech@lists.4d.com> wrote: I am trying to make a ComboBox object that is local to the Form. Hence >> I need the Array to be a Form. object ARRAY TEXT(Form.ChoicesArray;0) does not work; Trying to get the data into a COLLECTION and then use COLLECTION TO >> ARRAY (which should define the array easily) does not work: Form.col_UnitTypes:=ds.Unit_Type.all().orderBy("Name >> asc").toCollection("Name";dk with primary key) COLLECTION TO ARRAY(Form.col_UnitTypes;Form.box_Type_Unit;"Name") >> does not work ("4D was expecting a Variable" error). Is there now way to set up an ARRAY for Form.Array usage? Thanks for any observations, Chris ** 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: can an array be added to a Form's object list i.e. Form.Array?
Keith, Sure, if having the choice list in the data object is relevant. Depends on how the form is set up I think. Typically I would pass a data object to a form or subform to be populated with data or allow the user to edit it. I make the form for a particular kind of operation. Right now I'm working on Payments so I've got a main Payment form and a few subforms that manage some aspect of a payment. Like credit card entry, manual entry, static display and so on. So things like popups or combo boxes are static or dynamic within a range and the content is determined by the kind of form. All I care about getting into the data object is whatever choice is made. It sounds like you're describing a situation where the data object includes things like the choice lists. It's not a case of one being better than the other, more a case of different approaches to managing the form. On Tue, Oct 2, 2018 at 1:28 PM Keith Culotta via 4D_Tech < 4d_tech@lists.4d.com> wrote: > or for each value of ChoicesArray: OB SET(Form;"ChoicesArray"+string($i); > ChoicesArray{$i}) ? > > Keith > > > On Oct 2, 2018, at 3:10 PM, Keith Culotta via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > > > > You can save ChoicesArray to the Form object with OB SET > ARRAY(Form;"myarr";ChoicesArray). > > http://doc.4d.com/4Dv17/4D/17/OB-SET-ARRAY.301-3730702.en.html > > > > Also 'JSON Stringify array' will produce a string that can be > reconstituted with JSON PARSE ARRAY. > > FORM.myarr:=$stringifiedArray > > http://doc.4d.com/4Dv17/4D/17/JSON-PARSE-ARRAY.301-3730390.en.html > > > > Keith - CDI > > > >> On Oct 2, 2018, at 2:42 PM, Chris Belanger via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > >> > >> I am trying to make a ComboBox object that is local to the Form. Hence > I need the Array to be a Form. object > >> > >> ARRAY TEXT(Form.ChoicesArray;0) does not work; > >> > >> Trying to get the data into a COLLECTION and then use COLLECTION TO > ARRAY (which should define the array easily) does not work: > >> > >> Form.col_UnitTypes:=ds.Unit_Type.all().orderBy("Name > asc").toCollection("Name";dk with primary key) > >> COLLECTION TO ARRAY(Form.col_UnitTypes;Form.box_Type_Unit;"Name") > > >> > >> does not work ("4D was expecting a Variable" error). > >> > >> > >> Is there now way to set up an ARRAY for Form.Array usage? > >> > >> Thanks for any observations, > >> > >> Chris > >> > >> > >> ** > >> 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 > ** -- Kirk Brooks San Francisco, CA === *We go vote - they go home* ** 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: can an array be added to a Form's object list i.e. Form.Array?
or for each value of ChoicesArray: OB SET(Form;"ChoicesArray"+string($i); ChoicesArray{$i}) ? Keith > On Oct 2, 2018, at 3:10 PM, Keith Culotta via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > You can save ChoicesArray to the Form object with OB SET > ARRAY(Form;"myarr";ChoicesArray). > http://doc.4d.com/4Dv17/4D/17/OB-SET-ARRAY.301-3730702.en.html > > Also 'JSON Stringify array' will produce a string that can be reconstituted > with JSON PARSE ARRAY. > FORM.myarr:=$stringifiedArray > http://doc.4d.com/4Dv17/4D/17/JSON-PARSE-ARRAY.301-3730390.en.html > > Keith - CDI > >> On Oct 2, 2018, at 2:42 PM, Chris Belanger via 4D_Tech >> <4d_tech@lists.4d.com> wrote: >> >> I am trying to make a ComboBox object that is local to the Form. Hence I >> need the Array to be a Form. object >> >> ARRAY TEXT(Form.ChoicesArray;0) does not work; >> >> Trying to get the data into a COLLECTION and then use COLLECTION TO ARRAY >> (which should define the array easily) does not work: >> >> Form.col_UnitTypes:=ds.Unit_Type.all().orderBy("Name >> asc").toCollection("Name";dk with primary key) >> COLLECTION TO ARRAY(Form.col_UnitTypes;Form.box_Type_Unit;"Name") >> >> does not work ("4D was expecting a Variable" error). >> >> >> Is there now way to set up an ARRAY for Form.Array usage? >> >> Thanks for any observations, >> >> Chris >> >> >> ** >> 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: can an array be added to a Form's object list i.e. Form.Array?
Chris, As you found arrays are not supported for use with Form. Objects like a combo box are aren't that hard to do but until they support a collection as the data source you have to manage them in classic 4D fashion. Which means you can shuffle an array around using OB SET/GET ARRAY and some containing object. You don't get the nifty feature of the combo box updating the values in Form, of course. If the combo list is static you can put those values in a hard coded list or simply list them in the combo object. If they are dynamically built On Load you can just assign the array to the combo object. If the list is built before the form is displayed then you could put it in the data object passed to the form when it's opened and becomes Form. I like to have the combo box code fire on Data Change and at that point write the relevant value (Self->{0}) to my data object in Form. On Tue, Oct 2, 2018 at 12:42 PM Chris Belanger via 4D_Tech < 4d_tech@lists.4d.com> wrote: > I am trying to make a ComboBox object that is local to the Form. Hence I > need the Array to be a Form. object > > ARRAY TEXT(Form.ChoicesArray;0) does not work; > > Trying to get the data into a COLLECTION and then use COLLECTION TO ARRAY > (which should define the array easily) does not work: > > Form.col_UnitTypes:=ds.Unit_Type.all().orderBy("Name > asc").toCollection("Name";dk with primary key) > COLLECTION TO ARRAY(Form.col_UnitTypes;Form.box_Type_Unit;"Name") > > > does not work ("4D was expecting a Variable" error). > > > Is there now way to set up an ARRAY for Form.Array usage? > > Thanks for any observations, > > Chris > > > ** > 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 > ** -- Kirk Brooks San Francisco, CA === *We go vote - they go home* ** 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: can an array be added to a Form's object list i.e. Form.Array?
You can save ChoicesArray to the Form object with OB SET ARRAY(Form;"myarr";ChoicesArray). http://doc.4d.com/4Dv17/4D/17/OB-SET-ARRAY.301-3730702.en.html Also 'JSON Stringify array' will produce a string that can be reconstituted with JSON PARSE ARRAY. FORM.myarr:=$stringifiedArray http://doc.4d.com/4Dv17/4D/17/JSON-PARSE-ARRAY.301-3730390.en.html Keith - CDI > On Oct 2, 2018, at 2:42 PM, Chris Belanger via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > I am trying to make a ComboBox object that is local to the Form. Hence I need > the Array to be a Form. object > > ARRAY TEXT(Form.ChoicesArray;0) does not work; > > Trying to get the data into a COLLECTION and then use COLLECTION TO ARRAY > (which should define the array easily) does not work: > > Form.col_UnitTypes:=ds.Unit_Type.all().orderBy("Name > asc").toCollection("Name";dk with primary key) > COLLECTION TO ARRAY(Form.col_UnitTypes;Form.box_Type_Unit;"Name") > > does not work ("4D was expecting a Variable" error). > > > Is there now way to set up an ARRAY for Form.Array usage? > > Thanks for any observations, > > Chris > > > ** > 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 **