Network Monitor - GetURL2File

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Network Monitor - GetURL2File // Interactive Artwork

1  |  

Post by early // Sep 13, 2008, 5:55am

Total Posts: 46
I want to get this posted, so please excuse the style:


Fetch a binary file from the internet and write it to a file on disk.


URL: The fully qualified url to fetch ie. htpp://

Timeout: Time in seconds to allow for _completion_ of HTTP request.

Dest Name: The filename to create or overwrite

Dest Path: the fully-qualified directory to save the file


DestName: the fully-qualified name of the saved file (path and filename)

ErrStr: A friendly result string

Status: Normally the HTTP result (200 good, 404 not found, etc.)


Programmed in VBScript

Uses Microsoft.xmlHTTP

Particularly powerful when pointed at dynamic web content.

Timeout checking is crude - it will always timeout at midnight

Little error checking


This is experimental and educational code.

During testing, an unresponsive request would lock up trueSpace until I physically disconnected my internet connection.

Additional testing against specific URLs is recommended

It's not a bug, it's a feature

External URLs

Always be considerate with other people's data

There's a reason I haven't hooked my objects to timers.

Improvements needed for GetURL2File:

generalized to handle the other data types (text, html, xml)

Stream support - write data into target object without writing to disk

Better timeout checking

Asynchronous mode


Sync v. Async

Running the HTTP request asynchonously would be desirable. Unfortunately, I couldn't figure out how to do it in the Rosetta environment. I finally reverted to the synchonous request method, so timeout checking is problematical. Does anyone know if Rosetta supports a 'sleep' function like Wscript.Sleep()?



Post by early // Sep 13, 2008, 6:02am

Total Posts: 46
Here is a simple demonstration activity: live webcams in the workspace.

There are thousands of live webcams on the internet. Surf cams, traffic cams, city views, pets, landscapes, personal webcams, and security cameras to mention just a few. Many of them can be tapped with the GetURL2File object.

Simple webcam object.


GetEnv - to return the user's 'temp' directory

GetURL2File - pointed to an internet webcam, output to a temp file

ImportBitmap (System - Import library) - convert file to bitmap

Cube primitive - bitmap is mapped to the exposed D3D material DiffuseTexure

Sound Player - for some audio feedback when refresh is complete.

The virtual zoo:

Attached are three copies of my simple webcam display object, each pointed to a different URL. They can be updated individually, connected in parallel (as pictured) or in series.

Please do not abuse the webcams.

These webcams were active at the time of posting.

Polar Bears at the San Diego Zoo


Penguins at the Sidney Aquarium


Shamu at the San Diego Seaworld


The polar bears and penguins are uninteresting after dark, Seaworld replays the daytime stream at night.

Here are a few elaborations for the virtual zoo that I'll never have time to make:

Add a model of each animal. Make it selectable. Only selected webcams update quickly. Animals models could be animated and interactive. Tie each location to an animated, lit globe to visually indicate the local solar time. Construct enclosure models to match the webcam view, or something more fanciful. Etc. etc.

When you copy the webcam display object, update the temporary filename in GetURL2File to avoid conflicts.

Post by Norm // Sep 13, 2008, 7:52am

Total Posts: 862
Very interesting items. It is very cool to see these scenarios opening up in trueSpace!

Post by trueBlue // Sep 13, 2008, 8:07am

Total Posts: 1761
Very nice early! Works perfect! There is no Sleep function for tS76. I notice that you are creating:
Set WshShell = CreateObject("WScript.Shell")

Is it not possible to use Wscript.Sleep()?

Not sure if this is helpful with the Sleep function but here is your object with a Looped/Pause Activity from a boolean toggle button, Dock in the Stack/Panels button, and a Constant material.

Post by early // Sep 13, 2008, 8:27am

Total Posts: 46
I can create a 'shell' object, but Wscript is an environment, and Rosetta doesn't use it. So the Wscript.Sleep() function is not accessible. It is the place for Rosetta to provide (or not provide) that functionality. I couldn't find anything in the SDK.

See here for some discussion of the topic (and why it's complicated):

Post by Délé // Sep 13, 2008, 9:47am

Total Posts: 1374
Nice work again early! Again, this is exactly the kind of stuff that I've been wanting to see in tS but never knew how to do myself. It would be very cool if there was a way to have the video play on the cube, but even just grabbing a still shot is very cool.

Thanks for sharing all this cool stuff. It's great to learn from. :) :banana: is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn