-----Original Message----- From: Cj To: CIRCLE@post.queensu.ca Sent: 5/12/00 9:20 PM Subject: [CIRCLE] [NEWBIE]Centering Lines What would be the best way of centering lines of text in a text editor? If you wanted the same result(centered text) on the MUD? -----Reply----- You'd have to decide what to set as the width of everyone's screen that logs onto your mud. In most cases you will be wrong because of fonts, monitor sizes and different telnet mud clients, but by just choosing something like 80 to be the default you can make a mathematical formula to determine the number of spaces that you have to put before your string of text, such as: spaces = (80 - strlen(mystring)) / 2; and then create the line of text: *buf = '\0'; for (i = 1; i <= spaces; i++) strcat(buf, " "); sprintf(buf2, "%s%s\r\n", buf, mystring); buf2 is now your centered line of text. There is probably 5 different ways you can do this, but this is probably the easiest to understand. Later, you can probably add a variable to a character's saved information to allow them to change the length of the lines on their screen and then have your formula use that variable. Best regards, Rick +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT