Scripting: User-Defined Functions
-
- Site Admin
- Posts: 60602
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: User-Defined Functions
Yes, but this can be optimized because they are hard-coded.
FAQ | XY News RSS | XY Twitter
Re: Scripting: User-Defined Functions
I don't understand?admin wrote:Yes, but this can be optimized because they are hard-coded.
As described, there would be a list = a table of all pre-loaded user functions.
For each (name this one list has to be tested, if name can be found. (In scripting this would be just one GetTokenIndex().)
Aside from loading once, each function would only be touched, if it's name is found. Isn't that optimized?
If search order for this is last, it's only done when not found otherwise.
If this list is given a special Name Space, it can be addressed explicit, i.e. fast.
Win11 Pro 223H2 Gerrman
Re: Scripting: User-Defined Functions
What am I doing wrong? Since Saturday this doesn't work:
0. I load a fresh XY
1. I put this func.inc in <xyscripts> (warning: it modifies timestamps!)
[/size]2. I select a couple of files
3. I paste this in Try Scriptand run it.
All I get is an "Invalid date: $y" message.
0. I load a fresh XY
1. I put this func.inc in <xyscripts> (warning: it modifies timestamps!)
Code: Select all
function leveldate($items = <get "SelectedItemsPathNames" "|">) {
foreach ($item, "$items", "|") {
$m = report("{Modified yyyy-mm-dd hh:nn:ss.fffffff}", $item);
$c = report("{Created yyyy-mm-dd hh:nn:ss.fffffff}", $item);
$a = report("{Accessed yyyy-mm-dd hh:nn:ss.fffffff}", $item);
$x = (compare("$m", "$c", "d") == "1")?"$c":"$m";
$x = (compare("$x", "$a", "d") == "1")?"$a":"$x";
timestamp, "$x", "$item";
};
}
function leveldateall($items = <get "SelectedItemsPathNames" "|">) {
$y = report("{Modified yyyy-mm-dd hh:nn:ss.fffffff}", gettoken("$items",,"|"));
foreach ($item, "$items", "|") {
$m = report("{Modified yyyy-mm-dd hh:nn:ss.fffffff}", $item);
$c = report("{Created yyyy-mm-dd hh:nn:ss.fffffff}", $item);
$a = report("{Accessed yyyy-mm-dd hh:nn:ss.fffffff}", $item);
$x = (compare("$m", "$c", "d") == "1")?"$c":"$m";
$x = (compare("$x", "$a", "d") == "1")?"$a":"$x";
$y = (compare("$x", "$y", "d") == "1")?"$y":"$x";
};
timestamp, "$y", "$items";
}
3. I paste this in Try Script
Code: Select all
include func.inc
leveldate();
All I get is an "Invalid date: $y" message.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Re: Scripting: User-Defined Functions
What stays me over?admin wrote:Trust me.
(Sorry to English speakers: this was German )
Win11 Pro 223H2 Gerrman
Re: Scripting: User-Defined Functions
@Marco, nothing selected?
when I tried with no selection,a long bad date a list of dates for all current list items (unseparated) like this is returned:
Ed. because empty $item makes report() default to all current list items (and you did not add any separator in the template).
when I tried with no selection,
Code: Select all
set
COMMAND $m = report("{Modified yyyy-mm-dd hh:nn:ss.fffffff}", $item);
----
RESULT $m = "2015-03-13 21:18:06.16406252011-12-27 08:44:20.00000002015-04-25 23:11:08.8496093"
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Scripting: User-Defined Functions
No, I select a couple of files in the List.SammaySarkar wrote:@Marco, nothing selected?
Moreover, the first function gracefully does nothing if nothing is selected.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Re: Scripting: User-Defined Functions
Well, I see everything working (or not working) as expected.
Just add a step in the function and debug away.
ed. "the first function gracefully does nothing if nothing is selected." -- Nope. It continues.
Just add a step in the function and debug away.
ed. "the first function gracefully does nothing if nothing is selected." -- Nope. It continues.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Scripting: User-Defined Functions
Even with stepping enabled, XY jumps directly to the last line of code.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Re: Scripting: User-Defined Functions
I think Don broke the handling of the closing bracket when there are nested brackets.
This is enough to trigger it:Results in 'bye' > 'hi' > 'end'.
This is enough to trigger it:
Code: Select all
function leveldate() {
if (1) {
echo 'hi';
}
echo 'bye';
}
leveldate();
echo 'end';
Re: Scripting: User-Defined Functions
I would suggest the following
The default.inc will only be loaded for one liners (if and only if, the one liner has a non native function.)
The default.inc will only be loaded for one liners (if and only if, the one liner has a non native function.)
-
- Site Admin
- Posts: 60602
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: User-Defined Functions
I plan to officially release functions and include in 15.20. The features work alright for everybody now? (Not asking for extra wishes -- those will come in phase 2.)
FAQ | XY News RSS | XY Twitter
Re: Scripting: User-Defined Functions
So far everything works fine (and still excited about them)
One of my scripts helped you out? Please donate via Paypal
Re: Scripting: User-Defined Functions
Yep, works very very well.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]