[Windows Mobile Software Development] mistrix:
MortScript

Here`s some of my stuff, unfortunately mostly still on the "old" syntax.

I´ve started to rebuff some of the scripts (new syntax, mostly new concepts) but ran out of time during the last month.

I try to create "modules" for recurring tasks, to be called from within other scripts or, if appliccable, to be capable run standalone as well. Most of the module expect variables to be set, hence must be called using callscript.

Here is a newer one to display status messages and a kind of countdown. Once kicked off it runs on its own, refreshes (if required, i.e. if the status display needs to change) every second displaying the content of the registry value "info" until the registry value "DoShow" toggles. During the process a given startvalue (approximated duration) is decreased like a countdown and restartet if necessary.

This one is started with run, to have it operate totally independent, hence content is communicated via registry values.

# Modul zum Zeigen von Status / Info messages
# uebergeben per Reg. Werten
#
# HGH 11-26/06
#
errorlevel warn
#
if ( \
NOT \
( \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat","DoShow") \
AND \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat","RefCycle") \
AND \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat","Info") \
AND \
RegValueExists \
("HKCU","Software\Mistrix\ShowStat","InfoHeader") \
AND \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat", "OKAllow") \
) \
)
message ( \
"RegWerte nicht gefunden", \
SystemPath("ScriptName") \
& SystemPath("ScriptExt") \
)
exit
EndIf
#
# "Gesamtzeit" aus Reg lesen
GCycle = RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"RefCycle")
#
TStampStart = TimeStamp ()
#
while (RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow") = 1)
InfAlt = RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"Info")
If (TimeStamp () - TStampStart > GCycle )
TStampStart = TimeStamp ()
EndIf
ShowCycle = GCycle - TimeStamp () + TStampStart
Sleepmessage \
( \
ShowCycle , \
InfAlt, \
RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"InfoHeader"), \
1, \
RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow") <> 1 OR InfAlt ne RegRead \
("HKCU", "Software\Mistrix\ShowStat", \
"Info") \
)
#
# ggf. (OKAllow=1) warten,
# bis sich ein Status geaendert hat
while ( \
RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow") = 1 AND InfAlt eq RegRead \
("HKCU", "Software\Mistrix\ShowStat", \
"Info") AND RegRead ("HKCU", \
"Software\Mistrix\ShowStat", \
"OKAllow") = 1 \
)
sleep (1000)
EndWhile
#
EndWhile
#
exit

Next is an example, how to use it. There could be any

code instead of the sleeps,

just reload "Info" whenever you want to have your

status display updated...

# TestRahmen fuer Status / Info messages
# mittels ShowStat.mscr
#
# HGH 11-26/06
#
errorlevel warn
#
# Setzen der Reg. Werte - set the registry values
# Stausmeldungen aktiv - activate status display
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow", 1)
# Darf der User Message wegcklicken? -
# may the user cancel status display
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"OKAllow", 1)
# "Gesamtzeit" - approximated total time
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"RefCycle", 30)
# InfoHeader - title
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"InfoHeader", "TestStati" )
# InfoText - status text
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"Info", "Status1" )
#
# Starten der Show Info Routine - status modul start
run ( SystemPath("ScriptPath") \ "ShowStat.mscr")
#
sleep (8000)
#
# neuer Infotext - new status content
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"Info", "Status2" )
#
sleep (12000)
#
# neuer Infotext - new status content
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"Info", "Status3" )
#
sleep (5000)
#
# Statusmeldungen inaktiv - status display off
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow", 0)
#
exit