Ignition python scripting help

I am attempting to test this system in order to determine if I am able to log information to a log file which I’d like to be a txt file.
I am eventually going to be using this as an event handler for scan information and time stamps but for the time being I am just using the even script and the script playground to input my code.

sandtype = ‘coarse’
target = ‘concenation?’
for i in range(5):
print (‘open seasame\n’)
print i
filename = system.file.saveFile(“C:\Users\AJ\MyDownloadedFile.txt”)
if filename != None:
system.file.writeFile(filename, ‘\r\nIT’S’ + ’ %s’ %(sandtype) + ’ ’ + target, 1)

This is the sample code i’ve written into the playground in order to see if I can log information.
It prompts me to save the file at every iteration of the for loop, I will need this to work without prompting me.
Additionally, when I put this code into a timer event script, it does not even create a file and I’m pretty sure there is something wrong with the code recognition by the software.
Is this something that can be done and how can I debug my code in Ignition?

OK, now my code looks like this:
sandtype = ‘coarse’
target = ‘concenation?’
for i in range(5):
print (‘open seasame\n’)
print i
filename = “c://Users//AJ//hotpotato.txt”
if filename != None:
system.file.writeFile(filename, ‘\r\nIT’S’ + ’ %s’ %(sandtype) + ’ ’ + target, 1)

now how to I make this as an event timer script in my application to keep repeating this code?

ok now my code kind of works, but now I am in a place where I will need to create a timestamp and save this into my file, but when I 'm using the code

timeStamp = datetime.datetime.today()
timeStamp = str(timeStamp)
print (timeStamp)

This seems to do nothing in jython.
How should this look?

Are you importing datetime? It should be:import datetime timeStamp = datetime.datetime.today() timeStamp = str(timeStamp) print (timeStamp)That prints out:2012-04-25 08:14:18.519999

I pretty much got it the way I wanted it by using this

from java.util import Date
sandtype = ‘number’
target = system.db.dateFormat(Date(), “yyyy-MM-dd HH:mm:ss”)
katty = 'plush ’
filename = “c://Users//AJ//hotpotato.txt”
system.file.writeFile(filename, '\r\nIT’S ’ + target, 1)
for i in range(5):
print (‘open seasame\n’)
print i
system.file.writeFile(filename, ’ WATCH ’ + sandtype + str(i), 1)
I think this is all I needed for now.
Thanks for your help in another thread :stuck_out_tongue: