[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Multi dimensional arrays



PureBytes Links

Trading Reference Links

I found the following in my notes:
 
// 2d array functions
 
/* from a post by Tomasz J. (Graham's email 6/16/2006)
> so tell us how we access via tablename one element of our table ...
 
This is very easy ...
Desired access to tablename[x][y] can be implemented as follows
using VarSet / VarGet (note that this is only ONE OF MANY possible
ways)
 
Example use:
 
Set2DimTable( "blabla", 2, 3, High[ 0 ] );
 
This actually shows how VarSet/VarGet can be used to implement
"equivalent of doubly dimensioned arrays i.e. tables in pure AFL".

*/
 
function Set2DimTable( tablename, x, y, value )
{
 VarSet( tablename + StrFormat("%05.0f%05.0f", x, y ), value );
}
 
function Get2DimTable( tablename, x, y )
{
 return VarGet( tablename + StrFormat("%05.0f%05.0f", x, y ) );
}

 

Joseph Biran
____________________________________________

  _____  

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
Behalf Of Ara Kaloustian
Sent: Saturday, December 30, 2006 2:18 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Multi dimensional arrays


Dynamic variables "VarSet()", are not arrays. They are individual
elements that can be addressed because the variable name can be
created in such a  manner.
 
Example:
//Create variable names for 10 elements
for (i=1; i<=10; i++)
{
VarName = "SGCoeff_" + i;
}
 
You can of course create any dimension "array" you want by using this
scheme.
 
Caution though, these operations are not very fast, so for limited
size "arrays" they aer ok, but for computation heavy operations they
are not well suited.
 
Ara
 

----- Original Message ----- 
From: David Jennings <mailto:davidjennings@xxxxxxxxxxxxx>  
To: amibroker@xxxxxxxxxxxxxxx 
Sent: Saturday, December 30, 2006 12:47 PM
Subject: [amibroker] Multi dimensional arrays


I want to set up a two dimensional array 12 by 14 and populate it with
data e.g.;
 

SGCoef(1, 1) = 17;

SGCoef(1, 2) = 12;

SGCoef(1, 3) = -3;

SGCoef(1, 0) = 35;

 

SGCoef(2, 1) = 7;

SGCoef(2, 2) = 6;

SGCoef(2, 3) = 3;

SGCoef(2, 4) = -2;

SGCoef(2, 0) = 21;

 

SGCoef(3, 1) = 59;

SGCoef(3, 2) = 54;

SGCoef(3, 3) = 39;

SGCoef(3, 4) = 14;

SGCoef(3, 5) = -21;

SGCoef(3, 0) = 231;

 

SGCoef(4, 1) = 89;

SGCoef(4, 2) = 84;

SGCoef(4, 3) = 69;

SGCoef(4, 4) = 44;

SGCoef(4, 5) = 9;

SGCoef(4, 6) = -36;

SGCoef(4, 0) = 429; etc. etc.

 

I've read thru VarSet and VarGet and feel that I must be missing the
point viz: if I keep referencing array locations with varset - will I
not be recreating the array with a different dimensions and  the same
value in each cell?

 

 

Grateful for any help you can give.

 

DJ


Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.0/610 - Release Date: 12/30/2006 2:59 PM