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

Re: [amibroker] #define directive ?



PureBytes Links

Trading Reference Links




Salil,
 
instead of your
#define WRITE45_EMA   WriteIf ( LastValue(security) > 
LastValue(security45ema), "Price is above it 45 ema","Price is not above 45 
ema");
 
Write:
 
function WRITE45_EMA( security, sercurity45ema )
{
 WriteIf ( LastValue(security) > LastValue(security45ema), 
"Price is above it 45 ema","Price is not above 45 ema");
}
 
Then you can call it many times and save typing. Functions are 
generally preferred over in-place macro expansion
because of lack of side effects that macros have. Therefore 
they are way better for non-programmers.
Functions in AFL also provide much better performace than 
macros would because they are parsed once.
Macro expansion just increases the length of the code that has 
to be parsed and would slow down everything.
 
I have no intention to make AFL 100% the same as C/C++. 

Although AFL has some similarities to C they are two different 
beasts. First and most important is that
AFL is INTERPRETED while C is compiled. Due to this fact 
#define would be simply ineffective.
 
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Salil V 
  Gangal 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Monday, May 19, 2003 5:51 AM
  Subject: RE: [amibroker] #define 
  directive ?
  
  Graham,
   
  The #define directive allows one to write in short-hand rather than 
  writing  long code.  The compiler substiututes the short-hand into 
  its full form before executing it.
   
  As an example, say if one is writing the following again and again 
  and again in the program ==>
   
  WriteIf ( LastValue(security) > LastValue(security45ema), 
  "Price is above it 45 ema","Price is not above 45 ema");
   
  Then one can just define the short-hand 
   
  #define WRITE45_EMA   WriteIf ( LastValue(security) > 
  LastValue(security45ema), "Price is above it 45 ema","Price is not above 
  45 ema");
   
  And the within the program then one needs to write just 
  WRITE45_EMA which will mean writing whole of 'WriteIf ( 
  LastValue(security) > LastValue(security45ema), "Price is above it 45 
  ema","Price is not above 45 ema");' ! 
   
  This comes in very handy when one has very large code.  It cuts down 
  typing a lot.  Languages like C, C++ support #define.  Since AFL 
  already supports #include, which is similar to C, C++, I am wondering if there 
  is plan to add #define for AFL also ...
   
  Regards, 
  - Salil V Gangal 
  Graham <gkavanagh@xxxxxxxxxxxxx> 
  wrote:
  <BLOCKQUOTE 
  >
    
    

    
    <SPAN 
    >What is #define represent 
    ?
    <SPAN 
    > 
    
    <FONT face="Times New Roman" color=teal 
    size=3><SPAN 
    >Cheers,<FONT 
    color=teal size=3><SPAN 
    >Graham
    <FONT 
    face="Times New Roman" color=#339966 size=2><SPAN 
    ><A 
    href=""><SPAN 
    >http://groups.msn.com/ASXShareTrading
    <FONT 
    face="Times New Roman" color=#339966 size=2><SPAN 
    ><A 
    href=""><SPAN 
    >http://groups.msn.com/FMSAustralia
    <SPAN 
    >-----Original 
    Message-----From: Salil V 
    Gangal [mailto:salil_gangal@xxxxxxxxx] <SPAN 
    >Sent: Monday, 19 May 2003 9:40 
    AMTo: 
    amibroker@xxxxxxxxxxxxxxx<SPAN 
    >Subject: [amibroker] #define directive 
    ?
    <FONT face="Times New Roman" 
    size=2> 
    
    <FONT 
    face="Times New Roman" color=#ff4040 size=2><SPAN 
    >Tomasz,
    
    <FONT face="Times New Roman" 
    size=2> 
    
    <FONT face="Times New Roman" 
    size=2>There is #include in AFL, 
    but AFAIK there is no #define in AFL.
    
    <FONT face="Times New Roman" 
    size=2> 
    
    <FONT face="Times New Roman" 
    size=2>Are there any plans to add #define as 
    well ?  With ever increasing length of AFL scripts, I'm sure that 
    #define will cut-down lot of typing while writing AFL 
    scripts.
    
    <FONT face="Times New Roman" 
    size=2> 
    
    <FONT face="Times New Roman" 
    size=2> 
    
    
    <FONT 
    face="Times New Roman" color=#ff4040 size=2><SPAN 
    >Friends,
    
    <FONT face="Times New Roman" 
    size=2> 
    
    <FONT face="Times New Roman" 
    size=2>Are there any work-arounds for #define 
    in AFL ?
    
    <FONT face="Times New Roman" 
    size=2> 
    
    <FONT face="Times New Roman" 
    size=2>Regards,
    
    <FONT face="Times New Roman" 
    size=2>- <FONT 
    face="Times New Roman" color=#4040ff><SPAN 
    >Salil V Gangal 
    
    <DIV class=MsoNormal  
    align=center><SPAN 
    >
    
    
    <FONT face="Times New Roman" 
    size=2>Do you Yahoo!?<A 
    href="">The New 
    Yahoo! Search - Faster. Easier. Bingo. 
    Send 
    BUG REPORTS to bugs@xxxxxxxxxxxxx<SPAN 
    >Send 
    SUGGESTIONS to suggest@xxxxxxxxxxxxx<FONT 
    face="Courier New">-----------------------------------------<FONT 
    face="Courier New">Post AmiQuote-related messages ONLY to: 
    amiquote@xxxxxxxxxxxxxxx (Web 
    page: <A 
    href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT 
    face="Courier New">--------------------------------------------<FONT 
    face="Courier New">Check group FAQ at: <A 
    href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    Your use of Yahoo! Groups is subject to 
    the Yahoo! Terms of 
    Service. 
    Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 
    SUGGESTIONS to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <A 
    href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
    group FAQ at: <A 
    href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    Your use of Yahoo! Groups is subject to the <A 
    href="">Yahoo! Terms of Service. 
    
  
  
  Do you Yahoo!?<A 
  href="">The New 
  Yahoo! Search - Faster. Easier. Bingo. Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor












Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.