{}

我们的品牌

欢迎访问施耐德电气网站

欢迎访问我们的网站。
搜索常见问题解答
如何在Vijeo Dseigner中能否比较两个字符串变量?
问题描述:
在Vijeo Dseigner中比较两个字符串变量

所属产品线:
Vijeo Designer

解决方法:

可以使用脚本来实现,例程参考如下:

Below is a script to compare two string variables in Vijeo Designer:
String s1, s2; //declare two internal script string variables called s1 and s2
int mycompare; //declare integer variable mycompare
s1 = MyString01.getStringValue(); //let s1 equal to the external variable called MyString01
s2 = MyString02.getStringValue(); //let s2 equal to the external variable called MyString02
mycompare = s1.compareTo(s2); //compare the two strings, returns 0 if equal and anything else if not equal
if (mycompare == 0) //if statement to compare if mycompare is equal to 0
ResultString.write("String are equal"); //write a string constant to the external variable ResultString
else
ResultString.write("String are not equal"); //write a string constant to the external variable ResultString



是否有帮助?

探索更多
范围:
探索更多
范围: