Forgot your password?  

Not What You Meant?  There are 13 definitions for Program.  Also try: Bogus or TNT (software).

Call | Research & Encyclopedia Articles

Print-Friendly   Order the PDF version   Order the RTF version
About 2 pages (504 words)
Computer program Summary

 


Call

A line of a program that causes power to be temporarily transferred to a subroutine is a call. Efficient computer programmers avoid repeatedly writing lines of code throughout their programs that achieve the same end. If a program must perform a complicated calculation several times throughout the course of its execution, and the calculation requires thirty or forty lines of code to produce an answer, programmers often write the lines of code that represent the calculation as a subroutine. Because subroutines are essentially miniature programs that are able to function independently of the program in which they are embedded, they by definition have a clear beginning and end. Often, programmers place all subroutines at the end of the main program and write lines of code within the program that cause the various subroutines to be executed before the program continues.

A simple computer game written in BASIC, for example, may have as a player's goal to move a character resembling a dragon from one side of a maze-like cave to another without touching a wall, being bitten by an enemy dragon or falling in a bottomless pit. If any of the three aforementioned events occurs, the dragon breathes fire and then collapses on the ground, dead. Since the dragon dies in the same way from three different causes, the part of the program that makes the dragon appear to breathe fire and collapse is written as a subroutine.

Assume that the subroutine for the death of the dragon begins on line 64000 of the program and ends at line 65000. Within the body of the program will be several situations where the program queries whether the dragon is touching a wall, being bitten, or falling in a pit. If the answer is yes, the program calls on the death subroutine with the command "GOSUB 64000". This command is a call of the subroutine, which instructs the program to jump to line 64000 of the program and execute the instructions until it encounters the "RETURN" command on line 65000, which sends control back to the point in the main program where the dragon death subroutine was called.

Calls are not only used to transfer control to subroutines; they can also transfer brief control to a preprogrammed procedure or to an entirely different program. The command "COS(x)" in the C++ programming language is a call on the cosine function built into the math processor of the computer to return the value of the cosine of x. By the same procedure, the command "ABS(-543.34)" is a call on the math processor's absolute value function, which returns the value 543.34. An example of a call that transfers control to another program might be found when a program used to schedule office meetings must determine the day of the week upon which a certain date in the future falls. Since most of today's operating systems have a calendar built into their architecture, a call on the operating system's program may be made from the scheduling program to obtain the desired information.

This is the complete article, containing 504 words (approx. 2 pages at 300 words per page).

Ask any question on Computer program and get it answered FAST!
Answer questions in BookRags Q&A and earn points toward
discounted or even FREE Study Guides and other BookRags products!
Learn more about BookRags Q&A
Copyrights
Call from World of Computer Science. ©2005-2006 Thomson Gale, a part of the Thomson Corporation. All rights reserved.

Join BookRagslearn moreJoin BookRags

Join BookRagslearn moreJoin BookRags