ReneMiner
30-01-2015, 12:16
I was experimenting a little, playing around with heap and such and found some weird behaviour when using Print
Not sure about the reason but if i use Print to print out single letters in a row
(String * 1 here, but same happens if using Byte-layover and CHR$(variable) -function)
somehow the first char does not seem to reach the console-window
depending on how the string gets composed:
"string" & {variable|function} [&...]
or
{variable|function} & "string" [&...]
Uses "console"
Dim foo As DWord = HEAP_AllocByStr( "hello world!" _
& $CRLF _
& "welcome to thinBasic" )
PrintL HEAP_Get(foo)
PrintL
Dim char As String * 1 At foo
PrintL "first char: " & $DQ & char & $DQ
PrintL
PrintL "run 1: string " & $DQ & "." & $DQ & " in front"
PrintL
While VarPtr(char) <= HEAP_End(foo)
Print "." & char
SetAt( char, VarPtr(char)+1 )
Wend
PrintL Repeat$(2, $CRLF)
' reset
SetAt(char, foo)
PrintL "run 2: variable 'char' in front"
PrintL
While VarPtr(char) <= HEAP_End(foo)
Print char & "."
SetAt( char, VarPtr(char)+1 )
Wend
PrintL Repeat$(2, $CRLF)
SetAt(char, foo)
PrintL "where is the " & $DQ & char & $DQ & " ?"
PrintL $CRLF & " -------------------- key to end"
WaitKey
Not sure about the reason but if i use Print to print out single letters in a row
(String * 1 here, but same happens if using Byte-layover and CHR$(variable) -function)
somehow the first char does not seem to reach the console-window
depending on how the string gets composed:
"string" & {variable|function} [&...]
or
{variable|function} & "string" [&...]
Uses "console"
Dim foo As DWord = HEAP_AllocByStr( "hello world!" _
& $CRLF _
& "welcome to thinBasic" )
PrintL HEAP_Get(foo)
PrintL
Dim char As String * 1 At foo
PrintL "first char: " & $DQ & char & $DQ
PrintL
PrintL "run 1: string " & $DQ & "." & $DQ & " in front"
PrintL
While VarPtr(char) <= HEAP_End(foo)
Print "." & char
SetAt( char, VarPtr(char)+1 )
Wend
PrintL Repeat$(2, $CRLF)
' reset
SetAt(char, foo)
PrintL "run 2: variable 'char' in front"
PrintL
While VarPtr(char) <= HEAP_End(foo)
Print char & "."
SetAt( char, VarPtr(char)+1 )
Wend
PrintL Repeat$(2, $CRLF)
SetAt(char, foo)
PrintL "where is the " & $DQ & char & $DQ & " ?"
PrintL $CRLF & " -------------------- key to end"
WaitKey