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

Several Questions...
Author: Message:
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: Several Questions...
SpunkyLoveMuff's method may work in some cases, but there is an easier and sometimes better way to do it.
code:
// In this example, the variable sFile contains all the text from the file you read.
var sSearch = "Is this in the file?"; // The variable contains what you are searching for.
var nIndex = sFile.indexOf(sSearch); // Find the index that this phrase is located.
if(nIndex > -1){ // String.indexOf returns -1 if the string is not found
// nIndex is the position (an integer) that represents where the first character is. It is zero-based.
var nEndIndex = nIndex + sSearch.length - 1; // The variable nEndIndex represents the index that the phrase ends on.
// Do whatever you want
} else { // If the index is -1, the phrase not found
// Do whatever
}

Also, Huhu_Manix's code will not give you what you want. His code will give you "bc", it cuts off the first letter. If you want the second, third, and fourth letter of a string, use this:
code:
var sString = "hello"; // The string to extract from.
var sSubString = sString.substr(1,3); // The first parameter is the index to start at. It is zero-based. The second is how many characters to include. If you leave out the second, it will just cut off however many characters you specify in the first parameter.

This post was edited on 09-15-2006 at 11:33 PM by deAd.
09-15-2006 11:28 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Several Questions... - by Robin4286 on 09-15-2006 at 10:39 PM
RE: Several Questions... - by cloudhunter on 09-15-2006 at 10:44 PM
RE: Several Questions... - by Robin4286 on 09-15-2006 at 11:04 PM
RE: Several Questions... - by Spunky on 09-15-2006 at 11:08 PM
RE: Several Questions... - by Huhu_Manix on 09-15-2006 at 11:24 PM
RE: Several Questions... - by deAd on 09-15-2006 at 11:28 PM
RE: Several Questions... - by Huhu_Manix on 09-15-2006 at 11:39 PM
RE: Several Questions... - by markee on 09-16-2006 at 07:09 AM
RE: Several Questions... - by CookieRevised on 09-17-2006 at 01:29 AM
RE: RE: Several Questions... - by Huhu_Manix on 09-17-2006 at 12:37 PM
RE: Several Questions... - by deAd on 09-17-2006 at 01:34 PM
RE: Several Questions... - by Huhu_Manix on 09-17-2006 at 01:55 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