Vbscript howto (**** warning!)

If there is a detailed, definitive guide to how vbscript interacts with SysSytats then please point me to it! ;)

FWIW, I'd like to set the string value of a text overlay from within a vbscript. This is in WinXP using the Stardock ObjectDock+ as host.

Any advice gratefully acceped.

#231134

OK, it's early so I'm talking to myself for a while...

I managed to get something going, but now I'm stumped: Out of the following two code snippets, the first works while the second doesn't - can anyone please explain to me why? The corresponding ini files are virtually identical.

SysStatsModel.Meters(0) is a time meter BTW. I commented it out for testing for now.

TIA

Snippet #1

Function ScriptMeter_GetValue(selector)

'Set Am/Pm indicator

dim ampm

ampm = "AM"

ScriptMeter_GetValue = ampm

End Function

Snippet #2

Function ScriptMeter_GetValue(selector)

dim tz, ampm

tz = -10 * 3600 ' set timezone offset

' if((SysStatsModel.Meters(0) + tz) >= 43200) ' Work out if AM or PM

if(tz >= 43200) ' Work out if AM or PM

ampm = "PM"

else

ampm = "AM"

endif

ScriptMeter_GetValue = ampm 'Set Am/Pm indicator

End Function

#231160

Welcome to Aqua-Soft :)

Please do not double post. You could either edit your post (edit.gif) or wait for someone to help you.

#231235

Sorry about the double post.

The only other forum I regularly look at won't let you edit after 15 min (apart from usenet where editing is not possible at all).

My posts were 2 hrs apart so I assumed that it couldn't be done.

I shall be patient like the Grasshopper :cool:

#231420

OK, it's early so I'm talking to myself for a while...

I managed to get something going, but now I'm stumped: Out of the following two code snippets, the first works while the second doesn't - can anyone please explain to me why? The corresponding ini files are virtually identical.

SysStatsModel.Meters(0) is a time meter BTW. I commented it out for testing for now.

TIA

Snippet #1

Function ScriptMeter_GetValue(selector)

'Set Am/Pm indicator

dim ampm

ampm = "AM"

ScriptMeter_GetValue = ampm

End Function

Snippet #2

Function ScriptMeter_GetValue(selector)

dim tz, ampm

tz = -10 * 3600 ' set timezone offset

' if((SysStatsModel.Meters(0) + tz) >= 43200) ' Work out if AM or PM

if(tz >= 43200) ' Work out if AM or PM

ampm = "PM"

else

ampm = "AM"

endif

ScriptMeter_GetValue = ampm 'Set Am/Pm indicator

End Function

you are mixing vbScript and javaScript here. It should read:

if tz >= 43200 then

bla

else

bla

end if

I'm gonna suggest Judge to at least have a simple debug console like Konfabulator does so that he can yank out the script engine's complaints about syntax errors.

hth,

herd

#231504

you are mixing vbScript and javaScript here. It should read:

if tz >= 43200 then

bla

else

bla

end if

Hi Herd, thanks for the reply. I realised the syntax problems and now have it just like you have shown above, but it's still not working.

The debug suggestion sounds good to me!

The other thing that's not all that clear to me is exactly when & why is the ScriptMeter_GetValue(selector) funtion called. The doc says: "whenever SysStats wants to get the latest value of the meter" - but does not explain when this is. Any tips appreciated.

Thx

Chris.

So... what's the situation/other experiences with this? I'm just trying to set the value of a text overlay according to the return value of the script.

I see quite a few other scripts that do something similar (not quite identical) which I presume work OK.

Does this function "just work" for others or is there a known problem?

TIA

Chris

#231689

Hi Herd, thanks for the reply. I realised the syntax problems and now have it just like you have shown above, but it's still not working.
Problem now solved...

The reply above (by me!!) turned out to be not entirely accurate... I still had endif instead of end if in my script.

Once that was rectified it all came good.

So Herd was right on the money and I didn't pay enough attention :-0

#235199

Really looking forward to 2.5 then!

Another thing I miss (probably from my experience with Samurize) is the ability to test the guages - eg to check the range etc.

Samurize does this by providing a slider that simulates a meter value from min to max.

Just a thought!

#238463