There is not an explicit jump command, no. You can, however, put everything from line 76 on in a loop, and loop while restart == True instead. Then any code after this loop would only execute when restart == False. This should accomplish what you’re looking for.
As for adding to the count, if I’m understanding you right, all you have to do is just use an Assignment node and say var = var + 1. Logically, it sounds like you’re asking if(True OR False) which is ALWAYS true. Therefore you don’t need to make it a conditional at all, just increment the variable on its own line all the time.
Well. I guess it’s also a bit unpractical given that it looks at line numbers and not actual labels. So if a new node is inserted in the beginning of a program, you’d have to shift all your labels.
Woah, I’ve been looking into how to achieve something similar to a Jump to label on the UR. Can you share some more on this. what does the actual script look like to achieve this?
I mean you’re looking at it. That’s the whole script. It just jumps you to that line number. As efn points out, it’s not super great, since anything that changes your line numbering will in turn change where the jump instruction goes to. I spent a little time a while ago trying to guess my way into a hidden “label” instruction but didn’t find one.
Awesome, thanks for the information! That gives me a few options to try out. Still mind-blowing how UR is the only Robot Manufacturer I’ve dealt with without a jump/label command. I get why to some degree for simple applications, but for more complicated applications where you need to add in a check/retry/additional process based off certain conditions (especially after a deployment) it can become frustrating having to restructure the entire program to make it functional. It is what it is. Thanks Again!
Hey all, sorry to resurrect an old thread again, but it just occurred to me to try this and I’m super excited to see how this might screw me over later, but you can 100% use this jump_to_label() effectively, you just have to pair it with a label definition
URScript designates a label with a $, number, text. So if you insert a script line that follows that pattern, you can define your own label and then jump to it. In my example here I went ahead and chose 90,001 figuring that a decent schema for custom label would be something starting in 90,000, since I hope to God I don’t ever have 90,000 lines in a real program. You would not want to use any number small enough that Polyscope would be automatically assigning that label as a line number, otherwise you’ll get a duplicate label error. The obvious benefit here is that the line number we are jumping to will NOT change based on where it’s at in the Polyscope program! I have only tested and proven that this WORKS, not that there are potential issues with it. Would love someone from UR to chime in on any dangers here, but otherwise this seems like a fantastic tool to add to the tool belt.
That’s amazing. Thank you for sharing your find with us, Eric!
I really wonder why UR has not shared this function with the public … Maybe it’ll mess the execution up if you jump into a thread or subprogram directly, but I can’t see any other potential risks as long as you know what you’re doing.
I’ve been using this functionality for several months now and it hasn’t caused me any issues (within a single main program).
There’s just one feature I’m missing, which is available directly in PolyScope - reading the current label so that the program can return to the instruction where execution was interrupted.
I managed to work around this by reading the currently executed script line and matching it with the label assigned to that line, but maybe someone has found a variable or a get-function that allows reading the current label directly?