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>