uBasic
Syntax: [ Download ] [ Verstecken ]
Benutze uBasic Syntax Highlighting
@title Timer
@param a Stunden
@default a 0
@param b Minuten
@default b 1
:check
cls
gosub "date"
gosub "time"
sleep 800
if a=H and b=M then shoot else goto "check"
sleep 1000
print "ready"
end
:time
S=get_time 0
M=get_time 1
H=get_time 2
if S>9 and M>9 and H<10 then print "0";H;":";M;":";S
if S<10 and M>9 and H<10 then print "0";H;":";M;":0";S
if S>9 and M<10 and H<10 then print "0";H;":0";M;":";S
if S<10 and M<10 and H<10 then print "0";H;":0";M;":0";S
if S>9 and M<10 and H>9 then print H;":0";M;":";S
if S<10 and M<10 and H>9 then print H;":0";M;":0";S
if S<10 and M>9 and H>9 then print H;":";M;":0";S
if S>9 and M>9 and H>9 then print H;":";M;":";S
return
:date
D=get_time 3
N=get_time 4
Y=get_time 5
if N<10 and D>9 then print D;".0";N;".";Y
if N>9 and D<10 then print "0";D;".";N;".";Y
if N<10 and D<10 then print "0";D;".0";N;".";Y
if N>9 and D>9 then print D;".";N;".";Y
return
@param a Stunden
@default a 0
@param b Minuten
@default b 1
:check
cls
gosub "date"
gosub "time"
sleep 800
if a=H and b=M then shoot else goto "check"
sleep 1000
print "ready"
end
:time
S=get_time 0
M=get_time 1
H=get_time 2
if S>9 and M>9 and H<10 then print "0";H;":";M;":";S
if S<10 and M>9 and H<10 then print "0";H;":";M;":0";S
if S>9 and M<10 and H<10 then print "0";H;":0";M;":";S
if S<10 and M<10 and H<10 then print "0";H;":0";M;":0";S
if S>9 and M<10 and H>9 then print H;":0";M;":";S
if S<10 and M<10 and H>9 then print H;":0";M;":0";S
if S<10 and M>9 and H>9 then print H;":";M;":0";S
if S>9 and M>9 and H>9 then print H;":";M;":";S
return
:date
D=get_time 3
N=get_time 4
Y=get_time 5
if N<10 and D>9 then print D;".0";N;".";Y
if N>9 and D<10 then print "0";D;".";N;".";Y
if N<10 and D<10 then print "0";D;".0";N;".";Y
if N>9 and D>9 then print D;".";N;".";Y
return
Erstellt in 0.015 Sekunden, mit GeSHi 1.0.8.9
LUA
Syntax: [ Download ] [ Verstecken ]
Benutze Lua Syntax Highlighting
--[[
@title Timer
@param a Stunden
@default a 0
@param b Minuten
@default b 0
--]]
function date()
yyyy = (get_time("Y"))
mm = (get_time("M"))
if (tonumber(mm)<10) then
mm = "0"..mm
end
dd = (get_time("D"))
if (tonumber(dd)<10) then
dd = "0"..dd
end
ddmmyyyy = dd .. "." .. mm .. "." .. yyyy
end
function time()
hh = (get_time("h"))
if (tonumber(hh)<10) then
hh = "0"..hh
end
mi = (get_time("m"))
if (tonumber(mi)<10) then
mi = "0"..mi
end
ss = (get_time("s"))
if (tonumber(ss)<10) then
ss = "0"..ss
end
hhmmss = hh .. ":" .. mi .. ":" .. ss
end
--check
HH = a
if (tonumber(HH)<10) then
HH = "0"..HH
end
MI = b
if (tonumber(MI)<10) then
MI = "0"..MI
end
st = HH..":"..MI..":00"
repeat
sleep ( 1000 )
cls()
date()
time()
print ( "Start Time: "..st )
print ( "Act. Time: "..hhmmss )
print ( "Date: "..ddmmyyyy )
until st == hhmmss
shoot()
sleep ( 1000 )
print ( "ready" )
@title Timer
@param a Stunden
@default a 0
@param b Minuten
@default b 0
--]]
function date()
yyyy = (get_time("Y"))
mm = (get_time("M"))
if (tonumber(mm)<10) then
mm = "0"..mm
end
dd = (get_time("D"))
if (tonumber(dd)<10) then
dd = "0"..dd
end
ddmmyyyy = dd .. "." .. mm .. "." .. yyyy
end
function time()
hh = (get_time("h"))
if (tonumber(hh)<10) then
hh = "0"..hh
end
mi = (get_time("m"))
if (tonumber(mi)<10) then
mi = "0"..mi
end
ss = (get_time("s"))
if (tonumber(ss)<10) then
ss = "0"..ss
end
hhmmss = hh .. ":" .. mi .. ":" .. ss
end
--check
HH = a
if (tonumber(HH)<10) then
HH = "0"..HH
end
MI = b
if (tonumber(MI)<10) then
MI = "0"..MI
end
st = HH..":"..MI..":00"
repeat
sleep ( 1000 )
cls()
date()
time()
print ( "Start Time: "..st )
print ( "Act. Time: "..hhmmss )
print ( "Date: "..ddmmyyyy )
until st == hhmmss
shoot()
sleep ( 1000 )
print ( "ready" )
Erstellt in 0.009 Sekunden, mit GeSHi 1.0.8.9
Das uBasic-Skript ließ sich einfach realisieren, da die Strukturen allgemein bekannt sind. Mit der Formatierung der Anzeige stößt man an die Grenzen. Außerdem ist das Anzeige-Timing kritisch.
Das LUA-Skript ist für Programmier-Anfänger wesentlich komplizierter zu bewerkstelligen, ohne Studium diverser LUA-Seiten nicht machbar. Das Ergebnis ist aber besser. Man kann mit Zeichenketten arbeiten. Es können Funktionen definiert werden. Das Anzeige-Timing funktioniert tadellos. Variablen können frei definiert werden. Die Vorteile werden aber sicherlich erst bei komplexen Anwendungen deutlich.
Fazit:
Für einfache Aufgaben ist uBasic die 1. Wahl. Bei komplexe Aufgaben ist LUA die bessere Anwendung.
Um LUA besser einsetzen zu können, ist in Sachen Doku noch einiges zu tun. Insbesondere würde mich interessieren, welche Basis-Funktionen wie "tonumber" die CHDK-LUA-Version beinhaltet. Wie sieht es mit selbst erstellten Bibliotheken aus?
Vielleicht können wir ja mal eine Sammlung von Standard-Anwendungen für LUA zusammentragen.
Gruß msl