Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
agmark
Visitor

WriteAsciiFile

For testing purposes, I'd like to write and read from a tmp file. Seems simple enough, but I'm having trouble with a type mismatch. I'm using the following code:

tempfile = "tmp:/temp.txt"

success = WriteAsciiFile(tempfile, dtInSeconds)
print success ' this is true
text=ReadAsciiFile(tempfile)
print text


dtInSeconds is just a file creation date converted to seconds, so it's an integer. The string I'm converting to seconds is in this format: 2011-12-11 06:47:42.000
I'm sure it's something simple, but everything I've tried seems to fail.

On a related note, is the following ISO8601 format still not supported by Roku? 2011-12-11T06:47:42.000Z I'm stripping the T and Z out so it's no big deal but shouldn't it be fixed if it hasn't already?
TIA!
0 Kudos
3 REPLIES 3
MazeWizzard
Visitor

Re: WriteAsciiFile

Since you're writing a text file (in ASCII) maybe you should make it a string rather than in integer. Then, it won't type mismatch (that 2nd parameter to WriteAsciiFile is a string). Try the Stri(intVarNameWhateverItIs) to make it a string, or take the substring of the original date-time string.

Also, FYI... I'm assuming you've seen the roDateTime info in the component reference (Although that's not your type mismatch issue)
0 Kudos
belltown
Roku Guru

Re: WriteAsciiFile

success = WriteAsciiFile(tempfile, dtInSeconds.ToStr ())
0 Kudos
agmark
Visitor

Re: WriteAsciiFile

Thanks guys. I believe that did it. I tried using strtoi() and then realized I was bassackwards and decided to have a beer instead.

Yes, I've looked over the roDateTime component as well as searched the board for any discussion. At one point the roDateTime didn't support all formats (and it sounds like it still doesn't). I never saw a thread that indicated that it has been fixed to support other formats. It does indicate that the "T" is supported but doesn't mention the "Z". I've stripped both out so that's not an issue, but I'm just curious if it's been addressed. I'll try the full original format with T and Z sometime just to see.

Mark
0 Kudos