public int GetNumFieldValues(byte fieldNum, ushort subfieldIndex)
        {
            Field field = GetField(fieldNum);

            if (field == null)
            {
                return(0);
            }

            if (subfieldIndex == Fit.SubfieldIndexActiveSubfield)
            {
                return(field.GetNumValues());
            }

            Subfield subfield = field.GetSubfield(subfieldIndex);

            if ((subfield == null) || (subfield.CanMesgSupport(this)))
            {
                return(field.GetNumValues());
            }
            else
            {
                return(0);
            }
        }
        public int GetNumFieldValues(byte fieldNum)
        {
            Field field = GetField(fieldNum);

            if (field != null)
            {
                return(field.GetNumValues());
            }
            return(0);
        }
        public int GetNumFieldValues(String fieldName)
        {
            Field field = GetField(fieldName);

            if (field != null)
            {
                return(field.GetNumValues());
            }
            return(0);
        }
        public int GetNumFieldValues(byte fieldNum, string subfieldName)
        {
            Field field = GetField(fieldNum);

            if (field == null)
            {
                return(0);
            }

            Subfield subfield = field.GetSubfield(subfieldName);

            if ((subfield == null) || (subfield.CanMesgSupport(this)))
            {
                return(field.GetNumValues());
            }
            else
            {
                return(0);
            }
        }
        public void Write(Stream outStream, MesgDefinition mesgDef)
        {
            if (mesgDef == null)
            {
                mesgDef = new MesgDefinition(this);
            }

            EndianBinaryWriter bw = new EndianBinaryWriter(outStream, mesgDef.IsBigEndian);

            bw.Write(LocalNum);

            foreach (FieldDefinition fieldDef in mesgDef.GetFields())
            {
                Field field = GetField(fieldDef.Num);
                if (field == null)
                {
                    field = Profile.GetField(this.Num, fieldDef.Num);
                    fields.Add(field);
                }
                // The field could be blank, correctly formed or partially filled
                while (field.GetSize() < fieldDef.Size)
                {
                    field.AddValue(Fit.BaseType[fieldDef.Type & Fit.BaseTypeNumMask].invalidValue);
                }

                for (int i = 0; i < field.GetNumValues(); i++)
                {
                    object value = field.GetRawValue(i);
                    if (value == null)
                    {
                        value = Fit.BaseType[fieldDef.Type & Fit.BaseTypeNumMask].invalidValue;
                    }
                    switch (fieldDef.Type & Fit.BaseTypeNumMask)
                    {
                    case Fit.Enum:
                    case Fit.Byte:
                    case Fit.UInt8:
                    case Fit.UInt8z:
                        bw.Write((byte)value);
                        break;

                    case Fit.SInt8:
                        bw.Write((sbyte)value);
                        break;

                    case Fit.SInt16:
                        bw.Write((short)value);
                        break;

                    case Fit.UInt16:
                    case Fit.UInt16z:
                        bw.Write((ushort)value);
                        break;

                    case Fit.SInt32:
                        bw.Write((int)value);
                        break;

                    case Fit.UInt32:
                    case Fit.UInt32z:
                        bw.Write((uint)value);
                        break;

                    case Fit.Float32:
                        bw.Write((float)value);
                        break;

                    case Fit.Float64:
                        bw.Write((double)value);
                        break;

                    case Fit.String:
                        bw.Write((byte[])value);
                        // Write the null terminator
                        bw.Write((byte)0x00);
                        break;

                    default:
                        break;
                    }
                }
            }
        }