|
|
|
|
|
Outputing Data to Screen or DiskGraphic User Interfaces and Console Devices to code using paint, canvas, handle, context, widget and window functions.An overview of the different kinds of output possibilities available in most programming languages, along with the hurdles that may exist in using each output method.
IntroductionOutput is one of the basic features of a programming language that makes it useful - without any way to show the user what the result of their interaction has been, the application will probably not serve any real purpose. There are several places that we can output data to - the screen, the disk, a printer - and each one has to be dealt with in a slightly different manner, regardless of the programming language being used. Generally, text output to a console device is the easiest, but least flexible method of outputting the result of a computer program. Graphical output (to a Graphical User Interface, or GUI) is usually slightly more difficult, and if the text is being painted, slightly slower. In this context, painting is displaying a custom font, precisely, possibly with some effects (shadow, outline, etc.), usually to a higher resolution than regular text output. These two general principles also apply to printed output and disk output - the more complex the output result, the more difficult it is. In addition to this, and outside the scope of this computer programming tutorial, writing to removable permanent media such as DVD and CD is an even more complex proposition. Screen - TextMost programming languages provide some kind of basic screen output. All command line (or console) programming languages will offer a PRINT command or function (possibly under a different name) that can provide text output. In addition, it is usual that a programming language provide some form of formatted output support, although the complexity and flexibility will vary considerably from language to language. Restrictions for console text output in programming languages usually include a fixed screen width and height, with precise control over positioning being restricted to discrete (column, line) locations. The least flexible will only allow line-by-line display, with some limited possibilities for formatting the line being output. The most flexible will include functions for positioning the text, defining the text output window, and changing the colors. Screen - GUIGraphical User Interfaces (GUIs) usually have several methods of allowing the programming language to output text and graphics. This usually requires that the programmer set up a canvas onto which graphics and text can be painted. Most GUI implementations will also permit simple text output onto a control which is capable of displaying text. These will not usually permit graphics to be output beyond the line art that the system font supports. Typically, if painting is to be done, the programmer must obtain the dimensions of the canvas, usually through the acquisition of a reference to the screen driver (sometimes called a handle or context). If text output is being rendered to a control, the programmer need only define the control (or widget / window) and use functions in the programming language to change the text that it displays, and possibly the font. Disk Storage & PrintingDisk storage is akin to console output, and printing can be seen as akin to graphical output. However, it is also possible, under some operating systems (such as DOS) to print text only to a printer using basic line printer support. All programming languages will usually have a disk (file) output facility which mimics the text output previously discussed. In addition, there are a variety of file formats to handle graphics, some of which are binary, and some of which are essentially text files which describe how to render the image in question and need a special program to read and display them. If the file is not to be shared with other applications, then a closed file format (Word Document, for example) is acceptable, otherwise an open file format (image files formats, etc.) has to be used, and this will require some advanced programming. ConclusionOf course, each programming language and each platform will have it's own specific functionality for handling output, but the basic principles are usually the same. When designing a computer program, it is worth thinking about the output requirements even before choosing the language/platform, as it can be a complex chore to change from text to GUI or vice versa, due to the inherent differences in implementations. Navigation LinksMailing ListStay informed - sign up to the mailing list!
The copyright of the article Outputing Data to Screen or Disk in Computer Programming is owned by Guy Lecky-Thompson. Permission to republish Outputing Data to Screen or Disk in print or online must be granted by the author in writing.
|
|
|
|