codeigniter-boilerplatejs

I’ve been thinking about using Codeigniter as the back end for a couple of single page applications where the front end would be implemented using BoilerplateJS architecture. I wanted to create the basic structure for such a project and share it. Today I came across this question and thought I’d do this project and share it. Surprisingly putting together BoilerplateJS and Codeigniter was a breeze.

Most of the BoilerplateJS code will reside in a public folder in the Codeigniter root folder. The index page of BoilerplateJS will be in views folder and will be loaded by a controller when necessary. After some path modifications in the BoilerplateJS index file and requirejs route configs, everything started to work perfectly. All the server calls that were simulated by JSON text files are now actually served from a Codeigniter controller. I also used CodeIgniter Rest Server to implement the REST API.

The project is at: https://github.com/slayerjay/codeigniter-boilerplatejs

I’ve got an Arduino UNO board, and a Hitachi HD44780 type LCD. I wanted to write a python program to communicate with the Arduino board. The board can be connected to the computer via USB, and it appears as a COM port. Therefore we can easily communicate with the Arduino serial interface with python.

My aim is to create a python program that takes the input from the keyboard and display on the LCD. The LCD is connected to the Arduino board as mentioned in the Arduino example:

Circuit Diagram

The following is the code for the Arduino:

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.print("start");
}

void loop() {
  if (Serial.available()) {
    delay(100);  //wait some time for the data to fully be read
    lcd.clear();
    while (Serial.available() > 0) {
      char c = Serial.read();
      lcd.write(c);
    }
  }
}

To access the serial ports you need to set up the pySerial module for python. The Python code:

import serial
import time

s = serial.Serial(11, 9600) #port is 11 (for COM12), and baud rate is 9600
time.sleep(2)    #wait for the Serial to initialize
s.write('Ready...')
while True:
    str = raw_input('Enter text: ')
    str = str.strip()
    if str == 'exit' :
        break
    s.write(str)

I’m on a windows machine, and by default the Arduino is connected to COM12. Note that we need to wait for a little while after initializing the serial connection.

Arduino Board and the LCD Ready for input

Arduino Board and the LCD Ready for input

Arduino Board and the LCD, Python message is displayed

Arduino Board and the LCD, Python message is displayed

Python Console

Python Console

Gist: https://gist.github.com/4460208

Reference: http://playground.arduino.cc/interfacing/python

I am still an undergraduate, but I was involved in developing several applications, as projects and course work in the university and as products for several clients while I’m in the university and during my internship. I have seen that more and more enterprise applications are moving towards the web and have seen a trend towards enterprise applications being developed as Single Paged Applications.

Me, being an undergraduate is far from being an experienced software architect, but I have experience in developing the above types of applications, so here is my take on them.

Desktop applications may be connected through the internet or an intranet, and there may be server software or a database server in a central location. We have been used to these types of applications for a long time. They are reliable and very stable. But things have got complicated lately. There are a couple of popular operating systems, and most enterprises want their systems to be accessed by all such operating systems and devices as well. Developing separate native applications for different platforms is extremely costly and impractical. I believe that this is a major reason behind web applications being popular among enterprise application developers.

Web applications reside in a web server and accessed by users via the internet or an intranet and viewed on a web browser. Web applications provide some significant advantages. As mentioned above being platform independent is one of them. Unlike desktop applications they do not need special roll out or deployment procedures. Therefore deploying updates and new versions are very easy. The load on client machines is pretty low as well.

However there are several drawbacks of web applications. The user experience tend to be discontinuous because the pages need to refreshed each time an operation occurs, and response time is very slow because the webpage needs to be sent from the server. An un-interrupted connection to the server (or the internet) is required as well. But this however is minimized with HTML5’s new local storage feature.

Single Paged Applications tries to eliminate some of the drawbacks of traditional web applications.

A single-page application (SPA), also known as single-page interface (SPI), is a web application or web site that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application.

In an SPA, either all necessary code – HTML, JavaScript, and CSS – is retrieved with a single page load, or partial changes are performed loading new code on demand from the web server, usually driven by user actions. The page does not automatically reload during user interaction with the application, nor does control transfer to another page. Updates to the displayed page may or may not involve interaction with a server.

– Wikipedia article on Single Paged Applications

The following figure shows the architecture of a typical SPA:

Typical Single Paged Application Architecture

Since most of the UI rendering and manipulation happens on the browser it gives the user an uninterrupted experience, and since the load on server side is minimum, these applications tend to be very scalable. The Single Paged Applications tend to have a lot more modularized maintainable code, since the presentation layer is decoupled from the business logic and controllers. However Single Paged Applications have a long way to go and the technology is still maturing. But my bet is that we will see more and such applications in the future.

Often in many of our applications, we need to load and display images. It could be a banner image that you load on top of each window, or the photo of a user that you received over a network which you want to display on a JFrame. A neat solution to this problem can be achieved by drawing the image on a JPanel and placing it among your other GUI components.

In this post I will explain how to create a GUI component which will display an Image object using a JPanel. The following is the code for the JPanel. You can place it among your other GUI components, and when you need to display an image, call the setImage() method with the Image object as the parameter.

package imagepanel;

import java.awt.Graphics;
import java.awt.Image;

/**
 *
 * @author Janith (http://cyberasylum.wordpress.com/)
 */
public class ImagePanel extends javax.swing.JPanel {

    Image image;

    /** Creates new form ImagePanel */
    public ImagePanel() {
        image = null;
        initComponents();
    }

    public void setImage(Image image) {
        this.image = image;
        this.repaint(); //makes a call to the pain() method
    }

    @Override
    public void paint(Graphics g) {
        if (image == null) {
            return;
        }
        g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), this);  //draw our image over the full area of the JPanel
    }

    private void initComponents() {
        setPreferredSize(new java.awt.Dimension(200, 200));
        setLayout(null);
    }
}

Now you can place this panel in a JFrame, and display images. Assume I have an instance of the above class named as imagePanel, and then I can display the image by:

Image myImage = ImageIO.read(new FileInputStream(&quot;test.jpg&quot;));
imagePanel.setImage(myImage);

Click here to download the complete project file of the above code, which also includes a JFrame to test it.

When building a client – server based application, we need to send objects between the client and the server applications. And java provides two great mechanisms to achieve this: Object Serialization and Sockets. Once you know the basics of these two mechanisms, putting them together is not very hard. However there are some pitfalls that you need to avoid.

For this example I will make a small application.

The client application: will connect to the server and pass objects to the server. The passed objects will contain a String which the user entered on the console.

The server application: will echo the messages back to the client.

I assume you know a bit about object serialization and socket programming. But to give a brief introduction about serializing objects:

The object needs to implement the ‘Serializable’ interface. If you are going to serialize an object which is composed of many other objects, all those nested objects need to implement the ‘Serializable’ interface as well. If you happen to get a “java.io.NotSerializableException”, then it means you are trying to serialize an object that does not implement the Serializable interface. Most of Java’s objects do implement this interface.

When you have a ‘Serializable’ object with you, you can write it using the ObjectOutputStream.

ObjectOutputStream out = new ObjectOutputStream(/*Some output Stram*/);
out.writeObject(/*Some Serializable Object*/);
out.close();

To read the object the ObjectInputStream can be used:

ObjectInputStream in = new ObjectInputStream(/*Some input Stram*/);
/*Some Serializable object*/  =  in.readObject();
in.close();

Now let’s get into the example. I have created a ‘Message’ object which will be used to communicate between the server and the client. Basically the server and client will send ‘Message’ objects to each other.

Message class:

import java.io.Serializable;

/**
 *
 * @author Janith (http://cyberasylum.wordpress.com/)
 */
public class Message implements Serializable{

    private String message;

    public Message(String message) {
        this.message = message;
    }

    public String getMessage(){
        return message;
    }
}

The server application will wait for a connection, read the objects from the socket and reply,

Server Class:

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author Janith (http://cyberasylum.wordpress.com/)
 */
public class Server {

    private static final int PORT = 5000;

    public static void main(String[] args) {
        ServerSocket serverSocket = null;
        try {
            //Creates a new server socket with the given port number
            serverSocket = new ServerSocket(PORT);
        } catch (IOException ex) {
            System.out.println(&quot;Error occured while creating the server socket&quot;);
            return;
        }

        Socket socket = null;
        try {
            //Waits untill a connection is made, and returns that socket
            socket = serverSocket.accept();
        } catch (IOException ex) {
            System.out.println(&quot;Error occured while accepting the socket&quot;);
            return;
        }
        //Now we have established the a connection with the client
        System.out.println(&quot;Connection created, client IP: &quot; + socket.getInetAddress());
        ObjectInputStream in = null;
        ObjectOutputStream out = null;
        while (true) {
            try {
                if (in == null) {
                    in = new ObjectInputStream(socket.getInputStream());
                }
                Message message = (Message) in.readObject();
                System.out.println(&quot;Client said: &quot; + message.getMessage());

                //Send a reply to the client
                if (out == null) {
                    out = new ObjectOutputStream(socket.getOutputStream());
                }
                out.writeObject(new Message(&quot;Message recieved: &quot; + message.getMessage()));
                out.flush();
            } catch (Exception ex) {
                System.out.println(&quot;Error: &quot; + ex);
            }
        }
    }
}

Client Class:

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Scanner;

/**
 *
 * @author Janith (http://cyberasylum.wordpress.com/)
 */
public class Client {

    private static final String SERVER_IP = &quot;127.0.0.1&quot;;
    private static final int SERVER_PORT = 5000;

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);   //to read text from the console
        Socket socket = null;
        try {
            socket = new Socket(SERVER_IP, SERVER_PORT);
            System.out.println(&quot;Connected to server!&quot;);
        } catch (Exception ex) {
            System.out.println(&quot;Error connecting to server: &quot; + ex.getMessage());
        }

        ObjectInputStream in = null;
        ObjectOutputStream out = null;
        while (true) {
            try {
                if (out == null) {
                    out = new ObjectOutputStream(socket.getOutputStream());
                }

                //read a string
                System.out.println(&quot;Enter a message: &quot;);
                String str = scanner.next();

                //send it to server
                out.writeObject(new Message(str));
                out.flush();

                //get the reply from the server
                if (in == null) {
                    in = new ObjectInputStream(socket.getInputStream());
                }
                Message message = (Message) in.readObject();
                System.out.println(&quot;Server said: &quot; + message.getMessage());

            } catch (Exception ex) {
                System.out.println(&quot;Error: &quot; + ex);
            }
        }
    }
}

You can download the Netbeans project folder of this project from here (http://dl.dropbox.com/u/7290180/Serialization.rar).

Run the server part first and then run the client program.

A word of warning (and perhaps the most important part of this post)

The constructor of the ObjectInputStream ‘wait’s until the ObjectOutputStream of the other side to write a header. So if you try to construct the ObjectInputStream at the very beginning of both client and server program, you will end up in an ugly dead lock! Basically the client side will wait until the server to create its end of the stream, and the server side will wait until the client to create its end of the stream, and both sides will wait forever!

So, how do we solve this?

You should decide which side initiates the connection. i.e. you should decide which side would send an object first, and the other side should be prepared to read that. In the above example, the client sends the first message (so on the client side, first the ObjectOutputStream is created and on the server side, the ObjectInputStream is created). So I guess it would be a good rule of thumb to create the object input and output streams just before you use them.

Finally, in the above example the server is able to handle only one connection at a time, and that would be very inefficient for a server. So I have uploaded a better version of the above program where the server can handle multiple connections simultaneously using threads. Click here (http://dl.dropbox.com/u/7290180/SimpleClientServer.rar) to download the Netbeans project folder of the improved client server project.

I know this is a very long post, and hope I didn’t make it boring :). Hope you will find this useful.


For this example I will make a small application.

The client application: will connect to the server and pass objects to the server. The passed objects will contain a String which the user entered on the console.

The server application: will echo the messages back to the client.

Saving and retrieving files is a common problem when it comes to writing programs that has a database back end. In this post I will show you how to save and retrieve image files to and from a MySQL database, using Java. This method can be used to store any file in a database.

The Database:

For this example I will create a database called ‘DB’ and a table called ‘images’ where I will store the files. I use wampserver as my database manager.

The format for the ‘images’ table is as follows:

Index    :      INT
Photo    :      MEDIUMBLOB

The data type BLOB can be used to store byte values. There are four such data types available, namely TINYBLOB, MEDIUMBLOB, BLOB, LONGBLOB. Check here to find out the maximum sizes supported by each data type.

Java Program:

The following java program reads an image file (test.jpg) and saves it in the database in a record with index as 5. Then it reads back all the records that are in the table, and stores those images back on the hard disk.

Make sure you have installed MySQL Connector/J. If you are using NetBeans, you can add MySQL JDBC Driver to you libraries folder.

import com.mysql.jdbc.PreparedStatement;
import com.mysql.jdbc.Statement;
import java.awt.image.BufferedImage;
import java.io.*;
import java.sql.*;
import javax.imageio.ImageIO;

public class Main {

	public static void main(String[] args) {
		try {
			Class.forName(&quot;com.mysql.jdbc.Driver&quot;);
			String url = &quot;jdbc:mysql://localhost:3306/mysql&quot;;
			Connection con = DriverManager.getConnection(url, &quot;root&quot;, &quot;&quot;);
			System.out.println(&quot;Connected to db&quot;);

			//saving the image
			PreparedStatement psmnt = (PreparedStatement) con.prepareStatement(&quot;INSERT INTO DB.images VALUES(?,?)&quot;);
			psmnt.setInt(1, 5);
			File f = new File(&quot;test.jpg&quot;);
			psmnt.setBlob(2, new FileInputStream(f), f.length());
			psmnt.executeUpdate();
			System.out.println(&quot;Image saved in DB&quot;);

			//retrieving it

			Statement stmt = (Statement) con.createStatement();
			ResultSet rs = stmt.executeQuery(&quot;SELECT * FROM DB.images&quot;);
			int count = 0;
			while (rs.next()) {
				InputStream is = rs.getBinaryStream(&quot;photo&quot;);
				BufferedImage image = ImageIO.read(is); //the image is read in
				//store it back again as a file
				ImageIO.write(image, &quot;jpg&quot;, new FileOutputStream(&quot;recived&quot; + count + &quot;.jpg&quot;));
				count++;
			}

			System.out.println(count+&quot; images saved on disk&quot;);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

If you are trying to upload a large file, sometimes you might get a ‘packet size too large’ exception. You can increase the ‘max_allowed_packet’ variable of your server. Check here to find out how to do this.

If you want to know how to save, send and receive Java Image objects over a network have a look at this. It explains how to convert an Image object to a byte array. This byte array can be saved in an SQL database in a BLOB type data field.

Happy Coding! Continue reading

During the previous week I found out some tricks and tips in assembly, and thought of sharing them in this brief post.  I hope you will find these useful. I used NASM compiler to compile these codes.

Clearing a register:

Suppose you want to clear the ax register. XOR’ing it with itself will set all the bits in the register to zero.

xor ax, ax

Printing a single character on screen:

The interrupt 0x10 will print a given character on screen. The following code can be used to print a single character on screen.

mov al, '@'     ; character or the ASCII code of the character to be printed
mov ah, 0x0e    ; video – teletype output
int 0x10

Extracting some bits from a register:
Suppose you want to extract bits 3 and 4 of the AX register, and then print the decimal value on screen. The following code can be used to achieve this.
‘AND’ the register with a binary number which contains 1’s in the bit positions you want to extract. For our example it would be 0b0000000000011000 or 0x0018 (in hexadecimal). Then shift it right until our bits are the right-most bits. Then add 4b to it to get the ASCII number (ASCII value of ‘0’ is 48)

and ax, 0x0018    ; mask out bits 3 – 4
shr ax, 3         ; shift it right 3 times
add ax, 48        ; add 48 to get ASCII character
mov ah, 0x0e      ; print it
int 0x10

Remember the above code will work only if you are going to print values less than 9. If you want to convert a value more than 9 to decimal this will not work (I hope you understand why it doesn’t work 😉 ).

Printing out a register in binary:
For most of our debugging work, we will need to print the contents of a register in binary format. The following code can be used to print the contents of the CX register.

_print_reg:
;print the CX reg
push dx              ; save registers dx,ax,bx
push ax
push bx
mov dx, cx
mov cx, 16           ; loop for 16 times
print_loop:
    mov ax, 32768    ; set  ax = ob1000....
    and ax, dx       ; mask out the MSB of dx and store it in ax
    shr ax, 15       ; shift it to right 15 times
    add al, 48       ; add 48 to get the ASCII (would be either 0 or 1
    mov ah, 0x0e
    int 0x10         ; print it out
    shl dx, 1        ; shift left dx by 1
loop print_loop

pop bx;              ; restore the registers
pop ax
pop dx
ret

Hope these few tips will be helpful. That’s all for now :)


Have you ever wondered how to create those textual user interfaces that appear on console type windows? In this post I will explain how to create some simple user interfaces in C under Windows. With some simple coding, and a little bit of patience you will be able add some GUI elements to your C programs. However the following examples are only for windows operating systems. First let us take a look at some interfaces that I have done.

This shows a Stock Controlling System that I did as a class project. It has text boxes and message boxes and tables.

Inventory Control System user interface with a message box

Inventory Control System user interface

The following is the user interface of our Intelligent Car Park Management System, which we did as a group project in the university.

Car Park Management System User interface

Understanding the Console Window

The console window can be considered as a grid, with top left corner having the coordinates (0, 0).

In order to display our programs correctly, we need to set the size of the console window. Remember to follow this step to change the window size for your programs.

Right click on the title bar of the program and select Properties.

Right click on the title bar of the program and select Properties.

On the Layout tab, change the values as necessary. For this example, I will be using the settings that are shown on the screen shot.

Layout tab

The above procedure can be programmed into the code as well. For this refer the msdn for SetConsoleScreenBufferSize function (http://msdn.microsoft.com/en-us/library/ms686044(v=VS.85).aspx)

Alternative conio.h

We need some functions that are not implemented in the standard conio.h library. These include functions such as gotoxy(), getx(),gety() which basically manipulates the cursor position on the console window. There are a few alternate conio.h libraries available on the internet. I used the one which is available in the following forum by Arthur Christopher Watkins:

http://www.dynamicdrive.com/forums/showthread.php?t=35174

Or you can download a little bit modified version directly from here

It’s all about printf!

Now that you got the console window size adjusted, and alternate conio set up, it’s time to code!

Get an ASCII chart, and note the characters that can be used to draw lines, bends, etc. You can use the following code to print an ascii character.

int n=205;            //ascii code of the character
printf(“%c”,n);

Now you can use your creativity and imagination (and some loops of course :) ) to write functions that will print lines, text boxes, rectangles, etc. Here are some functions that I wrote:

#include &lt;stdio.h&gt;
#include &quot;altconio.h&quot;

void DrawHLine(int x,int y, int length);
void DrawVLine(int x,int y, int height);
void DrawFrame(int beginx,int beginy,int width,int height);

int main()
{
	clrscr();
	DrawFrame(3,3,10,10);
	DrawVLine(15,3,10);
	DrawHLine(3,15,10);
	gotoxy(0,20);
	system(&quot;pause&quot;);
	return 0;
}

void DrawHLine(int x,int y, int length)
/*
 * this function draws a horizontal line when
 * the x,y values of the starting point and length
 * is given.
 */
{
	int count;
	int currX=getx();	//get the currecnt cursor position
	int currY=gety();
	gotoxy(x,y);
	for(count=0;count&lt;length;count++)
		printf(&quot;%c&quot;,196);
	gotoxy(currX,currY);	//put the cursor back in place
}

void DrawVLine(int x,int y, int height)
/*
 * this function draws a verticle line when
 * the x,y values of the starting point and height
 * is given.
 */
{
	int count;
	int currX=getx();	//get the currecnt cursor position
	int currY=gety();
	gotoxy(x,y);
	for(count=0;count&lt;height;count++)
	{
		gotoxy(x,y+count);
		printf(&quot;%c&quot;,179);
	}
	gotoxy(currX,currY);	//put the cursor back in place
}

void DrawFrame(int beginx,int beginy,int width,int height)
/*
 * this function draws a box when the
 * x,y values of the top left corner
 * and hieght and width is given, and
 * clears the inside of it.
 */
{
	int count,i,j;
	int currX=getx();	//get the currecnt cursor position
	int currY=gety();
/*-------Top Horizontal line------*/
	gotoxy(beginx,beginy);
	printf(&quot;%c&quot;,201);
	for(count=1;count&lt;=width-2;count++)
		printf(&quot;%c&quot;,205);
	printf(&quot;%c&quot;,187);

/*-------Left verticle line-------*/
	gotoxy(beginx,beginy+1);
	for(count=1;count&lt;=height-2;count++)
	{   printf(&quot;%c&quot;,186);
		gotoxy(beginx,beginy+1+count);
	}

/*-------Right verticle line------*/
	gotoxy(beginx+width-1,beginy+1);
	for(count=1;count&lt;=height-2;count++)
	{   printf(&quot;%c&quot;,186);
		gotoxy(beginx+width-1,beginy+1+count);
	}

/*-------Bottom Horizontal line----*/
	gotoxy(beginx,beginy+height-1);
	printf(&quot;%c&quot;,200);
	for(count=1;count&lt;=width-2;count++)
		printf(&quot;%c&quot;,205);
	printf(&quot;%c&quot;,188);

/*-------Clearing inside the frame---*/
	for(i=1;i&lt;=height-2;i++)
	{
		gotoxy(beginx+1,beginy+i);
		for(j=1;j&lt;=width-2;j++)
			printf(&quot; &quot;);
	}
	gotoxy(currX,currY);	//put the cursor back in place
}

Note that the alternate conio.h library file (which is named as ‘altconio.h’) is in the same directory as my source file, so it is included as:

#include “altconio.h”

I’ll leave you with that for now. Try out the setcolor() function if the altconio.h header file to try out different colors. Experiment with these codes and have fun :)

#include <stdio.h>
#include “altconio.h”void DrawHLine(int x,int y, int length);
void DrawVLine(int x,int y, int height);
void DrawFrame(int beginx,int beginy,int width,int height);int main()
{
clrscr();
DrawFrame(3,3,10,10);
DrawVLine(15,3,10);
DrawHLine(3,15,10);
gotoxy(0,20);
system(“pause”);
return 0;
}void DrawHLine(int x,int y, int length)
/*
* this function draws a horizontal line when
* the x,y values of the starting point and length
* is given.
*/
{
int count;
int currX=getx();    //get the currecnt cursor position
int currY=gety();
gotoxy(x,y);
for(count=0;count<length;count++)
printf(“%c”,196);
gotoxy(currX,currY);    //put the cursor back in place
}void DrawVLine(int x,int y, int height)
/*
* this function draws a verticle line when
* the x,y values of the starting point and height
* is given.
*/
{
int count;
int currX=getx();    //get the currecnt cursor position
int currY=gety();
gotoxy(x,y);
for(count=0;count<height;count++)
{
gotoxy(x,y+count);
printf(“%c”,179);
}
gotoxy(currX,currY);    //put the cursor back in place
}

void DrawFrame(int beginx,int beginy,int width,int height)
/*
* this function draws a box when the
* x,y values of the top left corner
* and hieght and width is given, and
* clears the inside of it.
*/
{
int count,i,j;
int currX=getx();    //get the currecnt cursor position
int currY=gety();
/*——-Top Horizontal line——*/
gotoxy(beginx,beginy);
printf(“%c”,201);
for(count=1;count<=width-2;count++)
printf(“%c”,205);
printf(“%c”,187);

/*——-Left verticle line——-*/
gotoxy(beginx,beginy+1);
for(count=1;count<=height-2;count++)
{   printf(“%c”,186);
gotoxy(beginx,beginy+1+count);
}

/*——-Right verticle line——*/
gotoxy(beginx+width-1,beginy+1);
for(count=1;count<=height-2;count++)
{   printf(“%c”,186);
gotoxy(beginx+width-1,beginy+1+count);
}

/*——-Bottom Horizontal line—-*/
gotoxy(beginx,beginy+height-1);
printf(“%c”,200);
for(count=1;count<=width-2;count++)
printf(“%c”,205);
printf(“%c”,188);

/*——-Clearing inside the frame—*/
for(i=1;i<=height-2;i++)
{
gotoxy(beginx+1,beginy+i);
for(j=1;j<=width-2;j++)
printf(” “);
}
gotoxy(currX,currY);    //put the cursor back in place
}