7 Replies Latest reply on Sep 16, 2009 11:08 AM by comment_1

    function to add +1 to previous field number

    firth5

      Title

      function to add +1 to previous field number

      Post

      I feel stupid for asking so simple a function but....

       

      I've successfully created a script that adds a new record and inserts a bunch of text from the last record.

       

      The last thing that needs to happen is that I need to insert a value from the last record... but the number should be +1.

       

      I'm guessing I'll use script step "insert calculated result,"  but I can't find the function that simply retrieves the contents from a field, so I can add +1

       

      Please help.  And be kind.  I should know this.....

       

      : ) 

        • 1. Re: function to add +1 to previous field number
          firth5
             There are many reasons not to have an auto-entered serial number, too numerous to go into.  I wish it was that simple.  : )
          • 2. Re: function to add +1 to previous field number
            raybaudi
              

            firth5 wrote:

             

            I've successfully created a script that adds a new record and inserts a bunch of text from the last record.


            Hi

             

            write down your script and we'll modify it for your needs.

            • 3. Re: function to add +1 to previous field number
              philmodjunk
                

              It could be as simple as:

               

              Set Variable [$numb; table::field]

              New record

              Set field [table::field ; $numb + 1]

              • 4. Re: function to add +1 to previous field number
                mrvodka
                  

                firth5 wrote:
                There are many reasons not to have an auto-entered serial number, too numerous to go into.  I wish it was that simple.  : )

                 

                and if you take all of those reasons, I can probably double the reasons why it is dangerous to try an increment the number on your own.

                 

                You still have not stated the purpose here.

                 

                 

                Furthermore, I know that Phil was trying to help by offering a solution, but when it comes to a matter like this, it is not so simple and you should really think about it hard. How would this script as is work in a shared environment? How would this script work when the records are sorted. Better yet, how would this script work when it runs on a record that is not the last created record? It may serve your purposes, but most likely it will not.

                 

                 

                 


                • 5. Re: function to add +1 to previous field number
                  philmodjunk
                    

                  Mr. Vodka makes very good points.

                   

                  The script fragment I posted was intended as part of a larger script where you would indeed need to address each of those issues.

                   

                  LaRetta's original suggestion: an auto-entered serial number is a simple effective approach that works in most situtations while avoiding these very issues.

                  • 6. Re: function to add +1 to previous field number
                    firth5
                      

                    Hmmmm.... Okay, well, in answer to your queries:

                     

                    Here's WHY I want this "+1 script"

                     

                    As some of you know by now, I'm building a design database for an animation studio.  We create a design list based on a script (as in a story-type script, not the filemaker kind....).  Each design has a SCRIPT PAGE field.  We want to make sure that when we print out the list of designs, they appear in the order that the design appeared on the script page.  (ex. if AARON got on his BIKE and then met CHARLIE on page 1, we want to make sure that with the right sort, the designs would be listed:

                    AARON

                    BIKE

                    CHARLIE 

                    Therefore I created a second field:  SCRIPT PAGE ORDER

                    and we'd sort by SCRIPT PAGE / SCRIPT PAGE ORDER

                     

                    Now some caveats:

                    -- The script changes, so sometimes we need to go in and add a new record.  In this case the data person would edit the SCRIPT PAGE ORDER manually.  

                     

                    -- Once we've moved passed the script phase, there are many new designs being added that WON'T have "script page" (and therefore a "script page order") data.


                     

                     

                    So I want to create the following User Friendly buttons (that activate the scripts this thread is discussing) on the Data Entry page:

                     

                    1) NEW RECORD (new script page) 

                    2) NEW RECORD (same script page) 

                     

                     

                    (Now I may be wrong about this but) I don't think an auto serial number will work because:

                     

                    -- not every record will get a number in these fields

                    -- I want to be able to manually change them with ease.

                     

                     

                    Have I given enough information?  SET VARIABLE seems to be working for my needs, do you think it's the right solution? 

                     

                    How would this script as is work in a shared environment? -- in general, only one person will be using this script button.

                    How would this script work when the records are sorted. -- as stated, the sort is the whole point.

                    Better yet, how would this script work when it runs on a record that is not the last created record? -- The button/script is only available in form view, and I've put "go to field" at the start of script so that it makes that record the the current record.

                     

                    Thanks,

                    eric 

                    • 7. Re: function to add +1 to previous field number
                      comment_1
                        

                      I may be missing some of the complexity, but it seems to me that sorting by a calculation field like =

                       

                      Case (  SCRIPT PAGE ORDER ; SCRIPT PAGE ORDER ; 10^400 )

                       

                      should solve it.