#1 2017-09-11 22:09

Ammar
Member
Registered: 2015-11-06
Posts: 6

WideScanDirForFiles / Type mismatch

Hi

this is part of code i done before was working fine till today,

It's not running anymore, [Line 15] Error: Type mismatch, can you please help

var  Files : TStringsArray;
     Parts : TStringsArray;
     Path  : WideString;

begin

  Parts := SubMatchesRegEx(FileName, '(.+\))', False);
  ShowMessage( 'Parts[0] = ' + Parts[0] );

  Path  := WideExtractFilePath(FilePath);

  SetLength(Files, 0 );

  WideScanDirForFiles( Path, Files, False, False, False, Parts[0] + '*.mp4' );
  WideScanDirForFiles( Path, Files, False, False, False, Parts[0] + '*.mkv' );
  WideScanDirForFiles( Path, Files, False, False, False, Parts[0] + '*.avi' );
  WideScanDirForFiles( Path, Files, False, False, False, Parts[0] + '*.m4v' );

  ShowMessage( 'Files = ' + IntToStr(length(Files)) );

end.         

Offline

#2 2017-09-12 10:19

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

Re: WideScanDirForFiles / Type mismatch

You need to change the type of Files and Parts variables from TStringsArray to TWideStringArray type.

TStringsArray type has been deprecated since ReNamer 5.75. It has been replaced by TWideStringArray type. In ReNamer 6.7, all function declarations have been updated to eliminate the use of the legacy TStringsArray type, in favor of TWideStringArray type.

Offline

#3 2017-09-12 12:18

Ammar
Member
Registered: 2015-11-06
Posts: 6

Re: WideScanDirForFiles / Type mismatch

I have amended the variables type from TStringsArray to TWideStringArray type
Now I am getting different error

[Line 9] Exception: Out Of Range
[Line 15] Exception: Out Of Range

also I tried
regarding Line 9
  ShowMessage( 'Parts[0] = ' + WideToAnsi(Parts[0]) );

and Line 15
  WideScanDirForFiles( Path, Files, False, False, False, Parts[0] + AnsiToWide('*.mp4') );

and got the same error : Exception: Out Of Range

Offline

#4 2017-09-12 19:32

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

Re: WideScanDirForFiles / Type mismatch

"Exception: Out Of Range" means here:
there is nothing in 'Parts[0]', as probably your RegEx doesn't much anything?




To avoid that error message, you can use:


Parts := SubMatchesRegEx(FileName, '(.+\))', False);
if Length(Parts) <1 then exit;
..... your code here



-or-

  Parts := SubMatchesRegEx(FileName, '(.+\))', False);
  If Length(Parts)>0 Then
  begin
   ..... your code here
  end;




- - -


If you need help on RegEx, post some example file names and what you expect the RE should match.


- - -

 


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

#5 2017-09-12 21:27

Ammar
Member
Registered: 2015-11-06
Posts: 6

Re: WideScanDirForFiles / Type mismatch

Thank you for your help

Offline

Board footer

Powered by FluxBB