Language XBLite
(a console version)
| Date: | 11/11/06 |
| Author: | Guy Lonne |
| URL: | n/a |
| Comments: | 1 |
| Info: | http://perso.wanadoo.fr/xblite/ |
| Score: |
PROGRAM "test"
VERSION "1.0"
CONSOLE
DECLARE FUNCTION Entry ()
FUNCTION Entry ()
FOR b = 99 TO 3 STEP -1
? b; " bottles of beer on the wall,"; b; " bottles of beer."
b_1 = b - 1
? "Take one down and pass it around,"; b_1; " bottles of beer on the wall.\n"
NEXT b
? "2 bottles of beer on the wall, 2 bottles of beer."
? "Take one down and pass it around, 1 bottle of beer on the wall.\n"
? "1 bottle of beer on the wall, 1 bottle of beer."
? "Take one down and pass it around, no more bottles of beer on the wall.\n"
? "No more bottles of beer on the wall, no more bottles of beer."
? "Go to the store and buy some more, 99 bottles of beer on the wall.\n"
a$ = INLINE$ ("Press Enter to quit >")
END FUNCTION
END PROGRAM
Download Source | Write Comment
Alternative Versions
| Version | Author | Date | Comments | Rate |
|---|---|---|---|---|
| A WIN32 version of the xbasic compiler. | Guy Lonne | 10/06/06 | 0 |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
I asked 2 questions to David Szafranski concerning the console-mode submission:
1. why do I loose the very 1st line: " 99 bottles of beer on the wall, 2 bottles of beer."?
Your program prints many lines of text. It exceeds the default
number of lines in the console buffer. To add more buffer space
you need to use :
IMPORT "xio"
hStdOut = XioGetStdOut ()
' maxLines is number of lines in buffer
maxLines = 500
XioSetConsoleBufferSize (hStdOut, 0, maxLines)
2. why "? b; " bottles..." prints " n bottles..." with a leading space for n?
The leading space is for negative values.
Use STRING$() to remove leading space:
? STRING$(b);
Here is the corrected version:
PROGRAM "test"
VERSION "2.0"
CONSOLE
IMPORT "xio"
DECLARE FUNCTION Entry ()
FUNCTION Entry ()
hStdOut = XioGetStdOut ()
' maxLines is number of lines in buffer
maxLines = 500
XioSetConsoleBufferSize (hStdOut, 0, maxLines)
FOR b = 99 TO 3 STEP -1
' the leading space is for negative values
? STRING$(b);" bottles of beer on the wall,";b;" bottles of beer."
b_1 = b - 1
? "Take one down and pass it around,";b_1;" bottles of beer on the wall.\n"
NEXT b
? "2 bottles of beer on the wall, 2 bottles of beer."
? "Take one down and pass it around, 1 bottle of beer on the wall.\n"
? "1 bottle of beer on the wall, 1 bottle of beer."
? "Take one down and pass it around, no more bottles of beer on the wall.\n"
? "No more bottles of beer on the wall, no more bottles of beer."
? "Go to the store and buy some more, 99 bottles of beer on the wall.\n"
a$ = INLINE$ ("Press Enter to quit >"
END FUNCTION
END PROGRAM