Page 1 of 1
countdown
Posted: 16 Sep 2008 23:03
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.

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

Re: countdown
Posted: 17 Sep 2008 02:21
by TheQwerty
Unofficially you'll want to play around with:
It should beat creating a recursive loop with conditional subs.
Re: countdown
Posted: 17 Sep 2008 03:35
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.
Re: countdown
Posted: 17 Sep 2008 04:25
by serendipity
Thanks guys, much appreciated.
@TheQwerty:

, 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.
Re: countdown
Posted: 17 Sep 2008 04:44
by Muroph
that's not a timer.
it's a script to show a bug that i found while trying to make the timer.
Re: countdown
Posted: 17 Sep 2008 06:07
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.
Re: countdown
Posted: 17 Sep 2008 06:21
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.
Re: countdown
Posted: 17 Sep 2008 08:50
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...
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.
Re: countdown
Posted: 17 Sep 2008 13:38
by TheQwerty
serendipity wrote:Thanks guys, much appreciated.
@TheQwerty:

, 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.
Re: countdown
Posted: 17 Sep 2008 13:55
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])
Re: countdown
Posted: 17 Sep 2008 15:23
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?
Re: countdown
Posted: 17 Sep 2008 16:32
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.
Re: countdown
Posted: 17 Sep 2008 22:44
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...
Re: countdown
Posted: 18 Sep 2008 07:48
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.