Variable BeforeWindowCount, AfterWindowCount, LogFile, ProjectFileName, SourceFileName
ProjectFileName = ListItems Window.List, 1
If File('ReDMCSB:SOURCE:LOGFILE.TXT').Exists
	LogFile = File('ReDMCSB:SOURCE:LOGFILE.TXT').Text
Else 
	LogFile = 'REDMCSB:BUILD:ONECLICK.LOG'
End If 
BeforeWindowCount = ListCount Window.List
SelectMenu 'Source', 'MakeÉ'
SelectButton 'Check All'
SelectButton 'Make'
AfterWindowCount = ListCount Window.List
If AfterWindowCount = BeforeWindowCount         // If no compile error
	If Window('Link Errors').Exists
		Window('Link Errors').Front
		CloseWindow 
	End If 
	SelectMenu 'Project', 'Build ApplicationÉ'
	SelectButton 'Save'
	If NOT Window('Link Errors').Exists     // If no link error
		If DialogButton('Replace').Enabled
			SelectButton 'Replace'
		End If 
	Else 
		CloseWindow // Close link error message
		Window('Link Errors').Front
		SelectMenu 'Edit', 'Select All'
		SelectMenu 'Edit', 'Copy'
		ConvertClip 
		File(LogFile).Append = 'Link errors in project ' & ProjectFileName & ':<return>' & Clipboard & '<return>'
		Clipboard = ''
	End If 
Else 
	Variable PictureNumber
	PictureNumber = 1
	While File('REDMCSB:Picture ' & PictureNumber).Exists
		PictureNumber = PictureNumber + 1
	End While 
	FKey '3'        // Take a screenshot
	SourceFileName = ListItems Window.List, 1
	File(LogFile).Append = 'Compile error in project ' & ProjectFileName & ' in file ' & SourceFileName & '. See screenshot of error message in file Picture_' & PictureNumber & '.bmp<return>'
	CloseWindow // Close compile error message
End If 
SelectMenu 'File', 'Quit'
