Page 1 of 2

inputselect()

Posted: 20 Jul 2010 22:17
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 ;-)";}

Re: inputselect()

Posted: 21 Jul 2010 10:43
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.

Re: inputselect()

Posted: 21 Jul 2010 12:01
by admin
tick boxes is an idea for inputselect 2.0. :)

Re: inputselect()

Posted: 21 Jul 2010 12:13
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:

Re: inputselect()

Posted: 21 Jul 2010 14:02
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. :)

Re: inputselect()

Posted: 21 Jul 2010 17:27
by admin
admin wrote:tick boxes is an idea for inputselect 2.0. :)
Done! 8)

Re: inputselect()

Posted: 21 Jul 2010 21:04
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.

Re: inputselect()

Posted: 21 Jul 2010 23:53
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:

Re: inputselect()

Posted: 22 Jul 2010 08:39
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.

Re: inputselect()

Posted: 22 Jul 2010 10:45
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
-

Re: inputselect()

Posted: 22 Jul 2010 10:55
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é?

Re: inputselect()

Posted: 22 Jul 2010 11:16
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
-

Re: inputselect()

Posted: 22 Jul 2010 11:30
by admin
No, you are dreaming. :)

Re: inputselect()

Posted: 22 Jul 2010 12:10
by Stefan
admin wrote:...you are dreaming. :)
:shock: It is unbelievable what XYplorer all can produce :wink:

Re: inputselect()

Posted: 22 Jul 2010 13:59
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.