Looping char Array in STL

gedajus

Member
Join Date
May 2012
Location
Kaunas
Posts
3
Hello, I'm new in PLC programming so I need a little help...
I have an array of char (ARRAY[0..2047] of CHAR) in DataBlock and I need to scan that array for specific character or character combination... And i need to get adress of the result.

Ex: Find the adress of the first char 'b' in the array (of random data). And find the adress of the char 'o' followed by char 'z'...

Something like that.

My try:

In OB1 i have:

CALL "Func"
UID:="Block1".array1

in FC1 i have (from some example):
(UID is type ANY)

TAR1 #_ar1
L P##UID
LAR1
L W [AR1,P#0.0]
T #_wPLC_Type
L W [AR1,P#2.0]
T #_iLen
L W [AR1,P#4.0]
T #_iDB
L D [AR1,P#6.0]
AD DW#16#FFFFFF
SRD 3
T #_dwArea

from this i get data type, length of the data, DB number, and start adress.. And then what? :)

Is there a simple way to loop the array with like: L DB1.array1[n] where n is variable (like in C++, C#, pascal, etc..?). And not using pointers (which I'm not yet familiar with)
 
Last edited:
A different approach would be to copy the chars to a string variable and then use the IEC library functions to find the string(s) you are searching for. Add the found location to the base address of your data to report back the address.

Abort the above as the max length of a string is 254 chars.
 
Last edited:

Similar Topics

Hi, I am new to ladder logic. I have completed a code in the Xinje PLC XC3-32RT-E for one of the machines I am developing. Currently the program...
Replies
30
Views
1,042
Hello, I am programming a ladder routine that finds a part on a conveyor that has a given part number. I am having no problem finding the part and...
Replies
1
Views
1,911
I've got several ListBoxes that I want to perform the same function on. From my searches, you can accomplish this in VBA by using a FOR loop, but...
Replies
4
Views
2,901
Hello everyone, I am new to ladder logic and am currently working on a small project where I might need some help. So I am modifying the sequence...
Replies
9
Views
2,447
Hello, This is my very first post here - I'm working on a small brewery project with multiple solenoid valves. The instructions follow a set of...
Replies
2
Views
1,751
Back
Top Bottom