Jump to content
Ketarin forum

"random" function


Recommended Posts

I needed the ability to randomly select a source from a site the other day, in order to not fixate the download to one specific source and overburden it (not that that's very likely), but it would have been easier if there were a "random" function within Ketarin. I imagine it would operate in several different syntaxes, based on the source and parameters fed to it.


Here's simplest form:


This would parse and return one of the lines from the {varname} variable. Parsing would be performed by default at carriage returns.




This one parses {varname} in the same fashion, but at the delimiter specified, instead of at carriage returns.




This syntax would randomly return one of the variables named within it (note the lack of a 'varname' prefix).




Would randomly choose a value, inclusively, between 3000 and 3006.




This is the one that would be most applicable to me immediately. This one changes the behavior of a RegEx or Start/End variable to instead parse for multiple results of the RegEx or Start/End combo and return a RANDOM result from the matches. Yes, I understand this would be freaky and probably require a large rewrite of the variable handling stuff, but it would let us use a truly random source when available - instead of the first result. Imagine using it with this regex, for example:

<option value="([^"]+)">

Link to comment
Share on other sites

Hi Shawn,


only another dirty idea...... ;-)


if you can parse the content for {varname} the random function can be done over Ketarin command and a simple batch

Set /a Randomized=%random%

This will give you a number between 1-32767


Combined with some If-...Else Commands you could generate any number or Char you like and with wget.exe (as I use in my Softpedia template) you can download the source.


BUT you need a dummy Download link with alterating content for ketarin to initialize the download.



This could be the dummy with alterating content. It changes every 5 min.


Edited by Gozi
Link to comment
Share on other sites

Thanks, Gozi, but I'm actually more interested in obtaining a random source link from a regex-matching pattern from an HTML result. Such as the download source lists on MySQL, IrfanView, and similar sites where the list uses something much different than an appended number to identify the different sources.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.