04-05-2010 10:35 PM
04-05-2010 10:45 PM - edited 04-05-2010 10:46 PM
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.
04-05-2010 11:10 PM
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?
04-05-2010 11:10 PM
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?
04-06-2010 08:13 AM
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.
04-06-2010 08:00 PM
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?
04-06-2010 08:27 PM
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.
04-06-2010 08:50 PM - edited 04-06-2010 08:56 PM
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
04-06-2010 09:23 PM
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.
04-06-2010 09:58 PM