Page 1 of 1
Pseudo string types and zero
Posted: Sun Jan 11, 2009 11:12 am
by mback2k
It would be cool if .p-ascii, .p-utf8 and .p-unicode could also accept zero as argument. This would help a lot with Windows API functions that either accept a string or zero.
Posted: Sun Jan 11, 2009 12:38 pm
by srod
Yes I have encountered that a couple of times now; there are indeed occasions when I would like to pass a null string and not an empty one. Unfortunately, it would appear that #Null$ equates to an empty string and not a null one.
+1.

Posted: Sun Jan 11, 2009 3:08 pm
by Trond
Maybe this helps?
Code: Select all
Procedure GetRawString(N.i)
If N = 0
Debug "Null string"
Else
Debug PeekS(N)
EndIf
EndProcedure
a.s
CallFunctionFast(@GetRawString(), a)
Posted: Sun Jan 11, 2009 3:12 pm
by mback2k
Trond, I don't understand what the purpose of this code snippet is.
I don't want to use it with CallFunction or Prototypes, I am using many WinAPI libraries with Import and it's a little bit annoying to always do the ASCII->Unicode and back convertion on my own, because sometimes I need to pass a string to one function and another time I need to pass a zero as argument to the same function at the same parameter index.
Edit: Now I see what you mean, but that way I can't use benefit .p-types.
Posted: Sun Jan 11, 2009 3:15 pm
by Trond
It shows that if you pass a non-initialized string variable, then it's like passing a null string.
Posted: Sun Jan 11, 2009 3:17 pm
by mback2k
Yes, but always creating a dummy string variable before calling a function seems to be a little bit unconventional. IMHO.
Pseudotypes have a purpose and they work very well. They just need to be tweaked a little.
Posted: Sun Jan 11, 2009 3:19 pm
by srod
Aye Trond has a good point there. Now why the hell did I not think of that before? Ack, must be getting old!
Still, it would be more explicit in a way if the pseudotypes could just accept an explicit zero.