Two questions:
1. How can I convert an integer to a string without having to use an ugly hack like this:
char x_str[3]; x_str[2]=0; x_str[0]=(x/10)+'0'; x_str[1]=(x%10)+'0';
My libgccvb.h doesn’t have itoa(), so that’s what I’ve been using.
2. I need a better way of clearing the screen of text than this:
int Cls () { i = -1; while(i < 28) { i++; //that's 48 spaces right there vbTextOut(0, 0, i, " "); } }
Why not just copy over itoa from a newer version of libgccvb? 🙂
I don’t think the code you posted is ugly… It’s a little limited, but perfectly serviceable.
If you can’t find itoa() or want even more text formatting power, you could use dasi’s posprintf() port:
http://www.vr32.de/modules/newbb/viewtopic.php?post_id=6529#forumpost6529
And as for clearing text, just use setmem() on the BGMap segment you’re using for text output. Something like:
setmem(BGMMBase + (row * 128 + column * 2), 0, );
Where BGMMBase = 0x20000 (in case it’s not defined in your libgccvb.h).
You could wrap it in a “cls()” function, if you like.
You must be logged in to reply to this topic.
3 Posts
Last post Dec 29, 2009 • 21:43