5 Replies Latest reply on Feb 9, 2015 2:50 AM by Benjamin Fehr

    Is it possible to have more that one expression in a variable see below

    Raymond

      var1 is a variable; can we have more than one expression contained in a  variable? If so how do we do it?

      The purpose is to obtain data from the first of field f11 to f13 to input into Street type then street name.

       

      // Street Type

      // Let ( {[} var1 = expression1 {; var2 = expression2...]} ; calculation ) } ;

      Let ( 

        [

        var1  = "Street";   // "Road"; "Drive"; "Place"; "Avenue"; "Lane"; "Close"; "Grove"; "Court"; "Gardens" ;

        txt1 = FMP Line2 Import::f11 ;

        txt2 = FMP Line2 Import::f12 ;

        txt3 = FMP Line2 Import::f13

      ]  ;

       

      Case (

      PatternCount ( txt1 ; var1 ) ; RightWords ( txt1 ; 1) ;

      PatternCount ( txt2 ; var1 ) ; RightWords ( txt2 ; 1)

      )

      )

        • 1. Re: Is it possible to have more that one expression in a variable see below
          Benjamin Fehr

          I doubt you can.

          A trick could be to separate the values with a "pipe" = |

          I use this often for other purposes. There's a useful cf called GetBetween:

          FileMaker Custom Function:getbetween(text, starttext, stoptext,occurrence)

           

          getbetween("the Text", "from", "to", occurrence)

           

          Your var would be like

          var1 = "|Street|Road|Place|…"

           

          The extraction would be

          GetBetween ( var1; "|" ; "|" ; 1 )

          • 2. Re: Is it possible to have more that one expression in a variable see below
            erolst

            Raymond wrote:

            The purpose is to obtain data from the first of field f11 to f13 to input into Street type then street name.

            Try

             

            GetValue (

              List ( FMP Line2 Import::f11 ; FMP Line2 Import::f12 ; FMP Line2 Import::f13 ) ;

              1

            )

             

            to use the data from the first non-empty of these three fields.

             

            Or do you mean: “check if a given string appears in these three fields, and if so, use it”?

             

            Then try

             

            Case (

              PatternCount ( List ( FMP Line2 Import::f11 ; FMP Line2 Import::f12 ; FMP Line2 Import::f13 ) ; var ) ;

              var

            )

             

            where, depending on your data, it may be more safe to use FilterValues().

            • 3. Re: Is it possible to have more that one expression in a variable see below
              keywords

              It's not entirely clear to me what you are trying to achieve, but here are a couple of thoughts that might help you progress:

               

              1.     You could declare a series of variables—var1 = "street"; var2 = "road"; etc—rather than trying to set up a single variable containing the lot, which may be not doable.

               

              2.     If you then want to test whether the text contains one of these predefined variables, use PatternCount ( txt1 ; var1 ) or PatternCount ( txt1 ; var2 ) or PatternCount ( txt1 ; var3 ) … etc

               

              3.     If you are trying to extract the type of carriageway ( street, road, avenue, etc) from your imported text, do you really need to perform this test? Why not, assuming the type is consistently/almost always the right word, simply extract the right word using RightWords.

               

              If you can make your purpose clearer I might be able to come up with something further.

              • 4. Re: Is it possible to have more that one expression in a variable see below
                nicolai

                As other mentioned, using pipes or enclosing items inside xml tags is the most common way to store multiple values in the same variable (assuming,this is what you are trying to do)

                 

                You can also use repetitions on variables to assign multiple values and retrieve them with repeating functions. This looks like:

                 

                Set Variable [$myVar[2]]; Value: "New Value"]

                 

                You can also track variable repetitions in Data Viewer.

                 

                This will work if you keep it simple as support for repeated fields is quite limited.

                • 5. Re: Is it possible to have more that one expression in a variable see below
                  Benjamin Fehr

                  I wasn't aware of RepeatingFunctions in Var.

                  If we get a clou about what you aim to achieve, there might be other ways.

                  If this is about data import, there's plenty of ways to do better than this. "VirtualList" would be first to catch my mind.