[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/tokenupp.prg. Contains procedures: Main. This file provides legacy compatibility functions

[Assistant]
#ifdef __HARBOUR__
#require "hbct"
#endif

PROCEDURE Main()

   LOCAL cStr := ".,.This.,.is.,.a.,.test!"

   ctinit()

   ? "Begin test of TokenUpper()"
   ?

   ? "  Simple tests:"
   ? '   TokenUpper( "Hello, world, here I am!" )         == "Hello, World, Here I Am!" ?'
   ? '                                                    -> "' + TokenUpper( "Hello, world, here I am!" ) + '"'
   ? '   TokenUpper( "Hello, world, here I am!",, 3 )     == "Hello, World, Here I am!" ?'
   ? '                                                    -> "' + TokenUpper( "Hello, world, here I am!",, 3 ) + '"'
   ? '   TokenUpper( "Hello, world, here I am!", ",", 3 ) == "Hello, world, here I am!" ?'
   ? '                                                    -> "' + TokenUpper( "Hello, world, here I am!", ",", 3 ) + '"'
   ? '   TokenUpper( "Hello, world, here I am!", " w" )   == "Hello, wOrld, Here I Am!" ?'
   ? '                                                    -> "' + TokenUpper( "Hello, world, here I am!", " w" ) + '"'
   ?

   ? '  Uppercase the tokens in the string "' + cStr + '"'
   ? '            with CSetRef( .T. ) and "@"'
   CSetRef( .T. )
   ?
   ? '    --> return value of TokenUpper( @cStr ): ', TokenUpper( @cStr )
   ? '    --> cStr is now: "' + cStr + '"'

   ?
   ? "End test of TokenUpper()"
   ?

   ctexit()

   RETURN


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Here is a Harbour (xBase/Clipper) implementation:

Harbour test program: tests/directry.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#include "directry.ch"

PROCEDURE Main( filespec, attribs, cshort )

   LOCAL aDir
   LOCAL x, lShort := .F.

   IF ! cshort == NIL .AND. ( Upper( cShort ) == "TRUE" .OR. Upper( cShort ) == ".T." )
      lShort := .T.
   ENDIF

   aDir := Directory( filespec, attribs, lShort )

   Set( _SET_DATEFORMAT, "yyyy-mm-dd" )

   FOR x := 1 TO Len( aDir )
      ? ;
         PadR( aDir[ x, F_NAME ], 20 ), "|", ;
         Transform( aDir[ x, F_SIZE ], "9,999,999,999" ), "|", ;
         aDir[ x, F_DATE ], "|", ;
         aDir[ x, F_TIME ], "|", ;
         aDir[ x, F_ATTR ]
   NEXT

   RETURN


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement the following Harbour classes: xpp_Get. Harbour contribution module 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/tgetx.prg. Defines classes: xpp_Get. This file provides legacy compatibility functions

[Assistant]
#include "hbclass.ch"

CREATE CLASS xpp_Get INHERIT Get

   EXPORTED:

   METHOD posInBuffer( nRow, nCol )

   METHOD _end()
   METHOD _assign()
   METHOD _delete()

ENDCLASS

METHOD posInBuffer( nRow, nCol ) CLASS xpp_Get

   IF ::hasFocus .AND. ;
      nRow == ::nRow .AND. ;
      nCol >= ::nCol + ::nPos - 1 .AND. ;
      nCol <= ::nCol + ::nDispLen

      RETURN nCol - ::nCol + 1
   ENDIF

   RETURN 0

METHOD _end() CLASS xpp_Get
   RETURN ::end()

METHOD _assign() CLASS xpp_Get
   RETURN ::assign()

METHOD _delete() CLASS xpp_Get
   RETURN ::delete()


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/mouse1.prg. Provides functions: ft_MDblClk, ft_MInRegion, ft_MMickeys. This file provides legacy compatibility functions

[Assistant]
THREAD STATIC t_lCrsState := .F.
THREAD STATIC t_lMInit := .F.

FUNCTION ft_MDblClk( nClick, nButton, nInterval, nRow, nCol, nStart )

   LOCAL nVert, nHorz
   LOCAL lDouble
   LOCAL lDone
   LOCAL nPrs

   __defaultNIL( @nClick, 1 )
   __defaultNIL( @nButton, 0 )
   __defaultNIL( @nInterval, 0.5 )
   __defaultNIL( @nRow, MRow() )
   __defaultNIL( @nCol, MCol() )
   __defaultNIL( @nStart, Seconds() )

   nVert := nRow
   nHorz := nCol
   lDouble := lDone := ( nClick == 0 )

   DO WHILE ! lDone

      ft_MButPrs( nButton, @nPrs, @nVert, @nHorz )
      nVert := Int( nVert / 8 )
      nHorz := Int( nHorz / 8 )

      lDouble := ( nPrs > 0 )
      ldone := Seconds() - nStart >= nInterval .OR. lDouble

   ENDDO

   lDouble := lDouble .AND. ( nVert == nRow .AND. nHorz == nCol )

   IF nClick > 0
      nStart := Seconds()
   ENDIF

   IF lDouble

      lDouble := lDone := .F.

      DO WHILE ! lDone

         ft_MButPrs( nButton, @nPrs, @nVert, @nHorz )
         nVert := Int( nVert / 8 )
         nHorz := Int( nHorz / 8 )

         lDouble := ( nPrs > 0 )
         lDone := Seconds() - nStart >= nInterval .OR. lDouble

      ENDDO

      lDouble := lDouble .AND. nVert == nRow .AND. nHorz == nCol

   ENDIF

   RETURN lDouble

FUNCTION ft_MInRegion( nTR, nLC, nBR, nRC )
   RETURN ;
      MRow() >= nTR .AND. MRow() <= nBR .AND. ;
      MCol() >= nLC .AND. MCol() <= nRC

FUNCTION ft_MMickeys(  nX,  nY )

   nX := MRow()


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Write the following Harbour (xBase/Clipper) code:

Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/xhbmisc.prg. Provides functions: Occurs. This file provides legacy compatibility functions

[Assistant]
FUNCTION Occurs( s1, s2 )

   LOCAL nCount := 0
   LOCAL nPos := 0

   IF HB_ISSTRING( s1 ) .AND. HB_ISSTRING( s2 )
#if defined( HB_CLP_STRICT )
      DO WHILE ( nPos := hb_At( s1, s2, nPos + 1 ) ) != 0
         nCount++
      ENDDO
#else
      DO WHILE ( nPos := hb_At( s1, s2, nPos ) ) != 0
         nCount++
         nPos += Len( s1 )
      ENDDO
#endif
   ENDIF

   RETURN nCount


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Create Harbour OOP classes for the functionality described: Harbour contribution module 'gtwvg' (): contrib/gtwvg/parthdlr.prg. Defines classes: WvgPartHandler. This file provides platform-specific functionality

[Assistant]
#include "hbclass.ch"
#include "inkey.ch"
#include "hbgtinfo.ch"

#include "hbgtwvg.ch"
#include "wvtwin.ch"
#include "wvgparts.ch"

CREATE CLASS WvgPartHandler

   VAR    cargo

   METHOD new( oParent, oOwner )
   METHOD create( oParent, oOwner )
   METHOD configure( oParent, oOwner )
   METHOD destroy()
   METHOD handleEvent( hEvent, mp1, mp2 )
   METHOD status()

   METHOD removeChild( oChild )
   METHOD addChild( oWvg )
   METHOD childFromName( nNameId )
   METHOD childList()
   METHOD delChild( oWvg )
   METHOD setName( nNameId )
   METHOD setOwner( oWvg )
   METHOD setParent( oWvg )

   METHOD notifier( nEvent, xParams )
   METHOD controlWndProc( hWnd, nMessage, nwParam, nlParam )

   VAR    aChildren                             INIT {}
   VAR    nNameId
   VAR    oParent
   VAR    oOwner
   VAR    nStatus                               INIT 0

   VAR    sb_notifier
   METHOD notifierBlock( ... )                  SETGET

ENDCLASS

METHOD WvgPartHandler:new( oParent, oOwner )

   ::oParent := oParent
   ::oOwner  := oOwner

   RETURN Self

METHOD WvgPartHandler:create( oParent, oOwner )

   __defaultNIL( @oParent, ::oParent )
   __defaultNIL( @oOwner, ::oOwner )

   ::oParent := oParent
   ::oOwner  := oOwner

   RETURN Self

METHOD WvgPartHandler:configure( oParent, oOwner )

   __defaultNIL( @oParent, ::oParent )
   __defaultNIL( @oOwner, ::oOwner )

   ::oParent := oParent
   ::oOwner  := oOwner

   RETURN Self

METHOD WvgPartHandler:destroy()

   ::hChildren  := NIL
   ::nNameId    := NIL
   ::oParent    := NIL
   ::oOwner     := NIL

   RETURN Self

METHOD WvgPartHandler:handleEvent( hEvent, mp1, mp2 )

   HB_SYMBOL_UNUSED( hEvent )
   HB_SYMBOL_UNUSED( mp1 )
   HB_SYMBOL_UNUSED( mp2 )

   RETURN Self

METHOD WvgPartHandler:status()
   RETURN ::nStatus

METHOD WvgPartHandler:addChild( oWvg )

   oWvg:nNameID := oWvg:nID
   AAdd( ::aChildren, oWvg )

   RETURN Self

METHOD WvgPartHandler:childFromName( nNameId )

   LOCAL i, oWvg

   FOR i := 1 TO Len( ::aChildren )
      IF ::aChildren[ i ]:nNameID != NIL .AND. ::aChildren[ i ]:nNameID == nNameID
         oWvg := ::aChildren[ i ]
      ENDIF
   NEXT

   RETURN oWvg

METHOD WvgPartHandler:childList()
   RETURN ::aChildren

METHOD WvgPartHandler:removeChild( oChild )

   LOCAL n

   IF ( n := AScan( ::aChildren, {| o | o == oChild } ) ) > 0
      hb_ADel( ::aChildren, n, .T. )
   ENDIF

   RETURN Self

METHOD WvgPartHandler:delChild( oWvg )

   LOCAL n

   n := AScan( ::aChildren, {| o | o == oWvg } )
   IF n > 0
      oWvg:destroy()
      hb_ADel( ::aChildren, n, .T. )
   ENDIF

   RETURN Self

METHOD WvgPartHandler:setName( nNameId )

   LOCAL nOldNameId := ::nNameId

   IF HB_ISNUMERIC( nNameId )
      ::nNameID := nNameId
   ENDIF

   RETURN nOldNameId

METHOD WvgPartHandler:setOwner( oWvg )

   LOCAL oOldXbp := ::oOwner

   IF HB_ISOBJECT( oWvg )
      ::oOwner := oWvg
   ENDIF

   RETURN oOldXbp

METHOD WvgPartHandler:setParent( oWvg )

   LOCAL oOldXbp := ::oParent

   IF HB_ISOBJECT( oWvg )
      ::oParent := oWvg
   ENDIF

   RETURN oOldXbp

METHOD PROCEDURE WvgPartHandler:notifierBlock( ... )

   LOCAL a_ := hb_AParams()

   IF ! Empty( a_ ) .AND. HB_ISBLOCK( a_[ 1 ] )
      ::sb_notifier := a_[ 1 ]

   ELSEIF ! Empty( a_ ) .AND. HB_ISBLOCK( ::sb_notifier ) .AND. HB_ISNUMERIC( a_[ 1 ] ) .AND. HB_ISARRAY( a_[ 2 ] )
      Eval( ::sb_notifier, a_[ 1 ], a_[ 2 ], Self )

   ENDIF

   RETURN

METHOD WvgPartHandler:notifier( nEvent, xParams )

   LOCAL aPos, aMenuItem, nIndex, nCtrlID, oObj
   LOCAL nReturn := 0

   DO CASE
   CASE nEvent == HB_GTE_MOUSE

      DO CASE
      CASE xParams[ 1 ] == WM_MOUSEHOVER
         aPos := { xParams[ 3 ], xParams[ 4 ] }
      CASE xParams[ 1 ] == WM_MOUSELEAVE

      OTHERWISE
         aPos := iif( ::mouseMode == 2, { xParams[ 3 ], xParams[ 4 ] }, { xParams[ 5 ], xParams[ 6 ] } )
      ENDCASE

      SWITCH xParams[ 1 ]
      CASE WM_MOUSEHOVER
         IF HB_ISBLOCK( ::sl_enter )
            Eval( ::sl_enter, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_MOUSELEAVE
         IF HB_ISBLOCK( ::sl_leave )
            Eval( ::sl_leave, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_RBUTTONDOWN
         IF HB_ISBLOCK( ::sl_rbDown )
            Eval( ::sl_rbDown, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_LBUTTONDOWN
         IF HB_ISBLOCK( ::sl_lbDown )
            Eval( ::sl_lbDown, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_RBUTTONUP
         IF HB_ISBLOCK( ::sl_rbUp )
            Eval( ::sl_rbUp, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_LBUTTONUP
         IF HB_ISBLOCK( ::sl_lbUp )
            Eval( ::sl_lbUp, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_RBUTTONDBLCLK
         IF HB_ISBLOCK( ::sl_rbDblClick )
            Eval( ::sl_rbDblClick, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_LBUTTONDBLCLK
         IF HB_ISBLOCK( ::sl_lbDblClick )
            Eval( ::sl_lbDblClick, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_MBUTTONDOWN
         IF HB_ISBLOCK( ::sl_mbDown )
            Eval( ::sl_mbDown, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_MBUTTONUP
         IF HB_ISBLOCK( ::sl_mbClick )
            Eval( ::sl_mbClick, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_MBUTTONDBLCLK
         IF HB_ISBLOCK( ::sl_mbDblClick )
            Eval( ::sl_mbDblClick, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_MOUSEMOVE
         IF HB_ISBLOCK( ::sl_motion )
            Eval( ::sl_motion, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_MOUSEWHEEL
         IF HB_ISBLOCK( ::sl_wheel )
            Eval( ::sl_wheel, aPos, , Self )
         ENDIF
         EXIT
      CASE WM_NCMOUSEMOVE
         EXIT
      ENDSWITCH

   CASE nEvent == HB_GTE_KEYBOARD
      IF HB_ISBLOCK( ::keyboard )
         Eval( ::keyboard, xParams, , Self )
      ENDIF

   CASE nEvent == HB_GTE_SETFOCUS

      IF HB_ISBLOCK( ::sl_setInputFocus )
         Eval( ::sl_setInputFocus, , , Self )
      ENDIF
      ::lHasInputFocus := .T.

   CASE nEvent == HB_GTE_KILLFOCUS
      IF HB_ISBLOCK( ::sl_killInputFocus )
         Eval( ::sl_killInputFocus, , , Self )
      ENDIF
      ::lHasInputFocus := .F.

   CASE nEvent == HB_GTE_PAINT

   CASE nEvent == HB_GTE_GUIPARTS

      AEval( ::aChildren, {| o | wvg_InvalidateRect( o:hWnd ) } )

   CASE nEvent == HB_GTE_CLOSE
      IF HB_ISBLOCK( ::close )
         nReturn := Eval( ::close, , , Self )
      ENDIF

   CASE nEvent == HB_GTE_MENU
      DO CASE
      CASE xParams[ 1 ] == 0
         IF HB_ISOBJECT( ::oMenu )
            IF ! Empty( aMenuItem := ::oMenu:FindMenuItemById( xParams[ 2 ] ) )
               DO CASE
               CASE HB_ISBLOCK( aMenuItem[ 2 ] )
                  Eval( aMenuItem[ 2 ], aMenuItem[ 1 ], , aMenuItem[ 4 ] )
               CASE HB_ISBLOCK( aMenuItem[ 3 ] )
                  Eval( aMenuItem[ 3 ], aMenuItem[ 1 ], , aMenuItem[ 4 ] )
               ENDCASE
            ENDIF
         ENDIF

      CASE xParams[ 1 ] == 1 .AND. HB_ISOBJECT( ::oMenu )
         IF HB_ISBLOCK( ::oMenu:sl_beginMenu )
            Eval( ::oMenu:sl_beginMenu, , , Self )
         ENDIF

      CASE xParams[ 1 ] == 2 .AND. HB_ISOBJECT( ::oMenu )
         IF HB_ISBLOCK( ::oMenu:sl_endMenu )
            Eval( ::oMenu:sl_endMenu, , , Self )
         ENDIF

      ENDCASE

   CASE nEvent == HB_GTE_NOTIFY
      nCtrlID := xParams[ 1 ]
      IF ( nIndex := AScan( ::aChildren, {| o | o:nID == nCtrlID } ) ) > 0
         RETURN ::aChildren[ nIndex ]:handleEvent( HB_GTE_NOTIFY, xParams )
      ENDIF

   CASE nEvent == HB_GTE_COMMAND
      nCtrlID := xParams[ 2 ]
      IF ( nIndex := AScan( ::aChildren, {| o | o:nID == nCtrlID } ) ) > 0
         RETURN ::aChildren[ nIndex ]:handleEvent( HB_GTE_COMMAND, xParams )
      ENDIF

   CASE nEvent == HB_GTE_CTLCOLOR
      oObj := ::findObjectByHandle( xParams[ 2 ] )
      IF HB_ISOBJECT( oObj )


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Here is a Harbour (xBase/Clipper) implementation:

Harbour Runtime Library file: src/debug/dbgthsh.prg. Defines classes: HBDbHash. Provides functions: __dbgHashes, GetTopPos, GetBottomPos, HashBrowseSkip, HashKeyString. This file provides utility functions

[Assistant]
#pragma -b-

#define HB_CLS_NOTOBJECT
#include "hbclass.ch"

#include "inkey.ch"
#include "setcurs.ch"

CREATE CLASS HBDbHash

   VAR aWindows   INIT {}
   VAR TheHash
   VAR hashName
   VAR nCurWindow INIT 0
   VAR lEditable

   METHOD New( hHash, cVarName, lEditable )

   METHOD addWindows( hHash, nRow )
   METHOD doGet( oBrowse, pItem, nSet )
   METHOD SetsKeyPressed( nKey, oBrwSets, oWnd, cName, hHash )

ENDCLASS

METHOD New( hHash, cVarName, lEditable ) CLASS HBDbHash

   ::hashName := cVarName
   ::TheHash := hHash
   ::lEditable := hb_defaultValue( lEditable, .T. )

   ::addWindows( ::TheHash )

   RETURN Self

METHOD addWindows( hHash, nRow ) CLASS HBDbHash

   LOCAL oBrwSets
   LOCAL nSize := Len( hHash )
   LOCAL oWndSets
   LOCAL nColWidth
   LOCAL oCol
   LOCAL nKeyLen

   IF nSize < MaxRow() - 2
      IF HB_ISNUMERIC( nRow )
         oWndSets := HBDbWindow():New( GetTopPos( nRow ), 5, getBottomPos( nRow + nSize + 1 ), MaxCol() - 5, ;
            ::hashName + "[1.." + hb_ntos( nSize ) + "]", "N/W" )
      ELSE
         oWndSets := HBDbWindow():New( 1, 5, 2 + nSize, MaxCol() - 5, ;
            ::hashName + "[1.." + hb_ntos( nSize ) + "]", "N/W" )
      ENDIF
   ELSE
      oWndSets := HBDbWindow():New( 1, 5, MaxRow() - 2, MaxCol() - 5, ;
         ::hashName + "[1.." + hb_ntos( nSize ) + "]", "N/W" )
   ENDIF
   ::nCurWindow++
   oWndSets:lFocused := .T.
   AAdd( ::aWindows, oWndSets )

   oBrwSets := HBDbBrowser():New( oWndSets:nTop + 1, oWndSets:nLeft + 1, oWndSets:nBottom - 1, oWndSets:nRight - 1 )
   oBrwSets:ColorSpec := __dbg():ClrModal()
   oBrwSets:Cargo := { 1, {} }
   AAdd( oBrwSets:Cargo[ 2 ], hHash )

   oBrwSets:AddColumn( oCol := HBDbColumnNew( "", {|| ::hashName + "[" + HashKeyString( hHash, oBrwSets:cargo[ 1 ] ) + "]" } ) )

   nKeyLen := 0
   hb_HEval( hHash, {| k, v, p | HB_SYMBOL_UNUSED( k ), HB_SYMBOL_UNUSED( v ), nKeyLen := Max( nKeyLen, Len( ::hashName + HashKeyString( hHash, p ) ) + 2 ) } )
   oCol:width := nKeyLen
   oCol:DefColor := { 1, 2 }
   nColWidth := oCol:Width

   oBrwSets:AddColumn( oCol := HBDbColumnNew( "", {|| __dbgValToExp( hb_HValueAt( hHash, oBrwSets:cargo[ 1 ] ) ) } ) )

   oCol:width := oWndSets:nRight - oWndSets:nLeft - nColWidth - 2
   oCol:DefColor := { 1, 3 }

   oBrwSets:goTopBlock := {|| oBrwSets:cargo[ 1 ] := 1 }
   oBrwSets:goBottomBlock := {|| oBrwSets:cargo[ 1 ] := Len( oBrwSets:cargo[ 2 ][ 1 ] ) }
   oBrwSets:skipBlock := {| nPos | nPos := HashBrowseSkip( nPos, oBrwSets ), ;
                                   oBrwSets:cargo[ 1 ] := oBrwSets:cargo[ 1 ] + nPos, nPos }
   oBrwSets:colPos := 2

   ::aWindows[ ::nCurWindow ]:bPainted    := {|| oBrwSets:forcestable() }
   ::aWindows[ ::nCurWindow ]:bKeyPressed := ;
      {| nKey | ::SetsKeyPressed( nKey, oBrwSets, ::aWindows[ ::nCurWindow ], ::hashName, hHash ) }

   ::aWindows[ ::nCurWindow ]:ShowModal()

   RETURN Self

METHOD PROCEDURE doGet( oBrowse, pItem, nSet ) CLASS HBDbHash

   LOCAL oErr
   LOCAL cValue

   oBrowse:forceStable()

   cValue := __dbgValToExp( hb_HValueAt( pItem, nSet ) )

   IF __dbgInput( Row(), oBrowse:nLeft + oBrowse:GetColumn( 1 ):width + 1, ;
                  oBrowse:getColumn( 2 ):Width, @cValue, ;
                  __dbgExprValidBlock(), __dbgColors()[ 2 ], 256 )
      BEGIN SEQUENCE WITH __BreakBlock()
         hb_HValueAt( pItem, nSet, &cValue )
      RECOVER USING oErr
         __dbgAlert( oErr:description )
      END SEQUENCE
   ENDIF

   RETURN

METHOD SetsKeyPressed( nKey, oBrwSets, oWnd, cName, hHash ) CLASS HBDbHash

   LOCAL nSet := oBrwSets:cargo[ 1 ]
   LOCAL cOldname := ::hashName
   LOCAL uValue

   SWITCH nKey
   CASE K_UP
      oBrwSets:Up()
      EXIT

   CASE K_DOWN
      oBrwSets:Down()
      EXIT

   CASE K_HOME
   CASE K_CTRL_PGUP
   CASE K_CTRL_HOME
      oBrwSets:GoTop()
      EXIT

   CASE K_END
   CASE K_CTRL_PGDN
   CASE K_CTRL_END
      oBrwSets:GoBottom()
      EXIT

   CASE K_PGDN
      oBrwSets:pageDown()
      EXIT

   CASE K_PGUP
      oBrwSets:PageUp()
      EXIT

   CASE K_ENTER
      uValue := hb_HValueAt( hHash, nSet )

      IF HB_ISHASH( uValue )
         IF Len( uValue ) == 0
            __dbgAlert( "Hash is empty" )
         ELSE
            SetPos( ownd:nBottom, ownd:nLeft )
            ::aWindows[ ::nCurwindow ]:lFocused := .F.

            ::hashName := ::hashName + "[" + HashKeyString( hHash, nSet ) + "]"
            ::AddWindows( hb_HValueAt( hHash, nSet ), oBrwSets:RowPos + oBrwSets:nTop )
            ::hashName := cOldName

            hb_ADel( ::aWindows, ::nCurWindow, .T. )
            IF ::nCurwindow == 0
               ::nCurwindow := 1
            ELSE
               ::nCurwindow--
            ENDIF
         ENDIF
      ELSEIF HB_ISPOINTER( uValue ) .OR. ! ::lEditable
         __dbgAlert( "Value cannot be edited" )
      ELSE
         oBrwSets:RefreshCurrent()
         DO CASE
         CASE HB_ISOBJECT( uValue )
            __dbgObject( uValue, cName + "[" + HashKeyString( hHash, nSet ) + "]" )
         CASE HB_ISARRAY( uValue )
            IF Len( uValue ) == 0
               __dbgAlert( "Array is empty" )
            ELSE
               __dbgArrays( uValue, cName + "[" + HashKeyString( hHash, nSet ) + "]" )
            ENDIF
         OTHERWISE
            ::doGet( oBrwSets, hHash, nSet )
         ENDCASE
         oBrwSets:RefreshCurrent()
         oBrwSets:ForceStable()
      ENDIF
      EXIT

   ENDSWITCH

   oBrwSets:forcestable()

   ::aWindows[ ::nCurwindow ]:SetCaption( cName + "[" + hb_ntos( oBrwSets:cargo[ 1 ] ) + ".." + ;
      hb_ntos( Len( hHash ) ) + "]" )

   RETURN Self

FUNCTION __dbgHashes( hHash, cVarName, lEditable )
   RETURN HBDbHash():New( hHash, cVarName, lEditable )

STATIC FUNCTION GetTopPos( nPos )
   RETURN iif( ( MaxRow() - nPos ) < 5, MaxRow() - nPos, nPos )

STATIC FUNCTION GetBottomPos( nPos )
   RETURN iif( nPos < MaxRow() - 2, nPos, MaxRow() - 2 )

STATIC FUNCTION HashBrowseSkip( nPos, oBrwSets )
   RETURN ;
      iif( oBrwSets:cargo[ 1 ] + nPos < 1, -oBrwSets:cargo[ 1 ] + 1, ;
      iif( oBrwSets:cargo[ 1 ] + nPos > Len( oBrwSets:cargo[ 2 ][ 1 ] ), ;
      Len( oBrwSets:cargo[ 2 ][ 1 ] ) - oBrwSets:cargo[ 1 ], nPos ) )

STATIC FUNCTION HashKeyString( hHash, nAt )
   RETURN __dbgValToExp( hb_HKeyAt( hHash, nAt ) )


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Create Harbour preprocessor definitions: Harbour header file: include/hbclass.ch. Defines 10 constants including: HB_CLASS_CH_, HB_CLS_FWO, HB_CLS_CSY, HB_CLS_VO, HB_CLS_TOP. Declares 5 preprocessor commands. Declares 5 preprocessor translations. Defines Harbour internal constants and macros

[Assistant]
#ifndef HB_CLASS_CH_
#define HB_CLASS_CH_

#include "hboo.ch"

#ifndef HB_CLS_FWO
#ifndef HB_CLS_CSY
#ifndef HB_CLS_VO
#ifndef HB_CLS_TOP

#define HB_CLS_FWO
#define HB_CLS_CSY
#define HB_CLS_VO
#define HB_CLS_TOP
#define HB_CLS_XPP

#endif
#endif
#endif
#endif

#ifdef HB_CLP_STRICT
   #ifndef HB_CLS_NO_DECORATION
      #define HB_CLS_NO_DECORATION
   #endif
   #ifndef HB_CLS_PARAM_LIST
      #define HB_CLS_PARAM_LIST
   #endif
#endif

#if __pragma( WARNINGLEVEL ) < 3
   #ifndef HB_CLS_NO_PARAMS_ERR
      #define HB_CLS_NO_PARAMS_ERR
   #endif
#endif

#ifdef HB_CLS_NO_DECORATION
   #xtranslate __HB_CLS_MTHNAME <!ClassName!> <MethodName> => <MethodName>
#else
   #xtranslate __HB_CLS_MTHNAME <!ClassName!> <MethodName> => <ClassName>_<MethodName>
#endif

#ifndef HB_CLS_PARAM_LIST
   #define HB_CLS_PARAM_LIST ...
#endif

#ifdef HB_CLS_NO_DECLARATIONS
   #xcommand _HB_CLASS  <name>        =>
   #xcommand _HB_CLASS  <name> <name> =>
   #xcommand _HB_MEMBER <name>        =>
   #xcommand DECLARE    <*decl*>      =>
   #xtranslate AS <!type!>            =>
   #xtranslate AS CLASS <!name!>      =>
#endif

#ifdef HB_CLS_NOTOBJECT
   #xtranslate __HB_CLS_PAR([<cls,...>])  => { <cls> }
#else
   #xtranslate __HB_CLS_PAR([<cls,...>])  => iif( <.cls.>, { <cls> }, { @HBObject() } )
#endif

#ifdef HB_CLS_NOAUTOINIT
   #define __HB_CLS_NOINI .T.
#else
   #define __HB_CLS_NOINI .F.
#endif

#ifdef HB_CLS_NO_PARAMS_ERR
   #xtranslate __HB_CLS_PARAMS(<Method>)     => __HB_CLS_ASID(<Method>)
#else
   #xtranslate __HB_CLS_PARAMS(<Method>)     => <Method>
#endif

#ifdef HB_CLS_NO_OO_ERR
   #xtranslate __HB_CLS_ERR([<msg,...>]) =>
   #xtranslate __HB_CLS_WARN([<msg,...>]) =>
#else
   #xtranslate __HB_CLS_ERR([<msg,...>]) => ;#error [ <msg>] ; #line
   #xtranslate __HB_CLS_WARN([<msg,...>]) => ;#warning [ <msg>] ; #line
#endif

#translate @:<!MessageName!>([<MsgParams,...>]) => ;
                                ::realclass:<MessageName>([ <MsgParams>])

#xtranslate :Super( <!SuperClass!> ): => :<SuperClass>:

#xtranslate __HB_CLS_OPT(,) =>
#xtranslate __HB_CLS_OPT()     =>

#xtranslate __HB_CLS_ASSTRING( <FuncName> )                 => <(FuncName)>
#xtranslate __HB_CLS_ASSTRING( <FuncName>([<params,...>]) ) => <(FuncName)>
#xtranslate __HB_CLS_ASFUNC( <FuncName> )                   => <FuncName>()
#xtranslate __HB_CLS_ASFUNC( <FuncName>([<params,...>]) )   => <FuncName>([ <params>])
#xtranslate __HB_CLS_ASID( <FuncName> )                     => <FuncName>
#xtranslate __HB_CLS_ASID( <FuncName>([<params,...>]) )     => <FuncName>
#xtranslate __HB_CLS_ASARGS( <FuncName> )                   =>
#xtranslate __HB_CLS_ASARGS( <FuncName>([<Args,...>]) )     => [ <Args>]
#xtranslate __HB_CLS_ASARGSOPT( <FuncName> )                =>
#xtranslate __HB_CLS_ASARGSOPT( <FuncName>([<Args,...>]) )  => [, <Args>]

#xtranslate __HB_CLS_SCOPE( <x,...> )        => ) __HB_CLS_ERR( Can not use multiple scope qualifiers! )
#xtranslate __HB_CLS_SCOPE( .T., .F., .F. )  => HB_OO_CLSTP_EXPORTED
#xtranslate __HB_CLS_SCOPE( .F., .T., .F. )  => HB_OO_CLSTP_PROTECTED
#xtranslate __HB_CLS_SCOPE( .F., .F., .T. )  => HB_OO_CLSTP_HIDDEN
#xtranslate __HB_CLS_SCOPE( .F., .F., .F. )  => nScope

#xcommand CLASS <!ClassName!> [METACLASS <!metaClass!>] ;
             [ <frm: FROM, INHERIT> <!SuperClass1!> [,<!SuperClassN!>] ] ;
             [ <modulfriend: MODULE FRIENDLY> ] ;
             [ <static: STATIC> ] [ FUNCTION <FuncName> ] => ;
   _HB_CLASS <ClassName> <FuncName> ;;
   <static> function __HB_CLS_OPT( [<FuncName>,] <ClassName> ) ( HB_CLS_PARAM_LIST ) ;;
      STATIC s_oClass ;;
      LOCAL nScope, oClass, oInstance ;;
      IF s_oClass == NIL .AND. __clsLockDef( @s_oClass ) ;;
         BEGIN SEQUENCE ;;
            nScope := HB_OO_CLSTP_EXPORTED ; HB_SYMBOL_UNUSED( nScope ) ;;
            oClass  := iif( <.metaClass.>, <(metaClass)>, HBClass():new( <(ClassName)>, __HB_CLS_PAR( [ @<SuperClass1>() ] [ , @<SuperClassN>() ] ), @__HB_CLS_OPT([__HB_CLS_ASID(<FuncName>),] <ClassName>)() [, <.modulfriend.> ] ) ) ;;;
   #undef  _CLASS_NAME_ ; #define _CLASS_NAME_ <ClassName> ;;
   #undef  _CLASS_MODE_ ; #define _CLASS_MODE_ _CLASS_DECLARATION_

#xcommand ENDCLASS [<lck: LOCK, LOCKED>] => ;
            oClass:Create() ; [<-lck-> __clsLock( oClass:hClass ) ] ;;
         ALWAYS ;;
            __clsUnlockDef( @s_oClass, oClass ) ;;
         END SEQUENCE ;;
         oInstance := oClass:Instance() ;;
         IF __objHasMsg( oInstance, "InitClass" ) ;;
            oInstance:InitClass( HB_CLS_PARAM_LIST ) ;;
         END ;;
         RETURN oInstance ;;
      END ;;
      RETURN s_oClass:Instance() AS CLASS _CLASS_NAME_ ;;
   #undef  _CLASS_MODE_ ; #define _CLASS_MODE_ _CLASS_IMPLEMENTATION_

#xcommand DECLARED METHOD <type: FUNCTION, PROCEDURE> <MethodName> CLASS <!ClassName!> => ;
      static <type> __HB_CLS_MTHNAME <ClassName> <MethodName> ;;
      local Self AS CLASS <ClassName> := QSelf() AS CLASS <ClassName>

#xcommand __HB_CLS_DECLARE_METHOD <MethodName> <!ClassName!> => ;
   #xcommand METHOD \<type: FUNCTION, PROCEDURE> <MethodName> CLASS <ClassName> _CLASS_IMPLEMENTATION_ => ;
         DECLARED METHOD \<type> <MethodName> CLASS <ClassName>

#xcommand __HB_CLS_DECLARE_METHOD <!MethodName!> <!ClassName!> => ;
   #xcommand METHOD \<type: FUNCTION, PROCEDURE> <MethodName> CLASS <ClassName> _CLASS_IMPLEMENTATION_ => ;
         DECLARED METHOD \<type> <MethodName> CLASS <ClassName> ;;
   #xcommand METHOD \<type: FUNCTION, PROCEDURE> <MethodName>(\[ \<xparams,...>] ) CLASS <ClassName> _CLASS_IMPLEMENTATION_ => ;
         DECLARED METHOD \<type> <MethodName>(\[ \<xparams>] ) CLASS <ClassName>

#xcommand METHOD <type: FUNCTION, PROCEDURE> <MethodName> CLASS <!ClassName!> _CLASS_IMPLEMENTATION_ => ;
   __HB_CLS_WARN( Method \<<MethodName>> not declared or declaration mismatch in class \<<ClassName>> ) ;;
   DECLARED METHOD <type> <MethodName> CLASS <ClassName>

#xcommand METHOD <MethodName> [ <ctor: CONSTRUCTOR> ] [ AS <type> ] [ <export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<persistent: PERSISTENT, PROPERTY>] [<sync: SYNC>] [_CLASS_DECLARATION_] => ;
   _HB_MEMBER __HB_CLS_ASFUNC(<MethodName>) [<-ctor-> AS CLASS _CLASS_NAME_] [ AS <type> ];;
   __HB_CLS_DECLARE_METHOD __HB_CLS_PARAMS(<MethodName>) _CLASS_NAME_ ;;
   oClass:AddMethod( __HB_CLS_ASSTRING(<MethodName>), @__HB_CLS_ASID( __HB_CLS_MTHNAME _CLASS_NAME_ <MethodName> )(), __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ctor.>, HB_OO_CLSTP_CTOR, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ) + iif( <.sync.>, HB_OO_CLSTP_SYNC, 0 ) )

#xcommand ACCESS <AccessName> [ AS <type> ] [ <export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<persistent: PERSISTENT, PROPERTY>] [<sync: SYNC>] [_CLASS_DECLARATION_] => ;
   METHOD <AccessName> [ AS <type> ] <export> <protect> <hidde> <persistent> <sync> _CLASS_DECLARATION_

#xcommand ASSIGN <AssignName> [ AS <type> ] [ <export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<persistent: PERSISTENT, PROPERTY>] [<sync: SYNC>] [_CLASS_DECLARATION_] => ;
   METHOD _<AssignName> [ AS <type> ] <export> <protect> <hidde> <persistent> <sync> _CLASS_DECLARATION_

#xcommand METHOD <type: FUNCTION, PROCEDURE> <MethodName> [CLASS <!ClassName!>] => ;
   METHOD <type> <MethodName> CLASS __HB_CLS_OPT([<ClassName>,] _CLASS_NAME_) _CLASS_MODE_
#xcommand METHOD <MethodName> CLASS <!ClassName!> => METHOD FUNCTION  <MethodName> CLASS <ClassName> _CLASS_MODE_
#xcommand ACCESS <AccessName> CLASS <!ClassName!> => METHOD FUNCTION  <AccessName> CLASS <ClassName> _CLASS_MODE_
#xcommand ASSIGN <AssignName> CLASS <!ClassName!> => METHOD FUNCTION _<AssignName> CLASS <ClassName> _CLASS_MODE_

#xcommand METHOD <MethodName> _CLASS_IMPLEMENTATION_ => ;
   METHOD FUNCTION <MethodName> CLASS _CLASS_NAME_
#xcommand METHOD <MethodName> => METHOD <MethodName> _CLASS_MODE_


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Write Harbour functions: __i18n_fileName, __i18n_strEncode, __i18n_strDecode. Harbour Runtime Library file: src/rtl/hbi18n2.prg. Provides 7 functions including: __i18n_fileName, __i18n_strEncode, __i18n_strDecode, __i18n_potArrayLoad, __i18n_IsBOM_UTF8. This file provides utility functions

[Assistant]
#include "fileio.ch"

#define _I18N_NONE         0
#define _I18N_CONTEXT      1
#define _I18N_MSGID        2
#define _I18N_MSGSTR       3
#define _I18N_PLURAL       4
#define _I18N_SOURCE       5

#define _I18N_ITEM         { "", {}, {}, .F., NIL }

#define _I18N_EOL          Chr( 10 )
#define _I18N_DELIM        ( Chr( 0 ) + Chr( 3 ) + Chr( 0 ) )

STATIC FUNCTION __i18n_fileName( cFileName )

   IF Set( _SET_DEFEXTENSIONS )
      cFileName := hb_FNameExtSetDef( cFileName, ".pot" )
   ENDIF

   RETURN cFileName

STATIC FUNCTION __i18n_strEncode( cStr )
   RETURN SubStr( hb_StrToExp( cStr, .T. ), 2 )

STATIC FUNCTION __i18n_strDecode( cLine, cValue, lCont )

   LOCAL lRet := .F.
   LOCAL cText

   cText := hb_StrCDecode( cLine, @lCont )
   IF cText != NIL
      lRet := .T.
      IF cValue == NIL
         cValue := cText
      ELSE
         cValue += cText
      ENDIF
   ENDIF

   RETURN lRet

#define _BOM_VALUE      0xFEFF
#define _UTF8_BOM       hb_utf8Chr( _BOM_VALUE )

FUNCTION __i18n_potArrayLoad( cFile,  cErrorMsg )

   LOCAL cLine, cValue
   LOCAL nMode, nIndex, nOldIndex, nLine, n
   LOCAL aTrans, aItem, aLines
   LOCAL lCont
   LOCAL hFile

   __i18n_fileName( @cFile )
   IF ( hFile := FOpen( cFile ) ) == F_ERROR
      cErrorMsg := hb_StrFormat( "cannot open file: %1$s", cFile )
      RETURN NIL
   ENDIF
   cValue := Space( FSeek( hFile, 0, FS_END ) )
   FSeek( hFile, 0, FS_SET )
   n := FRead( hFile, @cValue, hb_BLen( cValue ) )
   FClose( hFile )
   IF n != hb_BLen( cValue )
      cErrorMsg := hb_StrFormat( "cannot read from file: %1$s", cFile )
      RETURN NIL
   ENDIF

   IF hb_utf8Asc( cValue ) == _BOM_VALUE
      cValue := SubStr( cValue, Len( _UTF8_BOM ) + 1 )
   ENDIF
   IF ! hb_eol() == _I18N_EOL
      cValue := StrTran( cValue, hb_eol(), _I18N_EOL )
   ENDIF
   IF ! hb_eol() == Chr( 13 ) + Chr( 10 )
      cValue := StrTran( cValue, Chr( 13 ) + Chr( 10 ), _I18N_EOL )
   ENDIF
   aLines := hb_ATokens( cValue, _I18N_EOL )

   cErrorMsg := NIL
   lCont := .F.
   nLine := 0
   nIndex := 1
   nMode := _I18N_NONE
   aTrans := {}
   aItem := _I18N_ITEM
   cValue := NIL
   FOR EACH cLine IN aLines
      cLine := AllTrim( cLine )
      ++nLine
      IF lCont
         cValue += hb_eol()
      ELSE
         IF hb_LeftEq( cLine, "#" ) .AND. nMode == _I18N_NONE
            IF hb_LeftEq( cLine, "#:" )
               IF Empty( aItem[ _I18N_SOURCE ] )
                  aItem[ _I18N_SOURCE ] := ""
               ELSE
                  aItem[ _I18N_SOURCE ] += " "
               ENDIF
               aItem[ _I18N_SOURCE ] += StrTran( LTrim( SubStr( cLine, 3 ) ), "\", "/" )
            ENDIF
            cLine := ""
         ELSEIF hb_LeftEq( cLine, "msgctxt " ) .AND. nMode == _I18N_NONE
            cLine := LTrim( SubStr( cLine, 9 ) )
            nMode := _I18N_CONTEXT
            cValue := NIL
         ELSEIF hb_LeftEq( cLine, "msgid " ) .AND. ;
               ( nMode == _I18N_NONE .OR. nMode == _I18N_CONTEXT )
            nIndex := 1
            cLine := LTrim( SubStr( cLine, 7 ) )
            IF nMode == _I18N_CONTEXT
               IF cValue == NIL
                  cErrorMsg := "undefined msgctxt value"
                  EXIT
               ENDIF
               aItem[ _I18N_CONTEXT ] := cValue
            ENDIF
            nMode := _I18N_MSGID
            cValue := NIL
         ELSEIF hb_LeftEq( cLine, "msgid_plural" ) .AND. nMode == _I18N_MSGID
            nOldIndex := nIndex
            nIndex := 2
            n := 13
            IF IsDigit( SubStr( cLine, n, 1 ) )
               nIndex := Val( SubStr( cLine, n ) ) + 1
               IF nIndex < 1
                  cErrorMsg := "wrong plural form index"
                  EXIT
               ENDIF
               DO WHILE IsDigit( SubStr( cLine, n, 1 ) )
                  ++n
               ENDDO
            ENDIF
            IF nIndex != nOldIndex + 1
               cErrorMsg := "wrong plural form index"
               EXIT
            ENDIF
            IF cValue == NIL
               cErrorMsg := "undefined msgid value"
               EXIT
            ENDIF
            aItem[ _I18N_PLURAL ] := .T.
            AAdd( aItem[ _I18N_MSGID ], cValue )
            cLine := LTrim( SubStr( cLine, n ) )
            cValue := NIL
         ELSEIF hb_LeftEq( cLine, "msgstr " ) .AND. nMode == _I18N_MSGID
            nIndex := 0
            cLine := LTrim( SubStr( cLine, 8 ) )
            nMode := _I18N_MSGSTR
            IF cValue == NIL
               cErrorMsg := "undefined msgid value"
               EXIT
            ENDIF
            AAdd( aItem[ _I18N_MSGID ], cValue )
            cValue := NIL
         ELSEIF hb_LeftEq( cLine, "msgstr[" ) .AND. ;
               ( nMode == _I18N_MSGID .OR. nMode == _I18N_MSGSTR )
            nOldIndex := iif( nMode == _I18N_MSGSTR, nIndex, -1 )
            nIndex := 0
            n := 8
            IF IsDigit( SubStr( cLine, n, 1 ) )
               nIndex := Val( SubStr( cLine, n ) )
               DO WHILE IsDigit( SubStr( cLine, n, 1 ) )
                  ++n
               ENDDO
            ENDIF
            DO WHILE SubStr( cLine, n, 1 ) == " "
               ++n
            ENDDO
            IF ! SubStr( cLine, n, 1 ) == "]"
               nIndex := -1
            ENDIF
            cLine := LTrim( SubStr( cLine, n + 1 ) )
            IF nIndex < 0 .OR. nIndex != nOldIndex + 1
               cErrorMsg := "wrong translation index"
               EXIT
            ENDIF
            IF cValue == NIL
               cErrorMsg := hb_StrFormat( "undefined %1$s value", ;
                  iif( nMode == _I18N_MSGID, "msgid", "msgstr" ) )
               EXIT
            ENDIF
            aItem[ _I18N_PLURAL ] := .T.
            AAdd( aItem[ nMode ], cValue )
            nMode := _I18N_MSGSTR
            cValue := NIL
         ELSEIF Empty( cLine ) .AND. nMode == _I18N_MSGSTR
            IF cValue == NIL
               cErrorMsg := "undefined msgstr value"
               EXIT
            ENDIF
            AAdd( aItem[ _I18N_MSGSTR ], cValue )
            AAdd( aTrans, aItem )
            aItem := _I18N_ITEM
            nMode := _I18N_NONE
            cValue := NIL
         ENDIF
      ENDIF

      IF lCont .OR. ! Empty( cLine )
         IF ( nMode != _I18N_CONTEXT .AND. ;
            nMode != _I18N_MSGID .AND. ;
            nMode != _I18N_MSGSTR ) .OR. ;
            ! __i18n_strDecode( cLine, @cValue, @lCont )
            cErrorMsg := "unrecognized line"
            EXIT
         ENDIF
      ENDIF
   NEXT

   IF cErrorMsg == NIL
      IF lCont
         cErrorMsg := "unclosed string"
      ELSEIF nMode == _I18N_MSGSTR
         IF cValue == NIL
            cErrorMsg := "undefined msgstr value"
         ELSE
            AAdd( aItem[ _I18N_MSGSTR ], cValue )
            AAdd( aTrans, aItem )
         ENDIF
      ELSEIF nMode != _I18N_NONE
         cErrorMsg := "unclosed translation definition"
      ENDIF
   ENDIF
   IF cErrorMsg == NIL .AND. Empty( aTrans )
      cErrorMsg := "cannot find any translation rules"
   ENDIF

   IF cErrorMsg != NIL
      cErrorMsg := hb_StrFormat( "%1$s:%2$d;%3$s", cFile, nLine, cErrorMsg )
      aTrans := NIL
   ENDIF

   RETURN aTrans

STATIC FUNCTION __i18n_IsBOM_UTF8( cFileName )

   LOCAL fhnd
   LOCAL cBuffer

   IF ( fhnd := FOpen( cFileName ) ) != F_ERROR
      cBuffer := hb_FReadLen( fhnd, hb_BLen( _UTF8_BOM ) )
      FClose( fhnd )
      IF cBuffer == _UTF8_BOM
         RETURN .T.
      ENDIF
   ENDIF

   RETURN .F.

FUNCTION __i18n_potArraySort( aTrans )
   RETURN ASort( aTrans,,, {| item1, item2 | __i18n_ItemToStr( item1 ) < __i18n_ItemToStr( item2 ) } )

STATIC FUNCTION __i18n_ItemToStr( item )

   LOCAL cSource := item[ _I18N_SOURCE ]
   LOCAL tmp

   hb_default( @cSource, "" )

   IF ( tmp := At( " ", cSource ) ) > 0
      cSource := Left( cSource, tmp - 1 )
   ENDIF

   IF ( tmp := RAt( ":", cSource ) ) > 0
      cSource := "~" + Left( cSource, tmp - 1 ) + Str( Val( SubStr( cSource, tmp + 1 ) ), 10, 0 )
   ENDIF


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement these Harbour functions: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/sessid.prg. Provides functions: tip_GenerateSID, tip_CheckSID, tip_DateToGMT. This file provides network protocol implementations

[Assistant]
#define SID_LENGTH       25
#define BASE_KEY_STRING  "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
#define CRC_KEY_STRING   "Ak3yStR1Ng"

FUNCTION tip_GenerateSID( cCRCKey )

   LOCAL cSID, nSIDCRC, cSIDCRC, n, cTemp, nKey, nRand
   LOCAL cBaseKeys   := BASE_KEY_STRING
   LOCAL nLenKeys    := Len( cBaseKeys )

   cCRCKey := Left( hb_defaultValue( cCRCKey, CRC_KEY_STRING ), 10 )

   cSID := ""
   nKey := 0
   FOR n := 1 TO SID_LENGTH
      nRand := hb_randInt( nLenKeys )
      cSID  += SubStr( cBaseKeys, nRand, 1 )
      nKey  += nRand
   NEXT

   nSIDCRC := nKey
   cSIDCRC := ""
   FOR n := 1 TO Len( cTemp )
      cSIDCRC += SubStr( cCRCKey, Val( SubStr( cTemp, n, 1 ) ) + 1, 1 )
   NEXT

   RETURN cSID + cSIDCRC

FUNCTION tip_CheckSID( cSID, cCRCKey )

   LOCAL nSIDCRC, cSIDCRC, n, cTemp, nKey

   cCRCKey := Left( hb_defaultValue( cCRCKey, CRC_KEY_STRING ), 10 )

   nKey := 0
   FOR n := 1 TO SID_LENGTH
      nKey += At( SubStr( cSID, n, 1 ), BASE_KEY_STRING )
   NEXT

   nSIDCRC := nKey
   cSIDCRC := ""
   FOR n := 1 TO Len( cTemp )
      cSIDCRC += SubStr( cCRCKey, Val( SubStr( cTemp, n, 1 ) ) + 1, 1 )
   NEXT

   RETURN Right( cSID, 5 ) == cSIDCRC

FUNCTION tip_DateToGMT( tDate )

   hb_default( @tDate, hb_DateTime() )

   RETURN ;
      { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }[ DoW( tDate ) ] + ", " + ;
      StrZero( Day( tDate ), 2 ) + " " + ;
      { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }[ Month( tDate ) ] + " " + ;
      StrZero( Year( tDate ), 4 ) + " " + ;
      hb_TToC( tDate, "", "hh:mm:ss" ) + " GMT"


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Write the following Harbour (xBase/Clipper) code:

Harbour Runtime Library file: src/rtl/tgethb.prg. Defines classes: hb_Get. This file implements object-oriented classes using Harbour's class system

[Assistant]
#include "hbclass.ch"

CREATE CLASS hb_Get INHERIT Get

   EXPORTED:

   METHOD hideInput( lHideInput ) SETGET
   METHOD style( cStyle ) SETGET

ENDCLASS

METHOD hideInput( lHideInput ) CLASS hb_Get

   IF lHideInput != NIL
      ::lHideInput := __eInstVar53( Self, "HIDEINPUT", lHideInput, "L", 1001 )
   ENDIF

   RETURN ::lHideInput

METHOD style( cStyle ) CLASS hb_Get

   IF cStyle != NIL
      ::cStyle := __eInstVar53( Self, "STYLE", cStyle, "C", 1001, {|| Len( cStyle ) == 1 } )
   ENDIF

   RETURN ::cStyle


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement the following Harbour classes: WvgTreeView, WvgTreeViewItem. Harbour contribution module 'gtwvg' (): contrib/gtwvg/treeview.prg. Defines classes: WvgTreeView, WvgTreeViewItem. This file provides platform-specific functionality

[Assistant]
#include "hbclass.ch"
#include "inkey.ch"
#include "hbgtinfo.ch"

#include "hbgtwvg.ch"
#include "wvtwin.ch"
#include "wvgparts.ch"

CREATE CLASS WvgTreeView INHERIT WvgWindow, WvgDataRef

   VAR    alwaysShowSelection                   INIT .F.
   VAR    hasButtons                            INIT .F.
   VAR    hasLines                              INIT .F.

   VAR    aItems                                INIT {}

   VAR    oRootItem
   ACCESS rootItem()                            INLINE ::oRootItem

   METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
   METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
   METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
   METHOD destroy()
   METHOD handleEvent( nMessage, aNM )

   METHOD itemFromPos( aPos )

   VAR    sl_itemCollapsed
   VAR    sl_itemExpanded
   VAR    sl_itemMarked
   VAR    sl_itemSelected

   METHOD itemCollapsed( xParam )               SETGET
   METHOD itemExpanded( xParam )                SETGET
   METHOD itemMarked( xParam )                  SETGET

   VAR    oItemSelected
   ACCESS itemSelected                          INLINE ::sl_itemSelected
   ASSIGN itemSelected( bBlock )                INLINE ::sl_itemSelected := bBlock

   VAR    hParentSelected
   VAR    hItemSelected
   VAR    textParentSelected                    INIT ""
   VAR    textItemSelected                      INIT ""

   METHOD getSelectionInfo( nlParam )
   METHOD setColorFG( nRGB )                    INLINE wvg_TreeView_SetTextColor( ::hWnd, iif( HB_ISSTRING( nRGB ), wvt_GetRGBColorByString( nRGB, 0 ), nRGB ) )
   METHOD setColorBG( nRGB )                    INLINE wvg_TreeView_SetBkColor( ::hWnd, iif( HB_ISSTRING( nRGB ), wvt_GetRGBColorByString( nRGB, 1 ), nRGB ) )
   METHOD setColorLines( nRGB )                 INLINE wvg_TreeView_SetLineColor( ::hWnd, nRGB )
   METHOD showExpanded( lExpanded, nLevels )    INLINE wvg_TreeView_ShowExpanded( ::hWnd, ;
      iif( HB_ISNIL( lExpanded ), .F., lExpanded ), nLevels )

ENDCLASS

METHOD WvgTreeView:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )

   ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )

   ::style       := WS_CHILD + WS_TABSTOP + WS_CLIPSIBLINGS
   ::exStyle     := WS_EX_CLIENTEDGE

   ::className   := "SysTreeView32"
   ::objType     := objTypeTreeView

   RETURN Self

METHOD WvgTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )

   ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )

   IF ::alwaysShowSelection
      ::style += TVS_SHOWSELALWAYS
   ENDIF
   IF ::hasButtons
      ::style += TVS_HASBUTTONS
   ENDIF
   IF ::hasLines
      ::style += TVS_HASLINES + TVS_LINESATROOT
   ENDIF

   ::oParent:AddChild( Self )

   ::createControl()

   ::oRootItem       := WvgTreeViewItem():New()
   ::oRootItem:hTree := ::hWnd
   ::oRootItem:oWnd  := Self

   IF ::visible
      ::show()
   ENDIF
   ::setPosAndSize( ::aPos, ::aSize )

   RETURN Self

METHOD WvgTreeView:handleEvent( nMessage, aNM )

   LOCAL aHdr

   SWITCH nMessage

   CASE HB_GTE_RESIZED
      IF ::isParentCrt()
         ::rePosition()
      ENDIF
      ::sendMessage( WM_SIZE, 0, 0 )

   CASE HB_GTE_COMMAND
      IF HB_ISBLOCK( ::sl_lbClick )
         Eval( ::sl_lbClick, , , Self )
         RETURN EVENT_HANDELLED
      ENDIF
      EXIT

   CASE HB_GTE_NOTIFY
      aHdr := wvg_GetNMTreeViewInfo( aNM[ 2 ] )

      DO CASE
      CASE aHdr[ NMH_code ] == NM_DBLCLK .OR. aHdr[ NMH_code ] == NM_RETURN
         ::editBuffer := ::oItemSelected
         IF ::isParentCrt()
            ::oParent:setFocus()
         ENDIF
         IF HB_ISBLOCK( ::sl_itemSelected )
            Eval( ::sl_itemSelected, ::oItemSelected, { 0, 0, 0, 0 }, Self )
         ENDIF
         IF ::isParentCrt()
            IF ::pointerFocus
               ::setFocus()
            ENDIF
         ELSE
            ::setFocus()
         ENDIF
         RETURN .F.

      CASE aHdr[ NMH_code ] == TVN_SELCHANGED
         ::getSelectionInfo( aNM[ 2 ] )
         IF ::isParentCrt()
            ::oParent:setFocus()
         ENDIF
         IF HB_ISBLOCK( ::sl_itemMarked )
            Eval( ::sl_itemMarked, ::oItemSelected, { 0, 0, 0, 0 }, Self )
         ENDIF
         IF ::isParentCrt()
            IF ::pointerFocus
               ::setFocus()
            ENDIF
         ELSE
            ::setFocus()
         ENDIF
         RETURN .T.

      OTHERWISE
         RETURN .F.

      ENDCASE
      EXIT

   ENDSWITCH

   RETURN EVENT_UNHANDELLED

METHOD PROCEDURE WvgTreeView:destroy()

   ::wvgWindow:destroy()

   RETURN

METHOD WvgTreeView:getSelectionInfo( nlParam )

   LOCAL hItemSelected, hParentOfSelected
   LOCAL cParent := Space( 20 )
   LOCAL cText   := Space( 20 )
   LOCAL n

   wvg_TreeView_GetSelectionInfo( ::hWnd, nlParam, @cParent, @cText, @hParentOfSelected, @hItemSelected )

   ::hParentSelected    := hParentOfSelected
   ::hItemSelected      := hItemSelected
   ::textParentSelected := RTrim( cParent )
   ::textItemSelected   := RTrim( cText   )

   IF ( n := AScan( ::aItems, {| o | o:hItem == hItemSelected } ) ) > 0
      ::oItemSelected      := ::aItems[ n ]
   ENDIF

   RETURN Self

METHOD WvgTreeView:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )

   ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )

   RETURN Self

METHOD WvgTreeView:itemFromPos( aPos )

   HB_SYMBOL_UNUSED( aPos )

   RETURN Self

METHOD WvgTreeView:itemCollapsed( xParam )

   IF HB_ISBLOCK( xParam ) .OR. xParam == NIL
      ::sl_paint := xParam
   ENDIF

   RETURN Self

METHOD WvgTreeView:itemExpanded( xParam )

   IF HB_ISBLOCK( xParam ) .OR. xParam == NIL
      ::sl_itemExpanded := xParam
   ENDIF

   RETURN Self

METHOD WvgTreeView:itemMarked( xParam )

   IF HB_ISBLOCK( xParam ) .OR. xParam == NIL
      ::sl_itemMarked := xParam
   ENDIF

   RETURN Self

CREATE CLASS WvgTreeViewItem

   VAR    caption                               INIT ""
   VAR    dllName                               INIT NIL
   VAR    expandedImage                         INIT -1
   VAR    image                                 INIT -1
   VAR    markedImage                           INIT -1

   VAR    hTree
   VAR    hItem
   VAR    oParent
   VAR    oWnd

   VAR    className                              INIT "TREEVIEWITEM"
   VAR    objType                                INIT objTypeTreeViewItem

   METHOD new()
   METHOD create()
   METHOD configure()
   METHOD destroy()

   METHOD Expand( lExpand )                      INLINE wvg_TreeView_Expand( ::hTree, ::hItem, ;
      iif( HB_ISLOGICAL( lExpand ), lExpand, .T. ) )
   METHOD isExpanded()
   METHOD setCaption( cCaption )
   METHOD setExpandedImage( nResIdoBitmap )
   METHOD setImage( nResIdoBitmap )
   METHOD setMarkedImage( nResIdoBitmap )

   METHOD addItem( cCaption )
   METHOD delItem()
   METHOD getChildItems()
   METHOD getParentItem()
   METHOD insItem()

ENDCLASS

METHOD WvgTreeViewItem:new()
   RETURN Self

METHOD WvgTreeViewItem:create()
   RETURN Self

METHOD WvgTreeViewItem:configure()
   RETURN Self

METHOD PROCEDURE WvgTreeViewItem:destroy()
   RETURN

METHOD PROCEDURE WvgTreeViewItem:isExpanded()
   RETURN

METHOD PROCEDURE WvgTreeViewItem:setCaption( cCaption )

   HB_SYMBOL_UNUSED( cCaption )

   RETURN

METHOD PROCEDURE WvgTreeViewItem:setExpandedImage( nResIdoBitmap )

   HB_SYMBOL_UNUSED( nResIdoBitmap )

   RETURN

METHOD PROCEDURE WvgTreeViewItem:setImage( nResIdoBitmap )

   HB_SYMBOL_UNUSED( nResIdoBitmap )

   RETURN

METHOD PROCEDURE WvgTreeViewItem:setMarkedImage( nResIdoBitmap )

   HB_SYMBOL_UNUSED( nResIdoBitmap )

   RETURN

METHOD WvgTreeViewItem:addItem( cCaption )

   LOCAL oItem, hParent

   oItem := WvgTreeViewItem():New()

   oItem:hTree   := ::hTree
   oItem:oParent := Self
   oItem:caption := cCaption
   oItem:oWnd    := ::oWnd

   hParent := iif( HB_ISOBJECT( oItem:oParent ), oItem:oParent:hItem, NIL )


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour header file: include/hbgfxdef.ch. Defines 10 constants including: _HBGFXDEF_CH_, HB_GFX_ACQUIRESCREEN, HB_GFX_RELEASESCREEN, HB_GFX_MAKECOLOR, HB_GFX_CLIPTOP. Defines color and display constants

[Assistant]
#ifndef _HBGFXDEF_CH_
#define _HBGFXDEF_CH_

#define HB_GFX_ACQUIRESCREEN   1
#define HB_GFX_RELEASESCREEN   2
#define HB_GFX_MAKECOLOR       3

#define HB_GFX_CLIPTOP        10
#define HB_GFX_CLIPLEFT       11
#define HB_GFX_CLIPBOTTOM     12
#define HB_GFX_CLIPRIGHT      13
#define HB_GFX_SETCLIP        14

#define HB_GFX_DRAWINGMODE    20

#define HB_GFX_GETPIXEL       50
#define HB_GFX_PUTPIXEL       51
#define HB_GFX_LINE           52
#define HB_GFX_RECT           53
#define HB_GFX_FILLEDRECT     54
#define HB_GFX_CIRCLE         55
#define HB_GFX_FILLEDCIRCLE   56
#define HB_GFX_ELLIPSE        57
#define HB_GFX_FILLEDELLIPSE  58
#define HB_GFX_FLOODFILL      59

#define HB_GFX_MODE_SOLID      1
#define HB_GFX_MODE_XOR        2
#define HB_GFX_MODE_ALPHA      3

#endif


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Here is a Harbour (xBase/Clipper) implementation:

Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/blink.prg. Provides functions: ft_Blink. This file provides legacy compatibility functions

[Assistant]
FUNCTION ft_Blink( cMsg, nRow, nCol )

   LOCAL cSavColor

   IF cMsg != NIL

      cSavColor := SetColor()

      hb_DispOutAt( ;
         iif( nRow == NIL, Row(), nRow ), ;
         iif( nCol == NIL, Col(), nCol ), ;
         cMsg, ;
         iif( "*" $ Left( cSavColor, 4 ), cSavColor, "*" + cSavColor ) )
   ENDIF

   RETURN NIL


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Here is a Harbour (xBase/Clipper) implementation:

Harbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/numtxtru.prg. This file provides utility functions

[Assistant]
#define NTSR_MALE    1
#define NTSR_FEMA    2
#define NTSR_MIDD    3
#define NTSR_1000_1  4
#define NTSR_1000_2  5
#define NTSR_1000_3  6
#define NTSR_CNT     7
#define NTSR_ROD     8
#define NTSR_ORDG    9
#define NTSR_CURR    10
#define NTSR_CENT    11
#define NTSR_MINUS   12
#define NTSR_MONTH   13
#define NTSR_YEAR    14

STATIC sc_aRus := { ;
   { "ноль", ;
     "один", ;
     "два", ;
     "три", ;
     "четыре", ;
     "пять", ;
     "шесть", ;
     "семь", ;
     "восемь", ;
     "девять", ;
     "десять", ;
     "одиннадцать", ;
     "двенадцать", ;
     "тринадцать", ;
     "четырнадцать", ;
     "пятнадцать", ;
     "шестнадцать", ;
     "семнадцать", ;
     "восемнадцать", ;
     "девятнадцать", ;
     "двадцать", ;
     "тридцать", ;
     "сорок", ;
     "пятьдесят", ;
     "шестьдесят", ;
     "семьдесят", ;
     "восемьдесят", ;
     "девяносто", ;
     "сто", ;
     "двести", ;
     "триста", ;
     "четыреста", ;
     "пятьсот", ;
     "шестьсот", ;
     "семьсот", ;
     "восемьсот", ;
     "девятьсот" }, ;
   { "ноль", "одна", "две" }, ;
   { "ноль", "одно" }, ;
   { "тысяча", "миллион", "миллиард", "триллион", "квадриллион" }, ;
   { "тысячи", "миллиона", "миллиарда", "триллиона", "квадриллиона" }, ;
   { "тысяч", "миллионов", "миллиардов", "триллионов", "квадриллионов" }, ;
   { "нулевой", ;
     "первый", ;
     "второй", ;
     "третий", ;
     "четвертый", ;
     "пятый", ;
     "шестой", ;
     "седьмой", ;
     "восьмой", ;
     "девятый", ;
     "десятый", ;
     "одиннадцатый", ;
     "двенадцатый", ;
     "тринадцатый", ;
     "четырнадцатый", ;
     "пятнадцатый", ;
     "шестнадцатый", ;
     "семнадцатый", ;
     "восемнадцатый", ;
     "девятнадцатый", ;
     "двадцатый", ;
     "тридцатый", ;
     "сороковой", ;
     "пятидесятый", ;
     "шестидесятый", ;
     "семидесятый", ;
     "восьмидесятый", ;
     "девяностый", ;
     "сотый", ;
     "двухсотый", ;
     "трехсотый", ;
     "четырехсотый", ;
     "пятисотый", ;
     "шестисотый", ;
     "семисотый", ;
     "восьмисотый", ;
     "девятисотый", ;
     "тысячный", "миллионный", "миллиардный", "триллионный", "квадриллионный" }, ;
   { "", ;
     "", ;
     "двух", ;
     "трех", ;
     "четырех", ;
     "пяти", ;
     "шести", ;
     "семи", ;
     "восьми", ;
     "девяти", ;
     "десяти", ;
     "одиннадцати", ;
     "двенадцати", ;
     "тринадцати", ;
     "четырнадцати", ;
     "пятнадцати", ;
     "шестнадцати", ;
     "семнадцати", ;
     "восемнадцати", ;
     "девятнадцати", ;
     "двадцати", ;
     "тридцати", ;
     "сорока", ;
     "пятидесяти", ;
     "шестидесяти", ;
     "семидесяти", ;
     "восьмидесяти", ;
     "девяносто" }, ;
   { "ий", "ья", "ая", "ье", "ое" }, ;
   { NTSR_MALE, "руб.", "рубль", "рубля", "рублей" }, ;
   { NTSR_FEMA, "коп.", "копейка", "копейки", "копеек" }, ;
   "минус", ;
   { "января", "февраля", "марта", "апреля", "мая", "июня", ;
     "июля", "августа", "сентября", "октября", "ноября", "декабря" }, ;
   { "год", "года" } }

STATIC sc_aUkr := { ;
   { "нуль", ;
     "один", ;
     "два", ;
     "три", ;
     "чотири", ;
     "п'ять", ;
     "шість", ;
     "сім", ;
     "вісім", ;
     "дев'ять", ;
     "десять", ;
     "одинадцять", ;
     "дванадцять", ;
     "тринадцять", ;
     "чотирнадцять", ;
     "п'ятнадцять", ;
     "шістнадцять", ;
     "сімнадцять", ;
     "вісімнадцять", ;
     "дев'ятнадцять", ;
     "двадцять", ;
     "тридцять", ;
     "сорок", ;
     "п'ятдесят", ;
     "шістдесят", ;
     "сімдесят", ;
     "вісімдесят", ;
     "дев'яносто", ;
     "сто", ;
     "двісті", ;
     "триста", ;
     "чотириста", ;
     "п'ятсот", ;
     "шістсот", ;
     "сімсот", ;
     "вісімсот", ;
     "дев'ятсот" }, ;
   { "нуль", "одна", "дві" }, ;
   { "нуль", "одно" }, ;
   { "тисяча", "мільон", "мільярд", "трильон", "квадрильон" }, ;
   { "тисячі", "мільона", "мільярда", "трильона", "квадрильона" }, ;
   { "тисяч", "мільонів", "мілльярдів", "трильонів", "квадрильонів" }, ;
   { "нульовий", ;
     "перший", ;
     "другий", ;
     "третій", ;
     "четвертий", ;
     "п'ятий", ;
     "шостий", ;
     "сьомий", ;
     "восьмий", ;
     "дев'ятий", ;
     "десятий", ;
     "одинадцятий", ;
     "дванадцятий", ;
     "тринадцятий", ;
     "чотирнадцятий", ;
     "п'ятнадцятий", ;
     "шістнадцятий", ;
     "сімнадцятий", ;
     "вісімнадцятий", ;
     "дев'ятнадцятий", ;
     "двадцятий", ;
     "тридцятий", ;
     "сороковий", ;
     "п'ятидесятий", ;
     "шестидесятий", ;
     "семидесятий", ;
     "вісьмидесятий", ;
     "дев'яностий", ;
     "сотий", ;
     "двухсотий", ;
     "трьохсотий", ;
     "чотирехсотий", ;
     "п'ятисотий", ;
     "шестисотий", ;
     "семисотий", ;
     "вісімсотий", ;
     "дев'ятисотий", ;
     "тисячний", "мільонний", "мільярдний", "трильонний", "квадрильонний" }, ;
   { "", ;
     "", ;
     "двух", ;
     "трьох", ;
     "чотирьох", ;
     "п'яти", ;
     "шости", ;
     "семи", ;
     "вісьми", ;
     "дев'яти", ;
     "десяти", ;
     "одинадцяти", ;
     "дванадцяти", ;
     "тринадцяти", ;
     "чотирнадцяти", ;
     "п'ятнадцяти", ;
     "шістнадцяти", ;
     "сімнадцяти", ;
     "вісімнадцяти", ;
     "дев'ятнадцяти", ;
     "двадцяти", ;
     "тридцяти", ;
     "сорока", ;
     "п'ятидесяти", ;
     "шестидесяти", ;
     "семидесяти", ;
     "вісьмидесяти", ;
     "дев'яносто" }, ;
   { "ій", "я", "а", "е", "е" }, ;
   { NTSR_FEMA, "грн.", "гривня", "гривні", "гривень" }, ;
   { NTSR_FEMA, "коп.", "копійка", "копійки", "копійок" }, ;
   "мінус", ;
   { "січня", "лютого", "березня", "квітня", "травня", "червня", ;
     "липня", "серпня", "вересня", "жовтня", "листопада", "грудня" }, ;
   { "рік", "року" } }

STATIC sc_aBel := { ;
   { "нуль", ;
     "адзін", ;
     "два", ;
     "тры", ;
     "чатыры", ;
     "пяць", ;
     "шэсць", ;
     "сем", ;
     "восем", ;
     "дзевяць", ;
     "дзесяць", ;
     "адзінаццаць", ;
     "дванаццаць", ;
     "трынаццаць", ;
     "чатырнаццаць", ;
     "пятнаццаць", ;
     "шаснаццаць", ;
     "сямнаццаць", ;
     "васямнаццаць", ;
     "дзевятнаццаць", ;
     "дваццаць", ;
     "трыццаць", ;
     "сорак", ;
     "пяцьдзесят", ;
     "шэсцьдзесят", ;
     "семдзесят", ;
     "восемдзесят", ;
     "дзевяноста", ;
     "сто", ;
     "дзвесце", ;
     "трыста", ;
     "чатырыста", ;
     "пяцьсот", ;
     "шэсьцьсот", ;
     "сямсот", ;
     "васямсот", ;
     "дзевяцьсот" }, ;
   { "нуль", "адна", "две" }, ;
   { "нуль", "адно" }, ;
   { "тысяча", "мільён", "мільярд", "трыльён", "квадрыльён" }, ;
   { "тысячы", "мільёна", "мільярда", "трыльёна", "квадрыльёна" }, ;
   { "тысяч", "мільёнаў", "мільярдаў", "трыльёнаў", "квадрыльёнаў" }, ;
   { "нулёвы", ;
     "першы", ;
     "другі", ;
     "трэйці", ;
     "чацьверты", ;
     "пяты", ;
     "шосты", ;
     "сёмы", ;
     "восьмы", ;
     "дзявяты", ;
     "дзясяты", ;
     "адзінаццаты", ;
     "дванаццаты", ;
     "трынаццаты", ;
     "чатырнаццаты", ;
     "пятнаццаты", ;
     "шаснаццаты", ;
     "сямнаццаты", ;
     "васямнаццаты", ;
     "дзевятнаццаты", ;
     "дваццаты", ;
     "трыццаты", ;
     "саракавы", ;
     "пяцідзесяты", ;
     "шасьцідзясяты", ;
     "сямідзясяты", ;
     "васьмідзясяты", ;
     "дзевяносты", ;
     "соты", ;
     "двухсоты", ;
     "трохсоты", ;
     "чатырохсоты", ;
     "пяцісоты", ;
     "шасьцісоты", ;
     "сямісоты", ;
     "васьмісоты", ;
     "дзевяцісоты", ;
     "тысячны", "мільённы", "мільярдны", "трыльённы", "квадрыльённы" }, ;
   { "", ;
     "", ;
     "двух", ;
     "трах", ;
     "чатырох", ;
     "пяці", ;
     "шасці", ;
     "сямі", ;
     "васьмі", ;
     "дзевяці", ;
     "дзесяці", ;
     "адзінаццаці", ;
     "дванаццаці", ;
     "трынаццаці", ;
     "чатырнаццаці", ;
     "пятнаццаці", ;
     "шаснаццаці", ;
     "сямнаццаці", ;
     "васямнаццаці", ;
     "дзевятнаццаці", ;
     "дваццаці", ;
     "трыццаці", ;
     "сарака", ;
     "пяціцдзесяці", ;
     "шасцідзесяці", ;
     "сямідзесяці", ;
     "васьмідзесяці", ;


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour test program: tests/strdelim.prg. Contains procedures: Main. This test file exercises basic Harbour language features

[Assistant]
PROCEDURE Main()

   LOCAL aArray := { { NIL } }

   aArray[ 1  ][ 1  ] := [Hello]

   ? aArray[ 1 ][ 1 ]

   ? 'World "Peace[!]"'

   ? "Harbour 'Power[!]'"

   ? [King 'Clipper "!"']

   RETURN


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour contribution module 'hbfoxpro' (FoxPro file format support): contrib/hbfoxpro/misc.prg. Provides 6 functions including: Sys, Id, AFillNested, __fox_Array, AElement. This file handles data format parsing and generation

[Assistant]
#include "setcurs.ch"
#include "dbinfo.ch"

FUNCTION Sys( nValue, xPar1 )

   SWITCH nValue
   CASE 0
      RETURN Id()
   CASE 1
      RETURN hb_ntos( Date() - CToD( "" ) )
   CASE 2
      RETURN hb_ntos( Seconds() )
   CASE 5
      RETURN Set( _SET_DEFAULT )
   CASE 6
      RETURN Set( _SET_PRINTFILE )
   CASE 10
      RETURN DToC( CToD( "" ) + hb_defaultValue( xPar1, 0 ) )
   CASE 11
      RETURN hb_ntos( iif( HB_ISDATETIME( xPar1 ), xPar1, ;
                           iif( HB_ISSTRING( xPar1 ), CToD( xPar1 ), ;
                           Date() ) ) - CToD( "" ) )
   CASE 100
      RETURN iif( Set( _SET_CONSOLE ), "ON", "OFF" )
   CASE 101
      RETURN Set( _SET_DEVICE )
   CASE 102
      RETURN iif( Set( _SET_PRINTER ), "ON", "OFF" )
   CASE 2002
      RETURN SetCursor( hb_defaultValue( xPar1, SC_NONE ) )
   CASE 2003
      RETURN CurDir()
   CASE 2011
      RETURN iif( ! dbInfo( DBOI_SHARED ),     "Exclusive", ;
             iif( dbInfo( DBI_ISFLOCK ),       "File locked", ;
             iif( dbRecordInfo( DBRI_LOCKED ), "Record locked", ;
                                               "Not locked" ) ) )
   CASE 2020
      RETURN hb_DiskSpace( Set( _SET_DEFAULT ) )
   OTHERWISE

   ENDSWITCH

   RETURN NIL

FUNCTION Id()
   RETURN NetName() + " # " + hb_UserName()

STATIC FUNCTION AFillNested( aValue, xVal )

   LOCAL item

   FOR EACH item IN aValue
      IF HB_ISARRAY( item )
         AFillNested( item, xVal )
      ELSE
         item := xVal
      ENDIF
   NEXT

   RETURN aValue

FUNCTION __fox_Array( ... )
   RETURN AFillNested( Array( ... ), .F. )

FUNCTION AElement( aValue, ... )
   RETURN aValue[ ... ]

FUNCTION InsMode( ... )
   RETURN Set( _SET_INSERT, ... )


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/timestmp.prg. Contains procedures: Main. This file provides network protocol implementations

[Assistant]
#require "hbtip"

#include "simpleio.ch"

PROCEDURE Main()

   ? "'" + tip_TimeStamp() + "'"
   ? "'" + tip_TimeStamp( NIL, 200 ) + "'"
   ? "'" + tip_TimeStamp( Date() ) + "'"
   ? "'" + tip_TimeStamp( Date(), 200 ) + "'"
   ? "'" + tip_TimeStamp( hb_DateTime() ) + "'"
   ? "'" + tip_TimeStamp( hb_DateTime(), 200 ) + "'"

   RETURN


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour contribution module 'hbformat' (Text formatting utilities): contrib/hbformat/hbfuncs.prg. Provides functions: __harbour_hbx. Contains procedures: __hbformat_BuildListOfFunctions, WalkDir, HBXToFuncList. This file provides graphics and image processing capabilities

[Assistant]
#include "directry.ch"

PROCEDURE __hbformat_BuildListOfFunctions(  cFunctions, cHBXList )

   LOCAL aFile
   LOCAL cName
   LOCAL lContribHBR := .F.

   HBXToFuncList( @cFunctions, __harbour_hbx() )

   FOR EACH aFile IN Directory( hb_DirBase() + "*.hbr" )
      IF hb_FileMatch( hb_FNameName( aFile[ F_NAME ] ), "contrib" )
         lContribHBR := .T.
      ENDIF
      FOR EACH cName IN hb_Deserialize( hb_ZUncompress( hb_MemoRead( hb_DirBase() + aFile[ F_NAME ] ) ) )
         cFunctions += "," + cName:__enumKey()
      NEXT
   NEXT

   IF ! lContribHBR
      WalkDir( hb_DirBase() + ".." + hb_ps() + "contrib", @cFunctions )
   ENDIF
   WalkDir( hb_DirBase() + ".." + hb_ps() + "addons", @cFunctions )

   FOR EACH cName IN hb_ATokens( cHBXList )
      HBXToFuncList( @cFunctions, hb_MemoRead( hb_PathJoin( hb_DirBase(), cName ) ) )
   NEXT

   RETURN

STATIC PROCEDURE WalkDir( cDir,  cFunctions )

   LOCAL aFile

   cDir := hb_DirSepAdd( cDir )

   FOR EACH aFile IN hb_DirScan( cDir, "*.hbx" )
      HBXToFuncList( @cFunctions, hb_MemoRead( cDir + aFile[ F_NAME ] ) )
   NEXT

   RETURN

STATIC PROCEDURE HBXToFuncList(  cFunctions, cHBX )
   LOCAL cLine

   FOR EACH cLine IN hb_ATokens( StrTran( cHBX, Chr( 13 ) ), Chr( 10 ) )
      IF Left( cLine, Len( "DYNAMIC " ) ) == "DYNAMIC "
         cFunctions += "," + SubStr( cLine, Len( "DYNAMIC " ) + 1 )
      ENDIF
   NEXT

   RETURN

STATIC FUNCTION __harbour_hbx()

#pragma __streaminclude "harbour.hbx" | RETURN %s


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Here is a Harbour (xBase/Clipper) implementation:

Harbour test program: tests/sdf.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
PROCEDURE Main()

   LOCAL ncount := 0

   USE test NEW

   COPY TO test1 SDF

   COPY FIELD first, last, street, city, state, zip TO test2 SDF FOR _field->salary > 50000

   COPY RECORD 3 TO test3 SDF

   COPY NEXT 4 TO test4 SDF

   GO BOTTOM
   SKIP -4
   COPY WHILE ncount++ < 9 TO test4a SDF

   GO BOTTOM
   SKIP -9
   COPY REST TO test5 SDF

   GO BOTTOM
   SKIP -9
   COPY TO test6 SDF WHILE ! Eof()

   GO BOTTOM
   SKIP -9
   COPY REST TO test7 SDF FOR _field->married

   DELETE FILE test8.txt
   APPEND FROM test8 SDF

   RETURN


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour utility program: utils/hbtest/rt_hvma.prg. Contains procedures: Main_HVMA. This file is part of the test framework

[Assistant]
#include "rt_main.ch"

#include "rt_vars.ch"

PROCEDURE Main_HVMA()

   LOCAL nA, nB, nC

   HBTEST mnIntP==10.OR.mnIntP==0         IS .T.
   HBTEST mnIntP==10.AND.mnLongP==0       IS .F.

#ifdef __HARBOUR__

   #pragma -ko-
#endif
   HBTEST NIL + 1                         IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:U:NIL;N:1 F:S"
   HBTEST NIL - 1                         IS "E 1 BASE 1082 Argument error (-) OS:0 #:0 A:2:U:NIL;N:1 F:S"

#ifdef __HARBOUR__
   #pragma -ko+
#endif

   HBTEST scString + NIL                  IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:C:HELLO;U:NIL F:S"
   HBTEST scString - NIL                  IS "E 1 BASE 1082 Argument error (-) OS:0 #:0 A:2:C:HELLO;U:NIL F:S"

#ifdef __HARBOUR__

   #pragma -ko-
#endif
   HBTEST 1 + NIL                         IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:N:1;U:NIL F:S"
#ifdef __HARBOUR__
   #pragma -ko+
#endif
   HBTEST 1 - NIL                         IS "E 1 BASE 1082 Argument error (-) OS:0 #:0 A:2:N:1;U:NIL F:S"

   HBTEST "A" - "B"                       IS "AB"
   HBTEST "A  " - "B"                     IS "AB  "
   HBTEST "A  " - "B "                    IS "AB   "
   HBTEST "A  " - " B"                    IS "A B  "
   HBTEST "   " - "B "                    IS "B    "

   HBTEST 1 / 0                           IS "E 5 BASE 1340 Zero divisor (/) OS:0 #:0 A:2:N:1;N:0 F:S"
   HBTEST 1 / NIL                         IS "E 1 BASE 1084 Argument error (/) OS:0 #:0 A:2:N:1;U:NIL F:S"
   HBTEST 1 * NIL                         IS "E 1 BASE 1083 Argument error (*) OS:0 #:0 A:2:N:1;U:NIL F:S"
   HBTEST 1 ** NIL                        IS "E 1 BASE 1088 Argument error (^) OS:0 #:0 A:2:N:1;U:NIL F:S"
   HBTEST 1 ^ NIL                         IS "E 1 BASE 1088 Argument error (^) OS:0 #:0 A:2:N:1;U:NIL F:S"
   HBTEST 1 % 0                           IS "E 5 BASE 1341 Zero divisor (%) OS:0 #:0 A:2:N:1;N:0 F:S"
   HBTEST 1 % NIL                         IS "E 1 BASE 1085 Argument error (%) OS:0 #:0 A:2:N:1;U:NIL F:S"

   HBTEST Str( 1 / 0   )                  IS "E 5 BASE 1340 Zero divisor (/) OS:0 #:0 A:2:N:1;N:0 F:S"
   HBTEST Str( 2 / 4   )                  IS "         0.50"
   HBTEST Str( 4 / 2   )                  IS "         2"
   HBTEST Str( 4 / 2.0 )                  IS "         2.00"
   HBTEST Str( 1 * 0   )                  IS "         0"
   HBTEST Str( 2 * 4   )                  IS "         8"
   HBTEST Str( 4 * 2.0 )                  IS "         8.0"
   HBTEST Str( 2 * 0.5 )                  IS "         1.0"
   HBTEST Str( 1 + 0   )                  IS "         1"
   HBTEST Str( 2 + 4   )                  IS "         6"
   HBTEST Str( 4 + 2.0 )                  IS "         6.0"
   HBTEST Str( 2 + 0.5 )                  IS "         2.5"
   HBTEST Str( 1 - 0   )                  IS "         1"
   HBTEST Str( 2 - 4   )                  IS "        -2"
   HBTEST Str( 4 - 2.0 )                  IS "         2.0"
   HBTEST Str( 2 - 0.5 )                  IS "         1.5"
   HBTEST Str( 1 % 0   )                  IS "E 5 BASE 1341 Zero divisor (%) OS:0 #:0 A:2:N:1;N:0 F:S"
   HBTEST Str( 2 % 4   )                  IS "         2"
   HBTEST Str( 4 % 2   )                  IS "         0"
   HBTEST Str( 4 % 2.0 )                  IS "         0.00"
   HBTEST Str( 2 % 4.0 )                  IS "         2.00"

   HBTEST Str(  3 %  3 )                   IS "         0"
   HBTEST Str(  3 %  2 )                   IS "         1"
   HBTEST Str(  3 %  1 )                   IS "         0"
   HBTEST Str(  3 %  0 )                   IS "E 5 BASE 1341 Zero divisor (%) OS:0 #:0 A:2:N:3;N:0 F:S"
   HBTEST Str(  3 % -1 )                   IS "         0"
   HBTEST Str(  3 % -2 )                   IS "         1"
   HBTEST Str(  3 % -3 )                   IS "         0"
   HBTEST Str( -3 %  3 )                   IS "         0"
   HBTEST Str( -3 %  2 )                   IS "        -1"
   HBTEST Str( -3 %  1 )                   IS "         0"
   HBTEST Str( -3 %  0 )                   IS "E 5 BASE 1341 Zero divisor (%) OS:0 #:0 A:2:N:-3;N:0 F:S"
   HBTEST Str( -3 % -1 )                   IS "         0"
   HBTEST Str( -3 % -2 )                   IS "        -1"
   HBTEST Str( -3 % -3 )                   IS "         0"
   HBTEST Str(  3 %  3 )                   IS "         0"
   HBTEST Str(  2 %  3 )                   IS "         2"
   HBTEST Str(  1 %  3 )                   IS "         1"
   HBTEST Str(  0 %  3 )                   IS "         0"
   HBTEST Str( -1 %  3 )                   IS "        -1"
   HBTEST Str( -2 %  3 )                   IS "        -2"
   HBTEST Str( -3 %  3 )                   IS "         0"
   HBTEST Str(  3 % -3 )                   IS "         0"
   HBTEST Str(  2 % -3 )                   IS "         2"
   HBTEST Str(  1 % -3 )                   IS "         1"
   HBTEST Str(  0 % -3 )                   IS "         0"
   HBTEST Str( -1 % -3 )                   IS "        -1"
   HBTEST Str( -2 % -3 )                   IS "        -2"
   HBTEST Str( -3 % -3 )                   IS "         0"

   nA := 1
   nB := 2
   nC := 3

   HBTEST nA                              IS 1
   HBTEST nB                              IS 2
   HBTEST nC                              IS 3

   HBTEST nA + nB                         IS 3
   HBTEST nB - nA                         IS 1
   HBTEST nB
   HBTEST Str( -( Month( sdDate ) ) )     IS "        -3"
   HBTEST Str( -( Val( "10" ) ) )         IS "       -10"
   HBTEST Str( -( Val( "100000" ) ) )     IS "   -100000"
   HBTEST Str( -( Val( "20.876" ) ) )     IS "       -20.876"
   HBTEST -( 0 )                          IS 0
   HBTEST -( 10 )                         IS -10
   HBTEST -( 10.505 )                     IS -10.505
   HBTEST -( 100000 )                     IS -100000
   HBTEST -( -10 )                        IS 10
   HBTEST -( "1" )                        IS "E 1 BASE 1080 Argument error (-) OS:0 #:0 A:1:C:1 F:S"

   HBTEST "AA" $ 1                        IS "E 1 BASE 1109 Argument error ($) OS:0 #:0 A:2:C:AA;N:1 F:S"
   HBTEST scString $ 1                    IS "E 1 BASE 1109 Argument error ($) OS:0 #:0 A:2:C:HELLO;N:1 F:S"
   HBTEST 1 $ "AA"                        IS "E 1 BASE 1109 Argument error ($) OS:0 #:0 A:2:N:1;C:AA F:S"

   HBTEST !   scStringE $ "XE"            IS .T.
   HBTEST ! ( scStringE $ "XE" )          IS .T.
   HBTEST     scStringE $ "XE"            IS .F.
   HBTEST !   "X" $ "XE"                  IS .F.
   HBTEST ! ( "X" $ "XE" )                IS .F.
   HBTEST     "X" $ "XE"                  IS .T.
   HBTEST     "X" $ Chr( 0 ) + "X"        IS .T.
   HBTEST ( "X" ) $ Chr( 0 ) + "X"        IS .T.
   HBTEST scString $ Chr( 0 ) + scString  IS .T.

   HBTEST scStringE $ scStringE           IS .F.
   HBTEST scStringE $ "bcde"              IS .F.

#ifdef __HARBOUR__
   #pragma -kh-
#endif
   HBTEST "" $ ""                         IS .T.
   HBTEST "" $ "bcde"                     IS .T.
#ifdef __HARBOUR__

   #pragma -kh+
   HBTEST "" $ ""                         IS .F.
   HBTEST "" $ "bcde"                     IS .F.
#endif
   HBTEST "d" $ "bcde"                    IS .T.
   HBTEST "D" $ "BCDE"                    IS .T.
   HBTEST "a" $ "bcde"                    IS .F.
   HBTEST "d" $ "BCDE"                    IS .F.
   HBTEST "D" $ "bcde"                    IS .F.
   HBTEST "de" $ "bcde"                   IS .T.
   HBTEST "bd" $ "bcde"                   IS .F.
   HBTEST "BD" $ "bcde"                   IS .F.

#ifndef __XPP__

   IF TEST_OPT_Z()

   HBTEST "1" .AND. "2"                   IS "E 1 BASE 1066 Argument error (conditional) OS:0 #:0 A:1:C:1 "
   HBTEST 1 .AND. 2                       IS "E 1 BASE 1066 Argument error (conditional) OS:0 #:0 A:1:N:1 "
   HBTEST NIL .AND. NIL                   IS "E 1 BASE 1066 Argument error (conditional) OS:0 #:0 A:1:U:NIL "


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Write the following Harbour (xBase/Clipper) code:

Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charslst.prg. Contains procedures: Main. This file provides legacy compatibility functions

[Assistant]
#ifdef __HARBOUR__
#require "hbct"
#endif

PROCEDURE Main()

   ctinit()

   ? "Begin test of CharSList()"
   ?

   ? "Simple tests:"
   ? '  CharSList( "Hello World !" ) == " !HWdelor" ? -> "' + CharSList( "Hello World !" ) + '"'
   ? '  CharSList( NIL ) == "" ? -> "' + CharSList( NIL ) + '"'

   ? "End test of CharSList()"
   ?

   ctexit()

   RETURN


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Write the following Harbour (xBase/Clipper) code:

Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/sleep.prg. Provides functions: ft_Sleep. This file provides legacy compatibility functions

[Assistant]
FUNCTION ft_Sleep( nSeconds, nInitial )

   IF HB_ISNUMERIC( nInitial )
      nInitial -= Seconds()
      IF nInitial > 0
         nInitial -= 86399
      ENDIF

      nSeconds += ninitial
   ENDIF

   hb_idleSleep( nSeconds )

   RETURN NIL


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Generate Harbour code for: Harbour test program: tests/memmgr.prg. Provides functions: build_mode, hb_mtvm. Contains procedures: Main. This test file exercises basic Harbour language features

[Assistant]
#include "simpleio.ch"

#define N_LOOPS   100000

#ifdef __HARBOUR__
#include "hbmemory.ch"
#endif

PROCEDURE Main()

   LOCAL nCPUSec, nRealSec, i, a

#ifdef __HARBOUR__

   IF Memory( HB_MEM_USEDMAX ) != 0
      ?
      ? "Warning !!! Memory statistics enabled."
   ENDIF
#endif
   ?
   ? Date(), Time(), Version() + build_mode() + ", " + OS()

   ?
   ? "testing single large memory blocks allocation and freeing..."
   nRealSec := Seconds()
   nCPUSec := hb_SecondsCPU()
   FOR i := 1 TO N_LOOPS
      a := Space( 50000 )
   NEXT
   a := NIL
   nCPUSec := hb_SecondsCPU() - nCPUSec
   nRealSec := Seconds() - nRealSec
   ? " CPU time:", nCPUSec, "sec."
   ? "real time:", nRealSec, "sec."

   ?
   ? "testing many large memory blocks allocation and freeing..."
   nRealSec := Seconds()
   nCPUSec := hb_SecondsCPU()
   a := Array( 100 )
   FOR i := 1 TO N_LOOPS
      a[ i % 100 + 1 ] := Space( 50000 )
      IF i % 200 == 0
         AFill( a, "" )
      ENDIF
   NEXT
   a := NIL
   nCPUSec := hb_SecondsCPU() - nCPUSec
   nRealSec := Seconds() - nRealSec
   ? " CPU time:", nCPUSec, "sec."
   ? "real time:", nRealSec, "sec."

   ?
   ? "testing large memory block reallocation with intermediate allocations..."
   ? "Warning!!! some compilers may badly fail here"
   WAIT

   nRealSec := Seconds()
   nCPUSec := hb_SecondsCPU()
   a := {}
   FOR i := 1 TO N_LOOPS
      AAdd( a, {} )
      IF i % 1000 == 0
         ?? i
      ENDIF
   NEXT
   nCPUSec := hb_SecondsCPU() - nCPUSec
   nRealSec := Seconds() - nRealSec
   ? " CPU time:", nCPUSec, "sec."
   ? "real time:", nRealSec, "sec."
   WAIT

   RETURN

FUNCTION build_mode()
#ifdef __CLIP__
   RETURN " (MT)"
#else
#ifdef __XHARBOUR__
   RETURN iif( hb_MultiThread(), " (MT)", "" ) + ;
      iif( Memory( HB_MEM_USEDMAX ) != 0, " (FMSTAT)", "" )
#else
#ifdef __HARBOUR__
   RETURN iif( hb_mtvm(), " (MT)", "" ) + ;
      iif( Memory( HB_MEM_USEDMAX ) != 0, " (FMSTAT)", "" )
#else
#ifdef __XPP__
   RETURN " (MT)"
#else
   RETURN ""
#endif
#endif
#endif
#endif

#if __HARBOUR__ < 0x010100

FUNCTION hb_mtvm()
   RETURN .F.

#endif


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Here is a Harbour (xBase/Clipper) implementation:

Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/tests/barcode2.prg. Contains procedures: Main. This file provides graphics and image processing capabilities

[Assistant]
#require "hbgd"

#define IMAGES_OUT "imgs_out" + hb_ps()

PROCEDURE Main()

   LOCAL bar

   LOCAL black  := { 0, 0, 0 }
   LOCAL white  := { 255, 255, 255 }

   LOCAL ccode13    := "P48WBQ7BX3M73X8V3WRT7F9JW"
   LOCAL ccode8     := "P48WBQ7BX3M73X8V3WRT7F9JW"
   LOCAL ccode128   := "P48WBQ7BX3M73X8V3WRT7F9JW"

   bar := GDBarCode():New( 13 )

   bar:Configure( 70, black, white, 2, 1 )

   bar:CreateBar( 205, 105, IMAGES_OUT + "bar13.jpg", white )

   bar:Draw13( ccode13 )

   bar:Finish( 2 )

   bar := GDBarCode():New( 8 )

   bar:Configure( 70, black, white, 2, 1 )

   bar:CreateBar( 154, 100, IMAGES_OUT + "bar8.gif", white )

   bar:Draw8( ccode8 )

   bar:Finish( 8 )

   bar:ResizeImage()

   bar := GDBarCode():New( 128 )

   bar:Configure( 50, black, white, 2, 1 )

   bar:CreateBar( 559, 88, IMAGES_OUT + "bar128.gif", white )

   bar:Draw128( cCode128, "A" )

   bar:Finish( 8 )

   bar := GDBarCode():New( 25 )

   bar:Configure( 25, black, white, 1, 1,, .T. )

   bar:CreateBar( 560, 60, IMAGES_OUT + "febraban.gif", white )
   bar:DrawI25( "P48WBQ7BX3M73X8V3WRT7F9JW" )
   bar:Finish( 8 )

   RETURN


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User]
Here is a Harbour (xBase/Clipper) implementation:

Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/tedit.prg. Defines classes: THtmlControl. This file provides legacy compatibility functions

[Assistant]
#include "hbclass.ch"
#include "cgi.ch"

#define _OPTION_TEXT      1
#define _OPTION_VALUE     2
#define _OPTION_LABEL     3
#define _OPTION_SELECTED  4
#define _OPTION_DISABLED  5

STATIC s_oForm

CREATE CLASS THtmlControl

   VAR nH
   VAR Document
   VAR FORM
   VAR oHtm

   VAR Caption
   VAR lBreak INIT .F.

   VAR TYPE INIT "TEXT"
   VAR Name
   VAR Value
   VAR Size
   VAR ROWS, COLS

   VAR cOutPut INIT ""

   VAR PICTURE INIT "@X"

   VAR aOptions INIT {}

   VAR TabIndex INIT 0
   VAR disabled INIT .F.
   VAR READONLY INIT .F.
   VAR Multiple INIT .F.
   VAR style
   VAR ID

   VAR MaxLength
   VAR MaxChars

   VAR Checked INIT .F.
   VAR lLabel INIT .F.

   VAR Source, Align
   VAR WRAP

   VAR onBlur
   VAR onChange
   VAR onFocus
   VAR onSelect
   VAR onClick
   VAR onMouseOver
   VAR onMouseOut
   VAR onMouseDown
   VAR onMouseup
   VAR onKeyPress
   VAR onKeyDown
   VAR onKeyUp

   METHOD SetName( c )     INLINE ::Name := c
   METHOD SetValue( c )    INLINE ::Value := c
   METHOD SetStyle( c )    INLINE ::Style := c
   METHOD SetId( c )       INLINE ::id := c
   METHOD SetRows( c )     INLINE ::Rows := c
   METHOD SetCols( c )     INLINE ::Cols := c
   METHOD SetCaption( c )  INLINE ::Caption := c
   METHOD SetPicture( c )  INLINE ::picture := c
   METHOD SetOnBlur( c )   INLINE ::onBlur := c
   METHOD SetOnChange( c ) INLINE ::onChange := c
   METHOD SetOnFocus( c )  INLINE ::onFocus := c
   METHOD SetOnSelect( c ) INLINE ::onSelect := c
   METHOD SetOnClick( c )  INLINE ::onClick := c
   METHOD SetOnMsOver( c ) INLINE ::onMouseOver := c
   METHOD SetOnMsOut( c )  INLINE ::onMouseOut := c
   METHOD SetSize( n )     INLINE ::Size := n
   METHOD SetMaxChars( n ) INLINE ::MaxChars := n
   METHOD SetChecked( l )  INLINE ::Checked := l
   METHOD SetAlign( c )    INLINE ::Align := c
   METHOD SetWrap( c )     INLINE ::wrap := c
   METHOD SetSource( c )   INLINE ::Source := c
   METHOD SetReadOnly( l ) INLINE ::readOnly := l
   METHOD SetDisabled( l ) INLINE ::disabled := l
   METHOD SetMultiple( l ) INLINE ::multiple := l
   METHOD SetOnMsDown( c ) INLINE ::onMouseDown := c
   METHOD SetOnMsUp( c )   INLINE ::onMouseup := c
   METHOD SetOnKPress( c ) INLINE ::onKeyPress := c
   METHOD SetOnKDown( c )  INLINE ::onKeyDown := c
   METHOD SetOnKUp( c )    INLINE ::onKeyUp := c
   METHOD SetLabel( l )    INLINE ::lLabel := l
   METHOD Put()
   METHOD AddOption( cOption, cValue, cLabel, lSelected, lDisabled )
   METHOD SetControl( name, rows, cols, size, maxchars, value, onfocus, ;
      onblur, onchange, onselect, onclick, onmsover, onmsout, ;
      onmsdown, onmsup, onkdown, onkup, onkprs, ;
      pic, cap, dis, ro, lMulti, checked, ;
      align, wrap, type, Style, ID, lLabel )

ENDCLASS

METHOD Put() CLASS THtmlControl

   LOCAL i
   LOCAL cStr := ""

   ::nH := HtmlPageHandle()
   ::form := HtmlFormName()
   ::oHtm := HtmlPageObject()

   ::cOutput += iif( ::lBreak, CRLF() + "
", CRLF() )
   IF ::lLabel
      ::cOutPut += CRLF() + "" + CRLF()
   ENDIF

   IF ::Caption != NIL
      ::cOutput += ::Caption + HTMLSPACE( 2 ) + " " + CRLF()
   ENDIF

   IF ::Type == "SELECT"
      ::cOutPut += CRLF() + ' <select ' + CRLF()
   ELSE
      ::cOutPut += CRLF() + ' <input type="'
      ::cOutput += ::Type + '"' + CRLF()
   ENDIF

   IF ::Name != NIL
      ::cOutput += Space( 2 ) + '     name="' + ::Name + '"' + CRLF()
   ENDIF

   IF ::Type == "TEXTAREA"

      IF ::Rows != NIL
         ::cOutput += Space( 2 ) + '     rows="' + hb_ntos( ::Rows ) + '"' + CRLF()
      ENDIF

      IF ::Cols != NIL
         ::cOutput += Space( 2 ) + '     cols="' + hb_ntos( ::Cols ) + '"' + CRLF()
      ENDIF

      IF ::Wrap != NIL
         ::cOutput += Space( 2 ) + '     wrap="' + ::Wrap + '"' + CRLF()
      ENDIF

   ENDIF

   IF ::value != NIL

      IF ::Picture == NIL
         ::Picture := "@X"
      ENDIF

      ::cOutput += Space( 2 ) + '    value="' + Transform( ::Value, ::Picture ) + '"' + CRLF()
   ENDIF

   IF ::maxChars != NIL
      ::cOutput += Space( 2 ) + 'maxlength="' + hb_ntos( ::maxChars ) + '"' + CRLF()
   ENDIF

   IF ::Size != NIL
      ::cOutput += Space( 2 ) + '     size="' + hb_ntos( ::Size ) + '"' + CRLF()
   ENDIF

   IF ::Id != NIL
      ::cOutput += Space( 2 ) + '       id="' + ::Id + '"' + CRLF()
   ENDIF

   IF ::Style != NIL
      ::cOutput += Space( 2 ) + '    style="' + ::Style + '"' + CRLF()
   ENDIF

   IF ::type == "IMAGE"

      IF ::Source != NIL
         ::cOutput += Space( 2 ) + '      src="' + ::Source + '"' + CRLF()
      ENDIF

   ENDIF

   IF ::Align != NIL
      ::cOutput += Space( 2 ) + '    align="' + ::Align + '"' + CRLF()
   ENDIF

   IF ::type == "RADIO" .OR. ::type == "CHECKBOX"

      IF ::Checked
         ::cOutput += Space( 2 ) + '   CHECKED' + CRLF()
      ENDIF

   ENDIF

   IF ::Disabled
      ::cOutput += Space( 2 ) + '  DISABLED' + CRLF()
   ENDIF

   IF ::Readonly
      ::cOutput += Space( 2 ) + '  READONLY' + CRLF()
   ENDIF

   IF ::onChange != NIL
      ::cOutput += Space( 2 ) + ' onChange="' + ::onChange + '"' + CRLF()
   ENDIF

   IF ::onFocus != NIL
      ::cOutput += Space( 2 ) + '  onFocus="' + ::onFocus + '"' + CRLF()
   ENDIF

   IF ::onBlur != NIL
      ::cOutput += Space( 2 ) + '   onBlur="' + ::onBlur + '"' + CRLF()
   ENDIF

   IF ::onSelect != NIL
      ::cOutput += Space( 2 ) + ' onSelect="' + ::onSelect + '"' + CRLF()
   ENDIF

   IF ::onClick != NIL
      ::cOutput += Space( 2 ) + '  onClick="' + ::onClick + '"' + CRLF()
   ENDIF

   IF ::onMouseOver != NIL
      ::cOutput += 'onMouseOver="' + ::onMouseOver + '"' + CRLF()
   ENDIF

   IF ::onMouseOut != NIL
      ::cOutput += Space( 1 ) + 'onMouseOut="' + ::onMouseOut + '"' + CRLF()
   ENDIF

   IF ::onMouseDown != NIL
      ::cOutput += 'onMouseDown="' + ::onMouseDown + '"' + CRLF()
   ENDIF

   IF ::onMouseUp != NIL
      ::cOutput += Space( 1 ) + 'onMouseUp="' + ::onMouseUp + '"' + CRLF()
   ENDIF

   IF ::onKeyDown != NIL
      ::cOutput += 'onKeyDown="' + ::onKeyDown + '"' + CRLF()
   ENDIF

   IF ::onKeyUp != NIL
      ::cOutput += Space( 1 ) + 'onKeyUp="' + ::onKeyUp + '"' + CRLF()
   ENDIF

   IF ::onKeyPress != NIL
      ::cOutput += Space( 1 ) + 'onKeyPress="' + ::onKeyPress + '"' + CRLF()
   ENDIF

   ::cOutput += " >" + CRLF()

   IF ::lLabel
      ::cOutPut += CRLF() + "" + CRLF()
   ENDIF

   ::oHtm:cStr += ::cOutput

   IF ::Type == "SELECT"

      FOR i := 1 TO Len( ::aOptions )
         cStr := "<option"
         cStr += iif( ::aOptions[ i, _OPTION_VALUE ] != NIL, ;
            " value=" + ::aOptions[ i, _OPTION_VALUE ], "" )
         cStr += iif( ::aOptions[ i, _OPTION_LABEL ] != NIL, ;
            " label=" + ::aOptions[ i, _OPTION_LABEL ], "" )
         cStr += iif( ::aOptions[ i, _OPTION_SELECTED ] != NIL .AND. ::aOptions[ i, _OPTION_SELECTED ], ;
            " SELECTED ", "" )
         cStr += iif( ::aOptions[ i, _OPTION_DISABLED ] != NIL .AND. ::aOptions[ i, _OPTION_DISABLED ], ;
            " DISABLED ", "" )
         cStr += ">" + ::aOptions[ i, _OPTION_TEXT ] + "</option>" + CRLF()

         ::oHtm:cStr += cStr
      NEXT

      ::oHtm:cStr += "</select>"
   ENDIF

   RETURN Self

METHOD AddOption( cOption, cValue, cLabel, lSelected, lDisabled ) CLASS THtmlControl

   AAdd( ::aOptions, { cOption, cValue, cLabel, lSelected, lDisabled } )

   RETURN Self

METHOD SetControl( name, rows, cols, size, maxchars, value, onfocus, ;
      onblur, onchange, onselect, onclick, onmsover, onmsout, ;
      onmsdown, onmsup, onkdown, onkup, onkprs, ;
      pic, cap, dis, ro, lMulti, checked, ;
      align, wrap, type, Style, ID, lLabel ) CLASS THtmlControl

   ::name := name
   ::rows := ROWS
   ::cols := COLS
   ::size := size
   ::maxChars := maxchars
   ::value := value
   ::onFocus := onfocus
   ::onBlur := onblur
   ::onChange := onchange
   ::onSelect := onselect
   ::onClick := onclick
   ::onMouseOver := onmsover
   ::onMouseOut := onmsout


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour Runtime Library file: src/rtl/libname.prg. Provides functions: hb_libName. This file provides utility functions

[Assistant]
FUNCTION hb_libName( cLibName, cLibDir )

   LOCAL cDir, cName, cExt

   IF HB_ISSTRING( cLibName )

      hb_FNameSplit( cLibName, @cDir, @cName, @cExt )

      IF Empty( cDir ) .AND. HB_ISSTRING( cLibDir )
         cDir := cLibDir
      ENDIF
      IF Empty( cExt )
         cExt := hb_libExt()
      ENDIF

      RETURN hb_FNameMerge( cDir, hb_libPrefix() + cName, cExt )
   ENDIF

   RETURN ""


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/xbox.prg. Contains procedures: Main. This file provides legacy compatibility functions

[Assistant]
#require "hbnf"

PROCEDURE Main()

   LOCAL i

   SetColor( "W/B" )
   CLS
   FOR i := 1 TO 24
      @ i, 0 SAY Replicate( "@", 80 )
   NEXT

   ft_XBox( , , , , , , , "This is a test", "of the XBOX() function" )
   ft_XBox( "L", "W", "D", "GR+/R", "W/B", 1, 10, "It is so nice", ;
      "to not have to do the messy chore", ;
      "of calculating the box size!" )
   ft_XBox( , "W", "D", "GR+/R", "W/B", 16, 10, "It is so nice", ;
      "to not have to do the messy chore", ;
      "of calculating the box size!", ;
      "Even though this line is way too long, and is in fact more than 80 characters long, if you care to check!" )

   RETURN


[System] You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following Harbour conventions. Use proper Hungarian notation for variable names (c=character, n=numeric, l=logical, a=array, o=object, b=codeblock).

[User] Implement these Harbour functions: Harbour contribution module 'rddmisc' (): contrib/rddmisc/rlcdx.prg. Provides functions: RLCDX_NEW, RLCDX_LOCK, RLCDX_UNLOCK, RLCDX_APPEND, RLCDX_GETFUNCTABLE. Contains procedures: RLCDX_INIT. This file handles database operations

[Assistant]
#include "hbusrrdd.ch"
#include "rddsys.ch"

ANNOUNCE RLCDX

STATIC FUNCTION RLCDX_NEW( pWA )

   LOCAL aWData := { 0, {} }

   USRRDD_AREADATA( pWA, aWData )

   RETURN HB_SUCCESS

STATIC FUNCTION RLCDX_LOCK( nWA, aLockInfo )

   LOCAL aWData, nResult, xRecId, i

   aWData := USRRDD_AREADATA( nWA )

   IF aLockInfo[ UR_LI_METHOD ] == DBLM_EXCLUSIVE
      aLockInfo[ UR_LI_METHOD ] := DBLM_MULTIPLE
      aLockInfo[ UR_LI_RECORD ] := RecNo()
   ENDIF

   IF aLockInfo[ UR_LI_METHOD ] == DBLM_MULTIPLE

      IF aWData[ 1 ] > 0
         aLockInfo[ UR_LI_RESULT ] := .T.
         RETURN HB_SUCCESS
      ENDIF

      xRecID := aLockInfo[ UR_LI_RECORD ]
      IF Empty( xRecID )
         xRecID := RecNo()
      ENDIF

      IF aWData[ 1 ] > 0
         aLockInfo[ UR_LI_RESULT ] := .T.
         RETURN HB_SUCCESS
      ELSEIF ( i := AScan( aWData[ 2 ], {| x | x[ 1 ] == xRecID } ) ) > 0
         ++aWData[ 2 ][ i ][ 2 ]
         aLockInfo[ UR_LI_RESULT ] := .T.
         RETURN HB_SUCCESS
      ENDIF

      IF ( nResult := UR_SUPER_LOCK( nWA, aLockInfo ) ) == HB_SUCCESS
         IF aLockInfo[ UR_LI_RESULT ]
            AAdd( aWData[ 2 ], { xRecID, 1 } )
         ENDIF
      ENDIF

      RETURN nResult

   ELSEIF aLockInfo[ UR_LI_METHOD ] == DBLM_FILE

      IF aWData[ 1 ] > 0
         ++aWData[ 1 ]
         RETURN HB_SUCCESS
      ENDIF

      IF ( nResult := UR_SUPER_LOCK( nWA, aLockInfo ) ) == HB_SUCCESS

         ASize( aWData[ 2 ], 0 )

         IF aLockInfo[ UR_LI_RESULT ]
            aWData[ 1 ] := 1
         ENDIF
      ENDIF

      RETURN nResult

   ENDIF

   aLockInfo[ UR_LI_RESULT ] := .F.

   RETURN HB_FAILURE

STATIC FUNCTION RLCDX_UNLOCK( nWA, xRecID )

   LOCAL aWData := USRRDD_AREADATA( nWA ), i

   IF HB_ISNUMERIC( xRecID ) .AND. xRecID > 0
      IF ( i := AScan( aWData[ 2 ], {| x | x[ 1 ] == xRecID } ) ) > 0
         IF --aWData[ 2 ][ i ][ 2 ] > 0
            RETURN HB_SUCCESS
         ENDIF
         hb_ADel( aWData[ 2 ], i, .T. )
      ELSE
         RETURN HB_SUCCESS
      ENDIF
   ELSE
      IF aWData[ 1 ] > 1
         --aWData[ 1 ]
         RETURN HB_SUCCESS
      ENDIF
      aWData[ 1 ] := 0
      ASize( aWData[ 2 ], 0 )
   ENDIF

   RETURN UR_SUPER_UNLOCK( nWA, xRecID )

STATIC FUNCTION RLCDX_APPEND( nWA, lUnlockAll )

   LOCAL aWData, nResult, xRecId, i

   lUnlockAll := .F.

   IF ( nResult := UR_SUPER_APPEND( nWA, lUnlockAll ) ) == HB_SUCCESS

      aWData := USRRDD_AREADATA( nWA )
      IF aWData[ 1 ] == 0
         xRecId := RecNo()

         IF ( i := AScan( aWData[ 2 ], {| x | x[ 1 ] == xRecID } ) ) > 0
            ++aWData[ 2 ][ i ][ 2 ]
         ELSE
            AAdd( aWData[ 2 ], { xRecID, 1 } )
         ENDIF
      ENDIF
   ENDIF

   RETURN nResult

REQUEST DBFCDX

FUNCTION RLCDX_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, pSuperRddID )

   LOCAL cSuperRDD := "DBFCDX"
   LOCAL aMethods[ UR_METHODCOUNT ]

   aMethods[ UR_NEW  ]   := @RLCDX_NEW()
   aMethods[ UR_LOCK ]   := @RLCDX_LOCK()
   aMethods[ UR_UNLOCK ] := @RLCDX_UNLOCK()
   aMethods[ UR_APPEND ] := @RLCDX_APPEND()

   RETURN USRRDD_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, ;
      cSuperRDD, aMethods, pSuperRddID )

INIT PROCEDURE RLCDX_INIT()

   rddRegister( "RLCDX", RDT_FULL )

   RETURN