You are not logged in.
Lost Password?


Register To Post



 Bottom   Previous Topic   Next Topic

#1
Converting integers to strings and Cls
Posted on: 2009/12/29 18:02
PVB Elite
Joined 2008/12/28
Slovenia
635 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (11 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
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 
()
{
  
= -1;
  while(
28)
  {
    
i++;                //that's 48 spaces right there
    
vbTextOut(00i"                                                ");
  }
}
Top

#2
Re: Converting integers to strings and Cls
Posted on: 2009/12/29 21:32
Administrator
Joined 2000/1/8
Germany
2521 Posts
Highscore Top10Highscore Top ScoreCoder#1 PosterHOTY09 1stLong Time User (15 Years) App Coder90+ Game Ratings
Why not just copy over itoa from a newer version of libgccvb? :)
Top

#3
Re: Converting integers to strings and Cls
Posted on: 2009/12/29 22:43
PVB Elite
Joined 2003/7/26
USA
1465 Posts
PVBCC EntryCoderContributorSpecial AchievementTop10 PosterHOTY09 EntryLong Time User (15 Years) App Coder20+ Game RatingsPVBCC 2013 Entry
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/view ... ost_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, <string length 2>);


Where BGMMBase = 0x20000 (in case it's not defined in your libgccvb.h).

You could wrap it in a "cls()" function, if you like.
Top

 Top   Previous Topic   Next Topic


Register To Post