Siemens SCL CONCAT (FC2)

cjd1965

Lifetime Supporting Member
Join Date
Apr 2007
Location
UK
Posts
1,659
Hi
I am trying to crate a function that needs to join strings together but it wont comile. complaining about the CONCAT code, Illegal parameter assignment

Code:
FUNCTION FC99 : VOID
VAR_TEMP
    Day_str: STRING[3];
    Day:INT;
END_VAR
VAR_OUTPUT
DateString : STRING[20] ;
END_VAR

BEGIN
//// assign some test data
Day_str:='' ; DateString :=''; Day := 5 ;
DateString := CONCAT(IN1:= INT_TO_STRING(Day) ,IN2:='/');
END_FUNCTION
 
You cannot assign the output of the concat function to the output of the FC - use a temp and then assign that:

Code:
FUNCTION FC99 : VOID
VAR_TEMP
    Day_str: STRING[3];
    Day:INT;
    DateString:STRING[20];
END_VAR
VAR_OUTPUT
DateStringO : STRING[20] ;
END_VAR

BEGIN
//// assign some test data
Day_str:='' ; DateString :=''; Day := 5 ;
DateString := CONCAT(IN1:= INT_TO_STRING(Day) ,IN2:='/');
DateStringo:=DateString;
END_FUNCTION
 
Random Bump, Great clue, Thanks!

Trivia: It seems that you cannot use inputs on string functions either. Those have to be moved to temp too.
 
The big experience that i have with strings in step7 is that the integrated STRING functions are very limited. I prefer to write my own STRING functions, then Im 100% sure that nothing can go wrong.

The logic is easy, the first bytes in a string defines the maximum number of character the string can contain, and the second byte defines the actual number of characters it contains. The rest of the string are the characters, each character is 1 byte, and if you google "ASCII table" you can see which dec or hex number the character is associated with.

Easy Example:

IN: String1[12] = 14 BYTE, startadress = DIX0.0 for example.
OUT: String2[12]

If I want to move the first 3 characters in 'String1' to the last 3 characters in 'String2' I can easilly write,

L String1[1]
T String2[10]

L String1[2]
T String2[11]

L String1[3]
T String2[12]

I you need to use some complex rearrangements, you can use an instance as a buffer. And more likely use the pointer functionality (AR1 and AR2).
 
Last edited:

Similar Topics

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,067
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,051
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,752
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,962
Hello All, I am new to programming with Tia Portal and I am having difficulty with something that we have found "easy" in other programming...
Replies
3
Views
2,376
Back
Top Bottom