558 Lines Of QuickBasic Glory
-
This post relates to the coding horror I posted about earlier today. I dug up my old Tetris code and I found it... the following is the 558 line QuickBasic subroutine I made in high school that prints a string to the screen. Enjoy. :)
SUB PrintMain (Variable1 AS STRING, Variable2 AS STRING, FunctionNum AS INTEGER)
DIM Letter AS STRING
STATIC PrintColor AS INTEGER
STATIC Left AS INTEGER
STATIC Top AS INTEGER
IF FunctionNum = 0 THEN
FOR i = 1 TO LEN(Variable1)
Letter = MID$(Variable1, i, 1)
IF Letter = "A" THEN
LINE (Left + 2, Top)-STEP(1, 0), PrintColor
LINE (Left + 1, Top + 1)-STEP(3, 0), PrintColor
LINE (Left, Top + 2)-STEP(1, 4), PrintColor, BF
LINE (Left + 4, Top + 2)-STEP(1, 4), PrintColor, BF
LINE (Left + 2, Top + 4)-STEP(1, 0), PrintColor, BF
END IF
IF Letter = "B" THEN
LINE (Left, Top)-STEP(5, 0), PrintColor
LINE (Left + 1, Top + 1)-STEP(1, 4), PrintColor, B
LINE (Left, Top + 6)-STEP(5, 0), PrintColor
LINE (Left + 3, Top + 3)-STEP(2, 0), PrintColor
LINE (Left + 5, Top + 1)-STEP(1, 1), PrintColor, B
LINE (Left + 5, Top + 4)-STEP(1, 1), PrintColor, B
END IF
IF Letter = "C" THEN
LINE (Left + 5, Top + 1)-STEP(1, 0), PrintColor
LINE (Left + 2, Top)-STEP(3, 0), PrintColor
LINE (Left + 1, Top + 1)-STEP(1, 0), PrintColor
LINE (Left, Top + 2)-STEP(1, 2), PrintColor, B
LINE (Left + 1, Top + 5)-STEP(1, 0), PrintColor
LINE (Left + 2, Top + 6)-STEP(3, 0), PrintColor
LINE (Left + 5, Top + 5)-STEP(1, 0), PrintColor
END IF
IF Letter = "D" THEN
LINE (Left, Top)-STEP(4, 0), PrintColor
LINE (Left + 1, Top + 1)-STEP(1, 4), PrintColor, B
LINE (Left, Top + 6)-STEP(4, 0), PrintColor
LINE (Left + 4, Top + 1)-STEP(1, 0), PrintColor
LINE (Left + 5, Top + 2)-STEP(1, 2), PrintColor, B
LINI bet it was fast :)
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth Edition -
I bet it was fast :)
xacc.ide
IronScheme - 1.0 RC 1 - out now!
((λ (x) `(,x ',x)) '(λ (x) `(,x ',x))) The Scheme Programming Language – Fourth EditionI didn't run any benchmarks, but I doubt running 60 or so IF statements for each character would be extremely performant. :)
-
Don't beat yourself up. It's called a learning curve. ;) FWIW, I could not look back at the code I wrote in my first two years without wanting to throw up in my mouth a little bit.
I'm not beating myself up. I'm beating my old self up. Which is in contrast to my current self, who is quite not idiotic. Well, until 10 years from now when I see my current self as an idiot too. ;P
-
aspdotnetdev wrote:
IF Letter = "`" THEN LINE (Left + 2, Top)-STEP(1, 1), PrintColor, B LINE (Left + 3, Top + 2)-STEP(1, 0), PrintColor END IF
Does anyone even USE that character? Seriously, man... Too much free time :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Ian Shlasko wrote:
Does anyone even USE that character? Seriously, man... Too much free time
The GCC compiler can use the ` character for parts of parameters to some of it's commands... I'm not sure which ones exactly, or even why they even decided to allow the ` character :doh: . I never bothered to figure out where the ` character could be used with it because it seems such a useless character. I don't even know what it's called... a wonky apostrophe? :laugh: Your right though, who even uses the ` character? :)
"People demand freedom of speech to make up for the freedom of thought which they avoid."
-
This post relates to the coding horror I posted about earlier today. I dug up my old Tetris code and I found it... the following is the 558 line QuickBasic subroutine I made in high school that prints a string to the screen. Enjoy. :)
SUB PrintMain (Variable1 AS STRING, Variable2 AS STRING, FunctionNum AS INTEGER)
DIM Letter AS STRING
STATIC PrintColor AS INTEGER
STATIC Left AS INTEGER
STATIC Top AS INTEGER
IF FunctionNum = 0 THEN
FOR i = 1 TO LEN(Variable1)
Letter = MID$(Variable1, i, 1)
IF Letter = "A" THEN
LINE (Left + 2, Top)-STEP(1, 0), PrintColor
LINE (Left + 1, Top + 1)-STEP(3, 0), PrintColor
LINE (Left, Top + 2)-STEP(1, 4), PrintColor, BF
LINE (Left + 4, Top + 2)-STEP(1, 4), PrintColor, BF
LINE (Left + 2, Top + 4)-STEP(1, 0), PrintColor, BF
END IF
IF Letter = "B" THEN
LINE (Left, Top)-STEP(5, 0), PrintColor
LINE (Left + 1, Top + 1)-STEP(1, 4), PrintColor, B
LINE (Left, Top + 6)-STEP(5, 0), PrintColor
LINE (Left + 3, Top + 3)-STEP(2, 0), PrintColor
LINE (Left + 5, Top + 1)-STEP(1, 1), PrintColor, B
LINE (Left + 5, Top + 4)-STEP(1, 1), PrintColor, B
END IF
IF Letter = "C" THEN
LINE (Left + 5, Top + 1)-STEP(1, 0), PrintColor
LINE (Left + 2, Top)-STEP(3, 0), PrintColor
LINE (Left + 1, Top + 1)-STEP(1, 0), PrintColor
LINE (Left, Top + 2)-STEP(1, 2), PrintColor, B
LINE (Left + 1, Top + 5)-STEP(1, 0), PrintColor
LINE (Left + 2, Top + 6)-STEP(3, 0), PrintColor
LINE (Left + 5, Top + 5)-STEP(1, 0), PrintColor
END IF
IF Letter = "D" THEN
LINE (Left, Top)-STEP(4, 0), PrintColor
LINE (Left + 1, Top + 1)-STEP(1, 4), PrintColor, B
LINE (Left, Top + 6)-STEP(4, 0), PrintColor
LINE (Left + 4, Top + 1)-STEP(1, 0), PrintColor
LINE (Left + 5, Top + 2)-STEP(1, 2), PrintColor, B
LINHey sir wi juant to iuse ur code in mexico can u ad ;P ń support
RS
-
Hey sir wi juant to iuse ur code in mexico can u ad ;P ń support
RS
robertosalazar wrote:
to iuse ur code
While the above terrible code is an excellent example, iUse™ is a registered trademark of Apple™. Please discontinue your use of this term. ;P
-
aspdotnetdev wrote:
IF Letter = "`" THEN LINE (Left + 2, Top)-STEP(1, 1), PrintColor, B LINE (Left + 3, Top + 2)-STEP(1, 0), PrintColor END IF
Does anyone even USE that character? Seriously, man... Too much free time :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Adnan Siddiqui always used it in place of apostrophes. But he's not been around for a few years now, I guess his bomb suit finally worked.
Cheers, विक्रम (Got my troika of CCCs!) After all is said and done, much is said and little is done.
-
Ian Shlasko wrote:
Does anyone even USE that character? Seriously, man... Too much free time
The GCC compiler can use the ` character for parts of parameters to some of it's commands... I'm not sure which ones exactly, or even why they even decided to allow the ` character :doh: . I never bothered to figure out where the ` character could be used with it because it seems such a useless character. I don't even know what it's called... a wonky apostrophe? :laugh: Your right though, who even uses the ` character? :)
"People demand freedom of speech to make up for the freedom of thought which they avoid."
It's called the backtick, gets a few obscure uses. I think you can use it for formatting at SO though. Some text-based markup systems (possibly Markdown?) use it to denote code etc. Just sayin'. :-\
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
-
CTRL+V is the best function ever. Once you learn that, you never need anything else... lol
Josh Davis
This is what plays in my head when I finish projects.What about Ctrl+C? :laugh:
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."
-
It's called the backtick, gets a few obscure uses. I think you can use it for formatting at SO though. Some text-based markup systems (possibly Markdown?) use it to denote code etc. Just sayin'. :-\
Don't forget to rate my post if it helped! ;) "He has no enemies, but is intensely disliked by his friends." "His mother should have thrown him away, and kept the stork." "There's nothing wrong with you that reincarnation won't cure." "He loves nature, in spite of what it did to him."