Resource

Resource Basics

Resource Name Filter With Exactly n Areas
Resource Version 1.0
Category Filter Script
Downloads 730
Release Date 3/29/2021 9:41:53 AM
 

Resource Details

Description This script filters images with an exact number of areas. The number is configurable
Installation Instructions Download to your <>\Scripts\FilterScripts folder
Usage Instructions Open a set of images
Start this filter script
Enter the number of areas
Changes in this version n.a.
Special Requirements
 

Author Information

Author Name IDimager Support
 

Available Attachments

Attachment #1 FilterWithNAreas.png
 

Script

var
  AAreaCount: Integer;

function Initialize: Boolean;
var
  AAreas: String;
begin
  // return false to cancel the filter operation

  result := False;
  AAreaCount := ReadFromRegistry('FilterWithXAreas', 'AreaCount', 1);
  AAreas := IntToStr(AAreaCount);
  if AskInput('Areas Count', 'How many areas should exist?', '', AAreas, False, nil) then
  begin
    if not IsValidNumberString(AAreas, False, '') then
      Say('Please enter a valid number')
    else
    begin
      AAreaCount := Trunc(StrToFloat(AAreas));
      WriteToRegistry('FilterWithXAreas', 'AreaCount', AAreaCount);
      result := True;
    end;
  end;
end;

procedure Finalize;
begin

end;

function Filter(AItem: TImageItem): Boolean;
var
  AAreas: TCatalogAreas;
begin
  AItem.Fetch;
  AAreas := TCatalogAreas.Create(TCatalogArea, '');
  try
    PublicCatalog.EnumAreasForImage(AItem, AAreas);
    result := (AAreas.Count = AAreaCount);
  finally
    AAreas.Free;
  end;
end;