
-----------------------------------
illu45
Thu Mar 10, 2005 8:58 pm

Table of Squares
-----------------------------------
Hey guys,

I'm trying to make a table that lists a number, makes a space and then lists a sqaure. What I have so far is this:

put "Number", "      ", "Sqaure"
for i : 1 .. 50
    if i**2 < 100 then
        put i, "              ", i ** 2
        delay (100)
    elsif i ** 2 >= 100 then
        put i, "             ", i ** 2
        delay (100)
    end if
end for


The only problem with this is that I want it to move over to the right instead of scrolling. After numerous failed attempts with the locate command, I decided to scrap it adn try to only use the "        ", as  you can see above, unfortunately, I can't seem to get it to wrap around that way.

Any ideas would be greatly appretiated,
illu45

-----------------------------------
person
Thu Mar 10, 2005 9:13 pm


-----------------------------------
can u explain wat u mean by "wrap"?

-----------------------------------
ssr
Thu Mar 10, 2005 9:33 pm


-----------------------------------
use something like this 

put "x":3
 8)

-----------------------------------
ssr
Thu Mar 10, 2005 10:13 pm


-----------------------------------
for i:1..16
put i:5.. 
end for
for i:1..16
put i**2:5.. 
end for
for i:1..maxcol
put"_"..
end for
for i:17..32
put i:5.. 
end for
for i:17..32
put i**2:5.. 
end for
for i:1..maxcol
put"_"..
end for
for i:33..48
put i:5.. 
end for
for i:33..48
put i**2:5.. 
end for
for i:1..maxcol
put"_"..
end for
for i:49..50
put i:5.. 
end for
put " "
for i:49..50
put i**2:5.. 
end for
These r such shameful codes
soo long
ppl probably do it in 5 lines
but this just shows the format ...... I think  :shock:  :?  8)

-----------------------------------
Cervantes
Fri Mar 11, 2005 4:31 pm


-----------------------------------
How about this?

var output : string
var row := 2
var col := 1
put "Number", "      ", "Sqaure"
for i : 1 .. 50
    output := intstr (i) + "**2 = " + intstr (i ** 2)
    if col + length (output) < maxcol then
        if col + length (output) + length (" ~~ ") < maxcol then
            output += " ~~ "
        end if
        locate (row, col)
        put output ..
        col += length (output)
    else
        row += 1
        col := 1
    end if
    delay (100)
end for


-----------------------------------
illu45
Fri Mar 11, 2005 6:23 pm


-----------------------------------
That works pretty well, except that the Numbe/Square headings and the numbers don't line up to well... I finished it up at school today, but don't have it on me (at home now), I'll post it on Monday.

-----------------------------------
illu45
Tue Mar 15, 2005 6:35 pm


-----------------------------------
Here's the code, as promised:


%Question 6
var row, col : int
row := 3
col := 1
put "Number", "      ", "Sqaure"
for i : 1 .. 50
    if i ** 2 < 100 then
        locate (row, col)
        row := row + 1
        put i, "              ", i ** 2
        if row = 25 then
            row := 3
            col := col + 30
            locate (row, col)
            put "Number", "      ", "Sqaure"
        end if
        delay (100)
    elsif i ** 2 >= 100 then
        locate (row, col)
        put i, "             ", i ** 2        
        row := row + 1
        if row = 25 then
            row := 3
            col := col + 30
            locate (1, col)
            put "Number", "      ", "Sqaure"
        end if
        delay (100)
    end if
end for


-----------------------------------
ssr
Tue Mar 15, 2005 7:11 pm


-----------------------------------
Here's the code, as promised:


%Question 6
var row, col : int
row := 3
col := 1
put "Number", "      ", "Sqaure"
for i : 1 .. 50
    if i ** 2 < 100 then
        locate (row, col)
        row := row + 1
        put i, "              ", i ** 2
        if row = 25 then
            row := 3
            col := col + 30
            locate (row, col)
            put "Number", "      ", "Sqaure"
        end if
        delay (100)
    elsif i ** 2 >= 100 then
        locate (row, col)
        put i, "             ", i ** 2        
        row := row + 1
        if row = 25 then
            row := 3
            col := col + 30
            locate (1, col)
            put "Number", "      ", "Sqaure"
        end if
        delay (100)
    end if
end for

lol thats what u wanted... :D

-----------------------------------
ssr
Tue Mar 15, 2005 7:47 pm


-----------------------------------
another code
 :D 
var c:=1
var r:=1
for i:1..50
r+=1
locate (r,c)
put i:2, "  ----->",i**2:4," |"
if r =23 then 
c+=16
r:=1
end if
end for


-----------------------------------
Flikerator
Wed Mar 16, 2005 12:09 pm


-----------------------------------
another code
 :D 
var c:=1
var r:=1
for i:1..50
r+=1
locate (r,c)
put i:2, "  ----->",i**2:4," |"
if r =23 then 
c+=16
r:=1
end if
end for


You knocked the shiz outa that code lolz
