Automation and ruby - listing largest files

Support for developers of new plugins, third-party plugin announcements and discussions.
User avatar
tukanos
Posts: 269
Joined: 21 Dec 2005, 19:14

Automation and ruby - listing largest files

Post by tukanos » 15 Feb 2016, 11:34

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.
Attachments
ruby_largest_files.zip
(2.43 KiB) Downloaded 141 times
Last edited by tukanos on 17 Feb 2016, 17:22, edited 4 times in total.

manison
Plugin Developer
Plugin Developer
Posts: 210
Joined: 09 Dec 2005, 23:23
Location: Ceske Budejovice, Czech Republic
Contact:

Re: Automation a ruby - listing largest files

Post by manison » 15 Feb 2016, 17:35

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 :)

User avatar
tukanos
Posts: 269
Joined: 21 Dec 2005, 19:14

Re: Automation a ruby - listing largest files

Post by tukanos » 15 Feb 2016, 19:33

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 4330 times
Why does the size of the InputBox does not adjust to the size of the string?

Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5126
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Automation a ruby - listing largest files

Post by Jan Rysavy » 15 Feb 2016, 20:14

We didn't need it :)

User avatar
tukanos
Posts: 269
Joined: 21 Dec 2005, 19:14

Re: Automation a ruby - listing largest files

Post by tukanos » 16 Feb 2016, 08:32

Jan Rysavy wrote:We didn't need it :)
I thought so :).

Post Reply