11 Replies Latest reply on Nov 17, 2008 7:19 AM by Orlando

    Script Parameter Function

    ttumbles

      Title

      Script Parameter Function

      Post

      I have a small script  (see bold text below) that finds any "blank" fields in a found set of records for an annual report.

      I have around 30+ fields that I will run this script on looking for blanks but each one has to be done separately.   The ONLYdifference between the script for one field and another is the CONSTRAIN FOUND SET (line 3)

      .

      Is there a way to use the Get (Script Parameter) function or something else to do the CONSTRAIN FOUBND SETso that I can eliminagte all but one script?????  The script below looks for blanks in the field "Z08_DOB".

      .

      Set Error Capture (On)

       

      Perform Script (Find all records for annual report)

       

      Constrain Found Set[Specified Find Requests: Find Records: Criteria: CUBMAIN::Z08_DOBB; "="] [Restore]

       

      If GFet (Last Error) = 401

       

      Show Custom Dialog[Message:"G O O D !";  "OK";  "Cancel" ]

       

      Exit Script

       

      End If

       

      Go to Layoiut ("Annual Report" (CUBMAIN)]

       

      Show Custom Dialog[Message:"Field(s0 cannot be blank.!";  "OK";  "Cancel" ]

      Exit Script

       

      THANKS IN ADVANCE for all your help!

       

      <!-- [if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif] --><!-- [if gte mso 9]><xml> <w:WordDocument>   <w:View>Normal</w:View>   <w:Zoom>0</w:Zoom>   <w:PunctuationKerning/>   <w:ValidateAgainstSchemas/>   <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>   <w:IgnoreMixedContent>false</w:IgnoreMixedContent>   <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>   <w:Compatibility>    <w:BreakWrappedTables/>    <w:SnapToGridInCell/>    <w:WrapTextWithPunct/>    <w:UseAsianBreakRules/>    <w:DontGrowAutofit/>   </w:Compatibility>   <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif] --><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif] --><!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal      {mso-style-parent:"";      margin:0in;      margin-bottom:.0001pt;      mso-pagination:widow-orphan;      font-size:12.0pt;      font-family:"Times New Roman";      mso-fareast-font-family:"Times New Roman";} @page Section1      {size:8.5in 11.0in;      margin:1.0in 0in 1.0in 0in;      mso-header-margin:.5in;      mso-footer-margin:.5in;      mso-paper-source:0;} div.Section1      {page:Section1;} --><!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable      {mso-style-name:"Table Normal";      mso-tstyle-rowband-size:0;      mso-tstyle-colband-size:0;      mso-style-noshow:yes;      mso-style-parent:"";      mso-padding-alt:0in 5.4pt 0in 5.4pt;      mso-para-margin:0in;      mso-para-margin-bottom:.0001pt;      mso-pagination:widow-orphan;      font-size:10.0pt;      font-family:"Times New Roman";      mso-ansi-language:#0400;      mso-fareast-language:#0400;      mso-bidi-language:#0400;} </style> <![endif] -->

      <!-- [if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas>   <v:f eqn="if lineDrawn pixelLineWidth 0"/>   <v:f eqn="sum @0 1 0"/>   <v:f eqn="sum 0 0 @1"/>   <v:f eqn="prod @2 1 2"/>   <v:f eqn="prod @3 21600 pixelWidth"/>   <v:f eqn="prod @3 21600 pixelHeight"/>   <v:f eqn="sum @0 0 1"/>   <v:f eqn="prod @6 1 2"/>   <v:f eqn="prod @7 21600 pixelWidth"/>   <v:f eqn="sum @8 21600 0"/>   <v:f eqn="prod @7 21600 pixelHeight"/>   <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:657pt; height:621pt'> <v:imagedata src="file:///C:\DOCUME~1\adm-dba\LOCALS~1\Temp\msohtml1\01\clip_image001.png"   o:title=""/> </v:shape><![endif] --><!-- [if !vml] -->
      <!-- [endif] -->
       

       

        • 1. Re: Script Parameter Function
          Orlando
            

          Hi ttumbles

           

          If I am reading this correctly, you want to be able to check if there are any blank fields in the found set?

           

          If this is teh case the easiest thing to do would be to create a calculated field that checks each of the fields and returns a value of 1 if any fields in that record are empty, and then perform a single find on that calculation being 1.

           

          The calculation would be something like this:

           

          AlertEmpty [Number] = 

           

            Case ( 

           

            IsEmpty ( Field1 ) ; 1 ;

            IsEmpty ( Field2 ) ; 1 ;

            IsEmpty ( Field3 ) ; 1 ;

            IsEmpty ( Field4 ) ; 1 ;

            IsEmpty ( Field5 ) ; 1 ;

           

            "" ) 

           

          Listing all the fields you want to check.

           

          I hope tis helps 

           

          • 2. Re: Script Parameter Function
            Kundinger
              

            Hi "ttumbles",
             
            A different approach to consider...
             
             
            If you are trying to prevent users from 'leaving' fields 'empty' or prevent them from entering 'inappropriate' data...
             
             A. Use FMP field validation options  --  'click' the "Options" button in the 'define fields' dialog
                 - FMP gives you many options to validate the user data input 
             
             B. Restrict MOST user data entry to predefined "Value Lists"
             
             C. Develop a customized validation system -- create a system that will analyze the data input and display a warning message
                 - I have used this method since FMP-2, before many of the now built-in validation options 
             
             
            The key here is...  you are "proactively" validating data entry as the user is inputting, as apposed to performing a "reactive" validation following the numerous data inputs!
             
             
            I hope this helps... Good Luck!!!

            Kundinger
             

            • 3. Re: Script Parameter Function
              ttumbles
                

              Crieria for a find is  -  CUBMAIN::Z08_DOBB; "="

               

              Orlando,

              Thanks for taking the time to help me with my solution.   Actually my small script works fine EXCEPT, since I have to look at ONLY one field at a time, I have to have a separate script for each field   OR  just one calculation field (like you suggested) BUT then I'd have to have a separate FIND for each field as I looked a them individually  to see which records had that field empty.  It's probably me, but I can't see that that helps me save any time.    What I want is for the USER to be able to click  a button to check for a specific field to see if any of the recrods have that field showing empty.

              .

              .

              I know this is just me and how I am NOT explaining it correctly.  What I was trying to do was substitute a new field name (perhaps based on the script parameter) in the  criteria line. (line 3 of my original script).

              .

              Thanks again!  You know I am finding this forum to be my very favorite.  Everybody is so very nice all the time and truly tries to help each other rather than scolding another developer for "not being the world's most brilliant programmer" like I've seen on other forums. 

              • 4. Re: Script Parameter Function
                ttumbles
                  

                Kundinger,

                Thanks so much for your reply.   I am really glad I discovered this forum.  So far it's a good place for FRIENDLY help.  I've been on forums where they get their jollies by basically "scolding people for being stupid".  I haven't fouind anyone out there, thks forum or others, who is stupid.  Everyone is just operates in different ways and is at a different developer's level.

                   I have a confession to make too.  I am not onlyi the developer for these databases, I am the chief user.  You're probably thinking "How in the workd can he get blank fields that aren't suposed to be blank if he is both???  Well I have to deal with the federal government (US Dept of Education). Those epeople change their minds and their field definitions in mid stream and often.  It gets to be a pretty big guessing game sometimes in order to meet their deadlines.

                .

                I am sorry.  I didn't mean to "dump" my wrok problems on you.  Just trying to explain why your help in restricting data entry to value lists, etc. is not always practical..................although I agree with yoiui 100% on doing those things when it IS practical.  Your advice DOES help and I appreciate it a bunch!!

                Thanks again! 

                 .

                 

                • 5. Re: Script Parameter Function
                  obeechi
                    

                  Let each field be a button. The button in each case will call on your one script via the Perform Script step. The parameter it sends will be the name of the field itself, or Self (I think Self will work, but my thinking is fuzzy right now). 

                   

                  Then instead of hard wiring the name of the field into your script, such as "Z80_D0B" simply use Get (Script Parameter), but you won't be able to use it in the Constrain Found Set step. So instead you can use If Get (Script Parameter) = "Field1" then Constrain Found Set, Else If ... et for each "Fieldn". This is not highly abstracted, because you're still wiring in the names of the fields into the script.

                   

                  Each time you add a field you'd have to modify the main script called, as well as add a button with a script parameter for the new field. This also means you have to keep changing your layout, so you might want to make your layout extensible by having placeholders for where new fields will go. 

                   

                  The Calculated field equal to 1 would allow you to do a complete check without clicking 30 buttons, so you might want to have a button for this too. 

                  • 6. Re: Script Parameter Function
                    ttumbles
                      

                    Obeechi,

                    The IF ....  ELSE IF  routine might be just what I needed. Thanks a ton!

                    I know it's not purely abstraction...............the true power of the Get (Script Paramenter) function but it still makes maintaining the whole thing a lot easier with just ONE script, even if I am modifying that script now and then., 

                    .

                    .

                    Since I am mostly FileMaker self taught, can you tell me what "extensible" means and how do I use "placeholders??   If this is too complicated to explain via e-mail, don't worry aobut it. I wil be reading about those terms all that I can.  You knonw it is just so much easier to ask someone who knows their stuff!

                    .

                    Again, thanks for the thoughts!  Truly appreciate them.

                    • 7. Re: Script Parameter Function
                      raybaudi
                        

                      Obeechi

                       

                      I'm sorry but the accepted solution isn't so good for me.

                       

                      "Let each field be a button"

                       

                      where, in a new layout ? Otherwise how can he write inside it ?

                      ( isn't better a button near the field ? )

                       

                       

                      "The parameter it sends will be the name of the field itself, or Self "

                       

                       

                      The parameter must be hardcoded and Self can't be a way because:


                      1) It can't be inserted as a script parameter
                      2) Self isn't the field name, but the field contents.
                      3) Get ( ActiveFiledName ) can't be used ( as you know )

                       

                      So the simplest way is to go on with numbers as script parameters.

                       

                      And the script will be something like this:

                       

                      If [ Get (ScriptParameter) = 1 ]

                      do this

                      End If

                      If [ Get (ScriptParameter) = 2 ]

                      do this

                      End If

                      ...

                      ...


                      • 8. Re: Script Parameter Function
                        raybaudi
                          

                        Hi Orlando

                         

                        Case (
                        IsEmpty ( Field1 ) ; 1 ;
                        IsEmpty ( Field2 ) ; 1 ;
                        IsEmpty ( Field3 ) ; 1 ;
                        IsEmpty ( Field4 ) ; 1 ;
                        IsEmpty ( Field5 ) ; 1 ;
                        "" )

                         

                         

                        the last case ( the default one ) isn't needed and the calc can have a boolean result simply with:

                         

                        IsEmpty ( Field1 )
                        or
                        IsEmpty ( Field2 )
                        or
                        IsEmpty ( Field3 )
                        or
                        IsEmpty ( Field4 )
                        or
                        IsEmpty ( Field5 )





                        • 9. Re: Script Parameter Function
                          Orlando
                            

                          Hi ttumbles, glad you found a solution, I did read it the wrong way.

                           

                          raybaudi, thanks for the comments regarding the Case statement, you are correct about the final line, the default value, this line is not needed if the default is blank, just a habit of mine to add that in.

                           

                          And in terms of your alternative for simply returning a boolean result, you calculation is perfectly valid and the end results is the same, but personally I would use the Case function as it will stop evaluating when a test returns true, where as your approach will have to evaluate every field in the calculation. 

                          • 10. Re: Script Parameter Function
                            raybaudi
                              

                            Hi Orlando


                            "but personally I would use the Case function as it will stop evaluating when a test returns true"


                            I thoughts about that but, I'm asking myself, the median value of a Case (  ) function with 5 cases is 3 opposed to the evaluation of 5 ...

                            Is it so quicker ?

                            • 11. Re: Script Parameter Function
                              Orlando
                                 Fair comment Daniele.