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 Dec 06, 2019 1:43 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
 Post subject: .append in ST
PostPosted: Tue Mar 28, 2017 1:15 pm 
Offline
User avatar

Joined: Wed May 04, 2016 2:43 pm
Posts: 23
Hi everyone,
I'm trying to do a small programm which send a sms each time that an alarm occur (with some exception for criticical alarm)
So this is my idea
First: I Browse my array where the alarm can occur with a for loop, if a or some alarms have occured, I'd like to stock the number of these inside an array
So this is why I'd like to have an .append function
Once I would have this new array, I just have to give it to my function block to send the sms in FIFO

So someone knows how could I use a similar function than append in ST?

Many thanks in advance


Top
   
 Post subject: Re: .append in ST
PostPosted: Tue Mar 28, 2017 1:38 pm 
Offline

Joined: Thu Oct 13, 2016 4:19 pm
Posts: 48
Location: Presezzo, Bergamo (ITA)
With .append you mean a dynamic array? If so you can't, codesys does not manage dynamic arrays.
With static arrays you can simply use a global variable as index and update it whenever you need.


Top
   
 Post subject: Re: .append in ST
PostPosted: Wed Mar 29, 2017 8:12 am 
Offline

Joined: Sat Jan 02, 2010 2:05 pm
Posts: 97
In Codesys 3, using __NEW, __DELETE and some pointers you could create a linked list (or a double linked list).

In TwinCAT you have FB_LinkedListCtrl (that creates the linked list automatically for you, but the linked list implementation is easy and you need only the aforementioned instructions).

Dynamic arrays are not an option in Codesys...

Hope this helps.

_________________
http://www.robotecnik.com - robots, CNC and PLC programming.


Top
   
 Post subject: Re: .append in ST
PostPosted: Wed Mar 29, 2017 10:56 am 
Offline
Frequent User
Frequent User

Joined: Fri Sep 02, 2011 8:02 pm
Posts: 309
A simple solution: define a large byte array or large string of 5000 chars (you probably have lots of RAM space on your target) and just byte copy and keep track of the number of bytes.

Then you do not need to worry about dynamic memory allocation, trash collection, etc.

_________________
Scott Cunningham
KEB America, Inc.
www.kebblog.com
www.kebamerica.com


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

All times are UTC+01:00


Who is online

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