Siemens SCL String assignment

cjd1965

Lifetime Supporting Member
Join Date
Apr 2007
Location
UK
Posts
1,659
Hi
I am playing around with SCL & Strings, what is the problem with the string assignment

VAR_TEMP
MyString : STRING[20] ;
END_VAR

MyString :='Hello' ; <<<<---------

I get the message illegal parameter assignment error in the compiler

Cheers
 
So what was the reason?

Hi I was premature to say it was working. I stripped down the bit above and it did compile. Now I have the 'full code' it does not. I am trying to compare an input string with a constant string and return true if they match


FUNCTION FC100 : Void
VAR_INPUT
NewString : STRING[20] ;
END_VAR
VAR_TEMP
MyString : STRING[20] ;
END_VAR
VAR_OUTPUT
Result : BOOL ;
END_VAR
MyString := 'hello' ;
Result := FALSE ;
IF NewString = MyString THEN
Result := TRUE ;
END_IF ;

;
END_FUNCTION

I get error of 'assignment error' with the cursor on line of Result:=TRUE ;
 
You have to copy the input parameter string to a temp before the comparison.

Code:
FUNCTION FC100 : Void
VAR_INPUT
NewString : STRING[20] ;
END_VAR
VAR_TEMP
MyString2:STRING[20]; 
MyString : STRING[20] ;
END_VAR
VAR_OUTPUT
Result : BOOL ; 
END_VAR
MyString := 'hello' ; 
MyString2:=NewString;
Result := FALSE ; 
IF MyString2 = MyString THEN 
Result := TRUE ; 
END_IF ;
;
END_FUNCTION
 

Similar Topics

I´m programming in SCL using the PLCsim simulator When I debug for instance integer variables, I can see their value in the right window. But...
Replies
10
Views
5,903
Hello, When you want compare values of an array to a range of numbers is it a right way to do that? FUNCTION ADD VAR_IN_OUT A:ARRAY[1..50]...
Replies
5
Views
2,076
Hi All, I need to try and convert some code from Siemens SCL (TIA16) over to Allen Bradley RS5000. I have attached an image of the SCL and what...
Replies
10
Views
4,062
in the scl code written in screenshot Line 1 condition is false but still the program checking the line 2 condition and says it is true i had...
Replies
3
Views
1,763
I am new to PLC programming. Is there a standard way to incorporate alarms / warnings / events such as the exceptions in C++ or Java where you can...
Replies
5
Views
1,989
Back
Top Bottom