Code: Select all
define txt.s="Hello world!"
define _str.s
define i.b
for i=1 to len(txt)
_str=_str+txt[i]"
next i
debug (_str)
Code: Select all
define txt.s="Hello world!"
define _str.s
define i.b
for i=1 to len(txt)
_str=_str+txt[i]"
next i
debug (_str)
Code: Select all
Define txt.s="Hello world!"
Define _str.s
For i=1 To Len(txt)
_str=_str+Mid(txt,i,1)
Next i
Debug (_str)
Code: Select all
For i=1 To Len(txt)
Code: Select all
Define txt.s="Hello world!"
Define _str.s
Define _strlen
_strlen=Len(txt)
For i=1 To _strlen
_str=_str+Mid(txt,i,1)
Next i
Debug (_str)
Code: Select all
Define txt.s="Hello world!"
Define *c.Character = @txt
Define _str.s
While *c\c
_str + Chr(*c\c)
*c + 2
Wend
Debug _str
Code: Select all
Define txt.s="Hello world!"
Define *c.Character = @txt
Define _str.s = Space(Len(txt))
Define *d.Character = @_str
While *c\c
*d\c= *c\c
*c + 2
*d + 2
Wend
Debug _str
Code: Select all
Structure ArrayOfChar
c.c[0]
EndStructure
Define txt.s="Hello world!"
Define *txt.ArrayOfChar = @txt
Define _str.s
len = Len(txt) - 1
For i = 0 To len
_str =_str + Chr(*txt\c[i])
Next i
Debug (_str)
Code: Select all
Structure ArrayOfChar
c.s{1}[0]
EndStructure
Define txt.s="Hello world!"
Define *txt.ArrayOfChar = @txt
Define _str.s
len = Len(txt) - 1
For i = 0 To len
_str =_str + *txt\c[i]
Next i
Debug (_str)
Code: Select all
Structure ArrayOfChar
StructureUnion
c.c[0]
s.s{1}[0]
EndStructureUnion
EndStructure
Define txt.s="Hello world!"
Define *txt.ArrayOfChar = @txt
Define _str.s
len = Len(txt) - 1
For i = 0 To len
_str =_str + *txt\s[i]
Next i
Debug (_str)
Code: Select all
EnableExplicit
DisableDebugger
Structure CharStr
StructureUnion
c.c
s.s{1}
EndStructureUnion
EndStructure
Define *s, StartTime, t1, t2, i, tmp.s
Define *c.CharStr, *u.Character
#Count = 1000000
tmp = "a"
*u = @tmp
*c = @tmp
; *u\c = 55
; *c\c = 55
StartTime = ElapsedMilliseconds()
For i = 0 To #Count
tmp = Chr(*u\c)
Next
t1 = ElapsedMilliseconds() - StartTime
StartTime = ElapsedMilliseconds()
For i = 0 To #Count
tmp = *c\s
Next
t2 = ElapsedMilliseconds() - StartTime
EnableDebugger
Debug "Chr = " + Str( t1)
Debug "Struct = " + Str( t2)
Code: Select all
Structure ArrayOfChar
StructureUnion ; shares memory (address)
c.c[0]
s.s{1}[0]
EndStructureUnion
EndStructure
Define txt$="Hello world!"
; will end in 30 seconds on M1 (without debugger):
For i = 0 To 111111 : txt$+"!" : Next
Define *txt.ArrayOfChar = @txt$
Define *txt2.Character = @txt$
Define _str.s
len = Len(txt$) - 1
t = ElapsedMilliseconds()
For i = 0 To len
_str + *txt\s[i]
Next i
t1= ElapsedMilliseconds() - t
;Debug (_str)
_str="" ; RESET
;len = Len(txt$) - 1
t = ElapsedMilliseconds()
For i = 0 To len
_str + Chr(*txt2\c)
*txt2 + 2 ; SizeOf(Character)
Next i
t2= ElapsedMilliseconds() - t
;Debug (_str)
_str="" ; RESET
;len = Len(txt$) - 1
t = ElapsedMilliseconds()
For i = 0 To len
_str + Chr(*txt\c[i])
Next i
t3= ElapsedMilliseconds() - t
;Debug (_str)
MessageRequester("Results",Str(t1)+~"\n"+Str(t2)+~"\n"+Str(t3))
Code: Select all
Define txt.s="Hello world!"
Define _str.s=txt
Debug (_str)
Nah; I just make a BIG "Hello world!!!!!!!!!!!!!!!" and then read each char and store it on the end of _str (for speed testing)