4 Replies Latest reply on Sep 28, 2012 1:39 PM by philmodjunk

    Proper Scripting

    Kirk_1

      Title

      Proper Scripting

      Post

           This script does not evaluate. Can you see why?

           I don't know if i can seperate the 497, 798 and 499 that way...

            

           Set Varalbe $min; value:Case (
                         Left ( $dzip ;3 )  or Left ( $ozip ;3 )  = 497; 498; 499 ; Fontier_Mars::BR_04 =  $marsMin1 )

        • 1. Re: Proper Scripting
          philmodjunk

               You cannot.

               Use:

               Set Varaible $min; value:Let ( L3 = GetAsNumber ( Left ( $ozip ; 3 ) ;
                                                          Case ( L3  > 497 and L3 < 499 ; Fontier_Mars::BR_04 =  $marsMin1 )
                                                         )

               I eliminated Left ( $dzip ;3 )  or as it does not make any sense in this calculation.

          • 2. Re: Proper Scripting
            philmodjunk

                 Hmmm, I doubt that Fontier_Mars::BR_04 =  $marsMin1 is correct syntax here as that will return either 1 (True) or 0 (False) depending on whether the value in Fontier_Mars::BR_04 equals the value in $marsMin1.

                 I suspect that you reallly want:

                 Set Varaible $min; value:Let ( L3 = GetAsNumber ( Left ( $ozip ; 3 ) ;
                                                            Case ( L3  > 497 and L3 < 499 ; $marsMin1 )
                                                           )

            • 3. Re: Proper Scripting
              Kirk_1

                   A new issue in proper scripting...

                   If $weight = 127 why does the script below evaluate to 0?

                   Its a set field... for a found set... it should put L5C in the field Fontier_Mars::AE_04

                   I did one additional test... if i changed $weight to 1270 i still get a 0. Why?

                   Let ( w = $weight ;

                   Case ( w < 500 ; Fontier_Mars::AE_04 = "L5C" ;
                              w < 1000 ; Fontier_Mars::AE_04 = 500 ;
                              w < 2000 ; Fontier_Mars::AE_04 = 1000 ;
                              w < 5000 ; Fontier_Mars::AE_04 = 2000 ;
                              w < 10000 ; Fontier_Mars::AE_04 = 5000  ;
                              w < 20000 ; Fontier_Mars::AE_04 = 10000
                   )

              • 4. Re: Proper Scripting
                philmodjunk

                     See my response to your other "proper scripting" post where you have the same issue in a different calculation. This is a fairly common mistake with new FileMaker Developers.

                     Here's a Rule to help you keep it straight.

                     In every calculation expression in FileMaker, the = sign is used to compare values to see if they are equal, producing a result of True or False. And True will be the number 1, False the number 0.

                     The ONLY exception to that is when = is used in the first part of a Let function:

                     Let ( A = 5 + 3 ; A * 5 )

                     Returns the value 40.

                     Let ( $A = 5 ; 1 )

                     Returns the value 1, but creates a variable named $A and stores the value 5 in it.

                     Other than the let function--which can be slipped into all kinds of calculated expressions, the set, insert, paste script steps are what you use to change the value of a field or variable.