It is currently Wed Apr 26, 2017 8:16 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: HTML version of AskList$()
Unread postPosted: Wed Oct 28, 2015 11:00 am 
Offline

Joined: Wed Apr 15, 2015 3:57 am
Posts: 421
I like this little replacement for SELECT... easier on my eyes:


Code:
! asklist.bas
! html ask list of buttons

FN.DEF writeln(f$, msg$)
TEXT.OPEN w, fh, f$
TEXT.WRITELN fh, msg$
TEXT.CLOSE fh
FN.END

FN.DEF readln$(f$)
FILE.EXISTS isoldfile, f$
IF isoldfile
  TEXT.OPEN r,fh3,f$
  TEXT.READLN fh3, a$
ELSE
  LET A$=""
ENDIF
FN.RTN a$
FN.END


! init display mode manager
fn.def dinit()
writeln("mode.txt","0")
fn.end

! change display mode to console, html or gr(aphics)
fn.def dmode(m$)
if m$="console" then m=0
if m$="html" then m=1
if m$="gr" then m=2

oldm=val(readln$("mode.txt"))
if val(readln$("mode.txt"))=m
fn.rtn m
endif
writeln("mode.txt",int$(m))
if oldm=1
html.close
pause 500
endif
if oldm=2
  gr.close
  pause 500
endif
if m=1

!h$="<html> <body bgcolor:~#FF0000~></body></html>
!h$=replace$(h$,"~",chr$(34))
  html.open 0
!  html.load.string h$
endif
if m=2
gr.open 255,0,0,0,0,1
pause 500
endif
fn.end



FN.DEF waitclick$()
DO
  PAUSE 100
  HTML.GET.DATALINK data$
  IF BACKGROUND() THEN EXIT
UNTIL data$ <> ""
! popup data$,0,0,0
IF IS_IN("BAK:", data$) = 1
  EXIT
ELSEIF IS_IN("DAT:", data$) = 1
  data$ = MID$(data$, 5) %' User link
ELSEIF IS_IN("LNK:file:///", data$) = 1 & IS_IN("?", data$) %' Submit link
  i=IS_IN("?", data$)
  data$="SUBMIT&"+MID$(data$, i+1)+"&"
ENDIF
FN.RTN data$
FN.END


fn.def asklist$(l,msg$,c)
dmode("html")
cr$="<br>"
dq$=chr$(34)

h$+="<!DOCTYPE html>"
h$+="<html lang=~en~>"
h$+="<body>"
h$+="<body style=~background-color:#000000; text-align:center;~>"

h$+= "<h1 style=~color:#999999~>"+msg$ +"</h1>"+cr$
list.size l,size

h$+="<div>"

for i=1 to size
list.get l,i,s$

but$="<button type=~button~  style=~background-color:#333333;color:#FFFFFF;text-align:center;font-size:20px;width:300px;height:50px;~ onclick=~doDataLink('"+s$+"')~;>"+s$+"</button><br>"
h$+= but$
next i
h$+="</div>"
h$+="<script type=~text/javascript~>"
h$+="function doDataLink(data) "
h$+="{Android.dataLink(data);}</script>"
h$+="</body>"
h$+= "</html>"
h$=replace$(h$,"~",dq$)
html.load.string h$
r$=waitclick$()

list.search l,r$,c

fn.rtn r$
fn.end

fn.def testlist()
dinit()
list.create s,l
list.add l,"Choice A","Choice B","Choice C","cancel"
do
c=0
r$=asklist$(l,"choose",&c)
popup r$+int$(c)
pause 1000
until r$="cancel"
dmode("console")
fn.end

testlist()
EXIT


Attachments:
2015-10-28 17.29.13.png
2015-10-28 17.29.13.png [ 32.96 KiB | Viewed 582 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred