09-18-2014 04:39 PM
@altenbach wrote:
Try to simplify this while loop 😄 😮
(It is important to know that the "array" indicator gets reset to default upstream somewhere in an earlier frame of a long flat sequence.)
I'll take that as "Maintain the Values and size of array as is"
Who needs a loop?
09-19-2014 01:24 AM - edited 09-19-2014 01:27 AM
@JÞB wrote:
I'll take that as "Maintain the Values and size of array as is"
Who needs a loop?
I didn't check the code, but I expect your version is actually incorrect (Jeff, you shouldn't be failing these classic CLAD questions ).
I think a simpler option is (array size+2) into a for loop and simply output the i as auto indexing, which I expect would perform better than your code, because there are fewer operations.
Now, whether those two extra elements are actually desirable or there from lack of understanding is another matter.
09-19-2014 06:20 AM
I would just use the Ramp function...
09-19-2014 09:09 AM
09-19-2014 09:14 AM
09-19-2014 09:47 AM
@JÞB wrote:
oh ye of little faith. you missed that the wire out of riffle via is an index
I think Yair's point was that the original RG code actually creates an output array that is two sizes too large. The loop only stops after [i] > N. Of course this is incorrect for the application where it was originally used, but in order to make your code equivalent, you need to add two elements. 😉
09-19-2014 10:07 AM
@altenbach wrote:
@JÞB wrote:
oh ye of little faith. you missed that the wire out of riffle via is an indexI think Yair's point was that the original RG code actually creates an output array that is two sizes too large. The loop only stops after [i] > N. Of course this is incorrect for the application where it was originally used, but in order to make your code equivalent, you need to add two elements. 😉
Yup, I totally overlooked the silly logic and wired that as a "less than" in my head
09-22-2014 12:18 PM - edited 09-22-2014 12:18 PM
I found this gem in some old company code today. Because using Typedefs and enums is too easy. Oh and shift registers.
The best part is that's barely even scratching the surface of what's wrong with this code.
09-22-2014 12:26 PM - edited 09-22-2014 12:26 PM
Well at least they knew they could use the scan from string to perform the string to enum conversion. I've seen many developers not know that...but yeah they should know that you can have an enum constant. Oh but I bet that the compiler is smart and does constant folding to replace the string constant with an enum constant...not that it makes it any better.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-24-2014 08:50 AM - edited 09-24-2014 08:52 AM
I like it!!
Although I would go so far as to suggest that this would not necessarily be a Rube every time. If you have 2 enums, one of which is applicable to this VI, and one of which is applicable to the whole project (or multiple projects) then the values in the eunms might not be the same even though you can guarantee 2 cases the same.
as I said, I like it... in the right circumstances it has its place! (probably just not where you found it!
James
<edit> (by it I mean the method of converting an enum via a string back into an enum!)