i have tested the deltarho code above 
http://purebasic.fr/english/viewtopic.p ... 70#p496402 and it works okay, then i have applied the exact same method to call the powerbasic function Retain$, it has the same structure as Remove$. but here is a strange phenomena:
powerbasic dll:
Code: Select all
#COMPILE DLL "PB_RetainAny.dll"
#DIM ALL
FUNCTION RetainAny( BYVAL MainString AS STRING, BYVAL MatchString AS STRING ) EXPORT AS WSTRING
LOCAL sText AS WSTRING
  'MainString =  "Lo38ok2 Ma, n6o nu1mbe78rs!"
  'MatchString = "0123456789"
   sText = RETAIN$( MainString, ANY MatchString )
  FUNCTION = sText
END FUNCTION 
PureBasic code:
Code: Select all
Prototype.l ProtoRetainAny( param1.p-bstr, param2.p-bstr )
If OpenLibrary( 0, "PB_RetainAny.dll" )
  RetainAny.ProtoRetainAny = GetFunction( 0, "RETAINANY" )
  s1$ = "Lo38ok2 Ma, n6o nu1mbe78rs!"
  s2$ = "20123456789"
  MessageRequester("", PeekS(RetainAny( s1$, s2$ ) ))
  CloseLibrary(0)
EndIf
but the purebasic messageRequester is empty
now uncomment any one line of the 2 lines in the powerbasic dll:
Code: Select all
'MainString =  "Lo38ok2 Ma, n6o nu1mbe78rs!"
'MatchString = "0123456789"
and the purebasic will output the correct result :
3826178
i find it strange since the MainString and MatchString does not pass together while they do with the code of deltarho. i miss something ??  . and if possible how to provide these 2 strings by reference to the powerbasic dll
Thanks in advance
EDIT:
the following method works in PB 5.43LTS but 
uncheck create unicode exec in compiler options
powerbasic DLL:
Code: Select all
#COMPILE DLL "powerbasic_DLL.dll"
FUNCTION MB_Retain ALIAS "Retain" (BYREF param1 AS ASCIIZ * 4096, BYREF param2 AS ASCIIZ * 4096) EXPORT AS STRING
a$=param1
b$=param2
c$ = RETAIN$(a$, ANY b$)
MSGBOX CHR$(34)+c$+CHR$(34)
FUNCTION=c$
END FUNCTION   
purebasic code:
Code: Select all
If OpenLibrary(1,"powerbasic_DLL.dll")
  c.s = "Lo38ok2 Ma, n6o nu1mbe78rs!"
  d.s = "0123456789"
 
  If GetFunction(1,"Retain")
    Debug PeekS(CallFunction(1,"Retain",@c,@d))
  EndIf  
  EndIf
  CloseLibrary(1)
it should output  3826178