G4C

; A GUI for finding files with the list command
; To be used from the dir.gc GUI *only*


WinBig -1 -1 400 150 ''
WinType 11110001
Box 0 0 0 0 out button

;========================== Genaral events

xOnLoad
setscreen dir.find $lv_fmscreen      ; it may be on another screen.

xOnOpen
setvar fd_dir  $$LV_DIR
setvar fd_id   $$LV_ID
setwintitle Dir.find 'Dir $fd_dir                                   '
setgad dir.find 2 ON

xOnClose
guiquit dir.find

xOnQuit
delvar fd_dir
delvar fd_id
delvar fd_string
delvar fd_file
delvar fd_fullpath

xOnFail
update dir.find 1 '*** Error during find ***'
guiwindow dir.find resume

;========================= Gadgets

Text    10 2 390 14 "Enter filename substring :" 120 NOBOX
gadid 1


xTextIn  5 15 390 20 "" fd_string "" 130
gadid 2
guiwindow dir.find wait
cd $fd_dir
setstack 6000
Launch 1 'list >env:.result SUB $fd_string ALL LFORMAT=%S%S'
setstack 4000


xOnReturn 1
lvchange dir.find 3 env:.result
guiwindow dir.find resume
update dir.find 1 'Ready - Click on file required.'


xlistview 5 40 390 108 "" fd_file "" 10 TXT
GADID 3
extract fd_file path fd_path
extract fd_file file fd_name
joinfile $fd_dir $fd_path fd_fullpath
lvdir dir.gc $fd_id #$fd_fullpath
lvfind dir.gc $fd_id $fd_name
if $fd_id = 1
   setwintitle dir.gc '$fd_fullpath                               '
else
   update dir.gc 10 '$fd_fullpath'
endif



