LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add row to last index of 2d array

Solved!
Go to solution

Ok, i´m already cursing this damn language for its illusion of  "simple".

I´m trying to do the EASIEST operation of any language: filling a row to the bottom of a 2D array.  i just can´t figure out how to do this.

 

 

I´m creating a 1D array with some resulting string data.. then i try to add it to an existing string array and this error shows up when i use the "Insert into array" function.

 

OFFCOURSE I KNOW THE DIMENTIONS ARE DIFFERENT!!!!!!!!!!, DUH??? PRECISELY!!! A 1-D ARRAY SHOULD BE THE ROW FOR A 2D ARRAY.

HOW ON EARTH AM I SUPOSED TO ADD A WHOLE ROW TO THE BOTTOM OF A 2D ARRAY ?

 

Sorry, this kind of nonsense just pisses me off.

Thanks in advance for any help.

 

Pedro

 

 

0 Kudos
Message 1 of 8
(5,337 Views)

You should be using Build Array instead.  Insert Into Array should really only be used if you are adding rows to the middle of your array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(5,328 Views)

Negative.

 

An array builder is exactly whan i´m using to concatenate all strings into the result array, which i´m obligated to resize afterwards in order to make it a 2D array suitable for insertion as a row.

 

If i pass directly from the BuildArray to the 2D ResultArray (which holds indicators), it throws an error saying the BuildArray function is trying to pass a 1D array to a 2D array. 

 

 Look at the picture i uploaded in my previous message.

 

 

0 Kudos
Message 3 of 8
(5,278 Views)

Your picture does not show any "build array" function.

 

Plese attach a simplified version of the actual VI instead of a picture..

 

Here's how to append a row (1D array) to an existing 2D array using "built array". Works just fine.

 

 

0 Kudos
Message 4 of 8
(5,225 Views)
Solution
Accepted by pguillem

@pguillem wrote:

Ok, i´m already cursing this damn language for its illusion of  "simple".

I´m trying to do the EASIEST operation of any language: filling a row to the bottom of a 2D array.


Let me guess - you want to take the HISTORIAL 2D array and add a result to the end of that. That's not what you're doing. You're taking a 1D array and trying to write it into a 2D array, which is why it breaks.

 

The important point to understand here is the basic concepts of dataflow, which should be explained in early LV tutorials - functions operate on the data you give them and front panel controls are not magical data stores. They just hold what you put into them. If what you want to do is what I described, you would need to do it in exactly the same way you would in C:  A = A + B, where I'm overriding + for appending. In this case, you need to read the value from the indicator, append to that value and then write it back. You can do that by creating a local variable from the indicator (and be aware that local variables are not the same as in C. You can use them the same way, but their primary use is for providing secondary access points to front panel controls. If you use them to store data, you will likely find yourself writing race condition, because LV tends to be much more parallel than C and they don't have atomic protections for read-write sequences).

 

LV is relatively simple. If you're suffering with this, I'm going to guess you're one of the people who think much more easily in the domain that text based languages use. If that's the case, you might not enjoy yourself. In any case, you should be careful not to cast everything you already know into LV terms, because that knowledge doesn't always translate correctly. What you should take, if you do have it, is orderly programming practices, like keeping your code neat (which your example isn't). I would also suggest taking a step back and going through some tutorials, as this is definitely the kind of thing that's explained in them.


___________________
Try to take over the world!
0 Kudos
Message 5 of 8
(5,167 Views)

@pguillem wrote:
 

Sorry, this kind of nonsense just pisses me off.

 

It could be worse.  You could be dealing with someone that doesn't understand something and still thinks they should be throwing out attitude when others try to point them in the right direction.  It's generally asinine to start a post with "negative" when you don't understand the content of the post you were replying to.

 

Use the search in the functions palette and look for "build array."  You can also use ctrl+space and type in "build array" to find that.  You can call any function whatever you'd like.  That doesn't mean you're speaking intelligently.  You're not using a build array.  If you were, you wouldn't be feeling the need to throw a tantrum on these forums.  The advice you were given was correct.  Calm yourself.

0 Kudos
Message 6 of 8
(5,159 Views)

Indeed TST and Natasftw. 

Your explanation came in VERY handy speaking in C terms, which made EVERYTHING as clear as possible.

I solved the problem with a local variable, as you suggested. 

 

I´ve been an avid C/Java coder for 12 years and i´m into Labview as a requirement course for the new career i´m studying (Bioengineering), hence the frustration... as i find C itself to be the most robust and usable solution for all my coding needs as a Bioengineer. I really try to breathe in when one is forced to learn this sort of tools by requirement, which i´m almost sure i won´t be using for any serious projects in the upcoming years. Maybe this notion will change as i dive into Labview.

 

I guess the learning curve is a matter of any language. Excuse me for cursing, normally i never loose it unless i´ve looked on 100 forums without answers.

 

AGAIN.THANKS FOR TAKING THE TIME TO SHARE YOUR KNOWLEDGE!!!

Pedro

 

 

 

 

0 Kudos
Message 7 of 8
(5,041 Views)

LV has advantages and disadvantages. There are things it's great at and things it's terrible at. Besides that, there are people who just don't think in the terms that LV uses. I see this most commonly in people who come from a programming background, but that's probably mainly because they have what to compare to and complain. It's certainly not the case with everyone who has a programming background (you have more than one in this thread, including me).

 

In any case, the question you should have been asking and weren't actually asking (presumably since you didn't know the terminology and differences between LV and C) is a noob question. It may be common for people to try diving into a new language and learning as they go (I have usually tried to go through some background material), but the paradigm LV uses is quite different from that of C, so learning properly is important, even though the basic learning curve required to get to functional application is actually much lower than that of C.

 

And like I said, be careful of using local variables as you would in C. In C they make sense. In LV they're dangerous and wires are a preferable way to pass data around.


___________________
Try to take over the world!
0 Kudos
Message 8 of 8
(4,991 Views)