Skip to content

Clear

Name - Description Default Type
<input> Any input is ignored. Any
<output> The input to this shard is passed through as its output. Any
Name The name of the variable. "" String&Any
Key The key of the value to read/write from/in the table (parameter applicable only if the target variable is or will become a table). None String&String
Global If the variable is or should be available to all of the wires in the same mesh. false Bool

Removes all the elements of the sequence passed to it in the :Name parameter. Applicable only to sequences.

Details

Clear removes all the elements of the sequence that has been passed to it in the :Name parameter.

This shard works on both sequences and tables. Parameter :Key applies only to tables.

Since variables may be locally scoped (created with (:Global false); exists only for current wire) or globally scoped (created with (:Global true); exists for all wires of that mesh), both parameters :Global and :Name are used in combination to identify the correct variable to clear.

Any input to this shard is ignored and instead passed through as its output.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[1 2 3] >= .seq                     ;; create local sequence
[4 5 6] >== .seq                    ;; create global sequence with same name

(Get .seq) (Log)                    ;; read local sequence  => [1, 2, 3]
(Get .seq :Global true) (Log)       ;; read global sequence => [4, 5, 6]

;; clear local sequence
(Clear :Name .seq)                  ;; clear local sequence
(Get .seq) (Log)                    ;; local sequence cleared => []  
(Get .seq :Global true) (Log)       ;; same-name global sequence intact => [4, 5, 6]  

100 (AppendTo .seq)                 ;; append something to local sequence
(Get .seq) (Log)                    ;; local sequence no more empty => [100]

;; clear the same-named global sequence
(Clear :Name .seq :Global true )    ;; clear global sequence
(Get .seq :Global true) (Log)       ;; global sequence cleared => []
(Get .seq) (Log)                    ;; local sequence intact => [100]  
[info] Set - Warning: setting an already exposed variable "seq", use Update to avoid this warning.
[info] [shards/General/Clear/Clear.edn] [1, 2, 3]
[info] [shards/General/Clear/Clear.edn] [4, 5, 6]
[info] [shards/General/Clear/Clear.edn] []
[info] [shards/General/Clear/Clear.edn] [4, 5, 6]
[info] [shards/General/Clear/Clear.edn] [100]
[info] [shards/General/Clear/Clear.edn] []
[info] [shards/General/Clear/Clear.edn] [100]