"Sputnik" help  
Sputnik Help
Range

Description

The range directive generates a sequence of values within a specified range and step size. It is commonly used in conjunction with the foreach directive to iterate over the generated sequence.

Varients

None.

Parameters

<dst>

Destination variable to store the generated sequence.

<start> Starting value of the sequence.
<end> Ending value of the sequence.
<step> Optional. Step size between values. (Defaults to 1 if not specified)

Remarks

The range directive supports both numerical and character ranges.
The resulting sequence is inclusive of both the start and end values.
If the <step> parameter is not specified, it defaults to 1.

To learn more go the main preprocessor macro section.

Related

Example (#)

Example of usage:

#range PAX, 500, 505, 1
#foreach PCX in PAX
    say PCX;
#ende

// PRINTS
// 500
// 501
// 502
// 503
// 504
// 505

Using variables:

#define STORE null
#define COUNTER null

#range STORE, 500, 505, 1
#foreach COUNTER in STORE
    say COUNTER;
#ende

// PRINTS
// 500
// 501
// 502
// 503
// 504
// 505

 

Example (.)

Example of usage:

#macro foo()
    local $i
    // Save the current state of all registers (PAX, PCX, etc.) to the argument stack
    .pushap  // Push all registers onto the argument stack

    // Example 1: Range from 500 to 505 with step 1
    .range PAX, 500, 505, 1
    .foreach $i in PAX
        say $i;
    .ende

    // Example 2: Range from 500 to 510 with step 2
    .range PAX, 500, 510, 2
    .foreach $i in PAX
        say $i;
    .ende

    // Example 3: Character ranges from 'a' to 'f', 'A' to 'F', and '0' to '0' with step 1
    .range PAX, 'a', 'f', 1
    .range PCX, 'A', 'F', 1
    .con PAX, PCX  // Concatenate PAX and PCX
    .range PCX, '0', '9', 1
    .con PAX, PCX  // Concatenate PAX and PCX
    .foreach $i in PAX
        say (char)$i;  // Print the character representation of the ASCII value
    .ende
    
    // Restore the registers from the argument stack to their previous state
    .popap  // Pop all registers from the argument stack
#endm

foo();

// PRINTS
// 500
// 501
// 502
// 503
// 504
// 505
// 500
// 502
// 504
// 506
// 508
// 510
// a
// b
// c
// d
// e
// f
// A
// B
// C
// D
// E
// F
// 0
// 1
// 2
// 3
// 4
// 5
// 6
// 7
// 8
// 9

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org