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.