Displaying the frame

Hi! Could anyone help me how to use frame? cause i am trying to use void frame() but it only gives me an error message. Please include the frame in the block of 21. BTW, i am using Turbo c++ (required compiler) Thank you!
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
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<ctype.h>
#include<process.h>
#include<string.h>
#include<dos.h>
#include<fstream.h>

int main()
{
 clrscr();
 int number;

 printf("Enter the atomic number of element(s):");
 scanf("%d",&number);

 switch (number)
   {

   case 1:
   gotoxy(21,10);
   cout<<"atomic number: 1";
   gotoxy(21,11);
   cout<<"symbol: H";
   break;

   default:printf("\n unknown color");
   }
   getch();
   }
   return 0;
  }
Last edited on
WHat do you mean with frame ?
Hi sir thomas! Thank you for your response. I'll try to explain, i am not good in english. Well anw, for example:

foid frame()
{
frame();
gotoxy(21,10);
cout<<"Hydrogen";
}
getch();
}

What i mean here there is a frame that you'll see in the output and then the hydrogen is inside the frame.
Last edited on
@daryledevs
I'm using MS Express, but this should work on your compiler after adding your #includes as needed. To create the frame, you would need to specify column and row for starting, and how wide and tall is needed. Hope this is what you were needing.

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
#include<iostream>
#include <conio.h>
#include <Windows.h>

using std::cout;
using std::endl;


void frame(int column, int row, int wide, int high);
void gotoxy(int x, int y);

int main()
{

	int number;

	printf("Enter the atomic number of element(s): (Enter a '1' only) ");
	scanf_s("%d", &number);

	switch (number)
	{

	case 1:
		frame(20,9,20,6);
		gotoxy(21,10);
		cout<<"atomic number: 1";
		gotoxy(25,13);
		cout<<"symbol: H";
		break;

	default:printf("\n unknown element");
	}
	gotoxy(20,25);
	_getch();

	return 0;
}

void frame(int column, int row, int wide, int high)
{
	gotoxy(column, row);
	cout << "\xDA";
	for(int x=1;x<wide-1;x++)
		cout << "\xC4";
	cout << "\xBF";
	for(int x=1;x<high-1;x++)
	{
		gotoxy(column, row+x);
		cout<<"\xB3";
		gotoxy(column+(wide-1), row+x);
		cout<<"\xB3";
	}
	gotoxy(column, row+high-1);
	cout << "\xC0";
	for(int x=1;x<wide-1;x++)
		cout << "\xC4";
	cout << "\xD9";
}

void gotoxy(int x, int y)
{
	HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD CursorPosition;

	CursorPosition.X = x;
	CursorPosition.Y = y;
	SetConsoleCursorPosition(console, CursorPosition);
}
@whitenite1,
nice solution, though I am afraid it won't work with his TurboC++.
@whitenite1,
Thank you for your effort sir but sadly, it doesn't work in Turbo C++. I'd like to send here the picture to see but i can't. Please check and download the source file here: https://projectsgeek.com/2014/10/periodic-table-program-using-c-language.html Please run it and to see the frames.
Last edited on
@Thomas1965

I am afraid it won't work with his TurboC++.


Don't see why not. Just need to remove the gotoxy() function in my code, since Turbo C++ already has it. Which means also removing the #include <windows.h> because it was only needed for my gotoxy function. The frame function is only displaying ASCII value written in hex. Also remove the #using std::?? statements, as they are not needed in Turbo C++, as well.

@whitenite,
you are right. With a few changes it should work.
@daryledevs

What I wrote should work, with just a few small changes as I mentioned to thomas1965. I was going with a frame around a single element, as you didn't specify what type of a frame was needed. If you can explain better what you're trying to get, I could probably show something much better.
sir @whitenite1, the codes with the syntax of frame(); is that i am talking about. It's perfect to use as design but when i tried to used this and also copy the header file, it doesn't work on me. Please help..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
	clrscr();
	frame();
	gotoxy(21,10);
	cout<<"Atomic No:               :4"<<"\n";
	gotoxy(21,11);
	cout<<"Symbol                   :Be"<<"\n";
	gotoxy(21,12);
	cout<<"Name                     :Berryllium"<<"\n";
	gotoxy(21,13);
	cout<<"Atomic Radius            :0.89"<<"\n";
	gotoxy(21,15);
	cout<<"Electronegativity        :1.47"<<"\n";
	gotoxy(30,20);
	cout<<"Press Any Key To Return......";
	}
@daryledevs

I was able to download the source for the program, and I found that I needed to add variable declarations to a couple of functions. Add these and see if they help you to run the program.
Under void frame()
int i;
Under void display()
int i,j,g;
@whitenite1, what makes me sad is i dunno where do i place that? hehe.
@daryledevs

Place the int declarations right after the {, so it looks like this...
1
2
3
4
5
void frame()
{
  int i;
// rest of code...
}

and
1
2
3
4
5
void display()
{
  int i, j, g;
// rest of code...
}
Last edited on
@whitenite1,

what i mean is i dunno where i am gonna place that. Could you place where here? https://paste.ofcode.org/X2fDWjU82H8r3JTQ7sq7Qc
@daryledevs

Sorry. Pretty much everything I was doing to help, was based on a completely different program, than the one your actually making. You pointed us to one program that had a frame described, a display function, etc., but the program you're actually making has none of them. Plus, I'm not using Turbo C++ and therefore cannot actually run your program as written.

Good luck then, as I'm not of any help.
@whitenite1,
well it's okay and i know you did your best and that's enough. Well sir, Thank you for helping me and godbless! :D
Topic archived. No new replies allowed.