Welcome to %s forums

BrainModular Users Forum

Login Register

get list of directory items via script

I need help on a Patch
Post Reply
woodslanding
Member
Posts: 1327
Contact:

get list of directory items via script

Unread post by woodslanding » 06 Dec 2022, 02:49

Last time I checked this was not possible, but Olivier said he planned to implement it. Has this happened?

Suddenly a bigger issue, because I cannot supress the endless trace of 'file not found' messages in the beta FREE version--the page with the option to suppress is unavailable. But there are reasons I need to check for existing files, even otherwise.

In the past, I have cabled out to the file lister module and back in, but I'd love to get it inline in my scripts while I'm refactoring, it's much cleaner.
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 06 Dec 2022, 11:43

will be implemented in the next release.

Code: Select all

  const DirectorySeparator : Char = {$IFDEF MSWINDOWS} '\'; {$ELSE} '/'; {$ENDIF}
  const LineEnding = #13#10;
  function  GetApplicationPath:string; //give the absolute path of the current Usine's folder

  procedure FindFiles(const Directory: String; Extensions: String; Recursive: Boolean; Result: TStringList); // [Extensions] can be a comma-text
  procedure FindDirectories(const Directory: String; Recursive: Boolean; Result: TStringList); 
  function WriteFileContents(const FileName: String; const Text: String; Append: Boolean): Boolean;
  function ReadFileContents(const FileName: String): String;
  function CreateDirectory(const Directory: String): Boolean;
  function ForceDirectories(const Directory: String): Boolean;
  function DeleteDirectory(const Directory: String; OnlyChildren: Boolean): Boolean;
  function DeleteFile(const FileName: String): Boolean;
  function RenameFile(const OldFileName, NewFileName: String): Boolean;
  function CopyFile(const SourceFileName, DestFileName: String; Overwrite: Boolean = False): Boolean;
  function FileExists(const FileName: String): Boolean;
  function DirectoryExists(const Directory: String): Boolean;
  function FileAge(const FileName: String): Int32; overload;
  function FileAge(const FileName: String; out FileDateTime: TDateTime): Boolean; overload;
  function ExtractFilePath(const FileName: String): String;
  function ExtractFileDrive(const FileName: String): String;
  function ExtractFileName(const FileName: String): String;
  function ExtractFileExt(const FileName: String): String;
  function ExtractFileDir(const FileName: String): String;
  function ExpandFileName(const FileName: String): String;
  function ExtractRelativePath(const BaseName, DestName: String): String;
  function IncludeTrailingPathDelimiter(const Path: String) : String;
  function ExcludeTrailingPathDelimiter(const Path: String): String;
  function IncludeTrailingBackslash(const Path: String) : String;
  function ExcludeTrailingBackslash(const Path: String): String;
  function IncludeLeadingPathDelimiter(const Path : String) : String;
  function ExcludeLeadingPathDelimiter(const Path: String): String;
  
  // for compatibility
  function  SubFileExt(filename:String):string;
  function  PathDelim:string; // returns '/' on MACOS, '\' on windows
  procedure CreateDir(dir:String);


woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 07 Dec 2022, 01:50

Thanks, Senso, that's great!

Can someone explain the meaning of 'const' in these definitions? I've never encountered it in arguments to a method before this release.

EDIT: of course, as soon as I hit send, I think of a possibility... does it mean you can't change its value in the method body??
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 07 Dec 2022, 07:43

Code: Select all

Can someone explain the meaning of 'const' in these definitions?
yes it means that you can't change it's value inside the procedure, so the procedure call is a little faster.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests