inputselect()

Discuss and share scripts and script files...
Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

inputselect()

Post by Stefan »

Nice surprise, thanks.

Code: Select all

v9.30.0003 - 2010-07-20 11:05
    + Scripting got a new function.
      Name:   inputselect
      Action: Pops a list of strings from which the selected one is
              returned.
      Syntax: inputselect(header, listdata, [delimiter=|], [style=1], _
                  [cancel], [width=600], [height=400], [windowcaption])
        header:     First line is printed in bold; any other lines are
                    printed non-bold; leave empty to show no header.
        listdata:   String of list items, delimited by delimiter.
        delimiter:  Delimiter; defaults to |.
        style:      1 = show file system icons for the items (= default)
                    2 = show checkboxes
                        prefix items with "+" to pre-check them
        cancel:     value to be returned when user cancels
                    if not set then cancel will terminate the script
        width:      Width of window in pixels (minimum: 250; maximum:
                    screen width; default: 600).
                    Percentages of screen width are supported, e.g. 75%.
        height:     Height of window in pixels (minimum: 150; maximum:
                    screen height; default: 400).
                    Percentages of screen height are supported, e.g. 75%.
        windowcaption:  Window caption.
        return:     The selected list item. If checkbox style then the
                    checked items are returned, separated by delimiter.
      Examples:
        // header and a list of drives; then go to the selected drive
        goto inputselect("Select Destination", "C:|D:|E:");
        // same with two-line header
        goto inputselect("Select Destination".<crlf>."Choose drive:", "C:|D:|E:");
        // no header
        goto inputselect(, "C:|D:|E:");
        // use checkboxes and icons (1 OR 2 = 3)
        text inputselect("Select Drives", "C:|D:|E:", , 3);
        // use checkboxes, pre-check "D:"); return "-" on cancel
        text inputselect("Select Drives", "C:|+D:|E:", , 3, "-");

First test

Show an dialog to select an script:

Code: Select all

//store current environment:
//the current folder:
$curFolder = "<curpath>";
	//the current selected files:
 	$curSelFiles = report("{name}|",1);
	//are there any file selected?:
	$CountSelected = getinfo("CountSelected");

 	//generate list of scripts (without sub-folders):
	goto "<xyscripts>";
	$preFilterScripts = input("Pre filter scripts by part of file name","Pattern, e.g. rename or B or *C", ,,"");
	//select only scripts *.xys
 	selfilter "$preFilterScripts*.xys",f;
	//collect all selected files 
	//without extension into var $myScripts
 	$myScripts = report("{basename}|",1);
	//cosmetic: de-select all
	sel;

	//go back to work folder:
 	goto $curFolder;
	//select the wanted file again (if any):
 	If ($CountSelected > 0){ selfilter $curSelFiles; }
	//show InputSelect-dialog to select an script: (needs at least XY v9.30.0003)
 	$cript = inputselect(Select an script to execute:,$myScripts);
	//and execute that script (if not cancelled):
 	If ($cript>""){ load $cript; }
EDIT: enhanced script >>> http://www.xyplorer.com/xyfc/viewtopic. ... 162#p50162

:lol: fun

--------------
EDIT:
changed
goto "<xypath>\scripts";
to
goto "<xyscripts>";


EDIT:
added $preFilterScripts
Update changelog



----------------
EDIT:
added BatchNewItemSerie_v5.xys

Code: Select all

"NewItems"
  $listdata = "+A-Z series (Items from A to Z)|0-9 series (Items from 0 to 9)|1-100|Create DIRs|+Create Files";

  //inputselect(header, listdata, [delimiter=|], [style=1], _
  //                  [cancel], [width=600], [height=400], [windowcaption])
  $inputselect = inputselect("Create files or dirs", $listdata,,2);
  //msg $inputselect,1;


   IF (strpos($inputselect, "Create DIRs")>0) {$Type   = "dir";}
   IF (strpos($inputselect, "Create Files")>0){$Type   = "file";}
   IF (strpos($inputselect, "Pad Zeros")>0)   {$SerieAmountPad = "yes";}

      
   IF (strpos($inputselect, "A-Z")>-1)
   {
     //create items A-Z
      $AZExt = ""; IF ($Type=='file'){$AZExt = ".TXT";}
      $count = 1;
      while($count<27)
      {
        new "<curpath>\" .chr($count + 64) . $AZExt, $Type;
        wait 50;
        $count++;
      }
   }

   IF (strpos($inputselect, "0-9")>-1)
   {
      //create items 0-9
         $digitExt = ""; IF ($Type=='file'){$digitExt = ".TXT";}
				 $count = 0;
				 while($count<10)
					{
					 new "<curpath>\" . $count . $digitExt, $Type;
					 wait 50;
					 $count++;
				  }
   }
   
   
   IF (strpos($inputselect, "1-100")>-1){msg "1-100 is not implemented yet ;-)";}
Last edited by Stefan on 31 Jul 2010 20:42, edited 4 times in total.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: inputselect()

Post by SkyFrontier »

...I was just about to post a suggestion to a multi script launcher... :D
What I have in mind is to have tick boxes to select several little tasks and perform then at once, mainly launching sets of programs for different sessions of work, or do a recurrent batch rename, open several folders in different tabs (is it possible via script, Don?) and launch one or two of those sets of programs (connect internet, launch a predefined second XYplorer instance and open burning software, for instance).
The tick boxes (HTML interface?) come in handy when one need to run one, two or three of those tasks regularly, but not that much to the point of being automated via task schedulers, for example.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 64847
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: inputselect()

Post by admin »

tick boxes is an idea for inputselect 2.0. :)

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: inputselect()

Post by Stefan »

admin wrote:tick boxes is an idea for inputselect 2.0. :)
Before i came to late :D
i had the idea to have an option to show the file comment in an second column.

Syntax: inputselect(header, listdata, [delimiter=|], [style=1],[width=600], [height=400], [windowcaption], [options])

Options
      1 = show column with XY's files comments

"FileName | FileComment"
ScriptA | Comment of scriptA
Script2 | Script to remove spaces


I just ask, maybe it's possible? :wink:

admin
Site Admin
Posts: 64847
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: inputselect()

Post by admin »

Stefan wrote:
admin wrote:tick boxes is an idea for inputselect 2.0. :)
Before i came to late :D
i had the idea to have an option to show the file comment in an second column.

Syntax: inputselect(header, listdata, [delimiter=|], [style=1],[width=600], [height=400], [windowcaption], [options])

Options
      1 = show column with XY's files comments

"FileName | FileComment"
ScriptA | Comment of scriptA
Script2 | Script to remove spaces


I just ask, maybe it's possible? :wink:
It's not. :)

admin
Site Admin
Posts: 64847
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: inputselect()

Post by admin »

admin wrote:tick boxes is an idea for inputselect 2.0. :)
Done! 8)

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: inputselect()

Post by TheQwerty »

Would be nice if this had an optional Cancel argument like Input().
Otherwise there's no way to determine if the user OK'ed a selection of nothing or Cancelled the dialog.

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: inputselect()

Post by PeterH »

Stefan wrote:First test

Show an dialog to select an script:

Code: Select all

...
	goto "<xydata>\scripts";
...
:lol: fun
Some good ideas, indeed. I should take more time for scripting... :mrgreen:

But one thing: you should replace the line shown above by:

Code: Select all

...
	goto "<xyscripts>";
...
That's more universal - and then it would work for me, too :roll:

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: inputselect()

Post by Stefan »

PeterH wrote:That's more universal - and then it would work for me, too
Yes, OK. But i was unsure if xyscripts exists, but know that xypath does, so i had decided to make it quick&dirty.
But you're right.

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: inputselect()

Post by Stefan »

:oops: :D i guess this radioboxes are too complicated or far behind your intending ?


$listdata = "+A-Z series (Items from A to Z) | [[0-9 series (Items from 0 to 9);1-100]] | [[Create DIRs;+Create Files]] | [[+Pad yes; Pad no; Pad two; Pad three]]";

[+] A-Z series (Items from A to Z)
-
(  ) 0-9 series (Items from 0 to 9)
(  ) 1-100
-
(  ) Create DIRs
(o) Create Files
-
(o) Pad yes
(  ) Pad no
(  ) Pad two
(  ) Pad three
-

admin
Site Admin
Posts: 64847
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: inputselect()

Post by admin »

Stefan wrote::oops: :D i guess this radioboxes are too complicated or far behind your intending ?


$listdata = "+A-Z series (Items from A to Z) | [[0-9 series (Items from 0 to 9);1-100]] | [[Create DIRs;+Create Files]] | [[+Pad yes; Pad no; Pad two; Pad three]]";

[+] A-Z series (Items from A to Z)
-
(  ) 0-9 series (Items from 0 to 9)
(  ) 1-100
-
(  ) Create DIRs
(o) Create Files
-
(o) Pad yes
(  ) Pad no
(  ) Pad two
(  ) Pad three
-
Qué?

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: inputselect()

Post by Stefan »

Analog to HTML Forms

we have now [X] check boxes
<input type="text" name="name" Value="Smith">

and while testing this nice new feature inputselect
i had the "need" for radio types (0) checkers
<INPUT type="radio" name="myOption" value="1">


So i want to ask if there is an interest (and possibility) to make this inputselect feature even more universal?

So I had an syntax like
[[ Create DIRs;+Create Files ]]
in mind to build groups of XOR-possibilities: Create dirs, or files, not both

So i would use:

Code: Select all

$listdata = "+A-Z series (Items from A to Z) | [[0-9 series (Items from 0 to 9);1-100]] | [b][[Create DIRs;+Create Files]][/b] | [[+Pad yes; Pad no; Pad two; Pad three]]";
To get an dialog like:

Code: Select all

[+] A-Z series (Items from A to Z)
-
(  ) 0-9 series (Items from 0 to 9)
(  ) 1-100
-
(  ) Create DIRs
(o) Create Files
-
(o) Pad yes
(  ) Pad no
(  ) Pad two
(  ) Pad three
-

admin
Site Admin
Posts: 64847
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: inputselect()

Post by admin »

No, you are dreaming. :)

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: inputselect()

Post by Stefan »

admin wrote:...you are dreaming. :)
:shock: It is unbelievable what XYplorer all can produce :wink:

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: inputselect()

Post by SkyFrontier »

Glad to know you probably are working on a session-manager, Stefan. Unfortunately I will really not have the time soon enough to accomplish some script-learning and solve some dull problems I still have in my daily file operations. Oh, well...

At least I am planing to gather a few small scripts/adaptions I made and make then available here. Hope Life stops cheating on me just in time.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Post Reply