4 Replies Latest reply on Mar 9, 2015 2:03 PM by philmodjunk

    Can Anybody Figure Out Why this Simple CF AddRemove (value; Content) not works

      Title

      Can Anybody Figure Out Why this Simple CF AddRemove (value; Content) not works

      Post

       AddRemove (FromMyData::GlobalValueList ; Data2ADD::simpleValueWords ) •it adds first value word to global. good ok. •it won't add same value word to global. good ok. •when adding a diiferent value word to global it is not as a value — it butts it up against the previous value word in all on string. THANKSnADVANCE yeeck!! rob

        • 1. Re: Can Anybody Figure Out Why this Simple CF AddRemove (value; Content) not works
          philmodjunk

          I suggest that you copy and paste your CF calculation here so that we can see it in order to look it over for possible mistakes.

          (I could make a guess at this point, but given the lack of info here, it would be just a wild shot in the dark...)

          • 2. Re: Can Anybody Figure Out Why this Simple CF AddRemove (value; Content) not works
            /* THANK YOU AddRemove ( value ; content ) Description: This function is a simple tool. It simply adds or removes a value from a return delimited list of values. The area where this is most useful is when working with portals and clicking a portal row to add or remove an ID value from a global field storing a multi-key value. A custom function which allows simple addition or extraction of values from a list. Sample Input:  AddRemove ( 4; "2¶3¶4¶5¶" ) Sample Output: 2 3 5 */ Let ( value_exists = PatternCount ( "¶" & content & "¶" ; "¶" & value & "¶" ); Case ( value_exists; MiddleValues ( Substitute ( "¶" & content ; "¶" & value & "¶" ; "¶" ) ; 2 ; 1000000 );  content & value & "¶")) HOWEVER not working!! As explained previously.
            • 3. Re: Can Anybody Figure Out Why this Simple CF AddRemove (value; Content) not works
               WHY MY POSTS SHOW MY PARAGRAPHS. BUT MY ONLINE POST SHOW THEM WITH ALL SENTENCES RUN TOGETHER, ALL IN ONE PARAGRAPH??
              • 4. Re: Can Anybody Figure Out Why this Simple CF AddRemove (value; Content) not works
                philmodjunk

                Let ( value_exists = PatternCount ( "¶" & content & "¶" ; "¶" & value & "¶" );

                Case ( value_exists; MiddleValues ( Substitute ( "¶" & content ; "¶" & value & "¶" ; "¶" ) ; 2 ; 1000000 );
                           content & value & "¶"
                          ) // case
                       ) // let

                Don't see how what you describe is possible. What I do see is that this function will insert leading and trailing returns not necessarily present in the original list of values. Note that the value returned may look like the returns are missing when viewed in FileMaker Advanced's data viewer.

                I would use:

                Let ( [ value_exists = Not IsEmpty ( FilterValues ( content ; value ) ) ;
                          AddedStr = If ( value_exists ; Substitute ( ¶ & content & ¶ ; ¶ & value & ¶ ; ¶ )
                        ] ;
                       Case ( valueExist ; List ( Content ; value ) ;
                                 Middle ( AddedStr ; 2 ; Length ( AddedStr ) - 2 ) ; // this line strips out the extra returns added earlier
                                ) // case
                       ) // let