Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Dec 07, 2019 7:38 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: STRANGE behaviour when passing a CString pointer (ByRef)
PostPosted: Fri Jan 13, 2012 10:05 am 
Offline

Joined: Tue Mar 22, 2011 4:46 am
Posts: 28
Hi,

I have an external method that gets a string pointer as an input parameter, like below:
Declare Function ExternalFunction LIB "name.dll" ALIAS "SomeAlias" (ByRef strName As CString) As Integer


When I call this method, if my Cstring variable (in this case "strName ") has less than 140 characters and does not contain a new line character then
appears as empty in the external method.

If the strName variable has more than 140 characters and also contains a new line character, then everything works just fine.

Anyone can explain this please?
Any help is appreciated!!!!

Real Studio 2011, Release 4, on Windows 7.


Top
 Profile  
Reply with quote  
 Post subject: Re: STRANGE behaviour when passing a CString pointer (ByRef)
PostPosted: Sun Jan 15, 2012 6:21 am 
Offline

Joined: Tue Mar 22, 2011 4:46 am
Posts: 28
Hi,

I have an external method (created with PowerBasic) that gets a string pointer as an input parameter, like below:
Declare Function ExternalFunction LIB "name.dll" ALIAS "SomeAlias" (ByRef strName As CString) As Integer


When I call this method, if my Cstring variable (in this case "strName ") has less than 140 characters and does not contain a new line character then
appears as empty in the external method.

If the strName variable has more than 140 characters and also contains a new line character, then everything works just fine.

Anyone can explain this please?
Any help is appreciated!!!!

Real Studio 2011, Release 4, on Windows 7.[/quote]


Top
 Profile  
Reply with quote  
 Post subject: Re: STRANGE behaviour when passing a CString pointer (ByRef)
PostPosted: Sun Jan 15, 2012 5:10 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
How is the parameter defined in the dll? char **? I presume you're passing a Memoryblock to the declare.


Top
 Profile  
Reply with quote  
 Post subject: Re: STRANGE behaviour when passing a CString pointer (ByRef)
PostPosted: Mon Jan 16, 2012 3:53 am 
Offline

Joined: Tue Mar 22, 2011 4:46 am
Posts: 28
Thanks for your response timhare.

In the PowerBasic method, the parameter is defined as "STRING POINTER" which is equivalent to char **.
In the RealBasic method, I'm calling the PB method using the string's pointer (use ByRef).

I tried to use memoryBlock but it didn't work at all.


Top
 Profile  
Reply with quote  
 Post subject: Re: STRANGE behaviour when passing a CString pointer (ByRef)
PostPosted: Mon Jan 16, 2012 1:40 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Declare it

(strname as Ptr)

and pass it a memoryblock.


Top
 Profile  
Reply with quote  
 Post subject: STRANGE behaviour when passing a CString pointer (ByRef)-SOL
PostPosted: Tue Jan 17, 2012 3:09 am 
Offline

Joined: Tue Mar 22, 2011 4:46 am
Posts: 28
Thank you very much timhare. It worked!!!!!
Actually I also had to change the string type in declaration of the PB method from STRING to STRINGZ (anyway this is PB).
But since I knew from your post what was the correct declaration in RB, I tried various declarations in the external method until it worked.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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