PureBytes Links
Trading Reference Links
|
Folks:
No doubt that I've re-invented the wheel here, and that the behavior of
AB's three data types (String, Number, Array) are well-known and
well-documented. My only problem is that I can't locate the documentation
that clearly states what the rules are. Will someone please point me to
exactly where in the help files the rules and behavior of the three data
types are defined, and precisely under what conditions the compiler
type-checks, typecasts, etc.?
I pretty much get the idea from my little experiment below, but I'd like to
study the entire documentation on the subject.
Thanks very much.
-Paul
/////////////
//display reference values for test
_TRACE( "#, C[Barcount-1] = " + NumToStr( C[BarCount-1], 1.2) );
_TRACE( "#, C[25] = " + NumToStr( C[25], 1.2) );
_TRACE( "#, C[37] = "+ NumToStr( C[37], 1.2) );
//test 1
testvar = StrToNum("123"); //create a var of type Number. Help explicitly
states that strtonum returns a "Number" type.
_TRACE( "#, test1 = " + testvar); //display is as expected
//test 2
testvar = C; //assign an entire Array to a Number variable. AA should
refuse to compile, since there should be a data type mismatch. Or does the
compiler see the new data type assignment and upgrade the Number var to an
Array type?
_TRACE( "#, test2 = " + testvar); //displays only last value of array. So
Testvar remains a Number type and is now holding only the last array value,
right?
//test 3
testvar = testvar[25]; //test whether testvar secretly is holding the
entire array. Yup! Trace only displayed the last element, but apparently
the whole array was there all along. But then shouldn't AA refuse to
compile due to type mismatch?
_TRACE( "#, test3 = " + testvar);
//test 4
testvar = testvar[37]; //shouldn't compile, right? The TestVar array no
longer exists and therefore element [37] should be
undefined. Interestingly, though, the value of testvar[37] IS still
defined, except it now contains only the single value from C[25] that
testvar last contained, back when it was a Number type.
_TRACE( "#, test4 = " + testvar);
//test 5
testvar = StrToNum("456"); //assign a single Number again.
_TRACE( "#, test5 = " + testvar);
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/
|