Scripting

Sunday, August 27, 2006 by Jaramia | Discussion: DesktopX

I have many objects that are pure text on the desktop, I was wondering how to make these 'texts' change every hour or day...or even if possible to make a button that can browse through the 'texts'

Thanks!
ZubaZ
Reply #1 Sunday, August 27, 2006 3:29 PM
Are these objects ones you made? What do they display now? Change from what to what?

More info is requiered
Jaramia
Reply #2 Sunday, August 27, 2006 3:55 PM
These are objects i made...they are just plain text, it will say a fact, then after a certain time that fact changes to another fact
SirSmiley
Reply #3 Sunday, August 27, 2006 4:58 PM
Timebased changes can be done with a simple timer script. So, could the button. Think of something similar to a toggle script.

Are you reading from a text file? xml? Or did you plan to put the text directly in the object? I'd suggest using an external file to keep the size down.
Jaramia
Reply #4 Sunday, August 27, 2006 5:16 PM
Umm, so should i make a text file for every fact(object)?

Still not sure how to do this script-wise...
sViz
Reply #5 Sunday, August 27, 2006 7:53 PM
Hi Jaramia.

You could use an array to make a list of the facts. Then add a counter to a timer to select which fact to display. If you insert the example script below into a text object you'll see what I mean.


Dim fact(3)'---An array with 3 variables (0, 1, 2)
fact(0)= "This is fact 1"
fact(1)= "This is fact 2"
fact(2)= "This is fact 3"


Sub object_OnScriptEnter
object.settimer 1, 2000'-- two-second timer (can be adjusted)
End Sub

Sub object_OnTimer1
object.text = fact(counter)
counter = counter + 1
if counter = Ubound(fact) then counter = 0
End Sub



BTW, SirSmiley, what's this about using external files? How is that possible and how do you include those files when exporting for upload?
ZubaZ
Reply #6 Sunday, August 27, 2006 9:49 PM
DX allows for any number of external files to be included on the summary tab.
I use it for fonts.
Jaramia
Reply #7 Sunday, August 27, 2006 11:43 PM
sVis, thanks for taking time to make a script for me but when i put it in a text object it doesnt seem to work...
ZubaZ
Reply #8 Monday, August 28, 2006 7:19 AM
DX allows for any number of external files to be included on the summary tab.
I use it for fonts.


An example of an embedded file:
WWW Link

Are you reading from a text file? xml? Or did you plan to put the text directly in the object? I'd suggest using an external file to keep the size down.


If you had a script that referenced an external file it would be easier for a non-scripting user to add their own text . . .
sViz
Reply #9 Monday, August 28, 2006 12:05 PM
Whoops, forgot to declare the counter.

Dim fact(3)'---An array with 3 variables (0, 1, 2)
fact(0)= "This is fact 1"
fact(1)= "This is fact 2"
fact(2)= "This is fact 3"
counter= 0

Sub object_OnScriptEnter
object.settimer 1, 2000'-- two-second timer (can be adjusted)
End Sub

Sub object_OnTimer1
object.text = fact(counter)
counter = counter + 1
if counter = Ubound(fact) then counter = 0
End Sub
SirSmiley
Reply #10 Monday, August 28, 2006 12:11 PM
BTW, SirSmiley, what's this about using external files? How is that possible and how do you include those files when exporting for upload?
As Zubaz said referencing the external file is easier for the user. Not sure whether I'd use xml or text(csv, etc) myself. Simple text files maybe easier to parse for the less experienced scripter (aka myself) - by using GetFile & readline from FSO. Now you could store the file in local storage per the help file or place it in My Documents & use the Environment Variable to point to it or allow the user to select the folder on initialization.

Edit: The lazy way to do the xml (if you're still learning the DOM like me) would be to get Chilkat's free XML activeX or Tortuga's activeX which can be called from within the script. Not as fast as the DOM but, for this stuff you most likely won't notice any difference.
sViz
Reply #11 Tuesday, August 29, 2006 3:29 PM
Hmm, sounds very interesting, SirSmiley. I'll have to dig into that when I get done with my current project. Thanks for the info.

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01