A method is a procedure or function that performs an operation on an object. A class method is a method that operates on a class reference instead of an object reference. If you read between the lines, you will find that class methods are accessible even when you haven't created an instance of the class (the object).





Subroutines are an important part of any programming language, and Object Pascal is no exception. In Delphi, there are generally two types of subroutines: a function and a procedure. The usual difference between a function and a procedure is that a function can return a value, and a procedure generally will not do so. A function is normally called as a part of an expression.





As like in any programming language, in Delphi, variables are placeholders used to store values; they have names and data types. The data type of a variable determines how the bits representing those values are stored in the computer's memory.





When the for statement begins running the counter variable is set to the starting value. Delphi than checks whether the value for the counter is less than the ending value. If the value is greater, nothing is done (program execution jumps to the line of code immediately following the for loop code block). If the starting value is less than the ending value, the body of the loop is executed (here:...





First of all, let's distinguish components from controls. Simply putt controls are those components that the user can see. Furthermore, Delphi distinguishes between windowed and nonwindowed (graphical) controls. The major distinction is that windowed controls can receive the focus and nonwindowed controls cannot. The distinction between windowed and graphical controls can be important when you...





he term scope refers to the availability of a variable or constant declared (or used) in one part of a program to other parts of a program. Unless we specify otherwise, changing the value of a variable named, let's say, SomeNumber in one procedure (function) will not affect another variable with the same name in another procedure (function). Since Delphi requires us to declare variables, it's a...





NAMES ARE FUNDAMENTAL TO PROGRAMMING, as I said a few chapters ago. There are a lot of details involved in declaring and using names. I have been avoiding some of those details. In this section, I'll reveal most of the truth (although still not the full truth) about declaring and using variables in Java. The material under the headings "Combining Initialization with Declaration" and...





UNDERSTANDING HOW PROGRAMS WORK IS ONE THING. Designing a program to perform some particular task is another thing altogether. In Section 3.2, I discussed how stepwise refinement can be used to methodically develop an algorithm. We can now see how subroutines can fit into the process. Stepwise refinement is inherently a top-down process, but the process does have a "bottom," that is, a...





AS COMPUTERS AND THEIR USER INTERFACES have become easier to use, they have also become more complex for programmers to deal with. You can write programs for a simple console-style user interface using just a few subroutines that write output to the console and read the user's typed replies. A modern graphical user interface, with windows, buttons, scroll bars, menus, text-input boxes, and so on,...





A SUBROUTINE THAT RETURNS A VALUE is called a function. A given function can only return a value of a specified type, called the return type of the function. A function call generally occurs in a position where the computer is expecting to find a value, such as the right side of an assignment statement, as an actual parameter in a subroutine call, or in the middle of some larger expression. A...





IF A SUBROUTINE IS A BLACK BOX, then a parameter provides a mechanism for passing information from the outside world into the box. Parameters are part of the interface of a subroutine. They allow you to customize the behavior of a subroutine to adapt it to a particular situation.





EVERY SUBROUTINE IN JAVA MUST BE DEFINED inside some class. This makes Java rather unusual among programming languages, since most languages allow free-floating, independent subroutines. One purpose of a class is to group together related subroutines and variables. Perhaps the designers of Java felt that everything must be related to something. As a less philosophical motivation, Java's designers...





FOR THE PAST TWO CHAPTERS, you've been learning the sort of programming that is done inside a single subroutine. In the rest of the text, we'll be more concerned with the larger scale structure of programs, but the material that you've already learned will be an important foundation for everything to come.In this section, before moving on to programming-in-the-large, we'll take a look at how...





THE SECOND BRANCHING STATEMENT in Java is the switch statement, which is introduced in this section. The switch is used far less often than the if statement, but it is sometimes useful for expressing a certain type of multi-way branch. Since this section wraps up coverage of all of Java's control statements, I've included a complete list of Java's statement types at the end of the section.





Now, an if statement is, in particular, a statement. This means that either statement-1 or statement-2 in the above if statement can itself be an if statement. A problem arises, however, if statement-1 is an if statement that has no else part. This special case is effectively forbidden by the syntax of Java. Suppose, for example, that you type













