# Atomic operation or not (RW 6.15.08)

**URL:** <https://tech-community.robotics.abb.com/t/atomic-operation-or-not-rw-6-15-08/12012>\
**Category:** RAPID Programming\
**Tags:** error, rapid-code\
**Created:** [August 26, 2025, 1:11pm UTC](https://tech-community.robotics.abb.com/t/atomic-operation-or-not-rw-6-15-08/12012 "2025-08-26T13:11:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RH\_Saar](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@RH\_Saar](https://tech-community.robotics.abb.com/u/RH_Saar)\
**Post date:** [August 26, 2025, 1:11pm UTC](https://tech-community.robotics.abb.com/t/atomic-operation-or-not-rw-6-15-08/12012/1 "2025-08-26T13:11:15Z")

</div>

Hi. I have these lines in code and once per week or just random i have error out of bounds so that means there is 0 in array position. That should not be, because I always write number 1,2,3 or 4. There are 4 trolleys.  
STATIONS{2}.TrolleyNR could be zero if there are no trolley in this station, but is updated when trolley is in transit in next code preview

“STATIONS{1}.TrolleyInTransitNR” / next lines are run only when TrolleyInTransitNR is not 0

10/ STATIONS{2}.TrolleyNR:=STATIONS{1}.TrolleyInTransitNR;  
20/ Trolleys{STATIONS{2}.TrolleyNR}.AtStationNr:=2;  
30/ STATIONS{2}.PartsLoaded:=AnyPartsLoaded(STATIONS{2}.TrolleyNR);

So error happen in line 20 or in function AnyPartsLoaded() because sometimes it tries to access 0 position in array (STATIONS{2}.TrolleyNR is resolved as 0, because is not yet updated from line 10)

I modified the code now to store this value in separate variable and wait if some errors happen again. But i am curious if operation at line 10 is atomic or not.

Stations ad Trolleys are:

PERS Trolley Trolleys{4}:=[[5,17311,FALSE,809468712,809468729,809468747,809468764,809468781],[4,17311,TRUE,809468814,809468831,809468848,809468866,809468883],[3,17311,TRUE,809468932,809468949,809468966,809468984,809469001],[2,17311,TRUE,0,0,0,0,0]];

PERS Station STATIONS{6};

Can be a problem, that PERS Station STATIONS{6} is not declared with values, so values are on memory only, but not shown in code? I can update code to show actual value in code too, but it works well without values:

PERS Station STATIONS{6}:=[[1,3,0,TRUE,TRUE],[0,2,0,TRUE,FALSE],[5,0,1,TRUE,FALSE],[0,0,0,TRUE,FALSE],[1,4,0,TRUE,TRUE],[0,0,3,TRUE,FALSE]];
