09-28-2020 09:59 PM
Hi, everybody. Please, help.
I need to read from an excel file the 3x5 array and write it to a global variable. Then I should be able to change the element (or elements) if needed of global variable. The aim is to be able to replace the elements of array taken from the excel file and use it in somewhere else.
Attaching the code that I wrote. Any kind of help is appreciated.
Solved! Go to Solution.
09-29-2020 12:18 AM - edited 09-29-2020 12:19 AM
You did not attach any subVIs and the code looks like it is full of race conditions and makes very little sense.
You are reading from the global (two places, redundant!) and writing to it in (at least) one place in parallel. (No way to tell what happens first and if you are also writing to it on one of the subVIs)
Where is "somewhere else"?
09-29-2020 08:49 AM
You appear to be using some third-party code to read from Excel, rather than NI's Report Generation Toolkit. It is difficult to "guess" what these unknown functions do, and what they might return.
Why don't you write a little routine that returns a 3x5 array (maybe 1, 2, 3 \\ 4, 5, 6 \\ 7, 8, 9 \\ 10, 11, 12 \\ 13, 14, 15) to replace the Excel code (that we can't see nor understand) and try to save this array to a temporary variable and change it as you want? Once you get this to work, you only have to figure out (with a separate little piece of code) how to read in the data from Excel.
Bob Schor
09-29-2020 09:36 AM
Hi, Bob
Actually, excel part is not so important. My problem is with changing array elements if needed.
09-29-2020 11:56 AM - edited 09-29-2020 11:57 AM
Hi Armagedon,
why do you need this global variable at all?
This is the core of your VI without the global:
@Armagedon wrote:
My problem is with changing array elements if needed.
You already use those ReplaceArrayElement functions, so what is your problem?
09-29-2020 12:16 PM
09-29-2020 12:22 PM
Hi srikrishna,
@srikrishnaNF wrote:
in that case you need to use the 'in place element structure' to replace the elements in a efficient way..
Why does he "need to" use that?
Why do you think this will be more efficient than a simple ReplaceArrayElement node?
09-29-2020 01:59 PM
@srikrishnaNF wrote:Then in that case you need to use the 'in place element structure' to replace the elements in a efficient way..
As Gerd already hinted, "Replace array element/subset" operates fully in-place and is equally efficient. It is also more flexible because it can also be used to replace entire rows or columns. Please don't overcomplicate the discussion. The IPE has useful applications, but this is not it.
09-29-2020 07:25 PM - edited 09-29-2020 07:27 PM
@GerdW,
You are awesome. Thanks a lot.
But, there is a problem that I could not figure out why it happens.
For example, when I am changing the element to one in 2x0 then all the column elements until 2x0 immediately becomes zero (0x0 and 1x0).
However, I am trying to be able to change elementwise. As you understand I am completely new to LabView. Please, help.
09-29-2020 10:19 PM
Then you must have done something wrong.
Attach your latest VI so we can see what that was and tell you how to fix it.