CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Thu Apr 27, 2017 7:50 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Jun 08, 2007 12:30 am 
Offline

Joined: Tue Jun 05, 2007 11:10 pm
Posts: 2
Hi,

I'm new to IEC 61131-3 programming. Could someone clarify what the assignment operator (":=") in ST does when working with strings.
E.g. myString := originalString;

I was assuming this does a full character by character copy of the string, but I know in some lanuages only a reference pointer is copied. Now I wonder if my assumption is incorrect since there is string copy function in the system string library - SysStrCpy() in SysLibStr.lib.

I've had some strange bugs happening ever since I started using strings and SFC (SFCCurrentStep in particular) and want to make sure I am using strings correctly.

Any feeback on STRING usage is appreciated.

Sebastian Hutten


Top
   
 Post subject:
PostPosted: Sat Jun 09, 2007 10:22 am 
Offline
Site Admin

Joined: Wed Jul 20, 2005 2:32 pm
Posts: 153
Hi

You are right. ':=' is a full character by character copy. (Certainly you may get a pointer to string see. ADR operator). Moreover you can use '=','>','<' in ST (but not '+', use CONCAT function). For example:

IF s2 = 'Shutten' THEN
s1 := CONCAT('Hello Mr.', s2);
END_IF

I advice you to use string functions from Standard.lib (LEN, LEFT, FIND etc. see 'String functions' in the manual) instead SysLibs…. (platform dependent).

One limitation: do not use the same string functions in different tasks.

_________________
_IP_


Top
   
PostPosted: Wed Mar 01, 2017 4:29 pm 
Offline

Joined: Tue Apr 21, 2009 2:20 pm
Posts: 3
Hi, its a very old topic but still valid. I have a question regarding the statement
Quote:
do not use the same string functions in different tasks

I already found that recommendation or hint, that STRING functions from the standard library are not programmed to be reentrant.
Okay, usually its clear. But can you tell me why?
If I need STRING functions in POUs outsourced in libraries, do have to avoid the usage oif the functions from this Standard lib!?
Which should I use else?

Thank you for your support.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited