Browse FAQs

How to compare two string variables in Vijeo Designer using scripting?

Published date: 31 May 2019

Issue: 
To show customers how to write a script to compare two string variables.


Product Line:
Vijeo Designer


Resolution:
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


Was this helpful?

What can we do to improve the information ?

Can't find what you are looking for?

Reach out to our customer care team to receive information on technical support, assistance for complaints and more.