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

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

Harbour test program: tests/rddtest/rddmktst.prg. Provides functions: test_main. This file handles database operations

[Assistant]
#ifdef _TEST_ADS_
  #undef _TEST_DESCEND_
  #undef _TEST_UNIQUE_
#endif

#define _TEST_CREATE_

#include "rddtst.prg"

#ifndef _TEST_CMPDIDX_
  #command RDDTEST INDEX on <key> tag <tg> to <fi> [ FOR <for> ] [ <desc: DESCENDING> ] => ;
           RDDTEST INDEX on <key> to <tg> [ FOR <for> ] [ <desc> ]
#endif

function test_main()
RDDTEST LOCAL n

RDDTEST RDDSETDEFAULT()

RDDTEST USE _DBNAME SHARED

RDDTEST DBGOTOP()
RDDTEST DBGOBOTTOM()
RDDTEST DBSKIP(0)
RDDTEST DBGOTO(0)
RDDTEST DBSKIP(1)
RDDTEST DBSKIP(-1)
RDDTEST DBSKIP(0)
RDDTEST SET DELETE ON
RDDTEST DBGOTOP()
RDDTEST DBGOBOTTOM()
RDDTEST DBSKIP(0)
RDDTEST DBGOTO(0)
RDDTEST DBSKIP(1)
RDDTEST DBSKIP(-1)
RDDTEST DBSKIP(0)
RDDTEST SET DELETE OFF

RDDTEST INDEX on FNUM tag TG_N to _DBNAME
RDDTEST INDEX on FSTR tag TG_C to _DBNAME

RDDTEST ORDSETFOCUS()

RDDTEST DBGOTOP()
RDDTEST DBGOBOTTOM()
RDDTEST DBSKIP(0)
RDDTEST DBGOTO(0)
RDDTEST DBSKIP(1)
RDDTEST DBSKIP(-1)
RDDTEST DBSKIP(0)
RDDTEST SET DELETE ON
RDDTEST DBGOTOP()
RDDTEST DBGOBOTTOM()
RDDTEST DBSKIP(0)
RDDTEST DBGOTO(0)
RDDTEST DBSKIP(1)
RDDTEST DBSKIP(-1)
RDDTEST DBSKIP(0)

RDDTEST DBGOTO(0)
RDDTEST DBSEEK('', .t.,.f.)
RDDTEST DBSEEK('', .t.,.t.)
RDDTEST DBSEEK('', .f.,.f.)
RDDTEST DBSEEK('', .f.,.t.)

RDDTEST SET DELETE OFF

RDDTEST ;
  for n := 1 to N_LOOP                     ;;
    dbappend()                             ;;
    replace FNUM with int( ( n + 2 ) / 3 ) ;;
    replace FSTR with chr( FNUM +48 )      ;;
  next

RDDTEST dbcommit()
RDDTEST dbunlock()

RDDTEST ORDSETFOCUS(1)
RDDTEST ORDSETFOCUS()
RDDTEST DBSEEK(0,.t.,.f.)
RDDTEST DBSEEK(0,.t.,.t.)
RDDTEST DBSEEK(0.5,.t.,.f.)
RDDTEST DBSEEK(0.5,.t.,.t.)
RDDTEST DBSEEK(1.0,.t.,.f.)
RDDTEST DBSEEK(1.0,.t.,.t.)
RDDTEST DBSEEK(2.0,.t.,.f.)
RDDTEST DBSEEK(2.0,.t.,.t.)
RDDTEST DBSEEK(2.5,.t.,.f.)
RDDTEST DBSEEK(2.5,.t.,.t.)
RDDTEST DBSEEK(5.0,.t.,.f.)
RDDTEST DBSEEK(5.0,.t.,.t.)
RDDTEST ORDSETFOCUS(2)
RDDTEST ORDSETFOCUS()

RDDTEST DBSEEK('', .t.,.f.)
RDDTEST DBSEEK('', .t.,.t.)
RDDTEST DBSEEK(' ',.t.,.f.)
RDDTEST DBSEEK(' ',.t.,.t.)
RDDTEST DBSEEK('0',.t.,.f.)
RDDTEST DBSEEK('0',.t.,.t.)
RDDTEST DBSEEK('1',.t.,.f.)
RDDTEST DBSEEK('1',.t.,.t.)
RDDTEST DBSEEK('2',.t.,.f.)
RDDTEST DBSEEK('2',.t.,.t.)
RDDTEST DBSEEK('3',.t.,.f.)
RDDTEST DBSEEK('3',.t.,.t.)
RDDTEST DBSEEK('4',.t.,.f.)
RDDTEST DBSEEK('4',.t.,.t.)
RDDTEST DBSEEK('5',.t.,.f.)
RDDTEST DBSEEK('5',.t.,.t.)
RDDTEST DBSEEK('6',.t.,.f.)
RDDTEST DBSEEK('6',.t.,.t.)

#ifdef _TEST_SCOPE_
RDDTEST ORDSCOPE(TOPSCOPE,'3')
RDDTEST ORDSCOPE(BOTTOMSCOPE,'4')
RDDTEST DBORDERINFO(DBOI_SCOPETOP)
RDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)
RDDTEST DBSEEK('', .t.,.f.)
RDDTEST DBSEEK('', .t.,.t.)
RDDTEST DBSEEK(' ',.t.,.f.)
RDDTEST DBSEEK(' ',.t.,.t.)
RDDTEST DBSEEK('0',.t.,.f.)
RDDTEST DBSEEK('0',.t.,.t.)
RDDTEST DBSEEK('1',.t.,.f.)
RDDTEST DBSEEK('1',.t.,.t.)
RDDTEST DBSEEK('2',.t.,.f.)
RDDTEST DBSEEK('2',.t.,.t.)
RDDTEST DBSEEK('3',.t.,.f.)
RDDTEST DBSEEK('3',.t.,.t.)
RDDTEST DBSEEK('4',.t.,.f.)
RDDTEST DBSEEK('4',.t.,.t.)
RDDTEST DBSEEK('5',.t.,.f.)
RDDTEST DBSEEK('5',.t.,.t.)
RDDTEST DBSEEK('6',.t.,.f.)
RDDTEST DBSEEK('6',.t.,.t.)

RDDTEST ORDSCOPE(TOPSCOPE,'3')
RDDTEST ORDSCOPE(BOTTOMSCOPE,'2')
RDDTEST DBORDERINFO(DBOI_SCOPETOP)
RDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)
RDDTEST DBSEEK('',.t.,.f.)
RDDTEST DBSEEK('',.t.,.t.)
RDDTEST DBSEEK('1',.t.,.f.)
RDDTEST DBSEEK('1',.t.,.t.)
RDDTEST DBSEEK('2',.t.,.f.)
RDDTEST DBSEEK('2',.t.,.t.)
RDDTEST DBSEEK('3',.t.,.f.)
RDDTEST DBSEEK('3',.t.,.t.)
RDDTEST DBSEEK('4',.t.,.f.)
RDDTEST DBSEEK('4',.t.,.t.)
#endif

#ifdef _TEST_DESCEND_
RDDTEST ORDDESCEND()
RDDTEST ORDDESCEND(,,.t.)
RDDTEST ORDDESCEND()
#endif
#ifdef _TEST_SCOPE_
RDDTEST DBORDERINFO(DBOI_SCOPETOP)
RDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)
RDDTEST ORDSCOPE(TOPSCOPE,NIL)
RDDTEST ORDSCOPE(BOTTOMSCOPE,NIL)
RDDTEST DBORDERINFO(DBOI_SCOPETOP)
RDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)
#endif
RDDTEST DBSEEK('', .t.,.f.)
RDDTEST DBSEEK('', .t.,.t.)
RDDTEST DBSEEK(' ',.t.,.f.)
RDDTEST DBSEEK(' ',.t.,.t.)
RDDTEST DBSEEK('0',.t.,.f.)
RDDTEST DBSEEK('0',.t.,.t.)
RDDTEST DBSEEK('1',.t.,.f.)
RDDTEST DBSEEK('1',.t.,.t.)
RDDTEST DBSEEK('2',.t.,.f.)
RDDTEST DBSEEK('2',.t.,.t.)
RDDTEST DBSEEK('3',.t.,.f.)
RDDTEST DBSEEK('3',.t.,.t.)
RDDTEST DBSEEK('4',.t.,.f.)
RDDTEST DBSEEK('4',.t.,.t.)
RDDTEST DBSEEK('5',.t.,.f.)
RDDTEST DBSEEK('5',.t.,.t.)
RDDTEST DBSEEK('6',.t.,.f.)
RDDTEST DBSEEK('6',.t.,.t.)
#ifdef _TEST_SCOPE_
RDDTEST ORDSCOPE(TOPSCOPE,'4')
RDDTEST ORDSCOPE(BOTTOMSCOPE,'3')
RDDTEST DBORDERINFO(DBOI_SCOPETOP)
RDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)
RDDTEST DBSEEK('', .t.,.f.)
RDDTEST DBSEEK('', .t.,.t.)
RDDTEST DBSEEK(' ',.t.,.f.)
RDDTEST DBSEEK(' ',.t.,.t.)
RDDTEST DBSEEK('0',.t.,.f.)
RDDTEST DBSEEK('0',.t.,.t.)
RDDTEST DBSEEK('1',.t.,.f.)
RDDTEST DBSEEK('1',.t.,.t.)
RDDTEST DBSEEK('2',.t.,.f.)
RDDTEST DBSEEK('2',.t.,.t.)
RDDTEST DBSEEK('3',.t.,.f.)
RDDTEST DBSEEK('3',.t.,.t.)
RDDTEST DBSEEK('4',.t.,.f.)
RDDTEST DBSEEK('4',.t.,.t.)
RDDTEST DBSEEK('5',.t.,.f.)
RDDTEST DBSEEK('5',.t.,.t.)
RDDTEST DBSEEK('6',.t.,.f.)
RDDTEST DBSEEK('6',.t.,.t.)

RDDTEST ORDSCOPE(TOPSCOPE,'3')
RDDTEST ORDSCOPE(BOTTOMSCOPE,'4')
RDDTEST DBORDERINFO(DBOI_SCOPETOP)
RDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)
RDDTEST DBSEEK('', .t.,.f.)
RDDTEST DBSEEK('', .t.,.t.)
RDDTEST DBSEEK(' ',.t.,.f.)
RDDTEST DBSEEK(' ',.t.,.t.)
RDDTEST DBSEEK('0',.t.,.f.)
RDDTEST DBSEEK('0',.t.,.t.)
RDDTEST DBSEEK('1',.t.,.f.)
RDDTEST DBSEEK('1',.t.,.t.)
RDDTEST DBSEEK('2',.t.,.f.)
RDDTEST DBSEEK('2',.t.,.t.)
RDDTEST DBSEEK('3',.t.,.f.)
RDDTEST DBSEEK('3',.t.,.t.)
RDDTEST DBSEEK('4',.t.,.f.)
RDDTEST DBSEEK('4',.t.,.t.)
RDDTEST DBSEEK('5',.t.,.f.)
RDDTEST DBSEEK('5',.t.,.t.)
RDDTEST DBSEEK('6',.t.,.f.)
RDDTEST DBSEEK('6',.t.,.t.)
#endif

RDDTEST INDEX on FSTR tag TG_C to _DBNAME DESCEND
RDDTEST DBSEEK('',.t.,.f.)
RDDTEST DBSEEK('',.t.,.t.)
RDDTEST DBSEEK(' ',.t.,.f.)
RDDTEST DBSEEK(' ',.t.,.t.)
RDDTEST DBSEEK('0',.t.,.f.)
RDDTEST DBSEEK('0',.t.,.t.)
RDDTEST DBSEEK('1',.t.,.f.)
RDDTEST DBSEEK('1',.t.,.t.)
RDDTEST DBSEEK('2',.t.,.f.)
RDDTEST DBSEEK('2',.t.,.t.)
RDDTEST DBSEEK('3',.t.,.f.)
RDDTEST DBSEEK('3',.t.,.t.)
RDDTEST DBSEEK('4',.t.,.f.)
RDDTEST DBSEEK('4',.t.,.t.)
RDDTEST DBSEEK('5',.t.,.f.)
RDDTEST DBSEEK('5',.t.,.t.)
RDDTEST DBSEEK('6',.t.,.f.)
RDDTEST DBSEEK('6',.t.,.t.)

#ifdef _TEST_SCOPE_
RDDTEST ORDSCOPE(TOPSCOPE,'4')
RDDTEST ORDSCOPE(BOTTOMSCOPE,'3')
RDDTEST DBORDERINFO(DBOI_SCOPETOP)
RDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)
RDDTEST DBSEEK('', .t.,.f.)
RDDTEST DBSEEK('', .t.,.t.)
RDDTEST DBSEEK(' ',.t.,.f.)
RDDTEST DBSEEK(' ',.t.,.t.)
RDDTEST DBSEEK('0',.t.,.f.)
RDDTEST DBSEEK('0',.t.,.t.)
RDDTEST DBSEEK('1',.t.,.f.)
RDDTEST DBSEEK('1',.t.,.t.)
RDDTEST DBSEEK('2',.t.,.f.)
RDDTEST DBSEEK('2',.t.,.t.)
RDDTEST DBSEEK('3',.t.,.f.)
RDDTEST DBSEEK('3',.t.,.t.)
RDDTEST DBSEEK('4',.t.,.f.)
RDDTEST DBSEEK('4',.t.,.t.)
RDDTEST DBSEEK('5',.t.,.f.)
RDDTEST DBSEEK('5',.t.,.t.)
RDDTEST DBSEEK('6',.t.,.f.)
RDDTEST DBSEEK('6',.t.,.t.)
#endif

RDDTEST INDEX on FSTR tag TG_C to _DBNAME
RDDTEST DBGOTOP()
RDDTEST DBSKIP(0)
RDDTEST DBSKIP(-1)
RDDTEST DBSKIP(0)
RDDTEST DBGOBOTTOM()
RDDTEST DBSKIP(0)
RDDTEST DBSKIP(1)
RDDTEST DBSKIP(0)

RDDTEST DBGOTO(1)
RDDTEST DBSKIP(-1)
RDDTEST DBSKIP(1)
RDDTEST DBSKIP(5)
RDDTEST DBSKIP(5)
RDDTEST DBSKIP(5)
RDDTEST DBSKIP(-1)
RDDTEST DBSKIP(-5)
RDDTEST DBSKIP(10)
RDDTEST DBSKIP(-5)
RDDTEST DBGOTO(16)
RDDTEST DBSKIP(-1)

#ifdef _TEST_SCOPE_
RDDTEST ORDSCOPE(TOPSCOPE,'3')
RDDTEST ORDSCOPE(BOTTOMSCOPE,'4')
RDDTEST DBORDERINFO(DBOI_SCOPETOP)
RDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)
#endif
RDDTEST DBGOTO(1)
RDDTEST DBSKIP(1)
RDDTEST DBGOTO(1)
RDDTEST DBSKIP(-1)

RDDTEST DBGOTO(4)
RDDTEST DBSKIP(1)
RDDTEST DBGOTO(4)
RDDTEST DBSKIP(-1)

RDDTEST DBGOTO(6)
RDDTEST DBSKIP(1)
RDDTEST DBGOTO(6)
RDDTEST DBSKIP(-1)

RDDTEST DBGOTO(7)
RDDTEST DBSKIP(1)
RDDTEST DBGOTO(7)
RDDTEST DBSKIP(-1)

RDDTEST DBGOTO(12)
RDDTEST DBSKIP(1)
RDDTEST DBGOTO(12)
RDDTEST DBSKIP(-1)

RDDTEST DBGOTO(13)
RDDTEST DBSKIP(1)
RDDTEST DBGOTO(13)
RDDTEST DBSKIP(-1)

RDDTEST DBGOTO(14)
RDDTEST DBSKIP(-1)
RDDTEST DBGOTO(16)
RDDTEST DBSKIP(-1)


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

[User] Write a Harbour program with procedures: Main. Harbour test program: tests/multiarg.prg. Provides functions: ShoutArg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
PROCEDURE Main()

   ShoutArg( 1, "1", 2.5, .T. )
   ShoutArg( 2, "1", 2.5, .T. )
   ShoutArg( 3, "1", 2.5, .T. )
   ShoutArg( 4, "1", 2.5, .T. )
   ShoutArg( 5, "1", 2.5, .T. )

   RETURN

FUNCTION ShoutArg( nArg, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 )

   HB_SYMBOL_UNUSED( x1 )
   HB_SYMBOL_UNUSED( x2 )
   HB_SYMBOL_UNUSED( x3 )
   HB_SYMBOL_UNUSED( x4 )
   HB_SYMBOL_UNUSED( x5 )
   HB_SYMBOL_UNUSED( x6 )
   HB_SYMBOL_UNUSED( x7 )
   HB_SYMBOL_UNUSED( x8 )
   HB_SYMBOL_UNUSED( x9 )
   HB_SYMBOL_UNUSED( x10 )

   ? nArg, "==", hb_PValue( nArg )

   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] Define Harbour macros and constants: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/restsets.prg. Provides functions: ft_RestSets. This file provides legacy compatibility functions

[Assistant]
#define FT_EXTRA_SETS    2
#define FT_SET_CENTURY   _SET_COUNT + 1
#define FT_SET_BLINK     _SET_COUNT + 2

FUNCTION ft_RestSets( aOldSets )

   AEval( aOldSets, ;
      {| xElement, nElementNo | ;
      Set( nElementNo, xElement ) }, ;
      1, _SET_COUNT )

   ft_SetCentury( aOldSets[ FT_SET_CENTURY ] )
   SetBlink( aOldSets[ FT_SET_BLINK ] )

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

Harbour Runtime Library file: src/rtl/getsys.prg. Provides 14 functions including: ReadModal, ReadModal, GetActive, GetPreValidate, GetPreValidate. Contains 7 procedures. This file implements the GET system for input field handling

[Assistant]
#ifdef HB_COMPAT_C53

#include "inkey.ch"

#define SLUPDATED       1
#define SOACTIVEGET     8
#define SXREADVAR       9

FUNCTION ReadModal( GetList, nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )
#else
FUNCTION ReadModal( GetList )
#endif

   LOCAL oGetList
   LOCAL oSaveGetList

   IF Empty( GetList )
      SetPos( MaxRow() - 1, 0 )
      RETURN .F.
   ENDIF

   oGetList := HBGetList():New( GetList )

   oSaveGetList := __GetListActive()
#ifdef HB_COMPAT_C53

#endif

   __GetListSetActive( oGetList )
   __GetListLast( oGetList )

#ifdef HB_COMPAT_C53
   oGetList:ReadModal( nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )
#else
   oGetList:ReadModal()
#endif

   __GetListSetActive( oSaveGetList )
#ifdef HB_COMPAT_C53

#endif

   SetPos( MaxRow() - 1, 0 )

   RETURN oGetList:Updated()

#ifdef HB_COMPAT_C53
PROCEDURE GetReader( oGet, oGetList, oMenu, aMsg )

   HB_SYMBOL_UNUSED( oGetList )

   oGet:Reader( oMenu, aMsg )

   RETURN
#else
PROCEDURE GetReader( oGet )

   oGet:Reader()

   RETURN
#endif

FUNCTION GetActive( oGet )

   LOCAL oGetList := __GetListActive()

   LOCAL oGetActiveOld

   THREAD STATIC t_oGetActive

   IF oGetList == NIL

      IF PCount() > 0
         oGetActiveOld := t_oGetActive
         t_oGetActive := oGet
         RETURN oGetActiveOld
      ELSE
         RETURN t_oGetActive
      ENDIF
   ELSE
      IF PCount() > 0
         RETURN oGetList:GetActive( oGet )
      ELSE
         RETURN oGetList:GetActive()
      ENDIF
   ENDIF

   RETURN NIL

PROCEDURE GetDoSetKey( bKeyBlock, oGet )

   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      oGetList:GetDoSetKey( bKeyBlock, oGet )
   ENDIF

   RETURN

#ifdef HB_COMPAT_C53
PROCEDURE GetApplyKey( oGet, nKey, oGetList, oMenu, aMsg )

   IF ! HB_ISOBJECT( oGetList )
      oGetList := __GetListActive()
   ENDIF
#else
PROCEDURE GetApplyKey( oGet, nKey )

   LOCAL oGetList := __GetListActive()
#endif

   IF oGetList != NIL
#ifdef HB_COMPAT_C53
      oGetList:GetApplyKey( nKey, oGet, oMenu, aMsg )
#else
      oGetList:GetApplyKey( nKey, oGet )
#endif
   ENDIF

   RETURN

#ifdef HB_COMPAT_C53
FUNCTION GetPreValidate( oGet, aMsg )
#else
FUNCTION GetPreValidate( oGet )
#endif
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
#ifdef HB_COMPAT_C53
      RETURN oGetList:GetPreValidate( oGet, aMsg )
#else
      RETURN oGetList:GetPreValidate( oGet )
#endif
   ENDIF

   RETURN .F.

#ifdef HB_COMPAT_C53
FUNCTION GetPostValidate( oGet, aMsg )
#else
FUNCTION GetPostValidate( oGet )
#endif

   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
#ifdef HB_COMPAT_C53
      RETURN oGetList:GetPostValidate( oGet, aMsg )
#else
      RETURN oGetList:GetPostValidate( oGet )
#endif
   ENDIF

   RETURN .F.

FUNCTION ReadExit( lExit )
   RETURN Set( _SET_EXIT, lExit )

FUNCTION ReadInsert( lInsert )
   RETURN Set( _SET_INSERT, lInsert )

FUNCTION Updated()

   LOCAL oGetList := __GetListLast()

   RETURN iif( oGetList != NIL, oGetList:Updated(), .F. )

PROCEDURE __KillRead()

   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      oGetList:KillRead( .T. )
   ENDIF

   RETURN

FUNCTION ReadUpdated( lUpdated )

   LOCAL oGetList := __GetListLast()

   IF oGetList != NIL
      IF PCount() > 0
         RETURN oGetList:ReadUpdated( lUpdated )
      ELSE
         RETURN oGetList:ReadUpdated()
      ENDIF
   ENDIF

   RETURN .F.

FUNCTION ReadKill( lKill )

   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      IF PCount() > 0
         RETURN oGetList:KillRead( lKill )
      ELSE
         RETURN oGetList:KillRead()
      ENDIF
   ENDIF

   RETURN .F.

FUNCTION ReadFormat( bFormat )

   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      IF PCount() > 0
         RETURN oGetList:SetFormat( bFormat )
      ELSE
         RETURN oGetList:SetFormat()
      ENDIF
   ENDIF

   RETURN NIL

PROCEDURE __SetFormat( bFormat )

   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      IF HB_ISEVALITEM( bFormat )
         oGetList:SetFormat( bFormat )
      ELSE
         oGetList:SetFormat()
      ENDIF
   ENDIF

   RETURN

#define SCORE_ROW       0
#define SCORE_COL       60

#define _GET_RANGE_FROM 10
#define _GET_RANGE_TO   11

FUNCTION RangeCheck( oGet, xDummy, xLow, xHigh )

   LOCAL xValue
   LOCAL cMessage
   LOCAL nKey

   HB_SYMBOL_UNUSED( xDummy )

   IF ! oGet:changed
      RETURN .T.
   ENDIF

   xValue := oGet:varGet()

   IF xValue >= xLow .AND. xValue <= xHigh
      RETURN .T.
   ENDIF

   IF Set( _SET_SCOREBOARD )

      cMessage := Left( __natMsg( _GET_RANGE_FROM ) + LTrim( Transform( xLow, "" ) ) + ;
         __natMsg( _GET_RANGE_TO ) + LTrim( Transform( xHigh, "" ) ), MaxCol() )

      hb_DispOutAt( SCORE_ROW, Min( 60, MaxCol() - Len( cMessage ) ), cMessage )

      DO WHILE ( nKey := Inkey( 0 ) ) == 0
      ENDDO
      hb_keyIns( nKey )

      hb_DispOutAt( SCORE_ROW, Min( 60, MaxCol() - Len( cMessage ) ), Space( Len( cMessage ) ) )

   ENDIF

   RETURN .F.


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

[Assistant]
#require "hbnf"

#define SCANCODE_ESCAPE   ( hb_BChar( 27 ) + hb_BChar( 1 ) )

PROCEDURE Main()

   LOCAL cKey

   CLS
   ? "Press any key, ESCape to exit:"

   DO WHILE .T.
      cKey := ft_ScanCode()
      ? Str( hb_BCode( hb_BSubStr( cKey, 1, 1 ) ), 3 ) + ", " + Str( hb_BCode( hb_BSubStr( cKey, 2, 1 ) ), 3 )
      IF cKey == SCANCODE_ESCAPE
         EXIT
      ENDIF
   ENDDO

   RETURN


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

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

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

[Assistant]
#define EOL chr(10)
#xtranslate QQOUT([<x,...>]) => [OUTSTD(<x>)]
#xtranslate QOUT([<x,...>]) => OUTSTD(EOL)[;OUTSTD(<x>)]

#include "hbclass.ch"

proc main()
local o:=myclass4():new(), i, cbErr

? DATE(), TIME(), VERSION(), OS()
?

? "myclass1 class vars:", str( __CLS_CNTCLSDATA(o:myclass1:classH), 3), "  => should be:   3"
? "myclass2 class vars:", str( __CLS_CNTCLSDATA(o:myclass2:classH), 3), "  => should be:   6"
? "myclass3 class vars:", str( __CLS_CNTCLSDATA(o:myclass3:classH), 3), "  => should be:   9"
cbErr := errorBlock( {| oErr | break( oErr ) } )
begin sequence
   ? "myclass4 class vars:", str( __CLS_CNTCLSDATA(o:myclass4:classH), 3), "  => should be:  12"
recover
   ? "ERROR: no selfclass casting"
end
errorBlock(cbErr)
? "myclass4 class vars:", str( __CLS_CNTCLSDATA(o:classH), 3), "  => should be:  12"
?

? "instance variables ["+ltrim(str(len(o)))+"]:"; ?
for i:=1 to len(o); ?? "",o[i]; next
? " => shoule be [0]:"
?
? "initialization..."
o:x1:=" X1 "; o:y1:=" Y1 "; o:z1:=" Z1 "
o:x2:=" X2 "; o:y2:=" Y2 "; o:z2:=" Z2 "
o:x3:=" X3 "; o:y3:=" Y3 "; o:z3:=" Z3 "
o:x4:=" X4 "; o:y4:=" Y4 "; o:z4:=" Z4 "

? "[1] MYCLASS1 VARS:", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, "  => should be: (x1) (y1) (z1)"
? "[2] MYCLASS1 VARS:", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, "  => should be: (x1) (y1) (z1)"
? "[2] MYCLASS2 VARS:", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, "  => should be: (x2) (y2) (z2)"
? "[3] MYCLASS1 VARS:", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, "  => should be: (x1) (y1) (z1)"
? "[3] MYCLASS2 VARS:", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, "  => should be: (x2) (y2) (z2)"
? "[3] MYCLASS3 VARS:", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, "  => should be: (x3) (y3) (z3)"
cbErr := errorBlock( {| oErr | break( oErr ) } )
begin sequence
   ? "[4] MYCLASS1 VARS:", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, "  => should be:  X1   Y1   Z1"
   ? "[4] MYCLASS2 VARS:", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, "  => should be:  X2   Y2   Z2"
   ? "[4] MYCLASS3 VARS:", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, "  => should be:  X3   Y3   Z3"
   ? "[4] MYCLASS4 VARS:", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, "  => should be:  X4   Y4   Z4"
recover
   ? "ERROR: no selfclass casting"
end
errorBlock(cbErr)
? "    MYCLASS1 VARS:", o:x1, o:y1, o:z1, "  => should be:  X1   Y1   Z1"
? "    MYCLASS2 VARS:", o:x2, o:y2, o:z2, "  => should be:  X2   Y2   Z2"
? "    MYCLASS3 VARS:", o:x3, o:y3, o:z3, "  => should be:  X3   Y3   Z3"
? "    MYCLASS4 VARS:", o:x4, o:y4, o:z4, "  => should be:  X4   Y4   Z4"
?

? "instance variables ["+ltrim(str(len(o)))+"]:"; ?
for i:=1 to len(o); ?? "",o[i]; next
? " => shoule be [0]:"
?

? "Setting MYCLASS1 class variables..."
o:myclass1:x1:="[X1]"
o:myclass1:y1:="[Y1]"
o:myclass1:z1:="[Z1]"
? "[1] MYCLASS1 VARS:", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, "  => should be: [X1] [Y1] [Z1]"
? "[2] MYCLASS1 VARS:", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, "  => should be: (x1) (y1) (z1)"
? "[2] MYCLASS2 VARS:", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, "  => should be: (x2) (y2) (z2)"
? "[3] MYCLASS1 VARS:", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, "  => should be: (x1) (y1) (z1)"
? "[3] MYCLASS2 VARS:", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, "  => should be: (x2) (y2) (z2)"
? "[3] MYCLASS3 VARS:", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, "  => should be: (x3) (y3) (z3)"
cbErr := errorBlock( {| oErr | break( oErr ) } )
begin sequence
   ? "[4] MYCLASS1 VARS:", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, "  => should be:  X1   Y1   Z1"
   ? "[4] MYCLASS2 VARS:", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, "  => should be:  X2   Y2   Z2"
   ? "[4] MYCLASS3 VARS:", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, "  => should be:  X3   Y3   Z3"
   ? "[4] MYCLASS4 VARS:", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, "  => should be:  X4   Y4   Z4"
recover
   ? "ERROR: no selfclass casting"
end
errorBlock(cbErr)
? "    MYCLASS1 VARS:", o:x1, o:y1, o:z1, "  => should be:  X1   Y1   Z1"
? "    MYCLASS2 VARS:", o:x2, o:y2, o:z2, "  => should be:  X2   Y2   Z2"
? "    MYCLASS3 VARS:", o:x3, o:y3, o:z3, "  => should be:  X3   Y3   Z3"
? "    MYCLASS4 VARS:", o:x4, o:y4, o:z4, "  => should be:  X4   Y4   Z4"
?

? "Setting MYCLASS2 class variables..."
o:myclass2:x1:="{X1}"
o:myclass2:y1:="{Y1}"
o:myclass2:z1:="{Z1}"
o:myclass2:x2:="{X2}"
o:myclass2:y2:="{Y2}"
o:myclass2:z2:="{Z2}"
? "[1] MYCLASS1 VARS:", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, "  => should be: [X1] [Y1] [Z1]"
? "[2] MYCLASS1 VARS:", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, "  => should be: {X1} {Y1} {Z1}"
? "[2] MYCLASS2 VARS:", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, "  => should be: {X2} {Y2} {Z2}"
? "[3] MYCLASS1 VARS:", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, "  => should be: (x1) (y1) (z1)"
? "[3] MYCLASS2 VARS:", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, "  => should be: (x2) (y2) (z2)"
? "[3] MYCLASS3 VARS:", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, "  => should be: (x3) (y3) (z3)"
cbErr := errorBlock( {| oErr | break( oErr ) } )
begin sequence
   ? "[4] MYCLASS1 VARS:", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, "  => should be:  X1   Y1   Z1"
   ? "[4] MYCLASS2 VARS:", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, "  => should be:  X2   Y2   Z2"
   ? "[4] MYCLASS3 VARS:", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, "  => should be:  X3   Y3   Z3"
   ? "[4] MYCLASS4 VARS:", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, "  => should be:  X4   Y4   Z4"
recover
   ? "ERROR: no selfclass casting"
end
errorBlock(cbErr)
? "    MYCLASS1 VARS:", o:x1, o:y1, o:z1, "  => should be:  X1   Y1   Z1"
? "    MYCLASS2 VARS:", o:x2, o:y2, o:z2, "  => should be:  X2   Y2   Z2"
? "    MYCLASS3 VARS:", o:x3, o:y3, o:z3, "  => should be:  X3   Y3   Z3"
? "    MYCLASS4 VARS:", o:x4, o:y4, o:z4, "  => should be:  X4   Y4   Z4"
?

? "Setting MYCLASS3 class variables..."
o:myclass3:x1:="<X1>"
o:myclass3:y1:="<Y1>"
o:myclass3:z1:="<Z1>"
o:myclass3:x2:="<X2>"
o:myclass3:y2:="<Y2>"
o:myclass3:z2:="<Z2>"
o:myclass3:x3:="<X3>"
o:myclass3:y3:="<Y3>"
o:myclass3:z3:="<Z3>"
? "[1] MYCLASS1 VARS:", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, "  => should be: [X1] [Y1] [Z1]"
? "[2] MYCLASS1 VARS:", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, "  => should be: {X1} {Y1} {Z1}"
? "[2] MYCLASS2 VARS:", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, "  => should be: {X2} {Y2} {Z2}"
? "[3] MYCLASS1 VARS:", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, "  => should be: <X1> <Y1> <Z1>"
? "[3] MYCLASS2 VARS:", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, "  => should be: <X2> <Y2> <Z2>"
? "[3] MYCLASS3 VARS:", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, "  => should be: <X3> <Y3> <Z3>"
cbErr := errorBlock( {| oErr | break( oErr ) } )
begin sequence
   ? "[4] MYCLASS1 VARS:", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, "  => should be:  X1   Y1   Z1"
   ? "[4] MYCLASS2 VARS:", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, "  => should be:  X2   Y2   Z2"
   ? "[4] MYCLASS3 VARS:", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, "  => should be:  X3   Y3   Z3"
   ? "[4] MYCLASS4 VARS:", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, "  => should be:  X4   Y4   Z4"
recover
   ? "ERROR: no selfclass casting"
end
errorBlock(cbErr)
? "    MYCLASS1 VARS:", o:x1, o:y1, o:z1, "  => should be:  X1   Y1   Z1"
? "    MYCLASS2 VARS:", o:x2, o:y2, o:z2, "  => should be:  X2   Y2   Z2"
? "    MYCLASS3 VARS:", o:x3, o:y3, o:z3, "  => should be:  X3   Y3   Z3"
? "    MYCLASS4 VARS:", o:x4, o:y4, o:z4, "  => should be:  X4   Y4   Z4"
?

? "Setting MYCLASS4 class variables..."
cbErr := errorBlock( {| oErr | break( oErr ) } )
begin sequence
   o:myclass4:x1:="|X1|"
   o:myclass4:y1:="|Y1|"
   o:myclass4:z1:="|Z1|"
   o:myclass4:x2:="|X2|"
   o:myclass4:y2:="|Y2|"
   o:myclass4:z2:="|Z2|"
   o:myclass4:x3:="|X3|"
   o:myclass4:y3:="|Y3|"
   o:myclass4:z3:="|Z3|"
   o:myclass4:x4:="|X4|"
   o:myclass4:y4:="|Y4|"
   o:myclass4:z4:="|Z4|"
recover


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

[User] Create Harbour preprocessor definitions: Harbour header file: include/hbgfx.ch. Defines constants: _HBGFX_CH_. Declares 5 preprocessor translations. Defines color and display constants

[Assistant]
#ifndef _HBGFX_CH_
#define _HBGFX_CH_

#include "hbgfxdef.ch"

#xtranslate hb_gfxAcquireScreen() => hb_gfxPrimitive( HB_GFX_ACQUIRESCREEN )
#xtranslate hb_gfxReleaseScreen() => hb_gfxPrimitive( HB_GFX_RELEASESCREEN )
#xtranslate hb_gfxMakeColor( <nRed>, <nGreen>, <nBlue>[, <nAlpha>] ) => hb_gfxPrimitive( HB_GFX_MAKECOLOR, <nRed>, <nGreen>, <nBlue>[, <nAlpha>] )
#xtranslate hb_gfxGetClip( <nTop>, <nLeft>, <nBottom>, <nRight> ) => <nTop> := hb_gfxPrimitive( HB_GFX_CLIPTOP ); <nLeft> := hb_gfxPrimitive( HB_GFX_CLIPLEFT ); <nBottom> := hb_gfxPrimitive( HB_GFX_CLIPBOTTOM ); <nRight> := hb_gfxPrimitive( HB_GFX_CLIPRIGHT )
#xtranslate hb_gfxSetClip( <nTop>, <nLeft>, <nBottom>, <nRight> ) => hb_gfxPrimitive( HB_GFX_SETCLIP, <nTop>, <nLeft>, <nBottom>, <nRight> )
#xtranslate hb_gfxDrawingMode( [<nMode>] ) => hb_gfxPrimitive( HB_GFX_DRAWINGMODE[, <nMode>] )
#xtranslate hb_gfxGetPixel( <nY>, <nX> ) => hb_gfxPrimitive( HB_GFX_GETPIXEL, <nY>, <nX> )
#xtranslate hb_gfxPutPixel( <nY>, <nX>, <nColor> ) => hb_gfxPrimitive( HB_GFX_PUTPIXEL, <nY>, <nX>, <nColor> )
#xtranslate hb_gfxLine( <nTop>, <nLeft>, <nBottom>, <nRight>, <nColor> ) => hb_gfxPrimitive( HB_GFX_LINE, <nTop>, <nLeft>, <nBottom>, <nRight>, <nColor> )
#xtranslate hb_gfxRect( <nTop>, <nLeft>, <nBottom>, <nRight>, <nColor> ) => hb_gfxPrimitive( HB_GFX_RECT, <nTop>, <nLeft>, <nBottom>, <nRight>, <nColor> )
#xtranslate hb_gfxFilledRect( <nTop>, <nLeft>, <nBottom>, <nRight>, <nColor> ) => hb_gfxPrimitive( HB_GFX_FILLEDRECT, <nTop>, <nLeft>, <nBottom>, <nRight>, <nColor> )
#xtranslate hb_gfxCircle( <nY>, <nX>, <nRadius>, <nColor> ) => hb_gfxPrimitive( HB_GFX_CIRCLE, <nY>, <nX>, <nRadius>, <nColor> )
#xtranslate hb_gfxFilledCircle( <nY>, <nX>, <nRadius>, <nColor> ) => hb_gfxPrimitive( HB_GFX_FILLEDCIRCLE, <nY>, <nX>, <nRadius>, <nColor> )
#xtranslate hb_gfxEllipse( <nY>, <nX>, <nRadY>, <nRadX>, <nColor> ) => hb_gfxPrimitive( HB_GFX_ELLIPSE, <nY>, <nX>, <nRadY>, <nRadX>, <nColor> )
#xtranslate hb_gfxFilledEllipse( <nY>, <nX>, <nRadY>, <nRadX>, <nColor> ) => hb_gfxPrimitive( HB_GFX_FILLEDELLIPSE, <nY>, <nX>, <nRadY>, <nRadX>, <nColor> )
#xtranslate hb_gfxFloodFill( <nY>, <nX>, <nColor> ) => hb_gfxPrimitive( HB_GFX_FLOODFILL, <nY>, <nX>, <nColor> )

#endif


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

[User] Implement these Harbour functions: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/datetime.prg. Provides 7 functions including: addmtest, bomtest, boqtest, boytest, ctodowtest. Contains procedures: Main. This file provides legacy compatibility functions

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

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

#include "hbextlng.ch"

PROCEDURE Main( cLang )

   LOCAL cScr
   LOCAL nChoice := 1
   LOCAL c    := .T.
   LOCAL farr := { ;
      "AddMonth( dDate )   Add a month to dDate      ", ;
      "BoM()               Beginning of month        ", ;
      "BoQ()               Returns first date of qtr ", ;
      "BoY()               Beginning of year         ", ;
      "CToDoW()            Day name to day number    ", ;
      "CToMonth()          Month name to number      ", ;
      "DaysInMonth()       number of days in xMonth  ", ;
      "DaysToMonth(dDate)  Returns num days to month ", ;
      "DMY( dDate, lmode)  date as DD month YY       ", ;
      "DoY( dDate )        Returns day of the year   ", ;
      "EoM( dDate )        Returns last day of month ", ;
      "EoQ( dDate )        Returns last date of qtr  ", ;
      "EoY( dDate )        Returns last day of year  ", ;
      "IsLeap( dDate )     Returns .T. if leap year  ", ;
      "LastDayOM( dDate )  Returns num days in month ", ;
      "MDY( dDate )        Returns stg Month DD, YY  ", ;
      "NToCDoW( nDay )     Returns name of day       ", ;
      "NToCMonth( nMth )   Returns name of month     ", ;
      "Quarter(date)       Returns qtr number of date", ;
      "SToD( ansi date)    Returns Clipper date      ", ;
      "Week( dDate, lSWN ) Returns numbef of week    ", }

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

   IF HB_ISSTRING( cLang )
      hb_langSelect( cLang )
   ENDIF

   CLS

   DO WHILE c
      cScr := SaveScreen( 2, 5, 24, 66 )

      @ 2, 5 TO 24, 66
      nChoice := AChoice( 3, 7, 23, 65, farr,,, nChoice )

      IF Empty( nChoice )
         RETURN
      ENDIF

      @ 0, 0 CLEAR TO MaxRow(), MaxCol()

      DO CASE
      CASE nChoice == 1
         addmtest()
      CASE nChoice == 2
         bomtest()
      CASE nChoice == 3
         boqtest()
      CASE nChoice == 4
         boytest()
      CASE nChoice == 5
         ctodowtest()
      CASE nChoice == 6
         ctomonthtest()
      CASE nChoice == 7
         dInMonthtest()
      CASE nChoice == 8
         d2month()
      CASE nChoice == 9
         dmytest()
      CASE nChoice == 10
         doytest()
      CASE nChoice == 11
         eomtest()
      CASE nChoice == 12
         eoqtest()
      CASE nChoice == 13
         eoytest()
      CASE nChoice == 14
         isleaptest()
      CASE nChoice == 15
         lastdayomtest()
      CASE nChoice == 16
         mdytest()
      CASE nChoice == 17
         ntocdowtest()
      CASE nChoice == 18
         ntocmthtest()
      CASE nChoice == 19
         qtrtest()
      CASE nChoice == 20
         stodtest()
      CASE nChoice == 21
         weektest()
      ENDCASE

      RestScreen( 2, 5, 24, 66, cScr )
   ENDDO

   RETURN

FUNCTION addmtest()

   LOCAL getlist := {}
   LOCAL dDate   := hb_SToD()
   LOCAL c       := .T.
   LOCAL mnth    := 0
   LOCAL nKey

   DO WHILE c
      @ 5, 10 SAY "AddMonth(dDate) returns the date incremented by"
      @ 6, 10 SAY "the number of days in months."
      @ 7, 10 SAY "Insert a date"
      @ 8, 10 SAY "How many months"
      @ 7, 60 GET dDate
      @ 8, 60 GET mnth PICTURE "99"

      SET CONFIRM ON
      SET ESCAPE ON
      READ
      SET ESCAPE OFF
      SET CONFIRM ON

      nKey := LastKey()

      IF nKey == K_ESC
         c := .F.
      ELSE

         @ 11, 39 SAY "The returned date is " + DToC( AddMonth( dDate, mnth ) )

         SET CURSOR OFF
         Inkey( 0 )
         SET CURSOR ON

      ENDIF

   ENDDO

   @ 0, 0 CLEAR

   RETURN NIL

FUNCTION bomtest()

   LOCAL getlist := {}
   LOCAL dDate   := hb_SToD()
   LOCAL c       := .T.
   LOCAL nKey

   DO WHILE c
      @ 5, 10 SAY "BoM(dDate) returns the date of the first day of dDate"
      @ 6, 10 SAY "If dDate is 2002-10-15 (that's in yyyy-mm-dd), BoM()"
      @ 7, 10 SAY "should return 2002-10-01. Test it, Insert a date"
      @ 9, 10 GET dDate

      SET CONFIRM ON
      SET ESCAPE ON
      READ
      SET ESCAPE OFF
      SET CONFIRM ON

      nKey := LastKey()

      IF nKey == K_ESC
         c := .F.
      ELSE
         @ 11, 10 SAY "The returned date is " + DToC( BoM( dDate ) )

         SET CURSOR OFF
         Inkey( 0 )
         SET CURSOR ON

      ENDIF

   ENDDO

   @ 0, 0 CLEAR

   RETURN NIL

FUNCTION boqtest()

   LOCAL getlist := {}
   LOCAL dDate   := hb_SToD()
   LOCAL c       := .T.
   LOCAL nKey

   DO WHILE c
      @ 5, 10 SAY "BoQ(dDate) returns the date of the first day of the"
      @ 6, 10 SAY "quarter in which dDate is situated. If dDate is"
      @ 7, 10 SAY "2002-10-15 (that's in yyyy-mm-dd), BoQ() should return"
      @ 8, 10 SAY "2002-09-01. Test it, Insert a date"

      @ 9, 10 GET dDate

      SET CONFIRM ON
      SET ESCAPE ON
      READ
      SET ESCAPE OFF
      SET CONFIRM ON

      nKey := LastKey()

      IF nKey == K_ESC
         c := .F.
      ELSE
         @ 11, 10 SAY "The returned date is " + DToC( BoQ( dDate ) )

         SET CURSOR OFF
         Inkey( 0 )
         SET CURSOR ON

      ENDIF

   ENDDO

   @ 0, 0 CLEAR

   RETURN NIL

FUNCTION boytest()

   LOCAL getlist := {}
   LOCAL dDate   := hb_SToD()
   LOCAL c       := .T.
   LOCAL nkey

   DO WHILE c
      @ 5, 10 SAY "BoY(dDate) returns the date of the first day of dDate"
      @ 6, 10 SAY "If dDate is 2002-10-15 (that's in yyyy-mm-dd), BoY()"
      @ 7, 10 SAY "should return 2002-01-01. Test it, Insert a date"
      @ 9, 10 GET dDate

      SET CONFIRM ON
      SET ESCAPE ON
      READ
      SET ESCAPE OFF
      SET CONFIRM ON

      nKey := LastKey()

      IF nKey == K_ESC
         c := .F.
      ELSE
         @ 11, 10 SAY "The returned date is " + DToC( BoY( dDate ) )

         SET CURSOR OFF
         Inkey( 0 )
         SET CURSOR ON

         dDate   := hb_SToD()

      ENDIF

   ENDDO

   @ 0, 0 CLEAR

   RETURN NIL

FUNCTION ctodowtest()

   LOCAL getlist := {}
   LOCAL cDow    := Space( 9 )
   LOCAL nkey
   LOCAL c       := .T.

   DO WHILE c
      @ 5, 10 SAY "CToDoW(dDate) receives the name of a day of the week and "
      @ 6, 10 SAY "returns a number representing its position in the week"
      @ 7, 10 SAY "Sunday returns 1. Test it, Insert a day"
      @ 9, 10 GET cDow

      SET CONFIRM ON
      SET ESCAPE ON
      READ
      SET ESCAPE OFF
      SET CONFIRM ON

      nKey := LastKey()

      IF nKey == K_ESC
         c := .F.
      ELSE
         @ 11, 10 SAY "The day number is " + Str( CToDoW( Upper( AllTrim( cDow ) ) ) )

         SET CURSOR OFF
         Inkey( 0 )
         SET CURSOR ON

         cDow := Space( 9 )

      ENDIF

   ENDDO

   @ 0, 0 CLEAR

   RETURN NIL

FUNCTION ctomonthtest()

   LOCAL getlist := {}
   LOCAL cDom    := Space( 9 )
   LOCAL c       := .T.
   LOCAL nKey

   DO WHILE c
      @ 5, 10 SAY "CToMonth(dDate) receives the name of a month and returns"
      @ 6, 10 SAY "a number representing its position in the month. April"
      @ 7, 10 SAY "returns 4. Test it, Insert a month"
      @ 9, 10 GET cDom PICTURE "!!!!!!!!!"

      SET CONFIRM ON
      SET ESCAPE ON
      READ
      SET ESCAPE OFF
      SET CONFIRM ON

      cDom := AllTrim( cDom )

      nKey := LastKey()

      IF nKey == K_ESC
         c := .F.
      ELSE
         @ 11, 10 SAY "The day number is " + Str( CToMonth( cDom ) )

         SET CURSOR OFF
         Inkey( 0 )
         SET CURSOR ON

         cDom := Space( 9 )
      ENDIF

   ENDDO

   @ 0, 0 CLEAR

   RETURN NIL

FUNCTION dInMonthtest()

   LOCAL getlist := {}
   LOCAL cMonth  := Space( 9 )
   LOCAL c       := .T.
   LOCAL nMonth
   LOCAL nKey
   LOCAL cLeap   := Space( 1 )

   DO WHILE c
      @ 5, 10 SAY "DaysInMonth() receives either the number of a month or"
      @ 6, 10 SAY "its name and returns the number of days in the month. "
      @ 7, 10 SAY "April returns 30. Test it. Insert a month number"
      @ 8, 10 SAY "Is it a leap year?"
      @ 7, 60 GET cMonth PICTURE "XXXXXXXXX"


[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/dispmsg.prg. Provides functions: ft_DispMsg. This file provides legacy compatibility functions

[Assistant]
#include "setcurs.ch"

FUNCTION ft_DispMsg( aInfo, cKey, nBoxTop, nBoxLeft, cnBoxString, lShadow )

   LOCAL xRtnVal := .F.
   LOCAL nWidest := 0
   LOCAL nBoxRight
   LOCAL nBoxBottom
   LOCAL cOldScreen
   LOCAL cOldCursor
   LOCAL cOldColor
   LOCAL i
   LOCAL j
   LOCAL nOption
   LOCAL x
   LOCAL y
   LOCAL aPos := {}
   LOCAL nLeft
   LOCAL aLeft

   FOR i := 1 TO Len( aInfo[ 1 ] )
      AAdd( aPos, {} )
   NEXT

   FOR i := 1 TO Len( aInfo[ 1 ] )

      DO WHILE At( "[", aInfo[ 1, i ] ) > 0
         x := At( "[", aInfo[ 1, i ] )
         y := At( "]", aInfo[ 1, i ] ) - 2
         AAdd( aPos[ i ], { x, y } )
         aInfo[ 1, i ] := StrTran( aInfo[ 1, i ], "[", "", 1, 1 )
         aInfo[ 1, i ] := StrTran( aInfo[ 1, i ], "]", "", 1, 1 )
      ENDDO

   NEXT

   AEval( aInfo[ 1 ], {| x | nWidest := Max( nWidest, Len( x ) ) } )

   IF nBoxLeft == NIL
      nLeft := Round( ( MaxCol() - nWidest ) / 2, 0 )
   ELSE
      nLeft := nBoxLeft + 2
   ENDIF

   IF nBoxLeft == NIL
      nBoxLeft := nLeft - 2
   ENDIF
   nBoxRight := nBoxLeft + nWidest + 3

   IF nBoxTop == NIL
      nBoxTop := ( MaxRow() - Len( aInfo[ 1 ] ) - 2 ) / 2 + 1
   ENDIF
   nBoxBottom := nBoxTop + Len( aInfo[ 1 ] ) + 1

   IF cnBoxString == NIL .OR. cnBoxString == 2
      cnBoxString := hb_UTF8ToStrBox( "╔═╗║╝═╚║ " )
   ELSEIF cnBoxString == 1
      cnBoxString := hb_UTF8ToStrBox( "┌─┐│┘─└│ " )
   ENDIF

   __defaultNIL( @lShadow, .T. )

   cOldScreen := SaveScreen( nBoxTop, nBoxLeft, nBoxBottom + 1, nBoxRight + 2 )

   cOldCursor := SetCursor( SC_NONE )

   cOldColor := SetColor( aInfo[ 2, Len( aInfo[ 2 ] ) ] )

   hb_DispBox( nBoxTop, nBoxLeft, nBoxBottom, nBoxRight, cnBoxString, ;
      aInfo[ 2, Len( aInfo[ 2 ] ) ] )
   IF lShadow
      hb_Shadow( nBoxTop, nBoxLeft, nBoxBottom, nBoxRight )
   ENDIF

   aLeft := Array( Len( aInfo[ 1 ] ) )
   FOR i := 1 TO Len( aInfo[ 1 ] )
      IF Len( aInfo[ 1, i ] ) == nWidest
         aLeft[ i ] := nLeft
      ELSE
         aLeft[ i ] := nLeft + Round( ( nWidest - Len( aInfo[ 1, i ] ) ) / 2, 0 )
      ENDIF
   NEXT

   FOR i := 2 TO Len( aInfo[ 2 ] )
      IF aInfo[ 2, i ] == NIL
         aInfo[ 2, i ] := aInfo[ 2, i - 1 ]
      ENDIF
   NEXT

   FOR i := 1 TO Len( aInfo[ 1 ] )
      hb_DispOutAt( nBoxTop + i, aLeft[ i ], aInfo[ 1, i ], aInfo[ 2, i ] )
   NEXT

   FOR i := 1 TO Len( aPos )
      FOR j := 1 TO Len( aPos[ i ] )

         ft_SetAttr( nBoxTop + i, ;
            aPos[ i, j, 1 ] + aLeft[ i ] - 1, ;
            nBoxTop + i, ;
            aPos[ i, j, 2 ] + aLeft[ i ] - 1, ;
            ft_Color2N( aInfo[ 2, Len( aInfo[ 2 ] ) ] ) )
      NEXT
   NEXT

   IF cKey != NIL
      IF Len( cKey ) == 1
         nOption := ft_SInkey( 0 )
         IF Upper( Chr( nOption ) ) == cKey
            xRtnVal := .T.
         ENDIF
      ELSE
         nOption := 0
         DO WHILE hb_BAt( Upper( Chr( nOption ) ), Upper( cKey ) ) == 0
            nOption := ft_SInkey( 0 )
         ENDDO
         xRtnVal := nOption
      ENDIF
      RestScreen( nBoxTop, nBoxLeft, nBoxBottom + 1, nBoxRight + 2, cOldScreen )
   ENDIF

   SetColor( cOldColor )
   SetCursor( cOldCursor )

   RETURN xRtnVal


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

[User] Write a Harbour program with procedures: Main. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/setatlik.prg. Contains procedures: Main. This file provides legacy compatibility functions

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

PROCEDURE Main()

   LOCAL cWildcard := " "

   ctinit()

   ? "Begin test of SetAtLike()"
   ? "  Default mode should be 0, is................................", SetAtLike()
   ? "  Setting mode to 1, return value should be 0, is.............", SetAtLike( 1 )
   ? "  Mode setting should now be 1, is............................", SetAtLike()
   ? "  Setting mode to 0 again, return value should still be 1, is ", SetAtLike( 0 )
   ?
   SetAtLike( , @cWildcard )
   ? "  Default wildcard character should be '?', is................", cWildcard
   SetAtLike( , "#" )
   SetAtLike( , @cWildcard )
   ? "  Setting wildcard to '#' and calling SetAtLike( , @cWildcard )"
   ? "    should yield '#' for cWildcard, does......................", cWildcard
   ? "End test of SetAtLike()"
   ?

   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] Create Harbour preprocessor definitions: Harbour test program: tests/mt/mttest06.prg. This test file tests specific function APIs

[Assistant]
#define N_THREADS 5
#define N_COUNT   1000000
#define N_INIT    100

memvar m_var

proc main()
   local aThreads := {}, i, nSum

   ? Version()
   private m_var := N_INIT
   ? "Starting threads: "
   for i :=1 to N_THREADS
      aadd( aThreads, hb_threadStart( @thFunc() ) )
      ?? "<" + hb_ntos( i ) + ">"
   next
   ? "Waiting for threads..."
   nSum := 0
   aEval( aThreads, {| x | hb_threadJoin( x, @i ), nSum += i } )
   ? "Threads joined"
   ? "Sum of results:", nSum
   ? "     should be:", N_THREADS
     iif( nSum == N_THREADS * ( N_INIT + N_COUNT ), "OK", "ERROR" )
return

static func thFunc()
   private m_var := N_INIT - 10
return do()

static func do()
   local i
   private m_var := m_var + 10
   for i := 1 to N_COUNT
      ++m_var
   next
return m_var


[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 'hbtpathy' (Telepath communication library): contrib/hbtpathy/telepath.ch. Defines 10 constants including: TELEPATH_CH_, TP_MAXPORTS, TE_PARAM, TE_NOPORT, TE_CLOSED. Defines file I/O constants

[Assistant]
#ifndef TELEPATH_CH_
#define TELEPATH_CH_

#define TP_MAXPORTS  8

#define TE_PARAM           -1
#define TE_NOPORT          -2
#define TE_CLOSED          -3
#define TE_CONFL           -4
#define TE_TMOUT           -5
#define TE_NDCD            -6
#define TE_ESCAPE          -7
#define TE_LENGTH          -8
#define TE_CANCEL          -9
#define TE_NOHDL           -10

#define TE_UCANCEL         -50
#define TE_RCANCEL         -51
#define TE_STARTTM         -52
#define TE_BLOCKTM         -53
#define TE_ACKTM           -54
#define TE_SENDTM          -55
#define TE_CLEARTM         -56
#define TE_NAK             -57
#define TE_BADACK          -58
#define TE_BADBLK          -59
#define TE_LONGBLK         -60
#define TE_ERRMAX          -61
#define TE_DUPBLK          -62
#define TE_PROTO           -63
#define TE_CKSUM           -64
#define TE_HDRTM           -65

#define TE_DISKFULL        -100
#define TE_NOFILE          -102
#define TE_NOPATH          -103
#define TE_MFILE           -104
#define TE_ACCESS          -105

#define TXS_START          1
#define TXS_SFILE          2
#define TXS_NEWNAME        3
#define TXS_SDATA          4
#define TXS_BLOCK          5
#define TXS_ERROR          6
#define TXS_ABFILE         7
#define TXS_ABORT          8
#define TXS_WEND           9
#define TXS_EFILE          10
#define TXS_END            11

#define TP_32MAGIC         0x2144DF1C

#define THS_RDSR           1
#define THS_RCTS           2
#define THS_RXOFF          4
#define THS_RDCD           8
#define THS_ADTR           16
#define THS_CDTR           32
#define THS_ARTS           64
#define THS_CRTS           128
#define THS_SXOFF          256

#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 'hbdoc' (Documentation generation utilities): contrib/hbdoc/_html.prg. Defines classes: GenerateHTML. Provides functions: GitRev. This file provides utility functions

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

#define EXTENSION  ".html"

#define STYLEFILE  "hbdoc.css"

CREATE CLASS GenerateHTML INHERIT TPLGenerate

   HIDDEN:

   METHOD RecreateStyleDocument( cStyleFile )
   METHOD OpenTagInline( cText, ... )
   METHOD OpenTag( cText, ... )
   METHOD Tagged( cText, cTag, ... )
   METHOD CloseTagInline( cText )
   METHOD CloseTag( cText )
   METHOD AppendInline( cText, cFormat, lCode )
   METHOD Append( cText, cFormat, lCode )
   METHOD Space() INLINE ::cFile += ", ", Self
   METHOD Spacer() INLINE ::cFile += hb_eol(), Self
   METHOD Newline() INLINE ::cFile += "<br>" + hb_eol(), Self
   METHOD NewFile()

   CLASS VAR lCreateStyleDocument AS LOGICAL INIT .T.
   VAR TargetFilename AS STRING INIT ""

   EXPORTED:

   METHOD NewIndex( cDir, cFilename, cTitle, cLang )
   METHOD NewDocument( cDir, cFilename, cTitle, cLang )
   METHOD AddEntry( oEntry )
   METHOD AddReference( oEntry, cReference, cSubReference )
   METHOD BeginSection( cSection, cFilename )
   METHOD EndSection( cSection, cFilename )
   METHOD Generate()

   METHOD WriteEntry( cField, cContent, lPreformatted ) HIDDEN

   VAR nStart INIT hb_MilliSeconds()
   VAR nIndent INIT 0

ENDCLASS

METHOD NewFile() CLASS GenerateHTML

   ::cFile += "<!DOCTYPE html>" + hb_eol()

   ::OpenTag( "html", "lang", StrTran( ::cLang, "_", "-" ) )
   ::Spacer()

   ::OpenTag( "meta", "charset", "utf-8" )
   ::OpenTag( "meta", "name", "referrer", "content", "origin" )
   ::OpenTag( "meta", "name", "viewport", "content", "initial-scale=1" )
   ::Spacer()

   ::OpenTag( "meta", "name", "generator", "content", "hbdoc" )
   ::OpenTag( "meta", "name", "keywords", "content", ;
      "Harbour, Clipper, xBase, database, Free Software, GPL, compiler, cross-platform, 32-bit, 64-bit" )
   ::Spacer()

   IF ::lCreateStyleDocument
      ::lCreateStyleDocument := .F.
      ::RecreateStyleDocument( STYLEFILE )
   ENDIF

   ::Append( ::cTitle, "title" )
   ::Spacer()

   ::OpenTag( "link", "rel", "stylesheet", "href", STYLEFILE )
   ::Spacer()

   ::OpenTag( "body" )
   ::Spacer()

   ::OpenTag( "header" )
   ::Append( ::cTitle, "h1" )
   ::CloseTag( "header" )
   ::Spacer()

   ::OpenTag( "main" )

   RETURN Self

STATIC FUNCTION GitRev()

   LOCAL cStdOut := ""

   hb_processRun( "git rev-parse --short HEAD",, @cStdOut )

   RETURN hb_StrReplace( cStdOut, Chr( 13 ) + Chr( 10 ) )

METHOD Generate() CLASS GenerateHTML

   LOCAL cRevision := GitRev()

   ::Spacer()
   ::CloseTag( "main" )

   ::Spacer()
   ::OpenTag( "footer" )
   ::Append( "Generated by hbdoc on " + hb_TToC( hb_DateTime() - ( hb_UTCOffset() / 86400 ), "yyyy-mm-dd", "hh:mm" ) + " UTC", "div" )

   ::OpenTagInline( "div" )
   ::AppendInline( "Based on commit " )
   #if defined( HB_VERSION_URL_BASE )
      ::OpenTagInline( "a", "href", hb_Version( HB_VERSION_URL_BASE ) + "tree/" + cRevision )
   #endif
   ::AppendInline( cRevision )
   #if defined( HB_VERSION_URL_BASE )
      ::CloseTagInline( "a" )
   #endif
   ::CloseTag( "div" )

   ::CloseTag( "footer" )

   ::super:Generate()

   RETURN Self

METHOD NewDocument( cDir, cFilename, cTitle, cLang ) CLASS GenerateHTML

   ::super:NewDocument( cDir, cFilename, cTitle, EXTENSION, cLang )
   ::NewFile()

   RETURN Self

METHOD NewIndex( cDir, cFilename, cTitle, cLang ) CLASS GenerateHTML

   ::super:NewIndex( cDir, cFilename, cTitle, EXTENSION, cLang )
   ::NewFile()

   RETURN Self

METHOD BeginSection( cSection, cFilename ) CLASS GenerateHTML

   cSection := SymbolToHTMLID( cSection )

   IF ::IsIndex()
      IF cFilename == ::cFilename
         ::OpenTagInline( "div", "id", cSection ):AppendInline( cSection, "h" + hb_ntos( ::Depth + 2 ) ):CloseTag( "div" )
      ELSE
         ::OpenTag( "a", "href", cFilename + ::cExtension + "#" + cSection ):Append( cSection, "h" + hb_ntos( ::Depth + 2 ) ):CloseTag( "a" )
      ENDIF
   ELSE
      ::OpenTagInline( "div", "id", cSection ):AppendInline( cSection, "h" + hb_ntos( ::Depth + 2 ) ):CloseTag( "div" )
   ENDIF
   ::TargetFilename := cFilename
   ::Depth++

   RETURN Self

METHOD EndSection( cSection, cFilename ) CLASS GenerateHTML

   HB_SYMBOL_UNUSED( cSection )
   HB_SYMBOL_UNUSED( cFilename )
   ::Depth--

   RETURN Self

METHOD AddReference( oEntry, cReference, cSubReference ) CLASS GenerateHTML

   IF HB_ISOBJECT( oEntry ) .AND. oEntry:ClassName() == "ENTRY"
      ::OpenTag( "a", "href", ::TargetFilename + ::cExtension + "#" + oEntry:_filename ):Append( oEntry:fld[ "NAME" ] ):CloseTag( "a" ):Append( oEntry:fld[ "ONELINER" ] ):Newline()
   ELSE
      IF HB_ISSTRING( cSubReference )
         ::OpenTag( "a", "href", cReference + ::cExtension + "#" + cSubReference ):Append( oEntry ):CloseTag( "a" ):Newline()
      ELSE
         ::OpenTag( "a", "href", cReference + ::cExtension  ):Append( oEntry ):CloseTag( "a" ):Newline()
      ENDIF
   ENDIF

   RETURN Self

METHOD AddEntry( oEntry ) CLASS GenerateHTML

   LOCAL item
   LOCAL cEntry

   ::Spacer()
   ::OpenTag( "section", "id", SymbolToHTMLID( oEntry:_filename ) )

   FOR EACH item IN FieldIDList()
      IF item == "NAME"
         cEntry := oEntry:fld[ "NAME" ]
         IF "(" $ cEntry .OR. Upper( cEntry ) == cEntry
            ::OpenTagInline( "h4" ):OpenTagInline( "code" ):AppendInline( cEntry ):CloseTagInline( "code" ):CloseTag( "h4" )
         ELSE
            ::OpenTagInline( "h4" ):AppendInline( cEntry ):CloseTag( "h4" )
         ENDIF
      ELSEIF oEntry:IsField( item ) .AND. oEntry:IsOutput( item ) .AND. Len( oEntry:fld[ item ] ) > 0
         ::WriteEntry( item, oEntry:fld[ item ], oEntry:IsPreformatted( item ) )
      ENDIF
   NEXT

   ::CloseTag( "section" )

   RETURN Self

METHOD PROCEDURE WriteEntry( cField, cContent, lPreformatted ) CLASS GenerateHTML

   STATIC s_class := { ;
      "NAME"     => "d-na", ;
      "ONELINER" => "d-ol", ;
      "EXAMPLES" => "d-ex", ;
      "TESTS"    => "d-te" }

   LOCAL cTagClass
   LOCAL cCaption
   LOCAL lFirst
   LOCAL tmp, tmp1
   LOCAL cLine
   LOCAL lCode, lTable, lTablePrev, cHeaderClass

   IF ! Empty( cContent )

      cTagClass := hb_HGetDef( s_class, cField, "d-it" )

      IF ! HB_ISNULL( cCaption := FieldCaption( cField ) )
         ::Tagged( cCaption, "div", "class", "d-d" )
      ENDIF

      DO CASE
      CASE lPreformatted

         ::OpenTag( "pre", "class", cTagClass )
         ::Append( cContent,, .T. )
         ::CloseTag( "pre" )

      CASE cField == "SEEALSO"

         ::OpenTagInline( "div", "class", cTagClass )
         lFirst := .T.
         FOR EACH tmp IN hb_ATokens( cContent, "," )
            tmp := AllTrim( tmp )
            IF ! HB_ISNULL( tmp )

               tmp1 := Parse( tmp, "(" )
               IF lFirst
                  lFirst := .F.
               ELSE
                  ::Space()
               ENDIF
               ::OpenTagInline( "code" ):OpenTagInline( "a", "href", "#" + SymbolToHTMLID( tmp1 ) ):AppendInline( tmp ):CloseTagInline( "a" ):CloseTagInline( "code" )
            ENDIF
         NEXT
         ::CloseTag( "div" )

      CASE cField == "SYNTAX"

         ::OpenTagInline( "div", "class", cTagClass )
         DO WHILE ! HB_ISNULL( cContent )
            ::OpenTagInline( "code" )
            ::AppendInline( Indent( Parse( @cContent, hb_eol() ), 0, -1,, .T. ),, .F. )
            ::CloseTagInline( "code" )
         ENDDO
         ::CloseTag( "div" )

      OTHERWISE

         ::OpenTag( "div", "class", cTagClass )
         ::nIndent++

         lTable := .F.

         DO WHILE ! HB_ISNULL( cContent )

            lCode := .F.
            lTablePrev := lTable

            tmp1 := ""
            DO WHILE ! HB_ISNULL( cContent )

               cLine := Parse( @cContent, hb_eol() )

               DO CASE
               CASE hb_LeftEq( LTrim( cLine ), "```" )
                  IF lCode
                     EXIT
                  ELSE
                     lCode := .T.
                  ENDIF
               CASE cLine == "<fixed>"
                  lCode := .T.


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

[User] Generate Harbour code for: Harbour Runtime Library file: src/rtl/tgetint.prg. Provides functions: __Get, __GetA. This file implements object-oriented classes using Harbour's class system

[Assistant]
REQUEST HB_PValue

FUNCTION __Get( bSetGet, cVarName, cPicture, bValid, bWhen )

   LOCAL oGet

   IF ! HB_ISSTRING( cVarName )
      RETURN NIL
   ENDIF

   IF ! HB_ISEVALITEM( bSetGet )
      IF FieldPos( cVarName ) > 0
         bSetGet := FieldWBlock( cVarName, Select() )
      ELSEIF ( bSetGet := MemVarBlock( cVarName ) ) == NIL

         bSetGet := hb_macroBlock( "iif(HB_PValue(1)==NIL," + cVarName + "," + cVarName + ":=hb_PValue(1))" )
      ENDIF
   ENDIF

   Eval( bSetGet )

   oGet := GetNew( ,, bSetGet, cVarName, cPicture )

   oGet:PreBlock := bWhen
   oGet:PostBlock := bValid

   RETURN oGet

FUNCTION __GetA( bGetArray, cVarName, cPicture, bValid, bWhen, aIndex )

   LOCAL oGet

   IF ! HB_ISSTRING( cVarName ) .OR. ! HB_ISARRAY( aIndex )
      RETURN NIL
   ENDIF

   IF ! HB_ISEVALITEM( bGetArray )

      IF FieldPos( cVarName ) > 0
         bGetArray := FieldWBlock( cVarName, Select() )
      ELSE
         DO WHILE ( bGetArray := MemVarBlock( cVarName ) ) == NIL
            __mvGet( cVarName )
         ENDDO
      ENDIF
   ENDIF

   IF ! ValType( Eval( bGetArray ) ) $ "AH"
      RETURN NIL
   ENDIF

   oGet := GetNew( ,, bGetArray, cVarName, cPicture )
   oGet:SubScript := aIndex

   oGet:PreBlock := bWhen
   oGet:PostBlock := bValid

   RETURN oGet


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

[User] Create Harbour preprocessor definitions: Harbour contribution module 'gtwvw' (): contrib/gtwvw/tests/inpfocus.prg. Provides 10 functions including: CreateToolbar, CreateStatusbar, MenuAction, OpenNewWindow, CloseLastWindow. Contains procedures: Main. This file provides platform-specific functionality

[Assistant]
#require "gtwvw"

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

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

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

#define STD_DELETE              5
#define STD_FILENEW             6

#define VIEW_PARENTFOLDER       8

#define IDM_OPENWIN     100
#define IDM_CLOSEWIN    101
#define IDM_ARRANGEWIN  102

#define _MAX_WINNUM  10

STATIC s_akeyhandlers[ _MAX_WINNUM ]

PROCEDURE Main()

   LOCAL ch

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

   IF ! SetMode( 25, 80 )
      wvw_MessageBox( 0, "Cannot set to (25,80) screen", "Warning", MB_OK + MB_ICONEXCLAMATION )
   ENDIF
   SetColor( "W*/N+" )
   CLS
   SetCursor( SC_NONE )
   @ 0, 0 SAY PadC( "This will demonstrate how to handle input on non-topmost window", MaxCol() + 1 )
   @ 1, 0 SAY PadC( "(Sorry that currently caret is shown on topmost window only)", MaxCol() + 1 )

   CreateToolbar( 0 )
   CreateStatusbar( 0 )

   ch := Inkey( 0 )
   DO WHILE ch != K_ESC
      IF ch == wvw_SetMenuKeyEvent( 0 )
         MenuAction( 0, wvw_GetLastMenuEvent( 0 ) )
      ENDIF
      ch := Inkey( 0 )
   ENDDO

   wvw_MessageBox( 0, "Thanks for trying this program", "Goodbye", MB_OK )

   RETURN

STATIC FUNCTION CreateToolbar( nWinNum )

   LOCAL nSysBitmap := 1
   LOCAL lDisplayText := .F.
   LOCAL hWndTB

   wvw_tbDestroy( nWinNum )

   hWndTB := wvw_tbCreate( nWinNum, lDisplayText, NIL, nSysBitmap )

   IF hWndTB == 0
      wvw_MessageBox( nWinNum, "FAILED to create toolbar", "Error", MB_OK + MB_ICONEXCLAMATION )
      RETURN .F.
   ENDIF

   wvw_tbAddButton( nWinNum, IDM_OPENWIN,  STD_FILENEW, "Open a new typewriter window", 1  )
   wvw_tbAddButton( nWinNum, IDM_CLOSEWIN, STD_DELETE, "Close last window", 1  )
   wvw_tbAddButton( nWinNum, IDM_ARRANGEWIN, VIEW_PARENTFOLDER, "Reposition all windows", 2  )

   RETURN .T.

STATIC FUNCTION CreateStatusbar( nWinNum )

   LOCAL hWndSB

   wvw_sbDestroy( nWinNum )
   hWndSB := wvw_sbCreate( nWinNum )
   IF hWndSB == 0
      wvw_MessageBox( nWinNum, "FAILED to create statusbar", "Error", MB_OK + MB_ICONEXCLAMATION )
      RETURN .F.
   ENDIF

   RETURN .T.

STATIC FUNCTION MenuAction( nWinNum, nCommand )

   DO CASE
   CASE nCommand == IDM_OPENWIN
      OpenNewWindow()
   CASE nCommand == IDM_CLOSEWIN
      CloseLastWindow()
   CASE nCommand == IDM_ARRANGEWIN
      wvw_XReposWindow()
   OTHERWISE
      wvw_MessageBox( nWinNum, "Unknown menu command", "Internal Error", MB_OK + MB_ICONEXCLAMATION )
   ENDCASE

   RETURN NIL

STATIC FUNCTION OpenNewWindow()

   LOCAL nWinNum := wvw_nNumWindows()
   LOCAL ctitle, nrow1, ncol1, nrow2, ncol2
   LOCAL ch

   IF nWinNum > _MAX_WINNUM
      wvw_MessageBox( nWinNum - 1, "Sorry, I don't think you can handle that many of windows :-)", ;
         "Sorry", MB_OK + MB_ICONASTERISK )
      RETURN .F.
   ENDIF

   ctitle := "Win #" + hb_ntos( nWinNum )
   nrow1  := 4 + ( nWinNum - 1 )
   ncol1  := 1 + ( nWinNum - 1 )
   SetColor( "W+/N" )
   IF wvw_nOpenWindow( ctitle, nrow1, ncol1, nrow2, ncol2, NIL, 0 ) != nWinNum

      wvw_MessageBox( 0, "Something horrible has happened, program aborted", ;
         "Internal Error", MB_OK + MB_ICONHAND )
      QUIT
   ENDIF
   wvw_NoClose( nWinNum )

   IF nWinNum > 1
      s_akeyhandlers[ nWinNum - 1 ] := {| n, ch | KeyHandler( n, ch ) }
   ENDIF

   SetCursor( SC_NORMAL )
   ch := Inkey( 0 )
   DO WHILE ch != K_ESC
      typing( ch )
      ch := Inkey( 0 )
   ENDDO

   wvw_lCloseWindow()

   IF nWinNum > 1
      s_akeyhandlers[ nWinNum - 1 ] := NIL
   ELSEIF nWinNum == 1
      SetCursor( SC_NONE )
   ENDIF

   RETURN .T.

STATIC FUNCTION CloseLastWindow()

   LOCAL nWinNum := wvw_nNumWindows() - 1

   wvw_nSetCurWindow( nWinNum )
   hb_keyPut( K_ESC )

   RETURN NIL

STATIC FUNCTION KeyHandler( nWinNum, ch )

   LOCAL nOldWin := wvw_nSetCurWindow( nWinNum )

   typing( ch )
   wvw_nSetCurWindow( nOldWin )

   RETURN NIL

STATIC FUNCTION typing( ch )

   IF ch >= 0 .AND. ch <= 255
      ?? hb_keyChar( ch )
      IF ch == K_ENTER
         ?? Chr( 10 )
      ELSEIF ch == K_BS
         ?? " " + Chr( 8 )
      ENDIF
   ENDIF

   RETURN NIL

#define WM_COMMAND                      0x0111
#define WM_CHAR                         0x0102

FUNCTION WVW_INPUTFOCUS( nWinNum, hWnd, message, wParam, lParam )

   LOCAL wParamLow := wvw_LOWORD( wParam )
   LOCAL nCommand, ch

   HB_SYMBOL_UNUSED( hWnd )
   HB_SYMBOL_UNUSED( lParam )

   IF message == WM_COMMAND .AND. nWinNum == 0
      nCommand := wParamLow
      MenuAction( 0, nCommand )
      RETURN .T.
   ENDIF

   IF nWinNum == 0
      RETURN .F.
   ENDIF

   DO CASE
   CASE message == WM_CHAR
      ch := wParam
      Eval( s_akeyhandlers[ nWinNum ], nWinNum, ch )
      RETURN .T.
   OTHERWISE

      RETURN .T.
   ENDCASE

   RETURN .F.

STATIC FUNCTION winMaxRow( nWinNum )

   LOCAL nOldWin := wvw_nSetCurWindow( nWinNum )
   LOCAL nmaxrow := MaxRow()

   wvw_nSetCurWindow( nOldWin )

   RETURN nmaxrow

STATIC FUNCTION winMaxCol( nWinNum )

   LOCAL nOldWin := wvw_nSetCurWindow( nWinNum )
   LOCAL nmaxCol := MaxCol()

   wvw_nSetCurWindow( nOldWin )

   RETURN nmaxCol


[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 'hbsqlit3' (SQLite3 database client library): contrib/hbsqlit3/errstr.prg. Provides functions: hb_sqlite3_errstr_short. This file handles database operations

[Assistant]
#include "hbsqlit3.ch"

FUNCTION hb_sqlite3_errstr_short( nError )

   IF ! HB_ISNUMERIC( nError )
      RETURN "HB_SQLITE_INVALID"
   ENDIF

   SWITCH nError
   CASE SQLITE_OK         ; RETURN "SQLITE_OK"
   CASE SQLITE_ERROR      ; RETURN "SQLITE_ERROR"
   CASE SQLITE_INTERNAL   ; RETURN "SQLITE_INTERNAL"
   CASE SQLITE_PERM       ; RETURN "SQLITE_PERM"
   CASE SQLITE_ABORT      ; RETURN "SQLITE_ABORT"
   CASE SQLITE_BUSY       ; RETURN "SQLITE_BUSY"
   CASE SQLITE_LOCKED     ; RETURN "SQLITE_LOCKED"
   CASE SQLITE_NOMEM      ; RETURN "SQLITE_NOMEM"
   CASE SQLITE_READONLY   ; RETURN "SQLITE_READONLY"
   CASE SQLITE_INTERRUPT  ; RETURN "SQLITE_INTERRUPT"
   CASE SQLITE_IOERR      ; RETURN "SQLITE_IOERR"
   CASE SQLITE_CORRUPT    ; RETURN "SQLITE_CORRUPT"
   CASE SQLITE_NOTFOUND   ; RETURN "SQLITE_NOTFOUND"
   CASE SQLITE_FULL       ; RETURN "SQLITE_FULL"
   CASE SQLITE_CANTOPEN   ; RETURN "SQLITE_CANTOPEN"
   CASE SQLITE_PROTOCOL   ; RETURN "SQLITE_PROTOCOL"
   CASE SQLITE_EMPTY      ; RETURN "SQLITE_EMPTY"
   CASE SQLITE_SCHEMA     ; RETURN "SQLITE_SCHEMA"
   CASE SQLITE_TOOBIG     ; RETURN "SQLITE_TOOBIG"
   CASE SQLITE_CONSTRAINT ; RETURN "SQLITE_CONSTRAINT"
   CASE SQLITE_MISMATCH   ; RETURN "SQLITE_MISMATCH"
   CASE SQLITE_MISUSE     ; RETURN "SQLITE_MISUSE"
   CASE SQLITE_NOLFS      ; RETURN "SQLITE_NOLFS"
   CASE SQLITE_AUTH       ; RETURN "SQLITE_AUTH"
   CASE SQLITE_FORMAT     ; RETURN "SQLITE_FORMAT"
   CASE SQLITE_RANGE      ; RETURN "SQLITE_RANGE"
   CASE SQLITE_NOTADB     ; RETURN "SQLITE_NOTADB"
   CASE SQLITE_ROW        ; RETURN "SQLITE_ROW"
   CASE SQLITE_DONE       ; RETURN "SQLITE_DONE"
   ENDSWITCH

   RETURN "HB_SQLITE_UNKNOWN_" + hb_ntos( nError )


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

[User] Write a Harbour program with procedures: Main. Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/tests/antialia.prg. Contains procedures: Main. This file provides graphics and image processing capabilities

[Assistant]
#require "hbgd"

#define IMAGES_IN  "imgs_in" + hb_ps()
#define IMAGES_OUT "imgs_out" + hb_ps()

PROCEDURE Main()

   LOCAL im
   LOCAL white, blue

   im := gdImageCreatePalette( 100, 100 )

   blue  := gdImageColorAllocate( im, 0, 0, 255 )

   gdImageLine( im, 0, 0, 99, 40, blue )

   gdImageSetAntiAliased( im, blue )

   gdImageLine( im, 0, 40, 99, 80, gdAntiAliased )

   gdImageJpeg( im, IMAGES_OUT + "antialiasedpal.jpg" )

   im := gdImageCreateTrueColor( 100, 100 )

   white := gdTrueColor( 255, 255, 255 )
   gdImageFilledRectangle( im, 0, 0, 100, 100, white )

   blue := gdImageColorAllocate( im, 0, 0, 255 )

   gdImageLine( im, 0, 0, 99, 40, blue )

   gdImageSetAntiAliased( im, blue )

   gdImageLine( im, 0, 40, 99, 80, gdAntiAliased )

   gdImageJpeg( im, IMAGES_OUT + "antialiasedtrue.jpg" )

   ?
   ? "Look at " + IMAGES_OUT + " folder for output images"
   ?

   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/mttest04.prg. This test file tests specific function APIs

[Assistant]
#ifdef __XHARBOUR__
   #xtranslate hb_threadStart( <x,...> ) => StartThread( <x> )
   #xtranslate hb_threadJoin( <x,...> ) => JoinThread( <x> )
#endif

#define N_THREADS 5

static s_nVar1 := 0
static s_nVar2 := 0
static s_aCounters
static s_hMutex

proc main()
   local aThreads, i, lEnd, nSum
   ? Version()
   ? "Main start"
   s_aCounters := array( N_THREADS )
   aFill( s_aCounters, 0 )
   aThreads := {}
   s_hMutex := hb_mutexCreate()
   lEnd := .F.
   ? "Starting threads: "
   for i := 1 to N_THREADS
      aadd( aThreads, hb_threadStart( @thFunc(), i, @lEnd ) )
      ?? "<" + hb_ntos( i ) + ">"
   next
   ? "Wait 5 seconds or hit any key..."
   inkey( 5 )
   lEnd := .T.
   ? "Waiting for threads..."
   aEval( aThreads, {| x | hb_threadJoin( x ) } )
   ? "Threads joined"
   nSum := 0
   aEval( s_aCounters, {| x | nSum += x } )
   ? "Sum of thread local counters:", nSum
   ? "Protected item result.......:", s_nVar2, ;
     iif( nSum == s_nVar2, "OK", "ERROR" )
   ? "Unprotected item result.....:", s_nVar1, "*"
   ? " * - can be different then local sum on real multi-CPU systems"
   ? "End of main"
return

proc thFunc( nThread, lEnd )
   while ! lEnd
      s_nVar1++
      hb_mutexLock( s_hMutex )
      s_nVar2++
      hb_mutexUnLock( s_hMutex )
      s_aCounters[ nThread ]++
   enddo
return


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

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

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

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

PROCEDURE Main()

   ctinit()

   ? "Begin test of CharAdd()"
   ?

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

   ? "End test of CharAdd()"
   ?

   ctexit()

   RETURN


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

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

Harbour contribution module 'hbcups' (CUPS printing system wrapper): contrib/hbcups/tests/test.prg. Contains procedures: Main. This file provides utility functions

[Assistant]
#require "hbcups"

PROCEDURE Main( cFile )

   LOCAL i
   LOCAL aPrinter

   hb_default( @cFile, __FILE__ )

   IF Empty( cupsGetDefault() )
      ? "No default printer configured"
   ELSE
      ? "Default printer:", cupsGetDefault()
   ENDIF

   ?
   ? "Cups Printer List:"

   FOR EACH i IN cupsGetDests()
      ? i:__enumIndex(), i
   NEXT

   IF Empty( cupsGetDefault() )
      WAIT
      CLS
      aPrinter := cupsGetDests()
      i := AChoice( 2, 5, 30, Len( aPrinter ) + 2, aPrinter )
      ? "Printing... Job ID:", cupsPrintFile( aPrinter[ i ], cFile, "Harbour CUPS Printing" )
   ELSE
      ? "Printing... Job ID:", cupsPrintFile( cupsGetDefault(), cFile, "Harbour CUPS Printing", { "sides=one-sided" } )
   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]
Here is a Harbour (xBase/Clipper) implementation:

Harbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/stringp.prg. Provides functions: ToChar, Debug. This file provides utility functions

[Assistant]
#include "hboo.ch"

FUNCTION ToChar( xTxt, cSeparator, lDebug )

   LOCAL cOut
   LOCAL n
   LOCAL nLen
   LOCAL aData

   hb_default( @cSeparator, " " )
   hb_default( @lDebug, .F. )

   SWITCH ValType( xTxt )
   CASE "C"
   CASE "M" ; RETURN iif( lDebug, '"' + xTxt + '"', xTxt )
   CASE "N" ; RETURN hb_ntos( xTxt )
   CASE "U" ; RETURN iif( lDebug, "NIL", "" )
   CASE "D" ; RETURN hb_DToC( xTxt, "yyyy-mm-dd" )
   CASE "L" ; RETURN iif( lDebug, iif( xTxt, ".T.", ".F." ), iif( xTxt, "True", "False" ) )
   CASE "B" ; RETURN iif( lDebug, "Block", Eval( xTxt ) )

   CASE "A"
      cOut := ""
      IF lDebug
         cOut += "{"
      ENDIF
      nLen := Len( xTxt )
      FOR n := 1 TO nLen
         cOut += ToChar( xTxt[ n ], cSeparator, lDebug )
         IF n != nLen
            cOut += cSeparator
         ENDIF
      NEXT
      IF lDebug
         cOut += "}"
      ENDIF
      EXIT

   CASE "O"
      IF lDebug
         cOut  := xTxt:ClassName() + "(#" + ToChar( xTxt:ClassH() ) + "):{"
         aData := __objGetValueList( xTxt )
         nLen  := Len( aData )
         FOR n := 1 TO nLen
            cOut += aData[ n ][ HB_OO_DATA_SYMBOL ] + ":" + ;
               ToChar( aData[ n ][ HB_OO_DATA_VALUE ], cSeparator, lDebug )
            IF n != nLen
               cOut += cSeparator
            ENDIF
         NEXT
         cOut += "}"
      ELSE
         cOut := ToChar( xTxt:Run(), cSeparator, lDebug )
      ENDIF
      EXIT

   ENDSWITCH

   RETURN cOut

FUNCTION Debug( xItem )

   ? ToChar( xItem, ", ", .T. )

   RETURN xItem


[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 extra library: extras/httpsrv/modules/tableservletdb.prg. Defines classes: TableManager, BasicXML. Provides functions: HRBMAIN. This file implements server functionality

[Assistant]
#include "hbclass.ch"

#define TABLE_NAME_PATH ".." + hb_ps() + ".." + hb_ps() + ".." + hb_ps() + "tests" + hb_ps() + "test.dbf"
#define SIMULATE_SLOW_REPLY

MEMVAR _REQUEST

FUNCTION HRBMAIN()

   LOCAL cXml, cPage, cCount, nCount
   LOCAL oTM
   LOCAL hGets := _REQUEST

   hb_default( @hGets, { => } )

   IF hb_HHasKey( hGets, "page" )

      cPage := hGets[ "page" ]

      oTM := TableManager():New()
      IF oTM:Open()
         oTM:Read()
         cXml := oTM:getXmlData( Val( cPage ) )
         oTM:Close()
      ENDIF

   ELSEIF hb_HHasKey( hGets, "count" )

      cCount := hGets[ "count" ]

      IF cCount == "true"
         oTM  := TableManager():New()
         IF oTM:Open()
            nCount := oTM:getLastRec()
            cXml := oTM:getXmlCount( nCount )
            oTM:Close()
         ENDIF
      ENDIF
   ENDIF

   IF ! Empty( cXml )
      uhttpd_SetHeader( "Content-Type", "text/xml" )

      uhttpd_SetHeader( "Cache-Control", "no-cache, must-revalidate" )
      uhttpd_SetHeader( "Expires", "Mon, 26 Jul 1997 05:00:00 GMT" )
      uhttpd_Write( cXml )
   ELSE
      uhttpd_SetHeader( "Content-Type", "text/xml" )
      uhttpd_Write( '<?xml version="1.0" encoding="ISO-8859-1"?>' )
      uhttpd_Write( "<pages><page>No Data</page></pages>" )
   ENDIF

   RETURN .T.

CREATE CLASS TableManager

   CLASS VAR ROWS_PER_PAGE INIT 23

   VAR aData               INIT {}

   VAR cTable              INIT TABLE_NAME_PATH
   VAR lOpened             INIT .F.

   METHOD New()
   METHOD Open()
   METHOD Close()          INLINE iif( ::lOpened, ( table->( dbCloseArea() ), ::lOpened := .F. ), )
   METHOD Read()
   METHOD getLastRec()     INLINE table->( LastRec() )
   METHOD getXmlData( page )
   METHOD getXmlCount( ncount )
   METHOD xmlEncode( input )

ENDCLASS

METHOD New() CLASS TableManager

   RETURN Self

METHOD Open() CLASS TableManager

   LOCAL cDBF := ::cTable

   IF ! ::lOpened

      CLOSE ALL
      USE ( cDBF ) ALIAS table SHARED NEW

      ::lOpened := Used()

   ENDIF

   RETURN ::lOpened

METHOD Read() CLASS TableManager

   LOCAL hMap, lOk := .F.

#ifdef SIMULATE_SLOW_REPLY

   hb_idleSleep( 0.5 )
#endif

   IF ::lOpened

      table->( dbGoTop() )

      DO WHILE table->( ! Eof() )

         hMap := { => }
         hMap[ "recno"   ] := StrZero( table->( RecNo() ), 4 )
         hMap[ "name"    ] := RTrim( table->first ) + " " + RTrim( table->last )
         hMap[ "address" ] := RTrim( table->street )
         hMap[ "city"    ] := RTrim( table->city )
         hMap[ "state"   ] := table->state
         hMap[ "zip"     ] := table->zip
         AAdd( ::aData, hMap )
         table->( dbSkip() )
      ENDDO

      lOk := .T.

   ENDIF

   RETURN lOK

METHOD getXmlData( page ) CLASS TableManager

   LOCAL startIndex, stopIndex
   LOCAL xml, i, map, key, cString

   startIndex := ( page - 1 )
   xml:append( '<?xml version="1.0" encoding="ISO-8859-1"?>' )

   xml:append( "
" )

   xml:append( "" )
   xml:append( '<cell key="recno">RecNo</cell>' )
   xml:append( '<cell key="name">Name</cell>' )
   xml:append( '<cell key="address">Address</cell>' )
   xml:append( '<cell key="city">City</cell>' )
   xml:append( '<cell key="state">State</cell>' )
   xml:append( '<cell key="zip">Zip</cell>' )
   xml:append( "" )

   FOR i := startIndex + 1 TO stopIndex
      map := ::aData[ i ]

      xml:append( "<row>" )

      FOR EACH KEY IN map:Keys

         cString := '<cell key="' + key + '">'
         cString += ::xmlEncode( hb_CStr( map[ key ] ) )
         cString += "</cell>"

         xml:append( cString )

      NEXT

      xml:append( "</row>" )

   NEXT

   xml:append( "
" )

   RETURN xml:toString()

METHOD getXmlCount( nCount ) CLASS TableManager

   LOCAL xml, n
   LOCAL nPages := nCount / ::ROWS_PER_PAGE

   IF Int( nPages ) < nPages
      nPages ++
   ENDIF

   xml := BasicXML():New()

   xml:append( '<?xml version="1.0" encoding="ISO-8859-1"?>' )

   xml:append( "<pages>" )
   FOR n := 1 TO nPages
      xml:append( "<page>" + hb_ntos( n ) + "</page>" )
   NEXT
   xml:append( "</pages>" )

   RETURN xml:toString()

METHOD xmlEncode( input ) CLASS TableManager

   LOCAL out, i, c

   IF input == NIL
      RETURN INPUT
   ENDIF

   out := ""

   FOR i := 1 TO Len( input )
      c := SubStr( input, i, 1 )
      SWITCH c
      CASE "&"
         out += "&"
         EXIT
      CASE "'"
         out += "'"
         EXIT
      CASE '"'
         out += """
         EXIT
      CASE "<"
         out += "<"
         EXIT
      CASE ">"
         out += ">"
         EXIT
      CASE Chr( 9 )
      CASE Chr( 13 )
      CASE Chr( 10 )
         out += c
         EXIT
      OTHERWISE

         IF Asc( c ) <= 0x1F .OR. Asc( c ) >= 0x80
            out += "&#x" + hb_NumToHex( Asc( c ) ) + ";"
         ELSE
            out += c
         ENDIF
         EXIT
      ENDSWITCH
   NEXT

   RETURN out

CREATE CLASS BasicXML

   VAR aData         INIT {}

   METHOD New()              CONSTRUCTOR
   METHOD append( cString )  INLINE AAdd( ::aData, cString )
   METHOD ToString()

ENDCLASS

METHOD New() CLASS BasicXML

   RETURN Self

METHOD ToString() CLASS BasicXML

   LOCAL s := ""

   AEval( ::aData, {| c | s += c + iif( Right( c, 1 ) == ">", hb_eol(), "" ) } )

   RETURN s


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

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

Harbour utility program: utils/hbtest/rt_array.prg. Contains procedures: Main_ARRAY. This file is part of the test framework

[Assistant]
#include "rt_main.ch"

#include "rt_vars.ch"

PROCEDURE Main_ARRAY()

#ifndef __XPP__
   HBTEST ACopy()                         IS NIL
#endif
   HBTEST ACopy( {}, "C" )                IS NIL
   HBTEST ACopy( "C", {} )                IS NIL
   HBTEST ACopy( {}, {} )                 IS "{.[0].}"
   HBTEST ACopy( {}, ErrorNew() )         IS "ERROR Object"
   HBTEST ACopy( ErrorNew(), {} )         IS "{.[0].}"
#ifndef __XPP__
   HBTEST AClone()                        IS NIL
#endif
   HBTEST AClone( NIL )                   IS NIL
   HBTEST AClone( {} )                    IS "{.[0].}"
   HBTEST AClone( ErrorNew() )            IS NIL
#ifndef __XPP__
   HBTEST AEval()                         IS "E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 "
   HBTEST AEval( NIL )                    IS "E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:1:U:NIL "
   HBTEST AEval( {} )                     IS "E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:1:A:{.[0].} "
#endif
   HBTEST AEval( {}, NIL )                IS "E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:2:A:{.[0].};U:NIL "
   HBTEST AEval( {}, {|| NIL } )          IS "{.[0].}"
   HBTEST AEval( ErrorNew(), {|| NIL } )  IS "ERROR Object"
#ifndef __XPP__
   HBTEST AScan()                         IS 0
   HBTEST AScan( NIL )                    IS 0
   HBTEST AScan( "A" )                    IS 0
   HBTEST AScan( {} )                     IS 0
#endif
   HBTEST AScan( {}, "" )                 IS 0
   HBTEST AScan( ErrorNew(), "NOT_FOUND" ) IS 0
#ifndef __XPP__
   HBTEST ASort()                         IS NIL
#endif
   HBTEST ASort( 10 )                     IS NIL
   HBTEST ASort( {} )                     IS "{.[0].}"
   HBTEST ASort( ErrorNew() )             IS NIL
#ifdef HB_CLP_STRICT
#ifndef __XPP__
   HBTEST AFill()                         IS "E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:4:U:NIL;B:{||...};U:NIL;U:NIL "
#endif
   HBTEST AFill( NIL )                    IS "E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:4:U:NIL;B:{||...};U:NIL;U:NIL "
#else
#ifndef __XPP__
   HBTEST AFill()                         IS "E 1 BASE 6004 Argument error (AFILL) OS:0 #:0 "
#endif
   HBTEST AFill( NIL )                    IS "E 1 BASE 6004 Argument error (AFILL) OS:0 #:0 A:1:U:NIL "
#endif
   HBTEST AFill( {} )                     IS "{.[0].}"
   HBTEST AFill( {}, 1 )                  IS "{.[0].}"
   HBTEST AFill( ErrorNew() )             IS "ERROR Object"
   HBTEST AFill( ErrorNew(), 1 )          IS "ERROR Object"
#ifndef __XPP__
   HBTEST ADel()                          IS NIL
   HBTEST ADel( NIL )                     IS NIL
   HBTEST ADel( { 1 } )                   IS "{.[1].}"
#endif
   HBTEST ADel( { 1 }, 0 )                IS "{.[1].}"
   HBTEST ADel( { 1 }, 100 )              IS "{.[1].}"
   HBTEST ADel( { 1 }, 1 )                IS "{.[1].}"
   HBTEST ADel( { 1 }, -1 )               IS "{.[1].}"
   HBTEST ADel( { 1 }, 0 )                IS "{.[1].}"
   HBTEST ADel( { 1 }, NIL )              IS "{.[1].}"
#ifndef __XPP__
   HBTEST ADel( ErrorNew() )              IS "ERROR Object"
#endif
   HBTEST ADel( ErrorNew(), 0 )           IS "ERROR Object"
   HBTEST ADel( ErrorNew(), 100 )         IS "ERROR Object"
   HBTEST ADel( ErrorNew(), 1 )           IS "ERROR Object"
   HBTEST ADel( ErrorNew(), -1 )          IS "ERROR Object"
   HBTEST ADel( ErrorNew(), 0 )           IS "ERROR Object"
   HBTEST ADel( ErrorNew(), NIL )         IS "ERROR Object"
#ifndef __XPP__
   HBTEST AIns()                          IS NIL
   HBTEST AIns( NIL )                     IS NIL
   HBTEST AIns( { 1 } )                   IS "{.[1].}"
#endif
   HBTEST AIns( { 1 }, 0 )                IS "{.[1].}"
   HBTEST AIns( { 1 }, 100 )              IS "{.[1].}"
   HBTEST AIns( { 1 }, 1 )                IS "{.[1].}"
   HBTEST AIns( { 1 }, -1 )               IS "{.[1].}"
   HBTEST AIns( { 1 }, 0 )                IS "{.[1].}"
   HBTEST AIns( { 1 }, NIL )              IS "{.[1].}"
#ifndef __XPP__
   HBTEST AIns( ErrorNew() )              IS "ERROR Object"
#endif
   HBTEST AIns( ErrorNew(), 0 )           IS "ERROR Object"
   HBTEST AIns( ErrorNew(), 100 )         IS "ERROR Object"
   HBTEST AIns( ErrorNew(), 1 )           IS "ERROR Object"
   HBTEST AIns( ErrorNew(), -1 )          IS "ERROR Object"
   HBTEST AIns( ErrorNew(), 0 )           IS "ERROR Object"
   HBTEST AIns( ErrorNew(), NIL )         IS "ERROR Object"
#ifndef __XPP__
   HBTEST ATail()                         IS NIL
#endif
   HBTEST ATail( NIL )                    IS NIL
   HBTEST ATail( "" )                     IS NIL
   HBTEST ATail( {} )                     IS NIL
   HBTEST ATail( { 1, 2 } )               IS 2
   HBTEST ATail( ErrorNew() )             IS NIL
#ifndef __XPP__
#ifdef HB_COMPAT_C53
   HBTEST ASize()                         IS "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 "
   HBTEST ASize( NIL )                    IS "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 ", "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:1:U:NIL "
   HBTEST ASize( {} )                     IS "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 ", "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:1:A:{.[0].} "
   HBTEST ASize( ErrorNew() )             IS "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 ", "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:1:O:ERROR Object "
#else
   HBTEST ASize()                         IS NIL
   HBTEST ASize( NIL )                    IS NIL
   HBTEST ASize( {} )                     IS NIL
   HBTEST ASize( ErrorNew() )             IS NIL
#endif
#endif
#ifdef HB_COMPAT_C53
   HBTEST ASize( NIL, 0 )                 IS "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 ", "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:2:U:NIL;N:0 "
   HBTEST ASize( NIL, 1 )                 IS "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 ", "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:2:U:NIL;N:1 "
   HBTEST ASize( NIL, -1 )                IS "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 ", "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:2:U:NIL;N:-1 "
#else
   HBTEST ASize( NIL, 0 )                 IS NIL
   HBTEST ASize( NIL, 1 )                 IS NIL
   HBTEST ASize( NIL, -1 )                IS NIL
#endif
   HBTEST ASize( {}, 0 )                  IS "{.[0].}"
   HBTEST ASize( ErrorNew(), 0 )          IS "ERROR Object"
   HBTEST ASize( {}, 1 )                  IS "{.[1].}"
   HBTEST ASize( { 1, 2 }, 1 )            IS "{.[1].}"
   HBTEST ASize( { 1, "AAAA" }, 1 )       IS "{.[1].}"
   HBTEST ASize( { "BBB", "AAAA" }, 0 )   IS "{.[0].}"
   HBTEST ASize( ErrorNew(), 1 )          IS "ERROR Object"
   HBTEST ASize( {}, -1 )                 IS "{.[0].}"
   HBTEST ASize( { 1 }, -1 )              IS "{.[0].}"
#ifdef __HARBOUR__
   HBTEST ASize( { 1 }, 5000 )            IS "{.[5000].}"
#else
   HBTEST ASize( { 1 }, 5000 )            IS "{.[1].}"
#endif
   HBTEST ASize( ErrorNew(), -1 )         IS "ERROR Object"
   HBTEST ASize( ErrorNew(), 100 )        IS "ERROR Object"
   HBTEST AAdd( NIL, NIL )                IS "E 1 BASE 1123 Argument error (AADD) OS:0 #:0 A:2:U:NIL;U:NIL F:S"
   HBTEST AAdd( {}, NIL )                 IS NIL
   HBTEST AAdd( {}, "A" )                 IS "A"
   HBTEST AAdd( ErrorNew(), NIL )         IS NIL
   HBTEST AAdd( ErrorNew(), "A" )         IS "A"
#ifndef __XPP__
   HBTEST Array()                         IS NIL
#endif
   HBTEST Array( 0 )                      IS "{.[0].}"
#ifdef __HARBOUR__
   HBTEST Array( 5000 )                   IS "{.[5000].}"
#else
   HBTEST Array( 5000 )                   IS "E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 "
#endif
   HBTEST Array( 1 )                      IS "{.[1].}"
   HBTEST Array( -1 )                     IS "E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 "
#ifdef __HARBOUR__

   #pragma -ko-
#endif
   HBTEST Array( 1, 0, -10 )              IS "E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 ", "E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 A:3:N:1;N:0;N:-10 "


[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/clsscope.prg. This test file tests object-oriented programming features

[Assistant]
#command  ? => OUTSTD(hb_eol())
#xtranslate QOUT(<x,...>) => OUTSTD(hb_eol(),<x>)

#include "hbclass.ch"

#xcommand MAKE_TEST(<obj>,<v>)                        ;
        =>  begin sequence                            ;;
               ? "      hVar:= ", <obj>:hVar:=<v>     ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      hVar   ", <obj>:hVar          ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      hrVar:=", <obj>:hrVar:=<v>    ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      hrVar  ", <obj>:hrVar         ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      pVar:= ", <obj>:pVar:=<v>     ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      pVar   ", <obj>:pVar          ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      prVar:=", <obj>:prVar:=<v>    ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      prVar  ", <obj>:prVar         ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      eVar:= ", <obj>:eVar:=<v>     ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      eVar   ", <obj>:eVar          ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      erVar:=", <obj>:erVar:=<v>    ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      erVar  ", <obj>:erVar         ;;
            end sequence

#xcommand MAKE_TESTBLOCK(<fn>,<o>,<v>)                                     ;
        =>  begin sequence                                                 ;;
               <fn>({| self | qout("      hVar:= ", ::hVar:=<v>)},<o>)     ;;
            end sequence                                                   ;;
            begin sequence                                                 ;;
               <fn>({| self | qout("      hrVar:=", ::hrVar:=<v>)},<o>)    ;;
            end sequence                                                   ;;
            begin sequence                                                 ;;
               <fn>({| self | qout("      pVar:= ", ::pVar:=<v>)},<o>)     ;;
            end sequence                                                   ;;
            begin sequence                                                 ;;
               <fn>({| self | qout("      prVar:=", ::prVar:=<v>)},<o>)    ;;
            end sequence                                                   ;;
            begin sequence                                                 ;;
               <fn>({| self | qout("      eVar:= ", ::eVar:=<v>)},<o>)     ;;
            end sequence                                                   ;;
            begin sequence                                                 ;;
               <fn>({| self | qout("      erVar:=", ::erVar:=<v>)},<o>)    ;;
            end sequence

#xcommand MAKE_TESTINLINE(<obj>,<mPref>)              ;
        =>  begin sequence                            ;;
               ? "      hVar:= ", <obj>:<mPref>hVar   ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      hrVar:=", <obj>:<mPref>hrVar  ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      pVar:= ", <obj>:<mPref>pVar   ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      prVar:=", <obj>:<mPref>prVar  ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      eVar:= ", <obj>:<mPref>eVar   ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      erVar:=", <obj>:<mPref>erVar  ;;
            end sequence

#xcommand MAKE_TESTINLINE0(<obj>[,<mPref>])           ;
        =>  begin sequence                            ;;
               ? "      hVar:= ", <obj>:b0hVar        ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      hrVar:=", <obj>:b0hrVar       ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      pVar:= ", <obj>:b0pVar        ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      prVar:=", <obj>:b0prVar       ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      eVar:= ", <obj>:b0eVar        ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      erVar:=", <obj>:b0erVar       ;;
            end sequence

#xcommand MAKE_TESTINLINE1(<obj>[,<mPref>])           ;
        =>  begin sequence                            ;;
               ? "      hVar:= ", <obj>:b1hVar        ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      hrVar:=", <obj>:b1hrVar       ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      pVar:= ", <obj>:b1pVar        ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      prVar:=", <obj>:b1prVar       ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      eVar:= ", <obj>:b1eVar        ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      erVar:=", <obj>:b1erVar       ;;
            end sequence

#xcommand MAKE_TESTINLINE2(<obj>[,<mPref>])           ;
        =>  begin sequence                            ;;
               ? "      hVar:= ", <obj>:b2hVar        ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      hrVar:=", <obj>:b2hrVar       ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      pVar:= ", <obj>:b2pVar        ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      prVar:=", <obj>:b2prVar       ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      eVar:= ", <obj>:b2eVar        ;;
            end sequence                              ;;
            begin sequence                            ;;
               ? "      erVar:=", <obj>:b2erVar       ;;
            end sequence

proc main()
LOCAL cbErr, self, o

? DATE(), TIME(), VERSION(), OS()
?

o:=clsX():new()
self:=cls2():new()
cbErr := errorBlock( {| oErr | errHandler( oErr ) } )

? "Class Access:"


[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 'hbodbc' (ODBC database connectivity): contrib/hbodbc/browse.prg. Provides functions: BrowseODBC, Skipped, ODBCFGet. Contains procedures: StatLine. This file handles database operations

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

FUNCTION BrowseODBC( nTop, nLeft, nBottom, nRight, oDataSource )

   LOCAL oBrw
   LOCAL cOldScreen
   LOCAL n, nOldCursor
   LOCAL nKey := 0
   LOCAL lExit := .F.
   LOCAL bAction
   LOCAL oColumn

   IF PCount() < 4
      nTop    := 1
      nLeft   := 0
      nBottom := MaxRow()
      nRight  := MaxCol()
   ENDIF

   nOldCursor := SetCursor( SC_NONE )
   cOldScreen := SaveScreen( nTop, nLeft, nBottom, nRight )

   hb_DispBox( nTop, nLeft, nBottom, nRight, HB_B_SINGLE_UNI )
   hb_DispOutAt( nTop + 1, nLeft + 1, Space( nRight - nLeft - 1 ) )

   oBrw := TBrowseNew( nTop + 2, nLeft + 1, nBottom - 1, nRight - 1 )

   oBrw:SkipBlock     := {| nRecs | Skipped( nRecs, oDataSource ) }
   oBrw:GoTopBlock    := {|| oDataSource:first() }
   oBrw:GoBottomBlock := {|| oDataSource:last() }

   oBrw:HeadSep := "-"

   FOR n := 1 TO Len( oDataSource:Fields )
      oColumn := TBColumn():New( oDataSource:Fields[ n ]:FieldName, ODBCFget( oDataSource:Fields[ n ]:FieldName, oDataSource ) )
      oBrw:AddColumn( oColumn )
   NEXT

   oBrw:Configure()
   oBrw:ForceStable()

   DO WHILE ! lExit

      DO WHILE .T.
         nKey := Inkey()
         IF oBrw:stabilize() .OR. nKey != 0
            EXIT
         ENDIF
      ENDDO

      IF nKey == 0

         oBrw:forceStable()
         Statline( oBrw, oDataSource )

         nKey := Inkey( 0 )

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

      DO CASE
      CASE nKey == K_ESC
         lExit := .T.

      CASE nKey == K_UP
         oBrw:Up()

      CASE nKey == K_DOWN
         oBrw:Down()

      CASE nKey == K_END
         oBrw:End()

      CASE nKey == K_HOME
         oBrw:Home()

      CASE nKey == K_LEFT
         oBrw:Left()

      CASE nKey == K_RIGHT
         oBrw:Right()

      CASE nKey == K_PGUP
         oBrw:PageUp()

      CASE nKey == K_PGDN
         oBrw:PageDown()

      CASE nKey == K_CTRL_PGUP
         oBrw:GoTop()

      CASE nKey == K_CTRL_PGDN
         oBrw:GoBottom()

      CASE nKey == K_CTRL_LEFT
         oBrw:panLeft()

      CASE nKey == K_CTRL_RIGHT
         oBrw:panRight()

      CASE nKey == K_CTRL_HOME
         oBrw:panHome()

      CASE nKey == K_CTRL_END
         oBrw:panEnd()

      ENDCASE
   ENDDO

   RestScreen( nTop, nLeft, nBottom, nRight, cOldScreen )
   SetCursor( nOldCursor )

   RETURN .T.

STATIC PROCEDURE StatLine( oBrw, oDataSource )

   LOCAL nTop   := oBrw:nTop - 1
   LOCAL nRight := oBrw:nRight

   hb_DispOutAt( nTop, nRight - 27, "Record " )

   IF oDataSource:LastRec() == 0
      hb_DispOutAt( nTop, nRight - 20, "<none>               " )
   ELSEIF oDataSource:RecNo() == oDataSource:LastRec() + 1
      hb_DispOutAt( nTop, nRight - 40, "         " )
      hb_DispOutAt( nTop, nRight - 20, "                <new>" )
   ELSE
      hb_DispOutAt( nTop, nRight - 20, PadR( hb_ntos( oDataSource:RecNo() ) + "/" + ;
         hb_ntos( oDataSource:LastRec() ), 16 ) + ;
         iif( oBrw:hitTop, "<bof>", "     " ) + ;
         iif( oBrw:hitBottom, "<eof>", "     " ) )
   ENDIF

   RETURN

STATIC FUNCTION Skipped( nRecs, oDataSource )

   LOCAL nSkipped := 0

   IF ! oDataSource:Eof()
      DO CASE
      CASE nRecs == 0

      CASE nRecs > 0
         DO WHILE nSkipped < nRecs
            IF ! oDataSource:Eof()
               oDataSource:next()
               IF oDataSource:Eof()
                  oDataSource:prior()
                  EXIT
               ENDIF
               nSkipped++
            ENDIF
         ENDDO
      CASE nRecs < 0
         DO WHILE nSkipped > nRecs
            IF ! oDataSource:Bof()
               oDataSource:prior()
               IF oDataSource:Bof()
                  EXIT
               ENDIF
               nSkipped--
            ENDIF
         ENDDO
      ENDCASE
   ENDIF

   RETURN nSkipped

STATIC FUNCTION ODBCFGet( cFieldName, oDataSource )

   IF HB_ISSTRING( cFieldName )

      RETURN {| x | iif( x == NIL, oDataSource:FieldByName( cFieldName ):value, NIL ) }
   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]
Write the following Harbour (xBase/Clipper) code:

Harbour Runtime Library file: src/rtl/text.prg. Contains procedures: __TextSave, __TextRestore. This file provides utility functions

[Assistant]
THREAD STATIC t_cFile
THREAD STATIC t_lOldPrinter
THREAD STATIC t_lOldExtra
THREAD STATIC t_cOldExtraFile

PROCEDURE __TextSave( cFile )

   t_cFile := cFile

   IF t_cFile == "PRINTER"
      t_lOldPrinter := Set( _SET_PRINTER, .T. )
   ELSE
      t_lOldExtra := Set( _SET_EXTRA, .T. )
      t_cOldExtraFile := Set( _SET_EXTRAFILE, cFile )
   ENDIF

   RETURN

PROCEDURE __TextRestore()

   IF t_cFile == "PRINTER"
      Set( _SET_PRINTER, t_lOldPrinter )
   ELSE
      Set( _SET_EXTRAFILE, t_cOldExtraFile )
      Set( _SET_EXTRA, t_lOldExtra )
   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]
Here is a Harbour (xBase/Clipper) implementation:

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

[Assistant]
MEMVAR p_cMyPubVar

STATIC s_bBlock1 := {|| Hello() }
STATIC s_bBlock2 := {|| p_cMyPubVar }

PROCEDURE Main()

   PUBLIC p_cMyPubVar := "Printed from a PUBLIC var from a codeblock assigned to a static variable."

   Eval( s_bBlock1 )
   ? Eval( s_bBlock2 )

   RETURN

FUNCTION Hello()

   ? "Printed from a codeblock assigned to a static variable."

   RETURN NIL