Qbasicnews.com

Full Version: Print in table format help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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

can you please help me, thanks
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.
can you check the link again, because it doesnt work for me thanks
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.
thank you very much
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
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
Thanks, wow very nice. Thanks man