Multi-dimension DGIntArray

Previous topic - Next topic

MrTAToad

I'm trying to access a multi-dimension array (created by X_GETFACE), but when trying to access it via [(x*width)+y] for example, I always hit the limit for the first dimension, which prevents me from accessing the complete array directly, or accessing any dimension other than the first one...

The odd thing is that the C++ shows that a(0,0) is valid, and yet I get compiler errors (which suggest that only a(0) is allowed)...

bigsofty

Easiest method I have found for understanding how GLB C internals work is to write a very simple, all in GLB code for what I want it to do, then compile it. Then examine the processed C code that is in the GLB temp dir("C:\Users\Ian\AppData\Local\Temp\glbasic" on my Win 7 64 O.S.)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Moru

And in C:\Documents and Settings\<username>\Local Settings\Temp\glbasic for windows XP

MrTAToad

#3
Yes, that is what I have do.

Unfortunately with a multi-dimension array, it has, for example
Code (glbasic) Select
PRINT( a(1,1),0,0);

and yet my attempts to access it results in :

Code (glbasic) Select
C:\Users\Me\AppData\Local\Temp\glbasic\gpc_temp1.cpp:4417: error: no match for call to `(__GLBASIC__::DGIntArray) (int, int)'
C:/Program Files (x86)/GLBasic_v11/Compiler/platform/Include/glb.h:441: note: candidates are: DGInt& __GLBASIC__::DGIntArray::operator()(int)
C:/Program Files (x86)/GLBasic_v11/Compiler/platform/Include/glb.h:481: note:                 __GLBASIC__::DGIntArray& __GLBASIC__::DGIntArray::operator()()


My test code is :

Code (glbasic) Select
float TSetup_Object::CheckSize(float xyz,DGIntArray face,int index1,int index2)
{
int indice;

DEBUG(face(0,0));

return 0.0;
}


The problem is that multi-dimension access is converted to a single array location - unfortunately DGIntArray is checking against the first indice and there is no access to the actual data...

MrTAToad

Genot stated that there needs to be GLBasic code somewhere to tell the compiler to use multi-dimension arrays - and that works fine.