Calander program!

Blitz3D Forums/Blitz3D Beginners Area/Calander program!

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi Agamer...
I guess you are looking for constructive critism?

Looks like you have a feel for the basic logic, but you need to optimize more. There is ALOT of redundant code in your program. For instance, you use the same large chunk of code for inputing and showing each month. You could use one small routine that will load any month.

I typed this up, didn't run it because of the image requirement but it shows how duplicate code can be avoided:
AppTitle"calander maker" 
Graphics 800,600 
HidePointer 


Print"welcome to the calander maker!" 
Print 
Print"Please now put you calander" 
Print"image into the Input folder" 
Print"It must be 800*600 pixels wide" 
Print 
;input of image name! 
Print"Please type in the file name" 
Print"remember it must be a .bmp" 
image$=Input() 
pic=LoadImage("input/" + image$ + ".bmp") 

Cls 

Locate 0,0 

;Date/month selection loop-------------------------------------------------------
Repeat 
	
	Print"Please input the month" 
	month$=Input() 
	gfxMonth=LoadImage (Left$(Lower$(month),3)+".bmp") ; All your *.bmps named "jan.bmp", "feb.bmp" etc...

	Print "please choose which calander you want" 
	Print "remember choose one which will stand out well" 
	Print "press any key to preview" 
	WaitKey() 
	Cls 

	DrawImage gfxMonth,0,0 
	MaskImage gfxMonth,0,0,0 
	Text 0,170,"1!" 

	Text 0,190,"please select a calander by typing the number below the calander" 
	Locate 0,200 
	monthsel$=Input() 

	If monthsel$=1
		DrawBlock pic,0,0 
		DrawImage gfxMonth,498,296 
		MaskImage gfxMonth,0,0,0 
	EndIf 

	savescreenshot() 
	FreeImage gfxMonth
	gfxMonth=0
	currentmonth=currentmonth+1
	
Until currentmonth=13

;-------------------------------------------------------------------------------

Delay 500 
Locate 0,0 
Print 
Print"Thankyou the calander is now" 
Print"waiting For you in the output folder!" 
Print"Please press any key to end this program" 
WaitKey 
End 

;[ Func: SaveScreenShot() ]#################################################################
Function SaveScreenshot() 
	iFileNumber% = 0 
	Repeat 
		iFileNumber = iFileNumber + 1 
		sFileName$ = "output/screenshot" + String$("0", 3 - Len(Str$(iFileNumber))) + iFileNumber + ".bmp" 
	Until Not(FileType(sFileName)) 
	SaveBuffer FrontBuffer(), sFileName 
End Function 


Cheers