I am trying to make create a count for a given input and to display the number of times it has been activated onto a numeric label.
From my searching the problem online i have tried to understand using memory bits and the gateway tag scripting but i have not been successful and would greatly appreciate advice.
What type of input is it, and how do you know it’s been activated ? Do you need to keep the count on a per-session basis, or does it need to be global ?
Well then, make a session.custom property, let’s call it click_counter, set it to 0.
Then, in your button’s event, add an onActionPerformed script, and make it
self.session.custom.click_counter += 1
If you need it globally instead, use a memory integer tag instead of a property, and make your script be something like this (ignoring error handling for simplicity sake):
i tried to do this as i was having the same problem but i recieved an error telling me there was a problem with the scripting. I just want to display how many times a button has been pressed on an LED display
It seems you are copy/pasting code you don’t understand. self doesn’t exist everywhere in Ignition. Please show more of what you are trying. When pasting code here on the forum, be sure to the use the “pre-formatted text” button as others have mentioned.
I am in perspective and have applied the code to the button but am now confused as to how this data can be displayed. I apologize for my lack of understanding as this is a learning curve for me
Do you mean you moved to perspective? Perspective buttons have an ‘onActionPerformed’ event, not actionPerformed.
I’m not trying to evade your questions, but honestly in the long run you’re going to be better off struggling through this on your own. Learning a new system is as much about learning what doesn’t work as learning what does work.
I know you’ve been referred to Inductive University already, I can’t stress enough to start there. These things will be come clear.
Here is a link to the Perspective Component Overview video, watch it and the others in the lesson, I think it will clear things up for you.
Thanks for the link Lrose, I will keep watching the videos and hopefully pick something up along the way. I think trial and error might be the way to go
Probably an Indentation error. Make sure that the pasted code has the same indentation and is at least tabbed or spaced over. If you haven't looked into some basic Python tutorials, those will probably do you good as well.