LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

excell: CVI stuck in WriteData

A strange problem encountered:
My Excel2000 demo works fine, but when I wrote my own WriteData() function (very similar to the original), and use it,
CVI gets "stuck" in  the following section:
Error:
    SetWaitCursor (0);
   
    // Free array of VARIANT
    if (vArray)
    {
        for (i=0;i<ROWS;i++)
        {
            for (j=0;j<COLUMNS;j++)
            {
                CA_VariantClear (&vArray[i*COLUMNS+j]);
            }
        }   
        free(vArray);
    }           
   
    // Free SAFEARRAY in VARIANT       
    CA_VariantClear(&MyVariant);
 
Execution is HALTED, and the last line is marked (as if it had a breakpoint), and when I keep pressing F5, this situation reoccurs.
 
This also happens in Release Mode, which is very strange
 
Any help would be appreciated
 
Thanx!
---JM
0 Kudos
Message 1 of 4
(3,315 Views)

Some additional info:

1) The last line in the excel table doesn't contain the data it should, but instead   #N/A appears in every cell

2) In Debug Output I get a message reagering a problem with invalid address on the Heap:

HEAP[myapp_dbg.exe]: Invalid Address specified to RtlSizeHeap( 00140000, 0016E838 )

Again any help would be appreciated.

Thanx!

---JM

0 Kudos
Message 2 of 4
(3,278 Views)
Make sure MyVariant is initialized. If you call CA_VariantClear with an uninitialized variant then this may cause a First-chance exception and result in your program getting suspended when attached to a debugger. You should always make sure the variant is initialized to some value or set to empty (using CA_VariantSetEmpty).
0 Kudos
Message 3 of 4
(3,263 Views)

Jojo,

In your code CA_VariantClear (&vArray[i*COLUMNS+j]), you might want to change it to CA_VariantClear (&vArray[(i*COLUMNS)+j]).  I have noticed that CVI doesn't follow the good old "Please Excuse My Dear Aunt Sally" rules.  For instance if I do a:

int * foo = malloc ( 10 + 1*(sizeof(int)) i will be allocated 14 bytes of memory

Where if I do a

int *foo = malloc ( (10+1)*sizeof(int))) I will be allocated 44 bytes of memory

0 Kudos
Message 4 of 4
(3,256 Views)