Jump to content

Plugins (deprecated)


Jon
 Share

Recommended Posts

  • Administrators

Jon,

could you please post some more information on how the params are beeing passed (by value or by reference) and how (or if) one can modify the params in the plugin function. I tried to play a bit with your  sample code, and after I called a newly created function in the AU3 script, I had very strange effects in the rest of the script, like:

* msgbox() had a title text, although there was no one defined ??

* there have been errors to parse the script, like "$var used before declared", although it has been declared just a line before that statement

* "Trailing characters" error after the last character of that line.

So I guess, I broke something when I tried to modifiy the passed parameters !??!

Thanks!

Cheers

Kurt

You don't touch the passed parameters except through the AU3_Getnnnn Functions. Like normal internal AutoIt functions there is no byref equivalent. The only variables you can change are the single return result and @error/@extended.
Link to comment
Share on other sites

Quick question, will plugins be included into a compiled script or will the plugin have to be distributed along with your compiled script?

<{POST_SNAPBACK}>

Currently, the compiled exe needs the dll, however, you can use FileInstall() to pack the dll into the exe.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Hey,

the new Dev-C++ (4.9.9.2) IDE looks very good :whistle:

Better than I have seen it a few month ago...

ohh..thanks for the info! :dance:

@Jon: don't know if it is right positioned in Idealab but if this "plugin"-functionality works and is ready so far (with the #plugin) then maybe there should be a new forum entry like "Plugins" where everyone can post her/his plugins.

Thanks so far :dance:

Holger

<{POST_SNAPBACK}>

Yes, I agree. Like AutoItX forum.
Link to comment
Share on other sites

Hey,

the new Dev-C++ (4.9.9.2) IDE looks very good :dance:

Better than I have seen it a few month ago...

<{POST_SNAPBACK}>

I've had the 4.9.9.2 for a few months now ... :whistle: But yes, it is very nice... :dance:
FootbaG
Link to comment
Share on other sites

@Jon: I started writing some Service-functions for testing.

The only thing I'm missing at the moment is to return an (multi)array.

At the moment I'm doing it like:

A|1

B|2

C|3

returns a string "A|1 LineFeed B|2 LineFeed C|3".

So long :whistle:

Holger

Link to comment
Share on other sites

Has anyone used this feature yet?  I'd like to make sure it actually works for one thing before I change anything else :whistle:

<{POST_SNAPBACK}>

Should the following work?

AU3_SetString(pMyResult,"Hello World");

I used your sample code, and changed the return value from int to string but I'm not getting the string when I return that value. Instead msgbox shows this: 6581362. int and real retrun values are O.K.

Here is the AU3 code:

$handle = PluginOpen("example.dll")
$retval = PluginFunc1("Hello", "Test") 
msgbox(0,"",$retval)
PluginClose($handle)

Am I doing something wrong? Thanks!

EDIT: I'm using Dev-C++ 4.9.9.2

EDIT#2: Also:

This works (shows "12345" in the message box)

pMyResult = AU3_AllocVar();
    AU3_SetInt32(pMyResult, 12345);
    szText  = AU3_GetString(pMyResult);
    MessageBox(NULL, szText, szTitle, MB_OK);

while this does not (shows strange characters instead of "Hello World")

pMyResult = AU3_AllocVar();
    AU3_SetString(pMyResult,"Hello World"); 
    szText  = AU3_GetString(pMyResult);
    MessageBox(NULL, szText, szTitle, MB_OK);

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Should the following work?

AU3_SetString(pMyResult,"Hello World");

I guess the problem is the call of AU3_FreeVar() in AU3_SetString(), as at the end of AU3_FreeVar() the allocated memory for the variable is released as well, while only m_szValue should be freed.

void AU3_FreeVar(AU3_PLUGIN_VAR *pVar)
{
    if (pVar == NULL)
        return;

    if (pVar->m_nType == AU3_PLUGIN_STRING)
        free(pVar->m_szValue);

    free(pVar);  <=== HERE

}

I "wrote" a second function, called AU3_FreeVarContent(), without the last free() and it seems to work now.

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

... still not working, with a strange effect....

This does not work.

pMyResult = AU3_AllocVar();

    /* Set the return variable to the integer value of 1 */

    AU3_SetString(pMyResult,"Hello World"); 
        szText  = AU3_GetString(pMyResult);
    MessageBox(NULL, szText, "Title", MB_OK);

    AU3_FreeString(szText);

    *p_AU3_Result       = pMyResult;
    *n_AU3_ErrorCode    = 5555;
    *n_AU3_ExtCode      = 6666;

It triggers an error in the AU3 script:

msgbox(0,"",$retval & " @error: " & @error & " @extended: " & @extended)

msgbox(0,"",$retval & " @error: " & ^ERROR

Error: Unknown macro.

While this does work (somehow at least), however the output string is kind of "damaged" ..... (i just added 12345 to the messagebox text).

pMyResult = AU3_AllocVar();

    /* Set the return variable to the integer value of 1 */

    AU3_SetString(pMyResult,"Hello World12345");        <== ADDED 12345 !!
        szText  = AU3_GetString(pMyResult);
    MessageBox(NULL, szText, "Title", MB_OK);

    AU3_FreeString(szText);

    *p_AU3_Result       = pMyResult;
    *n_AU3_ErrorCode    = 5555;
    *n_AU3_ExtCode      = 6666;

Output of msgbox: Hello World12345error5555 @extended: 6666

Should be: Hello World12345 @error: 5555 @extended: 6666

msgbox(0,"",$retval & "   @error: " & @error & " @extended: " & @extended)

So, the @ and the : are "cut" out !???!

I guess I'm doing something completely wrong.....

@Holger how did you return the strings? Which compiler do you use?

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

  • Administrators

pMyResult = AU3_AllocVar();

    AU3_SetString(pMyResult,"Hello World"); 

    *p_AU3_Result       = pMyResult;
    *n_AU3_ErrorCode    = 5555;
    *n_AU3_ExtCode      = 6666;

Don't set and then reread the result variable, just write to it once...for the result. The Get functions are for reading the input parameters only.

Link to comment
Share on other sites

  • Administrators

@Jon: I started writing some Service-functions for testing.

The only thing I'm missing at the moment is to return an (multi)array.

At the moment I'm doing it like:

A|1

B|2

C|3

returns a string "A|1 LineFeed B|2 LineFeed C|3".

So long :whistle:

Holger

Hmm, yes, arrays. That will need some work - it may not be pretty either (like the internal array setting code)
Link to comment
Share on other sites

pMyResult = AU3_AllocVar();

    AU3_SetString(pMyResult,"Hello World"); 

    *p_AU3_Result       = pMyResult;
    *n_AU3_ErrorCode    = 5555;
    *n_AU3_ExtCode      = 6666;

Don't set and then reread the result variable, just write to it once...for the result.  The Get functions are for reading the input parameters only.

<{POST_SNAPBACK}>

Ah, O.K. I did that now, but I'm still getting the AU3 error.

msgbox(0,"",$retval & " @error: " & @error & " @extended: " & @extended)

msgbox(0,"",$retval & " @error: " & ^ERROR

Error: Unknown macro.

Attached you'll find the plugin source code, the dll and the AU3 script. Hopefully somebody can reproduce this....

Very strange: I do get different errors with the same script, when I add some comments at the end of one script !???!

Can somebody please test this with the attached files?

EDIT: I'm getting a different error, when I use the original AU3_FreeVar() call. See error.jpg in second attached ZIP. That's again the problem I described in my previous posts AND the output string is kind of "damaged" also here. "@extended: 6666" becomes "extended6666". Where is the "@" and ": " ??? And, what's 6581362 in the message box. It should be "Hello World"....

Thanks

Kurt

plugin_problems.zip

plugin_problem_2.zip

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Mistake in the example I did.  #define NUMFUNCS should be 1 not 2 - will cause some overflow errors.  Try that.  Otherwise the code looks correct.

<{POST_SNAPBACK}>

O.K. I changed that, unfortunately I get the same error. :whistle:

Do you get the same errors with the DLL I sent? Could it be a problem with Dev-C++ ?? Unfortunately I don't have VC6 to test it with.

What about the "problem" in AU3_FreeVar I mentioned in an earlier post? If I don't change that code I will get that strange return value of 6581362. If I change the AU3_FreeVar code (delete free(pVar)), I get the correct return value ("Hello World"), however there seem to be some overflow errors (see last posts).

EDIT:

Why is the allocated memory of the variable freed in AU3_FreeVar()? AU3_FreeVar() is used at the beginning of all AU3_Setxxx functions, which will release the memory area of the plugin variable, allocated in AU3_AllocVar(). However, within the functions AU3_Setxxx the variable is still used.

void AU3_SetInt32(AU3_PLUGIN_VAR *pVar, int nValue)
{
    AU3_FreeVar(pVar);

    pVar->m_nType = AU3_PLUGIN_INT32;
    pVar->m_nValue = nValue;
}

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

  • Administrators

Yeah, you are correct. There is a bug

Create a new function called AU3_ResetVar() in au3plugin.c

/****************************************************************************
 * AU3_ResetVar()
 ****************************************************************************/

void AU3_ResetVar(AU3_PLUGIN_VAR *pVar)
{
    if (pVar == NULL)
        return;

    if (pVar->m_nType == AU3_PLUGIN_STRING)
        free(pVar->m_szValue);

}

And in all the AU3_Setxxx functions replace FreeVar with ResetVar.

I'll update and recheck when I get chance.

Link to comment
Share on other sites

Create a new function called AU3_ResetVar() in au3plugin.c

And in all the AU3_Setxxx functions replace FreeVar with ResetVar.

O.K., I already did that (see my post #29). After that changes I'm getting the errors described in my post #33. "Unknown macro @error" and "$retval used without declaration" (BTW: I did not change example.c or the AU3 script).

Strange..... There seems to be still an overflow somewhere.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Hmm, yes, arrays.  That will need some work - it may not be pretty either (like the internal array setting code)

arrays would be nice.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

  • Administrators

Ok, found the bugs. Redownload the sdk for the updated files. But, you will need to wait for the next beta release (also a bug in the AutoIt part :/ ) before it works.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...