[Gambas-user] Exist with wildcard

Brian G brian at westwoodsvcs.com
Wed Aug 4 19:21:06 CEST 2021


Hope this helps , functions from scripter component, exported if anyone thinks they are useful.


----- On Aug 4, 2021, at 10:48 AM, Bruce adamnt42 at gmail.com wrote:

> On Wed, 2021-08-04 at 20:08 +0930, bb wrote:
>> 
>> file (which there can't be, anyway). Just is there a file named, for
>> instance, "xyzzy:*.gambas" where * will be the gambas <version> in
>> the
>> directory I am looking at.

'' recursive search for libraries
Public Sub ListLibrariesIn(sPath As String, Optional Level As Integer = 0) As String[]

  Dim fileList As String[]
  Dim LibList As New String[]

  If Not Exist(sPath) Or If level > 4 Then Return LibList
  FileList = Dir(sPath, "*:*.gambas", gb.file)
  For Each sFile As String In FileList
    LibList.Add(sPath &/ sFile)
  Next
  FileList = Dir(sPath, "", gb.Directory)
  For Each sFile As String In FileList
    LibList.Insert(ListLibrariesIn(sPath &/ sFile, Level + 1))
  Next
  Return LibList

End

'' Version can be blank, "1" or "1.0" etc
Public Sub CheckLibVersions(sPath As String, Version As String) As String

  Dim sDir As String = File.Dir(sPath)

  If Not Exist(sDir) Then Return ""

  Dim sName As String = File.Name(sPath) & ":" & version & "*" & ".gambas"

  Dim sEntries As String[] = Dir(sDir, sName, gb.file).Sort()
  If sEntries.count > 0 Then
    Return sDir &/ sEntries[sEntries.max]   ' return the highest level library
  Else
    Return ""
  Endif

End

>> 
>> tia
>> bruce
>> 
>> 
> No, I am still not being clear enough.
> 
> Is there a file named, for instance "xyzzy:[anyversion].gambas" in the
> directory I am looking at. I want to use "*" as a wildcard for the
> [anyversion] part of the filename as I have no idea what the actual
> version in that directory is.
> 
> tia
> bruce
> 
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----


More information about the User mailing list