beyondsociety
Technical User
I have created a program that draws a box in tclite. I installed Borland Turbo C++ 2.01 and when I ran the program, I got errors.
I can't figure out whats the problem. Any help would be appreciated.
It works fine in tclite!
Heres the source code:
// Box_draw.cpp - Writing a Box for our editor
/*
The location == Left, right, and bottom
The border == Single line, double
The colors == Main color, border color
Char* border == An array of 8 characters
border[0] == Left top corner
border[1] == Top center
border[2] == Right-top corner
border[3] == Right side
border[4] == Right-bottom corner
border[5] == Bottom center
border[6] == Left-bottom corner
border[7] == Left side
*/
#include <stdio.h>
#in6clude <conio.h>
void box_draw(int lft, int top, int rgt, int btm,
char* border, int outline_clr, int contents_clr);
void startup();
int main()
{
startup();
box_draw(5,5,45,15,"ÚÄ¿³ÙÄÀ³",62,23);
getch();
return 0;
}
char blanks[] = // 80 space chars
" "
" ";
void box_draw(int lft, int top, int rgt, int btm,
char* border, int outline_clr, int contents_clr)
{
/*
Coordinates must be within screen. Minimum box is 4 Columns
by 3 Rows. Drawing fails if you go to both Screen Right and
Screen Bottom.
Border chars are top-left corner, top-center, etc.,
clockwise to left corner. Valid colors are 0 to 255.
*/
// set the outline color
textattr(outline_clr);
// write the top line
gotoxy(lft,top);
putch(border[0]);
// Heres the routine thats giving me the problem
// 1.Error, expression syntax error in function box_draw
// 2.Error, undefined symbol 'i' in function box_draw
int i = lft+1; // first error
while(i<rgt) // second error
{
putch(border[1]);
i++;
}
// ------------------------------------------------
putch(border[2]);
// build the center line
blanks[0] = border[7];
i = rgt - lft;
blanks = border[3];
blanks[i+1] = 0;
// write the center line
i = top + 1;
while(i<btm)
{
gotoxy(lft,i);
cprintf(blanks);
i++;
}
// write the bottom line
gotoxy(lft,btm);
putch(border[6]);
i = lft+1;
while(i<rgt)
{
putch(border[5]);
i++;
}
putch(border[4]);
// repaint the center
if(outline_clr != contents_clr)
box_draw(lft+1,top+1,rgt-1,btm-1,
" ",contents_clr,contents_clr);
// repairing blanks[]
i = rgt-lft;
blanks[0] = blanks = blanks[i+1] = ' ';
gotoxy(1,1);
printf("Write the top line"
;
gotoxy(1,2);
printf("Write the center"
;
gotoxy(1,3);
printf("Write the bottom"
;
}
void startup()
{
textmode(C4350);
textattr(23);
clrscr();
}
// end of T.cpp
I can't figure out whats the problem. Any help would be appreciated.
It works fine in tclite!
Heres the source code:
// Box_draw.cpp - Writing a Box for our editor
/*
The location == Left, right, and bottom
The border == Single line, double
The colors == Main color, border color
Char* border == An array of 8 characters
border[0] == Left top corner
border[1] == Top center
border[2] == Right-top corner
border[3] == Right side
border[4] == Right-bottom corner
border[5] == Bottom center
border[6] == Left-bottom corner
border[7] == Left side
*/
#include <stdio.h>
#in6clude <conio.h>
void box_draw(int lft, int top, int rgt, int btm,
char* border, int outline_clr, int contents_clr);
void startup();
int main()
{
startup();
box_draw(5,5,45,15,"ÚÄ¿³ÙÄÀ³",62,23);
getch();
return 0;
}
char blanks[] = // 80 space chars
" "
" ";
void box_draw(int lft, int top, int rgt, int btm,
char* border, int outline_clr, int contents_clr)
{
/*
Coordinates must be within screen. Minimum box is 4 Columns
by 3 Rows. Drawing fails if you go to both Screen Right and
Screen Bottom.
Border chars are top-left corner, top-center, etc.,
clockwise to left corner. Valid colors are 0 to 255.
*/
// set the outline color
textattr(outline_clr);
// write the top line
gotoxy(lft,top);
putch(border[0]);
// Heres the routine thats giving me the problem
// 1.Error, expression syntax error in function box_draw
// 2.Error, undefined symbol 'i' in function box_draw
int i = lft+1; // first error
while(i<rgt) // second error
{
putch(border[1]);
i++;
}
// ------------------------------------------------
putch(border[2]);
// build the center line
blanks[0] = border[7];
i = rgt - lft;
blanks = border[3];
blanks[i+1] = 0;
// write the center line
i = top + 1;
while(i<btm)
{
gotoxy(lft,i);
cprintf(blanks);
i++;
}
// write the bottom line
gotoxy(lft,btm);
putch(border[6]);
i = lft+1;
while(i<rgt)
{
putch(border[5]);
i++;
}
putch(border[4]);
// repaint the center
if(outline_clr != contents_clr)
box_draw(lft+1,top+1,rgt-1,btm-1,
" ",contents_clr,contents_clr);
// repairing blanks[]
i = rgt-lft;
blanks[0] = blanks = blanks[i+1] = ' ';
gotoxy(1,1);
printf("Write the top line"
gotoxy(1,2);
printf("Write the center"
gotoxy(1,3);
printf("Write the bottom"
}
void startup()
{
textmode(C4350);
textattr(23);
clrscr();
}
// end of T.cpp