float m[float];
m[4.1] = 5.5; //key is 4.1 (float) and value is 5.5 (float)
m[5.3] = 6.6;
write ("4.1 is mapped to %2.2lf", m[4.1]);
write ("5.3 is mapped to %2.2lf", m[5.3]);
for (float mykey : m)
{
write("%2.2lf is mapped to %2.2lf.", mykey, m[mykey]);
}
example 2:关联字符串
char[30] namen[char []];
strncpy(namen["Max"], "Mustermann", 30);
strncpy(namen["Vector"], "Informatik", 30);
for (char[] mykey : namen)
{
write("%s is mapped to %s", mykey, namen[mykey]);
}
4 结构体
结构的定义和使⽤同C:
variables
{
timeout on t2 timerstruct Point
{
int x;
int y;
};
struct Point myPoint;
struct Point allPoints[50];
}
on start
{
myPoint.x = 7;
myPoint.y = 2;
allPoints[3].x = 1;
allPoints[3].y = 5;
}
注意: CAPL中结构体默认按8字节对齐,可以在结构体定义前加_align来改变结构体对齐⽅式。example:
2 流程控制
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论