Пример #1
0
        public void ReadVariableRecord()
        {
            var valueLength      = _reader.ReadInt32();
            var hasVariableLabel = _reader.ReadInt32() == 1;
            var missingValueType = _reader.ReadInt32();

            _reader.ReadInt32(); //print format
            var decimalPlaces = _reader.ReadByte();
            var spssWidth     = _reader.ReadByte();
            var formatType    = _reader.ReadByte();

            _reader.ReadByte();
            var shortName = _reader.ReadBytes(8);

            var properties = new VariableProperties {
                FormatType = (FormatType)formatType, Index = _currentIndex, MissingValueType = missingValueType, ShortName = shortName, DecimalPlaces = decimalPlaces
            };

            if (hasVariableLabel)
            {
                properties.Label = ReadLabel();
            }
            if (Math.Abs(missingValueType) != 0)
            {
                ReadMissing(properties);
            }

            var blockWidth = ReadBlankRecords(valueLength);

            properties.ValueLength = blockWidth;
            properties.SpssWidth   = formatType == (int)FormatType.A ? blockWidth : spssWidth;
            _metadataInfo.Variables.Add(properties);
            _currentIndex += SpssMath.GetNumberOf32ByteBlocks(blockWidth);
        }
Пример #2
0
        private void settingsButton_Click(object sender, EventArgs e)
        {
            VariableProperties variableProperties = new VariableProperties(VCode);

            if (variableProperties.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Variable = variableProperties.Variable;
            VCode    = Variable;
            UpdateName();
        }
Пример #3
0
        private void variableToolStripMenuItem_Click(object sender, EventArgs e)
        {
            VariableProperties variableProperties = new VariableProperties();

            if (variableProperties.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Vvariable vvariable = new Vvariable(variableProperties.Variable);

            GlobalScopePanel.Controls.Add(vvariable);
            UpdateScope();
        }
Пример #4
0
        private Variable CreateVariable(string shortName, string label, VariableProperties properties)
        {
            var variable = Variable.Create(shortName, label == string.Empty ? null : label, properties.FormatType, properties.SpssWidth, properties.DecimalPlaces);

            variable.MissingValueType = (MissingValueType)properties.MissingValueType;
            if (properties.Missing == null)
            {
                return(variable);
            }
            variable.MissingValues = variable.FormatType == FormatType.A
                ? properties.Missing.Select(y => (object)_encoding.GetString(y).TrimEnd()).ToArray()
                : properties.Missing.Select(y => (object)BitConverter.ToDouble(y)).ToArray();
            return(variable);
        }
Пример #5
0
 private void ReadMissing(VariableProperties properties)
 {
     properties.Missing = Enumerable.Range(0, Math.Abs(properties.MissingValueType)).Select(_ => _reader.ReadBytes(8)).ToArray();
 }