sepString method

void sepString(
  1. ParamString string,
  2. String sep
)

Implementation

void sepString( ParamString string, String sep ){
	String src = "";
	String dst = "";
	int top;
	int end;
	bool _float;
	bool _break;
	int len;

	src = string.str();
	dst = "";
	top = 0;
	while( true ){
		_float = false;

		// 先頭を求める
		_break = false;
		for( ; top < src.length; top++ ){
			switch( ClipMath.charAt( src, top ) ){
			case '+':
			case '-':
			case '.':
			case 'e':
			case 'E':
			case 'i':
			case 'I':
			case '_':
			case ClipGlobal.charFract:
			case ':':
				if( ClipMath.charAt( src, top ) == '.' ){
					_float = true;
				}
				dst += ClipMath.charAt( src, top );
				break;
			default:
				_break = true;
				break;
			}
			if( _break ){
				break;
			}
		}
		if( top >= src.length ){
			break;
		}

		// 末尾を求める
		_break = false;
		for( end = top + 1; end < src.length; end++ ){
			switch( ClipMath.charAt( src, end ) ){
			case '+':
			case '-':
			case '.':
			case 'e':
			case 'E':
			case 'i':
			case 'I':
			case '_':
			case ClipGlobal.charFract:
			case ':':
				_break = true;
				break;
			}
			if( _break ){
				break;
			}
		}

		for( len = end - top; len > 0; len-- ){
			dst += ClipMath.charAt( src, top );
			top++;
			if( !_float && (len != 1) && ((len % 3) == 1) ){
				dst += sep;
			}
		}
	}

	string.set( dst );
}