#1 2007-11-12 16:43

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

PascalScript: WideExpand_Environment_Variable

It's  me again, sorry. roll

Just a question:
It seams i can't use environment-variables in Pascal script?

like
FileWriteContent('%Temp%\ReNamerCount.txt', IntToStr(I));


---------------------------
Error
---------------------------
Preview process has been terminated due to a critical error:

Pascal Script Execute:
[Line 4] Exception: Cannot create file "D:\ReNamerBeta 12.11\Help\%temp%\ReNaCount.txt".
Das System kann den angegebenen Pfad nicht finden.

---------------------------
OK   
---------------------------

Is there something like
vTEMP := WideExpandEnvVar(%tmp%) ?
FileWriteContent( vTEMP + '\ReNamerCount.txt', IntToStr(I));

I just try to use this for FileCounter.pas:

var   I: Integer;
begin
 I := I + 1;
 FileWriteContent('C:\ReNamerCounter.txt', IntToStr(I));
// later in an another script use ==>  FileCount := FileReadLine('C:\ReNamerCounter.txt', 1);
end.

Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#2 2007-11-22 01:02

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: PascalScript: WideExpand_Environment_Variable

I think you'll be happy to know that I've added this new function big_smile

function WideGetEnvironmentVar(const VarName: WideString): WideString;

No need for the "%" signs, just use WideGetEnvironmentVar('TEMP').

TRY: ReNamerBeta.zip

Offline

#3 2007-11-22 20:44

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: PascalScript: WideExpand_Environment_Variable

Yes that helps, many thanks Denies :D

I have test this with some files only. Will test more over the weekend.

FilesCountWrite.pas

var
  I: Integer;
  vTEMP: WideString;
begin
 I := I + 1;
 If I < 2 Then
 vTEMP := WideGetEnvironmentVar('TEMP');

 FileWriteContent(vTEMP + '\ReNamerCounter.txt', IntToStr(I));
end.

FilesCountRead.pas

var   
  I: Integer;
  vTEMP, vFileCount: WideString;
begin
  I := I + 1;
 If I < 2 Then 
 vTEMP := WideGetEnvironmentVar('TEMP');
 
 vFileCount := FileReadLine(vTEMP + '\ReNamerCounter.txt', 1);
 FileName := WideExtractBaseName(FileName) + ' (' + IntToStr(I) + ' of ' + vFileCount + ')' + WideExtractFileExt(FileName) 
end.

How to use:
- add files
- load Pascal Rule FilesCountWrite.pas
- load Pascal Rule FilesCountRead.pas
- press Preview
- disable Pascal Rule FilesCountWrite.pas
- check New Names

If you change the amount of files (add or uncheck some) THEN
- enable Pascal Rule FilesCountWrite.pas
- (maybe press Preview)
- disable Pascal Rule FilesCountWrite.pas

Great tool Denis

greeds
Stefan


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#4 2007-12-07 13:11

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: PascalScript: WideExpand_Environment_Variable

It's good too know that you are making a lot of use out this little function big_smile

Offline

Board footer

Powered by FluxBB