Index: BasicCompiler64/BasicCompiler.vcproj
===================================================================
--- BasicCompiler64/BasicCompiler.vcproj	(revision 9)
+++ BasicCompiler64/BasicCompiler.vcproj	(revision 11)
@@ -1386,8 +1386,4 @@
 					>
 				</File>
-				<File
-					RelativePath="..\BasicCompiler_Common\Variable.cpp"
-					>
-				</File>
 				<Filter
 					Name="Intermediate"
@@ -1511,4 +1507,16 @@
 					<File
 						RelativePath="..\BasicCompiler_Common\Const.h"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="Variable"
+					>
+					<File
+						RelativePath="..\BasicCompiler_Common\Variable.cpp"
+						>
+					</File>
+					<File
+						RelativePath="..\BasicCompiler_Common\Variable.h"
 						>
 					</File>
Index: BasicCompiler64/CParameter.cpp
===================================================================
--- BasicCompiler64/CParameter.cpp	(revision 9)
+++ BasicCompiler64/CParameter.cpp	(revision 11)
@@ -616,5 +616,9 @@
 				int VarType;
 				LONG_PTR lpVarIndex;
-				if(!GetVarOffset(1,Parms[i2],&VarType,&RelativeVar,&lpVarIndex)) continue;
+				if(!GetVarOffsetReadOnly(
+					Parms[i2],
+					&VarType,
+					&RelativeVar,
+					&lpVarIndex)) continue;
 
 				if(DummyTypeInfo.type!=DEF_ANY){
Index: BasicCompiler64/Compile_Calc.cpp
===================================================================
--- BasicCompiler64/Compile_Calc.cpp	(revision 9)
+++ BasicCompiler64/Compile_Calc.cpp	(revision 11)
@@ -535,6 +535,5 @@
 	//変数アドレスを取得
 	RELATIVE_VAR VarRelativeVar;
-	if(!GetVarOffset(
-		1,
+	if(!GetVarOffsetReadWrite(
 		variable,
 		&VarType,
Index: BasicCompiler64/Compile_CallProc.cpp
===================================================================
--- BasicCompiler64/Compile_CallProc.cpp	(revision 9)
+++ BasicCompiler64/Compile_CallProc.cpp	(revision 11)
@@ -187,5 +187,5 @@
 	RELATIVE_VAR RelativeVar;
 	LONG_PTR lp;
-	GetVarOffset(1,variable,&i,&RelativeVar,&lp);
+	GetVarOffsetReadOnly(variable,&i,&RelativeVar,&lp);
 	SetVarPtrToReg(REG_RAX,&RelativeVar);
 
@@ -408,5 +408,5 @@
 			else{
 				RELATIVE_VAR RelativeVar;
-				if(!GetVarOffset(1,ObjectName,&i2,&RelativeVar,0)) return -1;
+				if(!GetVarOffsetReadOnly(ObjectName,&i2,&RelativeVar,0)) return -1;
 				SetVarPtrToReg(REG_RCX,&RelativeVar);
 
Index: BasicCompiler64/Compile_Func.cpp
===================================================================
--- BasicCompiler64/Compile_Func.cpp	(revision 9)
+++ BasicCompiler64/Compile_Func.cpp	(revision 11)
@@ -74,5 +74,5 @@
 	int SubScripts[MAX_ARRAYDIM];
 	RELATIVE_VAR RelativeVar;
-	if(!GetVarOffset(1,tempParm,&type,&RelativeVar,&lpIndex,SubScripts)) return;
+	if(!GetVarOffsetReadOnly(tempParm,&type,&RelativeVar,&lpIndex,SubScripts)) return;
 
 
@@ -147,5 +147,5 @@
 				RELATIVE_VAR RelativeVar;
 				int type;
-				if(!GetVarOffset(1,ObjectName,&type,&RelativeVar,(LONG_PTR *)&pobj_c)) return;
+				if(!GetVarOffsetReadOnly(ObjectName,&type,&RelativeVar,(LONG_PTR *)&pobj_c)) return;
 				SetVarPtrToReg(REG_RCX,&RelativeVar);
 
@@ -217,5 +217,5 @@
 
 	//変数のアドレスを取得
-	if(!GetVarOffset(1,Parameter,&type,&RelativeVar,0)) return;
+	if(!GetVarOffsetReadOnly(Parameter,&type,&RelativeVar,0)) return;
 
 	SetVarPtrToReg(REG_RAX,&RelativeVar);
Index: BasicCompiler64/Compile_ProcOp.cpp
===================================================================
--- BasicCompiler64/Compile_ProcOp.cpp	(revision 9)
+++ BasicCompiler64/Compile_ProcOp.cpp	(revision 11)
@@ -326,4 +326,7 @@
 
 		lstrcpy(LocalVar[MaxLocalVarNum].name,psi->pRealParmInfo[i3].name);
+
+		// TODO: パラメータのConst定義の指定が未完成
+		LocalVar[MaxLocalVarNum].bConst=false;
 
 		LocalVar[MaxLocalVarNum].bArray=psi->pRealParmInfo[i3].bArray;
@@ -736,5 +739,5 @@
 			temp="_System_ReturnValue";
 		else temp=psi->name;
-		GetVarOffset(1,temp,&i3,&RelativeVar,&lpIndex);
+		GetVarOffsetReadWrite(temp,&i3,&RelativeVar,&lpIndex);
 
 		i3=psi->ReturnType;
Index: BasicCompiler64/Compile_Statement.cpp
===================================================================
--- BasicCompiler64/Compile_Statement.cpp	(revision 9)
+++ BasicCompiler64/Compile_Statement.cpp	(revision 11)
@@ -1179,6 +1179,5 @@
 
 		LONG_PTR lpIndex;
-		RELATIVE_VAR RelativeVar;
-		GetVarOffset(1,temporary,&type,&RelativeVar,&lpIndex);
+		type = GetVarType(temporary, &lpIndex, 1);
 
 		sprintf(temp2,"_System_InputDataPtr[%d]=VarPtr(%s)",i4,temporary);
Index: BasicCompiler64/Compile_Var.cpp
===================================================================
--- BasicCompiler64/Compile_Var.cpp	(revision 9)
+++ BasicCompiler64/Compile_Var.cpp	(revision 11)
@@ -179,5 +179,5 @@
 	return 1;
 }
-BOOL GetMemberOffset(BOOL bError,CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){
+BOOL GetMemberOffset(bool ErrorEnabled,CClass *pobj_c,char *member,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpNestIndex,BOOL bPrivateAccess){
 	int i,offset;
 
@@ -202,5 +202,5 @@
 	offset=GetSizeOfClassMember(pobj_c,VarName,&i);
 	if(i==pobj_c->iMemberNum){
-		if(bError) SetError(103,VarName,cp);
+		if(ErrorEnabled) SetError(103,VarName,cp);
 		return 0;
 	}
@@ -211,5 +211,5 @@
 		//同一クラスオブジェクトの場合はプライベートアクセスを容認する
 		if(pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
-			if(bError) SetError(107,VarName,cp);
+			if(ErrorEnabled) SetError(107,VarName,cp);
 			return 0;
 		}
@@ -218,9 +218,9 @@
 		if((bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PRIVATE)||
 			pobj_c->ppobj_Member[i]->dwAccess==ACCESS_NON){
-			if(bError) SetError(107,VarName,cp);
+			if(ErrorEnabled) SetError(107,VarName,cp);
 			return 0;
 		}
 		else if(bPrivateAccess==0&&pobj_c->ppobj_Member[i]->dwAccess==ACCESS_PROTECTED){
-			if(bError) SetError(108,VarName,cp);
+			if(ErrorEnabled) SetError(108,VarName,cp);
 			return 0;
 		}
@@ -239,5 +239,5 @@
 	else{
 		if(lpPtrOffset[0]){
-			if(bError) SetError(16,member,cp);
+			if(ErrorEnabled) SetError(16,member,cp);
 			return 0;
 		}
@@ -256,5 +256,5 @@
 		//配列オフセット
 		if(!GetArrayOffset(pobj_c->ppobj_Member[i]->SubScripts,array,*pType,pobj_c->ppobj_Member[i]->TypeInfo.u.lpIndex)){
-			if(bError) SetError(14,member,cp);
+			if(ErrorEnabled) SetError(14,member,cp);
 		}
 	}
@@ -268,5 +268,5 @@
 		if(*pType==DEF_OBJECT){
 			if(RefType!=DEF_OBJECT){
-				if(bError) SetError(104,member,cp);
+				if(ErrorEnabled) SetError(104,member,cp);
 				return 0;
 			}
@@ -278,5 +278,5 @@
 				//pObj[n].member
 				if(RefType!=DEF_OBJECT){
-					if(bError) SetError(104,member,cp);
+					if(ErrorEnabled) SetError(104,member,cp);
 					return 0;
 				}
@@ -291,5 +291,5 @@
 				//pObj->member
 				if(RefType!=DEF_PTR_OBJECT){
-					if(bError) SetError(104,member,cp);
+					if(ErrorEnabled) SetError(104,member,cp);
 					return 0;
 				}
@@ -315,5 +315,5 @@
 				//ppObj[n]->member
 				if(RefType!=DEF_PTR_OBJECT){
-					if(bError) SetError(104,member,cp);
+					if(ErrorEnabled) SetError(104,member,cp);
 					return 0;
 				}
@@ -329,10 +329,10 @@
 			}
 			else{
-				if(bError) SetError(104,member,cp);
+				if(ErrorEnabled) SetError(104,member,cp);
 				return 0;
 			}
 		}
 
-		if(!GetMemberOffset(bError,
+		if(!GetMemberOffset(ErrorEnabled,
 			pobj_c->ppobj_Member[i]->TypeInfo.u.pobj_Class,
 			NestMember,
@@ -371,5 +371,5 @@
 	SetReg_WholeVariable(DEF_PTR_VOID,&RelativeVar,reg);
 }
-BOOL GetVarOffset(BOOL bError,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
+BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss){
 	extern BOOL bCompilingGlobal;
 	int i,RefType;
@@ -387,4 +387,5 @@
 	LONG_PTR lpIndex;
 	int *pSubScripts;
+	bool bConst = false;
 
 
@@ -423,4 +424,5 @@
 			if(plpIndex) *plpIndex=lpIndex;
 			pSubScripts=LocalVar[i].SubScripts;
+			bConst = LocalVar[i].bConst;
 
 			goto ok;
@@ -463,5 +465,5 @@
 
 		pRelativeVar->dwKind=VAR_DIRECTMEM;
-		if(!GetMemberOffset(bError,pobj_CompilingClass,variable,pType,pRelativeVar,&lpIndex,1)) return 0;
+		if(!GetMemberOffset(ErrorEnabled,pobj_CompilingClass,variable,pType,pRelativeVar,&lpIndex,1)) return 0;
 		if(plpIndex) *plpIndex=lpIndex;
 		return 1;
@@ -534,5 +536,5 @@
 	}
 
-	if(bError) SetError(3,variable,cp);
+	if(ErrorEnabled) SetError(3,variable,cp);
 	pRelativeVar->dwKind=NON_VAR;
 	return 0;
@@ -563,4 +565,5 @@
 	if(plpIndex) *plpIndex=lpIndex;
 	pSubScripts=GlobalVar[i].SubScripts;
+	bConst = GlobalVar[i].bConst;
 
 
@@ -568,4 +571,8 @@
 ok:
 
+	if(bConst && WriteAccess){
+		//Const定義の変数に書き込みアクセスをしようとした場合
+		SetError(61,VarName,cp);
+	}
 
 	if(array[0]==0&&pSubScripts[0]!=-1){
@@ -600,5 +607,5 @@
 
 			LONG_PTR lp2;
-			if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
+			if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
 			if(plpIndex) *plpIndex=lp2;
 		}
@@ -616,5 +623,5 @@
 
 				LONG_PTR lp2;
-				if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
+				if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
 				if(plpIndex) *plpIndex=lp2;
 			}
@@ -634,5 +641,5 @@
 
 				LONG_PTR lp2;
-				if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
+				if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
 				if(plpIndex) *plpIndex=lp2;
 			}
@@ -658,5 +665,5 @@
 
 				LONG_PTR lp2;
-				if(!GetMemberOffset(bError,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
+				if(!GetMemberOffset(ErrorEnabled,(CClass *)lpIndex,member,pType,pRelativeVar,&lp2,0)) return 0;
 				if(plpIndex) *plpIndex=lp2;
 			}
@@ -1109,6 +1116,6 @@
 			lstrcpy(pVar->name,VarName);
 			pVar->fRef=0;
-			if(dwFlag & DIMFLAG_CONST) pVar->bConst = 1;
-			else pVar->bConst = 0;
+			if(dwFlag & DIMFLAG_CONST) pVar->bConst = true;
+			else pVar->bConst = false;
 			if(SubScripts[0]==-1) pVar->bArray=0;
 			else pVar->bArray=1;
@@ -1124,4 +1131,8 @@
 
 			if(InitBuf[0]){
+				//初期代入時のみ、書き込みアクセスを許可する
+				bool bConstBack = pVar->bConst;
+				pVar->bConst = false;
+
 				int result = InitLocalVar(-pVar->offset,
 					pVar->type,
@@ -1136,4 +1147,6 @@
 					OpcodeCalc(temporary);
 				}
+
+				pVar->bConst = bConstBack;
 			}
 			else{
Index: BasicCompiler64/NumOpe.cpp
===================================================================
--- BasicCompiler64/NumOpe.cpp	(revision 9)
+++ BasicCompiler64/NumOpe.cpp	(revision 11)
@@ -423,5 +423,9 @@
 
 					RELATIVE_VAR RelativeVar;
-					if(GetVarOffset(0,term,&i2,&RelativeVar,&index_stack[sp])){
+					if(GetVarOffset(
+						false,	//エラー表示あり
+						false,	//読み込み専用
+						term,
+						&i2,&RelativeVar,&index_stack[sp])){
 						//////////
 						// 変数
Index: BasicCompiler64/Opcode.h
===================================================================
--- BasicCompiler64/Opcode.h	(revision 9)
+++ BasicCompiler64/Opcode.h	(revision 11)
@@ -317,5 +317,5 @@
 void GetWithName(char *buffer);
 void SetThisPtrToReg(int reg);
-BOOL GetVarOffset(BOOL bError,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
+BOOL GetVarOffset(bool ErrorEnabled,bool WriteAccess,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0);
 BOOL SetInitGlobalData(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf);
 #define DIMFLAG_INITDEBUGVAR			1
Index: BasicCompiler64/OperatorProc.cpp
===================================================================
--- BasicCompiler64/OperatorProc.cpp	(revision 9)
+++ BasicCompiler64/OperatorProc.cpp	(revision 11)
@@ -325,6 +325,5 @@
 			int VarType;
 			LONG_PTR lpVarIndex;
-			if(!GetVarOffset(
-				1,
+			if(!GetVarOffsetReadOnly(
 				szTempVarName,
 				&VarType,
Index: BasicCompiler64/increment.cpp
===================================================================
--- BasicCompiler64/increment.cpp	(revision 9)
+++ BasicCompiler64/increment.cpp	(revision 11)
@@ -12,6 +12,5 @@
 	///////////////////////////
 
-	if(!GetVarOffset(
-		1,
+	if(!GetVarOffsetReadWrite(
 		lpszLeft,
 		&VarType,
