Re:making variable text conform to a constant space

From: Angus A. Mezick (dodger@WPI.EDU)
Date: 05/24/96


try this:
/*
   adds spaces to the end of strings so that you can be sure what length
> they
   will be.  First used to make the score command come out correctly
   takes in the string to alter and the total number of spaces the string
   should take up, puts out (in source) a string of length total_length
   ending with a \0
   masque 3/11/95
*/
void str_add_spaces(char *source,int total_length)
{
  char *string = source;
  int i=0;

  while((total_length>=i)&&(*string!='\0'))
   {
     *string++;
     i++;
   }

  for(;i<=total_length;i++)
   {
        *string=' ';
        *string++;
   }
  *string='\0';

}
thus on Thu, 23 May 1996 21:58:10 -0500, Mudder virtually scripted...

> I have a problem I have been trying to work out for a few days now.
> what I am trying to do is, as an example, make a box for some variable
> output to a player, Like exp or gold.
 
> this is what I want for output:

>             ______________________________________________
>            |                                              |
>            |   Exp to Level: 12345   current Exp: 123456  |
>            |                                              |
>            |   Gold on hand: 12345  Gold in bank: 123456  |
>            |______________________________________________|


> however, this is what I get :(

>             ______________________________________________
>            |                                              |
>            |   Exp to level: 123456  current Exp: 1234567   | <--
>            |                                              |      |
>            |   Gold on hand: 1234   Gold in bank: 12345 |    <---|                      
>            |______________________________________________|      |
>                                                                  |
> how do I make the box stay in place \____________________________|
> when the variables change?          /


> This problem is REALLY getting frustrating :(
 

> _Glenn_



This archive was generated by hypermail 2b30 : 12/18/00 PST