Null vs Blank in a string tag

williamlove

Member
Join Date
Jul 2007
Location
phoenix
Posts
59
I'm inquiring about what happens when a VB program writes a null to the value in a string tag in the Logix program called MyString. I am using "null" to mean precisely what it is in a VB program.

Suppose I also have a second tag in my Logix program called BlankString that contains '' (two back to back single quotes which I get when I backspace everything out of the tag in tag monitor). This tag is never touched by the VB program.

My goal is that at specified times the VB programmer will write a blank string to MyString so that the instruction EQU MyString BlankString yields a true.

Is there any difference between the so called null value and a blank string? I have heard that there is, and want to understand it better so I can tell the VB programmer more. Let me ask more specifically, if the VB programmer writes the null value to MyString will that populate the tag with something other than ''?

[I will respectfully ask that you answer only if you are pretty sure about your answer because we already have a lot of educated guesses and discussion.]
 
Well a null character is ASCII 0. Which is just as valid as any other character. An empty string is just that, the absence of any character.

So much for the definition.

So I got curious (at 3 am) and plugged it into VB. Dang! That wasn't what I expected!

For chr(0) (a null character), I got one double quote (not two single quotes). Converting the character to Hex (using Notepad++), I got 22 hex (a double quote on the ASCII table). That was the first surprise.

To be precise, I got just one double quote for a single Null character. This really shouldn't be possible since in the watch window VB always (up until now) used a pair of double quotes to bracket the string. The double quote isn't the data, it's just (half of) the container that VB presents it in.


Then I created a string of nulls, and seemingly regardless of of any string (whose length of nulls is greater than one), I get a single space character (hex 20). That was the other big surprise...

Here's what I ended up with in VB (the string of nulls goes way off into the distance).

In a way, I'm not surprised. Long ago I wrote a program in QB45 that allowed two PCs to swap data. I found out that if I sent an empty string out the port of one machine, I would lock up the receiving machine.

The lesson here was if you don't have something to say, then don't say it. Especially to a serial port in QB45. :)

NullString.jpg
 
Last edited:
Null and a blank string are two completely different things.
Setting an object (such as a VB string) to null means to set its pointer in memory to nothing. It is not the same as setting its value to ''.
Your VB programmer should just write '' in your string.
 
I think what driver is used to read/write a ControlLogix tag might affect whether it is a zero length string, a blank string, or a null. And I don't really understand this matter too a great extent.

If you happen to be able to read a ControlLogix tag with your setup, I'd be curious to know what would happen if you did the following:

1. Get online with the PLC.
2. Create a new string tag but don't touch it in tag monitor, leave it undisturbed and unused.
3. Read the contents of that tag from VB and note the result.
4. Get back online, put some value in the string tag. Hit the apply button. Then backspace until it looks like there's nothing left and the backspace key stops doing anything. Hit apply again (don't close the edit popup without hitting apply).
5. Read the tag from VB again. Do you get the same result as step 3?.

Thank you.
 

Similar Topics

Hi I need to send a null command down a comms port. But in the crimson software when i used /x00 it coming back "Cannot use null character is...
Replies
2
Views
420
So I'm trying to make a tag I created in WonderWare Historian display the correct tag values on the inTouch client but it is currently showing...
Replies
12
Views
1,543
I have to reprogamme a Prosoft MVI56MCMR and I cant find my programming lead. Would anyone have the pin out please.. as I can't find the details...
Replies
3
Views
2,202
I'm a fairly experienced DDE user, and use Excel spreadsheets to manage recipe variables on my machines. I have no problems reading an empty...
Replies
7
Views
3,237
Hi, I've been working on a project for a couple of weeks now using Studio 5000 Logix Designer (v31 project, also have v32 and v21 installed)...
Replies
0
Views
2,203
Back
Top Bottom