July 27, 201312 yr How would I find the position of a quotation mark in a bit of text? This calculation always returns zero, even if $text contains a quotation mark. Position ( $text; """ ; 1; 1)
July 27, 201312 yr How would I find the position of a quotation mark in a bit of text? This calculation always returns zero, even if $text contains a quotation mark. Position ( $text; """ ; 1; 1) It should work for you, Matthew. By chance is it smart quotes in the text instead of regular quotes? Another possibility - $text is a local variable. How are you using it?
July 27, 201312 yr Author Yes, $text is a local variable. Does that matter? How can I get around that?
July 27, 201312 yr Author The local variable is in a script. It contains text to be parsed, and so I'd like to know the position of quotation marks.
July 27, 201312 yr Author In case this helps.... My overall objective is to merge template text with data stored in filemaker fields (sort of like a mail merge). My template text contains some conditional statements that my script evaluates... similar to an IF(test; result1; result2) statement. To parse out result1 and result2, I need to know whether the semi-colons are contained within or without quotes. If they're within quotes then it will evaluate as text. If they are not quoted then the semicolon will serve as the delimiter between result1 and result2 (just like an ordinary Filemaker IF() function).... Sorry if that's too much information.
July 27, 201312 yr No need to change anything. Your expression is correct as is. Example: Let( $text = "word1" & Quote( "quoteme" ) & "word2"; List( $text; Position( $text; """; 1;1))) Result: word1"quoteme"word2 6
July 27, 201312 yr Author OK. I think my solution was adding curly quotes. I couldn't really tell with the my font. I guess that will take care of it.
July 27, 201312 yr Don't forget about the code and char functions. Char(8220) is the left double curly quote and char(8221) is the right double curly quote.
July 29, 201312 yr Author Thanks for the tips, both of you. The curly quotes definitely threw me off, and I also didn't know about the Char() function. It turns out I was making things too difficult (as is often the case). The simpler approach is to pass tagged text to the Evaluate() function, and let filemaker parse out the quote marks and semicolons. (Apparently 'Evaluate()' doesn't care about curly vs. straight quotes). I'm letting users create their own text templates, which they can then merge with data fields. For example, text is entered into the 'template' field looking something like this (with additional data fields 'Gender' and 'LastName'). Dear << IF (Gender = "male"; "Mr."; "Ms.") >> <<LastName>>, My script simply passes everything between the tags << >> to the Evaluate() function and then substitutes the result in place of the tagged text.
July 29, 201312 yr My prediction is that a near-future version of FileMaker ( the next version?) will allow us to use the calculation directly on layouts, just like we can now insert Get ( flag ) functions. You can sort of already do this using a self-defining conditionally formatted merge variable, but there are some refreshing and multi-window issues.
July 30, 201312 yr Author David, Use of calculations on layouts would be an interesting feature. For my purpose though, I want the user to be able to create their own merge templates, without having to go into layout mode or be given admin privileges to the database.
July 30, 201312 yr You know you don't need a script, you can use a calculation field. Whatever logic your script is using, you can put into a custom function ( for ease of updating ). You have your Merge Template field and your Merge Result calculation (or auto-enter calc).
Create an account or sign in to comment