Writing to text file help

crimnsonfox's picture

Hey, I'm rather new to Quartz Composer and amateur programmer I was wondering if anybody could help me with the programing problem I am having. Anyway the problem I'm having is writing to a text file without overwriting the string sent to it. It's probably a real simple solution I'm just a bit of a novice when it comes to programming. Anyway here is the patch I'm working on. Any help is greatly appreciated.

PreviewAttachmentSize
testwrite1.qtz5.37 KB

dust's picture
Re: Writing to text file help

Garret,

The text writer file will continually overwrite the contents each time you write to unless you change the name or directory of the text file your saving with each time stamp.

So I suggest a structure 2 file instead of writing to text. I added a structure to file in your patch. You will need kineme structure tools for this to work. Its pretty simple, I added a watcher which is watching to see if the players name changes, you could watch the index of the players name as well. So what this does is trigger a Queue to fill with your time stamp and also write that stamp to file. I also included how to read the structure file from disk. You do not need to do this as you can read back in memory from the queue but if you want to save high scores or what have you you will want to use a file to save that info to be called later.

PreviewAttachmentSize
testwriteV2.qtz25.38 KB

crimnsonfox's picture
Re: Writing to text file help

The file you sent me works when signaling to write with my patch, however a .plist file doesn't seem to appear anywhere on my desktop or my computer.

dust's picture
Re: Writing to text file help

how are you signaling to write the patch. all you should have to do is change your players index as it writes the file when there is a change. so if you do not select a player then it will not write, also it will not write from the start as there has been no state change so what you will need to do is change the players multi-plexor index to 0 from 7 this triggers the change and starts the write. to test just run through all the indexes starting from 0 to 7 tom should end up first and tammy as last index. if that doesn't work then using ~/Desktop/TimeRun.plist isn't working on your computer so change the name of the path to write to something like this

/Users/Crimmson/Desktop/TimeRun.plist

where Crimson is your user directory or user name etc...

let me know if that works. the principles are there you might want to use something else than the watcher as the watcher requires a state change. so if a user selects the same player twice then there will be no state change. what i would do is make two file structure writers so you can calculate the delta. for instance write one file of start times and one file for end time so an overall time calculation can be made. it would be easiest to stamp the time in seconds rather than using the time date formatter.

crimnsonfox's picture
Re: Writing to text file help

I signal the write patch by sending a value to the when the game the game over screen. The write signal definitely gets the signal, but some just doesn't write. Maybe it needs to get a longer signal? One thing I did I notice however it will create the file when i reset the queue. I did change the directory and it seemed to write on my desktop with I wonder, but like i said before only works when i reset the queue. If you want i can send my patch to you for you to look at.

dust's picture
Re: Writing to text file help

yeah upload it because hitting reset on the queue just clears the structure.

crimnsonfox's picture
Re: Writing to text file help

I sent you the patch via email (FC). If you need the images and stuff I can send you an archived form of it.

crimnsonfox's picture
Re: Writing to text file help

I wonder if its something with the queue because i seperated the string and it would write to the structure without the queue, but once i added the queue it wouldn't create a new file. here is a modified one i did

PreviewAttachmentSize
testwriteV2.qtz48.11 KB

jrs's picture
Re: Writing to text file help

Hi Guys,

I can't seem to load either of these examples as I get the following error

"QCStringTimecode at "Macro Patch/String Timecode" [StringTimecode_2]"

After doing some searching I think that QCStringTimecode is a private patch - I tried running the command line option (for leopard) but that doesn't work presumably as i'm on snow leopard.

How did you get the private patches enabled? I have kineme core 0.5.2

Cheers - James