Index: BasicCompiler_Common/Procedure.cpp
===================================================================
--- BasicCompiler_Common/Procedure.cpp	(revision 74)
+++ BasicCompiler_Common/Procedure.cpp	(revision 75)
@@ -1,6 +1,841 @@
 #include "common.h"
 
-SubInfo::SubInfo():
-  pNextData( NULL )
-{
+bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){
+	int i = 0;
+	int i2,i3,sw;
+	char temporary[8192],temp2[VN_SIZE];
+
+	//ソースコードの位置
+	this->codePos = nowLine;
+
+	//パラメータ
+	if(sourceOfParams[i]!='('){
+		SetError(1,NULL,nowLine);
+		return 0;
+	}
+	i++;
+	if(sourceOfParams[i]!=')'&& this->pParentClass ){
+		//クラスのメンバ関数の場合のみ、デストラクタにパラメータがある場合にエラーをだす
+		if(this->GetName()[0]=='~'){
+			SetError(114,NULL,nowLine);
+			i=JumpStringInPare(sourceOfParams,i);
+		}
+	}
+	while(1){
+		if(sourceOfParams[i]==')') break;
+
+		//ByRef
+		bool isRef;
+		if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){
+			isRef = false;
+			i+=2;
+		}
+		else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){
+			isRef = true;
+			i+=2;
+		}
+		else isRef = false;
+
+		//パラメータ名
+		bool isArray = false;
+		int subScripts[MAX_ARRAYDIM];
+		char name[VN_SIZE];
+		sw=0;
+		for(i2=0;;i++,i2++){
+			if(sourceOfParams[i]=='('){
+				if(!sw) sw=1;
+
+				i3=GetStringInPare(name+i2,sourceOfParams+i);
+				i2+=i3-1;
+				i+=i3-1;
+				continue;
+			}
+			if(sourceOfParams[i]=='['){
+				if(!sw) sw=1;
+
+				i3=GetStringInBracket(name+i2,sourceOfParams+i);
+				i2+=i3-1;
+				i+=i3-1;
+				continue;
+			}
+			if(!IsVariableChar(sourceOfParams[i])){
+				name[i2]=0;
+				break;
+			}
+			name[i2]=sourceOfParams[i];
+		}
+		if(sw){
+			//配列パラメータ
+			if( isRef == false ) SetError(29,NULL,nowLine);
+			isArray = true;
+
+			if((name[i2-2]=='('&&name[i2-1]==')')||
+				(name[i2-2]=='['&&name[i2-1]==']')){
+				subScripts[0]=LONG_MAX;
+				subScripts[1]=-1;
+
+				name[i2-2]=0;
+			}
+			else{
+				GetArrange(name,temp2,subScripts);
+				lstrcpy(name,temp2);
+			}
+
+			i2=lstrlen(name);
+		}
+
+		//型
+		Type type( DEF_NON );
+		if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
+			i+=2;
+
+			i2=0;
+			while(sourceOfParams[i]=='*'){
+				temporary[i2]=sourceOfParams[i];
+				i++;
+				i2++;
+			}
+			for(;;i++,i2++){
+				if(!IsVariableChar(sourceOfParams[i])){
+					if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){
+						temporary[i2++]=sourceOfParams[i++];
+						temporary[i2]=sourceOfParams[i];
+						continue;
+					}
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=sourceOfParams[i];
+			}
+
+			Type::StringToType( temporary, type );
+
+			if(temporary[0]=='*'&&
+				temporary[1]==1&&
+				(temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){
+				if(sourceOfParams[i]!='('){
+					SetError(10,temporary,nowLine);
+					break;
+				}
+				i3=GetStringInPare(temporary+i2,sourceOfParams+i);
+				i+=i3;
+				i2+=i3;
+
+				if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
+					temporary[i2++]=sourceOfParams[i++];
+					temporary[i2++]=sourceOfParams[i++];
+					for(;;i++,i2++){
+						if(!IsVariableChar(sourceOfParams[i])){
+							temporary[i2]=0;
+							break;
+						}
+						temporary[i2]=sourceOfParams[i];
+					}
+				}
+			}
+			else{
+				//TypeDefをする前のベース型を取得
+				GetOriginalTypeName(temporary);
+			}
+
+			if( type.IsNull() ){
+				SetError(3,temporary,nowLine);
+				type.SetBasicType( DEF_PTR_VOID );
+			}
+		}
+		else{
+			type.SetBasicType( GetTypeFromSimpleName(temporary) );
+			SetError(-103,temporary,nowLine);
+		}
+
+		if( type.IsProcPtr() ){
+			//関数ポインタの場合
+			type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine) );
+		}
+
+		Parameter *pParam = new Parameter( name, type, isRef );
+		if( isArray ){
+			pParam->SetArray( subScripts );
+		}
+
+		//パラメータを追加
+		this->params.push_back( pParam );
+
+		if(sourceOfParams[i]==','){
+			i++;
+			continue;
+		}
+		else if(sourceOfParams[i]==')') continue;
+		else{
+			SetError(1,NULL,nowLine);
+			break;
+		}
+	}
+	this->secondParmNum = (int)this->params.size();
+	i++;
+	if(sourceOfParams[i]=='('){
+		i++;
+		while(1){
+			if(sourceOfParams[i]==')') break;
+
+			//ByRef
+			bool isRef;
+			if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){
+				isRef = false;
+				i+=2;
+			}
+			else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){
+				isRef = true;
+				i+=2;
+			}
+			else isRef = false;
+
+			//パラメータ名
+			bool isArray = false;
+			int subScripts[MAX_ARRAYDIM];
+			char name[VN_SIZE];
+			sw=0;
+			for(i2=0;;i++,i2++){
+				if(sourceOfParams[i]=='('){
+					if(!sw) sw=1;
+
+					i3=GetStringInPare(name+i2,sourceOfParams+i);
+					i2+=i3-1;
+					i+=i3-1;
+					continue;
+				}
+				if(sourceOfParams[i]=='['){
+					if(!sw) sw=1;
+
+					i3=GetStringInBracket(name+i2,sourceOfParams+i);
+					i2+=i3-1;
+					i+=i3-1;
+					continue;
+				}
+				if(!IsVariableChar(sourceOfParams[i])){
+					name[i2]=0;
+					break;
+				}
+				name[i2]=sourceOfParams[i];
+			}
+			if(sw){
+				//配列パラメータ
+				if( isRef == false ) SetError(29,NULL,nowLine);
+				isArray = true;
+
+				if((name[i2-2]=='('&&name[i2-1]==')')||
+					(name[i2-2]=='['&&name[i2-1]==']')){
+					subScripts[0]=LONG_MAX;
+					subScripts[1]=-1;
+
+					name[i2-2]=0;
+				}
+				else{
+					GetArrange(name,temp2,subScripts);
+					lstrcpy(name,temp2);
+				}
+
+				i2=lstrlen(name);
+			}
+
+			//型
+			Type type( DEF_NON );
+			if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
+				i+=2;
+
+				i2=0;
+				while(sourceOfParams[i]=='*'){
+					temporary[i2]=sourceOfParams[i];
+					i++;
+					i2++;
+				}
+				for(;;i++,i2++){
+					if(!IsVariableChar(sourceOfParams[i])){
+						if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){
+							temporary[i2++]=sourceOfParams[i++];
+							temporary[i2]=sourceOfParams[i];
+							continue;
+						}
+						temporary[i2]=0;
+						break;
+					}
+					temporary[i2]=sourceOfParams[i];
+				}
+
+				Type::StringToType( temporary, type );
+
+				if(temporary[0]=='*'&&
+					temporary[1]==1&&
+					(temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){
+					if(sourceOfParams[i]!='('){
+						SetError(10,temporary,nowLine);
+						break;
+					}
+					i3=GetStringInPare(temporary+i2,sourceOfParams+i);
+					i+=i3;
+					i2+=i3;
+
+					if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
+						temporary[i2++]=sourceOfParams[i++];
+						temporary[i2++]=sourceOfParams[i++];
+						for(;;i++,i2++){
+							if(!IsVariableChar(sourceOfParams[i])){
+								temporary[i2]=0;
+								break;
+							}
+							temporary[i2]=sourceOfParams[i];
+						}
+					}
+				}
+				else{
+					//TypeDefをする前のベース型を取得
+					GetOriginalTypeName(temporary);
+				}
+
+				if( type.IsNull() ){
+					SetError(3,temporary,nowLine);
+					type.SetBasicType( DEF_PTR_VOID );
+				}
+			}
+			else{
+				type.SetBasicType( GetTypeFromSimpleName(temporary) );
+				SetError(-103,temporary,nowLine);
+			}
+
+			if( type.IsProcPtr() ){
+				//関数ポインタの場合
+				type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine) );
+			}
+
+			Parameter *pParam = new Parameter( name, type, isRef );
+			if( isArray ){
+				pParam->SetArray( subScripts );
+			}
+
+			//パラメータを追加
+			this->params.push_back( pParam );
+
+			if(sourceOfParams[i]==','){
+				i++;
+				continue;
+			}
+			else if(sourceOfParams[i]==')') continue;
+			else{
+				SetError(1,NULL,nowLine);
+				break;
+			}
+		}
+		i++;
+	}
+
+	if(sourceOfParams[i]){
+		///////////////////
+		// 戻り値を取得
+		///////////////////
+
+		if( !this->IsFunction() ){
+			// Sub/Macroの場合
+			SetError(38,this->GetName(),nowLine);
+		}
+
+		if( this->pParentClass ){
+			if( this->GetName() == this->pParentClass->name ||
+				this->GetName()[0]=='~'){
+				//クラスのコンストラクタ、デストラクタがFunction定義の場合はエラーをだす
+				SetError(115,NULL,nowLine);
+			}
+		}
+
+
+		i2=lstrlen(sourceOfParams)-2;
+
+		int sw_as=0;
+		for(;i2>0;i2--){
+			if(sourceOfParams[i2]==')') break;
+
+			if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){
+				i2+=2;
+				i3=0;
+				while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++];
+				for(;;i2++,i3++){
+					if(!IsVariableChar(sourceOfParams[i2])){
+						temporary[i3]=0;
+						break;
+					}
+					temporary[i3]=sourceOfParams[i2];
+				}
+				Type::StringToType( temporary, this->returnType );
+				if( this->returnType.IsNull() ) SetError(3,temporary,nowLine);
+
+				sw_as=1;
+				break;
+			}
+		}
+
+		if(!sw_as){
+			SetError(-104,this->GetName().c_str(),nowLine);
+
+			this->returnType.SetBasicType( DEF_DOUBLE );
+		}
+	}
+	else{
+		//戻り値なしのSub定義
+		this->returnType.SetNull();
+	}
+
+	//リアルパラメータ領域を取得（_System_LocalThisを考慮して2つだけ多く確保する場合がある）
+
+	if( this->pParentClass && isStatic == false ){
+		//オブジェクトメンバの場合は、第一パラメータを_System_LocalThis引き渡し用として利用
+		string name = "_System_LocalThis";
+		Type type( DEF_PTR_VOID );
+		this->realParams.push_back( new Parameter( name, type ) );
+	}
+
+	if( this->returnType.IsStruct() ){
+		//構造体を戻り値として持つ場合
+		//※第一パラメータ（Thisポインタありの場合は第二パラメータ）を戻り値用の参照宣言にする
+
+		string name = this->GetName();
+		if(name[0]==1&&name[1]==ESC_OPERATOR){
+			name="_System_ReturnValue";
+		}
+		Type type( DEF_STRUCT, this->returnType.GetIndex() );
+		this->realParams.push_back( new Parameter( name, type, true ) );
+	}
+
+	//パラメータをコピー
+	foreach( Parameter *pParam, params ){
+		this->realParams.push_back( new Parameter( *pParam ) );
+	}
+
+	return true;
 }
+
+bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
+	int i = 0;
+	int i2,i3,sw;
+	char temporary[8192],temp2[VN_SIZE];
+
+	//ソースコードの位置
+	this->codePos = nowLine;
+
+	//パラメータ
+	if(sourceOfParams[i]!='('){
+		SetError(1,NULL,nowLine);
+		return 0;
+	}
+	i++;
+
+	while(1){
+		if(sourceOfParams[i]==')') break;
+
+		//ByRef
+		bool isRef;
+		if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){
+			isRef = false;
+			i+=2;
+		}
+		else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){
+			isRef = true;
+			i+=2;
+		}
+		else isRef = false;
+
+		//パラメータ名
+		bool isArray = false;
+		int subScripts[MAX_ARRAYDIM];
+		char name[VN_SIZE];
+		sw=0;
+		for(i2=0;;i++,i2++){
+			if(sourceOfParams[i]=='('){
+				if(!sw) sw=1;
+
+				i3=GetStringInPare(name+i2,sourceOfParams+i);
+				i2+=i3-1;
+				i+=i3-1;
+				continue;
+			}
+			if(sourceOfParams[i]=='['){
+				if(!sw) sw=1;
+
+				i3=GetStringInBracket(name+i2,sourceOfParams+i);
+				i2+=i3-1;
+				i+=i3-1;
+				continue;
+			}
+			if(!IsVariableChar(sourceOfParams[i])){
+				name[i2]=0;
+				break;
+			}
+			name[i2]=sourceOfParams[i];
+		}
+		if(sw){
+			//配列パラメータ
+			if( isRef == false ) SetError(29,NULL,nowLine);
+			isArray = true;
+
+			if((name[i2-2]=='('&&name[i2-1]==')')||
+				(name[i2-2]=='['&&name[i2-1]==']')){
+				subScripts[0]=LONG_MAX;
+				subScripts[1]=-1;
+
+				name[i2-2]=0;
+			}
+			else{
+				GetArrange(name,temp2,subScripts);
+				lstrcpy(name,temp2);
+			}
+
+			i2=lstrlen(name);
+		}
+
+		//型
+		Type type( DEF_NON );
+		if(lstrcmp(name,"...")==0) type.SetBasicType( DEF_ELLIPSE );
+		else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
+			i+=2;
+
+			i2=0;
+			while(sourceOfParams[i]=='*'){
+				temporary[i2]=sourceOfParams[i];
+				i++;
+				i2++;
+			}
+			for(;;i++,i2++){
+				if(!IsVariableChar(sourceOfParams[i])){
+					if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){
+						temporary[i2++]=sourceOfParams[i++];
+						temporary[i2]=sourceOfParams[i];
+						continue;
+					}
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=sourceOfParams[i];
+			}
+
+			Type::StringToType( temporary, type );
+
+			if(temporary[0]=='*'&&
+				temporary[1]==1&&
+				(temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){
+				if(sourceOfParams[i]!='('){
+					SetError(10,temporary,nowLine);
+					break;
+				}
+				i3=GetStringInPare(temporary+i2,sourceOfParams+i);
+				i+=i3;
+				i2+=i3;
+
+				if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
+					temporary[i2++]=sourceOfParams[i++];
+					temporary[i2++]=sourceOfParams[i++];
+					for(;;i++,i2++){
+						if(!IsVariableChar(sourceOfParams[i])){
+							temporary[i2]=0;
+							break;
+						}
+						temporary[i2]=sourceOfParams[i];
+					}
+				}
+			}
+			else{
+				//TypeDefをする前のベース型を取得
+				GetOriginalTypeName(temporary);
+			}
+
+			if( type.IsNull() ){
+				SetError(3,temporary,nowLine);
+				type.SetBasicType( DEF_PTR_VOID );
+			}
+		}
+		else{
+			type.SetBasicType( GetTypeFromSimpleName(temporary) );
+			SetError(-103,temporary,nowLine);
+		}
+
+		if( type.IsProcPtr() ){
+			//関数ポインタの場合
+			type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine ) );
+		}
+
+		Parameter *pParam = new Parameter( name, type, isRef );
+		if( isArray ){
+			pParam->SetArray( subScripts );
+		}
+
+		//パラメータを追加
+		this->params.push_back( pParam );
+
+		if(sourceOfParams[i]==','){
+			i++;
+			continue;
+		}
+		else if(sourceOfParams[i]==')') continue;
+		else{
+			SetError(1,NULL,nowLine);
+			break;
+		}
+	}
+	i++;
+
+	if(sourceOfParams[i]){
+		///////////////////
+		// 戻り値を取得
+		///////////////////
+
+		i2=lstrlen(sourceOfParams)-2;
+
+		int sw_as=0;
+		for(;i2>0;i2--){
+			if(sourceOfParams[i2]==')') break;
+
+			if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){
+				i2+=2;
+				i3=0;
+				while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++];
+				for(;;i2++,i3++){
+					if(!IsVariableChar(sourceOfParams[i2])){
+						temporary[i3]=0;
+						break;
+					}
+					temporary[i3]=sourceOfParams[i2];
+				}
+				Type::StringToType( temporary, this->returnType );
+				if( this->returnType.IsNull() ) SetError(3,temporary,nowLine);
+
+				sw_as=1;
+				break;
+			}
+		}
+	}
+	else{
+		//戻り値なしのSub定義
+		this->returnType.SetNull();
+	}
+
+	return true;
+}
+
+bool ProcPointer::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){
+	int i = 0;
+	int i2,i3,sw;
+	char temporary[8192],temp2[VN_SIZE];
+
+	//ソースコードの位置
+	this->codePos = nowLine;
+
+	//パラメータ
+	if(sourceOfParams[i]!='('){
+		SetError(1,NULL,nowLine);
+		return 0;
+	}
+	i++;
+	while(1){
+		if(sourceOfParams[i]==')') break;
+
+		//ByRef
+		bool isRef;
+		if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){
+			isRef = false;
+			i+=2;
+		}
+		else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){
+			isRef = true;
+			i+=2;
+		}
+		else isRef = false;
+
+		//パラメータ名
+		bool isArray = false;
+		int subScripts[MAX_ARRAYDIM];
+		char name[VN_SIZE];
+		sw=0;
+		for(i2=0;;i++,i2++){
+			if(sourceOfParams[i]=='('){
+				if(!sw) sw=1;
+
+				i3=GetStringInPare(name+i2,sourceOfParams+i);
+				i2+=i3-1;
+				i+=i3-1;
+				continue;
+			}
+			if(sourceOfParams[i]=='['){
+				if(!sw) sw=1;
+
+				i3=GetStringInBracket(name+i2,sourceOfParams+i);
+				i2+=i3-1;
+				i+=i3-1;
+				continue;
+			}
+			if(!IsVariableChar(sourceOfParams[i])){
+				name[i2]=0;
+				break;
+			}
+			name[i2]=sourceOfParams[i];
+		}
+		if(sw){
+			//配列パラメータ
+			if( isRef == false ) SetError(29,NULL,nowLine);
+			isArray = true;
+
+			if((name[i2-2]=='('&&name[i2-1]==')')||
+				(name[i2-2]=='['&&name[i2-1]==']')){
+				subScripts[0]=LONG_MAX;
+				subScripts[1]=-1;
+
+				name[i2-2]=0;
+			}
+			else{
+				GetArrange(name,temp2,subScripts);
+				lstrcpy(name,temp2);
+			}
+
+			i2=lstrlen(name);
+		}
+
+		//型
+		Type type( DEF_NON );
+		if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
+			i+=2;
+
+			i2=0;
+			while(sourceOfParams[i]=='*'){
+				temporary[i2]=sourceOfParams[i];
+				i++;
+				i2++;
+			}
+			for(;;i++,i2++){
+				if(!IsVariableChar(sourceOfParams[i])){
+					if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){
+						temporary[i2++]=sourceOfParams[i++];
+						temporary[i2]=sourceOfParams[i];
+						continue;
+					}
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=sourceOfParams[i];
+			}
+
+			Type::StringToType( temporary, type );
+
+			if(temporary[0]=='*'&&
+				temporary[1]==1&&
+				(temporary[2]==ESC_FUNCTION||temporary[2]==ESC_SUB)){
+				if(sourceOfParams[i]!='('){
+					SetError(10,temporary,nowLine);
+					break;
+				}
+				i3=GetStringInPare(temporary+i2,sourceOfParams+i);
+				i+=i3;
+				i2+=i3;
+
+				if(temporary[2]==ESC_FUNCTION&&sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){
+					temporary[i2++]=sourceOfParams[i++];
+					temporary[i2++]=sourceOfParams[i++];
+					for(;;i++,i2++){
+						if(!IsVariableChar(sourceOfParams[i])){
+							temporary[i2]=0;
+							break;
+						}
+						temporary[i2]=sourceOfParams[i];
+					}
+				}
+			}
+			else{
+				//TypeDefをする前のベース型を取得
+				GetOriginalTypeName(temporary);
+			}
+
+			if( type.IsNull() ){
+				SetError(3,temporary,nowLine);
+				type.SetBasicType( DEF_PTR_VOID );
+			}
+		}
+		else{
+			type.SetBasicType( GetTypeFromSimpleName(temporary) );
+			SetError(-103,temporary,nowLine);
+		}
+
+		if( type.IsProcPtr() ){
+			//関数ポインタの場合
+			type.SetIndex( AddProcPtrInfo(temporary+3,temporary[2], nowLine ) );
+		}
+
+		Parameter *pParam = new Parameter( name, type, isRef );
+		if( isArray ){
+			pParam->SetArray( subScripts );
+		}
+
+		//パラメータを追加
+		this->params.push_back( pParam );
+
+		if(sourceOfParams[i]==','){
+			i++;
+			continue;
+		}
+		else if(sourceOfParams[i]==')') continue;
+		else{
+			SetError(1,NULL,nowLine);
+			break;
+		}
+	}
+	i++;
+
+	if(sourceOfParams[i]){
+		///////////////////
+		// 戻り値を取得
+		///////////////////
+
+		i2=lstrlen(sourceOfParams)-2;
+
+		int sw_as=0;
+		for(;i2>0;i2--){
+			if(sourceOfParams[i2]==')') break;
+
+			if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){
+				i2+=2;
+				i3=0;
+				while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++];
+				for(;;i2++,i3++){
+					if(!IsVariableChar(sourceOfParams[i2])){
+						temporary[i3]=0;
+						break;
+					}
+					temporary[i3]=sourceOfParams[i2];
+				}
+				Type::StringToType( temporary, this->returnType );
+				if( this->returnType.IsNull() ) SetError(3,temporary,nowLine);
+
+				sw_as=1;
+				break;
+			}
+		}
+	}
+	else{
+		//戻り値なしのSub定義
+		this->returnType.SetNull();
+	}
+
+	//戻り値のエラーチェック
+	if( IsFunction() ){
+		// Function定義
+
+		if( this->ReturnType().IsNull() ){
+			// 戻り値がない
+			SetError(26,this->GetName(),nowLine);
+		}
+	}
+	else{
+		if( !this->ReturnType().IsNull() ){
+			// Sub定義なのに、戻り値がある
+			SetError(38,this->GetName(),nowLine);
+		}
+	}
+
+	return true;
+}
+
+UserProc *UserProc::pCompilingUserProc = NULL;
