RaZgRiZ | 2014-04-14 00:08
CMD Conditional
10
points ]
 (1 vote)
It's back and it's better!

I was bored, so i was looking through my old nodes, and i decided to rework the CMD Flags into something less reliant on customizing the command to your liking and more towards freedom of action.
For your enjoyment, here it is in full glory. Hopefully the comments make it possible for code-illiterate people to understand what it is and how it works.

// Example of use:
// cmd [
//     [ condition 1 ]
//     [ condition 2 ]
//     ...
// ] [
//     [ on-success  1 ]
//     [ on-success  2 ]
//     ...
// ] [
//     [ on-failure 1 ]
//     [ on-failure 2 ]
//     ...
// ] [ action ]


// note 1: each condition that tests negative will terminate the script.
// note 2: all conditions must test positive for the action to run.

cmd = [
    local tmp l // declares "tmp" and "l" as temporary variables for use within cmd only
    tmp = 0 // giving our variable a value to boot
    l = (listlen $arg1) // total amount of conditions to check
    loopwhile i $l [>= $tmp 0] [
        if ((at $arg1 $i)) [
            do (at $arg2 $i) // execute custom action from second list on success
            tmp = (+ $tmp 1) // for every condition from the list that is true, add 1 to tmp
        ] [
            do (at $arg3 $i) // execute custom action from third list on failure
            tmp = -1 // end the loop early if condition is false
        ]
    ]
    if (= $tmp $l) arg4 // will only run once all given conditions successfully pass
]
10
points
 (1 vote)
User login
Users on Quadropolis
1 guest & no users online
ransom subject
16
points ]
 (3 votes)
Created 2010-09-04 01:12
15 years 44 weeks ago
Created 2025-02-09 15:35
1 year 20 weeks ago
30
points ]
 (3 votes)
Created 2019-05-17 21:51
7 years 7 weeks ago
30
points ]
 (3 votes)
Created 2020-06-13 21:05
6 years 3 weeks ago
20
points ]
 (2 votes)
Created 2021-05-24 00:01
5 years 6 weeks ago
8
points ]
 (1 vote)
Created 2024-06-02 14:26
2 years 4 weeks ago
8
points ]
 (1 vote)
Created 2024-06-02 22:13
2 years 4 weeks ago
vampirefrog
Created 2024-04-11 22:25
2 years 12 weeks ago
vampirefrog
29
points ]
 (4 votes)
Created 2010-05-30 10:00
16 years 5 weeks ago
Gangler
36
points ]
 (4 votes)
Created 2020-10-22 00:50
5 years 36 weeks ago
Zoocata
10
points ]
 (1 vote)
Created 2024-02-11 21:20
2 years 20 weeks ago
vampirefrog
10
points ]
 (1 vote)
Created 2023-07-23 20:02
2 years 49 weeks ago
36
points ]
 (4 votes)
Created 2020-12-10 12:49
5 years 29 weeks ago
Created 2023-12-12 23:34
2 years 29 weeks ago
Zoocata
Created 2023-11-27 23:00
2 years 31 weeks ago
20
points ]
 (2 votes)
Created 2023-10-01 15:21
2 years 39 weeks ago
9
points ]
 (1 vote)
Created 2023-06-13 17:54
3 years 3 weeks ago
Zoocata
27
points ]
 (3 votes)
Created 2023-05-05 20:58
3 years 8 weeks ago
Zoocata
18
points ]
 (2 votes)
Created 2023-03-02 01:40
3 years 18 weeks ago
Getridou
Created 2023-01-29 23:27
3 years 22 weeks ago