Matthew F Posted July 27, 2013 Posted July 27, 2013 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)
LaRetta Posted July 27, 2013 Posted July 27, 2013 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?
Matthew F Posted July 27, 2013 Author Posted July 27, 2013 Yes, $text is a local variable. Does that matter? How can I get around that?
LaRetta Posted July 27, 2013 Posted July 27, 2013 ? How are you using it? You've given no information yet.
Matthew F Posted July 27, 2013 Author Posted July 27, 2013 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.
Matthew F Posted July 27, 2013 Author Posted July 27, 2013 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.
bruceR Posted July 27, 2013 Posted July 27, 2013 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
Matthew F Posted July 27, 2013 Author Posted July 27, 2013 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.
bruceR Posted July 27, 2013 Posted July 27, 2013 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.
Matthew F Posted July 29, 2013 Author Posted July 29, 2013 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.
David Jondreau Posted July 29, 2013 Posted July 29, 2013 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.
Matthew F Posted July 30, 2013 Author Posted July 30, 2013 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.
David Jondreau Posted July 30, 2013 Posted July 30, 2013 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).
Recommended Posts
This topic is 4191 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now