Test case R0162
Full test suiteDevice test case
More string functions
This test case it part of the test suite proposed for new devices.
Test case ID: R0162
Language: ST
tests2/t0162.stPROGRAM R0162 VAR sx1,sx2,sx3,sx4,sx5,sx6,sx7,sx7b: STRING; i1,i9 : INT; END_VAR VAR_EXTERNAL _T_PARAMS : TEST_PARAMS; END_VAR VAR_TEMP sx8: STRING; END_VAR sx1 := R0162myconcat('HI, ', 'BYE',0,0); sx2 := R0162myconcat(s1 := 'HI',s2:='',i1:=0,i2:=0); sx3 := R0162myconcat(i1:=1, i2:=-3, s1:='HE', s2 := 'HO'); sx4 := R0162myconcat(s2 := 'HI', i2:= -9, s1:='' , i1:=0); sx7 := R0162myconcat(sx7,'AB',0,0); sx7 := R0162myconcat(sx7,'CD',10,10); sx7b := CONCAT(sx7b,'AB'); sx8 := R0162myconcat(sx8,'AB',0,0); sx6 := sx8; IF _T_PARAMS.cycle = _T_PARAMS.timestorun THEN // last iteration _GEB_ASSERT_(sx1 = 'HI, BYE'); _GEB_ASSERT_(sx2 = 'HI'); _GEB_ASSERT_(sx3 = 'HOHE'); _GEB_ASSERT_(sx4 = 'HI'); _GEB_ASSERT_(sx6 = 'AB'); _GEB_ASSERT_(sx7 = 'ABCDABCDABCD'); _GEB_ASSERT_(sx7b = 'ABABAB'); END_IF; END_PROGRAM // s:= myconcat(s1,s2,i1,i2) // CONCATENATES TWO STRINGS , the first has a default value. // if the sum of the two arguments is negative, inverts the order FUNCTION R0162myconcat : STRING VAR_INPUT s1 : STRING ; s2 : STRING[30] ; i1 : INT; i2 :INT; END_VAR VAR // vars not used, just for testing initialization s3 :STRING; s4 :STRING := 'XX'; i3 : INT :=3; // not used i4 :INT; END_VAR IF(i1+i2<0) THEN R0162myconcat := CONCAT(s2,s1); ELSE R0162myconcat := CONCAT(s1,s2); END_IF; i3 := R0162F1(40); END_FUNCTION FUNCTION R0162F1 : INT VAR_INPUT X: INT; END_VAR R0162F1 := X+1; END_FUNCTION