Help with PRINT command...
-
- Newbie
- Posts: 1
- Joined: Sat Jul 14, 2007 11:56 pm
Help with PRINT command...
Okay I'm new to programming and I'm making a text RPG Battler to practice coding. So I wanted to know if theres a way to make the text go down a line without doing this
PRINT "1. Attack"
PRINT "2. Defend"
PRINT "3. Magic"
PRINT "4. Escape"
Because that's the only way I know, lol. Just wondering if there's a more convenient way.
PRINT "1. Attack"
PRINT "2. Defend"
PRINT "3. Magic"
PRINT "4. Escape"
Because that's the only way I know, lol. Just wondering if there's a more convenient way.
Unless you plan to print these four lines more than once, your way is the best way.
If you plan on printing those lines many times, this way is better:
Then, each time you need to print the above, you use:
If you plan on printing those lines many times, this way is better:
Code: Select all
DIM P(4) AS STRING
P(1) = "1. Attack"
P(2) = "2. Defend"
P(3) = "3. Magic"
P(4) = "4. Escape"
Then, each time you need to print the above, you use:
Code: Select all
FOR I = 1 TO 4
PRINT P(I)
NEXT I
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
-
- Veteran
- Posts: 399
- Joined: Wed Mar 02, 2005 9:01 pm
- Location: Nashville, Tennessee
- Contact:
I don't know why you would want to, but you could print a carriage return:
Code: Select all
PRINT "1. Attack" + CHR$(13) + "2. Defend" + CHR$(13) + "3. Magic" + CHR$(13) + "4. Escape"
If you're looking for something similar to the C/C++ "\n" then see the post above me.
If you're going to be writing them out a lot, you could always create a sub called "DisplayBattleText" (or whatever) and store the text in there. Then just use a "CALL DisplayBattleText" in your program when you wanted it.
Locate command works as follows:
If you're going to be writing them out a lot, you could always create a sub called "DisplayBattleText" (or whatever) and store the text in there. Then just use a "CALL DisplayBattleText" in your program when you wanted it.
Locate command works as follows:
Code: Select all
LOCATE 5, 6 'that's y-pos, x-pos
PRINT "Where you stated in the previous command"
-
- Veteran
- Posts: 399
- Joined: Wed Mar 02, 2005 9:01 pm
- Location: Nashville, Tennessee
- Contact:
-
- Coder
- Posts: 12
- Joined: Thu Nov 02, 2006 3:51 pm
- Location: Washington
- Contact:
If you want to save lines, just use ":" like this
The ":" represents a new line.
Code: Select all
PRINT "Menu": PRINT "1. Item One": PRINT "2. Item Two"
-yah