home *** CD-ROM | disk | FTP | other *** search
- ' PASSREF.BAS
- ' by Tika Carr
- ' March 1997
- '
- ' Donated to the public domain
- ' No warranties or guarantees are expressed or implied.
- '
- ' Purpose: Demo of pass by reference and getting around global variables
-
- DECLARE SUB Decrement (i%)
- DECLARE SUB Increment (i%)
-
- CLS
-
- a% = 1
-
- ' results 1 1 2
- PRINT "Round 1:"
- PRINT "Initial Value:"; a%
- Increment (a%)
- PRINT "Passed by reference: "; a%
- Increment a%
- PRINT "Passed by value: "; a%
- PRINT
-
- 'results 2 3 2 3
- PRINT "Round 2: Pass by reference"
- a% = 2
- PRINT "Initial Value:"; a%
- Increment a%
- PRINT "After Increment:"; a%
- Decrement a%
- PRINT "After Decrement:"; a%
- Increment a%
- PRINT "After Second Increment:"; a%
- PRINT
-
- 'results 3 3 3 3
- PRINT "Round 3: Pass by value"
- PRINT "Initial Value"; a%
- Increment (a%)
- PRINT "After Increment:"; a%
- Decrement (a%)
- PRINT "After Decrement:"; a%
- Increment (a%)
- PRINT "After Second Increment:"; a%
- END
-
- SUB Decrement (i%) STATIC
- i% = i% - 1
- END SUB
-
- SUB Increment (i%) STATIC
- i% = i% + 1
- END SUB
-
-