12-07-2008 12:42 PM
t06afre wrote:This weekend I picked up this golden nugget from the Labview forum.
Ouch! I somehow missed that. No wonder I stayed out of that thread. 😄
I would guess we have about 98.5% too much code.
I would guess a single small toplevel VI state machine some logic, and the four picture VIs are all that's really needed.
It does not really take any brains to disassembe this monstrosity, just a gigantic monitor, paper and pencil and a huge amount of free time, which I unfortunately don't have.
It would be much cheaper to get the detailed specs and code it from scratch. 😄 Shouldn't take more that 10 minutes.
12-08-2008 01:57 PM - edited 12-08-2008 01:58 PM
The "referenceophils" way of programming:
Here's how we simulate latch action booleans, e.g. "quit" (but there are many more).
12-11-2008 07:45 AM

12-17-2008 05:12 AM
To retrieve an I16 from a 4 chars string received on a serial port, you can convert the string to an U8 array, chop off the last two elements, index explicitely the two remaining elements, convert each one to I16s, shift-left the first one and logical-or-e the result with the second.
Or you could typecast the string...

12-17-2008 05:48 AM
I love the cast function and i use it a lot. But has not your solution a smal flaw. 4 chars is 32 bytes or 2 I16. So the type input (in the type cast function) should have been connected to an array. Your solution will only convert the 2 first bytes to an I16. But this person needed the 2 last char converted to a number. ![]()

12-17-2008 05:59 AM - edited 12-17-2008 05:59 AM
Correct. You need to cast to a cluster of 2 i16, and select the second one. A bit more complicated, but still much easier than the original code.
Shane.
12-17-2008 12:14 PM - edited 12-17-2008 12:15 PM
Intaris wrote:Correct. You need to cast to a cluster of 2 i16, and select the second one. A bit more complicated, but still much easier than the original code.
Assuming we are not interested in the first two bytes at all and we know we only get four bytes in the string, we only need to convert the correct string subset as follows.

12-17-2008 10:17 PM - edited 12-17-2008 10:23 PM
Seems that you all missed the same point : the guy was just interest by the two first bytes (the last ones were CR LF)... 🙂
In the original solution, remove elements was completely useless...
12-17-2008 11:50 PM
12-18-2008 10:28 AM