Universal Robots Forum

FunctionModel - Using Variables

Hello,

When using the function model, adding functions I understand how to add variables to the function, but how do I use that variable in write script?

Function in function drop down with variables image

For example I am creating a function that uses an IP address, I add the function with the address variable and write this in the generateScript section.
image

In runtime I get an error, it seems like it doesn’t recongize p1 variable (which is the address). What am I doing wrong?

Have you defined/instantiate your variable p1 anywhere?

I am using the FunctionModel example to help out, it does this.
image
When the function is called p1 is given a value, do I have to define this else where?

No, sorry I thought you were using it in another context. Anyway, if you follow this sample there should not be any problem. Could you show the error that you are getting?

1 Like

I just figured it out. Was missing a bracket at the end of a long array variable. I thought it had something to do with that p1 variable from this error message

but the error was caused by the line above the highlighted because it was missing a bracket at the end. :man_facepalming:

1 Like