|
The two commands DS<( and IS>) are very unique. The first thing they do is either increase of decrease a variable by one. DS<( subtracts 1 and IS>( adds 1. The next thing the do is test to see if the variable is greater than or less than a given value. DS<( test to see if the value is greater than the variable and IS>( test to see if the value is less than the variable. If the test resolves to be true, then the next line will be executed. If it is false, then the next line will be skipped
DS: decrement and skip IS: increment and skip
Syntax:
DS<(variable,value) or IS<(variable,value)
Note: The value can be either a number, another variable, or an expression such as 10+40.
For DS<( this is how the execution will go:
- Subtract 1 from the variable given.
- Test to see if the value given is greater than or equal to the variable given.
- If the value is greater than or equal to the variable, then execute the next line.
- Otherwise, ignore the next line and go on.
For IS>( this is how the execution will go:
- Add 1 from the variable given.
- Test to see if the value given is less than or equal to the variable given.
- If the value is less than or equal to the variable, then execute the next line.
- Otherwise, ignore the next line and go on.
This diagram may help. Notice the < and > drop down to fit into the test that is preformed.
Example of DS<(:
Breakdown of code:
- ClrHome
- Clear the home screen.
- 10 -> A
- Store 10 in the variable A.
- Repeat A=0
- Repeat the following code until A=0
- DS<(A,5)
- Subtract 1 from A, and test to see if A is less than 5. If A is less than 5, then execute the next line.
- Disp A
- Display the value of the variable A. (This will only happen if A is less than or equal to 5)
- Pause
- Pause execution until the user presses ENTER.
- End
- End of loop. Go back to Repeat.
Program output:
Only 9, 8, 7, 6, and 5 are displayed. This is because the command to display the value of A is skipped if A is lower than 5.
Example of IS>(:
Breakdown of code:
- ClrHome
- Clear the home screen.
- 1 -> A
- Store 1 in the variable A.
- Repeat A=10
- Repeat the following code until A=10
- IS>(A,5)
- Add 1 to A, and test to see if A is greater than 5. If A is greater than 5, then execute the next line.
- Disp A
- Display the value of the variable A. (This will only happen if A is greater than or equal to 5)
- Pause
- Pause execution until the user presses ENTER.
- End
- End of loop. Go back to Repeat.
Program output:
Only 2, 3, 4, and 5 are displayed. This is because the command to display the value of A is skipped if A is greater than 5.
|