LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array Manipulation

Solved!
Go to solution
Ravens Fan that vi was useful. but if i want to have new input to store that isnt in the database, i have to continue on the default case to build array and write into spreadsheet?
0 Kudos
Message 11 of 27
(1,066 Views)

Move the write to spreadsheet out of the case structure.  Build the new value into the end of the array for -1 case instead of doing the replace array like in the default case.

 

You may want to do some checking before adding to the array to make sure the fields are properly filled out, and that the car number is the same as the one searched for.

 

(You don't want someone to search for a car no., not find it, then edit the number to something else that is in the array, then store it.)

 

You can leave the write to spreadsheet file in the default case, but you would also have to add another one to the -1 case after doing your checks.

Message Edited by Ravens Fan on 04-05-2010 11:46 PM
0 Kudos
Message 12 of 27
(1,063 Views)

ok so i have to search if the car number is in the database first. if it's not it go into the -1case and write it into the spreadsheet?

i have create a local variable for both the pillar and car number and put it outside the while loop.

i build array for both and connect a wire into insert into array function and connect another wire to write to spreadsheet.

am i doing the correct things? 

0 Kudos
Message 13 of 27
(1,054 Views)

ok so i have to search if the car number is in the database first. if it's not it go into the -1case and write it into the spreadsheet?

i have create a local variable for both the pillar and car number and put it outside the while loop.

i build array for both and connect a wire into insert into array function and connect another wire to write to spreadsheet.

am i doing the correct things? 

0 Kudos
Message 14 of 27
(1,054 Views)

Yes, you want to search the database first to be sure its not already in there.  My assumption of your application is that you can't have two cars with the same number.

 

Why are you putting any local variables outside the while loop?  They are only going to be read at the very beginning of the program.  You could put your variables outside the event structure (inside the while loop) if you need to read that value for multple event cases.  You can use local variables if you need to, as long as you understand what you are doing and understand what "race condition" means.

 

Do you want to put the new value into the middle of your array, then use Insert Into Array.  If you want to always put the value at the end, then use Build Array.  I find that new LabVIEW users always think they want to use Insert into Array when they really don't, and wind up using it wrong and wonder why they never get any new data added into their array.

0 Kudos
Message 15 of 27
(1,031 Views)

i dont really understand what is race condition means.

at the shift register with a constant of -1 what does it mean???

at the event structure, the search value change, if the value is not in the database the index will be -1. then it will go into the store value change at the event loop and go into the -1 case?

0 Kudos
Message 16 of 27
(1,022 Views)

Divineapple wrote:

i dont really understand what is race condition means.

 

Search the forums for that phrase.  When local variables are abused, there is a lack of control of when they are written to or read from. 

 

at the shift register with a constant of -1 what does it mean???

 

I wanted to get the code in the timeout case to run right at the beginning (thus the initial 0 timeout) and then never again (thus the -1).  I probably could have handled that differently, but that is what came to my mind when I first coded it up. 

 

at the event structure, the search value change, if the value is not in the database the index will be -1. then it will go into the store value change at the event loop and go into the -1 case?

Yes.   The only risk is if someone messes with the data in the controls between the time they hit Search and the time they hit Store.

 

 


 

0 Kudos
Message 17 of 27
(1,016 Views)

i try to build array of the car number and the pillar wire it into new element of subarray of the insert into array function.

but it have no index and it does not appear in the array indicator. only appear in the text file and it delete index 0 whenever i press store when it's index is -1

Message Edited by Divineapple on 04-06-2010 08:56 PM
0 Kudos
Message 18 of 27
(1,013 Views)

What is the meaning of the index in your array anyway?

 

What you can do is look at the current size of your array (no. of rows), add 1 to it, and use that as the index and build it into a 1-D array of strings with the pillar and car no., then build that 1-D array into the end of your 2-D array.

 

I don't know what you mean by it deletes index 0.

0 Kudos
Message 19 of 27
(1,005 Views)
this is what i have done to it.
0 Kudos
Message 20 of 27
(1,001 Views)