Guidance
指路人
g.yi.org
software / rapidq / Examples / File & Directory / fileops / Fileops.inc

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
'# QUOTE : Returns a quoted string
     FUNCTION Quote (StringToQuote AS STRING) AS STRING
      StringToQuote =  CHR$(34) + StringToQuote + CHR$(34)
      result = REPLACESUBSTR$(stringtoquote, CHR$(34) + CHR$(34), CHR$(34))
     END FUNCTION

'===============================================================================
'# STRIPPATH : Returns file path (without file name)
     FUNCTION StripPath (fullname AS STRING) AS STRING
      result = LEFT$(fullname, rinstr(fullname, "\"))
     END FUNCTION

'===============================================================================
'# STRIPFILENAME : Returns file name (without path)
     FUNCTION StripFileName (fullname AS STRING) AS STRING
      result = RIGHT$(fullname, LEN(fullname) - rinstr(fullname, "\"))
     END FUNCTION

'===============================================================================
'# STRIPFILEEXT : Returns file extension (like ".exe", ".html" etc.)
     FUNCTION StripFileExt (fullname AS STRING) AS STRING
      result = RIGHT$(fullname, LEN(fullname) - rinstr(fullname, ".") + 1)
     END FUNCTION

'===============================================================================
'# FILENAMENOEXT : Returns file name without extension
     FUNCTION FileNameNoExt(fullname AS STRING) AS STRING
      fullname = RIGHT$(fullname, LEN(fullname) - rinstr(fullname, "\"))
      result = LEFT$(fullname, rinstr(fullname, ".") - 1)
     END FUNCTION

'===============================================================================
'# FULLPATHNOEXT : Returns full path without file extension
     FUNCTION FullPathNoExt(fullname AS STRING) AS STRING
      result = LEFT$(fullname, rinstr(fullname, ".") - 1)
     END FUNCTION

'===============================================================================
'# C_Style : Returns "slashed" path from a "backslashed" one
     FUNCTION C_Style (fullname AS STRING) AS STRING
      fullname = REPLACESUBSTR$(fullname, "\\", "\")
      result = REPLACESUBSTR$(fullname, "\", "/")
     END FUNCTION

'===============================================================================
'# SYSDIR : Retrieves windows shell directories

'-------------------------|
' Allowed values for dir  |
'-----------------------------------------------------------------------------|
' Desktop                 | Templates               | AppData                 |
' Start Menu              | Programs                | Startup                 |
' Fonts                   | SendTo                  | Recent                  |
' Favorites               | Cache                   | Cookies                 |
' History                 | NetHood                 | Personal                |
' PrintHood               | Local AppData           | My Pictures             |
' Administrative Tools    |                         |                         |
'-----------------------------------------------------------------------------|

     FUNCTION SysDir (dir AS STRING) AS STRING
      DIM fo_reg AS QREGISTRY
      fo_reg.RootKey = &H80000001
      fo_reg.openkey ("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", 0)
      result = fo_reg.readstring(dir) + "\"
     END FUNCTION

'===============================================================================
'# HOMEDIR : The folder where the application is

     FUNCTION homedir() AS STRING
      result = LEFT$(COMMAND$(0), rinstr(COMMAND$(0), "\"))
     END FUNCTION

'===============================================================================
'# BROWSEFORFOLDERS : Returns the selected folder

     FUNCTION BrowseForFolders (initialdir AS STRING, wincapt AS STRING) AS STRING
      DIM bff_form AS QFORM
      WITH bff_form
       .height = 400
       .center
       .CAPTION = wincapt
       .delbordericons 2
      END WITH
      DIM bff_tree AS QDIRTREE
      WITH bff_tree
       .PARENT = bff_form
       .align = 5
      END WITH
      IF bff_form.CAPTION = "" THEN bff_form.CAPTION = "Select folder"
      IF DIREXISTS(initialdir) THEN
       bff_tree.directory = initialdir
      ELSE
       bff_tree.directory = CURDIR$
      END IF
      bff_form.SHOWMODAL
      result = bff_tree.directory
     END FUNCTION

'===============================================================================
'# BROWSEFORFILE : Returns the selected folder

     FUNCTION BrowseForFile (CAPTION AS STRING, filter AS STRING, _
       initialdir AS STRING) AS STRING

      DIM bff_od AS QOPENDIALOG
      WITH bff_od
       .CAPTION = CAPTION
       .filter = filter
       .initialdir = initialdir

       IF .EXECUTE THEN
        result = .filename
       END IF
      END WITH

     END FUNCTION

掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2021-10-23  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-07-25 21:42:14