Params
Console program51 lines of .st172 lines of generated C
Parameter 0 is one Parameter 1 is two
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
}
}main.st
parameter "items" {
type = String
position = 1
rest = true
}
ability "for" "Each" {
counter = ability.value.i
from = 0
while = data.value.i.current < length(param.items)
next = data.value.i.current + 1
body = [ability.print.Show]
}
ability "print" "Show" {
message = "Parameter ${data.value.i.current} is ${param.items[data.value.i.current]}"
}vars.st
ability "value" "i" {
type = Int
initial = 0
}
data "value" "i" {
of = ability.value.i
}tests/params.sttest
run "lists_each_argument" {
args = ["one", "two", "three"]
expect {
output_equals = "Parameter 0 is one\nParameter 1 is two\nParameter 2 is three\n"
}
}
run "no_arguments_prints_nothing" {
expect {
output_equals = ""
}
}Input, plan and generated C#
args.txt · command-line arguments
args.txt · command-line arguments
one
twostructop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.for.Each
+ ability.print.Show
+ ability.value.i
Plan: 1 to add, 0 to change, 0 to destroy.Generated main.c
To inspect this generated file, select C in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runTry it
cd c-params # a folder holding the .st files above
structop init
structop plan
structop apply -- one two