Image Viewer - Delete + Extra

Hello,

When I delete images from image viewer from particular folders, I want to do two additional things

  1. Increment a variable by 1
  2. Decrement a global variable by 1

Show VIEWERCMD=delete
@ifpath:D:\Pictures*
DOpus.vars.imgs -= 1
DOpus.vars.img_deleted +=1

Can someone guide me on how to do this please.

1 Like

This gets me near. I modified the Delete action on Image Viewr

@ifpath:D:\Pictures\*
  Show VIEWERCMD=delete
  ImageDeleter 
@ifpath:else
  Show VIEWERCMD=delete

And created a User Defined Function, ImageDeleter as

function OnClick(clickData)
{
   DOpus.vars.set("imgs", DOpus.vars.get("imgs") - 1);
   DOpus.vars.set("img_deleted", DOpus.vars.get("img_deleted") + 1);
}

Is there a neater way to achieve this.

That looks like a reasonable way to do it.

You could also do the whole thing in a single script inside the main button, if you want to simplify it a little.

I can't get the function to execute on embedding

@ifpath:D:\Pictures\*
    Show VIEWERCMD=delete

    @script jscript
    function deleter()
    {
        DOpus.vars.set("imgs", DOpus.vars.get("imgs") - 1);
        DOpus.vars.set("img_deleted", DOpus.vars.get("img_deleted") + 1);
    }

    deleter();

//ImageDeleter
@ifpath:else
  Show VIEWERCMD=delete

Pretty sure, I'm missing something. I tried various combination including OnClick as well as OnFileOperationComplete to avoid an explicit call to the function.

You can’t mix script and non-script like that in the same button. Do everything within a single script (in the OnClick event).

Thanks. I'll keep the previous version then.