Teen Programmers Unite  
 

 

Return to forum top

Qbasic 4.5 Color&Loop probs

Posted by headco10 [send private reply] at June 03, 2002, 11:53:19 AM

How can you make the color of one single line of print text to be 2+ different colors (like when making ASCII art)

and

When nesting loops and stuff, how does QB determine which LOOP goes with which DO.

Just starting to learn programming so these are probably simple questions, sorry, but please help cause these stupid little things are nagging me. Thanx

Posted by taubz [send private reply] at June 03, 2002, 06:57:30 PM

As far as question #2. Let's say I had the loops

for X = 1 to 5
for Y = 5 to 10
next X
next Y

That really wouldn't make much sense. The loops are sorta intertwined. All languages that use loops match the innermost "loop" (in this case "next") with the innermost "do" (in this case "for"). So:

do ' line 1
do ' line 2
loop ' line 3
loop ' line 4

2 always goes with 3, and 1 always goes with 4.

- taubz

Posted by headco10 [send private reply] at June 04, 2002, 01:09:10 PM

ok, thanks that helps me with that one question.

Posted by headco10 [send private reply] at June 04, 2002, 01:13:11 PM

What I meant by the first question though is I want one line of text to be 2 colors like:

print "What are you doing?"

{What are} {you doing?}
^ ^ ^ ^
Magenta Light Cyan

Posted by sphinX [send private reply] at June 05, 2002, 01:10:35 AM

What's wrong with:

color 5
print "What are ";
color 3
print "you doing?"

note: The semicolon is not an error, it is in fact the operator that will concatenate those two strings together and print them on the same line. It has to do with QBasic's idea of "print zones" ... read the PRINT help for more info.

Posted by headco10 [send private reply] at June 06, 2002, 11:00:16 AM

Thank You
I was forgetting the semicolon
I'm very new to programming so I'm still learning alot of things.

Posted by sphinX [send private reply] at June 06, 2002, 06:27:11 PM

That's Ok, I had to read the help file to find the semicolon, as it's been absolutely years since I used QBasic. So just remember, that when you're having trouble with anything, think of the most likely keyword that could help you (PRINT, in this example), and read the help thoroughly.

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.