Help on border pelase :(

I know this a a long code. All this code over here does is print out block letters horizontally. What i'm trying to do now is have a border outside of those block letters, which I don't seem to undertstand how to do it? can anyone help please?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
  enum alphbet {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,one,two,three,four,five,six,seven,eight,nine,zero,at,exclaim,question,period,com,plus,minus,multiply,col,underline};
	
void printoutusersentencebordertype (string &usertypes)
{
	{
	
	
	
	//User types in a sentence
	cout<<"\n\n\t\tMessage: ";
	cin>>usertypes;

	//Make a top left border;
	cout<<"\n\n\n";
	cout<<(char)(218);

	
	


	//Declare index to find the character in a string
	int index=0;
	int track=0;
	//start a for loop that will keep track of each row to be printed
	for (int track=0;track<5;track++)
				{//start of for loop
					//reset index
					index=0;
			
	do
		{//start do while parenthesis
			
					//declare a variable to store in a character. Declare enum type variable to store in a value
						alphbet store_letter_score;
						char letterstore=usertypes[index];
	
							switch (letterstore)
								{//start switch structure parthesis
								case 'a':store_letter_score=a;
								break;
								case 'b':store_letter_score=b;
								break;
								case 'c':store_letter_score=c;
								break;
								case 'd':store_letter_score=d;
								break;
								case 'e':store_letter_score=e;
								break;
								case 'f':store_letter_score=f;
								break;
								case 'g':store_letter_score=g;
								break;
								case 'h':store_letter_score=h;
								break;
								case 'i':store_letter_score=i;
								break;
								case 'j':store_letter_score=j;
								break;
								case 'k':store_letter_score=k;
								break;
								case 'l':store_letter_score=l;
								break;
								case 'm':store_letter_score=m;
								break;
								case 'n':store_letter_score=n;
								break;
								case 'o':store_letter_score=o;
								break;
								case 'p':store_letter_score=p;
								break;
								case 'q':store_letter_score=q;
								break;
								case 'r':store_letter_score=r;
								break;
								case 's':store_letter_score=s;
								break;
								case 't':store_letter_score=t;
								break;
								case 'u':store_letter_score=u;
								break;
								case 'v':store_letter_score=v;
								break;
								case 'w':store_letter_score=w;
								break;
								case 'x':store_letter_score=x;
								break;
								case 'y':store_letter_score=y;
								break;
								case 'z':store_letter_score=z;
								break;
								case '1':store_letter_score=one;
								break;
								case '2':store_letter_score=two;
								break;
								case '3':store_letter_score=three;
								break;
								case '4':store_letter_score=four;
								break;
								case '5':store_letter_score=five;
								break;
								case '6':store_letter_score=six;
								break;
								case '7':store_letter_score=seven;
								break;
								case '8':store_letter_score=eight;
								break;
								case '9':store_letter_score=nine;
								break;
								case '0':store_letter_score=zero;
								break;
								case '@':store_letter_score=at;
								break;
								case '!':store_letter_score=exclaim;
								break;
								case '?':store_letter_score=question;
								break;
								case '.':store_letter_score=period;
								break;
								case ',':store_letter_score=com;
								break;
								case '+':store_letter_score=plus;
								break;
								case '-':store_letter_score=minus;
								break;
								case '*':store_letter_score=multiply;
								break;
								case ':':store_letter_score=col;
								break;
								case '_':store_letter_score=underline;
								break;
								}//End switch structure parenthesis

   //You got the characters and the value
	//Print a horizontal line
	for (int tot_len_hor=0;tot_len_hor <= usertypes.length();tot_len_hor++)
	{
		cout<<(char)(196);//Print horizontal line
		//If index is one lower then the total length then print out vertical bar
			if (tot_len_hor==usertypes.length())
			{
				//print a vertical bar
				cout<<(char)(191);
			}
	
	}
	//print out the next row
	cout<<endl;
	//do if statements
	//if track is zero print row 1
		if (track==0)
		{
			for (int col=0;col<1;col++)
			{
			cout<<letters[store_letter_score][col];
			cout<<"  ";
			}
		}
		//If track is one print row 2
		 else if (track==1)
		{
			for(int col=1;col<2;col++)
			{
				//When printing the next row. Inset a endline and print a vertical bar
				cout<<endl;
				cout<<(char)(179);
				cout<<letters[store_letter_score][col];
				cout<<"  ";
			}
		}
		//If track is 2 print row 3
		 else if (track==2)
		{
			for(int col=2;col<3;col++)
			{
				//print out the next row and print a vertical bar
				cout<<endl;
				cout<<(char)(179);
				cout<<letters[store_letter_score][col];
				cout<< "  ";
			}
		}
		//If track is 3 print row 4
		 else if (track==3)
		{
			for(int col=3;col<4;col++)
			{
				
				cout<<letters[store_letter_score][col];
				cout<<"  ";
			}
		}
		//If tract is 4 print row 5
		 else if (track==4)
		{
			for(int col=4;col<5;col++)
			{
				cout<<letters[store_letter_score][col]; 
				cout<<"  ";
			}
		}
				
	index++;
		}//end do while loop
		while (index<usertypes.length());
		cout<<endl;
		
				} //end for while loop



}


}
1
2
3
4
5
6
7
8
9
const string letters[46][5]=
{
	{				
"   _____   ",						
"  /  _  \\  ",
" /  /_\\  \\ ",
"/    |    \\",
"\\____|__  /" },


this is an example of the blockletters.
anyone :(
It depends on the type of border you want to make. One function I often use to make borders is the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
void border(int x1,int y1,int width,int height)
{
    //increment values to make them inclusive
    width++,height++;
    char v_side=186,h_side=205;
    char tl_corner=201,tr_corner=187;
    char br_corner=188,bl_corner=200;

    //top left corner
    cursorJump(x1,y1,false);
    cout<<tl_corner;
    //lefthand side
    for (int i=y1+1;i<height+y1;i++)
    {
        cursorJump(x1,i,false);
        cout<<v_side;
    }
    //bottom left corner
    cursorJump(x1,y1+height,false);
    cout<<bl_corner;
    //bottom side
    for (int i=x1+1;i<width+x1;i++)
    {
        cursorJump(i,y1+height,false);
        cout<<h_side;
    }
    //bottom right corner
    cursorJump(x1+width,y1+height,false);
    cout<<br_corner;
    //righthand side
    for (int i=y1+1;i<height+y1;i++)
    {
        cursorJump(x1+width,i,false);
        cout<<v_side;
    }
    //top side
    for (int i=x1+1;i<width+x1;i++)
    {
        cursorJump(i,y1,false);
        cout<<h_side;
    }
    //top right coner
    cursorJump(x1+width,y1,false);
    cout<<tr_corner;
} 

but you will also need this function to make it work
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void cursorJump(short x,short y, bool clearLine)
{
    //move to desired position
    COORD cursor={x,y};
    HANDLE console=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(console,cursor);
    //clear remaining line when desired
    if (clearLine==true)
    {
        for (int i=x;i<80;i++)
        cout<<" ";
        //return to desired position
        cursorJump(x,y,false);
    }
} 

The way it works is you provide x and y for where the top left corner of the border will be, and a width and height for the border. If it doesn't appear correctly, just play with the numbers a bit until it does. It also creates some interesting possibilities for loops or variable sized borders based on other variable values, but it requires remembering that unlike arrays, the first coordinate is horizontal and the second vertical.
Example:
border(0,0,2,1);
This would create a border in the top left corner capable of fitting two characters next to each other inside of it, but only be one character tall on the inside. You could also refer to the extended ASCII table and change the char values inside the function if you prefer different symbols over the double line border.
Last edited on
Topic archived. No new replies allowed.