Shoutbox

My new command isn't being recognized (VB6) - 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)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: My new command isn't being recognized (VB6) (/showthread.php?tid=47341)

My new command isn't being recognized (VB6) by NanakiXIII on 07-08-2005 at 07:57 PM

I'm just learning a bit about writing plugins for MsgPlus in VB6 and I've been trying to write one that just adds one command, but my command isn't recognized and doesn't appear in the list that appears when you just press "/" in a conversation window. My plugin is loaded and checked in the MsgPlus preferences, so the problem must be in my coding. I just have no idea what I'm doing wrong.

I have the two modules loaded into my project and my own module looks like this:

code:
Public Function Initialize(ByVal nVersion As Long, ByVal sUserEmail As String, ByVal oMessenger As Object) As Boolean
    Initialize = True
End Function

Public Function ParseCommand(ByVal sCommand As String, ByVal sCommandArg As String, ByVal oConversationWnd As Object, ByRef sResult As String) As Boolean
If (StrComp(LCase(sCommand), "/xphobia", vbTextCompare) = 0) Then
    Dim PhobiaFile As String
    Dim Phobias() As String
    Dim RandomPhobia As String
    Open "E:\My Documents\phobialist.txt" For Input As #1
        PhobiaFile = Input(LOF(1), 1)
    Close #1
    Phobias = Split(PhobiaFile, vbNewLine)
    Randomize
    RandomPhobia = Phobias(Fix((UBound(Phobias) + 1) * Rnd))
    sResult = RandomPhobia
    ParseCommand = True
    Exit Function
End If
ParseCommand = False
End Function


It's supposed to pull up a file and send back a random line from it. That part works. I'm probably just missing something stupid because I've never done this before. Any help would be appreciated.
RE: My new command isn't being recognized (VB6) by Dempsey on 07-08-2005 at 08:00 PM

you havent done the GetPublishInfo bit

code:
Public Function GetPublishInfo(ByRef sPluginName As String, ByRef nCommandCount As Long, ByRef nTagCount As Long) As Boolean
        sPluginName = "Screenshot Sender 3"
        nCommandCount = 23
        nTagCount = 0
        GetPublishInfo = True
End Function



and GetPublishCommandInfo
code:
Public Function GetPublishCommandInfo(ByVal nCommandIdx As Long, ByRef sName As String, ByRef sValue As String, ByRef sHelp As String)
        If (nCommandIdx = 1) Then
            sName = "Send ..."
            sValue = "xsssend"



etc
RE: My new command isn't being recognized (VB6) by TheBlasphemer on 07-08-2005 at 08:47 PM

I don't think the PublishInfo part is mandatory to be honest...
If I where you, I'd first just try to return a constant string, and slowly start building back the code you have now, and at each step check if it still works.
That's the quickest way to find out what part is causing trouble...


RE: My new command isn't being recognized (VB6) by RaceProUK on 07-08-2005 at 09:24 PM

quote:
Originally posted by TheBlasphemer
I don't think the PublishInfo part is mandatory to be honest
Correctamundo ;)
The problem is probably to do with the file handling, as that's the part most likely to go wrong.
* RaceProUK has another read of the code...
* RaceProUK checks MSDN...
Looks like the code is fine. You'll need to do a few checks witht he file itself though: does it exist, can you read it, stuff like that.

And error handling code (On Error) wouldn't go amiss ;)
RE: My new command isn't being recognized (VB6) by NanakiXIII on 07-08-2005 at 09:40 PM

code:
'// Recognized plugin functions                             
'//                                                         
'// You must declare the functions in your class exactly as they are
'// declared in this file. Initialize() is the only mandatory   
'// function, all the other ones are optional.


I thought that meant that I only needed to use the functions that I needed to use, besides Initialize(). All the functions are declared in the modules from the API. Do I need to use all the functions?

My file is fine, I actually tested the Get-Random-Line code in a standard EXE and it worked just fine.

I replaced sResult = RandomPhobia with sResult = "hello", but nothing has changed.

I also have another question: Do I need to register my DLL again and again every time I need to test a change?

Thanks.
RE: My new command isn't being recognized (VB6) by Mike on 07-09-2005 at 05:35 AM

quote:
Originally posted by NanakiXIII
I also have another question: Do I need to register my DLL again and again every time I need to test a change?
Nope, I dont think so...
I think that VB automatically registers dlls when you compile them...

Also, have you added the correct registy entrie in HKEY_CURRENT_USER\Software\Patchou\MsgPlus2\RegisteredPlugins ?
The name should be whatever you want and the data should be "TheProjectNameOfYourPlugin.MainClassOfYourPlugin" (without the quotes)
RE: My new command isn't being recognized (VB6) by NanakiXIII on 07-09-2005 at 09:18 AM

Well I don't know about VB automatically registering DLLs, the MsgPlus API readme file instructs to register manually.

And yes, I did, otherwise my plugin wouldn't have been loaded into MsgPlus, I think.


RE: My new command isn't being recognized (VB6) by Mnjul on 07-09-2005 at 09:28 AM

Well, I still recommend add an On Error Goto statment. When Plus! says it doesn't recognize the command, it can also mean that there have been some errors during execution of the command.


RE: My new command isn't being recognized (VB6) by NanakiXIII on 07-09-2005 at 10:06 AM

Thanks, I added it just to be sure, but now I've made some progress, though I have no idea how.

I don't know what I did or changed, but my command is now being successfully interpreted. There's just one thing I don't like: my command still isn't listed in that list that's loaded when you just press "/". Does anyone know how to fix this?

EDIT: OK, nevermind, I figured it out.