It is currently Sat Feb 23, 2019 5:51 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: problem
PostPosted: Thu Jan 19, 2012 9:51 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Aug 03, 2011 4:52 am
Posts: 212
Location: Beirut, Lebanon
I'm using TailBite to make a small personal library:
Code:
Global resultsdll.s

ProcedureDLL.s removeextraspaces(str.s)
 
 resultsdll=str
 
 While FindString(resultsdll, "  ",1) > 0
   resultsdll=ReplaceString(resultsdll, "  ", " ")
Wend
ProcedureReturn resultsdll
EndProcedure


and I tested it with the following code:
Code:
Debug removeextraspaces2("aa                bbbbb               ccc")
Debug "aa bbbbb ccc"


It didn't work.

putting the procedure in the same file:
Code:
Global resultsdll.s

Procedure.s removeextraspaces2(str.s)
 resultsdll=str
 
 While FindString(resultsdll, "  ",1) > 0
   resultsdll=ReplaceString(resultsdll, "  ", " ")
Wend
ProcedureReturn resultsdll
EndProcedure

Debug removeextraspaces2("aa                bbbbb               ccc")
Debug "aa bbbbb ccc"



works perfectly.

what's the problem?

Thank you

_________________
PureBasic: Surprisingly simple, diabolically powerful


Top
 Profile  
Reply with quote  
 Post subject: Re: problem
PostPosted: Thu Jan 19, 2012 10:09 pm 
Offline
Addict
Addict

Joined: Tue May 06, 2003 5:07 pm
Posts: 2422
Location: UK
Don't know about Tailbite but you've got one useless line: Global resultsdll.s :)


Top
 Profile  
Reply with quote  
 Post subject: Re: problem
PostPosted: Fri Jan 20, 2012 2:39 am 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1020
DLL and Returnstrings.... a lot of confusing...

I think, Tailbite have some issues, if your code is too small.
so only Compile this one function is useless...

If I make a Userlib, i made parts.
First the Init Part, the private part and then the public part.
the public and private part is really necessary if you want get a
string from your dll.

i hope you understand my text.

Code:
; Init your DLL

EnableExplicit

ProcedureDLL YourLib_Init()
  Global ReturnString.s
EndProcedure
ProcedureDLL YourLib_End()
  ; here if you have something
  ; to free up by yourself like FreeImage() etc.
EndProcedure

; the private functions...

Procedure.s pRemoveExtraSpace(String.s)
 
  While FindString(String, "  ",1) > 0
    String = ReplaceString(String, "  ", " ")
  Wend
  ProcedureReturn String
 
EndProcedure

; the public functions...

ProcedureDLL.s RemoveExtraSpace(String$) ; get rid of spaces
  ReturnString = pRemoveExtraSpace(String$)
  ProcedureReturn ReturnString
EndProcedure

_________________
PureBasic 5.46 LTS / 5.62 (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 32GB RAM | iChill GeForce GTX 980 X4 Ultra | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: problem
PostPosted: Fri Jan 20, 2012 5:59 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Aug 03, 2011 4:52 am
Posts: 212
Location: Beirut, Lebanon
from the manual, it's written:

"Note about returning strings from DLL's:

If you want to return a string out of a DLL, the string has to be declared as Global before using it. "

Also, this is a small part from my lib

and last, this is no reply to my question

_________________
PureBasic: Surprisingly simple, diabolically powerful


Top
 Profile  
Reply with quote  
 Post subject: Re: problem
PostPosted: Sat Jan 21, 2012 12:52 am 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1020
have you try this out ?

Here it worked... PB4.61b1(x86) and Tailbite 1.48

_________________
PureBasic 5.46 LTS / 5.62 (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 32GB RAM | iChill GeForce GTX 980 X4 Ultra | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: problem
PostPosted: Sat Jan 21, 2012 2:20 am 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 7993
Location: Fort Nelson, BC, Canada
Quote:
Here it worked... PB4.61b1(x86) and Tailbite 1.48

Yes, it works here too, same setup. It worked with Tailbite 1.46 too.

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: problem
PostPosted: Sat Jan 21, 2012 8:19 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Aug 03, 2011 4:52 am
Posts: 212
Location: Beirut, Lebanon
I just installed TailBite 1.4.8 and PureBasic4.61b1 (I have older versions), the problem remains.
My part of lib is:
Code:
Global resultsdll.s
ProcedureDLL.s removeextraspaces(str.s)
 resultsdll=str
 
 While FindString(resultsdll, "  ",1) > 0
   resultsdll=ReplaceString(resultsdll, "  ", " ")
Wend
ProcedureReturn resultsdll
EndProcedure


My test code is:
Code:
Global resultsdll2.s

Procedure.s removeextraspaces2(str.s)
 resultsdll2=str
 
 While FindString(resultsdll2, "  ",1) > 0
   resultsdll2=ReplaceString(resultsdll2, "  ", " ")
Wend
ProcedureReturn resultsdll2
EndProcedure

Debug removeextraspaces2("aa                bbbbb               ccc")
Debug removeextraspaces( "aa                bbbbb               ccc")
Debug "aa bbbbb ccc"

; result:
;aa bbbbb ccc
;aa                bbbbb               ccc
;aa bbbbb ccc


using W7 x64 ultimate

_________________
PureBasic: Surprisingly simple, diabolically powerful


Top
 Profile  
Reply with quote  
 Post subject: Re: problem
PostPosted: Sat Jan 21, 2012 11:44 am 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1020
I mean.... have you try my code ? This works... I am also on Win7 x64

_________________
PureBasic 5.46 LTS / 5.62 (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 32GB RAM | iChill GeForce GTX 980 X4 Ultra | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: problem
PostPosted: Sun Jan 22, 2012 3:51 am 
Offline
Addict
Addict

Joined: Sun May 15, 2005 5:15 am
Posts: 1027
Location: Australia
Looking at the code, I do not see why it would not work, and if I'm not mistaken some have found it works?
Have you checked that the testing code (where you use the generated lib) is using the correct ASCII/Unicode mode? (i.e. the same as the lib was compiled with), or are you using the multilib mode?

Also, I advise you remove the global for the return string; it is NOT needed with TB, only with a DLL (Don't follow the DLL guidelines in the manual for TB, ProcedureDLL is only used to determine whether a Procedure is private/internal or public/external)

_________________
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!


Top
 Profile  
Reply with quote  
 Post subject: Re: problem
PostPosted: Sun Jan 22, 2012 11:33 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Aug 03, 2011 4:52 am
Posts: 212
Location: Beirut, Lebanon
Found it: in compiler options, I forget "generate unicode executable" checked

thanks all :D

_________________
PureBasic: Surprisingly simple, diabolically powerful


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


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 © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye