[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 'hbodbc' (ODBC database connectivity): contrib/hbodbc/tests/odbccall.prg. Contains procedures: Main. This file handles database operations

[Assistant]
#require "hbodbc"

PROCEDURE Main()

   LOCAL dsFunctions := TODBC():New( "DBQ=" + hb_FNameMerge( hb_DirBase(), "test.mdb" ) + ";Driver={Microsoft Access Driver (*.mdb)}" )

   dsFunctions:SetSQL( "SELECT * FROM test" )
   dsFunctions:Open()
   ? dsFunctions:FieldByName( "First" ):Value
   ? dsFunctions:Skip()
   ? dsFunctions:FieldByName( "First" ):Value
   ? dsFunctions:GoTo( 1 )
   ? dsFunctions:FieldByName( "First" ):Value
   ? dsFunctions:Prior()
   ? dsFunctions:FieldByName( "First" ):Value
   ? dsFunctions:First()
   ? dsFunctions:FieldByName( "First" ):Value
   ? dsFunctions:Last()
   ? dsFunctions:FieldByName( "First" ):Value
   ? dsFunctions:Close()

   dsFunctions:Destroy()

   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] Define Harbour macros and constants: Harbour contribution module 'gtwvw' (): contrib/gtwvw/tests/_wvwmous.prg. Defines classes: WVWMouseButton. This file provides platform-specific functionality

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

STATIC s_amouseobjlist := {}
STATIC s_ncurkey := 0
STATIC s_nkeyrepeater := NIL
STATIC s_nrepeatrate  := 0.1
STATIC s_nrepeatdelay := 0.5

#define _DEFAULT_CAPTION_FONT   "Tahoma"
#define _DEFAULT_CAPTION_HEIGHT 16

#define _IDX_BLACK               0
#define _IDX_BLUE                1
#define _IDX_GREEN               2
#define _IDX_CYAN                3
#define _IDX_RED                 4
#define _IDX_MAGENTA             5
#define _IDX_BROWN               6
#define _IDX_WHITE               7
#define _IDX_LIGHT_GRAY          8
#define _IDX_BRIGHT_BLUE         9
#define _IDX_BRIGHT_GREEN       10
#define _IDX_BRIGHT_CYAN        11
#define _IDX_BRIGHT_RED         12
#define _IDX_BRIGHT_MAGENTA     13
#define _IDX_YELLOW             14
#define _IDX_BRIGHT_WHITE       15

#define _MOBJECT_BUTTON  0
#define _MOBJECT_HSCROLL 1
#define _MOBJECT_VSCROLL 2

#define _BUTTON_NORMAL 0
#define _BUTTON_FLAT   1
#define _BUTTON_NONE   2
#define _BUTTON_HARD   3

CREATE CLASS WVWMouseButton

   VAR nWinId
   VAR lVisible
   VAR lEnable
   VAR lTight
   VAR nType
   VAR nRow1, nCol1, nRow2, nCol2

   VAR bClickBlock
   VAR bPressBlock

   VAR lRepeatPress

   VAR cCaption
   VAR cCaptionFont
   VAR nCaptionHeight
   VAR cImage

   VAR cNormalColor
   VAR cPressedColor

   VAR lPressed
   VAR lHover

   METHOD New( cCaption, nRow1, nCol1, nRow2, nCol2, bClickBlock, nType, lDraw, nWinId )

   METHOD Enable( lEnable )

   METHOD SetClickBlock( bBlock )
   METHOD GetClickBlock() INLINE ::bClickBlock

   METHOD SetPressBlock( bBlock )
   METHOD GetPressBlock() INLINE ::bPressBlock

   METHOD SetRepeatPress( lRepeat )
   METHOD GetRepeatPress() INLINE ::lRepeatPress

   METHOD SetCaption( cCaption )

   METHOD OnClick()
   METHOD OnPress()
   METHOD OnRelease()
   METHOD OnReleaseOut()
   METHOD OnMouseOut()
   METHOD OnMouseOver()

   METHOD Draw( nWinNum )

ENDCLASS

METHOD New( cCaption, nRow1, nCol1, nRow2, nCol2, bClickBlock, nType, lDraw, nWinId ) CLASS WVWMouseButton

   hb_default( @cCaption, "" )
   hb_default( @nRow1, 0 )
   hb_default( @nCol1, 0 )
   hb_default( @nRow2, nRow1 )
   hb_default( @nCol2, nCol1 + Max( 10, Len( cCaption ) + 2 ) - 1 )
   hb_default( @nType, _BUTTON_NORMAL )
   hb_default( @lDraw, .T. )
   hb_default( @nWinId, wvw_nNumWindows() - 1 )

   ::nWinId := nWinId

   ::nRow1 := nRow1
   ::nCol1 := nCol1
   ::nRow2 := nRow2
   ::nCol2 := nCol2

   ::bClickBlock   := iif( HB_ISBLOCK( bClickBlock ), bClickBlock, NIL )
   ::bPressBlock   := NIL

   ::lRepeatPress  := .F.

   ::lPressed  := .F.
   ::lHover    := .F.
   ::cCaption := cCaption
   ::cCaptionFont := _DEFAULT_CAPTION_FONT
   ::nCaptionHeight := _DEFAULT_CAPTION_HEIGHT

   ::cImage    := NIL

   ::cNormalColor := "W"
   ::cPressedColor := "W"

   ::lVisible := .T.
   ::lEnable  := .T.
   ::lTight   := .F.
   ::nType := nType

   IF lDraw
      ::Draw( ::nWinId )
   ENDIF

   RETURN Self

METHOD Enable( lEnable ) CLASS WVWMouseButton

   ::lEnable := lEnable
   ::draw()

   RETURN Self

METHOD SetClickBlock( bBlock ) CLASS WVWMouseButton

   ::bClickBlock := bBlock

   RETURN Self

METHOD SetPressBlock( bBlock ) CLASS WVWMouseButton

   ::bPressBlock := bBlock

   RETURN Self

METHOD SetRepeatPress( lRepeat ) CLASS WVWMouseButton

   ::lRepeatPress := lRepeat

   RETURN Self

METHOD SetCaption( cCaption ) CLASS WVWMouseButton

   ::cCaption := cCaption

   RETURN Self

METHOD OnPress() CLASS WVWMouseButton

   LOCAL lWasPressed
   IF ! ::lEnable
      RETURN Self
   ENDIF

   lWasPressed := ::lPressed
   ::lPressed := .T.
   ::Draw()

   IF ::lRepeatPress
      IF ! lWasPressed
         xKeyRepeater( .T. )
      ENDIF
      wvwm_SetKeyRepeater( .T. )
   ENDIF

   IF HB_ISBLOCK( ::bPressBlock )
      Eval( ::bPressBlock )
   ENDIF

   RETURN Self

METHOD OnClick() CLASS WVWMouseButton

   IF ! ::lEnable
      RETURN Self
   ENDIF

   IF HB_ISBLOCK( ::bClickBlock )
      Eval( ::bClickBlock )
   ENDIF

   RETURN Self

METHOD OnRelease() CLASS WVWMouseButton

   LOCAL lWasPressed := ::lPressed

   IF ! ::lEnable
      RETURN Self
   ENDIF

   ::lPressed := .F.
   ::Draw()

   IF ::lRepeatPress
      wvwm_SetKeyRepeater( .F. )
   ENDIF

   IF lWasPressed
      ::OnClick()
   ENDIF

   RETURN Self

METHOD OnReleaseOut() CLASS WVWMouseButton

   IF ! ::lEnable
      RETURN Self
   ENDIF

   ::lPressed := .F.
   ::Draw()

   RETURN Self

METHOD OnMouseOut() CLASS WVWMouseButton

   IF ! ::lEnable
      RETURN Self
   ENDIF

   if ::lRepeatPress .AND. ::lPressed
      wvwm_SetKeyRepeater( .F. )
   ENDIF

   ::lHover := .F.
   ::Draw()

   RETURN Self

METHOD OnMouseOver() CLASS WVWMouseButton

   IF ! ::lEnable
      RETURN Self
   ENDIF

   if ::lRepeatPress .AND. ::lPressed
      wvwm_SetKeyRepeater( .T. )
   ENDIF

   ::lHover := .T.
   ::Draw()

   RETURN Self

METHOD DRAW( nWinNum ) CLASS WVWMouseButton

   LOCAL nOldCursor := SetCursor( SC_NONE )
   LOCAL lMouseOver := ::lHover
   LOCAL lPressed := ::lPressed .AND. lMouseOver
   LOCAL aFontInfo := iif( ::nCaptionHeight == NIL, wvw_GetFontInfo( nWinNum ), NIL )
   LOCAL nLabelColor := iif( ! lPressed, RGB( 0, 0, 0 ), RGB( 96, 96, 96 ) )
   LOCAL lUseImage := HB_ISSTRING( ::cImage )

   IF ! ::lVisible .OR. ::nType == _BUTTON_NONE
      SetCursor( nOldCursor )
      RETURN Self
   ENDIF

   if ::nrow1 > ::nrow2 .OR. ::ncol1 > ::ncol2
      SetCursor( nOldCursor )
      RETURN Self
   ENDIF

   hb_default( @nWinNum, ::nWinId )

   IF lPressed
      IF ::nType != _BUTTON_HARD
         wvw_FillRectangle(   nWinNum, ::nrow1, ::nCol1, ::nrow2, ::nCol2, wvw_GetRGBColor( hb_ColorToN( ::cPressedColor ) ), ::lTight )
         wvw_DrawBoxRecessed( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::lTight )
      ELSE
         wvw_FillRectangle(   nWinNum, ::nrow1, ::nCol1, ::nrow2, ::nCol2, wvw_GetRGBColor( hb_ColorToN( ::cNormalColor ) ), ::lTight )
         wvw_DrawBoxRaised(   nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::lTight )
      ENDIF

      IF lUseImage .AND. ::nType != _BUTTON_NONE
         IF ! wvw_DrawImage( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::cImage, ::lTight )
            win_MessageBox( NIL, "Button Failed wvw_DrawImage(" + ::cImage + ")" )
         ENDIF
      ENDIF

      IF ! Empty( ::cCaption )
         wvw_DrawLabel( nWinNum, ::nRow1, _nCeiling( ( ::nCol2 + ::nCol1 ) / 2 ), ::cCaption, 6, , nLabelColor, RGB( 198, 198, 198 ), ::cCaptionFont, iif( HB_ISARRAY( afontinfo ), afontinfo[ 2 ], ::nCaptionHeight ), 0, , , , .F., .F. )
      ENDIF
   ELSE
      IF lMouseOver .OR. ::nType == _BUTTON_NORMAL .OR. ::nType == _BUTTON_HARD
         wvw_FillRectangle(   nWinNum, ::nrow1, ::nCol1, ::nrow2, ::nCol2, wvw_GetRGBColor( hb_ColorToN( ::cNormalColor ) ), ::lTight )
         wvw_DrawBoxRaised( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::lTight )
      ELSE

         wvw_DrawBoxGroup( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2 )
      ENDIF

      IF lUseImage .AND. ::nType != _BUTTON_NONE
         IF ! wvw_DrawImage( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::cImage, ::lTight )
            win_MessageBox( NIL, "Button Failed wvw_DrawImage(" + ::cImage + ")" )
         ENDIF
      ENDIF

      IF ! ::lEnable
         nLabelColor := RGB( 96, 96, 96 )
      ELSEIF lMouseOver
         nLabelColor := RGB( 255, 0, 0 )
      ENDIF

      IF ! Empty( ::cCaption )


[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 test program: tests/memory.prg. Contains procedures: Main. This test file exercises basic Harbour language features

[Assistant]
#include "hbmemory.ch"

PROCEDURE Main()

   ? "HB_MEM_CHAR      ", Memory( HB_MEM_CHAR       )
   ? "HB_MEM_BLOCK     ", Memory( HB_MEM_BLOCK      )
   ? "HB_MEM_RUN       ", Memory( HB_MEM_RUN        )
   ? "HB_MEM_VM        ", Memory( HB_MEM_VM         )
   ? "HB_MEM_EMS       ", Memory( HB_MEM_EMS        )
   ? "HB_MEM_FM        ", Memory( HB_MEM_FM         )
   ? "HB_MEM_FMSEGS    ", Memory( HB_MEM_FMSEGS     )
   ? "HB_MEM_SWAP      ", Memory( HB_MEM_SWAP       )
   ? "HB_MEM_CONV      ", Memory( HB_MEM_CONV       )
   ? "HB_MEM_EMSUSED   ", Memory( HB_MEM_EMSUSED    )
   ? "HB_MEM_USED      ", Memory( HB_MEM_USED       )
   ? "HB_MEM_USEDMAX   ", Memory( HB_MEM_USEDMAX    )
   ? "HB_MEM_STACKITEMS", Memory( HB_MEM_STACKITEMS )
   ? "HB_MEM_STACK     ", Memory( HB_MEM_STACK      )

   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 Runtime Library file: src/rtl/tmenusys.prg. Defines classes: HBMenuSys. This file implements menu system classes

[Assistant]
#include "hbclass.ch"

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

#define IS_IN( str, list )  ( "|" + ( str ) + "|" $ "|" + ( list ) + "|" )

#ifdef HB_COMPAT_C53

#define SNLASTEXIT      6
#define SNNEXTGET       12

CREATE CLASS HBMenuSys

   EXPORTED:

   METHOD Modal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )
   METHOD Init( oMenu )

   PROTECTED:

   METHOD PushMenu()
   METHOD PopMenu()
   METHOD PopChild( nNewLevel )
   METHOD PopAll()
   METHOD Execute()
   METHOD MHitTest( oNewMenu, nNewLevel, nNewItem )
   METHOD ShowMsg( lMode )
   METHOD GetMsgArray()

   VAR oMenu
   VAR lOldMsgFlag
   VAR cOldMessage
   VAR aMenuList
   VAR nMenuLevel
   VAR nOldRow
   VAR nOldCol
   VAR nOldCursor
   VAR lMsgFlag
   VAR nMsgRow
   VAR nMsgLeft
   VAR nMsgRight
   VAR cMsgColor
   VAR cMsgSaveS

ENDCLASS

METHOD Modal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList ) CLASS HBMenuSys

   LOCAL oTopMenu := ::oMenu

   LOCAL nReturn := 0

   LOCAL nKey
   LOCAL nNewItem
   LOCAL lLeftDown
   LOCAL oNewMenu
   LOCAL nNewLevel
   LOCAL oMenuItem
   LOCAL nMenuItem
   LOCAL nTemp
   LOCAL bKeyBlock
   LOCAL lSubMenu

   ::nOldRow    := Row()
   ::nOldCol    := Col()
   ::nOldCursor := SetCursor( SC_NONE )

   ::nMsgRow    := nMsgRow
   ::nMsgLeft   := nMsgLeft
   ::nMsgRight  := nMsgRight
   ::cMsgColor  := cMsgColor

   IF ( ::lMsgFlag := HB_ISNUMERIC( ::nMsgRow ) .AND. ;
                      HB_ISNUMERIC( ::nMsgLeft ) .AND. ;
                      HB_ISNUMERIC( ::nMsgRight ) )

      IF ! HB_ISSTRING( ::cMsgColor )
         ::cMsgColor := GetClrPair( SetColor(), 1 )
      ENDIF

      Scroll( ::nMsgRow, ::nMsgLeft, ::nMsgRow, ::nMsgRight )

      ::cMsgSaveS := SaveScreen( ::nMsgRow, ::nMsgLeft, ::nMsgRow, ::nMsgRight )
   ENDIF

   oTopMenu:select( nSelection )

   IF oTopMenu:ClassName() == "TOPBARMENU" .OR. oTopMenu:isOpen
      oTopMenu:display()
   ELSE
      oTopMenu:open()
   ENDIF

   IF nSelection <= 0

      DO WHILE nSelection <= 0

         nKey := Inkey( 0, hb_bitOr( INKEY_KEYBOARD, INKEY_LDOWN ) )

         IF nKey == K_LBUTTONDOWN .OR. nKey == K_LDBLCLK
            nSelection := oTopMenu:hitTest( MRow(), MCol() )

         ELSEIF ( nSelection := oTopMenu:getAccel( nKey ) ) != 0

         ELSEIF IsShortcut( oTopMenu, nKey, @nReturn )
            RETURN nReturn
         ELSE
            nSelection := 1
         ENDIF
      ENDDO

      oTopMenu:select( nSelection )
      oTopMenu:display()
   ENDIF

   IF ! oTopMenu:getItem( nSelection ):enabled
      RETURN 0
   ENDIF

   ::aMenuList      := Array( 16 )
   ::nMenuLevel     := 1
   ::aMenuList[ 1 ] := ::oMenu

   lLeftDown := MLeftDown()

   ::ShowMsg( .T. )

   DO WHILE .T.

      nKey := Inkey( 0 )

      IF ( bKeyBlock := SetKey( nKey ) ) != NIL
         Eval( bKeyBlock, ProcName( 1 ), ProcLine( 1 ), "" )
         LOOP
      ENDIF

      DO CASE
      CASE nKey == K_MOUSEMOVE

         IF lLeftDown

            IF ! ::MHitTest( @oNewMenu, @nNewLevel, @nNewItem )

            ELSEIF nNewLevel != ::nMenuLevel

               IF nNewItem != oNewMenu:current .AND. oNewMenu:GetItem( nNewItem ):enabled
                  ::oMenu := oNewMenu
                  ::PopChild( nNewLevel )
                  ::oMenu:select( nNewItem )
                  ::oMenu:display()
                  ::PushMenu()
                  ::ShowMsg( .T. )
               ENDIF

            ELSEIF nNewItem != oNewMenu:Current()

               ::PopChild( ::nMenuLevel )

               IF ::oMenu:getItem( nNewItem ):enabled
                  ::oMenu:select( nNewItem )
                  ::oMenu:display()
                  ::PushMenu()
                  ::ShowMsg( .T. )
               ENDIF
            ENDIF
         ENDIF

      CASE nKey == K_DOWN

         IF ::oMenu:ClassName() == "TOPBARMENU"
            IF ::PushMenu()
               ::ShowMsg( .T. )
            ENDIF
         ELSE
            nTemp := ::oMenu:getNext()
            IF nTemp == 0
               nTemp := ::oMenu:getFirst()
            ENDIF
            ::oMenu:select( nTemp )
            ::oMenu:display()
            ::ShowMsg( .T. )
         ENDIF

      CASE nKey == K_UP

         IF ! ::oMenu:ClassName() == "TOPBARMENU"
            nTemp := ::oMenu:getPrev()
            IF nTemp == 0
               nTemp := ::oMenu:getLast()
            ENDIF
            ::oMenu:select( nTemp )
            ::oMenu:display()
            ::ShowMsg( .T. )
         ENDIF

      CASE nKey == K_LEFT

         IF ( lSubMenu := ( ::nMenuLevel > 1 ) )
            ::PopMenu()
         ENDIF

         IF ::oMenu:ClassName() == "TOPBARMENU"
            nTemp := ::oMenu:getPrev()
            IF nTemp == 0
               nTemp := ::oMenu:getLast()
            ENDIF
            ::oMenu:select( nTemp )
            ::oMenu:display()
            IF lSubMenu
               ::PushMenu()
            ENDIF
         ENDIF
         ::ShowMsg( .T. )

      CASE nKey == K_RIGHT

         IF ( lSubMenu := ( ::nMenuLevel > 1 ) )
            ::PopMenu()
         ENDIF

         IF ::oMenu:ClassName() == "TOPBARMENU"
            nTemp := ::oMenu:getNext()
            IF nTemp == 0
               nTemp := ::oMenu:getFirst()
            ENDIF
            ::oMenu:select( nTemp )
            ::oMenu:display()
            IF lSubMenu
               ::PushMenu()
            ENDIF
         ENDIF
         ::ShowMsg( .T. )

      CASE nKey == K_ENTER

         IF ::PushMenu()
            ::ShowMsg( .T. )
         ELSE
            ::ShowMsg( .F. )
            nReturn := ::execute()
            IF nReturn != 0
               EXIT
            ENDIF
         ENDIF

      CASE nKey == K_ESC

         IF ::PopMenu()
            ::oMenu:display()
            ::ShowMsg( .T. )
         ELSE
            IF IS_IN( ::oMenu:ClassName(), "POPUPMENU|HB_POPUPMENU" )
               ::oMenu:close()
            ENDIF

            nReturn := -1
            EXIT
         ENDIF

      CASE nKey == K_LBUTTONDOWN

         IF ! ::MHitTest( @oNewMenu, @nNewLevel, @nNewItem )

            IF GetList != NIL .AND. HitTest( GetList, MRow(), MCol(), ::GetMsgArray() ) != 0
               GetActive():ExitState := GE_MOUSEHIT
               ReadStats( SNLASTEXIT, GE_MOUSEHIT )
               IF IS_IN( ::oMenu:ClassName(), "POPUPMENU|HB_POPUPMENU" )
                  ::PopMenu()
               ENDIF
               nReturn := -1
               EXIT
            ENDIF

            IF IS_IN( ::oMenu:ClassName(), "POPUPMENU|HB_POPUPMENU" )
               ::PopMenu()
            ENDIF

         ELSEIF nNewLevel == ::nMenuLevel
            ::oMenu:select( nNewItem )
            ::oMenu:display()
            ::PushMenu()
            ::ShowMsg( .T. )

         ELSE
            ::nMenuLevel := nNewLevel
            ::oMenu      := ::aMenuList[ ::nMenuLevel ]

            nMenuItem := ::oMenu:current
            IF ( oMenuItem := ::oMenu:getItem( ::oMenu:Current ) ):isPopUp()
               oMenuItem:data:close()
            ENDIF

            IF nMenuItem != nNewItem
               ::oMenu:select( nNewItem )
               ::oMenu:display()
               ::PushMenu()
            ENDIF

            ::ShowMsg( .T. )
         ENDIF

         lLeftDown := .T.

      CASE nKey == K_LBUTTONUP

         lLeftDown := .F.

         IF ::MHitTest( @oNewMenu, @nNewLevel, @nNewItem ) .AND. ;
            nNewLevel == ::nMenuLevel

            IF nNewItem == ::oMenu:current
               ::ShowMsg( .F. )
               nReturn := ::execute()
               IF nReturn != 0
                  EXIT
               ENDIF
            ENDIF
         ENDIF

      CASE ( nNewItem := ::oMenu:getAccel( nKey ) ) != 0

         IF ::oMenu:getItem( nNewItem ):enabled
            ::oMenu:select( nNewItem )
            ::oMenu:display()

            IF ! ::PushMenu()
               ::ShowMsg( .F. )
               nReturn := ::execute()
               IF nReturn != 0
                  EXIT
               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:

Header file for contribution module 'hbxdiff' (File difference/patching): contrib/hbxdiff/hbxdiff.ch. Defines 10 constants including: HBXDIFF_CH_, XDLT_STD_BLKSIZE, XDL_PATCH_NORMAL, XDL_PATCH_REVERSE, XDL_PATCH_MODEMASK. Defines Harbour internal constants and macros

[Assistant]
#ifndef HBXDIFF_CH_
#define HBXDIFF_CH_

#define XDLT_STD_BLKSIZE        ( 1024
#define XDL_PATCH_NORMAL        Asc( "-" )
#define XDL_PATCH_REVERSE       Asc( "+" )
#define XDL_PATCH_MODEMASK      ( hb_bitShift( 1, 8 ) - 1 )
#define XDL_PATCH_IGNOREBSPACE  hb_bitShift( 1, 8 )

#define XDL_MMB_READONLY        hb_bitShift( 1, 0 )

#define XDL_MMF_ATOMIC          hb_bitShift( 1, 0 )

#define XDL_BDOP_INS            1
#define XDL_BDOP_CPY            2
#define XDL_BDOP_INSB           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] Implement this Harbour module: Harbour test program: tests/cdx.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#ifndef __HARBOUR__
#include "clipper.ch"
#endif

PROCEDURE Main()

   LOCAL aStruct := { ;
      { "CHARACTER", "C", 25, 0 }, ;
      { "NUMERIC",   "N",  8, 0 }, ;
      { "DOUBLE",    "N",  8, 2 }, ;
      { "DATE",      "D",  8, 0 }, ;
      { "MEMO",      "M", 10, 0 }, ;
      { "LOGICAL",   "L",  1, 0 } }

   CLS
   dbUseArea( .T., "DBFCDX", "test", "TESTDBF", .T., .F. )
   dbCreate( "testcdx", aStruct, "DBFCDX", .T., "TESTCDX" )

   ? "RddName:", rddName()
   ? "Press any key to continue..."
   Inkey( 0 )
   Select( "TESTDBF" )
   SET FILTER TO TESTDBF->SALARY > 140000
   TESTDBF->( dbGoTop() )
   WHILE ! TESTDBF->( Eof() )
      TESTCDX->( dbAppend() )
      TESTCDX->CHARACTER := TESTDBF->FIRST
      TESTCDX->NUMERIC := TESTDBF->SALARY
      TESTCDX->MEMO := TESTDBF->FIRST + hb_eol() + ;
                       TESTDBF->LAST + hb_eol() + ;
                       TESTDBF->STREET
      TESTDBF->( dbSkip() )
   ENDDO

   ? TESTCDX->( RecCount() )
   TESTCDX->( dbGoTop() )
   ? TESTCDX->( Eof() )
   WHILE ! TESTCDX->( Eof() )
      ? TESTCDX->( RecNo() ), TESTCDX->NUMERIC
      ? TESTCDX->MEMO
      TESTCDX->( dbSkip() )
      ? "Press any key to continue..."
      Inkey( 0 )
   ENDDO

   hb_dbDrop( "testcdx.cdx" )

   Select( "TESTCDX" )
   ordCreate( "testcdx", "Character", "FIELD->CHARACTER", {|| FIELD->CHARACTER }, .F. )

   dbCloseAll()
   hb_dbDrop( "testcdx",, "DBFCDX" )

   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 'hbfoxpro' (FoxPro file format support): contrib/hbfoxpro/dll.prg. Provides functions: fox___DynCall. This file handles data format parsing and generation

[Assistant]
#include "hbdyn.ch"

FUNCTION fox___DynCall( cCommand, ... )

   LOCAL aParam

   LOCAL cFunction
   LOCAL cLibrary
   LOCAL nFuncFlags := hb_bitOr( HB_DYN_CALLCONV_CDECL, HB_DYN_ENC_RAW )

   LOCAL aCommand := hb_ATokens( cCommand )
   LOCAL nPos := 1

   LOCAL aType := { ;
      "SHORT"   => HB_DYN_CTYPE_SHORT, ;
      "INTEGER" => HB_DYN_CTYPE_INT, ;
      "SINGLE"  => HB_DYN_CTYPE_FLOAT, ;
      "DOUBLE"  => HB_DYN_CTYPE_DOUBLE, ;
      "LONG"    => HB_DYN_CTYPE_LONG, ;
      "STRING"  => HB_DYN_CTYPE_CHAR_PTR, ;
      "OBJECT"  => HB_DYN_CTYPE_VOID_PTR }

   IF nPos <= Len( aCommand ) .AND. Upper( aCommand[ nPos ] ) == "DECLARE"
      ++nPos
   ENDIF

   IF nPos <= Len( aCommand ) .AND. Upper( aCommand[ nPos ] ) $ aType
      nFuncFlags := hb_bitOr( nFuncFlags, aType[ Upper( aCommand[ nPos ] ) ] )
      ++nPos
   ELSE
      RETURN NIL
   ENDIF

   IF nPos <= Len( aCommand )
      cFunction := aCommand[ nPos ]
      ++nPos
   ELSE
      RETURN NIL
   ENDIF

   IF nPos <= Len( aCommand ) .AND. Upper( aCommand[ nPos ] ) == "IN"
      ++nPos
   ELSE
      RETURN NIL
   ENDIF

   IF nPos <= Len( aCommand )
      cLibrary := aCommand[ nPos ]
      ++nPos
   ELSE
      RETURN NIL
   ENDIF

   IF nPos <= Len( aCommand ) .AND. Upper( aCommand[ nPos ] ) == "AS"
      nPos += 2
   ENDIF

   aParam := { cFunction, cLibrary, nFuncFlags }

   DO WHILE nPos <= Len( aCommand )
      IF Upper( Upper( aCommand[ nPos ] ) ) $ aType
         AAdd( aParam, hb_bitOr( HB_DYN_ENC_RAW, aType[ Upper( aCommand[ nPos ] ) ] ) )
         ++nPos
      ENDIF
      IF nPos <= Len( aCommand ) .AND. aCommand[ nPos ] == "@"
         ++nPos
      ENDIF

      IF nPos <= Len( aCommand )
         ++nPos
      ENDIF
      IF nPos <= Len( aCommand ) .AND. aCommand[ nPos ] == ","
         ++nPos
      ENDIF
   ENDDO

   RETURN hb_DynCall( aParam, ... )


[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/charswap.prg. Contains procedures: Main. This file provides legacy compatibility functions

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

PROCEDURE Main()

   ctinit()

   ? "Begin test of CharSwap()"
   ?

   ? "Simple tests:"
   ? '  CharSwap( "0123456789" )  == "1032547698"  ? --> "' + CharSwap( "0123456789" ) + '"'
   ? '  CharSwap( "ABCDEFGHIJK" ) == "BADCFEHGJIK" ? --> "' + CharSwap( "ABCDEFGHIJK" ) + '"'
   ?

   ? "End test of CharSwap()"
   ?

   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 a Harbour program with procedures: Main. Harbour test program: tests/dates2.prg. Contains procedures: Main. This test file exercises basic Harbour language features

[Assistant]
PROCEDURE Main()

   LOCAL dDate := hb_SToD( "19990430" )

   ? Set( _SET_DATEFORMAT ), dDate
   Set( _SET_DATEFORMAT, "yyy/mm/ddd" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "on" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "off" )
   ? Set( _SET_DATEFORMAT ), dDate
   Set( _SET_DATEFORMAT, "yyy/m/d/yyy" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "on" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "off" )
   ? Set( _SET_DATEFORMAT ), dDate
   Set( _SET_DATEFORMAT, "m/d/y/m/d" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "on" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "off" )
   ? Set( _SET_DATEFORMAT ), dDate
   Set( _SET_DATEFORMAT, "mmmm/ddddd" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "on" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "off" )
   ? Set( _SET_DATEFORMAT ), dDate
   Set( _SET_DATEFORMAT, "mmmmm/dd" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "on" )
   ? Set( _SET_DATEFORMAT ), dDate
   __SetCentury( "off" )
   ? Set( _SET_DATEFORMAT ), dDate

   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:

Header file for contribution module 'hbmysql' (MySQL database client library): contrib/hbmysql/mysql.ch. Defines 10 constants including: HBMYSQL_CH_, MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG. Defines Harbour internal constants and macros

[Assistant]
#ifndef HBMYSQL_CH_
#define HBMYSQL_CH_

#define MYSQL_TYPE_DECIMAL      0
#define MYSQL_TYPE_TINY         1
#define MYSQL_TYPE_SHORT        2
#define MYSQL_TYPE_LONG         3
#define MYSQL_TYPE_FLOAT        4
#define MYSQL_TYPE_DOUBLE       5
#define MYSQL_TYPE_NULL         6
#define MYSQL_TYPE_TIMESTAMP    7
#define MYSQL_TYPE_LONGLONG     8
#define MYSQL_TYPE_INT24        9
#define MYSQL_TYPE_DATE         10
#define MYSQL_TYPE_TIME         11
#define MYSQL_TYPE_DATETIME     12
#define MYSQL_TYPE_YEAR         13
#define MYSQL_TYPE_NEWDATE      14
#define MYSQL_TYPE_VARCHAR      15
#define MYSQL_TYPE_BIT          16
#define MYSQL_TYPE_NEWDECIMAL   246
#define MYSQL_TYPE_ENUM         247
#define MYSQL_TYPE_SET          248
#define MYSQL_TYPE_TINY_BLOB    249
#define MYSQL_TYPE_MEDIUM_BLOB  250
#define MYSQL_TYPE_LONG_BLOB    251
#define MYSQL_TYPE_BLOB         252
#define MYSQL_TYPE_VAR_STRING   253
#define MYSQL_TYPE_STRING       254
#define MYSQL_TYPE_GEOMETRY     255

#define MYSQL_FS_NAME           1
#define MYSQL_FS_TABLE          2
#define MYSQL_FS_DEF            3
#define MYSQL_FS_TYPE           4
#define MYSQL_FS_LENGTH         5
#define MYSQL_FS_MAXLEN         6
#define MYSQL_FS_FLAGS          7
#define MYSQL_FS_DECIMALS       8

#define NOT_NULL_FLAG           hb_bitShift( 1, 0 )
#define PRI_KEY_FLAG            hb_bitShift( 1, 1 )
#define UNIQUE_KEY_FLAG         hb_bitShift( 1, 2 )
#define MULTIPLE_KEY_FLAG       hb_bitShift( 1, 3 )
#define BLOB_FLAG               hb_bitShift( 1, 4 )
#define UNSIGNED_FLAG           hb_bitShift( 1, 5 )
#define ZEROFILL_FLAG           hb_bitShift( 1, 6 )
#define BINARY_FLAG             hb_bitShift( 1, 7 )

#define ENUM_FLAG               hb_bitShift( 1, 8 )
#define AUTO_INCREMENT_FLAG     hb_bitShift( 1, 9 )
#define TIMESTAMP_FLAG          hb_bitShift( 1, 10 )
#define PART_KEY_FLAG           hb_bitShift( 1, 14 )
#define GROUP_FLAG              hb_bitShift( 1, 15 )

#define DBS_NOTNULL             5

#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] Define Harbour macros and constants: Harbour contribution module 'rddmisc' (): contrib/rddmisc/logrdd.prg. Provides 19 functions including: LOGRDD_INIT, LOGRDD_EXIT, LOGRDD_CREATE, LOGRDD_CREATEFIELDS, LOGRDD_OPEN. Contains procedures: _LOGRDD_INIT, OpenLogFile, ToLog. This file handles database operations

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

#define ARRAY_FILENAME      1
#define ARRAY_FHANDLE       2
#define ARRAY_TAG           3
#define ARRAY_ACTIVE        4
#define ARRAY_RDDNAME       5
#define ARRAY_MSGLOGBLOCK   6
#define ARRAY_USERLOGBLOCK  7

ANNOUNCE LOGRDD

DYNAMIC hb_LogRddInherit

STATIC s_nRddID := -1

STATIC FUNCTION LOGRDD_INIT( nRDD )

   LOCAL cFileName := "changes.log"
   LOCAL lActive   := .F.
   LOCAL cTag      := NetName() + "\" + hb_UserName()
   LOCAL cRDDName  := hb_LogRddInherit()

   USRRDD_RDDDATA( nRDD, { cFileName, NIL, cTag, lActive, cRDDName, NIL, NIL } )

   RETURN HB_SUCCESS

STATIC FUNCTION LOGRDD_EXIT( nRDD )

   LOCAL aRDDData  := USRRDD_RDDDATA( nRDD )

   IF aRDDData[ ARRAY_FHANDLE ] != NIL
      FClose( aRDDData[ ARRAY_FHANDLE ] )
      aRDDData[ ARRAY_FHANDLE ] := NIL
   ENDIF

   RETURN HB_SUCCESS

STATIC FUNCTION LOGRDD_CREATE( nWA, aOpenInfo )

   LOCAL nResult

   IF ( nResult := UR_SUPER_CREATE( nWA, aOpenInfo ) ) == HB_SUCCESS
      ToLog( "CREATE", nWA, aOpenInfo )
   ENDIF

   RETURN nResult

STATIC FUNCTION LOGRDD_CREATEFIELDS( nWA, aStruct )

   LOCAL nResult

   IF ( nResult := UR_SUPER_CREATEFIELDS( nWA, aStruct ) ) == HB_SUCCESS
      ToLog( "CREATEFIELDS", nWA, aStruct )
   ENDIF

   RETURN nResult

STATIC FUNCTION LOGRDD_OPEN( nWA, aOpenInfo )

   LOCAL nResult

   IF ( nResult := UR_SUPER_OPEN( nWA, aOpenInfo ) ) == HB_SUCCESS
      ToLog( "OPEN", nWA, aOpenInfo )
   ENDIF

   RETURN nResult

STATIC FUNCTION LOGRDD_CLOSE( nWA )

   LOCAL cFile  := dbInfo( DBI_FULLPATH )
   LOCAL cAlias := Alias()
   LOCAL nResult

   IF ( nResult := UR_SUPER_CLOSE( nWA ) ) == HB_SUCCESS
      ToLog( "CLOSE", nWA, cFile, cAlias )
   ENDIF

   RETURN nResult

STATIC FUNCTION LOGRDD_APPEND( nWA, lUnlockAll )

   LOCAL nResult

   IF ( nResult := UR_SUPER_APPEND( nWA, lUnlockAll ) ) == HB_SUCCESS
      ToLog( "APPEND", nWA, lUnlockAll )
   ENDIF

   RETURN nResult

STATIC FUNCTION LOGRDD_DELETE( nWA )

   LOCAL nResult

   IF ( nResult := UR_SUPER_DELETE( nWA ) ) == HB_SUCCESS
      ToLog( "DELETE", nWA )
   ENDIF

   RETURN nResult

STATIC FUNCTION LOGRDD_RECALL( nWA )

   LOCAL nResult

   IF ( nResult := UR_SUPER_RECALL( nWA ) ) == HB_SUCCESS
      ToLog( "RECALL", nWA )
   ENDIF

   RETURN nResult

STATIC FUNCTION LOGRDD_PUTVALUE( nWA, nField, xValue )

   LOCAL xOldValue := FieldGet( nField )
   LOCAL nResult   := UR_SUPER_PUTVALUE( nWA, nField, xValue )

   IF ! xOldValue == xValue
      ToLog( "PUTVALUE", nWA, nField, xValue, xOldValue )
   ENDIF

   RETURN nResult

STATIC FUNCTION LOGRDD_ZAP( nWA )

   LOCAL nResult

   IF ( nResult := UR_SUPER_ZAP( nWA ) ) == HB_SUCCESS
      ToLog( "ZAP", nWA )
   ENDIF

   RETURN nResult

REQUEST DBFCDX

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

   LOCAL cSuperRDD := hb_LogRddInherit()
   LOCAL aMyFunc[ UR_METHODCOUNT ]

   s_nRddID := nRddID

   aMyFunc[ UR_INIT         ] := @LOGRDD_INIT()
   aMyFunc[ UR_EXIT         ] := @LOGRDD_EXIT()
   aMyFunc[ UR_CREATE       ] := @LOGRDD_CREATE()
   aMyFunc[ UR_CREATEFIELDS ] := @LOGRDD_CREATEFIELDS()
   aMyFunc[ UR_OPEN         ] := @LOGRDD_OPEN()
   aMyFunc[ UR_CLOSE        ] := @LOGRDD_CLOSE()
   aMyFunc[ UR_APPEND       ] := @LOGRDD_APPEND()
   aMyFunc[ UR_DELETE       ] := @LOGRDD_DELETE()
   aMyFunc[ UR_RECALL       ] := @LOGRDD_RECALL()
   aMyFunc[ UR_PUTVALUE     ] := @LOGRDD_PUTVALUE()
   aMyFunc[ UR_ZAP          ] := @LOGRDD_ZAP()

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

INIT PROCEDURE _LOGRDD_INIT()

   rddRegister( "LOGRDD", RDT_FULL )

   RETURN

FUNCTION hb_LogRddLogFileName( cFileName )

   LOCAL aRDDData
   LOCAL cOldFileName

   IF s_nRddID >= 0

      aRDDData := USRRDD_RDDDATA( s_nRddID )

      cOldFileName := aRDDData[ ARRAY_FILENAME ]

      IF HB_ISSTRING( cFileName )
         aRDDData[ ARRAY_FILENAME ] := cFileName
      ENDIF
   ENDIF

   RETURN cOldFileName

FUNCTION hb_LogRddTag( cTag )

   LOCAL aRDDData
   LOCAL cOldTag

   IF s_nRddID >= 0

      aRDDData := USRRDD_RDDDATA( s_nRddID )

      cOldTag := aRDDData[ ARRAY_TAG ]

      IF HB_ISSTRING( cTag )
         aRDDData[ ARRAY_TAG ] := cTag
      ENDIF
   ENDIF

   RETURN cOldTag

FUNCTION hb_LogRddActive( lActive )

   LOCAL aRDDData
   LOCAL lOldActive

   IF s_nRddID >= 0

      aRDDData := USRRDD_RDDDATA( s_nRddID )

      lOldActive := aRDDData[ ARRAY_ACTIVE ]

      IF HB_ISLOGICAL( lActive )
         aRDDData[ ARRAY_ACTIVE ] := lActive
      ENDIF
   ENDIF

   RETURN lOldActive

FUNCTION hb_LogRddMsgLogBlock( bMsgLogBlock )

   LOCAL aRDDData
   LOCAL bOldMsgLogBlock

   IF s_nRddID >= 0

      aRDDData := USRRDD_RDDDATA( s_nRddID )

      bOldMsgLogBlock := aRDDData[ ARRAY_MSGLOGBLOCK ]

      IF HB_ISEVALITEM( bMsgLogBlock )
         aRDDData[ ARRAY_MSGLOGBLOCK ] := bMsgLogBlock
      ENDIF
   ENDIF

   RETURN bOldMsgLogBlock

FUNCTION hb_LogRddUserLogBlock( bUserLogBlock )

   LOCAL aRDDData
   LOCAL bOldUserLogBlock

   IF s_nRddID >= 0

      aRDDData := USRRDD_RDDDATA( s_nRddID )

      bOldUserLogBlock := aRDDData[ ARRAY_MSGLOGBLOCK ]

      IF HB_ISEVALITEM( bUserLogBlock )
         aRDDData[ ARRAY_USERLOGBLOCK ] := bUserLogBlock
      ENDIF
   ENDIF

   RETURN bOldUserLogBlock

FUNCTION hb_LogRddValueToText( uValue )

   LOCAL cType
   LOCAL cText

   SWITCH cType := ValType( uValue )
   CASE "C"  ; cText := hb_StrToExp( uValue ) ; EXIT
   CASE "N"  ; cText := hb_ntos( uValue ) ; EXIT
   CASE "D"  ; cText := DToS( uValue ) ; cText := "0d" + iif( Empty( cText ), "00000000", cText ) ; EXIT
   OTHERWISE ; cText := hb_ValToStr( uValue )
   ENDSWITCH

   RETURN "[" + cType + "]>>>" + cText + "<<<"

STATIC PROCEDURE OpenLogFile( nWA )

   LOCAL aRDDData  := USRRDD_RDDDATA( USRRDD_ID( nWA ) )
   LOCAL cFileName := aRDDData[ ARRAY_FILENAME ]
   LOCAL hFile     := aRDDData[ ARRAY_FHANDLE ]
   LOCAL lActive   := aRDDData[ ARRAY_ACTIVE ]

   IF lActive .AND. hFile == NIL

      IF hb_FileExists( cFileName )
         hFile := FOpen( cFileName, FO_READWRITE + FO_SHARED )
      ELSE
         hFile := FCreate( cFileName )

         IF FError() == 0 .AND. hFile != F_ERROR
            FClose( hFile )
            hFile := FOpen( cFileName, FO_READWRITE + FO_SHARED )
         ENDIF
      ENDIF
      IF FError() == 0 .AND. hFile != F_ERROR

         FSeek( hFile, 0, FS_END )
      ELSE
         hFile := NIL
      ENDIF

      aRDDData[ ARRAY_FHANDLE  ] := hFile
   ENDIF

   RETURN

STATIC FUNCTION ToString( cCmd, nWA, xPar1, xPar2, xPar3 )

   SWITCH cCmd
   CASE "CREATE"

      RETURN xPar1[ UR_OI_NAME ]
   CASE "CREATEFIELDS"

      RETURN hb_ValToExp( xPar1 )
   CASE "OPEN"

      RETURN 'Table: "' + xPar1[ UR_OI_NAME ] + '", Alias: "' + Alias() + '", WorkArea: ' + hb_ntos( nWA )
   CASE "CLOSE"

      RETURN 'Table: "' + xPar1 + '", Alias: "' + xPar2 + '", WorkArea: ' + hb_ntos( nWA )
   CASE "APPEND"

      RETURN Alias() + "->RecNo() == " + hb_ntos( RecNo() )
   CASE "DELETE"

      RETURN Alias() + "->RecNo() == " + hb_ntos( RecNo() )
   CASE "RECALL"

      RETURN Alias() + "->RecNo() == " + hb_ntos( RecNo() )
   CASE "PUTVALUE"

      HB_SYMBOL_UNUSED( xPar3 )
      RETURN Alias() + "(" + hb_ntos( RecNo() ) + ")->" + PadR( FieldName( xPar1 ), 10 ) + " := " + hb_LogRddValueToText( xPar2 )
   CASE "ZAP"

      RETURN 'Alias: "' + Alias() + ' Table: "' + dbInfo( DBI_FULLPATH ) + '"'
   ENDSWITCH

   RETURN NIL

STATIC PROCEDURE ToLog( cCmd, nWA, xPar1, xPar2, xPar3 )

   LOCAL aRDDData := USRRDD_RDDDATA( USRRDD_ID( nWA ) )
   LOCAL lActive  := aRDDData[ ARRAY_ACTIVE ]
   LOCAL hFile, cTag, cRDDName, bMsgLogBlock, bUserLogBlock, cLog

   IF lActive

      cTag          := aRDDData[ ARRAY_TAG ]
      cRDDName      := aRDDData[ ARRAY_RDDNAME ]


[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: WvgComboBox. Harbour contribution module 'gtwvg' (): contrib/gtwvg/combobox.prg. Defines classes: WvgComboBox. 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 WvgComboBox INHERIT WvgWindow, WvgDataRef

   VAR    type                                  INIT WVGCOMBO_DROPDOWN
   VAR    drawMode                              INIT WVG_DRAW_NORMAL
   VAR    nCurSelected                          INIT 0

   VAR    aInfo                                 INIT    NIL

   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 sendCBMessage( nMsg, wParam, lParam ) INLINE wvg_SendCBMessage( ::pWnd, nMsg, wParam, lParam )
   METHOD listBoxFocus( lFocus )
   METHOD listBoxSize()
   METHOD sleSize()

   METHOD addItem( cItem )
   METHOD clear()                               INLINE ::sendCBMessage( CB_RESETCONTENT )
   METHOD delItem( nIndex )                     INLINE ::sendCBMessage( CB_DELETESTRING, nIndex - 1 )
   METHOD getItem( nIndex )                     INLINE ::sendCBMessage( CB_GETLBTEXT, nIndex - 1 )
   METHOD insItem( nIndex, cItem )              INLINE ::sendCBMessage( CB_INSERTSTRING, nIndex - 1, cItem )
   METHOD setItem( nIndex, cItem )              VIRTUAL
   METHOD setIcon( nItem, cIcon )

   VAR    oSLE
   VAR    oListBox
   ACCESS XbpSLE                                INLINE ::oSLE
   ACCESS XbpListBox                            INLINE ::oListBox

   VAR    sl_itemMarked
   VAR    sl_itemSelected
   VAR    sl_drawItem

   METHOD itemMarked( ... )                     SETGET
   METHOD itemSelected( ... )                   SETGET
   METHOD drawItem( ... )                       SETGET

ENDCLASS

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

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

   ::style       := WS_CHILD + WS_TABSTOP + WS_BORDER + WS_VSCROLL + CBS_NOINTEGRALHEIGHT + CBS_AUTOHSCROLL

   ::className   := "COMBOBOX"
   ::objType     := objTypeComboBox

   RETURN Self

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

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

   ::oParent:AddChild( Self )

   DO CASE
   CASE ::type == WVGCOMBO_DROPDOWNLIST
      ::style += CBS_DROPDOWNLIST
   CASE ::type == WVGCOMBO_SIMPLE
      ::style += CBS_SIMPLE
   OTHERWISE
      ::style += CBS_DROPDOWN
   ENDCASE

   ::createControl()

   IF ::visible
      ::show()
   ENDIF
   ::setPosAndSize()

   IF ! Empty( ::aInfo := ::sendCBMessage( CB_GETCOMBOBOXINFO ) )
      ::oSLE := WvgSLE():new()
      ::oSLE:oParent := Self
      ::oSLE:hWnd := ::aInfo[ 5 ]
      ::oSLE:pWnd := win_N2P( ::aInfo[ 5 ] )

      ::oListBox := WvgListBox():new()
      ::oListBox:oParent := Self
      ::oListBox:hWnd := ::aInfo[ 6 ]
      ::oListBox:pWnd := win_N2P( ::aInfo[ 6 ] )
   ENDIF

   RETURN Self

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

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

   RETURN Self

METHOD PROCEDURE WvgComboBox:destroy()

   ::wvgWindow:destroy()

   RETURN

METHOD WvgComboBox:handleEvent( nMessage, aNM )

   DO CASE

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

   CASE nMessage == HB_GTE_COMMAND
      DO CASE
      CASE aNM[ 1 ] == CBN_SELCHANGE
         ::nCurSelected := ::editBuffer := wvg_lbGetCurSel( ::hWnd ) + 1
         IF ::isParentCrt()
            ::oParent:setFocus()
         ENDIF
         ::itemMarked()
         IF ::isParentCrt()
            IF ::pointerFocus
               ::setFocus()
            ENDIF
         ENDIF

      CASE aNM[ 1 ] == CBN_DBLCLK
         ::editBuffer := ::nCurSelected
         IF ::isParentCrt()
            ::oParent:setFocus()
         ENDIF
         ::itemSelected()
         IF ::isParentCrt()
            IF ::pointerFocus
               ::setFocus()
            ENDIF
         ENDIF

      CASE aNM[ 1 ] == CBN_KILLFOCUS
         ::killInputFocus()

      CASE aNM[ 1 ] == CBN_SETFOCUS
         ::setInputFocus()

      ENDCASE

   CASE nMessage == HB_GTE_KEYTOITEM
      IF aNM[ 1 ] == K_ENTER
         IF ::isParentCrt()
            ::oParent:setFocus()
         ENDIF
         ::itemSelected()
         IF ::isParentCrt()
            IF ::pointerFocus
               ::setFocus()
            ENDIF
         ENDIF
      ENDIF

   CASE nMessage == HB_GTE_CTLCOLOR
      IF HB_ISNUMERIC( ::clr_FG )
         wvg_SetTextColor( aNM[ 1 ], ::clr_FG )
      ENDIF
      IF HB_ISNUMERIC( ::hBrushBG )
         wvg_SetBkMode( aNM[ 1 ], 1 )
         RETURN ::hBrushBG
      ELSE
         RETURN wvg_GetCurrentBrush( aNM[ 1 ] )
      ENDIF

   ENDCASE

   RETURN EVENT_UNHANDELLED

METHOD WvgComboBox:addItem( cItem )

   IF HB_ISSTRING( cItem )
      RETURN ::sendCBMessage( CB_ADDSTRING, cItem )
   ENDIF

   RETURN -1

METHOD WvgComboBox:listBoxFocus( lFocus )

   LOCAL lOldFocus := ::sendCBMessage( CB_GETDROPPEDSTATE )

   IF HB_ISLOGICAL( lFocus )
      ::sendCBMessage( CB_SHOWDROPDOWN, lFocus )
   ENDIF

   RETURN lOldFocus

METHOD WvgComboBox:sleSize()

   IF HB_ISOBJECT( ::oSLE )
      RETURN ::oSLE:currentSize()
   ENDIF

   RETURN { 0, 0 }

METHOD WvgComboBox:listBoxSize()

   IF HB_ISOBJECT( ::oListBox )
      RETURN ::oListBox:currentSize()
   ENDIF

   RETURN { 0, 0 }

METHOD WvgComboBox:setIcon( nItem, cIcon )

   HB_SYMBOL_UNUSED( nItem )
   HB_SYMBOL_UNUSED( cIcon )

   RETURN Self

METHOD WvgComboBox:itemMarked( ... )

   LOCAL a_ := hb_AParams()

   IF Len( a_ ) == 1 .AND. HB_ISBLOCK( a_[ 1 ] )
      ::sl_itemMarked := a_[ 1 ]
   ELSEIF Len( a_ ) >= 0 .AND. HB_ISBLOCK( ::sl_itemMarked )
      Eval( ::sl_itemMarked, , , Self )
   ENDIF

   RETURN Self

METHOD WvgComboBox:itemSelected( ... )

   LOCAL a_ := hb_AParams()

   IF Len( a_ ) == 1 .AND. HB_ISBLOCK( a_[ 1 ] )
      ::sl_itemSelected := a_[ 1 ]
   ELSEIF Len( a_ ) >= 0 .AND. HB_ISBLOCK( ::sl_itemSelected )
      Eval( ::sl_itemSelected, , , Self )
   ENDIF

   RETURN Self

METHOD WvgComboBox:drawItem( ... )

   LOCAL a_ := hb_AParams()

   IF Len( a_ ) == 1 .AND. HB_ISBLOCK( a_[ 1 ] )
      ::sl_xbePDrawItem := a_[ 1 ]
   ELSEIF Len( a_ ) >= 2 .AND. HB_ISBLOCK( ::sl_xbePDrawItem )
      Eval( ::sl_xbePDrawItem, a_[ 1 ], a_[ 2 ], Self )
   ENDIF

   RETURN Self


[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/output.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#ifndef __HARBOUR__
#include "clipper.ch"
#endif

PROCEDURE Main()

   OutStd( hb_eol(), "Testing Harbour device management on", Date() )
   SET ALTERNATE TO output_a ADDITIVE
   Set( _SET_EXTRAFILE, "output_e.ext", .F. )
   SET PRINTER TO output_p
   SET MARGIN TO 5
   QOut( "SCREEN, EXTRA, NOT ALTERNATE, NOT PRINTER" )
   @ 5, 5 SAY "SCREEN, NOT EXTRA, NOT ALTERNATE NOT PRINTER"
   SET ALTERNATE ON
   SET PRINTER ON
   QOut( "SCREEN, EXTRA, ALTERNATE AND PRINTER" )
   @ 10, 10 SAY "SCREEN, NOT EXTRA, NOT ALTERNATE, NOT PRINTER"
   SET DEVICE TO PRINTER
   Set( _SET_EXTRAFILE, "" )
   QOut( "SCREEN, ALTERNATE AND PRINTER AGAIN, BUT NOT EXTRA" )
   SET PRINTER OFF
   Set( _SET_EXTRAFILE, "output_e.ext", .T. )
   QOut( "SCREEN, EXTRA, AND ALTERNATE, BUT NOT PRINTER" )
   @ 15, 15 SAY "PRINTER, NOT SCREEN, NOT ALTERNATE"
   EJECT

   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] Generate Harbour code for: Harbour Runtime Library file: src/rtl/hbini.prg. Provides 7 functions including: hb_iniNew, hb_iniRead, hb_iniReadStr, hb_iniFileLow, hb_iniStringLow. Contains procedures: hb_iniSetComment. This file provides file I/O operations

[Assistant]
#include "fileio.ch"

STATIC s_cLineComment := ";"
STATIC s_cHalfLineComment := "#"

PROCEDURE hb_iniSetComment( cLc, cHlc )

   IF HB_ISSTRING( cLc )
      s_cLineComment := cLc
   ENDIF

   IF HB_ISSTRING( cHlc )
      s_cHalfLineComment := cHlc
   ENDIF

   RETURN

FUNCTION hb_iniNew( lAutoMain )

   LOCAL hIni := { => }

   IF hb_defaultValue( lAutoMain, .T. )
      hIni[ "MAIN" ] := { => }
   ENDIF

   RETURN hIni

FUNCTION hb_iniRead( cFileSpec, lKeyCaseSens, cSplitters, lAutoMain )
   RETURN hb_iniReadStr( iif( HB_ISSTRING( cFileSpec ), hb_iniFileLow( cFileSpec ), "" ), lKeyCaseSens, cSplitters, lAutoMain )

FUNCTION hb_iniReadStr( cData, lKeyCaseSens, cSplitters, lAutoMain )

   LOCAL hIni := { => }

   hb_default( @lKeyCaseSens, .T. )
   hb_default( @lAutoMain, .T. )

   hb_HCaseMatch( hIni, lKeyCaseSens )

   IF lAutoMain
      hIni[ "MAIN" ] := { => }
   ENDIF

   RETURN hb_iniStringLow( hIni, hb_defaultValue( cData, "" ), lKeyCaseSens, ;
                           hb_defaultValue( cSplitters, "=" ), lAutoMain )

STATIC FUNCTION hb_iniFileLow( cFileSpec )

   LOCAL cFile, nLen
   LOCAL hFile
   LOCAL cData
   LOCAL aFiles := hb_ATokens( cFileSpec, hb_osPathListSeparator() )

   IF Empty( aFiles )
      aFiles := { cFileSpec }
   ENDIF

   hFile := F_ERROR
   FOR EACH cFile IN aFiles
      IF ! Empty( cFile ) .AND. hb_FileExists( cFile )
         IF ( hFile := FOpen( cFile ) ) != F_ERROR
            EXIT
         ENDIF
      ENDIF
   NEXT

   IF hFile == F_ERROR
      RETURN ""
   ENDIF

   cData := Space( FSeek( hFile, 0, FS_END ) )
   FSeek( hFile, 0, FS_SET )
   nLen := FRead( hFile, @cData, hb_BLen( cData ) )
   cData := hb_BLeft( cData, nLen )
   FClose( hFile )

   RETURN cData

STATIC FUNCTION hb_iniStringLow( hIni, cData, lKeyCaseSens, cSplitters, lAutoMain )

   LOCAL aKeyVal, hCurrentSection
   LOCAL cLine
   LOCAL reComment, reInclude, reSection, reSplitters

   reComment := hb_regexComp( s_cHalfLineComment + "|^[ \t]*" + s_cLineComment )
   reInclude := hb_regexComp( "include (.*)" )
   reSection := hb_regexComp( "[[](.*)[]]" )
   reSplitters := hb_regexComp( cSplitters )

   hCurrentSection := iif( lAutoMain, hIni[ "MAIN" ], hIni )

   cLine := ""
   FOR EACH cData IN hb_ATokens( cData, .T. )
      cLine += AllTrim( cData )

      IF Right( cLine, 3 ) == " ||"
         cLine := hb_StrShrink( cLine, 2 )

         IF ! cData:__enumIsLast()
            LOOP
         ENDIF
      ENDIF

      IF Empty( cLine )
         LOOP
      ENDIF

      IF ! Empty( aKeyVal := hb_regexSplit( reComment, cLine ) )
         IF Empty( cLine := AllTrim( aKeyVal[ 1 ] ) )

            LOOP
         ENDIF
      ENDIF

      IF ! Empty( aKeyVal := hb_regex( reInclude, cLine ) )

         aKeyVal[ 2 ] := AllTrim( aKeyVal[ 2 ] )
         IF Len( aKeyVal[ 2 ] ) == 0
            LOOP
         ENDIF
         hb_iniStringLow( hIni, hb_iniFileLow( aKeyVal[ 2 ] ), lKeyCaseSens, cSplitters, lAutoMain )

      ELSEIF ! Empty( aKeyVal := hb_regex( reSection, cLine ) )
         cLine := AllTrim( aKeyVal[ 2 ] )
         IF Len( cLine ) != 0
            hCurrentSection := { => }
            IF ! lKeyCaseSens
               cLine := Upper( cLine )
            ENDIF
            hIni[ cLine ] := hCurrentSection
         ENDIF

      ELSEIF Len( aKeyVal := hb_regexSplit( reSplitters, cLine,,, 1 ) ) == 1

      ELSE

         IF ! lKeyCaseSens
            aKeyVal[ 1 ] := Upper( aKeyVal[ 1 ] )
         ENDIF
         hCurrentSection[ AllTrim( aKeyVal[ 1 ] ) ] := AllTrim( aKeyVal[ 2 ] )
      ENDIF

      cLine := ""
   NEXT

   RETURN hIni

FUNCTION hb_iniWrite( xFileName, hIni, cCommentBegin, cCommentEnd, lAutoMain )

   LOCAL hFile
   LOCAL lClose
   LOCAL cBuffer

   cBuffer := hb_iniWriteStr( hIni, cCommentBegin, cCommentEnd, lAutoMain )

   IF ! HB_ISSTRING( cBuffer )
      RETURN .F.
   ENDIF

   IF HB_ISSTRING( xFileName )
      hFile := FCreate( xFileName )
      lClose := .T.
   ELSEIF HB_ISNUMERIC( xFileName )
      hFile := xFileName
      lClose := .F.
   ELSE
      RETURN .F.
   ENDIF

   IF hFile == F_ERROR
      RETURN .F.
   ENDIF

   IF FWrite( hFile, cBuffer ) != hb_BLen( cBuffer )
      IF lClose
         FClose( hFile )
      ENDIF
      RETURN .F.
   ENDIF

   IF lClose
      FClose( hFile )
   ENDIF

   RETURN .T.

FUNCTION hb_iniWriteStr( hIni, cCommentBegin, cCommentEnd, lAutoMain )

   LOCAL cNewLine := hb_eol()
   LOCAL cSection
   LOCAL cBuffer := ""

   IF ! HB_ISHASH( hIni )
      RETURN NIL
   ENDIF

   IF HB_ISSTRING( cCommentBegin ) .AND. ! Empty( cCommentBegin )
      cBuffer += cCommentBegin + cNewLine
   ENDIF

   hb_default( @lAutoMain, .T. )

   IF lAutoMain .AND. !( "MAIN" $ hIni )
      lAutoMain := .F.
   ENDIF

   IF lAutoMain

      hb_HEval( hIni[ "MAIN" ], {| cKey, xVal | ;
         cBuffer += hb_CStr( cKey ) + "=" + hb_CStr( xVal ) + cNewLine } )
   ELSE

      hb_HEval( hIni, {| cKey, xVal | iif( HB_ISHASH( xVal ), , ;
         cBuffer += hb_CStr( cKey ) + "=" + hb_CStr( xVal ) + cNewLine ) } )
   ENDIF

   FOR EACH cSection IN hIni

      IF lAutoMain

         IF cSection:__enumKey == "MAIN"
            LOOP
         ENDIF
      ELSE

         IF ! HB_ISHASH( cSection )
            LOOP
         ENDIF
      ENDIF

      cBuffer += cNewLine + "[" + hb_CStr( cSection:__enumKey ) + "]" + cNewLine

      hb_HEval( cSection, ;
         {| cKey, xVal | cBuffer += hb_CStr( cKey ) + "=" + ;
         hb_CStr( xVal ) + cNewLine } )
   NEXT

   IF HB_ISSTRING( cCommentEnd ) .AND. ! Empty( cCommentEnd )
      cBuffer += cCommentEnd + cNewLine
   ENDIF

   RETURN iif( Empty( cBuffer ), NIL, cBuffer )


[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] Define Harbour macros and constants: Harbour header file: include/hbsocket.ch. Defines 10 constants including: HB_SOCKET_CH_, HB_SOCKET_ERR_NONE, HB_SOCKET_ERR_PIPE, HB_SOCKET_ERR_TIMEOUT, HB_SOCKET_ERR_WRONGADDR. Defines Harbour internal constants and macros

[Assistant]
#ifndef HB_SOCKET_CH_
#define HB_SOCKET_CH_

#define HB_SOCKET_ERR_NONE                0
#define HB_SOCKET_ERR_PIPE                1
#define HB_SOCKET_ERR_TIMEOUT             2
#define HB_SOCKET_ERR_WRONGADDR           3
#define HB_SOCKET_ERR_AFNOSUPPORT         4
#define HB_SOCKET_ERR_PFNOSUPPORT         5
#define HB_SOCKET_ERR_PROTONOSUPPORT      6
#define HB_SOCKET_ERR_PARAMVALUE          7
#define HB_SOCKET_ERR_NOSUPPORT           8
#define HB_SOCKET_ERR_NORESOURCE          9
#define HB_SOCKET_ERR_ACCESS              10
#define HB_SOCKET_ERR_ADDRINUSE           11
#define HB_SOCKET_ERR_INTERRUPT           12
#define HB_SOCKET_ERR_ALREADYCONNECTED    13
#define HB_SOCKET_ERR_CONNREFUSED         14
#define HB_SOCKET_ERR_CONNABORTED         15
#define HB_SOCKET_ERR_CONNRESET           16
#define HB_SOCKET_ERR_NETUNREACH          17
#define HB_SOCKET_ERR_NETDOWN             18
#define HB_SOCKET_ERR_NETRESET            19
#define HB_SOCKET_ERR_INPROGRESS          20
#define HB_SOCKET_ERR_ALREADY             21
#define HB_SOCKET_ERR_ADDRNOTAVAIL        22
#define HB_SOCKET_ERR_READONLY            23
#define HB_SOCKET_ERR_AGAIN               24
#define HB_SOCKET_ERR_INVALIDHANDLE       25
#define HB_SOCKET_ERR_INVAL               26
#define HB_SOCKET_ERR_PROTO               27
#define HB_SOCKET_ERR_PROTOTYPE           28
#define HB_SOCKET_ERR_NOFILE              29
#define HB_SOCKET_ERR_NOBUFS              30
#define HB_SOCKET_ERR_NOMEM               31
#define HB_SOCKET_ERR_FAULT               32
#define HB_SOCKET_ERR_NAMETOOLONG         33
#define HB_SOCKET_ERR_NOENT               34
#define HB_SOCKET_ERR_NOTDIR              35
#define HB_SOCKET_ERR_LOOP                36
#define HB_SOCKET_ERR_MSGSIZE             37
#define HB_SOCKET_ERR_DESTADDRREQ         38
#define HB_SOCKET_ERR_NOPROTOOPT          39
#define HB_SOCKET_ERR_NOTCONN             40
#define HB_SOCKET_ERR_SHUTDOWN            41
#define HB_SOCKET_ERR_TOOMANYREFS         42
#define HB_SOCKET_ERR_RESTARTSYS          43
#define HB_SOCKET_ERR_NOSR                44
#define HB_SOCKET_ERR_HOSTDOWN            45
#define HB_SOCKET_ERR_HOSTUNREACH         46
#define HB_SOCKET_ERR_NOTEMPTY            47
#define HB_SOCKET_ERR_USERS               48
#define HB_SOCKET_ERR_DQUOT               49
#define HB_SOCKET_ERR_STALE               50
#define HB_SOCKET_ERR_REMOTE              51
#define HB_SOCKET_ERR_PROCLIM             52
#define HB_SOCKET_ERR_DISCON              53
#define HB_SOCKET_ERR_NOMORE              54
#define HB_SOCKET_ERR_CANCELLED           55
#define HB_SOCKET_ERR_INVALIDPROCTABLE    56
#define HB_SOCKET_ERR_INVALIDPROVIDER     57
#define HB_SOCKET_ERR_PROVIDERFAILEDINIT  58
#define HB_SOCKET_ERR_REFUSED             59
#define HB_SOCKET_ERR_SYSNOTREADY         60
#define HB_SOCKET_ERR_VERNOTSUPPORTED     61
#define HB_SOCKET_ERR_NOTINITIALISED      62
#define HB_SOCKET_ERR_TRYAGAIN            63
#define HB_SOCKET_ERR_HOSTNOTFOUND        64
#define HB_SOCKET_ERR_NORECOVERY          65
#define HB_SOCKET_ERR_NODATA              66
#define HB_SOCKET_ERR_SYSCALLFAILURE      67
#define HB_SOCKET_ERR_SERVICENOTFOUND     68
#define HB_SOCKET_ERR_TYPENOTFOUND        69
#define HB_SOCKET_ERR_OTHER               70

#define HB_SOCKET_AF_LOCAL                1
#define HB_SOCKET_AF_INET                 2
#define HB_SOCKET_AF_IPX                  4
#define HB_SOCKET_AF_INET6                10
#define HB_SOCKET_AF_PACKET               17

#define HB_SOCKET_PF_LOCAL                HB_SOCKET_AF_LOCAL
#define HB_SOCKET_PF_INET                 HB_SOCKET_AF_INET
#define HB_SOCKET_PF_IPX                  HB_SOCKET_AF_IPX
#define HB_SOCKET_PF_INET6                HB_SOCKET_AF_INET6
#define HB_SOCKET_PF_PACKET               HB_SOCKET_AF_PACKET

#define HB_SOCKET_PT_STREAM               1
#define HB_SOCKET_PT_DGRAM                2
#define HB_SOCKET_PT_RAW                  3
#define HB_SOCKET_PT_RDM                  4
#define HB_SOCKET_PT_SEQPACKET            5

#define HB_SOCKET_IPPROTO_IP              0
#define HB_SOCKET_IPPROTO_ICMP            1
#define HB_SOCKET_IPPROTO_IGMP            2
#define HB_SOCKET_IPPROTO_IPIP            4
#define HB_SOCKET_IPPROTO_TCP             6
#define HB_SOCKET_IPPROTO_EGP             8
#define HB_SOCKET_IPPROTO_PUP             12
#define HB_SOCKET_IPPROTO_UDP             17
#define HB_SOCKET_IPPROTO_IDP             22
#define HB_SOCKET_IPPROTO_DCCP            23
#define HB_SOCKET_IPPROTO_RDP             29
#define HB_SOCKET_IPPROTO_TP              29
#define HB_SOCKET_IPPROTO_IPV6            41
#define HB_SOCKET_IPPROTO_ROUTING         43
#define HB_SOCKET_IPPROTO_FRAGMENT        44
#define HB_SOCKET_IPPROTO_RSVP            46
#define HB_SOCKET_IPPROTO_GRE             47
#define HB_SOCKET_IPPROTO_ESP             50
#define HB_SOCKET_IPPROTO_AH              51
#define HB_SOCKET_IPPROTO_ICMPV6          58
#define HB_SOCKET_IPPROTO_NONE            59
#define HB_SOCKET_IPPROTO_DSTOPTS         60
#define HB_SOCKET_IPPROTO_ND              77
#define HB_SOCKET_IPPROTO_ICLFXBM         78
#define HB_SOCKET_IPPROTO_EON             80
#define HB_SOCKET_IPPROTO_MTP             92
#define HB_SOCKET_IPPROTO_ENCAP           98
#define HB_SOCKET_IPPROTO_PIM             103
#define HB_SOCKET_IPPROTO_COMP            108
#define HB_SOCKET_IPPROTO_PGM             113
#define HB_SOCKET_IPPROTO_L2TP            115
#define HB_SOCKET_IPPROTO_SCTP            132
#define HB_SOCKET_IPPROTO_RAW             255

#define HB_SOCKET_MSG_OOB                 0x01
#define HB_SOCKET_MSG_PEEK                0x02
#define HB_SOCKET_MSG_DONTROUTE           0x04
#define HB_SOCKET_MSG_WAITALL             0x08

#define HB_SOCKET_SHUT_RD                 0
#define HB_SOCKET_SHUT_WR                 1
#define HB_SOCKET_SHUT_RDWR               2

#define HB_SOCKET_IFF_UP                  0x0001
#define HB_SOCKET_IFF_BROADCAST           0x0002
#define HB_SOCKET_IFF_LOOPBACK            0x0004
#define HB_SOCKET_IFF_POINTOPOINT         0x0008
#define HB_SOCKET_IFF_MULTICAST           0x0010

#define HB_SOCKET_IFINFO_FAMILY           1
#define HB_SOCKET_IFINFO_NAME             2
#define HB_SOCKET_IFINFO_FLAGS            3
#define HB_SOCKET_IFINFO_ADDR             4
#define HB_SOCKET_IFINFO_NETMASK          5
#define HB_SOCKET_IFINFO_BROADCAST        6
#define HB_SOCKET_IFINFO_P2PADDR          7
#define HB_SOCKET_IFINFO_HWADDR           8
#define HB_SOCKET_IFINFO_LEN              8

#define HB_SOCKET_ADINFO_FAMILY           1
#define HB_SOCKET_ADINFO_ADDRESS          2
#define HB_SOCKET_ADINFO_PATH             2
#define HB_SOCKET_ADINFO_PORT             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] Implement this Harbour module: Header file for contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/ctvideo.ch. Defines 8 constants including: _CTVIDEO_CH, VCARD_MONOCHROME, VCARD_CGA, VCARD_HERCULES, VCARD_MCGA

[Assistant]
#ifndef _CTVIDEO_CH
#define _CTVIDEO_CH

#define VCARD_MONOCHROME    1
#define VCARD_CGA           2
#define VCARD_HERCULES      5
#define VCARD_MCGA          10
#define VCARD_PGA           19
#define VCARD_EGA           55
#define VCARD_VGA           127

#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] Write a Harbour program with procedures: Main. Harbour test program: tests/aliasrt.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
PROCEDURE Main()

   USE test

   REPLACE Age WITH 1
   ? FIELD->Age

   REPLACE 1->Age WITH 2
   ? FIELD->Age

   REPLACE TEST->Age WITH 4
   ? FIELD->Age

   TEST->Age := 5
   ? FIELD->Age

   TEST->( FieldPut( FieldPos( "AGE" ), 6 ) )
   ? FIELD->Age

   dbCloseArea()

   SELECT 2

   USE test

   ? ( "B" )->FIRST
   ? ( "2" )->FIRST
   ? 2->FIRST
   ? B->FIRST

   Inkey( 0 )

   ? Select()
   ? Select( 1 )
   ? Select( 2 )

   ? "0", Select( "0" )
   ? "1", Select( "1" )
   ? "2", Select( "2" )
   ? "A", Select( "A" )
   ? "B", Select( "B" )
   ? "C", Select( "C" )
   ? "D", Select( "D" )
   ? "E", Select( "E" )
   ? "F", Select( "F" )
   ? "G", Select( "G" )
   ? "H", Select( "H" )
   ? "I", Select( "I" )
   ? "J", Select( "J" )
   ? "K", Select( "K" )
   ? "L", Select( "L" )
   ? "M", Select( "M" )
   ? "N", Select( "N" )
   ? "O", Select( "O" )
   ? "P", Select( "P" )
   ? "Q", Select( "Q" )
   ? "R", Select( "R" )
   ? "S", Select( "S" )
   ? "T", Select( "T" )
   ? "U", Select( "U" )
   ? "V", Select( "V" )
   ? "W", Select( "W" )
   ? "X", Select( "X" )
   ? "Y", Select( "Y" )
   ? "Z", Select( "Z" )

   Inkey( 0 )

   ? ""  , dbSelectArea()     , Select()
   ? ""  , dbSelectArea( NIL ), Select()

   ? "0" , dbSelectArea( "0" ), Select()
   ? "1" , dbSelectArea( "1" ), Select()
   ? "2" , dbSelectArea( "2" ), Select()
   ? "A" , dbSelectArea( "A" ), Select()
   ? "B" , dbSelectArea( "B" ), Select()
   ? "C" , dbSelectArea( "C" ), Select()
   ? "D" , dbSelectArea( "D" ), Select()
   ? "E" , dbSelectArea( "E" ), Select()
   ? "F" , dbSelectArea( "F" ), Select()
   ? "G" , dbSelectArea( "G" ), Select()
   ? "H" , dbSelectArea( "H" ), Select()
   ? "I" , dbSelectArea( "I" ), Select()
   ? "J" , dbSelectArea( "J" ), Select()
   ? "K" , dbSelectArea( "K" ), Select()

   ? "M" , dbSelectArea( "M" ), Select()

   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] Create Harbour preprocessor definitions: Header file for contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/ctscan.ch. Defines 10 constants including: KS_DISABLE, KS_A, KS_B, KS_C, KS_D. Defines Harbour internal constants and macros

[Assistant]
#define KS_DISABLE          hb_BChar( 255 ) + hb_BChar( 255 )

#define KS_A                hb_BChar( 65 )  + hb_BChar( 16 )
#define KS_B                hb_BChar( 66 )  + hb_BChar( 48 )
#define KS_C                hb_BChar( 67 )  + hb_BChar( 46 )
#define KS_D                hb_BChar( 68 )  + hb_BChar( 32 )
#define KS_E                hb_BChar( 69 )  + hb_BChar( 18 )
#define KS_F                hb_BChar( 70 )  + hb_BChar( 33 )
#define KS_G                hb_BChar( 71 )  + hb_BChar( 34 )
#define KS_H                hb_BChar( 72 )  + hb_BChar( 35 )
#define KS_I                hb_BChar( 73 )  + hb_BChar( 23 )
#define KS_J                hb_BChar( 74 )  + hb_BChar( 36 )
#define KS_K                hb_BChar( 75 )  + hb_BChar( 37 )
#define KS_L                hb_BChar( 76 )  + hb_BChar( 38 )
#define KS_M                hb_BChar( 77 )  + hb_BChar( 39 )
#define KS_N                hb_BChar( 78 )  + hb_BChar( 49 )
#define KS_O                hb_BChar( 79 )  + hb_BChar( 24 )
#define KS_P                hb_BChar( 80 )  + hb_BChar( 25 )
#define KS_Q                hb_BChar( 81 )  + hb_BChar( 30 )
#define KS_R                hb_BChar( 82 )  + hb_BChar( 19 )
#define KS_S                hb_BChar( 83 )  + hb_BChar( 31 )
#define KS_T                hb_BChar( 84 )  + hb_BChar( 20 )
#define KS_U                hb_BChar( 85 )  + hb_BChar( 22 )
#define KS_V                hb_BChar( 86 )  + hb_BChar( 47 )
#define KS_W                hb_BChar( 87 )  + hb_BChar( 44 )
#define KS_X                hb_BChar( 88 )  + hb_BChar( 45 )
#define KS_Y                hb_BChar( 89 )  + hb_BChar( 21 )
#define KS_Z                hb_BChar( 90 )  + hb_BChar( 17 )

#define KS_a                hb_BChar( 97 )  + hb_BChar( 16 )
#define KS_b                hb_BChar( 98 )  + hb_BChar( 48 )
#define KS_c                hb_BChar( 99 )  + hb_BChar( 46 )
#define KS_d                hb_BChar( 100 ) + hb_BChar( 32 )
#define KS_e                hb_BChar( 101 ) + hb_BChar( 18 )
#define KS_f                hb_BChar( 102 ) + hb_BChar( 33 )
#define KS_g                hb_BChar( 103 ) + hb_BChar( 34 )
#define KS_h                hb_BChar( 104 ) + hb_BChar( 35 )
#define KS_i                hb_BChar( 105 ) + hb_BChar( 23 )
#define KS_j                hb_BChar( 106 ) + hb_BChar( 36 )
#define KS_k                hb_BChar( 107 ) + hb_BChar( 37 )
#define KS_l                hb_BChar( 108 ) + hb_BChar( 38 )
#define KS_m                hb_BChar( 109 ) + hb_BChar( 39 )
#define KS_n                hb_BChar( 110 ) + hb_BChar( 49 )
#define KS_o                hb_BChar( 111 ) + hb_BChar( 24 )
#define KS_p                hb_BChar( 112 ) + hb_BChar( 25 )
#define KS_q                hb_BChar( 113 ) + hb_BChar( 30 )
#define KS_r                hb_BChar( 114 ) + hb_BChar( 19 )
#define KS_s                hb_BChar( 115 ) + hb_BChar( 31 )
#define KS_t                hb_BChar( 116 ) + hb_BChar( 20 )
#define KS_u                hb_BChar( 117 ) + hb_BChar( 22 )
#define KS_v                hb_BChar( 118 ) + hb_BChar( 47 )
#define KS_w                hb_BChar( 119 ) + hb_BChar( 44 )
#define KS_x                hb_BChar( 120 ) + hb_BChar( 45 )
#define KS_y                hb_BChar( 121 ) + hb_BChar( 21 )
#define KS_z                hb_BChar( 122 ) + hb_BChar( 17 )

#define KS_1                hb_BChar( 49 )  + hb_BChar( 2 )
#define KS_2                hb_BChar( 50 )  + hb_BChar( 3 )
#define KS_3                hb_BChar( 51 )  + hb_BChar( 4 )
#define KS_4                hb_BChar( 52 )  + hb_BChar( 5 )
#define KS_5                hb_BChar( 53 )  + hb_BChar( 6 )
#define KS_6                hb_BChar( 54 )  + hb_BChar( 7 )
#define KS_7                hb_BChar( 55 )  + hb_BChar( 8 )
#define KS_8                hb_BChar( 56 )  + hb_BChar( 9 )
#define KS_9                hb_BChar( 57 )  + hb_BChar( 10 )
#define KS_0                hb_BChar( 48 )  + hb_BChar( 11 )

#define KS_DOT              hb_BChar( 46 )  + hb_BChar( 52 )
#define KS_COMMA            hb_BChar( 44 )  + hb_BChar( 51 )

#define KS_CTRL_A           hb_BChar( 1 )   + hb_BChar( 30 )
#define KS_CTRL_B           hb_BChar( 2 )   + hb_BChar( 48 )
#define KS_CTRL_C           hb_BChar( 3 )   + hb_BChar( 46 )
#define KS_CTRL_D           hb_BChar( 4 )   + hb_BChar( 32 )
#define KS_CTRL_E           hb_BChar( 5 )   + hb_BChar( 18 )
#define KS_CTRL_F           hb_BChar( 6 )   + hb_BChar( 33 )
#define KS_CTRL_G           hb_BChar( 7 )   + hb_BChar( 34 )
#define KS_CTRL_H           hb_BChar( 8 )   + hb_BChar( 35 )
#define KS_CTRL_I           hb_BChar( 9 )   + hb_BChar( 23 )
#define KS_CTRL_M           hb_BChar( 13 )  + hb_BChar( 50 )
#define KS_CTRL_N           hb_BChar( 14 )  + hb_BChar( 49 )
#define KS_CTRL_R           hb_BChar( 18 )  + hb_BChar( 19 )
#define KS_CTRL_S           hb_BChar( 19 )  + hb_BChar( 31 )
#define KS_CTRL_T           hb_BChar( 20 )  + hb_BChar( 20 )
#define KS_CTRL_U           hb_BChar( 21 )  + hb_BChar( 22 )
#define KS_CTRL_V           hb_BChar( 22 )  + hb_BChar( 47 )
#define KS_CTRL_W           hb_BChar( 23 )  + hb_BChar( 17 )
#define KS_CTRL_X           hb_BChar( 24 )  + hb_BChar( 45 )
#define KS_CTRL_Y           hb_BChar( 25 )  + hb_BChar( 21 )
#define KS_CTRL_Z           hb_BChar( 26 )  + hb_BChar( 44 )

#define KS_ALT_A            hb_BChar( 0 )   + hb_BChar( 30 )
#define KS_ALT_B            hb_BChar( 0 )   + hb_BChar( 48 )
#define KS_ALT_C            hb_BChar( 0 )   + hb_BChar( 46 )
#define KS_ALT_D            hb_BChar( 0 )   + hb_BChar( 32 )
#define KS_ALT_E            hb_BChar( 0 )   + hb_BChar( 18 )
#define KS_ALT_F            hb_BChar( 0 )   + hb_BChar( 33 )
#define KS_ALT_G            hb_BChar( 0 )   + hb_BChar( 34 )
#define KS_ALT_H            hb_BChar( 0 )   + hb_BChar( 35 )
#define KS_ALT_I            hb_BChar( 0 )   + hb_BChar( 23 )
#define KS_ALT_J            hb_BChar( 0 )   + hb_BChar( 36 )
#define KS_ALT_K            hb_BChar( 0 )   + hb_BChar( 37 )
#define KS_ALT_L            hb_BChar( 0 )   + hb_BChar( 38 )
#define KS_ALT_M            hb_BChar( 0 )   + hb_BChar( 50 )
#define KS_ALT_N            hb_BChar( 0 )   + hb_BChar( 49 )
#define KS_ALT_O            hb_BChar( 0 )   + hb_BChar( 24 )
#define KS_ALT_P            hb_BChar( 0 )   + hb_BChar( 25 )
#define KS_ALT_Q            hb_BChar( 0 )   + hb_BChar( 16 )
#define KS_ALT_R            hb_BChar( 0 )   + hb_BChar( 19 )
#define KS_ALT_S            hb_BChar( 0 )   + hb_BChar( 31 )
#define KS_ALT_T            hb_BChar( 0 )   + hb_BChar( 20 )
#define KS_ALT_U            hb_BChar( 0 )   + hb_BChar( 22 )
#define KS_ALT_V            hb_BChar( 0 )   + hb_BChar( 47 )
#define KS_ALT_W            hb_BChar( 0 )   + hb_BChar( 17 )
#define KS_ALT_X            hb_BChar( 0 )   + hb_BChar( 45 )
#define KS_ALT_Y            hb_BChar( 0 )   + hb_BChar( 21 )
#define KS_ALT_Z            hb_BChar( 0 )   + hb_BChar( 44 )

#define KS_ALT_1            hb_BChar( 0 )   + hb_BChar( 120 )
#define KS_ALT_2            hb_BChar( 0 )   + hb_BChar( 121 )
#define KS_ALT_3            hb_BChar( 0 )   + hb_BChar( 122 )
#define KS_ALT_4            hb_BChar( 0 )   + hb_BChar( 123 )
#define KS_ALT_5            hb_BChar( 0 )   + hb_BChar( 124 )
#define KS_ALT_6            hb_BChar( 0 )   + hb_BChar( 125 )
#define KS_ALT_7            hb_BChar( 0 )   + hb_BChar( 126 )
#define KS_ALT_8            hb_BChar( 0 )   + hb_BChar( 127 )
#define KS_ALT_9            hb_BChar( 0 )   + hb_BChar( 128 )
#define KS_ALT_0            hb_BChar( 0 )   + hb_BChar( 129 )

#define KS_F1               hb_BChar( 0 )   + hb_BChar( 59 )
#define KS_F2               hb_BChar( 0 )   + hb_BChar( 60 )
#define KS_F3               hb_BChar( 0 )   + hb_BChar( 61 )
#define KS_F4               hb_BChar( 0 )   + hb_BChar( 62 )
#define KS_F5               hb_BChar( 0 )   + hb_BChar( 63 )
#define KS_F6               hb_BChar( 0 )   + hb_BChar( 64 )
#define KS_F7               hb_BChar( 0 )   + hb_BChar( 65 )
#define KS_F8               hb_BChar( 0 )   + hb_BChar( 66 )
#define KS_F9               hb_BChar( 0 )   + hb_BChar( 67 )


[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/color.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#include "color.ch"

PROCEDURE Main()

   LOCAL cColor := "r+/bg*,rg*/ng+,w/n,b+/w,rg/b,w+/n*"

   ? "original set ", Set( _SET_COLOR )
   ? "should match ", SetColor( cColor )
   ? "input 1      ", cColor
   ? "return       ", SetColor( "1/7,9/15" )
   ? "input 2      ", "1/7,9/15"
   ? "return       ", SetColor()
   ? "final set    ", Set( _SET_COLOR )

   SetColor( "BG/N, N/BG" )
   ? "Hello1"
   ColorSelect( CLR_ENHANCED )
   ? "Hello2"
   ColorSelect( CLR_STANDARD )
   ? "Hello3"
   ColorSelect( CLR_ENHANCED )
   SetColor( "GR/N, N/GR" )
   ? "Hello4"
   ColorSelect( CLR_ENHANCED )
   ? "Hello5"
   ColorSelect( CLR_STANDARD )
   ? "Hello6"
   SetColor( "B/N, N/B" )
   ? "Hello7"

   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] Create Harbour preprocessor definitions: Header file for contribution module 'hbodbc' (ODBC database connectivity): contrib/hbodbc/sql.ch. Defines 10 constants including: HBODBC_CH_, SQL_INVALID_HANDLE, SQL_ERROR, SQL_SUCCESS, SQL_SUCCESS_WITH_INFO. Defines keyboard input constants

[Assistant]
#ifndef HBODBC_CH_
#define HBODBC_CH_

#define SQL_INVALID_HANDLE              -2
#define SQL_ERROR                       -1
#define SQL_SUCCESS                     0
#define SQL_SUCCESS_WITH_INFO           1
#define SQL_STILL_EXECUTING             2
#define SQL_NO_DATA                     100
#define SQL_NO_DATA_FOUND               SQL_NO_DATA
#define SQL_NEED_DATA                   99

#define SQL_SUCCEEDED( rc )             ( hb_bitAnd( rc, hb_bitNot( SQL_SUCCESS_WITH_INFO ) ) == SQL_SUCCESS )

#define SQL_CHAR                        1
#define SQL_NUMERIC                     2
#define SQL_DECIMAL                     3
#define SQL_INTEGER                     4
#define SQL_SMALLINT                    5
#define SQL_FLOAT                       6
#define SQL_REAL                        7
#define SQL_DOUBLE                      8
#define SQL_DATE                        9
#define SQL_TIME                        10
#define SQL_TIMESTAMP                   11
#define SQL_VARCHAR                     12
#define SQL_TYPE_DATE                   91
#define SQL_TYPE_TIME                   92
#define SQL_TYPE_TIMESTAMP              93
#define SQL_LONGVARCHAR                 -1
#define SQL_BINARY                      -2
#define SQL_VARBINARY                   -3
#define SQL_LONGVARBINARY               -4
#define SQL_BIGINT                      -5
#define SQL_TINYINT                     -6
#define SQL_BIT                         -7
#define SQL_WCHAR                       -8
#define SQL_WVARCHAR                    -9
#define SQL_NVARCHAR                    SQL_WVARCHAR
#define SQL_WLONGVARCHAR                -10

#define SQL_TYPE_NULL                   0
#define SQL_TYPE_MIN                    SQL_WLONGVARCHAR
#define SQL_TYPE_MAX                    SQL_TYPE_TIMESTAMP
#define SQL_ALL_TYPES                   0

#define SQL_NO_NULLS                    0
#define SQL_NULLABLE                    1
#define SQL_NULLABLE_UNKNOWN            2

#define SQL_NULL_DATA                   -1
#define SQL_DATA_AT_EXEC                -2
#define SQL_NTS                         -3

#define SQL_CLOSE                       0
#define SQL_DROP                        1
#define SQL_UNBIND                      2
#define SQL_RESET_PARAMS                3

#define SQL_COLUMN_COUNT                0
#define SQL_COLUMN_NAME                 1
#define SQL_COLUMN_TYPE                 2
#define SQL_COLUMN_LENGTH               3
#define SQL_COLUMN_PRECISION            4
#define SQL_COLUMN_SCALE                5
#define SQL_COLUMN_DISPLAY_SIZE         6
#define SQL_COLUMN_NULLABLE             7
#define SQL_COLUMN_UNSIGNED             8
#define SQL_COLUMN_MONEY                9
#define SQL_COLUMN_UPDATABLE            10
#define SQL_COLUMN_AUTO_INCREMENT       11
#define SQL_COLUMN_CASE_SENSITIVE       12
#define SQL_COLUMN_SEARCHABLE           13
#define SQL_COLUMN_TYPE_NAME            14
#define SQL_COLUMN_TABLE_NAME           15
#define SQL_COLUMN_OWNER_NAME           16
#define SQL_COLUMN_QUALIFIER_NAME       17
#define SQL_COLUMN_LABEL                18
#define SQL_COLATT_OPT_MAX              SQL_COLUMN_LABEL
#define SQL_COLUMN_DRIVER_START         1000

#define SQL_COLATT_OPT_MIN              SQL_COLUMN_COUNT

#define SQL_ATTR_READONLY               0
#define SQL_ATTR_WRITE                  1
#define SQL_ATTR_READWRITE_UNKNOWN      2

#define SQL_UNSEARCHABLE                0
#define SQL_LIKE_ONLY                   1
#define SQL_ALL_EXCEPT_LIKE             2
#define SQL_SEARCHABLE                  3

#define SQL_FETCH_NEXT                  1
#define SQL_FETCH_FIRST                 2
#define SQL_FETCH_LAST                  3
#define SQL_FETCH_PRIOR                 4
#define SQL_FETCH_ABSOLUTE              5
#define SQL_FETCH_RELATIVE              6
#define SQL_FETCH_BOOKMARK              8

#define SQL_AUTOCOMMIT_OFF              0
#define SQL_AUTOCOMMIT_ON               1
#define SQL_AUTOCOMMIT                  102

#define SQL_INFO_FIRST                  0
#define SQL_ACTIVE_CONNECTIONS          0
#define SQL_ACTIVE_STATEMENTS           1
#define SQL_DATA_SOURCE_NAME            2
#define SQL_DRIVER_HDBC                 3
#define SQL_DRIVER_HENV                 4
#define SQL_DRIVER_HSTMT                5
#define SQL_DRIVER_NAME                 6
#define SQL_DRIVER_VER                  7
#define SQL_FETCH_DIRECTION             8
#define SQL_ODBC_API_CONFORMANCE        9
#define SQL_ODBC_VER                    10
#define SQL_ROW_UPDATES                 11
#define SQL_ODBC_SAG_CLI_CONFORMANCE    12
#define SQL_SERVER_NAME                 13
#define SQL_SEARCH_PATTERN_ESCAPE       14
#define SQL_ODBC_SQL_CONFORMANCE        15

#define SQL_DATABASE_NAME               16
#define SQL_DBMS_NAME                   17
#define SQL_DBMS_VER                    18

#define SQL_ACCESSIBLE_TABLES           19
#define SQL_ACCESSIBLE_PROCEDURES       20
#define SQL_PROCEDURES                  21
#define SQL_CONCAT_NULL_BEHAVIOR        22
#define SQL_CURSOR_COMMIT_BEHAVIOR      23
#define SQL_CURSOR_ROLLBACK_BEHAVIOR    24
#define SQL_DATA_SOURCE_READ_ONLY       25
#define SQL_DEFAULT_TXN_ISOLATION       26
#define SQL_EXPRESSIONS_IN_ORDERBY      27
#define SQL_IDENTIFIER_CASE             28
#define SQL_IDENTIFIER_QUOTE_CHAR       29
#define SQL_MAX_COLUMN_NAME_LEN         30
#define SQL_MAX_CURSOR_NAME_LEN         31
#define SQL_MAX_OWNER_NAME_LEN          32
#define SQL_MAX_PROCEDURE_NAME_LEN      33
#define SQL_MAX_QUALIFIER_NAME_LEN      34
#define SQL_MAX_TABLE_NAME_LEN          35
#define SQL_MULT_RESULT_SETS            36
#define SQL_MULTIPLE_ACTIVE_TXN         37
#define SQL_OUTER_JOINS                 38
#define SQL_OWNER_TERM                  39
#define SQL_PROCEDURE_TERM              40
#define SQL_QUALIFIER_NAME_SEPARATOR    41
#define SQL_QUALIFIER_TERM              42
#define SQL_SCROLL_CONCURRENCY          43
#define SQL_SCROLL_OPTIONS              44
#define SQL_TABLE_TERM                  45
#define SQL_TXN_CAPABLE                 46
#define SQL_USER_NAME                   47

#define SQL_CONVERT_FUNCTIONS           48
#define SQL_NUMERIC_FUNCTIONS           49
#define SQL_STRING_FUNCTIONS            50
#define SQL_SYSTEM_FUNCTIONS            51
#define SQL_TIMEDATE_FUNCTIONS          52

#define SQL_CONVERT_BIGINT              53
#define SQL_CONVERT_BINARY              54
#define SQL_CONVERT_BIT                 55
#define SQL_CONVERT_CHAR                56
#define SQL_CONVERT_DATE                57
#define SQL_CONVERT_DECIMAL             58
#define SQL_CONVERT_DOUBLE              59
#define SQL_CONVERT_FLOAT               60
#define SQL_CONVERT_INTEGER             61
#define SQL_CONVERT_LONGVARCHAR         62
#define SQL_CONVERT_NUMERIC             63
#define SQL_CONVERT_REAL                64
#define SQL_CONVERT_SMALLINT            65
#define SQL_CONVERT_TIME                66
#define SQL_CONVERT_TIMESTAMP           67
#define SQL_CONVERT_TINYINT             68
#define SQL_CONVERT_VARBINARY           69
#define SQL_CONVERT_VARCHAR             70
#define SQL_CONVERT_LONGVARBINARY       71

#define SQL_TXN_ISOLATION_OPTION        72
#define SQL_ODBC_SQL_OPT_IEF            73

#define SQL_QUERY_TIMEOUT               0
#define SQL_MAX_ROWS                    1
#define SQL_NOSCAN                      2
#define SQL_MAX_LENGTH                  3
#define SQL_ASYNC_ENABLE                4
#define SQL_BIND_TYPE                   5

#define SQL_HANDLE_ENV                  1
#define SQL_HANDLE_DBC                  2
#define SQL_HANDLE_STMT                 3
#define SQL_HANDLE_DESC                 4

#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] Generate Harbour code for: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/oletst1.prg. Contains procedures: Main. This file provides platform-specific functionality

[Assistant]
#require "hbwin"

#define NETSERVER  "127.0.0.1"
#define NETPORT    2941
#define NETPASSWD  "topsecret"

PROCEDURE Main()

   LOCAL oObject

   oObject := win_oleCreateObject( "MyOleRPCServer" )

   IF ! Empty( oObject )
      IF oObject:connect( NETSERVER, NETPORT,, NETPASSWD )
         ? "Connected to the server:", NETSERVER

         ? oObject:Upper( "hello world !!!" )
         ? "SERVER DATE:",     oObject:Date()
         ? "SERVER TIME:",     oObject:Time()
         ? "SERVER DATETIME:", oObject:hb_DateTime()
      ELSE
         ? "Cannot connect to the server:", NETSERVER
      ENDIF
   ELSE
      ? "Can not access 'MyOleRPCServer' OLE server."
   ENDIF

   WAIT

   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 'gtwvw' (): contrib/gtwvw/tests/prog1.prg. Provides 10 functions including: xBrowse1, DbSkipBlock, TBNext, TBPrev, VouBlockField. Contains procedures: Main, xGet1. This file provides platform-specific functionality

[Assistant]
#require "gtwvw"

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

STATIC s_zwin := {}
STATIC s_cStdColor := "N/W,N/GR*,,,N/W*"

PROCEDURE Main()

   LOCAL i, j
   LOCAL lMainCoord

#if defined( __HBSCRIPT__HBSHELL ) .AND. defined( __PLATFORM__WINDOWS )
   hbshell_gtSelect( "GTWVW" )
#endif

   lMainCoord := wvw_SetMainCoord( .T. )

   wvw_SetCodepage( , 255 )

   SET SCOREBOARD OFF
   SetColor( s_cStdColor )
   SetCursor( SC_NONE )
   CLS
   @ 0, 0 SAY PadC( "This is the Main Window", MaxCol() + 1 )

   DispBegin()
   FOR i := 1 TO MaxRow() - 1
      FOR j := 0 TO MaxCol()
         hb_DispOutAtBox( i, j, hb_UTF8ToStrBox( "▒" ) )
      NEXT
   NEXT
   DispEnd()

   lboxmessage( "Welcome to our test program." + hb_eol() + ;
      "This program will show typical GET and BROWSE dialogs " + ;
      "with brief help on the bottom of the screen." )
   xGet1()
   xBrowse1()
   lboxmessage( "That's all folks" )

   SetCursor( SC_NORMAL )

   RETURN

PROCEDURE xGet1()

   LOCAL cName := PadR( "Name", 20 )
   LOCAL cAddr := PadR( "Address", 25 )
   LOCAL cPhone := PadR( "Phone", 15 )
   LOCAL cFax  := PadR( "Fax", 15 )
   LOCAL lDone := .F.
   LOCAL getlist := {}
   LOCAL oldCurs := SetCursor( SC_NORMAL )

   znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), 10, 20, 22, 59, "Some Window" )

   DO WHILE ! lDone
      @ 12, 22 SAY "Name    : " GET cName  PICT "@!K" WHEN lMessage( "Please enter your name" )
      @ 14, 22 SAY "Address : " GET cAddr  PICT "@!K" WHEN lMessage( "Please enter your address" )
      @ 16, 22 SAY "Phone   : " GET cPhone PICT "@K"  WHEN lMessage( "Please enter your phone number" )
      @ 18, 22 SAY "Fax     : " GET cFax   PICT "@K"  WHEN lMessage( "Please enter your fax number" )
      READ

      lMessage( "" )
      lDone := lyesno( "Done?" )
   ENDDO

   zrevwindow()

   SetCursor( oldCurs )

   RETURN

FUNCTION xBrowse1()

   LOCAL nKey, bBlock, oBrowse, i
   LOCAL lEnd    := .F.
   LOCAL info_
   LOCAL nTop    :=  6
   LOCAL nLeft   :=  3
   LOCAL nBottom := MaxRow() - 2
   LOCAL nRight  := MaxCol() - 3
   LOCAL nCursor := SetCursor( SC_NONE )

   USE "..\..\..\tests\test" NEW
   IF NetErr()
      RETURN NIL
   ENDIF
   info_ := dbStruct()

   SetColor( "N/W*,N/GR*,,,N/W* " )
   oBrowse := TBrowseNew( nTop + 1, nLeft + 1, nBottom - 1, nRight - 1 )

   oBrowse:ColSep        := hb_UTF8ToStrBox( "│" )
   oBrowse:HeadSep       := hb_UTF8ToStrBox( "═" )
   oBrowse:GoTopBlock    := {|| dbGoTop() }
   oBrowse:GoBottomBlock := {|| dbGoBottom() }
   oBrowse:SkipBlock     := {| nSkip | dbSkipBlock( nSkip, oBrowse ) }

   FOR i := 1 TO Len( info_ )
      bBlock := VouBlockField( i )
      oBrowse:AddColumn( TBColumnNew( info_[ i, 1 ], bBlock ) )
   NEXT

   oBrowse:configure()

   znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), nTop, nLeft, nBottom, nRight, "test.dbf" )

   WHILE ! lEnd
      oBrowse:ForceStable()

      lMessage( "Record #" + hb_ntos( RecNo() ) )

      nKey := Inkey( 0 )

      DO CASE
      CASE nKey == K_ESC .OR. nKey == K_ENTER
         lEnd := lYesNo( "Done?" )
      CASE nKey == K_DOWN
         oBrowse:Down()
      CASE nKey == K_UP
         oBrowse:Up()
      CASE nKey == K_LEFT
         oBrowse:Left()
      CASE nKey == K_RIGHT
         oBrowse:Right()
      CASE nKey == K_PGDN
         oBrowse:pageDown()
      CASE nKey == K_PGUP
         oBrowse:pageUp()
      CASE nKey == K_CTRL_PGUP
         oBrowse:goTop()
      CASE nKey == K_CTRL_PGDN
         oBrowse:goBottom()
      CASE nKey == K_HOME
         oBrowse:home()
      CASE nKey == K_END
         oBrowse:end()
      CASE nKey == K_CTRL_LEFT
         oBrowse:panLeft()
      CASE nKey == K_CTRL_RIGHT
         oBrowse:panRight()
      CASE nKey == K_CTRL_HOME
         oBrowse:panHome()
      CASE nKey == K_CTRL_END
         oBrowse:panEnd()
      ENDCASE
   ENDDO

   lMessage( "" )

   zrevwindow()

   SetCursor( nCursor )

   dbCloseArea()

   RETURN NIL

STATIC FUNCTION DbSkipBlock( n, oTbr )

   LOCAL nSkipped := 0

   HB_SYMBOL_UNUSED( oTbr )

   IF n == 0
      dbSkip( 0 )
   ELSEIF n > 0
      DO WHILE nSkipped != n .AND. TBNext( oTbr )
         nSkipped++
      ENDDO
   ELSE
      DO WHILE nSkipped != n .AND. TBPrev( oTbr )
         nSkipped--
      ENDDO
   ENDIF

   RETURN  nSkipped

STATIC FUNCTION TBNext( oTbr )

   LOCAL nSaveRecNum := RecNo()
   LOCAL lMoved := .T.

   HB_SYMBOL_UNUSED( oTbr )

   IF Eof()
      lMoved := .F.
   ELSE
      dbSkip( 1 )
      IF Eof()
         lMoved := .F.
         dbGoto( nSaveRecNum )
      ENDIF
   ENDIF

   RETURN lMoved

STATIC FUNCTION TBPrev( oTbr )

   LOCAL nSaveRecNum := RecNo()
   LOCAL lMoved := .T.

   HB_SYMBOL_UNUSED( oTbr )

   dbSkip( -1 )
   IF Bof()
      dbGoto( nSaveRecNum )
      lMoved := .F.
   ENDIF

   RETURN lMoved

STATIC FUNCTION VouBlockField( i )

   RETURN  {|| FieldGet( i ) }

FUNCTION lMessage( cMsg )

   LOCAL cOldColor := SetColor( s_cStdColor )
   @ MaxRow(), 0 SAY PadC( cMsg, MaxCol() + 1 )
   SetColor( cOldColor )

   RETURN .T.

FUNCTION lYesNo( cMsg )

   LOCAL nTopLine, ;
      nLeft := 5, ;
      nBotLine := MaxRow() - 2, ;
      nRight := MaxCol() - 5
   LOCAL nChoice, nWidth
   LOCAL oldCurs := SetCursor( SC_NONE )
   LOCAL oldColor := SetColor( s_cStdColor )

   hb_default( @cMsg, "Please Confirm" )

   cmsg := " " + AllTrim( cmsg ) + " "
   nWidth := Max( Len( cmsg ), Len( "Yes" ) )
   nTopLine := nBotLine - 2 - 1

   nLeft := Max( nLeft, ( ( nRight + nLeft )
   znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cMsg )

   @ nTopLine + 1, nLeft + 1 PROMPT PadR( "Yes", nWidth )
   @ nTopLine + 2, nLeft + 1 PROMPT PadR( "No", nWidth )
   MENU TO nChoice

   zrevwindow()

   SetCursor( oldCurs )
   SetColor( oldColor )

   RETURN nChoice == 1

FUNCTION lBoxMessage( cMsg, cTitle )

   LOCAL nTopLine, ;
      nLeft := 5, ;
      nBotLine := MaxRow() - 2, ;
      nRight := MaxCol() - 5
   LOCAL nwidth, nmaxwidth, i, nNumLines, cAline
   LOCAL oldCurs := SetCursor( SC_NONE )
   LOCAL oldColor := SetColor( s_cStdColor )

   hb_default( @cTitle, "Info" )

   cmsg := AllTrim( cmsg )
   nNumLines := MLCount( cmsg, ( nright - nleft ) - 1 )
   nWidth := iif( nNumLines < 2, Len( cmsg ), nRight - nLeft - 1 )
   nTopLine := nBotLine - nNumLines - 1
   IF nTopLine < 0
      nNumLines += nTopLine
      nTopLine := 0
   ENDIF

   nMaxWidth := 0
   FOR i := 1 TO nNumLines
      nMaxWidth := Max( nMaxWidth, Len( RTrim( MemoLine( cmsg, nwidth, i ) ) ) )
   NEXT

   nLeft := Max( nLeft, Int( ( ( nRight + nLeft ) / 2 ) - ( nMaxWidth / 2 ) - 1 ) )
   nRight := nLeft + nMaxWidth + 1

   znewwindow( hb_UTF8ToStrBox( "┌─┐│┘─└│" ), nTopLine, nLeft, nBotLine, nRight, cTitle )
   DispBegin()
   FOR i := 1 TO nNumLines
      cAline := MemoLine( cMsg, nWidth, i )
      hb_DispOutAt( nTopLine + i, nLeft + 1, PadC( AllTrim( cAline ), nMaxWidth ) )
   NEXT
   DispEnd()

   Inkey( 0 )

   zrevwindow()

   SetCursor( oldCurs )
   SetColor( oldColor )

   RETURN .T.

FUNCTION ZNEWWINDOW( wtype, r1, c1, r2, c2, ctitle, ccolor )

   LOCAL i := Len( s_zwin )
   LOCAL cScreen := SaveScreen( r1, c1, r2, c2 )
   LOCAL cOldColor := SetColor()
   LOCAL nrow := Row(), ncol := Col()

   hb_default( @ctitle, "" )
   hb_default( @ccolor, s_cStdColor )

   SetColor( ccolor )

   wvw_nOpenWindow( ctitle, r1, c1, r2, c2 )

   AAdd( s_zwin, { i + 1, r1, c1, r2, c2, cScreen, ctitle, nrow, ncol, coldcolor } )

   SetColor( ccolor )

   hb_Scroll( r1, c1, r2, c2 )

   hb_DispBox( r1, c1, r2, c2, wtype )
   IF ! Empty( ctitle )
      cTitle := " " + AllTrim( ctitle ) + " "
      hb_DispOutAt( r1, nCeiling( ( c2 + c1 - Len( cTitle ) ) / 2 ), cTitle )
   ENDIF

   SetColor( cOldColor )

   RETURN i + 1

FUNCTION ZREVWINDOW()

   LOCAL i := Len( s_zwin )

   IF i == 0

      RETURN NIL
   ENDIF

   wvw_lCloseWindow()

   RestScreen( s_zwin[ i ][ 2 ], s_zwin[ i ][ 3 ], s_zwin[ i ][ 4 ], s_zwin[ i ][ 5 ], s_zwin[ i ][ 6 ] )


[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 header file: utils/hbtest/rt_main.ch. Defines constants: __CLIPPER__, HB_CLP_STRICT. Declares 1 preprocessor translations. Defines Harbour internal constants and macros

[Assistant]
#translate HBTEST <x> IS <result,...> => TEST_CALL( #<x>, {|| <x> }, <result> )

#ifndef __HARBOUR__
   #ifndef __XPP__
      #ifndef __CLIP__
         #ifndef FlagShip
            #ifndef __VO__
               #define __CLIPPER__
            #endif
         #endif
      #endif
   #endif
#endif

#ifdef __HARBOUR__
   #pragma linenumber=on
#else
   #define HB_CLP_STRICT
#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] Write a Harbour program with procedures: ErrorSys. Harbour Runtime Library file: src/rtl/errsys.prg. Provides functions: DefError, ErrorMessage. Contains procedures: ErrorSys. This file implements error handling and reporting

[Assistant]
#include "error.ch"

PROCEDURE ErrorSys()

   ErrorBlock( {| oError | DefError( oError ) } )

   RETURN

STATIC FUNCTION DefError( oError )

   LOCAL cMessage
   LOCAL cOSError

   LOCAL aOptions
   LOCAL nChoice

   LOCAL n

   IF oError:genCode == EG_ZERODIV .AND. ;
      oError:canSubstitute
      RETURN 0
   ENDIF

   IF oError:genCode == EG_LOCK .AND. ;
      oError:canRetry

      RETURN .T.
   ENDIF

   IF oError:genCode == EG_OPEN .AND. ;
      oError:osCode == 32 .AND. ;
      oError:canDefault
      NetErr( .T. )
      RETURN .F.
   ENDIF

   IF oError:genCode == EG_APPENDLOCK .AND. ;
      oError:canDefault
      NetErr( .T. )
      RETURN .F.
   ENDIF

   cMessage := ErrorMessage( oError )
   IF ! Empty( oError:osCode )
      cOSError := hb_StrFormat( "(DOS Error %1$d)", oError:osCode )
   ENDIF

   aOptions := {}

   AAdd( aOptions, "Quit" )

   IF oError:canRetry
      AAdd( aOptions, "Retry" )
   ENDIF

   IF oError:canDefault
      AAdd( aOptions, "Default" )
   ENDIF

   DO WHILE ( nChoice := Alert( cMessage + ;
      iif( cOSError == NIL, "", ";" + cOSError ), aOptions ) ) == 0
   ENDDO

   IF ! Empty( nChoice )
      SWITCH aOptions[ nChoice ]
      CASE "Break"
         Break( oError )
      CASE "Retry"
         RETURN .T.
      CASE "Default"
         RETURN .F.
      ENDSWITCH
   ENDIF

   IF cOSError != NIL
      cMessage += " " + cOSError
   ENDIF

   OutErr( hb_eol() )
   OutErr( cMessage )

   n := 1
   DO WHILE ! Empty( ProcName( ++n ) )
      OutErr( hb_eol() )
      OutErr( hb_StrFormat( "Called from %1$s(%2$d)  ", ;
         ProcName( n ), ;
         ProcLine( n ) ) )
   ENDDO

   ErrorLevel( 1 )
   QUIT

   RETURN .F.

STATIC FUNCTION ErrorMessage( oError )

   LOCAL cMessage := iif( oError:severity > ES_WARNING, "Error", "Warning" ) + " "

   IF HB_ISSTRING( oError:subsystem )
      cMessage += oError:subsystem()
   ELSE
      cMessage += "???"
   ENDIF

   IF HB_ISNUMERIC( oError:subCode )
      cMessage += "/" + hb_ntos( oError:subCode )
   ELSE
      cMessage += "/???"
   ENDIF

   IF HB_ISSTRING( oError:description )
      cMessage += "  " + oError:description
   ENDIF

   DO CASE
   CASE ! Empty( oError:filename )
      cMessage += ": " + oError:filename
   CASE ! Empty( oError:operation )
      cMessage += ": " + oError:operation
   ENDCASE

   RETURN cMessage


[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/flink.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#include "simpleio.ch"

PROCEDURE Main()

   hb_MemoWrit( "_hb_h.tmp", ">h.tmp<" )

   ? hb_FLink()
   ? FError()

   ? hb_FLinkRead()
   ? FError()

   ? hb_FLinkRead( "_hb_h.tmp" )
   ? FError()

   ? hb_FLink( "_hb_h.tmp", "_hb_hlnk.tmp" )
   ? FError()

   hb_MemoWrit( "_hb_s.tmp", ">s.tmp<" )

   ? hb_FLinkSym()
   ? FError()

   ? hb_FLinkSym( "_hb_s.tmp", "_hb_slnk.tmp" )
   ? FError()

   ? hb_FLinkRead( "_hb_slnk.tmp" )
   ? FError()

   hb_DirCreate( "_hb_d" )

   ? hb_FLinkSym( "_hb_d", "_hb_dlnk" )
   ? FError()

   ? hb_FLinkRead( "_hb_dlnk" )
   ? FError()

   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 extra library: extras/hbxlsxml/tests/example3.prg. Contains procedures: Main. This file provides spreadsheet generation capabilities

[Assistant]
#require "hbxlsxml"

PROCEDURE Main()

   LOCAL xml, sheet1, format4

   xml := ExcelWriterXML():New( "my file.xml" )

   sheet1 := xml:addSheet( "Plan 1" )

   format4 := xml:addStyle( "my style" )
   format4:setFontSize( 20 )
   format4:setFontColor( "yellow" )
   format4:bgColor( "blue" )

   sheet1:columnWidth( 1, 150 )
   sheet1:columnWidth( 2, 150 )
   sheet1:columnWidth( 3, 150 )
   sheet1:writeString( 2, 3, "celula 2_3", format4 )
   sheet1:writeString( 2, 2, "celula 2_2", format4 )
   sheet1:writeString( 2, 1, "celula 2_1", format4 )

   sheet1:writeString( 1, 1, "celula 1_1", format4 )
   sheet1:writeString( 1, 3, "celula 1_3", format4 )
   sheet1:cellMerge( 1, 1, 1, 0 )

   xml:writeData( "example3.xml" )

   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 Harbour functions: KeySec. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/keysec.prg. Provides functions: KeySec. This file provides legacy compatibility functions

[Assistant]
THREAD STATIC t_hIdle

FUNCTION KeySec( nKey, nTime, nCounter, lMode )

   LOCAL nSeconds

   IF t_hIdle != NIL
      hb_idleDel( t_hIdle )
      t_hIdle := NIL
   ENDIF

   IF HB_ISNUMERIC( nKey )

      IF ! HB_ISNUMERIC( nTime )
         nTime := 0
      ELSEIF nTime < 0
         nTime := -nTime / 18.2
      ENDIF
      nTime


[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 a Harbour program with procedures: Main. Harbour test program: tests/clasname.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
PROCEDURE Main()

   AEval( { NIL, {}, "", 0, CToD( "" ), .F., {|| NIL }, ErrorNew() }, ;
      {| x | QOut( x:className() ) } )

   ?

   ? NIL:className()
   ? {}:className()
   ? "":className()
   ? 0:className()
   ? CToD( "" ):className()
   ? .F. :className()
   ? {|| NIL }:className()
   ? ErrorNew():className()

   ?

   ? NIL         :  className()
   ? {}          :  className()
   ? ""          :  className()
   ? 0           :  className()
   ? CToD( "" )  :  className()
   ? .F.         :  className()
   ? {|| NIL }   :  className()
   ? ErrorNew()  :  className()

   ?
   ? ( NIL:className() ):className()

   ?
   ? ( ( NIL:className() ):className() ):className()

   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 test program: tests/idle.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
PROCEDURE Main()

   CLS

   ? "DEFAULT IDLEREPEAT =", Set( _SET_IDLEREPEAT )
   ?
   ? "Idle Block should be displayed multiple times until key or 10 seconds elapsed!"
   ? "Press any key to begin..."
   ?
   Inkey( 0 )

   hb_idleAdd( {|| QOut( "Idle Block" ) } )
   Inkey( 2 )

   Set( _SET_IDLEREPEAT, .F. )

   hb_idleAdd( {|| QOut( "Idle Block2" ) } )

   CLS
   ? "Idle Block & Block-2 should display ONCE! while waitning for key or 10 seconds elapsed!"
   ?
   Inkey( 2 )

   ?
   ? "Again - Idle Block & Block-2 should display ONCE! while waitning for key or 10 seconds elapsed!"
   ?
   Inkey( 2 )
   ?

   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 a Harbour program with procedures: Main. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/dates4.prg. Provides functions: CheckDate. Contains procedures: Main. This file provides legacy compatibility functions

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

PROCEDURE Main()

   LOCAL i
   LOCAL dDate := Date()

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

   FOR i := 7 TO 49 STEP 7
      CheckDate( dDate )
      dDate += i
   NEXT

   RETURN

FUNCTION CheckDate( dDate )

   ? "Testing date:", dDate
   ? "Days in month..:", DaysInMonth( dDate )
   ? "Day of year....:", DoY( dDate )
   ? "Begin of month.:", BoM( dDate )
   ? "End of month...:", EoM( dDate )
   ? "Week of month..:", WoM( dDate )
   ? "Begin of year..:", BoY( dDate )
   ? "End of year....:", EoY( dDate )
   ?

   RETURN NIL