02-25-2020 08:12 AM
@LeeBowers1 wrote:
Yea, the device manufacturer are telling me it has to be floating point. If i manually manipulate the resulting string from the function the device responds correctly.
Not sure where to go from here now
Hmm. "22" can be a floating point, it just doesn't have any decimals.
Either manipulate the string, or use a library that does allow you to specify this. Perhaps someone can point one out.
For the manipulation, we can help if you tell us what to change. All numbers? Specific numbers? Numbers in arrays? Etc..
This adds ".0" to all integers labeled "a":
02-25-2020 08:33 AM
I have attached my code.
If i send the string, at the bottom of case 2, the device works as it should. Else it sends 22 and the device doesnt respond. if i send 22.1, for example, i then get 22.11111115566 - it gives me loads of digits after the dp.
I appreciate your help on this matter, thank you
02-25-2020 08:43 AM
your little snippet of code This adds ".0" to all integers labeled "a": would work but i tried to copy the function but it isnt working. do you have the actual vi please you can send.
Thank you
02-25-2020 08:44 AM
If I set it to 22.1, I get ":22.100000000000001421". Both are right, 22.1 probably can't be represented as exactly 22.1, because of the limited resolution of the float...
Does the device accept these "long floats"? Or is it really picky? Must it be exactly 1 decimal?
I'm sure we can make a reg.ex. to fix this as well, if it's required.
02-25-2020 08:47 AM
@LeeBowers1 wrote:
your little snippet of code This adds ".0" to all integers labeled "a": would work but i tried to copy the function but it isnt working. do you have the actual vi please you can send.
Thank you
The forum messes up those images, by shrinking the size. You can get a valid snippet from the link, but it's tricky.
02-25-2020 08:49 AM
sorry forgot to mention, im on version 17
02-25-2020 09:15 AM
Recreating it would probably have been faster (just remember to set the Search and Replace String to reg.ex.).
The snippet wouldn't work for LV17,even if you got a proper download.
02-25-2020 09:19 AM
Recently, I've been using the JSONText add-on as it accepts a JSON path expression (with a few limitations in the current release) to extract individual/multiple items from the JSON text string, in addition to the previously discussed example of wiring a cluster to define the datatype for the entire JSON string. It's available for LabVIEW 2017+ on the VI Package Manager.
Here's a link if you don't have the VI Package Manager. http://sine.ni.com/nips/cds/view/p/lang/en/nid/216651
If you're unfamiliar with JSON paths, this online tool is quite helpful https://jsonpath.com/
02-25-2020 09:28 AM
reg .ex - regular expression ........ found it WOW ok - working a treat - Thank you isn't enough but thank you.
02-25-2020 09:28 AM - edited 02-25-2020 09:30 AM
@pjroland1121 wrote:
Recently, I've been using the JSONText add-on as it accepts a JSON path expression (with a few limitations in the current release) to extract individual/multiple items from the JSON text string, in addition to the previously discussed example of wiring a cluster to define the datatype for the entire JSON string. It's available for LabVIEW 2017+ on the VI Package Manager.
Big question is if it allows you to specify the nr. of decimal points...