I thought you could do implicit conversion between String and Text. But it doesn’t always work.
I created a new function:
Function MyFunction(var1 as text, var2 as text, var3 as text) as Boolean
If I then do the following:
Dim A as string = "Some String"
Dim B as String = "Some other string"
Dim C as String = "A third string"
If MyFunction(A,B,C) Then
// Some code
End If
I get a compile error that states “Expected (Text, Text, Text), but these arguments are (String, String, String).”
If String implicitly coverts to Text, why is this an error? Do I have to create Text variables first? That’s going to make implementing text based functions a lot more difficult.
Oh, so Text to String is implicit but String to Text is not. Well, that’s confusing! You would think implicit conversions would be reciprocal!
No, I wanted to do something completely in the new framework plus it could be something that I need to use for iOS or maybe not. But the String.ToText method works fine enough…
One of the reasons Text has been introduced is to get rid of the troubles with implicit conversion (same as with the Auto data type as replacement for Variants). So it makes sense that Text → String is converted implicitly, but String → Text needs an explicit conversion with ToText.
If we’ve been diligent with managing our encodings for strings and want to make the transition to the new framework an easier process, is there any way (with extends/assigns or some sort of global trickery) to allow implicit conversions from String to Text within an individual project?
I’m not sure I well understand what TEXT is / String.
But I have questions, will the Xojo event which actually use or return String will use Text in the future ?
For example :
event KeyDown(Key as String) as Boolean
in a socket :
PageReceived(url as string, httpStatus as integer, headers as internetHeaders, content as string) Handles PageReceived
I don’t have exemple where the return valu is String but I suppose there is.
Will have I to replace all my String variables in Text ? Is it better to do so (String deprecated in the future) ?