Jump to content

Adding on to an array


Recommended Posts

Hey all again. I'm back with more of my Pinewood Derby project stuff. I've been reading other somewhat similar issues in the forums, been talking with my partner, AND the professor. The professor didn't help much. :thumbdown: Here's what I'm trying to figure out:

I have 2 strings: one belongs to racer 1, one belongs to racer 2. Each string is the name of the racer and the race time of the racer, which was converted into a string then concatenated onto the name. What I want to do is, as the 'tournament' goes on, display my 'top 10' racers and their times into an array. My issue is that I can't find out how to add a racer in by using the original string controls that I used for each original racer. Every time I change the name from 'Juan' to 'Joe', the respective element in the array changes from 'Juan' to 'Joe'. I want that array to just have information written to it once, then the next time something is written, it's written to a different element. I've tried indexing in different ways and whatnot, but maybe someone can help me understand how to do this. Thanks a lot guys for your help. It's been greatly appreciated.

-Scooter

Link to comment

It would help if you could post either your code or a screen shot of it to see exactly what you are doing now. As for the way you are keeping your data I have to ask why you are concatenating the racer's name and time together. These are two independent pieces of data. By concatenating them you are treating them as a single piece of data which they are not. If this was done to solve your sorting issues I think you should revisit that issue and write the code to correctly sort the clusters. Combining the data to make the sort work may achieve what you desire but it is a bad way of getting there.

Link to comment

post-15313-1239675130.jpg?width=400



Sorry it looks horrible and not scaled very well. I just had to get the image up.

And sorry also that my previous post was a pretty horrible explanation. I was in a hurry to get to work from school where I was working on the project so I just threw something up and hoped someone would understand my plea for help.

Basically, this is what I want to know: how do I get it to just leave 'asdf' and 'jkl;' in elements 1 and 2, and then with those same two string indicators turn right back around and stick something else like 'qwert' and 'yuiop' in elements 3 and 4 respectively? (while leaving elements 1 and 2 as they are)

Link to comment

QUOTE (Scooter_X @ Apr 14 2009, 07:43 AM)

http://lavag.org/old_files/monthly_04_2009/post-15313-1239675130.jpg' target="_blank">post-15313-1239675130.jpg?width=400

Sorry it looks horrible and not scaled very well. I just had to get the image up.

And sorry also that my previous post was a pretty horrible explanation. I was in a hurry to get to work from school where I was working on the project so I just threw something up and hoped someone would understand my plea for help.

Basically, this is what I want to know: how do I get it to just leave 'asdf' and 'jkl;' in elements 1 and 2, and then with those same two string indicators turn right back around and stick something else like 'qwert' and 'yuiop' in elements 3 and 4 respectively? (while leaving elements 1 and 2 as they are)

Hi Scooter_X

I do not want to give you the answer as its your school project but I can give you some direction

When you execute or run your program the string elements are built and the array of string is formed. Now this does not remain in memory as you do not store it anywhere. So the next time your run your program it does not retain any values from the previous run. Look for and read about uninitialized shift registers and functional globals in the forums and LabVIEW help this should give you some direction

Link to comment

Scooter,

I'm not sure that I fully understand what you're trying to do but you're trying to initialise a string array then you could consider having your strings in a .txt or .ini file and reading the string values using a loop. The loop index could then be used to insert each new string into your string array. The array palette contains a function to do this.

Lightworker

QUOTE (Scooter_X @ Apr 14 2009, 03:13 AM)

http://lavag.org/old_files/monthly_04_2009/post-15313-1239675130.jpg' target="_blank">post-15313-1239675130.jpg?width=400

Sorry it looks horrible and not scaled very well. I just had to get the image up.

And sorry also that my previous post was a pretty horrible explanation. I was in a hurry to get to work from school where I was working on the project so I just threw something up and hoped someone would understand my plea for help.

Basically, this is what I want to know: how do I get it to just leave 'asdf' and 'jkl;' in elements 1 and 2, and then with those same two string indicators turn right back around and stick something else like 'qwert' and 'yuiop' in elements 3 and 4 respectively? (while leaving elements 1 and 2 as they are)

Link to comment

QUOTE (santi122 @ Apr 17 2009, 02:07 AM)

Hi Scooter,

do you want to do it like this way ??

Scooter,

Notice that he has "concatenate inputs" checked so that instead of making a 2 dimensional array when he combines his two previous arrays, he makes a longer 1 dimensional array. Right-click on your "build array" vi to check that option. I think this is the source of your problems.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.