Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Detecting characters in a string

Cegaiel Shan
Registered User
Join date: 12 Apr 2007
Posts: 9
05-26-2007 20:16
Hi, I just finished a radio script that queries my webserver via llHTTPRequest that then gets the song/title info from the Shoutcast DNAS server and displays it as floating text.

Everything is fine except one thing, when it plays a commercial, it displays the commercial name as a song title, too. ie: ~+ [MP-8] Hot 108 Jamz Music Imager 8 (2007) +~
Sometimes its very long. Not all stations use the same format, but most have certain characters they use in song titles that are commercials. In the above example, the commercials always begin with ~+

Let's say my string for the songtitle is string songtitle.
Is there a way I can parse this string to look for the characters ~+ and thus I can tell it to do something else, like make songtitle = "Playing Commerical"?

In visual basic, I could handle this easy with
If Instr(songtitle),"+~";) Then songtitle = "Commericial"

Is there something similiar to this in LSL?

Thanks
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
05-26-2007 20:54
Without writing it myself, use llSubStringIndex, which is:

integer llSubStringIndex(string source, string pattern)

returns the index in the string where that pattern appears, so for you it would be:

integer index = llSubStringIndex(songtitle, "~+";);
Cegaiel Shan
Registered User
Join date: 12 Apr 2007
Posts: 9
Thanks
05-27-2007 01:38
Worked like a charm :D