I’ve got a problem with string handling, and I’ve got most of it figured out except for one little part. I went over this with Bobby earlier and I checked out a few things. Thanks again Bobby!
This is what I’m doing: I have a table with a varchar(100) field. I wrote a socket program that grabs udp messages and writes them to this table. My messages are 44 bytes long, and I verified that all 44 bytes are making it to the table by querying the column with “SELECT len(Message) FROM Messages WHERE MessageID = 1”.
The problem is that the string will often contain null characters in the middle, and for some reason fpmi truncates the string at the first null. This is what I have in my project:
There is a dynamic property called “Message” of type string. I bind it to a query with “SELECT Message FROM Messages WHERE Message ID = 1”.
I have another dynamic property called “MessageLength”. I bind it to another query as above, “SELECT len(Message) FROM Messages WHERE Message ID = 1”.
In the component, I have a property change event set up to run some script whenever the content of the message changes:
if event.propertyName == 'Message': Message = event.source.Message print len(Message)
But, when I bind the message to the dynamic property “Message”, it is truncated at ten bytes (the 11th byte is null). But I know the table data is correct, because the other dynamic property “MessageLength” shows 44. And although the string is jibberish, I can see that there are many more than 10 characters in the field.
Bobby had me look at prepared statements for the insert, but since then I’ve verified that the data is making it to the table correctly with my exisiting code. I just need to get it back out into the fpmi environment. I’ve dealt with this when reading files in Python by using the ‘rb’ parameter, but don’t know if there is something I can do in my query to emulate that. I thought of using the varbinary type, but didn’t know how to bind that to any of the fpmi data types.
I hope this makes sense, and I’m probably missing something obvious. Any ideas?