Tag syntax examples

These examples show tag syntax in the
FactoryTalk Design Studio
DSL.
Specifying a tag declaration with a default value
tag DINT myTag := 10;
tag DINT[2] myTag {
[0] := 1;
[1] := 1;
}
tag SomeStruct myTag {
mem1 := 10;
mem2 := 10;
mem3.submem1 := 10; // using short form
}
Specifying a tag instance while setting some properties and a value
tag dint myTag { }
// declaring a new tag
tag input dint myTag { desc:=”hello”, style:=hex} := 10 // comment in code
tag input safety constant dint myTag { desc:=”hello, eh”, style:=hex, min:=0, max:=10 } := 10
Declaring a structure
struct MyStruct {
dint mem1;
MyOtherStruct mem2;
}
struct MyOtherStruct {
dint mem3
}
Specifying a tag instance and setting values
Tag MyStruct myTag {
desc := “this is myTag desc”
mem1 {
style := hex
}
MyOtherStruct mem2 {
desc := “this is mem2 desc”
mem3 {
desc := “this is mem3 desc”
}
}
}
Shortcut for setting tag values
// Also applies to the below setting tag values
// Declaring a tag instance – setting initial values
tag MyStruct myTag {
desc := “this is myTag desc”
dint min := 0
dint mem1.style := hex
OtherStruct mem2
mem2.desc := “this is mem2 desc”
mem2.mem3.desc := “this is mem3 desc”
mem2.mem3 := 10;
}
tag MyStruct myStruct := { mem1:=1, mem2:=2, mem3 :={mem31 := 1, mem32 := 2 } }
/// initializing tag values
tag SomeUDT myStruct {
desc := "hello"
mem1 := 1
mem2 := 2
mem3 {
subMem1 := 3
sumMem2 := 4
}
}
/// an array of structures
tag timer[10] tOut {
[1].acc.1 := 1;
[2].acc {
.3 := 1;
desc := 'hello';
}
}
struct myStruct {
timer[10] ta;
}
tag myStruct[4] tt {
[1].ta[1].acc := 1;
[2].ta {
[3].pre := 1;
[2].pre { desc := 'hello'; }
}
}
/// settings within members
tag MyUDT myTagNoValue {
mem1 { desc := ‘Desc On mem1’; }
mem3 {
LEN {desc:=’Desc on mem3.LEN’;}
}
}
tag MyUDT myTagWithValue {
mem1 { desc := ""Desc On mem1"" } := 10
mem2 := 20;
mem3 {
LEN { desc := ""Desc On mem3.LEN"" } := 30
POS := 40;
}
}
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.