[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:

Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hbcompat.ch. Defines constants: __PLATFORM__WINDOWS, __PLATFORM__LINUX, HB_GTI_CLIPBOARDPAST. Declares 5 preprocessor commands. Declares 5 preprocessor translations. Defines keyboard input constants

[Assistant]
#ifdef __HARBOUR__

#include "hbgtinfo.ch"
#include "hbgfx.ch"

#ifdef __XHARBOUR__

   #if defined( __PLATFORM__Windows ) .AND. ! defined( __PLATFORM__WINDOWS )
      #define __PLATFORM__WINDOWS
   #endif
   #if defined( __PLATFORM__Linux ) .AND. ! defined( __PLATFORM__LINUX )
      #define __PLATFORM__LINUX
   #endif

   #xtranslate hb_gtInfo( HB_GTI_INKEYREAD [, <x>] )   => SetInkeyBeforeBlock( [<x>] ) <-x->
   #xtranslate hb_gtInfo( HB_GTI_INKEYFILTER [, <x>] ) => SetInkeyAfterBlock( [<x>] ) <-x->

   #xtranslate hb_ScrMaxRow()                  => gtInfo( HB_GTI_SCREENHEIGHT )
   #xtranslate hb_ScrMaxCol()                  => gtInfo( HB_GTI_SCREENWIDTH )
   #xtranslate MaxRow( .T. )                   => gtInfo( HB_GTI_SCREENHEIGHT )
   #xtranslate MaxCol( .T. )                   => gtInfo( HB_GTI_SCREENWIDTH )
   #xtranslate hb_keyNext( [<x>] )             => NextKey( <x> )

   #xtranslate hb_osNewLine()                  => hb_eol()
   #xtranslate hb_osPathSeparator()            => hb_ps()

   #xtranslate hb_dbPack()                     => __dbPack()
   #xtranslate hb_dbZap()                      => __dbZap()
   #xtranslate hb_dbDrop( [<x,...>] )          => dbDrop( <x> )
   #xtranslate hb_dbExists( [<x,...>] )        => dbExists( <x> )
   #xtranslate hb_FieldLen( [<x>] )            => FieldLen( <x> )
   #xtranslate hb_FieldDec( [<x>] )            => FieldDec( <x> )
   #xtranslate hb_FieldType( [<x>] )           => FieldType( <x> )

   #xtranslate hb_processOpen( [<x,...>] )     => hb_OpenProcess( <x> )
   #xtranslate hb_processClose( [<x,...>] )    => hb_CloseProcess( <x> )

   #xtranslate hb_IsRegex( [<x>] )             => hb_IsRegexString( <x> )
   #xtranslate hb_MethodName( [<x,...>] )      => MethodName( <x> )
   #xtranslate hb_libLoad( [<x,...>] )         => LibLoad( <x> )
   #xtranslate hb_libFree( [<x,...>] )         => LibFree( <x> )
   #xtranslate hb_Adler32( [<x,...>] )         => hb_Checksum( <x> )
   #xtranslate hb_keySetLast( [<x,...>] )      => hb_SetLastKey( <x> )
   #xtranslate hb_CStr( [<x,...>] )            => CStr( <x> )
   #xtranslate hb_ValToExp( [<x,...>] )        => ValToPrgExp( <x> )
   #xtranslate hb_rddInfo( [<x,...>] )         => rddInfo( <x> )
   #xtranslate hb_idleSleep( [<x,...>] )       => SecondsSleep( <x> )
   #xtranslate hb_UserName()                   => NetName( 1 )
   #xtranslate hb_FSize( <x> )                 => FileSize( <x> )
   #xtranslate hb_WildMatch( [<x,...>] )       => WildMatch( <x> )
   #xtranslate hb_bitTest( [<x,...>] )         => hb_bitIsSet( <x> )
   #xtranslate hb_Deserialize( <x> )           => hb_DeserialNext( <x> )

   #xtranslate hb_HexToNum( [<c,...>] )        => HexToNum( <c> )
   #xtranslate hb_NumToHex( [<n,...>] )        => NumToHex( <n> )
   #xtranslate hb_HexToStr( [<c,...>] )        => HexToStr( <c> )
   #xtranslate hb_StrToHex( [<c,...>] )        => StrToHex( <c> )

   #xtranslate hb_AScan( [<x,...>] )           => AScan( <x> )
   #xtranslate hb_RAScan( [<x,...>] )          => RAScan( <x> )
   #xtranslate hb_AIns( [<x,...>] )            => AIns( <x> )
   #xtranslate hb_ADel( [<x,...>] )            => ADel( <x> )
   #xtranslate hb_At( [<x,...>] )              => At( <x> )

   #xtranslate hb_DateTime( [<x,...>] )        => DateTime( <x> )
   #xtranslate hb_Hour( [<x>] )                => Hour( <x> )
   #xtranslate hb_Minute( [<x>] )              => Minute( <x> )
   #xtranslate hb_TToS( [<x>] )                => TToS( <x> )
   #xtranslate hb_SToT( [<x>] )                => SToT( <x> )
   #xtranslate hb_TToC( [<x,...>] )            => TToC( <x> )
   #xtranslate hb_CToT( [<x,...>] )            => CToT( <x> )

   #xtranslate hb_GetEnv( [<x,...>] )          => GetEnv( <x> )
   #xtranslate hb_SetKey( [<x,...>] )          => SetKey( <x> )

   #xtranslate hb_i18n_gettext( <x> )          => i18n( <x> )

   #xtranslate hb_cdpSelect( [<x,...>] )       => hb_SetCodepage( <x> )

   #xtranslate hb_argv( [<x,...>] )            => hb_CmdArgArgV( <x> )

   #xtranslate hb_PIsByRef( @<!localVar!> )    => hb_IsByRef( @<localVar> )

   #xtranslate hb_iniSetComment( [<x,...>] )   => hb_SetIniComment( <x> )
   #xtranslate hb_iniRead( [<x,...>] )         => hb_ReadIni( <x> )
   #xtranslate hb_iniWrite( [<x,...>] )        => hb_WriteIni( <x> )

   #xtranslate hb_DisableWaitLocks( [<x>] )    => DisableWaitLocks( <x> )

   #xtranslate hb_gtLock()                     => hbConsoleLock()
   #xtranslate hb_gtUnlock()                   => hbConsoleUnlock()

   #xtranslate hb_mtvm()                       => hb_MultiThread()
   #xtranslate hb_threadSelf()                 => GetCurrentThread()
   #xtranslate hb_threadID( [<x,...>] )        => GetThreadId( <x> )
   #xtranslate hb_threadStart( <x,...> )       => StartThread( [<x>] )
   #xtranslate hb_threadJoin( <x> )            => JoinThread( <x> )
   #xtranslate hb_threadQuitRequest( <x> )     => KillThread( <x> )
   #xtranslate hb_threadWaitForAll()           => WaitForThreads()
   #xtranslate hb_threadTerminateAll()         => KillAllThreads()

   #xtranslate hb_mutexNotify( <x,...> )       => Notify( <x> )
   #xtranslate hb_mutexNotifyAll( <x,...> )    => NotifyAll( <x> )

   #xtranslate hb_mutexSubscribe( <x,...> )    => {| mtx, nTimeOut, xSubscribed | ;;
                                                  LOCAL lSubscribed ;;
                                                  xSubscribed := Subscribe( mtx, ;
                                                                            iif( HB_ISNUMERIC( nTimeOut ), nTimeOut
   #xcommand TEXT INTO <v> => #pragma __text|<v>+=%s+hb_eol();<v>:=""

   #xcommand DEFAULT => OTHERWISE

   #xtranslate hb_enumIndex( <!v!> ) => <v>:__enumIndex()

   #xcommand TRY => BEGIN SEQUENCE WITH __BreakBlock()
   #xcommand CATCH [<!oErr!>] => RECOVER [USING <oErr>] <-oErr->
   #xcommand FINALLY => ALWAYS

   #xtranslate \<|[<x,...>]| => {| <x> |
   #xcommand > [<*x*>]       => } <x>

   #translate ( <exp1> IN <exp2> )     => ( ( <exp1> ) $ ( <exp2> ) )
   #translate ( <exp1> HAS <exp2> )    => ( hb_regexHas( <exp2>, <exp1> ) )
   #translate ( <exp1> LIKE <exp2> )   => ( hb_regexLike( <exp2>, <exp1> ) )
   #translate ( <exp1> \<\< <exp2> )   => ( hb_bitShift( <exp1>, <exp2> ) )
   #translate ( <exp1> >> <exp2> )     => ( hb_bitShift( <exp1>, -( <exp2> ) ) )

   #if defined( XHB_BITOP )
      #translate ( <exp1> | <exp2> )      => ( xhb_bitOr( <exp1>, <exp2> ) )
      #translate ( <exp1> & <exp2> )      => ( xhb_bitAnd( <exp1>, <exp2> ) )
      #translate ( <exp1> ^^ <exp2> )     => ( xhb_bitXor( <exp1>, <exp2> ) )
   #endif

   #command @ <row>, <col> PROMPT <prompt> [ MESSAGE <msg> ] [ COLOR <color> ] => ;
      __AtPrompt( <row>, <col>, <prompt>, <msg>, <color> )

   #command SET TRIMFILENAME <x:ON,OFF,&> => Set( _SET_TRIMFILENAME, <(x)> )
   #command SET TIME FORMAT [TO] <f>      => Set( _SET_TIMEFORMAT, <f> )

   #define HB_GTI_CLIPBOARDPAST HB_GTI_CLIPBOARDPASTE

   #xtranslate gtSetClipboard( <x> )           => hb_gtInfo( HB_GTI_CLIPBOARDDATA, <x> )
   #xtranslate gtGetClipboard()                => hb_gtInfo( HB_GTI_CLIPBOARDDATA )
   #xtranslate gtGetClipboardSize()            => Len( hb_gtInfo( HB_GTI_CLIPBOARDDATA ) )
   #xtranslate gtPasteClipboard()              => hb_gtInfo( HB_GTI_CLIPBOARDPASTE )
   #xtranslate gtProcessMessages()             => NextKey()
   #xtranslate SetInkeyBeforeBlock( [<x>] )    => hb_gtInfo( HB_GTI_INKEYREAD [, <x>] ) <-x->
   #xtranslate SetInkeyAfterBlock( [<x>] )     => hb_gtInfo( HB_GTI_INKEYFILTER [, <x>] ) <-x->
   #xtranslate GfxPrimitive( [<x,...>] )       => hb_gfxPrimitive( <x> )
   #xtranslate GfxText( [<x,...>] )            => hb_gfxText( <x> )

   #xtranslate hb_OpenProcess( [<x,...>] )     => hb_processOpen( <x> )
   #xtranslate hb_CloseProcess( [<x,...>] )    => hb_processClose( <x> )

   #xtranslate hb_IsRegexString( [<x>] )       => hb_IsRegex( <x> )
   #xtranslate MethodName( [<x,...>] )         => hb_MethodName( <x> )


[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: Header file for contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/hbole.ch. Defines 10 constants including: HBOLE_CH_, WIN_VT_EMPTY, WIN_VT_NULL, WIN_VT_I2, WIN_VT_I4. Defines file I/O constants

[Assistant]
#ifndef HBOLE_CH_
#define HBOLE_CH_

#define WIN_VT_EMPTY                0
#define WIN_VT_NULL                 1
#define WIN_VT_I2                   2
#define WIN_VT_I4                   3
#define WIN_VT_R4                   4
#define WIN_VT_R8                   5
#define WIN_VT_CY                   6
#define WIN_VT_DATE                 7
#define WIN_VT_BSTR                 8
#define WIN_VT_DISPATCH             9
#define WIN_VT_ERROR                10
#define WIN_VT_BOOL                 11
#define WIN_VT_VARIANT              12
#define WIN_VT_UNKNOWN              13
#define WIN_VT_DECIMAL              14
#define WIN_VT_I1                   16
#define WIN_VT_UI1                  17
#define WIN_VT_UI2                  18
#define WIN_VT_UI4                  19
#define WIN_VT_I8                   20
#define WIN_VT_UI8                  21
#define WIN_VT_INT                  22
#define WIN_VT_UINT                 23
#define WIN_VT_VOID                 24
#define WIN_VT_HRESULT              25
#define WIN_VT_PTR                  26
#define WIN_VT_SAFEARRAY            27
#define WIN_VT_CARRAY               28
#define WIN_VT_USERDEFINED          29
#define WIN_VT_LPSTR                30
#define WIN_VT_LPWSTR               31
#define WIN_VT_RECORD               36
#define WIN_VT_INT_PTR              37
#define WIN_VT_UINT_PTR             38
#define WIN_VT_FILETIME             64
#define WIN_VT_BLOB                 65
#define WIN_VT_STREAM               66
#define WIN_VT_STORAGE              67
#define WIN_VT_STREAMED_OBJECT      68
#define WIN_VT_STORED_OBJECT        69
#define WIN_VT_BLOB_OBJECT          70
#define WIN_VT_CF                   71
#define WIN_VT_CLSID                72
#define WIN_VT_VERSIONED_STREAM     73

#define WIN_VT_BSTR_BLOB            0x0fff
#define WIN_VT_VECTOR               0x1000
#define WIN_VT_ARRAY                0x2000
#define WIN_VT_BYREF                0x4000
#define WIN_VT_RESERVED             0x8000
#define WIN_VT_ILLEGAL              0xffff
#define WIN_VT_ILLEGALMASKED        0x0fff
#define WIN_VT_TYPEMASK             0x0fff

#define WIN_CO_E_CLASSSTRING        0x800401F3
#define WIN_OLE_E_WRONGCOMPOBJ      0x8004000E
#define WIN_REGDB_E_WRITEREGDB      0x80040151
#define WIN_REGDB_E_CLASSNOTREG     0x80040154
#define WIN_E_PENDING               0x8000000A
#define WIN_E_NOTIMPL               0x80004001
#define WIN_E_NOINTERFACE           0x80004002
#define WIN_E_POINTER               0x80004003
#define WIN_E_ABORT                 0x80004004
#define WIN_E_FAIL                  0x80004005
#define WIN_E_UNEXPECTED            0x8000FFFF
#define WIN_E_ACCESSDENIED          0x80070005
#define WIN_E_HANDLE                0x80070006
#define WIN_E_OUTOFMEMORY           0x8007000E
#define WIN_E_INVALIDARG            0x80070057
#define WIN_DISP_E_UNKNOWNINTERFACE 0x80020001
#define WIN_DISP_E_MEMBERNOTFOUND   0x80020003
#define WIN_DISP_E_PARAMNOTFOUND    0x80020004
#define WIN_DISP_E_TYPEMISMATCH     0x80020005
#define WIN_DISP_E_UNKNOWNNAME      0x80020006
#define WIN_DISP_E_NONAMEDARGS      0x80020007
#define WIN_DISP_E_BADVARTYPE       0x80020008
#define WIN_DISP_E_EXCEPTION        0x80020009
#define WIN_DISP_E_OVERFLOW         0x8002000A
#define WIN_DISP_E_BADINDEX         0x8002000B
#define WIN_DISP_E_UNKNOWNLCID      0x8002000C
#define WIN_DISP_E_ARRAYISLOCKED    0x8002000D
#define WIN_DISP_E_BADPARAMCOUNT    0x8002000E
#define WIN_DISP_E_PARAMNOTOPTIONAL 0x8002000F
#define WIN_DISP_E_BADCALLEE        0x80020010
#define WIN_DISP_E_NOTACOLLECTION   0x80020011
#define WIN_DISP_E_DIVBYZERO        0x80020012
#define WIN_DISP_E_BUFFERTOOSMALL   0x80020013

#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 contribution module 'gtwvg' (): contrib/gtwvg/statbar.prg. Defines classes: WvgStatusBar, WvgStatusBarPanel. 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 WvgStatusBar INHERIT WvgWindow

   VAR    caption                               INIT ""
   VAR    sizeGrip                              INIT .T.

   VAR    aItems                                INIT {}

   METHOD numItems()                            INLINE Len( ::aItems )

   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 addItem( cCaption, xImage, cDLL, nStyle, cKey, nMode )
   METHOD delItem( nItemORcKey )
   METHOD getItem( nItemORcKey )
   METHOD clear()
   METHOD panelClick( xParam )                  SETGET
   METHOD panelDblClick( xParam )               SETGET

ENDCLASS

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

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

   ::style       := WS_CHILD + WS_BORDER + SBARS_TOOLTIPS
   ::className   := STATUSCLASSNAME
   ::objType     := objTypeStatusBar

   RETURN Self

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

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

   IF ::sizeGrip
      ::style += SBARS_SIZEGRIP
   ENDIF

   ::oParent:AddChild( Self )

   ::createControl()

   ::SetWindowProcCallback()

   IF ::visible
      ::show()
   ENDIF

   ::addItem( , , , , , -1 )

   RETURN Self

METHOD WvgStatusBar:handleEvent( nMessage, aNM )

   LOCAL nHandled := 1
   LOCAL nObj, aNMH

   DO CASE

   CASE nMessage == HB_GTE_RESIZED
      ::sendMessage( WM_SIZE, 0, 0 )
      RETURN 0

   CASE nMessage == HB_GTE_COMMAND
      IF HB_ISBLOCK( ::sl_lbClick )
         Eval( ::sl_lbClick, , , Self )
         RETURN 0
      ENDIF

   CASE nMessage == HB_GTE_NOTIFY
      aNMH := wvg_GetNMMouseInfo( aNM[ 2 ] )

      DO CASE
      CASE aNMH[ NMH_code ] == NM_CLICK

         IF HB_ISBLOCK( ::sl_lbClick )
            IF aNMH[ NMH_dwItemSpec ] >= 0
               nObj := aNMH[ NMH_dwItemSpec ] + 1

               Eval( ::sl_lbClick, ::aItems[ nObj ], , Self )
            ENDIF

            nHandled := 0
         ENDIF

      ENDCASE

   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 nHandled

METHOD PROCEDURE WvgStatusBar:destroy()

   LOCAL i, nItems

   IF ( nItems := Len( ::aItems ) ) > 0
      FOR i := 1 TO nItems

      NEXT
   ENDIF

   ::wvgWindow:destroy()

   RETURN

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

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

   RETURN Self

METHOD WvgStatusBar:addItem( cCaption, xImage, cDLL, nStyle, cKey, nMode )

   LOCAL oPanel, lSuccess

   __defaultNIL( @nMode, 0 )

   HB_SYMBOL_UNUSED( xImage )
   HB_SYMBOL_UNUSED( cDLL )

   oPanel := WvgStatusBarPanel():new( cCaption, nStyle, cKey )
   oPanel:oParent := Self

   oPanel:index := ::numItems + 1

   lSuccess := wvg_StatusBarCreatePanel( ::hWnd, nMode )

   IF lSuccess
      AAdd( ::aItems, oPanel )
   ELSE
      RETURN NIL
   ENDIF

   RETURN oPanel

METHOD WvgStatusBar:delItem( nItemORcKey )

   LOCAL nIndex := 0

   DO CASE
   CASE HB_ISNUMERIC( nItemORcKey )
      nIndex := AScan( ::aItems, {| o | o:key == nItemORcKey } )
   CASE HB_ISNUMERIC( nItemORcKey )
      nIndex := nItemORcKey
   ENDCASE

   IF nIndex > 0

      hb_ADel( ::aItems, nIndex, .T. )
   ENDIF

   RETURN Self

METHOD WvgStatusBar:getItem( nItemORcKey )

   LOCAL nIndex := 0, oPanel

   DO CASE
   CASE HB_ISSTRING( nItemORcKey )
      nIndex := AScan( ::aItems, {| o | o:key == nItemORcKey } )
   CASE HB_ISNUMERIC( nItemORcKey )
      nIndex := nItemORcKey
   ENDCASE

   IF nIndex > 0
      oPanel := ::aItems[ nIndex ]
   ENDIF

   RETURN oPanel

METHOD WvgStatusBar:clear()

   LOCAL i

   FOR i := 1 TO ::numItems

   NEXT

   ::aItems := {}

   RETURN Self

METHOD WvgStatusBar:panelClick( xParam )

   IF HB_ISBLOCK( xParam ) .OR. HB_ISNIL( xParam )
      ::sl_lbClick := xParam
   ENDIF

   RETURN Self

METHOD WvgStatusBar:panelDblClick( xParam )

   IF HB_ISBLOCK( xParam ) .OR. HB_ISNIL( xParam )
      ::sl_lbDblClick := xParam
   ENDIF

   RETURN Self

CREATE CLASS WvgStatusBarPanel

   VAR    alignment                             INIT WVGALIGN_LEFT
   VAR    autosize                              INIT WVGSTATUSBAR_AUTOSIZE_NONE
   VAR    bevel                                 INIT WVGSTATUSBAR_BEVEL_INSET
   VAR    enabled                               INIT .T.
   VAR    index                                 INIT 0
   VAR    key                                   INIT ""
   VAR    style                                 INIT WVGSTATUSBAR_PANEL_TEXT
   VAR    sl_caption                            INIT ""
   VAR    image                                 INIT NIL
   VAR    tooltipText                           INIT ""
   VAR    visible                               INIT .T.
   VAR    left                                  INIT 0
   VAR    width                                 INIT 0
   VAR    minWidth                              INIT 0

   METHOD new( cCaption, nStyle, cKey )
   METHOD caption( cCaption )                   SETGET

   VAR    oParent

ENDCLASS

METHOD WvgStatusBarPanel:new( cCaption, nStyle, cKey )

   __defaultNIL( @cCaption, ::sl_caption )
   __defaultNIL( @nStyle, ::style )
   __defaultNIL( @cKey, ::key )

   ::sl_caption     := cCaption
   ::style          := nStyle
   ::key            := cKey

   RETURN Self

METHOD WvgStatusBarPanel:caption( cCaption )

   IF cCaption == NIL
      RETURN ::sl_caption
   ELSE
      __defaultNIL( @cCaption, ::sl_caption )

      ::sl_caption := cCaption

      wvg_StatusBarSetText( ::oParent:hWnd, ::index, cCaption )
   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] Generate Harbour code for: Harbour test program: tests/achoice6.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#include "inkey.ch"

PROCEDURE Main()

   LOCAL x1 := 24
   LOCAL x2 := 35
   LOCAL y1 := 7.6
   LOCAL y2 := 9.9

   hb_keyPut( { K_DOWN, K_DOWN } )

   CLS
   DispBox( y1, x1, y2 + 1, x2 + 1,, "W+/B,N/BG" )
   AChoice( y1 + 1, x1 + 1, y2, x2, ;
      { "menu 1", "menu 2", "menu 3" }, ;
      { .T., .F., .T. } )

   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 contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/acctweek.prg. Provides functions: ft_AcctWeek. This file provides legacy compatibility functions

[Assistant]
FUNCTION ft_AcctWeek( dGivenDate, nWeekNum )

   LOCAL nTemp, aRetVal

   IF HB_ISNUMERIC( dGivenDate )
      nWeekNum := dGivenDate
      dGivenDate := Date()
   ELSEIF ! HB_ISDATE( dGivenDate )
      dGivenDate := Date()
   ENDIF

   aRetVal := ft_AcctYear( dGivenDate )

   IF HB_ISNUMERIC( nWeekNum )
      nTemp := Int( ( aRetVal[ 3 ] - aRetVal[ 2 ] ) / 7 ) + 1
      IF nWeekNum < 1 .OR. nWeekNum > nTemp
         nWeekNum := nTemp
      ENDIF
      dGivenDate := aRetVal[ 2 ] + ( nWeekNum - 1 )


[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/memoedit.ch. Defines 10 constants including: _MEMOEDIT_CH, ME_IDLE, ME_UNKEY, ME_UNKEYX, ME_INIT. Defines Harbour internal constants and macros

[Assistant]
#ifndef _MEMOEDIT_CH
#define _MEMOEDIT_CH

#define ME_IDLE         0
#define ME_UNKEY        1
#define ME_UNKEYX       2
#define ME_INIT         3
#ifndef HB_CLP_STRICT
#define ME_REQUEST      4

#endif

#define ME_DEFAULT      0
#define ME_IGNORE       32
#define ME_DATA         33
#define ME_TOGGLEWRAP   34
#define ME_TOGGLESCROLL 35
#define ME_WORDRIGHT    100
#define ME_BOTTOMRIGHT  101
#ifndef HB_CLP_STRICT
#define ME_PASTE        110
#endif

#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 the following Harbour (xBase/Clipper) code:

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

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

#include "simpleio.ch"

PROCEDURE Main()

   ? NumLine( "" ), 0
   ? NumLine( "-" ), 1
   ? NumLine( Replicate( "-", 80 ) ), 2
   ? NumLine( Replicate( "-", 160 ) ), 3
   ? NumLine( Replicate( "-", 100 ), 30 ), 4
   ? NumLine( "-" + Chr( 13 ) + Chr( 10 ) ), 2
   ? NumLine( "-" + Chr( 10 ) ), 2
   ? NumLine( "-" + Chr( 13 ) + Chr( 10 ) + "=" ), 2
   ? NumLine( "-" + Chr( 10 ) + "=" ), 2
   ? NumLine( Replicate( "-", 100 ) + Chr( 13 ) + Chr( 10 ), 30 ), 5
   ? NumLine( Replicate( "-", 100 ) + Chr( 10 ), 30 ), 5

   RETURN


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

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

Harbour contribution module 'hbhttpd' (Multithreaded HTTP/HTTPS server framework): contrib/hbhttpd/log.prg. Defines classes: UHttpdLog. This file provides network protocol implementations

[Assistant]
#include "hbclass.ch"

#include "fileio.ch"

CREATE CLASS UHttpdLog

   METHOD New( cFileName )
   METHOD Add( cMsg )
   METHOD Close()
   METHOD IsOpen()

   PROTECTED:

   VAR cFileName
   VAR fhnd      INIT F_ERROR

ENDCLASS

METHOD New( cFileName ) CLASS UHttpdLog

   IF HB_ISSTRING( cFileName )

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

      ::cFileName := cFileName
   ENDIF

   RETURN Self

METHOD IsOpen() CLASS UHttpdLog
   RETURN ::fhnd != F_ERROR

METHOD Add( cMsg ) CLASS UHttpdLog

   IF ! HB_ISSTRING( cMsg )
      RETURN .F.
   ENDIF

   IF ::fhnd == F_ERROR .AND. ! Empty( ::cFileName )
      ::fhnd := hb_FCreate( ::cFileName, FC_NORMAL, FO_WRITE + FO_DENYNONE )
   ENDIF

   RETURN ::fhnd != F_ERROR .AND. FWrite( ::fhnd, cMsg ) == hb_BLen( cMsg )

METHOD Close() CLASS UHttpdLog

   LOCAL lRetVal

   IF ::fhnd != F_ERROR
      lRetVal := FClose( ::fhnd )
      ::fhnd := F_ERROR
   ELSE
      lRetVal := .F.
   ENDIF

   RETURN lRetVal


[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 'gtwvw' (): contrib/gtwvw/tests/demo.prg. Contains procedures: Main. This file provides platform-specific functionality

[Assistant]
#require "gtwvw"

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

#define MF_INSERT                     0
#define MF_CHANGE                   128
#define MF_APPEND                   256
#define MF_DELETE                   512
#define MF_REMOVE                  4096

#define MF_BYCOMMAND                  0
#define MF_BYPOSITION              1024

#define MF_SEPARATOR               2048

#define MF_ENABLED                    0
#define MF_GRAYED                     1
#define MF_DISABLED                   2

#define MF_UNCHECKED                  0
#define MF_CHECKED                    8
#define MF_USECHECKBITMAPS          512

#define MF_STRING                     0
#define MF_BITMAP                     4
#define MF_OWNERDRAW                256

#define MF_POPUP                     16
#define MF_MENUBARBREAK              32
#define MF_MENUBREAK                 64

#define MF_UNHILITE                   0
#define MF_HILITE                   128

#define MB_OK                                 0
#define MB_OKCANCEL                           1
#define MB_ABORTRETRYIGNORE                   2
#define MB_YESNOCANCEL                        3
#define MB_YESNO                              4
#define MB_RETRYCANCEL                        5
#define MB_CANCELTRYCONTINUE                  6

#define MB_ICONHAND                          16
#define MB_ICONQUESTION                      32
#define MB_ICONEXCLAMATION                   48
#define MB_ICONASTERISK                      64

#define MB_USERICON                         128
#define MB_ICONWARNING              MB_ICONEXCLAMATION
#define MB_ICONERROR                MB_ICONHAND

#define MB_ICONINFORMATION          MB_ICONASTERISK
#define MB_ICONSTOP                 MB_ICONHAND

#define MB_DEFBUTTON1                         0
#define MB_DEFBUTTON2                       256
#define MB_DEFBUTTON3                       512
#define MB_DEFBUTTON4                       768

#define MB_APPLMODAL                          0
#define MB_SYSTEMMODAL                     4096
#define MB_TASKMODAL                       8192
#define MB_HELP                           16384

#define MB_NOFOCUS                        32768
#define MB_SETFOREGROUND                  65536
#define MB_DEFAULT_DESKTOP_ONLY          131072

#define MB_TOPMOST                       262144
#define MB_RIGHT                         524288
#define MB_RTLREADING                   1048576

#define IDOK                1
#define IDCANCEL            2
#define IDABORT             3
#define IDRETRY             4
#define IDIGNORE            5
#define IDYES               6
#define IDNO                7
#define IDCLOSE             8
#define IDHELP              9

#define IDTRYAGAIN          10

#define WVW_MAXWINDOWS    20
#define WVW_DEFAULT_MENUKEYEVENT  1024

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

#define IDM_DEMO_GET     101
#define IDM_DEMO_BROWSE  102
#define IDM_DEMO_CONSOLE 103

#define IDM_DEMO_EXIT    199

#define IDM_TOOLBAR_RESET  501
#define IDM_TOOLBAR_DELETE 502
#define IDM_TOOLBAR_ENABLE  503
#define IDM_TOOLBAR_DISABLE  504

#define IDM_WINDOW_SPACING_INCREASE  201
#define IDM_WINDOW_SPACING_DECREASE  202
#define IDM_WINDOW_SPACING_DEFAULT   203

#define IDM_HELP_HELP    301
#define IDM_HELP_INFO    302

#define IDM_NETCONNECT    401
#define IDM_NETDISCONNECT 402
#define IDM_BACK          403
#define IDM_FORWARD       404
#define IDM_COPY          405
#define IDM_PASTE         406

STATIC s_amiscobjlist := {}
STATIC s_afontinfo := {}

PROCEDURE Main()

   LOCAL nCurWindow
   LOCAL hMenu, hPopupmenu
   LOCAL cLabel := "This is the Main Window"
   LOCAL nCursor
   LOCAL kF1, kF2, kF3
   LOCAL kF9, kF10, kF11
   LOCAL oMouse
   LOCAL ch

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

   Set( _SET_EVENTMASK, INKEY_ALL )

   Set( _SET_DATEFORMAT, "yyyy-mm-dd" )
   SET SCOREBOARD OFF

   wvw_SetVertCaret( .T. )
   wvw_pbSetFont( , "Tahoma", 14 )
   nCursor := SetCursor( SC_NONE )

   IF ! SetDefaultWindowSize()
      ldebug( "Cannot setDefaultWindowSize()" )
   ELSE
      ldebug( "Successfully setDefaultWindowSize()" )
   ENDIF

   IF wvw_sbCreate() > 0 .AND. ;
      wvw_sbAddPart( , "99:99:99" ) > 0
      wvw_SetTimer( , 1000 )
   ENDIF

   s_afontinfo := wvw_GetFontInfo()

   hb_gtInfo( HB_GTI_INKEYFILTER, {| nkey | nAfterInkey( nkey ) } )
   wvw_SetMouseMove( , .T. )
   kF1 := SetKey( K_F1, {|| xHelp() } )
   kF2 := SetKey( K_F2, {|| xDebugInfo() } )
   kF3 := SetKey( K_F3, {|| Demo_Console() } )

   kF9 := SetKey( K_F9, {|| wvw_SetLineSpacing( NIL, wvw_SetLineSpacing() - 2 ) } )
   kF10 := SetKey( K_F10, {|| wvw_SetLineSpacing( NIL, wvw_SetLineSpacing() + 2 ) } )
   kF11 := SetKey( K_F11, {|| wvw_SetDefLineSpacing( wvw_SetLineSpacing() ) } )

   hMenu := wvw_CreateMenu()
   hPopupMenu := wvw_CreateMenu()
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_DEMO_GET, "~GET demo"  )
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_DEMO_BROWSE, "~BROWSE demo" )
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_DEMO_CONSOLE, "~CONSOLE demo (F3)" )

   wvw_AppendMenu( hPopupMenu, MF_SEPARATOR )
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_DEMO_EXIT, "E~xit"  )
   wvw_AppendMenu( hMenu, MF_ENABLED + MF_POPUP, hPopupMenu, "~Demos",  )

   hPopupMenu := wvw_CreateMenu()
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_TOOLBAR_ENABLE,  "~Enable Toolbar" )
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_TOOLBAR_DISABLE, "~Disable Toolbar" )
   wvw_AppendMenu( hPopupMenu, MF_SEPARATOR )
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_TOOLBAR_RESET,  "~Reset Toolbar" )
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_TOOLBAR_DELETE, "~Delete Toolbar" )
   wvw_AppendMenu( hMenu, MF_ENABLED + MF_POPUP, hPopupMenu, "~Toolbar",  )

   hPopupMenu := wvw_CreateMenu()
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_WINDOW_SPACING_DECREASE, "~Decrease Line Spacing (F9)" )
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_WINDOW_SPACING_INCREASE, "~Increase Line Spacing (F10)" )
   wvw_AppendMenu( hPopupMenu, MF_SEPARATOR )
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_WINDOW_SPACING_DEFAULT,  "~Set As Default Line Spacing (F11)" )
   wvw_AppendMenu( hMenu, MF_ENABLED + MF_POPUP, hPopupMenu, "~Window",  )

   hPopupMenu := wvw_CreateMenu()
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_HELP_HELP, "~Help (F1)"  )
   wvw_AppendMenu( hPopupMenu, MF_SEPARATOR )
   wvw_AppendMenu( hPopupMenu, MF_ENABLED + MF_STRING, IDM_HELP_INFO, "~Info (F2)"  )
   wvw_AppendMenu( hMenu, MF_ENABLED + MF_POPUP, hPopupMenu, "~Help",  )

   wvw_SetMenu( , hMenu )

   nCurWindow := wvw_nNumWindows() - 1

   CreateToolbar( nCurWindow )

   ResetMiscObjects( nCurWindow )
   AddMiscObjects( nCurWindow, {| nWindow | wvw_DrawLabel( nWindow, 1, 40, cLabel, 6,, RGB( 255, 255, 255 ), RGB( 198, 198, 198 ), "Arial", s_afontinfo[ 2 ], , , , , .T., .T. ) } )

   wvwm_ResetMouseObjects( nCurWindow )
   wvwm_AddMouseObjects( nCurWindow, WVWMouseButton():New( "Info!", MaxRow() - 2, 67, , , {|| xDebugInfo() } ) )

   oMouse := WVWMouseButton():New( "Flat",   MaxRow() - 2, 67 - 11, , , {|| lboxmessage( "flat" ) }, 1, NIL )
   oMouse:cImage := "vouch1.gif"
   oMouse:cCaption := ""
   wvwm_AddMouseObjects( nCurWindow, oMouse )

   oMouse := WVWMouseButton():New( "None",   MaxRow() - 2, 67 - 11 - 11, , , {|| lboxmessage( "none" ) }, 2, NIL )
   oMouse:Enable( .T. )
   wvwm_AddMouseObjects( nCurWindow, oMouse )

   wvwm_AddMouseObjects( nCurWindow, WVWMouseButton():New( "Hard",   MaxRow() - 2, 67 - 11 - 11 - 11, , , {|| lboxmessage( "hard" ) }, 3, NIL ) )


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

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

Harbour Runtime Library file: src/rtl/tbrowsys.prg. Provides functions: TApplyKey. Contains 14 procedures. This file implements object-oriented classes using Harbour's class system

[Assistant]
#ifdef HB_COMPAT_C53

#include "button.ch"
#include "tbrowse.ch"

FUNCTION TApplyKey( nKey, oBrowse )
   RETURN oBrowse:applyKey( nKey )

PROCEDURE TBAddCol()
   RETURN

PROCEDURE TBBBlock()
   RETURN

PROCEDURE TBClose()
   RETURN

PROCEDURE TBCreate()
   RETURN

PROCEDURE TBDelCol()
   RETURN

PROCEDURE TBDisplay()
   RETURN

PROCEDURE TBEditCell()
   RETURN

PROCEDURE TBFBlock()
   RETURN

PROCEDURE TBGoBot()
   RETURN

PROCEDURE TBGoTop()
   RETURN

PROCEDURE TBInsCol()
   RETURN

PROCEDURE TBModal()
   RETURN

PROCEDURE TBSBlock()
   RETURN

PROCEDURE TBSkip()
   RETURN

#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 'hbhpdf' (PDF generation library (libharu)): contrib/hbhpdf/tests/test.prg. Contains procedures: Main. This file provides graphics and image processing capabilities

[Assistant]
#require "hbhpdf"

PROCEDURE Main()

   ? hb_HPDF_GetErrorString()
   ? hb_HPDF_GetErrorString( NIL )
   ? hb_HPDF_GetErrorString( "a" )
   ? hb_HPDF_GetErrorString( {} )
   ? hb_HPDF_GetErrorString( 100 )
   ? hb_HPDF_GetErrorString( HPDF_ARRAY_ITEM_UNEXPECTED_TYPE )

   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 test program: tests/rddtest/cdxcl53.prg. Provides functions: test_main. This test file tests specific function APIs

[Assistant]
REQUEST dbfcdx
#define _TESTRDD "dbfcdx"
#include "rddtst.prg"

FUNCTION test_main()

RDDTESTC {0,.t.,.t.,.f.}, LOCAL n
RDDTESTF "DBFCDX", {0,.t.,.t.,.f.}, RDDSETDEFAULT()
RDDTESTC {1,.t.,.t.,.f.}, USE "_tst" SHARED
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)
RDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)
RDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)
RDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)
RDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)
RDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)
RDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)
RDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)
RDDTESTC {1,.t.,.f.,.f.}, SET DELETE OFF
RDDTESTC {1,.t.,.t.,.f.}, INDEX on FNUM tag TG_N to "_tst"
RDDTESTC {1,.t.,.t.,.f.}, INDEX on FSTR tag TG_C to "_tst"
RDDTESTF "TG_C", {1,.t.,.t.,.f.}, ORDSETFOCUS()
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)
RDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)
RDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)
RDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)
RDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)
RDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)
RDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)
RDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)
RDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)
RDDTESTF .f., {1,.f.,.t.,.f.}, DBSEEK("", .T.,.F.)
RDDTESTF .f., {1,.f.,.t.,.f.}, DBSEEK("", .T.,.T.)
RDDTESTF .f., {1,.f.,.t.,.f.}, DBSEEK("", .F.,.F.)
RDDTESTF .f., {1,.f.,.t.,.f.}, DBSEEK("", .F.,.T.)
RDDTESTC {1,.f.,.t.,.f.}, SET DELETE OFF
RDDTESTC {15,.f.,.f.,.f.}, for n:=1 to 15                    ; dbappend()                          ; replace FNUM with int((n+2)/3)      ; replace FSTR with chr(FNUM+48)      ; next
RDDTESTF NIL, {15,.f.,.f.,.f.}, dbcommit()
RDDTESTF NIL, {15,.f.,.f.,.f.}, dbunlock()
RDDTESTF "TG_C", {15,.f.,.f.,.f.}, ORDSETFOCUS(1)
RDDTESTF "TG_N", {15,.f.,.f.,.f.}, ORDSETFOCUS()
RDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(0,.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0,.T.,.T.)
RDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(0.5,.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0.5,.T.,.T.)
RDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(1.0,.T.,.F.)
RDDTESTF .t., {3,.f.,.f.,.t.}, DBSEEK(1.0,.T.,.T.)
RDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(2.0,.T.,.F.)
RDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK(2.0,.T.,.T.)
RDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK(2.5,.T.,.F.)
RDDTESTF .f., {6,.f.,.f.,.f.}, DBSEEK(2.5,.T.,.T.)
RDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(5.0,.T.,.F.)
RDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK(5.0,.T.,.T.)
RDDTESTF "TG_N", {15,.f.,.f.,.t.}, ORDSETFOCUS(2)
RDDTESTF "TG_C", {15,.f.,.f.,.t.}, ORDSETFOCUS()
RDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK("", .T.,.F.)
RDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK("", .T.,.T.)
RDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(" ",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(" ",.T.,.T.)
RDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK("0",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("0",.T.,.T.)
RDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK("1",.T.,.F.)
RDDTESTF .t., {3,.f.,.f.,.t.}, DBSEEK("1",.T.,.T.)
RDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK("2",.T.,.F.)
RDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK("2",.T.,.T.)
RDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK("3",.T.,.F.)
RDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK("3",.T.,.T.)
RDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK("4",.T.,.F.)
RDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK("4",.T.,.T.)
RDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK("5",.T.,.F.)
RDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK("5",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("6",.T.,.F.)
RDDTESTF .f., {15,.f.,.f.,.f.}, DBSEEK("6",.T.,.T.)
RDDTESTF NIL, {15,.f.,.f.,.f.}, ORDSCOPE(0,"3")
RDDTESTF NIL, {15,.f.,.f.,.f.}, ORDSCOPE(1,"4")
RDDTESTF "3", {15,.f.,.f.,.f.}, DBORDERINFO(39)
RDDTESTF "4", {15,.f.,.f.,.f.}, DBORDERINFO(40)
RDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK("", .T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("", .T.,.T.)
RDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK(" ",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(" ",.T.,.T.)
RDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK("0",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("0",.T.,.T.)
RDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK("1",.T.,.F.)
RDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK("1",.T.,.T.)
RDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK("2",.T.,.F.)
RDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK("2",.T.,.T.)
RDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK("3",.T.,.F.)
RDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK("3",.T.,.T.)
RDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK("4",.T.,.F.)
RDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK("4",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("5",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("5",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("6",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("6",.T.,.T.)
RDDTESTF "3", {16,.f.,.t.,.f.}, ORDSCOPE(0,"3")
RDDTESTF "4", {16,.f.,.t.,.f.}, ORDSCOPE(1,"2")
RDDTESTF "3", {16,.f.,.t.,.f.}, DBORDERINFO(39)
RDDTESTF "2", {16,.f.,.t.,.f.}, DBORDERINFO(40)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("1",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("1",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("2",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("2",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("3",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("3",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("4",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("4",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, ORDDESCEND()
RDDTESTF .f., {16,.f.,.t.,.f.}, ORDDESCEND(,,.T.)
RDDTESTF .t., {16,.f.,.t.,.f.}, ORDDESCEND()
RDDTESTF "2", {16,.f.,.t.,.f.}, DBORDERINFO(39)
RDDTESTF "3", {16,.f.,.t.,.f.}, DBORDERINFO(40)
RDDTESTF .t., {16,.f.,.t.,.f.}, ORDSCOPE(0,NIL)
RDDTESTF .t., {16,.f.,.t.,.f.}, ORDSCOPE(1,NIL)
RDDTESTF NIL, {16,.f.,.t.,.f.}, DBORDERINFO(39)
RDDTESTF NIL, {16,.f.,.t.,.f.}, DBORDERINFO(40)
RDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK("", .T.,.F.)
RDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK("", .T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(" ",.T.,.F.)
RDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(" ",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("0",.T.,.F.)
RDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK("0",.T.,.T.)
RDDTESTF .t., {3,.f.,.f.,.t.}, DBSEEK("1",.T.,.F.)
RDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK("1",.T.,.T.)
RDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK("2",.T.,.F.)
RDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK("2",.T.,.T.)
RDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK("3",.T.,.F.)
RDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK("3",.T.,.T.)
RDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK("4",.T.,.F.)
RDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK("4",.T.,.T.)
RDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK("5",.T.,.F.)
RDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK("5",.T.,.T.)
RDDTESTF .f., {15,.f.,.f.,.f.}, DBSEEK("6",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("6",.T.,.T.)
RDDTESTF NIL, {16,.f.,.t.,.f.}, ORDSCOPE(0,"4")
RDDTESTF NIL, {16,.f.,.t.,.f.}, ORDSCOPE(1,"3")
RDDTESTF "4", {16,.f.,.t.,.f.}, DBORDERINFO(39)
RDDTESTF "3", {16,.f.,.t.,.f.}, DBORDERINFO(40)
RDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK("", .T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("", .T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(" ",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(" ",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("0",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("0",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("1",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("1",.T.,.T.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("2",.T.,.F.)
RDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK("2",.T.,.T.)
RDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK("3",.T.,.F.)
RDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK("3",.T.,.T.)


[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: include/ord.ch. Defines constants: HB_ORD_CH_, TOPSCOPE, BOTTOMSCOPE. Declares 5 preprocessor commands. Declares 1 preprocessor translations. Defines Harbour internal constants and macros

[Assistant]
#ifndef HB_ORD_CH_
#define HB_ORD_CH_

#define TOPSCOPE           0
#define BOTTOMSCOPE        1

#command SET SCOPETOP TO              => ordScope( TOPSCOPE, nil )
#command SET SCOPETOP TO <x>          => ordScope( TOPSCOPE, <x> )

#command SET SCOPEBOTTOM TO           => ordScope( BOTTOMSCOPE, nil )
#command SET SCOPEBOTTOM TO <x>       => ordScope( BOTTOMSCOPE, <x> )

#command SET SCOPE TO                 => ordScope( TOPSCOPE, nil );
                                       ; ordScope( BOTTOMSCOPE, nil )

#command SET SCOPE TO <x>, <y>        => ordScope( TOPSCOPE, <x> );
                                       ; ordScope( BOTTOMSCOPE, <y> )

#command SET SCOPE TO <x>             => ordScope( TOPSCOPE, <x> );
                                       ; ordScope( BOTTOMSCOPE, <x> )

#command SET SCOPE TO ,<x>            => ordScope( BOTTOMSCOPE, <x> )

#ifdef HB_COMPAT_C53

#xtranslate ORDCOND( [FOR <for>]                             ;
                     [<all:ALL>] [WHILE <while>]             ;
                     [EVAL <eval>] [EVERY <every>]           ;
                     [RECORD <rec>] [NEXT <next>]            ;
                     [<rest:REST>] [<descend: DESCENDING>] ) ;
      => ordCondSet( <"for">, <{for}>,                       ;
                     [<.all.>], <{while}>,                   ;
                     <{eval}>, <every>,                      ;
                     RecNo(), <next>, <rec>,                 ;
                     [<.rest.>], [<.descend.>] )

#endif

#include "dbinfo.ch"

#endif


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

[User] Implement these Harbour functions: Harbour test program: tests/readhrb.prg. Provides functions: DecodeScope. Contains procedures: Main, PrintItem. This test file tests specific function APIs

[Assistant]
#include "fileio.ch"

#define HRB_HEADER      ( hb_BChar( 192 ) + hb_BChar( 72 ) + hb_BChar( 82 ) + hb_BChar( 66 ) )
#define HB_FS_PUBLIC    ( 0x0001 )
#define HB_FS_STATIC    ( 0x0002 )
#define HB_FS_FIRST     ( 0x0004 )
#define HB_FS_INIT      ( 0x0008 )
#define HB_FS_EXIT      ( 0x0010 )
#define HB_FS_MESSAGE   ( 0x0020 )
#define HB_FS_MEMVAR    ( 0x0080 )
#define HB_FS_PCODEFUNC ( 0x0100 )
#define HB_FS_LOCAL     ( 0x0200 )
#define HB_FS_DYNCODE   ( 0x0400 )
#define HB_FS_DEFERRED  ( 0x0800 )
#define HB_FS_FRAME     ( 0x1000 )
#define HB_FS_INITEXIT  ( HB_FS_INIT + HB_FS_EXIT )

STATIC s_aScopes := { ;
   { HB_FS_PUBLIC    , "HB_FS_PUBLIC" }, ;
   { HB_FS_STATIC    , "HB_FS_STATIC" }, ;
   { HB_FS_FIRST     , "HB_FS_FIRST" }, ;
   { HB_FS_INIT      , "HB_FS_INIT" }, ;
   { HB_FS_EXIT      , "HB_FS_EXIT" }, ;
   { HB_FS_MESSAGE   , "HB_FS_MESSAGE" }, ;
   { HB_FS_MEMVAR    , "HB_FS_MEMVAR" }, ;
   { HB_FS_PCODEFUNC , "HB_FS_PCODEFUNC" }, ;
   { HB_FS_LOCAL     , "HB_FS_LOCAL" }, ;
   { HB_FS_DYNCODE   , "HB_FS_DYNCODE" }, ;
   { HB_FS_DEFERRED  , "HB_FS_DEFERRED" }, ;
   { HB_FS_FRAME     , "HB_FS_FRAME" } }

PROCEDURE Main( cFrom )

   LOCAL hFile
   LOCAL cBlock
   LOCAL n, m
   LOCAL nVal
   LOCAL nSymbols
   LOCAL nFuncs
   LOCAL cScope
   LOCAL nLenCount
   LOCAL nIdx
   LOCAL cSymbol

   Set( _SET_ALTERNATE, "readhrb.out" )
   Set( _SET_ALTERNATE, .T. )

   hb_default( @cFrom, "default" )

   cFrom := hb_FNameExtSetDef( cFrom, ".hrb" )

   hFile := FOpen( cFrom )
   IF hFile == F_ERROR
      ? "No such file:", cFrom
   ELSE
      cBlock := FReadStr( hFile, 4 )

      IF !( cBlock == HRB_HEADER )
         ? "Invalid input file detected!"
      ELSE
         FReadStr( hFile, 2 )
         cBlock := FReadStr( hFile, 4 )
         nSymbols := ;
            hb_BCode( hb_BSubStr( cBlock, 1, 1 ) ) + ;
            hb_BCode( hb_BSubStr( cBlock, 2, 1 ) )
         ?? "+--------------------------+------------+---------------------------------+"
         ? "| Symbol Name              |  Type      | Scope                           |"
         ? "+--------------------------+------------+---------------------------------+"

         FOR n := 1 TO nSymbols
            cBlock := FReadStr( hFile, 1 )
            cSymbol := ""
            DO WHILE hb_BCode( cBlock ) != 0
               cSymbol += cBlock
               cBlock := FReadStr( hFile, 1 )
            ENDDO
            cScope := FReadStr( hFile, 1 )
            cBlock := FReadStr( hFile, 1 )
            nIdx   := hb_BCode( cBlock ) + 1
            PrintItem( cSymbol, nIdx, hb_BCode( cScope ) )
         NEXT
         ? "+--------------------------+------------+---------------------------------+"
         ? " ", hb_ntos( nSymbols ), "SYMBOL(s) found."
         ?

         ACCEPT "Do you want do list all pcode values? (y/N) " TO m

         IF m $ "Yy"
            ?
            cBlock := FReadStr( hFile, 4 )
            nFuncs := ;
               hb_BCode( hb_BSubStr( cBlock, 1, 1 ) ) + ;
               hb_BCode( hb_BSubStr( cBlock, 2, 1 ) )
               cSymbol := ""
               DO WHILE hb_BCode( cBlock ) != 0
                  cSymbol += cBlock
                  cBlock := FReadStr( hFile, 1 )
               ENDDO
               cBlock := FReadStr( hFile, 4 )
               nLenCount := ;
                  hb_BCode( hb_BSubStr( cBlock, 1, 1 ) ) + ;
                  hb_BCode( hb_BSubStr( cBlock, 2, 1 ) )
               ? "Symbol:", cSymbol
               ? "Length:", hb_ntos( nLenCount ), "byte(s)"
               ? "PCode: "

               FOR m := 1 TO nLenCount
                  cBlock := FReadStr( hFile, 1 )
                  nVal   := hb_BCode( cBlock )
                  ?? hb_NumToHex( nVal, 2 )
                  IF nVal > 32 .AND. nVal < 128
                     ?? "(" + cBlock + ")"
                  ENDIF
                  IF m != nLenCount
                     ?? ","
                  ENDIF
               NEXT
               ? "----"
            NEXT
         ENDIF
      ENDIF
      FClose( hFile )
   ENDIF
   Set( _SET_ALTERNATE, .F. )

   RETURN

PROCEDURE PrintItem( cSymbol, nType, nScope )

   LOCAL aTypes := { "NOLINK", "FUNC", "EXTERN", "SYM_DEF" }

   ? "| " + PadR( cSymbol, 25 ) + "| " + ;
      PadR( hb_ntos( nType - 1 ) + " (" + aTypes[ nType ] + ")", 11 ) + "| " + ;
      PadR( DecodeScope( nScope ), 32 ) + "|"

   RETURN

FUNCTION DecodeScope( nScope )

   LOCAL cScope := ""
   LOCAL i

   FOR i := 1 TO Len( s_aScopes )
      IF hb_bitAnd( nScope, s_aScopes[ i ][ 1 ] ) == s_aScopes[ i ][ 1 ]
         cScope += "+" + s_aScopes[ i ][ 2 ]
      ENDIF
   NEXT

   RETURN hb_NumToHex( nScope, 2 ) + iif( Empty( cScope ), "", " (" + SubStr( cScope, 2 ) + ")" )


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

[User] Create Harbour preprocessor definitions: Harbour Runtime Library file: src/debug/dbgtobj.prg. Defines classes: HBDbObject. Provides functions: __dbgObject, __dbgObjGetValue, __dbgObjSetValue. This file provides utility functions

[Assistant]
#pragma -b-

#define HB_CLS_NOTOBJECT
#include "hbclass.ch"

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

#define OMSG_NAME       1
#define OMSG_VALUE      2
#define OMSG_EDIT       3

CREATE CLASS HBDbObject

   VAR aWindows       INIT {}
   VAR Theobj
   VAR objname
   VAR nCurWindow     INIT 0
   VAR pItems         INIT {}
   VAR ArrayIndex     INIT 1
   VAR lEditable

   METHOD New( oObject, cVarName, lEditable )
   METHOD addWindows( nRow )
   METHOD doGet( oBrowse )
   METHOD SetsKeyPressed( nKey, oBrwSets )

ENDCLASS

METHOD New( oObject, cVarName, lEditable ) CLASS HBDbObject

   LOCAL cMsg, cMsgAcc
   LOCAL aMessages, aMethods
   LOCAL xValue

   __dbgSetGo( __dbg():pInfo )

   aMessages := oObject:classSel()
   ASort( aMessages,,, {| x, y | x + Chr( 0 ) < y + Chr( 0 ) } )
   aMethods := {}
   FOR EACH cMsg IN aMessages
      IF hb_LeftEq( cMsg, "_" ) .AND. ;
         hb_AScan( aMessages, cMsgAcc := SubStr( cMsg, 2 ),,, .T. ) > 0
         xValue := __dbgObjGetValue( oObject, cMsgAcc )
         AAdd( ::pItems, { cMsgAcc, xValue, .T. } )
      ELSEIF hb_AScan( aMessages, "_" + cMsg,,, .T. ) == 0
         AAdd( aMethods, cMsg )
      ENDIF
   NEXT
   FOR EACH cMsg IN aMethods
      AAdd( ::pItems, { Lower( cMsg ), "Method", .F. } )
   NEXT

   ::objname := cVarName
   ::TheObj := oObject
   ::lEditable := hb_defaultValue( lEditable, .T. )

   ::addWindows()

   RETURN Self

METHOD addWindows( nRow ) CLASS HBDbObject

   LOCAL oBrwSets
   LOCAL nSize := Len( ::pItems )
   LOCAL oWndSets
   LOCAL oCol
   LOCAL nMaxLen

   IF nSize < MaxRow() - 2
      IF HB_ISNUMERIC( nRow )
         oWndSets := HBDbWindow():New( nRow, 5, iif( nRow + nSize + 1 < MaxRow() - 2, nRow + nSize + 1, MaxRow() - 2 ), MaxCol() - 5, ;
            ::objname + " is of class: " + ::TheObj:ClassName(), "N/W" )
      ELSE
         oWndSets := HBDbWindow():New( 1, 5, 2 + nSize, MaxCol() - 5, ;
            ::objname + " is of class: " + ::TheObj:ClassName(), "N/W" )
      ENDIF
   ELSE
      oWndSets := HBDbWindow():New( 1, 5, MaxRow() - 2, MaxCol() - 5, ;
         ::objname + " is of class: " + ::TheObj:ClassName(), "N/W" )
   ENDIF

   ::nCurWindow++
   oWndSets:lFocused := .T.
   AAdd( ::aWindows, oWndSets )

   oBrwSets := HBDbBrowser():New( oWndSets:nTop + 1, oWndSets:nLeft + 1, oWndSets:nBottom - 1, oWndSets:nRight - 1 )

   oBrwSets:ColorSpec := __dbg():ClrModal()
   oBrwSets:GoTopBlock := {|| ::Arrayindex := 1 }
   oBrwSets:GoBottomBlock := {|| ::arrayindex := Len( ::pItems ) }
   oBrwSets:SkipBlock := {| nSkip, nPos | nPos := ::arrayindex, ;
                                          ::arrayindex := Max( 1, Min( ::arrayindex + nSkip, Len( ::pItems ) ) ), ;
                                          ::arrayindex - nPos }

   nMaxLen := 0
   AEval( ::pItems, {| x | nMaxLen := Max( nMaxLen, Len( x[ OMSG_NAME ] ) ) } )
   oBrwSets:AddColumn( oCol := HBDbColumnNew( "", {|| ::pItems[ ::arrayindex ][ OMSG_NAME ] } ) )
   oCol:width := nMaxLen
   oCol:DefColor := { 1, 2 }
   oBrwSets:Freeze := 1

   oBrwSets:AddColumn( oCol := HBDbColumnNew( "", {|| iif( ! ::pItems[ ::ArrayIndex ][ OMSG_EDIT ], ;
      ::pItems[ ::ArrayIndex ][ OMSG_VALUE ], ;
      __dbgValToExp( __dbgObjGetValue( ::TheObj, ::pItems[ ::arrayindex ][ OMSG_NAME ] ) ) ) } ) )

   oCol:DefColor := { 1, 3 }
   oCol:width := oWndSets:nRight - oWndSets:nLeft - nMaxLen - 2
   oBrwSets:colPos := 2

   ::aWindows[ ::nCurWindow ]:bPainted    := {|| oBrwSets:ForceStable() }
   ::aWindows[ ::nCurWindow ]:bKeyPressed := {| nKey | ::SetsKeyPressed( nKey, oBrwSets ) }
   ::aWindows[ ::nCurwindow ]:cCaption := ::objname + " is of class: " + ::TheObj:ClassName()

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

   RETURN Self

METHOD PROCEDURE doGet( oBrowse ) CLASS HBDbObject

   LOCAL oErr
   LOCAL cValue
   LOCAL lCanAcc
   LOCAL aItemRef

   oBrowse:forceStable()

   aItemRef := ::pItems[ ::ArrayIndex ]
   cValue := __dbgObjGetValue( ::TheObj, aItemRef[ OMSG_NAME ], @lCanAcc )
   IF ! lCanAcc
      __dbgAlert( cValue )
      RETURN
   ENDIF
   cValue := __dbgValToExp( cValue )

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

   RETURN

METHOD PROCEDURE SetsKeyPressed( nKey, oBrwSets ) CLASS HBDbObject

   LOCAL aItemRef

   SWITCH nKey
   CASE K_UP
      oBrwSets:Up()
      EXIT

   CASE K_DOWN
      oBrwSets:Down()
      EXIT

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

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

   CASE K_PGDN
      oBrwSets:pageDown()
      EXIT

   CASE K_PGUP
      oBrwSets:PageUp()
      EXIT

   CASE K_ENTER

      aItemRef := ::pItems[ ::ArrayIndex ]
      DO CASE
      CASE HB_ISARRAY( aItemRef[ OMSG_VALUE ] )
         IF Len( aItemRef[ OMSG_VALUE ] ) > 0
            HBDbArray():New( aItemRef[ OMSG_VALUE ], aItemRef[ OMSG_NAME ] )
         ENDIF
      CASE HB_ISHASH( aItemRef[ OMSG_VALUE ] )
         IF Len( aItemRef[ OMSG_VALUE ] ) > 0
            HBDbHash():New( aItemRef[ OMSG_VALUE ], aItemRef[ OMSG_NAME ] )
         ENDIF
      CASE HB_ISOBJECT( aItemRef[ OMSG_VALUE ] )
         HBDbObject():New( aItemRef[ OMSG_VALUE ], aItemRef[ OMSG_NAME ] )
      CASE ! aItemRef[ OMSG_EDIT ] .OR. ;
           HB_ISBLOCK( aItemRef[ OMSG_VALUE ] ) .OR. ;
           HB_ISPOINTER( aItemRef[ OMSG_VALUE ] ) .OR. ;
           ! ::lEditable
         __dbgAlert( "Value cannot be edited" )
      OTHERWISE
         oBrwSets:RefreshCurrent()
         ::doGet( oBrwSets )
         oBrwSets:RefreshCurrent()
         oBrwSets:ForceStable()
      ENDCASE

   ENDSWITCH

   oBrwSets:ForceStable()

   RETURN

FUNCTION __dbgObject( oObject, cVarName, lEditable )
   RETURN HBDbObject():New( oObject, cVarName, lEditable )

STATIC FUNCTION __dbgObjGetValue( oObject, cVar, lCanAcc )

   LOCAL nProcLevel := __dbg():nProcLevel
   LOCAL xResult
   LOCAL oErr

   BEGIN SEQUENCE WITH {|| Break() }
      xResult := __dbgSendMsg( nProcLevel, oObject, cVar )
      lCanAcc := .T.
   RECOVER
      BEGIN SEQUENCE WITH __BreakBlock()

         xResult := __dbgSendMsg( 0, oObject, cVar )
         lCanAcc := .T.
      RECOVER USING oErr
         xResult := oErr:description
         lCanAcc := .F.
      END SEQUENCE
   END SEQUENCE

   RETURN xResult

STATIC FUNCTION __dbgObjSetValue( oObject, cVar, xValue )

   LOCAL nProcLevel := __dbg():nProcLevel
   LOCAL oErr

   BEGIN SEQUENCE WITH {|| Break() }
      __dbgSendMsg( nProcLevel, oObject, "_" + cVar, xValue )
   RECOVER
      BEGIN SEQUENCE WITH __BreakBlock()

         __dbgSendMsg( 0, oObject, "_" + cVar, xValue )
      RECOVER USING oErr
         __dbgAlert( oErr:description )
      END SEQUENCE
   END SEQUENCE

   RETURN xValue


[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 'hbzebra' (Barcode generation library): contrib/hbzebra/tests/bmp.prg. Provides functions: hb_zebra_draw_bmp. Contains procedures: Main, DrawBarcode. This file provides graphics and image processing capabilities

[Assistant]
#require "hbzebra"
#require "hbbmp"

#define WIDTH     1

REQUEST HB_GT_CGI_DEFAULT

PROCEDURE Main()

   DrawBarcode( WIDTH, "EAN13",      "477012345678" )
   DrawBarcode( WIDTH, "EAN8",       "1234567" )
   DrawBarcode( WIDTH, "UPCA",       "01234567891" )
   DrawBarcode( WIDTH, "UPCE",       "123456" )
   DrawBarcode( WIDTH, "CODE39",     "ABC123" )
   DrawBarcode( WIDTH, "CODE39",     "ABC123", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( WIDTH, "ITF",        "12345678901", HB_ZEBRA_FLAG_CHECKSUM )
   DrawBarcode( WIDTH, "MSI",        "1234567", HB_ZEBRA_FLAG_CHECKSUM )
   DrawBarcode( WIDTH, "CODABAR",    "40156", HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( WIDTH, "CODE93",     "ABC-123" )
   DrawBarcode( WIDTH, "CODE11",     "1234567890", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( WIDTH, "CODE128",    "Code 128" )
   DrawBarcode( WIDTH, "PDF417",     "Hello, World of Harbour!!! It's 2D barcode PDF417 :)" )
   DrawBarcode( WIDTH, "DATAMATRIX", "Hello, World of Harbour!!! It's 2D barcode DataMatrix :)" )
   DrawBarcode( WIDTH, "QRCODE",     "https:

   ?

   RETURN

STATIC PROCEDURE DrawBarcode( nLineWidth, cType, cCode, nFlags )

   LOCAL hZebra, cFile, cBitMap, pBMP, ;
         nLineHeight, nX, nY, nWidth, nHeight, nDepth, nAlign, nColor

   SWITCH cType
   CASE "EAN13"      ; hZebra := hb_zebra_create_ean13( cCode, nFlags )   ; EXIT
   CASE "EAN8"       ; hZebra := hb_zebra_create_ean8( cCode, nFlags )    ; EXIT
   CASE "UPCA"       ; hZebra := hb_zebra_create_upca( cCode, nFlags )    ; EXIT
   CASE "UPCE"       ; hZebra := hb_zebra_create_upce( cCode, nFlags )    ; EXIT
   CASE "CODE39"     ; hZebra := hb_zebra_create_code39( cCode, nFlags )  ; EXIT
   CASE "ITF"        ; hZebra := hb_zebra_create_itf( cCode, nFlags )     ; EXIT
   CASE "MSI"        ; hZebra := hb_zebra_create_msi( cCode, nFlags )     ; EXIT
   CASE "CODABAR"    ; hZebra := hb_zebra_create_codabar( cCode, nFlags ) ; EXIT
   CASE "CODE93"     ; hZebra := hb_zebra_create_code93( cCode, nFlags )  ; EXIT
   CASE "CODE11"     ; hZebra := hb_zebra_create_code11( cCode, nFlags )  ; EXIT
   CASE "CODE128"    ; hZebra := hb_zebra_create_code128( cCode, nFlags ) ; EXIT
   CASE "PDF417"     ; hZebra := hb_zebra_create_pdf417( cCode, nFlags ); nLineHeight := nLineWidth
   CASE "DATAMATRIX" ; hZebra := hb_zebra_create_datamatrix( cCode, nFlags ); nLineHeight := nLineWidth ; EXIT
   CASE "QRCODE"     ; hZebra := hb_zebra_create_qrcode( cCode, nFlags ); nLineHeight := nLineWidth ; EXIT
   ENDSWITCH

   IF hZebra != NIL
      IF hb_zebra_geterror( hZebra ) == 0

         IF nLineHeight == NIL
            nLineHeight := nLineWidth
         ? cType, "code width", hb_ntos( nWidth ), "height", hb_ntos( nHeight )
         IF Empty( pBMP := hb_bmp_new( nWidth, nHeight, nDepth ) )
            ? "Cannot create BMP image"
         ELSE

            nColor := hb_bmp_color( pBMP, 255, 255, 255 )
            hb_bmp_rect( pBMP, 0, 0, nWidth, nHeight, nColor )

            nColor := hb_bmp_color( pBMP, 0, 0, 0 )
            ? "Building BMP with", cType, "code for vale:", hb_zebra_getcode( hZebra )
            hb_zebra_draw_bmp( hZebra, pBMP, nColor, nX, nY, nLineWidth, nLineHeight )
            cFile := Lower( cType ) + ".bmp"
            ? "Creating BMP file:", cFile
            IF ! hb_bmp_save( pBMP, cFile )
               ? "Cannot save BMP to file:", cFile
            ENDIF

            pBMP := NIL
         ENDIF

         cBitMap := hb_zebra_getbitmap( hZebra, nAlign, .T., @nWidth, @nHeight, nLineWidth, nLineHeight, nX )
         pBMP := hb_bmp_frombitmap( cBitMap, nAlign, nWidth, nHeight, nDepth, , ,  )
         cFile := Lower( cType ) + "b.bmp"
         ? "Creating BMP file:", cFile
         IF ! hb_bmp_save( pBMP, cFile )
            ? "Cannot save BMP to file:", cFile
         ENDIF

         pBMP := NIL

      ELSE
         ? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
      ENDIF
      hb_zebra_destroy( hZebra )
   ELSE
      ? "Invalid barcode type", cType
   ENDIF
   ?

   RETURN

STATIC FUNCTION hb_zebra_draw_bmp( hZebra, pBMP, nColor, ... )

   IF hb_zebra_geterror( hZebra ) != 0
      RETURN HB_ZEBRA_ERROR_INVALIDZEBRA
   ENDIF

   RETURN hb_zebra_draw( hZebra, {| x, y, w, h | hb_bmp_rect( pBMP, x, y, w, h, nColor ) }, ... )


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

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

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

[Assistant]
PROCEDURE Main()

   ? ">" + hb_SHA1( "hello" ) + "<"
   ? ">" + hb_SHA1( "hello", .F. ) + "<"
   ? ">" + hb_SHA1( "hello", .T. ) + "<"

   ? ">" + hb_HMAC_SHA1( "hello", "key" ) + "<"
   ? ">" + hb_HMAC_SHA1( "hello", "key", .F. ) + "<"
   ? ">" + hb_HMAC_SHA1( "hello", "key", .T. ) + "<"

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

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

PROCEDURE Main()

#if defined( __HBSCRIPT__HBSHELL )
   #if defined( __PLATFORM__WINDOWS )
      hbshell_gtSelect( "GTWVT" )
   #elif defined( __PLATFORM__UNIX )
      hbshell_gtSelect( "GTXWC" )
   #endif
#endif

   IF hb_gtInfo( HB_GTI_ISGRAPHIC )
      hb_gtInfo( HB_GTI_FONTNAME, "Lucida Console" )
   ELSE
      ? "launch me under a graphical GT"
      QUIT
   ENDIF

   ? "GT" + hb_gtVersion() + " test"

   ?  hb_gtInfo( HB_GTI_ISFULLSCREEN, .T. ), "we should be on full screen"
   WAIT
   ?  hb_gtInfo( HB_GTI_ISFULLSCREEN, .F. ), "we should be windowed"
   ?  hb_gtInfo( HB_GTI_ALTENTER, .T. ), "<Alt+Enter> is now enabled, try it"
   DO WHILE Inkey( 0 ) != K_ESC
      ? Row()
   ENDDO

   RETURN


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

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

Harbour contribution module 'rddmisc' (): contrib/rddmisc/smtcdx.prg. Provides functions: SMTCDX_GETFUNCTABLE. Contains procedures: SMTCDX_INIT. This file handles database operations

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

REQUEST DBFCDX
REQUEST DBFFPT

ANNOUNCE SMTCDX

FUNCTION SMTCDX_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, pSuperRddID )
   RETURN USRRDD_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, ;
      "DBFCDX", {}, pSuperRddID )

INIT PROCEDURE SMTCDX_INIT()

   rddRegister( "SMTCDX", RDT_FULL )
   rddInfo( RDDI_MEMOTYPE, DB_MEMO_SMT, "SMTCDX" )

   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 'hbsqlit3' (SQLite3 database client library): contrib/hbsqlit3/tests/backup.prg. Provides functions: CallBack, cErrorMsg, PrepareDB. Contains procedures: init_trace, Main. This file handles database operations

[Assistant]
#require "hbsqlit3"

#include "fileio.ch"

PROCEDURE init_trace( pDb, cPrefix )
   LOCAL hFile
   IF sqlite3_libversion_number() < 3014000
      sqlite3_trace( pDb, .T., cPrefix + ".log" )
   ELSE
      hFile := FOpen( cPrefix + ".log", FO_READWRITE + HB_FO_CREAT )
      FSeek( hFile, 0, FS_END )
      sqlite3_trace_v2( pDb, SQLITE_TRACE_STMT + SQLITE_TRACE_CLOSE, {| nMask, p, x |
         IF nMask == SQLITE_TRACE_STMT
            IF hb_LeftEq( x, "--" )
               FWrite( hFile, x + hb_eol() )
            ELSE
               FWrite( hFile, sqlite3_expanded_sql( p ) + hb_eol() )
            ENDIF
         ELSEIF nMask == SQLITE_TRACE_CLOSE
            FWrite( hFile, "Closing the database connection: " + sqlite3_db_filename( p, "main" ) + hb_eol() )
         ENDIF
         RETURN 0
      } )
   ENDIF
   RETURN

PROCEDURE Main()

   LOCAL cFileSource := ":memory:", cFileDest := "backup.db", cSQLTEXT
   LOCAL pDbSource, pDbDest, pBackup, cb, nDbFlags

   ? "Using SQLite3 version " + hb_NToS( sqlite3_libversion_number() )

   IF sqlite3_libversion_number() < 3006011
      ErrorLevel( 1 )
      RETURN
   ENDIF

   IF Empty( pDbSource := PrepareDB( cFileSource ) )
      ErrorLevel( 1 )
      RETURN
   ENDIF

   nDbFlags := SQLITE_OPEN_CREATE + SQLITE_OPEN_READWRITE + ;
      SQLITE_OPEN_EXCLUSIVE
   pDbDest := sqlite3_open_v2( cFileDest, nDbFlags )

   IF Empty( pDbDest )
      ? "Can't open database : ", cFileDest
      ErrorLevel( 1 )
      RETURN
   ENDIF

   init_trace( pDbDest, "backup" )

   pBackup := sqlite3_backup_init( pDbDest, "main", pDbSource, "main" )
   IF Empty( pBackup )
      ? "Can't initialize backup"
      ErrorLevel( 1 )
      RETURN
   ELSE
      ? "Start backup.."
   ENDIF

   IF sqlite3_backup_step( pBackup, -1 ) == SQLITE_DONE
      ? "Backup successful."
   ENDIF

   sqlite3_backup_finish( pBackup )

   pDbSource := NIL

   ?
   ? cSQLTEXT := "SELECT * FROM main.person WHERE age BETWEEN 20 AND 40"
   cb := @CallBack()
   ? cErrorMsg( sqlite3_exec( pDbDest, cSQLTEXT, cb ) )

   pDbDest := NIL

   sqlite3_sleep( 3000 )

   RETURN

FUNCTION CallBack( nColCount, aValue, aColName )

   LOCAL nI
   LOCAL oldColor := SetColor( "G/N" )

   FOR nI := 1 TO nColCount
      ? PadR( aColName[ nI ], 5 ), " == ", aValue[ nI ]
   NEXT

   SetColor( oldColor )

   RETURN 0

STATIC FUNCTION cErrorMsg( nError, lShortMsg )

   hb_default( @lShortMsg, .T. )

   RETURN iif( lShortMsg, hb_sqlite3_errstr_short( nError ), sqlite3_errstr( nError ) )

STATIC FUNCTION PrepareDB( cFile )

   LOCAL cSQLTEXT
   LOCAL pDb, pStmt
   LOCAL hPerson := { ;
      "Bob" => 52, ;
      "Fred" => 32, ;
      "Sasha" => 17, ;
      "Andy" => 20, ;
      "Ivet" => 28 ;
      }, enum

   pDb := sqlite3_open( cFile, .T. )
   IF Empty( pDb )
      ? "Can't open/create database : ", cFile

      RETURN NIL
   ENDIF

   init_trace( pDb, "backup" )

   cSQLTEXT := "CREATE TABLE person( name TEXT, age INTEGER )"
   IF sqlite3_exec( pDb, cSQLTEXT ) != SQLITE_OK
      ? "Can't create table : person"
      pDb := NIL

      RETURN NIL
   ENDIF

   cSQLTEXT := "INSERT INTO person( name, age ) VALUES( :name, :age )"
   pStmt := sqlite3_prepare( pDb, cSQLTEXT )
   IF Empty( pStmt )
      ? "Can't prepare statement : ", cSQLTEXT
      pDb := NIL

      RETURN NIL
   ENDIF

   FOR EACH enum IN hPerson
      sqlite3_reset( pStmt )
      sqlite3_bind_text( pStmt, 1, enum:__enumKey() )
      sqlite3_bind_int( pStmt, 2, enum:__enumValue() )
      sqlite3_step( pStmt )
   NEXT

   sqlite3_clear_bindings( pStmt )
   sqlite3_finalize( pStmt )

   RETURN pDb


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

[Assistant]
PROCEDURE Main()

   LOCAL start := Seconds(), stop

   ? "start   ", start
   Tone( 440, 9.1 )
   Tone( 880, 9.1 )
   Tone( 440, 9.1 )
   stop := Seconds()
   ? "stop    ", stop
   ? "duration", ( stop - start ), "(should be close to 1.5)"

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

[Assistant]
PROCEDURE Main()

   LOCAL oForm := TForm():New()
   LOCAL oSecond

   ? "What's the default oForm and calculate area"
   ? hb_ValToExp( oForm )
   ? oForm:CalcArea()
   ? "Set nTop to 5 and recalculate"
   oForm:nTop := 5
   ? hb_ValToExp( oForm )
   ? oForm:CalcArea()

   ? "Create a new instance and calculate area"
   oSecond := TForm():New()
   ? hb_ValToExp( oSecond )
   ? oSecond:CalcArea()

   RETURN

FUNCTION TForm()

   STATIC s_oClass

   IF s_oClass == NIL
      s_oClass := HBClass():New( "TFORM" )

      s_oClass:AddData( "cName" )
      s_oClass:AddData( "nTop"   , 10 )
      s_oClass:AddData( "nLeft"  , 10 )
      s_oClass:AddData( "nBottom", 20 )
      s_oClass:AddData( "nRight" , 40 )

      s_oClass:AddMethod( "New",  @New() )
      s_oClass:AddMethod( "Show", @Show() )
      s_oClass:AddInline( "CalcArea", ;
         {| self | ( ::nRight - ::nLeft )
   ? "lets show a form from here :-)"

   RETURN NIL


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

[User] Implement these Harbour functions: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/daytobow.prg. Provides functions: ft_DayToBoW. This file provides legacy compatibility functions

[Assistant]
FUNCTION ft_DayToBoW( dGivenDate )

   LOCAL nRetVal, nDOW_Start

   nDOW_Start := ft_DateCnfg()[ 2 ]

   IF ! HB_ISDATE( dGivenDate )
      dGivenDate := Date()
   ENDIF

   nRetVal := DoW( dGivenDate ) - nDOW_Start
   IF nRetVal < 0
      nRetVal += 7
   ENDIF

   RETURN nRetVal


[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:

Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/win32prn.ch. Defines 10 constants including: _WIN32PRN_CH, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS. Defines error handling constants and codes

[Assistant]
#ifndef _WIN32PRN_CH
#define _WIN32PRN_CH

#include "hbwin.ch"

#define HKEY_CLASSES_ROOT           WIN_HKEY_CLASSES_ROOT
#define HKEY_CURRENT_USER           WIN_HKEY_CURRENT_USER
#define HKEY_LOCAL_MACHINE          WIN_HKEY_LOCAL_MACHINE
#define HKEY_USERS                  WIN_HKEY_USERS
#define HKEY_PERFORMANCE_DATA       WIN_HKEY_PERFORMANCE_DATA
#define HKEY_CURRENT_CONFIG         WIN_HKEY_CURRENT_CONFIG
#define HKEY_DYN_DATA               WIN_HKEY_DYN_DATA

#define CBR_110                     WIN_CBR_110
#define CBR_300                     WIN_CBR_300
#define CBR_600                     WIN_CBR_600
#define CBR_1200                    WIN_CBR_1200
#define CBR_2400                    WIN_CBR_2400
#define CBR_4800                    WIN_CBR_4800
#define CBR_9600                    WIN_CBR_9600
#define CBR_14400                   WIN_CBR_14400
#define CBR_19200                   WIN_CBR_19200
#define CBR_38400                   WIN_CBR_38400
#define CBR_56000                   WIN_CBR_56000
#define CBR_57600                   WIN_CBR_57600
#define CBR_115200                  WIN_CBR_115200
#define CBR_128000                  WIN_CBR_128000
#define CBR_256000                  WIN_CBR_256000

#define NOPARITY                    WIN_NOPARITY
#define ODDPARITY                   WIN_ODDPARITY
#define EVENPARITY                  WIN_EVENPARITY
#define MARKPARITY                  WIN_MARKPARITY
#define SPACEPARITY                 WIN_SPACEPARITY

#define ONESTOPBIT                  WIN_ONESTOPBIT
#define ONE5STOPBITS                WIN_ONE5STOPBITS
#define TWOSTOPBITS                 WIN_TWOSTOPBITS

#define DTR_CONTROL_DISABLE         WIN_DTR_CONTROL_DISABLE
#define DTR_CONTROL_ENABLE          WIN_DTR_CONTROL_ENABLE
#define DTR_CONTROL_HANDSHAKE       WIN_DTR_CONTROL_HANDSHAKE

#define RTS_CONTROL_DISABLE         WIN_RTS_CONTROL_DISABLE
#define RTS_CONTROL_ENABLE          WIN_RTS_CONTROL_ENABLE
#define RTS_CONTROL_HANDSHAKE       WIN_RTS_CONTROL_HANDSHAKE
#define RTS_CONTROL_TOGGLE          WIN_RTS_CONTROL_TOGGLE

#define FORM_LETTER                 WIN_DMPAPER_LETTER
#define FORM_A4                     WIN_DMPAPER_A4
#define FORM_CUSTOM                 WIN_DMPAPER_USER

#define PS_SOLID                    WIN_PS_SOLID

#define RGB( nR, nG, nB )           WIN_RGB( nR, nG, nB )

#define RGB_BLACK                   HB_WIN_RGB_BLACK
#define RGB_BLUE                    HB_WIN_RGB_BLUE
#define RGB_GREEN                   HB_WIN_RGB_GREEN
#define RGB_CYAN                    HB_WIN_RGB_CYAN
#define RGB_RED                     HB_WIN_RGB_RED
#define RGB_MAGENTA                 HB_WIN_RGB_MAGENTA
#define RGB_BROWN                   HB_WIN_RGB_YELLOW
#define RGB_WHITE                   HB_WIN_RGB_WHITE

#define MM_TEXT                     WIN_MM_TEXT
#define MM_LOMETRIC                 WIN_MM_LOMETRIC
#define MM_HIMETRIC                 WIN_MM_HIMETRIC
#define MM_LOENGLISH                WIN_MM_LOENGLISH
#define MM_HIENGLISH                WIN_MM_HIENGLISH

#define FW_DONTCARE                 WIN_FW_DONTCARE
#define FW_THIN                     WIN_FW_THIN
#define FW_EXTRALIGHT               WIN_FW_EXTRALIGHT
#define FW_ULTRALIGHT               WIN_FW_ULTRALIGHT
#define FW_LIGHT                    WIN_FW_LIGHT
#define FW_NORMAL                   WIN_FW_NORMAL
#define FW_REGULAR                  WIN_FW_REGULAR
#define FW_MEDIUM                   WIN_FW_MEDIUM
#define FW_SEMIBOLD                 WIN_FW_SEMIBOLD
#define FW_DEMIBOLD                 WIN_FW_DEMIBOLD
#define FW_BOLD                     WIN_FW_BOLD
#define FW_EXTRABOLD                WIN_FW_EXTRABOLD
#define FW_ULTRABOLD                WIN_FW_ULTRABOLD
#define FW_HEAVY                    WIN_FW_HEAVY
#define FW_BLACK                    WIN_FW_BLACK

#define TA_NOUPDATECP               WIN_TA_NOUPDATECP
#define TA_UPDATECP                 WIN_TA_UPDATECP
#define TA_LEFT                     WIN_TA_LEFT
#define TA_RIGHT                    WIN_TA_RIGHT
#define TA_CENTER                   WIN_TA_CENTER
#define TA_TOP                      WIN_TA_TOP
#define TA_BOTTOM                   WIN_TA_BOTTOM
#define TA_BASELINE                 WIN_TA_BASELINE

#define HORZSIZE                    WIN_HORZSIZE
#define VERTSIZE                    WIN_VERTSIZE
#define HORZRES                     WIN_HORZRES
#define VERTRES                     WIN_VERTRES
#define NUMBRUSHES                  WIN_NUMBRUSHES
#define NUMPENS                     WIN_NUMPENS
#define NUMFONTS                    WIN_NUMFONTS
#define NUMCOLORS                   WIN_NUMCOLORS
#define RASTERCAPS                  WIN_RASTERCAPS
#define LOGPIXELSX                  WIN_LOGPIXELSX
#define LOGPIXELSY                  WIN_LOGPIXELSY
#define PHYSICALWIDTH               WIN_PHYSICALWIDTH
#define PHYSICALHEIGHT              WIN_PHYSICALHEIGHT
#define PHYSICALOFFSETX             WIN_PHYSICALOFFSETX
#define PHYSICALOFFSETY             WIN_PHYSICALOFFSETY
#define SCALINGFACTORX              WIN_SCALINGFACTORX
#define SCALINGFACTORY              WIN_SCALINGFACTORY

#define DMBIN_UPPER                 WIN_DMBIN_UPPER
#define DMBIN_ONLYONE               WIN_DMBIN_ONLYONE
#define DMBIN_LOWER                 WIN_DMBIN_LOWER
#define DMBIN_MIDDLE                WIN_DMBIN_MIDDLE
#define DMBIN_MANUAL                WIN_DMBIN_MANUAL
#define DMBIN_ENVELOPE              WIN_DMBIN_ENVELOPE
#define DMBIN_ENVMANUAL             WIN_DMBIN_ENVMANUAL
#define DMBIN_AUTO                  WIN_DMBIN_AUTO
#define DMBIN_TRACTOR               WIN_DMBIN_TRACTOR
#define DMBIN_SMALLFMT              WIN_DMBIN_SMALLFMT
#define DMBIN_LARGEFMT              WIN_DMBIN_LARGEFMT
#define DMBIN_LARGECAPACITY         WIN_DMBIN_LARGECAPACITY
#define DMBIN_CASSETTE              WIN_DMBIN_CASSETTE
#define DMBIN_FORMSOURCE            WIN_DMBIN_FORMSOURCE
#define DMBIN_FIRST                 WIN_DMBIN_FIRST
#define DMBIN_LAST                  WIN_DMBIN_LAST

#define DMRES_DRAFT                 WIN_DMRES_DRAFT
#define DMRES_LOW                   WIN_DMRES_LOW
#define DMRES_MEDIUM                WIN_DMRES_MEDIUM
#define DMRES_HIGH                  WIN_DMRES_HIGH

#define DMDUP_SIMPLEX               WIN_DMDUP_SIMPLEX
#define DMDUP_VERTICAL              WIN_DMDUP_VERTICAL
#define DMDUP_HORIZONTAL            WIN_DMDUP_HORIZONTAL

#define ANSI_CHARSET                WIN_ANSI_CHARSET
#define DEFAULT_CHARSET             WIN_DEFAULT_CHARSET
#define SYMBOL_CHARSET              WIN_SYMBOL_CHARSET
#define MAC_CHARSET                 WIN_MAC_CHARSET
#define SHIFTJIS_CHARSET            WIN_SHIFTJIS_CHARSET
#define HANGEUL_CHARSET             WIN_HANGEUL_CHARSET
#define HANGUL_CHARSET              WIN_HANGUL_CHARSET
#define JOHAB_CHARSET               WIN_JOHAB_CHARSET
#define GB2312_CHARSET              WIN_GB2312_CHARSET
#define CHINESEBIG5_CHARSET         WIN_CHINESEBIG5_CHARSET
#define GREEK_CHARSET               WIN_GREEK_CHARSET
#define TURKISH_CHARSET             WIN_TURKISH_CHARSET
#define VIETNAMESE_CHARSET          WIN_VIETNAMESE_CHARSET
#define HEBREW_CHARSET              WIN_HEBREW_CHARSET
#define ARABIC_CHARSET              WIN_ARABIC_CHARSET
#define BALTIC_CHARSET              WIN_BALTIC_CHARSET
#define RUSSIAN_CHARSET             WIN_RUSSIAN_CHARSET
#define THAI_CHARSET                WIN_THAI_CHARSET
#define EASTEUROPE_CHARSET          WIN_EASTEUROPE_CHARSET
#define OEM_CHARSET                 WIN_OEM_CHARSET

#define MM_TO_INCH                  25.4

#define TRANSPARENT                 1
#define OPAQUE                      2

#define BS_SOLID                    0
#define BS_NULL                     1
#define BS_HOLLOW                   BS_NULL
#define BS_HATCHED                  2
#define BS_PATTERN                  3
#define BS_INDEXED                  4
#define BS_DIBPATTERN               5
#define BS_DIBPATTERNPT             6
#define BS_PATTERN8X8               7
#define BS_DIBPATTERN8X8            8
#define BS_MONOPATTERN              9

#define HS_HORIZONTAL               0


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

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

Harbour test program: tests/largefil.prg. Provides functions: main. This test file tests specific function APIs

[Assistant]
function main()

   local aStruct := { { "FIELD1", "C", 256, 0 },;
                      { "FIELD2", "C", 256, 0 },;
                      { "FIELD3", "C", 256, 0 },;
                      { "FIELD4", "C", 256, 0 } }
   local nRec
   local i
   local cFileName := "testdbf"
   local nTotalRecs := 5000000

   REQUEST DBFCDX
   RddSetDefault( "DBFCDX" )

   dbCreate( cFileName, aStruct )
   dbUseArea( .T.,, cFileName, "long", .F. )
   OrdCreate( cFileName + IndexExt(),, "Left( field->FIELD1, 30 )" )

   for nRec := 1 to nTotalRecs
      long->( dbAppend() )
      long->FIELD1 := PadL( nRec, 30, Space( 1 ) )
   next

   ? "File size is : " + Transform( hb_fSize( cFileName + ".dbf" ), "@ZE ###,###,###,###" )
   ? "Index size is: " + Transform( hb_fSize( cFileName + IndexExt() ), "@ZE ###,###,###,###" )

   ? "Testing index..."
   for nRec := 1 to nTotalRecs / 10
      if ! long->( dbSeek( PadL( nRec, 30, Space( 1 ) ) ) )
         ? "Seek on value " + LTrim( Str( nRec ) ) + " failed!!"
      endif
   next
   ? "Index test ended"
   ? "Press any key..."
   Inkey( 0 )

   long->( dbCloseArea() )
   fErase( cFileName + ".dbf" )
   fErase( cFileName + IndexExt() )

return 0


[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/rdd.prg. Contains procedures: Main. This file handles database operations

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

REQUEST DBFCDX

PROCEDURE Main()

   LOCAL aRdd := rddList()

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

   SET EXCLUSIVE OFF

   QOut( "Registered RDD's:", hb_ntos( Len( aRdd ) ), "=>" )
   AEval( aRdd, {| cDriver | QQOut( "", cDriver ) } )
   QOut()
   rddSetDefault( "DBFCDX" )
   dbCreate( "testdbf", aStruct, "DBFCDX" )
   dbUseArea( , , "testdbf.dbf", "ALIAS_1" )
   ? Bof()
   dbSelectArea( 2 )
   dbUseArea( , "SDF", "testdbf.dbf", "ALIAS_2" )
   dbSelectArea( 3 )
   dbUseArea( , "DELIM", "testdbf.dbf", "ALIAS_3" )
   ? Eof()
   dbSelectArea( 4 )
   dbUseArea( , "DBFNTX", "testdbf.dbf", "ALIAS_4" )
   ? Found()
   dbGoBottom()
   dbGoto( 1 )
   dbSelectArea( 5 )
   dbUseArea( , "DBF", "testdbf.dbf", "ALIAS_5" )
   dbGoTop()
   dbSkip()
   dbCloseArea()
   dbCloseAll()
   hb_dbDrop( "testdbf",, "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] Generate Harbour code for: Harbour test program: tests/hbinline.prg. Provides functions: hb_inLine. This test file tests specific function APIs

[Assistant]
proc main()
local hb_inLine := " (var) "

? hb_inLine { hb_retc("inLine"); } + hb_inLine(" parameter ") {
     hb_retc( hb_parc( 1 ) );
     } + "!" + hb_inLine + hb_inLine() { hb_retc( ":-)" ); } + ;
  hb_inLine() + "{}"

return

function hb_inLine()
return " func() "


[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/debug/dbgmenu.prg. Provides functions: __dbgBuildMenu. This file provides utility functions

[Assistant]
#pragma -b-

#xcommand MENU [<oMenu>] => [ <oMenu> := ] HBDbMenu():New()
#xcommand MENUITEM [ <oMenuItem> PROMPT ] <cPrompt> ;
          [ IDENT <nIdent> ] [ ACTION <uAction,...> ] ;
          [ CHECKED <bChecked> ] => ;
   [ <oMenuItem> := ] HBDbMenu():AddItem( HBDbMenuItem():New( <cPrompt>, ;
   [{|| <uAction> }], [<bChecked>], [<nIdent>] ) )
#xcommand SEPARATOR => HBDbMenu():AddItem( HBDbMenuItem():New( "-" ) )
#xcommand ENDMENU => ATail( HBDbMenu():aMenus ):Build()

FUNCTION __dbgBuildMenu( oDebugger )

   LOCAL oMenu

   MENU oMenu
      MENUITEM " ~File "
      MENU
         MENUITEM " ~Open..."         ACTION oDebugger:Open()
         MENUITEM " ~Resume"          ACTION oDebugger:Resume()
         MENUITEM " O~S Shell"        ACTION oDebugger:OSShell()
         SEPARATOR
         MENUITEM " e~Xit    Alt-X "  ACTION oDebugger:Quit()
      ENDMENU

      MENUITEM " ~Locate "
      MENU
         MENUITEM " ~Find"            ACTION oDebugger:Locate()
         MENUITEM " ~Next"            ACTION oDebugger:FindNext()
         MENUITEM " ~Previous"        ACTION oDebugger:FindPrevious()
         MENUITEM " ~Goto line..."    ACTION oDebugger:SearchLine()
         SEPARATOR
         MENUITEM " ~Case sensitive " IDENT "CASE" ;
            ACTION oDebugger:ToggleCaseSensitive() ;
            CHECKED oDebugger:lCaseSensitive
      ENDMENU

      MENUITEM " ~View "
      MENU
         MENUITEM " ~Sets"            ACTION oDebugger:ViewSets()
         MENUITEM " ~WorkAreas   F6"  ACTION oDebugger:ShowWorkAreas()
         MENUITEM " ~App Screen  F4 " ACTION oDebugger:ShowAppScreen()
         SEPARATOR
         MENUITEM " ~CallStack" IDENT "CALLSTACK";
            ACTION oDebugger:Stack() ;
            CHECKED oDebugger:lShowCallStack
      ENDMENU

      MENUITEM " ~Run "
      MENU
         MENUITEM " ~Animate" IDENT "ANIMATE" ;
            ACTION ( oDebugger:ToggleAnimate(), oDebugger:Animate() ) ;
            CHECKED oDebugger:lAnimate
         MENUITEM " ~Step              F8 " ACTION oDebugger:Step()
         MENUITEM " ~Trace            F10"  ACTION oDebugger:Trace()
         MENUITEM " ~Go                F5"  ACTION oDebugger:Go()
         MENUITEM " to ~Cursor         F7"  ACTION oDebugger:ToCursor()
         MENUITEM " ~Next routine Ctrl-F5"  ACTION oDebugger:NextRoutine()
         SEPARATOR
         MENUITEM " s~Peed..."              ACTION oDebugger:Speed()
      ENDMENU

      MENUITEM " ~Point "
      MENU
         MENUITEM " ~Watchpoint..."         ACTION oDebugger:WatchPointAdd()
         MENUITEM " ~Tracepoint..."         ACTION oDebugger:TracePointAdd()
         MENUITEM " ~Breakpoint   F9 "      ACTION oDebugger:BreakPointToggle()
         MENUITEM " ~Delete..."             ACTION oDebugger:WatchPointDel()
      ENDMENU

      MENUITEM " ~Monitor "
      MENU
         MENUITEM " ~Public" IDENT "PUBLIC" ;
            ACTION oDebugger:Public() ;
            CHECKED oDebugger:lShowPublics

         MENUITEM " pri~Vate " IDENT "PRIVATE" ;
            ACTION oDebugger:Private() ;
            CHECKED oDebugger:lShowPrivates

         MENUITEM " ~Static" IDENT "STATIC" ;
            ACTION oDebugger:Static() ;
            CHECKED oDebugger:lShowStatics

         MENUITEM " ~Local" IDENT "LOCAL" ;
            ACTION oDebugger:Local() ;
            CHECKED oDebugger:lShowLocals

         MENUITEM " ~Global" IDENT "GLOBAL" ;
            ACTION oDebugger:Global() ;
            CHECKED oDebugger:lShowGlobals

         SEPARATOR

         MENUITEM " ~All" IDENT "ALL" ;
            ACTION oDebugger:All() ;
            CHECKED oDebugger:lAll

         MENUITEM " S~how all Globals" IDENT "SHOWALLGLOBALS" ;
            ACTION oDebugger:ShowAllGlobals() ;
            CHECKED oDebugger:lShowAllGlobals

         MENUITEM " s~Ort" ACTION oDebugger:Sort()
      ENDMENU

      MENUITEM " ~Options "
      MENU
         MENUITEM " ~Preprocessed Code" IDENT "PPO" ;
            ACTION oDebugger:OpenPPO() ;
            CHECKED oDebugger:lPPO
         MENUITEM " ~Line Numbers" IDENT "LINE" ;
            ACTION oDebugger:LineNumbers() ;
            CHECKED oDebugger:lLineNumbers
         MENUITEM " ~Exchange Screens"      ACTION oDebugger:NotSupported()
         MENUITEM " swap on ~Input"         ACTION oDebugger:NotSupported()
         MENUITEM " code~Block Trace" IDENT "CODEBLOCK" ;
            ACTION oDebugger:CodeblockTrace() ;
            CHECKED oDebugger:lCBTrace
         MENUITEM " ~Menu Bar"              ACTION oDebugger:NotSupported()
         MENUITEM " mono ~Display" IDENT "MONO";
            ACTION oDebugger:MonoDisplay() ;
            CHECKED oDebugger:lMonoDisplay
         MENUITEM " ~Colors..."             ACTION oDebugger:Colors()
         MENUITEM " ~Tab Width..."          ACTION oDebugger:TabWidth()
         MENUITEM " path for ~Files..."     ACTION oDebugger:PathForFiles()
         MENUITEM " R~un at startup" IDENT "ALTD" ;
            ACTION oDebugger:RunAtStartup() ;
            CHECKED oDebugger:lRunAtStartup
         SEPARATOR
         MENUITEM " ~Save Settings..."      ACTION oDebugger:SaveSettings()
         MENUITEM " ~Restore Settings... "  ACTION oDebugger:RestoreSettings()
      ENDMENU

      MENUITEM " ~Window "
      MENU
         MENUITEM " ~Next      Tab "        ACTION oDebugger:NextWindow()
         MENUITEM " ~Prev   Sh-Tab"         ACTION oDebugger:PrevWindow()
         MENUITEM " ~Move"                  ACTION oDebugger:NotSupported()
         MENUITEM " ~Size"                  ACTION oDebugger:NotSupported()
         MENUITEM " ~Zoom       F2"         ACTION oDebugger:NotSupported()
         MENUITEM " ~Iconize"               ACTION oDebugger:NotSupported()
         SEPARATOR
         MENUITEM " ~Tile"                  ACTION oDebugger:NotSupported()
      ENDMENU

      MENUITEM " ~Help "
      MENU
         MENUITEM " ~About Help "           ACTION oDebugger:ShowHelp()
         SEPARATOR
         MENUITEM " ~Keys"                  ACTION oDebugger:ShowHelp( "Keys" )
         MENUITEM " ~Windows"               ACTION oDebugger:ShowHelp( "Windows" )
         MENUITEM " ~Menus"                 ACTION oDebugger:ShowHelp( "Menus" )
         MENUITEM " ~Commands"              ACTION oDebugger:ShowHelp( "Commands" )
      ENDMENU

   ENDMENU

   RETURN oMenu


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

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

Harbour Runtime Library file: src/vm/harbinit.prg. Contains 4 procedures. This file provides utility functions

[Assistant]
#include "inkey.ch"

ANNOUNCE SYSINIT

PROCEDURE CLIPPER520()
   RETURN

#ifdef HB_COMPAT_C53

PROCEDURE CLIPPER530()
   RETURN

#endif

PROCEDURE __HBVMInit()

   MEMVAR GetList

   PUBLIC GetList := {}

   ErrorSys()

   RETURN

PROCEDURE __SetHelpK()

   SetKey( K_F1, {| p, l, v | __XHelp( p, l, v ) } )

   RETURN


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

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

Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/win_reg.prg. Provides 7 functions including: win_regRead, win_regWrite, win_regDelete, win_regQuery, Bin2U. Contains procedures: win_regPathSplit. This file provides platform-specific functionality

[Assistant]
#include "hbwin.ch"

#define KEY_QUERY_VALUE                1
#define KEY_SET_VALUE                  2
#define KEY_CREATE_SUB_KEY             4
#define KEY_ENUMERATE_SUB_KEYS         8
#define KEY_NOTIFY                     16
#define KEY_CREATE_LINK                32

PROCEDURE win_regPathSplit( cRegPath,  nHKEY,  cKey,  cEntry )

   LOCAL cHKEY
   LOCAL tmp

   nHKEY := WIN_HKEY_CURRENT_USER
   cKey := ""
   cEntry := ""

   tmp := At( "\", cRegPath )
   IF tmp > 0
      cHKEY := Left( cRegPath, tmp - 1 )
      cRegPath := SubStr( cRegPath, tmp + 1 )

      tmp := RAt( "\", cRegPath )
      IF tmp > 0
         cKey := Left( cRegPath, tmp - 1 )
         cEntry := SubStr( cRegPath, tmp + 1 )
      ELSE
         cEntry := cRegPath
      ENDIF

      DO CASE
      CASE Left( cHKEY, Len( "HKCU"                  ) ) == "HKCU"                  ; nHKEY := WIN_HKEY_CURRENT_USER
      CASE Left( cHKEY, Len( "HKLM"                  ) ) == "HKLM"                  ; nHKEY := WIN_HKEY_LOCAL_MACHINE
      CASE Left( cHKEY, Len( "HKCR"                  ) ) == "HKCR"                  ; nHKEY := WIN_HKEY_CLASSES_ROOT
      CASE Left( cHKEY, Len( "HKU"                   ) ) == "HKU"                   ; nHKEY := WIN_HKEY_USERS
      CASE Left( cHKEY, Len( "HKPD"                  ) ) == "HKPD"                  ; nHKEY := WIN_HKEY_PERFORMANCE_DATA
      CASE Left( cHKEY, Len( "HKCC"                  ) ) == "HKCC"                  ; nHKEY := WIN_HKEY_CURRENT_CONFIG
      CASE Left( cHKEY, Len( "HKDD"                  ) ) == "HKDD"                  ; nHKEY := WIN_HKEY_DYN_DATA
      CASE Left( cHKEY, Len( "HKEY_CURRENT_USER"     ) ) == "HKEY_CURRENT_USER"     ; nHKEY := WIN_HKEY_CURRENT_USER
      CASE Left( cHKEY, Len( "HKEY_LOCAL_MACHINE"    ) ) == "HKEY_LOCAL_MACHINE"    ; nHKEY := WIN_HKEY_LOCAL_MACHINE
      CASE Left( cHKEY, Len( "HKEY_CLASSES_ROOT"     ) ) == "HKEY_CLASSES_ROOT"     ; nHKEY := WIN_HKEY_CLASSES_ROOT
      CASE Left( cHKEY, Len( "HKEY_USERS"            ) ) == "HKEY_USERS"            ; nHKEY := WIN_HKEY_USERS
      CASE Left( cHKEY, Len( "HKEY_PERFORMANCE_DATA" ) ) == "HKEY_PERFORMANCE_DATA" ; nHKEY := WIN_HKEY_PERFORMANCE_DATA
      CASE Left( cHKEY, Len( "HKEY_CURRENT_CONFIG"   ) ) == "HKEY_CURRENT_CONFIG"   ; nHKEY := WIN_HKEY_CURRENT_CONFIG
      CASE Left( cHKEY, Len( "HKEY_DYN_DATA"         ) ) == "HKEY_DYN_DATA"         ; nHKEY := WIN_HKEY_DYN_DATA
      ENDCASE
   ENDIF

   RETURN

FUNCTION win_regRead( cRegPath, xDefault, nRegSam )

   LOCAL nHKEY, cKey, cEntry

   win_regPathSplit( cRegPath, @nHKEY, @cKey, @cEntry )

   RETURN win_regGet( nHKEY, cKey, cEntry, xDefault, nRegSam )

FUNCTION win_regWrite( cRegPath, xValue, nType, nRegSam )

   LOCAL nHKEY, cKey, cEntry

   win_regPathSplit( cRegPath, @nHKEY, @cKey, @cEntry )

   RETURN win_regSet( nHKEY, cKey, cEntry, xValue, nType, nRegSam )

FUNCTION win_regDelete( cRegPath, nRegSam )

   LOCAL nHKEY, cKey, cEntry
   LOCAL lRetVal
   LOCAL pKeyHandle

   win_regPathSplit( cRegPath, @nHKEY, @cKey, @cEntry )

   IF Empty( cEntry )
      lRetVal := win_regDeleteKey( nHKEY, cKey )
   ELSE
      hb_default( @nRegSam, 0 )

      IF win_regOpenKeyEx( nHKEY, cKey, 0, hb_bitOr( KEY_SET_VALUE, nRegSam ), @pKeyHandle )
         lRetVal := win_regDeleteValue( pKeyHandle, cEntry )
         win_regCloseKey( pKeyHandle )
      ELSE
         lRetVal := .F.
      ENDIF
   ENDIF

   RETURN lRetVal

FUNCTION win_regQuery( nHKEY, cKeyName, cEntryName, xValue, lSetIt, nRegSam )

   LOCAL xKey := win_regGet( nHKEY, cKeyName, cEntryName,, nRegSam )

   LOCAL cValType := ValType( xValue )
   LOCAL lRetVal

   hb_default( @lSetIt, .F. )

   IF cValType == "L"
      xValue := iif( xValue, 1, 0 )
      cValType := ValType( xValue )
   ELSEIF cValType == "D"
      xValue := DToS( xValue )
      cValType := ValType( xValue )
   ENDIF

   lRetVal := ( xKey != NIL .AND. xValue != NIL .AND. cValType == ValType( xKey ) .AND. xValue == xKey )
   IF ! lRetVal .AND. lSetIt
      lRetVal := win_regSet( nHKEY, cKeyName, cEntryName, xValue,, nRegSam )
   ENDIF

   RETURN lRetVal

STATIC FUNCTION Bin2U( c )

   LOCAL l := Bin2L( c )

   RETURN iif( l < 0, l + 4294967296, l )

FUNCTION win_regGet( nHKEY, cKeyName, cEntryName, xDefault, nRegSam )

   LOCAL xRetVal
   LOCAL pKeyHandle
   LOCAL nValueType

   hb_default( @nRegSam, 0 )

   IF win_regOpenKeyEx( nHKEY, cKeyName, 0, hb_bitOr( KEY_QUERY_VALUE, nRegSam ), @pKeyHandle )

      win_regQueryValueEx( pKeyHandle, cEntryName, 0, @nValueType, @xRetVal )

      IF HB_ISSTRING( xRetVal )
         DO CASE
         CASE nValueType == WIN_REG_DWORD .OR. ;
              nValueType == WIN_REG_DWORD_LITTLE_ENDIAN
            xRetVal := Bin2U( xRetVal )
         CASE nValueType == WIN_REG_DWORD_BIG_ENDIAN
            xRetVal := Bin2U( hb_BRight( xRetVal, 2 ) + hb_BLeft( xRetVal, 2 ) )
         CASE nValueType == WIN_REG_QWORD .OR. ;
              nValueType == WIN_REG_QWORD_LITTLE_ENDIAN
            xRetVal := hb_bitShift( Bin2U( hb_BSubStr( xRetVal, 5, 4 ) ), 32 ) +;
                                    Bin2U( hb_BSubStr( xRetVal, 1, 4 ) )
         OTHERWISE

            IF hb_BRight( xRetVal, 1 ) == hb_BChar( 0 )
               xRetVal := hb_BLeft( xRetVal, hb_BLen( xRetVal ) - 1 )
            ENDIF
         ENDCASE
      ELSE
         xRetVal := xDefault
      ENDIF

      win_regCloseKey( pKeyHandle )
   ELSE
      xRetVal := xDefault
   ENDIF

   RETURN xRetVal

FUNCTION win_regSet( nHKEY, cKeyName, cEntryName, xValue, nValueType, nRegSam )

   LOCAL cName
   LOCAL lRetVal := .F.
   LOCAL pKeyHandle

   hb_default( @nRegSam, 0 )

   IF win_regCreateKeyEx( nHKEY, cKeyName, 0, 0, 0, hb_bitOr( KEY_SET_VALUE, nRegSam ), 0, @pKeyHandle )

      SWITCH ValType( xValue )
      CASE "L"
         nValueType := WIN_REG_DWORD
         cName := iif( xValue, 1, 0 )
         EXIT
      CASE "D"
         nValueType := WIN_REG_SZ
         cName := DToS( xValue )
         EXIT
      CASE "N"
         IF ! HB_ISNUMERIC( nValueType ) .OR. ;
            !( nValueType == WIN_REG_DWORD .OR. ;
               nValueType == WIN_REG_DWORD_LITTLE_ENDIAN .OR. ;
               nValueType == WIN_REG_DWORD_BIG_ENDIAN .OR. ;
               nValueType == WIN_REG_QWORD .OR. ;
               nValueType == WIN_REG_QWORD_LITTLE_ENDIAN )
            nValueType := WIN_REG_DWORD
         ENDIF
         cName := xValue
         EXIT
      CASE "C"
      CASE "M"
         IF ! HB_ISNUMERIC( nValueType ) .OR. ;
            !( nValueType == WIN_REG_SZ .OR. ;
               nValueType == WIN_REG_EXPAND_SZ .OR. ;
               nValueType == WIN_REG_MULTI_SZ )
            nValueType := WIN_REG_SZ
         ENDIF
         cName := xValue
         EXIT
      ENDSWITCH

      IF cName != NIL
         lRetVal := win_regSetValueEx( pKeyHandle, cEntryName, 0, nValueType, cName )
      ENDIF

      win_regCloseKey( pKeyHandle )
   ENDIF

   RETURN lRetVal