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

Re: [amibroker] Application of Dynamic Array Variables



PureBytes Links

Trading Reference Links

Not sure if this will help, but watch your data types.

VarGet()
VarGetText()
VarSet()
VarSetText()

BR,
Dennis

On Sep 13, 2008, at 3:50 PM, Ken Close wrote:

I previously asked (and received good help) on how to assign a dynamic name to array variables.  Such as Price01, Price02, Fund01, Fund02, etc, where the "01" and "02" are provided by VarSet commands. I have proven the more simple of these to work.
 
However, when I attempt to execute a practical application, I get a variety of errors which I cannot solve.
 
I would like to plot a line of numbers using gfx commands, in order to create a title with evenly formatted columns.
I can do this with many repeats of lines, manually changing the 01,02,03 parts of the variable names.
Such as
 
GfxSelectPen( colorBlue );
for( i = 1; i < 5 && i < BarCount; i++ )
  {
   PrintInCell( StrFormat(Fund01), 1, 0 );
   PrintInCell( StrFormat(BuyDateDisp01),1, 1 );
   PrintInCell( StrFormat("$" + NumDec(BuyPrice01,1.2) ),1, 2 );
   PrintInCell( StrFormat("$" + NumDec(Val01,1.0) ),1, 3 );
   PrintInCell( StrFormat("$" + NumDec(Val01Today,1.0) ),1, 4 );
   PrintInCell( StrFormat("$" + NumDec(ValChg01,1.0) ), 1, 5 );
   PrintInCell( StrFormat(Fund01),2, 0 );
   PrintInCell( StrFormat(BuyDateDisp01),2, 1 );
   PrintInCell( StrFormat("$" + NumDec(BuyPrice01,1.2) ),2, 2 );
   PrintInCell( StrFormat("$" + NumDec(Val01,1.0) ),2, 3 );
   PrintInCell( StrFormat("$" + NumDec(Val01Today,1.0) ),2, 4 );
   PrintInCell( StrFormat("$" + NumDec(ValChg01,1.0) ), 2, 5 );
  }
 
(NumDec) is a function to control the decimal formatting--not germane to my current barrier.)
 
If I try to put in something like this:
 
procedure PrintOneLine(j)
  {
   PrintInCell( StrFormat(Fund(j)),j, 0 );
   PrintInCell( StrFormat(BuyDateDisp(j)),j, 1 );
   PrintInCell( StrFormat("$" + NumDec(BuyPricex(j),1.2) ),j, 2 );
   PrintInCell( StrFormat("$" + NumDec(Val(j),1.0) ),j, 3 );
   PrintInCell( StrFormat("$" + NumDec(ValToday(j),1.0) ),j, 4 );
   PrintInCell( StrFormat("$" + NumDec(ValChg(j),1.0) ),    j, 5 );
  }

 

Then I get errors from the functions I have previously set up to try and assign the dynamic part of the variable, such as

 

function Price( k )
{
  return VarGet( "Price"+ StrFormat("%02.0f", k ) );
}
 
function Fund( k )
{
  return VarGet( "Fund"+ StrFormat("%02.0f", k ) );
}

 

 

So, while the advice to use VarSet or VarGet functions was good advice, I am unable to implement it, even after trying variations of statements.

 

Does anyone have an example of using dynamic variables to print Title statements, either traditional AFL or using the new GFX which you could share so I could get on with the coding.

 

Lacking any help on this, I guess my only other alternative is repetitive lines for each set of variables, controlled with IF statements.  Messy.

 

Thanks for any help.

 

Ken

 

 

 

 


__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___