Page 1 of 1
String pointer wrong parameter type?
Posted: Tue Sep 22, 2009 10:15 am
by Mistrel
This works in PureBasic but as a TailBite library it's classified as "Bad parameter type: a string is expected.".
Code: Select all
ProcedureDLL TB_Test(*String.s)
Debug *String.s
EndProcedure
TB_Test(@"Hello!")
Re: String pointer wrong parameter type?
Posted: Tue Sep 22, 2009 11:22 am
by helpy
Sorry! Originally I wrote in german! Here the translation:
According to the error message "*String.s" in the procedure declaration is interpreted as string (not as pointer) ... that means: the routine expects a string, but @"Hello!" is a pointer!
Try this:
Code: Select all
ProcedureDLL TB_Test(*pString.String)
Debug "Pointer: " + Str( *pString )
Debug "String: " + *pString\s
EndProcedure
TB_Test(@"Hello!")
The combination of pointer "*" and datatype ".s" should never be used!
Re: String pointer wrong parameter type?
Posted: Tue Sep 22, 2009 2:24 pm
by lexvictory
@Mistrel: wasn't it discussed in one of your bug reports that a pointer with .s at the end doesn't make sense? (I'm not sure I kept reading the posts)
TB looks at the suffix (.s in this case) and uses that. Pointers would be caught in the default case.
Code: Select all
Select rv$
Case "b":
ImportFunction()\RetValue$ = "Byte"
Case "w":
ImportFunction()\RetValue$ = "Word"
Case "l":
ImportFunction()\RetValue$ = "Long"
Case "f":
ImportFunction()\RetValue$ = "Float"
Case "q":
ImportFunction()\RetValue$ = "Quad"
Case "d":
ImportFunction()\RetValue$ = "Double"
Case "s":
ImportFunction()\RetValue$ = "String"
Default
ImportFunction()\RetValue$ = "Long"
EndSelect
Re: String pointer wrong parameter type?
Posted: Wed Sep 23, 2009 5:09 am
by Mistrel
lexvictory wrote:@Mistrel: wasn't it discussed in one of your bug reports that a pointer with .s at the end doesn't make sense? (I'm not sure I kept reading the posts)
I made a very long post about this but it seems to have disappeared. My post is simply in regards to unexpected functionality. It's not mirroring the same behavior as PureBasic, which is unexpected.