Qbasicnews.com
April 09, 2020, 07:00:42 AM
 Pages: [1]
 Author Topic: Print in table format help  (Read 2391 times)
z06leonhart
New Member

Posts: 11

 « on: March 09, 2003, 10:30:12 PM »

CLS
FOR x = 0 TO 10
FOR y = 0 TO 10
z = x * y
PRINT x; "*" ;y; "=" ;z
NEXT x
NEXT y

i supposed to make a multiplication tables from 1 to 10
i think i did everything. But can anyone show me how can i put that in a table format(not just a long list of mul)like:

0 * 0 = 0   0 * 1 = 0   0 * 2 = 0  0 * 3 = 0  0 * 4 = 0  continue to 10
0*  1 = 0 and so on
0 * 2 = 0 so on

 Logged
toonski84
__/--\__

Posts: 2567

 « Reply #1 on: March 09, 2003, 10:43:53 PM »

well, with this nifty function you can print at x and y coordinates:

http://qbasicnews.com/qboho/qcklocate.shtml

just remember:  you can't print at zero, and since those multiplication value can be up to three digits, you might want to space out each entry 4 characters.  so by plugging in the x values times four plus 1, and the y value plus 1, you can have something table-like to mess with.
 Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
z06leonhart
New Member

Posts: 11

 « Reply #2 on: March 09, 2003, 10:52:42 PM »

can you check the link again, because it doesnt work for me thanks
 Logged
pr0gger
I hold this place together

Posts: 775

 « Reply #3 on: March 09, 2003, 10:56:12 PM »

here's what's there:

LOCATE Statement Details

Syntax
LOCATE [row][,[column][,[cursor][,[start,stop]]]]

Argument   Description
row        The number of a row on the screen; row is a numeric
expression returning an integer. If row is not specified,
then the line (row) does not change.
column     The number of a column on the screen; column is a numeric
expression returning an integer. If column is not
specified, then the column location does not change.
cursor     A Boolean value indicating whether the cursor is visible
or not. A value of 0 (zero) indicates cursor off; a value
of 1 indicates cursor on.
start      The starting scan line of cursor on the screen. It must
be a numeric expression returning an integer.
stop       The ending scan line of cursor on the screen. It must be
a numeric expression returning an integer.

You may omit any argument from the statement. When you omit the row
or column, LOCATE leaves the cursor at the row or column where it was
moved by a previous LOCATE or a previous input or output statement,
whichever occurred most recently. When you omit other arguments,
QuickBASIC assumes the previous value for the argument.

Note that the start and stop lines are the CRT scan lines that specify
which pixels on the screen are lit. A wider range between the start
and stop lines produces a taller cursor, such as one that occupies an
entire character block. When start is less than stop, LOCATE produces
a two-part cursor. If the start line is given, stop must also be
specified.

The last line on the screen is reserved for the soft-key display and
is not accessible to the cursor unless the soft-key display is off
(KEY OFF) and LOCATE is used with PRINT to write on the line.
 Logged

size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
z06leonhart
New Member

Posts: 11

 « Reply #4 on: March 09, 2003, 10:59:30 PM »

thank you very much
 Logged
z06leonhart
New Member

Posts: 11

 « Reply #5 on: March 11, 2003, 01:30:47 AM »

Can you tell me where do i put "locate"

i tried to plug something like Locate y+1, x+4 almost after every single line. I also try many other number for LOCATE without the x and y. N still it doesnt work right.

CLS
FOR x = 1 TO 10
FOR y = 0 TO 10
z = x * y
PRINT x; "*" ;y; "=" ;z
NEXT x
NEXT y
 Logged
Dex4now
Member

Posts: 75

 « Reply #6 on: March 11, 2003, 06:27:50 AM »

Try this:

Code:

CLS
FOR y = 0 to 10
FOR x = 1 to 10
z = x * y
z\$ = RIGHT\$(STR\$(z), LEN(STR\$(z)) - 1)
x\$ = RIGHT\$(STR\$(x), LEN(STR\$(x)) - 1)
y\$ = RIGHT\$(STR\$(y), LEN(STR\$(y)) - 1)
LOCATE y + 4, (x * 8) - 7: PRINT USING "&*&=&"; x\$; y\$; z\$
NEXT x
NEXT y
END

Notice that you can't fit the a 10 by 10 grid on an 80 column
screen without doing a bit of data compression.  Thats what
necessitated the wierd string manipulations.

Even this method still wraps the last digit in the last answer,
so try this also, the "table" method:

Code:

CLS
SCREEN 12
FOR x = 1 TO 10
COLOR 10: LOCATE 4, (x * 7) + 1: PRINT USING "###"; x
NEXT x
FOR y = 0 TO 10
COLOR 10: LOCATE y + 6, 1: PRINT USING "####"; y
FOR x =1 TO 10
z = x * y
COLOR 11: LOCATE y + 6, (x * 7): PRINT USING "####"; z
NEXT x
NEXT y
END

Mess around with all this till you get what you like.

Dex
 Logged
z06leonhart
New Member

Posts: 11

 « Reply #7 on: March 11, 2003, 04:52:58 PM »

Thanks, wow very nice. Thanks man
 Logged
 Pages: [1]