Author Topic: Single Character strings  (Read 1300 times)

sds5150

  • Newbie
  • *
  • Posts: 14
    • View Profile
Single Character strings
« on: February 07, 2020, 04:45:12 PM »
We have a PLC tag that is defined as a String1 which has a max character of 1

How do I write to this tag?
When I try to do a
Write(String.Format("Q3_Pan[0].Part.Type.Code", "x")

I get the following error
MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException: 'Unknown data type. Unable to create byte stream. 50345'


Thanks

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Single Character strings
« Reply #1 on: February 07, 2020, 06:49:48 PM »
Your code is missing a bracket and seems to be incorrect format all together.

Have you tried Write("Q3_Pan[0].Part.Type.Code", "x")?

See also what response you will get if you try using:

WriteCustomString(ByVal tagName As String, ByVal value As String, definedStringLength As Integer)

which in your case would be:

WriteCustomString("Q3_Pan[0].Part.Type.Code", "x", 1)

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Single Character strings
« Reply #2 on: February 07, 2020, 08:08:54 PM »
I just tested this and you have to use the WriteCustomString in the code.

As for the visual control, the attached modified version of the BasicLabel will allow you to read the String1 data type, as well as to write to it.
This will work for as long as you enable its InterpretValueAsCLXString property, set the correct length in the CustomCLXStringLength property and add your tag to both PLCAddressValue and PLCAddressKeypadCollection properties.
« Last Edit: January 14, 2021, 10:07:08 PM by Godra »

sds5150

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Single Character strings
« Reply #3 on: February 11, 2020, 10:54:23 AM »
That helped!
Thanks!