1 2 Previous Next 27 Replies Latest reply on Jun 27, 2014 10:47 AM by LaRetta

    For the love of UX

    user22862

      GOAL

       

      To provide a user a list of checkboxes, that can be selected to indicate the need to run a specific task. The task only changes by one variable inside the script, this variable value is the same as the value for the checkbox.

       

      I understand I can pass a parameter in and set the variable with get script parameter, but, can I also have this script repeat, and change parameter for each checked box?

        • 1. Re: For the love of UX
          Malcolm

          You can pass a list as the parameter then loop through the list to perform your script.

           

          Malcolm

          • 2. Re: For the love of UX
            user22862

            The ah ha, moment... Thank you!

             

            Kevon

            • 3. Re: For the love of UX
              user22862

              Passing the list in is no problem, but extracting into the variables, and creating the loop I'm having difficulty with.

               

              REASON

              The number of variables in the list is also a variable! It may be 1, it may be 5.

               

              So what I have here would only work if I knew the number of variables......

               

              Set Variable [$Variable1 ; value: GetValue ( Get ( Scriptparameter ) ; 1 ) ]
              Set Variable [$Variable2 ; value: GetValue ( Get ( Scriptparameter ) ; 2 ) ]
              Set Variable [$Variable2 ; value: GetValue ( Get ( Scriptparameter ) ; 3 ) ]

              • 4. Re: For the love of UX
                Malcolm

                set variable

                Loop

                    Exit Loop if [ Let($i = $i + 1; $i > $n)

                    Set Variable $Variable1 ; value: GetValue ( Get ( Scriptparameter ) ; 1 )

                End Loop

                 

                 

                malcolm

                • 5. Re: For the love of UX
                  user22862

                  Interesting how that created a link back to the thread.

                   

                  What I am able to see with mouse over, is

                   

                   

                  set variable ( $n ; valuecount ( Get ( ScriptParameter ) )

                  Loop

                      Exit Loop if [ Let($i = $i + 1; $i > $n)

                   

                  [MY SCRIPT HERE]

                   

                      Set Variable ( $Variable1 ; value: GetValue ( Get ( ScriptParameter ) ; 1 )

                  End Loop

                   

                   

                  I see that it would exit my loop after the end of the list - Thank you!

                   

                  I don't fully comprehend what is going on, that will change which parameter it will use?

                  • 6. Re: For the love of UX
                    BruceRobertson

                    Set Variable ( $p; get( scriptParameter ))

                    Set Variable ( $n; valueCount( $p))

                    Loop

                      Exit Loop if [ Let( $i = $i + 1; $i > $n) ]

                      Set Variable ( $thisVariable ; getValue( $p; $i ))

                    [ your script that does something with $thisVariable ]

                    End Loop

                    • 7. Re: For the love of UX
                      Malcolm

                      Hmm, the forum has a bunch of hidden features that get triggered by square brackets.

                       

                      The code didn’t address the variable naming issue. You could simply put a call to a subscript in your loop, passing each item from the list as a parameter. I find that is a good way to handle these sort of issues. I write a script that handles the  job in it’s simplest form then write other scripts which build on that basic functionality.

                       

                      If you want to build a list of variables in the loop you need to use the evaluate function to generate named variables within the loop. You insert something like this:

                       

                      set variable ($tmp; Evaluate(“Let ($variable_” & $i & “=“ & quote(getvalue(get(scriptparameter); $i )) & “;1)”) )

                       

                      Malcolm

                      • 8. Re: For the love of UX
                        user22862

                        "You could simply put a call to a subscript in your loop, passing each item from the list as a parameter. I find that is a good way to handle these sort of issues."

                         

                        Great idea.. I'm already calling several other scripts from this one, same reasoning you mention. I think this is the best, and as you stated, teh simplest form!

                         

                         

                        Bruce,

                         

                        Thank you very much. Am I correct in assuming that the $i will automatically change to reflect the next value in the list of parameters?

                         

                         

                        This would work, however I really also need that variable to change the name of the file being opened from the script. So I think I will need to go the route of passing a single variable at a time.

                         

                        But while I need to solve this problem, I also want to learn anything I am able, if you have time to explain?

                        • 9. Re: For the love of UX
                          BruceRobertson

                          No, that's backwards.

                           

                          $thisVariable will change to reflect the fact that it holds line number $i of whatever got passed in as the script parameter.

                           

                          Once you have grabbed this line, then your script can do whatever you need to do with it.

                           

                          It would be really helpful if you could submit your file - or a simplified version of your file - as an attachment. And also it would be helpful to use more meaningful terminoloogy so we could see what you are trying to do.

                           

                          Loop processing is really really basic scripting and there are probably other things you're doing that would benefit from getting some experienced commentary.

                          • 10. Re: For the love of UX
                            user22862

                            Agreed that this would be beneficial, and while loop processing is very basic, so am I to FileMaker.

                             

                            We hired a developer/consultant two years ago and found out way in, that it was a terrible mistake. Over the last two years I have been trying to self teach. We have hired a new development company that is handling fixing the original project. However on the side, I have been building my own solution to learn on.

                             

                            I tend to be a very cautious person, so would you be open to me sending it to you directly? I would greatly appreciate your input, and possibly even be interested in compensating you for your time, if you feel it would be helpful.

                            • 11. Re: For the love of UX
                              ChadAdams

                              Thank you very much. Am I correct in assuming that the $i will automatically change to reflect the next value in the list of parameters?

                               

                               

                              This would work, however I really also need that variable to change the name of the file being opened from the script. So I think I will need to go the route of passing a single variable at a time.

                               

                              But while I need to solve this problem, I also want to learn anything I am able, if you have time to explain?

                               

                              Hi Kevon,

                               

                              The $i in Bruce's example is just a counter.  The example is very concise and elegant, but a tad hard to get your head around if you are new to the concept.  You could accomplish the same thing with the following script:

                               

                               

                              Set Variable ( $p; get( scriptParameter ))

                              Set Variable ( $n; valueCount( $p))

                              Set Variable ( $i ; 0 )

                              Loop

                                Set Variable ( $i ; $i + 1 )

                                Exit Loop if [ $i > $n ]

                                Set Variable ( $thisVariable ; getValue( $p; $i ))

                              [ your script that does something with $thisVariable ]

                              End Loop

                               

                               

                              Peple often use $i as a counter type variable as it stands for iteration (or index? or integer? I don't know).  FileMaker doesn't care what you name your variables. Although $i is nice and short to type, I often make it more explicit (for myself and those coming after me) and instead do something like this:

                               

                               

                              Set Variable ( $p; get( scriptParameter ))

                              Set Variable ( $n; valueCount( $p))

                              Set Variable ( $counter ; 0 )

                              Loop

                                Set Variable ( $counter ; $counter + 1 )

                                Exit Loop if [ $counter > $n ]

                                Set Variable ( $thisVariable ; getValue( $p; $counter ))

                              [ your script that does something with $thisVariable ]

                              End Loop

                               

                              Hope that helps it make mores sense.

                               

                              Chad


                              • 12. Re: For the love of UX
                                user22862

                                Chad,

                                 

                                Thank you very much for the time taken to explain and provided examples. I admit that loop is something I haven't learned to properly utilize. I'm still learning how to get things done, and end up writing much longer scripts than I need too, I'm sure.

                                 

                                I learn best by rolling up my sleeves and doing the work. Then searching out answers to my problems. What I've found is after learning new techniques, I'm able to go back to my scripts and trim down the length. Loop combined with calculations will be a great asset to many of my scripts in this next revision.

                                 

                                Again, thank you very much for your time!

                                • 13. Re: For the love of UX
                                  BruceRobertson

                                  I have sent you a reply by private message here.

                                   

                                  But I will also suggest that on your personal project file, don't forget that you can save a clone of the file, and share that.

                                  Perhaps you're not willing to share even a clone. That is understandable.

                                   

                                  It may also be a good idea to create a file that you are willing to share, that is a simplified version of what you are trying to accomplish, and which has dummy data.

                                   

                                  Also: in message 8, you mention for the first time, something about file names. But there is no further explanation, so we don't know what that refers to or what you are trying to do with files. Perhaps you could explain?

                                  • 14. Re: For the love of UX
                                    user22862

                                    Understand the clone, and making it distributable. I also don't think what I've built is anything earthshattering, however I don't feel there is much to be gained from sharing the file.

                                     

                                     

                                    What I am trying to accomplish is prepopulate a PDF using PDF Manipulator. This was teh easy part, and I have half a dozen small companies using this succsefully. Now comes my challenge to make thiis able to prepopulate, 1, or many PDF's.

                                     

                                    The PDF naming convention matches that of my file, and I DO use a loop function during the current import process. The importing of any number of PDF's and creation of a new record, with field data, is complete. What I was struggling with was passing the list of variables, and grabbing just one, running the loop, and then running another loop with a different variable.

                                     

                                    Inside the loop, I have a script that succesfully prepopulates a PDF. I have changed the location and PDF that it grabs to rename, based on the parameter that is passed into the script. I didn't have the ambition to stay awake and debug the script lastnight, however what I believe happened was the same parameter was used 4 times in a row. ( valuecount returned 4, because there was 4 items in parameter list )

                                     

                                    Hopefully tonioght after work I will get to debug this and get it working. ( filemaker is not a job, rather a hobby )

                                     

                                    I apreciate your help and insight, I also apreciate your ambition reflected in your PM.

                                    1 2 Previous Next