1 2 Previous Next 23 Replies Latest reply on Dec 23, 2013 3:27 PM by philmodjunk

    Help Needed with a field set Calculation

    shae1725

      Title

      Help Needed with a field set Calculation

      Post

           Im having trouble with a Button calculation. not as easy as  I first thought!

           What I what to achieve is to have a button set a field    Parent::ColorIDList    with the contents of the first record of    Child::ColorID

           on each press of the button I want to REPLACE the first record in Parent::ColorIDList  with  the next Child::ColorID and so on until the last record when the calculation goes back to the first Record.

           I also want to skip any records which have no value (I have a field Child::cCountColor already in place for this purpose)

           I will probably create two buttons using a script parameter with   +1 and -1 to go forwards and backwards but can probably do that part myself. if someone one could guide me on the first part I would be very thankful.

        • 1. Re: Help Needed with a field set Calculation
          philmodjunk

               Can you explain what you are trying to do in more detail? The "next record" part of your description doesn't seem to make sense here.

          • 2. Re: Help Needed with a field set Calculation
            shae1725

                 Hope this makes sense

                 ColorGroup::ColorID          ie   1              2           3

                 ColorGroup::Color              ie   Red         Blue      Orange

                 ColorGroup::cCount           ie   18             6           0

                  

                 I need to populate  Layout::ColorIDList  with  ColorID   1 -  2  -  3 etc

                 When I press button for first time Set field ColorIDList     first record  =1  on second press 2 then 3 and so on (replacing not adding) when last record reached return to first

                 The ColorIDList is used in other parts of my application  sorting by multiple ColorID ie to show for example red blue and orange together so the field is set as a List

                 Its a very small table and will have no more than 20 records

                 This is  an added feature to the sorted Horizontal Portal Technique you helped me with

                  

                  

            • 3. Re: Help Needed with a field set Calculation
              SteveStrickland_1

                   What I do is write all the fields to variables in a script. You need 1 extra for the first record. Then use the variables to change the field contents. It takes 2 such scripts, one for the forward commutator and another for the reverse.

                   Here I load the variable with a subscript and then commute the data using variables. You can do the same with fields.

                    

              • 4. Re: Help Needed with a field set Calculation
                shae1725

                     From looking at that script I would have to set variables for the amount of variables I might need

                     and if I end up adding more records to the table I would have to rewrite the script?

                     I'm not even a good amateur coder so correct me if I'm wrong!

                     I had thought that because the ColorIDs data are numeric 1 2 3 4 etc that I could have a calculation without having to goto the table to retrieve data and that I could just get the total record count and a +1 OR -1 script parameter would work

                • 5. Re: Help Needed with a field set Calculation
                  SteveStrickland_1

                       You can't create a variable name by script so what I did in my "load variables" subscript is create more variables than I need. In fact, I create 24 variables even though only 5 are used for this commutator.

                       If your number of records is variable then you can use Loop() to load your pre-named variables and another Loop() to commute the values. This will require some scripting skill.

                       A commutator like this will always commute values according to a fixed pattern. You won't need to code another commutator unless you need a different pattern. Notice that my commutator is not sequential and can't be looped while yours is sequential and can be looped.

                       A linear commutator can be more easily scripted but both ours are circular requiring a bit extra attention. You could script it with special conditions for handling the first and last record. To me that's a more complex script but something that can certainly be done if one wishes to avoid loops.

                  • 6. Re: Help Needed with a field set Calculation
                    philmodjunk

                         You shouldn't need a different variable for every value. You can put all the values as a list in one variable.

                         But I still don't get this part:

                         

                              When I press button for first time Set field ColorIDList     first record  =1  on second press 2 then 3 and so on (replacing not adding) when last record reached return to first

                         Are you trying to replace all the values in ColorIDList with a new set of values, the values from all the records in a new found set?

                         If that is what you are trying to do, this can be done with a pretty simple looping script. (And in FileMaker 13, there's a new summary field that can make this happen with one set field step.)

                    • 7. Re: Help Needed with a field set Calculation
                      shae1725

                           Thanks for your time Steve

                           But I don't really understand the Commute Pieces step you describe! its I bit over and above my skill level at the moment.

                      • 8. Re: Help Needed with a field set Calculation
                        shae1725

                             Not sure if I can describe any better than this

                              

                             Every time I press the button the previous value is to be REPLACED by the new value!    there will be only 1 value in the ColorIDList at any time

                              

                              

                             Button first press ColorIDList   = value ColorGroupID    Record 1

                                   second press ColorIDList  = value ColorGroupID    Record 2 

                             and so on

                        • 9. Re: Help Needed with a field set Calculation
                          SteveStrickland_1

                               I'll try to explain what a commutator is.

                               Imagine that we have 5 values stored in 5 containers. It doesn't matter if the containers are fields, records or variables. We start off with this:

                               1 2 3 4 5

                               We now "commute" each value to another container, let's say the right hand neighbor, so we end up with:

                               5 1 2 3 4

                               Or we could commute the values to the left and get:

                               2 3 4 5 1

                               The collection of all the individual commutes performed together is called a commutator. It's a function that "commutes" the values from one place to another.

                               Of course, commutators can be quite complex in some cases. One that just says "everyone move over 1 unit to the right" is very simple and can be performed on a data set of any size. Commutators aren't restricted to operating on the full set of data. Maybe you only want top commute 3 of the values. They don't have to be linear, either. Values can move from any container to any other container.

                               I hope that helps a little.

                               I'm using them in a situation where 2 circular commutators intersect each other. It looks complex in the interface but at its heart its still just everyone on a ring move 1 unit to the right or left.

                          • 10. Re: Help Needed with a field set Calculation
                            philmodjunk
                                 

                                      Not sure if I can describe any better than this

                                 But from WHERE are the new values gotten? Is this a related set of records? A found set?

                                 Instead of "the next record" do you mean the "next value" in your color list? Such that you are deleting a value from the list while keeping the others?

                                 Are all the values in the list to be replaced or just some of them?

                                 I keep coming up with multiple scenarios that fit what you describe that are actually quite different from each other...

                                 Why do you need to do this one button click at a time? What is the purpose behind this?

                                 A step by step narrative description of what the user has one their screen and why they are doing this might nail this down.

                            • 11. Re: Help Needed with a field set Calculation
                              shae1725

                                   Hi Steve

                                   I probably didn't explain my needs very well and thanks for your explanation of a commutator! I can see why I should study the process as it looks like a pretty handy skill set to have! I use a lot of horizontal portals and I can see how a commutator could be used for more complicated horizontal portal scrolling. you will probably see me posting for help on the subject soon and any help would be appreciated :)

                                   Im going to post a better explanation and a snap of the script I came up with . which is pretty simple and works really well. although more experienced FM users could probably suggest a better solution.

                                   Many Thanks

                              • 12. Re: Help Needed with a field set Calculation
                                shae1725

                                     Hi Phil

                                     I have posted a snap of the script I came up with.

                                     First I added a "list summary field" of the  records in the ColorGroup Table!

                                     I thought I would have to loop but this works! with every press of the button ColorIDList is replaced with the next ColorGroup value and will cycle through all the records to the last and and then back to the first!

                                     The only thing I can't work out is how to cycle backwards! I tried using a     +1    and     -1 ScriptParameter

                                     The purpose behind this button that on each press of the button my Horizontal Portal (ref the one you helped with) will display just one Group of colors!

                                     The button is just an added shortcut on my application to simply scroll through colors individually!

                                     .

                                      

                                      

                                • 13. Re: Help Needed with a field set Calculation
                                  philmodjunk

                                       Yes, that is a new and very handy summary field in FileMaker 13.

                                       But your script raises more questions than it answers. Could you please describe what end result you are trying to produce here?

                                       And you haven't answered any of my questions so I am still looking at multiple interpretations of what you might be attempting here.

                                       Does ColorIDList store a single value or a list of values?

                                       And what data do you expect to see in the ColorIDList field after the set field step has executed? What did you intend it to do?

                                  • 14. Re: Help Needed with a field set Calculation
                                    shae1725

                                         Lets forget about the button and what I want to do for a moment.

                                          

                                         I have a Table of Products

                                         I have a horizontal portal on my layout showing these products (this table contains a field ColorID) .    it looks like a color picker

                                         I have another table which contains all the color Groups ie (Red Blue etc) it also has a ColorID field and is related to the same in product table) I have a portal on my layout displaying this tables contents.

                                         If I click on any of The Color Group portal rows then ColorIDList gets populated with the Color Groups ID (I can List multiple ColorGroups)

                                         ColorIDList then filters the Product portal so I see all the products that belong to the related ColorGroups!

                                         This allows me to view any combination of the products related to their ColorID.

                                         The above all works perfectly as it should!

                                          

                                         Now the Button that I scripted for!

                                         This button is to allow me to Filter the products by their Color Group ID - ONE at a time! with each press of the button setting the ColorIDList with the next ColorGroup ID 

                                         This is the behaviour I need (even if to some it doesn't make sense as I already can filter by Color Group using the existing portal described above)

                                         My application is extremely demanding because its being built for both severly autistic young adults and non autistics to use. I have to design different ways to do the same thing depending on the students needs and my knowledge of how they can best interact with the GUI Im building

                                         The summary list field used in the script is based on the Color Group Table IDs

                                         All I can say is at this point is that the script I built works! but I would like to have two buttons with a script parameter in each with +1 and -1 so that I can scroll backwards and forwards.

                                         Many Thanks

                                          

                                          

                                          

                                          

                                          

                                          

                                          

                                    1 2 Previous Next