Basic

The Basic toolbox holds the nodes nearly every graph uses: arithmetic and math functions, text, dates and times, arrays, random values, and running other programs. It also holds the value nodes you type into, such as Number and Text, and the control flow of Routine graphs: loops, branches, Switch and Try.

Start here whatever you want to build. When a node you need is "add two numbers", "join some text" or "repeat this for each item", it is in Basic.

  • Included in: Divooka Explore and Divooka Compute, every tier. Every document has it, even one made from the Blank workload.
  • Maturity: Stable · Support: Tier 1 (proposed) · what these mean
  • Open it: node library (Ctrl+Shift+Space) → Basic, or search for a node with Ctrl+Space.
  • Examples and reference: Ctrl+Shift+E → Basics (12 examples) and Procedural Context (6 examples) · node reference

New to graphs? Start with Your first program.

Main ideas

Value nodes hold what you type. Number, Text Line, Text, Boolean, Date & Time, Color, Path, Array and Dictionary are in the Primitive Nodes category. Each holds one value you edit on the node and passes it along a wire.

Most nodes are calculations. Add, Format, Join, Days Between and the rest take inputs and give a result. They run when their inputs are ready.

Control flow is for Routine graphs. The Procedural Programming category (Sequence, For Each, While, Branch, Switch, Try, Return) is used in Routine graphs, where nodes run in the order their Next and Previous pins connect them.

Example: go through a list

The task: print each fruit in a list, then print one closing sentence.

Open Basics > Array Basics from the examples (Ctrl+Shift+E). It is a Routine graph:

  1. Print Line, Message Enumerating fruits:.
  2. Array holds three texts: Apple, Banana, Cherry. It is a value node, so it sits under the steps and feeds For Each's Collection input.
  3. For Each runs its Next output once for each item. Wire Next to a Print Line and its Current Item output to that Print Line's Message.
  4. For Each's Completed output runs once, after the last item. Wire it to Join, with Separator set to a space and its values typed straight onto the pin: All, fruits, enumerated.
  5. A last Print Line prints Join's result.

Run it with F5. The console shows:

Enumerating fruits:
Apple
Banana
Cherry
All fruits enumerated.

The two outputs of For Each are the point of this example. Next is the loop's body; Completed is what happens after the loop. Wiring the step after the loop to Next instead is the most common first mistake.

To use your own data: edit the Array node's items, or wire in an array from another node, such as Text to Lines in Data Types or Read All Lines in Operating System.

Example: every kind of loop and branch

Open Procedural Context > Basic Control Flows. One Routine runs each control-flow node in turn: Sequence, Branch, Switch, For, For Each, While, Repeat, Break and Continue, and Return. Each part prints a line, so you can match each node to what it did. The console starts:

Sequence: first
Sequence: second
Sequence: third
Branch: 4 is even
Branch: 7 is odd
Switch: red means stop
Switch: green means go
Switch: blue means nothing
For Loop: pass 1 of 3

More examples to open

Example What it shows
Basics > Hello World A first program
Basics > Read Line Ask a question and read the answer
Basics > Function Delegates Functions passed around as values
Procedural Context > Try and Catch Catch a failure and carry on
Procedural Context > Try and Finally Clean up whether a step fails or not

Tips and limits

  • Search by type. In the toolbox tray, Add double:0 double:1 finds the Add nodes whose first two inputs are numbers, and ->string finds nodes that return text.
  • Random values can repeat. Seeded Generator makes a generator from a seed; the "From Generator" nodes then give the same sequence on every run.
  • Running programs. Run Command and Run Shell Command in Processes start another program and give you its output and exit code. They run on the computer the graph runs on, with your permissions.
  • Date and time nodes are many. Date Time Routines has over 130 nodes. Type part of the name, such as Days Between, rather than browsing.

Goes well with: Data Types for lists, dictionaries and conversions; Operating System for files and the console.

What is in the toolbox

Category Some of its nodes
Date Time Routines Add, Add Days, Add Hours, Add Microseconds and 134 more
Number Routines Atomic Mass Unit, Avogadro, Boltzmann Constant, Coulomb Constant and 157 more
3D Vector Negative Infinity, One, Positive Infinity, Size In Bytes and 92 more
Text Routines Ampersand, Asterisk, At, Backslash and 80 more
Array Routines As Read Only, Binary Search, Clear, Clone and 48 more
Enum Routines Add Flag, Format, From Value, Get Enum Values and 16 more
Procedural Programming Sequence, For Each, For, While and 12 more
Primitive Nodes Number, Text Line, Boolean, Date & Time and 6 more
Random Pick at Random, Pick From Generator, Pick at Random by Weight, Pick by Weight From Generator and 5 more
Processes Command Line, Is Running, Run Command, Run Shell Command and 3 more
Boolean Routines And, Choose, Not, Or and 1 more
Command Result Error, Exit Code, Output, Succeeded and 1 more
Advanced Types Function, Switch Value, Choose Value
Running Process Process Id, Program, To String
Programming Capture, Apply Function
Basic Comment, Select Output

See also