Mail Archives: djgpp/1999/01/10/10:40:46
Non vital information in ().
vern (vern AT iocc DOT com) wrote:
: here is the finction. it is the part of a 'scrolling window' that
: displays the messages, and scrolls them.
: the locate(x, y) function moves the cursor on the screen to column x,
: and row y. the clrreset() function resets the text colors.
:
:
: void msginput(char *msg) /* NEEDS WORK */
: {
:
: int x = 0; /* used as a loop counter */
: char msg1[78]; /* always contains line 1 */
: char msg2[78]; /* always contains line 2 */
: char msg3[78]; /* always contains line 3 */
: char msg4[78]; /* always contains line 4 */
Are these msg? supposed to remember things in between calls? The code
later on seems to indicate that. Then you need to make them static.
: textcolor(3); /* set color to cyan */
:
: if(count==0) /* print on the top line */
: {
: strcpy(msg1,msg);
(As you know the max length is 78 I'd do this to guard against too
long input strings:
#define MAX_LEN (78)
char msg1[ MAX_LEN ];
...
strncopy(msg1, msg, MAX_LEN);
msg1[ MAX_LEN - 1 ] = 0;
)
: locate(2,19);
: cprintf("%s",msg1);
: locate(2,20);
: count++;
: }
: else if(count==1) /* print on the second line */
: {
: strcpy(msg2,msg);
: locate(2,20);
: cprintf("%s",msg2);
: locate(2,21);
: count++;
: }
: else if(count==2) /* print on the third line */
: {
: strcpy(msg3,msg);
: locate(2,21);
: cprintf("%s",msg3);
: locate(2,22);
: count++;
: }
: else if(count==3) /* print on the fourth line */
: {
: strcpy(msg4,msg);
: locate(2,22);
: cprintf("%s",msg4);
: count++;
: }
: else if(count==4) /* move everything up a line, and print the newest
: line */
(Perhaps you should consider a switch statement.)
: {
: strcpy(msg1,msg2); /* recopy all the strings */
: strcpy(msg2,msg3);
: strcpy(msg3,msg4);
: strcpy(msg4,msg);
Here you copy garbage to msg1, then garbage to msg2, then to
msg3. Then you copy your in param (msg) to msg4.
: locate(2,19);
:
: cprintf("
: ");
(What's this? Doesn't cprintf() support '\n'?)
[Klippa, klapp, kluppit rest of code.]
Holmboe, Symphony No. 8,
MartinS
- Raw text -