X web hosting - CHAPTER 6 Making Decisions with
CHAPTER 6 Making Decisions with Conditional Logic To create truly useful applications, you need to provide your programs with the capability to analyze data, and then make logical decisions based on the results of that analysis. This is achieved through the execution of conditional statements that work with mathematical, comparison and logical operators to define conditional tests and the courses of action to take, based on the results of the test. By applying conditional programming techniques demonstrated in this chapter, you can develop REALbasic applications that react dynamically to different data and provide users with an interactive experience. Specifically, you learn how to Test between two or more conditions Alter the logical flow of your program code Generate random numbers Apply operating system-specific conditional logic Implementing Conditional Logic By default, REALbasic executes code statements in a sequential order. For example, if you specified a set of ten code statements to be executed when the user clicks a PushButton control, REALbasic executes each statement, one at a time, in the order the statements were written. This type of execution works just fine much of the time. In some situations, though, you might want to conditionally execute a block of statements. For example, suppose you wrote an application that continually writes text to a log file. Before writing to the log file, you would want to add logic to your program to make sure the log file exists. If the log file does not exist, then you would want to tell REALbasic to create the file first. In this scenario, the code statement that checks for and creates a new log file only runs when the application determines that a log file does not already exist. Otherwise, these statements are skipped. Adding this type of conditional check to your application can help prevent errors by ensuring the application always has a log file to write to. Conditional logic within a computer program is only a matter of determining whether a condition evaluates to either True or False and specifying what actions to take based on the results of the test. REALbasic provides you with three sets of programming statements that you
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.