Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Oct 19, 2017 6:32 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Modify a string array in a plugin ?
PostPosted: Tue May 06, 2008 12:38 pm 
Offline

Joined: Sun Apr 20, 2008 9:38 pm
Posts: 10
Using the example code

REALstring arrayTestStringFunc(REALstringArray arr)
{
.
.
.
MessageBox(0,REALCString(REALGetArrayString(arr,i)),"Real Array Test",1);

RServername = REALBuildString(servername, strlen(servername));

REALSetArrayValue( (REALarray) arr,i, RServername);

MessageBox(0,REALCString(REALGetArrayString(arr,i)),"Real Array Test",1);

return RServername;
}

The first message box shows the contents of the string passed to plugin in the arrary arr(i)
The REALSetArrayValue does not produce any error in compile or execution
The second message box shows the ORIGINAL contents of the array ( it is unmodified after the REALSetArrayValue )
The function properly returns the RServerName to Realbasic, but the array remains unmodified by the plugin.

The plugin acts like the array of strings is passed to the plugin byvalue. Is there a way for the plugin to modify the array ?


Top
 Profile  
Reply with quote  
 Post subject: Re: Modify a string array in a plugin ?
PostPosted: Tue May 06, 2008 12:49 pm 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Hi,

REALGetArrayString returns a string which you must unlock.

Gruß
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Modify a string array in a plugin ?
PostPosted: Wed May 07, 2008 7:37 am 
Offline

Joined: Sun Apr 20, 2008 9:38 pm
Posts: 10
Thanks so much for the reply, but I am tring to modify the Array, not the string I extracted from it.

I wanted to pass an array to a plugin, modify its contents and return it to realbasic.

I can do this with a structure (ByRef), or return a string from a function. But I do not see any way to modify a string array, passed to a plugin.

Imagine using a plugin to sort the contents of the array, for instance........


Top
 Profile  
Reply with quote  
 Post subject: Re: Modify a string array in a plugin ?
PostPosted: Wed May 07, 2008 4:19 pm 
Offline
User avatar

Joined: Wed Sep 28, 2005 8:39 am
Posts: 9341
Location: St Augusta, MN
You can modify the contents by using REALSetArrayValue -- which is documented in the SDK under the Plugin SDK Array Reference.


Top
 Profile  
Reply with quote  
 Post subject: Re: Modify a string array in a plugin ?
PostPosted: Wed May 07, 2008 7:52 pm 
Offline

Joined: Sun Apr 20, 2008 9:38 pm
Posts: 10
Thanks Aaron,

As you can see for the code snippet above, I tried to use that function, as (sparsely) documented, but it does not change the array value, even in the plugin, immediatlely following the RealSetArrayValue command. It appears that it is calling the Plugin function ByVal , or I am modifying a 'locked' memory area. If I try to change the array to BYRef, I get untold amount of compiler errors or the RB executable crashes.

REALmethodDefinition arrayTestStringDefn = {
(REALproc) arrayTestStringFunc,
REALnoImplementation,
"arrayTestString(arr() as String) As String" <------- ByRef ?
};
Is ByRef needed above for the array to be modified ?

REALstring arrayTestStringFunc(REALstringArray arr) <---------- *arr ?

*arr does not produce happy campers, lots of compiler errors. Casts that overcome compiler errors cause the realbasic app to lockup.

The only thing that is unusual is the need to cast the REALstringArray to a REALarray in the REALSetArrayValue. Although it is declared in the function parameter as REALstringArray, and I can read it by casting it to (REALarray), the compiler pukes if I try to use REALSetArrayValueString .... undefined error ......


Top
 Profile  
Reply with quote  
 Post subject: Re: Modify a string array in a plugin ?
PostPosted: Wed May 07, 2008 9:58 pm 
Offline
User avatar

Joined: Wed Sep 28, 2005 8:39 am
Posts: 9341
Location: St Augusta, MN
If you take the original code, and step thru it to the point where it gets into PluginMain.cpp, you should get into REALSetArrayValueString. Are you sure that the function pointers are loaded properly? The first function loaded is a call to RuntimeArrayDirectGetSetProc, and the second is a function pointer loaded from calling RuntimeArrayDirectGetSetProc itself.


Top
 Profile  
Reply with quote  
 Post subject: Re: Modify a string array in a plugin ?
PostPosted: Thu May 08, 2008 2:30 pm 
Offline

Joined: Sun Apr 20, 2008 9:38 pm
Posts: 10
I was limited in the version of RB I could use, due to libcairopango dependencies not being met in the version of Redhat RHEL4 I must be compatible with. These dependencies probably cannot be met. So I was using RB2007 r2....No Debugging avaiable..... Rb2008r2 works with the same array plugin that rb2007r2 fails on. So I am going to try RB2007r4, to see if I can make arrays work, or debug the problem, and hopefully still have RHEL4 compatibility........

Thanks again.....


Top
 Profile  
Reply with quote  
 Post subject: Re: Modify a string array in a plugin ?
PostPosted: Thu May 08, 2008 4:01 pm 
Offline

Joined: Sun Apr 20, 2008 9:38 pm
Posts: 10
rb2007r4 executables ldd shows libpangocairo-1.0.so.0 => not found

So I guess I am screwed comming and going... I will have to pass array type data another way I guess......


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group