How to convert the Date/Time to a string?
Hey, folks!
I'm using a Date/Time object that runs a stop watch to determine how long it takes a person to go through my project.
I have set up a String object such that when the last frame is displayed, the Date/Time object "retrieves the stop watch time," then "sets it to Numerical Value A."
I then have a String object which "converts the numeric value to a string" of the Date/Time objects "Value A."
This string value is then set as the Amendable string, is to display that Amendable string, and is to "append a file" (using a File object) the String object's "Amendable string."
Theoretically, I am expecting the output of the stop watch time (though I'm not sure whether it would display as seconds, minute and seconds, or what). Instead, when I view the text file (which the File object creates and appends), I get the same repetitive string:
"825182518251...." (and continues for about 25 characters)
So, my question is: What am I doing wrong? How can I get a text file to output the stop watch time which started on the second frame of my project?
Thank you for your input!
Most graciously,
RGBreality
Re: How to convert the Date/Time to a string?
Put the Str$ of the stopwatch time into an edit box (or any other object that saves) and save it. Don't use string objects like that to save... and don't use the Rich Edit either. ;)
Re: How to convert the Date/Time to a string?
It sounds like the stopwatch value is 8251 (milliseconds?), and it's appending it to the file more than once.
Re: How to convert the Date/Time to a string?
Thanks for your reply, LB!
I must still be doing something wrong...
I have the original iteration of the Date/Time object on the first frame. Then, in a sub-application, I have a copy of the Date/Time object (dragged-and-dropped from the original frame); there is also an edit box in which its text is set that "every chronological second" (of the Date/Time object's stop watch time), it is to "get the chronological time of the stop watch" (using this expression:
Str$(chrono of ("Master Time"))
"Master Time" being the name of the Date/Time object.
I then have a Global Event that states when the "application reaches frame 26" (the last frame) it is to set Flag 1 of the Date/Time object on.
Back in the sub-application, there is an event which states that if "Flag 1 of the Date/Time object on," then the Edit box is to "save a text file" of the set text.
I set the sub-application to always be on top so that as I go through my run-time application, I can watch its value. Alas, as I go through it, the Edit box always reads "0," as if the stop watch never started. Furthermore, when the application ends, there is no text file saved.
So, what might I be doing wrong here?
Thanks for your guidance and help, as always!
RGBreality
Re: How to convert the Date/Time to a string?
Does the flag ever turn on? Look at it in the debugger.
Re: How to convert the Date/Time to a string?
After doing a bit of reworking on this, I was able to use a TimeX object, start a "global timer," then set the text in an Edit box object to the "time since the game began," then write that to a text file.
However, the numeric value is not one which has much meaning. It reads "86578". I'm not sure what units of measure that is (is that milliseconds, or seconds?), so I can't begin to write a formula that would convert that string to something more meaningful.
Any ideas?
RGBreality
Re: How to convert the Date/Time to a string?
Could you give us an idea how lone it actually took before it stopped the timer and did this?
Also, you should not use time since game began, you want to use the time of the global timer you started.
Re: How to convert the Date/Time to a string?
Hmmmm... That's interesting...
When I set the Edit box to set its text to the numeric conversion of the TimeX object's global timer (timer 1), the text file value it outputs is "0".
In reality, since I am testing this, it takes me less than a minute to click through all the frames from begin to end. So, the global time should be something around there.
RGBreality
Re: How to convert the Date/Time to a string?
Would it be about 8 seconds, you think?
Re: How to convert the Date/Time to a string?
I think one thing I did wrong was that even though I used only one timer for this TimeX object (you can create more than one timer for a TimeX object), the first time is "0" and not "1" (even though one may specify you only want "1" timer).
So, once I started "global timer 0" and specified the Edit box to save the numeric conversion of "global timer 0" I received a value other than "0". Again, though, it is an ambiguous number: "27906".
Reading their documentation, it seems that the TimeX object uses milliseconds in time.
So, if I wanted to convert this to seconds, it would be roughly 27.9 seconds?
What if I wanted to create a formula and set up the Edit box to display "X" minutes and "Y" seconds. How would I do something like that?
EDIT:
So, I took a stab at this... Assuming that the TimeX object outputs all values in milliseconds, then I would use these formulas to calculate seconds and minutes:
Set Alterable Value A to GetTimer ("TimeX", 0) //milliseconds
Set Alterable Value B to Alterable Value A ("Edit Box")/1000 //sets into seconds
Set Alterable Value C to Alterable Value B ("Edit Box")/60 //sets into minutes
Set Text Str$(Alterable Value C("Edit Box") //displays Total Time in minutes
This works to properly display the minutes in a numeric (though literally string) value in a text file. However, I'd like to be able to include the following in the text file output:
1.) Include seconds in the text file output
2.) Include units of measure, so that the text file would read, "{Alterable Value C} minutes {Alterable Value B} seconds"
Is there a way I can do that?
RGBreality
Re: How to convert the Date/Time to a string?
Why not use the object designed to convert between Hours, Minutes, and seconds for you? The "Seconds to HMS" object?
Re: How to convert the Date/Time to a string?
Wow, that sounds like a kick-ass object! Thanks to you, I just looked it up on Neatwares' site.
Let me see if I can figure out how this object is used.
Thanks again!
RGBreality