Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Plugin access to arrays?

May
13,009
174
I could be dreaming, but I seem to recall a mention to Plugin access to arrays. Does it exist?
 
HELP PLUGINS says:
ArrayVariables

Plugins can access TCC array variables directly through the ArrayVariables array. See TakeCmd.h in the SDK for details.

but I have not been able to find a copy of TakeCmd.h which documents this interface. I vaguely remember seeing a synopsis at one point, and being deeply confused by it. Let me know if you figure it out....
 
HELP PLUGINS says:


but I have not been able to find a copy of TakeCmd.h which documents this interface. I vaguely remember seeing a synopsis at one point, and being deeply confused by it. Let me know if you figure it out....
I was aware of the existence of that array (or at least a function to get a pointer to it). TakeCmd.dll has
Code:
g:\tc24> undecorate ?ArrayVariables@@3PAUARRAYS@@A
struct ARRAYS * ArrayVariables
but it's not documented and I have no clue what the struct may look like. I was hoping for ways to manipulate array entries. If the array of structs gives pointers to the arrays and the arrays are like "C" arrays, that would be good enough. If they're not like "C" arrays, we'd need some functions.
 
I figured out a little. This much (the name) works (32-bit version).
Code:
struct ARRAY
{
    LPWSTR szName;
    BYTE bytes[64];    
};

    ARRAY *Arrays = (ARRAY*) GetProcAddress(global.hTCDLL, "?ArrayVariables@@3PAUARRAYS@@A");
    Sprintf(szExpr, L"SETARRAY array_name[3,4,5,6]");
    Command(szExpr, 0);
    Sprintf(szExpr, L"SET array_name[0,0,0,0]=666");
    Command(szExpr, 0);
    Printf(L"Address of name: 0x%lX\r\n", Arrays[0].szName);
    Printf(L"ArrayName = %s\r\n", Arrays[0].szName);

Output:
Code:
Address of name: 0x1C36B48
ArrayName = array_name

I can't make a lot of sense out of the next 64 bytes. I see the 4 sizes there (though the last one looks different from the first three), There doesn't seerm to be a number of dimensions or a pointer to the beginning of the array.
Code:
    for ( INT i=0; i<64;i++ )
        Printf(L"%d ", Arrays[0].bytes[i]);

Output:
Code:
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 152 121 196 1
 
This was the 64 bytes following the name pointer for a 3x4x5x6 array.

Code:
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 152 121 196 1

Here are the 64 bytes following the name pointer for a 3x4x5 array.

Code:
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 8 121 118 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

It doesn't even look like the same kind of struct. I give up.
 

Similar threads

Back
Top