Analog Clock

55 views
Skip to first unread message

xav

unread,
Oct 23, 2005, 7:06:21 AM10/23/05
to KML Discussions
I wrote a little program which places an analog clock on GE
and updates it every second.

The program runs on the local PC, not on a server and the network
link that is used points to the file that is updated locally by the program.

It is a HTML application (HTA) written in VBScript, so it works
only if you have MS Internet Explorer installed.

I chose HTA because it is easy for me to produce a user interface
with HTML and the scripting language makes it easy for anybody to
modify the code.

If you change the program for better or draw some clock dials or hands,
please post them here.
The attached zip file contains the program (KMLClock.hta),
the helpfile (clokhelp.htm) and a couple of clock dials and clock hands.

To install, just unzip the attachment to a directory on your local PC
where you have writing permission and doubleclick KMLClock.hta.

Then click on "open in GE" and start the clock.
In GE doubleclick on the network link to fly to the clock.
The parameters of the clock (size, location, graphis etc) can be
changed on the fly.
If you change the location, don't forget to fly to it.

More detailed instructions are in clockhelp.htm.

Have fun

xav

The bug with pathnames that contain spaces is now fixed.
167999-KMLClock.zip

TJ1

unread,
Oct 23, 2005, 10:04:20 AM10/23/05
to KML Discussions
This sounds cool

I think I managed to cause a bug just by looking at it though because the first time I ran it the inteface came up and also the "Script Error" dialog:

Line 310, Char 5, Path not found, Code 0 in KMLClock.hta

Dismissing that, and then pressing the Dial browser button, and selecting dial1.gif, I get 4 errors reporting Invalid Path.

However if I go through the browse file-chooser dialogs manually the files are selected.

Maybe it has something to do with using LFNs with spaces in them? I installed to my Desktop so the paths are:

C:\Documents%20and%20Settings\TJ\Desktop\clock\.....

When I start the clock, and click open in GE at the top of the screen it reports

Cannot find file file;///C:/Documents%2520and%2520Settings/tj/Desktop/KMLClock/clocklink.kml.

Note: I had to use a semi-colon after file because the colon was causing the UBB code to think i was writing a tag!

From that it seems you're url-encoding the file path, which already has a url encoded space (%20) and its encoding the % sign (%25).

xav

unread,
Oct 23, 2005, 10:12:29 AM10/23/05
to KML Discussions
TJ1,

Couldyou please help me debugging by installing it in a directory without spaces in the path? It works Ok on my machine.
Thanks
xav

TJ1

unread,
Oct 23, 2005, 10:35:18 AM10/23/05
to KML Discussions
Yes, it is the space in the path - when windows already represents it with %20, your code is using a function that also encodes HTML entities to %xxx so it encodes the % belonging to %20, giving %2520.

Works fine in paths without spaces.

xav

unread,
Oct 23, 2005, 10:37:59 AM10/23/05
to KML Discussions
The problem is with spaces in the pathnames.
So I will edit the original post and put a warning there.

Please inform me if there are other Errors.

xav

TJ1

unread,
Oct 23, 2005, 11:28:06 AM10/23/05
to KML Discussions
You should be able to do a simple string replace on the file paths to prevent this happening.

Something along the lines of

path = str_replace('%20', ' ', path);

Simply replace the encoded entity with the space character. Do this on return from the File Chooser dialogs and any other functions that get the current working directory.

You can't rely on users not installing to paths with spaces in them:

"C:\Program Files\"
"C:\Documents and Settings\"

are the most popular locations for installing apps.

xav

unread,
Oct 23, 2005, 1:07:44 PM10/23/05
to KML Discussions
Thanks again!

I just uploaded the corrected program to the original post. It now accepts pathnames with spaces. The problem was in the function that returned the working directory. I did not use string replace but the VBScript function UnEscape which workes fine..

xav
Reply all
Reply to author
Forward
0 new messages