# Monitoring current line of scipt the robot is executing

**URL:** <https://forum.universal-robots.com/t/monitoring-current-line-of-scipt-the-robot-is-executing/31247>\
**Category:** URScript\
**Created:** [November 6, 2023, 8:38pm UTC](https://forum.universal-robots.com/t/monitoring-current-line-of-scipt-the-robot-is-executing/31247 "2023-11-06T20:38:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kentamatuda](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kentamatuda](https://forum.universal-robots.com/u/kentamatuda)\
**Post date:** [November 6, 2023, 8:38pm UTC](https://forum.universal-robots.com/t/monitoring-current-line-of-scipt-the-robot-is-executing/31247/1 "2023-11-06T20:38:07Z")

</div>

I just started working with the robot recently so apology if this is a dumb question. I typically use the script node to program the robots’ movements instead of using the pendant through waypoints. I wondering if there are any ways to track/view which line of the script the robot is executing (ie. which “movel” values) to keep track of the robot’s movements. Is there a way to do this through a variable or any other way? Any suggestions are greatly appreciated. My typical script would look something like below:

def Program():  
toolTcp = p[0, 0, 0, 0, 0, 1.5708]  
toolWeight = 0  
toolCog = [0, 0, 0]  
Speed000 = 0.08  
Speed001 = 0.08  
Zone000 = 0.001  
Zone001 = 0.01  
set\_tcp(toolTcp)  
set\_payload(toolWeight, toolCog)  
movej([1.5708, -0.8727, -2.0944, -1.5708, 1.6057, 3.1416], a=3.1416, v=0.2513, r=Zone000)  
popup(“Moved to home position press CONTINUE to start the program”, “StartConfirmation”,warning=False,error=False,blocking=True)  
movel(p[-0.12965, 0.6096, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.19262, 0.60576, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.25439, 0.59303, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.31308, 0.57, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.36665, 0.53675, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.41422, 0.49532, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.45701, 0.44892, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.49823, 0.4011, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.54279, 0.35645, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.59614, 0.32321, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
movel(p[-0.65779, 0.31157, 0, -2.22144, 2.22144, 0], a=1, v=Speed001, r=Zone001)  
end

---

<div class="post-metadata">

**Author:** ![robin\_gdwl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/robin_gdwl/32/2676_2.png) [@robin\_gdwl](https://forum.universal-robots.com/u/robin_gdwl)\
**Post date:** [November 7, 2023, 7:47am UTC](https://forum.universal-robots.com/t/monitoring-current-line-of-scipt-the-robot-is-executing/31247/2 "2023-11-07T07:47:00Z")

</div>

Not sure if there are better ways but the easiest would probably be the way you described, by simply incrementing a variable after each waypoint (`wp_index = wp_index + 1`)  
You can then either look at the variable section to check the current value or use the textmsg() function to print it to the log.

---

<div class="post-metadata">

**Author:** ![kentamatuda](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kentamatuda](https://forum.universal-robots.com/u/kentamatuda)\
**Post date:** [November 7, 2023, 7:07pm UTC](https://forum.universal-robots.com/t/monitoring-current-line-of-scipt-the-robot-is-executing/31247/3 "2023-11-07T19:07:39Z")

</div>

Thank you for your response. The only drawback to this is that it’ll require this line of code (`wp_index = wp_index + 1` ) after each line of code which essentially doubles the number of lines of code the program has unless I’m missing something… Any idea how I may be able to avoid this?

---

<div class="post-metadata">

**Author:** ![robin\_gdwl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/robin_gdwl/32/2676_2.png) [@robin\_gdwl](https://forum.universal-robots.com/u/robin_gdwl)\
**Post date:** [November 8, 2023, 12:55pm UTC](https://forum.universal-robots.com/t/monitoring-current-line-of-scipt-the-robot-is-executing/31247/4 "2023-11-08T12:55:40Z")

</div>

How long is your program and how are you sending it to the robot?  
Doubling the number of lines should not be a big problem if your program has less than 10000 lines.
