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

[Assistant]
#include "simpleio.ch"

PROCEDURE Main()

   ? hb_libName( NIL )
   ? hb_libName( "" )
   ? hb_libName( "name" )
   ? hb_libName( "name.ext" )
   ? hb_libName( "name." )
   ? hb_libName( "name.ext", NIL )
   ? hb_libName( "dir" + hb_ps() + "name.ext", NIL )
   ? hb_libName( "name.ext", "mydir" )
   ? hb_libName( "dir" + hb_ps() + "name.ext", "mydir" )
   ? hb_libName( "name.ext", "mydir" + hb_ps() )
   ? hb_libName( "dir" + hb_ps() + "name.ext", "mydir" + hb_ps() )

   RETURN


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

[User] Implement this Harbour module: Harbour test program: tests/dbf.prg. Contains procedures: Main. This file handles database operations

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

PROCEDURE Main()

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

   REQUEST DBFCDX

   dbCreate( "testdbf", aStruct, "DBFCDX", .T., "MYALIAS" )

   ? "[" + MYALIAS->MEMO1 + "]"
   ? "[" + MYALIAS->MEMO2 + "]"
   ? "-"
   MYALIAS->( dbAppend() )
   MYALIAS->MEMO1 := "Hello world!"
   MYALIAS->MEMO2 := "Harbour power"
   ? "[" + MYALIAS->MEMO1 + "]"
   ? "[" + MYALIAS->MEMO2 + "]"
   MYALIAS->( dbAppend() )
   MYALIAS->MEMO1 := "This is a test for field MEMO1."
   MYALIAS->MEMO2 := "This is a test for field MEMO2."
   ? "[" + MYALIAS->MEMO1 + "]"
   ? "[" + MYALIAS->MEMO2 + "]"
   MYALIAS->NUMERIC := 90
   MYALIAS->DOUBLE := 120.138
   ? "[" + Str( MYALIAS->DOUBLE ) + "]"
   ? "[" + Str( MYALIAS->NUMERIC ) + "]"

   ? ""
   ? "Press any key..."
   Inkey( 0 )

   ? ""
   ? "Append 50 records with memos..."
   FOR nI := 1 TO 50
      MYALIAS->( dbAppend() )
      MYALIAS->MEMO1 := "This is a very long string. " + ;
         "This may seem silly however strings like this are still " + ;
         "used. Not by good programmers though, but I've seen " + ;
         "stuff like this used for Copyright messages and other " + ;
         "long text. What is the point to all of this you'd say. " + ;
         "Well I am coming to the point right now, the constant " + ;
         "string is limited to 256 characters and this string is " + ;
         "a lot bigger. Do you get my drift ? If there is somebody " + ;
         "who has read this line upto the very end: Esto es un " + ;
         "sombrero grande ridiculo." + Chr( 13 ) + Chr( 10 ) + ;
         "/" + Chr( 13 ) + Chr( 10 ) + "[;-)" + Chr( 13 ) + Chr( 10 ) + ;
         "\"
   NEXT
   MYALIAS->( dbCommit() )

   ? "Records before ZAP:", MYALIAS->( LastRec() )
   ? "Size of files (data and memo):", Directory( "testdbf.dbf" )[ 1 ][ 2 ], ;
      Directory( "testdbf.fpt" )[ 1 ][ 2 ]
   MYALIAS->( __dbZap() )
   MYALIAS->( dbCommit() )
   ? "Records after ZAP:", MYALIAS->( LastRec() )
   ? "Size of files (data and memo):", Directory( "testdbf.dbf" )[ 1 ][ 2 ], ;
      Directory( "testdbf.fpt" )[ 1 ][ 2 ]
   ? "Value of fields MEMO1, MEMO2, DOUBLE and NUMERIC:"
   ? "[" + MYALIAS->MEMO1 + "]"
   ? "[" + MYALIAS->MEMO2 + "]"
   ? "[" + Str( MYALIAS->DOUBLE ) + "]"
   ? "[" + Str( MYALIAS->NUMERIC ) + "]"
   ? "Press any key..."
   Inkey( 0 )
   dbCloseAll()

   dbCreate( "testdbf", aStruct, , .T., "MYALIAS" )

   FOR nI := 1 TO 10
      MYALIAS->( dbAppend() )
      MYALIAS->NUMERIC := nI
      ? "Adding a record", nI
      IF nI == 3 .OR. nI == 7
         MYALIAS->( dbDelete() )
         ? "Deleting record", nI
      ENDIF
   NEXT
   MYALIAS->( dbCommit() )

   ? ""
   ? "With SET DELETED OFF"
   ? "Press any key..."
   Inkey( 0 )

   MYALIAS->( dbGoTop() )
   DO WHILE ! MYALIAS->( Eof() )
      ? MYALIAS->NUMERIC
      MYALIAS->( dbSkip() )
   ENDDO

   SET DELETED ON
   ? ""
   ? "With SET DELETED ON"
   ? "Press any key..."
   Inkey( 0 )

   MYALIAS->( dbGoTop() )
   DO WHILE ! MYALIAS->( Eof() )
      ? MYALIAS->NUMERIC
      MYALIAS->( dbSkip() )
   ENDDO

   ? ""
   ? "With SET DELETED ON"
   ? "and  SET FILTER TO MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8"
   ? "Press any key..."
   Inkey( 0 )

   MYALIAS->( dbSetFilter( {|| MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8 }, ;
      "MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8" ) )
   MYALIAS->( dbGoTop() )
   DO WHILE ! MYALIAS->( Eof() )
      ? MYALIAS->NUMERIC
      MYALIAS->( dbSkip() )
   ENDDO

   SET DELETED OFF
   ? ""
   ? "With SET DELETED OFF"
   ? "and  SET FILTER TO MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8"
   ? "Press any key..."
   Inkey( 0 )

   MYALIAS->( dbSetFilter( {|| MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8 }, ;
      "MYALIAS->NUMERIC > 2 .AND. MYALIAS->NUMERIC < 8" ) )
   MYALIAS->( dbGoTop() )
   DO WHILE ! MYALIAS->( Eof() )
      ? MYALIAS->NUMERIC
      MYALIAS->( dbSkip() )
   ENDDO

   ? "dbFilter() => " + dbFilter()
   ? ""

   ? "Testing __dbPack()"
   ? "Records before PACK:", MYALIAS->( LastRec() )
   ? "Size of files (data and memo):", Directory( "testdbf.dbf" )[ 1 ][ 2 ], ;
      Directory( "testdbf.dbt" )[ 1 ][ 2 ]
   SET FILTER TO
   MYALIAS->( __dbPack() )
   MYALIAS->( dbCommit() )
   ? "Records after PACK:", MYALIAS->( LastRec() )
   ? "Size of files (data and memo):", Directory( "testdbf.dbf" )[ 1 ][ 2 ], ;
      Directory( "testdbf.dbt" )[ 1 ][ 2 ]
   ? "Press any key..."
   Inkey( 0 )
   ? "Value of fields:"
   MYALIAS->( dbGoTop() )
   DO WHILE ! MYALIAS->( Eof() )
      ? MYALIAS->NUMERIC
      MYALIAS->( dbSkip() )
   ENDDO
   ? ""

   ? "Open test.dbf and LOCATE FOR TESTDBF->SALARY > 145000"
   ? "Press any key..."
   Inkey( 0 )
   dbUseArea( , , "test", "TESTDBF" )
   LOCATE for TESTDBF->SALARY > 145000
   DO WHILE TESTDBF->( Found() )
      ? TESTDBF->FIRST, TESTDBF->LAST, TESTDBF->SALARY
      CONTINUE
   ENDDO
   ? ""
   ? "LOCATE FOR TESTDBF->MARRIED .AND. TESTDBF->FIRST > 'S'"
   ? "Press any key..."
   Inkey( 0 )
   dbUseArea( , , "test", "TESTDBF" )
   LOCATE for TESTDBF->MARRIED .AND. TESTDBF->FIRST > 'S'
   DO WHILE TESTDBF->( Found() )
      ? TESTDBF->FIRST, TESTDBF->LAST, TESTDBF->MARRIED
      CONTINUE
   ENDDO

   dbCloseAll()
   hb_dbDrop( "testdbf",, "DBFCDX" )

   RETURN


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

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

[Assistant]
#require "hbnf"

PROCEDURE Main()

   LOCAL aNames := { ;
      "Adams", ;
      "Addams", ;
      "Atoms", ;
      "Adamson", ;
      "Cajun", ;
      "Cagen", ;
      "Cochy", ;
      "Cocci", ;
      "Smith", ;
      "Smythe", ;
      "Naylor", ;
      "Nailer", ;
      "Holberry", ;
      "Wholebary", ;
      "Jackson", ;
      "Jekksen", ;
      "The Source", ;
      "The Sores", ;
      "Jones", ;
      "Johns", ;
      "Lennon", ;
      "Lenin", ;
      "Fischer", ;
      "Fisher", ;
      "O'Donnell", ;
      "O Donald", ;
      "Pugh", ;
      "Pew", ;
      "Heimendinger", ;
      "Hymendinker", ;
      "Knight", ;
      "Nite", ;
      "Lamb", ;
      "Lamb Chops", ;
      "Stephens", ;
      "Stevens", ;
      "Neilson", ;
      "Nelson", ;
      "Tchaikovski", ;
      "Chikofski", ;
      "Caton", ;
      "Wright", ;
      "Write", ;
      "Right", ;
      "Manual", ;
      "Now", ;
      "Wheatabix", ;
      "Science", ;
      "Cinzano", ;
      "Lucy", ;
      "Reece", ;
      "Righetti", ;
      "Oppermann", ;
      "Bookkeeper", ;
      "McGill", ;
      "Magic", ;
      "McLean", ;
      "McLane", ;
      "Maclean", ;
      "Exxon" }

   Set( _SET_SCOREBOARD, .F. )
   SetColor( "W/B" )
   CLS

   AEval( aNames, ;
      {| cName, nElem | ;
      SetPos( _ftRow( nElem ), _ftCol( nElem ) ), ;
      QQOut( PadR( cName, 18, "." ) + ft_Metaph( cName ) ) ;
      } )

   SetPos( 21, 0 )

   RETURN

STATIC FUNCTION _ftRow( nElem )

   RETURN iif( nElem > 40, nElem - 40, iif( nElem > 20, nElem - 20, nElem ) )

STATIC FUNCTION _ftCol( nElem )

   RETURN iif( nElem > 40,  55, iif( nElem > 20, 28, 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/alias.prg. Provides functions: Test. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
MEMVAR m_privateVar
MEMVAR unknVar

PROCEDURE Main()

   LOCAL localVar
   STATIC s_staticVar
   FIELD fieldVar
   FIELD aliasedField IN aaa
   MEMVAR memvarVar
   PRIVATE m_privateVar

   ? m_privateVar
   ? memvarVar
   ? localVar
   ? s_staticVar
   ? fieldVar
   ? aliasedField
   ? unknVar

   ? 1->m_privateVar
   ? 1->memvarVar
   ? 1->localVar
   ? 1->s_staticVar
   ? 1->fieldVar
   ? 1->aliasedField
   ? 1->unknVar

   ? alias->m_privateVar
   ? alias->memvarVar
   ? alias->localVar
   ? alias->s_staticVar
   ? alias->fieldVar
   ? alias->aliasedField
   ? alias->unknVar

   ? ( localVar )->m_privateVar
   ? ( localVar )->memvarVar
   ? ( localVar )->localVar
   ? ( localVar )->s_staticVar
   ? ( localVar )->fieldVar
   ? ( localVar )->aliasedField
   ? ( localVar )->unknVar

   ? ( localVar )->( m_privateVar, memvarVar, localVar, s_staticVar, fieldVar, aliasedField, unknVar )
   ? alias->( m_privateVar, memvarVar, localVar, s_staticVar, fieldVar, aliasedField, unknVar )
   ? 2->( m_privateVar, memvarVar, localVar, s_staticVar, fieldVar, aliasedField, unknVar )
   ? ( localVar, 2 )->( m_privateVar, memvarVar, localVar, s_staticVar, fieldVar, aliasedField, unknVar )

   ? m_privateVar++
   ? memvarVar++
   ? localVar++
   ? s_staticVar++
   ? fieldVar++
   ? aliasedField++
   ? unknVar++

   ? 1->m_privateVar++
   ? 1->memvarVar++
   ? 1->localVar++
   ? 1->s_staticVar++
   ? 1->fieldVar++
   ? 1->aliasedField++
   ? 1->unknVar++

   ? alias->m_privateVar++
   ? alias->memvarVar++
   ? alias->localVar++
   ? alias->s_staticVar++
   ? alias->fieldVar++
   ? alias->aliasedField++
   ? alias->unknVar++

   ? ( localVar )->m_privateVar++
   ? ( localVar )->memvarVar++
   ? ( localVar )->localVar++
   ? ( localVar )->s_staticVar++
   ? ( localVar )->fieldVar++
   ? ( localVar )->aliasedField++
   ? ( localVar )->unknVar++

   ? m_privateVar  += m_privateVar
   ? memvarVar     += memvarVar
   ? localVar      += localVar
   ? s_staticVar   += s_staticVar
   ? fieldVar      += fieldVar
   ? aliasedField  += aliasedField
   ? unknVar       += unknVar

   ? 1->m_privateVar  += 1->m_privateVar
   ? 1->memvarVar     += 1->memvarVar
   ? 1->localVar      += 1->localVar
   ? 1->s_staticVar   += 1->s_staticVar
   ? 1->fieldVar      += 1->fieldVar
   ? 1->aliasedField  += 1->aliasedField
   ? 1->unknVar       += 1->unknVar

   ? alias->m_privateVar  += alias->m_privateVar
   ? alias->memvarVar     += alias->memvarVar
   ? alias->localVar      += alias->localVar
   ? alias->s_staticVar   += alias->s_staticVar
   ? alias->fieldVar      += alias->fieldVar
   ? alias->aliasedField  += alias->aliasedField
   ? alias->unknVar       += alias->unknVar

   ? ( localVar )->m_privateVar   += ( localVar )->m_privateVar
   ? ( localVar )->memvarVar      += ( localVar )->memvarVar
   ? ( localVar )->localVar       += ( localVar )->localVar
   ? ( localVar )->s_staticVar    += ( localVar )->s_staticVar
   ? ( localVar )->fieldVar       += ( localVar )->fieldVar
   ? ( localVar )->aliasedField   += ( localVar )->aliasedField
   ? ( localVar )->unknVar        += ( localVar )->unknVar

   ? ( localVar )->m_privateVar   += 2->m_privateVar
   ? ( localVar )->memvarVar      += 2->memvarVar
   ? ( localVar )->localVar       += 2->localVar
   ? ( localVar )->s_staticVar    += 2->s_staticVar
   ? ( localVar )->fieldVar       += 2->fieldVar
   ? ( localVar )->aliasedField   += 2->aliasedField
   ? ( localVar )->unknVar        += 2->unknVar

   ? alias->( aliasedField, MEMVAR->m_privateVar, 1->( Test( 2->fieldVar ) ) )

   MEMVAR->m_privateVar := 0
   M->localVar := 1
   MEMVA->fieldVar := 2

   FIELD->fieldVar := 0
   FIEL->aliasedFieldVar := 1

   RETURN

STATIC FUNCTION Test()
   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 Harbour functions: ft_AAvg. Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/aavg.prg. Provides functions: ft_AAvg. This file provides legacy compatibility functions

[Assistant]
#define FORCE_BETWEEN( x, y, z )         ( y := Max( Min( y, z ), x ) )

FUNCTION ft_AAvg( aArray, nStartIndex, nEndIndex )

   __defaultNIL( @nStartIndex, 1 )
   __defaultNIL( @nEndIndex, Len( aArray ) )

   FORCE_BETWEEN( 1, nEndIndex,   Len( aArray ) )
   FORCE_BETWEEN( 1, nStartIndex, nEndIndex )

   RETURN iif( ! HB_ISARRAY( aArray ) .OR. Empty( aArray ), ;
      0, ;
      ft_ASum( aArray, nStartIndex, nEndIndex ) / ;
      ( nEndIndex - nStartIndex + 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] Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/acctadj.prg. Provides functions: ft_AcctAdj. This file provides legacy compatibility functions

[Assistant]
FUNCTION ft_AcctAdj( dGivenDate, lIsEnd )

   LOCAL nTemp

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

   hb_default( @lIsEnd, .F. )

   nTemp := ft_DayToBoW( dGivenDate )

   IF nTemp > ( 2 + iif( lIsEnd, 0, 1 ) )
      dGivenDate += 7 - nTemp
   ELSE
      dGivenDate -= nTemp
   ENDIF

   IF lIsEnd
      dGivenDate--
   ENDIF

   RETURN dGivenDate


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

[User] Implement this Harbour module: Harbour test program: tests/gtcolors.prg. Contains procedures: Main. This test file exercises basic Harbour language features

[Assistant]
PROCEDURE Main( xBlink )

   LOCAL bg, fg, n

   CLS
   ?
   ? OS(), Version(), Date(), Time()
   ? "GT" + hb_gtVersion(), hb_gtVersion( 1 )
   ?

   SetBlink( Empty( xBlink ) )
   FOR bg := 0 TO 15
      FOR fg := 0 TO 15
         n := bg
         @ 5 + bg, 5 + fg * 4 SAY "[" + hb_NumToHex( n, 2 ) + "]" COLOR hb_NToColor( n )
      NEXT
   NEXT
   ?
   ?
   Inkey( 0 )

   RETURN


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

[User] Implement this Harbour module: Harbour header file: include/hb.ch. Defines constants: HB_CH_. Defines keyboard input constants

[Assistant]
#ifndef HB_CH_
#define HB_CH_

#include "color.ch"
#include "dbstruct.ch"
#include "directry.ch"
#include "fileio.ch"
#include "hbgtinfo.ch"
#include "hbhash.ch"
#include "hbserial.ch"
#include "hbver.ch"
#include "inkey.ch"
#include "setcurs.ch"

#endif


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

[User] Generate Harbour code for: Harbour header file: extras/gfspell/spell.ch. Defines 10 constants including: COMMON_WORDS, CACHE_WORDS, DICTIONARY_PATH, DICTIONARY_NAME, AUXILIARY_DICTIONARY. Defines keyboard input constants

[Assistant]
#define COMMON_WORDS                 1
#define CACHE_WORDS                  2
#define DICTIONARY_PATH              3
#define DICTIONARY_NAME              4
#define AUXILIARY_DICTIONARY         5
#define EXTRA_CODE_BLOCK             6
#define ADD_SUFFIXES                 7
#define ADD_PREFIXES                 8
#define ADD_PLURALS                  9
#define SORT_SUGGESTIONS             10
#define SUGGEST_PREFERENCE           11
#define MINIMUM_WORD_LENGTH          12
#define METAPHONE_SIZE               13
#define MAX_DIFFERENCE               14
#define THESAURUS_NAME               15
#define CHECK_FOR_RUNONS             16


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

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

Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/getinfo.prg. Provides 7 functions including: SaveGets, RestGets, CountGets, CurrentGet, GetFldRow. This file provides legacy compatibility functions

[Assistant]
MEMVAR GetList

FUNCTION SaveGets()

   LOCAL aGetList := GetList

   GetList := {}

   RETURN aGetList

FUNCTION RestGets( aGetList )
   RETURN ( GetList := aGetList ) != NIL

FUNCTION CountGets()
   RETURN Len( GetList )

FUNCTION CurrentGet()

   LOCAL oActive := GetActive()

   RETURN AScan( GetList, {| oGet | oGet == oActive } )

FUNCTION GetFldRow( nField )

   LOCAL oGet

   IF ! HB_ISNUMERIC( nField )
      oGet := GetActive()
   ELSEIF nField >= 1 .AND. nField <= Len( GetList )
      oGet := GetList[ nField ]
   ENDIF

   RETURN iif( oGet != NIL, oGet:Row, -1 )

FUNCTION GetFldCol( nField )

   LOCAL oGet

   IF ! HB_ISNUMERIC( nField )
      oGet := GetActive()
   ELSEIF nField >= 1 .AND. nField <= Len( GetList )
      oGet := GetList[ nField ]
   ENDIF

   RETURN iif( oGet != NIL, oGet:Col, -1 )

FUNCTION GetFldVar( nField )

   LOCAL oGet

   IF ! HB_ISNUMERIC( nField )
      oGet := GetActive()
   ELSEIF nField >= 1 .AND. nField <= Len( GetList )
      oGet := GetList[ nField ]
   ENDIF

   RETURN iif( oGet != NIL, oGet:Name, -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 contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/ftp_dl.prg. Contains procedures: Main. This file provides network protocol implementations

[Assistant]
#require "hbtip"

PROCEDURE Main( cURL, ... )

   LOCAL lRetVal := .T.

   LOCAL aFiles, cFile
   LOCAL oFTP, oURL

   IF ! Empty( aFiles := { ... } )

      hb_default( @cURL, "ftp:

      oURL := TUrl():New( cURL )

      oFTP := TIPClientFTP():New( oURL, .T. )
      oFTP:nConnTimeout := 20000
      oFTP:bUsePasv := .T.

      IF oFTP:Open( cURL )
         FOR EACH cFile IN aFiles
            ? "Filename:", cFile
            IF ! oFtp:DownloadFile( cFile )
               lRetVal := .F.
               EXIT
            ENDIF
         NEXT
         oFTP:Close()
      ELSE
         ? "Could not connect to FTP server", oURL:cServer
         IF oFTP:SocketCon == NIL
            ? "Connection not initialized"
         ELSEIF hb_inetErrorCode( oFTP:SocketCon ) == 0
            ? "Server response:", oFTP:cReply
         ELSE
            ? "Error in connection:", hb_inetErrorDesc( oFTP:SocketCon )
         ENDIF
         lRetVal := .F.
      ENDIF
   ENDIF

   ErrorLevel( iif( lRetVal, 0, 1 ) )

   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 'gtwvg' (): contrib/gtwvg/sle.prg. Defines classes: WvgSLE. This file provides platform-specific functionality

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

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

CREATE CLASS WvgSLE INHERIT WvgWindow, WvgDataRef

   VAR    align                                 INIT WVGSLE_LEFT
   VAR    autoKeyboard                          INIT .T.
   VAR    autoSize                              INIT .F.
   VAR    autoTab                               INIT .F.
   VAR    border                                INIT .T.
   VAR    bufferLength                          INIT 32
   VAR    editable                              INIT .T.
   VAR    unReadable                            INIT .F.

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

   METHOD clear()
   METHOD copyMarked()
   METHOD cutMarked()
   METHOD delMarked()                           VIRTUAL
   METHOD editBuffer()                          VIRTUAL
   METHOD pasteMarked()                         VIRTUAL
   METHOD queryFirstChar()                      VIRTUAL
   METHOD queryMarked()                         VIRTUAL
   METHOD setFirstChar()                        VIRTUAL
   METHOD setMarked()                           VIRTUAL

   METHOD setInsertMode( lInsertMode )          VIRTUAL

   VAR    sl_hScroll
   ACCESS hScroll                               INLINE ::sl_hScroll
   ASSIGN hScroll( bBlock )                     INLINE ::sl_hScroll := bBlock

   VAR    sl_typeOut
   ACCESS typeOut                               INLINE ::sl_typeOut
   ASSIGN typeOut( bBlock )                     INLINE ::sl_typeOut := bBlock

   METHOD changed( lChanged )                   SETGET

   VAR    sl_returnPressed
   METHOD returnPressed( bReturnPressed )       SETGET

ENDCLASS

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

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

   ::style       := WS_CHILD
   ::className   := "EDIT"
   ::objType     := objTypeSLE

   RETURN Self

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

   LOCAL es_ := { ES_LEFT, ES_RIGHT, ES_CENTER }

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

   ::style += es_[ ::align ]
   ::style += ES_AUTOHSCROLL

   IF ::tabStop
      ::style += WS_TABSTOP
   ENDIF
   IF ::autoSize

   ENDIF
   IF ! ::editable
      ::style += ES_READONLY
   ENDIF
   IF ::unReadable
      ::style += ES_PASSWORD
   ENDIF
   IF ::border
      ::style += WS_BORDER
   ENDIF

   ::oParent:addChild( Self )

   ::createControl()

   ::SetWindowProcCallback()

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

   IF HB_ISOBJECT( ::datalink )
      Eval( ::datalink )
   ENDIF

   ::sendMessage( EM_SETLIMITTEXT, ::bufferLength )

   RETURN Self

METHOD WvgSLE:handleEvent( nMessage, aNM )

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

   CASE nMessage == HB_GTE_COMMAND
      DO CASE
      CASE aNM[ NMH_code ] == EN_CHANGE

      CASE aNM[ NMH_code ] == EN_UPDATE

      CASE aNM[ NMH_code ] == EN_MAXTEXT

      CASE aNM[ NMH_code ] == EN_KILLFOCUS
         IF HB_ISBLOCK( ::sl_killInputFocus )
            Eval( ::sl_killInputFocus, , , Self )
         ENDIF

      CASE aNM[ NMH_code ] == EN_SETFOCUS
         IF HB_ISBLOCK( ::sl_setInputFocus )
            Eval( ::sl_setInputFocus, , , Self )
         ENDIF

      ENDCASE

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

   CASE nMessage == HB_GTE_ANY
      DO CASE
      CASE aNM[ NMH_code ] == WM_KILLFOCUS
         IF HB_ISBLOCK( ::sl_killInputFocus )
            Eval( ::sl_killInputFocus, , , Self )
         ENDIF

      CASE aNM[ NMH_code ] == WM_SETFOCUS
         IF HB_ISBLOCK( ::sl_setInputFocus )
            Eval( ::sl_setInputFocus, , , Self )
         ENDIF

      CASE aNM[ NMH_code ] == WM_KEYDOWN
         DO CASE
         CASE aNM[ 2 ] == K_ENTER
            IF ::isParentCrt()
               ::oParent:setFocus()
            ENDIF
            IF HB_ISBLOCK( ::sl_returnPressed )
               Eval( ::sl_returnPressed, , , Self )
            ENDIF
         CASE aNM[ 2 ] == VK_TAB
            IF ::isParentCrt()
               ::oParent:setFocus()
               RETURN EVENT_HANDELLED
            ENDIF
         CASE aNM[ 2 ] == 65

         ENDCASE

      ENDCASE

   ENDCASE

   RETURN EVENT_UNHANDELLED

METHOD PROCEDURE WvgSLE:destroy()

   ::wvgWindow:destroy()

   RETURN

METHOD WvgSLE:changed( lChanged )

   LOCAL lChg := ::sendMessage( EM_GETMODIFY, 0, 0 )

   IF HB_ISLOGICAL( lChanged )
      ::sendMessage( EM_SETMODIFY, iif( lChanged, 0, 1 ), 0 )
   ENDIF

   RETURN lChg

METHOD WvgSLE:clear()

   LOCAL cText := ::getData()

   ::setData( "" )

   RETURN Len( cText )

METHOD WvgSLE:copyMarked()

   LOCAL n, nB, nE

   n := ::sendMessage( EM_GETSEL )
   nB := wvg_LOWORD( n )
   nE := wvg_HIWORD( n )

   IF ( n := nE - nB ) > 0
      wvt_SetClipboard( SubStr( ::getData(), nB, n ) )
   ENDIF

   RETURN n

METHOD WvgSLE:cutMarked()

   LOCAL n, nB, nE, cText

   n := ::sendMessage( EM_GETSEL )
   nB := wvg_LOWORD( n )
   nE := wvg_HIWORD( n )

   IF ( n := nE - nB ) > 0
      cText := ::getData()
      ::setData( SubStr( cText, 1, nB - 1 ) + SubStr( cText, nE ) )
   ENDIF

   RETURN n

METHOD WvgSLE:returnPressed( bReturnPressed )

   IF HB_ISBLOCK( bReturnPressed )
      ::sl_returnPressed := bReturnPressed
   ELSEIF HB_ISBLOCK( ::sl_returnPressed )
      Eval( ::sl_returnPressed, , , Self )
   ENDIF

   RETURN Self


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

[User] Write a Harbour program with procedures: Main. Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/ftp_adv.prg. Contains procedures: Main. This file provides network protocol implementations

[Assistant]
#require "hbtip"

#include "directry.ch"

PROCEDURE Main( cURL )

   LOCAL oFTP, oURL, aFile

   IF Empty( oURL := TUrl():New( cURL ) )
      ? "Invalid URL", cURL
      RETURN
   ENDIF

   IF ! oURL:cProto == "ftp"
      ? "This is a 'DELE' test for FTP."
      ? "Use an FTP address with a file that you can delete."
      RETURN
   ENDIF

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

   oFTP := TIPClientFTP():New( oURL )
   oFTP:nConnTimeout := 20000
   ? "Connecting with", oURL:cServer
   IF oFTP:Open( cURL )
      ? "Connection established"
      ? "File listing"
      FOR EACH aFile IN oFTP:ListFiles()
         IF aFile:__enumIndex() > 10
            ? "Skipping the rest..."
            EXIT
         ENDIF
         ? aFile[ F_DATE ], Str( aFile[ F_SIZE ], 10 ), aFile[ F_NAME ]
      NEXT
      IF oFTP:CWD( oURL:cPath )
         ? "CWD success"
         IF ! Empty( oURL:cFile )
            ? "Deleting", oURL:cPath
            IF oFTP:Dele( oURL:cFile )
               ? "DELE success"
            ELSE
               ? "DELE failure (server reply:", oFTP:cReply + ")"
            ENDIF
         ENDIF
      ELSE
         ? "CWD failure (server reply:", oFTP:cReply + ")"
      ENDIF

      oFTP:Close()
   ELSE
      ? "Could not connect with", oURL:cServer
      IF oFTP:SocketCon == NIL
         ? "Connection not initiated"
      ELSEIF hb_inetErrorCode( oFTP:SocketCon ) == 0
         ? "Server replied:", oFTP:cReply
      ELSE
         ? "Error in connection:", hb_inetErrorDesc( oFTP:SocketCon )
      ENDIF
   ENDIF

   ? "Done"

   RETURN


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

[User] Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/aredit.prg. Provides functions: TestGet. Contains procedures: Main. This file provides legacy compatibility functions

[Assistant]
#require "hbnf"

#include "inkey.ch"

PROCEDURE Main()

   LOCAL i, ar[ 3, 26 ], aBlocks[ 3 ], aHeadings, nElem := 1, bGetFunc, cRet

   FOR i := 1 TO 26
      ar[ 1, i ] := i
      ar[ 2, i ] := Chr( Asc( "A" ) + i - 1 )
      ar[ 3, i ] := Chr( Asc( "Z" ) - i + 1 )
   NEXT

   aHeadings  := { "Numbers", "Letters", "Reverse" }

   aBlocks[ 1 ] := {|| Str( ar[ 1, nElem ], 2 ) }
   aBlocks[ 2 ] := {|| ar[ 2, nElem ] }
   aBlocks[ 3 ] := {|| ar[ 3, nElem ] }

   bGetFunc   := {| b, ar, nDim, nElem | TestGet( b, ar, nDim, nElem ) }

   SET SCOREBOARD OFF
   SetColor( "W/N" )
   CLS
   @ 21, 4 SAY "Use Cursor Keys To Move Between Fields, <F7> = Delete Row, <F8> = Add Row"
   @ 22, 7 SAY "<ESC> = Quit Array Edit, <Enter> or <Any Other Key> Edits Element"
   SetColor( "N/W, W/N, , , W/N" )
   cRet := ft_ArEdit( 3, 5, 18, 75, ar, @nElem, aHeadings, aBlocks, bGetFunc )
   SetColor( "W/N" )
   CLS
   ? cRet
   ? "LastKey() = ESC:", LastKey() == K_ESC

   RETURN

FUNCTION TestGet( b, ar, nDim, nElem )

   LOCAL GetList   := {}
   LOCAL nRow      := Row()
   LOCAL nCol      := Col()
   LOCAL cSaveScrn := SaveScreen( 21, 0, 22, MaxCol() )
   LOCAL cOldColor := SetColor( "W/N" )

   @ 21, 0 CLEAR TO 22, MaxCol()
   @ 21, 29 SAY "Editing Array Element"
   SetColor( cOldColor )
   DO CASE
   CASE nDim == 1
      @ nRow, nCol GET ar[ 1, nElem ] PICTURE "99"
      READ
      b:refreshAll()
   CASE nDim == 2
      @ nRow, nCol GET ar[ 2, nElem ] PICTURE "!"
      READ
      b:refreshAll()
   CASE nDim == 3
      @ nRow, nCol GET ar[ 3, nElem ] PICTURE "!"
      READ
      b:refreshAll()
   ENDCASE
   RestScreen( 21, 0, 22, MaxCol(), cSaveScrn )
   @ nRow, nCol SAY ""

   RETURN .T.


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

[User] Create Harbour preprocessor definitions: Harbour Runtime Library file: src/rtl/hbdoc.prg. Provides 7 functions including: __hbdoc_FromSource, __hbdoc_DirLastModified, __hbdoc_LoadDir, __hbdoc_ToSource, __hbdoc_FilterOut. Contains procedures: __hbdoc__read_langdir, __hbdoc__read_file, __hbdoc__read_stream. This file provides utility functions

[Assistant]
#include "directry.ch"
#include "fileio.ch"
#include "hbserial.ch"

#define _HBDOC_SRC_SUBDIR       "doc"
#define _HBDOC_SRC_EXT          ".txt"

#define _HBDOC_ADD_MSG( a, m )  IF HB_ISARRAY( a ); AAdd( a, m ); ENDIF

REQUEST hb_ZCompress

FUNCTION __hbdoc_FromSource( cFile, aErrMsg )

   LOCAL aEntry := {}

   IF HB_ISSTRING( cFile )
      __hbdoc__read_stream( aEntry, cFile, "(stream)",, aErrMsg )
   ENDIF

   RETURN aEntry

FUNCTION __hbdoc_DirLastModified( cDir )

   LOCAL aFile

   LOCAL cDocDir
   LOCAL aDocFile
   LOCAL tDoc

   LOCAL tLast := 0d0

   IF HB_ISSTRING( cDir )

      cDir := hb_DirSepAdd( cDir )

      IF hb_DirExists( cDir + _HBDOC_SRC_SUBDIR )

         FOR EACH aFile IN Directory( cDir + _HBDOC_SRC_SUBDIR + hb_ps() + hb_osFileMask(), "D" )
            IF "D" $ aFile[ F_ATTR ] .AND. ;
               !( aFile[ F_NAME ] == "." ) .AND. ;
               !( aFile[ F_NAME ] == ".." )

               cDocDir := cDir + _HBDOC_SRC_SUBDIR + hb_ps() + aFile[ F_NAME ]

               FOR EACH aDocFile IN Directory( cDocDir + hb_ps() + "*" + _HBDOC_SRC_EXT )
                  IF hb_FGetDateTime( cDocDir + hb_ps() + aDocFile[ F_NAME ], @tDoc ) .AND. ;
                     tLast < tDoc
                     tLast := tDoc
                  ENDIF
               NEXT
            ENDIF
         NEXT
      ENDIF
   ENDIF

   RETURN tLast

FUNCTION __hbdoc_LoadDir( cDir, cName, aErrMsg )

   LOCAL hMeta
   LOCAL nCount
   LOCAL aFile
   LOCAL aEntry

   IF HB_ISSTRING( cDir )

      cDir := hb_DirSepAdd( cDir )

      IF hb_DirExists( cDir + _HBDOC_SRC_SUBDIR )

         aEntry := {}
         hMeta := { => }

         IF HB_ISSTRING( cName )
            hMeta[ "_COMPONENT" ] := cName
         ENDIF

         nCount := 0
         FOR EACH aFile IN Directory( cDir + _HBDOC_SRC_SUBDIR + hb_ps() + hb_osFileMask(), "D" )
            IF "D" $ aFile[ F_ATTR ] .AND. ;
               !( aFile[ F_NAME ] == "." ) .AND. ;
               !( aFile[ F_NAME ] == ".." )

               __hbdoc__read_langdir( aEntry, cDir + _HBDOC_SRC_SUBDIR + hb_ps() + aFile[ F_NAME ], hMeta, aErrMsg )
               ++nCount
            ENDIF
         NEXT

         IF nCount == 0
            _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: Component (%1$s) has no language subdirs", cDir ) )
         ENDIF
      ENDIF
   ENDIF

   RETURN aEntry

STATIC PROCEDURE __hbdoc__read_langdir( aEntry, cDir, hMeta, aErrMsg )

   LOCAL aFile
   LOCAL nCount

   hMeta[ "_LANG" ] := hb_FNameName( hb_DirSepDel( cDir ) )

   nCount := 0
   FOR EACH aFile IN Directory( cDir + hb_ps() + "*" + _HBDOC_SRC_EXT )
      __hbdoc__read_file( aEntry, cDir + hb_ps() + aFile[ F_NAME ], hMeta, aErrMsg )
      ++nCount
   NEXT

   IF nCount == 0
      _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: Component (%1$s) has no documentation files", cDir ) )
   ENDIF

   RETURN

STATIC PROCEDURE __hbdoc__read_file( aEntry, cFileName, hMeta, aErrMsg )

   LOCAL aFilenameTemplateMap := { ;
      "FUNCTION"   => "func_"  , ;
      "C FUNCTION" => "cfunc_" , ;
      "CLASS"      => "class_" , ;
      "COMMAND"    => "cmd_"   , ;
      "PP"         => "pp_"    }

   LOCAL tmp

   IF "TEMPLATE" $ hMeta
      hb_HDel( hMeta, "TEMPLATE" )
   ENDIF

   FOR EACH tmp IN aFilenameTemplateMap
      IF hb_LeftEqI( cFileName, tmp )
         hMeta[ "TEMPLATE" ] := tmp:__enumKey()
      ENDIF
   NEXT

   hMeta[ "_DOCSOURCE" ] := cFileName

   __hbdoc__read_stream( aEntry, MemoRead( cFileName ), cFileName, hMeta, aErrMsg )

   RETURN

STATIC PROCEDURE __hbdoc__read_stream( aEntry, cFile, cFileName, hMeta, aErrMsg )

   LOCAL hEntry := NIL
   LOCAL cLine
   LOCAL cSection
   LOCAL tmp
   LOCAL nLine
   LOCAL nStartCol

   cFile := StrTran( cFile, Chr( 13 ) )
   cFile := StrTran( cFile, Chr( 9 ), " " )

   nLine := 0
   FOR EACH cLine IN hb_ATokens( cFile, Chr( 10 ) )

      cLine := SubStr( cLine, 4 )
      ++nLine

      SWITCH AllTrim( cLine )
      CASE "$DOC$"
         IF hEntry != NIL
            _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$d: $DOC$ without $END$", cFileName, nLine ) )
         ELSEIF ! Empty( hEntry )
            AAdd( aEntry, hEntry )
         ENDIF
         hEntry := { => }
         IF HB_ISHASH( hMeta )
            FOR EACH tmp IN hMeta
               hEntry[ tmp:__enumKey() ] := tmp
            NEXT
         ENDIF
         EXIT
      CASE "$END$"
         IF hEntry == NIL
            _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$d: $END$ without $DOC$", cFileName, nLine ) )
         ELSEIF ! Empty( hEntry )
            AAdd( aEntry, hEntry )
         ENDIF
         hEntry := NIL
         EXIT
      OTHERWISE
         IF hEntry == NIL

         ELSEIF Left( LTrim( cLine ), 1 ) == "$" .AND. Right( RTrim( cLine ), 1 ) == "$"
            cLine := AllTrim( cLine )
            cSection := SubStr( cLine, 2, Len( cLine ) - 2 )
            IF cSection $ hEntry
               _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$d: Duplicate sections inside the same entry", cFileName, nLine ) )
            ELSE
               hEntry[ cSection ] := ""
            ENDIF
         ELSEIF ! Empty( cSection )
            IF Empty( hEntry[ cSection ] )

               nStartCol := Len( cLine ) - Len( LTrim( cLine ) ) + 1
            ELSE
               hEntry[ cSection ] += Chr( 10 )
            ENDIF
            hEntry[ cSection ] += SubStr( cLine, nStartCol )
         ELSEIF ! Empty( cLine )
            _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$d: Content outside section", cFileName, nLine ) )
         ENDIF
      ENDSWITCH
   NEXT

   IF hEntry != NIL
      _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$d: $DOC$ without $END$", cFileName, nLine ) )
   ENDIF

   RETURN

FUNCTION __hbdoc_ToSource( aEntry )

   LOCAL cSource := ""
   LOCAL hEntry
   LOCAL item
   LOCAL cLine
   LOCAL cLineOut

   IF HB_ISARRAY( aEntry )
      FOR EACH hEntry IN aEntry
         cSource += hb_eol()
         cSource += "" + hb_eol()
      NEXT
   ENDIF

   RETURN cSource

FUNCTION __hbdoc_FilterOut( cFile )

   LOCAL lEntry := .F.
   LOCAL cLine
   LOCAL cOK := ""
   LOCAL nToSkip := 0
   LOCAL nEmpty := 0

   cFile := StrTran( cFile, Chr( 13 ) )
   cFile := StrTran( cFile, Chr( 9 ), " " )

   FOR EACH cLine IN hb_ATokens( cFile, Chr( 10 ) )

      SWITCH AllTrim( SubStr( cLine, 4 ) )
      CASE "$DOC$"
         lEntry := .T.
         EXIT
      CASE "$END$"
         lEntry := .F.
         nToSkip := 1
         EXIT
      OTHERWISE
         IF ! lEntry
            IF nToSkip > 0
               nToSkip--
            ELSE
               IF Empty( cLine )
                  nEmpty++
               ELSE
                  nEmpty := 0
               ENDIF
               IF nEmpty < 2
                  cOK += cLine
                  IF ! cLine:__enumIsLast()
                     cOK += hb_eol()
                  ENDIF
               ENDIF
            ENDIF
         ENDIF
      ENDSWITCH
   NEXT

   RETURN cOK

#define _HBDOC_EXT       ".hbd"

#define _HBDOC_SIG_LEN   6
#define _HBDOC_SIGNATURE ( ;
   hb_BChar( 0xC0 ) + ;
   hb_BChar( 0x48 ) + ;
   hb_BChar( 0x42 ) + ;
   hb_BChar( 0x44 ) + ;
   hb_BChar( 0x01 ) + ;
   hb_BChar( 0x00 ) )

FUNCTION __hbdoc_SaveHBD( cFileName, aEntry )

   LOCAL fhnd

   IF HB_ISSTRING( cFileName ) .AND. ;
      HB_ISARRAY( aEntry )

      IF Set( _SET_DEFEXTENSIONS )
         cFileName := hb_FNameExtSetDef( cFileName, _HBDOC_EXT )
      ENDIF

      IF ( fhnd := hb_FCreate( cFileName,, FO_CREAT + FO_TRUNC + FO_READWRITE + FO_EXCLUSIVE ) ) != F_ERROR
         FWrite( fhnd, _HBDOC_SIGNATURE )
         FWrite( fhnd, hb_Serialize( aEntry, HB_SERIALIZE_COMPRESS ) )
         FClose( fhnd )
         RETURN .T.
      ENDIF
   ENDIF

   RETURN .F.

FUNCTION __hbdoc_LoadHBD( cFileName )

   LOCAL fhnd
   LOCAL aEntry := NIL

   LOCAL cBuffer

   IF HB_ISSTRING( cFileName )

      IF Set( _SET_DEFEXTENSIONS )


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

[User] Implement the following Harbour classes: win_BMP. Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/win_tbmp.prg. Defines classes: win_BMP. This file provides platform-specific functionality

[Assistant]
#include "hbclass.ch"

#include "hbwin.ch"

CREATE CLASS win_BMP

   EXPORTED:

   METHOD New()
   METHOD LoadFile( cFileName, aDimXY )
   METHOD Create()
   METHOD Destroy()
   METHOD IsSupported( oPrn,  nError )
   METHOD Draw( oPrn, aRectangle,  nError )

   VAR Type     INIT 0
   VAR DimXY    INIT { 0, 0 }
   VAR Rect     INIT { 0, 0, 0, 0 }

   VAR BitMap   INIT ""
   VAR FileName INIT ""

ENDCLASS

METHOD New() CLASS win_BMP
   RETURN Self

METHOD LoadFile( cFileName, aDimXY ) CLASS win_BMP

   ::FileName := cFileName
   ::Bitmap := win_LoadBitmapFile( ::FileName )
   IF Empty( ::Bitmap )
      ::Type := 0
      ::DimXY := { 0, 0 }
   ELSE
      ::Type := win_bitmapType( ::Bitmap )
      IF HB_ISARRAY( aDimXY )
         ::DimXY := aDimXY
      ELSEIF ! win_bitmapDimensions( ::Bitmap, @::DimXY[ 1 ], @::DimXY[ 2 ] )
         ::DimXY := { 1, 1 }
      ENDIF
   ENDIF

   RETURN ::Type != HB_WIN_BITMAP_UNKNOWN

METHOD Create() CLASS win_BMP
   RETURN Self

METHOD Destroy() CLASS win_BMP
   RETURN NIL

METHOD IsSupported( oPrn,  nError ) CLASS win_BMP
   RETURN ( nError := win_bitmapIsSupported( oPrn:hPrinterDc, ::Bitmap ) ) == 0

METHOD Draw( oPrn, aRectangle,  nError ) CLASS win_BMP

   IF HB_ISARRAY( aRectangle )
      ::Rect := aRectangle
   ENDIF

   RETURN iif( ::IsSupported( oPrn, @nError ), oPrn:DrawBitMap( Self ), .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]
Write the following Harbour (xBase/Clipper) code:

Header file for contribution module 'gtwvg': contrib/gtwvg/wvtwin.ch. Defines 10 constants including: _WVGWIN_CH, TOOLBARCLASSNAME, STATUSCLASSNAME, TB_ADDBITMAP, TB_SAVERESTOREA. Declares 1 preprocessor translations. Defines color and display constants

[Assistant]
#ifndef _WVGWIN_CH
#define _WVGWIN_CH

#xtranslate MAKELONG( <nLow>, <nHigh> )   => ( ( <nLow> ) + ( <nHigh> )
#define TOOLBARCLASSNAME                          "ToolbarWindow32"
#define STATUSCLASSNAME                           "msctls_statusbar32"

#define TB_ADDBITMAP                              ( WM_USER + 19 )
#define TB_SAVERESTOREA                           ( WM_USER + 26 )
#define TB_SAVERESTOREW                           ( WM_USER + 76 )
#define TB_CUSTOMIZE                              ( WM_USER + 27 )
#define TB_ADDSTRINGA                             ( WM_USER + 28 )
#define TB_ADDSTRINGW                             ( WM_USER + 77 )
#define TB_GETITEMRECT                            ( WM_USER + 29 )
#define TB_BUTTONSTRUCTSIZE                       ( WM_USER + 30 )
#define TB_SETBUTTONSIZE                          ( WM_USER + 31 )
#define TB_SETBITMAPSIZE                          ( WM_USER + 32 )
#define TB_AUTOSIZE                               ( WM_USER + 33 )
#define TB_GETTOOLTIPS                            ( WM_USER + 35 )
#define TB_SETTOOLTIPS                            ( WM_USER + 36 )
#define TB_SETPARENT                              ( WM_USER + 37 )
#define TB_SETROWS                                ( WM_USER + 39 )
#define TB_GETROWS                                ( WM_USER + 40 )
#define TB_GETBITMAPFLAGS                         ( WM_USER + 41 )
#define TB_SETCMDID                               ( WM_USER + 42 )
#define TB_CHANGEBITMAP                           ( WM_USER + 43 )
#define TB_GETBITMAP                              ( WM_USER + 44 )
#define TB_GETBUTTONTEXTA                         ( WM_USER + 45 )
#define TB_GETBUTTONTEXTW                         ( WM_USER + 75 )
#define TB_REPLACEBITMAP                          ( WM_USER + 46 )
#define TB_SETINDENT                              ( WM_USER + 47 )
#define TB_SETIMAGELIST                           ( WM_USER + 48 )
#define TB_GETIMAGELIST                           ( WM_USER + 49 )
#define TB_LOADIMAGES                             ( WM_USER + 50 )
#define TB_GETRECT                                ( WM_USER + 51 )
#define TB_SETHOTIMAGELIST                        ( WM_USER + 52 )
#define TB_GETHOTIMAGELIST                        ( WM_USER + 53 )
#define TB_SETDISABLEDIMAGELIST                   ( WM_USER + 54 )
#define TB_GETDISABLEDIMAGELIST                   ( WM_USER + 55 )
#define TB_SETSTYLE                               ( WM_USER + 56 )
#define TB_GETSTYLE                               ( WM_USER + 57 )
#define TB_GETBUTTONSIZE                          ( WM_USER + 58 )
#define TB_SETBUTTONWIDTH                         ( WM_USER + 59 )
#define TB_SETMAXTEXTROWS                         ( WM_USER + 60 )
#define TB_GETTEXTROWS                            ( WM_USER + 61 )

#define TB_GETBUTTONTEXT                          TB_GETBUTTONTEXTW
#define TB_SAVERESTORE                            TB_SAVERESTOREW
#define TB_ADDSTRING                              TB_ADDSTRINGW

#define TB_GETOBJECT                              ( WM_USER + 62 )
#define TB_GETHOTITEM                             ( WM_USER + 71 )
#define TB_SETHOTITEM                             ( WM_USER + 72 )
#define TB_SETANCHORHIGHLIGHT                     ( WM_USER + 73 )
#define TB_GETANCHORHIGHLIGHT                     ( WM_USER + 74 )
#define TB_MAPACCELERATORA                        ( WM_USER + 78 )

#define TB_GETINSERTMARK                          ( WM_USER + 79 )
#define TB_SETINSERTMARK                          ( WM_USER + 80 )
#define TB_INSERTMARKHITTEST                      ( WM_USER + 81 )
#define TB_MOVEBUTTON                             ( WM_USER + 82 )
#define TB_GETMAXSIZE                             ( WM_USER + 83 )
#define TB_SETEXTENDEDSTYLE                       ( WM_USER + 84 )
#define TB_GETEXTENDEDSTYLE                       ( WM_USER + 85 )
#define TB_GETPADDING                             ( WM_USER + 86 )
#define TB_SETPADDING                             ( WM_USER + 87 )
#define TB_SETINSERTMARKCOLOR                     ( WM_USER + 88 )
#define TB_GETINSERTMARKCOLOR                     ( WM_USER + 89 )

#define TB_SETCOLORSCHEME                         CCM_SETCOLORSCHEME
#define TB_GETCOLORSCHEME                         CCM_GETCOLORSCHEME

#define TB_SETUNICODEFORMAT                       CCM_SETUNICODEFORMAT
#define TB_GETUNICODEFORMAT                       CCM_GETUNICODEFORMAT

#define TB_MAPACCELERATORW                        ( WM_USER + 90 )
#define TB_MAPACCELERATOR                         TB_MAPACCELERATORW

#define TBIMHT_AFTER                              1
#define TBIMHT_BACKGROUND                         2

#define TBBF_LARGE                                1

#define TBIF_IMAGE                                1
#define TBIF_TEXT                                 2
#define TBIF_STATE                                4
#define TBIF_STYLE                                8
#define TBIF_LPARAM                               16
#define TBIF_COMMAND                              32
#define TBIF_SIZE                                 64

#define TBIF_BYINDEX                              2147483648

#define TBBUTTONINFO                              TBBUTTONINFOW
#define LPTBBUTTONINFO                            LPTBBUTTONINFOW

#define TB_GETBUTTONINFOW                         ( WM_USER + 63 )
#define TB_SETBUTTONINFOW                         ( WM_USER + 64 )
#define TB_GETBUTTONINFOA                         ( WM_USER + 65 )
#define TB_SETBUTTONINFOA                         ( WM_USER + 66 )
#define TB_GETBUTTONINFO                          TB_GETBUTTONINFOW
#define TB_SETBUTTONINFO                          TB_SETBUTTONINFOW

#define TB_INSERTBUTTONW                          ( WM_USER + 67 )
#define TB_ADDBUTTONSW                            ( WM_USER + 68 )
#define TB_ADDBUTTONSA                            ( WM_USER + 20 )
#define TB_HITTEST                                ( WM_USER + 69 )
#define TB_INSERTBUTTON                           TB_INSERTBUTTONW
#define TB_ADDBUTTONS                             TB_ADDBUTTONSW

#define TB_SETDRAWTEXTFLAGS                       ( WM_USER + 70 )
#define TB_GETSTRING                              ( WM_USER + 92 )

#define TBN_FIRST                                 -700
#define TBN_GETBUTTONINFOA                        ( TBN_FIRST - 0 )
#define TBN_BEGINDRAG                             ( TBN_FIRST - 1 )
#define TBN_ENDDRAG                               ( TBN_FIRST - 2 )
#define TBN_BEGINADJUST                           ( TBN_FIRST - 3 )
#define TBN_ENDADJUST                             ( TBN_FIRST - 4 )
#define TBN_RESET                                 ( TBN_FIRST - 5 )
#define TBN_QUERYINSERT                           ( TBN_FIRST - 6 )
#define TBN_QUERYDELETE                           ( TBN_FIRST - 7 )
#define TBN_TOOLBARCHANGE                         ( TBN_FIRST - 8 )
#define TBN_CUSTHELP                              ( TBN_FIRST - 9 )
#define TBN_DROPDOWN                              ( TBN_FIRST - 10 )
#define TBN_GETOBJECT                             ( TBN_FIRST - 12 )
#define TBN_HOTITEMCHANGE                         ( TBN_FIRST - 13 )
#define TBN_DRAGOUT                               ( TBN_FIRST - 14 )
#define TBN_DELETINGBUTTON                        ( TBN_FIRST - 15 )
#define TBN_GETDISPINFOA                          ( TBN_FIRST - 16 )
#define TBN_GETDISPINFOW                          ( TBN_FIRST - 17 )
#define TBN_GETINFOTIPA                           ( TBN_FIRST - 18 )
#define TBN_GETINFOTIPW                           ( TBN_FIRST - 19 )
#define TBN_GETBUTTONINFOW                        ( TBN_FIRST - 20 )
#define TBN_RESTORE                               ( TBN_FIRST - 21 )
#define TBN_SAVE                                  ( TBN_FIRST - 22 )
#define TBN_INITCUSTOMIZE                         ( TBN_FIRST - 23 )


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

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

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

[Assistant]
#require "hbnf"

PROCEDURE Main()

   LOCAL aString := { ;
      "RTrim('abc ')", ;
      "NotARealFunc()", ;
      "ft_DispMsg()", ;
      'RTrim(cVar+"abc"+Left(cString)), Found()', ;
      "IsItLinked()", ;
      "lRetVal := Found()", ;
      "!Eof() .AND. Month(Date())=12 .AND. YeeHa()", ;
      "!Eof() .AND. Month(Date())=12", ;
      "!Eof() .AND. Month(Date(YeeHa()))=12", ;
      "Left(SubStr(nNum,4,Val(cChar+Asc(c))))", ;
      "Eof(>> Note: Syntax IS NOT checked! <<)"           }

   CLS
   @ 1, 0 SAY "String Tested                               Result"
   @ 2, 0 TO 2, MaxCol()
   AEval( aString, {| ele | QOut( ele, Space( 45 - Len( ele ) ), ft_Linked( ele ) ) } )
   @ MaxRow() - 2, 0

   RETURN


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

[User] Implement these Harbour functions: Harbour Runtime Library file: src/rtl/valtoexp.prg. Provides 6 functions including: hb_CStr, hb_ValToExp, s_valToExp, __itemSetRef, __itemSetObj. This file provides utility functions

[Assistant]
FUNCTION hb_CStr( xVal )

   LOCAL v := ValType( xVal )

   SWITCH v
   CASE "C"
   CASE "M" ; RETURN xVal
   CASE "N" ; RETURN Str( xVal )
   CASE "D" ; RETURN iif( Empty( xVal ), "0d00000000", "0d" + DToS( xVal ) )
   CASE "T" ; RETURN 't"' + hb_TSToStr( xVal, .T. ) + '"'
   CASE "L" ; RETURN iif( xVal, ".T.", ".F." )
   CASE "S" ; RETURN "@" + xVal:name + "()"
   CASE "B" ; RETURN "{|| ... }"
   CASE "O" ; RETURN "{ " + xVal:className() + " Object }"
   CASE "A" ; RETURN "{ Array of " + hb_ntos( Len( xVal ) ) + " Items }"
   CASE "H" ; RETURN "{ Hash of " + hb_ntos( Len( xVal ) ) + " Items }"
   CASE "P" ; RETURN "<pointer>"
   OTHERWISE
      IF xVal == NIL
         RETURN "NIL"
      ENDIF
   ENDSWITCH

   RETURN "???:" + v

FUNCTION hb_ValToExp( xVal, lRaw )

   RETURN s_valToExp( xVal, hb_defaultValue( lRaw, .F. ) )

STATIC FUNCTION s_valToExp( xVal, lRaw, cInd, hRefs, cRefs, cObjs )

   LOCAL cVal, cKey, cClass
   LOCAL tmp
   LOCAL v := ValType( xVal )

   SWITCH v
   CASE "C"
   CASE "M" ; RETURN hb_StrToExp( xVal )
   CASE "N" ; RETURN hb_ntos( xVal )
   CASE "D" ; RETURN iif( Empty( xVal ), "0d00000000", "0d" + DToS( xVal ) )
   CASE "T" ; RETURN 't"' + hb_TSToStr( xVal, .T. ) + '"'
   CASE "L" ; RETURN iif( xVal, ".T.", ".F." )
   CASE "S" ; RETURN "@" + xVal:name + "()"
   CASE "O"
      cClass := xVal:className()
   CASE "A"
   CASE "H"
      tmp := __vmItemID( xVal )
      IF cInd == NIL
         cInd := cRefs := ""
         hRefs := { tmp => cInd }
      ELSEIF tmp $ hRefs
         IF !( cRefs == "" )
            cRefs += ","
         ENDIF
         cRefs += "{{" + cInd + "}," + hRefs[ tmp ] + "}"
         RETURN "NIL"
      ELSE
         hRefs[ tmp ] := "{" + cInd + "}"
         cInd += ","
      ENDIF

      IF v == "H"
         IF Empty( xVal )
            cVal := "{=>}"
         ELSE
            cVal := "{"
            FOR EACH tmp IN xVal
               cKey := s_valToExp( tmp:__enumKey(), lRaw )
               cVal += iif( tmp:__enumIsFirst(), "", ", " ) + ;
                  cKey + "=>" + ;
                  s_valToExp( tmp, lRaw, cInd + cKey, hRefs, @cRefs, @cObjs )
            NEXT
            cVal += "}"
         ENDIF
      ELSE
         cVal := "{"
         IF ! lRaw .AND. v == "O"
            FOR EACH tmp IN __objGetIVars( xVal )
               cVal += iif( tmp:__enumIsFirst(), '{"', ', {"' ) + ;
                       tmp[ 1 ] + '", ' + ;
                       s_valToExp( tmp[ 2 ], lRaw, ;
                                   cInd + hb_ntos( tmp:__enumIndex() ) + ",2", ;
                                   hRefs, @cRefs, @cObjs ) + "}"
            NEXT
         ELSE
            FOR EACH tmp IN xVal
               cVal += iif( tmp:__enumIsFirst(), "", ", " ) + ;
                  s_valToExp( tmp, lRaw, cInd + hb_ntos( tmp:__enumIndex() ), hRefs, @cRefs, @cObjs )
            NEXT
         ENDIF
         cVal += "}"
      ENDIF

      IF v == "O"
         IF cObjs == NIL
            cObjs := ""
         ELSE
            cObjs += ","
         ENDIF
         cObjs += '{"' + cClass + '",'
         IF ! cInd == ""
            cObjs += "{" + hb_StrShrink( cInd ) + "}"
         ENDIF
         cObjs += "}"
      ENDIF
      IF cInd == ""
         IF ! Empty( cRefs )
            cVal := "__itemSetRef( " + cVal + ", {" + cRefs + "} )"
         ENDIF
         IF ! Empty( cObjs )
            cVal := iif( lRaw, "__itemSetObjRaw( ", ;
                               "__itemSetObj( " ) + cVal + ", {" + cObjs + "} )"
         ENDIF
      ENDIF
      EXIT
   CASE "P" ; RETURN "<pointer>"
   CASE "B" ; RETURN "{|| ... }"
   OTHERWISE
      IF xVal == NIL
         cVal := "NIL"
      ELSE
         cVal := "???:" + v
      ENDIF
   ENDSWITCH

   RETURN cVal

FUNCTION __itemSetRef( xVal, aRefs )

   LOCAL aRef

   FOR EACH aRef in aRefs
      xVal[ hb_ArrayToParams( aRef[ 1 ] ) ] := ;
         iif( aRef[ 2 ] == NIL, xVal, xVal[ hb_ArrayToParams( aRef[ 2 ] ) ] )
   NEXT

   RETURN xVal

FUNCTION __itemSetObj( xVal, aObjs )

   LOCAL aRef

   FOR EACH aRef in aObjs
      __objRestoreIVars( iif( aRef[ 2 ] == NIL, xVal, ;
                              xVal[ hb_ArrayToParams( aRef[ 2 ] ) ] ), aRef[ 1 ] )
   NEXT

   RETURN xVal

FUNCTION __itemSetObjRaw( xVal, aObjs )

   LOCAL aRef

   FOR EACH aRef in aObjs
      __objSetClass( iif( aRef[ 2 ] == NIL, xVal, ;
                          xVal[ hb_ArrayToParams( aRef[ 2 ] ) ] ), aRef[ 1 ] )
   NEXT

   RETURN xVal


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

[User] Create Harbour preprocessor definitions: Header file for contribution module 'hbmzip' (ZIP file handling): contrib/hbmzip/hbmzip.ch. Defines 10 constants including: HB_MZIP_CH_, HB_ZIP_OPEN_CREATE, HB_ZIP_OPEN_CREATEAFTER, HB_ZIP_OPEN_ADDINZIP, Z_ERRNO. Defines Harbour internal constants and macros

[Assistant]
#ifndef HB_MZIP_CH_
#define HB_MZIP_CH_

#define HB_ZIP_OPEN_CREATE              0
#define HB_ZIP_OPEN_CREATEAFTER         1
#define HB_ZIP_OPEN_ADDINZIP            2

#define Z_ERRNO                         -1

#define UNZ_OK                          0
#define UNZ_END_OF_LIST_OF_FILE         -100
#define UNZ_ERRNO                       Z_ERRNO
#define UNZ_EOF                         0
#define UNZ_PARAMERROR                  -102
#define UNZ_BADZIPFILE                  -103
#define UNZ_INTERNALERROR               -104
#define UNZ_CRCERROR                    -105

#define ZIP_OK                          0
#define ZIP_EOF                         0
#define ZIP_ERRNO                       Z_ERRNO
#define ZIP_PARAMERROR                  -102
#define ZIP_BADZIPFILE                  -103
#define ZIP_INTERNALERROR               -104

#endif


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

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

Harbour Runtime Library file: src/rtl/scrollbr.prg. Defines classes: ScrollBar. This file provides utility functions

[Assistant]
#include "hbclass.ch"

#include "button.ch"
#include "color.ch"

#ifdef HB_COMPAT_C53

CREATE CLASS ScrollBar FUNCTION HBScrollBar

   EXPORTED:

   VAR cargo

   METHOD barLength() SETGET
   METHOD bitmaps( aBitmaps ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
   METHOD current( nCurrent ) SETGET
   METHOD end( nEnd ) SETGET
   METHOD offset( nOffset ) SETGET
   METHOD orient( nOrient ) SETGET
   METHOD sBlock( bSBlock ) SETGET
   METHOD start( nStart ) SETGET
   METHOD style( cStyle ) SETGET
   METHOD thumbPos( nThumbPos ) SETGET
   METHOD total( nTotal ) SETGET

   METHOD display()
   METHOD update()
   METHOD hitTest( nMRow, nMCol )

   METHOD Init( nStart, nEnd, nOffset, bSBlock, nOrient )

   PROTECTED:

   VAR aBitmaps
   VAR nBarLength
   VAR cColorSpec
   VAR cStyle
   VAR nCurrent   INIT 1
   VAR nEnd       INIT 0
   VAR nOffset
   VAR nOrient
   VAR nStart     INIT 0
   VAR nThumbPos  INIT 1
   VAR nTotal     INIT 100
   VAR bSBlock

   VAR lOverride  INIT .F.

   METHOD CalcThumbPos()

ENDCLASS

METHOD display() CLASS ScrollBar

   LOCAL cColor
   LOCAL cStyle
   LOCAL nOffset
   LOCAL nStart
   LOCAL nEnd
   LOCAL nPos

   IF ::CalcThumbPos()

      cStyle  := ::cStyle
      nOffset := ::nOffset
      nStart  := ::nStart
      nEnd    := ::nEnd - 1

      DispBegin()

      cColor := hb_ColorIndex( ::cColorSpec, 0 )

      IF ::nOrient == SCROLL_VERTICAL

         FOR nPos := nStart + 1 TO nEnd
            hb_DispOutAt( nPos, nOffset, SubStr( cStyle, 2, 1 ), cColor )
         NEXT

         cColor := hb_ColorIndex( ::cColorSpec, 1 )
         hb_DispOutAt( nStart, nOffset, SubStr( cStyle, 1, 1 ), cColor )
         hb_DispOutAt( nStart + ::nThumbPos, nOffset, SubStr( cStyle, 3, 1 ), cColor )
         hb_DispOutAt( nEnd + 1, nOffset, SubStr( cStyle, 4, 1 ), cColor )
      ELSE

         hb_DispOutAt( nOffset, nStart + 1, Replicate( SubStr( cStyle, 2, 1 ), nEnd - nStart ), cColor )

         cColor := hb_ColorIndex( ::cColorSpec, 1 )
         hb_DispOutAt( nOffset, nStart, SubStr( cStyle, 1, 1 ), cColor )
         hb_DispOutAt( nOffset, nStart + ::nThumbPos, SubStr( cStyle, 3, 1 ), cColor )
         hb_DispOutAt( nOffset, nEnd + 1, SubStr( cStyle, 4, 1 ), cColor )

      ENDIF

      DispEnd()

      RETURN .T.
   ENDIF

   RETURN .F.

METHOD update() CLASS ScrollBar

   LOCAL nOldThumbPos := ::nThumbPos

   IF HB_ISEVALITEM( ::bSBlock )
      Eval( ::bSBlock )
   ENDIF

   IF ::CalcThumbPos() .AND. nOldThumbPos != ::nThumbPos

      DispBegin()

      IF ::nOrient == SCROLL_VERTICAL
         hb_DispOutAt( ::nStart + nOldThumbPos, ::nOffSet, SubStr( ::cStyle, 2,  1 ), hb_ColorIndex( ::cColorSpec, 0 ) )
         hb_DispOutAt( ::nStart + ::nThumbPos, ::nOffset, SubStr( ::cStyle, 3, 1 ), hb_ColorIndex( ::cColorSpec, 1 ) )
      ELSE
         hb_DispOutAt( ::nOffset, ::nStart + nOldThumbPos, SubStr( ::cStyle, 2, 1 ), hb_ColorIndex( ::cColorSpec, 0 ) )
         hb_DispOutAt( ::nOffset, ::nStart + ::nThumbPos, SubStr( ::cStyle, 3, 1 ), hb_ColorIndex( ::cColorSpec, 1 ) )
      ENDIF

      DispEnd()

      RETURN .T.
   ENDIF

   RETURN .F.

METHOD hitTest( nMRow, nMCol ) CLASS ScrollBar

   IF ::nOrient == SCROLL_VERTICAL

      DO CASE
      CASE nMCol != ::nOffset
      CASE nMRow < ::nStart
      CASE nMRow > ::nEnd
      CASE nMRow == ::nStart
         RETURN HTSCROLLUNITDEC
      CASE nMRow == ::nEnd
         RETURN HTSCROLLUNITINC
      CASE nMRow < ::nThumbPos + ::nStart
         RETURN HTSCROLLBLOCKDEC
      CASE nMRow > ::nThumbPos + ::nStart
         RETURN HTSCROLLBLOCKINC
      CASE nMRow == ::nThumbPos + ::nStart
         RETURN HTSCROLLTHUMBDRAG
      ENDCASE

      IF nMCol == ::nOffset + 1 .OR. nMCol == ::nOffset

         DO CASE
         CASE nMCol != ::nOffset .AND. nMCol != ::nOffset + 1
         CASE nMRow < ::nStart
         CASE nMRow > ::nEnd
         CASE nMRow == ::nStart
            RETURN HTSCROLLUNITDEC
         CASE nMRow == ::nEnd
            RETURN HTSCROLLUNITINC
         CASE nMRow < ::nThumbPos + ::nStart
            RETURN HTSCROLLBLOCKDEC
         CASE nMRow > ::nThumbPos + ::nStart
            RETURN HTSCROLLBLOCKINC
         CASE nMRow == ::nThumbPos + ::nStart
            RETURN HTSCROLLTHUMBDRAG
         ENDCASE
      ENDIF
   ELSE

      DO CASE
      CASE nMRow != ::nOffset
      CASE nMCol < ::nStart
      CASE nMCol > ::nEnd
      CASE nMCol == ::nStart
         RETURN HTSCROLLUNITDEC
      CASE nMCol == ::nEnd
         RETURN HTSCROLLUNITINC
      CASE nMCol < ::nThumbPos + ::nStart
         RETURN HTSCROLLBLOCKDEC
      CASE nMCol > ::nThumbPos + ::nStart
         RETURN HTSCROLLBLOCKINC
      CASE nMCol == ::nThumbPos + ::nStart
         RETURN HTSCROLLTHUMBDRAG
      ENDCASE
   ENDIF

   RETURN HTNOWHERE

METHOD barLength() CLASS ScrollBar
   RETURN ::nBarLength

METHOD bitmaps( aBitmaps ) CLASS ScrollBar

   IF HB_ISARRAY( aBitmaps ) .AND. ;
      Len( aBitmaps ) == 3

      ::aBitmaps := aBitmaps
   ENDIF

   RETURN ::aBitmaps

METHOD colorSpec( cColorSpec ) CLASS ScrollBar

   IF HB_ISSTRING( cColorSpec ) .AND. ;
      ! Empty( hb_ColorIndex( cColorSpec, 1 ) ) .AND. ;
      Empty( hb_ColorIndex( cColorSpec, 2 ) )

      ::cColorSpec := cColorSpec
   ENDIF

   RETURN ::cColorSpec

METHOD current( nCurrent ) CLASS ScrollBar

   IF HB_ISNUMERIC( nCurrent ) .AND. ;
      nCurrent <= ::nTotal .AND. ;
      nCurrent != ::nCurrent

      ::nCurrent := nCurrent
   ENDIF

   RETURN ::nCurrent

METHOD end( nEnd ) CLASS ScrollBar

   IF HB_ISNUMERIC( nEnd ) .AND. ;
      nEnd >= ::nStart .AND. ;
      nEnd != ::nEnd

      ::nEnd := nEnd
      ::nBarLength := nEnd - ::nStart - 1
   ENDIF

   RETURN ::nEnd

METHOD offset( nOffset ) CLASS ScrollBar

   IF HB_ISNUMERIC( nOffset ) .AND. ;
      nOffset != ::nOffset

      ::nOffset := nOffset
   ENDIF

   RETURN ::nOffset

METHOD orient( nOrient ) CLASS ScrollBar

   IF HB_ISNUMERIC( nOrient ) .AND. ;
      ( nOrient == SCROLL_VERTICAL .OR. nOrient == SCROLL_HORIZONTAL )

      ::nOrient := nOrient
   ENDIF

   RETURN ::nOrient

METHOD sBlock( bSBlock ) CLASS ScrollBar

   IF HB_ISEVALITEM( bSBlock )
      ::bSBlock := bSBlock
   ENDIF

   RETURN ::bSBlock

METHOD start( nStart ) CLASS ScrollBar

   IF HB_ISNUMERIC( nStart ) .AND. ;
      nStart <= ::nEnd .AND. ;
      nStart != ::nStart

      ::nStart := nStart
      ::nBarLength := ::nEnd - nStart - 1
   ENDIF

   RETURN ::nStart

METHOD style( cStyle ) CLASS ScrollBar

   IF HB_ISSTRING( cStyle ) .AND. ;
      Len( cStyle ) == 4

      ::cStyle := cStyle
   ENDIF

   RETURN ::cStyle

METHOD thumbPos( nThumbPos ) CLASS ScrollBar

   IF HB_ISNUMERIC( nThumbPos )

      DO CASE
      CASE nThumbPos < 1
         ::nThumbPos := 1
      CASE nThumbPos >= ::nBarLength
         ::nThumbPos := ::nBarLength
      CASE nThumbPos >= ::nBarLength - 1
         ::nThumbPos := nThumbPos
      OTHERWISE
         ::nThumbPos := nThumbPos
      ENDCASE

      ::lOverride := ( nThumbPos != 0 )
   ENDIF

   RETURN ::nThumbPos

METHOD total( nTotal ) CLASS ScrollBar

   IF HB_ISNUMERIC( nTotal ) .AND. ;
      nTotal >= 2 .AND. ;
      nTotal != ::nTotal

      ::nTotal := nTotal
   ENDIF

   RETURN ::nTotal

METHOD CalcThumbPos() CLASS ScrollBar

   LOCAL nBarLength := ::nBarLength
   LOCAL nTotal := ::nTotal

   IF nBarLength < 2 .OR. nTotal < 2
      RETURN .F.
   ENDIF

   IF ! ::lOverride
      ::nThumbPos := Min( Max( Round( ::nCurrent
#define SB_THUMB        hb_UTF8ToStr( "░" )
#define SB_TRACK        hb_UTF8ToStr( "▓" )

METHOD Init( nStart, nEnd, nOffset, bSBlock, nOrient ) CLASS ScrollBar

   LOCAL cColor

   __defaultNIL( @nOrient, SCROLL_VERTICAL )

   IF ! HB_ISNUMERIC( nStart ) .OR. ;
      ! HB_ISNUMERIC( nEnd ) .OR. ;
      ! HB_ISNUMERIC( nOffset ) .OR. ;
      ! ValType( bSBlock ) $ "BU" .OR. ;
      ! HB_ISNUMERIC( nOrient ) .OR. ;
      ( nOrient != SCROLL_VERTICAL .AND. nOrient != SCROLL_HORIZONTAL )
      RETURN NIL
   ENDIF

   ::end        := nEnd
   ::offSet     := nOffset


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

[Assistant]
PROCEDURE Main()

   LOCAL s := " " + Chr( 0 ) + "  mab  " + Chr( 0 ) + " "

   StrDump( s )
   ? s

   ? '"' + LTrim( s ) + '"'
   ? '"' + RTrim( s ) + '"'
   ? '"' + AllTrim( s ) + '"'

   RETURN

STATIC PROCEDURE StrDump( s )

   LOCAL tmp

   FOR EACH tmp IN s
      ? Asc( tmp )
   NEXT

   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 contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/menu1.prg. Provides 7 functions including: ft_Menu1, __ftAcUdf, _ftWidest, _ftLocat, _ftBailOut. This file provides legacy compatibility functions

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

#define DISABLE     0
#define ENABLE      1

THREAD STATIC t_aChoices := {}
THREAD STATIC t_aValidKeys := {}
THREAD STATIC t_nHPos
THREAD STATIC t_nVPos
THREAD STATIC t_nMaxRow
THREAD STATIC t_nMaxCol

FUNCTION ft_Menu1( aBar, aOptions, aColors, nTopRow, lShadow )

   LOCAL nTtlUsed
   LOCAL sMainScrn, lCancMode, lLooping := .T.

   LOCAL aBarCol[ Len( aBar ) ]

   LOCAL aBarKeys[ Len( aBar ) ]

   LOCAL aKeyCodes := { ;
      K_ALT_A, ;
      K_ALT_B, ;
      K_ALT_C, ;
      K_ALT_D, ;
      K_ALT_E, ;
      K_ALT_F, ;
      K_ALT_G, ;
      K_ALT_H, ;
      K_ALT_I, ;
      K_ALT_J, ;
      K_ALT_K, ;
      K_ALT_L, ;
      K_ALT_M, ;
      K_ALT_N, ;
      K_ALT_O, ;
      K_ALT_P, ;
      K_ALT_Q, ;
      K_ALT_R, ;
      K_ALT_S, ;
      K_ALT_T, ;
      K_ALT_U, ;
      K_ALT_V, ;
      K_ALT_W, ;
      K_ALT_X, ;
      K_ALT_Y, ;
      K_ALT_Z }

   LOCAL aBarWidth[ Len( aBar ) ]

   LOCAL aBoxLoc[ Len( aBar ) ]

   LOCAL aLastSel[ Len( aBar ) ]

   LOCAL cBorder  := aColors[ 1 ]
   LOCAL cBox     := aColors[ 2 ]
   LOCAL cBar     := aColors[ 3 ]
   LOCAL cCurrent := aColors[ 4 ]
   LOCAL cUnSelec := aColors[ 5 ]

   t_nMaxRow := MaxRow()
   t_nMaxCol := MaxCol()

   __defaultNIL( @nTopRow, 0 )

   AFill( aLastSel, 1 )
   t_aChoices := aOptions

   aBarCol[ 1 ] := 0
   nTtlUsed := Len( aBar[ 1 ] ) + 1
   AEval( aBar, ;
      {| x, i | HB_SYMBOL_UNUSED( x ), aBarcol[ i ] := nTtlUsed, nTtlUsed += ( Len( aBar[ i ] ) + 1 ) }, ;
      2, Len( aBar ) - 1 )

   AFill( aBarWidth, 1 )
   AEval( t_aChoices, {| x, i | HB_SYMBOL_UNUSED( x ), _ftWidest( @i, t_aChoices, @aBarWidth ) } )

   AEval( t_aChoices, {| x, i | HB_SYMBOL_UNUSED( x ), _ftLocat( i, aBarCol, aBarWidth, @aBoxLoc, t_nMaxCol ) } )

   AEval( t_aChoices, {| x, i | HB_SYMBOL_UNUSED( x ), AAdd( t_aValidKeys, "" ), ;
      _ftValKeys( i, t_aChoices, @t_aValidKeys ) } )

   SetColor( cBar )
   hb_Scroll( nTopRow, 0, nTopRow )
   AEval( aBar, {| x, i | HB_SYMBOL_UNUSED( x ), hb_DispOutAt( nTopRow, aBarCol[ i ], aBar[ i ] ) } )

   AEval( aBarKeys, {| x, i | HB_SYMBOL_UNUSED( x ), aBarKeys[ i ] := ;
      aKeyCodes[ Asc( Upper( LTrim( aBar[ i ] ) ) ) - Asc( "@" ) ] } )

   lCancMode := SetCancel( .F. )
   AltD( DISABLE )

   SAVE SCREEN TO sMainScrn

   t_nHPos := 1
   t_nVPos := 1
   DO WHILE lLooping
      RESTORE SCREEN FROM sMainScrn
      SetColor( cCurrent )
      hb_DispOutAt( nTopRow, aBarCol[ t_nHPos ], aBar[ t_nHPos ] )
      IF lShadow == NIL .OR. lShadow
         hb_Shadow( nTopRow + 1, aBoxLoc[ t_nHPos ], Len( t_aChoices[ t_nHPos, 1 ] ) + nTopRow + 2, aBarWidth[ t_nHPos ] + 3 + aBoxLoc[ t_nHPos ] )
      ENDIF
      hb_DispBox( nTopRow + 1, aBoxLoc[ t_nHPos ], Len( t_aChoices[ t_nHPos, 1 ] ) + nTopRow + 2, aBarWidth[ t_nHPos ] + 3 + aBoxLoc[ t_nHPos ], hb_UTF8ToStrBox( "╔═╗║╝═╚║ " ), cBorder )
      SetColor( cBox + "," + cCurrent + ",,," + cUnselec )
      t_nVPos := AChoice( nTopRow + 2, aBoxLoc[ t_nHPos ] + 2, Len( t_aChoices[ t_nHPos, 1 ] ) + nTopRow + 2, aBarWidth[ t_nHPos ] + 1 + aBoxLoc[ t_nHPos ], t_aChoices[ t_nHPos, 1 ], t_aChoices[ t_nHPos, 3 ], {| nMode | __ftAcUdf( nMode ) }, aLastSel[ t_nHPos ] )
      DO CASE
      CASE LastKey() == K_RIGHT .OR. LastKey() == K_TAB
         t_nHPos := iif( t_nHPos == Len( t_aChoices ), 1, t_nHPos + 1 )
      CASE LastKey() == K_LEFT .OR. LastKey() == K_SH_TAB
         t_nHPos := iif( t_nHPos == 1, Len( t_aChoices ), t_nHPos - 1 )
      CASE LastKey() == K_ESC
         lLooping := _ftBailOut( cBorder, cBox )
      CASE LastKey() == K_HOME
         t_nHPos := 1
      CASE LastKey() == K_END
         t_nHPos := Len( t_aChoices )
      CASE LastKey() == K_ENTER
         aLastSel[ t_nHPos ] := t_nVPos
         IF t_aChoices[ t_nHPos, 2, t_nVPos ] != NIL
            SetCancel( lCancMode )
            AltD( ENABLE )
            lLooping := Eval( t_aChoices[ t_nHPos, 2, t_nVPos ] )
            AltD( DISABLE )
            SetCancel( .F. )
         ENDIF
      CASE AScan( aBarKeys, LastKey() ) > 0
         t_nHPos := AScan( aBarKeys, LastKey() )
      ENDCASE
   ENDDO
   SetCancel( lCancMode )
   AltD( ENABLE )
   RESTORE SCREEN FROM sMainScrn

   RETURN NIL

STATIC FUNCTION __ftAcUdf( nMode )

   LOCAL nRtnVal := AC_CONT

   DO CASE
   CASE nMode == AC_HITTOP
      hb_keyPut( K_CTRL_END )
   CASE nMode == AC_HITBOTTOM
      hb_keyPut( K_CTRL_HOME )
   CASE nMode == AC_EXCEPT
      IF Upper( hb_keyChar( LastKey() ) ) $ t_aValidKeys[ t_nHPos ]
         IF t_aChoices[ t_nHPos, 3, At( Upper( hb_keyChar( LastKey() ) ), t_aValidKeys[ t_nHPos ] ) ]
            hb_keyPut( K_ENTER )
            nRtnVal := AC_GOTO
         ENDIF
      ELSE
         nRtnVal := AC_SELECT
      ENDIF
   ENDCASE

   RETURN nRtnVal

STATIC FUNCTION _ftWidest( i, t_aChoices, aBarWidth )

   AEval( t_aChoices[ i, 1 ], {| a, b | HB_SYMBOL_UNUSED( a ), aBarWidth[ i ] := ;
      Max( aBarWidth[ i ], Len( t_aChoices[ i, 1, b ] ) ) } )

   RETURN NIL

STATIC FUNCTION _ftLocat( i, aBarCol, aBarWidth, aBoxLoc, t_nMaxCol )

   aBoxLoc[ i ] := iif( aBarCol[ i ] + aBarWidth[ i ] + 4 > t_nMaxCol + 1, ;
      t_nMaxCol - 3 - aBarWidth[ i ], aBarCol[ i ] )

   RETURN NIL

STATIC FUNCTION _ftBailOut( cBorder, cBox )

   LOCAL sOldScreen, nKeyPress, nOldCursor

   nOldCursor := SetCursor( SC_NONE )
   sOldScreen := SaveScreen( t_nMaxRow / 2 - 1, 24, t_nMaxRow / 2 + 2, 55 )
   hb_Shadow( t_nMaxRow / 2 - 1, 24, t_nMaxRow / 2 + 2, 55 )
   hb_DispBox( t_nMaxRow / 2 - 1, 24, t_nMaxRow / 2 + 2, 55, hb_UTF8ToStrBox( "╔═╗║╝═╚║ " ), cBorder )
   hb_DispOutAt( t_nMaxRow / 2, 26, "Press ESCape To Confirm Exit", cBox )
   hb_DispOutAt( t_nMaxRow / 2 + 1, 27, "Or Any Other Key To Resume", cBox )
   nKeyPress := Inkey( 0 )
   RestScreen( t_nMaxRow / 2 - 1, 24, t_nMaxRow / 2 + 2, 55, sOldScreen )
   SetCursor( nOldCursor )

   RETURN nKeyPress != K_ESC

STATIC FUNCTION _ftValKeys( nNum, t_aChoices, t_aValidKeys )

   AEval( t_aChoices[ nNum, 1 ], {| x | t_aValidKeys[ nNum ] += Left( x, 1 ) } )

   RETURN NIL

FUNCTION ft_Fill( aArray, cMenuOption, bBlock, lAvailable )

   AAdd( aArray[ 1 ], cMenuOption )
   AAdd( aArray[ 2 ], bBlock )
   AAdd( aArray[ 3 ], lAvailable )

   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] Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/atrepl.prg. Contains procedures: Main. This file provides legacy compatibility functions

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

PROCEDURE Main()

   ctinit()

   ? "Begin test of AtRepl()"
   ?

   ? "Simple tests:"

   ? '  AtRepl( "ABC", "ABCDABCDABC", "xx" ) == "xxDxxDxx" ? --> "' + AtRepl( "ABC", "ABCDABCDABC", "xx" ) + '"'
   ? '  AtRepl( "ABC", "ABCDABC", "ZYXW" ) == "ZYXWDZYXW" ? --> "' + AtRepl( "ABC", "ABCDABC", "ZYXW" ) + '"'
   ? '  AtRepl( "ABC", "ABCDABCDABC", "xx", 2 ) == "xxDxxDABC" ? --> "' + AtRepl( "ABC", "ABCDABCDABC", "xx", 2 ) + '"'
   ? '  AtRepl( "ABC", "ABCDABCDABC", "xx", 2, .T. ) == "ABCDxxDABC" ? --> "' + AtRepl( "ABC", "ABCDABCDABC", "xx", 2, .T. ) + '"'
   ? '  AtRepl( "ABC", "ABCDABCDABC", "xx", 2, .T., 1 ) == "ABCDABCDxx" ? '
   ? '           --> "' + AtRepl( "ABC", "ABCDABCDABC", "xx", 2, .T., 1 ) + '"'

   ? "End test of AtRepl()"
   ?

   ctexit()

   RETURN


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

[User] Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/ctmisc.prg. Provides 8 functions including: AlloFree, Center, CSetCurs, CSetKey, CSetCent. This file provides legacy compatibility functions

[Assistant]
#include "color.ch"
#include "setcurs.ch"

#include "hbmemory.ch"

FUNCTION AlloFree( lMode )

   hb_default( @lMode, .F. )

   RETURN Memory( iif( lMode, HB_MEM_CHAR, HB_MEM_BLOCK ) )

FUNCTION Center( c, n, p, lMode )

   LOCAL cRet

   IF ! HB_ISNUMERIC( n )
      n := MaxCol() + 1 - Col()
      c := ""
   ENDIF

   IF HB_ISLOGICAL( p )
      lMode := p
      p := NIL
   ELSE
      IF ! HB_ISLOGICAL( lMode )
         lMode := .F.
      ENDIF
   ENDIF

   cRet := PadC( RTrim( c ), n, p )

   RETURN iif( lMode, cRet, RTrim( cRet ) )

FUNCTION CSetCurs( l )

   IF ! HB_ISLOGICAL( l )
      RETURN SetCursor() != SC_NONE
   ENDIF

   RETURN SetCursor( iif( l, SC_NORMAL, SC_NONE ) ) != SC_NONE

FUNCTION CSetKey( n )

   RETURN SetKey( n )

FUNCTION CSetCent( nCentury )

   RETURN __SetCentury( nCentury )

FUNCTION LToC( l )

   RETURN iif( l, "T", "F" )

FUNCTION DosParam()

   LOCAL cRet := ""
   LOCAL nCount := hb_argc(), i

   FOR i := 1 TO nCount
      cRet += iif( i == 1, "", " " ) + hb_argv( i )
   NEXT

   RETURN cRet

FUNCTION ExeName()

   RETURN hb_ProgName()


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

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

Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tbwhile.prg. Provides functions: ft_BrwsWhl, TbSkipWhil, TbWhileTop, TbWhileBot. This file provides legacy compatibility functions

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

FUNCTION ft_BrwsWhl( aFields, bWhileCond, cKey, nFreeze, lSaveScrn, ;
      cColorList, cColorShad, nTop, nLeft, nBottom, nRight )

   LOCAL b, column, i
   LOCAL cHead, bField, lKeepScrn, cScrnSave
   LOCAL cColorSave, cColorBack, nCursSave
   LOCAL lMore, nKey, nPassRec

   __defaultNIL( @nFreeze, 0 )
   __defaultNIL( @lSaveScrn, .T. )
   __defaultNIL( @cColorList, "N/W, N/BG, B/W, B/BG, B/W, B/BG, R/W, B/R" )
   __defaultNIL( @cColorShad, "N/N" )
   __defaultNIL( @nTop, 2 )
   __defaultNIL( @nLeft, 2 )
   __defaultNIL( @nBottom, MaxRow() - 2 )
   __defaultNIL( @nRight, MaxCol() - 2 )

   lKeepScrn := PCount() > 6

   dbSeek( cKey )
   IF ! Found() .OR. LastRec() == 0
      RETURN 0
   ENDIF

   b := TBrowseDB( nTop, nLeft, nBottom, nRight )

   b:headSep := hb_UTF8ToStrBox( "═╤═" )
   b:colSep  := hb_UTF8ToStrBox( " │ " )
   b:footSep := hb_UTF8ToStrBox( "═╧═" )

   b:skipBlock := {| x | TbSkipWhil( x, bWhileCond ) }

   b:goTopBlock    := {|| TbWhileTop( cKey ) }
   b:goBottomBlock := {|| TbWhileBot( cKey ) }

   b:colorSpec := cColorList

   FOR i := 1 TO Len( aFields )
      cHead  := aFields[ i, 1 ]
      bField := aFields[ i, 2 ]

      column := TBColumnNew( cHead, bField )

      column:defColor := { 3, 4 }

      b:addColumn( column )
   NEXT

   IF nFreeze != 0
      b:freeze := nFreeze
   ENDIF

   IF lSaveScrn
      cScrnSave := SaveScreen( 0, 0, MaxRow(), MaxCol() )
   ENDIF
   cColorSave := SetColor()

   cColorBack := iif( "," $ cColorList, ;
      SubStr( cColorList, 1, At( ",", cColorList ) - 1 ), cColorList )

   IF ! lKeepScrn
      SetColor( cColorBack )
      hb_Scroll()
   ENDIF

   hb_Scroll( nTop + 1, nLeft + 1, nBottom + 1, nRight + 1,,, cColorShad )
   hb_Scroll( nTop, nLeft, nBottom, nRight,,, cColorBack )
   SetColor( cColorSave )

   nCursSave := SetCursor( SC_NONE )

   lMore := .T.
   DO WHILE lMore

      nKey := 0
      DispBegin()
      DO WHILE nKey == 0 .AND. ! b:stable
         b:stabilize()
         nKey := Inkey()
      ENDDO
      DispEnd()

      IF b:stable

         IF b:hitTop .OR. b:hitBottom
            Tone( 125, 0 )
         ENDIF

         DispBegin()
         b:refreshCurrent()
         b:forceStable()
         DispEnd()

         nKey := Inkey( 0 )
      ENDIF

      SWITCH nKey
      CASE K_DOWN
         b:down()
         EXIT

      CASE K_UP
         b:up()
         EXIT

      CASE K_PGDN
         b:pageDown()
         EXIT

      CASE K_PGUP
         b:pageUp()
         EXIT

      CASE K_CTRL_PGUP
         b:goTop()
         EXIT

      CASE K_CTRL_PGDN
         b:goBottom()
         EXIT

      CASE K_RIGHT
         b:Right()
         EXIT

      CASE K_LEFT
         b:Left()
         EXIT

      CASE K_HOME
         b:home()
         EXIT

      CASE K_END
         b:end()
         EXIT

      CASE K_CTRL_LEFT
         b:panLeft()
         EXIT

      CASE K_CTRL_RIGHT
         b:panRight()
         EXIT

      CASE K_CTRL_HOME
         b:panHome()
         EXIT

      CASE K_CTRL_END
         b:panEnd()
         EXIT

      CASE K_ESC
         nPassRec := 0
         lMore := .F.
         EXIT

      CASE K_ENTER
         nPassRec := RecNo()
         lMore := .F.
         EXIT

      ENDSWITCH
   ENDDO

   IF lSaveScrn
      RestScreen( 0, 0, MaxRow(), MaxCol(), cScrnSave )
   ENDIF
   SetCursor( nCursSave )
   SetColor( cColorSave )

   RETURN nPassRec

STATIC FUNCTION TbSkipWhil( n, bWhileCond )

   LOCAL i := 0

   IF n == 0 .OR. LastRec() == 0
      dbSkip( 0 )

   ELSEIF n > 0 .AND. RecNo() != LastRec() + 1
      WHILE i < n
         dbSkip()
         IF Eof() .OR. ! Eval( bWhileCond )
            dbSkip( -1 )
            EXIT
         ENDIF
         i++
      ENDDO

   ELSEIF n < 0
      DO WHILE i > n
         dbSkip( -1 )
         IF Bof()
            EXIT
         ELSEIF ! Eval( bWhileCond )
            dbSkip()
            EXIT
         ENDIF
         i--
      ENDDO
   ENDIF

   RETURN i

STATIC FUNCTION TbWhileTop( cKey )

   dbSeek( cKey )

   RETURN NIL

STATIC FUNCTION TbWhileBot( cKey )

   dbSeek( Left( cKey, Len( cKey ) - 1 ) + Chr( Asc( Right( cKey, 1 ) ) + 1 ), .T. )
   dbSkip( -1 )

   RETURN NIL


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

[User] Implement this Harbour module: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/atnum.prg. Contains procedures: Main. This file provides legacy compatibility functions

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

#include "ct.ch"

PROCEDURE Main()

   LOCAL cStr := "...This...is...a...test!"

   ctinit()

   ? "Begin test of AtNum()"
   ?
   ? "  Value of cStr is: " + '"' + cStr + '"'
   ?

   ? "  Simple tests:"
   ? '  AtNum( "..", cStr )       should be 18,'
   ? '                               and is ', AtNum( "..", cStr )
   ? '  AtNum( "..", cStr, 2 )    should be 8,'
   ? '                               and is ', AtNum( "..", cStr, 2 )
   ? '  AtNum( "..", cStr, 2, 2 ) should be 13,'
   ? '                               and is ', AtNum( "..", cStr, 2, 2 )
   ?

   ? "  Multi-Pass tests"
   ? "  Setting CSetAtMupa() to .T."
   CSetAtMupa( .T. )
   ? '  AtNum( "..", cStr )       should be 18,'
   ? '                               and is ', AtNum( "..", cStr )
   ? '  AtNum( "..", cStr, 2 )    should be 2,'
   ? '                               and is ', AtNum( "..", cStr, 2 )
   ? '  AtNum( "..", cStr, 2, 2 ) should be 9,'
   ? '                               and is ', AtNum( "..", cStr, 2, 2 )
   ? "  Setting CSetAtMupa() to .F."
   CSetAtMupa( .F. )
   ?

   ? "  SetAtLike tests"
   ? '  Setting SetAtLike( CT_SETATLIKE_WILDCARD, "." )'
   SetAtLike( CT_SETATLIKE_WILDCARD, "." )
   ? '  AtNum( "..", cStr )        should be 23,'
   ? '                                and is ', AtNum( "..", cStr )
   ? '  AtNum( "..", cStr, 2, 2 )  should be 5,'
   ? '                                and is ', AtNum( "..", cStr, 2, 2 )
   ? '  AtNum( "..", cStr, 2, 10 ) should be 13,'
   ? '                                and is ', AtNum( "..", cStr, 2, 10 )
   ?

   ? "End test of AtNum()"
   ?

   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] Implement this Harbour module: Harbour test program: tests/usrrdd/exhsx.prg. Contains procedures: Main. This test file tests specific function APIs

[Assistant]
#include "dbinfo.ch"

PROCEDURE Main()

   FIELD FIRST, LAST, STREET, CITY
   LOCAL n, hs

   dbCreate( "_tst", { ;
      { "FIRST",       "C", 20,  0 }, ;
      { "LAST",        "C", 20,  0 }, ;
      { "STREET",      "C", 30,  0 }, ;
      { "CITY",        "C", 30,  0 }, ;
      { "STATE",       "C",  2,  0 }, ;
      { "ZIP",         "C", 10,  0 }, ;
      { "HIREDATE",    "D",  8,  0 }, ;
      { "MARRIED",     "L",  1,  0 }, ;
      { "AGE",         "N",  2,  0 }, ;
      { "SALARY",      "N",  6,  0 }, ;
      { "NOTES",       "C", 70,  0 } } )
   USE _tst
   HSX_CREATE( "_tst", "FIRST+LAST+STREET+CITY", 2, 0, .T., 3 )
   APPEND FROM test

   hs := HSX_HANDLE( "_tst" )
   hs_Set( hs, "SHERMAN" )
   DO WHILE ( n := hs_Next( hs ) ) > 0
      dbGoto( n )
      IF hs_Verify( hs ) > 0
         ? RTrim( FIRST + LAST + STREET + CITY )
      ENDIF
   ENDDO
   WAIT

   IF dbInfo( DBI_RM_SUPPORTED )

      hs_Filter( hs, "SHERMAN" )
      dbGoTop()
      Browse()
   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] Define Harbour macros and constants: Harbour Runtime Library file: src/debug/dbgtarr.prg. Defines classes: HBDbArray. Provides functions: __dbgArrays, GetTopPos, GetBottomPos, ArrayBrowseSkip. This file provides utility functions

[Assistant]
#pragma -b-

#define HB_CLS_NOTOBJECT
#include "hbclass.ch"

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

CREATE CLASS HBDbArray

   VAR aWindows   INIT {}
   VAR TheArray
   VAR arrayname
   VAR nCurWindow INIT 0
   VAR lEditable

   METHOD New( aArray, cVarName, lEditable )

   METHOD addWindows( aArray, nRow )
   METHOD doGet( oBrowse, pItem, nSet )
   METHOD SetsKeyPressed( nKey, oBrwSets, oWnd, cName, aArray )

ENDCLASS

METHOD New( aArray, cVarName, lEditable ) CLASS HBDbArray

   ::arrayName := cVarName
   ::TheArray := aArray
   ::lEditable := hb_defaultValue( lEditable, .T. )

   ::addWindows( ::TheArray )

   RETURN Self

METHOD addWindows( aArray, nRow ) CLASS HBDbArray

   LOCAL oBrwSets
   LOCAL nSize := Len( aArray )
   LOCAL oWndSets
   LOCAL nColWidth
   LOCAL oCol

   IF nSize < MaxRow() - 2
      IF HB_ISNUMERIC( nRow )
         oWndSets := HBDbWindow():New( GetTopPos( nRow ), 5, getBottomPos( nRow + nSize + 1 ), MaxCol() - 5, ;
            ::arrayName + "[1.." + hb_ntos( nSize ) + "]", "N/W" )
      ELSE
         oWndSets := HBDbWindow():New( 1, 5, 2 + nSize, MaxCol() - 5, ;
            ::arrayName + "[1.." + hb_ntos( nSize ) + "]", "N/W" )
      ENDIF
   ELSE
      oWndSets := HBDbWindow():New( 1, 5, MaxRow() - 2, MaxCol() - 5, ;
         ::arrayName + "[1.." + hb_ntos( nSize ) + "]", "N/W" )
   ENDIF

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

   oBrwSets := HBDbBrowser():New( oWndSets:nTop + 1, oWndSets:nLeft + 1, oWndSets:nBottom - 1, oWndSets:nRight - 1 )
   oBrwSets:ColorSpec := __dbg():ClrModal()
   oBrwSets:Cargo := { 1, {} }
   AAdd( oBrwSets:Cargo[ 2 ], aArray )

   oBrwSets:AddColumn( oCol := HBDbColumnNew( "", {|| ::arrayName + "[" + hb_ntos( oBrwSets:cargo[ 1 ] ) + "]" } ) )
   oCol:width := Len( ::arrayName + "[" + hb_ntos( Len( aArray ) ) + "]" )
   oCol:DefColor := { 1, 2 }
   nColWidth := oCol:Width

   oBrwSets:AddColumn( oCol := HBDbColumnNew( "", {|| __dbgValToExp( aArray[ oBrwSets:cargo[ 1 ] ] ) } ) )

   oCol:width := oWndSets:nRight - oWndSets:nLeft - nColWidth - 2
   oCol:defColor := { 1, 3 }

   oBrwSets:goTopBlock := {|| oBrwSets:cargo[ 1 ] := 1 }
   oBrwSets:goBottomBlock := {|| oBrwSets:cargo[ 1 ] := Len( oBrwSets:cargo[ 2 ][ 1 ] ) }
   oBrwSets:skipBlock := {| nPos | nPos := ArrayBrowseSkip( nPos, oBrwSets ), ;
                                   oBrwSets:cargo[ 1 ] := oBrwSets:cargo[ 1 ] + nPos, nPos }
   oBrwSets:colPos := 2

   ::aWindows[ ::nCurWindow ]:bPainted    := {|| oBrwSets:forcestable() }
   ::aWindows[ ::nCurWindow ]:bKeyPressed := ;
      {| nKey | ::SetsKeyPressed( nKey, oBrwSets, ::aWindows[ ::nCurWindow ], ::arrayName, aArray ) }

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

   RETURN Self

METHOD PROCEDURE doGet( oBrowse, pItem, nSet ) CLASS HBDbArray

   LOCAL oErr
   LOCAL cValue

   oBrowse:forceStable()

   cValue := __dbgValToExp( pItem[ nSet ] )

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

   RETURN

METHOD SetsKeyPressed( nKey, oBrwSets, oWnd, cName, aArray ) CLASS HBDbArray

   LOCAL nSet := oBrwSets:cargo[ 1 ]
   LOCAL cOldName := ::arrayName

   SWITCH nKey
   CASE K_UP
      oBrwSets:Up()
      EXIT

   CASE K_DOWN
      oBrwSets:Down()
      EXIT

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

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

   CASE K_PGDN
      oBrwSets:pageDown()
      EXIT

   CASE K_PGUP
      oBrwSets:PageUp()
      EXIT

   CASE K_ENTER
      IF HB_ISARRAY( aArray[ nSet ] )
         IF Len( aArray[ nSet ] ) == 0
            __dbgAlert( "Array is empty" )
         ELSE
            SetPos( oWnd:nBottom, oWnd:nLeft )
            ::aWindows[ ::nCurWindow ]:lFocused := .F.
            ::arrayname := ::arrayname + "[" + hb_ntos( nSet ) + "]"
            ::AddWindows( aArray[ nSet ], oBrwSets:RowPos + oBrwSets:nTop )
            ::arrayname := cOldName

            hb_ADel( ::aWindows, ::nCurWindow, .T. )
            IF ::nCurWindow == 0
               ::nCurWindow := 1
            ELSE
               ::nCurWindow--
            ENDIF
         ENDIF
      ELSEIF HB_ISPOINTER( aArray[ nSet ] ) .OR. ! ::lEditable
         __dbgAlert( "Value cannot be edited" )
      ELSE
         oBrwSets:RefreshCurrent()
         DO CASE
         CASE HB_ISOBJECT( aArray[ nSet ] )
            __dbgObject( aArray[ nSet ], cName + "[" + hb_ntos( nSet ) + "]" )
         CASE HB_ISHASH( aArray[ nSet ] )
            IF Len( aArray[ nSet ] ) == 0
               __dbgAlert( "Hash is empty" )
            ELSE
               __dbgHashes( aArray[ nSet ], cName + "[" + hb_ntos( nSet ) + "]" )
            ENDIF
         OTHERWISE
            ::doGet( oBrwsets, aArray, nSet )
         ENDCASE
         oBrwSets:RefreshCurrent()
         oBrwSets:ForceStable()
      ENDIF
      EXIT

   ENDSWITCH

   oBrwSets:forceStable()

   ::aWindows[ ::nCurWindow ]:SetCaption( cName + "[" + hb_ntos( oBrwSets:cargo[ 1 ] ) + ".." + ;
      hb_ntos( Len( aArray ) ) + "]" )

   RETURN Self

FUNCTION __dbgArrays( aArray, cVarName, lEditable )
   RETURN HBDbArray():New( aArray, cVarName, lEditable )

STATIC FUNCTION GetTopPos( nPos )
   RETURN iif( ( MaxRow() - nPos ) < 5, MaxRow() - nPos, nPos )

STATIC FUNCTION GetBottomPos( nPos )
   RETURN iif( nPos < MaxRow() - 2, nPos, MaxRow() - 2 )

STATIC FUNCTION ArrayBrowseSkip( nPos, oBrwSets )
   RETURN ;
      iif( oBrwSets:cargo[ 1 ] + nPos < 1, -oBrwSets:cargo[ 1 ] + 1, ;
      iif( oBrwSets:cargo[ 1 ] + nPos > Len( oBrwSets:cargo[ 2 ][ 1 ] ), ;
      Len( oBrwSets:cargo[ 2 ][ 1 ] ) - oBrwSets:cargo[ 1 ], nPos ) )


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

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

Harbour contribution module 'gtwvg' (): contrib/gtwvg/tests/_cuigdlg.prg. Provides functions: FetchText. Contains procedures: ExecGCUI, GCUIConsole. This file provides platform-specific functionality

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

PROCEDURE ExecGCUI()

   IF hb_mtvm()
      hb_threadStart( {| oCrt | oCrt := WvgCrt():New( , , { 2, 4 }, { 20, 81 }, , .T. ), ;
         oCrt:icon := GetResource( "dia_excl.ico" ), ;
         oCrt:create(), ;
         GCUIConsole( oCrt ), ;
         oCrt:destroy() } )
   ENDIF

   RETURN

#xtranslate Alert( => MyAlert(

PROCEDURE GCUIConsole( oCrt )

   LOCAL dDate      := Date()
   LOCAL cName      := PadR( "Some Usefule Name", 35 )
   LOCAL cAdd1      := PadR( "Linda Goldman Avenue", 35 )
   LOCAL cAdd2      := PadR( "Excellent Street", 35 )
   LOCAL cAdd3      := PadR( "Suit #415", 35 )
   LOCAL nSlry      := 9000
   LOCAL nColGet    := 8
   LOCAL GetList    := {}
   LOCAL hBoxR, hTxt

   SET SCOREBOARD OFF

   SetColor( "N/W,N/GR*,,,N/W*" )
   CLS
   hb_gtInfo( HB_GTI_WINTITLE, "WVG Simplified yet Powerful CUI-GUI Console!" )

   @ MaxRow(), 0 SAY PadC( "Navigate the Gets", MaxCol() + 1 ) COLOR "W+/B"

   @  2, nColGet SAY "< Date >"
   @  5, nColGet SAY "<" + PadC( "Name", 33 ) + ">"
   @  8, nColGet SAY "<" + PadC( "Address", 33 ) + ">"
   @ 15, nColGet SAY "< Salary >"

   @  3, nColGet GET dDate  ;
      WHEN  {|| Wvg_SetGObjData( hTxt, 1, FetchText( 1 ) ) } ;
      VALID {|| Wvg_SetGObjData( hTxt, 6, RGB( 255, 0, 0 ) ), .T. }
   @  6, nColGet GET cName  ;
      WHEN  {|| Wvg_SetGObjData( hTxt, 1, FetchText( 2 ) ) } ;
      VALID {|| Wvg_SetGObjData( hTxt, 6, RGB( 255, 255, 0 ) ), ;
      Wvg_SetGObjState( hBoxR, 3 ), .T. }
   @  9, nColGet GET cAdd1  ;
      WHEN  {|| Wvg_SetGObjData( hTxt, 1, FetchText( 3 ) ) } ;
      VALID {|| Wvg_SetGObjData( hTxt, 6, RGB( 255, 0, 255 ) ), .T. }
   @ 11, nColGet GET cAdd2  ;
      WHEN  {|| Wvg_SetGObjData( hTxt, 1, FetchText( 4 ) ) } ;
      VALID {|| Wvg_SetGObjData( hTxt, 6, RGB( 255, 255, 255 ) ), ;
      Wvg_SetGObjState( hBoxR, 1 ), .T. }
   @ 13, nColGet GET cAdd3  ;
      WHEN  {|| Wvg_SetGObjData( hTxt, 6, RGB( 198, 21, 140 ) ), .T. }
   @ 16, nColGet GET nSlry PICTURE "@Z 9999999.99" ;
      WHEN  {|| Wvg_SetGObjData( hTxt, 6, RGB( 0, 0, 0 ) ), .T. }

   AEval( GetList, {| oGet | Wvg_BoxGet( oGet:Row, oGet:Col, Len( Transform( oGet:VarGet(), oGet:Picture ) ) ) } )

   hBoxR := Wvg_BoxRaised( 1, 2, 18, 49, { -5, -5, 5, 5 } )

   Wvg_BoxRecessed( 1, 2, 18, 49 )

   Wvg_BoxGroupRaised( 2, 4, 17, 47, { -7, -7, 7, 7 } )

   hTxt := Wvg_TextBox( 3, 57, 16, 75, { 10, 10, -10, -10 }, "This is first TextBox Line!", 2, 2 )

   Wvg_Image( 15, 36, 16, 42, { -3, -3, 3, 3 }, GOBJ_IMAGESOURCE_FILE, GetResource( "Vouch1.bmp" ) )
   Wvg_BoxRaised( 15, 36, 16, 42, { -2, -2, 2, 2 } )

   Wvg_ShadedRect( 1, 54, 18, 79, { -5, -5, 5, 5 }, 0, { 65000, 21000, 7000, 56000 }, { 255, 32255, 16000, 32500 } )

   Wvg_BoxRaised( 1, 54, 18, 79, { -5, -5, 5, 5 } )

   oCrt:refresh()

   READ

   My_Alert( "How did you like the 'Alert' replacement?", { "WOW", "OK", "OOps" } )

   RETURN

STATIC FUNCTION FetchText( nMode )

   LOCAL cText

   DO CASE
   CASE nMode == 1
      cText := "Do you know Harbour is gaining a popularity what Clipper enjoyed at one time! "
      cText += "Enjoy it."
   CASE nMode == 2
      cText := "Do you know Harbour can host pure console, cui+gui console, pure gui consoles applications? "
      cText += "This demonstration is a proof of that."
   CASE nMode == 3
      cText := "Do you know Harbour is a multi-gt, multi-window, multi-thread compiler far superior than others in the market! "
      cText += "And is FREE."
   CASE nMode == 4
      cText := "Enjoy and contribute to the project any way you can. Develop, Debug, Support, and spread a word of mouth!"
   ENDCASE

   RETURN cText