ReNamer:Pascal Script:Reuse variable

From den4b Wiki
Revision as of 14:49, 27 January 2013 by Stefan (talk | contribs) (First content collection - work in process)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page is work in process!

If you want to store a variable to reuse the value later you can read here a few tips.

For examples you can store the last used path, folder or file name or parts of them. Also you may want to store an index number, or perhaps a list of the original file names.

There are two main techniques to store variable values: use the registry or use a temporary file on disc.

First we take a look on the file approach.

We use simple plain text files to store the variable.

The ReNamer PascalScript functions to write and read text files are:

FileWriteContent( "FileName" , "Content" ); FileAppendContent( "FileName" , "Content" );

FileReadContent("FileName"); FileCountLines("FileName"); FileReadLine( "FileName" , LineNum );

For "FileName" you can just use a name without a path to store the file into the ReNamer folder. Example: FileWriteContent( "FileName.txt" , "Content" ); FileWriteContent( ".\FileName.txt" , "Content" );

To use an full path to your ReNamer folder use the ReNamer PascalScript function "GetApplicationPath" Example: FileWriteContent( WideExtractFilePath(GetApplicationPath) + "FileName.txt" , "Content" );

You can use your private temp (temporary) folder in your profile by using the ReNamer PascalScript function "WideGetTempPath" Example: FileWriteContent( WideGetTempPath + "FileName.txt" , "Content" );

Also you can access all system environment variables by using "WideGetEnvironmentVar" Example:

 UserName := WideGetEnvironmentVar('USERNAME');

PascalScript rule examples

First rule in rule list: (GET stored variable 'LastFolder')


    if(WideFileExists(WideGetTempPath +'\den4b_LastFolder.txt')) then
        LastFold := FileReadContent(WideGetTempPath +'den4b_LastFolder.txt');

  //check if it works:

Last rule in rule list: (SET variable 'LastFolder' to stored for later reuse)


       ParentFold := CalculateMetaTag(FilePath, 'File_FolderName');
       FileWriteContent(WideGetTempPath + 'den4b_LastFolder.txt', ParentFold);
  //check if it works:
  ExecuteProgram('notepad ' + WideGetTempPath + '\den4b_LastFolder.txt',false);