Using Borland C++ on the Student network

You start Borland C++ by going to Windows 95 Start Button, Programs, Programming, Borland C++5, Borland C++
Writing a simple DOS program
Start Borland C++.
Choose New Project from the Project Menu.
Choose
Target Type: Application [.exe]
Platform: DOS Standard
Target Model: Large
Standard Libraries: Class Library, Runtime Library
Click OK
Double click on the [.cpp] file in the bottom tree view.
Type your program into the .cpp file window.
Choose Run from the Debug Menu.
Sample code:
 
#include <iostream.h>
#include <conio.h>
int main()
{
  cout << "Hello, World" << endl;
  cout << "Press any key to continue" << endl;
  getch();
  return 0;
}
 
Writing a DOS program with graphics
Proceed as above but when starting the project choose 
Standard Libraries: BGI, Class Library, Runtime Library.
The BGI makes sure the graphics libraries are linked.
 
Sample code:
 
#include <iostream.h>
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
 
int main(void)
{
 
   /* request autodetection */
 
   int gdriver = DETECT, gmode, errorcode;
   int xmax, ymax, midx, midy;
 
   /* initialize graphics and local variables */
 
   initgraph(&gdriver, &gmode, "L:\\BC5\\BGI");
 
   /* read result of initialization */
 
   errorcode = graphresult();
 
   if (errorcode != grOk) { /* an error occurred */
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
   }
 
   // Change to black on white background
   // Default is white on black
 
   setpalette (0, EGA_WHITE);
   setpalette (15, EGA_BLACK);
 
   // Note coordinates are pixels.
   // The top left hand corner is (0,0)
   // The bottom right hand corner is (xmax, ymax)
   // i.e x increases from 0 left to right
   //     y increases from top to bottom
 
   xmax = getmaxx();
   ymax = getmaxy();
 
   /* draw a diagonal line */
 
   line(0, 0, xmax, ymax);
 
   midx = getmaxx() / 2;
   midy = getmaxy() / 2;
 
   /* move the CP to the center of the screen */
 
   moveto(midx, midy);
 
   /* output text starting at the CP */
 
   outtext("This ");
   outtext("is ");
   outtext("a ");
   outtext("test.");
 
   /* clean up */
 
   getch();
   closegraph();
   return 0;
}
 
Note that the 3rd argument in
 
   initgraph(&gdriver, &gmode, "L:\\BC5\\BGI");
has to be changed from the default given in all examples.
To find out about other graphics functions choose Contents from the HELP Menu, click on the Search Button and type graphics. Choose DOS Graphics Routines to get a list of all the routines.
 
Printing your DOS Graphics Output
 
There does not seem to be a straightforward way of printing the DOS Graphics output directly. One way to do it indirectly is as follows:
 
Run your graphics program.
Press Print Scrn (top row of buttons). This puts the picture on the Windows clipboard.
Press return to return to Borland C++ and minimise Borland C++.
Start Word.
Select Paste from the edit menu or use the paste toolbar button.
Print the Word document.

Juno Champion

The school holds Juno Champion status, the highest award of this IoP scheme to recognise and reward departments that can demonstrate they have taken action to address the under-representation of women in university physics and to encourage better practice for both women and men.