hpconvert.java
来自「一个简单的visio程序。」· Java 代码 · 共 1,924 行 · 第 1/4 页
JAVA
1,924 行
{
return new VString( OCT$(expression) );
}
public static Variant OCT(HCurr expression) throws HpException
{
return new VString( OCT$(expression) );
}
public static Variant OCT(HDate expression) throws HpException
{
return new VString( OCT$(expression) );
}
public static Variant OCT(fixedString expression) throws HpException
{
return new VString( OCT$(expression) );
}
public static Variant OCT(String expression) throws HpException
{
return new VString( OCT$(expression) );
}
/**
*CInt(expression)
*Converts an expression to an Integer.
*/
public static short CINT(Variant expression) throws HpException
{
int number=0;
double d = hpstring.get_db(expression);
number = hpstring.dbl2int( d );
if( number<-32768 || number>32767 )
throw new HpException(6, "Overflow");
return (short)number;
}
public static short CINT(boolean expression) throws HpException
{
return expression==true ? (short)-1:(short)0;
}
public static short CINT(HByte expression) throws HpException
{
return (short)(expression.byteValue());
}
public static short CINT(short expression) throws HpException
{
return expression;
}
public static short CINT(int expression) throws HpException
{
if( expression<-32768 || expression>32767 )
throw new HpException(6, "Overflow");
return (short)expression;
}
public static short CINT(float expression) throws HpException
{
if( expression<-32768 || expression>32767 )
throw new HpException(6, "Overflow");
int number = hpstring.dbl2int( (double)expression );
return (short)number;
}
public static short CINT(double expression) throws HpException
{
if( expression<-32768 || expression>32767 )
throw new HpException(6, "Overflow");
int number = hpstring.dbl2int(expression);
return (short)number;
}
public static short CINT(HCurr expression) throws HpException
{
double d = expression.dblValue();
if( d<-32768 || d>32767 )
throw new HpException(6, "Overflow");
int number = hpstring.dbl2int(d);
return (short)number;
}
public static short CINT(HDate expression) throws HpException
{
double d = expression.dblValue();
if( d<-32768 || d>32767 )
throw new HpException(6, "Overflow");
int number = hpstring.dbl2int(d);
return (short)number;
}
public static short CINT(fixedString expression) throws HpException
{
String s = expression.strValue();
double d = hpstring.strtodbl(s);
if( d<-32768 || d>32767 )
throw new HpException(6, "Overflow");
int number = hpstring.dbl2int(d);
return (short)number;
}
public static short CINT(String expression) throws HpException
{
double d = hpstring.strtodbl(expression);
if( d<-32768 || d>32767 )
throw new HpException(6, "Overflow");
int number = hpstring.dbl2int(d);
return (short)number;
}
/**
*CLng(expression)
*Converts an expression to an long.
*/
public static int CLNG( Variant exp) throws HpException
{
int tmp;
double d = hpstring.get_db( exp );
if(d>Integer.MAX_VALUE || d<Integer.MIN_VALUE)
throw new HpException(6,"Overflow");
tmp = hpstring.dbl2int(d);
return tmp ;
}
public static int CLNG( boolean exp) throws HpException
{
return exp==true ? -1:0;
}
public static int CLNG( HByte exp) throws HpException
{
return (int)(exp.byteValue());
}
public static int CLNG( short exp) throws HpException
{
return (int)exp;
}
public static int CLNG( int exp) throws HpException
{
return exp;
}
public static int CLNG( float exp) throws HpException
{
if(exp>Integer.MAX_VALUE || exp<Integer.MIN_VALUE)
throw new HpException(6,"Overflow");
return hpstring.dbl2int((double)exp);
}
public static int CLNG( double exp) throws HpException
{
if(exp>Integer.MAX_VALUE || exp<Integer.MIN_VALUE)
throw new HpException(6,"Overflow");
return hpstring.dbl2int(exp);
}
public static int CLNG( HCurr exp) throws HpException
{
double d = exp.dblValue();
if(d>Integer.MAX_VALUE || d<Integer.MIN_VALUE)
throw new HpException(6,"Overflow");
return hpstring.dbl2int(d);
}
public static int CLNG( HDate exp) throws HpException
{
double d = exp.dblValue();
if(d>Integer.MAX_VALUE || d<Integer.MIN_VALUE)
throw new HpException(6,"Overflow");
return hpstring.dbl2int(d);
}
public static int CLNG( fixedString exp) throws HpException
{
String s = exp.strValue();
double d = hpstring.strtodbl(s);
if(d>Integer.MAX_VALUE || d<Integer.MIN_VALUE)
throw new HpException(6,"Overflow");
return hpstring.dbl2int(d);
}
public static int CLNG( String exp) throws HpException
{
double d = hpstring.strtodbl(exp);
if(d>Integer.MAX_VALUE || d<Integer.MIN_VALUE)
throw new HpException(6,"Overflow");
return hpstring.dbl2int(d);
}
/**
*CSng(expression)
*Converts an expression to a Single.
*/
public static float CSNG(Variant exp ) throws HpException
{
float f = exp.sglValue();
if( Float.isInfinite(f) || Float.isNaN(f) )
throw new HpException(6,"Overflow");
return f;
}
public static float CSNG(boolean exp ) throws HpException
{
return exp==true ? (float)-1:(float)0;
}
public static float CSNG(HByte exp ) throws HpException
{
return (float)(exp.byteValue());
}
public static float CSNG(short exp ) throws HpException
{
return (float)exp;
}
public static float CSNG(int exp ) throws HpException
{
return (float)exp;
}
public static float CSNG(float exp ) throws HpException
{
return exp;
}
public static float CSNG(HCurr exp ) throws HpException
{
float f = exp.sglValue();
if( Float.isInfinite(f) || Float.isNaN(f) )
throw new HpException(6,"Overflow");
return f;
}
public static float CSNG(HDate exp ) throws HpException
{
float f = exp.sglValue();
if( Float.isInfinite(f) || Float.isNaN(f) )
throw new HpException(6,"Overflow");
return f;
}
public static float CSNG(fixedString exp ) throws HpException
{
String s = exp.strValue();
float f = (float)(hpstring.strtodbl(s) );
if( Float.isInfinite(f) || Float.isNaN(f) )
throw new HpException(6,"Overflow");
return f;
}
public static float CSNG(String exp ) throws HpException
{
float f = (float)(hpstring.strtodbl(exp) );
if( Float.isInfinite(f) || Float.isNaN(f) )
throw new HpException(6,"Overflow");
return f;
}
/**
*CDbl(expression)
*Converts an expression to a double.
*/
public static double CDBL(Variant exp) throws HpException
{
double d = hpstring.get_db( exp);
if( Double.isInfinite(d) || Double.isNaN(d) )
throw new HpException(6,"Overflow");
return d;
}
public static double CDBL(boolean exp) throws HpException
{
return exp==true ? (double)-1:(double)0;
}
public static double CDBL(HByte exp) throws HpException
{
return (double)(exp.byteValue());
}
public static double CDBL(short exp) throws HpException
{
return (double)exp;
}
public static double CDBL(int exp) throws HpException
{
return (double)exp;
}
public static double CDBL(float exp) throws HpException
{
return (double)exp;
}
public static double CDBL(double exp) throws HpException
{
return exp;
}
public static double CDBL(HCurr exp) throws HpException
{
double d = exp.dblValue();
if( Double.isInfinite(d) || Double.isNaN(d) )
throw new HpException(6,"Overflow");
return d;
}
public static double CDBL(HDate exp) throws HpException
{
return exp.dblValue();
}
public static double CDBL(fixedString exp) throws HpException
{
String s = exp.strValue();
double d = hpstring.strtodbl(s);
if( Double.isInfinite(d) || Double.isNaN(d) )
throw new HpException(6,"Overflow");
return d;
}
public static double CDBL(String exp) throws HpException
{
double d = hpstring.strtodbl(exp);
if( Double.isInfinite(d) || Double.isNaN(d) )
throw new HpException(6,"Overflow");
return d;
}
/**
*CStr(expression)
*Converts an expression to a string.
*/
public static String CSTR(Variant exp) throws HpException
{
String str = hpstring.get_str(exp);
return str;
}
public static String CSTR(boolean exp) throws HpException
{
return (new Boolean(exp)).toString();
}
public static String CSTR(HByte exp) throws HpException
{
return exp.strValue();
}
public static String CSTR(short exp) throws HpException
{
return Short.toString(exp);
}
public static String CSTR(int exp) throws HpException
{
return Integer.toString(exp);
}
public static String CSTR(float exp) throws HpException
{
return Float.toString(exp);
}
public static String CSTR(double exp) throws HpException
{
return Double.toString(exp);
}
public static String CSTR(HCurr exp) throws HpException
{
return exp.strValue();
}
public static String CSTR(HDate exp) throws HpException
{
return exp.strValue();
}
public static String CSTR(fixedString exp) throws HpException
{
return new String( exp.getfixedString() );
}
public static String CSTR(String exp) throws HpException
{
return exp;
}
/**
*CByte(expression)
*Converts an expression to a byte.
*/
public static HByte CBYTE(Variant exp) throws HpException
{
short number=0;
int type = exp.getType();
switch (type)
{
case Variant.V_NULL:
throw new HpException(94,"Invalid use of null");
case Variant.V_EMPTY:
number = exp.intValue();
break;
case Variant.V_FIX_STR:
case Variant.V_STR:
int i_number = hpstring.dbl2int( hpstring.get_db( exp) );
if( i_number>255 || i_number<0 )
throw new HpException(6, "Overflow");
number = (short)i_number;
break;
case Variant.V_BYTE:
case Variant.V_INT:
case Variant.V_LONG:
case Variant.V_CURR:
case Variant.V_DBL:
case Variant.V_SINGLE:
case Variant.V_DATE:
case Variant.V_VAR:
int tmpint = hpstring.dbl2int( hpstring.get_db(exp) );
if( tmpint>255 || tmpint<0 )
throw new HpException(6, "Overflow");
number = (short)tmpint;
break;
case Variant.V_OBJ:
//Wrapper obj = exp.getObject();
//if( obj==null )
// throw new HpException( 91, "Object variable or With block variable not set");
boolean b = (((VObject)exp).getProperty("dfault")).boolValue();
number = (b) ? (short)255 : (short)0;
break;
case Variant.V_BOL:
boolean bol = exp.boolValue();
if( bol==true )
number = (short)255;
else
number = 0;
break;
default:
throw new HpException(13,"Type mismatch");
}
//result.HcAssign(new Variant(number));
return new HByte(number);
}
public static HByte CBYTE(boolean exp) throws HpException
{
if( exp==true )
return new HByte((short)255 );
else
return new HByte((short)0 );
}
public static HByte CBYTE(HByte exp) throws HpException
{
return new HByte(exp.byteValue());
}
public static HByte CBYTE(short exp) throws HpException
{
if( exp>255 || exp<0 )
throw new HpException(6, "Overflow");
return new HByte(exp);
}
public static HByte CBYTE(int exp) throws HpException
{
if( exp>255 || exp<0 )
throw new HpException(6, "Overflow");
return new HByte((short)exp);
}
public static HByte CBYTE(float exp) throws HpException
{
if( exp>255 || exp<0 )
throw new HpException(6, "Overflow");
return new HByte( (short)exp);
}
public static HByte CBYTE(double exp) throws HpException
{
if( exp>255 || exp<0 )
throw new HpException(6, "Overflow");
return new HByte((short)exp);
}
public static HByte CBYTE(HCurr exp) throws HpException
{
double d = exp.dblValue();
if( d>255 || d<0 )
throw new HpException(6, "Overflow");
return new HByte((short)( hpstring.dbl2int(d)));
}
public static HByte CBYTE(HDate exp) throws HpException
{
double d = exp.dblValue();
if( d>255 || d<0 )
throw new HpException(6,"Overflow");
return new HByte((short)(hpstring.dbl2int(d)));
}
public static HByte CBYTE(fixedString exp) throws HpException
{
String s = exp.strValue();
double d = hpstring.strtodbl(s);
if( d>255 || d<0 )
throw new HpException(6,"Overflow");
return new HByte( (short)(hpstring.dbl2int(d) ) );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?