Public Sub ShowFilesMenu()
Dim strPath As String
strPath = rutaScriptsExternos
ShowFilesMenuWithPath(strPath)
End
Public Sub ShowFilesMenuWithPath(strPath As String)
ShowFilesMenuInternal(strPath)
End
Public Sub ShowFilesMenuInternal(strPath As String, Optional stxExt As String[], Optional bolRec As Boolean)
Dim stxFiles As New String[]
Dim strFile As String
Dim i As Integer
stxFiles = RListFiles(strPath, stxExt, bolRec)
Dim oMenu As New FMain.Menu77 'indico el menú donde se mostrara el listado de archivos
For Each strFile In stxFiles
Dim oMenuItem As Menu77
oMenuItem = oMenu.Add(MenuFileFromPath(strFile))
oMenuItem.Tag = strFile
Connection(oMenuItem, "Activate", Me, "OpenFile")
Next
End
Public Sub OpenFile(sender As Object)
Dim strFilePath As String
strFilePath = Sender.Tag
End
Private Function MenuFileFromPath(strFilePath As String) As String
' Esta función toma un camino completo de un archivo
' y devuelve solo el nombre del archivo para mostrar en el menú.
Dim strFile As String
strFile = File.Name(strFilePath)
Return strFile
End
Public Function RListFiles(strPath As String, Optional stxExt As String[], Optional bolRec As Boolean) As String[]
Dim stxTmp As New String[]
Dim stxFiles As New String[]
Dim strFile As String
Dim strExt As String
stxTmp.Clear
stxFiles.Clear
strPath = ArrangePath(strPath)
Select Stat(strPath).Type
Case gb.File
strPath = File.Dir(strPath)
End Select
If stxExt <> Null Then
Select stxExt.Count
Case 0
If bolRec = True Then
stxTmp.Insert(RDir(strPath, "*.py"))
Else
stxTmp.Insert(Dir(strPath, "*.py", gb.File))
Endif
Case Else
For Each strExt In stxExt
If bolRec = True Then
stxTmp.Insert(RDir(strPath, "*." & strExt))
Else
stxTmp.Insert(Dir(strPath, "*." & strExt, gb.File))
Endif
Next
End Select
Else
If bolRec = True Then
stxTmp.Insert(RDir(strPath, "*.py"))
Else
stxTmp.Insert(Dir(strPath, "*.py", gb.File))
Endif
Endif
For Each strFile In stxTmp
Select Stat(strPath &/ strFile).Type
Case gb.File
stxFiles.Add(strPath &/ strFile)
End Select
Next
Return stxFiles
End
Public Function ArrangePath(strPath As String) As String
If Right(strPath, 1) <> "/" Then
strPath &= "/"
Endif
Return strPath
End