PureBytes Links
Trading Reference Links
|
Ken,On Sep 14, 2008, at 12:45 PM, Ken Close wrote: Dennis: thanks for the reminder. I have not yet had time to try the differences. If the dynamic variable will contain text (like a symbol name), then use VarSetText, ie, Sym01, Sym02. ???
Yes. If the dynamic variable will contain a date, which to use?
If it is a date number, use number. If date is a text string, use the text version. Obviously calculations from prices will be VarSet/VarGet.
Yes, any number --including Null. Related question: Can I format decimal places within the formatting part of a StrFormat comand? If I want to show $ to two decimal places, what would it look like? The only example in help shows something related to file open commands, not display strings.
The following should give you some good hints to try:
I generally don't use this command, but I was filling out a Glossary entry for it and had to look for a reference to the formats since they are not specified in the AB functions page.
I made a comment in the Glossary entry about it:
Begin_entry: Name_entry: StrFormat() Name_long: write formatted output to string Description: Returns a formatted string from format and optional values Return_type: s Return_name: Formatted String Arg_type: s Arg_name: formatString // Number of additional arguments is determined by formatString // Need one Arg for each format spec in formatString // No way to specify a variable number of arguments, so I fake it Arg_type: a|n Arg_name: OptionalValue Arg_type: a|n Arg_name: ... Link_name: Wikipedia Link_name: C++ Format String Spec // Badly need a real AFL spec doc --perhaps a UKB article Version_AB: 4.5 Tag_group: AFL Tag_group: Functions Tag_group: String manipulation Tag_group: Type Conversions Tag_search: convert Tag_search: format Related_entry: printf() End_entry:
Best regards, Dennis
Thanks for commenting. Ken 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
__,_._,___
|
|