Two lines with one Print?
Blitz3D Forums/Blitz3D Beginners Area/Two lines with one Print?
| ||
In the past, with other programming languages, I've been able to set up a string so that it got printed out as multiple lines of text, without having to call Print more then once. I can't seem to get that to work in Blitz3D. Somthing like this usually works. myString$ = "Line 1" + Chr$(13) + "Line2" Print myString$ the Chr$(13) is a carriage return I believe. Can anyone that understands my problem explain to me how I might achieve multiple lines with one call to Print/Write/Text? The only solution I'm seeing is rather cumbersome. I don't want to have to read each character in a loop using Mid$ in order to achieve this effect, unless that's indeed the easiest solution. Thanks in advance! |
| ||
Short answer: you can't. Longer answer: you might want to look into the Instr() command. That'll let you basically search a string for a Chr$(13). You can then snip out the bit you want, print it to screen, rinse and repeat until there's none of your original string left. Should be pretty fast, too. Oh, and consider bitmap fonts instead of TTF/Text/Print. |
| ||
I'm new to 3D, having actually only really made text based games until now, lol. I was wanting to be able to put some text on a few textures and was looking to do it the laziest and most familiar way possible. I didn't want to use a bitmap font mostly because of the extra effort :P Thanks for the information! I'll probably put this off tell tomorow then, as I decide what to do. |
| ||
Just draw the texture in paint. :) |
| ||
I didn't want to use a bitmap font mostly because of the extra effort :P Get Fontext. Dead easy to use and comes with code to draw fonts with minimal effort. Its free now, too. |
| ||
Does Write work with CHr$(13)? --------edit------------------- Ah, tried it. No it doesn't. I'm a little suprised that the control code ASCII chars cannot be used in this matter. If it's merely a matter of reducing the number of lines in your code, perhaps using colons between Print statements may help? |
| ||
it should be relative easy to write a print wrapper that will interpret some control chars like linebreak. example: my_print "hello" + chr$(10) + "world" waitkey() end function my_print(pri$) for i=1 to len(pri$) mi$=mid$(pri$,i,1) if mi$=chr$(10) then print pri2$ pri2$="" else pri2$=pri2$+mi$ endif next print pri2$ end function BTW, unlike Print, DebogLog allows to use eg. CHR$(10). |
| ||
You could even replace the blitz function print with your own print function like the one above, but using Write(). No recursive funtion calls allowed! |