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

Re: [amibroker] Re: Boolean question



PureBytes Links

Trading Reference Links




Wolfgang,
 
That was an excellent explanation and it helps a 
lot.
 
I had assumed that passing two arrays through a 
boolean test would automatically give a boolean result since the test was on a 
boolean basis.
 
The explanation of the stored result actually 
being an array of float vs. array of boolean is what I needed.
 
Thanks to all who helped!
 
-CS
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Wolfgang Schwendt 

  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Tuesday, May 27, 2003 2:09 PM
  Subject: [amibroker] Re: Boolean 
  question
  Hello,Like many scripting languages, AFL is a 
  loosely typed language, whichmeans in computer science parlance that you 
  don't have to explicitlydeclare the type of your variables before you use 
  them. The type of avariable is automatically inferred from the type of the 
  expressionsassigned to that variable.The advantage is that scripts 
  can be written in just a few lines ofcode, without any formal variable 
  declarations being required.  This disadvantage is that sometimes 
  the meaning (semantic) of scriptscan become more difficult to 
  understand.  For example, it can be muchmore difficult to see quickly 
  what the type of a variable is.> T1=20;> 
  Z1=BarIndex()>T1;> > Does Z1 contain a boolean 
  response?> I'm still new to AFL, but my understanding of the 
  example given in thequestion would be as follows:BarIndex() 
  returns an Array (as per the AB help).Hence also the "greater than" 
  operator '>' returns an array.   Itcompares the elements of 
  the BarIndex()-array element-wise with 20. In the result array either 0 or 
  1 is stored is stored for eachelement-wise comparison respectively,  
  with 0 indicating false and 1indicating true.     The 
  result array is an array of float numbers, soits type is actually "array 
  of float"  and not "array of boolean".If I'm not mistaken, AFL 
  has actually not any real boolean variables.It interprets a float value of 
  0 as false, and a float value not equalto 0 as true.So the answer 
  to the question is: Z1 is an array of float values.> Anyone know 
  how to convert Z1 to boolean?in order to convert Z1 to a boolean value 
  (actually a float value),you need to reference a specific element of the 
  arrayThis can be done with the array access operator '[]', e.g. with 
  anexpression like result[i],  with i specifying the index of the 
  arrayelement you want to refer to.Hope it 
  helps,WolfgangSend 
  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.