Page 1 of 1
GetFilePartWE
Posted: Thu Mar 17, 2011 2:57 pm
by Droopy
Hello,
Code: Select all
ProcedureDLL.s GetFilePartWE(file.s) ; Return only file part without extension
file.s=ReverseString(GetFilePart(file))
file=Right(file,Len(file)-FindString(file,".",1))
file=ReverseString(file)
ProcedureReturn file
EndProcedure
Test :
Code: Select all
Debug GetFilePartWE(ProgramFilename())
The function return Purebasic1
With Tailbite 1.4.7 the function return : C:\Users\descaves\AppData\Local\Temp\Purebasic1.exePurebasic1
Any idea ?
Re: GetFilePartWE
Posted: Thu Mar 17, 2011 3:19 pm
by gnozal
Iirc it's a known Tailbite issue with string returning functions when used as procedure parameters.
I guess this code works ?
Code: Select all
Tmp.s = ProgramFilename()
Debug GetFilePartWE(Tmp)
Re: GetFilePartWE
Posted: Thu Mar 17, 2011 3:37 pm
by Droopy
Hello Gnozal.
I know a function wich return string can't call another function wich return string.
But i call GetProgramFilename() wich is an internal function.
Your solution works.
My old lib (Purebasic 3.94) works well with this function.
Could this bug be fixed ?
Re: GetFilePartWE
Posted: Thu Mar 17, 2011 3:46 pm
by gnozal
I guess it's related to the other string issues.
It probably could be fixed but I am no asm guru.
And the fix should only be applied if a function was used as string parameter.
Re: GetFilePartWE
Posted: Thu Mar 17, 2011 4:45 pm
by Droopy
Code: Select all
ProcedureDLL.s Test(file.s)
ProcedureReturn
EndProcedure
Compiled and tested with MessageRequester("",Test(ProgramFilename()))
return C:\Users\descaves\AppData\Local\Temp\Purebasic1.exe
Re: GetFilePartWE
Posted: Thu Mar 17, 2011 10:49 pm
by Droopy
Is it possible to create a topic for asm guru to fix this bug ?
Re: GetFilePartWE
Posted: Mon Mar 21, 2011 11:52 am
by lexvictory
I don't know that it can be fixed; string handling is done differently in PB made functions than it is in C - at least from what I can tell by the example sources in C
I might take a look when I get the time, but if someone can figure out the cause of it I might be able to write a quick fix...
I may have thought of a solution to calling another TB string function from a TB procedure, but we'll see how that works...