On this page:
10.1 Read and write data in a stage
10.2 Reader, model, and interpreter
9.3

10 Data sources and storage🔗ℹ

A resource declaration names data outside a workflow: where it would be read from or stored. Write the declaration directly in the workflow:

Compact

#lang sciencelogo

workflow "Trace a pendulum timing"

resource timings [path = "data/timings.csv" kind = "table"]

 

elapsed = timings.elapsed

timings.period = elapsed

Verbose

#lang sciencelogo

workflow "Trace a pendulum timing"

resource timings [set path to "data/timings.csv" set kind to "table"]

 

set elapsed to elapsed of timings

set period of timings to elapsed

The first assignment declares that elapsed comes from the elapsed location within timings. The second declares that elapsed goes to its period location. A dotted path may continue into nested data, such as timings.observations.first. The declaration may describe a file path, URL, database, or other storage; the language prescribes no fixed fields. resource timings [] is also valid when the storage location is specified elsewhere.

resource names are unique within a workflow and cannot conflict with a procedure, interface, performer, import alias, or stage state set name. The declared name by itself is not a data value. To refer to data outside the workflow, use a dotted path rooted in that name. An undeclared path is rejected. A quoted URL or file path is ordinary text and does not read or write anything. The declaration fields describe the resource for inspection; a dotted path addresses its data, not a declaration field. The path is a logical address; an external application would interpret it for the particular file, table, or database. Source-code paths in import, include, and interface references identify language definitions; they are separate from data paths.

10.1 Read and write data in a stage🔗ℹ

Within a paired stage, read into a field of information, environment, or factors, or write a state field to a data location:

Compact

resource timings [path = "data/timings.csv"]

performer researcher [kind = "human"]

 

stage Inspect-timing by researcher from state [

  information = [elapsed = unknown]

]

information.elapsed = timings.elapsed

timings.checked = information.elapsed

end stage with state [

  information = [elapsed = unknown]

]

Verbose

resource timings [set path to "data/timings.csv"]

performer researcher [set kind to "human"]

 

start stage Inspect-timing by researcher from state [

  set information to [set elapsed to unknown]

]

set elapsed of information to elapsed of timings

set checked of timings to elapsed of information

end stage with state [

  set information to [set elapsed to unknown]

]

The entry and exit states remain complete declarations. When a data read assigns into state, its target needs an existing parent set or record. A data write may take a value from an available state field. These assignments record the intended flow; the paired stage body is not executed. If the stage names a performer, the workflow model links that performer to its data assignments.

10.2 Reader, model, and interpreter🔗ℹ

The reader checks resource declarations, names, and stage locations. The workflow model preserves the declaration and each assignment, with reads-from or writes-to links to the named data source or destination. The full dotted address remains in the assignment. The interpreter treats an inbound data value as unknown and performs no external read or write. The model describes the written method; it does not show that data was transferred in a particular run. The data source and storage contract records the accepted rules.