CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Fri Oct 18, 2019 12:53 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Coding Best Practices
PostPosted: Thu Mar 28, 2019 2:43 pm 
Offline

Joined: Wed Mar 27, 2019 4:19 pm
Posts: 17
I am working on an existing project. This project has a number of function calls with the format:

String3 := CONCAT(STR1 := String1, STR2 := String2);

This works properly. My preference would be:

String3 := CONCAT(String1, String2);

This also works. Is there a mention in any coding style documentation that suggests one style or the other?

Could there be a performance difference between the two?

First Style
CPU Step 1: Assign STR1 the value of String1
CPU Step 2: Assign STR2 the value of String2
CPU Step 3: Call CONCAT with STR1 and STR2
VS.
CPU STEP 1: CALL CONCAT with String1 and String2

_________________
Thomas Stevic
Honeywell Intelligrated | Safety and Productivity Solutions


Top
   
PostPosted: Thu Mar 28, 2019 3:45 pm 
Offline

Joined: Fri Mar 10, 2017 4:45 am
Posts: 44
As far as performance goes, there doesn't seem to be a difference:
Attachment:
Capture.PNG


As for style, I agree with you, that CONCAT(String1, String2) is more readable, but on more complex functions where the inputs might not be as intuitive, I'll use the names.


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Mar 29, 2019 5:49 am 
Offline

Joined: Mon Oct 01, 2012 8:33 am
Posts: 53
Adding to what TVM said, for large function calls it's common to list parameters on separate lines as shown below. Also note the different notation for input and output parameters.
Code:
   Result := SomeFunction(
      Input_01 := in01,         // Input parameters
      Input_02 := in02,
      Input_03 := in03,
         "        "
      Input_99 := in99,
      Output_01 => out01,      // Output parameters
      Output_02 => out02,
   );


Top
   
PostPosted: Mon Apr 01, 2019 12:06 pm 
Offline

Joined: Wed Mar 27, 2019 4:19 pm
Posts: 17
rickj wrote:
Adding to what TVM said, for large function calls it's common to list parameters on separate lines as shown below. Also note the different notation for input and output parameters.
Code:
   Result := SomeFunction(
      Input_01 := in01,         // Input parameters
      Input_02 := in02,
      Input_03 := in03,
         "        "
      Input_99 := in99,
      Output_01 => out01,      // Output parameters
      Output_02 => out02,
   );

_________________
Thomas Stevic
Honeywell Intelligrated | Safety and Productivity Solutions


Top
   
PostPosted: Mon Apr 01, 2019 12:08 pm 
Offline

Joined: Wed Mar 27, 2019 4:19 pm
Posts: 17
Thank You!

_________________
Thomas Stevic
Honeywell Intelligrated | Safety and Productivity Solutions


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

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 6 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