"Object not callable error" on a project script

I am sure I am missing something in the path or something stupid but -

doing some testing with project script using an event script on a button. I keep getting the error below.

not callable pdf.pdf (116.9 KB)

In the future, post your screenshots and script using preformatted text directly to the forum rather than in a PDF.

Your'e trying to call the script file directly, but you should be calling a function inside the script file.

Thanks for the reply, I do appreciate it.

Can you provide or direct me to examples of either of the items in your reply? pre-formatted text or the calling the function bit?

Thanks in advance.

The pre-formatted text option looks like this: </> in the toolbar when you're typing your message.

For scripting, refer to this video in Inductive University. I recommend going through all the videos to learn how to do all the various things you'll do in Ignition. While the videos only teach the basics, it should help with your issue.

I have watched this video. Just watched again since you recommended, I mean, what kind of jerk would ask for help and then not do what someone recommended, am I right?

Whatever I am doing wrong was not clear to me.

Thanks, again.

The script file you created is called Sandbox.printToCon but inside that file there's going to be a function starting with def. I don't know what it's called because it's not in your PDF, but let's just assume it's named printInfo, so your script call should be Sandbox.printToCon.printInfo('hello world')

Edit: To direclty corelate your script to what the video shows, in the video they don't have a package and just a script file named message which is the equivalent to your Sandbox.printToCon. Their sayHello function is what you're missing or not showing.


```yes im with you. Sorry, I had thought my script was in the upload. I did have a function defined there. I have edited it all so it makes more sense:

def printToCon(x):
      print x
Sandbox.print.printToCon('hello world")
The error is now gone but nothing is actually printing to the console. 

That was as big step forward though. I knew I was leaving something out of the path. Too close to the forrest, sort of thing.

If your script is still named printToCon, your function call would be:

Sandbox.printToCon.printToCon('hello world')

Hi, Sean.
You're now formatting everything as code. Have a look at Wiki - how to post code on this forum.

I changed the second part to "print" to aid in trouble shooting. Looks clearer now. I had forgotten that you can have multiple functions in each packet of scripts in each module so when I had the same name it was, indeed, confusing me.

that was just an accident man. Thanks.

while we are on the subject on how to - is there a wiki about posting pictures the appropriate way?

Works like a champ in Vision. I must be doing something dim in perspective. I will dive into that.

Cheers.

Just to close the loop on this for anyone else that comes along. I created a new function in Sandbox.print:

def printToConPerspective(x):
       
      system.perspective.print(x)

Then just called that one in the button on the perspective view and it worked enough.

One more "Thanks!" for the help.