| << 5.5.3- Summary of Reusing Code | Chapter5 |
Summary
The real power of programming comes from the ability to control and direct the order of execution of statements. In this chapter we looked at three families of control structures:
- Branching, where only one of several possible sets of code is executed
- Looping, where a set of code is performed over and over
- Jumping, where VBScript pauses execution of the current script block, jumps over and executes a different script block, and then comes back to resume the execution of the original script block.
Each of these techniques has two ways of being implemented in ASP:
When branching between just two choices we use the If...Then statement that makes its decision based on an expression that evaluates to true or false. If we have more than one outcome then we use the Select Case structure.
When we write a loop we must consider how many cycles we want to run through. If we know the number of cycles before starting the loop we generally use the For...Next structure. If we don't know then we use the Do...While structure.
When writing jumping structures we must ask if we expect VBScript to return some kind of answer from the code that we jump to. If yes, then we write the other code as a function. If we expect the other code only to perform actions then it is written as a sub procedure.
With these tools we can now orchestrate the order in which our lines of code are executed. In some cases we may skip over lines while other times we may repeat code. Each of these control construction techniques will provide a supporting role in the use of the ASP objects and components that you will learn to use in the to use in the remainder of the book.
| << 5.5.3- Summary of Reusing Code | Chapter5 |

RSS

