All Things WinBatch > Customer Service

Code in your Tech Database not running on my Win8.1/WB 2021 computer



I get an error when I ran the Alarm Clock code from your tech support page:

I was attempting to learn more about time coding/functions.

I have attached an image of the error

Which article are you referring to? Perhaps you have a copy&paste issue like the one you had adding the URL to your post?

I've done a LOT of work with time over the years and it's actually fairly simple. Just like Tony, I have no idea what you're referencing here but I do see by your error that you have a "bad value".

Working from your error and the variables (trytime, now, x) it contains, the following code works famously.

--- Code: Winbatch ---now = TimeYmdHms( )
Display (5, "5 second display", "Do something for 5 seconds")
trytime = TimeYmdHms( )
x = TimeDiffSecs(trytime, now)
Message ("Seconds Passed",x)
A good place to start is to search for "Time Functions" in the Consolidated WIL Help file. There are plenty of examples as well as explanations of the various time functions.  ;)

Just a guess but the OP may have been referring to the following article:

If so it dates back 20 years or so and it does have a minor coding error. The line
--- Code: Winbatch --- trytime=strcat(strsub(now,1,9),a,":00")
should read
--- Code: Winbatch --- trytime=strcat(strsub(now,1,11),a,":00")
It is a trivial thing to find and correct once the script is executed in a WBS debugger.


[0] Message Index

Go to full version