Page 1 of 1

Automation and ruby - listing largest files

Posted: 15 Feb 2016, 11:34
by tukanos
After I have manged to use Ruby as other COM language in the Automation plugin, I wanted to write more complex script to show and test the possibilities. I have decided to share for anyone who would like to write in ruby too.

Script displays n (user input) largest files at the path entered by the user (take from Salamander panel, but user can overwrite it). Nothing life changing but, at least for me, practical. I also wanted to have some framework for next scripts.

Nearly everything worked as it should. The biggest issue was caused Salamander.AbortScript(), because for unknown reason that has hang whole salamander when executed. I wanted to abort the script when user pressed cancel at InputBox (from what I tested it works for jscript and vbsript). I have circumvented the issue by managing the program workflow.

I hope someone will enjoy the script too .).

EDIT: New version of the file - to fix the cancel button even after wrong user answer. Should be final version.

Re: Automation a ruby - listing largest files

Posted: 15 Feb 2016, 17:35
by manison
The biggest issue was caused Salamander.AbortScript(), because for unknown reason that has hang whole salamander when executed. I wanted to abort the script when user pressed cancel at InputBox (from what I tested it works for jscript and vbsript).
I recommend avoiding Salamander.AbortScript method in 3rd party script engines. I found it to be very buggy. You will probably have issues with WScript.Quit as well (you can try it). If it also hangs the WScript host, you can report the bug to the engine author.
I have circumvent the issue by managing the program workflow.
It's always the better idea :)

Re: Automation a ruby - listing largest files

Posted: 15 Feb 2016, 19:33
by tukanos
manison wrote:
The biggest issue was caused Salamander.AbortScript(), because for unknown reason that has hang whole salamander when executed. I wanted to abort the script when user pressed cancel at InputBox (from what I tested it works for jscript and vbsript).
I recommend avoiding Salamander.AbortScript method in 3rd party script engines. I found it to be very buggy. You will probably have issues with WScript.Quit as well (you can try it). If it also hangs the WScript host, you can report the bug to the engine author.
I have circumvent the issue by managing the program workflow.
It's always the better idea :)
I see :), thank you for the confirmation. The WScript.Quit did not quit the program at all - the program just continued.

I have one question concerning the InputBox:
InputBox_issue.jpg
InputBox_issue.jpg (34.47 KiB) Viewed 12332 times
Why does the size of the InputBox does not adjust to the size of the string?

Re: Automation a ruby - listing largest files

Posted: 15 Feb 2016, 20:14
by Jan Rysavy
We didn't need it :)

Re: Automation a ruby - listing largest files

Posted: 16 Feb 2016, 08:32
by tukanos
Jan Rysavy wrote:We didn't need it :)
I thought so :).