Microsoft Small Basic

Program Listing: DBV633
'
'calendário SB
'GraphicsWindow.Width= 500
'GraphicsWindow.Height= 400
'GraphicsWindow.Title="Calendar"
'need to add GUI
GraphicsWindow.Width=500
GraphicsWindow.Height=400
GraphicsWindow.Top= Desktop.Height/2-GraphicsWindow.Width/2
GraphicsWindow.Left=Desktop.Width/2-GraphicsWindow.Width/2
GraphicsWindow.CanResize=0
GraphicsWindow.BackgroundColor="Black"
GraphicsWindow.Title="Calendar Month View"
dstX= 55 'distance betwen x collumn in the month view
dstY= 35
new()
For m=1 To 7
distance_X[semana[m]]= m*dstX
EndFor
For n=1 To 12
month_menu[n]= n
EndFor
For n=1902 To 3000
year_menu[n]= n
EndFor
GraphicsWindow.BrushColor="Blue"
drop_month= LDControls.AddComboBox(month_menu,GraphicsWindow.Width/3,GraphicsWindow.Height/2)
Controls.Move(drop_month,GraphicsWindow.Width/3,150)
drop_year= LDControls.AddComboBox(year_menu,GraphicsWindow.Width/3,GraphicsWindow.Height/2)
Controls.Move(drop_year,GraphicsWindow.Width/3,250)
GraphicsWindow.BrushColor=LDColours.Bisque
GraphicsWindow.DrawText(GraphicsWindow.Width/3,130,"Select month number")
GraphicsWindow.DrawText(GraphicsWindow.Width/3,230,"Select the year")
GraphicsWindow.FontSize=29
GraphicsWindow.BrushColor="Orange"
vbutton= Controls.AddButton("View",GraphicsWindow.Width/3,300)
Controls.SetSize(vbutton, GraphicsWindow.Width/3, 44)
GraphicsWindow.FontSize=30
Controls.ButtonClicked=bc
Sub bc
objmes= LDControls.ComboBoxGetSelected(drop_month)
objano= LDControls.ComboBoxGetSelected(drop_year)
objdia= maxdia[objmes]
getmonth()
EndSub

Sub getmonth
GraphicsWindow.BrushColor=LDColours.HSLtoRGB(Math.GetRandomNumber(360),0.3+((Math.GetRandomNumber(5))/10),0.3+((Math.GetRandomNumber(5))/10))
nw= LDWindows.Create()
GraphicsWindow.Width=500
GraphicsWindow.Height=300
GraphicsWindow.Top= Desktop.Height/2-GraphicsWindow.Width/2
GraphicsWindow.Left=Desktop.Width/2-GraphicsWindow.Width/2
GraphicsWindow.Title="Calculating"
GraphicsWindow.FontSize=10
GraphicsWindow.PenColor="Purple"
For n=0 To Array.GetItemCount(semana)+1
If n>0 And n<=Array.GetItemCount(semana) Then
GraphicsWindow.DrawText(dstX*n+5 ,25,semana[n])
EndIf
EndFor
'draw grid
For m=0 To dstY Step dstY
GraphicsWindow.DrawLine(dstX,m+15, GraphicsWindow.Width-dstX-5,m+15 )
EndFor
For m=dstX To GraphicsWindow.Width-dstX Step dstX
GraphicsWindow.DrawLine(m, GraphicsWindow.Height-dstY+15,m,dstY-20 )
EndFor
For m= dstY*2 To dstY*8 Step dstY
GraphicsWindow.DrawLine(dstX,m,GraphicsWindow.Width-dstX-5,m )
EndFor
GraphicsWindow.BrushColor="Black"
GraphicsWindow.FillRectangle(10,50,GraphicsWindow.Width-dstX,20)
GraphicsWindow.BrushColor=LDColours.HSLtoRGB(Math.GetRandomNumber(360),0.3+((Math.GetRandomNumber(5))/10),0.3+((Math.GetRandomNumber(5))/10))
GraphicsWindow.FontSize=30
LDGraphicsWindow.ExitOnClose="False"
GraphicsWindow.CanResize=0
GraphicsWindow.BackgroundColor="Black"
new:
new()
yposn=30
pcnt= (100/(objano-ano))
a=1
While a=1
ddsemana= ddsemana+1
dia= dia+1
If ddsemana=8 Then
ddsemana=1
If mes=objmes Then
yposn=yposn+dstY
EndIf
EndIf
rmd= Math.Floor(maxdia[2]-min[Math.Remainder(ano,4) ])
If dia>rmd And mes=2 Then
dia=1
mes= mes+1
yposn=30
EndIf
If dia>maxdia[mes] Then
dia=1
mes= mes+1
EndIf
If mes>12 Then
mes=1
ano=ano+1
yposn=30
EndIf
If dia = objdia And mes=objmes And ano=objano Then
a=2
EndIf
If objmes=mes And objano=ano Then
GraphicsWindow.DrawText(distance_X[semana[ddsemana]]+5,yposn+40,dia)
EndIf
EndWhile
GraphicsWindow.Title="View of moth "+month_name[mes]+" - "+ano
EndSub
Sub new
yposn=30
dia= 1
mes= 1
ano= 1901
maxdia="1=31;2=29;3=31;4=30;5=31;6=30;7=31;8=31;9=30;10=31;11=30;12=31;"
min="0=0;1=1;2=1;3=1;"
ddsemana= 3
month_name="1=Janeiro;2=Fevereiro;3=Março;4=Abril;5=Maio;6=Junho;7=Julho;8=Agosto;9=Setembro;10=Outubro;11=Novembro;12=Dezembro;"
semana="1=Domingo;2=Segunda;3=Terça;4=Quarta;5=Quinta;6=Sexta;7=Sábado;"
'month_name = "1 = January; 2 = February; 3 = March; 4 = April; 5 = May; 6 = June; 7 = July; 8 = August; 9 = September; 10 = October; 11 = November; 12 = December ; "
'semana = "1 = Sunday; 2 = Monday; 3 = Tuesday; 4 = Wednesday; 5 = Thursday; 6 = Friday; 7 = Saturday;"
'month_name = "1 = 1-р сар; 2 = 2-р сар; 3 = 3-р сар; 4 = 4-р сар; 5 = 5-р сар; 6 = 6-р сар; 7 = 7-р сар; 8 = 8-р сар; ; "
'semana = "1 = Ням; 2 = Даваа; 3 = Мягмар; 4 = Лхагва; 5 = Пүрэв; 6 = Баасан; 7 = Бямба;"
EndSub