Hi group,
is it possible to use the operator_multiply so that you can write : s2 = 3*s1
if s1 contains “0”, then s2 contains “000”
if s1 contains “abC” then s2 will have “abCabCabC”
thanks.
Hi group,
is it possible to use the operator_multiply so that you can write : s2 = 3*s1
if s1 contains “0”, then s2 contains “000”
if s1 contains “abC” then s2 will have “abCabCabC”
thanks.
Nope. But you can create a method that does that.
My M_String module has a Repeat function that does that. I lifted it from StringUtils which demonstrated the fastest way.
Sub copies(text As String, a As Integer) As String
Dim myText As string
For counter As Integer = 1 to a
mytext = mytext + text
Next
Return myText
End Sub
Code
Dim NewText As String = copies(s1, 3)
//Something like that.
[quote=298392:@Jym Morton]Sub copies(text As String, a As Integer) As String
Dim myText As string
For counter As Integer = 1 to a
mytext = mytext + text
Next
Return myText
End Sub
Code
Dim NewText As String = copies(s1, 3)
//Something like that.[/quote]
NOTE: Don’t use Text as a parameter name. It’s a keyword.
Why has nobody mentioned the method shown in Xojo’s own Language Ref???
Examples/Advanced/MemoryBlock/FastStringAppend
Hmmm I use it all the time because it’s not in the list and doesn’t throw an error.
[quote=298669:@Jym Morton]Hmmm I use it all the time because it’s not in the list and doesn’t throw an error.
https://documentation.xojo.com/index.php/Category:Keywords[/quote]
Please don’t poke that fire. I like being able to use a Text property on HTML Edit to make it behave like a TextArea.
[quote=298669:@Jym Morton]Hmmm I use it all the time because it’s not in the list and doesn’t throw an error.
https://documentation.xojo.com/index.php/Category:Keywords[/quote]
It is not a problem in older versions of Xojo pre-2015. But in more recent versions, you will not be able to use Text anymore in new properties, because it is a reserved word. I simply switched to ‘txt’.
Note that your old projects won’t be broken. Xojo ensured that older parameters and variables called “Text” will still be honored ; you simply cannot create a new one.
I would advise that if you create new parameters and variables, you try to switch to something different for now on, in order to avoid future issues.‘txt’, ‘texte’, whatever…