print function
Moderators:Administrator, Global Moderator
I am just starting to learn quick basic and am having trouble with a print function. I am trying to print the alphabet in alternating order, such as A, b, C, d....
Also I need to know how to get it to print on one line. At this point I have no problem getting it to print in the alternating order, but it isnt all on the one line.
Any help would be greatly appreciated.
Thanks
Also I need to know how to get it to print on one line. At this point I have no problem getting it to print in the alternating order, but it isnt all on the one line.
Any help would be greatly appreciated.
Thanks
Re: print function
There's a couple different ways you could do this. One way would be to build a string before you print;
-----------------------------------------------------------
FOR x = 1 to 52
READ a$
alphabet$ = alphabet$ + a$
NEXT x
PRINT alphabet$
. . .
' your code
. . .
DATA A,a,B,b,C,c, . . . .
-----------------------------------------------------------
If you want a space between the letters, do: alphabet$ = alphabet$ + a$ + " "
or, use the "LOCATE" function
-----------------------------------------------------------
row = 10
col = 4
FOR x = 1 to 52
READ a$
LOCATE row, col + x: PRINT a$
NEXT x
. . .
' your code
. . .
DATA A,a,B,b,C,c, . . .
-----------------------------------------------------------
I always prefer using the LOCATE statement myself, but there are other ways.
-----------------------------------------------------------
FOR x = 1 to 52
READ a$
alphabet$ = alphabet$ + a$
NEXT x
PRINT alphabet$
. . .
' your code
. . .
DATA A,a,B,b,C,c, . . . .
-----------------------------------------------------------
If you want a space between the letters, do: alphabet$ = alphabet$ + a$ + " "
or, use the "LOCATE" function
-----------------------------------------------------------
row = 10
col = 4
FOR x = 1 to 52
READ a$
LOCATE row, col + x: PRINT a$
NEXT x
. . .
' your code
. . .
DATA A,a,B,b,C,c, . . .
-----------------------------------------------------------
I always prefer using the LOCATE statement myself, but there are other ways.
Re: print function
Thanks for the help.
What if I want them to alternate between capital and lower case.
Ex. A, b, C, d, E, f, G, h....
What if I want them to alternate between capital and lower case.
Ex. A, b, C, d, E, f, G, h....
Re: print function
You can put anything you want into a DATA statement:
DATA A,b,C,d,E,my poo don't stink,f,G,h, . . .
Just make sure the "FOR x = . . ." has the correct number of elements.
FOR x = 1 to 26 if you're going to use one letter of the alphabet each.
DATA A,b,C,d,E,my poo don't stink,f,G,h, . . .
Just make sure the "FOR x = . . ." has the correct number of elements.
FOR x = 1 to 26 if you're going to use one letter of the alphabet each.
Re: print function
Or better yet, try this code:
---------------------------------------------
CLS
a$=""
FOR x = 1 to 26
IF x MOD 2 > 0 THEN a = x + 64 else a = x + 96
a$ = a$ + CHR$(a)
NEXT x
LOCATE 10, 10: PRINT a$
END
-----------------------------------------------
The two 10's can be anywhere you want on the screen.
---------------------------------------------
CLS
a$=""
FOR x = 1 to 26
IF x MOD 2 > 0 THEN a = x + 64 else a = x + 96
a$ = a$ + CHR$(a)
NEXT x
LOCATE 10, 10: PRINT a$
END
-----------------------------------------------
The two 10's can be anywhere you want on the screen.
Re: print function
Hey, thanks a lot for the help. As I said earlier this is my first time working with quick basic or anyother programming language and I'm still trying to catch on to all the concepts.
Thanks again.
Thanks again.
Re: print function
You're welcome. ;D
I'm in the intermediate stage. I know more than beginners, but not as much as the experts.
When I get stuck, I go over to: QuickBasicNews.Com
Another great QB forum.
I'm in the intermediate stage. I know more than beginners, but not as much as the experts.
When I get stuck, I go over to: QuickBasicNews.Com
Another great QB forum.
Re: print function
Hi,
To print om the same line put a
;
after the print statement
ie.
PRINT "A";
PRINT "b";
PRINT "C";
.
.
.
PRINT "z"
Pappy
To print om the same line put a
;
after the print statement
ie.
PRINT "A";
PRINT "b";
PRINT "C";
.
.
.
PRINT "z"
Pappy