MCPcopy Index your code
hub / github.com/endbasic/endbasic / new

Method new

std/src/data.rs:68–99  ·  view source on GitHub ↗

Creates a new `READ` command.

(index: Rc<RefCell<usize>>)

Source from the content-addressed store, hash-verified

66impl ReadCommand {
67 /// Creates a new `READ` command.
68 pub fn new(index: Rc<RefCell<usize>>) -> Rc<Self> {
69 Rc::from(Self {
70 metadata: CallableMetadataBuilder::new("READ")
71 .with_syntax(&[(
72 &[],
73 Some(&RepeatedSyntax {
74 name: Cow::Borrowed("vref"),
75 type_syn: RepeatedTypeSyntax::VariableRef,
76 sep: ArgSepSyntax::Exactly(ArgSep::Long),
77 require_one: true,
78 allow_missing: false,
79 }),
80 )])
81 .with_category(CATEGORY)
82 .with_description(
83 "Extracts data values from DATA statements.
84DATA statements can appear anywhere in the program and they register data values into an array of \
85values. READ is then used to extract values from this array into the provided variables in the \
86order in which they were defined. In other words: READ maintains an internal index into the data \
87array that gets incremented by the number of provided variables every time it is executed.
88The variable references in the vref1..vrefN list must match the types or be compatible with the \
89values in the corresponding position of the data array. Empty values in the data array can be \
90specified by DATA, and those are converted into the default values for the relevant types: \
91booleans are false, numbers are 0, and strings are empty.
92Attempting to extract more values than are defined by DATA results in an \"out of data\" error.
93The index that READ uses to extract DATA values can be reset by RESTORE and, more generally, by \
94CLEAR.",
95 )
96 .build(),
97 index,
98 })
99 }
100}
101
102#[async_trait(?Send)]

Callers

nothing calls this directly

Calls 4

with_descriptionMethod · 0.80
with_categoryMethod · 0.80
with_syntaxMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected