Title: Re: [amibroker] Re: How to convert a string to non-string characters?!
Is everybody getting this same email about twenty times? They are still coming in... but less frequently.
or is this a problem at my end?
h
Wednesday, November 26, 2008, 7:42:31 PM, you wrote:
> It isn't impossible, just akward. I would try to find another way.
> StrToNum will convert the number up to the first non-number, the
> character + in your case. That is why you get 3 instead of 12.
> 3 + 4 + 5 is not a number and strToNum is not smart enough to add the
> numbers. When it gets to the + it quits and returns 3.
> To sum numbers in a string you have to parse the string to extract
> the numbers. This will extract the numbers from the string and sum
> them. The printf lines show what is being done along the way.
> VarSetText("Condition1", "3 + 4 + 5");
>
> aStr = VarGetText("Condition1");
> a = aStr;
> Offset = StrFind(aStr, "+") +1;
> Len = StrLen(aStr);
> b = StrMid(aStr, Offset, Len);
> Offset = StrFind(b, "+") +1;
> Len = StrLen(b);
> d = StrMid(b, Offset, Len);
> // this shows the output of the parser
> // at this point a, b and d are strings, not numbers.
> printf("a= " + a + ", b= " + b + ", d= " + d);
> // strToNum returns the number up to first text character
> x = StrToNum(a); // x = 3
> y = StrToNum(b); // y = 4
> z = StrToNum(d); // z = 5
> // now you can sum the numbers
> printf("\nTotal =" + NumToStr(x+y+z, 1));
> Of course if you have an alphanumeric string, such as "Sum 3 plus 4
> and then add 5.", the parsing it will get very difficult but it can
> be done.
> Barry
> --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@xxx> wrote:
>> If it is just plain impossible to convert strings to actual values
>> (other than plain numbers), perhaps my DLL plugin needs to spit
> work in
>> a different way?
>> This is the type of thing I am trying to achieve - to cycle through
>> thousands of conditions like:
>> Condition1 = MA(C, 12) > C5 AND MA(C,20) < Close;
>> Condition2 = EMA(L,4) > C3 OR MA(H,7) > Close;
>> .
>> .
>> .
>> Condition2555 = MA(H, 50) < C12 AND EMA(L, 12) < Close;
>> Setting the left sides of the above expressions is easy, using
> dynamic
>> variables.
>> But my DLL spits out the right sides of the above expressions, but
> only
>> as strings. So instead of the DLL returning strings, how else could
> it
>> interface with AmiBroker so that the dynamic assignments above are
>> created in the AFL?
>> --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@> wrote:
>> >
>> > Or to take a more trivial example, the following prints "3"
> instead of
>> > "12":
>> >
>> > VarSetText("Condition1", "3 + 4 + 5");
>> >
>> > Total = StrToNum (VarGetText("Condition1"));
>> >
>> > printf ("Sum %g", Total);
>> >
>> > How do I convert the above string so that Total is equal to the
>> > _expression_ itself, which is equal to 12?
>> >
>> >
>> > --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" zoopfree@ wrote:
>> > >
>> > > Yes, tried that. But since the values spit out by the function
>> aren't
>> > > just pure numbers, it does not seem to work.
>> > >
>> >
> ------------------------------------
> **** IMPORTANT ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
> *********************
> TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
> *********************
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
> 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/
> <*> Your email settings:
> Individual Email | Traditional
> <*> To change settings online go to:
> http://groups.yahoo.com/group/amibroker/join
> (Yahoo! ID required)
> <*> To change settings via email:
> mailto:amibroker-digest@xxxxxxxxxxxxxxx
> mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
> <*> 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/
__._,_.___
**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
*********************************
__,_._,___
|