Need to neaten my popupmenu script

Discuss and share scripts and script files...
Post Reply
reebae
Posts: 17
Joined: 12 Aug 2020 13:57

Need to neaten my popupmenu script

Post 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

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Need to neaten my popupmenu script

Post 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...
One of my scripts helped you out? Please donate via Paypal

reebae
Posts: 17
Joined: 12 Aug 2020 13:57

Re: Need to neaten my popupmenu script

Post 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.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Need to neaten my popupmenu script

Post 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
One of my scripts helped you out? Please donate via Paypal

Post Reply