zack13532 Posted June 25, 2012 Report Share Posted June 25, 2012 The basic setup for my program is as follows: I have a Global Array of "Device" objects (each of which is actually an object of a type that descends from Device). Each object has a bunch of different pieces of information, including a table of data. I'm having an interesting problem with removing a device from this global array. Once I do so (inside of a VI that reads the Global variable, calls the remove element array function on it with the relevant index, and sends the output back to the global variable, setting it), the data table of each device proceeding the removed element in the array gets blanked out. As in, set to the default value - the table dimension sizes are still the same, the array is not empty, just at its default value. Curiously enough, the other pieces of information stored as the private data for each object (everything besides the data table) are still intact post-removal. I have an idea of what might be causing this behind the scenes (shifted pointers in the removal process get messed up or something), but I have no idea how I can fix it. My question is, of course, how do I remove an element but ensure that all proceeding elements have all their data intact? Any help is greatly appreciated! Quote Link to comment
zack13532 Posted June 25, 2012 Author Report Share Posted June 25, 2012 Hmmmm. Upon further inspection (really should have done this before I posted). The data gets blanked out only when a certain type of device is removed. This device type, we'll call it "DS", has a table that should be 3x3. the other device type I've been trying it with, we'll call it "NT", has a table that should be 3x12. I thought this would be irrelevant because both tables are inside separate private data clusters for their respective classes. No VIs are being called on the devices themselves in this process, only the remove element function is called on the global array of devices. Quote Link to comment
crelf Posted June 25, 2012 Report Share Posted June 25, 2012 Ok, that sounds super wierd. Can you strip down the code and upload a chunk that demonstrates the issue? ie: an example with read/write methods that access your data. Quote Link to comment
zack13532 Posted June 25, 2012 Author Report Share Posted June 25, 2012 Yeah if I can't figure it out in an hour or two I'll do that. It'll probably take me a little while to strip it all down and include just the necessary stuff, but this is obviously a critical part of the program. Quote Link to comment
zack13532 Posted June 25, 2012 Author Report Share Posted June 25, 2012 Wow I feel pretty stupid. My issue was that I had two different VIs working with the global and one was using shift registers. In one VI I am able to edit the data and in the other I am able to add and remove devices. In the add/remove device VI I was using a shift register to store any changes until a Save button was pressed. Oftentimes I would make changes to the data in the editing VI while this was running, then go and delete a device and Save. This would take the value that was being passed along the shift register (and not the data values that had recently been updated into the global device array) and store it into the global device array. The effect was the device was removed, but none of the updates that took place in the editing VI were actually saved. My solution was to just add a boolean to the global variable that can be used to detect when a change was made in the editing VI. Sorry for wasting anyone's time! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.