Index: BasicCompiler32/Compile_Var.cpp
===================================================================
--- BasicCompiler32/Compile_Var.cpp	(revision 3)
+++ BasicCompiler32/Compile_Var.cpp	(revision 8)
@@ -853,5 +853,9 @@
 	int CalcType;
 	LONG_PTR lpCalcIndex;
-	CalcType=StaticCalculation(true, InitBuf,type,&i64data,&lpCalcIndex);
+	CalcType=StaticCalculation(false, InitBuf,type,&i64data,&lpCalcIndex);
+	if(!CalcType){
+		//動的データだった場合
+		return 0;
+	}
 	if(IsRealNumberType(CalcType)){
 		memcpy(&dbl,&i64data,sizeof(double));
@@ -995,7 +999,34 @@
 	extern HANDLE hHeap;
 	int i2,i3,VarSize;
+	char VarName[VN_SIZE];
+
+
+	if(dwFlag & DIMFLAG_CONST){
+		//////////////////////////////////
+		// 定数変数の場合を考慮
+		//////////////////////////////////
+		for(i2=0;;i2++){
+			if(Parameter[i2] == '=' ||
+				Parameter[i2] == 1 && Parameter[i2] == ESC_AS ||
+				Parameter[i2] =='('){
+					VarName[i2] = 0;
+					break;
+			}
+			VarName[i2] = Parameter[i2];
+		}
+
+		//定数と２重定義されていないる場合は抜け出す
+		if(CDBConst::obj.GetType(VarName)){
+			return;
+		}
+
+		//定数マクロとして定義されている場合は抜け出す
+		if(GetConstHash(VarName)){
+			return;
+		}
+	}
+
 
 	//構文を解析
-	char VarName[VN_SIZE];
 	int SubScripts[MAX_ARRAYDIM];
 	TYPEINFO TypeInfo;
@@ -1005,13 +1036,21 @@
 		return;
 
+
+	//定数と２重定義されていないかを調べる
+	if(CDBConst::obj.GetType(VarName)){
+		SetError(15,VarName,cp);
+		return;
+	}
+
+	//定数マクロとして定義されている場合
+	if(GetConstHash(VarName)){
+		SetError(15,VarName,cp);
+		return;
+	}
+
+
 	//タイプサイズを取得
 	int TypeSize;
 	TypeSize=GetTypeSize(TypeInfo.type,TypeInfo.u.lpIndex);
-
-	//定数と２重定義されていないかを調べる
-	if(GetConstHash(VarName)){
-		SetError(15,VarName,cp);
-		return;
-	}
 
 	if(dwFlag&DIMFLAG_STATIC){
@@ -1071,25 +1110,38 @@
 			if(VarSize%4) VarSize+=4-(VarSize%4);
 
+			VARIABLE *pVar = &LocalVar[MaxLocalVarNum];
+
+			MaxLocalVarNum++;
+
 			//変数データを追加
-			lstrcpy(LocalVar[MaxLocalVarNum].name,VarName);
-			LocalVar[MaxLocalVarNum].fRef=0;
-			if(SubScripts[0]==-1) LocalVar[MaxLocalVarNum].bArray=0;
-			else LocalVar[MaxLocalVarNum].bArray=1;
-			LocalVar[MaxLocalVarNum].type=TypeInfo.type;
-			LocalVar[MaxLocalVarNum].u.index=TypeInfo.u.lpIndex;
+			lstrcpy(pVar->name,VarName);
+			pVar->fRef=0;
+			if(dwFlag & DIMFLAG_CONST) pVar->bConst = 1;
+			else pVar->bConst = 0;
+			if(SubScripts[0]==-1) pVar->bArray=0;
+			else pVar->bArray=1;
+			pVar->type=TypeInfo.type;
+			pVar->u.index=TypeInfo.u.lpIndex;
 			AllLocalVarSize+=VarSize;
-			LocalVar[MaxLocalVarNum].offset=AllLocalVarSize;
+			pVar->offset=AllLocalVarSize;
 
 			//レキシカルスコープ
-			LocalVar[MaxLocalVarNum].ScopeLevel=obj_LexScopes.GetNowLevel();
-			LocalVar[MaxLocalVarNum].ScopeStartAddress=obj_LexScopes.GetStartAddress();
-			LocalVar[MaxLocalVarNum].bLiving=TRUE;
+			pVar->ScopeLevel=obj_LexScopes.GetNowLevel();
+			pVar->ScopeStartAddress=obj_LexScopes.GetStartAddress();
+			pVar->bLiving=TRUE;
 
 			if(InitBuf[0]){
-				InitLocalVar(-LocalVar[MaxLocalVarNum].offset,
-					LocalVar[MaxLocalVarNum].type,
-					LocalVar[MaxLocalVarNum].u.index,
-					LocalVar[MaxLocalVarNum].SubScripts,
+				int result = InitLocalVar(-pVar->offset,
+					pVar->type,
+					pVar->u.index,
+					pVar->SubScripts,
 					InitBuf);
+
+				if(!result){
+					//動的な式だった場合は代入演算を行う
+					char temporary[8192];
+					sprintf(temporary,"%s=%s",VarName,InitBuf);
+					OpcodeCalc(temporary);
+				}
 			}
 			else{
@@ -1106,5 +1158,5 @@
 				//add eax,offset
 				OpBuffer[obp++]=(char)0x05;
-				*((long *)(OpBuffer+obp))=-LocalVar[MaxLocalVarNum].offset;
+				*((long *)(OpBuffer+obp))=-pVar->offset;
 				AddLocalVarAddrSchedule();
 				obp+=sizeof(long);
@@ -1122,6 +1174,4 @@
 				obp+=sizeof(long);
 			}
-
-			MaxLocalVarNum++;
 		}
 
