Page 1 of 1

Need to neaten my popupmenu script

Posted: 17 Apr 2022 16:58
by reebae
Hello,

I have 3 image templates in a folder. I frequently need to use these to create new images. I would like to click a button, select one of the 3 image templates and have it copied to my current folder. A toolbar button is ok, but a catalog entry would be optimal. So far, I have this script:

Code: Select all

   $sourcedir = "C:\Users\me\and\my\subfolders";
   popupmenu('::image01;backupto "", $sourcedir . "\01.png", 2, , , , , , 0|::image02;backupto "", $sourcedir . "\02.png", 2, , , , , , 0|::image03;backupto "", $sourcedir . "\03.png", 2, , , , , , 0');
I think my method may be a bit messy, and the $sourcedir is not working anyway -- it throws a "C:\Users\me\currentfolder\$sourcedir\01.png" does not exist error. Bad syntax in there which I can overcome by just adding the full path for each image. But it would be nice to condense this script, make it neat and easily understandable down the road (for myself). I also wonder if my backupto scripting can be condensed. I aim to do a simple copy, no prompts, no show progress box. This is currently working well as long as I correct my path, but can the command be shortened? Not the end of the world if it cannot.

Thank you

Re: Need to neaten my popupmenu script

Posted: 17 Apr 2022 17:31
by highend

Code: Select all

    $sourcedir = "C:\Users\me\and\my\subfolders";
    $menu      = <<<>>>
::image01|backupto "", $sourcedir . "\01.png", 2, 8:=0;
::image02|backupto "", $sourcedir . "\02.png", 2, 8:=0;
::image03|backupto "", $sourcedir . "\03.png", 2, 8:=0;
    >>>;
    popupmenu($menu, 6:=<crlf>, 7:="|");
?

Untested...

Re: Need to neaten my popupmenu script

Posted: 17 Apr 2022 19:22
by reebae
Oh this is pretty. This is exactly what I was hoping for. I only had to change

Code: Select all

$sourcedir . "\01.png"
to

Code: Select all

"$sourcedir\01.png"
, another welcomed change. Thank you very much.

I wasn't aware of the "8:=0" option -- I assume this is the 8th parameter and is set to 0.

Thank you again.

Re: Need to neaten my popupmenu script

Posted: 18 Apr 2022 08:54
by highend
I assume this is the 8th parameter and is set to 0
Note: Counting starts from 0, so this is the 9th parameter: show_progress