Post by zzz000abc on Feb 29, 2020 19:56:41 GMT
create a form with any number of fields on the fly.
' by changing the entries of fls$ you can modify increase or derease
' fields.
WindowWidth=500
fls$="first name ;last name;cell;landline; address; email;pin;city;profile;company;status"
fmx=wc(fls$)
fn=1:x=10:y=10:w=200:h=40:dx=120:dy=10
lmax=0
for i=1 to fmx
if len(word$(fls$,i,";"))>lmax then lmax=len(word$(fls$,i,";"))
next
lmax=lmax+40
for i=1 to fmx
s$=space$(lmax-len(word$(fls$,i,";")))+mid$(word$(fls$,i,";"),1,15)+" :"'+space$(lmax-len(word$(fls$,i,";")))
ss$=ss$+s$+";"
next
ss$=left$(ss$,len(ss$)-1)
scr=1:lscr=(fmx mod 5 >0)+int(fmx/5):dim subrec$(lscr)
[scr0]
fmx1=min(fmx,5*scr)
fn=1+(scr-1)*5
k=cntrl1(fn,fmx1,ss$)
WindowHeight=50*((fmx1 mod 5=0)*5+fmx1 mod 5)+150
wtitle$="screen";str$(scr);"/";str$(lscr)
open wtitle$ for window as #1
k=cntrl2(fn,fmx1)
wait
[prev1]
if scr>1 then close #1:scr=scr-1 :goto [scr0]
wait
[next1]
if scr<lscr then close #1:scr=scr+1: goto [scr0]
wait
[save1]
subrec$(scr)=post$(fn,fmx1)
rec$=""
for i=1 to lscr
if subrec$(i)<>"" then rec$=rec$+subrec$(i)+";"
next
rec$=left$(rec$,len(rec$)-1)
print rec$
wait
[close1]
close #1 :end
wait
function cntrl1(fn,fmx,fls$)
x=10:y=10:w=200:h=50:dx=120:dy=10:dlim$=";"
if fn>fmx then goto [wm]
statictext #1.st1,word$(fls$,fn,dlim$),x,y,w,50
textbox #1.tb1,x+w,y+20,w,h:fn=fn+1
if fn>fmx then goto [wm]
statictext #1.st2,word$(fls$,fn,dlim$),x,y+50,w,50
textbox #1.tb2,x+w,y+20+50,w,h:fn=fn+1
if fn>fmx then goto [wm]
statictext #1.st3,word$(fls$,fn,dlim$),x,y+100,w,50
textbox #1.tb3,x+w,y+100+20,w,h:fn=fn+1
if fn>fmx then goto [wm]
statictext #1.st4,word$(fls$,fn,dlim$),x,y+150,w,50
textbox #1.tb4,x+w,y+150+20,w,h:fn=fn+1
if fn>fmx then goto [wm]
statictext #1.st5,word$(fls$,fn,dlim$),x,y+200,w,50
textbox #1.tb5,x+w,y+200+20,w,h
[wm]
fn=((fmx mod 5=0)*5+(fmx mod 5)+1)
button #1.bt1,"<prev",[prev1],UL,x,y+fn*50
button #1.bt2,"next>",[next1],UL,x+120,y+fn*50
button #1.bt3,"save",[save1],UL,x+240,y+fn*50
button #1.bt4,"close",[close1],UL,x+380,y+fn*50
cntrl1=0
end function
function cntrl2(fn,fmx)
#1.bt1 "!font tahoma 15"
#1.bt2 "!font tahoma 15"
#1.bt3 "!font tahoma 15"
#1.bt4 "!font tahoma 15"
if fn>fmx then goto [nxt]
#1.st1 "!font tahoma 15 bold"
#1.tb1 "!font tahoma 20":fn=fn+1
if fn>fmx then goto [nxt]
#1.st2 "!font tahoma 15"
#1.tb2 "!font tahoma 16" :fn=fn+1
if fn>fmx then goto [nxt]
#1.st3 "!font tahoma 15"
#1.tb3 "!font tahoma 15" :fn=fn+1
if fn>fmx then goto [nxt]
#1.st4 "!font tahoma 15"
#1.tb4 "!font tahoma 15" :fn=fn+1
if fn>fmx then goto [nxt]
#1.st5 "!font tahoma 15"
#1.tb5 "!font tahoma 15" :fn=fn+1
[nxt]
cntrl2=0
end function
function post$(fn,fmx)
p$=""
if fn>fmx then goto [npost]
#1.tb1 "!contents? p1$" :fn=fn+1:p$=p$+p1$+";"
if fn>fmx then goto [npost]
#1.tb2 "!contents? p2$" :fn=fn+1:p$=p$+p2$+";"
if fn>fmx then goto [npost]
#1.tb3 "!contents? p3$" :fn=fn+1:p$=p$+p3$+";"
if fn>fmx then goto [npost]
#1.tb4 "!contents? p4$" :fn=fn+1:p$=p$+p4$+";"
if fn>fmx then goto [npost]
#1.tb5 "!contents? p5$" :p$=p$+p5$
[npost]
post$=p$
end function
function wc(l$)
while word$(l$,k+1,";")<>""
k=k+1
wend
wc=k
end function