Define
Console program57 lines of .st123 lines of generated C
The circumference of a circle radius 3.000000 is 18.849541 The area of a circle radius 3.000000 is 28.274309
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
}
}main.st
ability "define" "PI" {
value = 3.14159
}
ability "set" "Circ" {
target = ability.value.circ
value = var.rad * 2 * const.PI
}
ability "set" "Area" {
target = ability.value.area
value = var.rad * var.rad * const.PI
}
ability "print" "ShowCirc" {
message = "The circumference of a circle radius ${var.rad} is ${data.value.circ.current}"
depends_on = [ability.set.Circ]
}
ability "print" "ShowArea" {
message = "The area of a circle radius ${var.rad} is ${data.value.area.current}"
depends_on = [ability.set.Area, ability.print.ShowCirc]
}vars.st
variable "rad" {
type = Float
default = 3
}
ability "value" "circ" {
type = Float
}
data "value" "circ" {
of = ability.value.circ
}
ability "value" "area" {
type = Float
}
data "value" "area" {
of = ability.value.area
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.define.PI
+ ability.set.Circ
+ ability.set.Area
+ ability.print.ShowCirc
+ ability.print.ShowArea
+ ability.value.circ
+ ability.value.area
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-define # a folder holding the .st files above
structop init
structop plan
structop apply