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

[amibroker] Some very basic facts about passing function arguments



PureBytes Links

Trading Reference Links

Yuki,

> TJ> You should read carefully function syntax:
> 
> Okay, I will happily try this.  But is is not a "should read
> carefully" situation.  It is a programmer-versus non programmer
> situation.  I simply did not understand that a parameter cannot be
> skipped.  And either does the AFL check routine, either.  ^_^  It
> says nothing is wrong with the code.

It is obvious that you have no experience in writing code.
However it is also obvious that parameters IN THE MIDDLE can not be skipped.

Let's imagine you have function called Circle
that gets 4 parameters x, y, radius and thickness.

Circle( x = 0, y = 0, r = 10, thickness= 1);

Now you "skip" two first and say

Circle( 20, 2 );

What happens?

Actually executed code is
Circle( 20, 2, 10,  1 );

The specified parameters take values as you written them,
other take default values (10, 1 ).

And you end up having circle with diameter of 10 plotted at coordinates (20,2)
with thickness = 1.

No error message is generated because it can not be generated
since all parameters are JUST NUMBERS.

You can however skip last parameter
Circle( 20, 2, 10 ); // thickness takes default value of 1 here

And you should also know that parameter names are just for reference
(they are called formal parameters).
When calling  you DO NOT SUPPLY the names, just VALUES !

Writing:
AddColumn(pchng, "Pct. Chg.", format = 0.000);

makes no sense as "format" is just the formal parameter name,
for reference only (so you know what is the meaning of the parameter).
It is NOT used by the compiler/interpreter.

Instead when calling just provide VALUES:
AddColumn(pchng, "Pct. Chg.", 0.000);

or
AddColumn(pchng, "Pct. Chg.", 1.2, -1, -1, 200 ); // 200 is the width

One must NOT skip arguments in the middle. What you can do
is to skip last or a couple of last arguments. 

Best regards,
Tomasz Janeczko
amibroker.com



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a difference. Find and fund world-changing projects at GlobalGiving.
http://us.click.yahoo.com/PcNrnD/PbOLAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/