07-25-2018 10:40 AM
Hi All,
Can anyone suggest a simple way of selecting a case based on the position of array elements.
E.g - First position in array calls case 1, last position in array calls case 2, everything else case 3.
Thank You
07-25-2018 10:50 AM
This problem is, on the one hand, almost trivial (provided you know some things about the Array, such as its size so you can identify the Last Element), and confusing (is the Array "known in advance", "being generated", "something else"?).
This would be a perfect time for you to have written some code to get yourself started, realized "Oops, I don't know how to ...", attached your code (so we have a clue what you are really trying to do), and then asked for help.
Why don't you try that? You might even be able to "do it yourself" ...
Bob Schor
07-25-2018 10:51 AM
It feels like you're leaving out some information here.
Do you have an array containing some values, and another value as input, and you're looking to see if it matches the first or last elements and then choosing a case based on that?
Or are you doing a FOR loop that indexes every element of an array and you want the first and last iterations to have a special case?
Or is it another situation entirely?
07-25-2018 11:11 AM
Autoindex your array on a FOR loop containing a case structure wired to the iteration terminal.
(I am sure there are much better solutions to your problem. What are you trying to do?)
07-26-2018 04:21 AM
Hi All,
sorry for the poor description of my problem. As you have probably guessed I am learning Labview. In hindsight I should have explained better.
I have an array of type string going into a FOR loop (auto indexing) and I want to put a case statement inside the for loop to format the string depending on if its the first element, last element or anything in between. The size of the array is not known.
I have found an answer for first and last element in the array using array size then comparing it to the Loop counter. Ideally I was looking for a neat solution to do all three within a single FOR loop.
Thanks
07-26-2018 05:23 AM - edited 07-26-2018 05:26 AM
i am paraphrasing Bob-no-images-we-are-not-british-Shor:
please attach code not images.
if you don't want to attach your whole VI, create a new one showing only the part where you have a problem with (which is always a good choice).
regards
EDIT: for your consideration (and to help you help us help you)
https://forums.ni.com/t5/Community-Documents/Unofficial-Forum-Rules-and-Guidelines/ta-p/3536495
07-26-2018 06:51 AM - edited 07-26-2018 07:14 AM
Hi, is something like this would solve your problem ?
(This is a snippet, you can drag it into your vi to test it).
Edit : With the snippet attached as suggested by jwscs
07-26-2018 07:09 AM - edited 07-26-2018 07:16 AM
hi Arik.v³
unfortunately, you also have to attach the snippet .png,
with the new forum design, they messed up the drag+drop directly from the image,
so the original file is needed.
(see Notice at top of the forum https://forums.ni.com/t5/LabVIEW/Notice-Attach-VI-Snippets-to-post-rather-than-upload/td-p/3660471)
regards
EDIT: ok it is not really necessary as more a convenience
if you right clikc on the image and "View Image" (or somesuch) you get a link like this
/t5/image/serverpage/image-id/232256i4F1EFB6A0F27AC90/image-size/large?v=1.0&px=999
if you remove the "/image-size/....." part
/t5/image/serverpage/image-id/232256i4F1EFB6A0F27AC90
you can then drag+drop it
07-26-2018 07:17 AM
Hi Jwscs,
Thanks for the remark, I made an edit on my previous post to attach the snippet.