[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/speedtst.prg. Provides functions: spd_logfile. Contains procedures: spd_out. This test file benchmarks performance characteristics

[Assistant]
#define N_TESTS 56
#define N_LOOPS 1000000
#define ARR_LEN 16

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

#ifdef __CLIPPER__

   #ifndef __ST__
      #define __ST__
   #endif

   #xtranslate hb_secondsCPU([<x>]) => seconds()
#endif

#ifdef FlagShip
   #define __NO_OBJ_ARRAY__

   #ifndef __ST__
      #define __ST__
   #endif
   #xtranslate hb_secondsCPU([<x>]) => secondsCPU(<x>)

   #xtranslate seconds() => fs_seconds()
#endif

#ifdef __XPP__
   #define __NO_OBJ_ARRAY__

   #xtranslate hb_secondsCPU([<x>]) => seconds()
#endif

#ifdef __CLIP__
   #define __NO_OBJ_ARRAY__

   #ifndef __ST__
      #define __ST__
   #endif
   #xtranslate hb_secondsCPU([<x>]) => secondsCPU(<x>)
#endif

#ifdef __XHARBOUR__

   #ifndef __ST__
      #ifndef __MT__
         #ifndef MT
            #ifndef HB_THREAD_SUPPORT
               #define __ST__
            #endif
         #endif
      #endif
   #endif
   #xtranslate hb_secondsCPU([<x>]) => secondsCPU(<x>)
#endif

#ifndef __MT__
   #ifndef __ST__
      #define __MT__
   #endif
#endif

#command ? => spd_out()
#command ? <xx,...> => spd_out();spd_out(<xx>)
#command ?? <xx,...> => spd_out(<xx>)

#ifdef __HARBOUR__
   #ifdef __XHARBOUR__
      #define EOL hb_osNewLine()
   #else
      #define EOL hb_eol()
   #endif
#else
   #ifndef EOL
      #define EOL chr(10)
   #endif
#endif

#xcommand TEST <testfunc>                 ;
          [ WITH <locals,...> ]           ;
          [ STATIC <statics,...> ]        ;
          [ FIELD  <fields,...> ]         ;
          [ MEMVAR <memvars,...> ]        ;
          [ PRIVATE <privates,...> ]      ;
          [ PUBLIC <publics,...> ]        ;
          [ INIT <init> ]                 ;
          [ EXIT <exit> ]                 ;
          [ INFO <info> ]                 ;
          CODE [ <testExp,...> ] =>       ;
   func <testfunc> ;                      ;
      local time, i:=nil, x:=nil ;        ;
      [ local <locals> ; ]                ;
      [ static <statics> ; ]              ;
      [ field <fields> ; ]                ;
      [ memvar <memvars> ; ]              ;
      [ private <privates> ; ]            ;
      [ public <publics> ; ]              ;
      [ <init> ; ]                        ;
      time := hb_secondsCPU() ;           ;
      for i:=1 to N_LOOPS ;               ;
         [ ( <testExp> ) ; ]              ;
      next ;                              ;
      time := hb_secondsCPU() - time ;    ;
      [ <exit> ; ]                        ;
   return { procname() + ": " + iif( <.info.>, <(info)>, #<testExp> ), time }

STATIC s_lStdOut := .F.

#ifdef __HARBOUR__
#ifndef __XHARBOUR__
#include "hbver.ch"
#endif
#endif

#ifdef __HARBOUR__
proc main( ... )
   local aParams := hb_aparams()
#else
proc main( _p01, _p02, _p03, _p04, _p05, _p06, _p07, _p08, _p09, _p10, ;
           _p11, _p12, _p13, _p14, _p15, _p16, _p17, _p18, _p19, _p20 )
   local aParams := ;
      asize( { _p01, _p02, _p03, _p04, _p05, _p06, _p07, _p08, _p09, _p10, ;
               _p11, _p12, _p13, _p14, _p15, _p16, _p17, _p18, _p19, _p20 }, ;
             min( pCount(), 20 ) )
#endif
   local nMT, cExclude, lScale, cParam, cMemTests, lSyntax, i, j

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

   lSyntax := lScale := .f.
   cMemTests := "030 031 023 025 027 041 042 044 053 054 019 022 032 033 055 056 "
   cExclude := ""
   nMT := 0
   for j := 1 to len( aParams )
      cParam := lower( aParams[ j ] )
      if cParam = "--thread"
         if substr( cParam, 9, 1 ) == "="
            if isdigit( substr( cParam, 10, 1 ) )
               nMT := val( substr( cParam, 10 ) )
            elseif substr( cParam, 10 ) == "all"
               nMT := -1
            else
               lSyntax := .t.
            endif
         elseif empty( substr( cParam, 9 ) )
            nMT := -1
         else
            lSyntax := .t.
         endif
      elseif cParam = "--exclude="
         if substr( cParam, 11 ) == "mem"
            cExclude += cMemTests
         else
            cExclude += strtran( strtran( strtran( substr( cParam, 11 ), ;
                        ".", " " ), ".", " " ), "/", " " ) + " "
         endif
      elseif cParam = "--only="
         cExclude := ""
         if substr( cParam, 8 ) == "mem"
            cParam := cMemTests
         endif
         for i := 1 to N_TESTS
            if ! strzero( i, 3 ) $ cParam
               cExclude += strzero( i, 3 ) + " "
            endif
         next
      elseif cParam == "--scale"
         lScale := .t.
      elseif cParam == "--stdout"
         s_lStdOut := .t.
      else
         lSyntax := .t.
      endif
      if lSyntax
         ? "Unknown option:", cParam
         ? "syntax: speedtst [--thread[=<num>]] [--only=<test(s)>] [--exclude=<test(s)>]"
         ?
         return
      endif
   next

   IF ! s_lStdOut
      set alternate to ( spd_logfile() ) additive
      set alternate on
   ENDIF

   test( nMT, cExclude, lScale )

   IF ! s_lStdOut
      set alternate off
      set alternate to
   ENDIF

return

STATIC PROCEDURE spd_out( p1, p2, p3, p4, p5, p6 )
   LOCAL nPCount := PCount()

   IF s_lStdOut
      DO CASE
      CASE nPCount == 0 ; OutStd( EOL )
      CASE nPCount == 1 ; OutStd( p1 )
      CASE nPCount == 2 ; OutStd( p1, p2 )
      CASE nPCount == 3 ; OutStd( p1, p2, p3 )
      CASE nPCount == 4 ; OutStd( p1, p2, p3, p4 )
      CASE nPCount == 5 ; OutStd( p1, p2, p3, p4, p5 )
      CASE nPCount == 6 ; OutStd( p1, p2, p3, p4, p5, p6 )
      ENDCASE
   ELSE
      DO CASE
      CASE nPCount == 0 ; QOut()
      CASE nPCount == 1 ; QQOut( p1 )
      CASE nPCount == 2 ; QQOut( p1, p2 )
      CASE nPCount == 3 ; QQOut( p1, p2, p3 )
      CASE nPCount == 4 ; QQOut( p1, p2, p3, p4 )
      CASE nPCount == 5 ; QQOut( p1, p2, p3, p4, p5 )
      CASE nPCount == 6 ; QQOut( p1, p2, p3, p4, p5, p6 )
      ENDCASE
   ENDIF
   RETURN

STATIC FUNCTION spd_logfile()
#ifndef __HARBOUR__
   RETURN "speedtst.txt"
#else
   LOCAL cName
   hb_FNameSplit( hb_ArgV( 0 ),, @cName )
   RETURN hb_FNameMerge( , cName, ".txt" )
#endif

TEST t000 INFO "empty loop overhead" CODE

TEST t001 WITH L_C:=dtos(date()) CODE x := L_C

TEST t002 WITH L_N:=112345.67    CODE x := L_N

TEST t003 WITH L_D:=date()       CODE x := L_D

TEST t004 STATIC s_once := NIL, S_C ;
          INIT hb_threadOnce( @s_once, {|| S_C := dtos( date() ) } ) ;
          CODE x := S_C

TEST t005 STATIC s_once := NIL, S_N ;
          INIT hb_threadOnce( @s_once, {|| S_N := 112345.67 } ) ;
          CODE x := S_N

TEST t006 STATIC s_once := NIL, S_D ;
          INIT hb_threadOnce( @s_once, {|| S_D := date() } ) ;
          CODE x := S_D

TEST t007 MEMVAR M_C ;
          PRIVATE M_C := dtos( date() ) ;
          CODE x := M->M_C

TEST t008 MEMVAR M_N ;
          PRIVATE M_N := 112345.67 ;
          CODE x := M->M_N

TEST t009 MEMVAR M_D ;
          PRIVATE M_D := date() ;
          CODE x := M->M_D

TEST t010 STATIC s_once := NIL ;
          MEMVAR P_C ;
          PUBLIC P_C ;
          INIT hb_threadOnce( @s_once, {|| M->P_C := dtos( date() ) } ) ;
          CODE x := M->P_C

TEST t011 STATIC s_once := NIL ;
          MEMVAR P_N ;
          PUBLIC P_N ;
          INIT hb_threadOnce( @s_once, {|| M->P_N := 112345.67 } ) ;
          CODE x := M->P_N

TEST t012 STATIC s_once := NIL ;
          MEMVAR P_D ;
          PUBLIC P_D ;
          INIT hb_threadOnce( @s_once, {|| M->P_D := date() } ) ;
          CODE x := M->P_D

TEST t013 FIELD  F_C ;
          INIT use_dbsh() EXIT close_db() ;
          CODE x := F_C

TEST t014 FIELD F_N ;
          INIT use_dbsh() EXIT close_db() ;
          CODE x := F_N

TEST t015 FIELD F_D ;
          INIT use_dbsh() EXIT close_db() ;
          CODE x := F_D

TEST t016 WITH o := errorNew() CODE x := o:Args

TEST t017 WITH o := errorArray() CODE x := o[2]

TEST t018 CODE round( i / 1000, 2 )

TEST t019 CODE str( i / 1000 )


[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 contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/hbedit.prg. Provides 14 functions including: EditorNew, EditorCargo, EditorTitle, EditorMode, EditorSize. Contains 5 procedures. This file provides utility functions

[Assistant]
#include "inkey.ch"
#include "setcurs.ch"
#include "fileio.ch"
#include "box.ch"

#define EDIT_LOWER      0
#define EDIT_UPPER      1
#define EDIT_SAME       2

#define EDIT_HARD       13

#define EDIT_EDIT       .T.
#define EDIT_VIEW       .F.

#define E_EDIT          1
#define E_TOP           2
#define E_LEFT          3
#define E_BOTTOM        4
#define E_RIGHT         5
#define E_TITLE         6
#define E_COLOR         7
#define E_FRAME         8
#define E_LINELEN       9
#define E_MODE          10
#define E_INSERT        11
#define E_CARGO         12
#define E_STRUCT_LEN    12

THREAD STATIC t_nESize := 4096

FUNCTION EditorNew( nTop, nLeft, nBottom, nRight, nLength, ;
      cFrame, cTitle, cColor, nSize, nEscape )

   LOCAL pEdit, oEdit

   __defaultNIL( @nSize, t_nESize )
   hb_default( @nLength, 80 )

   pEdit := ed_New( nLength, 4, nSize, nEscape )
   IF ! Empty( pEdit )

      __defaultNIL( @cFrame, HB_B_DOUBLE_UNI )
      __defaultNIL( @cColor, "W/N,W+/N,W+/R,GR+/N,G+/N" )

      oEdit := Array( E_STRUCT_LEN )
      oEdit[ E_EDIT ]    := pEdit
      oEdit[ E_TOP ]     := nTop
      oEdit[ E_LEFT ]    := nLeft
      oEdit[ E_BOTTOM ]  := nBottom
      oEdit[ E_RIGHT ]   := nRight
      oEdit[ E_LINELEN ] := nLength
      oEdit[ E_FRAME ]   := cFrame
      oEdit[ E_TITLE ]   := cTitle
      oEdit[ E_COLOR ]   := cColor
      oEdit[ E_MODE ]    := EDIT_VIEW

      ed_Config( pEdit, nTop, nLeft, nBottom, nRight, 0, 0 )
   ENDIF

   RETURN oEdit

PROCEDURE EditorKill( oEdit )

   oEdit[ E_EDIT ] := NIL

   RETURN

FUNCTION EditorCargo( oEdit, xCargo )

   LOCAL _xCargo := oEdit[ E_CARGO ]

   IF PCount() >= 2
      oEdit[ E_CARGO ] := xCargo
   ENDIF

   RETURN _xCargo

FUNCTION EditorTitle( oEdit, cTitle )

   LOCAL _cTitle := oEdit[ E_TITLE ]

   IF HB_ISSTRING( cTitle )
      oEdit[ E_TITLE ] := cTitle
   ENDIF

   RETURN _cTitle

FUNCTION EditorMode( oEdit, lMode )

   LOCAL _lMode := oEdit[ E_MODE ]

   IF HB_ISLOGICAL( lMode )
      oEdit[ E_MODE ] := lMode
   ENDIF

   RETURN _lMode

FUNCTION EditorSize( nSize )

   LOCAL _nSize := t_nESize

   IF nSize != NIL
      t_nESize := nSize
   ENDIF

   RETURN _nSize

PROCEDURE EditorAddText( oEdit, cText )

   ed_AddText( oEdit[ E_EDIT ], cText )

   RETURN

PROCEDURE EditorSetText( oEdit, cText )

   ed_SetText( oEdit[ E_EDIT ], cText )

   RETURN

PROCEDURE EditorInsText( oEdit, cText, nLine )

   IF nLine == NIL
      nLine := ed_LCount( oEdit[ E_EDIT ] )
   ENDIF

   ed_InsText( oEdit[ E_EDIT ], cText, nLine )

   RETURN

FUNCTION EditorGetText( oEdit, nCarret )

   hb_default( @nCarret, EDIT_HARD )

   RETURN ed_GetText( oEdit[ E_EDIT ], nCarret )

FUNCTION EditorLCount( oEdit )
   RETURN ed_LCount( oEdit[ E_EDIT ] )

FUNCTION EditorGetLine( oEdit, nLine )
   RETURN ed_GetLine( oEdit[ E_EDIT ], nLine )

FUNCTION EditorNextLine( oEdit )
   RETURN ed_GetNext( oEdit[ E_EDIT ] )

FUNCTION EditorFile( xInput, cOutput, nLineLen, ;
      lConv, nEscape, lSave )

   LOCAL nHandle, nLen, oEdit, lSaved, lClose := .F.
   LOCAL nSize

   hb_default( @lSave, .T. )

   IF HB_ISSTRING( xInput )
      nHandle := FOpen( xInput )
      lClose := .T.
   ELSE
      nHandle := xInput
   ENDIF

   IF nHandle != F_ERROR
      nLen := Max( FileLength( nHandle ), t_nESize )
   ELSE
      nLen := t_nESize
   ENDIF

   nSize := iif( nLen < 8192, nLen
   oEdit := EditorNew( 1, 0, 23, 79, nLineLen, "---      ", cOutput, , ;
      nSize, nEscape )

   IF nHandle != F_ERROR
      ed_ReadText( oEdit[ E_EDIT ], nHandle, 0, nLen, ;
         iif( lConv == NIL, .F., lConv ) )
      IF lClose
         FClose( nHandle )
      ENDIF
   ELSE
      EditorSetText( oEdit, " " )
   ENDIF

   EditorCargo( oEdit, cOutput )

   lSaved := EditorEdit( oEdit, EDIT_EDIT, .F. )
   EditorKill( oEdit )

   RETURN lSaved

FUNCTION EditorRead( oEditor, nHandle, nOffset, nLen, lConv )

   RETURN ed_ReadText( oEditor[ E_EDIT ], nHandle, nOffset, nLen, ;
      iif( lConv == NIL, .T., lConv ) )

FUNCTION EditorEdit( oEdit, lEdit, lFrame )

   LOCAL nRow, nCol := 0, nKey, bKey, oBox, nCursor, nState
   LOCAL nTop, nLeft, nBottom, nRight
   LOCAL lSaveAllowed, lSaved := .F.

   oBox := SaveBox( oEdit[ E_TOP ], oEdit[ E_LEFT ], ;
      oEdit[ E_BOTTOM ], oEdit[ E_RIGHT ], ;
      oEdit[ E_COLOR ], oEdit[ E_FRAME ] )

   oEdit[ E_INSERT ] := Set( _SET_INSERT )
   nCursor := SetCursor( iif( oEdit[ E_INSERT ], SC_NORMAL, SC_SPECIAL1 ) )
   IF HB_ISLOGICAL( lEdit )
      oEdit[ E_MODE ] := lEdit
   ENDIF
   lSaveAllowed := ( SetKey( K_F2 ) == NIL )

   nTop    := oEdit[ E_TOP ] + 1
   nLeft   := oEdit[ E_LEFT ] + 1
   nBottom := oEdit[ E_BOTTOM ] - 1
   nRight  := oEdit[ E_RIGHT ] - 1
   IF lFrame != NIL .AND. ! lFrame
      nLeft--
      nBottom++
      nRight++
   ENDIF
   nState := oEdit[ E_RIGHT ] - 8

   ed_Config( oEdit[ E_EDIT ], nTop, nLeft, nBottom, nRight, 0, 0 )

   DO WHILE .T.
      nRow := ed_Stabilize( oEdit[ E_EDIT ] )

      IF nRow != ed_Row( oEdit[ E_EDIT ] )
         nRow := ed_Row( oEdit[ E_EDIT ] )
         hb_DispOutAt( oEdit[ E_TOP ], nState, StrZero( nRow, 4 ) )
      ENDIF
      IF nCol != ed_Col( oEdit[ E_EDIT ] )
         nCol := ed_Col( oEdit[ E_EDIT ] )
         hb_DispOutAt( oEdit[ E_TOP ], nState + 5, StrZero( nCol, 3 ) )
      ENDIF
      SetPos( nTop + ed_WinRow( oEdit[ E_EDIT ] ), nLeft + ed_WinCol( oEdit[ E_EDIT ] ) )

      nKey := Inkey( 0 )

      DO CASE
      CASE !( hb_keyChar( nKey ) == "" )
         IF oEdit[ E_MODE ]
            ed_PutChar( oEdit[ E_EDIT ], Asc( hb_keyChar( nKey ) ), oEdit[ E_INSERT ] )
         ENDIF

      CASE nKey == K_F2 .AND. lSaveAllowed
         lSaved := EditorSave( oEdit )

      CASE EditorMove( oEdit[ E_EDIT ], nKey )

      CASE nKey == K_DOWN
         IF ! ed_Down( oEdit[ E_EDIT ] )
            hb_Scroll( nTop, nLeft, nBottom, nRight, 1 )
         ENDIF

      CASE nKey == K_UP
         IF ! ed_Up( oEdit[ E_EDIT ] )
            hb_Scroll( nTop, nLeft, nBottom, nRight, -1 )
         ENDIF

      CASE nKey == K_ESC
         EXIT

      OTHERWISE
         bKey := SetKey( nKey )
         IF HB_ISBLOCK( bKey )
            Eval( bKey, oEdit )
         ELSE
            IF oEdit[ E_MODE ]
               EditorKeys( oEdit, nKey )
            ENDIF
         ENDIF
      ENDCASE
   ENDDO

   SetCursor( nCursor )
   RestBox( oBox )

   RETURN lSaved

STATIC PROCEDURE EditorKeys( oEdit, nKey )

   LOCAL i

   DO CASE
   CASE nKey == K_CTRL_Y
      ed_DelLine( oEdit[ E_EDIT ] )

   CASE nKey == K_CTRL_T
      ed_DelWord( oEdit[ E_EDIT ] )

   CASE nKey == K_DEL
      ed_DelChar( oEdit[ E_EDIT ] )

   CASE nKey == K_BS
      ed_BSpace( oEdit[ E_EDIT ], oEdit[ E_INSERT ] )

   CASE nKey == K_ENTER
      ed_Return( oEdit[ E_EDIT ], oEdit[ E_INSERT ] )

   CASE nKey == K_TAB
      FOR i := 1 TO 4
         ed_PutChar( oEdit[ E_EDIT ], Asc( " " ), oEdit[ E_INSERT ] )
      NEXT

   CASE nKey == K_INS
      oEdit[ E_INSERT ] := ! oEdit[ E_INSERT ]
      Set( _SET_INSERT, oEdit[ E_INSERT ] )
      SetCursor( iif( oEdit[ E_INSERT ], SC_NORMAL, SC_SPECIAL1 ) )

   ENDCASE

   RETURN

STATIC FUNCTION EditorMove( pEdit, nKey )

   LOCAL lMoved := .T.

   DO CASE
   CASE nKey == K_PGDN       ; ed_PgDown( pEdit )
   CASE nKey == K_PGUP       ; ed_PgUp( pEdit )
   CASE nKey == K_CTRL_PGUP  ; ed_Top( pEdit )
   CASE nKey == K_CTRL_PGDN  ; ed_Bottom( pEdit )
   CASE nKey == K_RIGHT      ; ed_Right( pEdit )
   CASE nKey == K_LEFT       ; ed_Left( pEdit )
   CASE nKey == K_HOME       ; ed_Home( pEdit )
   CASE nKey == K_CTRL_HOME  ; ed_Home( pEdit )
   CASE nKey == K_END        ; ed_End( pEdit )
   CASE nKey == K_CTRL_END   ; ed_End( pEdit )
   CASE nKey == K_CTRL_RIGHT
   CASE nKey == K_CTRL_LEFT  ; ed_PWord( pEdit )
   OTHERWISE                 ; lMoved := .F.
   ENDCASE

   RETURN lMoved

STATIC FUNCTION EditorSave( oEdit )


[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 'hbtpathy' (Telepath communication library): contrib/hbtpathy/telepath.prg. Provides 17 functions including: tp_baud, tp_inkey, tp_close, tp_reopen, tp_open. Contains procedures: tp_delay, tp_clearin, tp_clrkbd. This file provides legacy compatibility functions

[Assistant]
#include "telepath.ch"

#include "hbcom.ch"

#define TPFP_NAME          1
#define TPFP_HANDLE        2
#define TPFP_BAUD          3
#define TPFP_DBITS         4
#define TPFP_PARITY        5
#define TPFP_SBITS         6
#define TPFP_OC            7
#define TPFP_INBUF         8
#define TPFP_INBUF_SIZE    9

THREAD STATIC t_aPorts
THREAD STATIC t_nErrorCode := 0

FUNCTION tp_baud( nPort, nNewBaud )

   hb_default( @nNewBaud, 0 )

   IF ! isport( nPort ) .OR. Empty( t_aPorts[ nPort, TPFP_NAME ] )
      RETURN TE_NOPORT
   ENDIF

   IF ! isopenport( nPort )
      RETURN 0
   ENDIF

   IF nNewBaud > 0
      IF hb_comInit( t_aPorts[ nPort, TPFP_HANDLE ], nNewBaud, t_aPorts[ nPort, TPFP_PARITY ], t_aPorts[ nPort, TPFP_DBITS ], t_aPorts[ nPort, TPFP_SBITS ] )
         t_aPorts[ nPort, TPFP_BAUD ] := nNewBaud
      ELSE

      ENDIF
   ENDIF

   RETURN t_aPorts[ nPort, TPFP_BAUD ]

FUNCTION tp_inkey( ... )
   RETURN Inkey( ... )

PROCEDURE tp_delay( nTime )

   hb_default( @nTime, 0 )

   IF nTime < 0
      RETURN
   ELSEIF nTime > 1800
      nTime := 1800
   ENDIF

   hb_idleSleep( nTime )

   RETURN

FUNCTION tp_close( nPort, nTimeout )

   hb_default( @nTimeout, 0 )

   IF ! isopenport( nPort )
      RETURN 0
   ENDIF

   IF nTimeout > 0
      tp_flush( nPort, nTimeout )
   ENDIF

   IF t_aPorts[ nPort, TPFP_HANDLE ] >= 0

      hb_comClose( t_aPorts[ nPort, TPFP_HANDLE ] )

      t_aPorts[ nPort, TPFP_OC ] := .F.
      t_aPorts[ nPort, TPFP_INBUF ] := ""
      t_aPorts[ nPort, TPFP_HANDLE ] := -1
   ENDIF

   RETURN 0

FUNCTION tp_reopen( nPort, nInSize, nOutSize )

   LOCAL nBaud, nData, cParity, nStop, cPortName

   IF ! isport( nPort ) .OR. Empty( t_aPorts[ nPort, TPFP_NAME ] )
      RETURN TE_NOPORT
   ENDIF

   cPortname   := t_aPorts[ nPort, TPFP_NAME ]
   nBaud       := t_aPorts[ nPort, TPFP_BAUD ]
   nData       := t_aPorts[ nPort, TPFP_DBITS ]
   cParity     := t_aPorts[ nPort, TPFP_PARITY ]
   nStop       := t_aPorts[ nPort, TPFP_SBITS ]

   RETURN tp_open( nPort, nInSize, nOutSize, nBaud, nData, cParity, nStop, cPortName )

FUNCTION tp_open( nPort, nInSize, nOutSize, nBaud, nData, cParity, nStop, cPortname )

   IF ! isport( nPort )
      RETURN TE_NOPORT
   ENDIF

   hb_default( @nInSize, 1536 )
   hb_default( @nOutSize, 1536 )
   hb_default( @nBaud, 1200 )
   hb_default( @nData, 8 )
   hb_default( @cParity, "N" )
   hb_default( @nStop, 1 )

   IF HB_ISSTRING( cPortname )
      hb_comSetDevice( nPort, cPortname )
   ENDIF

   t_aPorts[ nPort, TPFP_NAME       ] := cPortname
   t_aPorts[ nPort, TPFP_BAUD       ] := nBaud
   t_aPorts[ nPort, TPFP_DBITS      ] := nData
   t_aPorts[ nPort, TPFP_PARITY     ] := cParity
   t_aPorts[ nPort, TPFP_SBITS      ] := nStop
   t_aPorts[ nPort, TPFP_OC         ] := .F.
   t_aPorts[ nPort, TPFP_INBUF      ] := ""
   t_aPorts[ nPort, TPFP_INBUF_SIZE ] := nInSize
   t_aPorts[ nPort, TPFP_HANDLE     ] := -1

   IF hb_comOpen( nPort )

      t_aPorts[ nPort, TPFP_HANDLE ] := nPort

      IF hb_comInit( t_aPorts[ nPort, TPFP_HANDLE ], t_aPorts[ nPort, TPFP_BAUD ], t_aPorts[ nPort, TPFP_PARITY ], t_aPorts[ nPort, TPFP_DBITS ], t_aPorts[ nPort, TPFP_SBITS ] )
         t_aPorts[ nPort, TPFP_OC ] := .T.
         RETURN 0
      ELSE
         tp_close( t_aPorts[ nPort, TPFP_HANDLE ] )
         RETURN TE_PARAM
      ENDIF
   ENDIF

   t_aPorts[ nPort, TPFP_NAME       ] := ""
   t_aPorts[ nPort, TPFP_HANDLE     ] := -1
   t_aPorts[ nPort, TPFP_BAUD       ] := 1200
   t_aPorts[ nPort, TPFP_DBITS      ] := 8
   t_aPorts[ nPort, TPFP_PARITY     ] := "N"
   t_aPorts[ nPort, TPFP_SBITS      ] := 1
   t_aPorts[ nPort, TPFP_OC         ] := .F.
   t_aPorts[ nPort, TPFP_INBUF      ] := ""
   t_aPorts[ nPort, TPFP_INBUF_SIZE ] := 0

   RETURN TE_CONFL

FUNCTION tp_recv( nPort, nLength, nTimeout )

   LOCAL nDone
   LOCAL cRet

   IF ! HB_ISNUMERIC( nLength )
      nLength := t_aPorts[ nPort, TPFP_INBUF_SIZE ]
   ENDIF
   hb_default( @nTimeout, 0 )

   FetchChars( nPort )

   nDone := Seconds() + iif( nTimeout >= 0, nTimeout, 0 )

   DO WHILE Len( t_aPorts[ nPort, TPFP_INBUF ] ) < nLength .AND. ;
         ( nTimeout < 0 .OR. Seconds() < nDone )

      IF ! tp_idle()
         FetchChars( nPort )
      ELSE
         EXIT
      ENDIF
   ENDDO

   IF nLength > Len( t_aPorts[ nPort, TPFP_INBUF ] )
      cRet := t_aPorts[ nPort, TPFP_INBUF ]
      t_aPorts[ nPort, TPFP_INBUF ] := ""
   ELSE
      cRet := SubStr( t_aPorts[ nPort, TPFP_INBUF ], 1, nLength )
      t_aPorts[ nPort, TPFP_INBUF ] := SubStr( t_aPorts[ nPort, TPFP_INBUF ], nLength + 1 )
   ENDIF

   RETURN cRet

FUNCTION tp_send( nPort, cString, nTimeout )

   hb_default( @cString, "" )
   hb_default( @nTimeout, 0 )

   IF ! isopenport( nPort )
      RETURN 0
   ENDIF
   IF Len( cString ) == 0
      RETURN 0
   ENDIF

   RETURN hb_comSend( t_aPorts[ nPort, TPFP_HANDLE ], cString,, nTimeout )

FUNCTION tp_sendsub( nPort, cString, nStart, nLength, nTimeout )

   hb_default( @nStart, 1 )
   IF ! HB_ISNUMERIC( nLength )
      nLength := Len( cString )
   ENDIF

   RETURN tp_send( nPort, SubStr( cString, nStart, nLength ), nTimeout )

FUNCTION tp_recvto( nPort, cDelim, nMaxlen, nTimeout )

   LOCAL cChar
   LOCAL nAt
   LOCAL nStartPos := 1, nFirst := 0
   LOCAL nDone, cRet := ""

   IF ! isopenport( nPort )
      RETURN ""
   ENDIF

   IF ! HB_ISSTRING( cDelim ) .OR. Len( cDelim ) == 0
      RETURN ""
   ENDIF

   hb_default( @nMaxLen, 64999 )
   hb_default( @nTimeout, 0 )

   FetchChars( nPort )

   IF nTimeout == 0 .AND. Len( t_aPorts[ nPort, TPFP_INBUF ] ) == 0
      RETURN ""
   ENDIF

   nDone := Seconds() + iif( nTimeout >= 0, nTimeout, 0 )

   DO WHILE ( nTimeout < 0 .OR. Seconds() < nDone )

      IF Len( cDelim ) == 1

         nAt := hb_At( cDelim, t_aPorts[ nPort, TPFP_INBUF ], nStartPos )

         IF nAt > 0 .AND. iif( nFirst > 0, nAt < nFirst, .T. )
            nFirst := nAt
         ENDIF

      ELSE

         FOR EACH cChar IN cDelim

            nAt := hb_At( cChar, t_aPorts[ nPort, TPFP_INBUF ], nStartPos )

            IF nAt > 0 .AND. iif( nFirst > 0, nAt < nFirst, .T. )
               nFirst := nAt
            ENDIF

         NEXT

      ENDIF

      IF nFirst > 0
         EXIT

      ELSE

         nStartPos := Max( Len( t_aPorts[ nPort, TPFP_INBUF ] ), 1 )

         IF nStartPos >= nMaxLen
            EXIT
         ENDIF

         IF ! tp_idle()
            FetchChars( nPort )
         ELSE
            EXIT
         ENDIF
      ENDIF

   ENDDO

   IF nFirst > 0
      cRet := Left( t_aPorts[ nPort, TPFP_INBUF ], nFirst )
      t_aPorts[ nPort, TPFP_INBUF ] := SubStr( t_aPorts[ nPort, TPFP_INBUF ], nFirst + 1 )
   ENDIF

   RETURN cRet

FUNCTION tp_lookfor( nPort, cLookfor )

   IF ! isopenport( nPort )
      RETURN 0
   ENDIF

   FetchChars( nPort )

   RETURN At( cLookfor, t_aPorts[ nPort, TPFP_INBUF ] )

FUNCTION tp_inchrs( nPort )

   IF ! isopenport( nPort )
      RETURN 0
   ENDIF

   FetchChars( nPort )

   RETURN Len( t_aPorts[ nPort, TPFP_INBUF ] )

FUNCTION tp_infree( nPort )

   IF ! isopenport( nPort )
      RETURN 0
   ENDIF

   RETURN __tp_infree( t_aPorts[ nPort, TPFP_HANDLE ] )

FUNCTION tp_outfree( nPort )

   IF ! isopenport( nPort )
      RETURN 0
   ENDIF

   RETURN __tp_outfree( t_aPorts[ nPort, TPFP_HANDLE ] )

PROCEDURE tp_clearin( nPort )

   IF isopenport( nPort )
      FetchChars( nPort )
      t_aPorts[ nPort, TPFP_INBUF ] := ""
   ENDIF

   RETURN

PROCEDURE tp_clrkbd()

   CLEAR TYPEAHEAD

   RETURN

FUNCTION tp_crc16( cString )

   RETURN hb_ByteSwapW( hb_CRCCT( cString ) )

FUNCTION tp_crc32( cString )

   RETURN hb_CRC32( cString )

FUNCTION tp_waitfor( ... )

   LOCAL aParam := hb_AParams()
   LOCAL nPort

   nPort := aParam[ 1 ]

   IF ! isopenport( nPort )
      RETURN 0
   ENDIF

   RETURN 0

FUNCTION tp_ctrlcts( nPort, nNewCtrl )

   LOCAL nCurValue
   LOCAL nFlag

   IF ! isopenport( nPort )
      RETURN 0
   ENDIF


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

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

Harbour test program: tests/lnlenli1.prg. Provides functions: LongLine1. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
PROCEDURE Main()

   LongLine1()

   RETURN

FUNCTION LongLine1()
   RETURN { ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;
      { I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ), {|| I_( "XXXXXXXXXXXXXXXXXXXXXXXXXXX" ) }, 99, 9 }, ;


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

[User] Create Harbour preprocessor definitions: Harbour header file: include/hbgtinfo.ch. Defines 10 constants including: HB_GTINFO_CH_, HB_GTI_ISGRAPHIC, HB_GTI_SCREENWIDTH, HB_GTI_SCREENHEIGHT, HB_GTI_SCREENDEPTH. Defines keyboard input constants

[Assistant]
#ifndef HB_GTINFO_CH_
#define HB_GTINFO_CH_

#define HB_GTI_ISGRAPHIC        0
#define HB_GTI_SCREENWIDTH      1
#define HB_GTI_SCREENHEIGHT     2
#define HB_GTI_SCREENDEPTH      3
#define HB_GTI_FONTSIZE         4
#define HB_GTI_FONTWIDTH        5
#define HB_GTI_DESKTOPWIDTH     6
#define HB_GTI_DESKTOPHEIGHT    7
#define HB_GTI_DESKTOPDEPTH     8
#define HB_GTI_COMPATBUFFER     9
#define HB_GTI_KBDSHIFTS        10
#define HB_GTI_KBDSPECIAL       11
#define HB_GTI_KBDALT           12
#define HB_GTI_ISSCREENPOS      13
#define HB_GTI_FULLSCREEN       HB_GTI_ISSCREENPOS
#define HB_GTI_KBDSUPPORT       14
#define HB_GTI_CLIPBOARDDATA    15
#define HB_GTI_CLIPBOARDPASTE   16
#define HB_GTI_CURSORBLINKRATE  19
#define HB_GTI_DESKTOPROWS      20
#define HB_GTI_DESKTOPCOLS      21
#define HB_GTI_FONTWEIGHT       22
#define HB_GTI_FONTQUALITY      23
#define HB_GTI_FONTNAME         24
#define HB_GTI_CODEPAGE         25
#define HB_GTI_WINTITLE         26
#define HB_GTI_ICONFILE         27
#define HB_GTI_ICONRES          28
#define HB_GTI_MOUSESTATUS      29

#define HB_GTI_INPUTFD          30
#define HB_GTI_OUTPUTFD         31
#define HB_GTI_ERRORFD          32

#define HB_GTI_ESCDELAY         33

#define HB_GTI_VIEWMAXHEIGHT    34
#define HB_GTI_VIEWMAXWIDTH     35

#define HB_GTI_VIEWPORTHEIGHT   36
#define HB_GTI_VIEWPORTWIDTH    37

#define HB_GTI_STDOUTCON        38
#define HB_GTI_STDERRCON        39

#define HB_GTI_ISCTWIN          40
#define HB_GTI_ISMULTIWIN       41
#define HB_GTI_GETWIN           42
#define HB_GTI_SETWIN           43
#define HB_GTI_NEWWIN           44

#define HB_GTI_ADDKEYMAP        45
#define HB_GTI_DELKEYMAP        46

#define HB_GTI_ISUNICODE        47

#define HB_GTI_SELECTCOPY       48
#define HB_GTI_RESIZABLE        49
#define HB_GTI_CLOSABLE         50

#define HB_GTI_NOTIFIERBLOCK    51
#define HB_GTI_SCREENSIZE       52
#define HB_GTI_PALETTE          53

#define HB_GTI_RESIZEMODE       54
#define HB_GTI_SETPOS_XY        55
#define HB_GTI_SETPOS_ROWCOL    56

#define HB_GTI_BOXCP            57

#define HB_GTI_CARGO            58
#define HB_GTI_FONTSEL          59

#define HB_GTI_INKEYFILTER      60
#define HB_GTI_INKEYREAD        61

#define HB_GTI_ALTENTER         62
#define HB_GTI_ISFULLSCREEN     63
#define HB_GTI_ONLINE           64
#define HB_GTI_VERSION          65

#define HB_GTI_MAXIMIZED        66
#define HB_GTI_FONTATTRIBUTE    67
#define HB_GTI_UNITRANS         68
#define HB_GTI_WINHANDLE        69
#define HB_GTI_MOUSEPOS_XY      70
#define HB_GTI_DISPIMAGE        71
#define HB_GTI_REDRAWMAX        72
#define HB_GTI_RESIZESTEP       73
#define HB_GTI_CLOSEMODE        74
#define HB_GTI_MINIMIZED        75
#define HB_GTI_QUICKEDIT        76
#define HB_GTI_SYSMENUADD       77
#define HB_GTI_MSGBOX           78
#define HB_GTI_SOUND            79

#define HB_GTI_FONTW_THIN       1
#define HB_GTI_FONTW_NORMAL     2
#define HB_GTI_FONTW_BOLD       3

#define HB_GTI_FONTQ_DRAFT      1
#define HB_GTI_FONTQ_NORMAL     2
#define HB_GTI_FONTQ_HIGH       3

#define HB_GTI_FONTA_FIXMETRIC  0x0001
#define HB_GTI_FONTA_CLRBKG     0x0002
#define HB_GTI_FONTA_DRAWBOX    0x0004
#define HB_GTI_FONTA_CTRLCHARS  0x0008
#define HB_GTI_FONTA_NOSTRETCH  0x0010

#define HB_GTI_KBD_SHIFT        0x000001
#define HB_GTI_KBD_CTRL         0x000002
#define HB_GTI_KBD_ALT          0x000004
#define HB_GTI_KBD_KEYPAD       0x000008
#define HB_GTI_KBD_SCROLOCK     0x000010
#define HB_GTI_KBD_NUMLOCK      0x000020
#define HB_GTI_KBD_CAPSLOCK     0x000040
#define HB_GTI_KBD_INSERT       0x000080
#define HB_GTI_KBD_LSHIFT       0x000100
#define HB_GTI_KBD_RSHIFT       0x000200
#define HB_GTI_KBD_LCTRL        0x000400
#define HB_GTI_KBD_RCTRL        0x000800
#define HB_GTI_KBD_LALT         0x001000
#define HB_GTI_KBD_RALT         0x002000
#define HB_GTI_KBD_LWIN         0x004000
#define HB_GTI_KBD_RWIN         0x008000
#define HB_GTI_KBD_MENU         0x010000

#ifdef HB_LEGACY_LEVEL4

#define HB_GTE_ACTIVATE         1
#define HB_GTE_SETFOCUS         2
#define HB_GTE_KILLFOCUS        3
#define HB_GTE_CLOSE            4
#define HB_GTE_RESIZED          5
#endif

#define HB_GTI_RESIZEMODE_FONT  0
#define HB_GTI_RESIZEMODE_ROWS  1

#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 the following Harbour classes: THtml. Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/thtm.prg. Defines classes: THtml. This file provides legacy compatibility functions

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

THREAD STATIC t_nHtm  := NIL
THREAD STATIC t_cForm := 0
THREAD STATIC t_oPage := 0

CREATE CLASS THtml

   VAR nH
   VAR FName, TITLE
   VAR FontFace INIT "Verdana"
   VAR FontSize INIT 1
   VAR FontColor INIT "black"
   VAR aImages
   VAR lCgi  INIT .F.
   VAR cStr    Init ""
   VAR BaseURL, BaseTarget
   VAR lFont INIT .F.

   METHOD Newalt( cType )
   METHOD cgiNew( cTitle, cLinkTitle, cCharSet, aScriptSRC, ;
      BGIMAGE, BGCOLOR, txtColor, aJsCode, ;
      onLoad, onUnload, ;
      cLinkClr, cVLinkClr, cALinkClr, ;
      cStyle, aImages, aServerSrc, ;
      cBaseURL, cBaseTarget, ;
      nRefresh, cRefreshURL, cStyleScr, ;
      lNocache, NOF, nMarginTop, nMarginHeight, ;
      nMarginWidth, nMarginLeft, lCgi, cFile )
   METHOD New( cTitle, cLinkTitle, cCharSet, aScriptSRC, ;
      BGIMAGE, BGCOLOR, txtColor, aJsCode, ;
      onLoad, onUnload, ;
      cLinkClr, cVLinkClr, cALinkClr, ;
      cStyle, aImages, aServerSrc, ;
      cBaseURL, cBaseTarget, ;
      nRefresh, cRefreshURL, cStyleScr, ;
      lNocache, NOF, nMarginTop, nMarginHeight, ;
      nMarginWidth, nMarginLeft, lCgi, cFile )

   METHOD CGIClose()

   METHOD SetPageColor( cColor, lBody ) INLINE hb_default( @lBody, .T. ), ::cStr += iif( lBody, '', ' bgcolor="' + cColor + '" ' )

   METHOD SetTextColor( cColor, lBody ) INLINE hb_default( @lBody, .T. ), ::cStr += iif( lBody, '', ' text="' + cColor + '" ' )

   METHOD SetBgImage( cImage, lBody ) INLINE hb_default( @lBody, .T. ), ::cStr += iif( lBody, '', ' background="' + cImage + '" ' )

   METHOD Close()

   METHOD SetCenter( lOn ) INLINE ::cStr += iif( lOn, "", "" )

   METHOD SetFont( cFont, lBold, lItalic, lULine, nSize, cColor, lSet )

   METHOD StartFont( cFont, lBold, lItalic, lULine, nSize, cColor, lSet, lPut )

   METHOD DefineFont( cFont, cType, nSize, cColor, lSet )

   METHOD EndFont()

   METHOD Say( str, font, size, type, color, style )

   METHOD QQOut( c ) INLINE hb_default( @c, "" ), ::cStr += c

   METHOD QOut( c ) INLINE hb_default( @c, "" ), ::cStr += CRLF() + c + "
" + CRLF()

   METHOD Write( c ) INLINE hb_default( @c, "" ), ::cStr += c

   METHOD WriteLN( c ) INLINE hb_default( @c, "" ), ::cStr += CRLF() + c + "
" + CRLF()

   METHOD SayColor( t, c ) INLINE hb_default( @t, "" ), hb_default( @c, "black" ), ;
      ::cStr += '' + t + ""

   METHOD Space( n ) INLINE hb_default( @n, 1 ), ::cStr += Replicate( " ", n  )

   METHOD PutImage( cImage, nBorder, nHeight, cOnclick, cOnMsOver, cOnMsOut, ;
      cName, cAlt, cTarget, nWidth, lBreak, ID, MAP, ALING, HSPACE )

   METHOD Text( cText, nCols, lWrap ) INLINE hb_default( @lWrap, .T. ), hb_default( @nCols, 80 ), ;
      ::cStr += "
", ">" ) + CRLF() + cText + CRLF() + "
" + CRLF()

   METHOD MultiCol( txt, cols, gutter, width ) INLINE hb_default( @txt, "" ), ;
      hb_default( @cols, 2 ), ;
      hb_default( @gutter, 5 ), ;
      hb_default( @width, 100 ), ;
      ::cStr += '<multicol cols="' + hb_ntos( cols ) + '" gutter="' + hb_ntos( gutter ) + '" width="' + hb_ntos( width ) + '">', ;
      ::cStr += txt, ;
      ::cStr += "</multicol>"

   METHOD PutHeading( cText, nWeight, lCentered )

   METHOD HLine( nSize, nWidth, lShade, cColor )

   METHOD PutParagraph() INLINE ::cStr += "

" + CRLF()

   METHOD Paragraph( lStart, cAlign, cStyle )

   METHOD PutBreak() INLINE ::cStr += "
" + CRLF()

   METHOD Marquee( cText, cFont, cFntColor, nFntSize, cAlign, nWidth, nHeight, cbgColor, ;
      cBehavior, cDirection, nScrollAmt, nScrollDelay, LOOP, ;
      onMsOver, onMsOut, onClick, onStart, onFinish )

   METHOD StartMarquee( cFont, cFntColor, nFntSize, cAlign, nWidth, nHeight, cbgColor, ;
      cBehavior, cDirection, nScrollAmt, nScrollDelay, LOOP, ;
      onMsOver, onMsOut, onClick, onStart, onFinish )
   METHOD EndMarquee()

   METHOD PutTextUrl( cText, cUrl, cOnClick, cOnMsOver, cOnMsout, cTarget, font, clr, size, style, bld, lbreak, cClass )

   METHOD PutImageUrl( cImage, nBorder, nHeight, cUrl, ;
      cOnclick, cOnMsOver, cOnMsOut, cName, cAlt, cTarget, nWidth, lbreak, cClass, ;
      Id, hSpace, Aling )

   METHOD DefineTable( nCols, nBorder, nWidth, nHeight, ColorFore, ColorBG, ;
      l3d, lRuleCols, lRuleRows, cClrDark, cClrLight, cClrBorder, ;
      nCellPadding, nCellSpacing, cAling, lRules, ;
      bgImage, cStyle, Id, NOF )

   METHOD TableHead( cHead, cColor, cAlign, cFont, nSize, cFntColor, nHeight, cBgPic )

   METHOD NewTableRow( cColor, vAling, aLing )

   METHOD EndTableRow()

   METHOD NewTableCell( cAlign, cColor, cFont, nSize, cFntColor, nHeight, ;
      cBgPic, nWidth, lWrap, nColspan, nRowspan, cValign, ;
      clrdrk, clrlt, cBdrClr, cClass, lNoFont )

   METHOD EndTableCell()

   METHOD EndTable()

   METHOD NewList() INLINE ::cStr += "
" + CRLF()

   METHOD ListItem() INLINE ::cStr += "
 "

   METHOD EndList() INLINE ::cStr += "
 "

   METHOD NewForm( cMethod, cAction, cName )

   METHOD FormImage( cText, name, File )

   METHOD FormEdit( cType, cName, xValue, nSize )

   METHOD FormReset( cText )

   METHOD FormSubmit( cText )

   METHOD FormQOut( c ) INLINE ::cStr += c + "
" + CRLF()

   METHOD FormQQOut( c ) INLINE ::cStr += c + CRLF()

   METHOD EndForm() INLINE ::cStr += CRLF() + "</form>" + CRLF()

   METHOD PushButton( cName, cCaption, cCgiApp, cOnClick, cOnFocus, cOnBlur, cOnMsOver, cOnMsOut, style, ID )

   METHOD endButton()

   METHOD Button( cName, cCaption, cOnClick, cCgiApp, cOnMsOver, cOnMsOut, style, ID )

   METHOD iFrame( name, src, border, marginwidth, marginheight, scrolling, align, WIDTH, HEIGHT )

   METHOD StartJava() INLINE ::cStr += '


[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 'hbtest' (Test framework utilities): contrib/hbtest/tests/test.prg. Provides functions: TestObj. Contains procedures: Main. This file provides utility functions

[Assistant]
#require "hbtest"

PROCEDURE Main()

   LOCAL cTable := hb_FNameExtSet( __FILE__, ".dbf" )

   dbCreate( cTable, { { "TESTM", "M", 10, 0 } }, NIL, .T., "w_TEST" )
   dbAppend()
   w_TEST->TESTM := "hello"

   HBTEST 2 + 2             IS 4
   HBTEST "a" + "b"         IS "ab"
   HBTEST Chr( 0 )          IS Chr( 0 )
   HBTEST 0d20111213        IS 0d20111213
   HBTEST NIL               IS NIL
   HBTEST .T.               IS .T.
   HBTEST " " + " "         IS "  "
   HBTEST w_TEST->TESTM     IS "hello"
   HBTEST { "a", {} }       IS '{"a", {}}'
   HBTEST { "a" => 100 }    IS '{"a"=>100}'
   HBTEST TestObj()         IS '__itemSetObjRaw( {NIL, NIL, NIL, "Harbour", NIL, NIL, NIL, NIL, NIL, NIL, NIL, NIL}, {{"ERROR",}} )'

   HBTEST 2 + ""            IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:N:2;C: F:S"
   HBTEST 2 + Chr( 9 )      IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:N:2;C:\011 F:S"
   HBTEST 2 + '"'           IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:N:2;C:\042 F:S"
   HBTEST 2 + "'"           IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:N:2;C:' F:S"
   HBTEST "" + 0d20111213   IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:C:;D:0d20111213 F:S"
   HBTEST .T. - .F.         IS "E 1 BASE 1082 Argument error (-) OS:0 #:0 A:2:L:.T.;L:.F. F:S"
   HBTEST w_TEST->TESTM + 0 IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:M:hello;N:0 F:S"
   HBTEST {} + 0            IS "E 1 BASE 1081 Argument error (+) OS:0 #:0 A:2:A:{ Array of 0 Items };N:0 F:S"

   HBTEST hb_BChar( 254 )   IS hb_BChar( 255 )
   HBTEST 0d20111213        IS 0d20111214
   HBTEST 2 + 2             IS 5
   HBTEST .T.               IS .F.

   dbCloseArea()
   hb_dbDrop( cTable )

   RETURN

STATIC FUNCTION TestObj()

   LOCAL o := ErrorNew()

   o:description := "Harbour"

   RETURN o


[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 'gtwvg': contrib/gtwvg/wvgparts.ch. Defines 10 constants including: _WVG_CH, DA_MODE, objTypeNone, objTypeCrt, objTypeWindow. Defines file I/O constants

[Assistant]
#ifndef _WVG_CH
#define _WVG_CH

#define DA_MODE                                   1

#define objTypeNone                               0
#define objTypeCrt                                1
#define objTypeWindow                             2
#define objTypeActiveX                            3
#define objTypeDialog                             4
#define objTypeToolBar                            5
#define objTypeToolBarButton                      6
#define objTypeMenu                               7
#define objTypeStatusBar                          8
#define objTypePushButton                         9
#define objTypeComboBox                           10
#define objTypeListBox                            11
#define objTypeStatic                             12
#define objTypeTreeView                           13
#define objTypeTreeViewItem                       14
#define objTypeCheckBox                           15
#define objTypeRadioButton                        16
#define objType3State                             17
#define objTypeSLE                                18
#define objTypeMLE                                19
#define objTypeDA                                 20
#define objTypeScrollBar                          21
#define objTypeTabPage                            22

#define NMH_code                                  1
#define NMH_controlID                             2
#define NMH_hWnd                                  3
#define NMH_dwItemSpec                            4
#define NMH_action                                4

#define EVENT_HANDELLED                           0
#define EVENT_UNHANDELLED                         1

#define WVG_AUTOSIZE                              -1

#define WVGALIGN_TOP                              0
#define WVGALIGN_LEFT                             0
#define WVGALIGN_BOTTOM                           8
#define WVGALIGN_RIGHT                            2
#define WVGALIGN_HCENTER                          1
#define WVGALIGN_VCENTER                          4
#define WVGALIGN_WORDBREAK                        16

#define WVGFRAME_NONE                             0
#define WVGFRAME_RECT                             1
#define WVGFRAME_BOX                              2
#define WVGFRAME_RAISED                           16
#define WVGFRAME_RECESSED                         32
#define WVGFRAME_THICK                            128
#define WVGFRAME_DASHED                           256
#define WVGFRAME_DOTTED                           512

#define WVGTOOLBAR_STYLE_STANDARD                 0
#define WVGTOOLBAR_STYLE_FLAT                     1
#define WVGTOOLBAR_STYLE_VERTICAL                 2

#define WVGTOOLBAR_BUTTON_DEFAULT                 0

#define WVGSTATUSBAR_AUTOSIZE_NONE                0
#define WVGSTATUSBAR_AUTOSIZE_SPRING              1
#define WVGSTATUSBAR_AUTOSIZE_CONTENTS            2

#define WVGSTATUSBAR_BEVEL_NONE                   0
#define WVGSTATUSBAR_BEVEL_INSET                  1
#define WVGSTATUSBAR_BEVEL_RAISED                 2

#define WVGSTATUSBAR_PANEL_TEXT                   0
#define WVGSTATUSBAR_PANEL_CAPSLOCK               1
#define WVGSTATUSBAR_PANEL_NUMLOCK                2
#define WVGSTATUSBAR_PANEL_INSERT                 3
#define WVGSTATUSBAR_PANEL_SCROLL                 4
#define WVGSTATUSBAR_PANEL_TIME                   5
#define WVGSTATUSBAR_PANEL_DATE                   6
#define WVGSTATUSBAR_PANEL_KANA                   7

#define WVGSTATIC_TYPE_TEXT                       1
#define WVGSTATIC_TYPE_GROUPBOX                   2
#define WVGSTATIC_TYPE_ICON                       3
#define WVGSTATIC_TYPE_SYSICON                    4
#define WVGSTATIC_TYPE_BITMAP                     5
#define WVGSTATIC_TYPE_FGNDRECT                   6
#define WVGSTATIC_TYPE_BGNDRECT                   7
#define WVGSTATIC_TYPE_FGNDFRAME                  8
#define WVGSTATIC_TYPE_BGNDFRAME                  9
#define WVGSTATIC_TYPE_HALFTONERECT               10
#define WVGSTATIC_TYPE_HALFTONEFRAME              11
#define WVGSTATIC_TYPE_RAISEDBOX                  12
#define WVGSTATIC_TYPE_RECESSEDBOX                13
#define WVGSTATIC_TYPE_RAISEDRECT                 14
#define WVGSTATIC_TYPE_RECESSEDRECT               15
#define WVGSTATIC_TYPE_RAISEDLINE                 16
#define WVGSTATIC_TYPE_RECESSEDLINE               17

#define WVGSTATIC_FRAMETHIN                       1
#define WVGSTATIC_FRAMETHICK                      2

#define WVGDLG_FRAMESTAT_MINIMIZED                1
#define WVGDLG_FRAMESTAT_MAXIMIZED                2
#define WVGDLG_FRAMESTAT_NORMALIZED               3

#define WVGSTATIC_TEXT_LEFT                       WVGALIGN_LEFT
#define WVGSTATIC_TEXT_RIGHT                      WVGALIGN_RIGHT
#define WVGSTATIC_TEXT_CENTER                     WVGALIGN_HCENTER
#define WVGSTATIC_TEXT_TOP                        WVGALIGN_TOP
#define WVGSTATIC_TEXT_VCENTER                    WVGALIGN_VCENTER
#define WVGSTATIC_TEXT_BOTTOM                     WVGALIGN_BOTTOM
#define WVGSTATIC_TEXT_WORDBREAK                  WVGALIGN_WORDBREAK

#define WVGSTATIC_BITMAP_TILED                    1
#define WVGSTATIC_BITMAP_SCALED                   2

#define WVG_DRAW_NORMAL                           0

#define WVGLISTBOX_MM_SINGLE                      1

#define WVG_PP_FGCLR                              2
#define WVG_PP_BGCLR                              4
#define WVG_PP_COMPOUNDNAME                       15
#define WVG_PP_FONT                               16

#define WVGSLE_LEFT                               1
#define WVGSLE_RIGHT                              2
#define WVGSLE_CENTER                             3

#define WVGMENUBAR_MIS_SEPARATOR                  4
#define WVGMENUBAR_MIS_BUTTONSEPARATOR            512

#define WVGSCROLL_HORIZONTAL                      1
#define WVGSCROLL_VERTICAL                        2

#define WVGSB_PREVPOS                             1
#define WVGSB_NEXTPOS                             2
#define WVGSB_PREVPAGE                            3
#define WVGSB_NEXTPAGE                            4
#define WVGSB_SLIDERTRACK                         5
#define WVGSB_ENDTRACK                            6
#define WVGSB_ENDSCROLL                           7
#define WVGSB_TOP                                 11
#define WVGSB_BOTTOM                              12

#define WVGTABPAGE_TAB_BOTTOM                     2
#define WVGTABPAGE_TAB_TOP                        4

#define WVGTOOLBAR_BUTTON_SEPARATOR               4

#define WVGCOMBO_SIMPLE                           1
#define WVGCOMBO_DROPDOWN                         2
#define WVGCOMBO_DROPDOWNLIST                     3

#define WVG_IMAGE_ICONFILE                        1
#define WVG_IMAGE_ICONRESOURCE                    2
#define WVG_IMAGE_BITMAPFILE                      3
#define WVG_IMAGE_BITMAPRESOURCE                  4

#endif


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

[User] Generate Harbour code for: Header file for contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/cterror.ch. Defines 10 constants including: _CTERROR_CH, CT_ERROR_MATHLIB_RANGEL, CT_ERROR_MATHLIB_RANGEH, CT_ERROR_GENERAL_RANGEL, CT_ERROR_GENERAL_RANGEH. Defines error handling constants and codes

[Assistant]
#ifndef _CTERROR_CH
#define _CTERROR_CH

#define CT_ERROR_MATHLIB_RANGEL     100
#define CT_ERROR_MATHLIB_RANGEH     199

#define CT_ERROR_GENERAL_RANGEL    1000
#define CT_ERROR_GENERAL_RANGEH    1199

#define CT_ERROR_WINDOW_RANGEL     1200
#define CT_ERROR_WINDOW_RANGEH     1599

#define CT_ERROR_EXTDRV_RANGEL     1600
#define CT_ERROR_EXTDRV_RANGEH     2399

#define CT_ERROR_SERIAL_RANGEL     2400
#define CT_ERROR_SERIAL_RANGEH     3099

#define CT_ERROR_STRING_RANGEL     3100
#define CT_ERROR_STRING_RANGEH     4499

#define CT_ERROR_NUMBIT_RANGEL     4500
#define CT_ERROR_NUMBIT_RANGEH     4999

#define CT_ERROR_VIDEO_RANGEL      5000
#define CT_ERROR_VIDEO_RANGEH      5699

#define CT_ERROR_DISC_RANGEL       5700
#define CT_ERROR_DISC_RANGEH       6399

#define CT_ERROR_PRINT_RANGEL      6400
#define CT_ERROR_PRINT_RANGEH      6699

#define CT_ERROR_DATE_RANGEL       6700
#define CT_ERROR_DATE_RANGEH       7099

#define CT_ERROR_DBF_RANGEL        7100
#define CT_ERROR_DBF_RANGEH        7299

#define CT_ERROR_SWITCH_RANGEL     7300
#define CT_ERROR_SWITCH_RANGEH     7799

#define CT_ERROR_SYSINF_RANGEL     7800
#define CT_ERROR_SYSINF_RANGEH     8099

#define CT_ERROR_MISC_RANGEL       8100
#define CT_ERROR_MISC_RANGEH       8399

#define CT_ERROR_MATH_RANGEL       8400
#define CT_ERROR_MATH_RANGEH       8699

#define CT_ERROR_PEEK_RANGEL       8800
#define CT_ERROR_PEEK_RANGEH       8899

#define CT_ERROR_GETREAD_RANGEL    8900
#define CT_ERROR_GETREAD_RANGEH    9099

#define CT_ERROR_CTINIT          1014
#define CT_ERROR_CTEXIT          1020
#define CT_ERROR_CSETARGERR      1032

#define CT_ERROR_WACLOSE         1212
#define CT_ERROR_WBOARD          1222
#define CT_ERROR_WBOX            1232
#define CT_ERROR_WCENTER         1242
#define CT_ERROR_WCLOSE          1252
#define CT_ERROR_WCOL            1262
#define CT_ERROR_WFCOL           1272
#define CT_ERROR_WFLASTCOL       1292
#define CT_ERROR_WFORMAT         1302
#define CT_ERROR_WFROW           1312
#define CT_ERROR_WLASTCOL        1322
#define CT_ERROR_WLASTROW        1332
#define CT_ERROR_WNUM            1342
#define CT_ERROR_WMODE           1352
#define CT_ERROR_WMOVE           1362
#define CT_ERROR_WOPEN           1372
#define CT_ERROR_WROW            1382
#define CT_ERROR_WSELECT         1392
#define CT_ERROR_WSETMOVE        1404
#define CT_ERROR_WSETSHADOW      1412
#define CT_ERROR_WSTEP           1422

#define CT_ERROR_CGA40           1614
#define CT_ERROR_CGA80           1624
#define CT_ERROR_DSETKBIOS       1634
#define CT_ERROR_DSETNOLINE      1644
#define CT_ERROR_DSETQFILE       1654
#define CT_ERROR_DSETTYPE        1662
#define CT_ERROR_DSETWINDOW      1674
#define CT_ERROR_EGA43           1684
#define CT_ERROR_FIRSTCOL        1692
#define CT_ERROR_FIRSTROW        1702
#define CT_ERROR_GETBOXGROW      1712
#define CT_ERROR_GETCURSOR       1722
#define CT_ERROR_GETKXLAT        1732
#define CT_ERROR_GETKXTAB        1741
#define CT_ERROR_GETLINES        1752
#define CT_ERROR_GETMODE         1761
#define CT_ERROR_GETPAGE         1772
#define CT_ERROR_GETPBIOS        1782
#define CT_ERROR_GETPXLAT        1791
#define CT_ERROR_GETSCRMODE      1802
#define CT_ERROR_GETTAB          1811
#define CT_ERROR_INKEYTRAP       1822
#define CT_ERROR_INPUTMODE       1832
#define CT_ERROR_KEYREAD         1841
#define CT_ERROR_KEYSEND         1854
#define CT_ERROR_MAXCOL          1862
#define CT_ERROR_MAXPAGE         1872
#define CT_ERROR_MAXROW          1882
#define CT_ERROR_MONOCHROME      1894
#define CT_ERROR_PAGECOPY        1904
#define CT_ERROR_PRINTERROR      1912
#define CT_ERROR_SETBELL         1921
#define CT_ERROR_SETBOXGROW      1931
#define CT_ERROR_SETCURSOR       1942
#define CT_ERROR_SETKXLAT        1954
#define CT_ERROR_SETKXTAB        1964
#define CT_ERROR_SETLINES        1971
#define CT_ERROR_SETMAXCOL       1984
#define CT_ERROR_SETMAXROW       1994
#define CT_ERROR_SETPAGE         2004
#define CT_ERROR_SETPBIOS        2014
#define CT_ERROR_SETPXLAT        2024
#define CT_ERROR_SETQNAME        2034
#define CT_ERROR_SETSCRMODE      2044
#define CT_ERROR_SETTAB          2054
#define CT_ERROR_TRAPANYKEY      2061
#define CT_ERROR_TRAPINPUT       2071
#define CT_ERROR_TRAPSHIFT       2081
#define CT_ERROR_VGA28           2094
#define CT_ERROR_VGA50           2104

#define CT_ERROR_COM_BREAK       2414
#define CT_ERROR_COM_CLOSE       2424
#define CT_ERROR_COM_COUNT       2432
#define CT_ERROR_COM_CRC         2442
#define CT_ERROR_COM_CTS         2454
#define CT_ERROR_COM_DCD         2464
#define CT_ERROR_COM_DOSCON      2471
#define CT_ERROR_COM_DSR         2484
#define CT_ERROR_COM_DTR         2494
#define CT_ERROR_COM_ERRCHR      2504
#define CT_ERROR_COM_EVENT       2512
#define CT_ERROR_COM_FLUSH       2524
#define CT_ERROR_COM_GETIO       2532
#define CT_ERROR_COM_GETIRQ      2542
#define CT_ERROR_COM_HARD        2554
#define CT_ERROR_COM_INIT        2564
#define CT_ERROR_COM_KEY         2574
#define CT_ERROR_COM_LSR         2582
#define CT_ERROR_COM_MCR         2592
#define CT_ERROR_COM_MSR         2602
#define CT_ERROR_COM_NUM         2612
#define CT_ERROR_COM_OPEN        2624
#define CT_ERROR_COM_READ        2631
#define CT_ERROR_COM_REMOTE      2644
#define CT_ERROR_COM_RING        2654
#define CT_ERROR_COM_RTS         2664
#define CT_ERROR_COM_SCOUNT      2672
#define CT_ERROR_COM_SEND        2682
#define CT_ERROR_COM_SETIO       2694
#define CT_ERROR_COM_SETIRQ      2704
#define CT_ERROR_COM_SFLUSH      2714
#define CT_ERROR_COM_SKEY        2724
#define CT_ERROR_COM_SMODE       2732
#define CT_ERROR_COM_SOFT        2744
#define CT_ERROR_COM_SOFT_R      2754
#define CT_ERROR_COM_SOFT_S      2764
#define CT_ERROR_XMOBLOCK        2771
#define CT_ERROR_XMOCHECK        2782
#define CT_ERROR_ZEROINSERT      2791
#define CT_ERROR_ZEROREMOVE      2801

#define CT_ERROR_ADDASCII        3111
#define CT_ERROR_AFTERATNUM      3121
#define CT_ERROR_ASCIISUM        3132
#define CT_ERROR_ASCPOS          3142
#define CT_ERROR_ATADJUST        3151
#define CT_ERROR_ATNUM           3162
#define CT_ERROR_ATREPL          3171
#define CT_ERROR_ATTOKEN         3182
#define CT_ERROR_BEFORATNUM      3191
#define CT_ERROR_CENTER          3201
#define CT_ERROR_CHARADD         3211
#define CT_ERROR_CHARAND         3221
#define CT_ERROR_CHAREVEN        3231
#define CT_ERROR_CHARHIST        3247
#define CT_ERROR_CHARLIST        3251
#define CT_ERROR_CHARMIRR        3261
#define CT_ERROR_CHARMIX         3271
#define CT_ERROR_CHARNOLIST      3281
#define CT_ERROR_CHARNOT         3291
#define CT_ERROR_CHARODD         3301
#define CT_ERROR_CHARONE         3311
#define CT_ERROR_CHARONLY        3321
#define CT_ERROR_CHAROR          3331
#define CT_ERROR_CHARPACK        3341
#define CT_ERROR_CHARRELA        3352
#define CT_ERROR_CHARRELREP      3361
#define CT_ERROR_CHARREM         3371
#define CT_ERROR_CHARREPL        3381
#define CT_ERROR_CHARRLL         3391
#define CT_ERROR_CHARRLR         3401
#define CT_ERROR_CHARSHL         3411
#define CT_ERROR_CHARSHR         3421
#define CT_ERROR_CHARSLIST       3431
#define CT_ERROR_CHARSORT        3441
#define CT_ERROR_CHARSPREAD      3451
#define CT_ERROR_CHARSUB         3461
#define CT_ERROR_CHARSWAP        3471
#define CT_ERROR_CHARUNPACK      3481
#define CT_ERROR_CHARXOR         3491
#define CT_ERROR_CHECKSUM        3502
#define CT_ERROR_COUNTLEFT       3512
#define CT_ERROR_COUNTRIGHT      3522
#define CT_ERROR_CRYPT           3531
#define CT_ERROR_CSETATMUPA      3544
#define CT_ERROR_CSETREF         3554
#define CT_ERROR_EXPAND          3561
#define CT_ERROR_JUSTLEFT        3571
#define CT_ERROR_JUSTRIGHT       3581
#define CT_ERROR_LIKE            3594
#define CT_ERROR_LTOC            3601
#define CT_ERROR_MAXLINE         3612
#define CT_ERROR_NUMAT           3622
#define CT_ERROR_NUMLINE         3632
#define CT_ERROR_NUMTOKEN        3642
#define CT_ERROR_PADLEFT         3651
#define CT_ERROR_PADRIGHT        3661


[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 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/tests/hb_f.prg. Contains procedures: Main, my_goto. This file provides utility functions

[Assistant]
#require "hbmisc"

#include "fileio.ch"

PROCEDURE Main( cFile )

   hb_default( @cFile, __FILE__ )

   IF hb_FUse( cFile, FO_READ ) > 1

      DO WHILE ! hb_FAtEof()
         ? "line " + Str( hb_FRecNo(), 2 ) + " " + hb_FReadLn()
         hb_FSkip( 1 )
      ENDDO
      ?
      my_goto( 18 )
      my_goto( 2 )

      hb_FGoBottom()
      ?
      ? "after hb_FGoBottom() now in line # " + hb_ntos( hb_FRecNo() )

      hb_FGoTop()
      ?
      ? "after hb_FGoTop() now in line # " + hb_ntos( hb_FRecNo() )

      ?
      ? "hb_FLastRec() = " + hb_ntos( hb_FLastRec() )

      hb_FUse()
   ENDIF

   RETURN

STATIC PROCEDURE my_goto( n_go )

   hb_FGoto( n_go )
   ?
   ? "after hb_FGoto( " + hb_ntos( n_go ) + " )"
   ? "line " + hb_ntos( hb_FRecNo() ) + " is " + LTrim( hb_FReadLn() )

   RETURN


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

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

Header file for contribution module 'hbhpdf' (PDF generation library (libharu)): contrib/hbhpdf/harupdf.ch. Defines 10 constants including: _HARUPDF_CH, HPDF_INFO_CREATION_DATE, HPDF_INFO_MOD_DATE, HPDF_INFO_AUTHOR, HPDF_INFO_CREATOR. Defines color and display constants

[Assistant]
#ifndef _HARUPDF_CH
#define _HARUPDF_CH

#define HPDF_INFO_CREATION_DATE             0
#define HPDF_INFO_MOD_DATE                  1
#define HPDF_INFO_AUTHOR                    2
#define HPDF_INFO_CREATOR                   3
#define HPDF_INFO_PRODUCER                  4
#define HPDF_INFO_TITLE                     5
#define HPDF_INFO_SUBJECT                   6
#define HPDF_INFO_KEYWORDS                  7
#define HPDF_INFO_EOF                       8

#define HPDF_VER_12                         0
#define HPDF_VER_13                         1
#define HPDF_VER_14                         2
#define HPDF_VER_15                         3
#define HPDF_VER_16                         4
#define HPDF_VER_EOF                        5

#define HPDF_ENCRYPT_R2                     2
#define HPDF_ENCRYPT_R3                     3

#define HPDF_CS_DEVICE_GRAY                 0
#define HPDF_CS_DEVICE_RGB                  1
#define HPDF_CS_DEVICE_CMYK                 2
#define HPDF_CS_CAL_GRAY                    3
#define HPDF_CS_CAL_RGB                     4
#define HPDF_CS_LAB                         5
#define HPDF_CS_ICC_BASED                   6
#define HPDF_CS_SEPARATION                  7
#define HPDF_CS_DEVICE_N                    8
#define HPDF_CS_INDEXED                     9
#define HPDF_CS_PATTERN                     10
#define HPDF_CS_EOF                         11

#define HPDF_BUTT_END                       0
#define HPDF_ROUND_END                      1
#define HPDF_PROJECTING_SCUARE_END          2
#define HPDF_LINECAP_EOF                    3

#define HPDF_MITER_JOIN                     0
#define HPDF_ROUND_JOIN                     1
#define HPDF_BEVEL_JOIN                     2
#define HPDF_LINEJOIN_EOF                   3

#define HPDF_FILL                           0
#define HPDF_STROKE                         1
#define HPDF_FILL_THEN_STROKE               2
#define HPDF_INVISIBLE                      3
#define HPDF_FILL_CLIPPING                  4
#define HPDF_STROKE_CLIPPING                5
#define HPDF_FILL_STROKE_CLIPPING           6
#define HPDF_CLIPPING                       7
#define HPDF_RENDERING_MODE_EOF             8

#define HPDF_WMODE_HORIZONTAL               0
#define HPDF_WMODE_VERTICAL                 1
#define HPDF_WMODE_EOF                      2

#define HPDF_PAGE_LAYOUT_SINGLE             0
#define HPDF_PAGE_LAYOUT_ONE_COLUMN         1
#define HPDF_PAGE_LAYOUT_TWO_COLUMN_LEFT    2
#define HPDF_PAGE_LAYOUT_TWO_COLUMN_RIGHT   3
#define HPDF_PAGE_LAYOUT_EOF                4

#define HPDF_PAGE_MODE_USE_NONE             0
#define HPDF_PAGE_MODE_USE_OUTLINE          1
#define HPDF_PAGE_MODE_USE_THUMBS           2
#define HPDF_PAGE_MODE_FULL_SCREEN          3
#define HPDF_PAGE_MODE_EOF                  4

#define HPDF_PAGE_NUM_STYLE_DECIMAL         0
#define HPDF_PAGE_NUM_STYLE_UPPER_ROMAN     1
#define HPDF_PAGE_NUM_STYLE_LOWER_ROMAN     2
#define HPDF_PAGE_NUM_STYLE_UPPER_LETTERS   3
#define HPDF_PAGE_NUM_STYLE_LOWER_LETTERS   4
#define HPDF_PAGE_NUM_STYLE_EOF             5

#define HPDF_XYZ                            0
#define HPDF_FIT                            1
#define HPDF_FIT_H                          2
#define HPDF_FIT_V                          3
#define HPDF_FIT_R                          4
#define HPDF_FIT_B                          5
#define HPDF_FIT_BH                         6
#define HPDF_FIT_BV                         7
#define HPDF_DST_EOF                        8

#define HPDF_ANNOT_TEXT_NOTES               0
#define HPDF_ANNOT_LINK                     1
#define HPDF_ANNOT_SOUND                    2
#define HPDF_ANNOT_FREE_TEXT                3
#define HPDF_ANNOT_STAMP                    4
#define HPDF_ANNOT_SQUARE                   5
#define HPDF_ANNOT_CIRCLE                   6
#define HPDF_ANNOT_STRIKE_OUT               7
#define HPDF_ANNOT_HIGHTLIGHT               8
#define HPDF_ANNOT_UNDERLINE                9
#define HPDF_ANNOT_INK                      10
#define HPDF_ANNOT_FILE_ATTACHMENT          11
#define HPDF_ANNOT_POPUP                    12

#define HPDF_ANNOT_INVISIBLE                0
#define HPDF_ANNOT_HIDDEN                   1
#define HPDF_ANNOT_PRINT                    2
#define HPDF_ANNOT_NOZOOM                   3
#define HPDF_ANNOT_NOROTATE                 4
#define HPDF_ANNOT_NOVIEW                   5
#define HPDF_ANNOT_READONLY                 6

#define HPDF_ANNOT_NO_HIGHTLIGHT            0
#define HPDF_ANNOT_INVERT_BOX               1
#define HPDF_ANNOT_INVERT_BORDER            2
#define HPDF_ANNOT_DOWN_APPEARANCE          3
#define HPDF_ANNOT_HIGHTLIGHT_MODE_EOF      4

#define HPDF_ANNOT_ICON_COMMENT             0
#define HPDF_ANNOT_ICON_KEY                 1
#define HPDF_ANNOT_ICON_NOTE                2
#define HPDF_ANNOT_ICON_HELP                3
#define HPDF_ANNOT_ICON_NEW_PARAGRAPH       4
#define HPDF_ANNOT_ICON_PARAGRAPH           5
#define HPDF_ANNOT_ICON_INSERT              6
#define HPDF_ANNOT_ICON_EOF                 7

#define HPDF_BS_SOLID                       0
#define HPDF_BS_DASHED                      1
#define HPDF_BS_BEVELED                     2
#define HPDF_BS_INSET                       3
#define HPDF_BS_UNDERLINED                  4

#define HPDF_BM_NORMAL                      0
#define HPDF_BM_MULTIPLY                    1
#define HPDF_BM_SCREEN                      2
#define HPDF_BM_OVERLAY                     3
#define HPDF_BM_DARKEN                      4
#define HPDF_BM_LIGHTEN                     5
#define HPDF_BM_COLOR_DODGE                 6
#define HPDF_BM_COLOR_BUM                   7
#define HPDF_BM_HARD_LIGHT                  8
#define HPDF_BM_SOFT_LIGHT                  9
#define HPDF_BM_DIFFERENCE                  10
#define HPDF_BM_EXCLUSHON                   11
#define HPDF_BM_EOF                         12

#define HPDF_TS_WIPE_RIGHT                  0
#define HPDF_TS_WIPE_UP                     1
#define HPDF_TS_WIPE_LEFT                   2
#define HPDF_TS_WIPE_DOWN                   3
#define HPDF_TS_BARN_DOORS_HORIZONTAL_OUT   4
#define HPDF_TS_BARN_DOORS_HORIZONTAL_IN    5
#define HPDF_TS_BARN_DOORS_VERTICAL_OUT     6
#define HPDF_TS_BARN_DOORS_VERTICAL_IN      7
#define HPDF_TS_BOX_OUT                     8
#define HPDF_TS_BOX_IN                      9
#define HPDF_TS_BLINDS_HORIZONTAL           10
#define HPDF_TS_BLINDS_VERTICAL             11
#define HPDF_TS_DISSOLVE                    12
#define HPDF_TS_GLITTER_RIGHT               13
#define HPDF_TS_GLITTER_DOWN                14
#define HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT 15
#define HPDF_TS_REPLACE                     16
#define HPDF_TS_EOF                         17

#define HPDF_PAGE_SIZE_LETTER               0
#define HPDF_PAGE_SIZE_LEGAL                1
#define HPDF_PAGE_SIZE_A3                   2
#define HPDF_PAGE_SIZE_A4                   3
#define HPDF_PAGE_SIZE_A5                   4
#define HPDF_PAGE_SIZE_B4                   5
#define HPDF_PAGE_SIZE_B5                   6
#define HPDF_PAGE_SIZE_EXECUTIVE            7
#define HPDF_PAGE_SIZE_US4x6                8
#define HPDF_PAGE_SIZE_US4x8                9
#define HPDF_PAGE_SIZE_US5x7                10
#define HPDF_PAGE_SIZE_COMM10               11
#define HPDF_PAGE_SIZE_EOF                  12

#define HPDF_PAGE_PORTRAIT                  0
#define HPDF_PAGE_LANDSCAPE                 1

#define HPDF_ENCODER_TYPE_SINGLE_BYTE       0
#define HPDF_ENCODER_TYPE_DOUBLE_BYTE       1
#define HPDF_ENCODER_TYPE_UNINITIALIZED     2
#define HPDF_ENCODER_UNKNOWN                3

#define HPDF_BYTE_TYPE_SINGLE               0
#define HPDF_BYTE_TYPE_LEAD                 1
#define HPDF_BYTE_TYPE_TRIAL                2
#define HPDF_BYTE_TYPE_UNKNOWN              3

#define HPDF_TALIGN_LEFT                    0
#define HPDF_TALIGN_RIGHT                   1
#define HPDF_TALIGN_CENTER                  2
#define HPDF_TALIGN_JUSTIFY                 3

#define HPDF_TRUE                           .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] Implement this Harbour module: Harbour source file: src/rdd/rddord.prg. Provides 7 functions including: dbCreateIndex, dbSetIndex, dbClearIndex, dbReindex, IndexExt. Contains procedures: dbSetOrder. This file implements core Record Driver Driver functionality

[Assistant]
#include "dbinfo.ch"

FUNCTION dbCreateIndex( cOrderBagName, cKeyExpr, bKeyExpr, lUnique, cOrderName )
   RETURN ordCreate( cOrderBagName, cOrderName, cKeyExpr, bKeyExpr, lUnique )

FUNCTION dbSetIndex( cIndexName )
   RETURN ordListAdd( cIndexName )

FUNCTION dbClearIndex()
   RETURN ordListClear()

FUNCTION dbReindex()
   RETURN ordListRebuild()

PROCEDURE dbSetOrder( nOrderNum )

   IF HB_ISSTRING( nOrderNum ) .AND. ! Empty( Val( nOrderNum ) )
      nOrderNum := Val( nOrderNum )
   ENDIF

   ordSetFocus( nOrderNum )

   RETURN

FUNCTION IndexExt()
   RETURN ordBagExt()

FUNCTION IndexKey( nOrder )

   IF ! HB_ISNUMERIC( nOrder )
      RETURN ordKey( nOrder )
   ENDIF

   IF Used()
      RETURN ordKey( nOrder )
   ENDIF

   RETURN ""

FUNCTION ordSetRelation( xArea, bRelation, cRelation )
   RETURN dbSetRelation( xArea, bRelation, cRelation, .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] Define Harbour macros and constants: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charsub.prg. Contains procedures: Main. This file provides legacy compatibility functions

[Assistant]
#ifdef __HARBOUR__
#require "hbct"
#else
#define hb_BChar( n ) Chr( n )
#endif

PROCEDURE Main()

   ctinit()

   ? "Begin test of CharSub()"
   ?

   ? "Simple tests:"
   ? '  CharAdd( "123456789", hb_BChar( 1 ) ) == "012345678" ? -> "' + CharSub( "123456789", hb_BChar( 1 ) ) + '"'
   ? '  CharAdd( "123456789", hb_BChar( 1 ) + hb_BChar( 2 ) ) == "002244668" ? -> "' + CharSub( "123456789", hb_BChar( 1 ) + hb_BChar( 2 ) ) + '"'
   ? '  CharAdd( "012345678", hb_BChar( 255 ) ) == "123456789" ? -> "' + CharSub( "012345678", hb_BChar( 255 ) ) + '"'
   ? '  CharAdd( "012345678", hb_BChar( 255 ) + hb_BChar( 254 ) ) == "133557799" ? -> "' + CharSub( "012345678", hb_BChar( 255 ) + hb_BChar( 254 ) ) + '"'

   ? "End test of CharSub()"
   ?

   ctexit()

   RETURN


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

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

Harbour test program: tests/wcecon.prg. This test file tests specific function APIs

[Assistant]
#include "hbgtinfo.ch"

request DBFCDX

proc main()

   field F1, F2, FX
   local nMaxScrRow, nMaxScrCol
   local cPath, cName, cExt, cDrive
   local i, j, k

   hb_gtInfo( HB_GTI_CODEPAGE, 255 )

   hb_cdpSelect( "EN" )
   hb_setTermCP( "EN" )

   hb_gtInfo( HB_GTI_FONTWIDTH, 6 )
   hb_gtInfo( HB_GTI_FONTSIZE, 12 )

   SetMode( MaxRow() + 1, MaxCol() + 1 )

   nMaxScrRow := hb_gtInfo( HB_GTI_DESKTOPROWS )
   nMaxScrCol := hb_gtInfo( HB_GTI_DESKTOPCOLS )

   SetMode( nMaxScrRow, nMaxScrCol )

   ? "rows =", hb_ntos( maxrow() + 1 )
   ? "cols =", hb_ntos( maxcol() + 1 )
   inkey( 0 )

   alert( OS() + ";" + Version() + ";GT" + hb_gtVersion() )

   hb_FNameSplit( hb_argv( 0 ), @cPath, @cName, @cExt, @cDrive )
   cPath += "data" + hb_ps()

   Alert( "Database path:;;" + cPath )

   rddSetDefault("DBFCDX")
   if ! hb_dirExists( cPath )
      hb_dirCreate( cPath )
   endif
   dbCreate( cPath + "mydata", { ;
      { "F1", "C", 10, 0 }, ;
      { "F2", "=",  8, 0 }, ;
      { "FX", "M",  4, 0 } } )
   use ( cPath + "mydata" )
   index on F1 tag T1
   index on F2 tag T2
   while lastrec() < 10
      dbappend()
      F1 := "rec:" + str( recno(), 3 )
      FX := "[rec:" + str( recno(), 3 ) + "]"
   enddo
   dbCommit()
   dbGoTop()
   browse()

   CLS
   for i := 0 to 15
      for j := 0 to 15
         dispout( " " + chr( i
   ?; devout( hb_UTF8ToStr( "┌─┬─┐  ╔═╦═╗  ╒═╤═╕  ╓─╥─╖  ▄▄▄" ) )
   ?; devout( hb_UTF8ToStr( "│ │ │  ║ ║ ║  ├─┼─┤  ╟─╫─╢  ▌■▐" ) )
   ?; devout( hb_UTF8ToStr( "├─┼─┤  ╠═╬═╣  │ │ │  ║ ║ ║  ▌█▐" ) )
   ?; devout( hb_UTF8ToStr( "│ │ │  ║ ║ ║  ╞═╪═╡  ╠═╬═╣  ▌■▐" ) )
   ?; devout( hb_UTF8ToStr( "└─┴─┘  ╚═╩═╝  ╘═╧═╛  ╙─╨─╜  ▀▀▀" ) )
   inkey( 0 )

   ?
   ? "@ - interrupt, keycodes test "
   while ( k := inkey( 0 ) ) != hb_keyCode( "@" )
      ? ; devout( "key=" + str( k, 12 ) + ", char='" + hb_keyChar( k ) + "'" )
   enddo

   dbCloseAll()

   hb_dbDrop( cPath + "mydata" )
   DirRemove( cPath )

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

[Assistant]
FUNCTION ft_SInkey( waittime )

   LOCAL nKey, cBlock

   DO CASE
   CASE PCount() == 0
      nKey := Inkey()

   CASE waittime == NIL .AND. PCount() == 1
      nKey := Inkey( 0 )

   OTHERWISE
      nKey := Inkey( waittime )

   ENDCASE

   IF ( cBlock := SetKey( nKey ) ) != NIL

      Eval( cBlock, ProcName( 1 ), ProcLine( 1 ), NIL )
   ENDIF

   RETURN nKey


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

[Assistant]
#include "inkey.ch"

PROCEDURE Main()

   LOCAL cColor := SetColor( "W+/B" )

#ifdef _SET_EVENTMASK
   Set( _SET_EVENTMASK, INKEY_ALL )
   MSetCursor( .T. )
#endif

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

   CLS

   USE test
   Browse()

   SetColor( cColor )
   CLS

   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 'hbxdiff' (File difference/patching): contrib/hbxdiff/tests/test3.prg. Provides functions: Diff. Contains procedures: Main. This file provides utility functions

[Assistant]
#require "hbxdiff"

PROCEDURE Main()

   LOCAL pMMFOld, pMMFNew
   LOCAL cFileCtx

   pMMFOld := xdl_init_mmfile( XDLT_STD_BLKSIZE )
   pMMFNew := xdl_init_mmfile( XDLT_STD_BLKSIZE, XDL_MMF_ATOMIC )

   cFileCtx := hb_MemoRead( __FILE__ )

   xdl_write_mmfile( pMMFOld, @cFileCtx )
   xdl_write_mmfile( pMMFNew, cFileCtx + hb_eol() + Space( 3 ) + "RETURN NIL" + hb_eol() )

   xdl_diff( pMMFOld, pMMFNew, 0, 3, {| ... | Diff( ... ) } )
   xdl_diff( pMMFOld, pMMFNew, 0, 3, @Diff() )

   RETURN

FUNCTION Diff( ... )

   LOCAL e

   FOR EACH e IN { ... }
      ? e
   NEXT

   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] Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/elapsed.prg. Provides functions: ft_Elapsed. This file provides legacy compatibility functions

[Assistant]
FUNCTION ft_Elapsed( dStart, dEnd, cTimeStart, cTimeEnd )

   LOCAL nTotalSec, nCtr, nConstant, nTemp, aRetVal[ 4 ][ 2 ]

   IF HB_ISSTRING( dStart )
      cTimeStart := dStart
      dStart     := Date()
   ELSEIF ! HB_ISDATE( dStart )
      dStart     := Date()
   ENDIF

   IF HB_ISSTRING( dEnd )
      cTimeEnd := dEnd
      dEnd     := Date()
   ELSEIF ! HB_ISDATE( dEnd )
      dEnd     := Date()
   ENDIF

   IF ! HB_ISSTRING( cTimeStart )
      cTimeStart := "00:00:00"
   ENDIF
   IF ! HB_ISSTRING( cTimeEnd )
      cTimeEnd   := "00:00:00"
   ENDIF

   nTotalSec := ( dEnd - dStart )
      Val( SubStr( cTimeEnd, At( ":", cTimeEnd ) + 1, 2 ) )
      iif( RAt( ":", cTimeEnd ) == At( ":", cTimeEnd ), 0, ;
      Val( SubStr( cTimeEnd, RAt( ":", cTimeEnd ) + 1 ) ) ) - ;
      Val( cTimeStart )
      Val( SubStr( cTimeStart, At( ":", cTimeStart ) + 1, 2 ) )
      iif( RAt( ":", cTimeStart ) == At( ":", cTimeStart ), 0, ;
      Val( SubStr( cTimeStart, RAt( ":", cTimeStart ) + 1 ) ) )

   nTemp := nTotalSec

   FOR nCtr := 1 TO 4
      nConstant := iif( nCtr == 1, 86400, iif( nCtr == 2, 3600, iif( nCtr == 3, 60, 1 ) ) )
      aRetVal[ nCtr ][ 1 ] := Int( nTemp / nConstant )
      aRetval[ nCtr ][ 2 ] := nTotalSec / nConstant
      nTemp -= aRetVal[ nCtr ][ 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]
Write the following Harbour (xBase/Clipper) code:

Harbour contribution module 'sddoci' (): contrib/sddoci/tests/test1.prg. Contains procedures: Main. This file handles database operations

[Assistant]
#require "rddsql"
#require "sddoci"

#include "simpleio.ch"

REQUEST SDDOCI, SQLMIX

PROCEDURE Main()

   LOCAL tmp

#if defined( __HBSCRIPT__HBSHELL )
   rddRegister( "SQLBASE" )
   rddRegister( "SQLMIX" )
   hb_SDDOCI_Register()
#endif

   rddSetDefault( "SQLMIX" )

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

   AEval( rddList(), {| X | QOut( X ) } )

   ? "-1-"
   ? "Connect:", tmp := rddInfo( RDDI_CONNECT, { "OCILIB", "ORCL", "scott", "tiger" } )
   IF tmp == 0
      ? "Unable connect to the server"
   ENDIF
   ? "-2-"
   ? "Use:", dbUseArea( .T., , "select * from emp", "emp" )
   ? "-3-"
   ? "Alias:", Alias()
   ? "-4-"
   ? "DB struct:", hb_ValToExp( dbStruct() )
   ? "-5-"
   FOR tmp := 1 TO FCount()
      ? FieldName( tmp ), hb_FieldType( tmp ), hb_FieldLen( tmp ), hb_FieldDec( tmp )
   NEXT
   ? "-6-"
   Inkey( 0 )
   Browse()

   INDEX ON FIELD->SAL TO salary
   dbGoTop()
   Browse()
   dbCloseArea()

   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 'gtwvg' (): contrib/gtwvg/tests/demowvg1.prg. Provides functions: wvt_Paint, SetGT, MyChoice, DispStatusMsg, ClearStatusMsg. Contains 4 procedures. This file provides platform-specific functionality

[Assistant]
#require "gtwvg"

#include "inkey.ch"
#include "hbgtinfo.ch"
#include "hbver.ch"

#define IMAGE_VOUCH                hb_DirBase() + "vouch1.bmp"
#define IMAGE_BROWSE               hb_DirBase() + "v_browse.ico"
#define IMAGE_VR                   hb_DirBase() + "vr_1.ico"
#define IMAGE_NOTES                hb_DirBase() + "v_notes.ico"
#define IMAGE_TOOLS                hb_DirBase() + "v_tools.ico"
#define IMAGE_HELP                 hb_DirBase() + "v_notes.ico"

MEMVAR GetList

PROCEDURE Main()

   LOCAL aPaint

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

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

   Set( _SET_EVENTMASK, INKEY_ALL + HB_INKEY_GTEVENT )

   wvt_SetGUI( .T. )
   wvt_SetFont( "Courier New", 18, 0, 0 )
   wvt_SetMouseMove( .T. )

   SetColor( "N/W" )
   CLS
   wvt_ShowWindow( SW_RESTORE )
   Wvt_SetTitle( "Harbour's GTWVG Demo ( Simplified )" )
   wvt_SetIcon( hb_DirBase() +  "vr_1.ico" )

   SetGT( 1, hb_gtSelect() )

   aPaint := {}

   AAdd( aPaint, { "Label", {|| wvt_DrawLabel( 1, 40, "Harbour Console GUI Demo", 6, , RGB( 255, 255, 255 ), RGB( 198, 198, 198 ), "Arial", 26, , , , , .T., .T. ) }, { WVT_BLOCK_LABEL, 1, 10, 3, 50 } } )
   AAdd( aPaint, { "Box_1", {|| wvt_DrawBoxRaised( 4, 4, 20, 75 ) }, { WVT_BLOCK_BOX, 4, 4, 20, 75 } } )
   AAdd( aPaint, { "Box_2", {|| wvt_DrawBoxRecessed( 7, 61, 13, 70 ) }, { WVT_BLOCK_BOX, 7, 61, 13, 70 } } )
   AAdd( aPaint, { "Box_3", {|| wvt_DrawBoxGroup( 15, 59, 18, 72 ) }, { WVT_BLOCK_BOX, 15, 59, 18, 72 } } )
   AAdd( aPaint, { "Box_4", {|| wvt_DrawBoxGroup( 5, 6, 19, 44 ) }, { WVT_BLOCK_BOX, 5, 6, 19, 44 } } )
   AAdd( aPaint, { "Image", {|| wvt_DrawImage( 8, 62, 12, 69, IMAGE_VOUCH ) }, { WVT_BLOCK_IMAGE, 8, 62, 12, 69 } } )
   AAdd( aPaint, { "Box_5", {|| wvt_DrawBoxRecessed( 7, 48, 13, 55 ) }, { WVT_BLOCK_BOX, 7, 48, 13, 55 } } )
   AAdd( aPaint, { "Line_1", {|| wvt_DrawLine( MaxRow() - 2, 0, MaxRow() - 2, MaxCol(), WVT_LINE_HORZ, WVT_LINE_RECESSED, WVT_LINE_BOTTOM ) }, NIL } )
   AAdd( aPaint, { "Gets", {|| AEval( GetList, {| oGet | wvt_DrawBoxGet( oGet:Row, oGet:Col, Len( Transform( oGet:VarGet(), oGet:Picture ) ) ) } ) }, NIL } )

   ExecForm( aPaint )

   RETURN

FUNCTION wvt_Paint()

   WvtPaintObjects()

   RETURN NIL

STATIC PROCEDURE ExecForm( aPaint )

   LOCAL cColor  := SetColor()
   LOCAL aPnt
   LOCAL dDate   := Date()
   LOCAL cName   := PadR( "Pritpal Bedi", 35 )
   LOCAL cAdd1   := PadR( "60, New Professor Colony", 35 )
   LOCAL cAdd2   := PadR( "Ludhiana, INDIA", 35 )
   LOCAL cAdd3   := PadR( hb_Version( HB_VERSION_URL_BASE ), 35 )
   LOCAL nSlry   := 20000
   LOCAL nColGet := 8

   aPnt := WvtSetPaint( aPaint )

   SetColor( "N/W" )
   CLS
   SetColor( "N/W,N/GR*,,,N/W*" )

   SetKey( K_F2, {|| DoModalDialog() } )

   @  6, nColGet SAY "< Date >"
   @  9, nColGet SAY "<" + PadC( "Name", 33 ) + ">"
   @ 12, nColGet SAY "<" + PadC( "Address", 33 ) + ">"
   @ 16, 61      SAY "< Salary >"
   @  7, nColGet GET dDate WHEN DispStatusMsg( "Date must be Valid" )
   @ 10, nColGet GET cName WHEN DispStatusMsg( "Must be one of the list!" ) VALID ( MyChoice() < 7 )
   @ 13, nColGet GET cAdd1 WHEN DispStatusMsg( "Press F2 to get modal window" )
   @ 15, nColGet GET cAdd2 WHEN DispStatusMsg( "Press F2 to activate modal window" )
   @ 17, nColGet GET cAdd3 WHEN DispStatusMsg( "Press F2 to bring in front a modal window" )
   @ 17, 61      GET nSlry PICTURE "@Z 9999999.99" WHEN ClearStatusMsg()

   READ

   SetColor( cColor )
   WvtSetPaint( aPnt )

   RETURN

STATIC FUNCTION SetGT( nIndex, pGT )

   LOCAL oldGT
   STATIC s_pGT_ := { NIL, NIL, NIL }

   oldGT := s_pGT_[ nIndex ]
   IF PCount() == 2
      s_pGT_[ nIndex ] := pGT
   ENDIF

   RETURN oldGT

STATIC FUNCTION MyChoice( aChoices )

   LOCAL scr, clr, nChoice

   hb_default( @aChoices, { "One", "Two", "Three", "Four", "Five", "Six", "Seven" } )

   scr := SaveScreen( 7, 48, 13, 55 )
   clr := SetColor( "N/W*,GR+/B*,,,GR+/B" )

   nChoice := AChoice( 7, 48, 13, 55, aChoices )

   SetColor( clr )
   RestScreen( 7, 48, 13, 55, scr )

   RETURN nChoice

FUNCTION DispStatusMsg( cMsg )

   ClearStatusMsg()

   wvt_DrawLabel( MaxRow(), 60, cMsg, 6, , 0, RGB( 198, 198, 198 ), "Arial", 18, , 900 )

   RETURN .T.

STATIC FUNCTION ClearStatusMsg()

   LOCAL nRow := Row()
   LOCAL nCol := Col()

   hb_DispOutAt( MaxRow(), 42, Space( 37 ), "W/W" )

   SetPos( nRow, nCol )

   RETURN .T.

STATIC PROCEDURE DoModalDialog()

   LOCAL oCrt, nSel
   LOCAL aPnt   := WvtSetPaint( {} )
   LOCAL aPaint := {}

   oCrt := WvgCrt():New( , , { 4, 8 }, { 12, 49 }, , .T. )

   oCrt:lModal      := .T.
   oCrt:resizable   := .F.
   oCrt:closable    := .F.
   oCrt:title       := "Modal Dialog!"
   oCrt:icon        := hb_DirBase() + "vr_1.ico"

   oCrt:Create()
   oCrt:show()

   AAdd( aPaint, { "Box_V", {|| wvt_DrawBoxRaised( 1, 2, 11, 47 ) }, NIL, { WVT_BLOCK_BOX, 0, 0, MaxRow(), MaxCol() } } )
   WvtSetPaint( aPaint )

   SetColor( "N/W" )
   CLS
   DO WHILE .T.
      nSel := Alert( "A modal window !;Click on parent window;Move this window", { "OK" } )
      IF nSel == 0 .OR. nSel == 1
         EXIT
      ENDIF
   ENDDO

   oCrt:Destroy()

   WvtSetPaint( aPnt )

   RETURN

#if ! defined( __HBSCRIPT__HBSHELL )

PROCEDURE hb_GTSYS()

   REQUEST HB_GT_WVG_DEFAULT
   REQUEST HB_GT_WVT
   REQUEST HB_GT_WGU

   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]
Here is a Harbour (xBase/Clipper) implementation:

Harbour contribution module 'hbblat' (Blat email sending utility): contrib/hbblat/tests/test.prg. Contains procedures: Main. This file provides utility functions

[Assistant]
#require "hbblat"

#define ADDRESS_FROM   "yourname@domain.com"
#define ADDRESS_TO     "hbblat_test@fsgiudice.com"

#define SERVER_SMTP    "your.stmpserver.com"

PROCEDURE Main()

   LOCAL nRet
   LOCAL oBlat := HBBlat():New()

   ?
   ? "HBBlat test"

   oBlat:cFrom                   := ADDRESS_FROM
   oBlat:cTo                     := ADDRESS_TO

   oBlat:cBody                   := e"Body part\n\rEnd Body"
   oBlat:cServerSMTP             := SERVER_SMTP
   oBlat:cSubject                := "Test from Blat"

   oBlat:cPostScriptumFile       := "f_ps.txt"
   oBlat:lRequestDisposition     := .T.
   oBlat:lRequestReturnReceipt   := .T.

   oBlat:cAttachTextFiles        := "f_subjct.txt"
   oBlat:aAttachTextFiles        := { __FILE__, "blatcmd.prg", "f_ps.txt" }
   oBlat:cAttachListTextFile     := "f_listtx.txt"

   oBlat:cLogFile                := "log.txt"
   oBlat:lLogTimestamp           := .T.
   oBlat:lDebug                  := .T.
   oBlat:lLogOverwrite           := .T.

   ? "Checking options ..."

   ?
   ? "Command .........: ", oBlat:GetCommand()

   ? "Sending mail ..."
   ? "Return Value ....: ", nRet := oBlat:Send()

   ? "Error String ....: ", oBlat:ErrorString()

   ? "Blat Error ......: ", oBlat:BlatError()
   ? "Blat Error String: ", oBlat:BlatErrorString()

   ?
   ? iif( nRet == 0, "mail sent correctly!", "mail NOT sent" )
   ?

   RETURN


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

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

Harbour test program: tests/classch.prg. Defines classes: TTest, TParent. Contains procedures: Main. This test file tests object-oriented programming features

[Assistant]
#include "hbclass.ch"

PROCEDURE Main()

   LOCAL o := TTest():New( "one", "two" )

   ? o:ClassName()
   ? o:One
   ? o:Two

   o:Test()

   RETURN

CREATE CLASS TTest INHERIT TParent

   VAR One, Two, Three

   METHOD New( One, Two )

   METHOD Test() INLINE QOut( "Hello" )

ENDCLASS

METHOD New( One, Two ) CLASS TTest

   ::super:New()

   ::One := One
   ::Two := Two

   RETURN Self

CREATE CLASS TParent

   VAR One

   METHOD New()

ENDCLASS

METHOD New() CLASS TParent

   ? "TParent:New()"

   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 header file: include/hbhash.ch. Defines 10 constants including: HB_HASH_CH_, HB_HAUTOADD_NEVER, HB_HAUTOADD_ACCESS, HB_HAUTOADD_ASSIGN, HB_HAUTOADD_ALWAYS. Defines Harbour internal constants and macros

[Assistant]
#ifndef HB_HASH_CH_
#define HB_HASH_CH_

#define HB_HAUTOADD_NEVER       0x00
#define HB_HAUTOADD_ACCESS      0x01
#define HB_HAUTOADD_ASSIGN      0x02
#define HB_HAUTOADD_ALWAYS      hb_bitOr( HB_HAUTOADD_ACCESS, HB_HAUTOADD_ASSIGN )
#define HB_HAUTOADD_REFERENCE   HB_HAUTOADD_ALWAYS

#define HB_HMERGE_UNION         0
#define HB_HMERGE_INTERSECT     1
#define HB_HMERGE_DIFFERENCE    2
#define HB_HMERGE_REMOVE        3

#endif


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

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

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

[Assistant]
#include "simpleio.ch"

#include "hbdyn.ch"

PROCEDURE Main()

   #if defined( __PLATFORM__WINDOWS )

   LOCAL hLib
   LOCAL cData

   #define MAX_PATH 260

   #define MB_OK                       0x00000000
   #define MB_OKCANCEL                 0x00000001
   #define MB_ABORTRETRYIGNORE         0x00000002
   #define MB_YESNOCANCEL              0x00000003
   #define MB_YESNO                    0x00000004
   #define MB_RETRYCANCEL              0x00000005
   #define MB_CANCELTRYCONTINUE        0x00000006
   #define MB_ICONHAND                 0x00000010
   #define MB_ICONQUESTION             0x00000020
   #define MB_ICONEXCLAMATION          0x00000030
   #define MB_ICONASTERISK             0x00000040
   #define MB_USERICON                 0x00000080
   #define MB_DEFBUTTON2               0x00000100
   #define MB_DEFBUTTON3               0x00000200
   #define MB_DEFBUTTON4               0x00000300
   #define MB_SYSTEMMODAL              0x00001000
   #define MB_TASKMODAL                0x00002000
   #define MB_HELP                     0x00004000
   #define MB_NOFOCUS                  0x00008000
   #define MB_SETFOREGROUND            0x00010000
   #define MB_DEFAULT_DESKTOP_ONLY     0x00020000
   #define MB_TOPMOST                  0x00040000
   #define MB_RIGHT                    0x00080000
   #define MB_RTLREADING               0x00100000

   ? "MsgBox:", hb_DynCall( { "MessageBoxA", "user32.dll", HB_DYN_CALLCONV_STDCALL }, 0, "Hello world!", "Harbour sez", hb_bitOr( MB_OKCANCEL, MB_ICONEXCLAMATION, MB_HELP ) )

   hLib := hb_libLoad( "libcurl.dll" )
   IF ! Empty( hLib )
      ? hb_DynCall( { "curl_version", hLib, HB_DYN_CTYPE_CHAR_PTR } )
      hb_libFree( hLib )
      ? hb_DynCall( { "curl_version", "libcurl.dll", HB_DYN_CTYPE_CHAR_PTR } )
   ENDIF

   #define SPI_SETDRAGFULLWINDOWS 37

   ? "Full content drag: OFF"
   ? hb_DynCall( { "SystemParametersInfo", "user32.dll", HB_DYN_CALLCONV_STDCALL }, SPI_SETDRAGFULLWINDOWS, 0, 0, 0 )
   Inkey( 0 )

   ? "Full content drag: ON"
   ? hb_DynCall( { "SystemParametersInfo", "user32.dll", HB_DYN_CALLCONV_STDCALL }, SPI_SETDRAGFULLWINDOWS, 1, 0, 0 )
   Inkey( 0 )

   #define CSIDL_APPDATA               0x001a
   #define CSIDL_ADMINTOOLS            0x0030

   hLib := hb_libLoad( "shell32.dll" )
   ? "ValType( hLib ): ", ValType( hLib )
   ? "------"
   cData := Space( MAX_PATH )
   ? "HB_DYNCALL (BOOL retval): ", hb_DynCall( { "SHGetSpecialFolderPathA", hLib, hb_bitOr( HB_DYN_CALLCONV_STDCALL, HB_DYN_CTYPE_BOOL ) }, 0, @cData, CSIDL_APPDATA, 0 )
   ? "@cData: ", cData, "<"
   ? "------"
   ? "HB_DYNCALL: ", hb_DynCall( { "SHGetFolderPathA", hLib, HB_DYN_CALLCONV_STDCALL }, 0, CSIDL_ADMINTOOLS, 0, 0, cData )
   ? "cData:", cData, "<"
   ? "------"
   cData := Space( MAX_PATH )
   ? "HB_DYNCALL (PARAMS): ", hb_DynCall( { "SHGetSpecialFolderPathA", hLib, HB_DYN_CALLCONV_STDCALL, NIL, NIL, NIL, HB_DYN_CTYPE_BOOL }, 0, @cData, CSIDL_APPDATA, 0 )
   ? "@cData: ", cData, "<"
   ? "------"
   cData := Space( MAX_PATH )
   ? "HB_DYNCALL @ASCII: ", hb_DynCall( { "SHGetFolderPathA", hLib, HB_DYN_CALLCONV_STDCALL }, 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
   ? "@cData: ", cData, "<"
   ? "------"
   cData := Space( MAX_PATH )
   ? "HB_DYNCALL @UTF16: ", hb_DynCall( { "SHGetFolderPathW", hLib, HB_DYN_CALLCONV_STDCALL + HB_DYN_ENC_UTF16 }, 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
   ? "@cData: ", cData, "<"
   ? "------"
   cData := Space( MAX_PATH )
   ? "HB_DYNCALL @UTF16 + psz: ", hb_DynCall( { "SHGetFolderPathW", hLib, HB_DYN_CALLCONV_STDCALL + HB_DYN_ENC_UTF16 + HB_DYC_OPT_NULLTERM }, 0, CSIDL_ADMINTOOLS, 0, 0, @cData )
   ? "@cData: ", cData, "<"
   ? "------"
   cData := Space( MAX_PATH )
   ? "cData BEFORE: ", cData, "<"
   ? "HB_DYNCALL (MISSING @): ", hb_DynCall( { "SHGetFolderPathA", hLib, HB_DYN_CALLCONV_STDCALL }, 0, CSIDL_ADMINTOOLS, 0, 0, cData )
   ? "cData AFTER: ", cData, "<"
   ? "------"
   hb_libFree( hLib )

   #endif

   RETURN