Beispiel #1
0
        ///<summary>
        ///Returns a string containing the element from the current segment.
        ///</summary>
        ///<param name="elementNumber">The element number that you want to return</param>
        public String Element(int elementNumber)
        {
            int count        = 0;
            int startIndex   = 0;
            int endIndex     = 0;
            int currentIndex = 0;

            while (count < elementNumber && currentIndex != -1)
            {
                currentIndex = LineText.IndexOf(x12File.elementDelimiter, startIndex);
                startIndex   = currentIndex + 1;
                count++;
            }

            if (currentIndex != -1)
            {
                endIndex = LineText.IndexOf(x12File.elementDelimiter, startIndex);
                if (endIndex == -1)
                {
                    endIndex = LineText.Length;
                }
                return(LineText.Substring(startIndex, endIndex - startIndex));
            }
            else
            {
                return(String.Empty);
            }
        }
Beispiel #2
0
        internal int AddFixedSegment(int segmentTextStart, int segmentTextEnd)
        {
            if (segmentTextEnd < segmentTextStart)
            {
                return(-1);
            }

            LineSegments.Add(
                new PcLineSegment(
                    LineText.Substring(
                        segmentTextStart,
                        segmentTextEnd - segmentTextStart + 1
                        )
                    )
                );

            //Return the location of the start of the next segment
            return(segmentTextEnd + 1);
        }