c=0
dim last$(50),first$(50),age$(50),phone$(50)
dim recnum(50)
nomainwin
WindowWidth = 688
WindowHeight = 575
statictext #main.statictext1, "StaticText Caption", 38, 66, 100, 440
statictext #main.statictext2, "StaticText Caption", 148, 66, 100, 440
statictext #main.statictext3, "StaticText Caption", 248, 66, 100, 440
statictext #main.statictext4, "StaticText Caption", 348, 66, 100, 440
open "Showing Records directly from File" for window as #main
print #main, "font ms_sans_serif 0 16"
open "C:\myTestData.txt" for input as #fo
c=0
while eof(#fo)=0
c=c+1
input #fo, name$
last$(c)=name$
input #fo, name$
first$(c)=name$
input #fo, q$
age$(c)=q$
input #fo, q$
phone$(c)=q$
wend
close #fo
recnum=c
showRec1$=""
showRec2$=""
showRec3$=""
showRec4$=""
for i=1 to recnum
showRec1$=showRec1$+last$(i)+chr$(10)+chr$(13)
showRec2$=showRec2$+first$(i)+chr$(10)+chr$(13)
showRec3$=showRec3$+age$(i)+chr$(10)+chr$(13)
showRec4$=showRec4$+phone$(i)+chr$(10)+chr$(13)
next i
print #main.statictext1,showRec1$
print #main.statictext2,showRec2$
print #main.statictext3,showRec3$
print #main.statictext4,using("###,###.##",showRec4$)
[main.inputLoop] 'wait here for input event
wait
END
' Form created with the help of Freeform-J v.261006
' Generated on Jun 19, 2015 at 10:17:41
nomainwin
WindowWidth = 328
WindowHeight = 310
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
N=40 'as big as you need
dim array$(N)
listbox #main.listbox1, array$(, [listbox1DoubleClick], 22, 16, 272, 250
Stylebits #main.listbox1, _WS_HSCROLL, 0,0, 0
open "untitled" for window as #main
print #main, "trapclose [quit.main]"
print #main, "font courier_new 8" 'you need monospaced font so columns neatly stack up
'populate listbox array. Make it big (run several times)
for k = 1 to 5
restore
for i = 1 to 5
j=j+1
read a1$, a2$, n1, n2
array$(j)=padr$(a1$,12)+padr$(a2$,10)+" "+using("###",n1)+" "+using("#######.##",n2)
next
next
'reload listbox
#main.listbox1 "reload"
wait
[quit.main]
Close #main
END
[listbox1DoubleClick] 'Perform action for the listbox named 'listbox1'
'Insert your own code here
wait
data Jones, Joyce, 22, 5.6
data Newman, Bill, 26, 0.35
data Abercrombe, "Tom Cruise", 35, 1254.25
data Belton, Mindy, 28, 1245687.8
data Doyle, Barbara, 15, 1040.05
'-------------------------------
'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