problem

TailBite specific forum

Moderators: gnozal, ABBKlaus, lexvictory

morosh
Enthusiast
Enthusiast
Posts: 293
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

problem

Post by morosh »

I'm using TailBite to make a small personal library:

Code: Select all

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: Select all

Debug removeextraspaces2("aa                bbbbb               ccc")
Debug "aa bbbbb ccc"
It didn't work.

putting the procedure in the same file:

Code: Select all

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
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: problem

Post by Polo »

Don't know about Tailbite but you've got one useless line: Global resultsdll.s :)
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: problem

Post by Bisonte »

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: Select all

; 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 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
morosh
Enthusiast
Enthusiast
Posts: 293
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: problem

Post by morosh »

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
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: problem

Post by Bisonte »

have you try this out ?

Here it worked... PB4.61b1(x86) and Tailbite 1.48
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8425
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: problem

Post by netmaestro »

Here it worked... PB4.61b1(x86) and Tailbite 1.48
Yes, it works here too, same setup. It worked with Tailbite 1.46 too.
BERESHEIT
morosh
Enthusiast
Enthusiast
Posts: 293
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: problem

Post by morosh »

I just installed TailBite 1.4.8 and PureBasic4.61b1 (I have older versions), the problem remains.
My part of lib is:

Code: Select all

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: Select all

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
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: problem

Post by Bisonte »

I mean.... have you try my code ? This works... I am also on Win7 x64
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Re: problem

Post by lexvictory »

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!
Post Reply