CHAPTER 6 (Bulletproof web design) MAKING DECISIONS WITH CONDITIONAL LOGIC

CHAPTER 6 MAKING DECISIONS WITH CONDITIONAL LOGIC 175 Table 6-4. REALbasic Mathematical Operators Operator Type Example + Add 5 + 5 = 10 -Subtract 10 5 = 5 * Multiply 5 * 5 = 25 \ Division (Integer) 15 \ 2 = 7 / Division (Floating Point) 15 / 2 = 7.5 Mod Modulo 15 Mod 2 = 1 An example of how to work with most of these mathematical operators was provided in RB Calculator application presented in Chapter 5. Logical Operators At times, you may want to combine comparison operations together to make a decision. For example, you might want to execute a given set of code statements only when both the values of X and Y are greater than to zero. You could set up this test as the following shows. If X > 0 Then If Y > 0 Then MsgBox(”Both X and Y are greater than zero.”) End If End If Using the REALbasic Andlogical operator, however, you could rewrite these statements as in the following. If X > 0 And Y > 0 Then MsgBox(”Both X and Y are greater than zero.”) End If As you can see, using the And operator saves you two lines of code and makes things easier to read and understand. Table 6-5 lists the logical operators supported by REALbasic and describes their function. Table 6-5. REALbasic Logical Operators Operator Type Example And Both comparisons are True X >= 0 And Y >= 5 Or Either comparison is True X = 0 Or Y = 0 Not Reverses the value of a Boolean value Not (X > Y)
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Leave a Reply