FIND_FILE@ example

MODULE mainWindow
  CHARACTER *260 status
  CHARACTER *261 foundFiles(100)
  INTEGER numFoundFiles, selection(99), view
  INTEGER ctrl
  CHARACTER*128 rootDirectory, filename
END

WINAPP
PROGRAM find_file_test
  USE mainWindow
  INCLUDE <windows.ins>
  INTEGER i
  INTEGER start_search, clear_list
  EXTERNAL start_search, clear_list

  status = ""
  foundFiles(1) = "|Filename_600"
  numFoundFiles = 0
  selection(1) = 1
  view = 1
  rootDirectory = "c:\program files\Silverfrost"
  filename= "readme.txt"
  i = winio@("%ww%sy[3d_thin]%ca[Example file finder]&")
  i = winio@("%lv%ff&", 720, 480, foundFiles, 99, selection, view)
  i = winio@("Directory:%ta%68rs%ff&", rootDirectory)
  i = winio@("File:%ta%68rs%ff&", filename)
  i = winio@("%`^bt[Search] %^bt[Clear list]%ff&", start_search, clear_list)
  i = winio@("%96st&" , status)
  i = winio@("%lw" , ctrl)
END

INTEGER FUNCTION start_search()
  USE mainWindow
  INCLUDE <windows.ins>
  INTEGER find_file_callback
  EXTERNAL find_file_callback
  INTEGER searchStopped
  CHARACTER*8 cnum, numFoundFilesString

  searchStopped = find_file@ (rootDirectory, filename, find_file_callback)
  numFoundFilesString = cnum(numFoundFiles)
  status = numFoundFilesString(:LEN_TRIM(numFoundFilesString)) //" items displayed"
  CALL window_update@(status)
  start_search = 1
END

INTEGER FUNCTION clear_list()
  USE mainWindow
  INCLUDE <windows.ins>
  INTEGER i

  DO i=2, 99
    foundFiles(i) = ""
  ENDDO

  numFoundFiles = 0
  status = ""
  CALL window_update@(status)
  clear_list = 1
END

INTEGER FUNCTION find_file_callback()
  USE mainWindow
  INCLUDE <windows.ins>
  CHARACTER*260 reason, path
  reason = clearwin_string@("FIND_FILE_CALLBACK_REASON" )
  IF (reason == "FILE_FOUND" ) THEN
    path = clearwin_string@("FILE_FOUND" )
    IF(numFoundFiles < 99) THEN
      numFoundFiles = numFoundFiles + 1
      foundFiles(numFoundFiles+1) = "|" //path
      CALL window_update@(foundFiles)
    ENDIF
  ELSEIF (reason == "CHECKING_DIRECTORY" ) THEN
    path = clearwin_string@("CHECKING_DIRECTORY" )
    status = path
    CALL window_update@(status)
 ENDIF

  find_file_callback = 0
END

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited