使用 GlobalTextList 中的内容分配字符串变量

时间:2021-07-15 18:35:22

标签: plc codesys

有没有办法用 GlobalTextList 中的字符串内容分配字符串变量?

同样重要的是,当它从 GlobalTextList 分配变量时,它使用来自 GlobalTextList 的正确语言。

1 个答案:

答案 0 :(得分:1)

您想从静态动态文本列表中获取 ST 中的字符串吗?

这个函数会做到:

FUNCTION F_GetText : STRING
VAR_INPUT
    sTextList : STRING;
    sId : STRING;
END_VAR

sTextList := CONCAT('Port_851.',sTextList);
F_GetText := VisuElems.CmpDynamicText.DynamicTextGetText(
    pstTextList:= ADR(sTextList), 
    pstTextIndex:= ADR(sId)
    )^;
  • 如果是静态文本,则将数字作为参数指定为 STRING

  • 如果您使用的是 TwinCAT,则此方法需要 HMI 的许可。另一种选择是通过 ADS 和一个外部程序来完成这项工作。

相关帖子:

Codesys 3. How to get the translations from static or dinamic text file in ST?