Is there a way to define new lines in strings? Like how in C you type /n
new line?
Blitz3D Forums/Blitz3D Beginners Area/new line? chr$(13)
string$ = "line1" + chr$(13) + "line2"
ok... wait that doesn't work! it really should of. the windows/dos newline trigger is chr$(13)+chr$(10). that didn't work either.
string$ = "line1" + chr$(13) + "line2"
ok... wait that doesn't work! it really should of. the windows/dos newline trigger is chr$(13)+chr$(10). that didn't work either.
Print "Hi"
Print ""
Print "Hi"
Print ""
Print "Hi"
What dmaz says does work in as much as you can create a string with a carriage return/newline character in it, but displaying them in blitz is another matter, as it seems print/write/text only work with printable characters.
Try this, its a simple function that does what you need (i think). I saw DarkLordz do this with a bitmap font, it was quiet nice.
Updated the code, i found a little bug. Oh yes, i took credit for it too! :D
; Set Graphics ; Graphics 640, 480, 16, 2 SetBuffer BackBuffer() ; My String ; my_string$ = "BlitzBasic" + Chr(13) + "-=Rulez=-" + Chr(13) + Chr(13) + "By Cermit!" ; Main Loop ; Repeat ; Random Color ; Color Rnd(255), Rnd(255), Rnd(255) ; Draw Your String ; DrawText(my_string$, 240, 210) ; Loop End ; Flip Cls Until KeyHit(1) End ; Draw Text Function ; Function DrawText(my_str$, x, y) Local char$, lines, offset = 1 For s = 1 To Len(my_str$) char$ = Mid$(my_str$, s, 1) If Asc(char$) = 13 Then Text x, y + lines * 14, Mid$(my_str$, offset, s - offset) offset = s + 1 lines = lines + 1 EndIf Next Text x, y + lines * 14, Mid$(my_str$, offset, s - offset) End Function
Updated the code, i found a little bug. Oh yes, i took credit for it too! :D
Uh?
Cermit/Darklordz's approach will do. Just spreading it out over multiple Print commands won't work because I want to store some text of arbitrary length in a string variable and have it display correctly. So I'll use that DrawText command instead of simply calling Text.