I think I’ve run into this before, but can’t remember for sure whether I solved it by adding or removing end statements . . (or did something else).
I’m getting a syntax error when running my program, and the error message shows the very end of the UR-created script file for the program, highlighting the final end statement.
The end of the program is a thread created with a Polyscope node, and the end statements balance out within that, so I’m assuming I have an extra end statement in one of the several scripts I’ve created.
I believe that if statements with a single line following don’t require an end statement, but I add them in because I think I remember running into a problem a while back which was solved with adding an end statement at the end of an if.
My next step is to start going through my scripts & commenting out an end statement here and there to see what happens, but I was wondering if anyone knows the absolute rules.
Will the Polyscope - created .script file for the program show correct indentation which might give me a clue, or will it just follow whatever indentation I used in my original script?
OK, found that I was missing an end statement after an if, in a function definition way up in the script - looks like first pass, the system just counts ifs, whiles, etc. and tries to match them with ends - if they don’t match it, apparently just throws the error at the end of the program.
A couple side notes - this was a section of code that I had ChatGPT create, while I was trying to decide if it could be helpful for writing scripts.
My conclusion is that ChatGPT can help with some logic, and possibly to do some error checking (probably would have found the spelling error I made in one of the variables), but it really isn’t aware of the limitations of URScript, so it generates code in (I assume) python.
This means that it uses lots of functions and syntax that don’t work in URScript.
If I know where it’s wrong, and tell it, for example, that it has to use While loops rather than For . . . Next, it will do that, but you have to be able to find the differences and have it rewrite the program.
My take on why ChatGPT doesn’t write good code in URScript is because opening an account requires to agree to their terms and conditions, which happens to have something around the lines of “all interaction with ChatGPT can be used for training the AI”.
This means all code you share or used by ChatGPT generation can break the confidentiality agreement between a programmer and their employer.
Thus, most of URScript code that has been used to train ChatGPT are basic examples (here why my example is from a manual) or open source code that is maintained by collaborators. This is very likely to be a small majority of users, and probably most of the source code developed by advanced users is not available online.
I would suggest you to reconsider using ChatGPT and look into other options if you plan to use AI generated code at work.
I think that so far, the things I have asked it to do have been generic enough that we wouldn’t worry too much about confidentiality - we’re an internal integrator, so our customers are either our own division or sister divisions, so we have a fair amount of leeway.
However, it will be good to keep in mind to keep things fairly generic and be careful with what info is included in any comments, etc.
I have heard good things from Microsoft Copilot Enterprise. Apparently it is possible for a company to allocate all related-files and AI interaction in a local server, so the Copilot AI from Microsoft gets deployed and executes from there. I have also heard the code generated is pretty good and less buggy compared to Chat GPT.
@cags , thanks for the quick reply. it makes total sense, I personally used github copilot for other projects and I’d back up your statement regarding collecting info fro diff files and making code suggestions that are quite accurate. What i wonder is the following, since tomorrow I am starting the advanced course.
Can I create UR programs in VSCode? so I can leverage github copilot? what are the limitations? I am asking this because while reading the Script Manual i got to this post. it says UR can be control by Script Level. if you need me to create a new post, please let me know.
if you can hint me links where i can read more about that topic, happy to read documentation.
I am not surprised since Copilot was trained using code from GitHub, which belongs to Microsoft, and I would guess Microsoft tries to protect the code from being filtered to train AIs belonging to competitors, such as Chat GPT.
You can open and see .urp files in VSCode, but generating .urp files on your own is not recommended, since the XML format varies depending on the version and this documentation is not public. See here.
You can create a program that only runs a script. And then, edit and do everything through this script. There is a URScript extension for VSCode available.
I think on the Advanced Course they only cover the basics of URScript, since the goal is to go deeper in other areas. Once you are registered for the course, (in case the course provider has made them available) you can download the reference guide and workbook on PDF and see where this goes.