realbasic-plugins
[Top] [All Lists]

REALRegisterModule problem

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: REALRegisterModule problem
From: Bob Delaney <delaneyrm at earthlink dot net>
Date: Tue, 20 May 2008 01:04:28 -0500
Authentication-results: mx.google.com; spf=pass (google.com: domain of realbasic-plugins-bounces at lists dot realsoftware dot com designates 66.116.103.65 as permitted sender) smtp dot mail=realbasic-plugins-bounces at lists dot realsoftware dot com
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
I wanted to test passing an array of doubles from a REALbasic  
application to a plugin which would then modify the values in that  
array for the application.

My G4 iMac has OS X 10.5.2. I used Xcode 3.0 with the latest SDK  
plugin files from RB 2008 Release 2 to make the plugin. I've read that  
it's better to use REALRegisterModule rather than REALRegisterMethod,  
so I used the example "Complete Module" from the SDK to code the  
interface file as:

_____
/* testArray.cpp */

#if WIN32
#include "WinHeader++.h"
#endif

#include "rb_plugin.h"

static void modifyArray(REALarray arr);

static REALmethodDefinition TestArrayMethods[] = {
        { (REALproc)modifyArray, REALnoImplementation, "modifyArray(arr As  
REALarray)" },
};


REALmoduleDefinition TestArrayDefinition = {
        
        kCurrentREALControlVersion,
        
        // This field specifies the name of the class which will be
        // exposed to the user
        "TestArray",
        
        // Methods
        TestArrayMethods,
        sizeof( TestArrayMethods ) / sizeof( REALmethodDefinition ),
        
        // Constants
        nil,
        0,
        
        // Properties
        nil,
        0,
};

static void modifyArray(REALarray arr)
{
        int             i, n;
        double  value;
        
        n = REALGetArrayUBound(arr);
        
        for(i=0;i<n;i++)
        {
                REALGetArrayValue(arr, i, &value);
                REALSetArrayValue(arr, i, 2*value);
        }
        
}/* modifyArray */

void PluginEntry()
{
        
        // Register our module
        REALRegisterModule( &TestArrayDefinition );
        
}
_____

The plugin "testArray.dylib" compiled with no problems. I put that  
into REALbasic's Plugins folder. Then I created an RB project with a  
Pushbutton and a Multi-line EditField. The Pushbutton script is:

   dim arr(6) As Double
   dim i As Integer
   dim myString As String
   for i=0 to 5
     arr(i)=i
   next
   TestArray.modifyArray(arr)
   myString=""
   for i=0 to 5
     myString = myString + val(arr(i)) + EndOfLine
   next
   EditField1.text = myString

Note that for the line after the first "next" typing "Tes" caused  
"TestArray" to appear. And then typing "." caused "modifyArray" to  
appear. Since my REALmoduleDefinition did define the class name as  
"TestArray", and my method is named "modifyArray", all seemed well.

But when I clicked on the "Run" button I got an error window saying:
_____
An error occurred while compiling this project.

Message: There is no class with this name.

File: testArray.dylib

Location: TestArray.modifyArray
_____

What am I doing wrong? I note that I was able to compile and use the  
"Complete Module" plugin without having this problem.

Thanks for your help.
Bob

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>