Shift an Array of Strings

CoderByNature

Member
Join Date
Jun 2023
Location
Canada
Posts
5
Hey all, was wondering if it was possible to shift values in an array of strings?

I have a database that I am loading up with "Users" in the form of strings, String[64], my dilemma comes when I am attempting to delete the user from the database.

What I would love to do is take the found position of the data I want to delete and then copy the entire array from below that value up 1. So if I found the User data I want to delete at Userdata[8], then shift values Userdata[9]-[63] to Userdata[8]-[62] and write 0 in value Userdata[63].

So far I have tried COP(UserData[FSC_User.POS+1]) to UserData[FSC_User.POS] with length of (63 - FSC_User.POS) and an FAL command with the same logic. Neither have worked o_O

Just wondering if this is possible or if there is a better way to do it

Thanks in advance for any guidance here
 
You can't use an indirect address for an indirect address.

Move your FSC_User.POS tag into a DINT tag. Use that DINT tag for your indirect address.

MOV FSC_USER.POS FSC_POSITION. ADD FSC_POSITION 1 FSC_POSITION1

Same with the Length. Create a LENGTH tag. Do the math separately and put value in LENGTH Tag.

SUB 63 FSC_USER.POS LENGTH

Then do the copy.
COP(UserData[FSC_POSITION1]) to UserData[FSC_POSITION] LENGTH
 
Neither have worked

What do you mean by that?
That it wouldn't compile, or that that the data didn't shift as you expected?

If the former, or if you reset FSC control word before executing the COP, you may need to put some local junk DINTs to calculate the positions and length prior to the COP.

This will also make debugging easier, as you can control the values in those registers to observe the change you expect.
 

Similar Topics

I'm still a little remedial with my Step 7 classic knowledge. I'm working on in Simatic Manager 5.5, SP4, and I need a little insight of how to...
Replies
10
Views
2,746
I have searched quite a bit, but I'm struggling to figure this one out. Any assistance would be greatly appreciated. The COP and MOV instructions...
Replies
6
Views
2,048
Hello all, I find myself writing some new logic and I am storing records of analog values so that it will be possible to look back on them and...
Replies
7
Views
3,186
Trying to put together an array to do the following Dial has 8 positions Each position can have a status of 0,1 or 2. 0-not present 1-OK 2-Not...
Replies
8
Views
2,801
I've got a Powerflex 700 that doesn't like to get going in the mornings. This motor will run anywhere from 30 seconds to 5 minutes before it just...
Replies
3
Views
175
Back
Top Bottom