Anytime Help Center

Using Quote Characters within a NetLinx String Expression

Rating


The NetLinx language has a defined format for strings to be used in variables and in commands such as FIND_STRING, SEND_STRING, etc. The format consists of double quotes to enclose the full string, with comma-separated constants or variables within. ASCII string elements are delimited by single quotes. Thus, StrExp = "'The result is: ',ITOA(nSum),$0D" is a valid expression.

However, there are times where the string you wish to look for or create contains single or double quote characters within the text itself. In order to include these characters and keep NetLinx happy, you will need to use the equivalent byte values for the quote characters within your expression. The byte value for a double quote is $22 (or decimal 34), and the single quote is $27 (decimal 39). You can thus build your expression as below:

DEFINE_VARIABLE

CHAR Q = $22

INTEGER nPreset

CHAR sName[20]

CHAR sOut[30]

DEFINE_START

// Build a device command containing double quotes:

nPreset = 5

sName = 'Banquet'

sOut = "'Set Preset: ',ITOA(nPreset),' Name: ',Q,sName,Q,$0D"

// send sample to Diagnostics

send_string 0,"sOut"

// Resulting output:

Set Preset: 5 Name: "Banquet"$0D


Important note: beware of copy/paste from word processing or email programs which may substitute in “smart quotes” which can really confuse your string expressions!




Downloads

Product

 

Topic

Programming

Related Articles

Last modified at 6/11/2021 4:38 PM by PRO Knowledge Base
Top