Scripting

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!
3,136 views 11 replies
Reply #1 Top
Are these objects ones you made? What do they display now? Change from what to what?

More info is requiered
Reply #2 Top
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
Reply #3 Top
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.
Reply #4 Top
Umm, so should i make a text file for every fact(object)?

Still not sure how to do this script-wise...
Reply #5 Top
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?
Reply #6 Top
DX allows for any number of external files to be included on the summary tab.
I use it for fonts.
Reply #7 Top
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...
Reply #8 Top
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 . . .
Reply #9 Top
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
Reply #10 Top
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.
Reply #11 Top
Hmm, sounds very interesting, SirSmiley. I'll have to dig into that when I get done with my current project. Thanks for the info.