countdown

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

countdown

Post by serendipity »

I did not have the time to make my own. But has anybody got a handy countdown script? For example say to preview photos every 5 second, like a slideshow. I am sure this can be used for other things.
Thanks.

Update: maybe Don can provide a command for this. Just wondering.

:oops: Maybe I can hack the <date ss> to do this. No time now, if anybody has figured it out it would be nice. :)

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

Re: countdown

Post by TheQwerty »

Unofficially you'll want to play around with:

Code: Select all

Wait(milliseconds);
:wink:

It should beat creating a recursive loop with conditional subs.

Muroph
Posts: 561
Joined: 21 Aug 2007 16:13

Re: countdown

Post by Muroph »

TheQwerty wrote:It should beat creating a recursive loop with conditional subs.
that's what tried to do.
but i found a possible bug.
try this script.
recursion checker must be off.

Code: Select all

setkey 0, test,test,"test.ini";
  sub _test;

 "_test"
  getkey $test, test,test,"test.ini";
  incr $test;
  $next = ($test < 10)?_test:_end;
  msg "$test/10 clicks<crlf>Next step = $next";
  setkey $test, test,test,"test.ini";
  sub $next;

 "_end"
  getkey $test, test,test,"test.ini";
  msg "The script ended with $test of 10 clicks.<crlf>Try again?",1;
if i didn't screw up, it should make you click "ok" 10 times before ending.
but looks like the conditional doesn't work when the script calls itself.
on the second loop the condition "$test>=10" will be evaluated true when it should be false, since $test==2.
My shared scripts:
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: countdown

Post by serendipity »

Thanks guys, much appreciated.
@TheQwerty: :shock: , how did u get the info about the command "wait(milliseconds)"? Thats what I precisely wanted.
@Muroph: Thanks for trying out the script, but I was looking for a method where I wont have to click. Like for example in a photo slideshow.

Muroph
Posts: 561
Joined: 21 Aug 2007 16:13

Re: countdown

Post by Muroph »

that's not a timer.
it's a script to show a bug that i found while trying to make the timer.
My shared scripts:
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: countdown

Post by serendipity »

Muroph wrote:that's not a timer.
it's a script to show a bug that i found while trying to make the timer.
Oh sorry, I misread your post. Thanks again.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: countdown

Post by serendipity »

One thing I needed this was for a simple automatic slideshow, but seems like once full screen preview has started, scripts dont work automatically. User intervention is needed for exiting every image. I was hoping this would work, but doesnt:

Code: Select all

"Slideshow : slideshow"
 inputfolder $folder, <curpath>, "Select folder";
 goto $folder;
 setting HideFoldersInList, 1;
 sel 1;
 sub slide;
 
"_slide : slide"
//Full screen preview
 #1003;
 wait (3000);
 sel +1;
 sub slide

Instead I settled for this:

Code: Select all

"Slideshow : slideshow"
 inputfolder $folder, <curpath>, "Select folder";
 goto $folder;
 setting HideFoldersInList, 1;
 sel a;
 getinfo $count, "CountSelected";
 copytext $count;
 //Find panel
 #260;
 //Preview panel
 #174;
 //maximize info panel
 #667;
 //Maximize window
 #1028;
 sel 1;
 sub slide;
 
"_slide : slide"
 wait (3000);
 sel +1;
 set $count, <clipboard>;
 incr $count, $count, -1;
 copytext $count;
 $eval= $count > 0 ? "slide" : "end";
 sub $eval
 
"_end : end"
 //Restore window size
 #1029;
 //Last info panel size
 #666;
  status "End of Slideshow";
 
I anyway have the Irfanview script too, but having it in XY would have been sweet.

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

Re: countdown

Post by admin »

Muroph wrote:
TheQwerty wrote:It should beat creating a recursive loop with conditional subs.
that's what tried to do.
but i found a possible bug.
try this script.
recursion checker must be off.

Code: Select all

setkey 0, test,test,"test.ini";
  sub _test;

 "_test"
  getkey $test, test,test,"test.ini";
  incr $test;
  $next = ($test < 10)?_test:_end;
  msg "$test/10 clicks<crlf>Next step = $next";
  setkey $test, test,test,"test.ini";
  sub $next;

 "_end"
  getkey $test, test,test,"test.ini";
  msg "The script ended with $test of 10 clicks.<crlf>Try again?",1;
if i didn't screw up, it should make you click "ok" 10 times before ending.
but looks like the conditional doesn't work when the script calls itself.
on the second loop the condition "$test>=10" will be evaluated true when it should be false, since $test==2.
Oh, yes, interesting. The comparison is not numerical but alphabetical, so "2" > "10"! :) So, do we need variable types now? Is this getting out of hand? I just wanted to make a little scripting feature... :wink:

PHP has no variable types, but apparently some smart detection. I have written the returns into the comments:

Code: Select all

<?php
$test = "2";
echo ($test < "10")?"True":"False";// True
echo ($test < 10)?"True":"False";// True

$test = 2;
echo ($test < "10")?"True":"False";// True
echo ($test < 10)?"True":"False";// True

$test = "a2";
echo ($test < "a10")?"True":"False";// False!
echo ($test < 10)?"True":"False";// True ("a2" is probably evaluated as numeric 0)
?>
I guess it checks whether one of the compared operands is numerical and then applies a numeric comparison. Should I do that too? I'd think so. I would not like to add special operators for string vs. numeric comparison.

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

Re: countdown

Post by TheQwerty »

serendipity wrote:Thanks guys, much appreciated.
@TheQwerty: :shock: , how did u get the info about the command "wait(milliseconds)"? Thats what I precisely wanted.
You can garner the valid scripting commands by looking at XYplorer.exe in Raw Preview (or any hex editor), but you'll have to guess if there are parameters and what they are.
admin wrote:I guess it checks whether one of the compared operands is numerical and then applies a numeric comparison. Should I do that too? I'd think so. I would not like to add special operators for string vs. numeric comparison.
I almost think that it might be best that if either operand is within quotes you should treat it as a string comparison, otherwise numeric.

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

Re: countdown

Post by admin »

TheQwerty wrote:
admin wrote:I guess it checks whether one of the compared operands is numerical and then applies a numeric comparison. Should I do that too? I'd think so. I would not like to add special operators for string vs. numeric comparison.
I almost think that it might be best that if either operand is within quotes you should treat it as a string comparison, otherwise numeric.
But the state of being quoted is lost once the operand is set to a variable:

Code: Select all

msg (2 < "10"); // would be 1
msg ("2" < "10"); // would be 0
$a = 2; msg ($a < "10"); // would be 1?
$a = "2"; msg ($a < "10"); // would be 1?
I would prefer going the PHP way. I could later add a function to force string or numeric comparison:

Code: Select all

function compare (operator, op1, op2, [comparetype=string|numeric])

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

Re: countdown

Post by PeterH »

Don't understand PHP related to this till now...
Is comparison ("A" > "B") allowed, or only (2 > 3)? What if (2 > "A") or ("2" > "A")?

I found that (1 == "1") is true, so it seams PHP can interpret numeric strings as numbers? In this case I'd expect that if both comparison-operands are numeric, they should (by default) be compared numerical, else char by char?

Muroph
Posts: 561
Joined: 21 Aug 2007 16:13

Re: countdown

Post by Muroph »

admin wrote:But the state of being quoted is lost once the operand is set to a variable:

Code: Select all

msg (2 < "10"); // would be 1
msg ("2" < "10"); // would be 0
$a = 2; msg ($a < "10"); // would be 1?
$a = "2"; msg ($a < "10"); // would be 1?
i like qwerty's idea, but i don't think you got it right here.
it should be:

Code: Select all

msg (2 < 10); //number, would be 1
msg (2 < "10"); //string, would be 0
msg ("2" < "10"); //string, would be 0
$a = "2"; msg ($a < 10); //number, would be 1
$a = 2; msg ($a < "10"); //string, would be 0
$a = 2; msg ("$a" < 10); //string, would be 0
the quotes are on the conditional, not on the set command.
My shared scripts:
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: countdown

Post by jacky »

admin wrote:I guess it checks whether one of the compared operands is numerical and then applies a numeric comparison. Should I do that too? I'd think so.
Might be wrong there, but I think PHP does numerical comparison no matter what. To do string comparisons, there are special functions. IMO that's be the right thing to do here as well, do numerical comparisons for now, maybe later add a function to do a string comparison...
Proud XYplorer Fanatic

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

Re: countdown

Post by admin »

jacky wrote:
admin wrote:I guess it checks whether one of the compared operands is numerical and then applies a numeric comparison. Should I do that too? I'd think so.
Might be wrong there, but I think PHP does numerical comparison no matter what. To do string comparisons, there are special functions. IMO that's be the right thing to do here as well, do numerical comparisons for now, maybe later add a function to do a string comparison...
Is this a numerical comparison? Should be True then, or? But is False...

Code: Select all

echo ("2a" < "10a")?"True":"False";// False!
But, yes, I agree. I will mimic PHP here.

Post Reply