Hello
I modify the GetListOfFiles for the file search in my project folder. I do not know the method for get the automatic project folder path.
If anyone know the way, please let me know.
I want to auto set the value for "sFolder" in current project folder. Here is code.
I modify the GetListOfFiles for the file search in my project folder. I do not know the method for get the automatic project folder path.
If anyone know the way, please let me know.
I want to auto set the value for "sFolder" in current project folder. Here is code.
Code: Select all
/*
Original Script Name: GetListOfFiles
Creation Date: 2008-04-16
Last Modified: 2016-02-18
Copyright: Copyright (c) 2016 by Mofi
Original: https://www.ultraedit.com/resources/scripts/GetListOfFiles.js
https://forums.ultraedit.com/viewtopic.php?f=52&t=5442
Modify for the project file search
Script Name: SearchFile
Last Modified: 2010-04-17
Modified by bitchen
*/
function SearchFiles (nFileList, sDirectory, sFileType, bSubDirs)
{
var nOutputType = (typeof(g_nDebugMessage) == "number") ? g_nDebugMessage : 2;
if (typeof(nFileList) != "number" || nFileList < 0 || nFileList > 1) nFileList = 1;
if (nFileList == 0)
{
// Search in a default directory (sFolder).
UltraEdit.outputWindow.write("Search directory: " + sDirectory);
if (typeof(sFileType) != "string" || sFileType == "") sFileType = "";
if (typeof(bSubDirs) != "boolean") bSubDirs = false;
nFileList = 0;
}
else if (nFileList == 1)
{ // Search in a specified directory?
// If no directory specified, use current working directory.
if (typeof(sDirectory) != "string" || sDirectory == "" ) sDirectory = ".\\";
// Append a backslash if it is missing at end of the directory string.
else if (sDirectory[sDirectory.length-1] != "\\") sDirectory += "\\";
// Search for all files if no file type is specified.
if (typeof(sFileType) != "string" || sFileType == "") sFileType = "*";
if (typeof(bSubDirs) != "boolean") bSubDirs = false;
nFileList = 0;
}
else
{
nFileList = 0;
sDirectory = ""; // For the list of open, favorite, project
sFileType = ""; // or solution files the other 3 parameters
bSubDirs = false; // have always the same default values.
}
// Remember current regular expression engine.
var nRegexEngine = UltraEdit.regexMode;
UltraEdit.ueReOn();
UltraEdit.frInFiles.directoryStart=sDirectory;
UltraEdit.frInFiles.filesToSearch=nFileList;
UltraEdit.frInFiles.matchCase=false;
UltraEdit.frInFiles.matchWord=false;
UltraEdit.frInFiles.regExp=false;
UltraEdit.frInFiles.searchInFilesTypes=sFileType;
UltraEdit.frInFiles.searchSubs=bSubDirs;
UltraEdit.frInFiles.unicodeSearch=false;
UltraEdit.frInFiles.useOutputWindow=true;
UltraEdit.frInFiles.find("");
return true;
}
// End of function SearchFiles
/*** SearchFiles **************************************************************/
// Code to demonstrate the usage of the function SearchFiles.
var g_nDebugMessage=1; // Enable debug messages with message boxes.
var nSearchIn=0; // Stores users choice where to search.
var sFolder="Z:\\PROJECT\\"; // Stores the search root folder specified by the user.
var sFiles=""; // Stores the search files/types specified by the user.
var bSubFolders=false; // Stores the users choice for searching in subdirectories.
var nSubFolders = 1;
UltraEdit.outputWindow.showStatus=false;
UltraEdit.outputWindow.clear();
if (UltraEdit.outputWindow.visible == false) UltraEdit.outputWindow.showWindow(true);
//if (UltraEdit.document.length < 1)
//{
// /* If no file is open the commands getValue and getString currently (UE v14.20.1)
// do not open message boxes for user input and return always 0 respectively NULL.
// As workaround open a new file and later close that file without saving. */
// UltraEdit.newFile();
//}
nSearchIn = UltraEdit.getValue("Search in the project dir. (= 0) or in special dir.(= 1)?",1);
if (nSearchIn == 0)
{
sFiles = UltraEdit.getString("Please enter the files/types to find:",1);
if (sFiles == "") sFiles = "*";
UltraEdit.outputWindow.write("Find files/types: " + sFiles);
bSubFolders = true;
var sUsersChoice = bSubFolders ? "true" : "false";
UltraEdit.outputWindow.write("Search subfolders: " + sUsersChoice);
}
else if (nSearchIn == 1)
{
UltraEdit.outputWindow.write("Get list of files: in directory");
sFolder = UltraEdit.getString("Please enter the path to the directory:",1);
if ((sFolder == "") || (sFolder == ".\\"))
{
UltraEdit.outputWindow.write("Search directory: .\\ (= working directory)");
}
else
{
UltraEdit.outputWindow.write("Search directory: " + sFolder);
}
sFiles = UltraEdit.getString("Please enter the files/types to find:",1);
if (sFiles == "") sFiles = "*";
UltraEdit.outputWindow.write("Find files/types: " + sFiles);
nSubFolders = UltraEdit.getValue("Search in subdirectories (0/1 = no/yes)?",1);
if (nSubFolders) bSubFolders = true;
var sUsersChoice = bSubFolders ? "true" : "false";
UltraEdit.outputWindow.write("Search subfolders: " + sUsersChoice);
}
SearchFiles(nSearchIn,sFolder,sFiles,bSubFolders);