Justin Goeres Posted September 13, 2007 Report Share Posted September 13, 2007 Our local users' group last night had a presentation based on the Tips and Tricks to Speed LabVIEW Development session from NIWeek. Since I missed that one at the conference, I went. On one of the slides, there was a new (to me) tip that wasn't part of the presentation. You can use the N terminal of an auto-indexing For Loop as a proxy to the size of the (smallest) incoming array. All these years, I've been manually calculating the Array Size outside the loop! Of course, it's obvious now that I've seen it. Am I the last person in the world to learn this? EDIT: This was supposed to go in the LabVIEW (General) forum, but in my excitement I posted it in the wrong place. Quote Link to comment
Chris Davis Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Justin Goeres @ Sep 12 2007, 08:17 AM) Am I the last person in the world to learn this? No, you're not the last person in the world to learn this. I am. Thanks for sharing the information, I didn't get to attend that session at NIWeek either. Quote Link to comment
Justin Goeres Posted September 13, 2007 Author Report Share Posted September 13, 2007 I just realized that calling that indicator "% complete" in the example code was an absolutely braindead choice... :headbang: Quote Link to comment
Aristos Queue Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Justin Goeres @ Sep 12 2007, 08:17 AM) Of course, it's obvious now that I've seen it. Am I the last person in the world to learn this? You may have just learned this, but it could be worse. I've actually received a product suggestion that said "LabVIEW should have a better way to calculate the size of an array". The method used in the attached VI would make your diagram look something like this: http://lavag.org/old_files/monthly_09_2007/post-5877-1189607671.png' target="_blank"> So you're doing fine.... ;-) Quote Link to comment
Grampa_of_Oliva_n_Eden Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Justin Goeres @ Sep 12 2007, 09:17 AM) ...Of course, it's obvious now that I've seen it. Am I the last person in the world to learn this? ... I reacted the same way when I saw someone wire an enum to a format into string. I thought it was great but everyone else said "You didn't know that?" I think this is not our short-coming but rather due to the sparse upgrade notes. I religeously read every one of these cover to cover and still I miss stuff. WE really need EXHAUSTIVE upgrade notes! Ben Quote Link to comment
Aristos Queue Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Ben @ Sep 12 2007, 09:40 AM) WE really need EXHAUSTIVE upgrade notes! I don't think that would've helped for your enum example nor Justin's wire-the-N. Those have been in LabVIEW for a long long time. Quote Link to comment
crelf Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Aristos Queue @ Sep 13 2007, 12:32 AM) I've actually received a product suggestion that said "LabVIEW should have a better way to calculate the size of an array". There's a better way? Quote Link to comment
ragglefrock Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(crelf @ Sep 12 2007, 10:06 AM) There's a better way? I prefer this method of getting an array's size. Quote Link to comment
David Boyd Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(ragglefrock @ Sep 12 2007, 11:23 AM) I prefer this method of getting an array's size.Oooh, now that's so "clever" it's downright scary. I would have NEVER thunka' that as an alternative. Dave Quote Link to comment
jaegen Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(crelf @ Sep 12 2007, 08:06 AM) There's a better way? I think AQ's "friend" didn't realize there was an "Array Size" function built into LV, and was calculating them him/herself with the method shown. Jaegen Quote Link to comment
crelf Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(jaegen @ Sep 13 2007, 02:13 AM) I think AQ's "friend" didn't realize there was an "Array Size" function built into LV, and was calculating them him/herself with the method shown. I was kidding Quote Link to comment
Grampa_of_Oliva_n_Eden Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(jaegen @ Sep 12 2007, 12:13 PM) I think AQ's "friend" didn't realize there was an "Array Size" function built into LV, and was calculating them him/herself with the method shown.Jaegen It could be worse! The customer could have sumbitted the following code to find array size. http://lavag.org/old_files/monthly_09_2007/post-29-1189618192.png' target="_blank"> Yep, it rediculous. Yes, I wrote it. Ben Quote Link to comment
crelf Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Ben @ Sep 13 2007, 03:30 AM) It could be worse! The customer could have sumbitted the following code to find array size. What the? Can you talk us through it? Quote Link to comment
Ton Plomp Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(crelf @ Sep 12 2007, 07:43 PM) What the? Can you talk us through it? Well that's what the http://forums.ni.com/ni/board/message?board.id=170&message.id=267659&page=1&view=by_date_ascending' target="_blank">NI forums is for in dept problem generation instead of solving Ton Quote Link to comment
lavezza Posted September 13, 2007 Report Share Posted September 13, 2007 This all reminds me of some code a hardware vendor supplied us many years ago. I've reproduced the style below. Creative(?!) use of the N terminal. Quote Link to comment
Thang Nguyen Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Ben @ Sep 12 2007, 09:40 AM) I reacted the same way when I saw someone wire an enum to a format into string. @Ben: Could you tell me what is the format into string VI? I don't know about this . I have to you the property strings[] and array indicator to get the string of an enum. @All: You guys are experts in LabVIEW, so if you have time, it's really helpful if you can list down these tricks in VI. I really want to learn more about these stuffs. It's hot :thumbup: . Thang Nguyen Quote Link to comment
Justin Goeres Posted September 13, 2007 Author Report Share Posted September 13, 2007 QUOTE(crelf @ Sep 12 2007, 08:06 AM) There's a better way? This gives me an idea for kind of a cool thing to do. Not a Coding Challenge exactly, but more like a Cleverness Festival! :beer: We could pick an interesting trivial problem (Array Size is a really good one) and challenge LAVA members to find original (not optimal) ways to solve it. We could constrain it with a few simple rules like Must not use any subVIs except those provided in vi.lib or OpenG. All code must fit in a block diagram window of a certain size (and no stacked sequences!) All code must obey basic LabVIEW style conventions or whatever. I'm just brainstorming here. Might be fun to see what's lurking in the corners of our brains. Quote Link to comment
crelf Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(lavezza @ Sep 13 2007, 04:28 AM) This all reminds me of some code a hardware vendor supplied us many years ago. I've reproduced the style below. I feel dirty (and not in a good way). QUOTE(Justin Goeres @ Sep 13 2007, 04:40 AM) a Cleverness Festival! That sounds awesome! Quote Link to comment
Justin Goeres Posted September 13, 2007 Author Report Share Posted September 13, 2007 QUOTE(Thang Nguyen @ Sep 12 2007, 11:31 AM) @Ben: Could you tell me what is the format into string VI? I don't know about this . I have to you the property strings[] and array indicator to get the string of an enum. Welcome to The Cool Kids' Club: http://lavag.org/old_files/monthly_09_2007/post-2992-1189622895.png' target="_blank"> Format Into String is in your String palette. BTW, there's a more versatile Get Strings from Enum function in the OpenG Data Tools library. It takes a variant as input, so you're not limited to using it with just one enum. Quote Link to comment
Ton Plomp Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Justin Goeres @ Sep 12 2007, 08:40 PM) This gives me an idea for kind of a cool thing to do. Not a Coding Challenge exactly, but more like a Cleverness Festival! :beer: We could pick an interesting trivial problem (Array Size is a really good one) and challenge LAVA members to find original (not optimal) ways to solve it. We could constrain it with a few simple rules like Must not use any subVIs except those provided in vi.lib or OpenG. All code must fit in a block diagram window of a certain size (and no stacked sequences!) All code must obey basic LabVIEW style conventions. It's an exercise in creativity, not obfuscation. or whatever. I'm just brainstorming here. Might be fun to see what's lurking in the corners of our brains. QUOTE(crelf @ Sep 12 2007, 08:42 PM) That sounds awesome! Well to get started (this are the easy ones) Note: the second method only goes for brown cluster arrays or numerics (eg static length per element) Ton Quote Link to comment
Grampa_of_Oliva_n_Eden Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(tcplomp @ Sep 12 2007, 03:17 PM) Well to get started (this are the easy ones) Ton RE: My array size example "If you want people to respond, say something rediculous." (Ben) The Interesting Stuff thread that Yen started on NI has lot of links to LV trivia. For obfuse code see the thread that Christian started. It has examples that range from the simple to the subtle. Ben Quote Link to comment
jpdrolet Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Justin Goeres @ Sep 12 2007, 02:49 PM) Welcome to The Cool Kids' Club: Format Into String is in your String palette. BTW, there's a more versatile Get Strings from Enum function in the OpenG Data Tools library. It takes a variant as input, so you're not limited to using it with just one enum. I think an even lesser known trivia is to use Scan from String to read an enum string Quote Link to comment
eaolson Posted September 13, 2007 Report Share Posted September 13, 2007 QUOTE(Justin Goeres @ Sep 12 2007, 08:17 AM) Of course, it's obvious now that I've seen it. Am I the last person in the world to learn this? I believe I can authoritatively say no, you weren't the last. Now, am *I* the last person in the world to learn this? For some reason, I knew you could wire the N terminal inside a For loop, but doing it in the case of an auto-indexed loop never occurred to me. Quote Link to comment
lavezza Posted September 13, 2007 Report Share Posted September 13, 2007 Here's my Array Size. Quote Link to comment
LAVA 1.0 Content Posted September 14, 2007 Report Share Posted September 14, 2007 QUOTE(eaolson @ Sep 12 2007, 04:39 PM) I believe I can authoritatively say no, you weren't the last. Now, am *I* the last person in the world to learn this? Sorry, it's not you, it's me! No wonder I failed the CLD on the first pass. :headbang: Next thing is someone will tell me I can convert an enum to a string with a single function :laugh: (Yes, I know how) I actually learned many of the enum tricks when reading "http://safari.oreilly.com/0130093653' target="_blank">A Software Engineering Approach to LabVIEW" Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.