      *>----------------------------------------------------------------
      *> A dbcspicx stores a COBOL pic x(n) enabling you to treat data
      *> of this type as an object.
      *> This class provides the basic comparison operators, display
      *> mechanism and hashing methods for pic x items.
      *>
      *>#See class "picx".
      *>
      *> Copyright (C) 1991-1999 Micro Focus International Ltd.
      *>
      *>----------------------------------------------------------------
      $set linkcount(150)
      $set mfoo localcount(150)
       class-id. dbcspicx data is protected
               inherits from cobolpicx with data.

        object section.
        class-control.
           DBCScobolpicx is class "dbcspicx"
           intrinsic is class "intrnsic"
           cobolpicx is class "picx"
           characterarray is class "chararry"
           ValueSet is class "valueset"
           DBCSCharacterArray is class "dbcsarry"
           OrderedCollection is class "ordrdcll".

       working-storage section.
       01 dbcsEnvironmentStatus    pic x comp-5 external.
           88  isSBCSEnv value 1.
           88  isDBCSEnv value 2.
       01 maxBytesPerChar redefines
           dbcsEnvironmentStatus   pic x comp-5.

       class-object.

       object-storage section.
       01 numberOfCharacters pic x(4) comp-5.

      *>----------------------------------------------------------------
      *> PRIVATE. initialize class data
      *>----------------------------------------------------------------
       method-id. "initializeclass".

       procedure division.
           invoke super "initializeclass"
           move DBCSEnvironmentStatus to storagerequirements
           move 1 to numberOfCharacters
           exit method.
       end method "initializeclass".
      *>----------------------------------------------------------------
      *> PRIVATE. Set the length in characters of this intrinsic to the
      *> character size specified by lnkCharSize.
      *>----------------------------------------------------------------
       method-id. "SetLength".

       linkage section.
       01 lnkCharLength        pic s9(9) comp-5.

       procedure division using lnkCharLength.
           move lnkCharLength to numberOfCharacters
           multiply DBCSEnvironmentStatus by numberOfCharacters
                   giving storageRequirements
           exit method.
       end method "SetLength".
      *>----------------------------------------------------------------
      *> Return the base class dbcspicx for any clone of dbcspicx.
      *>----------------------------------------------------------------
       method-id. "baseClass".

       linkage section.
       01 lnkclass          usage object reference.

       procedure division returning lnkclass.
           set lnkclass to dbcspicx
           exit method.
       end method "baseClass".
      *>----------------------------------------------------------------
      *> Return the length in characters of this intrinsic
      *>----------------------------------------------------------------
       method-id. "size".

       linkage section.
       01 lnkCharLength        pic s9(9) comp-5.

       procedure division returning lnkCharLength.
           move numberOfCharacters to lnkCharLength
           exit method.
       end method "size".
      *>----------------------------------------------------------------
      *> Return the length in bytes of this intrinsic
      *>----------------------------------------------------------------
       method-id. "sizeInBytes".

       linkage section.
       01 lnkByteLength        pic s9(9) comp-5.

       procedure division returning lnkByteLength.
           move storageRequirements to lnkByteLength
           exit method.
       end method "sizeInBytes".

       end class-object.

       Object.

       object-storage section.
      *>-------------------------------------------------------------
      *> Return the length in bytes of this intrinsic object.
      *>-------------------------------------------------------------
       Method-id. "sizeInBytes".

       local-storage section.
       01 charSize                 pic s9(9) comp-5.

       linkage section.
       01 lnkByteSize              pic s9(9) comp-5.

       procedure division returning lnkByteSize.
           invoke selfClass "size" returning charSize
           invoke DBCSCharacterArray "StringLengthInBytes"
                               using instanceData(1:)
                                     charSize
                           returning lnkByteSize
           exit method.
       end method "sizeInBytes".
      *>----------------------------------------------------------------
      *> Return the length in characters of this intrinsic object.
      *>----------------------------------------------------------------
       method-id. "size".

       linkage section.
       01 lnkCharLength        pic s9(9) comp-5.

       procedure division returning lnkCharLength.
           invoke selfClass "size" returning lnkCharLength
           exit method.
       end method "size".
      *>----------------------------------------------------------------
      *> Return -1 if this dbcspicx is less than anArray.
      *> Return  0 if this dbcspicx is equal to anArray.
      *> Return +1 if this dbcspicx is greater than anArray.
      *>----------------------------------------------------------------
       method-id. "compareTo".

       local-storage section.
       01 aPtr                     usage pointer.
       01 byteSize                 pic x(4) comp-5.
       01 compareByteSize          pic x(4) comp-5.


       linkage section.
       01 anArray                   usage object reference.

       01 lnkResult                pic s9(9) comp-5.
          88 lnkLessThan                               value -1.
          88 lnkEqual                                  value  0.
          88 lnkGreaterThan                            value  1.

        01 lnkCompareValue.
           03 lnkByte              pic x occurs 1 to maxNumberBytes
                                       depending on compareByteSize.

       procedure division using anArray returning lnkResult.

           invoke self "sizeInBytes" returning byteSize
           invoke anArray "sizeInBytes" returning compareByteSize
           invoke self "malloc" using compareByteSize returning aPtr
           set address of lnkCompareValue to aPtr
           invoke anArray "getValue" returning lnkCompareValue
           if instanceData(1:byteSize) < lnkCompareValue
               set lnkLessThan to true
           else
               if instancedata(1:byteSize) > lnkCompareValue
                   set lnkGreaterThan to true
               else
                   set lnkEqual to true
               end-if
           end-if
           invoke self "dealloc" using aPtr
           exit method.
       end method "compareTo".
      *>----------------------------------------------------------------
      *> Return a new string stripped of all leading and trailing spaces
      *> If this method was invoked with an INVOKE AS a static will be
      *> returned, otherwise an object reference will be returned.
      *>----------------------------------------------------------------
       method-id. "trimBlanks".

       local-storage section.
       01 stringStartPosition          pic 9(4) comp.
       01 stringOffset                 pic 9(4) comp.
       01 charLengthInBytes            pic 9(2) comp.
          88 singleByteCharacter                       value 1.
          88 doubleByteCharacter                       value 2.
       01 DBCSspace                    pic xx.
       01 byteSize                     pic s9(9) comp-5.
       01 compareByteSize              pic s9(9) comp-5.
       01 compareCharSize              pic s9(9) comp-5.
       01 characterFoundStatus         pic x comp-5.
          88 noCharactersFound                         value 0.
          88 nonSpaceCharacterFound                    value 1.
       01 pseudoStringStart            pic s9(9) comp-5.
       01 pseudoStringEnd              pic s9(9) comp-5.
       01 pseudoCharSize               pic s9(9) comp-5.
       01 pseudoByteSize               pic s9(9) comp-5.
       01 aClass                       usage object reference.

       linkage section.
       01 lnkValue.
           03 lnkByte          pic x occurs 0 to maxNumberBytes
                                   depending on compareByteSize.

       procedure division returning lnkValue.

           move 1 to stringStartPosition
           move 1 to stringOffset
           move zero to charLengthInBytes
           set noCharactersFound to True
           invoke DBCScharacterArray "getDBCSspace" returning DBCSspace
           invoke self "sizeInBytes" returning byteSize
           perform until nonSpaceCharacterFound or
                         stringOffset > byteSize
               call "CBL_CLASSIFY_DBCS_CHAR" using
                 instanceData(1:byteSize)
                 stringStartPosition
                 stringOffset
                 CharLengthInBytes
               if singleByteCharacter
                   if instanceData(stringOffset:1)
                     = space
                       add charLengthInBytes to stringOffset
                   else
                       set nonSpaceCharacterFound to true
                   end-if
               else
                   if instanceData(stringOffset:2)
                     = DBCSSpace
                       add charLengthInBytes to stringOffset
                   else
                       set nonSpaceCharacterFound to true
                   end-if
               end-if
           end-perform
           move stringOffset to pseudoStringStart
       *>>
       *>> Check for trailing space characters.
       *>>
           if nonSpaceCharacterFound
               set noCharactersFound to true
               move 1 to stringStartPosition
               move byteSize to stringOffset
               move zero to charLengthInBytes
               perform until nonSpaceCharacterFound
                   call "CBL_CLASSIFY_DBCS_CHAR" using
                     instanceData(1:byteSize)
                     stringStartPosition
                     stringOffset
                     CharLengthInBytes
                   if singleByteCharacter
                       if instanceData(stringOffset:1) = space
                           subtract 1 from stringOffset
                       else
                           set nonSpaceCharacterFound to true
                       end-if
                   else
                       if instanceData(stringOffset:2) = DBCSSpace
       *>>
       *>> The stringOffset has already been adjusted to the first
       *>> byte of the Double-Byte Character.
       *>>
                           subtract 1 from stringOffset
                       else
       *>>
       *>> Ensure that both of the bytes of the Double-Byte Character
       *>> are included.
       *>>
                           add 1 to stringOffset
                           set nonSpaceCharacterFound to true
                       end-if
                   end-if
               end-perform
               move stringOffset to pseudoStringEnd
       *>>
       *>> Determine the number of characters between the
       *>> pseudoStringStart and the pseudoStringEnd
       *>>
               move 1 to StringStartPosition
               move zero to CharLengthInBytes
               move zero to pseudoCharSize
               compute pseudoByteSize = pseudoStringEnd -
                                        pseudoStringStart + 1
               move pseudoStringStart to stringOffset
               perform until stringOffset > pseudoStringEnd
                   call "CBL_CLASSIFY_DBCS_CHAR" using
                     instanceData(1:byteSize)
                     stringStartPosition
                     stringOffset
                     CharLengthInBytes
                   add CharLengthInBytes to stringOffset
                   add 1 to pseudoCharSize
               end-perform
               if self = null
                   move instanceData(pseudoStringStart:pseudoByteSize)
                   to lnkValue
               else
                   invoke dbcspicx "newClass" using pseudoCharSize
                           returning aClass
                   invoke aClass "withValue" using
                       instancedata(pseudoStringStart:pseudoByteSize)
                           returning lnkValue
               end-if
           else
               if self = null
                   move zero to pseudoCharSize
               else
                   invoke dbcspicx "newClass" using pseudoCharSize
                       returning aClass
                   invoke aClass "withValue" using
                       instanceData(1:pseudoByteSize)
                           returning lnkValue
               end-if
           end-if
           exit method
       end method "trimBlanks".
      *>----------------------------------------------------------------
      *> Return the hash value of this dbcspicx.
      *>----------------------------------------------------------------
       method-id. "hash".

       local-storage section.
       01 aChar                    pic x.
       01 numChar redefines aChar  pic x comp-5.
       01 byteSize                 pic s9(9) comp-5.
       01 hashLoop                 pic x(4) comp-5.
       01 characterType            pic x(4) comp-5.
          88 noCharactersFound                 value 1.
          88 nonSpaceFound                     value 2.

       01 stringStartPosition      pic 9(4) comp.
       01 stringOffset             pic 9(4) comp.
       01 charLengthInBytes        pic 9(2) comp.
          88 singleByteChar                    value 1.
          88 doubleByteChar                    value 2.

       01 DBCSSpace                pic x(2).

       linkage section.
       01 lnkHashValue             pic s9(9) comp-5.

       procedure division returning lnkHashValue.

           move zero to lnkHashValue
           move 1 to stringStartPosition
           invoke self "sizeInBytes" giving byteSize
           move byteSize to stringOffset
           move zero to charLengthInBytes
           set noCharactersFound to true
           invoke DBCSCharacterArray "getDBCSSpace" returning DBCSSpace
           perform until nonSpaceFound or stringOffset = zero
               call "CBL_CLASSIFY_DBCS_CHAR" using
                 instancedata(1:byteSize)
                 stringStartPosition
                 stringOffset
                 charLengthInBytes
               if singleByteChar
                   if instancedata(stringOffset:1) =
                     space
                       subtract 1 from stringOffset
                   else
                       set nonSpaceFound to true
                   end-if
               else
                   if instancedata(stringOffset:2)
                      = DBCSSpace
       *>> stringOffset has already adjusted to the 1st byte of DBC.
                       subtract 1 from stringOffset
                   else
       *>> ensure both characters of DBC are included in the hash value.
                       add 1 to stringOffset
                       set nonSpaceFound to true
                   end-if
               end-if
           end-perform
           move stringOffset to hashLoop
           perform varying hashLoop from StringOffset by -1
             until hashLoop = zero
              move instanceData(hashLoop:1) to aChar
              compute lnkHashValue = lnkHashValue * 47 + numChar
           end-perform
           if lnkHashValue < 0
               compute lnkHashValue = - lnkHashValue
           end-if
           exit method.
       end method "hash".
      *>----------------------------------------------------------------
      *> Replace the contents of the receiver at the index
      *> position lnkCharIndex with lnkCharacter.
      *>----------------------------------------------------------------
       method-id. "atPut".

       local-storage section.
       01 aPtr                     usage pointer.
       01 exceptionnumber          pic x(4) comp-5.
       01 charSize                 pic s9(9) comp-5.
       01 maxByteSize              pic s9(9) comp-5.
       01 stringStartPosition      pic 9(4) comp.
       01 stringOffset             pic 9(4) comp.
       01 charLengthInBytes        pic 9(2) comp.
       01 oldCharLengthInBytes     pic 9(2) comp.
       01 newCharLengthInBytes     pic 9(2) comp.
       01 charCount                pic s9(9) comp-5.
       01 byteIndexPosition        pic s9(9) comp-5.
       01 oldbytePosition          pic s9(9) comp-5.
       01 newbytePosition          pic s9(9) comp-5.
       01 oldbyteLength            pic s9(9) comp-5.
       01 newbyteLength            pic s9(9) comp-5.

       linkage section.
       01 lnkCharIndex             pic x(4) comp-5.
       01 lnkCharacter.
           03 lnkByte              pic x occurs 1 to maxNumberBytes
                                       depending on maxBytesPerChar.

       01 lnkNewString.
          03 lnkNewByte            pic x occurs 1 to maxNumberBytes
                                       depending on maxByteSize.

       procedure division using lnkCharIndex lnkCharacter.
           invoke selfClass "size" returning charSize
           if lnkCharIndex > charSize or lnkCharIndex < 1
               move 3 to exceptionNumber
               invoke self "RaiseException" using exceptionNumber
           else
       *>>
       *>> Initialisation.
       *>>
               invoke selfClass "sizeInBytes" returning maxByteSize
               invoke self "malloc" using maxByteSize returning aPtr
               set address of lnkNewString to aPtr
       *>>
       *>> Locate the byte position of the character to be replaced,
       *>> and determine its length in bytes.
       *>>
               move 1 to stringStartPosition
               move 1 to stringOffset
               move zero to charLengthInBytes
               perform varying charCount from 1 by 1
                 until charCount > lnkCharIndex
                   call "CBL_CLASSIFY_DBCS_CHAR" using
                     instancedata(1:maxByteSize)
                     stringStartPosition
                     stringOffset
                     charLengthInBytes
                   add charLengthInBytes to stringOffset
               end-perform
               move charLengthInBytes to oldCharLengthInBytes
               subtract charLengthInBytes from stringOffset
                                          giving byteIndexPosition
       *>>
       *>> Determine the length in bytes of the new replacement
       *>> character.
       *>>
               move 1 to stringStartPosition
               move 1 to stringOffset
               move zero to charLengthInBytes
               call "CBL_CLASSIFY_DBCS_CHAR" using lnkCharacter
                                                   stringStartPosition
                                                   stringOffset
                                                   charLengthInBytes
               move charLengthInBytes to newCharLengthInBytes
       *>>
       *>> Move all the characters before the replacement character,
       *>> to the new string.
       *>>
               move 1 to oldBytePosition
               subtract 1 from byteIndexPosition giving oldByteLength
               move 1 to newBytePosition
               move oldByteLength to newByteLength
               move instanceData(oldBytePosition:oldByteLength) to
                   lnkNewString(newBytePosition:newByteLength)
       *>>
       *>> step position past the bytes we've just copied
       *>>
               add oldByteLength to oldBytePosition
       *>>
       *>> Move the new replacement character to the new string.
       *>>
               add newByteLength to newBytePosition
               move newCharLengthInBytes to newByteLength
               move lnkCharacter(1:newByteLength) to
                    lnkNewString(newBytePosition:newByteLength)
       *>>
       *>> Ignore the character which will be replaced.
       *>>
               add oldCharLengthInBytes to oldBytePosition
       *>>
       *>> Move all the characters after the replacement character,
       *>> to the new string.
       *>>
               add newCharLengthInBytes to newBytePosition
               compute oldByteLength = maxByteSize -
                                       oldBytePosition + 1
               move oldByteLength to newByteLength
               move instanceData(oldBytePosition:oldByteLength) to
                    lnkNewString(newBytePosition:newByteLength)
       *>>
       *>> Update the old DBCS character array using the new string
       *>>
               move lnkNewString to
                       instanceData(1:maxByteSize)
       *>>
       *>> De-allocate used memory.
       *>>
               invoke self "dealloc" using aPtr
           end-if
           exit method.
       end method "atPut".
      *>----------------------------------------------------------------
      *> Return the character of the receiver at the character index
      *> position lnkCharIndexPosition.
      *>----------------------------------------------------------------
       method-id. "at".

       local-storage section.
       01 exceptionNumber          pic x(4) comp-5.
       01 byteSize                 pic s9(9) comp-5.
       01 charSize                 pic s9(9) comp-5.
       01 stringStartPosition      pic 9(4) comp.
       01 stringOffset             pic 9(4) comp.
       01 charLengthInBytes        pic 9(2) comp.
       01 charCount                pic s9(9) comp-5.

       linkage section.
       01 lnkCharIndexPosition     pic x(4) comp-5.
       01 lnkCharacter.
          03 lnkByte               pic x occurs 1 to maxNumberBytes
                                       depending on charLengthInBytes.

       procedure division using lnkCharIndexPosition
                      returning lnkCharacter.

           invoke self "size" returning charSize
           if lnkCharIndexPosition > charSize or
              lnkCharIndexPosition < 1
               move 3 to exceptionNumber
               invoke self "RaiseException" using exceptionNumber
                                        returning lnkCharacter
           else
               invoke self "sizeInBytes" returning byteSize
               move 1 to stringStartPosition
               move 1 to stringOffset
               move zero to charLengthInBytes
               perform varying charCount from 1 by 1
                 until charCount > lnkCharIndexPosition
                   call "CBL_CLASSIFY_DBCS_CHAR" using
                           instanceData(1:byteSize)
                           stringStartPosition
                           stringOffset
                           charLengthInBytes
                   add charLengthInBytes to stringOffset
               end-perform
               subtract charLengthInBytes from stringOffset
               move instanceData(stringOffset:charLengthInBytes) to
                   lnkCharacter(1:charLengthInBytes)
           end-if
           exit method
       end method "at".
      *>----------------------------------------------------------------
      *> Return the index position of the first occurrence of lnkObject
      *> (starting the search at lnkStartCharIndexPosition) in the
      *> receiver. If no such element is found, return zero instead.
      *>----------------------------------------------------------------
       method-id. "indexOfString".

       local-storage section.
       01 aPtr                         usage pointer.
       01 exceptionNumber              pic x(4) comp-5.
       01 charIndexPosition            pic x(4) comp-5.
       01 compareCharSize              pic x(4) comp-5.
       01 compareByteSize              pic x(4) comp-5.
       01 charSize                     pic x(4) comp-5.
       01 byteSize                     pic x(4) comp-5.
       01 stringStartPosition          pic 9(4) comp.
       01 stringOffset                 pic 9(4) comp.
       01 charLengthInBytes            pic 9(2) comp.
          88 singleByteCharacter                       value 1.
          88 doubleByteCharacter                       value 2.

       linkage section.
       01 lnkObject                    usage object reference.
       01 lnkStartCharIndexPosition    pic x(4) comp-5.
       01 lnkCharIndexPosition         pic x(4) comp-5.

       01 lnkCompareValue.
          03 lnkByte                   pic x occurs 1 to maxNumberBytes
                                           depending on compareByteSize.

       procedure division using lnkObject
                                lnkStartCharIndexPosition
                                returning lnkCharIndexPosition.

           invoke selfClass "size" returning charSize
           if lnkStartCharIndexPosition < 1 or
              lnkStartCharIndexPosition > charSize
               move 3 to exceptionNumber
               invoke self "raiseException" using exceptionNumber
                                        returning lnkCharIndexPosition
           else
               move 1 to stringStartPosition
               move 1 to stringOffset
               move zero to charLengthInBytes
               move zero to lnkCharIndexPosition
               invoke lnkObject "sizeInBytes" returning compareByteSize
               invoke self "malloc" using compareByteSize returning aPtr
               set address of lnkCompareValue to aPtr
               invoke lnkObject "getValue" returning lnkCompareValue
               invoke lnkObject "size" returning compareCharSize
               invoke self "sizeInBytes" returning byteSize
               perform varying charIndexPosition from 1 by 1
                 until charIndexPosition > charSize or
                   charIndexPosition + compareCharSize - 1 > charSize or
                   lnkCharIndexPosition not = zero
                   if charIndexPosition >=
                      lnkStartCharIndexPosition and
                      instanceData(stringOffset:compareByteSize)
                      = lnkCompareValue
                       move charIndexPosition to lnkCharIndexPosition
                   else
                       call "CBL_CLASSIFY_DBCS_CHAR" using
                           instanceData(1:byteSize)
                           stringStartPosition
                           stringOffset
                           charLengthInBytes
                       add charLengthInBytes to stringOffset
                   end-if
               end-perform
               invoke self "dealloc" using aptr
           end-if
           exit method.
       end method "indexOfString".
      *>----------------------------------------------------------------
      *> Return a new string as a result of concatenating this picx with
      *> lnkObject. If this method was invoked with an INVOKE AS
      *> a static will be returned, otherwise an object reference will
      *> be returned instead.
      *>----------------------------------------------------------------
       method-id. "concat".

       local-storage section.
       01 valueByteSize            pic x(4) comp-5.
       01 compareByteSize          pic x(4) comp-5.
       01 compareByteSize2         pic x(4) comp-5.
       01 byteSize                 pic x(4) comp-5.
       01 charSize                 pic x(4) comp-5.
       01 compareCharSize          pic x(4) comp-5.
       01 newCharSize              pic x(4) comp-5.
       01 aPtr                     usage pointer.
       01 aPtr2                    usage pointer.

       linkage section.
       01 lnkObject            usage object reference.

       01 lnkNewObject object reference.
       01 lnkValue redefines lnkNewObject.
          03 lnkByte           pic x occurs 1 to maxNumberBytes
                                   depending on valueByteSize.

       01 lnkCompareValue.
           03 lnkCompareByte   pic x occurs 1 to maxNumberBytes
                                   depending on compareByteSize.
       01 lnkComparevalue2.
           03 lnkCompareByte2  pic x occurs 1 to maxNumberBytes
                                   depending on compareByteSize2.

       procedure division using lnkObject returning lnkNewObject.
           invoke lnkObject "sizeInBytes" returning compareByteSize
           invoke self "malloc" using compareByteSize returning aPtr
           set address of lnkCompareValue to aPtr
           invoke lnkObject "getValue" returning lnkCompareValue
           invoke self "sizeInBytes" returning byteSize
           if self equal to null
               move instanceData(1:byteSize) to
                    lnkValue(1:byteSize)
               move lnkCompareValue to
                    lnkValue(byteSize + 1:compareByteSize)
           else
               add compareByteSize to byteSize
                           giving compareByteSize2
               invoke self "malloc" using compareByteSize2
                       returning aPtr2
               set address of lnkCompareValue2 to aPtr2
               move instanceData(1:byteSize) to
                    lnkCompareValue2(1:byteSize)
               move lnkCompareValue to
                    lnkCompareValue2(byteSize + 1:compareByteSize)
               move objectReferenceSize to valueByteSize
               invoke self "size" returning charSize
               invoke lnkObject "size" returning compareCharSize
               add compareCharSize to charSize giving newCharSize
               invoke cobolpicx "withLengthValue"
                       using newCharSize
                             lnkCompareValue2
                   returning lnkNewObject
               invoke self "dealloc" using aPtr2
           end-if
           invoke self "dealloc" using aPtr
           exit method.
       end method "concat".
      *>----------------------------------------------------------------
      *> Return true if this DBCS COBOL PICX contains one or more DBCS
      *> characters. otherwise it will return false.
      *>----------------------------------------------------------------
       method-id. "containsDBCScharacters".
       local-storage section.
       01 byteSize             pic x(4) comp-5.

       linkage section.
       01 lnkBool              pic x comp-5.
          88 lnkIsFalse                        value 0.
          88 lnkIsTrue                         value 1.

       01 lnkObject            usage object reference.

       procedure division using lnkObject returning lnkBool.
           invoke self "sizeInBytes" returning byteSize
           invoke DBCScharacterArray "isDBCSstringByteLengthValue"
                           using byteSize
                                 instanceData(1:byteSize)
                       returning lnkBool
           exit method.
       end method "containsDBCScharacters".
      *>----------------------------------------------------------------
      *> Set the value of this DBCS COBOL Pic X to lnkString.
      *>----------------------------------------------------------------
       method-id. "setValue".

       local-storage section.
       01 charSize         pic s9(9) comp-5.
       01 byteSize         pic s9(9) comp-5.

       linkage section.
       01 lnkString.
           03 lnkByte      pic x occurs 1 to maxNumberBytes
                               depending on byteSize.

       procedure division using lnkString.
           invoke selfClass "size" returning charSize
           invoke DBCSCharacterArray "stringLengthInBytes"
                   using lnkString
                         charSize
               returning byteSize
           move lnkString to
               instanceData(1:byteSize)
           exit method.
       end method "setValue".

      *>----------------------------------------------------------------
      *> Return an ordered collection of dbcspicx's which
      *> represents each separate line of this dbcspicx.
      *>----------------------------------------------------------------
       method-id. "asSeparateLines".

       working-storage section.
       01 lineFeedCharacter        pic x value x"0A".

       local-storage section.
       01 anObject                 usage object reference.
       01 collectionSize           pic x(4) comp-5.
       01 characterCount           pic s9(9) comp-5.
       01 stringStartPosition      pic 9(4) comp.
       01 stringOffset             pic 9(4) comp.
       01 charLengthInBytes        pic 9(2) comp.
          88 singleByteCharacter                   value 1.
          88 doubleByteCharacter                   value 2.
       01 stringByteLength         pic x(4) comp-5.
       01 startOfLine              pic x(4) comp-5.
       01 byteSize                 pic x(4) comp-5.

       linkage section.
       01 lnkCollection            usage object reference.

       procedure division returning lnkCollection.
           move 5 to collectionSize
           invoke orderedcollection "ofReferences"
                       using collectionSize
                   returning lnkCollection
           move 1 to startOfLine
           move 1 to stringStartPosition
           move 1 to stringOffset
           move zero to charLengthInBytes
           move zero to characterCount
           invoke self "sizeInBytes" returning byteSize
           perform until stringOffset > byteSize
               call "CBL_CLASSIFY_DBCS_CHAR" using
                       instanceData(1:byteSize)
                       stringStartPosition
                       stringOffset
                       charLengthInBytes
               if singleByteCharacter
                   if instanceData(stringOffset:1) = lineFeedCharacter
                       subtract startOfLine from stringOffset
                           giving stringByteLength
                       if characterCount = zero
                           continue
                       else
                           invoke cobolpicx "withLengthValue"
                               using characterCount
                                     instancedata(startOfLine:
                                     stringBytelength)
                           returning anObject
                           invoke lnkCollection "add"
                               using anObject
                       end-if
                       move zero to characterCount
                       add 1 to stringOffset giving Startofline
                   else
                       add 1 to characterCount
                   end-if
               else
                   add 1 to characterCount
               end-if
               add charLengthInBytes to stringOffset
           end-perform
           if startOfLine <= byteSize
               compute stringByteLength = byteSize - startOfLine + 1
               if characterCount = zero
                   continue
               else
                   invoke cobolpicx "withLengthValue"
                           using characterCount
                                 instanceData(startOfLine:
                                 stringByteLength)
                       returning anObject
                   invoke lnkcollection "add"
                           using anObject
               end-if
           end-if
           exit method.
       end method "asSeparateLines".
       end object.
       end class dbcspicx.
