Minor scripting related wishes (a generic thread)

Features wanted...
bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Minor scripting related wishes (a generic thread)

Post by bdeshi »

could you add favorite lists to get() ?
eg:

Code: Select all

"list_favorites", [separator=CRLF], [flags]
[separator]:  String to place between items. Defaults to CRLF (line feed).
flags:        Defaults to "dfo".
 d = Return folders.
 f = Return files.
 o = Return other types of favs.
return:       List of favorite items.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: Minor scripting related wishes (a generic thread)

Post by klownboy »

+1 We've pulled the Favorites Files and Folders a number of times in various scripts, like CleanRecent using getkey, but this would make it much easier and we'd be assured they're up-to-date.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Minor scripting related wishes (a generic thread)

Post by highend »

Can you add one more data parameter to tab("get", ...) please?

"home": path to the home zone / location

Afaik there is no easy way (apart from saving the whole tabset and read out the home location from the pane.ini file afterwards) to get this path.

This would make scripts like http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=8633 much smaller & cleaner (apart from unnecessary writes on ssd drives).

This is the missing piece to get all necessary information from a tab (apart from the icon, but this is just one additional line of scripting)!
One of my scripts helped you out? Please donate via Paypal

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Minor scripting related wishes (a generic thread)

Post by bdeshi »

can sc html() become stronger and support returning POST returns ?

Submitting a POST form will need to close the html dlg.

Perhaps the dlg "close" btn could be tied to submitting a form...
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

Some dereferenced variable wishes...
  1. The unset SC should have the smarts to correctly handle unsetting a dereferenced variable even if it is supplied in an argument after the variable holding the name.

    Code: Select all

    $var = '$a'; *$var = 'test';
    Unset *$var, $var; // Works correctly.
    
    $var = '$a'; *$var = 'test';
    Unset $var, *$var; // Leaves $a.
  2. The IsSet SC doesn't seem to understand the dereference operator. This can be worked around by testing if the dereferenced value is the variable names, but that's not 100% accurate. In the following demo IsSet(*$var) should be the same as IsSet($a):

    Code: Select all

    "Demo"
    	$a_IsSetA    = IsSet($a);
    	$a_IsSetVar  = IsSet($var);
    	$a_IsSetDVar = IsSet(*$var);
    	$a_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$a_WA = $a_IsSetA == $a_ValEqStr;
    
    	$var = '$a';
    
    	$b_IsSetA    = IsSet($a);
    	$b_IsSetVar  = IsSet($var);
    	$b_IsSetDVar = IsSet(*$var);
    	$b_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$b_WA = $b_IsSetA == $b_ValEqStr;
    
    	*$var = 'value';
    
    	$c_IsSetA    = IsSet($a);
    	$c_IsSetVar  = IsSet($var);
    	$c_IsSetDVar = IsSet(*$var);
    	$c_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$c_WA = $c_IsSetA == $c_ValEqStr;
    
    	$a = 'try again';
    
    	$d_IsSetA    = IsSet($a);
    	$d_IsSetVar  = IsSet($var);
    	$d_IsSetDVar = IsSet(*$var);
    	$d_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$d_WA = $d_IsSetA == $d_ValEqStr;
    
    	$a = '$a';
    
    	$e_IsSetA    = IsSet($a);
    	$e_IsSetVar  = IsSet($var);
    	$e_IsSetDVar = IsSet(*$var);
    	$e_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$e_WA = $e_IsSetA == $e_ValEqStr;
    
    
    	unset $var, $a;
    
    	Text <<<RESULTS
                            IsSet($a) - IsSet($var) - IsSet(*$var) - (*$var) != '*$var' && (*$var) != $var - Workaround Works?
        Before $var is set: $a_IsSetA         - $a_IsSetVar           - $a_IsSetDVar            - $a_ValEqStr                                     - $a_WA
         After $var = '$a': $b_IsSetA         - $b_IsSetVar           - $b_IsSetDVar            - $b_ValEqStr                                     - $b_WA
     After *$var = 'value': $c_IsSetA         - $c_IsSetVar           - $c_IsSetDVar            - $c_ValEqStr                                     - $c_WA
    After $a = 'try again': $d_IsSetA         - $d_IsSetVar           - $d_IsSetDVar            - $d_ValEqStr                                     - $d_WA
           After $a = '$a': $e_IsSetA         - $e_IsSetVar           - $e_IsSetDVar            - $e_ValEqStr                                     - $e_WA
    RESULTS
    	, 800;
    [/size]

zer0
Posts: 2673
Joined: 19 Jan 2009 20:11

Re: Minor scripting related wishes (a generic thread)

Post by zer0 »

I would like for folderreport's classic directory dump to be enhanced to show individual and total quantity of files of child folders in the listing of details of the parent folder. Having to look and add things up for individual folders is actually quite a drag. Thank you in advance! :tup:
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

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

Re: Minor scripting related wishes (a generic thread)

Post by admin »

TheQwerty wrote:Some dereferenced variable wishes...
  1. The unset SC should have the smarts to correctly handle unsetting a dereferenced variable even if it is supplied in an argument after the variable holding the name.

    Code: Select all

    $var = '$a'; *$var = 'test';
    Unset *$var, $var; // Works correctly.
    
    $var = '$a'; *$var = 'test';
    Unset $var, *$var; // Leaves $a.
  2. The IsSet SC doesn't seem to understand the dereference operator. This can be worked around by testing if the dereferenced value is the variable names, but that's not 100% accurate. In the following demo IsSet(*$var) should be the same as IsSet($a):

    Code: Select all

    "Demo"
    	$a_IsSetA    = IsSet($a);
    	$a_IsSetVar  = IsSet($var);
    	$a_IsSetDVar = IsSet(*$var);
    	$a_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$a_WA = $a_IsSetA == $a_ValEqStr;
    
    	$var = '$a';
    
    	$b_IsSetA    = IsSet($a);
    	$b_IsSetVar  = IsSet($var);
    	$b_IsSetDVar = IsSet(*$var);
    	$b_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$b_WA = $b_IsSetA == $b_ValEqStr;
    
    	*$var = 'value';
    
    	$c_IsSetA    = IsSet($a);
    	$c_IsSetVar  = IsSet($var);
    	$c_IsSetDVar = IsSet(*$var);
    	$c_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$c_WA = $c_IsSetA == $c_ValEqStr;
    
    	$a = 'try again';
    
    	$d_IsSetA    = IsSet($a);
    	$d_IsSetVar  = IsSet($var);
    	$d_IsSetDVar = IsSet(*$var);
    	$d_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$d_WA = $d_IsSetA == $d_ValEqStr;
    
    	$a = '$a';
    
    	$e_IsSetA    = IsSet($a);
    	$e_IsSetVar  = IsSet($var);
    	$e_IsSetDVar = IsSet(*$var);
    	$e_ValEqStr  = (*$var) != '*$var' && (*$var) != $var;
    	$e_WA = $e_IsSetA == $e_ValEqStr;
    
    
    	unset $var, $a;
    
    	Text <<<RESULTS
                            IsSet($a) - IsSet($var) - IsSet(*$var) - (*$var) != '*$var' && (*$var) != $var - Workaround Works?
        Before $var is set: $a_IsSetA         - $a_IsSetVar           - $a_IsSetDVar            - $a_ValEqStr                                     - $a_WA
         After $var = '$a': $b_IsSetA         - $b_IsSetVar           - $b_IsSetDVar            - $b_ValEqStr                                     - $b_WA
     After *$var = 'value': $c_IsSetA         - $c_IsSetVar           - $c_IsSetDVar            - $c_ValEqStr                                     - $c_WA
    After $a = 'try again': $d_IsSetA         - $d_IsSetVar           - $d_IsSetDVar            - $d_ValEqStr                                     - $d_WA
           After $a = '$a': $e_IsSetA         - $e_IsSetVar           - $e_IsSetDVar            - $e_ValEqStr                                     - $e_WA
    RESULTS
    	, 800;
    [/size]
1. Not possible. Or do you mean by smartness that XY should reorder the arguments?
2. Confirmed and fixed.

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

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

admin wrote:
TheQwerty wrote:
  1. The unset SC should have the smarts to correctly handle unsetting a dereferenced variable even if it is supplied in an argument after the variable holding the name.

    Code: Select all

    $var = '$a'; *$var = 'test';
    Unset *$var, $var; // Works correctly.
    
    $var = '$a'; *$var = 'test';
    Unset $var, *$var; // Leaves $a.
1. Not possible. Or do you mean by smartness that XY should reorder the arguments?
2. Confirmed and fixed.
1. :veryconfused: The user shouldn't have to think about the order of the arguments they pass to unset. XY should detect and unset any dereferenced variable arguments (*$var) first, then unset the rest of the variables. If you want to think of it as reordering the arguments upon receiving them okay. :tup:

2. Sweet - thanks! :appl:

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

Re: Minor scripting related wishes (a generic thread)

Post by admin »

1. OK. :)

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Minor scripting related wishes (a generic thread)

Post by bdeshi »

either add a reload operation to tabset() or make "load" reload passed tabset from disk if it's current.
ATM "load"ing a current tabset just statuses "tabset already opened". This disrupts updating loaded tabset with manual modifications to it's ini.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

I hope to one-day see this in the change log:

Code: Select all

* SC Load: Now the labels argument also supports CRLF-separated lists of labels.
Reasoning:
  1. ;-separated lists in code are ugly.
  2. ;-separated lists make it difficult to visualize the generated menu.
  3. HEREDOCs can be used to generate CRLF-separated lists.

Code: Select all

"Show Menu (Ugly)"
  $menu = '_favs;_favFiles;_favsFull;-;_drives;_drivesSpecial;-;_tabsAll;_tabsPane';
  Load '*', $menu;

"Show Menu (Less Ugly)"
  $menu = <<<MENU
_favs
_favFiles
_favsFull
-
_drives
_drivesSpecial
-
_tabsAll
_tabsPane
MENU;
  Load '*', Replace($menu, <crlf>, ';');

"Show Menu (Nice)"
  Load '*', <<<MENU
_favs
_favFiles
_favsFull
-
_drives
_drivesSpecial
-
_tabsAll
_tabsPane
MENU;

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

Re: Minor scripting related wishes (a generic thread)

Post by admin »

OK, and thanks for the change log text. :biggrin:

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

Re: Minor scripting related wishes (a generic thread)

Post by admin »

SammaySarkar wrote:either add a reload operation to tabset() or make "load" reload passed tabset from disk if it's current.
ATM "load"ing a current tabset just statuses "tabset already opened". This disrupts updating loaded tabset with manual modifications to it's ini.
Why not use "revert? Help:
"revert" Revert the current tabset to its saved state.

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Minor scripting related wishes (a generic thread)

Post by bdeshi »

OK. :tup:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Minor scripting related wishes (a generic thread)

Post by TheQwerty »

On the edge of being a bug - timestamp's type and source_type arguments are case-sensitive and unfortunately the SC gives the impression that it works even though it doesn't when those arguments are capitalized.

Demo:

Code: Select all

"Timestamp Case Sensitivity"
	$item = New("%temp%\<date yyyy-mm-dd_hhnnss>.txt", 'f',, 'u');
	$property = '#date.modified';

	$original = Property($property, $item);

	timestamp 'm', '1990-01-01 1:00', $item;
	$lowerCase = Property($property, $item);

	timestamp 'M', '2000-02-02 2:00', $item;
	$upperCase = Property($property, $item);

	Echo <<<MESSAGE
File: '$item'

Modified date:
Original = $original
timestamp 'm', '1990-01-01 1:00': $lowerCase (Correct.)
timestamp 'M', '2000-02-02 2:00': $upperCase (Incorrect!)
MESSAGE;

	delete 1,, $item;
Change-log message ready to be copied and pasted after issue is resolved. ;)

Code: Select all

* SC timestamp: Now the type and source_type arguments are case-insensitive.

Post Reply