 RTSLVU
		
			RTSLVU
		
		
		
		
		
		
		
		
	
			07-16-2009 01:13 PM
I have a 1D array of 25 elements, that could grow at a later date...
I heed to write each element to a local variable.
What is the best way besides using the Index Array with 25 index inputs and outputs?
Why dosen't Decimate 1D Array have an option to function this way?
 BVSmith
		
			BVSmith
		
		
		
		
		
		
		
		
	
			07-16-2009 02:04 PM
You can build an array of references to each of the local variables and use a for loop to read the array values and write them to their value property.
 
 altenbach
		
			altenbach
		
		
		 
		
		
		
		
		
	
			07-16-2009 02:12 PM - edited 07-16-2009 02:17 PM
RTSLVU wrote:I have a 1D array of 25 elements, that could grow at a later date...
I heed to write each element to a local variable.
What is the best way besides using the Index Array with 25 index inputs and outputs?
Does this mean you have 25 local variables??? And if the array later grows, you want to add more locals???
Why don't you make the control or indicator an array instead??
Can you show us some code so we get a better feeling on what you are trying to do?
(also, if you want all 25 element is sequential order, you don't need to wire any indices. SImply resize for 25 output (see here) ;))
 smercurio_fc
		
			smercurio_fc
		
		
		
		
		
		
		
		
	
			07-16-2009 02:17 PM - edited 07-16-2009 02:18 PM
RTSLVU wrote:I heed to write each element to a local variable.
Red flag.
Please elaborate on exactly what you're doing. This is usually a bad idea.
EDIT: I see altenbach already covered this. Got distracted while writing reply.
 Darin.K
		
			Darin.K
		
		
		
		
		
		
		
		
	
			07-16-2009 02:24 PM
I'd preface this by saying that there is usually a more elegant solution than using 25+ local variables for anything. If I were to do this, I'd use the 'Invoke Node' to Set a control value for each element of the array. I have included a simple example, in this case the names of the controls are sequentially numbered so it is easy to generate the names, otherwise I suppose you could create a constant array of strings to match the name to the proper array index. It still is not a pretty solution, but it does look better than 25+ outputs on the index array vi going to 25 local variables.
07-16-2009 02:57 PM
Is 25 locals too many? My entire project probablyhas around 150 locals. In short I have to control and monitor 5 systems under test. 250 measurment points of temperature, AC/DC voltage, and AC/DC curent, and 25 control points, plus this is located outdoors so I also have to monitor the equipment cabnet.
Anyway here is a small vi I was experementing with. In a nutshell I need to save a nd restore bunch timers in case the computer gets rebooted, crashes, or whatever...
 altenbach
		
			altenbach
		
		
		 
		
		
		
		
		
	
			07-16-2009 03:17 PM
btw, both of your FOR loops can be deleted without change in outcome. The conversion bullets accept array directly. Try it! 😉
So, why do you need locals? You code does not explain....
Why not keep the times in a shift register as an array?
07-16-2009 03:40 PM
altenbach wrote:btw, both of your FOR loops can be deleted without change in outcome. The conversion bullets accept array directly. Try it! 😉
OMG, I never would have suspected.
altenbach wrote:So, why do you need locals? You code does not explain....
Why not keep the times in a shift register as an array?
As stupid as it sounds, the person that approves my code does not like shift registers.
 PaulG.
		
			PaulG.
		
		
		
		
		
		
		
		
	
			07-16-2009 03:52 PM
RTSLVU wrote:As stupid as it sounds, the person that approves my code does not like shift registers.
It doesn't just SOUND stupid. It's D-U-M dumb.  