|
Post by jarychk on Jul 1, 2022 7:28:21 GMT
I made-up this one myself. This example partly does what I want and partly not do what I want. Alignment is not good. The commas are not doing what I want. Maybe TAB()? I did not see TAB() as part of text nor textedit controls. I was hoping for at least, neat columnar display but not happening.
dim array$(20,3)
array$(1,1)="top col 1" array$(1,2)="top col 2" array$(1,3)="top col 3"
array$(2,1)="mid col 1" array$(2,2)="mid col 2" array$(2,3)="mid col 3"
array$(3,1)="bottom col 1" array$(3,2)="bottom col 2" array$(3,3)="bottom col 3"
'Form created with the help of Freeform 3 v07-31-2015 'Generated on Jul 01, 2022 at 00:00:04
[setup.main.Window]
'-----Begin code for #main nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) '-----Begin GUI objects code TexteditorColor$ = "white" texteditor #main.textedit1, 20, 57, 465, 145
'-----End GUI objects code
'-----Begin menu code menu #main, "Edit" ' <-- Texteditor menu. '-----End menu code open "textedit control" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]"
for i1=1 to 3 for i2=1 to 3 print #main.textedit1,array$(i1,i2);","; next i2 print #main.textedit1,"" next i1
[main.inputLoop] 'wait here for input event wait
[quit.main] 'End the program close #main end
|
|
|
Post by tsh73 on Jul 1, 2022 8:11:36 GMT
only way I know is 1) switch to monospaced font, like Couruer_new (so all characters take same space in pixels) 2) add spaces so fields take same amount of characters
dim array$(20,3)
array$(1,1)="top col 1" array$(1,2)="top col 2" array$(1,3)="top col 3"
array$(2,1)="mid col 1" array$(2,2)="mid col 2" array$(2,3)="mid col 3"
array$(3,1)="bottom col 1" array$(3,2)="bottom col 2" array$(3,3)="bottom col 3"
'Form created with the help of Freeform 3 v07-31-2015 'Generated on Jul 01, 2022 at 00:00:04
[setup.main.Window]
'-----Begin code for #main nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) '-----Begin GUI objects code TexteditorColor$ = "white" texteditor #main.textedit1, 20, 57, 465, 145
'-----End GUI objects code
'-----Begin menu code menu #main, "Edit" ' <-- Texteditor menu. '-----End menu code open "textedit control" for window as #main 'print #main, "font ms_sans_serif 10" print #main, "font courier 10" print #main, "trapclose [quit.main]"
for i1=1 to 3 for i2=1 to 3 'print #main.textedit1,array$(i1,i2);","; print #main.textedit1, padr$(array$(i1,i2), 15); next i2 print #main.textedit1,"" next i1
[main.inputLoop] 'wait here for input event wait
[quit.main] 'End the program close #main end
'--------------------------------------------- 'adds spaces from the left until 'n' symbols 'if n<len(a$) returns left$(a$,n) function padl$(a$,n) padl$ = left$(space$(n-len(a$))+a$,n) end function
'adds spaces from the right until 'n' symbols 'if n<len(a$) returns left$(a$,n) function padr$(a$,n) padr$ = left$(a$+space$(n-len(a$)),n) end function
|
|
|
Post by jarychk on Jul 1, 2022 8:57:02 GMT
Thanks, tsh73. I have trouble understanding exactly how the pad$() function works, but clearly you are making use of spaces. I may need to try to create something different. Not sure how yet. ( At one time a long time ago, I had some skills with string-handling. I lost most of that skill.)
|
|
|
Post by jarychk on Jul 1, 2022 9:28:44 GMT
This is somewhat of an improvement:
dim array$(20,3)
array$(1,1)="top col 1" array$(1,2)="top col 2" array$(1,3)="top col 3"
array$(2,1)="mid col 1" array$(2,2)="mid col 2" array$(2,3)="mid col 3"
array$(3,1)="bottom col 1" array$(3,2)="bottom col 2" array$(3,3)="bottom col 3"
'Form created with the help of Freeform 3 v07-31-2015 'Generated on Jul 01, 2022 at 00:00:04
[setup.main.Window]
'-----Begin code for #main nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) '-----Begin GUI objects code TexteditorColor$ = "white" texteditor #main.textedit1, 20, 57, 465, 145
'-----End GUI objects code
'-----Begin menu code menu #main, "Edit" ' <-- Texteditor menu. '-----End menu code open "textedit control" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]"
rem singleray$ to hold entire array in one single variable singleray$="" for i1=1 to 3 for i2=1 to 3 let singleray$=singleray$+array$(i1,i2)+space$(5) next i2 singleray$=singleray$+chr$(13) next i1 rem rem what happens when print that to the control? print #main.textedit1,singleray$
[main.inputLoop] 'wait here for input event wait
[quit.main] 'End the program close #main end
|
|
|
Post by tsh73 on Jul 1, 2022 10:53:48 GMT
You add fixed amount of space between items. But to align columns, each item should be padded by spaces to same column width.
|
|
|
Post by jarychk on Jul 1, 2022 18:43:26 GMT
You add fixed amount of space between items. But to align columns, each item should be padded by spaces to same column width. I will move along that idea soon. I'll use the idea along with putting the array variables into a single string variable and will make length adjustments using SPACE$().
|
|