|
Post by honkytonk on May 16, 2020 7:14:56 GMT
An exemple for study: Change dimcell value and see
NOMAINWIN WindowWidth = 615: WindowHeight = 400 UpperLeftX = 10: UpperLeftY = 20 GRAPHICBOX #w.m, 5, 5, 600, 360 OPEN "Help" FOR window_nf AS #w #w, "TRAPCLOSE [closeHelp]" #w.m "down;fill black" dimcell=30: a$=" A B C D E F G H J I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0" for x=1 to int(600/dimcell) 'number of cells for y=1 to int(360/dimcell) r=int(rnd(1)*255) + 1: g=int(rnd(1)*255) + 1: b=int(rnd(1)*255) + 1 col$=str$(r)+" "+str$(g)+" "+str$(b) #w.m, "color ";col$: #w.m, "backcolor ";col$ if xx >= 600 then xx=1: yy=yy+dimcell if n > 37 then n=1 #w.m, "place ";xx;" ";yy: #w.m, "boxfilled ";xx+dimcell-1; " ";yy+dimcell-1 #w.m, "color black": #w.m, "backcolor ";col$ #w.m, "place ";xx+10;" ";yy+18: #w.m, "\";word$(a$,n) xx=xx+dimcell: n=n+1 next y next x wait [closeHelp] CLOSE #w END
|
|
|
Post by B+ on May 16, 2020 17:31:12 GMT
Modifying honkytonks to show color changing in table with easier a$() array for our table values:
'set up constants global XMAX, YMAX, a$, cellPixels, cellsWide, cellsHigh XMAX = 600 : YMAX = 360 : cellPixels = 30 'by 30 cellsWide = 20 : cellsHigh = 12
dim a$(cellsWide, cellsHigh) 'table for row = 1 to cellsHigh for col = 1 to cellsWide a$(col, row) = mid$("ABCDEFGHIJKLMNOPQRSTUVWXYZ", row, 1) + Mid$("abcdefghijklmnopqrstuvwxyz", col, 1) 'Print a$(col, row) next next
'so the row is the Capital letter and the column is the lower case letter
NOMAINWIN WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = 100: UpperLeftY = 20 OPEN "Stripe Table" FOR graphics_nsb_nf AS #w #w "TRAPCLOSE quit" #w "down"
for y = 1 to cellsHigh for x = 1 to cellsWide '20 across, 12 down r=int(rnd(1)*255) + 1: g=int(rnd(1)*255) + 1: b=int(rnd(1)*255) + 1 col$=str$(r)+" "+str$(g)+" "+str$(b) #w "color ";col$: #w "backcolor ";col$ #w "place ";(x-1)*cellPixels;" ";(y-1)*cellPixels #w "boxfilled ";x*cellPixels; " ";y*cellPixels #w "color black": #w "backcolor ";col$ #w "place ";(x-1)*cellPixels+5;" ";(y-1)*cellPixels+19 #w "\";a$(x, y) next next call pause 500 scan
' changing random colors to stripes, either the rows or the columns
do scan 'make rnd bright color r=int(rnd(1)*128) + 127: g=int(rnd(1)*128) + 127: b=int(rnd(1)*128) + 127 col$=str$(r)+" "+str$(g)+" "+str$(b) stripe = (stripe + 1) mod 4 select case stripe case 0 for y = 1 to cellsHigh for x = 1 to cellsWide step 2 scan call colorCell x, y, col$ call pause 100 next next case 1 for y = 1 to cellsHigh for x = 2 to cellsWide step 2 scan call colorCell x, y, col$ call pause 100 next next case 2 for y = 1 to cellsHigh step 2 for x = 1 to cellsWide scan call colorCell x, y, col$ call pause 100 next next case 3 for y = 0 to cellsHigh step 2 for x = 1 to cellsWide scan call colorCell x, y, col$ call pause 100 next next end select loop until 0 wait
sub quit h$ CLOSE #w END end sub
sub colorCell col, row, c$ 'note$ a$ and cellPixels were made global so this sub could access their values #w "color ";c$: #w "backcolor ";c$ #w "place ";(col-1)*cellPixels;" ";(row-1)*cellPixels #w "boxfilled ";col*cellPixels; " ";row*cellPixels #w "color black": #w "backcolor ";c$ #w "place ";(col-1)*cellPixels+5;" ";(row-1)*cellPixels+19 #w "\";a$(col, row) end sub
sub pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
|
|
|
Post by tsh73 on May 16, 2020 21:07:01 GMT
There are NO table control in Just Basic.
Depending on what you really want, you can * print text in aligned form * draw grid and text in a graphicbox * draw grid and text in a graphicbox and make one cell editable with textbox control * make HTML source table and use any browser to show \ print table for you * make CSV file and use Excel|Open Office Calc (or such) to show \ work with table further. That't just what came to my mind.
|
|
|
Post by honkytonk on May 17, 2020 10:23:08 GMT
To reflect and correct
NOMAINWIN WindowWidth = 615: WindowHeight = 400 UpperLeftX = 10: UpperLeftY = 20 GRAPHICBOX #w.m, 5, 5, 600, 360 OPEN "Help" FOR window_nf AS #w #w, "TRAPCLOSE [closeHelp]" #w.m "down;fill black" dimcell=20: a$=" A B C D E F G H J I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0" for x=1 to int(600/dimcell) ' #w.m "place 10 15": #w.m "\?" if flag=1 then col$="yellow" if flag=0 then col$="white" for y=1 to int(360/dimcell) #w.m, "color ";col$: #w.m, "backcolor ";col$ if xx >= 600 then xx=1: yy=yy+dimcell if n > 37 then n=1 #w.m, "place ";xx;" ";yy: #w.m, "boxfilled ";xx+dimcell-1; " ";yy+dimcell-1 #w.m, "color black": #w.m, "backcolor ";col$ #w.m, "place ";xx+10;" ";yy+18: #w.m, "\";word$(a$,n) xx=xx+dimcell: n=n+1 next y flag=flag+1: if flag=2 then flag=0 next x wait [closeHelp] CLOSE #w END
|
|
ice
New Member
Posts: 10
|
Post by ice on May 18, 2020 10:44:35 GMT
Thank you all so much for your replies. I will try experimenting with the dimcell values.
|
|
|
Post by honkytonk on May 18, 2020 12:18:48 GMT
Thank you all so much for your replies. I will try experimenting with the dimcell values. Look at what's wrong in the code of: "yesterday at 12:23 pm" to get white yellow white yellow white line. Look at how many boxes the color changes. Only two lines are concerned. (plus two; As JB will tell you if you forget them).
|
|
|
Post by jarych on May 23, 2020 4:30:21 GMT
I ran both of them just to see what they looked like (their result). You have yourself a fine exercsise. Maybe you are planning to do something more with it.
I looked through the code to see how you made the second example stick, while the first example did not stick, when another window covered them. I forgot the command for this, but I cannot find anything in your code that makes the difference.
|
|
|
Post by tsh73 on May 23, 2020 6:49:16 GMT
it's supposed to be
#w.m, "flush"
|
|
|
Post by honkytonk on May 23, 2020 10:03:42 GMT
it's supposed to be #w.m, "flush" On the other hand, it's been a while since I broke my head so that in the code: "May 17, 2020 at 12:23 pm"; the first letter is in the first box without shifting the last boxes in "x". (#w.m, "place ";xx+10-dimcell (for "A" in first place)) I do not understand why the first letter is in the second box, when the xx value is 1 when writing.
|
|
|
Post by jarych on May 24, 2020 0:52:58 GMT
it's supposed to be #w.m, "flush" On the other hand, it's been a while since I broke my head so that in the code: "May 17, 2020 at 12:23 pm"; the first letter is in the first box without shifting the last boxes in "x". (#w.m, "place ";xx+10-dimcell (for "A" in first place)) I do not understand why the first letter is in the second box, when the xx value is 1 when writing. That should be the command. Still, I do not see it in either of honkytonk's code examples.
|
|
|
Post by B+ on May 24, 2020 3:45:07 GMT
fixed, your code uses n for letters.
NOMAINWIN WindowWidth = 615: WindowHeight = 400 UpperLeftX = 10: UpperLeftY = 20 GRAPHICBOX #w.m, 5, 5, 600, 360 OPEN "Help" FOR window_nf AS #w #w, "TRAPCLOSE [closeHelp]" #w.m "down;fill black" dimcell=20: a$=" A B C D E F G H J I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0" n = 1 for x=1 to int(600/dimcell) ' #w.m "place 10 15": #w.m "\?" if flag=1 then col$="yellow" if flag=0 then col$="white" for y=1 to int(360/dimcell) #w.m, "color ";col$: #w.m, "backcolor ";col$ if xx >= 600 then xx=1: yy=yy+dimcell if n > 37 then n=1 #w.m, "place ";xx;" ";yy: #w.m, "boxfilled ";xx+dimcell-1; " ";yy+dimcell-1 #w.m, "color black": #w.m, "backcolor ";col$ #w.m, "place ";xx+10;" ";yy+18: #w.m, "\";word$(a$,n) xx=xx+dimcell: n=n+1 next y flag=flag+1: if flag=2 then flag=0 next x wait [closeHelp] CLOSE #w END
|
|
|
Post by honkytonk on May 24, 2020 9:12:01 GMT
@ B+: Oh my good it's so obvious that a wolf would have eaten me. VĂ©ry thank.
|
|