ZennoLab

Automate everything

User Tools

Site Tools


Sidebar

Translations of this page:

en:ranges

Ranges

It's pretty common in project creation process to use predefined numbers for matches while you search for elements, set numbers of lines in lists, tables and so on. But sometimes you will need more than 1 match. Ranges will help you to handle this.

Here are some examples for list processing but you will be able to use them for every action's option where you have to input numbers.

When we use ranges:

  • When we need to take more than 1 line. For example, you want to get 1st and 3rd lines only.
  • When we need to take the last line, but don't know how many of them are in your list.
  • When you need to take random line.
  • When you need to take several lines.
  • When you need to take several lines from certain interval.
  • When you need to take even/odd lines from certain interval.
  • When you need to take random even/odd lines from certain interval.

Extracting a range or several ranges of lines

If you need to extract, for instance, lines from number five to number seven then you write the following in the line number field:

4-6 (less for one line as numeration starts with 0).

You can indicate several ranges separating them with a semi column ( ; ) or comma ( , ).

Example: 10-15;7;22-34

Extracting a random line from the list

To do this write random in the line number field.

You do not know the length of the list but you need to get all lines

The end of file is designated by the key word end.

So you simply indicate the range 10-end, for example, and it will extract lines starting from the eleventh one and up until the list end.

Extracting all lines from the list

To extract all lines from the file you can put as the line number all.

Extracting a random line or several random lines from a range

To do this write random in the line number field then the number of lines you need to extract and then in brackets indicate the range of lines from which to extract.

Example:

random1(1,12-15,35-end) - to extract one line from a range

or

random15(1,12-15,35-end) - to extract 15 lines from a range. randomAll(1,12-15,35-end) to extract all lines from specified interval randomly (randomAll is available in ZennoPoster starting from version 5.9.3).

Excluding ranges

Sometimes you need to take a range of lines exluding some of them. For example, the following range random1(0-(end-5)) allows to take random line from the whole list excluding last 5 lines from it.

Excluding ranges are available starting from ZennoPoster 5.9.3 version.

Extracting only even lines

To take first even line, use the following ranges: even(1,12-15,35-end) or even1(1,12-15,35-end)

To take first 5 even lines, use the following range: even15(1,12-15,35-end)

To take all even lines: evenAll(1,12-15,35-end)

The operator even is available starting from ZennoPoster 5.9.3 version.

Extracting only odd lines

To take the first odd line, use the following ranges: odd(1,12-15,35-end) or odd1(1,12-15,35-end)

To take first 5 odd lines, use the following range: odd15(1,12-15,35-end)

To take all odd lines: oddAll(1,12-15,35-end)

The operator odd is available starting from ZennoPoster 5.9.3 version.

Combining operators

The operators ramdom, even and odd can be combined.

For example, to take all even lines randomly from certain range, you can use the following expression: randomAll(evenAll(1,12-15,35-end))

The ability to combine operators is available starting from ZennoPoster 5.9.3 version.

en/ranges.txt · Last modified: 2015/09/23 18:49 by lokiys