1 Reply Latest reply on May 21, 2012 1:04 PM by philmodjunk

    writing a function to separate text

    rounakjain

      Title

      writing a function to separate text

      Post

      User enters text "15-200" in a field named "25"

      A custom function must translate this into "25x15-200"

      User enter text "15-200;20-100) in a field named "25"

      This should be translated into "25x15-200;25x20-100"

      User enter text "" in a field named "25" and "15-100" in a field named "20"

      This should be translated into "20x15-100" (i.e. ignore blanks)

      Kindly help me with writing this kind of function.

        • 1. Re: writing a function to separate text
          philmodjunk

          Entering multiple values into the same field is almost always a less than optimum design.

          Nevertheless, if you have FileMaker Advanced, you could create this custom function:

          //InsertFieldName(FieldName ; ValueList )
          //
          //FieldName : Text.
          //ValueList    : Return separated list of values to which FieldName will be appended
          //
          Let ( [vc = ValueCount ( ValueList ) ;
                   p = Position ( FieldName ; "::" ; 1 ; 1 ) ;
                   fn = If ( p ; Right ( Fieldname ; Length ( FieldName ) - p - 1 ) ; FieldName )
                  ] ;
                  Case ( vc = 0 ; "" ;
                            vc = 1 ; fn & "x" & Valuelist ;
                            fn & "x" & GetValue( valueList ; 1) & "; " & InsertFieldName ( fn ; RightValues ( ValueList ; vc - 1) )
                           )  // case
                )  // let

          For the initial call to this function, use one of these options:

          InsertFieldName ( "25" ; Substitute ( YourTable::Field ; ";" ; ¶ ) )

          InsertFieldName ( "YourTable::25" ; Substitute ( YourTable::Field ; ";" ; ¶ ) )

          InsertFieldName ( GetFieldName ( YourTable::YourField) ; Substitute ( YourTable::Field ; ";" ; ¶ ) )

          InsertFieldName ( Get ( ActiveFieldName ) ; Substitute ( YourTable::Field ; ";" ; ¶ ) )