Yab2Cpp/yab-IDE/Programs/Examples/FileboxDemo.yab

54 lines
1.2 KiB
Plaintext
Raw Normal View History

#!yab
import Filebox
dir$ = "/boot/home/"
window open 100,100 to 500,500, "Demo",dir$
Filebox(10,10,350,390,"Filebox", 1, "Demo")
FileboxDirectory("Filebox", dir$, false)
button 360,10,390,30, "DirUp", "..", "Demo"
dim msg$(1)
inloop = true
while(inloop)
n = split(message$, msg$(), "|")
for i=1 to n
print msg$(i)
// Quit
if(msg$(i) = "Demo:_QuitRequested") inloop = false
// Button pressed and we are not in the root directory
if(msg$(i) = "DirUp" and dir$<>"/") then
t = len(dir$)-1
while(mid$(dir$,t,1)<>"/")
t = t - 1
wend
dir$ = left$(dir$,t)
WINDOW SET "Demo", "Title", dir$
FileboxDirectory("Filebox", dir$, false)
endif
// An item is invoked
if(instr(msg$(i),"Filebox:_Invoke:")) then
position = val(right$(msg$(i),len(msg$(i))-16))
// if the item is a directory, then update the filebox else print the filename
if(FileboxIsDirectory("Filebox", position,dir$)) then
dir$ = dir$ + FileboxName$("Filebox", position) + "/"
WINDOW SET "Demo", "Title", dir$
FileboxDirectory("Filebox", dir$, false)
else
print dir$+FileboxName$("Filebox", position)
endif
endif
next i
sleep 0.01
wend
window close "Demo"