`
Clarion in general: Using very big arrays by creating them in C 2002-08-31 -- Ole-morten Heien Newsgroups: comp.lang.clarion I just tried this and it works very well: In your project, add an external file. Name it MyCool.cpp or wathever. Just have the CPP extension This should be in the code: extern "C" int GetValue(int,int); extern "C" viod PutValue(int,int,int); int ThisArray[1000000][128]; /* This declares an array on 128 MB!!! */ extern "C" int GetValue(int X, int Y) { return ThisArray[X][Y]; } extern "C" void PutValue(int X, int Y, int Value) { ThisArray[X][Y] = Value; } In your Clarion app you should declare the function in your global map MAP Module('MyCool.CPP') GetValue(Long,Long),Long,RAW,Name('_GetValue') PutValue(Long,Long,Long),RAW,Name(('_PutValue') END!Module END!Map Change your: MyArray[x,y]=z to PutValue(x,y,z) and r# = MyArray[x,y] to r# = GetValue(x,y) Compile and run. Fast? My machine is a Pentium 4 2.4Ghz and 256 MB ram Two kind of tests: a. Loop I# = 1 to X Loop O# = 1 to Y PutValue(I#,O#,I#) End!Loop End!oop 1b. Loop I# = 1 to X Loop O# = 1 to Y q# = GetValue(I#,O#) End!Loop End!Loop Looping the tests with X<5000000 and y=100 was around 5 seconds from x<=100000 and y=100 was pretty instant :-) HTH Ole-Morten Heien Langaard Software ------------------------------ WEB: www.langaard.no MAIL: o-mheien@langaard.no ICQ: 72785878 MSN: o-mheien@langaard.no On Fri, 30 Aug 2002 13:36:01 -0700, "Bob Campbell" Printed November 21, 2024, 3:10 pm This article has been viewed/printed 35217 times. Google search has resulted in 33 hits on this article since January 25, 2004. |