I am trying to print date&time on a label every time I click on a button. I want the date&time to update only every time the button is being clicked,otherwise read the previous date&time that was printed. I have written this script: self.custom.timestamp == dateFormat(now(0),"MMM d, h:mm a")
,on the onClick event of the button, hoping to print the date in a custom parameter of the button (called timestamp), that I could then read from a different text label.
However it doesn’t seem to be working… any ideas?
Please format any scirpts/code using the preformatted text button
The problem is you are using Ignition’s expression language in a script. You can just set the label’s text value to the time directly. Also, you should use the onActionPerformed event instead of onClick
I believe that the project is updating the label’s value to what ever it is in the designer when you save it. Normally, I would say use client tags and bind them to the labels to make the data persist, but perspective doesn’t have client tags and I haven’t used perspective very much myself to know the best method for this.