Hear a quiet man
Published on March 25, 2008 By p e d In DesktopX

Hi Guys,

Quick question.

Is it possible to loop thru an objects states similar to

For Each obj In DesktopX.Objects
 
Next

or any other way?

Thanks


Comments
on Apr 08, 2008
Hi,
I've never tried it personally.But, I can tell you this,each object has, two, shall I say parts,the scipting section is written to separately.I think that might be a good way to put it.
In other words I would define all the states in the scripting section if I needed DX
to pick up on them.
Sorry I'm not better at codeing.
Eddie
on Apr 08, 2008
I never used this method... However I'm sure it must work. You may write something like this:

For Each obj In DesktopX.Objects
Select Case obj.name
Case "name1"
It obj.state = "state1" Then obj.state = "state2" Else obj.state = "state3"
Case "name2"
Select Case obj.state
Case "state1" '<== do something
Case "state2" '<== do something
Case "state3" '<== do something
etc...
End Select
End Select
Next
on May 05, 2008
Don't think there is a way to cycles through the states or get a list of states for an object.

You can use Object.States("").property to set a value for all states of an object however.

There is also the possible complex method of accessing the theme.ini (theme2.ini?) in the Object.Directory folder and parsing it to get the states of an object. But that would not pick up any states that have been added since last save.

And probably wouldn't work for any packaged themes and gadgets etc.

This is something I dont think will have a 'workaround' solution unless it's put directly into DesktopX function.

Could be wrong.
on May 05, 2008
Just tried a sub and it's do-able...messy but, doable. It would be nice if they added a "*.Name" namespace for states.

Here's what I did. On a simple image object I created five states named "state1"(up to 5).
Then I looped through them to verify if they existed. Obviously, you must likely would put this data into an array after running the sub or function.
Code: vbscript
  1. Sub Object_OnScriptEnter
  2. Call IterateStates
  3. End Sub
  4. Sub IterateStates
  5. sActiveState=Object.State
  6. For x=1 To 5
  7. strState="state"&x
  8. 'x=Object.State(strState)
  9. If Object.States(strState).Picture "" Then
  10. If sActiveState=strState Then
  11. oList=oList&"Active: "&strState&vbnewline
  12. Else
  13. oList=oList&strState &vbnewline
  14. End If
  15. End If
  16. Next
  17. msgbox oList
  18. End Sub
on May 07, 2008
Yes but you have to know what they are before you test them, and you would need an 'index' label to your states, or something you can vary on each cycle.

A powerful point behind a collection is that you don't necessarily know what it contains.

One thing which would tell you if an object has a state or not is if DesktopX threw an error if the state didn't exist. BUT I DON"T want that, because I use this non error response to allow me to do many things in my creations, and there is no real use to having DesktopX chuck a fit if the state isn't there.

A states collection for an object would be fine.
Where we can:
For each objState in Object.States
MsgBox("Found state: "&objState.Name
Next

or something, like we can for children and group objects.
on May 07, 2008
I agree this could be a good addition to 3.51?

I just noticed if i look at the ABOUT screen, (in pro) i no longer see a detailed version number.. or ANY #.. is it just me?
on May 13, 2008
I just noticed if i look at the ABOUT screen, (in pro) i no longer see a detailed version number.. or ANY #.. is it just me?

Sorry but I got a number.

but if it makes you feel any better my screen went dead on sign in from a bad pool header lol.Thats life always something going on.  
on May 23, 2008
Thanks for all the replies folks.

Guess I'll leave that part out of my desktop for now.