What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » My new command isn't being recognized (VB6)

My new command isn't being recognized (VB6)
Author: Message:
NanakiXIII
New Member
*

Avatar

Posts: 8
34 / Male / –
Joined: May 2003
O.P. My new command isn't being recognized (VB6)
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.
07-08-2005 07:57 PM
Profile E-Mail PM Find Quote Report
Dempsey
Scripting Contest Winner
*****

Avatar
http://AdamDempsey.net

Posts: 2395
Reputation: 53
37 / Male / Flag
Joined: Jul 2003
RE: My new command isn't being recognized (VB6)
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

This post was edited on 07-08-2005 at 08:01 PM by Dempsey.
SoundPacks   -   Scripts   -   Skins

that's not a bug, thats an unexpected feature
07-08-2005 08:00 PM
Profile E-Mail PM Web Find Quote Report
TheBlasphemer
Senior Member
****

Avatar

Posts: 714
Reputation: 47
36 / – / –
Joined: Mar 2004
RE: My new command isn't being recognized (VB6)
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...
[Image: theblasp.png]
07-08-2005 08:47 PM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: My new command isn't being recognized (VB6)
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 ;)
[Image: spartaafk.png]
07-08-2005 09:24 PM
Profile PM Web Find Quote Report
NanakiXIII
New Member
*

Avatar

Posts: 8
34 / Male / –
Joined: May 2003
O.P. RE: My new command isn't being recognized (VB6)
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.
07-08-2005 09:40 PM
Profile E-Mail PM Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
RE: My new command isn't being recognized (VB6)
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)
YouTube closed-captions ripper (also allows you to download videos!)
07-09-2005 05:35 AM
Profile E-Mail PM Web Find Quote Report
NanakiXIII
New Member
*

Avatar

Posts: 8
34 / Male / –
Joined: May 2003
O.P. RE: My new command isn't being recognized (VB6)
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.
07-09-2005 09:18 AM
Profile E-Mail PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: My new command isn't being recognized (VB6)
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.
07-09-2005 09:28 AM
Profile PM Web Find Quote Report
NanakiXIII
New Member
*

Avatar

Posts: 8
34 / Male / –
Joined: May 2003
O.P. RE: My new command isn't being recognized (VB6)
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.

This post was edited on 07-09-2005 at 10:23 AM by NanakiXIII.
07-09-2005 10:06 AM
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