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
4 guests & no users online
43
points ]
 (5 votes)
Created 2018-05-04 17:27
1 week 5 days ago
7YearBitch
33
points ]
 (4 votes)
Created 2018-03-30 18:06
6 weeks 5 days ago
15
points ]
 (2 votes)
Created 2018-03-25 15:52
7 weeks 3 days ago
nopnotme
12
points ]
 (2 votes)
Created 2017-09-29 21:52
32 weeks 5 days ago
7YearBitch
22
points ]
 (3 votes)
Created 2018-03-30 17:47
6 weeks 5 days ago
7YearBitch
28
points ]
 (4 votes)
Created 2018-02-28 00:20
11 weeks 1 day ago
Ao1 Pointblank
73
points ]
 (8 votes)
Created 2018-03-22 02:14
8 weeks 10 hours ago
15
points ]
 (2 votes)
Created 2018-04-25 02:24
3 weeks 1 day ago
7
points ]
 (1 vote)
Created 2018-04-20 14:42
3 weeks 5 days ago
15
points ]
 (2 votes)
Created 2018-03-02 09:43
10 weeks 6 days ago
sevnnseven
15
points ]
 (2 votes)
Created 2018-03-02 09:41
10 weeks 6 days ago
42
points ]
 (5 votes)
Created 2015-06-11 00:04
2 years 48 weeks ago
sevnnseven
25
points ]
 (3 votes)
Created 2018-03-01 19:26
10 weeks 6 days ago
25
points ]
 (3 votes)
Created 2018-02-13 11:00
13 weeks 2 days ago
23
points ]
 (3 votes)
Created 2012-08-30 04:30
5 years 37 weeks ago
49
points ]
 (5 votes)
Created 2017-06-22 03:17
47 weeks 9 hours ago
39
points ]
 (4 votes)
Created 2018-01-11 11:11
18 weeks 1 hour ago
12
points ]
 (2 votes)
Created 2017-09-29 22:03
32 weeks 5 days ago
25
points ]
 (3 votes)
Created 2017-11-20 13:55
25 weeks 2 days ago
25
points ]
 (3 votes)
Created 2017-11-23 23:59
24 weeks 6 days ago
Who's new
  • DON
  • sevnnseven
  • 7YearBitch
  • Mustangflier
  • Ao1 Pointblank