What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Use DLL

Use DLL
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Use DLL
You could do it the dirty way, by using string functions such as String.indexOf and String.substr:
code:
//This is a sample string, you'll probably want to get this string through some code...
var strTitle = "Start Page - Microsoft Visual Basic 2008 Express Edition";
//Try to find the last occurrence of the title suffix
var pos = strTitle.lastIndexOf(" - Microsoft Visual Basic 2008 Express Edition");
if(pos !== -1) {
   //Found it, now cut the wanted part from the string
   var strTitleName = str.substr(0, pos);
} else {
   //Not found, some error handling here?
}
A bit more advanced method, but much shorter and cleaner, is to use regular expressions:
code:
var strTitle = "Start Page - Microsoft Visual Basic 2008 Express Edition";
//Make a RegExp object - check out the link for an explanation of the used special characters.
var reSuffix = new RegExp("^(.+) \\- Microsoft Visual Basic 2008 Express Edition$", "i");
//Test the string with the RegExp
if(reSuffix.test(strTitle)) {
   //Got a match, the name is now in $1
   var strTitleName = RegExp.$1;
} else {
   //No match, some error handling here?
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
05-27-2008 04:05 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Use DLL - by Mindstorms on 05-26-2008 at 04:40 PM
RE: Use DLL - by Spunky on 05-26-2008 at 06:41 PM
RE: Use DLL - by ShawnZ on 05-27-2008 at 12:32 AM
RE: Use DLL - by Mindstorms on 05-27-2008 at 03:34 PM
RE: Use DLL - by Matti on 05-27-2008 at 04:05 PM
RE: Use DLL - by Mindstorms on 05-27-2008 at 04:55 PM
RE: Use DLL - by Matti on 05-27-2008 at 07:11 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On