Shoutbox

Use DLL - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Use DLL (/showthread.php?tid=83949)

Use DLL by Mindstorms on 05-26-2008 at 04:40 PM

Hello,

I'm a VB.NET developer normally, so I created a DLL with the functions I need. Now I have to load the DLL into an Messenger Plus! Script, and after hours of searching, I can't find an example.
Is there anyone that could help me out with this?

Kind regards,
Thomas


RE: Use DLL by Spunky on 05-26-2008 at 06:41 PM

I'm fairly certain it's the same as calling DLLs for APIs so you want to look for Interop.Call(dll_name, function_name, param1, param2 etc)


RE: Use DLL by ShawnZ on 05-27-2008 at 12:32 AM

quote:
Originally posted by SpunkyLoveMuff
I'm fairly certain it's the same as calling DLLs for APIs so you want to look for Interop.Call(dll_name, function_name, param1, param2 etc)

nope, not for .NET dlls. there isn't an easy way to do it.
RE: Use DLL by Mindstorms on 05-27-2008 at 03:34 PM

Well, in that case, I have another question:
I have a string "* - Microsoft Visual Basic 2008 Express Edition", and the only thing I want to be left over is everything before " - Microsoft Visual Basic 2008 Express Edition".

So, "Start Page - Microsoft Visual Basic 2008 Express Edition" » "Start Page".

How can I do this with JScript RegExp?


RE: Use DLL by Matti on 05-27-2008 at 04:05 PM

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?
}

RE: Use DLL by Mindstorms on 05-27-2008 at 04:55 PM

It doesn't seem to work, when I use it in my program nothing happens.
When I use this website
http://www.regular-expressions.info/javascriptexample.html and use "^(.+) \\- Microsoft Visual Basic 2008 Express Edition$" as regexp and "Start Page - Microsoft Visual Basic 2008 Express Edition" as subject string, the message is "No match".


Ah, after some messing with RegExp, I see that you had a slash to much, it has to be "^(.+)\ - Microsoft Visual Basic 2008 Express Edition$" Thankyou!
RE: Use DLL by Matti on 05-27-2008 at 07:11 PM

Ah yes, my mistake. Hyphens should only be escaped when in a character class (between [ and ]).

Good you figured it out yourself! :P