PureBytes Links
Trading Reference Links
|
Hello,
This is of course logical if you consider types and evaluation order.
This is so because expressions are evaluated from LEFT to RIGHT and
expression type is specified by LEFT side part.
If you write:
"TEXT" + 3;
AmiBroker will first take "TEXT" (string) and because of string type of left-side
operand it interpret + operator as string concatenation and
then it will evaluate 3. Since 3 is a NUMBER and can not be directly concatenated
it is first converted to string "3" (because implict cast from number to string is supported)
and then it is concatenated to "TEXT" so output will be
"TEXT3"
(string)
If you write this other way:
3 + "TEXT";
the left side operand is a number and thus expression value has to be a number
and + operator is interpreted as numeric addition. Then "TEXT" is evaluated but
it is a string and NUMERIC addition is not possible with strings therefore you get error message.
if you write
NumToStr( 3 ) + "TEXT";
it will first convert 3 to STRING "3" and concatenate strings instead of numerically adding them.
The same effect can be achieved this way:
"" + 3 + "TEXT";
Left-hand empty string "" ensures that the expression has STRING type.
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "treliff" <treliff@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, April 13, 2004 7:28 AM
Subject: [amibroker] Re: pls help: using AddToComposite in for-statement
> One final note: i noticed that
>
> NumToStr(n)+"Ticker"
>
> does work while
>
> n+"Ticker"
>
> does not,
>
> just a detail if preferred the number before the ticker.
>
> -treliff
>
>
>
>
>
>
> 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
> Yahoo! Groups Links
>
>
>
>
>
>
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
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/
|