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

[amibroker] Re: StrFind - What exactly does "character index" mean ?



PureBytes Links

Trading Reference Links

gmorlosky,

If noone else replies sooner, I'll have a look over the weekend at the sample I gave you earlier and debug it as necessary. I won't have access to it before then.

As for your questions below, the value returned from StrFind is the index at which your substring is first discovered. The index is one based, meaning that the first character is at index 1, the second character at index 2, etc. It does not matter whether the string contains letters, numbers or both, they are all treated generically as characters.

Given the string str = "1234abc4", StrFind(str, "4") would return 4 since the first 4 is discovered at index 4. StrFind(str, "abc") would return 5, etc.

Similarly, with StrExtract everything is generically treated as characters. To pull any given token out of the list, you must pass the index of the token that you want. A token is any number of characters appearing between two commas (or from the start of the string to the first comma or from the last comma to the end of the string). The index is zero based, meaning that the first token is at index 0, the second token at index 1, etc.

e.g.
str = "9,10,11" 
StrExtract(str, 1) would give "10"

Mike
 
--- In amibroker@xxxxxxxxxxxxxxx, "gmorlosky" <gmorlosky@xxx> wrote:
>
> What exactly does "character index" mean ?
> 
> StrFind()
> Returns 0 if not found, otherwise returns  (one-based) of first occurrence.
> 
> If I wanted to pull any particular number from a comma delimited string of (see below), how would I extract that ? we have StrExtract, but what about NumExtract ?
> 
> ,0,
> 1,
> 2,
> 3,
> 4,
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/