What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » I need a little more help...

I need a little more help...
Author: Message:
dbgtrgr
New Member
*

Avatar
^.^

Posts: 14
33 / Male / –
Joined: Apr 2004
O.P. I need a little more help...
ok, I have a text file that has a line that goes:

<email>begininfo <info><email>endinfo

(Example: example@db.combegininfo w00texample@db.comendinfo)

that way I can search for <email>begininfo to find the beginning of the information, then look for <email>endinfo to find the end of the information so it can extract it.

From what I can tell this script should do the trick... But it's not working right :\

code:
if(Message == '!charname'){
        tf = fso.OpenTextFile(Path, ForReading, true);
        FileInfo = tf.ReadAll();
        tf.Close();
        var Start = FileInfo.indexOf(Contact.Email + 'begininfo');
        Start = Start + Contact.Email.length + 10;
        var End = CharInfo.indexOf(Contact.Email + 'endinfo');
        var Info = FileInfo.substr(Start,End);
        ChatWnd.SendMessage(Info);
}

This post was edited on 07-25-2006 at 10:56 PM by dbgtrgr.
Countdown to Christmas: 6365 days, 43 minutes, 44 seconds ago
07-25-2006 10:50 PM
Profile E-Mail PM Find Quote Report
Shondoit
Full Member
***

Avatar
Hmm, Just Me...

Posts: 227
Reputation: 15
35 / Male / Flag
Joined: Jul 2006
RE: I need a little more help...
code:
if(Message == '!charname'){
   tf = fso.OpenTextFile(Path, ForReading, true);
   FileInfo = tf.ReadAll();
   tf.Close();
   var Start = FileInfo.indexOf(Contact.Email + 'begininfo');
   Start = Start + Contact.Email.length + 10;
   var End = FileInfo.indexOf(Contact.Email + 'endinfo');
   var Info = FileInfo.substring(Start, End);
   ChatWnd.SendMessage(Info);
}
This should work
You wrote CharInfo, instead of FileInfo
and you wrote .substr this could work, but not in this way

you have 2 ways to extract text from a string...
substr and substring, the both take 2 params, but the second param is treated different, with substr this param is treated as the length after the starting point, and with substring this param is treated as ending point

But I would suggest using a better way, using Regular Expressions
code:
if(Message == '!charname'){
   tf = fso.OpenTextFile(Path, ForReading, true);
   FileInfo = tf.ReadAll();
   tf.Close();
   var Match = new RegExp(Contact.Email + "begininfo(.*)" + Contact.Email + "endinfo", "");
   //You could change this to:
   //"<" + Contact.Email + ">(.*)<\/" + Contact.Email + ">"]
   //That way you can write the text like
   //<example@db.com>w00t</example@db.com>
   //This should be more readable and more open for changes

   Match.test(FileInfo)
   Info = RegExp.$1
   ChatWnd.SendMessage(Info);

(I haven't tested this yet...)
It's a lot shorter...
It tries to match the string wich starts with Contact.Email + "begininfo"
Then "(.*)", the dot [.] says it should match every possible character, the asterisk [*] says it should match the preceding character 0 or more times, and its enclosed in parentheses [(] [)], so it is saved in the $1 variable of RegExp, then it matches Contact.Email + "endinfo" at the end

Look here for more information about RegExp's <Link>

This post was edited on 07-25-2006 at 11:41 PM by Shondoit.
My scripts:                            [Image: shondoit.gif]
+ Timezone
+ Camelo
+ Multisearch
07-25-2006 11:34 PM
Profile PM Find Quote Report
dbgtrgr
New Member
*

Avatar
^.^

Posts: 14
33 / Male / –
Joined: Apr 2004
O.P. RE: I need a little more help...
hmm... Thank you ^^ You have been most helpfull. Especially about the substr substring thing... ^^
Countdown to Christmas: 6365 days, 43 minutes, 44 seconds ago
07-25-2006 11:57 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


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