Пример #1
0
        internal static SpssVariable LoadVariable(SpssVariablesCollection parent, string varName, int varType)
        {
            FormatTypeCode writeFormat, printFormat;
            int            writeDecimal, writeWidth, printDecimal, printWidth;

            SpssException.ThrowOnFailure(SpssSafeWrapper.spssGetVarWriteFormat(parent.Document.Handle, varName, out writeFormat, out writeDecimal, out writeWidth), "spssGetVarWriteFormat");
            SpssException.ThrowOnFailure(SpssSafeWrapper.spssGetVarPrintFormat(parent.Document.Handle, varName, out printFormat, out printDecimal, out printWidth), "spssGetVarPrintFormat");

            SpssVariable variable;

            switch (varType)
            {
            case 0:
                // This may be a date or a numeric
                if (SpssDateVariable.IsDateVariable(writeFormat))
                {
                    variable = new SpssDateVariable(parent, varName, writeFormat, writeWidth, printFormat, printWidth);
                }
                else
                {
                    variable = new SpssNumericVariable(parent, varName, writeFormat, writeDecimal, writeWidth, printFormat, printDecimal, printWidth);
                }

                break;

            default:
                Debug.Assert(varType == printWidth);
                variable = new SpssStringVariable(parent, varName, varType);
                break;
            }

            return(variable);
        }
Пример #2
0
 protected override bool IsApplicableFormatTypeCode(FormatTypeCode formatType)
 {
     return(formatType != FormatTypeCode.SPSS_FMT_A &&
            !SpssDateVariable.IsDateVariable(formatType));
 }