Index: /trunk/abdev/BasicCompiler32/Opcode.h
===================================================================
--- /trunk/abdev/BasicCompiler32/Opcode.h	(revision 363)
+++ /trunk/abdev/BasicCompiler32/Opcode.h	(revision 364)
@@ -188,5 +188,5 @@
 
 private:
-	bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType );
+	bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, bool &isErrored );
 public:
 	const UserProc *_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType = false );
Index: /trunk/abdev/BasicCompiler32/commandvalue.h
===================================================================
--- /trunk/abdev/BasicCompiler32/commandvalue.h	(revision 363)
+++ /trunk/abdev/BasicCompiler32/commandvalue.h	(revision 364)
@@ -94,4 +94,5 @@
 #define COM_ABSTRACT	0x11B2
 #define COM_NAMESPACE	0x11B3
+#define COM_TRY			0x11B4
 
 //ウィンドウ制御
Index: /trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
===================================================================
--- /trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp	(revision 363)
+++ /trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp	(revision 364)
@@ -148,4 +148,6 @@
 		// グローバル領域をコンパイル
 		////////////////////////////////////////
+
+		UserProc::pGlobalProc = &userProc;
 
 		const UserProc *pBackUserProc = &UserProc::CompilingUserProc();
Index: /trunk/abdev/BasicCompiler64/Opcode.h
===================================================================
--- /trunk/abdev/BasicCompiler64/Opcode.h	(revision 363)
+++ /trunk/abdev/BasicCompiler64/Opcode.h	(revision 364)
@@ -287,5 +287,5 @@
 
 private:
-	bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType );
+	bool EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, bool &isErrored );
 
 public:
Index: /trunk/abdev/BasicCompiler_Common/ParamImpl.cpp
===================================================================
--- /trunk/abdev/BasicCompiler_Common/ParamImpl.cpp	(revision 363)
+++ /trunk/abdev/BasicCompiler_Common/ParamImpl.cpp	(revision 364)
@@ -107,6 +107,8 @@
 }
 
-bool ParamImpl::EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType ){
+bool ParamImpl::EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, bool &isErrored ){
 	//パラメータを識別してオーバーロードを解決
+
+	isErrored = false;
 
 	//パラメータの個数が不一致の場合
@@ -137,7 +139,11 @@
 			Type nullParam( DEF_NON );
 
-			NumOpe_GetType(Parms[i],
+			if( !NumOpe_GetType(Parms[i],
 				( level <= OVERLOAD_LEVEL3 )? nullParam : param,
-				argType);
+				argType) )
+			{
+				isErrored = true;
+				return false;
+			}
 		}
 		else{
@@ -206,9 +212,19 @@
 	const UserProc *pUserProc = NULL;
 
-	for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ ){
-
-		BOOST_FOREACH( const UserProc *pTempUserProc, subs ){
-
-			if(EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type() )){
+	for( int level=OVERLOAD_MIN_LEVEL; level<=OVERLOAD_MAX_LEVEL; level++ )
+	{
+		BOOST_FOREACH( const UserProc *pTempUserProc, subs )
+		{
+			bool isErrored = false;
+			bool isHit = false;
+			isHit = EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type(), isErrored );
+			if( isErrored )
+			{
+				// 照合中にエラーが起きた場合
+				return NULL;
+			}
+
+			if( isHit )
+			{
 				trace_for_overload( "レベル" << level << " ○適合..." << pTempUserProc->_paramStr );
 
@@ -216,4 +232,5 @@
 					if( isEnabledReturnType ){
 						SetError(52,name,cp);
+						return NULL;
 					}
 					else{
@@ -238,10 +255,13 @@
 
 	if( !pUserProc ){
-		BOOST_FOREACH( const UserProc *pTempUserProc, subs ){
-
+		BOOST_FOREACH( const UserProc *pTempUserProc, subs )
+		{
 			//エラーチェック
-			if(pTempUserProc->Params().size()==this->ParmsNum){
-				if( pUserProc ){
+			if(pTempUserProc->Params().size()==this->ParmsNum)
+			{
+				if( pUserProc )
+				{
 					SetError(52,name,cp);
+					return NULL;
 				}
 
Index: /trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
===================================================================
--- /trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h	(revision 363)
+++ /trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h	(revision 364)
@@ -99,17 +99,22 @@
 public:
 	enum SCOPE_TYPE{
-		//ベース
+		// ベース
 		SCOPE_TYPE_BASE,
 
-		//分岐
+		// 分岐
 		SCOPE_TYPE_IF,
 
-		//ループ
+		// ループ
 		SCOPE_TYPE_DO,
 		SCOPE_TYPE_FOR,
 		SCOPE_TYPE_WHILE,
 
-		//ケース分け
+		// ケース分け
 		SCOPE_TYPE_SELECT,
+
+		// 例外処理
+		SCOPE_TRY,
+		SCOPE_CATCH,
+		SCOPE_FINALLY,
 	};
 
Index: /trunk/abdev/BasicCompiler_Common/include/Procedure.h
===================================================================
--- /trunk/abdev/BasicCompiler_Common/include/Procedure.h	(revision 363)
+++ /trunk/abdev/BasicCompiler_Common/include/Procedure.h	(revision 364)
@@ -382,4 +382,5 @@
 	static const UserProc *pCompilingUserProc;
 public:
+	static const UserProc *pGlobalProc;
 	static void CompileStartForGlobalArea(){
 		pCompilingUserProc = NULL;
Index: /trunk/abdev/BasicCompiler_Common/include/ver.h
===================================================================
--- /trunk/abdev/BasicCompiler_Common/include/ver.h	(revision 363)
+++ /trunk/abdev/BasicCompiler_Common/include/ver.h	(revision 364)
@@ -6,6 +6,6 @@
 // バージョン付加文字列
 #ifdef _AMD64_
-#define VER_INFO		"(x64) (rev.374)"
+#define VER_INFO		"(x64) (rev.375)"
 #else
-#define VER_INFO		"(rev.374)"
+#define VER_INFO		"(rev.375)"
 #endif
Index: /trunk/abdev/BasicCompiler_Common/src/Exception.cpp
===================================================================
--- /trunk/abdev/BasicCompiler_Common/src/Exception.cpp	(revision 363)
+++ /trunk/abdev/BasicCompiler_Common/src/Exception.cpp	(revision 364)
@@ -103,4 +103,9 @@
 	void Try()
 	{
+		// レキシカルスコープをレベルアップ
+		compiler.codeGenerator.lexicalScopes.Start(
+			compiler.codeGenerator.GetNativeCodeSize(),
+			LexicalScope::SCOPE_TRY
+		);
 	}
 
@@ -113,7 +118,21 @@
 		}
 
+		if( catchScopes.size() )
+		{
+			// 既に1回以上のCatchが存在するとき
+
+			// レキシカルスコープをレベルダウン
+			compiler.codeGenerator.lexicalScopes.End();
+		}
+
 		JmpFinally();
 
 		catchScopes.push_back( CatchScope( paramType, compiler.codeGenerator.GetNativeCodeSize() ) );
+
+		// レキシカルスコープをレベルアップ
+		compiler.codeGenerator.lexicalScopes.Start(
+			compiler.codeGenerator.GetNativeCodeSize(),
+			LexicalScope::SCOPE_CATCH
+		);
 	}
 	void Finally()
@@ -125,7 +144,21 @@
 		}
 
+		if( catchScopes.size() )
+		{
+			// 既に1回以上のCatchが存在するとき
+
+			// レキシカルスコープをレベルダウン
+			compiler.codeGenerator.lexicalScopes.End();
+		}
+
 		isDefinedFinally = true;
 
 		ResolveJmpFinally();
+
+		// レキシカルスコープをレベルアップ
+		compiler.codeGenerator.lexicalScopes.Start(
+			compiler.codeGenerator.GetNativeCodeSize(),
+			LexicalScope::SCOPE_FINALLY
+		);
 	}
 
@@ -136,4 +169,15 @@
 			Finally();
 		}
+
+		if( catchScopes.size() || isDefinedFinally )
+		{
+			// 既に1回以上のCatch、またはFinallyが存在するとき
+
+			// レキシカルスコープをレベルダウン
+			compiler.codeGenerator.lexicalScopes.End();
+		}
+
+		// レキシカルスコープをレベルダウン
+		compiler.codeGenerator.lexicalScopes.End();
 	}
 
@@ -174,5 +218,10 @@
 
 			// Catchアドレス
-			compiler.GetObjectModule().dataTable.schedules.push_back( Schedule( &UserProc::CompilingUserProc(), dataTableOffset + pos ) );
+			const UserProc *pUserProc = &UserProc::CompilingUserProc();
+			if( UserProc::IsGlobalAreaCompiling() )
+			{
+				pUserProc = UserProc::pGlobalProc;
+			}
+			compiler.GetObjectModule().dataTable.schedules.push_back( Schedule( pUserProc, dataTableOffset + pos ) );
 			compiler.GetObjectModule().dataTable.schedules.back().SpecifyCatchAddress();
 			pos += sizeof(LONG_PTR);
@@ -188,9 +237,4 @@
 void TryCommand()
 {
-	if( UserProc::IsGlobalAreaCompiling() )
-	{
-		SetError();
-	}
-
 	tryScopes.push_back( TryScope() );
 	tryScopes.back().Try();
@@ -213,8 +257,9 @@
 	}
 
+	char varName[VN_SIZE];
 	Type paramType;
 	if( parameter[0] )
 	{
-		char varName[VN_SIZE], typeName[VN_SIZE];
+		char typeName[VN_SIZE];
 		SplitSyntacticForAs( parameter, varName, typeName );
 		if( !typeName[0] )
@@ -232,4 +277,19 @@
 
 	tryScopes.back().Catch( paramType );
+
+	if( paramType.IsObject() )
+	{
+		int backCp = cp;
+
+		char temporary[1024];
+		sprintf( temporary, "Dim %s = Thread.CurrentThread().__GetThrowintParamObject() As %s", varName, paramType.GetClass().GetFullName().c_str() );
+		MakeMiddleCode( temporary );
+		ChangeOpcode( temporary );
+		lstrcpy( temporary, "Thread.CurrentThread().__Catched()" );
+		MakeMiddleCode( temporary );
+		ChangeOpcode( temporary );
+
+		cp = backCp;
+	}
 }
 void FinallyCommand()
Index: /trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
===================================================================
--- /trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp	(revision 363)
+++ /trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp	(revision 364)
@@ -43,5 +43,10 @@
 	if( scheduleType == Schedule::CatchAddress )
 	{
-		PutCatchAddressSchedule( &UserProc::CompilingUserProc(), l );
+		const UserProc *pUserProc = &UserProc::CompilingUserProc();
+		if( UserProc::IsGlobalAreaCompiling() )
+		{
+			pUserProc = UserProc::pGlobalProc;
+		}
+		PutCatchAddressSchedule( pUserProc, l );
 	}
 	else
Index: /trunk/abdev/BasicCompiler_Common/src/Procedure.cpp
===================================================================
--- /trunk/abdev/BasicCompiler_Common/src/Procedure.cpp	(revision 363)
+++ /trunk/abdev/BasicCompiler_Common/src/Procedure.cpp	(revision 364)
@@ -434,4 +434,5 @@
 
 const UserProc *UserProc::pCompilingUserProc = NULL;
+const UserProc *UserProc::pGlobalProc = NULL;
 
 
Index: /trunk/abdev/ProjectEditor/Common.h
===================================================================
--- /trunk/abdev/ProjectEditor/Common.h	(revision 363)
+++ /trunk/abdev/ProjectEditor/Common.h	(revision 364)
@@ -66,5 +66,5 @@
 #define APPLICATION_NAME "ActiveBasic 5.0"
 #define VERSION_APPLI_NAME APPLICATION_NAME
-#define VERSION_STRING "5.00.00 (rev.356)"
+#define VERSION_STRING "5.00.00 (rev.375)"
 
 #endif
Index: /trunk/abdev/ProjectEditor/EndPairCommandComplement.cpp
===================================================================
--- /trunk/abdev/ProjectEditor/EndPairCommandComplement.cpp	(revision 363)
+++ /trunk/abdev/ProjectEditor/EndPairCommandComplement.cpp	(revision 364)
@@ -75,4 +75,5 @@
 	if(lstrcmpi(temporary,"Select")==0) return COM_SELECT;
 	if(lstrcmpi(temporary,"Sub")==0) return COM_SUB;
+	if(lstrcmpi(temporary,"Try")==0) return COM_TRY;
 	if(lstrcmpi(temporary,"Type")==0) return COM_TYPE;
 	if(lstrcmpi(temporary,"While")==0) return COM_WHILE;
@@ -150,4 +151,7 @@
 			lstrcpy(buffer,"End Sub");
 			break;
+		case COM_TRY:
+			lstrcpy(buffer,"End Try");
+			break;
 		case COM_TYPE:
 			lstrcpy(buffer,"End Type");
@@ -317,4 +321,23 @@
 		ComplementWndInfo.pMemberInfo[1].dwProc=0;
 		ComplementWndInfo.pMemberInfo[1].dwAccess=ACCESS_PAIRCOMMAND;
+	}
+	else if(CmdId==COM_TRY){
+		ComplementWndInfo.pMemberInfo=(MEMBERINFO *)HeapAlloc(hHeap,0,sizeof(MEMBERINFO)*4);
+		ComplementWndInfo.MemberNum=3;
+
+		ComplementWndInfo.pMemberInfo[0].pName=(char *)HeapAlloc(hHeap,0,10);
+		lstrcpy(ComplementWndInfo.pMemberInfo[0].pName,"End Try");
+		ComplementWndInfo.pMemberInfo[0].dwProc=0;
+		ComplementWndInfo.pMemberInfo[0].dwAccess=ACCESS_PAIRCOMMAND;
+
+		ComplementWndInfo.pMemberInfo[1].pName=(char *)HeapAlloc(hHeap,0,10);
+		lstrcpy(ComplementWndInfo.pMemberInfo[1].pName,"Catch");
+		ComplementWndInfo.pMemberInfo[1].dwProc=0;
+		ComplementWndInfo.pMemberInfo[1].dwAccess=ACCESS_PAIRCOMMAND;
+
+		ComplementWndInfo.pMemberInfo[2].pName=(char *)HeapAlloc(hHeap,0,8);
+		lstrcpy(ComplementWndInfo.pMemberInfo[2].pName,"Finally");
+		ComplementWndInfo.pMemberInfo[2].dwProc=0;
+		ComplementWndInfo.pMemberInfo[2].dwAccess=ACCESS_PAIRCOMMAND;
 	}
 	else{
Index: /trunk/abdev/ProjectEditor/SubOperation.cpp
===================================================================
--- /trunk/abdev/ProjectEditor/SubOperation.cpp	(revision 363)
+++ /trunk/abdev/ProjectEditor/SubOperation.cpp	(revision 364)
@@ -439,4 +439,5 @@
 		case COM_SELECT:
 		case COM_SUB:
+		case COM_TRY:
 		case COM_TYPE:
 		case COM_TYPEDEF:
@@ -465,4 +466,5 @@
 	}
 	else if(str[0]=='c'||str[0]=='C'){
+		if(lstrcmpi(str,"Catch")==0) return -1;
 		if(lstrcmpi(str,"Case")==0) return -1;
 		if(lstrcmp(str,"Char")==0) return -1;
@@ -508,4 +510,5 @@
 		if(lstrcmp(str,"False")==0) return -1;
 		if(lstrcmpi(str,"Field")==0) return COM_FIELD;
+		if(lstrcmpi(str,"Finally")==0) return -1;
 		if(lstrcmpi(str,"For")==0) return COM_FOR;
 		if(lstrcmpi(str,"Function")==0) return COM_FUNCTION;
@@ -583,5 +586,7 @@
 		if(lstrcmpi(str,"Then")==0) return -1;
 		if(lstrcmpi(str,"This")==0) return -1;
+		if(lstrcmpi(str,"Throw")==0) return -1;
 		if(lstrcmp(str,"True")==0) return -1;
+		if(lstrcmp(str,"Try")==0) return COM_TRY;
 		if(lstrcmpi(str,"Type")==0) return COM_TYPE;
 		if(lstrcmpi(str,"TypeDef")==0) return COM_TYPEDEF;
Index: /trunk/abdev/ProjectEditor/TextEditor_KeyEvent.cpp
===================================================================
--- /trunk/abdev/ProjectEditor/TextEditor_KeyEvent.cpp	(revision 363)
+++ /trunk/abdev/ProjectEditor/TextEditor_KeyEvent.cpp	(revision 364)
@@ -82,5 +82,9 @@
 		lstrcmpi(temporary,"Private")==0||
 		lstrcmpi(temporary,"Protected")==0||
-		lstrcmpi(temporary,"Public")==0
+		lstrcmpi(temporary,"Public")==0||
+
+		lstrcmpi(temporary,"Try")==0||
+		lstrcmpi(temporary,"Catch")==0||
+		lstrcmpi(temporary,"Finally")==0
 		) return 1;
 	else if(lstrcmpi(temporary,"Select")==0) return 2;
@@ -135,5 +139,8 @@
 		lstrcmpi(temporary,"Private")==0||
 		lstrcmpi(temporary,"Protected")==0||
-		lstrcmpi(temporary,"Public")==0
+		lstrcmpi(temporary,"Public")==0||
+
+		lstrcmpi(temporary,"Catch")==0||
+		lstrcmpi(temporary,"Finally")==0
 		) return 1;
 	else if(lstrcmpi(temporary,"EndSelect")==0) return 2;
@@ -816,6 +823,7 @@
 	if(
 		pobj_nv->BackNum_PairStatementComplement&&
-		(nVirtualKey=='c'||nVirtualKey=='C'||		//Case
+		(nVirtualKey=='c'||nVirtualKey=='C'||		//Case、Catch
 		nVirtualKey=='e'||nVirtualKey=='E'||		//End ～
+		nVirtualKey=='f'||nVirtualKey=='F'||		//Finally
 		nVirtualKey=='l'||nVirtualKey=='L'||		//Loop
 		nVirtualKey=='n'||nVirtualKey=='N'||		//Next
