Skip to content

Instantly share code, notes, and snippets.

@MrCoder
Created October 29, 2024 03:58
Show Gist options
  • Save MrCoder/dcdf127c85e86db5cdfe62fd5dc874cf to your computer and use it in GitHub Desktop.
Save MrCoder/dcdf127c85e86db5cdfe62fd5dc874cf to your computer and use it in GitHub Desktop.

Simple Action

Hello world

This is defined on \
several **lines**

alt text

Start/Stop/End

start
Hello world
This is defined on \
several **lines**
stop

alt text

start
Hello world
This is defined on \
several **lines**
end

alt text

Conditional

# `is` a key word and a separator. Content before `is` is rendered inside the node; content after `is` is render on the line
# `equals` works exactly as `is`.
if(Graphviz installed is yes) {
    process all\ndiagrams
} else if(no){    # in this case, the else line does not have a lable
    process only \
    __sequence__ and __actiivty__ diagrams
}

condition1

# `is` a key word and a separator. Content before `is` is rendered inside the node; content after `is` is render on the line
# `equals` works exactly as `is`.
if(color? is [red]red) {
    print red
} else {    # in this case, the else line does not have a lable
    print not red
}

condition2

# `equals` works exactly as `is`.
if(counter equals 5) {
    print 5
} else {
    print not 5
}

condition3

Several tests

start
if(condition A is yes) {
    Text 1
} else {
    if(condition B is yes) {
       Text 2
       stop
    } else if(no) {
        if(condition C is yes) {
            Text 3
        } else if(no) {
            if(condition D is yes) {
                Text 4
            } else if(nothing) {
                Text else
            }
        }
    }
}
stop

alt text

Several tests (vertical)

start
// [vertical]
if(condition A is yes) {
    Text 1
} else {
    if(condition B is yes) {
       Text 2
       stop
    } else if(no) {
        if(condition C is yes) {
            Text 3
        } else if(no) {
            if(condition D is yes) {
                Text 4
            } else if(nothing) {
                Text else
            }
        }
    }
}
stop

Switch and case [switch, case, endswitch]

start
switch(test?) {
    case condition A:
        Text 1
    case condition B:
        Text 2
    case condition C:
        Text 3
    case condition D:
        Text 4
    case condition E:
        Text 5
}
stop

switch

Conditional with stop on an action [kill, detach]

if(condition?) {
    error
    stop
}
[palegreen]action

kill

if(condition?) {
    [pink]error
    kill
}
[palegreen]action

alt text

detach

if(condition?) {
    [pink]error
    detach
}
[palegreen]action

alt text

Repeat loop

start
do {
    read data
    generate diagrams
} while (more data? is yes) until (no)
stop

Repeat loop with repeat action and backward action

start
do {
l_foo: foo as starting label
    read data
    generate diagrams
} while (more data? is yes goto l_backward) until (no) goto l_stop

l_backward: this is backward
goto foo

l_stop: stop

repeat-backward

Break on a repeat look [break]

start
do {
    Test something
    if(Something went wrong? is no) {
        [palegreen]OK
        break
    } else if(NOK) {
        Alert "Error with long text"
    }
} while (Something went wrong with long text? is yes) until (no)

Alert "Success"
stop


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment