1 2 Previous Next 29 Replies Latest reply on Sep 13, 2016 7:35 AM by beverly

    Else If


      Hi all


      Apologies if this is in the wrong location, first time posting here!


      Totally new to Filemaker so just trying to figure out a simple Else If function.  I have a page with a bunch of buttons, each with a different hazard from a risk assessment form.  Below this are 5 fields.  When a button is pressed, the hazard description is loaded into the fields.  If the first field is empty, the text goes there.  If it's full, the text goes in the second field.  If the second field is full, it goes in the third field.  And so on and so on.


      I pieced together the following:


      IF [field1=""]

      INSERT TEXT [field1;"Access egress blocked restricted work place"]


      ELSE IF [field1="0"]

      INSERT TEXT [field2;"Access egress blocked restricted work place"]


      ELSE IF [field1="0" and field2="0"]

      INSERT TEXT [field3;"Access egress blocked restricted work place"]


      END IF


      Now I know this is probably a laughable attempt but the first part works at least.  If there's nothing in field1, the text inserts in there.  If I place a 0 in field one, the text inserts into field 2.  However, if I then add a 0 to field 2, the text still inserts into field 2 after the 0 so obviously the second ELSE IF function is wrong. 


      So, my questions are:


      What can I use in place of the and in order to make the second ELSE IF function consider the state of 2 fields instead of one?


      And what can I use in place of the 0 to make the function see any data in the field, numerical or textual, and move onto the next field?


      Any help would be greatly appreciated!



        • 1. Re: Else If

          welcome hbee!


          =0 is not the same as IsEmpty()


          & Insert Text is a "paste"

          when a Set Field is preferable


          If you have 5 buttons and each has a different "text", I believe I would pass the value of the test as a script parameter.


          Perform Script ( SET_hazards ; "<<your text here>>"  // this will be different for each button )




          Set Variable ( $sp = Get ( ScriptParameter ) )

          If ( not IsEmpty ( $sp ) // script only runs if you've pass a parameter )


               If ( not IsEmpty ( field1 ) )

                    Set Field ( field1 ; $sp )

               Else If ( not IsEmpty ( field2 ) )

                    Set Field ( field2 ; $sp )

               Else If ...


               End If


          End if



          Finish the Else If for the rest of the fields. This will work for every button (passing different text) and all fields. It will go through IN ORDER and find the first empty field, and fill it with the text.



          • 2. Re: Else If

            Thank you Beverly, the response is much appreciated!


            Again, you'll have to excuse my ignorance here, still struggling a bit.


            So, I now have 2 scripts running.  1 is the Perform Script function which I have like this:


            Perform Script ["SET_hazards"; Parameter: ""01 Access | egress blocked | restricted work place"]


            If I assign this script to the button, it seems to work for the first button press, it certainly dumps the desired text in the first field.  Is the 'Parameter' part correct though?  That's not in your example but the only place I could see to put it in the 'Specity Script' window was at the bottom in the 'Optional Script Parameter:' field.


            Then I have a second script called SET_hazards that looks like this:


            Set Variable [$sp; Value; Get ( ScriptParameter )]

            If [not IsEmpty ( $sp )]

            Set Field [Project Brief::RA Hazard#1; $sp]

            Else If [not IsEmpty (Project Brief::RA Hazard#2)]

            Set Field [Project Brief::RA Hazard#2; $sp]

            End If


            This is not working at all.  Can you tell me where I've gone wrong please?



            • 3. Re: Else If

              The button has one script step and the parameter can be different for each button.

              If you have not posted screen shots please send the dialog you assign to the first button.


              Sent from miPhone

              • 4. Re: Else If

                This is the script assigned to the first button:



                And this is the SET_hazards script:



                • 5. Re: Else If

                  Show the button dialog


                  Sent from miPhone

                  • 6. Re: Else If

                    Sorry Beverly, not sure what you mean, how do I find that?


                    I've decided not to use a button but a checkbox instead.  Would this make a difference?

                    • 7. Re: Else If

                      When you create the button, you have the option to assign a single script step or a perform script:


                      When select single step, type

                      Perform Script

                      then select your script:


                      & add the parameter.


                      You can duplicate this button for each one, rename the label AND change the "optional script parameter" for each button. That way you are using the same script, but passing different parameters.


                      • 8. Re: Else If

                        Ah ok yes I understand, thanks. However, I'm not using a button any more, I'm using a checkbox. Does the same dialog apply to checkboxes?


                        For each checkbox, I right click, go to 'set script triggers', then going to 'select' next to 'script:' and selecting the relevant script from the 'specify scripy' window. Is that right?

                        • 9. Re: Else If

                          you did not specify checkbox. Please post a screen shot of your layout with the "buttons" (if any) and the checkbox formatted field. as well the fields you need "filled". and then describe again what steps you are trying to do based on the screen shots.



                          • 10. Re: Else If

                            Seems like it would be much simpler and much more flexible just to add a new related record each time instead of trying to determine which of a set of duplicate fields to which to set with your value.

                            • 11. Re: Else If

                              I mentioned that a few posts ago, apologies for the confusion.


                              Ok here's the layout:


                              You can see the 2 checkboxes at the top.  There will be a list of 52 of these.  Here is what I need:


                              1. When a checkbox is checked, I need the associated hazard title, for example 'Access/egress blocked/restricted (work place)' to load into the next available hazard field at the bottom of the screen.
                              2. When the checkbox is unchecked, I need the associated hazard title to be removed from the fields at the bottom.


                              Is that enough info?  Let me know if you need more. And sorry again for the confusion!  Very new at this!



                              • 12. Re: Else If

                                step one: learn about checkboxes


                                • put a text field on the layout and format as checkboxes (assign any valuelist)

                                • put the same field on the layout but do NOT format as checkboxes

                                • now check and uncheck the field with checkboxes

                                • note the values that appear in the same field as you check/uncheck


                                The VALUES in the field whether formatted or not will appear in the order you add (or remove them). This is a return-delimited list and there are many things that can be done with that list.


                                Rather than pushing the values into other fields (which can be done), is there any reason to NOT leave as the checkboxes and the values in that field?


                                Let me know if you understand this step.


                                • 13. Re: Else If

                                  Ha you've lost me!


                                  What do you mean by 'format as checkboxes'?  So I create a new text field in the field picker and then what?  Can't see an option to format as checkboxes.


                                  I was using the Field/Control Tool to create the checkboxes, is that wrong?


                                  When I add a checkbox using this tool, it asks me to link it with a field like this:



                                  It then says 'value list missing' so I go to the 'values from' section on the inspector and then create a new value list with a custom value of 'Animals / insects wild performing etc' or whatever info I want dumped into the fields below when the checkbox is checked.  Is that correct?


                                  Thanks again for being so patient!



                                  • 14. Re: Else If

                                    step two: doing something with the values in a checkbox field

                                    • ask yourself if you want the other 5 fields filled as a check box is checked

                                    • ask yourself what should happen if you UNCHECK a value - does it get removed from one of the 5 fields

                                    • ask yourself if once checked, and placed into a field, can a value be placed into multiple fields

                                    • if not filling the fields every time a checkbox is checked, when do you want the other fields filled

                                    • how is the value list populated (to make the checkboxes labels)?


                                    because of the structure, a revision, such as suggested by phil might be a better method. but first we need to answer the questions posed above.



                                    1 2 Previous Next