1. File extensions

Hi all,

Someone wanted a function to extract the extension from a path\filename s=
o
I have posted these functions. =

It is possible to have a path\filename like these :-

        C:\DATABASE.DBS\DATAFILE
        C:\DATABASE.DBS\INDEX.IDX\DATAFILE.DAT

These are quite legal, so we must only search from the end of the sequenc=
e
NOT from the start, if it is not found within the last three then it ain'=
t
there.

-- Return file extension as a sequence --
global function Extension(sequence e)
  integer len
  len =3D length(e)
  for idx =3D len to len - 3 by -1 do -- Scan fron end
    if e[idx] =3D '.' then -- until we find a "."
      return e[idx..len] -- then exit with ".EXT"
    end if
  end for
  return {} -- Else return blank
end function

-- Return pointer to file extension --
global function ExtensionPtr(sequence e)
  integer len
  len =3D length(e)
  for idx =3D len to len - 3 by -1 do -- Scan from last
    if e[idx] =3D '.' then -- Found "." =

      return idx -- exit with index
    end if
  end for
  return 0 -- ext not found
end function


Have fun guys - Peter

new topic     » topic index » view message » categorize

2. File extensions

Hi all,
Ok I am writin a prog using EDB but I want to use my own extensions. The 
idea is that there is two databases the main file with extension KTM 
(KeyTrackerMain) and the second file KTH (KeyTrackerHistory).
when the user selects "Open" from the menu they will only see the KTM 
file. The procedure below does this but I can't create the second file 
with the KTH i always get filename.KTH.KTM


procedure OpenChoice_onClick ()
filenamemain = getOpenFileName( 
    MainWindow,                  -- parent window 
    "",                         -- no default name 
    { "KeyTrack File", "*.KTM"} )
    if length( filenamemain ) = 0 then 
        return 
    end if

filenamehist = filenamemain[1..length(filenamemain)-4] & ".KTH"


Come visit me at www.locksdownunder.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu