This is only for the year 2016, which is almost over, lol. I never planned on sharing this, but will now in case anyone wants something like it. The code is not pretty or optimized well, but it seems to work. It's very basic and hard coded for 2016 only. I'm planning a rewrite already, for 2017 and beyond.
Just tap on a day to add an entry for that date. Entries are saved as text files in the gigbook-data folder. if you need any help just ask.
- Dav
DEVICE NOTE: The Code below is only for iPad, but ricardobytes has made and posted a version HERE that will run on iPhone & iPod touch. Thanks ricardobytes!
Code: Select all
'GigBook2016.txt
'An event calendar/journal for 2016
'Press a number to add events on that day.
'An editing window will open to allow input.
'Press done when you have finished editing.
'Highlighted days means an event is scheduled.
'To erase highlight press clear on editing page.
'Data saved in /gigbook-2016/ directory.
'Entry filenames saved like: 2016-10-12.txt
'Coded by Dav OCT/2016
'ONLY WORKS FOR IPAD AND FOR THE YEAR 2016
if lowstr$(device_type$())<>"ipad" then
print "Sorry, only designed for iPad."
end
end if
if current_year()<>2016 then
print "Sorry, only for the year 2016."
end
end if
'make gigbook directory if doesn't exist
if file_exists("gigbook-data/") = 0 then
dir "gigbook-data" create
end if
option base 1
set orientation vertical
'===
top:
'===
graphics
graphics clear .9,.9,.9
get screen size sw,sh
set buttons custom
set buttons font size 42
draw font size 37
gosub GetData
draw color 0,0,.8
fill color .9,.9,1
draw font size 56
tm$=month$&" - 2016"
tx=((sw/2)-text_width(tm$)/2)
draw text tm$ at tx,30
draw font size 37
draw text "Sun Mon Tue Wed Thu Fri Sat" at 10,100
'draw month view
y=150!yc=sw/7!dim day$(days)!events=0
for t = 1 to days
day$(t)=dayname$(xp)
draw color 0,0,.8
'see if event saved for this day
'if so, make button special color.
entry$="2016-"&str$(SelMonth)&"-"&str$(t)&".txt"
if file_exists("/gigbook-data/"&entry$) =1 then
events=events+1
fill color .89,.89,1
else
fill color 1,1,1
end if
'use special color if days todays date
if current_year()=2016 then
if SelMonth=current_month() then
if t=current_date() then
'fill color 1,.7,.7
draw color 1,1,1
fill color 0,0,1
end if
end if
end if
'draw days in the month
button str$(t) text t at yc*(xp-1),y size yc,yc
xp=xp+1
if xp=8 then
xp=1!y=y+yc
end if
next t
'draw nav buttons
set buttons font size 65
button "<" text chr$(9664) at 25,20 size 75,75
button ">" text chr$(9654) at sw-91,20 size 75,75
set buttons font size 42
'draw info at bottom
draw font size 22
tm$="You have "&str$(events)&" entries for "&month$&"."
tx=((sw/2)-text_width(tm$)/2)
draw text tm$ at tx,830
tm$="Clck on day to add/view/clear entry."
tx=((sw/2)-text_width(tm$)/2)
draw text tm$ at tx,855
'show todays date
tm$="Today is "&today$
tx=((sw/2)-text_width(tm$)/2)
draw text tm$ at tx,900
'see if today has and entry
te$="2016-"&str$(current_month())&"-"&str$(current_date())&".txt"
if file_exists("/gigbook-data/"&te$) =1 then
tm$="You have an event scheduled for today."
else
tm$="You have no events scheduled today."
end if
tx=((sw/2)-text_width(tm$)/2)
draw text tm$ at tx,925
draw font size 37
'wait for user to make a move
do
for d=1 to days
if button_pressed(str$(d)) then goto dodate
next d
if button_pressed("<") then
if SelMonth > 1 then
'erase
for t = 1 to days
button str$(t) delete
next t
SelMonth = SelMonth -1 ! goto Top
end if
end if
if button_pressed(">") then
if SelMonth < 12 then
'erase
for t = 1 to days
button str$(t) delete
next t
SelMonth = SelMonth +1 ! goto Top
end if
end if
slowdown
until 0
dodate:
'erase month buttons
button "<" delete ! button ">" delete
for t = 1 to days
button str$(t) delete
next t
graphics clear .9,.9,.9
'draw paper
shadow on
draw color 0,0,1
draw line 45,120 to 45,sh
draw line 49,120 to 49,sh
for s= 1 to 21
draw line 0,130+(41.3*s) to sw,130+(41.3*s)
next s
'draw title bar
fill color 0,.5,1
fill rect 0,0 to sw,110
draw color 1,1,1
tm$=day$(d)&" "&month$&" "&str$(d)&", 2016"
tx=((sw/2)-text_width(tm$)/2)
draw text tm$ at tx,10
shadow off
fill color .7,.7,.7
draw color 1,1,1
button "done" text "done" at sw-130,50 size 125,56
draw color 1,1,1
fill color 1,.5,.5
button "clear" text "clear" at 500,50 size 125,56
'make entry filename
entry$="2016-"&str$(SelMonth)&"-"&str$(d)&".txt"
f$="/gigbook-data/"&entry$
draw font size 22
draw text "File: "&f$ at 25,65
draw font size 37
refield:
'make an editor field
field "1" text "" at 60,122 size sw-86,sh-(381) ml
field "1" font size 36
field "1" back alpha 0
'load entry if filename exists
if file_exists(f$) then
file f$ setpos 0 'top of file
e$=""
do
file f$ readline lin$
e$=e$&lin$&chr$(10)
until file_end(f$)=1
field "1" text e$
end if
do
if button_pressed("clear") then
field "1" delete
file f$ delete
goto refield
end if
until button_pressed("done")
'grab text, if any, to txt$
txt$= field_text$("1")
file f$ delete
field "1" delete
button "done" delete
button "clear" delete
'only save data to file if txt$ not empty
if txt$<>"" then
file f$ write 32 'make a file to use
file f$ setpos 0 'go to beginning
for u=1 to len(txt$)
file f$ write asc(mid$(txt$,u,1))
next u
end if
goto top
end
'=======
GetData: 'Get & set Month & day data
'======= 'xp is day of week the 1st falls on
'default is current month
if SelMonth=0 then SelMonth=current_month()
if SelMonth = 1 then
month$="January" ! days = 31 ! xp = 6
end if
if SelMonth = 2 then
month$="February" ! days = 29 ! xp = 2
end if
if SelMonth = 3 then
month$="March" ! days = 31 ! xp = 3
end if
if SelMonth = 4 then
month$="April" ! days = 30 ! xp = 6
end if
if SelMonth = 5 then
month$="May" ! days = 31 ! xp = 1
end if
if SelMonth = 6 then
month$="June" ! days = 30 ! xp = 4
end if
if SelMonth = 7 then
month$="July" ! days = 31 ! xp = 6
end if
if SelMonth = 8 then
month$="August" ! days = 31 ! xp = 2
end if
if SelMonth = 9 then
month$="September" ! days = 30 ! xp = 5
end if
if SelMonth = 10 then
month$="October" ! days = 31 ! xp = 7
end if
if SelMonth = 11 then
month$="November" ! days = 30 ! xp = 3
end if
if SelMonth = 12 then
month$="December" ! days = 31 ! xp = 5
end if
return
def dayname$(num)
if num = 1 then return "Sunday"
if num = 2 then return "Monday"
if num = 3 then return "Tuesday"
if num = 4 then return "Wednesday"
if num = 5 then return "Thursday"
if num = 6 then return "Friday"
if num = 7 then return "Saturday"
end def
def today$
'just a nice full display of todays date:
'Wednesday, October 5th, 2016
cd=current_day()
if cd = 0 then cd$="Sunday, "
if cd = 1 then cd$="Monday, "
if cd = 2 then cd$="Tuesday, "
if cd = 3 then cd$="Wednesday, "
if cd = 4 then cd$="Thursday, "
if cd = 5 then cd$="Friday, "
if cd = 6 then cd$="Saturday, "
cm=current_month()
if cm=1 then cm$="January "
if cm=2 then cm$="February "
if cm=3 then cm$="March "
if cm=4 then cm$="April "
if cm=5 then cm$="May "
if cm=6 then cm$="June "
if cm=7 then cm$="July "
if cm=8 then cm$="August "
if cm=9 then cm$="September "
if cm=10 then cm$="October "
if cm=11 then cm$="November "
if cm=12 then cm$="December "
c=current_date()!cdd$=str$(c)
if c=1 or c=21 or c=31 then cdd$=cdd$&"st, "
if c=2 or c=22 then cdd$=cdd$&"nd, "
if c=3 or c=23 then cdd$=cdd$&"rd, "
if c>3 and c<21 then cdd$=cdd$&"th, "
if c>23 and c <31 then cdd$=cdd$&"th, "
return cd$&cm$&cdd$&"2016"
end def