Right or Wrong, this is the behavior.
The workaround is to store you message in a variable and print the
variable after the loop/if statement is finished. You can accumulate
messages like so:
myMsg = "";
for (loop conditions)
{
//do stuff
myMsg = myMsg + WriteVal( x, 1.3) + "\n";
}
myMsg;
--
Terry
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Giovanni Moretti
Sent: Sunday, October 01, 2006 04:16
To: [email protected]
Subject: [amibroker] Troubling inconsistency in WriteVal, Printf Usage
Hi
I'm finding that a WriteVal inside a if-statement doesn't get displayed
whereas one outside does ...
The following doesn't make much sense but does show the effect:
PlotChannel = ParamToggle("Channel", "No,Yes", 0);
Channel = 2 * ATR(10);
printf("Channel Width #1: "); WriteVal(Channel , 1.4);
if (PlotChannel) {
printf("Channel Width #2: "); WriteVal(Channel , 1.4);
printf("Channel Width #3: ");
printf(WriteVal(Channel , 1.4)); printf("\n");
}
Produces:
===============================
Channel Width #1: 0.0188
Channel Width #2: Channel Width #3: 0.0188
================================
/There's no value printed for Case #2!/
I remember somewhere that /WriteVal /is actually a synonym for /NumToStr
/so it sort of makes sense that you have to actually print it, but this
is an obvious inconsistency from a user's point of view. Logically,
there's no reason why having WriteVal inside the IF statement should
prevent the value being displayed (as long as the condition is true of
course :-).
Tomasz - How about a warning message that no output will be displayed
(or better still make it so the value is displayed)?
I couldn't find any documentation on how %f, %g (what is a "g"?) and %e
are used ...
How does one do the equivalent of the C/C++:
printf("Close is %s\n", WriteVal(Close, 1.4));
eg print a message, a value and a newline in one statement in AFL?
With printf and %f, are you supposed to specify the whole field width
and then the decimal places (eg "%8.4f") or does the printf in AFL use
the format specifiers like the 1.4 in WriteVal?
A couple of trivial examples would be really appreciated ...
Thanks
Giovanni
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 other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
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 other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/