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

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

Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/tbwhile.prg. Provides functions: make_dbf. Contains procedures: Main. This file provides legacy compatibility functions

[Assistant]
#require "hbnf"

PROCEDURE Main()

   LOCAL aFields := {}, cKey := "O", cOldColor
   LOCAL nFreeze := 1, lSaveScrn := .T., nRecSel
   LOCAL cColorList := "N/W, N/BG, B/W, B/BG, B/W, B/BG, R/W, B/R"
   LOCAL cColorShad := "N/N"
   LOCAL GetList := {}

   FIELD last, first

   IF ! hb_dbExists( "tbnames.dbf" )
      make_dbf()
   ENDIF

   USE tbnames

   IF ! hb_dbExists( "tbnames.ntx" )
      INDEX ON last + first TO tbnames
   ENDIF

   SET INDEX TO tbnames

   AAdd( aFields, { "Last Name" , {|| tbnames->Last }  } )
   AAdd( aFields, { "First Name", {|| tbnames->First } } )
   AAdd( aFields, { "City"      , {|| tbnames->City }  } )

   cOldColor := SetColor( "N/BG" )
   CLS
   @ 5, 10 SAY "Enter First Letter Of Last Name:" GET cKey PICTURE "!"
   READ

   nRecSel := ft_BrwsWhl( aFields, {|| tbnames->Last = cKey }, cKey, nFreeze, ;
      lSaveScrn, cColorList, cColorShad, 3, 6, MaxRow() - 2, MaxCol() - 6 )

   ?
   IF nRecSel == 0
      ? "Sorry, NO Records Were Selected"
   ELSE
      ? "You Selected " + ;
         tbnames->Last + " " + ;
         tbnames->First + " " + ;
         tbnames->City
   ENDIF
   ?

   WAIT
   SetColor( cOldColor )
   CLS

   RETURN

STATIC FUNCTION make_dbf()

   LOCAL x, aData := { ;
      { "SHAEFER", "KATHRYN", "415 WEST CITRUS ROAD #150", "LOS ANGELES", "CA", "90030" }, ;
      { "OLSON", "JAMES", "225 NORTH RANCH ROAD", "LOS ANGELES", "CA", "90023"          }, ;
      { "KAYBEE", "JOHN", "123 SANDS ROAD", "CAMARILLO", "CA", "93010"                  }, ;
      { "HERMAN", "JIM", "123 TOON PAGE ROAD", "VENTURA", "CA", "93001"                 }, ;
      { "BURNS", "FRANK", "123 VIRGINA STREET", "OXNARD", "CA", "93030"                 }, ;
      { "PIERCE", "HAWKEYE", "123 OLD TOWN ROAD", "PORT MUGU", "CA", "93043"            }, ;
      { "MORGAN", "JESSICA", "123 FRONTAGE ROAD", "CAMARILLO", "CA", "93010"            }, ;
      { "POTTER", "ROBERT", "123 FIR STREET", "OXNARD", "CA", "93030"                   }, ;
      { "WORTH", "MARY", "123-1/2 JOHNSON DRIVE", "OXNARD", "CA", "93033"               }, ;
      { "JOHNSON", "SUSAN", "123 QUEENS STREET", "OXNARD", "CA", "93030"                }, ;
      { "SAMSON", "SAM", "215 MAIN STREET", "OXNARD", "CA", "93030"                     }, ;
      { "NEWNAME", "JAMES", "215 MAIN STREET", "LOS ANGELES", "CA", "90000"             }, ;
      { "OLEANDAR", "JILL", "425 FLORAL PARK DRIVE", "FLORAL PARK", "NY", "10093"       }, ;
      { "SUGARMAN", "CANDY", "1541 SWEETHEART ROAD", "HERSHEY", "PA", "10132"           } }

   dbCreate( "tbnames", { ;
      { "LAST ", "C", 18, 0, }, ;
      { "FIRST", "C",  9, 0, }, ;
      { "ADDR ", "C", 28, 0, }, ;
      { "CITY ", "C", 21, 0, }, ;
      { "STATE", "C",  2, 0, }, ;
      { "ZIP  ", "C",  9, 0, } } )
   USE tbnames
   FOR x := 1 TO Len( aData )
      APPEND BLANK
      AEval( aData[ x ], {| e, n | FieldPut( n, e ) } )
   NEXT
   USE

   RETURN NIL


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

[User] Implement this Harbour module: Harbour test program: tests/dynsym.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
PROCEDURE Main()

   LOCAL nCount := __dynsCount()
   LOCAL nPos

   FOR nPos := 1 TO nCount
      ? __dynsGetName( nPos )
   NEXT

   nPos := __dynsGetIndex( "MAIN" )
   ? "MAIN", nPos

   ? __dynsGetName( nPos )
   ? __dynsGetName()
   ? __dynsGetName( 0 )
   ? __dynsGetName( 100000 )
   ? __dynsGetName( __dynsGetIndex( "HB_THISDOESNTEXIST_" ) )

   RETURN


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

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

Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/olesrv2.prg. Provides functions: get_data. Contains procedures: DllMain. This file provides platform-specific functionality

[Assistant]
#define CLS_Name  "MyOleTimeServer"
#define CLS_ID    "{5552013F-2990-4D6C-9C96-55A4BDDCE376}"

PROCEDURE DllMain()

   LOCAL hAction

   hAction := { => }
   hb_HCaseMatch( hAction, .F. )
   hAction[ "DATE" ]     := @Date()
   hAction[ "TIME" ]     := @Time()
   hAction[ "DATETIME" ] := @hb_DateTime()
   hAction[ "VALUE" ]    := NIL
   hAction[ "GETDATA" ]  := @get_data()

   win_oleServerInit( CLS_ID, CLS_Name, hAction, .T. )

   RETURN

STATIC FUNCTION get_data( ... )

   LOCAL hAction := QSelf()

   IF hAction[ "VALUE" ] == NIL
      RETURN "(:VALUE IS NOT SET)"
   ENDIF

   RETURN ":VALUE='" + hAction[ "VALUE" ] + "'"

ANNOUNCE GT_SYS
REQUEST HB_GT_GUI_DEFAULT


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

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

Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/calendar.prg. Provides functions: ft_Calendar, JDOY. This file provides legacy compatibility functions

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

FUNCTION ft_Calendar( nRow, nCol, cColor, lShadow, lShowHelp )

   LOCAL nJump := 0, nKey := 0, cSavColor, cSaveScreen, cSaveCursor
   LOCAL aRetVal[ 8 ]
   LOCAL nHelpRow, cSaveHelp, lHelpIsDisplayed := .F.

   __defaultNIL( @nRow, 1 )
   __defaultNIL( @nCol, 63 )
   __defaultNIL( @cColor, "W+/G" )
   __defaultNIL( @lShadow, .F. )
   __defaultNIL( @lShowHelp, .F. )

   nRow := iif( nRow < 1 .OR. nRow > 21,  1, nRow )
   nCol := iif( nCol < 1 .OR. nCol > 63, 63, nCol )

   cSavColor   := SetColor( cColor )
   cSaveScreen := SaveScreen( nRow - 1, nCol - 1, nRow + 3, nCol + 17 )
   cSaveCursor := SetCursor( SC_NONE )

   IF lShadow
      hb_DispBox( nRow - 1, nCol - 1, nRow + 2, nCol + 15, HB_B_SINGLE_UNI )
      hb_Shadow( nRow - 1, nCol - 1, nRow + 2, nCol + 15 )
   ENDIF

   IF lShowHelp
      nHelpRow := iif( nRow > 10, nRow - 10, nRow + 6 )
   ENDIF

   DO WHILE nKey != K_ESC

      DO CASE
      CASE nKey == K_HOME
         nJump := nJump - 1

      CASE nKey == K_END
         nJump := nJump + 1

      CASE nKey == K_UP
         nJump := nJump - 30

      CASE nKey == K_DOWN
         nJump := nJump + 30

      CASE nKey == K_PGUP
         nJump := nJump - 365

      CASE nKey == K_PGDN
         nJump := nJump + 365

      CASE nKey == K_RIGHT
         nJump := nJump - 7

      CASE nKey == K_LEFT
         nJump := nJump + 7

      CASE nKey == K_INS
         nJump := 0

      CASE nKey == K_F1
         IF lShowHelp .AND. ! lHelpIsDisplayed
            lHelpIsDisplayed := .T.
            cSaveHelp := SaveScreen( nHelpRow - 1, 1, nHelpRow + 7, 80 )
            ft_XBox( "L",,, cColor, cColor, nHelpRow, 1, ;
               "Home, Up_Arrow or PgUp keys page by day, month or year to a past date.", ;
               "End, Dn_Arrow or PgDn keys page by day, month or year to a future date.", ;
               "Left_Arrow or Right_Arrow keys page by week to a past or future date.", ;
               "Hit Ins to reset to today's date, F1 to get this help, ESC to quit." )
         ENDIF

      ENDCASE

      aRetVal[ 1 ] :=         Date() + nJump
      aRetVal[ 2 ] :=  Month( Date() + nJump )
      aRetVal[ 3 ] :=    Day( Date() + nJump )
      aRetVal[ 4 ] :=   Year( Date() + nJump )
      aRetVal[ 5 ] := CMonth( Date() + nJump )
      aRetVal[ 6 ] :=   CDoW( Date() + nJump )
      aRetVal[ 7 ] :=   JDOY( aRetVal[ 4 ], aRetVal[ 2 ], aRetVal[ 3 ] )

      hb_DispOutAt( nRow, nCol, ;
         Left( aRetval[ 6 ], 3 ) + " " + ;
         Str( aRetVal[ 3 ], 2, 0 ) + " " + ;
         Left( aRetVal[ 5 ], 3 ) + " " + ;
         Str( aRetVal[ 4 ], 4, 0 ) )

      hb_DispOutAt( nRow + 1, nCol, ;
         Str( aRetVal[ 7 ], 3, 0 ) )

      nKey := 0
      DO WHILE nKey == 0
         hb_DispOutAt( nRow + 1, nCol + 3, "    " + Time() )
         nKey := Inkey( 1 )
      ENDDO
      aRetVal[ 8 ] := Time()
   ENDDO

   SetColor( cSavColor )
   SetCursor( cSaveCursor )
   RestScreen( nRow - 1, nCol - 1, nRow + 3, nCol + 17, cSaveScreen )
   IF lHelpIsDisplayed
      RestScreen( nHelpRow - 1, 1, nHelpRow + 7, 80, cSaveHelp )
   ENDIF

   RETURN aRetVal

STATIC FUNCTION JDOY( nYear, nMonth, nDay )

   LOCAL cString := "000031059090120151181212243273304334"

   RETURN VALS( cString, ( nMonth - 1 )


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

[User] Define Harbour macros and constants: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/client.prg. Defines classes: TIPClient. This file provides network protocol implementations

[Assistant]
#include "hbclass.ch"

#include "error.ch"
#include "fileio.ch"

#if defined( _SSL_DEBUG_TEMP )
   #include "simpleio.ch"
#endif

#include "hbssl.ch"
#undef __HBEXTREQ__
#include "hbssl.hbx"

#define RCV_BUF_SIZE  Int( ::InetRcvBufSize( ::SocketCon ) / 2 )
#define SND_BUF_SIZE  Int( ::InetSndBufSize( ::SocketCon ) / 2 )

CREATE CLASS TIPClient

   CLASS VAR bInitSocks  INIT .F.
   CLASS VAR cCRLF       INIT tip_CRLF()

   VAR oUrl
   VAR oCredentials
   VAR nStatus           INIT 0
   VAR SocketCon
   VAR bTrace

   VAR nDefaultRcvBuffSize
   VAR nDefaultSndBuffSize

   VAR nLength           INIT -1
   VAR nRead             INIT 0
   VAR nLastRead         INIT 0

   VAR nDefaultPort
   VAR nConnTimeout
   VAR bInitialized      INIT .F.

   VAR cReply
   VAR nAccessMode
   VAR nWrite            INIT 0
   VAR nLastWrite        INIT 0

   VAR bEof              INIT .F.
   VAR isOpen            INIT .F.

   VAR exGauge

   VAR lSSL              INIT .F.

   VAR lHasSSL           INIT tip_SSL()
   VAR ssl_ctx
   VAR ssl
   VAR nSSLError         INIT 0

   VAR Cargo

   VAR cProxyHost        INIT ""
   VAR nProxyPort        INIT 0
   VAR cProxyUser
   VAR cProxyPassword
   VAR lProxyXferSSL     INIT .F.

   METHOD New( oUrl, xTrace, oCredentials )
   METHOD Open( cUrl )

   METHOD EnableSSL( lEnable )

   METHOD Read( nLen )
   METHOD ReadToFile( cFile, nMode, nSize )
   METHOD Write( cData, nLen, lCommit )
   METHOD Commit()
   METHOD WriteFromFile( cFile )
   METHOD Reset()
   METHOD Close()

   METHOD SetProxy( cProxyHost, nProxyPort, cProxyUser, cProxyPassword )

   METHOD lastErrorCode() INLINE ::nLastError
   METHOD lastErrorMessage( SocketCon ) INLINE ::inetErrorDesc( SocketCon )

   METHOD InetRcvBufSize( SocketCon, nSizeBuff )
   METHOD InetSndBufSize( SocketCon, nSizeBuff )

   METHOD InetTimeOut( SocketCon, nConnTimeout )

   METHOD HasSSL() INLINE ::lHasSSL

   PROTECTED:

   VAR nLastError INIT 0

   METHOD OpenProxy( cServer, nPort, cProxy, nProxyPort, cResp, cUserName, cPassword, cUserAgent )
   METHOD ReadHTTPProxyResponse( cResponse )

   METHOD inetRecv( SocketCon, cStr1, len )
   METHOD inetRecvLine( SocketCon, nRet, size )
   METHOD inetRecvAll( SocketCon, cRet, size )
   METHOD inetCount( SocketCon )
   METHOD inetSendAll( SocketCon, cData, nLen )
   METHOD inetErrorCode( SocketCon )
   METHOD inetErrorDesc( SocketCon )
   METHOD inetConnect( cServer, nPort, SocketCon )

   METHOD Log( ... )

ENDCLASS

METHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClient

   LOCAL oErr
   LOCAL oLog
   LOCAL lSSL

   DO CASE
   CASE HB_ISSTRING( xTrace ) .OR. hb_defaultValue( xTrace, .F. )
      oLog := TIPLog():New( iif( HB_ISSTRING( xTrace ), xTrace, NIL ) )
      ::bTrace := {| cMsg | iif( PCount() > 0, oLog:Add( cMsg ), oLog:Close() ) }
   CASE HB_ISEVALITEM( xTrace )
      ::bTrace := xTrace
   ENDCASE

   IF HB_ISSTRING( oUrl )
      oUrl := TUrl():New( oUrl )
   ENDIF

   SWITCH oURL:cProto
   CASE "ftp"
   CASE "http"
   CASE "pop"
   CASE "smtp"
      lSSL := .F.
      EXIT
   CASE "ftps"
   CASE "https"
   CASE "pop3s"
   CASE "pops"
   CASE "smtps"
      IF ::lHasSSL
         lSSL := .T.
         EXIT
      ENDIF
   OTHERWISE
      oErr := ErrorNew()
      oErr:Args          := { Self, oURL:cProto }
      oErr:CanDefault    := .F.
      oErr:CanRetry      := .F.
      oErr:CanSubstitute := .T.
      oErr:Description   := "unsupported protocol"
      oErr:GenCode       := EG_UNSUPPORTED
      oErr:Operation     := ::className() + ":new()"
      oErr:Severity      := ES_ERROR
      oErr:SubCode       := 1081
      oErr:SubSystem     := "BASE"
      Eval( ErrorBlock(), oErr )
   ENDSWITCH

   IF ! ::bInitSocks
      hb_inetInit()
      IF ::lHasSSL
         SSL_init()
         RAND_seed( hb_randStr( 20 ) + hb_TToS( hb_DateTime() ) + NetName() )
      ENDIF
      ::bInitSocks := .T.
   ENDIF

   IF ::lHasSSL .AND. lSSL
      ::EnableSSL( .T. )
   ENDIF

   ::oUrl         := oUrl
   ::oCredentials := oCredentials

   RETURN Self

METHOD Open( cUrl ) CLASS TIPClient

   LOCAL nPort

   IF HB_ISSTRING( cUrl )
      ::oUrl := TUrl():New( cUrl )
   ENDIF

   nPort := iif( ::oUrl:nPort == -1, ::nDefaultPort, ::oUrl:nPort )

   ::SocketCon := hb_inetCreate()

   ::InetTimeOut( ::SocketCon )

   IF ::cProxyHost == ""
      ::inetConnect( ::oUrl:cServer, nPort, ::SocketCon )
      IF ::inetErrorCode( ::SocketCon ) != 0
         RETURN .F.
      ENDIF
   ELSEIF ! ::OpenProxy( ::oUrl:cServer, nPort, ::cProxyHost, ::nProxyPort,, ::cProxyUser, ::cProxyPassword, "Mozilla/3.0 compatible" )
      RETURN .F.
   ENDIF
   ::isOpen := .T.

   RETURN .T.

METHOD EnableSSL( lEnable ) CLASS TIPClient

   LOCAL lSuccess

   IF ::lSSL == lEnable
      RETURN .T.
   ENDIF

   ::lProxyXferSSL := .F.

   IF lEnable
      IF ::lHasSSL
         ::ssl_ctx := SSL_CTX_new()
         ::ssl := SSL_new( ::ssl_ctx )
         ::lSSL := .T.
         lSuccess := .T.
      ELSE
         lSuccess := .F.
      ENDIF
   ELSE
      IF ::lHasSSL
         ::lSSL := .F.
         lSuccess := .T.
      ELSE
         lSuccess := .T.
      ENDIF
   ENDIF

   RETURN lSuccess

METHOD OpenProxy( cServer, nPort, cProxy, nProxyPort, cResp, cUserName, cPassword, cUserAgent ) CLASS TIPClient

   LOCAL cRequest
   LOCAL lRet := .F.
   LOCAL tmp

   ::inetConnect( cProxy, nProxyPort, ::SocketCon )

   IF ( tmp := ::inetErrorCode( ::SocketCon ) ) == 0
      cRequest := ;
         "CONNECT " + cServer + ":" + hb_ntos( nPort ) + " HTTP/1.1" + Chr( 13 ) + Chr( 10 ) + ;
         "Proxy-Connection: Keep-Alive" + Chr( 13 ) + Chr( 10 )
      IF HB_ISSTRING( cUserAgent ) .AND. ! cUserAgent == ""
         cRequest += "User-Agent: " + cUserAgent + Chr( 13 ) + Chr( 10 )
      ENDIF
      IF HB_ISSTRING( cUserName ) .AND. ! cUserName == ""
         cRequest += "Proxy-Authorization: Basic " + hb_base64Encode( cUserName + ":" + hb_defaultValue( cPassword, "" ) ) + Chr( 13 ) + Chr( 10 )
      ENDIF
      cRequest += Chr( 13 ) + Chr( 10 )
      ::inetSendAll( ::SocketCon, cRequest )
      cResp := ""
      IF ::ReadHTTPProxyResponse( @cResp ) .AND. ;
         ( tmp := At( " ", cResp ) ) > 0 .AND. ;
         Val( SubStr( cResp, tmp + 1 ) ) == 200
         lRet := .T.
      ELSE
         ::close()
      ENDIF
   ELSE
      cResp := hb_ntos( tmp )
   ENDIF

   IF lRet .AND. ::lSSL .AND. ::lHasSSL
      __tip_SSLConnectFD( ::ssl, ::SocketCon )
      ::lProxyXferSSL := .T.
   ELSE
      ::lProxyXferSSL := .F.
   ENDIF

   RETURN lRet

METHOD ReadHTTPProxyResponse(  cResponse ) CLASS TIPClient

   LOCAL cBuffer

   DO WHILE .T.
      cBuffer := Space( 1 )
      IF ::inetRecv( ::SocketCon, @cBuffer, hb_BLen( cBuffer ) ) <= 0
         RETURN .F.
      ENDIF
      cResponse += cBuffer
      IF hb_BRight( cResponse, 4 ) == e"\r\n\r\n"
         EXIT
      ENDIF
   ENDDO

   RETURN .T.

METHOD Close() CLASS TIPClient

   LOCAL nRet

   IF Empty( ::SocketCon )
      nRet := -1
   ELSE
      nRet := hb_inetClose( ::SocketCon )

      IF ::lSSL .AND. ::lHasSSL
         SSL_shutdown( ::ssl )
         ::ssl := NIL
         ::ssl_ctx := NIL
      ENDIF

      ::SocketCon := NIL
      ::isOpen := .F.
      ::lProxyXferSSL := .F.
   ENDIF

   IF HB_ISEVALITEM( ::bTrace )

      Eval( ::bTrace )
   ENDIF

   RETURN nRet

METHOD Reset() CLASS TIPClient

   ::bInitialized := .F.
   ::bEof := .F.

   RETURN .T.

METHOD Commit() CLASS TIPClient
   RETURN .T.

METHOD Read( nLen ) CLASS TIPClient

   LOCAL cStr0
   LOCAL cStr1

   IF ::nLength > 0 .AND. ::nLength == ::nRead
      RETURN NIL
   ENDIF

   IF ! HB_ISNUMERIC( nLen ) .OR. nLen <= 0 .OR. ( ::nLength > 0 .AND. nLen > ::nLength - ::nRead )
      nLen := ::nLength - ::nRead
   ENDIF

   IF nLen <= 0

      cStr1 := Space( RCV_BUF_SIZE )
      cStr0 := ""
      DO WHILE ( ::nLastRead := ::inetRecv( ::SocketCon, @cStr1, RCV_BUF_SIZE ) ) > 0
         ::nRead += ::nLastRead


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

[User] Implement these Harbour functions: Harbour test program: tests/langmsg.prg. Provides functions: GET_DAYS, GET_MONTHS, GET_ERR, HB_LANGERRINTR, GET_IERR. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#include "hblang.ch"

PROCEDURE Main( cLng )

   LOCAL i, a, aDay, aMnt, aErr, aInt, cDtFrm, cTrue, cFalse

   hb_langSelect( "en" )
   aDay := GET_DAYS()
   aMnt := GET_MONTHS()
   aErr := GET_ERR()
   aInt := GET_IERR()
   cDtFrm := hb_langMessage( HB_LANG_ITEM_BASE_TEXT )
   cTrue := hb_langMessage( HB_LANG_ITEM_BASE_TEXT + 1 )
   cFalse := hb_langMessage( HB_LANG_ITEM_BASE_TEXT + 2 )

   IF ! Empty( cLng )
      hb_langSelect( Upper( cLng ) )
   ENDIF

   ? hb_langName()
   ? "HB_LANG_ITEM_BASE_ID     ", "[" + hb_langMessage( HB_LANG_ITEM_BASE_ID      ) + "]"
   ? "HB_LANG_ITEM_BASE_MONTH  ", "[" + hb_langMessage( HB_LANG_ITEM_BASE_MONTH   ) + "]"
   ? "HB_LANG_ITEM_BASE_DAY    ", "[" + hb_langMessage( HB_LANG_ITEM_BASE_DAY     ) + "]"
   ? "HB_LANG_ITEM_BASE_NATMSG ", "[" + hb_langMessage( HB_LANG_ITEM_BASE_NATMSG  ) + "]"
   ? "HB_LANG_ITEM_BASE_ERRDESC", "[" + hb_langMessage( HB_LANG_ITEM_BASE_ERRDESC ) + "]"
   ? "HB_LANG_ITEM_BASE_ERRINTR", "[" + hb_langMessage( HB_LANG_ITEM_BASE_ERRINTR ) + "]"
   ? "HB_LANG_ITEM_BASE_TEXT   ", "[" + hb_langMessage( HB_LANG_ITEM_BASE_TEXT    ) + "]"
   ? "hb_langErrMsg(0)", hb_langErrMsg( 0 )
   ?
   ? "date format:", hb_langMessage( HB_LANG_ITEM_BASE_TEXT ) + " (" + cDtFrm + ")"
   ? "   TRUE val:", hb_langMessage( HB_LANG_ITEM_BASE_TEXT + 1 ) + " (" + cTrue + ")"
   ? "  FALSE val:", hb_langMessage( HB_LANG_ITEM_BASE_TEXT + 2 ) + " (" + cFalse + ")"
   ?
   Inkey( 0 )

   ? "Errors:"
   ?
   a := GET_ERR()
   FOR i := 1 TO Len( a )
      ? PadR( a[ i ][ 1 ], 15 ) + "|" + PadR( aErr[ i ][ 2 ], 30 ) + "|" + PadR( a[ i ][ 2 ], 32 )
   NEXT
   ?
   Inkey( 0 )

   ? "Internal errors:"
   ?
   a := GET_IERR()
   FOR i := 1 TO Len( a )
      ? PadR( a[ i ][ 1 ], 15 ) + "|" + PadR( aInt[ i ][ 2 ], 30 ) + "|" + PadR( a[ i ][ 2 ], 32 )
   NEXT
   ?
   Inkey( 0 )

   ? "Days:"
   ?
   a := GET_DAYS()
   FOR i := 1 TO Len( a )
      ? "  " + PadR( aDay[ i ], 15 ) + a[ i ]
   NEXT
   ?
   Inkey( 0 )

   ? "Months:"
   ?
   a := GET_MONTHS()
   FOR i := 1 TO Len( a )
      ? "  " + PadR( aMnt[ i ], 15 ) + a[ i ]
   NEXT
   ?
   Inkey( 0 )

   RETURN

STATIC FUNCTION GET_DAYS()

   LOCAL i, n, aDays[ 7 ], dt := Date()

   FOR i := 1 TO 7
      n := DoW( dt )
      aDays[ n ] := CDoW( dt )
      ++dt
   NEXT

   RETURN aDays

STATIC FUNCTION GET_MONTHS()

   LOCAL i, n, aMonths[ 12 ], dt := Date()

   dt -= Day( dt ) - 1
   FOR i := 1 TO 12
      n := Month( dt )
      aMonths[ n ] := CMonth( dt )
      dt += 31
      dt -= Day( dt ) - 1
   NEXT

   RETURN aMonths

STATIC FUNCTION GET_ERR()
   RETURN { ;
      { "EG_ARG         ", hb_langErrMsg(  1 ) }, ;
      { "EG_BOUND       ", hb_langErrMsg(  2 ) }, ;
      { "EG_STROVERFLOW ", hb_langErrMsg(  3 ) }, ;
      { "EG_NUMOVERFLOW ", hb_langErrMsg(  4 ) }, ;
      { "EG_ZERODIV     ", hb_langErrMsg(  5 ) }, ;
      { "EG_NUMERR      ", hb_langErrMsg(  6 ) }, ;
      { "EG_SYNTAX      ", hb_langErrMsg(  7 ) }, ;
      { "EG_COMPLEXITY  ", hb_langErrMsg(  8 ) }, ;
      { "               ", hb_langErrMsg(  9 ) }, ;
      { "               ", hb_langErrMsg( 10 ) }, ;
      { "EG_MEM         ", hb_langErrMsg( 11 ) }, ;
      { "EG_NOFUNC      ", hb_langErrMsg( 12 ) }, ;
      { "EG_NOMETHOD    ", hb_langErrMsg( 13 ) }, ;
      { "EG_NOVAR       ", hb_langErrMsg( 14 ) }, ;
      { "EG_NOALIAS     ", hb_langErrMsg( 15 ) }, ;
      { "EG_NOVARMETHOD ", hb_langErrMsg( 16 ) }, ;
      { "EG_BADALIAS    ", hb_langErrMsg( 17 ) }, ;
      { "EG_DUPALIAS    ", hb_langErrMsg( 18 ) }, ;
      { "EG_NOOBJECT    ", hb_langErrMsg( 19 ) }, ;
      { "EG_CREATE      ", hb_langErrMsg( 20 ) }, ;
      { "EG_OPEN        ", hb_langErrMsg( 21 ) }, ;
      { "EG_CLOSE       ", hb_langErrMsg( 22 ) }, ;
      { "EG_READ        ", hb_langErrMsg( 23 ) }, ;
      { "EG_WRITE       ", hb_langErrMsg( 24 ) }, ;
      { "EG_PRINT       ", hb_langErrMsg( 25 ) }, ;
      { "               ", hb_langErrMsg( 26 ) }, ;
      { "               ", hb_langErrMsg( 27 ) }, ;
      { "               ", hb_langErrMsg( 28 ) }, ;
      { "               ", hb_langErrMsg( 29 ) }, ;
      { "EG_UNSUPPORTED ", hb_langErrMsg( 30 ) }, ;
      { "EG_LIMIT       ", hb_langErrMsg( 31 ) }, ;
      { "EG_CORRUPTION  ", hb_langErrMsg( 32 ) }, ;
      { "EG_DATATYPE    ", hb_langErrMsg( 33 ) }, ;
      { "EG_DATAWIDTH   ", hb_langErrMsg( 34 ) }, ;
      { "EG_NOTABLE     ", hb_langErrMsg( 35 ) }, ;
      { "EG_NOORDER     ", hb_langErrMsg( 36 ) }, ;
      { "EG_SHARED      ", hb_langErrMsg( 37 ) }, ;
      { "EG_UNLOCKED    ", hb_langErrMsg( 38 ) }, ;
      { "EG_READONLY    ", hb_langErrMsg( 39 ) }, ;
      { "EG_APPENDLOCK  ", hb_langErrMsg( 40 ) }, ;
      { "EG_LOCK        ", hb_langErrMsg( 41 ) }, ;
      { "               ", hb_langErrMsg( 42 ) }, ;
      { "               ", hb_langErrMsg( 43 ) }, ;
      { "               ", hb_langErrMsg( 44 ) }, ;
      { "               ", hb_langErrMsg( 45 ) }, ;
      { "EG_ARRACCESS   ", hb_langErrMsg( 46 ) }, ;
      { "EG_ARRASSIGN   ", hb_langErrMsg( 47 ) }, ;
      { "EG_ARRDIMENSION", hb_langErrMsg( 48 ) }, ;
      { "EG_NOTARRAY    ", hb_langErrMsg( 49 ) }, ;
      { "EG_CONDITION   ", hb_langErrMsg( 50 ) } }

STATIC FUNCTION HB_LANGERRINTR( n )
   RETURN hb_langMessage( HB_LANG_ITEM_BASE_ERRINTR + n - 9000 )

STATIC FUNCTION GET_IERR()
   RETURN { ;
      { "HB_EI_ERRUNRECOV      ", HB_LANGERRINTR( 9000 ) }, ;
      { "HB_EI_ERRRECFAILURE   ", HB_LANGERRINTR( 9001 ) }, ;
      { "HB_EI_ERRNOBLOCK      ", HB_LANGERRINTR( 9002 ) }, ;
      { "HB_EI_ERRTOOMANY      ", HB_LANGERRINTR( 9003 ) }, ;
      { "HB_EI_RDDINVALID      ", HB_LANGERRINTR( 9004 ) }, ;
      { "HB_EI_CLSINVMETHOD    ", HB_LANGERRINTR( 9005 ) }, ;
      { "HB_EI_XGRABALLOC      ", HB_LANGERRINTR( 9006 ) }, ;
      { "HB_EI_XREALLOCNULL    ", HB_LANGERRINTR( 9007 ) }, ;
      { "HB_EI_XREALLOCINV     ", HB_LANGERRINTR( 9008 ) }, ;
      { "HB_EI_XREALLOC        ", HB_LANGERRINTR( 9009 ) }, ;
      { "HB_EI_XFREEINV        ", HB_LANGERRINTR( 9010 ) }, ;
      { "HB_EI_XFREENULL       ", HB_LANGERRINTR( 9011 ) }, ;
      { "HB_EI_VMBADSTARTUP    ", HB_LANGERRINTR( 9012 ) }, ;
      { "HB_EI_VMNOSTARTUP     ", HB_LANGERRINTR( 9013 ) }, ;
      { "HB_EI_VMBADOPCODE     ", HB_LANGERRINTR( 9014 ) }, ;
      { "HB_EI_VMNOTSYMBOL     ", HB_LANGERRINTR( 9015 ) }, ;
      { "HB_EI_VMINVSYMBOL     ", HB_LANGERRINTR( 9016 ) }, ;
      { "HB_EI_VMNOTCBLOCK     ", HB_LANGERRINTR( 9017 ) }, ;
      { "HB_EI_VMPOPINVITEM    ", HB_LANGERRINTR( 9018 ) }, ;
      { "HB_EI_STACKUFLOW      ", HB_LANGERRINTR( 9019 ) }, ;
      { "HB_EI_ITEMBADCOPY     ", HB_LANGERRINTR( 9020 ) }, ;
      { "HB_EI_MVBADSYMBOL     ", HB_LANGERRINTR( 9021 ) }, ;
      { "HB_EI_XMEMOVERFLOW    ", HB_LANGERRINTR( 9022 ) }, ;
      { "HB_EI_XGRABNULLSIZE   ", HB_LANGERRINTR( 9023 ) }, ;
      { "HB_EI_XREALLOCNULLSIZE", HB_LANGERRINTR( 9024 ) }, ;
      { "HB_EI_XALLOCNULLSIZE  ", HB_LANGERRINTR( 9025 ) } }


[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 'hbexpat' (XML parsing library (Expat)): contrib/hbexpat/unitable.prg. Provides functions: hb_XML_get_unicode_table. This file handles data format parsing and generation

[Assistant]
#include "hbextcdp.ch"

#define _UNI_NAME_NORM( s )  hb_StrReplace( s, "-. " )

FUNCTION hb_XML_get_unicode_table( cCP )

   THREAD STATIC t_uni

   LOCAL cdp

   IF t_uni == NIL

      t_uni := { => }
      FOR EACH cdp IN hb_cdpList()
         t_uni[ _UNI_NAME_NORM( hb_cdpUniID( cdp ) ) ] := cdp
      NEXT
   ENDIF

   IF ( cCP := _UNI_NAME_NORM( cCP ) ) $ t_uni
      RETURN __hb_XML_cdpU16Map( t_uni[ cCP ] )
   ENDIF

   RETURN NIL


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

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

Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/win_tcom.prg. Defines classes: win_Com. This file provides platform-specific functionality

[Assistant]
#include "hbclass.ch"

#include "hbwin.ch"

CREATE CLASS win_Com

   ACCESS Open()     INLINE ::lOpen
   ACCESS PortName() INLINE ::cPortName

   PROTECT nPort     INIT -1
   PROTECT lOpen     INIT .F.
   PROTECT cPortName INIT ""

   METHOD Init( cPortName, nBaudRate, nParity, nByteSize, nStopBits )
   METHOD QueueSize( nInQueue, nOutQueue )
   METHOD TimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant )
   METHOD Read(  cString, nLength )
   METHOD Recv( nLength, nResult )
   METHOD RecvTo( cDelim, nMaxlen )
   METHOD Write( cString )
   METHOD Status( lCTS, lDSR, lRing, lDCD )
   METHOD QueueStatus( lCTSHold, lDSRHold, lDCDHold, lXoffHold, lXoffSent, nInQueue, nOutQueue )
   METHOD SetRTS( lCTS )
   METHOD SetDTR( lDTR )
   METHOD RTSFlow( nRTS )
   METHOD DTRFlow( nDTR )
   METHOD XonXoffFlow( lXonXoff )
   METHOD Purge( lRXBuffer, lTXBuffer )
   METHOD PurgeRX()
   METHOD PurgeTX()
   METHOD Close( nDrain )
   METHOD DebugDCB( nDebug )
   METHOD ErrorText()
   METHOD Error()

ENDCLASS

METHOD Init( cPortName, nBaudRate, nParity, nByteSize, nStopBits ) CLASS win_Com

   ::cPortName := Upper( cPortName )
   IF Left( ::cPortName, 3 ) == "COM"
      ::nPort := Val( SubStr( ::cPortName, 4 ) ) - 1
      IF win_comOpen( ::nPort, nBaudRate, nParity, nByteSize, nStopBits ) != -1
         ::lOpen := .T.
      ENDIF
   ENDIF

   RETURN Self

METHOD QueueSize( nInQueue, nOutQueue ) CLASS win_Com
   RETURN win_comSetQueueSize( ::nPort, nInQueue, nOutQueue )

METHOD TimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant ) CLASS win_Com
   RETURN win_comSetTimeouts( ::nPort, nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant )

METHOD Read(  cString, nLength ) CLASS win_Com

   cString := Space( nlength )

   RETURN win_comRead( ::nPort, @cString )

METHOD Recv( nLength, nResult ) CLASS win_Com
   RETURN win_comRecv( ::nPort, nLength, @nResult )

METHOD RecvTo( cDelim, nMaxlen ) CLASS win_Com

   LOCAL nResult
   LOCAL cRecv := ""

   LOCAL cString

   DO WHILE .T.
      cString := Space( 1 )
      IF ( nResult := win_comRead( ::nPort, @cString ) ) != -1
         IF nResult == 0
            EXIT
         ELSE
            cRecv += cString
            IF cDelim != NIL .AND. cString == cDelim
               EXIT
            ENDIF
            IF Len( cRecv ) == nMaxlen
               EXIT
            ENDIF
         ENDIF
      ELSE
         EXIT
      ENDIF
   ENDDO

   RETURN cRecv

METHOD Write( cString ) CLASS win_Com
   RETURN win_comWrite( ::nPort, cString )

METHOD Status( lCTS, lDSR, lRing, lDCD ) CLASS win_Com
   RETURN win_comStatus( ::nPort, @lCTS, @lDSR, @lRing, @lDCD )

METHOD QueueStatus( lCTSHold, lDSRHold, lDCDHold, lXoffHold, lXoffSent, nInQueue, nOutQueue ) CLASS win_Com
   RETURN win_comQueueStatus( ::nPort, @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )

METHOD SetRTS( lCTS ) CLASS win_Com
   RETURN win_comSetRTS( ::nPort, lCTS )

METHOD SetDTR( lDTR ) CLASS win_Com
   RETURN win_comSetDTR( ::nPort, lDTR )

METHOD RTSFlow( nRTS ) CLASS win_Com
   RETURN win_comRTSFlow( ::nPort, nRTS )

METHOD DTRFlow( nDTR ) CLASS win_Com
   RETURN win_comDTRFlow( ::nPort, nDTR )

METHOD XonXoffFlow( lXonXoff ) CLASS win_Com
   RETURN win_comXonXoffFlow( ::nPort, lXonXoff )

METHOD Purge( lRXBuffer, lTXBuffer ) CLASS win_Com
   RETURN win_comPurge( ::nPort, lRXBuffer, lTXBuffer )

METHOD PurgeRX() CLASS win_Com
   RETURN win_comPurge( ::nPort, .T., .F. )

METHOD PurgeTX() CLASS win_Com
   RETURN win_comPurge( ::nPort, .F., .T. )

METHOD Close( nDrain ) CLASS win_Com
   RETURN win_comClose( ::nPort, iif( Empty( nDrain ), 0, nDrain ) )

METHOD DebugDCB( nDebug ) CLASS win_Com
   RETURN win_comDebugDCB( ::nPort, nDebug )

METHOD ErrorText() CLASS win_Com

   LOCAL nFcn := win_comFuncLast( ::nPort )
   LOCAL cString
   LOCAL nError
   LOCAL cMsg
   LOCAL aWinPortFcns := { ;
      "CreateFile", ;
      "GetCommState", ;
      "SetCommState", ;
      "SetupComm", ;
      "GetCommTimeouts", ;
      "SetCommTimeouts", ;
      "CloseHandle", ;
      "WriteFile", ;
      "ReadFile", ;
      "GetCommModemStatus", ;
      "PurgeComm", ;
      "ClearCommError", ;
      "EscapeCommFunction", ;
      "GetCommProperties" }

   IF nFcn >= 1 .AND. nFcn <= Len( aWinPortFcns )
      cString := aWinPortFcns[ nFcn ] + "(), "
   ELSE
      cString := "Function number (" + hb_ntos( nFcn ) + ") invalid, "
   ENDIF

   cMsg := Space( 256 )
   wapi_FormatMessage( NIL, NIL, nError := win_comError( ::nPort ), NIL, @cMsg )

   RETURN cString + "error (" + hb_ntos( nError ) + ") : " + cMsg

METHOD Error() CLASS win_Com
   RETURN win_comError( ::nPort )


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

[Assistant]
#require "hbzebra"
#require "hbhpdf"

PROCEDURE Main()

   LOCAL pdf
   LOCAL page

   pdf := HPDF_New()
   page := HPDF_AddPage( pdf )
   HPDF_Page_SetSize( page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT )
   HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, "Helvetica", NIL ), 12 )

   DrawBarcode( page,  20,   1, "EAN13",      "477012345678" )
   DrawBarcode( page,  40,   1, "EAN8",       "1234567" )
   DrawBarcode( page,  60,   1, "UPCA",       "01234567891" )
   DrawBarcode( page,  80,   1, "UPCE",       "123456" )
   DrawBarcode( page, 100,   1, "CODE39",     "ABC123" )
   DrawBarcode( page, 120,   1, "CODE39",     "ABC123", HB_ZEBRA_FLAG_CHECKSUM )
   DrawBarcode( page, 140, 0.5, "CODE39",     "ABC123", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE2_5 )
   DrawBarcode( page, 160,   1, "CODE39",     "ABC123", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 180,   1, "ITF",        "1234", HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 200,   1, "ITF",        "12345678901", HB_ZEBRA_FLAG_CHECKSUM )
   DrawBarcode( page, 220,   1, "MSI",        "1234" )
   DrawBarcode( page, 240,   1, "MSI",        "1234", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 260,   1, "MSI",        "1234567", HB_ZEBRA_FLAG_CHECKSUM )
   DrawBarcode( page, 280,   1, "CODABAR",    "40156", HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 300,   1, "CODABAR",    "-1234", HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 320,   1, "CODE93",     "ABC-123" )
   DrawBarcode( page, 340,   1, "CODE93",     "TEST93" )
   DrawBarcode( page, 360,   1, "CODE11",     "12", HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 380,   1, "CODE11",     "1234567890", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )
   DrawBarcode( page, 400,   1, "CODE128",    "Code 128" )
   DrawBarcode( page, 420,   1, "CODE128",    "1234567890" )
   DrawBarcode( page, 440,   1, "CODE128",    "Wikipedia" )
   DrawBarcode( page, 460,   1, "PDF417",     "Hello, World of Harbour!!! It's 2D barcode PDF417 :)" )
   DrawBarcode( page, 540,   1, "DATAMATRIX", "Hello, World of Harbour!!! It's 2D barcode DataMatrix :)" )
   DrawBarcode( page, 580,   1, "QRCODE",     "http:

   FErase( hb_FNameExtSet( __FILE__, ".pdf" ) )
   ? HPDF_SaveToFile( pdf, hb_FNameExtSet( __FILE__, ".pdf" ) )

   RETURN

PROCEDURE DrawBarcode( page, nY, nLineWidth, cType, cCode, nFlags )

   LOCAL hZebra, nLineHeight, cTxt

   nY := HPDF_Page_GetHeight( page ) - nY

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

   IF hZebra != NIL
      IF hb_zebra_geterror( hZebra ) == 0
         IF Empty( nLineHeight )
            nLineHeight := 16
         ENDIF
         HPDF_Page_BeginText( page )
         HPDF_Page_TextOut( page,  40, nY - 13, cType )
         cTxt := hb_zebra_getcode( hZebra )
         IF Len( cTxt ) < 20
            HPDF_Page_TextOut( page, 150, nY - 13, cTxt )
         ENDIF
         HPDF_Page_EndText( page )
         hb_zebra_draw_hpdf( hZebra, page, 300, nY, nLineWidth, -nLineHeight )
      ELSE
         ? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
      ENDIF
      hb_zebra_destroy( hZebra )
   ELSE
      ? "Invalid barcode type", cType
   ENDIF

   RETURN

STATIC FUNCTION hb_zebra_draw_hpdf( hZebra, page, ... )

   IF hb_zebra_geterror( hZebra ) != 0
      RETURN HB_ZEBRA_ERROR_INVALIDZEBRA
   ENDIF

   hb_zebra_draw( hZebra, {| x, y, w, h | HPDF_Page_Rectangle( page, x, y, w, h ) }, ... )

   HPDF_Page_Fill( page )

   RETURN 0


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

[User] Write a Harbour program with procedures: Main. Harbour test program: tests/classes.prg. Provides functions: TForm, New, Show. Contains procedures: Main. This test file tests object-oriented programming features

[Assistant]
PROCEDURE Main()

   LOCAL oForm := TForm():New()

   ? oForm:ClassName()

   oForm:Show()

   RETURN

FUNCTION TForm()

   STATIC s_oClass

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

      s_oClass:AddData( "cName" )
      s_oClass:AddData( "nTop" )
      s_oClass:AddData( "nLeft" )
      s_oClass:AddData( "nBottom" )
      s_oClass:AddData( "nRight" )

      s_oClass:AddMethod( "New",  @New() )
      s_oClass:AddMethod( "Show", @Show() )

      s_oClass:Create()
   ENDIF

   RETURN s_oClass:Instance()

STATIC FUNCTION New()

   LOCAL Self := QSelf()

   ::nTop    := 10
   ::nLeft   := 10
   ::nBottom := 20
   ::nRight  := 40

   RETURN Self

STATIC FUNCTION Show()

   LOCAL Self := QSelf()

   ? "lets show a form from here :-)"

   RETURN NIL


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

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

[Assistant]
#include "ftint86.ch"

FUNCTION ft_NWUID( nConn )

   LOCAL aRegs[ INT86_MAX_REGS ]
   LOCAL cReqPkt
   LOCAL cRepPkt

   IF nConn == NIL
      nConn := ft_NWLStat()
   ENDIF

   cReqPkt := hb_BChar( 22 )
   cReqPkt += hb_BChar( nConn )
   cReqPkt := I2Bin( hb_BLen( cReqPkt ) ) + cReqPkt

   cRepPkt := Space( 63 )

   aRegs[ AX ] := MAKEHI( 227 )
   aRegs[ DS ] := cReqPkt
   aRegs[ SI ] := REG_DS
   aRegs[ ES ] := cRepPkt
   aRegs[ DI ] := REG_ES

   ft_int86( 33, aRegs )

   RETURN AllTrim( StrTran( hb_BSubStr( aRegs[ ES ], 9, 48 ), hb_BChar( 0 ) ) )


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

[User] Write a Harbour program with procedures: Main. Harbour test program: tests/inhprob.prg. Defines classes: One, Two, Three. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#include "hbclass.ch"

PROCEDURE Main()

   LOCAL o := Three():New()

   o:CheckIt()

   RETURN

CREATE CLASS One

   METHOD New() INLINE Self
   METHOD Test() INLINE QOut( "One" )
   METHOD CheckIt() INLINE ::Test()

ENDCLASS

CREATE CLASS Two FROM One

   METHOD Test() INLINE ::super:Test()
   METHOD CheckIt() INLINE ::super:CheckIt()

ENDCLASS

CREATE CLASS Three FROM Two

   METHOD Test() INLINE QOut( "Three" )

ENDCLASS


[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 header file: include/fileio.ch. Defines 10 constants including: _FILEIO_CH, FC_NORMAL, FC_READONLY, FC_HIDDEN, FC_SYSTEM. Defines keyboard input constants

[Assistant]
#ifndef _FILEIO_CH
#define _FILEIO_CH

#define FC_NORMAL          0
#define FC_READONLY        1
#define FC_HIDDEN          2
#define FC_SYSTEM          4

#define HB_FA_ALL          0x00000000

#define HB_FA_READONLY     0x00000001
#define HB_FA_HIDDEN       0x00000002
#define HB_FA_SYSTEM       0x00000004
#define HB_FA_LABEL        0x00000008
#define HB_FA_DIRECTORY    0x00000010
#define HB_FA_ARCHIVE      0x00000020
#define HB_FA_DEVICE       0x00000040
#define HB_FA_NORMAL       0x00000080

#define HB_FA_ANY          ( HB_FA_READONLY + HB_FA_HIDDEN + HB_FA_SYSTEM + HB_FA_DIRECTORY + HB_FA_ARCHIVE )

#define HB_FA_TEMPORARY    0x00000100
#define HB_FA_SPARSE       0x00000200
#define HB_FA_REPARSE      0x00000400
#define HB_FA_COMPRESSED   0x00000800
#define HB_FA_OFFLINE      0x00001000
#define HB_FA_NOTINDEXED   0x00002000
#define HB_FA_ENCRYPTED    0x00004000
#define HB_FA_VOLCOMP      0x00008000

#define HB_FA_SUID         0x08000000
#define HB_FA_SGID         0x04000000
#define HB_FA_SVTX         0x02000000
#define HB_FA_RUSR         0x01000000
#define HB_FA_WUSR         0x00800000
#define HB_FA_XUSR         0x00400000
#define HB_FA_RGRP         0x00200000
#define HB_FA_WGRP         0x00100000
#define HB_FA_XGRP         0x00080000
#define HB_FA_ROTH         0x00040000
#define HB_FA_WOTH         0x00020000
#define HB_FA_XOTH         0x00010000

#define FO_READ            0
#define FO_WRITE           1
#define FO_READWRITE       2

#define HB_FO_CREAT        0x0100
#define HB_FO_TRUNC        0x0200
#define HB_FO_EXCL         0x0400
#define HB_FO_DEFAULTS     0x1000

#define FO_CREAT           HB_FO_CREAT
#define FO_TRUNC           HB_FO_TRUNC
#define FO_EXCL            HB_FO_EXCL
#define FO_DEFAULTS        HB_FO_DEFAULTS

#define FO_COMPAT          0
#define FO_EXCLUSIVE       16
#define FO_DENYWRITE       32
#define FO_DENYREAD        48
#define FO_DENYNONE        64
#define FO_SHARED          FO_DENYNONE

#define FS_SET             0
#define FS_RELATIVE        1
#define FS_END             2

#define FD_BINARY          1
#define FD_RAW             FD_BINARY
#define FD_TEXT            2
#define FD_COOKED          FD_TEXT
#define FD_ASCII           FD_TEXT

#define F_ERROR            ( -1 )

#define HB_FLX_EXCLUSIVE   0x0000
#define HB_FLX_SHARED      0x0100
#define HB_FLX_NO_WAIT     0x0000
#define HB_FLX_WAIT        0x0200

#define HB_DISK_AVAIL      0
#define HB_DISK_FREE       1
#define HB_DISK_USED       2
#define HB_DISK_TOTAL      3

#define HB_VF_TIMEOUT      1
#define HB_VF_PORT         2
#define HB_VF_EOF          3
#define HB_VF_SHUTDOWN     4
#define HB_VF_RDHANDLE     5
#define HB_VF_WRHANDLE     6
#define HB_VF_IONAME       7

#endif


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

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

[Assistant]
#require "hbnf"

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

PROCEDURE Main()

   LOCAL cDosScrn
   LOCAL nDosRow
   LOCAL nDosCol
   LOCAL lColor
   LOCAL nMaxRow
   LOCAL nType

   LOCAL cNormH, cNormN
   LOCAL cWindH, cWindN
   LOCAL cErrH, cErrN

   SET SCOREBOARD OFF

   lColor := .T.

   cNormH := iif( lColor, "W+/BG", "W+/N" )
   cNormN := iif( lColor, "N/BG", "W/N"  )
   cWindH := iif( lColor, "W+/B", "W+/N" )
   cWindN := iif( lColor, "W/B", "W/N"  )
   cErrH  := iif( lColor, "W+/R", "W+/N" )
   cErrN  := iif( lColor, "W/R", "W/N"  )

   cDosScrn := SaveScreen()
   nDosRow := Row()
   nDosCol := Col()
   SetColor( "W/N" )
   CLS
   nMaxRow := MaxRow()
   SetBlink( .F. )
   SetColor( cWindN + "*" )
   CLS
   SetColor( cNormN )

   ft_DispMsg( { { "[Esc] To Abort Changes   [PgDn] To Continue" }, { cNormN, , cNormH } }, , nMaxRow - 5 )

   ft_DispMsg( { { "[E]dit     [P]rint    [D]elete", ;
      "[Esc]ape       [Alt-Q]" }, ;
      { cErrN, cErrN, cErrH } }, , 2 )

   nType := ft_DispMsg( { { ;
      "Create Or Edit [I]nvoice", ;
      "Create Or Edit [O]rder", ;
      "Create Or Edit [B]ack Order", ;
      "Create Or Edit [Q]uote", ;
      "[Esc] To Exit" }, ;
      { cWindN, , , , , cWindH } }, "BIOQ" + hb_BChar( K_ESC ) )

   HB_SYMBOL_UNUSED( nType )

   SetColor( "W/N" )
   SetCursor( SC_NORMAL )
   SetBlink( .T. )
   RestScreen( , , , , cDosScrn )
   SetPos( nDosRow, nDosCol )

   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 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charshl.prg. Contains procedures: Main. This file provides legacy compatibility functions

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

PROCEDURE Main()

   LOCAL ni, cStr

   ctinit()

   ? "Begin test of CharShl()"
   ?

   ? "Simple tests:"
   ? '  CharShl( hb_BChar( 1 ) + hb_BChar(  2 ) + hb_BChar(  4 ) + hb_BChar(  8 ) + hb_BChar(  16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 ) =='
   ? '           hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ) + hb_BChar(  0 ) + hb_BChar(  0 ) + hb_BChar(   0 ) ? -->'

   ? '           '
   cStr := CharShl( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 )
   FOR ni := 1 TO Len( cStr )
      ?? "hb_BChar( " + hb_ntos( Asc( SubStr( cStr, ni, 1 ) ) ) + " )"
      IF ni < Len( cStr )
         ?? " + "
      ENDIF
   NEXT
   ?

   ? "End test of CharShl()"
   ?

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

[Assistant]
#require "hbnf"

#include "inkey.ch"

PROCEDURE Main()

   LOCAL aRet

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

   SetColor( "w+/b" )
   CLS
   IF ft_NumLock()
      ft_NumLock( .F. )
   ENDIF
   hb_keyPut( K_F1 )
   aRet := ft_Calendar( 10, 40, "w+/rb", .T., .T. )
   @ 1, 0 SAY "Date        :" + DToC( aRet[ 1 ] )
   @ 2, 0 SAY "Month Number:" + Str( aRet[ 2 ], 2, 0 )
   @ 3, 0 SAY "Day Number  :" + Str( aRet[ 3 ], 2, 0 )
   @ 4, 0 SAY "Year Number :" + Str( aRet[ 4 ], 4, 0 )
   @ 5, 0 SAY "Month       :" + aRet[ 5 ]
   @ 6, 0 SAY "Day         :" + aRet[ 6 ]
   @ 7, 0 SAY "Julian Day  :" + Str( aRet[ 7 ], 3, 0 )
   @ 8, 0 SAY "Current Time:" + aRet[ 8 ]

   RETURN


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

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

[Assistant]
#include "rt_main.ch"

#include "rt_vars.ch"

PROCEDURE Main_DATE()

   LOCAL cDate := "1999-11-25"

   HBTEST Year( NIL )                           IS "E 1 BASE 1112 Argument error (YEAR) OS:0 #:0 A:1:U:NIL F:S"
   HBTEST Year( 100 )                           IS "E 1 BASE 1112 Argument error (YEAR) OS:0 #:0 A:1:N:100 F:S"
#ifdef __HARBOUR__
   HBTEST Year( @sdDate )                       IS 1984
#endif
   HBTEST Year( sdDate)                         IS 1984
   HBTEST Year( sdDateE)                        IS 0
   HBTEST Str( Year( hb_SToD( "19990905" ) ) )  IS " 1999"

   HBTEST Month( NIL )                          IS "E 1 BASE 1113 Argument error (MONTH) OS:0 #:0 A:1:U:NIL F:S"
   HBTEST Month( 100 )                          IS "E 1 BASE 1113 Argument error (MONTH) OS:0 #:0 A:1:N:100 F:S"
#ifdef __HARBOUR__
   HBTEST Month( @sdDate )                      IS 3
#endif
   HBTEST Month( sdDate )                       IS 3
   HBTEST Month( sdDateE )                      IS 0
   HBTEST Str( Month( hb_SToD( "19990905" ) ) ) IS "  9"

   HBTEST Day( NIL )                            IS "E 1 BASE 1114 Argument error (DAY) OS:0 #:0 A:1:U:NIL F:S"
   HBTEST Day( 100 )                            IS "E 1 BASE 1114 Argument error (DAY) OS:0 #:0 A:1:N:100 F:S"
#ifdef __HARBOUR__
   HBTEST Day( @sdDate )                        IS 25
#endif
   HBTEST Day( sdDate )                         IS 25
   HBTEST Day( sdDateE )                        IS 0
   HBTEST Str( Day( hb_SToD( "19990905" ) ) )   IS "  5"

   HBTEST Len( Time() )                   IS 8

   HBTEST DoW( NIL )                      IS "E 1 BASE 1115 Argument error (DOW) OS:0 #:0 A:1:U:NIL F:S"
   HBTEST DoW( 100 )                      IS "E 1 BASE 1115 Argument error (DOW) OS:0 #:0 A:1:N:100 F:S"
#ifdef __HARBOUR__
   HBTEST DoW( @sdDate )                  IS 1
#endif
   HBTEST DoW( sdDate )                   IS 1
   HBTEST DoW( sdDateE )                  IS 0
   HBTEST DoW( hb_SToD( "20000222" ) )    IS 3
   HBTEST DoW( hb_SToD( "20000223" ) )    IS 4
   HBTEST DoW( hb_SToD( "20000224" ) )    IS 5
   HBTEST DoW( hb_SToD( "20000225" ) )    IS 6
   HBTEST DoW( hb_SToD( "20000226" ) )    IS 7
   HBTEST DoW( hb_SToD( "20000227" ) )    IS 1
   HBTEST DoW( hb_SToD( "20000228" ) )    IS 2
   HBTEST DoW( hb_SToD( "20000229" ) )    IS 3
   HBTEST DoW( hb_SToD( "20000230" ) )    IS 0
   HBTEST DoW( hb_SToD( "20000231" ) )    IS 0
   HBTEST DoW( hb_SToD( "20000301" ) )    IS 4

   HBTEST CMonth( NIL )                   IS "E 1 BASE 1116 Argument error (CMONTH) OS:0 #:0 A:1:U:NIL F:S"
   HBTEST CMonth( 100 )                   IS "E 1 BASE 1116 Argument error (CMONTH) OS:0 #:0 A:1:N:100 F:S"
#ifdef __HARBOUR__
   HBTEST CMonth( @sdDate )               IS "March"
#endif
   HBTEST CMonth( sdDate )                IS "March"
   HBTEST CMonth( sdDateE )               IS ""
   HBTEST CMonth( hb_SToD( "19990101" ) ) IS "January"
   HBTEST CMonth( hb_SToD( "19990201" ) ) IS "February"
   HBTEST CMonth( hb_SToD( "19990301" ) ) IS "March"
   HBTEST CMonth( hb_SToD( "19990401" ) ) IS "April"
   HBTEST CMonth( hb_SToD( "19990501" ) ) IS "May"
   HBTEST CMonth( hb_SToD( "19990601" ) ) IS "June"
   HBTEST CMonth( hb_SToD( "19990701" ) ) IS "July"
   HBTEST CMonth( hb_SToD( "19990801" ) ) IS "August"
   HBTEST CMonth( hb_SToD( "19990901" ) ) IS "September"
   HBTEST CMonth( hb_SToD( "19991001" ) ) IS "October"
   HBTEST CMonth( hb_SToD( "19991101" ) ) IS "November"
   HBTEST CMonth( hb_SToD( "19991201" ) ) IS "December"

   HBTEST CDoW( NIL )                     IS "E 1 BASE 1117 Argument error (CDOW) OS:0 #:0 A:1:U:NIL F:S"
   HBTEST CDoW( 100 )                     IS "E 1 BASE 1117 Argument error (CDOW) OS:0 #:0 A:1:N:100 F:S"
#ifdef __HARBOUR__
   HBTEST CDoW( @sdDate )                 IS "Sunday"
#endif
   HBTEST CDoW( sdDate )                  IS "Sunday"
   HBTEST CDoW( sdDateE )                 IS ""
   HBTEST CDoW( hb_SToD( "20000222" ) )   IS "Tuesday"
   HBTEST CDoW( hb_SToD( "20000223" ) )   IS "Wednesday"
   HBTEST CDoW( hb_SToD( "20000224" ) )   IS "Thursday"
   HBTEST CDoW( hb_SToD( "20000225" ) )   IS "Friday"
   HBTEST CDoW( hb_SToD( "20000226" ) )   IS "Saturday"
   HBTEST CDoW( hb_SToD( "20000227" ) )   IS "Sunday"
   HBTEST CDoW( hb_SToD( "20000228" ) )   IS "Monday"
   HBTEST CDoW( hb_SToD( "20000229" ) )   IS "Tuesday"
   HBTEST CDoW( hb_SToD( "20000230" ) )   IS ""
   HBTEST CDoW( hb_SToD( "20000231" ) )   IS ""
   HBTEST CDoW( hb_SToD( "20000301" ) )   IS "Wednesday"

   HBTEST DToC( NIL )                     IS "E 1 BASE 1118 Argument error (DTOC) OS:0 #:0 A:1:U:NIL F:S"
   HBTEST DToC( 100 )                     IS "E 1 BASE 1118 Argument error (DTOC) OS:0 #:0 A:1:N:100 F:S"
   HBTEST DToC( "" )                      IS "E 1 BASE 1118 Argument error (DTOC) OS:0 #:0 A:1:C: F:S"
#ifdef __HARBOUR__
   HBTEST DToC( @sdDate )                 IS "1984-03-25"
#endif
   HBTEST DToC( sdDate )                  IS "1984-03-25"
   HBTEST DToC( sdDateE )                 IS "    -  -  "

   HBTEST CToD( NIL )                     IS "E 1 BASE 1119 Argument error (CTOD) OS:0 #:0 A:1:U:NIL F:S"
   HBTEST CToD( 100 )                     IS "E 1 BASE 1119 Argument error (CTOD) OS:0 #:0 A:1:N:100 F:S"
   HBTEST CToD( "" )                      IS hb_SToD("        ")
#ifdef __HARBOUR__
   HBTEST CToD( @cDate )                  IS hb_SToD("19991125")
#endif
   HBTEST CToD( cDate )                   IS hb_SToD("19991125")
   HBTEST CToD( "1999-11-25/10" )         IS hb_SToD("19991125")

   HBTEST DToS( NIL )                     IS "E 1 BASE 1120 Argument error (DTOS) OS:0 #:0 A:1:U:NIL F:S"
   HBTEST DToS( 100 )                     IS "E 1 BASE 1120 Argument error (DTOS) OS:0 #:0 A:1:N:100 F:S"
#ifdef __HARBOUR__
   HBTEST DToS( @sdDate )                 IS "19840325"
#endif
   HBTEST DToS( sdDate )                  IS "19840325"
   HBTEST DToS( sdDateE )                 IS "        "

   RETURN

#include "rt_init.ch"


[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 utility program: utils/hbtest/rt_mt.prg. Provides functions: DO_MTTES1. Contains procedures: Main_MT, thFunc. This file is part of the test framework

[Assistant]
#include "rt_main.ch"

#include "rt_vars.ch"

#define N_THREADS 5
#define N_JOBS    1000

PROCEDURE Main_MT()

#ifdef __HARBOUR__
   IF hb_mtvm()
      HBTEST DO_MTTES1()              IS "OK"
   ENDIF
#endif

   RETURN

#ifdef __HARBOUR__
STATIC FUNCTION DO_MTTES1()

   LOCAL aThreads, aResults, i, nDigit, nSum, nExpected
   LOCAL mtxJobs, mtxResults

   aThreads := {}
   aResults := {}
   mtxJobs := hb_mutexCreate()
   mtxResults := hb_mutexCreate()
   FOR i := 1 TO N_THREADS
      AAdd( aThreads, hb_threadStart( @thFunc(), mtxJobs, mtxResults ) )
   NEXT
   nDigit := 10
   FOR i := 1 TO N_JOBS
      hb_mutexNotify( mtxJobs, nDigit )
      nDigit++
   NEXT
   FOR i := 1 TO N_THREADS
      hb_mutexNotify( mtxJobs, NIL )
   NEXT
   FOR i := 1 TO N_JOBS
      hb_mutexSubscribe( mtxResults,, @nDigit )
      AAdd( aResults, nDigit )
   NEXT
   AEval( aThreads, {| x | hb_threadJoin( x ) } )
   nSum := 0
   FOR EACH nDigit IN aResults
      nSum += nDigit
   NEXT
   nSum := Round( nSum, 2 )
   nExpected := Round( ( 10 + 10 + N_JOBS - 1 ) / 2 / 3
      RETURN "OK"
   ENDIF

   RETURN "ERROR, final sum: " + hb_ntos( nSum ) + ;
                 " expected: " + hb_ntos( nExpected )

STATIC PROCEDURE thFunc( mtxJobs, mtxResults )

   LOCAL xJob, xResult

   DO WHILE .T.
      hb_mutexSubscribe( mtxJobs,, @xJob )
      IF xJob == NIL
         EXIT
      ENDIF
      xResult := xJob / 3
      hb_mutexNotify( mtxResults, xResult )
   ENDDO

   RETURN

#endif

#include "rt_init.ch"


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

[Assistant]
#ifdef __XHARBOUR__
#define OTHERWISE DEFAULT
#define ENDSWITCH END
#endif

PROCEDURE Main()

   LOCAL a := 1
   MEMVAR m_b
   PRIVATE m_b := "m_b"

#ifndef __XHARBOUR__
   SWITCH a
   ENDSWITCH
#endif

   ?
   ? "1111111111111111111111111111111"
   SWITCH a
   CASE 1
      ? "FOUND: 1"
   ENDSWITCH

   ?
   ? "2222222222222222222222222222222"
   SWITCH a
   CASE 1
      ? "FOUND: 1"
      EXIT
   CASE "2"
      ? a
   ENDSWITCH

   ?
   ? "3333333333333333333333333333333"
   SWITCH a
   CASE 1
      ? "FOUND: 1"
   CASE "2"
      ? "FOUND: 2"
   OTHERWISE
      ? "other"
   ENDSWITCH

#ifndef __XHARBOUR__
   ?
   ? "44444444444444444444444444444444444"
   SWITCH a
   OTHERWISE
      ? "OTHERWISE"
   ENDSWITCH
#endif

   ?
   ? "55555555555555555555555555555555555"
   a := "EE"
#ifndef __XHARBOUR__
   SWITCH a
   CASE 11
      ? "11"
      EXIT

   CASE "CCCC" + "DDDD"
      ? a + a
      EXIT

   CASE "a&m_b"
   CASE 1 + 1
   CASE { 11111111, 22222222222 }[ 1 ]
   CASE 1 + 1 + 1
      ? "3"
      EXIT

   CASE 1 + 1
      ? "4"
      EXIT
   CASE 123456789
   CASE 0
      EXIT
   CASE "AAAA"
   CASE "BBBBB"
      ? a
      EXIT
   CASE Chr( 12 ) + Chr( 15 )
      ? "Chr()"
      EXIT
   OTHERWISE
      ? "NOT FOUND: running OTHER"
   ENDSWITCH
#endif

   ?
   ? "666666666666666666666666666666666666666666"
   a := "2"
   SWITCH a
   CASE 1
      ? "FOUND: 1"
      ? a
      EXIT
   CASE "2"
      SWITCH a + a
      CASE 1
         ? "Nested FOUND 1"
         EXIT
      CASE "22"
         ? "Nested FOUND: 22"
         EXIT
      OTHERWISE
         ? "Nested OTHERWISE"
      ENDSWITCH
      ?? "In CASE 1"
      ? a
   ENDSWITCH

   ? "========================================="

   RETURN


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

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

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

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

CREATE CLASS WvgCheckBox INHERIT WvgWindow, WvgDataRef

   VAR    autosize                              INIT .F.
   VAR    caption                               INIT ""
   VAR    pointerFocus                          INIT .T.
   VAR    selection                             INIT .F.

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

   METHOD setCaption( xCaption )

   ACCESS selected                              INLINE ::sl_lbClick
   ASSIGN selected( bBlock )                    INLINE ::sl_lbClick := bBlock

ENDCLASS

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

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

   ::style       := WS_CHILD + BS_PUSHBUTTON + BS_AUTOCHECKBOX + BS_NOTIFY
   ::className   := "BUTTON"
   ::objType     := objTypeCheckBox

   RETURN Self

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

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

   ::oParent:AddChild( Self )

   ::createControl()

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

   ::setCaption( ::caption )
   IF ::selection
      ::sendMessage( BM_SETCHECK, BST_CHECKED, 0 )
   ENDIF
   ::editBuffer := ( wvg_Button_GetCheck( ::hWnd ) == BST_CHECKED )

   RETURN Self

METHOD WvgCheckBox:handleEvent( nMessage, aNM )

   DO CASE

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

   CASE nMessage == HB_GTE_COMMAND
      IF aNM[ NMH_code ] == BN_CLICKED
         ::editBuffer := ( wvg_Button_GetCheck( ::hWnd ) == BST_CHECKED )
         IF HB_ISBLOCK( ::sl_lbClick )
            IF ::isParentCrt()
               ::oParent:setFocus()
            ENDIF
            Eval( ::sl_lbClick, ::editBuffer, , Self )
            IF ::pointerFocus
               ::setFocus()
            ENDIF
         ENDIF
      ENDIF

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

   ENDCASE

   RETURN EVENT_UNHANDELLED

METHOD PROCEDURE WvgCheckBox:destroy()

   ::wvgWindow:destroy()

   RETURN

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

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

   RETURN Self

METHOD WvgCheckBox:setCaption( xCaption )

   IF HB_ISSTRING( xCaption )
      ::caption := xCaption
      wvg_SendMessageText( ::hWnd, WM_SETTEXT, 0, ::caption )
   ENDIF

   RETURN Self


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

[User] Define Harbour macros and constants: Harbour test program: tests/ipclnt.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#include "hbsocket.ch"

#define ADDRESS                     "127.0.0.1"
#define PORT                        10000
#define EOT                         hb_BChar( 4 )

PROCEDURE Main()

   LOCAL hSocket

   IF Empty( hSocket := hb_socketOpen() )
      ? "socket create error " + hb_ntos( hb_socketGetError() )
   ENDIF
   IF ! hb_socketConnect( hSocket, { HB_SOCKET_AF_INET, ADDRESS, PORT } )
      ? "socket connect error " + hb_ntos( hb_socketGetError() )
   ENDIF

   ? hb_socketSend( hSocket, "hi" + EOT )
   ? hb_socketSend( hSocket, "how" + EOT )
   ? hb_socketSend( hSocket, "you doing?" + EOT )
   ? hb_socketSend( hSocket, "quit" + EOT )

   hb_socketShutdown( hSocket )
   hb_socketClose( hSocket )

   RETURN


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

[User] Define Harbour macros and constants: Harbour Runtime Library file: src/rtl/typefile.prg. Contains procedures: __TypeFile. This file implements object-oriented classes using Harbour's class system

[Assistant]
#include "error.ch"
#include "fileio.ch"

#define BUFFER_LENGTH  8192

PROCEDURE __TypeFile( cFile, lPrint )

   LOCAL nHandle
   LOCAL cBuffer
   LOCAL nRead
   LOCAL nHasRead
   LOCAL nSize
   LOCAL nBuffer
   LOCAL oErr
   LOCAL nRetries
   LOCAL aSaveSet[ 2 ]
   LOCAL cDir, cName, cExt
   LOCAL cTmp
   LOCAL cPath
   LOCAL i

   hb_default( @lPrint, .F. )

   IF ! HB_ISSTRING( cFile )
      oErr := ErrorNew()
      oErr:severity    := ES_ERROR
      oErr:genCode     := EG_ARG
      oErr:subSystem   := "BASE"
      oErr:SubCode     := 2009
      oErr:Description := ProcName()
      Eval( ErrorBlock(), oErr )
   ENDIF

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

   IF Empty( cDir )

      cTmp := StrTran( Set( _SET_DEFAULT ) + ";" + Set( _SET_PATH ), ",", ";" )

      i := Len( cTmp )
      DO WHILE SubStr( cTmp, i, 1 ) == ";"
         cTmp := Left( cTmp, --i )
      ENDDO

      FOR EACH cPath IN hb_ATokens( cTmp, ";" )
         IF hb_FileExists( cTmp := hb_FNameMerge( cPath, cName, cExt ) )
            cFile := cTmp
            EXIT
         ENDIF
      NEXT
   ENDIF

   nRetries := 0
   DO WHILE ( nHandle := FOpen( cFile, FO_READWRITE ) ) == F_ERROR
      oErr := ErrorNew()
      oErr:severity    := ES_ERROR
      oErr:genCode     := EG_OPEN
      oErr:subSystem   := "BASE"
      oErr:SubCode     := 2011
      oErr:canDefault  := .T.
      oErr:canRetry    := .T.
      oErr:fileName    := cFile
      oErr:OsCode      := FError()
      oErr:tries       := ++nRetries
      IF ! hb_defaultValue( Eval( ErrorBlock(), oErr ), .T. )
         RETURN
      ENDIF
   ENDDO

   IF lPrint
      aSaveSet[ 1 ] := Set( _SET_DEVICE, "PRINTER" )
      aSaveSet[ 2 ] := Set( _SET_PRINTER, .T. )
   ENDIF

   nSize   := FSeek( nHandle, 0, FS_END )
   nBuffer := Min( nSize, BUFFER_LENGTH )

   FSeek( nHandle, 0 )

   nHasRead := 0
   cBuffer := Space( nBuffer )
   QOut()
   DO WHILE ( nRead := FRead( nHandle, @cBuffer, nBuffer ) ) > 0
      nHasRead += nRead
      QQOut( cBuffer )
      nBuffer := Min( nSize - nHasRead, nBuffer )
      cBuffer := Space( nBuffer )
   ENDDO

   FClose( nHandle )

   IF lPrint
      Set( _SET_DEVICE,  aSaveSet[ 1 ] )
      Set( _SET_PRINTER, aSaveSet[ 2 ] )
   ENDIF

   RETURN


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

[User] Implement this Harbour module: Header file for contribution module 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/dmlb.ch. Defines constants: _DMLB_CH, DB_WORKSPACE, DB_ZEROSPACE. Defines database/RDD constants

[Assistant]
#ifndef _DMLB_CH
#define _DMLB_CH

#define DB_WORKSPACE    1
#define DB_ZEROSPACE    2

#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/server.prg. Contains procedures: Main, Progress. This test file tests specific function APIs

[Assistant]
PROCEDURE Main( cPort )

   LOCAL Socket, s
   LOCAL nResponse, cResponse
   LOCAL nTurn := 0, nTurn1 := 0
   LOCAL bCont := .T.

   CLS

   IF Empty( cPort )
      cPort := "2000"
   ENDIF

   hb_inetInit()

   @ 1, 15 SAY "H A R B O U R - Inet Api Server Demo"
   @ 2,  5 SAY "Contact this server using telnet or the Harbour Inet Client demo"
   @ 3,  5 SAY "Press a [KEY] to terminate the program"
   @ 5,  5 SAY "Server listening on port " + cPort + "..."
   Socket := hb_inetServer( Val( cPort ) )
   hb_inetTimeout( Socket, 500 )

   DO WHILE bCont

      @ 6, 5 SAY Space( 70 )
      @ 7, 5 SAY Space( 70 )
      @ 8, 5 SAY Space( 70 )
      @ 9, 5 SAY Space( 70 )
      @ 6, 5

      DO WHILE bCont
         Progress( @nTurn, 5, 39 )
         s := hb_inetAccept( Socket )
         IF hb_inetErrorCode( Socket ) == 0
            EXIT
         ENDIF
         IF Inkey() != 0
            bCont := .F.
         ENDIF
      ENDDO

      IF ! bCont
         EXIT
      ENDIF

      hb_inetTimeout( s, 500 )

      @ 6, 5 SAY "Connection from: " + hb_inetAddress( s ) + ":" + Str( hb_inetPort( s ), 5 )
      @ 7, 5 SAY "Receiving: "
      @ 8, 5

      nResponse := hb_inetSend( s, "Welcome to my server!" + hb_eol() )

      DO WHILE bCont

         hb_inetTimeout( s, 250 )

         hb_inetPeriodCallback( s, { @Progress(), @nTurn, 6, 39 } )

         cResponse := hb_inetRecvLine( s, @nResponse )

         DO CASE
         CASE hb_inetErrorCode( s ) == 0
            IF Lower( cResponse ) == "quit"
               bCont := .F.
            ENDIF
            @ 8, 5 SAY Space( 70 )
            @ 8, 5 SAY cResponse
            cResponse := "Count: " + Str( nResponse ) + " characters" + hb_eol()
            hb_inetSend( s, cResponse )

         CASE hb_inetErrorCode( s ) == -1

            Progress( @nTurn1, 7, 17 )

         OTHERWISE
            @ 7, 5 SAY "Received Error " + Str( hb_inetErrorCode( s ) ) + ": " + hb_inetErrorDesc( s )
            @ 8, 5 SAY Space( 70 )
            @ 9, 5 SAY Space( 70 )
            @ 9, 5 SAY "Press a key to continue"
            Inkey( 0 )
            EXIT

         ENDCASE

         IF Inkey() != 0
            bCont := .F.
         ENDIF
      ENDDO
   ENDDO

   hb_inetCleanup()

   RETURN

PROCEDURE Progress( nProgress, nDrow, nDcol )

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

   @ nDrow, nDcol SAY "[ ]"

   DO CASE
   CASE nProgress == 0
      @ nDrow, nDcol + 1 SAY "-"
   CASE nProgress == 1
      @ nDrow, nDcol + 1 SAY "\"
   CASE nProgress == 2
      @ nDrow, nDcol + 1 SAY "|"
   CASE nProgress == 3
      @ nDrow, nDcol + 1 SAY "/"
   ENDCASE

   nProgress++

   IF nProgress == 4
      nProgress := 0
   ENDIF

   @ nRow, nCol

   RETURN


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

[User] Generate Harbour code for: Harbour test program: tests/objasign.prg. Provides functions: TNumber, New. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
PROCEDURE Main()

   LOCAL o := TNumber():New()

   ? "Direct reference : ", o:x

   o:x := "I am a data"
   ? "Assign text      : ", o:x

   o:x := 4
   ? "Assign 4         : ", o:x

   ? "Post increment   : ", o:x++
   ? "After            : ", o:x
   ? "Pre decrement    : ", --o:x
   ? "After            : ", o:x

   o:x += 2
   ? "Plus 2           : ", o:x

   o:x -= 3
   ? "Minus 3          : ", o:x

   o:x
   ? "Times 3          : ", o:x

   o:x /= 1.5
   ? "Divide by 1.5    : ", o:x

   o:x %= 4
   ? "Modulus 4        : ", o:x

   o:x ^= 3
   ? "To the power 3   : ", o:x

   ? "Global stack"
   ? hb_ValToExp( __dbgVMStkGList() )
   ? "Statics"
   ? hb_ValToExp( __dbgVMVarSList() )

   RETURN

FUNCTION TNumber()

   STATIC oNumber

   IF oNumber == NIL
      oNumber := HBClass():New( "TNumber" )

      oNumber:AddData( "x" )
      oNumber:AddMethod( "New", @New() )
      oNumber:Create()
   ENDIF

   RETURN oNumber:Instance()

STATIC FUNCTION New()

   LOCAL self := QSelf()

   ::x := 1

   RETURN Self


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

[User] Implement this Harbour module: Harbour header file: include/hbtrace.ch. Defines 10 constants including: HB_TRACE_CH_, HB_TR_ALWAYS, HB_TR_FATAL, HB_TR_ERROR, HB_TR_WARNING. Declares 3 preprocessor translations. Defines Harbour internal constants and macros

[Assistant]
#ifndef HB_TRACE_CH_
#define HB_TRACE_CH_

#define HB_TR_ALWAYS     0
#define HB_TR_FATAL      1
#define HB_TR_ERROR      2
#define HB_TR_WARNING    3
#define HB_TR_INFO       4
#define HB_TR_DEBUG      5
#define HB_TR_LAST       6

#ifdef _HB_TR_NOALWAYS_
#undef HB_TR_ALWAYS
#define HB_TR_ALWAYS     HB_TR_LAST
#endif

#define HB_TR_DEFAULT   HB_TR_WARNING

#ifdef HB_TR_LEVEL_ALWAYS
#define HB_TR_LEVEL     HB_TR_ALWAYS
#endif
#ifdef HB_TR_LEVEL_FATAL
#define HB_TR_LEVEL     HB_TR_FATAL
#endif
#ifdef HB_TR_LEVEL_ERROR
#define HB_TR_LEVEL     HB_TR_ERROR
#endif
#ifdef HB_TR_LEVEL_WARNING
#define HB_TR_LEVEL     HB_TR_WARNING
#endif
#ifdef HB_TR_LEVEL_INFO
#define HB_TR_LEVEL     HB_TR_INFO
#endif
#ifdef HB_TR_LEVEL_DEBUG
#define HB_TR_LEVEL     HB_TR_DEBUG
#endif

#ifndef HB_TR_LEVEL
#define HB_TR_LEVEL     HB_TR_DEFAULT
#endif

#xtranslate HB_TRACE_STEALTH( <l>, <x,...> ) => HB_TRACE( <l>, <x> )
#xtranslate HB_TRACE( <l>, ( <x,...> ) )     => HB_TRACE( <l>, <x> )
#xtranslate HB_TRACE( <l>, <x,...> )         => ;
            iif( HB_TR_LEVEL >= <l>, hb_traceLogAt( <l>, <x> ), )

#endif


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

[User] Generate Harbour code for: Harbour contribution module 'hbblink' (Blinker function extender): contrib/hbblink/blinker.prg. Provides 53 functions including: BliDbgHan, BliDemDte, BliDemDteBas, BliDemMin, BliErrNum. Contains 10 procedures. This file provides utility functions

[Assistant]
#include "hbhrb.ch"
#include "hbmemory.ch"

#include "hbblink.ch"

STATIC s_cSerialNum := ""
STATIC s_cDemoDate := ""
STATIC s_nDemoMinutes := 0
STATIC s_nError := 0
STATIC s_cErrorParam := ""
STATIC s_lLibOverrides := .F.

THREAD STATIC t_nErrorLevel := 0
THREAD STATIC t_nErrorMaj := 0
THREAD STATIC t_nErrorMin := 0

PROCEDURE hb_BliVerNum( cString )

   IF HB_ISSTRING( cString )
      s_cSerialNum := cString
   ENDIF

   RETURN

PROCEDURE hb_BliDemDte( dDate )

   IF HB_ISDATE( dDate )
      s_cDemoDate := DToS( dDate )
   ENDIF

   RETURN

PROCEDURE hb_BliDemMin( nValue )

   IF HB_ISNUMERIC( nValue )
      s_nDemoMinutes := nValue
   ENDIF

   RETURN

FUNCTION BliDbgHan( nValue )

   STATIC s_nDebugHandle := 1
   LOCAL nOldValue := s_nDebugHandle

   IF HB_ISNUMERIC( nValue )
      s_nDebugHandle := nValue
   ENDIF

   RETURN nOldValue

FUNCTION BliDemDte()
   RETURN s_cDemoDate

FUNCTION BliDemDteBas()
   RETURN s_cDemoDate

FUNCTION BliDemMin( nValue )

   LOCAL nOldValue := s_nDemoMinutes

   IF HB_ISNUMERIC( nValue )
      s_nDemoMinutes := nValue
   ENDIF

   RETURN nOldValue

PROCEDURE BliDisFrg( fhnd )

   HB_SYMBOL_UNUSED( fhnd )

   RETURN

FUNCTION BliErrNum()
   RETURN s_nError

FUNCTION BliErrPrm()
   RETURN s_cErrorParam

FUNCTION BliErrPrmBas()
   RETURN s_cErrorParam

FUNCTION BliLibLib( cLib )
   RETURN iif( s_lLibOverrides, hb_hrbLoad( HB_HRB_BIND_OVERLOAD, cLib ), hb_hrbLoad( cLib ) )

FUNCTION BliFunHan( pLib, cFunction )
   RETURN hb_hrbGetFunSym( pLib, cFunction )

FUNCTION BliFunCal( ... )

   LOCAL aParams := hb_AParams()
   LOCAL pFunction

   IF Len( aParams ) > 0
      pFunction := ATail( aParams )
      ASize( aParams, Len( aParams ) - 1 )
      RETURN hb_hrbDo( pFunction, hb_ArrayToParams( aParams ) )
   ENDIF

   RETURN NIL

PROCEDURE BliLibFre( pLib )

   hb_hrbUnload( pLib )

   RETURN

PROCEDURE BliLibOvr( lValue )

   IF HB_ISLOGICAL( lValue )
      s_lLibOverrides := lValue
   ENDIF

   RETURN

PROCEDURE BliLstFrg( fhnd )

   HB_SYMBOL_UNUSED( fhnd )

   RETURN

FUNCTION BliMemAvl()
   RETURN Memory( HB_MEM_CHAR )

FUNCTION BliMemSiz()
   RETURN Memory( HB_MEM_CHAR )

FUNCTION BliMemBlk( nBlockSize )

   HB_SYMBOL_UNUSED( nBlockSize )

   RETURN Memory( HB_MEM_CHAR )

FUNCTION BliMemPak( nValue )

   STATIC s_nGCFrequency := 0
   LOCAL nOldValue := s_nDemoMinutes

   IF HB_ISNUMERIC( nValue )
      s_nGCFrequency := nValue
   ENDIF

   RETURN nOldValue

FUNCTION BliMemUse()
   RETURN Memory( HB_MEM_USED )

PROCEDURE BliOvlClr()
   RETURN

FUNCTION BliOvlOps()
   RETURN Memory( HB_MEM_CHAR )

PROCEDURE BliOvlRes()
   RETURN

FUNCTION BliOvlSiz()
   RETURN 0

PROCEDURE BliOvlSus( nValue )

   HB_SYMBOL_UNUSED( nValue )

   RETURN

FUNCTION BliPtrDec( nPointer, nValue )
   RETURN nPointer - nValue

FUNCTION BliPtrInc( nPointer, nValue )
   RETURN nPointer + nValue

FUNCTION BliSerNum()
   RETURN s_cSerialNum

FUNCTION BliSerNumBas()
   RETURN s_cSerialNum

FUNCTION BliStrFrg( cString )

   HB_SYMBOL_UNUSED( cString )

   RETURN ""

FUNCTION BliVerNum()
   RETURN 700

FUNCTION BliCpuRel()
   RETURN hb_ReleaseCPU()

FUNCTION BliMgrSts( nParam )

   SWITCH nParam
   CASE BliCacheLoc     ; RETURN BliCacheNone
   CASE BliHostMode     ; RETURN BliHostNone
   CASE BliMachineMode  ; RETURN BliMode286Prot
   CASE BliOverlaySize  ; RETURN Memory( HB_MEM_CHAR )
   CASE BliRealMemAvail ; RETURN Memory( HB_MEM_CHAR )
   CASE BliCacheSize
   CASE BliExtMemAvail
   CASE BliOverlayLoc
   CASE BliVirMemAvail
   ENDSWITCH

   RETURN 0

FUNCTION SwpAddEnv( nBytes )

   HB_SYMBOL_UNUSED( nBytes )

   RETURN 32768

FUNCTION SwpAddStr( cPID, cString )

   HB_SYMBOL_UNUSED( cPID )
   HB_SYMBOL_UNUSED( cString )

   RETURN 1

FUNCTION SwpAddStrBas( cPID, cString )

   HB_SYMBOL_UNUSED( cPID )
   HB_SYMBOL_UNUSED( cString )

   RETURN 1

FUNCTION SwpCurDir( lValue )

   HB_SYMBOL_UNUSED( lValue )

   RETURN .T.

FUNCTION SwpDisMsg( lValue )

   HB_SYMBOL_UNUSED( lValue )

   RETURN .F.

FUNCTION SwpEms320( lValue )

   HB_SYMBOL_UNUSED( lValue )

   RETURN .F.

FUNCTION SwpErrLev()
   RETURN t_nErrorLevel

FUNCTION SwpErrMaj()
   RETURN t_nErrorMaj

FUNCTION SwpErrMin()
   RETURN t_nErrorMin

FUNCTION SwpFreEms( nLimitKB )

   HB_SYMBOL_UNUSED( nLimitKB )

   RETURN 0

FUNCTION SwpUseEms( lValue )

   HB_SYMBOL_UNUSED( lValue )

   RETURN .F.

FUNCTION SwpFreXms( nLimitKB )

   HB_SYMBOL_UNUSED( nLimitKB )

   RETURN 0

FUNCTION SwpUseXms( lValue )

   HB_SYMBOL_UNUSED( lValue )

   RETURN .F.

FUNCTION SwpUseUmb( lValue )

   HB_SYMBOL_UNUSED( lValue )

   RETURN .F.

FUNCTION SwpGetKey( lValue )

   HB_SYMBOL_UNUSED( lValue )

   RETURN .F.

FUNCTION SwpGetPid( cIDString )

   HB_SYMBOL_UNUSED( cIDString )

   RETURN .F.

FUNCTION SwpVidMde( lValue )

   HB_SYMBOL_UNUSED( lValue )

   RETURN .F.

FUNCTION SwpGetStr()
   RETURN ""

FUNCTION SwpKeyBrd( cKeyString )

   HB_SYMBOL_UNUSED( cKeyString )

   RETURN 0

FUNCTION SwpKeyBrdBas( cKeyString )

   HB_SYMBOL_UNUSED( cKeyString )

   RETURN 0

FUNCTION SwpKeyClr( nValue )

   HB_SYMBOL_UNUSED( nValue )

   RETURN 0

FUNCTION SwpNobOot( lValue )

   HB_SYMBOL_UNUSED( lValue )

   RETURN .F.

FUNCTION SwpRunCmd( cCommand, nMem, cRunPath, cTempPath )

   HB_SYMBOL_UNUSED( nMem )
   HB_SYMBOL_UNUSED( cRunPath )
   HB_SYMBOL_UNUSED( cTempPath )

   IF ! HB_ISSTRING( cCommand ) .OR. Empty( cCommand )
#if defined( __PLATFORM__UNIX )
      cCommand := GetEnv( "SHELL" )
#else
      cCommand := GetEnv( "COMSPEC" )
#endif
   ENDIF

   RETURN ( t_nErrorLevel := hb_run( cCommand ) ) != -1

FUNCTION SwpSetEnv( cString )

   LOCAL cPair
   LOCAL tmp

   FOR EACH cPair IN hb_ATokens( cString, hb_BChar( 255 ) )
      IF ( tmp := At( "=", cPair ) ) > 0
         hb_SetEnv( Left( cPair, tmp - 1 ), SubStr( cPair, tmp + 1 ) )
      ENDIF
   NEXT

   RETURN .T.

FUNCTION SwpSetPid( cIDString )

   HB_SYMBOL_UNUSED( cIDString )

   RETURN .T.

FUNCTION SwpSetPidBas( cIDString )

   HB_SYMBOL_UNUSED( cIDString )

   RETURN .T.

FUNCTION SwpSetStr( cString )

   HB_SYMBOL_UNUSED( cString )

   RETURN .T.

FUNCTION SwpSetStrBas( cString )

   HB_SYMBOL_UNUSED( cString )

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

Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/url.prg. Defines classes: TUrl. This file provides network protocol implementations

[Assistant]
#include "hbclass.ch"

CREATE CLASS TUrl

   VAR cAddress  INIT ""
   VAR cProto    INIT ""
   VAR cUserid   INIT ""
   VAR cPassword INIT ""
   VAR cServer   INIT ""
   VAR cPath     INIT ""
   VAR cQuery    INIT ""
   VAR cFile     INIT ""
   VAR nPort     INIT -1

   METHOD New( cUrl )
   METHOD SetAddress( cUrl )
   METHOD BuildAddress()
   METHOD BuildQuery()
   METHOD AddGetForm( xPostData )

   HIDDEN:

   CLASS VAR cREuri   INIT hb_regexComp( "(?:(.*):
   CLASS VAR cREServ  INIT hb_regexComp( "(?:([^:@]*):?([^@:]*)@|)([^:]+):?(.*)" )
   CLASS VAR cREFile  INIT hb_regexComp( "^((?:/.*/)|/)*(.*)$" )

ENDCLASS

METHOD New( cUrl ) CLASS TUrl

   ::SetAddress( cUrl )

   RETURN Self

METHOD SetAddress( cUrl ) CLASS TUrl

   LOCAL aMatch, cServer, cPath

   IF ! HB_ISSTRING( cUrl )
      RETURN .F.
   ENDIF

   ::cAddress := cUrl
   ::cProto := ;
   ::cUserid := ;
   ::cPassword := ;
   ::cServer := ;
   ::cPath := ;
   ::cQuery := ;
   ::cFile := ""
   ::nPort := -1

   IF cUrl == ""
      RETURN .T.
   ENDIF

   IF Empty( aMatch := hb_regex( ::cREuri, cUrl ) )
      RETURN .F.
   ENDIF

   ::cProto := Lower( aMatch[ 2 ] )
   cServer := aMatch[ 3 ]
   cPath := aMatch[ 4 ]
   ::cQuery := aMatch[ 5 ]

   aMatch := hb_regex( ::cREServ, cServer )
   ::cUserId := aMatch[ 2 ]
   ::cPassword := aMatch[ 3 ]
   ::cServer := aMatch[ 4 ]
   ::nPort := Val( aMatch[ 5 ] )
   IF ::nPort < 1
      ::nPort := -1
   ENDIF

   aMatch := hb_regex( ::cREFile, cPath )
   ::cPath := aMatch[ 2 ]
   ::cFile := aMatch[ 3 ]

   RETURN .T.

METHOD BuildAddress() CLASS TUrl

   LOCAL cRet := ""

   IF ::cProto != NIL
      ::cProto := Lower( ::cProto )
   ENDIF

   IF ! Empty( ::cProto ) .AND. ! ::cServer == ""
      cRet := ::cProto + ":
   ENDIF

   IF ! ::cUserid == ""
      cRet += ::cUserid
      IF ! ::cPassword == ""
         cRet += ":" + ::cPassword
      ENDIF
      cRet += "@"
   ENDIF

   IF ! ::cServer == ""
      cRet += ::cServer
      IF ::nPort > 0
         cRet += ":" + hb_ntos( ::nPort )
      ENDIF
   ENDIF

   IF ::cPath == "" .OR. ! Right( ::cPath, 1 ) == "/"
      ::cPath += "/"
   ENDIF

   cRet += ::cPath + ::cFile
   IF ! ::cQuery == ""
      cRet += "?" + ::cQuery
   ENDIF

   RETURN iif( cRet == "", NIL, ::cAddress := cRet )

METHOD BuildQuery() CLASS TUrl

   LOCAL cLine

   IF ::cPath == "" .OR. ! Right( ::cPath, 1 ) == "/"
      ::cPath += "/"
   ENDIF

   cLine := ::cPath + ::cFile
   IF ! ::cQuery == ""
      cLine += "?" + ::cQuery
   ENDIF

   RETURN cLine

METHOD AddGetForm( xPostData ) CLASS TUrl

   LOCAL cData := ""
   LOCAL item

   DO CASE
   CASE HB_ISHASH( xPostData )
      FOR EACH item IN xPostData
         cData += ;
            tip_URLEncode( AllTrim( hb_CStr( item:__enumKey() ) ) ) + "=" + ;
            tip_URLEncode( AllTrim( hb_CStr( item ) ) )
         IF ! item:__enumIsLast()
            cData += "&"
         ENDIF
      NEXT
   CASE HB_ISARRAY( xPostData )
      FOR EACH item IN xPostData
         cData += ;
            tip_URLEncode( AllTrim( hb_CStr( item:__enumIndex() ) ) ) + "=" + ;
            tip_URLEncode( AllTrim( hb_CStr( item ) ) )
         IF ! item:__enumIsLast()
            cData += "&"
         ENDIF
      NEXT
   CASE HB_ISSTRING( xPostData )
      cData := xPostData
   ENDCASE

   RETURN iif( cData == "", NIL, ;
      ::cQuery += iif( ::cQuery == "", "", "&" ) + cData )


[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 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/dll.ch. Defines 9 constants including: _DLL_CH, DLL_CDECL, DLL_STDCALL, DLL_SYSTEM, DLL_OSAPI

[Assistant]
#ifndef _DLL_CH
#define _DLL_CH

#define DLL_CDECL                   0x08
#define DLL_STDCALL                 0x20
#define DLL_SYSTEM                  0x04
#if defined( __PLATFORM__WINDOWS )
#define DLL_OSAPI                   DLL_STDCALL
#elif defined( __PLATFORM__OS2 )
#define DLL_OSAPI                   DLL_SYSTEM
#else
#define DLL_OSAPI                   DLL_CDECL
#endif

#define DLL_CALLMODE_COPY           0
#define DLL_CALLMODE_NORMAL         DLL_CALLMODE_COPY

#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 'hbct' (CA-Tools compatibility library): contrib/hbct/ct.prg. Provides functions: ctinit, ctexit. Contains procedures: _CTINIT, _CTEXIT. This file provides legacy compatibility functions

[Assistant]
STATIC s_bInitialized := .F.

FUNCTION ctinit()

   IF ! s_bInitialized
      s_bInitialized := ctcinit()
   ENDIF

   RETURN s_bInitialized

INIT PROCEDURE _CTINIT()

   IF ! s_bInitialized
      s_bInitialized := ctcinit()
   ENDIF

   RETURN

FUNCTION ctexit()

   IF s_bInitialized
      ctcexit()
      s_bInitialized := .F.
   ENDIF

   RETURN NIL

EXIT PROCEDURE _CTEXIT()

   IF s_bInitialized
      ctcexit()
      s_bInitialized := .F.
   ENDIF

   RETURN


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

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

[Assistant]
FUNCTION ft_AcctQtr( dGivenDate, nQtrNum )

   LOCAL nYTemp, nQTemp, aRetVal

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

   aRetVal      := ft_Qtr( dGivenDate )
   nYTemp       := Val( SubStr( aRetVal[ 1 ], 1, 4 ) )
   nQTemp       := Val( SubStr( aRetVal[ 1 ], 5, 2 ) )
   aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )
   aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )

   IF dGivenDate < aRetVal[ 2 ]

      dGivenDate := ft_MAdd( dGivenDate, - 1 )
      aRetVal    := ft_Qtr( dGivenDate )
      nQTemp     -= 1
      IF nQTemp  == 0
         nYTemp  -= 1
         nQTemp  := 4
      ENDIF
      aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )
      aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )

   ELSEIF dGivenDate > aRetVal[ 3 ]

      dGivenDate := ft_MAdd( dGivenDate, 1 )
      aRetVal    := ft_Qtr( dGivenDate )
      nQTemp     += 1
      IF nQTemp  == 5
         nYTemp  += 1
         nQTemp  := 1
      ENDIF
      aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )
      aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )

   ENDIF

   IF HB_ISNUMERIC( nQtrNum )
      IF nQtrNum < 1 .OR. nQtrNum > 4
         nQtrNum := 4
      ENDIF
      aRetVal      := ft_Qtr( dGivenDate, nQtrNum )
      nYTemp       := Val( SubStr( aRetVal[ 1 ], 1, 4 ) )
      nQTemp       := Val( SubStr( aRetVal[ 1 ], 5, 2 ) )
      aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )
      aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )
   ENDIF

   aRetVal[ 1 ] := Str( nYTemp, 4 ) + StrZero( nQTemp, 2 )

   RETURN aRetVal


[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 'hbnetio' (Network I/O operations): contrib/hbnetio/tests/netiomt1.prg. Contains procedures: Main. This file provides network protocol implementations

[Assistant]
#require "hbnetio"

#define NETSERVER  "127.0.0.1"
#define NETPORT    2940
#define NETPASSWD  "toptopsecret"

PROCEDURE Main()

   ? "CONNECTING..."
   ? "netio_Connect():", netio_Connect( NETSERVER, NETPORT,, NETPASSWD )
   ?

   ? "Number of connected clients:", Len( netio_FuncExec( "netio_conninfo" ) )
   ? "SHUTDOWN server:", netio_FuncExec( "netio_shutdown" )
   ?

   ? "netio_Disconnect():", netio_Disconnect( NETSERVER, NETPORT )

   RETURN


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

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

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

[Assistant]
FUNCTION ft_InvClr( cDsrdColor )

   LOCAL cBackground
   LOCAL cForeground
   LOCAL cModifiers

   __defaultNIL( @cDsrdColor, SetColor() )

   cDsrdColor := Left( cDsrdColor, At( ",", cDsrdColor + "," ) - 1 )

   cModifiers := ;
      iif( "*" $ cDsrdColor, "*", "" ) + ;
      iif( "+" $ cDsrdColor, "+", "" )

   cForeground := AllTrim( Left( cDsrdColor,   At( "/", cDsrdColor ) - 1 ) )
   cBackground := AllTrim( SubStr( cDsrdColor, At( "/", cDsrdColor ) + 1 ) )

   RETURN ;
      StrTran( StrTran( cBackground, "+" ), "*" ) + cModifiers + "/" + ;
      StrTran( StrTran( cForeground, "+" ), "*" )


[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 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/http_cli.prg. Contains procedures: Main. This file provides network protocol implementations

[Assistant]
#require "hbssl"
#require "hbtip"

#if ! defined( __HBSCRIPT__HBSHELL )
REQUEST __HBEXTERN__HBSSL__
#endif

PROCEDURE Main( cProxy )

   LOCAL cURL := iif( tip_SSL(), "https", "http" ) + ":
   LOCAL oHTTP := TIPClientHTTP():New( cURL, .T. )

   ? "Proxy:", cProxy
   ? "URL:", cURL

   IF HB_ISSTRING( cProxy )
      oHTTP:setProxy( TUrl():New( cProxy ) )
   ENDIF
   oHTTP:setCookie( "test01=value01" )

   IF oHTTP:Open()
      IF oHTTP:Post( "test" )
         ? oHTTP:cReply
         ? hb_ValToExp( oHTTP:hHeaders )
      ELSE
         ? "Error:", "oHTTP:Post()", oHTTP:lastErrorMessage()
      ENDIF
      oHTTP:Close()
   ELSE
      ? "Error:", "oHTTP:Open()", oHTTP:lastErrorMessage()
   ENDIF

   RETURN


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

[User] Write Harbour functions: MenuModal, ShowMsg, IsShortcut. Harbour Runtime Library file: src/rtl/menusys.prg. Provides functions: MenuModal, ShowMsg, IsShortcut, IsQuick. This file provides utility functions

[Assistant]
#include "hbclass.ch"

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

#ifdef HB_COMPAT_C53

FUNCTION MenuModal( oTopMenu, nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )
   RETURN HBMenuSys():New( oTopMenu ):modal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )

FUNCTION ShowMsg( aMsg, lMode )

   HB_SYMBOL_UNUSED( aMsg )
   HB_SYMBOL_UNUSED( lMode )

   RETURN .F.

FUNCTION IsShortcut( oMenu, nKey,  nID )

   LOCAL nItem
   LOCAL nTotal
   LOCAL nShortCut
   LOCAL oItem
   LOCAL i

   DO CASE

   CASE ! oMenu:ClassName() == "TOPBARMENU"

      RETURN IsQuick( oMenu, nKey, @nID )

   CASE ( nShortCut := oMenu:getShortCt( nKey ) ) > 0 .AND. ;
        ( oItem := oMenu:getItem( nShortcut ) ):enabled .AND. ;
        ! oItem:isPopUp()

      oMenu:select( nShortCut )
      Eval( oItem:data, oItem )
      nID := oItem:ID

      RETURN .T.

   CASE nShortCut == 0

      nTotal := oMenu:itemCount
      nItem  := oMenu:current

      IF nItem == 0
         nItem := 1
      ENDIF

      FOR i := 1 TO nTotal

         IF ( oItem := oMenu:getItem( nItem ) ):enabled .AND. ;
            oItem:isPopUp() .AND. ;
            IsQuick( oItem:data, nKey, @nID )

            RETURN .T.
         ENDIF

         IF ++nItem > nTotal
            nItem := 1
         ENDIF
      NEXT

   ENDCASE

   RETURN .F.

FUNCTION IsQuick( oMenu, nKey,  nID )

   LOCAL nItem
   LOCAL nTotal
   LOCAL nShortCut
   LOCAL oItem

   IF ( nShortCut := oMenu:getShortCt( nKey ) ) == 0

      nTotal := oMenu:itemCount

      FOR nItem := 1 TO nTotal

         IF ( oItem := oMenu:getItem( nItem ) ):enabled .AND. ;
            oItem:isPopUp() .AND. ;
            IsQuick( oItem:data, nKey, @nID )

            RETURN .T.
         ENDIF
      NEXT

   ELSEIF !( oItem := oMenu:getItem( nShortCut ) ):isPopUp() .AND. oItem:enabled

      oMenu:select( nShortCut )
      Eval( oItem:data, oItem )
      nID := oItem:ID

      RETURN .T.

   ENDIF

   RETURN .F.

#endif


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

[User] Implement this Harbour module: Harbour contribution module 'hbcairo' (Cairo graphics library wrapper): contrib/hbcairo/tests/hellow.prg. Contains procedures: Main. This file provides graphics and image processing capabilities

[Assistant]
#require "hbcairo"

REQUEST HB_CODEPAGE_LTWIN

PROCEDURE Main()

   LOCAL hSurface, hCairo, nI

   hb_cdpSelect( "LTWIN" )
   hSurface := cairo_pdf_surface_create( "hellow.pdf", 566.9, 793.7 )
   hCairo := cairo_create( hSurface )

   cairo_select_font_face( hCairo, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD )
   cairo_set_font_size( hCairo, 16 )
   cairo_set_source_rgb( hCairo, 0, 0, 0 )

   cairo_move_to( hCairo, 50, 50 )
   cairo_show_text( hCairo, "Hello, World!" )

   cairo_set_line_width( hCairo, 1 )
   FOR nI := 1 TO 10
      cairo_set_source_rgb( hCairo, hb_Random(), hb_Random(), hb_Random() )
      cairo_rectangle( hCairo, 100 + nI
   cairo_select_font_face( hCairo, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL )
   cairo_set_font_size( hCairo, 10 )
   cairo_set_source_rgb( hCairo, 0, 0, 0 )
   cairo_move_to( hCairo, 50, 300 )
   cairo_show_text( hCairo, hb_UTF8ToStr( "Plaukė žąselė per ežerėlį..." ) )

   cairo_show_page( hCairo )
   cairo_destroy( hCairo )
   cairo_surface_destroy( hSurface )

   RETURN


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

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

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

[Assistant]
#ifdef __XHARBOUR__
   #xtranslate hb_threadStart( <x,...> ) => StartThread( <x> )
   #xtranslate hb_threadJoin( <x,...> ) => JoinThread( <x> )
   #command begin sequence   => try
   #command always           => finally
#endif

proc main()
   local thID, i
   ? Version()
   ? "Main start"
   thID := hb_threadStart( @thFunc(), "A", "B", "C" )
   ? "Thread ID:", thID
   ? "==================="
   ?
   begin sequence
      for i := 1 to 10
         ?? "M"
         hb_idleSleep( 0.050 )
         if i == 5
            ? "Main QUIT"
            quit
         endif
      next
      ? "==================="
   always
      ? "Main ALWAYS section"
      ?
   endsequence
   ? "End of main"
return

proc thFunc( ... )
   local i
   ? "Thread begin"
   ? "Parameters:"
   aeval( hb_aParams(), {| x | qqout( "", x ) } )
   ?
   begin sequence
      for i := 1 to 10
         ?? "t"
         hb_idleSleep( 0.030 )
      next
   always
      ? "Thread ALWAYS section"
      ?
   endsequence
   ? "Thread end"
   ?
return

exit proc p
? "I'm EXIT procedure"


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

[User] Implement this Harbour module: Harbour header file: include/getexit.ch. Defines 10 constants including: _GETEXIT_CH, GE_NOEXIT, GE_UP, GE_DOWN, GE_TOP

[Assistant]
#ifndef _GETEXIT_CH
#define _GETEXIT_CH

#define GE_NOEXIT       0
#define GE_UP           1
#define GE_DOWN         2
#define GE_TOP          3
#define GE_BOTTOM       4
#define GE_ENTER        5
#define GE_WRITE        6
#define GE_ESCAPE       7
#define GE_WHEN         8
#define GE_SHORTCUT     9
#define GE_MOUSEHIT     10

#endif