LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in Method String Class - Byte Offset from Point

Solved!
Go to solution

Hello everyone, I've encountered an issue with the 'Byte Offset from Point' method in LabVIEW. It seems to work fine when applied to a string directly, but when the string is within a cluster, the method doesn't function properly. Has anyone else experienced this issue, and if so, do you have any suggestions for resolving it? Thank you!

I have attached a simple code for demonstration.

0 Kudos
Message 1 of 15
(367 Views)

My code as png:

0 Kudos
Message 2 of 15
(362 Views)

Hi Max,

 

I see the same behaviour in LV2019:

The byte offset is shown correctly for a string control on the front panel, but not when I move the string control into a cluster.

With string inside cluster I always get a result of "19" (aka string length)…

Best regards,
GerdW


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

Thank you for your response.
Do you have any idea how to do it another way...?

0 Kudos
Message 4 of 15
(309 Views)

I don't really have practical experience with this method, and the help for it doesn't specify what the coordinates actually are, but it looks like the coordinates are relative to the owning object (usually the pane, in this case the cluster). If you take the coords from the mouse event (which are in pane coords, I believe) and subtract the Position property of the owner, you can feed that into the method to get the correct offset.

 

Note that this is complicated by the existence of things like the label/caption/border/etc. which are included in the Position property. You can use the Master Bounds Rect property, but that's defined as a scripting method, so you would need to enable scripting to access it.


___________________
Try to take over the world!
0 Kudos
Message 5 of 15
(275 Views)

I have a Mouse Down Event configured on a string control that resides within a cluster. When the mouse is clicked within the string control, I need to determine the byte offset of the clicked position within the string.

To achieve this, I'm using the 'Byte Offset from Point' method in LabVIEW, passing the coordinates provided by the Mouse Down Event as the point argument. However, I've noticed that this method works perfectly when the string control is not within a cluster. But when the string is inside a cluster, the method fails to provide the correct byte offset.

Does anyone have any insights into why the 'Byte Offset from Point' method might behave differently when applied to a string within a cluster? Any suggestions or alternative approaches would be greatly appreciated.

Thank you for your help!"

 

maxnoder1995_0-1713963086950.png

 

0 Kudos
Message 6 of 15
(264 Views)

I have a Mouse Down Event configured on a string control that resides within a cluster. When the mouse is clicked within the string control, I need to determine the byte offset of the clicked position within the string.

I have to do it without  'Byte Offset from Point' method.

that my code but I don't know what I'm missing... I think it's the initial position given to Get Text Rect.vi.

maxnoder1995_1-1713966019103.png

 

 

0 Kudos
Message 7 of 15
(266 Views)

Hi Max,

 


@maxnoder1995 wrote:

that my code but I don't know what I'm missing... I think it's the initial position given to Get Text Rect.vi.


That is no code, it's an image of code.

We cannot edit/run/debug images with LabVIEW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 15
(246 Views)
Solution
Accepted by topic author maxnoder1995

@maxnoder1995 wrote:

I have a Mouse Down Event configured on a string control that resides within a cluster. When the mouse is clicked within the string control, I need to determine the byte offset of the clicked position within the string.

I have to do it without  'Byte Offset from Point' method.

that my code but I don't know what I'm missing... I think it's the initial position given to Get Text Rect.vi.

 


This small snippet should give an idea how to achieve this. Its not ideal, needs to be "fine tuned" for the clicks exactly between the chars (currently may give wrong answer), but I hope overall idea should be clear more or less.

ByteOffset.png

0 Kudos
Message 9 of 15
(218 Views)

Wow!! Thank you very much.
Use "Text.Positon" instead of "Position" to be precise.
If my text is justifed to the right, do you think it will be a problem to make it work?

0 Kudos
Message 10 of 15
(198 Views)