LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String Constant Double Quotes

Hello,

I am using TCP communication to communicate between LabVIEW code which I have written, and other software. I am using the pair TCP Write and TCP Read to send a string (which functions as a command) to the other software in CRLF mode, 100 bytes at a time. I am using a string constant to set the string. The other software sometimes requires the commands to be within double quotation marks, so do I need to include those in the string constant, or by virtue of being a string constant will the double quotes be included when sent via TCP communication?

 

Thanks in advance!

 

TLDR; Does string constant have quotation marks surrounding it?

0 Kudos
Message 1 of 5
(1,958 Views)

If you want quotation marks (single or double) inside the string, you must write them yourself.

 

LabVIEW doesn't add quotation marks.

 

Text based languages often use (double) quotes to delimit the beginning/end of a string constant, but in LabVIEW that's unnecessary since it is graphically contained in the box 🙂 


GCentral
0 Kudos
Message 2 of 5
(1,954 Views)

Hi sun5et,

 


@sun5et wrote:

do I need to include those in the string constant,


Yes.

 


@sun5et wrote:

TLDR; Does string constant have quotation marks surrounding it?


In LabVIEW you get what you see! When the string value does not contain any quotation marks, then there are no quotation marks…

 

In other programming languages this is the same: even when you define a string using quotation marks (like "this is a string") those quotation marks are not content of the string, they just define that string for the compiler.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 5
(1,951 Views)

@cbutcher wrote:

Text based languages often use (double) quotes to delimit the beginning/end of a string constant.


And if you want double quotes (an/or quotes in such a string you have to add them too but since that character is already used as a syntax element you need to escape it. Depending on the language you have to double that character to mean a literal character or prepend an escape character such as a backslash. There is no standard programming language which automagically knows that your specific device needs quotes around specific elements in the command string.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 5
(1,947 Views)

I'll give the OP some slack on this one. Probing a String wire does indeed show the data in quotes in the table to the left. It's "raw" in the "probe display" area, so I can see why it might be confusing and why someone might think it's using quotes "under the hood" somehow:

 

BertMcMahan_0-1657825585106.png

 

So yes, echoing what others have said- there are no automatic quotation marks in LabVIEW. Whatever you type in the box is what's sent. The probe window has quotes to delineate where the string starts and stops. It's more useful if there are lots of spaces. For example, adding five spaces before and five after:

 

BertMcMahan_1-1657825674592.png

If it were me I'd probably not have any quotes there but I can understand why they did it this way.

0 Kudos
Message 5 of 5
(1,925 Views)