Universal Robots+

Saving a value permanently, not in the DataModel

Hi.

When I create a new instalation, everything goes to the default values on the datamodel… natural and usefull in most scenarios. But I want to store a value that remains unchanged between instalation files or even if I upgrade the URCap to a newer version…

Should I go for the write to/read from a file technique?? or is there another method to achieve this??

Hello,

there are next to the datamodel also other ways to store data. See the following post for more details:

I have succesfully readed content of a .txt file from an “activation” folder inside the URcap files folder with this Code:

String lineReaded = “”;
java.net.URL fileURL = getClass().getResource("/<Folder inside “resources”>/FileToStore.txt");
InputStreamReader inputReader = new InputStreamReader(getClass().getResouceAsStream(fileURL.getPath()));
BufferedReader reader = new BufferedReader (inputReader);
try{
lineReaded = reader.readLine();
//and so on, for loop or whatever
reader.close();
}catch (IOException e){
e.printStackTrace();
}

Is based in what I found here:
https://forum.universal-robots.com/t/loading-script-file-from-the-resources-folder/3391

But Im completly lost on Writing to that file. I readed all related topics in the forum(some resources has broken links) and googling for 12+ hours and maked 30+ test builds and nothing… Could someone share with me a code to put a “HelloWorld” into an existent .txt file???

@artiminds @SonglinCai @dozminkowski @jbm

… sorry to bother.