 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
Geoff
Joined: 16 Jan 2002 Posts: 5
|
|
Format and Time variables |
|
I'm experienceing a problem with formatting times. I have: dim this_time, Time dim timestr, String Now(this_time) Format( this_time, "hhmm", timestr ) No matter what time it is, the formatted string becomes '0000'. I can step through in the debugger and see that the correct time is obtained, but the Format is failing. I have also tried a previous suggestion posted here of using a format string of "hh:mm" and removing the colon with a Replace statement, to no avail. I have also tried including the seconds digits ("hhmmss", "hh:mm:ss") and have had the same problem. Unlike the previously-posted issue (search on "time format" to find the thread), this is happening constantly, not just 5% of the time. I did get it to work at one point on my dev machine, but when I tried to use the identical script on the production server, the issue arose again. Thanks! Geoff
|
|
Wed Jan 16, 2002 12:26 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: Format and Time variables |
|
hhmm is invalid format, however the exact interpretation depends on the Regional Settings in the Control Panel. Here is what you can do to make it always work. Dim( timestr, String ) Now( this_time ) Format( this_time, "hh:mm", timestr ) Replace( timestr, ":", "", timestr ) or simply Dim( timestr, String ) Replace( "@T"hh:mm"", ":", "", timestr ) : I'm experienceing a problem with formatting times. : I have: dim this_time, Time : dim timestr, String : Now(this_time) : Format( this_time, "hhmm", timestr ) : No matter what time it is, the formatted string becomes '0000'. : I can step through in the debugger and see that the correct time : is obtained, but the Format is failing. : I have also tried a previous suggestion posted here of using : a format string of "hh:mm" and removing the colon with a Replace : statement, to no avail. : I have also tried including the seconds digits ("hhmmss", : "hh:mm:ss") : and have had the same problem. : Unlike the previously-posted issue (search on "time format" to find : the thread), this is happening constantly, not just 5% of the time. : I did get it to work at one point on my dev machine, but when I tried : to use the identical script on the production server, the issue : arose again. : Thanks! : Geoff
|
|
Wed Jan 16, 2002 3:54 pm |
|
 |
Geoff
Joined: 16 Jan 2002 Posts: 5
|
|
Re: Format and Time variables |
|
Thanks for the reply! However... : hhmm is invalid format, however the exact interpretation depends on the : Regional Settings in the Control Panel. Here is what you can do to make it : always work. The Format and Format Symbols documentation makes no mention of requiring a colon, although I see it entered as the time separator in my Control Panel. I have not changed my settings, so they are what I take to be the standard for the Eastern timezone in the U.S. : Dim( timestr, String ) : Now( this_time ) : Format( this_time, "hh:mm", timestr ) : Replace( timestr, ":", "", timestr ) When I mentioned that I tried including the colon and removing it with a Replace call, this is the EXACT code I tried! It still returned '0000'. Stepping through, the variable this_time obtained the correct time but timestr becomes '00:00', then finally '0000'. : Replace( "@T"hh:mm"", ":", "", timestr ) Since my first message, I found this issue addressed in a number of other forum articles, so I now have it working by using @T in the Dim statement: Dim dateTimeStr, string, "@T"mmddyyhhmm"" While this works, I wonder if perhaps the next release of 24x7 could address the issue or at least explain why Format may not work in some cases. Thanks again!
|
|
Thu Jan 17, 2002 9:59 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: Format and Time variables |
|
How is this_time variable declared? The format differs from @T in that it may cause some data type conversions where @ is just a dynamic text substitution value. : Thanks for the reply! : However... : The Format and Format Symbols documentation makes no mention of : requiring a colon, although I see it entered as the time separator : in my Control Panel. I have not changed my settings, so they are : what I take to be the standard for the Eastern timezone in the U.S. : When I mentioned that I tried including the colon and removing : it with a Replace call, this is the EXACT code I tried! It still : returned '0000'. Stepping through, the variable this_time obtained : the correct time but timestr becomes '00:00', then finally '0000'. : Since my first message, I found this issue addressed in a number : of other forum articles, so I now have it working by using @T : in the Dim statement: Dim dateTimeStr, string, : "@T"mmddyyhhmm"" : While this works, I wonder if perhaps the next release of 24x7 : could address the issue or at least explain why Format may not : work in some cases. : Thanks again!
|
|
Thu Jan 17, 2002 12:59 pm |
|
 |
Geoff
Joined: 16 Jan 2002 Posts: 5
|
|
Re: Format and Time variables |
|
: How is this_time variable declared?
Howdy!
In my trial script this_time was declared as a Time type.
|
|
Fri Jan 18, 2002 10:56 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: Format and Time variables |
|
Hm... I just pasted your original script into version 3.1.3 and worked fine there. I have US-based regional settings in my Control Panel. dim this_time, Time dim timestr, String Now(this_time) Format( this_time, "hhmm", timestr ) : Howdy! : In my trial script this_time was declared as a Time type.
|
|
Fri Jan 18, 2002 2:17 pm |
|
 |
Geoff
Joined: 16 Jan 2002 Posts: 5
|
|
Re: Format and Time variables |
|
I used that same script... I think it's more of a reliability issue than anything. As I wrote in my initial message, I wrote out the script on my development machine and tested it. I had it working and then went to add it to the production server. The same code would not function on the other machine. What I didn't write was that I then came backe to my development machine, changed the script to use the Replace scheme, and tried it. That script didn't work, so I re-entered the original script and saved it. I tried it out and THAT script was no longer working! I don't know what I did, but there's an example of the same script behaving differently on the same machine. If you have a chance, try changing the script to one that formats the time into "hh:mm" and then use the Replace function to remove the colon. Test it and see if it works... you may encounter the issue. If you don't, change it back to the original text and run it again. I don't know. I was saving my changes and using "Run Now". Maybe I should have tried shutting down 24x7 and restarting it. : Hm... : I just pasted your original script into version 3.1.3 and worked fine there. : I have US-based regional settings in my Control Panel. : dim this_time, Time : dim timestr, String : Now(this_time) : Format( this_time, "hhmm", timestr )
|
|
Mon Jan 21, 2002 9:24 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: Format and Time variables |
|
It works fine for me. Which regional settings do you use? I would like to try your settings and play with this script some more. How do you know or check that the returned value is incorrect? BTW. You don't need to save or restart, if you use "Run Now". : I used that same script... I think it's more of a reliability : issue than anything. As I wrote in my initial message, I wrote : out the script on my development machine and tested it. I had : it working and then went to add it to the production server. : The same code would not function on the other machine. : What I didn't write was that I then came backe to my development : machine, changed the script to use the Replace scheme, and tried : it. That script didn't work, so I re-entered the original script : and saved it. I tried it out and THAT script was no longer working! : I don't know what I did, but there's an example of the same script : behaving differently on the same machine. : If you have a chance, try changing the script to one that formats the : time into "hh:mm" and then use the Replace function to remove the : colon. Test it and see if it works... you may encounter the issue. : If you don't, change it back to the original text and run it again. : I don't know. I was saving my changes and using "Run Now". Maybe I : should have tried shutting down 24x7 and restarting it.
|
|
Mon Jan 21, 2002 10:13 am |
|
 |
Geoff
Joined: 16 Jan 2002 Posts: 5
|
|
Re: Format and Time variables |
|
I use English (United States) settings. In particular, my time settings are "h:mm:ss tt" with a colon as time separator. They didn't change at any time while I was working. At first, I'd test the return value to see what directory was being created (my script creates a directory whose name is based on the time of day and then does other processing). When I was getting directories named '0000', I then stepped through the script in the Debugger. The Now function returned the correct time, but using Format then changed it to all zeroes. Thanks for the Run Now tip. I figured as much, I was just trying to make sure that I was running my latest changes. : It works fine for me. Which regional settings do you use? I would like to try : your settings and play with this script some more. : How do you know or check that the returned value is incorrect? : BTW. You don't need to save or restart, if you use "Run Now".
|
|
Thu Jan 24, 2002 9:52 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|