Jump to content
Developer Wiki and Function Reference Links ×

escaping quotes for record format criteria


Recommended Posts

I'm really struggling with escaping quotes properly. I want to perform some actions on symbols that have a certain record format field, but I cannot seem to get the criteria to work using ForEachObject.

 

Im using selCriteria:=concat('CPA Products'.'Serial'=,RF1) as the criteria where selCriteria is the selection criteria and RF1 is a string variable for the record format field contents. Because of all the record format quotes, I cannot seem to get it to work no matter how I try to escape them. Any help would be appreciated.

Link to comment

Or my favorite, CHR(39) 😉

 

CHR(39) puts in ascii character which is the single quote.  So my version would look something like:

 

selCriteria:=Concat(CHR(39),'CPA Products',CHR(39)'.',CHR(39),'Serial',CHR(39),'=',RF1);

 

I just use CHR(39) where quotes are actually needed in the final string.

 

To debug, I use AlrtDialog(selCriteria); to see what is actually being produced.

 

double and triple single quotes are great after you get them working correctly, but they are such a pain to try and read and differentiate. CHR(39) is typing a little more, but you then know exactly what you are doing at a glance.

  • Like 1
Link to comment

Per Pat's suggestion of using chr(39), you can make a "const" declaration of "k39"= chr(39)" which makes is example a tiny bit easier to implement;

 

CONST

    k39 = chr(39)

 

VAR

    asdfasdf

 

BEGIN

    selCriteria:=Concat(k39, 'CPA Products', k39, '.', k39, 'Serial', k39, '=', RF1);

END;

 

Suggestion: spaces after commas have no effect but make the function parameters easier to read.  Pat is missing a comma after the second CHR(39).  That happens to me all the time setting up criteria strings.

  • Like 1
Link to comment

Thanks for the extra hint Sam. You could even set the Const to be something like a capital Q so it is not even any extra characters to type.

 

Julian, now that you mention it, that sounds vaguely familiar to me also. A quick search didn't turn up anything in my archives either though. I will keep looking. I want to say that perhaps is was not done in VS, but rather though BBEdit or something else?

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...