Post by bluatigro on Jun 28, 2018 9:53:32 GMT
this is the text version of a agenda whit some AI
i wil try to build a GUI version next
this is not tested code
but is error free says JB
i wil try to build a GUI version next
this is not tested code
but is error free says JB
''bluatigro 28 jun 2018
''avertilo 1.0
dim info$( 10 , 10 ) , card$( 2000 )
global cardtel
[info]
print "bluatigro presents : avertilo 1.0"
print "a text based agenda whit warning system ."
print "1 : add warning ."
print "2 : see warnings ."
print "3 : exit avertilo 1.0"
input "choise [ 1 , 2 , 3 ] = " ; in$
in = int( val( in$ ) )
if in <> 1 and in <> 2 and in <> 3 then
print "ERROR : choise must be 1 or 2 or 3 !!"
goto [info]
end if
if in = 1 then goto [add.warning]
if in = 2 then goto [see.warnings]
if in = 3 then
print "end avertilo ."
end
end if
goto [info]
[add.warning]
[dato.monato]
input "month [ 3 chars ] = " ; monato$
if dato.monato( monato$ ) = 0 then
print "ERROR : month not good !!"
goto [dato.monato]
end if
[dato.tago]
input "day [ 1 ... 31 ] = " ; tago$
tago = val( tago$ )
if tago < 1 or tago > 31 then
print "ERROR : day not good !!"
goto [dato.tago]
end if
[dato.jaro]
input "jear [ 2000 ... ] = " ; year$
year = val( year$ )
if year < 2000 then
print "ERROR : year in far past !!"
goto [dato.jaro]
end if
if year > 3000 then
input "WARNING : wood you life that long ? [ y , n ] " ; in$
if lower$( in$ ) = "n" then goto [dato.jaro]
end if
dato$ = monato$ + " " + tago$ + ", " + year$
[timo]
input "time [ uu:mm:ss ] = " ; timo$
u = val( word$( timo$ , 1 , ":" ) )
m = val( word$( timo$ , 2 , ":" ) )
s = val( word$( timo$ , 3 , ":" ) )
if u < 0 or u > 24 then
print "ERROR : hours not good !!"
goto [timo]
end if
if m < 0 or m > 59 then
print "ERROR : minutes not good !!"
goto [timo]
end if
if s < 0 or s > 59 then
print "ERROR : seconds not good !!"
goto [timo]
end if
input "warning = " ; in$
averto$ = date$() + "," + dato$ + "," + year$ + "," + in$
open "avertilo.txt" for append as #uit
print #uit , averto$
close #uit
goto [info]
[see.warnings]
files DefaultDir$ , "avertilo.txt" , info$()
if val( info$( 0 , 0 ) ) <> 0 then
open "avertilo.txt" for input as #in
cardtel = 0
while not( eof( #in ) )
line input #in , q$
dato2$ = word$( q$ , 2 , "," )
tago2 = dato.tago( dato2$ )
monato2 = dato.monato( dato2$ )
jaro2 = dato.jaro( dato2$ )
dato1$ = date$()
tago1 = dato.tago( dato1$ )
monato1 = dato.monato( dato1$ )
jaro1 = dato.jaro( dato1$ )
if tago2 >= 1 and tago2 <= 31 _
and monato2 >= 1 and monato2 <= 12 _
and jaro2 >= 2000 then
''dato2 is real
tagoj1 = tagoj( tago1 , monato1 , jaro1 )
tagoj2 = tagoj( tago2 , monato2 , jaro2 )
if tagoj1 <= tagoj2 then
''dato2 is in future or now so store in waring
card$( cardtel ) = q$
cardtel = cardtel + 1
end if
end if
wend
close #in
else
print "no warnings file add warnings first ."
goto [info]
end if
if cardtel = 0 then
print "i cant find any warning in the futue or today ."
else
for i = 0 to cardtel
print "warning number : " ; i ; " of : " ; cardtel ; " ."
print "inputed : " ; word$( card$( i ) , 1 , "," )
print "date : " ; word$( card$( i ) , 2 , "," )
print "time : " ; word$( card$( i ) , 3 , "," )
print "warning = " ; word$( card$( i ) , 4 , "," )
input "[ push return for next warning ]" ; in$
next i
end if
goto [info]
function dato.tago( dato$ )
dato.tago = val( word$( dato$ , 2 ) )
end function
function dato.monato( dato$ )
monato$ = lower$( word$( dato$ , 1 ) )
q$ = "jan feb mrt apr may jun jul aug sep okt nov dec"
uit = 0
for i = 1 to 12
if monato$ = word$( q$ , i ) then uit = i
next i
dato.monato = uit
end function
function dato.jaro( dato$ )
dato.jaro = val( word$( dato$ , 3 ) )
end function
function tagoj( day , month , year )
year = year - 1
month = month + 12
uit = int( 2.6001 * ( month - 2 ) - 0.2 ) _
+ day + year + int( year / 4 ) - 3
tagoj = uit
end function