Thank you for the reference, unfortunately most went well over my head. Problem ended up being in the oddest place. Why does ignition “molest” contents of tags of Data Type “String”? I ran into saving a time stamp to a string tag end up with that value jumbled enough that, later, it couldn’t be ‘coerced’/recognized as a date.
Set up a memory tag of Data Type “string” named {[default]string_memory_tag} and then run this:
time_now = system.date.now()
system.tag.write("[default]string_memory_tag", time_now )
print "==="
saved = system.tag.read("[default]string_memory_tag")
print "now = %s \nsaved = %s" % (time_now,saved.value)
#duration = system.date.minutesBetween(time_now,saved.value)
#print "difference = %s" % (duration)
script console prints the following:
>>>
2
===
now = Fri Oct 05 14:44:25 EDT 2018
saved = 2018-10-05 14:44:25
>>>
I’ve never used a language before where strings saved to a string variable/tag get rearranged like this behind the scenes!!
I’ve since ‘discovered’ that tag can’t be a type “String” but must be “Date”. Change “string_memory_tag” tag to Data Type “Date” and uncomment the last 2 lines and run it again. It now prints:
>>>
2
===
now = Fri Oct 05 14:37:37 EDT 2018
saved = Fri Oct 05 14:37:37 EDT 2018
difference = 0
>>>
BTW, can someone tell me why system.tag.write() emits a “2” to the script console output?
Thank you.
P.S. sorry for posting replies under someone else’s question instead of my question. I also didn’t know I could edit posts.