{"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/tests/counter.prg. Contains procedures: Main. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbgd\"\n\n\n#define IMAGES_IN \"imgs_in\" + hb_ps()\n#define IMAGES_OUT \"imgs_out\" + hb_ps()\n\n#define DISPLAY_NUM 10\n\nPROCEDURE Main( cValue, cBaseImage )\n\n LOCAL oI, oIDigits, nWidth, nHeight, nDigits, nNumWidth, oTemp\n\n LOCAL aNumberImages := {}\n LOCAL n, nValue\n\n \n hb_default( @cValue, Str( hb_RandomInt( 1, 10 ^ DISPLAY_NUM ), DISPLAY_NUM ) )\n hb_default( @cBaseImage, \"d57chevy.gif\" )\n\n IF ! hb_FileExists( IMAGES_IN + cBaseImage )\n ? \"ERROR: Base Image File '\" + IMAGES_IN + cBaseImage + \"' not found\"\n QUIT\n ENDIF\n\n nValue := Val( cValue )\n\n \n IF nValue > 10 ^ DISPLAY_NUM\n nValue := 10 ^ DISPLAY_NUM\n ENDIF\n\n cValue := StrZero( nValue, DISPLAY_NUM )\n\n ? \"Value = \", cValue\n\n \n oIDigits := GDImage():LoadFromGif( IMAGES_IN + cBaseImage )\n\n \n nWidth := oIDigits:Width()\n nHeight := oIDigits:Height()\n\n \n DO CASE\n CASE nWidth % 10 == 0 \n nDigits := 10\n CASE nWidth % 11 == 0 \n nDigits := 11\n CASE nWidth % 13 == 0 \n nDigits := 13\n OTHERWISE\n ? \"Error on digits image\"\n ENDCASE\n nNumWidth := nWidth / nDigits\n\n ? \"nNumWidth, nWidth, nHeight, nDigits = \", nNumWidth, nWidth, nHeight, nDigits\n\n \n FOR n := 1 TO nDigits\n oTemp := oIDigits:Copy( ( n - 1 )\n oTemp:SaveGif( IMAGES_OUT + StrZero( n - 1, 2 ) + \".gif\" )\n \n \n AAdd( aNumberImages, oTemp:Clone() )\n NEXT\n\n \n oI := GDImage():New( nNumWidth\n ? \"Image dimensions: \", oI:Width(), oI:Height()\n\n \n FOR n := 1 TO Len( cValue )\n \n oTemp := aNumberImages[ Val( SubStr( cValue, n, 1 ) ) + 1 ]:Clone()\n \n oTemp:SaveGif( IMAGES_OUT + \"Pos_\" + StrZero( n, 2 ) + \".gif\" )\n \n oI:SetTile( oTemp )\n \n oI:Rectangle( ( n - 1 )\n oI:SaveGif( IMAGES_OUT + \"counter.gif\" )\n\n \n ?\n ? \"Look at \" + IMAGES_OUT + \" folder for output images\"\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/qtr.prg. Provides functions: ft_Qtr. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_Qtr( dGivenDate, nQtrNum )\n\n LOCAL nTemp, aRetVal\n\n IF HB_ISNUMERIC( dGivenDate )\n nQtrNum := dGivenDate\n dGivenDate := Date()\n ELSEIF ! HB_ISDATE( dGivenDate )\n dGivenDate := Date()\n ENDIF\n\n aRetval := ft_Year( dGivenDate )\n\n IF HB_ISNUMERIC( nQtrNum )\n IF nQtrNum < 1 .OR. nQtrNum > 4\n nQtrNum := 4\n ENDIF\n dGivenDate := ft_MAdd( aRetVal[ 2 ], 3"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour header file: include/set.ch. Defines 10 constants including: _SET_CH, _SET_EXACT, _SET_FIXED, _SET_DECIMALS, _SET_DATEFORMAT. Defines color and display constants"}, {"role": "assistant", "content": "#ifndef _SET_CH\n#define _SET_CH\n\n#define _SET_EXACT 1\n#define _SET_FIXED 2\n#define _SET_DECIMALS 3\n#define _SET_DATEFORMAT 4\n#define _SET_EPOCH 5\n#define _SET_PATH 6\n#define _SET_DEFAULT 7\n\n#define _SET_EXCLUSIVE 8\n#define _SET_SOFTSEEK 9\n#define _SET_UNIQUE 10\n#define _SET_DELETED 11\n\n#define _SET_CANCEL 12\n#define _SET_DEBUG 13\n#define _SET_TYPEAHEAD 14\n\n#define _SET_COLOR 15\n#define _SET_CURSOR 16\n#define _SET_CONSOLE 17\n#define _SET_ALTERNATE 18\n#define _SET_ALTFILE 19\n#define _SET_DEVICE 20\n#define _SET_EXTRA 21\n#define _SET_EXTRAFILE 22\n#define _SET_PRINTER 23\n#define _SET_PRINTFILE 24\n#define _SET_MARGIN 25\n\n#define _SET_BELL 26\n#define _SET_CONFIRM 27\n#define _SET_ESCAPE 28\n#define _SET_INSERT 29\n#define _SET_EXIT 30\n#define _SET_INTENSITY 31\n#define _SET_SCOREBOARD 32\n#define _SET_DELIMITERS 33\n#define _SET_DELIMCHARS 34\n\n#define _SET_WRAP 35\n#define _SET_MESSAGE 36\n#define _SET_MCENTER 37\n#define _SET_SCROLLBREAK 38\n\n#define _SET_EVENTMASK 39 \n\n#define _SET_VIDEOMODE 40 \n\n#define _SET_MBLOCKSIZE 41 \n#define _SET_MFILEEXT 42 \n\n#define _SET_STRICTREAD 43 \n#define _SET_OPTIMIZE 44 \n#define _SET_AUTOPEN 45 \n#define _SET_AUTORDER 46 \n#define _SET_AUTOSHARE 47 \n\n#define _SET_COUNT 47\n\n#define _SET_LANGUAGE 100 \n#define _SET_IDLEREPEAT 101 \n#define _SET_FILECASE 102 \n#define _SET_DIRCASE 103 \n#define _SET_DIRSEPARATOR 104 \n#define _SET_EOF 105 \n#define _SET_HARDCOMMIT 106 \n#define _SET_FORCEOPT 107 \n#define _SET_DBFLOCKSCHEME 108 \n#define _SET_DEFEXTENSIONS 109 \n#define _SET_EOL 110 \n#define _SET_TRIMFILENAME 111 \n#define _SET_HBOUTLOG 112 \n#define _SET_HBOUTLOGINFO 113 \n#define _SET_CODEPAGE 114 \n#define _SET_OSCODEPAGE 115 \n#define _SET_TIMEFORMAT 116 \n#define _SET_DBCODEPAGE 117 \n\n#define HB_SET_BASE 100\n#define HB_SET_COUNT ( _SET_DBCODEPAGE - HB_SET_BASE + 1 )\n\n#define HB_SET_CASE_MIXED 0\n#define HB_SET_CASE_LOWER 1\n#define HB_SET_CASE_UPPER 2\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/ftpcli.prg. Defines classes: TIPClientFTP. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"directry.ch\"\n\n#include \"tip.ch\"\n\n#define _PORT_MIN 16000\n#define _PORT_MAX 24000\n\nSTATIC s_nPort := _PORT_MIN\nSTATIC s_mutexPort := hb_mutexCreate()\n\nCREATE CLASS TIPClientFTP INHERIT TIPClient\n\n VAR nDataPort\n VAR cDataServer\n VAR bUsePasv INIT .T.\n VAR RegBytes\n VAR RegPasv\n \n VAR SocketControl\n VAR SocketPortServer\n\n METHOD New( oUrl, xTrace, oCredentials )\n METHOD Open( cUrl )\n METHOD Close()\n METHOD GetReply()\n METHOD Commit()\n METHOD ScanLength()\n METHOD TransferStart()\n\n METHOD Pasv()\n METHOD Quit()\n METHOD TypeI()\n METHOD TypeA()\n METHOD NoOp()\n METHOD Rest( nPos )\n METHOD Pwd()\n METHOD Cwd( cPath )\n METHOD Dele( cPath )\n METHOD LS( cSpec )\n METHOD Rename( cFrom, cTo )\n METHOD MKD( cPath )\n METHOD RMD( cPath )\n METHOD Retr( cFile )\n METHOD Stor( cFile )\n METHOD List( cSpec )\n METHOD UserCommand( cCommand, lPasv, lReadPort, lGetReply )\n\n METHOD Port()\n METHOD SendPort()\n METHOD ReadAuxPort()\n METHOD Read( nLen )\n METHOD Write( cData, nLen )\n METHOD MGet( cSpec, cLocalPath )\n METHOD MPut( cFileSpec, cAttr )\n METHOD UploadFile( cLocalFile, cRemoteFile )\n METHOD DownloadFile( cLocalFile, cRemoteFile )\n METHOD ListFiles( cFileSpec )\n METHOD FileSize( cFileSpec )\n\nENDCLASS\n\nMETHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClientFTP\n\n ::super:new( oUrl, iif( hb_defaultValue( xTrace, .F. ), \"ftp\", xTrace ), oCredentials )\n\n ::nDefaultPort := 21\n ::nConnTimeout := 3000\n ::nAccessMode := TIP_RW \n\n ::nDefaultSndBuffSize := ::nDefaultRcvBuffSize := 65536\n\n \n ::RegBytes := hb_regexComp( \"\\(([0-9]+)[ )a-zA-Z]\" )\n ::RegPasv := hb_regexComp( \"([0-9]*) *, *([0-9]*) *, *([0-9]*) *, *([0-9]*) *, *([0-9]*) *, *([0-9]*)\" )\n\n RETURN Self\n\nMETHOD Open( cUrl ) CLASS TIPClientFTP\n\n IF HB_ISSTRING( cUrl )\n ::oUrl := TUrl():New( cUrl )\n ENDIF\n\n IF ! ::oUrl:cUserid == \"\" .AND. ;\n ! ::oUrl:cPassword == \"\"\n\n IF ::super:Open()\n IF ::GetReply()\n ::inetSendAll( ::SocketCon, \"USER \" + ::oUrl:cUserid + ::cCRLF )\n IF ::GetReply()\n ::inetSendAll( ::SocketCon, \"PASS \" + ::oUrl:cPassword + ::cCRLF )\n IF ::GetReply() .AND. ::TypeI() \n RETURN .T.\n ENDIF\n ENDIF\n ENDIF\n ENDIF\n ENDIF\n\n RETURN .F.\n\nMETHOD Close() CLASS TIPClientFTP\n\n ::InetTimeOut( ::SocketCon )\n\n ::Quit()\n\n RETURN ::super:Close()\n\nMETHOD GetReply() CLASS TIPClientFTP\n\n LOCAL nLen\n LOCAL cRep := ::cReply := ::inetRecvLine( ::SocketCon, @nLen, 128 )\n\n IF cRep == NIL\n RETURN .F.\n ENDIF\n\n \n DO WHILE ! Empty( cRep ) .AND. SubStr( cRep, 4, 1 ) == \"-\"\n cRep := ::cReply := hb_defaultValue( ::inetRecvLine( ::SocketCon, @nLen, 128 ), \"\" )\n ENDDO\n\n \n RETURN ::inetErrorCode( ::SocketCon ) == 0 .AND. Val( Left( ::cReply, 1 ) ) < 4\n\nMETHOD Commit() CLASS TIPClientFTP\n\n hb_inetClose( ::SocketCon )\n\n ::SocketCon := ::SocketControl\n ::bInitialized := .F.\n\n \n RETURN ::GetReply() .AND. ! hb_LeftEq( ::cReply, \"5\" )\n\n\nMETHOD ScanLength() CLASS TIPClientFTP\n\n LOCAL aBytes := hb_regex( ::RegBytes, ::cReply )\n\n IF ! Empty( aBytes )\n ::nLength := Val( aBytes[ 2 ] )\n ENDIF\n\n RETURN .T.\n\nMETHOD TransferStart() CLASS TIPClientFTP\n\n LOCAL skt\n\n ::SocketControl := ::SocketCon\n\n IF ::bUsePasv\n skt := hb_inetConnectIP( ::cDataServer, ::nDataPort )\n IF skt != NIL .AND. ::inetErrorCode( skt ) == 0\n \n IF ! ::GetReply()\n hb_inetClose( skt )\n RETURN .F.\n ENDIF\n\n ::InetTimeOut( skt )\n\n ::SocketCon := skt\n ELSE\n RETURN .F.\n ENDIF\n ELSE\n ::SocketCon := hb_inetAccept( ::SocketPortServer )\n IF Empty( ::SocketCon )\n ::bInitialized := .F.\n ::SocketCon := ::SocketControl\n ::GetReply()\n RETURN .F.\n ENDIF\n ENDIF\n\n \n IF HB_ISNUMERIC( ::nDefaultSndBuffSize )\n ::InetSndBufSize( ::SocketCon, ::nDefaultSndBuffSize )\n ENDIF\n IF HB_ISNUMERIC( ::nDefaultRcvBuffSize )\n ::InetRcvBufSize( ::SocketCon, ::nDefaultRcvBuffSize )\n ENDIF\n\n RETURN .T.\n\nMETHOD Pasv() CLASS TIPClientFTP\n\n LOCAL aRep\n\n ::inetSendAll( ::SocketCon, \"PASV\" + ::cCRLF )\n\n IF ! ::GetReply()\n RETURN .F.\n ENDIF\n\n IF Empty( aRep := hb_regex( ::RegPasv, ::cReply ) )\n RETURN .F.\n ENDIF\n\n ::cDataServer := aRep[ 2 ] + \".\" + aRep[ 3 ] + \".\" + aRep[ 4 ] + \".\" + aRep[ 5 ]\n ::nDataPort := Val( aRep[ 6 ] )\n ::inetSendAll( ::SocketCon, \"QUIT\" + ::cCRLF )\n\n RETURN ::GetReply()\n\nMETHOD TypeI() CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"TYPE I\" + ::cCRLF )\n\n RETURN ::GetReply()\n\nMETHOD TypeA() CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"TYPE A\" + ::cCRLF )\n\n RETURN ::GetReply()\n\nMETHOD NoOp() CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"NOOP\" + ::cCRLF )\n\n RETURN ::GetReply()\n\nMETHOD Rest( nPos ) CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"REST \" + hb_ntos( Int( hb_defaultValue( nPos, 0 ) ) ) + ::cCRLF )\n\n RETURN ::GetReply()\n\nMETHOD PWD() CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"PWD\" + ::cCRLF )\n IF ::GetReply()\n ::cReply := SubStr( ::cReply, At( '\"', ::cReply ) + 1, ;\n RAt( '\"', ::cReply ) - At( '\"', ::cReply ) - 1 )\n RETURN .T.\n ENDIF\n\n RETURN .F.\n\nMETHOD CWD( cPath ) CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"CWD \" + cPath + ::cCRLF )\n\n RETURN ::GetReply()\n\nMETHOD Dele( cPath ) CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"DELE \" + cPath + ::cCRLF )\n\n RETURN ::GetReply()\n\nMETHOD LS( cSpec ) CLASS TIPClientFTP\n\n IF ::bUsePasv .AND. ! ::Pasv()\n RETURN .F.\n ENDIF\n\n IF ! ::bUsePasv .AND. ! ::Port()\n RETURN .F.\n ENDIF\n\n ::inetSendAll( ::SocketCon, \"NLST \" + hb_defaultValue( cSpec, \"\" ) + ::cCRLF )\n\n RETURN hb_defaultValue( ::ReadAuxPort(), \"\" )\n\nMETHOD Rename( cFrom, cTo ) CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"RNFR \" + hb_defaultValue( cFrom, \"\" ) + ::cCRLF )\n IF ::GetReply()\n ::inetSendAll( ::SocketCon, \"RNTO \" + hb_defaultValue( cTo, \"\" ) + ::cCRLF )\n RETURN ::GetReply()\n ENDIF\n\n RETURN .F.\n\n\nMETHOD MKD( cPath ) CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"MKD \" + cPath + ::cCRLF )\n\n RETURN ::GetReply()\n\n\nMETHOD RMD( cPath ) CLASS TIPClientFTP\n\n ::inetSendAll( ::SocketCon, \"RMD \" + cPath + ::cCRLF )\n\n RETURN ::GetReply()\n\nMETHOD Retr( cFile ) CLASS TIPClientFTP\n\n IF ::bUsePasv .AND. ! ::Pasv()\n RETURN .F.\n ENDIF\n\n ::inetSendAll( ::SocketCon, \"RETR \" + cFile + ::cCRLF )\n\n IF ::TransferStart()\n ::ScanLength()\n RETURN .T.\n ENDIF\n\n RETURN .F.\n\nMETHOD Stor( cFile ) CLASS TIPClientFTP\n\n IF ::bUsePasv .AND. ! ::Pasv()\n RETURN .F.\n ENDIF\n\n ::inetSendAll( ::SocketCon, \"STOR \" + cFile + ::cCRLF )\n\n \n IF ! ::bUsePasv\n ::GetReply()\n ENDIF\n\n RETURN ::TransferStart()\n\nMETHOD List( cSpec ) CLASS TIPClientFTP\n\n LOCAL cStr\n\n IF ::bUsePasv .AND. ! ::Pasv()\n RETURN NIL\n ENDIF\n IF ! ::bUsePasv .AND. ! ::Port()\n RETURN NIL\n ENDIF\n\n hb_default( @cSpec, \"\" )\n\n IF ! Empty( cSpec )\n cSpec := \" \" + cSpec\n ENDIF\n\n ::inetSendAll( ::SocketCon, \"LIST\" + cSpec + ::cCRLF )\n cStr := ::ReadAuxPort()\n ::bEof := .F.\n\n RETURN cStr\n\nMETHOD UserCommand( cCommand, lPasv, lReadPort, lGetReply ) CLASS TIPClientFTP\n\n IF ::bUsePasv .AND. hb_defaultValue( lPasv, .T. ) .AND. ! ::Pasv()\n RETURN .F.\n ENDIF\n\n ::inetSendAll( ::SocketCon, hb_defaultValue( cCommand, \"\" ) )\n\n IF hb_defaultValue( lReadPort, .T. )\n lReadPort := ::ReadAuxPort() \n ENDIF\n\n IF hb_defaultValue( lGetReply, .F. )\n lGetReply := ::GetReply() \n ENDIF\n\n RETURN .T.\n\nMETHOD Port() CLASS TIPClientFTP\n\n ::SocketPortServer := hb_inetCreate( ::nConnTimeout )\n\n hb_mutexLock( s_mutexPort )\n\n DO WHILE ++s_nPort < _PORT_MAX\n hb_inetServer( s_nPort, ::SocketPortServer )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/wvtext.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbgtinfo.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\n#define RGB( r, g, b ) ( r + ( g\n hbshell_gtSelect( \"GTWVT\" )\n #elif defined( __PLATFORM__UNIX )\n hbshell_gtSelect( \"GTXWC\" )\n #endif\n#endif\n\n AFill( aKeys, 0 )\n\n hb_gtInfo( HB_GTI_FONTNAME , \"Lucida Console\" )\n hb_gtInfo( HB_GTI_FONTWIDTH, nWidth )\n hb_gtInfo( HB_GTI_FONTSIZE , nHeight )\n hb_gtInfo( HB_GTI_WINTITLE , \"GT-Test (Resizable by FONT)\" )\n hb_gtInfo( HB_GTI_ALTENTER, .T. ) \n SetCursor( SC_NONE )\n\n hb_gtInfo( HB_GTI_CLOSABLE, .F. )\n\n DispScreen()\n\n DO WHILE .T.\n FOR nI := 1 TO Len( aKeys )\n IF aKeys[ nI ] == 0 .OR. nI > MaxRow() - 1\n EXIT\n ENDIF\n @ nI, MaxCol() - 5 SAY Str( aKeys[ nI ], 4, 0 )\n NEXT\n\n IF nMSec != NIL .AND. hb_MilliSeconds() > nMSec + 2000\n hb_DispOutAt( MaxRow(), 0, Space( MaxCol() + 1 ), \"N/G*\" )\n nMSec := NIL\n ENDIF\n\n nKey := Inkey( 0.1, 254 + HB_INKEY_GTEVENT )\n\n IF nKey == 0\n LOOP\n ENDIF\n\n AIns( aKeys, 1 )\n aKeys[ 1 ] := nKey\n FOR nI := 1 TO Len( aKeys )\n IF aKeys[ nI ] == 0 .OR. nI > MaxRow() - 1\n EXIT\n ENDIF\n @ nI, MaxCol() - 5 SAY Str( aKeys[ nI ], 4, 0 )\n NEXT\n\n IF nKey == K_ESC\n EXIT\n ENDIF\n\n\n DO CASE\n CASE nKey == K_ENTER\n Alert( \" Pressed\" )\n\n CASE nKey == hb_keyCode( \"0\" ) \n SetColor( \"W+/B,GR+/N,W/B,B/B,G+/N\" )\n DO WHILE .T.\n nModeCols := MaxCol() + 1\n nModeRows := MaxRow() + 1\n @ MaxRow() / 2 - 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2 + 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 2 SAY \"SetMode( 99, 999 ) -Cancels\"\n @ MaxRow() / 2, 11 GET nModeRows PICTURE \"99\" RANGE 10, 99\n @ MaxRow() / 2, 16 GET nModeCols PICTURE \"999\" RANGE 20, 300\n READ\n IF LastKey() == K_ESC\n EXIT\n ENDIF\n IF ! SetMode( nModeRows, nModeCols )\n Alert( \"SetMode() Failed!\" )\n ELSE\n EXIT\n ENDIF\n ENDDO\n DispScreen()\n\n CASE nKey == hb_keyCode( \"1\" ) \n nWndHeight := hb_gtInfo( HB_GTI_SCREENHEIGHT )\n nMaxWHeight := hb_gtInfo( HB_GTI_DESKTOPHEIGHT )\n SetColor( \"W+/B,GR+/N,W/B,B/B,G+/N\" )\n @ MaxRow() / 2 - 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2 + 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 2 SAY \"Get/Set Window Height: 9999 (Max: \" + hb_ntos( nMaxWHeight ) + \")\"\n @ MaxRow() / 2, 25 GET nWndHeight PICTURE \"9999\" RANGE 100, nMaxWHeight\n READ\n IF LastKey() != K_ESC\n hb_gtInfo( HB_GTI_SCREENHEIGHT, nWndHeight )\n ENDIF\n DispScreen()\n\n CASE nKey == hb_keyCode( \"2\" ) \n nWndWIDTH := hb_gtInfo( HB_GTI_SCREENWIDTH )\n nMaxWWIDTH := hb_gtInfo( HB_GTI_DESKTOPWIDTH )\n SetColor( \"W+/B,GR+/N,W/B,B/B,G+/N\" )\n @ MaxRow() / 2 - 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2 + 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 2 SAY \"Get/Set Window WIDTH: 9999 (Max: \" + hb_ntos( nMaxWWIDTH ) + \")\"\n @ MaxRow() / 2, 24 GET nWndWIDTH PICTURE \"9999\" RANGE 100, nMaxWWIDTH\n READ\n IF LastKey() != K_ESC\n hb_gtInfo( HB_GTI_SCREENWIDTH, nWndWIDTH )\n ENDIF\n DispScreen()\n\n CASE nKey == hb_keyCode( \"3\" ) \n aWndSize := hb_gtInfo( HB_GTI_SCREENSIZE )\n nMaxWWIDTH := hb_gtInfo( HB_GTI_DESKTOPWIDTH )\n nMaxWHeight := hb_gtInfo( HB_GTI_DESKTOPHEIGHT )\n SetColor( \"W+/B,GR+/N,W/B,B/B,G+/N\" )\n @ MaxRow() / 2 - 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2 + 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 2 SAY \"Get/Set Window Size(WxH): 9999 x 9999 (Max: \" + hb_ntos( nMaxWWIDTH ) + \" x \" + hb_ntos( nMaxWHeight ) + \")\"\n @ MaxRow() / 2, 28 GET aWndSize[ 1 ] PICTURE \"9999\" RANGE 100, nMaxWWIDTH\n @ MaxRow() / 2, 35 GET aWndSize[ 2 ] PICTURE \"9999\" RANGE 100, nMaxWHeight\n READ\n IF LastKey() != K_ESC\n hb_gtInfo( HB_GTI_SCREENSIZE, aWndSize )\n ENDIF\n DispScreen()\n\n CASE nKey == hb_keyCode( \"4\" ) \n aWndSize := hb_gtInfo( HB_GTI_SETPOS_XY )\n SetColor( \"W+/B,GR+/N,W/B,B/B,G+/N\" )\n @ MaxRow() / 2 - 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2 + 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 2 SAY \"Get/Set Window Position in pixels(Left/Top): 9999 / 9999 \"\n @ MaxRow() / 2, 47 GET aWndSize[ 1 ] PICTURE \"9999\"\n @ MaxRow() / 2, 54 GET aWndSize[ 2 ] PICTURE \"9999\"\n READ\n IF LastKey() != K_ESC\n hb_gtInfo( HB_GTI_SETPOS_XY, aWndSize )\n ENDIF\n DispScreen()\n\n CASE nKey == hb_keyCode( \"5\" ) \n aWndSize := hb_gtInfo( HB_GTI_SETPOS_ROWCOL )\n SetColor( \"W+/B,GR+/N,W/B,B/B,G+/N\" )\n @ MaxRow() / 2 - 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2 + 1, 0 SAY Space( MaxCol() )\n @ MaxRow() / 2, 2 SAY \"Get/Set Window Position by Row/Col: 999 / 999 \"\n @ MaxRow() / 2, 38 GET aWndSize[ 1 ] PICTURE \"999\"\n @ MaxRow() / 2, 44 GET aWndSize[ 2 ] PICTURE \"999\"\n READ\n IF LastKey() != K_ESC\n hb_gtInfo( HB_GTI_SETPOS_ROWCOL, aWndSize[ 1 ], aWndSize[ 2 ] )\n ENDIF\n DispScreen()\n\n CASE nKey == K_F1\n Alert( \"Additional Hot-Key Test Settings:;;\" + ;\n \"0 - SetMode( nRows, nCols ) test ;\" + ;\n \"1 - Get/Set HB_GTI_SCREENHEIGHT test ;\" + ;\n \"2 - Get/Set HB_GTI_SCREENWIDTH test ;\" + ;\n \"3 - Get/Set HB_GTI_SCREENSIZE test ;\" + ;\n \"4 - Get/Set HB_GTI_SETPOS_XY test ;\" + ;\n \"5 - Get/Set HB_GTI_SETPOS_ROWCOL test\", , \"W+/B\" )\n\n CASE nKey == K_F2\n lMark := hb_gtInfo( HB_GTI_SELECTCOPY )\n hb_gtInfo( HB_GTI_SELECTCOPY, ! lMark )\n\n CASE nKey == K_F3\n lResize := hb_gtInfo( HB_GTI_RESIZABLE )\n hb_gtInfo( HB_GTI_RESIZABLE, ! lResize )\n DispScreen()\n\n CASE nKey == K_F4\n lClose := hb_gtInfo( HB_GTI_CLOSABLE )\n hb_gtInfo( HB_GTI_CLOSABLE, ! lClose )\n DispScreen()\n\n CASE nKey == K_F5\n SetPalette( 1 )\n\n CASE nKey == K_F6\n SetPalette( 0 )\n\n CASE nKey == K_F7\n SetPaletteIndex()\n\n CASE nKey == K_F8\n Alert( \"Menu text changed. Was: \" + hb_gtInfo( HB_GTI_SELECTCOPY, DToS(Date() ) + \" \" + Time() ) )\n\n CASE nKey == K_F9\n hb_gtInfo( HB_GTI_RESIZEMODE, iif( hb_gtInfo( HB_GTI_RESIZEMODE ) == HB_GTI_RESIZEMODE_ROWS, HB_GTI_RESIZEMODE_FONT, HB_GTI_RESIZEMODE_ROWS ) )\n hb_gtInfo( HB_GTI_WINTITLE , \"GT-Test (Resizable by \" + iif( hb_gtInfo( HB_GTI_RESIZEMODE ) == HB_GTI_RESIZEMODE_ROWS, \"ROWS\", \"FONT\" ) + \")\" )\n DispScreen()\n\n CASE nKey == K_F10\n IF hb_mtvm()\n hb_threadStart( @thFunc() )\n ELSE\n Alert( \"MT mode not available. Rebuild this program with -mt switch and try again.\" )\n ENDIF\n\n CASE nKey == K_F11\n lAltEnter := hb_gtInfo( HB_GTI_ALTENTER )\n hb_gtInfo( HB_GTI_ALTENTER, ! lAltEnter )\n DispScreen()\n\n CASE nKey == K_F12\n cFontName := hb_gtInfo( HB_GTI_FONTNAME )\n IF cFontName == \"Lucida Console\"\n hb_gtInfo( HB_GTI_FONTNAME , \"Courier New\" )\n ELSEIF cFontName == \"Courier New\"\n hb_gtInfo( HB_GTI_FONTNAME , \"Terminal\" )\n ELSEIF cFontName == \"Terminal\"\n hb_gtInfo( HB_GTI_FONTNAME , \"DejaVu Sans Mono\" )\n ELSE"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/ole.prg. Contains 9 procedures. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\nPROCEDURE Main()\n\n LOCAL nOption\n\n CLS\n\n DO WHILE .T.\n ? \"\"\n ? \"Select OLE test:\"\n ? \"1) MS Excel\"\n ? \"2) MS Word\"\n ? \"3) MS Outlook (1)\"\n ? \"4) MS Outlook (2)\"\n ? \"5) Internet Explorer\"\n ? \"6) OpenOffice Calc\"\n ? \"7) OpenOffice Writer\"\n ? \"8) OpenOffice Open\"\n ? \"9) Send mail via CDO\"\n ? \"a) Read ADODB table\"\n ? \"b) SOAP Toolkit client\"\n ? \"c) PocketSOAP client\"\n ? \"d) Internet Explorer with callback\"\n ? \"e) Create shortcut\"\n ? \"0) Quit\"\n ? \"> \"\n\n nOption := Inkey( 0 )\n ?? hb_keyChar( nOption )\n\n IF nOption == hb_keyCode( \"1\" )\n Exm_MSExcel()\n ELSEIF nOption == hb_keyCode( \"2\" )\n Exm_MSWord()\n ELSEIF nOption == hb_keyCode( \"3\" )\n Exm_MSOutlook()\n ELSEIF nOption == hb_keyCode( \"4\" )\n Exm_MSOutlook2()\n ELSEIF nOption == hb_keyCode( \"5\" )\n Exm_IExplorer()\n ELSEIF nOption == hb_keyCode( \"6\" )\n Exm_OOCalc()\n ELSEIF nOption == hb_keyCode( \"7\" )\n Exm_OOWriter()\n ELSEIF nOption == hb_keyCode( \"8\" )\n Exm_OOOpen()\n ELSEIF nOption == hb_keyCode( \"9\" )\n Exm_CDO()\n ELSEIF nOption == hb_keyCode( \"a\" )\n Exm_ADODB()\n ELSEIF nOption == hb_keyCode( \"b\" )\n Exm_SOAP()\n ELSEIF nOption == hb_keyCode( \"c\" )\n Exm_PocketSOAP()\n ELSEIF nOption == hb_keyCode( \"d\" )\n Exm_IExplorer2()\n ELSEIF nOption == hb_keyCode( \"e\" )\n Exm_CreateShortcut()\n ELSEIF nOption == hb_keyCode( \"0\" )\n EXIT\n ENDIF\n ENDDO\n\n RETURN\n\nSTATIC PROCEDURE Exm_MSExcel()\n\n LOCAL oExcel, oWorkBook, oWorkSheet, oAS\n LOCAL nI, nCount\n\n IF ( oExcel := win_oleCreateObject( \"Excel.Application\" ) ) != NIL\n\n oWorkBook := oExcel:WorkBooks:Add()\n\n \n FOR EACH oWorkSheet IN oWorkBook:WorkSheets\n ? oWorkSheet:Name\n NEXT\n\n \n nCount := oWorkBook:WorkSheets:Count()\n\n \n FOR nI := 1 TO nCount\n ? oWorkBook:WorkSheets:Item( nI ):Name\n NEXT\n\n \n FOR nI := 1 TO nCount\n ? oWorkBook:WorkSheets( nI ):Name\n NEXT\n\n oAS := oExcel:ActiveSheet()\n\n \n oAS:Cells:Font:Name := \"Arial\"\n oAS:Cells:Font:Size := 12\n\n oAS:Cells( 1, 1 ):Value := \"OLE from Harbour\"\n oAS:Cells( 1, 1 ):Font:Size := 16\n\n \n ? \"Object valtype:\", ValType( oAS:Cells( 1, 1 ) ), \"Value:\", oAS:Cells( 1, 1 ):Value\n\n oAS:Cells( 3, 1 ):Value := \"String:\"\n oAS:Cells( 3, 2 ):Value := \"Hello, World!\"\n\n oAS:Cells( 4, 1 ):Value := \"Numeric:\"\n oAS:Cells( 4, 2 ):Value := 1234.56\n oAS:Cells( 4, 3 ):Value := oAS:Cells( 4, 2 ):Value\n oAS:Cells( 4, 4 ):Value := oAS:Cells( 4, 2 ):Value\n oAS:Cells( 4, 3 ):Value\n oAS:Cells( 5, 1 ):Value := \"Logical:\"\n oAS:Cells( 5, 2 ):Value := .T.\n\n oAS:Cells( 6, 1 ):Value := \"Date:\"\n oAS:Cells( 6, 2 ):Value := Date()\n\n oAS:Cells( 7, 1 ):Value := \"Timestamp:\"\n oAS:Cells( 7, 2 ):Value := hb_DateTime()\n\n \n oAS:Columns( 1 ):Font:Bold := .T.\n oAS:Columns( 2 ):HorizontalAlignment := - 4152 \n\n oAS:Columns( 1 ):AutoFit()\n oAS:Columns( 2 ):AutoFit()\n oAS:Columns( 3 ):AutoFit()\n oAS:Columns( 4 ):AutoFit()\n\n oAS:Cells( 3, 2 ):Font:ColorIndex := 3 \n\n oAS:Range( \"A1:B1\" ):HorizontalAlignment := 7\n oAS:Range( \"A3:A7\" ):Select()\n\n oExcel:Visible := .T.\n\n oExcel:Quit()\n ELSE\n ? \"Error: MS Excel not available. [\" + win_oleErrorText() + \"]\"\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE Exm_MSWord()\n\n LOCAL oWord, oText\n\n IF ( oWord := win_oleCreateObject( \"Word.Application\" ) ) != NIL\n\n oWord:Documents:Add()\n\n oText := oWord:Selection()\n\n oText:Text := \"OLE from Harbour\" + hb_eol()\n oText:Font:Name := \"Arial\"\n oText:Font:Size := 48\n oText:Font:Bold := .T.\n\n oWord:Visible := .T.\n oWord:WindowState := 1 \n ELSE\n ? \"Error. MS Word not available.\", win_oleErrorText()\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE Exm_MSOutlook()\n\n LOCAL oOL, oList\n\n IF ( oOL := win_oleCreateObject( \"Outlook.Application\" ) ) != NIL\n oList := oOL:CreateItem( 7 )\n oList:DLName := \"Distribution List\"\n oList:Display( .F. )\n ELSE\n ? \"Error. MS Outlook not available.\", win_oleErrorText()\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE Exm_MSOutlook2()\n\n LOCAL oOL, oLista, oMail\n LOCAL i\n\n IF ( oOL := win_oleCreateObject( \"Outlook.Application\" ) ) != NIL\n\n oMail := oOL:CreateItem( 0 )\n\n FOR i := 1 TO 10\n oMail:Recipients:Add( \"Contact\" + hb_ntos( i ) + ;\n \"\" )\n NEXT\n\n oLista := oOL:CreateItem( 7 )\n oLista:DLName := \"Test with distribution list\"\n oLista:Display( .F. )\n oLista:AddMembers( oMail:Recipients )\n oLista:Save()\n oLista:Close( 0 )\n ELSE\n ? \"Error. MS Outlook not available.\", win_oleErrorText()\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE Exm_IExplorer()\n\n LOCAL oIE\n\n IF ( oIE := win_oleCreateObject( \"InternetExplorer.Application\" ) ) != NIL\n oIE:Visible := .T.\n oIE:Navigate( \"https:\n ELSE\n ? \"Error. Internet Explorer not available.\", win_oleErrorText()\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE Exm_IExplorer2()\n\n LOCAL oIE\n\n IF ( oIE := win_oleCreateObject( \"InternetExplorer.Application\" ) ) != NIL\n oIE:__hSink := __axRegisterHandler( oIE:__hObj, {| ... | QOut( ... ) } )\n oIE:Visible := .T.\n oIE:Navigate( \"https:\n WHILE oIE:ReadyState != 4\n hb_idleSleep( 0 )\n ENDDO\n ELSE\n ? \"Error. Internet Explorer not available.\", win_oleErrorText()\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE Exm_OOCalc()\n\n LOCAL oServiceManager, oDesktop, oDoc, oSheet\n\n IF ( oServiceManager := win_oleCreateObject( \"com.sun.star.ServiceManager\" ) ) != NIL\n oDesktop := oServiceManager:createInstance( \"com.sun.star.frame.Desktop\" )\n oDoc := oDesktop:loadComponentFromURL( \"private:factory/scalc\", \"_blank\", 0, {} )\n\n oSheet := oDoc:getSheets:getByIndex( 0 )\n\n oSheet:getCellRangeByName( \"A1\" ):setString( \"OLE from Harbour\" )\n\n oSheet:getCellRangeByName( \"A3\" ):setString( \"String:\" )\n oSheet:getCellRangeByName( \"B3\" ):setString( \"Hello, World!\" )\n\n oSheet:getCellRangeByName( \"A4\" ):setString( \"Numeric:\" )\n oSheet:getCellRangeByName( \"B4\" ):setValue( 1234.56 )\n\n oSheet:getCellRangeByName( \"A5\" ):setString( \"Logical:\" )\n oSheet:getCellRangeByName( \"B5\" ):setValue( .T. )\n oSheet:getCellRangeByName( \"B5\" ):setPropertyValue( \"NumberFormat\", 99 ) \n\n oSheet:getCellRangeByName( \"A6\" ):setString( \"Date:\" )\n oSheet:getCellRangeByName( \"B6\" ):setValue( Date() )\n oSheet:getCellRangeByName( \"B6\" ):setPropertyValue( \"NumberFormat\", 36 ) \n\n oSheet:getCellRangeByName( \"A7\" ):setString( \"Timestamp:\" )\n oSheet:getCellRangeByName( \"B7\" ):setValue( hb_DateTime() )\n oSheet:getCellRangeByName( \"B7\" ):setPropertyValue( \"NumberFormat\", 51 ) \n\n oSheet:getCellRangeByName( \"A3\" ):setPropertyValue( \"IsCellBackgroundTransparent\", .F. )\n oSheet:getCellRangeByName( \"A3\" ):setPropertyValue( \"CellBackColor\", 255 ) \n oSheet:getCellRangeByName( \"B3\" ):setPropertyValue( \"CharColor\", 255\n ? \"Error. OpenOffice not available.\", win_oleErrorText()\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE Exm_OOWriter()\n\n LOCAL oServiceManager, oDesktop, oDoc, oText, oCursor, oTable, oRow, oCell, oRows\n\n IF ( oServiceManager := win_oleCreateObject( \"com.sun.star.ServiceManager\" ) ) != NIL\n oDesktop := oServiceManager:createInstance( \"com.sun.star.frame.Desktop\" )\n oDoc := oDesktop:loadComponentFromURL( \"private:factory/swriter\", \"_blank\", 0, {} )\n\n oText := oDoc:getText\n oCursor := oText:createTextCursor\n\n oText:insertString( oCursor, \"OpenOffice Writer scripting from Harbour.\" + Chr( 10 ), .F. )\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/debug.prg. Provides functions: FuncSecond, TForm, New, Show, Transfer. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL oForm := TForm():New()\n LOCAL nNumber := 15\n\n HB_SYMBOL_UNUSED( nNumber )\n\n ? oForm:ClassName()\n oForm:Show()\n ?\n\n ? \"-OBJECT additions-\"\n ? \"What is in oForm ? \"\n ? hb_ValToExp( oForm:Transfer() )\n\n ? \"Does transfer exists ? \", __objHasMsg( oForm, \"Transfer\" )\n ? \"Is transfer DATA ? \", __objHasData( oForm, \"Transfer\" )\n ? \"Is transfer METHOD ? \", __objHasMethod( oForm, \"Transfer\" )\n ? \"Does nLeft exists ? \", __objHasMsg( oForm, \"nLeft\" )\n ? \"Is nLeft DATA ? \", __objHasData( oForm, \"nLeft\" )\n ? \"Is nLeft METHOD ? \", __objHasMethod( oForm, \"nLeft\" )\n ? \"Does unknown exists ? \", __objHasMsg( oForm, \"Unknown\" )\n ? \"Is unknown DATA ? \", __objHasData( oForm, \"Unknown\" )\n ? \"Is unknown METHOD ? \", __objHasMethod( oForm, \"Unknown\" )\n\n ? \"Set nLeft to 50 and nRight to 100\"\n oForm:Transfer( { \"nLeft\", 50 }, { \"nRight\", 100 } )\n ? hb_ValToExp( oForm:Transfer() )\n\n Inkey( 0 )\n\n ? \"-DEBUG Functions-\"\n ? \"-Statics-\"\n ? hb_ValToExp( __dbgVMVarSList() )\n\n ? \"-Global Stack-\"\n ? hb_ValToExp( __dbgVMStkGList() )\n\n ? \"-Local Stack-\"\n ? hb_ValToExp( __dbgVMStkLList() )\n\n ? \"-Parameters-\"\n ? hb_ValToExp( __dbgVMParLList() )\n\n Inkey( 0 )\n\n FuncSecond( 241, \"Hello\" )\n\n RETURN\n\nSTATIC FUNCTION FuncSecond( nParam, cParam, uParam )\n\n LOCAL cWhat := \"Something\"\n LOCAL nNumber := 2\n LOCAL xParam\n LOCAL xStack\n\n HB_SYMBOL_UNUSED( cWhat )\n HB_SYMBOL_UNUSED( nNumber )\n\n HB_SYMBOL_UNUSED( nParam )\n HB_SYMBOL_UNUSED( cParam )\n HB_SYMBOL_UNUSED( uParam )\n\n ?\n ? \"-Second procedure-\"\n ?\n\n ? \"-Statics-\"\n ? hb_ValToExp( __dbgVMVarSList() )\n ?\n\n ? \"-Global Stack- Len=\", __dbgVMStkGCount()\n ? hb_ValToExp( __dbgVMStkGList() )\n ?\n\n ? \"-Local Stack- Len=\", __dbgVMStkLCount()\n ? hb_ValToExp( xStack := __dbgVMStkLList() )\n ?\n\n ? \"-Parameters-\"\n ? hb_ValToExp( xParam := __dbgVMParLList() )\n IF ! Empty( xStack ) .AND. xParam[ xStack[ 7 ] ] == \"Hello\"\n ? \":-)\"\n ENDIF\n\n Inkey( 0 )\n\n RETURN NIL\n\n\nSTATIC FUNCTION TForm()\n\n STATIC s_oClass\n\n IF s_oClass == NIL\n s_oClass := HBClass():New( \"TFORM\" ) \n\n s_oClass:AddData( \"cName\" ) \n s_oClass:AddData( \"nTop\" )\n s_oClass:AddData( \"nLeft\" )\n s_oClass:AddData( \"nBottom\" )\n s_oClass:AddData( \"nRight\" )\n\n s_oClass:AddVirtual( \"aExcept\" ) \n\n s_oClass:AddMethod( \"New\", @New() ) \n s_oClass:AddMethod( \"Show\", @Show() )\n s_oClass:AddMethod( \"Transfer\", @Transfer() )\n\n s_oClass:Create() \n ENDIF\n\n RETURN s_oClass:Instance() \n\n\nSTATIC FUNCTION New()\n\n LOCAL Self := QSelf()\n\n ::nTop := 10\n ::nLeft := 10\n ::nBottom := 20\n ::nRight := 40\n\n RETURN Self\n\nSTATIC FUNCTION Show()\n\n LOCAL Self := QSelf()\n\n ? \"lets show a form from here :-)\"\n\n RETURN NIL\n\n\nSTATIC FUNCTION Transfer( ... )\n\n LOCAL Self := QSelf()\n LOCAL aParam := __dbgVMParLList()\n LOCAL nLen := PCount()\n LOCAL xRet\n LOCAL xData\n\n IF nLen == 0\n xRet := __objGetValueList( Self, ::aExcept() )\n ELSE\n FOR EACH xData IN aParam\n\n IF HB_ISARRAY( xData )\n\n IF HB_ISARRAY( xData[ 1 ] ) \n xRet := __objSetValueList( Self, xData )\n ELSE \n xRet := __objSetValueList( Self, { xData } )\n ENDIF\n\n ELSEIF HB_ISOBJECT( xData ) \n xRet := ::Transfer( xData:Transfer() )\n ELSEIF !( ValType( xData ) == \"U\" )\n ? \"TRANSFER: Incorrect argument(\", xData:__enumIndex(), \") \", xData\n ENDIF\n\n NEXT\n ENDIF\n\n RETURN xRet"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbssl' (OpenSSL wrapper for SSL/TLS encryption): contrib/hbssl/tests/digest.prg. Contains procedures: Main. This file implements security and encryption functions"}, {"role": "assistant", "content": "#require \"hbssl\"\n\nPROCEDURE Main()\n\n LOCAL ctx\n LOCAL digest\n\n LOCAL key\n LOCAL iv\n\n SSL_init()\n\n OpenSSL_add_all_digests()\n OpenSSL_add_all_ciphers()\n\n ? \"Version built against:\", hb_NumToHex( OPENSSL_VERSION_NUMBER() )\n ? \"Version loaded:\", hb_NumToHex( SSLeay() )\n\n ctx := EVP_MD_CTX_create()\n EVP_MD_CTX_init( ctx )\n\n EVP_DigestInit_ex( ctx, \"SHA256\" )\n EVP_DigestUpdate( ctx, \"sample text\" )\n digest := \"\"\n EVP_DigestFinal( ctx, @digest )\n ? \"SHA256\", \">\" + hb_StrToHex( digest ) + \"<\"\n\n EVP_DigestInit_ex( ctx, HB_EVP_MD_SHA256 )\n EVP_DigestUpdate( ctx, \"sample text\" )\n digest := \"\"\n EVP_DigestFinal( ctx, @digest )\n ? \"SHA256\", \">\" + hb_StrToHex( digest ) + \"<\"\n\n EVP_MD_CTX_cleanup( ctx )\n\n EVP_DigestInit_ex( ctx, HB_EVP_MD_RIPEMD160 )\n EVP_DigestUpdate( ctx, \"sample text\" )\n digest := \"\"\n EVP_DigestFinal( ctx, @digest )\n ? \"RIPEMD160\", \">\" + hb_StrToHex( digest ) + \"<\"\n\n key := \"\"\n iv := \"\"\n ? \"EVP_BytesToKey\", EVP_BytesToKey( HB_EVP_CIPHER_AES_192_OFB, HB_EVP_MD_SHA256, \"salt1234\", \"data\", 2, @key, @iv )\n ? \"KEY\", hb_StrToHex( key )\n ? \">\" + key + \"<\"\n ? \"IV\", hb_StrToHex( iv )\n ? \">\" + iv + \"<\"\n\n key := \"\"\n iv := \"\"\n ? \"EVP_BytesToKey\", EVP_BytesToKey( \"AES-192-OFB\", \"SHA256\", \"salt1234\", \"data\", 2, @key, @iv )\n ? \"KEY\", hb_StrToHex( key )\n ? \">\" + key + \"<\"\n ? \"IV\", hb_StrToHex( iv )\n ? \">\" + iv + \"<\"\n\n key := \"\"\n iv := \"\"\n ? \"EVP_BytesToKey\", EVP_BytesToKey( \"AES-192-OFB\", \"SHA256\",, \"data\", 2, @key, @iv )\n ? \"KEY\", hb_StrToHex( key )\n ? \">\" + key + \"<\"\n ? \"IV\", hb_StrToHex( iv )\n ? \">\" + iv + \"<\"\n\n EVP_cleanup()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: PushButton. Harbour Runtime Library file: src/rtl/pushbtn.prg. Defines classes: PushButton. Provides functions: PushButton, _PushButt_. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"button.ch\"\n#include \"color.ch\"\n#include \"setcurs.ch\"\n\n\n#ifdef HB_COMPAT_C53\n\nCREATE CLASS PushButton FUNCTION HBPushButton\n\n EXPORTED:\n\n VAR cargo \n\n VAR bmpXOff INIT -1 \n VAR bmpYOff INIT -1 \n VAR capXOff INIT -1 \n VAR capYOff INIT -1 \n VAR sizeX INIT 0 \n VAR sizeY INIT 0 \n\n METHOD display()\n METHOD hitTest( nMRow, nMCol )\n METHOD killFocus()\n METHOD select( nPos )\n METHOD setFocus()\n\n METHOD bitmap( cBitmap ) SETGET\n METHOD buffer() SETGET\n METHOD caption( cCaption ) SETGET\n METHOD col( nCol ) SETGET\n METHOD colorSpec( cColorSpec ) SETGET\n METHOD fBlock( bFBlock ) SETGET\n METHOD hasFocus() SETGET\n METHOD message( cMessage ) SETGET\n METHOD row( nRow ) SETGET\n METHOD sBlock( bSBlock ) SETGET\n METHOD typeOut() SETGET\n METHOD style( cStyle ) SETGET\n\n METHOD Init( nRow, nCol, cCaption ) \n\n PROTECTED:\n\n VAR cBitmap INIT \"\"\n VAR lBuffer INIT .F.\n VAR cCaption\n VAR nCol\n VAR cColorSpec\n VAR bFBlock\n VAR lHasFocus INIT .F.\n VAR cMessage INIT \"\"\n VAR nRow\n VAR bSBlock\n VAR cStyle INIT \"<>\"\n VAR lTypeOut INIT .F.\n\nENDCLASS\n\nMETHOD setFocus() CLASS PushButton\n\n IF ! ::lHasFocus\n ::lHasFocus := .T.\n ::display()\n\n IF HB_ISEVALITEM( ::bFBlock )\n Eval( ::bFBlock )\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD select( nPos ) CLASS PushButton\n\n LOCAL nCurPos := nPos\n\n IF ::lHasFocus\n ::lbuffer := .T.\n ::display()\n\n IF HB_ISNUMERIC( nPos )\n\n IF nPos == 32\n\n Inkey( 0.4 )\n DO WHILE nCurPos == 32\n nCurPos := Inkey( 0.1 )\n ENDDO\n ELSE\n DO WHILE nPos == Inkey( 0 )\n ENDDO\n ENDIF\n ENDIF\n\n IF HB_ISEVALITEM( ::bSBlock )\n Eval( ::bSBlock )\n ENDIF\n\n ::lBuffer := .F.\n ::display()\n ENDIF\n\n RETURN Self\n\nMETHOD killFocus() CLASS PushButton\n\n IF ::lHasFocus\n ::lHasFocus := .F.\n\n IF HB_ISEVALITEM( ::bFBlock )\n Eval( ::bFBlock )\n ENDIF\n\n ::display()\n ENDIF\n\n RETURN Self\n\nMETHOD hitTest( nMRow, nMCol ) CLASS PushButton\n\n LOCAL nCurrentPos := 1\n LOCAL nLen := Len( ::cCaption )\n LOCAL nStyleLen\n LOCAL nAccelPos\n\n IF ( nAccelPos := At( \"&\", ::cCaption ) ) > 0 .AND. nAccelPos < nLen\n nLen--\n ENDIF\n\n IF ( nStyleLen := Len( ::cStyle ) ) == 2\n nLen += 2\n ELSEIF nStyleLen == 8\n nCurrentPos := 3\n nLen += 2\n ENDIF\n\n IF nMRow >= ::Row .AND. ;\n nMCol >= ::Col .AND. ;\n nMRow < ::Row + nCurrentPos .AND. ;\n nMCol < ::Col + nLen\n RETURN HTCLIENT\n ENDIF\n\n RETURN HTNOWHERE\n\nMETHOD display() CLASS PushButton\n\n LOCAL cColor\n LOCAL cStyle := ::cStyle\n LOCAL cCaption := ::cCaption\n LOCAL nRow := ::nRow\n LOCAL nCol := ::nCol\n LOCAL nPos\n\n DispBegin()\n\n DO CASE\n CASE ::lBuffer\n cColor := hb_ColorIndex( ::cColorSpec, 2 )\n CASE ::lHasFocus\n cColor := hb_ColorIndex( ::cColorSpec, 1 )\n OTHERWISE\n cColor := hb_ColorIndex( ::cColorSpec, 0 )\n ENDCASE\n\n IF ( nPos := At( \"&\", cCaption ) ) == 0\n ELSEIF nPos == Len( cCaption )\n nPos := 0\n ELSE\n cCaption := Stuff( cCaption, nPos, 1, \"\" )\n ENDIF\n\n IF ! Empty( cStyle )\n\n nCol++\n\n IF Len( cStyle ) == 2\n hb_DispOutAt( ::nRow, ::nCol, SubStr( cStyle, 1, 1 ), cColor )\n hb_DispOutAt( ::nRow, ::nCol + Len( cCaption ) + 1, SubStr( cStyle, 2, 1 ), cColor )\n ELSE\n nRow++\n hb_DispBox( ::nRow, ::nCol, ::nRow + 2, ::nCol + Len( cCaption ) + 1, cStyle, cColor )\n ENDIF\n ENDIF\n\n IF ! Empty( cCaption )\n\n hb_DispOutAt( nRow, nCol, cCaption, cColor )\n\n IF nPos != 0\n hb_DispOutAt( nRow, nCol + nPos - 1, SubStr( cCaption, nPos, 1 ), hb_ColorIndex( ::cColorSpec, 3 ) )\n ENDIF\n ENDIF\n\n DispEnd()\n\n RETURN Self\n\nMETHOD bitmap( cBitmap ) CLASS PushButton\n\n IF cBitmap != NIL\n ::cBitmap := __eInstVar53( Self, \"BITMAP\", cBitmap, \"C\", 1001 )\n ENDIF\n\n RETURN ::cBitmap\n\nMETHOD buffer() CLASS PushButton\n RETURN ::lBuffer\n\nMETHOD caption( cCaption ) CLASS PushButton\n\n IF cCaption != NIL\n ::cCaption := __eInstVar53( Self, \"CAPTION\", cCaption, \"C\", 1001 )\n ENDIF\n\n RETURN ::cCaption\n\nMETHOD col( nCol ) CLASS PushButton\n\n IF nCol != NIL\n ::nCol := __eInstVar53( Self, \"COL\", nCol, \"N\", 1001 )\n ENDIF\n\n RETURN ::nCol\n\nMETHOD colorSpec( cColorSpec ) CLASS PushButton\n\n IF cColorSpec != NIL\n ::cColorSpec := __eInstVar53( Self, \"COLORSPEC\", cColorSpec, \"C\", 1001, ;\n {|| ! Empty( hb_ColorIndex( cColorSpec, 3 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 5 ) ) } )\n ENDIF\n\n RETURN ::cColorSpec\n\nMETHOD fBlock( bFBlock ) CLASS PushButton\n\n IF PCount() > 0\n ::bFBlock := iif( bFBlock == NIL, NIL, __eInstVar53( Self, \"FBLOCK\", bFBlock, \"B\", 1001 ) )\n ENDIF\n\n RETURN ::bFBlock\n\nMETHOD hasFocus() CLASS PushButton\n RETURN ::lHasFocus\n\nMETHOD message( cMessage ) CLASS PushButton\n\n IF cMessage != NIL\n ::cMessage := __eInstVar53( Self, \"MESSAGE\", cMessage, \"C\", 1001 )\n ENDIF\n\n RETURN ::cMessage\n\nMETHOD row( nRow ) CLASS PushButton\n\n IF nRow != NIL\n ::nRow := __eInstVar53( Self, \"ROW\", nRow, \"N\", 1001 )\n ENDIF\n\n RETURN ::nRow\n\nMETHOD sBlock( bSBlock ) CLASS PushButton\n\n IF PCount() > 0\n ::bSBlock := iif( bSBlock == NIL, NIL, __eInstVar53( Self, \"SBLOCK\", bSBlock, \"B\", 1001 ) )\n ENDIF\n\n RETURN ::bSBlock\n\nMETHOD typeOut() CLASS PushButton\n RETURN .F.\n\nMETHOD style( cStyle ) CLASS PushButton\n\n IF cStyle != NIL\n ::cStyle := __eInstVar53( Self, \"STYLE\", cStyle, \"C\", 1001, {|| Len( cStyle ) == 0 .OR. Len( cStyle ) == 2 .OR. Len( cStyle ) == 8 } )\n ENDIF\n\n RETURN ::cStyle\n\nMETHOD Init( nRow, nCol, cCaption ) CLASS PushButton\n\n LOCAL cColor\n\n IF ! HB_ISNUMERIC( nRow ) .OR. ;\n ! HB_ISNUMERIC( nCol )\n RETURN NIL\n ENDIF\n\n __defaultNIL( @cCaption, \"\" )\n\n ::caption := cCaption\n ::nCol := nCol\n ::nRow := nRow\n\n IF IsDefColor()\n ::cColorSpec := \"W/N,N/W,W+/N,W+/N\"\n ELSE\n cColor := SetColor()\n ::cColorSpec := ;\n hb_ColorIndex( cColor, CLR_UNSELECTED ) + \",\" + ;\n hb_ColorIndex( cColor, CLR_ENHANCED ) + \",\" + ;\n hb_ColorIndex( cColor, CLR_STANDARD ) + \",\" + ;\n hb_ColorIndex( cColor, CLR_BACKGROUND )\n ENDIF\n\n RETURN Self\n\nFUNCTION PushButton( nRow, nCol, cCaption )\n RETURN HBPushButton():New( nRow, nCol, cCaption )\n\nFUNCTION _PushButt_( cCaption, cMessage, cColorSpec, bFBlock, bSBlock, cStyle, nSizeX, nSizeY, nCapXOff, nCapYOff, cBitmap, nBmpXOff, nBmpYOff )\n\n LOCAL o := HBPushButton():New( Row(), Col(), cCaption )\n\n o:message := cMessage\n o:colorSpec := cColorSpec\n o:fBlock := bFBlock\n o:sBlock := bSBlock\n o:style := cStyle\n o:sizeX := nSizeX\n o:sizeY := nSizeY\n o:capXOff := nCapXOff\n o:capYOff := nCapYOff\n o:bitmap := cBitmap\n o:bmpXOff := nBmpXOff\n o:bmpYOff := nBmpYOff\n\n RETURN o\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour header file: include/dbedit.ch. Defines 10 constants including: _DBEDIT_CH, DE_IDLE, DE_HITTOP, DE_HITBOTTOM, DE_EMPTY. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef _DBEDIT_CH\n#define _DBEDIT_CH\n\n\n#define DE_IDLE 0 \n#define DE_HITTOP 1 \n#define DE_HITBOTTOM 2 \n#define DE_EMPTY 3 \n#define DE_EXCEPT 4 \n\n\n#define DE_ABORT 0 \n#define DE_CONT 1 \n#define DE_REFRESH 2 \n#ifdef HB_CLP_UNDOC\n #define DE_APPEND 3 \n#endif\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'gtwvg' (): contrib/gtwvg/tests/_tbrowse.prg. Provides functions: BrwHandleResize, BrwBuildTree. Contains procedures: WvtMyBrowse, ExecBrowser, BrwShowColumn. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"button.ch\"\n#include \"dbstruct.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n#include \"hbgtinfo.ch\"\n#include \"hbver.ch\"\n\n#define K_MOVING 1001\n\n#define K_SBLINEUP 1051\n#define K_SBLINEDOWN 1052\n#define K_SBPAGEUP 1053\n#define K_SBPAGEDOWN 1054\n\n#define K_SBLINELEFT 1055\n#define K_SBLINERIGHT 1056\n#define K_SBPAGELEFT 1057\n#define K_SBPAGERIGHT 1058\n\n#define K_SBTHUMBTRACKVERT 1059\n#define K_SBTHUMBTRACKHORZ 1060\n\nPROCEDURE WvtMyBrowse()\n\n IF hb_mtvm()\n hb_threadStart( {| oCrt | oCrt := WvgCrt():new( , , { -1, -2 }, { 34, 69 }, , .T. ), ;\n oCrt:resizeMode := HB_GTI_RESIZEMODE_ROWS, ;\n oCrt:icon := GetResource( \"dia_excl.ico\" ), ;\n oCrt:create(), ;\n wvt_SetGUI( .T. ), ;\n ExecBrowser( oCrt ), ;\n oCrt:destroy() } )\n\n ELSE\n ExecBrowser()\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE ExecBrowser( oCrt )\n\n LOCAL nKey, bBlock, oBrowse, aLastPaint, i, pGT\n LOCAL cFileIndex, cFileDbf, cRDD, nIndex, oTBar, cScr, info_ \n LOCAL lEnd := .F.\n LOCAL aBlocks := {}\n LOCAL nTop := 4\n LOCAL nLeft := 3\n LOCAL nBottom := MaxRow() - 2\n LOCAL nRight := MaxCol() - 3\n LOCAL nCursor := SetCursor( 0 )\n LOCAL nRow := Row()\n LOCAL nCol := Col()\n LOCAL cColor := SetColor( \"N/W*,N/GR*,,,N/W*\" )\n LOCAL aObjects := WvtSetObjects( {} )\n LOCAL hPopup := wvt_SetPopupMenu()\n LOCAL oVBar, oHBar, oCom, oTre, oChk, oSLE, oLBx, aNvg, oIdx\n\n STATIC s_nStyle := 0\n\n THREAD STATIC t_nFactor := 200\n THREAD STATIC t_lActiveX := .F.\n\n IF oCrt == NIL\n cScr := SaveScreen( 0, 0, MaxRow(), MaxCol() )\n ENDIF\n\n BrwBuildMenu( oCrt )\n oTBar := BrwBuildToolBar( oCrt )\n oTBar:buttonClick := {| oBtn | Vou_ExecTBarAction( oBtn ) }\n\n SetMode( MaxRow() + 1, MaxCol() + 1 ) \n\n pGT := SetGT( 2, hb_gtSelect() )\n\n cRDD := \"DBFCDX\"\n cFileDbf := hb_DirBase() + \"..\" + hb_ps() + \"..\" + hb_ps() + \"..\" + hb_ps() + \"tests\" + hb_ps() + \"test.dbf\"\n cFileIndex := \"test.z01\"\n\n USE ( cFileDbf ) NEW SHARED VIA ( cRDD )\n IF NetErr()\n RETURN\n ENDIF\n IF FLock()\n INDEX ON Test->FIRST TAG \"001\" TO ( cFileIndex )\n INDEX ON Test->LAST TAG \"002\" TO ( cFileIndex )\n INDEX ON Test->CITY TAG \"003\" TO ( cFileIndex )\n dbUnlock()\n ENDIF\n SET INDEX TO\n SET INDEX TO ( cFileIndex )\n SET ORDER TO 1\n dbGoto( 50 )\n\n info_ := dbStruct()\n\n Popups( 2 )\n\n oBrowse := TBrowseWvg():New( nTop + 2, nLeft + 12, nBottom - 1, nRight - 1 )\n\n oBrowse:ColSep := \" \"\n oBrowse:HeadSep := \"__\"\n oBrowse:GoTopBlock := {|| dbGoTop() }\n oBrowse:GoBottomBlock := {|| dbGoBottom() }\n oBrowse:SkipBlock := {| nSkip | dbSkipBlock( nSkip, oBrowse ) }\n\n FOR i := 1 TO Len( info_ )\n bBlock := VouBlockField( i )\n oBrowse:AddColumn( TBColumnNew( info_[ i,1 ], bBlock ) )\n NEXT\n oBrowse:configure()\n\n IF s_nStyle > 5\n s_nStyle := 0\n ENDIF\n wvt_SetPen( s_nStyle, 0, RGB( 210,1210,210 ) )\n s_nStyle++\n hb_gtInfo( HB_GTI_WINTITLE, \"WVT GUI TBrowse()\" )\n\n AAdd( aBlocks, {|| wvt_DrawBoxRaised( oBrowse:nTop - 2, oBrowse:nLeft - 2, oBrowse:nBottom + 1, oBrowse:nRight + 2 ) } )\n AAdd( aBlocks, {|| wvt_DrawBoxRecessed( oBrowse:nTop, oBrowse:nLeft, oBrowse:nBottom, oBrowse:nRight ) } )\n AAdd( aBlocks, {|| wvt_DrawGridHorz( oBrowse:nTop + 3, oBrowse:nLeft, oBrowse:nRight, oBrowse:nBottom - oBrowse:nTop - 2 ) } )\n AAdd( aBlocks, {|| wvt_DrawGridVert( oBrowse:nTop, oBrowse:nBottom, oBrowse:aColumnsSep, Len( oBrowse:aColumnsSep ) ) } )\n\n Vou_BrwAddScrollBars( oCrt, oBrowse, @oVBar, @oHBar )\n\n aLastPaint := WvtSetBlocks( aBlocks )\n\n hb_DispBox( 0, 0, MaxRow(), MaxCol(), \" \", \"N/W\" )\n hb_DispOutAt( oBrowse:nTop - 2, oBrowse:nleft - 2, PadC( cFileDbf, oBrowse:nRight - oBrowse:nLeft + 5 ), \"W+/B*\" )\n\n oCom := BrwBuildActiveX( oCrt, oBrowse )\n oChk := BrwBuildCheckBox( oCrt, oBrowse, @t_lActiveX )\n oSLE := BrwBuildSLE( oCrt, oBrowse )\n aNvg := BrwBuildNvg( oCrt, oBrowse, oCom )\n oLBx := BrwBuildListBox( oCrt, oBrowse )\n oIdx := BrwBuildListBoxIdx( oCrt, oBrowse )\n BrwBuildButtons( oCrt, oBrowse )\n oTre := BrwBuildTree( oCrt, oBrowse )\n\n wvt_Keyboard( HB_K_RESIZE ) \n\n WHILE ! lEnd\n DispBegin()\n DO WHILE ( ( nKey := Inkey( , INKEY_ALL + HB_INKEY_GTEVENT ) ) == 0 .OR. nKey == K_MOVING ) .AND. ! oBrowse:stabilize()\n ENDDO\n DispEnd()\n\n IF nKey == 0\n oVBar:setData( ordKeyNo() )\n oHBar:setData( oBrowse:colPos )\n DO WHILE ( ( nKey := Inkey( , INKEY_ALL + HB_INKEY_GTEVENT ) ) == 0 .OR. nKey == K_MOVING )\n ENDDO\n ENDIF\n\n DO CASE\n CASE nKey == K_F12\n t_nFactor--\n hb_gtInfo( HB_GTI_SPEC, HB_GTS_FACTOR, t_nFactor )\n\n CASE nKey == K_F11\n t_nFactor++\n hb_gtInfo( HB_GTI_SPEC, HB_GTS_FACTOR, t_nFactor )\n\n CASE nKey == K_F6\n hb_gtInfo( HB_GTI_RESIZABLE, .F. )\n\n CASE nKey == K_F7\n hb_gtInfo( HB_GTI_RESIZABLE, .T. )\n\n CASE nKey == K_F2\n nIndex := IndexOrd()\n nIndex++\n IF nIndex > 3\n nIndex := 1\n ENDIF\n SET ORDER TO ( nIndex )\n oBrowse:RefreshAll()\n oBrowse:ForceStable()\n\n CASE nKey == K_F3\n DoModalWindow()\n\n CASE nKey == K_F4\n hb_gtInfo( HB_GTI_SPEC, HB_GTS_WNDSTATE, HB_GTS_WS_MAXIMIZED )\n\n CASE BrwHandleKey( oBrowse, nKey, @lEnd )\n\n CASE nKey == HB_K_RESIZE\n BrwHandleResize( oCrt, oBrowse, oVBar, oHBar, oCom, oSLE, oLBx, oTre, oChk, aNvg, oIdx, t_lActiveX, cFileDbf )\n\n ENDCASE\n ENDDO\n\n wvt_SetPen( 0 )\n WvtSetBlocks( aLastPaint )\n WvtSetObjects( aObjects )\n\n DevPos( nRow, nCol )\n SetColor( cColor )\n SetCursor( nCursor )\n\n dbCloseArea()\n\n IF oCrt == NIL\n RestScreen( 0, 0, MaxRow(), MaxCol(), cScr )\n ENDIF\n wvt_SetPopupMenu( hPopup )\n SetGT( 2, pGT )\n\n RETURN\n\nSTATIC FUNCTION BrwHandleResize( oCrt, oBrw, oVBar, oHBar, oCom, oSLE, oLBx, oTre, oChk, aNvg, oIdx, lActiveX, cFileDbf )\n\n HB_SYMBOL_UNUSED( oSle )\n HB_SYMBOL_UNUSED( oLBx )\n HB_SYMBOL_UNUSED( oChk )\n HB_SYMBOL_UNUSED( oIdx )\n\n oCrt:setFocus()\n\n oBrw:nBottom := iif( lActiveX, 20, MaxRow() - 3 )\n oBrw:nRight := MaxCol() - 4\n oBrw:configure()\n\n hb_DispBox( 0, 0, MaxRow(), MaxCol(), \" \", \"N/W\" )\n hb_DispOutAt( oBrw:nTop - 2, oBrw:nleft - 2, PadC( cFileDbf, oBrw:nRight - oBrw:nLeft + 5 ), \"W+/B*\" )\n\n oVBar:setPosAndSize()\n oHBar:setPosAndSize()\n oCom:setPosAndSize()\n\n oTre:setPosAndSize()\n\n BrwReposButtons( oCrt ) \n\n IF lActiveX\n aNvg[ 1 ]:show()\n aNvg[ 2 ]:show()\n oCom:show()\n ELSE\n aNvg[ 1 ]:hide()\n aNvg[ 2 ]:hide()\n oCom:hide()\n ENDIF\n\n \n oCrt:hide()\n oCrt:show()\n\n RETURN .T.\n\nSTATIC PROCEDURE BrwShowColumn( oBrw, cHeading )\n\n LOCAL i, j, nCur\n\n nCur := oBrw:colPos\n FOR i := 1 TO oBrw:colCount\n IF oBrw:getColumn( i ):heading == cHeading\n EXIT\n ENDIF\n NEXT\n IF i < nCur\n FOR j := nCur - 1 TO i STEP -1\n oBrw:Left()\n NEXT\n ELSEIF i > nCur\n FOR j := nCur + 1 TO i\n oBrw:Right()\n NEXT\n ENDIF\n oBrw:refreshCurrent()\n oBrw:forceStable()\n\n RETURN\n\nSTATIC FUNCTION BrwBuildTree( oCrt )\n\n LOCAL oTree, oItem1, oItem2\n\n oTree := WvgTreeView():new( oCrt )\n oTree:hasLines := .T.\n oTree:hasButtons := .T.\n oTree:alwaysShowSelection := .T.\n oTree:create( , , { -24, -1 }, { {|| -( MaxRow() - 1 - 24 ) }, -10 } )\n oTree:setColorFG( \"W+\" )\n oTree:setColorBG( \"R*\" )\n oTree:itemSelected := {| oItem | wvg_MessageBox( , iif( oItem != NIL, oItem:caption, \"Some Problem\" ) ) }\n\n oItem1 := oTree:rootItem:addItem( \"First level A\" )\n\n oTree:rootItem:addItem( \"First level B\" )\n\n oItem2 := oItem1:addItem( \"Second level 1\" )\n oItem1:addItem( \"Second level 2\" )\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour extra library: extras/hbusb/tests/test.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbusb\"\n\nPROCEDURE Main()\n\n LOCAL nRetVal\n LOCAL pDeviceList\n LOCAL nDeviceCount\n LOCAL nDeviceNumber\n LOCAL nBusNumber\n LOCAL nDeviceAddress\n LOCAL pDescriptor\n LOCAL nVendorID\n LOCAL nProductID\n LOCAL nNumConfigurations\n LOCAL pDeviceHandle\n LOCAL cData\n LOCAL nLength\n LOCAL tmp\n\n ? \"Initialising libusb\"\n nRetVal := libusb_init()\n ?? \" returns\", nRetVal\n\n ? \"Getting Device List\"\n nDeviceCount := libusb_get_device_list( NIL, @pDeviceList )\n ?? \" returns\", nDeviceCount, \"which is the number of USB devices found\"\n ? \"Device list address is\", pDeviceList\n\n FOR nDeviceNumber := 0 TO nDeviceCount - 1\n nBusNumber := libusb_get_bus_number( pDeviceList, nDeviceNumber )\n ? \"Bus Number:\", hb_ntos( nBusNumber )\n nDeviceAddress := libusb_get_device_address( pDeviceList, nDeviceNumber )\n ?? \" Address:\", hb_ntos( nDeviceAddress )\n nRetVal := libusb_get_device_descriptor( pDeviceList, nDeviceNumber, @pDescriptor, @nVendorID, @nProductID, @nNumConfigurations )\n ?? \" return:\", hb_ntos( nRetVal )\n ?? \" Vendor:\", hb_ntos( nVendorID )\n ?? \" Product:\", hb_ntos( nProductID )\n ?? \" Config Count:\", hb_ntos( nNumConfigurations )\n NEXT\n\n ? \"Freeing Device List\"\n libusb_free_device_list( NIL )\n\n ?\n ? \"Opening Device\"\n pDeviceHandle := libusb_open_device_with_vid_pid( NIL, 1523, 255 )\n ? \"returns\", pDeviceHandle\n\n IF Empty( pDeviceHandle )\n ? \"Cannot open the device\"\n ELSE\n ? \"Testing for kernel having claimed interface\"\n nRetVal := libusb_kernel_driver_active( pDeviceHandle, 0 )\n ? \"returns\", nRetVal\n\n IF nRetVal == LIBUSB_KERNEL_HAS_INTERFACE\n ? \"Kernel has interface\"\n ? \"Detaching Kernel from interface\"\n nRetVal := libusb_detach_kernel_driver( pDeviceHandle, 0 )\n ? \"returns\", nRetVal\n ENDIF\n ? \"Claiming Interface\"\n nRetVal := libusb_claim_interface( pDeviceHandle, 0 )\n ? \"returns\", nRetVal\n\n cData := Space( 512 )\n nLength := 0\n ? \"Querying device\"\n FOR tmp := 1 TO 500\n nRetVal := libusb_bulk_transfer( pDeviceHandle, LIBUSB_ENDPOINT_IN, 100, @cData, @nLength )\n HB_SYMBOL_UNUSED( nRetVal )\n IF hb_BLen( cData ) > 0\n SWITCH hb_BCode( hb_BSubStr( cData, -2, 1 ) )\n CASE 0\n ? \"Clear\"\n EXIT\n CASE 1\n ? \"Left Pedal\"\n EXIT\n CASE 2\n ? \"Middle Pedal\"\n EXIT\n CASE 3\n ? \"Left and Middle Pedals\"\n EXIT\n CASE 4\n ? \"Right Pedal\"\n EXIT\n CASE 5\n ? \"Left and Right Pedals\"\n EXIT\n CASE 6\n ? \"Middle and Right Pedals\"\n EXIT\n CASE 7\n ? \"All Three Pedals\"\n EXIT\n OTHERWISE\n ? \"Error\"\n ENDSWITCH\n ENDIF\n NEXT\n\n ? \"Releasing Interface\"\n nRetVal := libusb_release_interface( pDeviceHandle, 0 )\n ? \"returns\", nRetVal\n\n ? \"Reattaching Kernel to interface\"\n nRetVal := libusb_attach_kernel_driver( pDeviceHandle, 0 )\n ? \"returns\", nRetVal\n ENDIF\n\n ? \"Closing Device\"\n libusb_close( pDeviceHandle )\n\n ? \"Deinitialising libusb\"\n libusb_exit()\n ?? \" done\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/gcd.prg. Provides functions: ft_GCD. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_GCD( nNumber1, nNumber2 )\n\n LOCAL nHold1 \n LOCAL nHold2 \n LOCAL nResult \n\n \n IF nNumber1 == 0 .OR. nNumber2 == 0\n nResult := 0 \n ELSE \n\n nHold1 := Max( Abs( nNumber1 ), Abs( nNumber2 ) )\n nHold2 := Min( Abs( nNumber1 ), Abs( nNumber2 ) )\n\n DO WHILE .T.\n\n nResult := nHold1 % nHold2 \n nHold1 := nHold2 \n nHold2 := nResult \n\n IF nResult <= 0\n EXIT\n ENDIF\n ENDDO\n\n nResult := nHold1 \n\n ENDIF \n\n RETURN nResult"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/xppop.prg. Defines classes: Character, Array. Contains procedures: xpp_Init. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nANNOUNCE XPP_OP_OVERLOAD\n\n\n#xcommand OPTIONAL INHERIT => ;\n IF hb_IsFunction( <\"className\"> ) ;;\n AAdd( oClass:asSuper, @__() ) ;;\n ENDIF\n\nINIT PROCEDURE xpp_Init()\n\n ASSOCIATE CLASS xpp_op_Character WITH TYPE Character\n ASSOCIATE CLASS xpp_op_Array WITH TYPE Array\n\n RETURN\n\nCREATE CLASS Character FUNCTION xpp_op_Character\n\n OPTIONAL INHERIT HBCharacter\n OPERATOR \"[]\" FUNCTION xpp_Index()\n\nENDCLASS\n\nCREATE CLASS Array FUNCTION xpp_op_Array\n\n OPTIONAL INHERIT HBArray\n OPERATOR \"$$\" FUNCTION xpp_Include()\n\nENDCLASS"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/pvid.prg. Provides functions: ft_PushVid, ft_PopVid. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#define PV_ROW 1\n#define PV_COL 2\n#define PV_COLOR 3\n#define PV_IMAGE 4\n#define PV_CURSOR 5\n#define PV_BLINK 6\n#define PV_NOSNOW 7\n#define PV_MAXROW 8\n#define PV_MAXCOL 9\n#define PV_SCORE 10\n\nTHREAD STATIC t_aVideo := {}\n\nFUNCTION ft_PushVid()\n\n AAdd( t_aVideo, { Row(), ;\n Col(), ;\n SetColor(), ;\n SaveScreen( 0, 0, MaxRow(), MaxCol() ), ;\n Set( _SET_CURSOR ), ;\n SetBlink(), ;\n NoSnow(), ;\n MaxRow() + 1, ;\n MaxCol() + 1, ;\n Set( _SET_SCOREBOARD ) } )\n\n RETURN Len( t_aVideo )\n\nFUNCTION ft_PopVid()\n\n LOCAL nNewSize := Len( t_aVideo ) - 1\n LOCAL aBottom := ATail( t_aVideo )\n\n IF nNewSize >= 0\n SetMode( aBottom[ PV_MAXROW ], aBottom[ PV_MAXCOL ] )\n Set( _SET_CURSOR, aBottom[ PV_CURSOR ] )\n NoSnow( aBottom[ PV_NOSNOW ] )\n SetBlink( aBottom[ PV_BLINK ] )\n RestScreen( 0, 0, MaxRow(), MaxCol(), aBottom[ PV_IMAGE ] )\n SetColor( aBottom[ PV_COLOR ] )\n SetPos( aBottom[ PV_ROW ], aBottom[ PV_COL ] )\n Set( _SET_SCOREBOARD, aBottom[ PV_SCORE ] )\n\n ASize( t_aVideo, nNewSize )\n ENDIF\n\n RETURN Len( t_aVideo )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/tests/regexrpl.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"xhb\"\n\nPROCEDURE Main()\n\n LOCAL cString, cRegex, cReplace\n\n CLS\n\n ? \"*** xHarbour hb_regexReplace() test ***\"\n ?\n ?\n ? \"A simple replace, return is a single match, without submatches.\"\n ? \"Using 1 to retrieve matches\"\n cString := \"aaabbbcccddd111222333aaabbbcccddd111222333\"\n cRegex := \"aaa\"\n cReplace := \"999\"\n ? \"String: \", cString\n ? \"Result: \", hb_regexReplace( cRegEx, cString, cReplace,,,, 1 )\n ?\n ? \"A replace with a capturing match, return is a submatch.\"\n ? \"Using 2 to retrieve 1st submatches\"\n cString := \"aaabbbcccddd111222333aaabbbcccddd111222333\"\n cRegex := \"(aaa)\"\n cReplace := \"999\"\n ? \"String: \", cString\n ? \"Result: \", hb_regexReplace( cRegEx, cString, cReplace,,,, 2 )\n ?\n WAIT\n\n ?\n ? \"Replacing a multiline string searching text that is on single line.\"\n cString := \"Hi folks! This is a real\" + hb_eol() + \"multiline text. Try this as a test.\"\n cRegex := \"(?im)this (.*) a\"\n cReplace := \"\"\n ? \"String: \", cString\n ? \"Result: \", hb_regexReplace( cRegEx, cString, cReplace,,,, 2 )\n ?\n WAIT\n\n ?\n ? \"Replacing a multiline string searching text that is splitted on more lines.\"\n cString := \"Hi all. This is a\" + hb_eol() + ;\n \"multiline text. Try this as a test\" + hb_eol() + ;\n \"with another line of text.\"\n cRegex := \"(?ims)(.*?)\"\n cReplace := \"\"\n ? \"String: \", cString\n ? \"Result: \", hb_regexReplace( cRegEx, cString, cReplace,,,, 2 )\n ?\n WAIT\n\n ?\n ? \"Replacing a multifield string.\"\n cString := \"/C=IT/O=xHarbour/OU=www.xharbour.com/CN=GIUDICE_FRANCESCO_SAVERIO/email=info@fsgiudice.com\"\n cRegex := \"(?:\\/(\\w+)=)([\\w.@]+)\"\n cReplace := \"\"\n ? \"String: \", cString\n ? \"Result: \", hb_regexReplace( cRegEx, cString, cReplace,,,, 2 )\n ?\n WAIT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbfship' (Fships library functions): contrib/hbfship/stroccur.prg. Provides functions: StrOccurs. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION StrOccurs( cSub, cStr, lAny )\n\n LOCAL nCount := 0, nPos := 0\n\n IF HB_ISSTRING( cSub ) .AND. HB_ISSTRING( cStr )\n IF hb_defaultValue( lAny, PCount() < 3 )\n DO WHILE ( nPos := hb_At( cSub, cStr, nPos + 1 ) ) != 0\n nCount++\n ENDDO\n ELSE\n DO WHILE ( nPos := hb_At( cSub, cStr, nPos ) ) != 0\n nCount++\n nPos += Len( cSub )\n ENDDO\n ENDIF\n ENDIF\n\n RETURN nCount"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/regex2.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n\nPROCEDURE Main()\n\n LOCAL pCompiled\n LOCAL cRegex\n LOCAL cSentence\n LOCAL nRow\n LOCAL aMatch, cMatch\n\n LOCAL GetList := {}\n\n SET CONFIRM ON\n\n CLS\n\n @ 2, 15 SAY \"Regular expression test\"\n\n @ 4, 5 SAY \"Insert regular expression(s) and strings to test for.\"\n @ 5, 5 SAY \"Press to exit\"\n\n cRegex := Space( 60 )\n cSentence := Space( 120 )\n DO WHILE LastKey() != K_ESC\n\n @ 8, 5 SAY \"REGEX : \" GET cRegex PICTURE \"@S30\"\n @ 9, 5 SAY \"PHRASE: \" GET cSentence PICTURE \"@S60\"\n READ\n IF LastKey() != K_ESC\n\n @ 12, 5 CLEAR TO MaxRow(), MaxCol()\n\n pCompiled := hb_regexComp( RTrim( cRegex ) )\n IF Empty( pCompiled )\n @ 12, 5 SAY \"Invalid REGEX expression\"\n LOOP\n ENDIF\n\n aMatch := hb_regex( pCompiled, RTrim( cSentence ) )\n IF aMatch != NIL\n @ 12, 5 SAY \"MATCHES:\"\n nRow := 13\n FOR EACH cMatch IN aMatch\n @ nRow++, 5 SAY \">\" + cMatch\n NEXT\n ELSE\n @ 12, 5 SAY \"No matches\"\n ENDIF\n ENDIF\n ENDDO\n\n CLS\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/vidcur.prg. Provides functions: ft_GetVCur. Contains procedures: ft_SetVcur. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"setcurs.ch\"\n\n\nPROCEDURE ft_SetVcur( nPage, nRow, nCol )\n\n HB_SYMBOL_UNUSED( nPage )\n\n SetPos( nRow, nCol )\n\n RETURN\n\n\nFUNCTION ft_GetVCur( nPage )\n\n LOCAL nTop, nBot\n\n HB_SYMBOL_UNUSED( nPage )\n\n SWITCH SetCursor()\n CASE SC_NORMAL\n nTop := 6\n nBot := 7\n EXIT\n CASE SC_INSERT\n nTop := 4\n nBot := 7\n EXIT\n CASE SC_SPECIAL1\n nTop := 0\n nBot := 7\n EXIT\n CASE SC_SPECIAL2\n nTop := 0\n nBot := 3\n EXIT\n OTHERWISE\n nTop := nBot := 0\n ENDSWITCH\n\n RETURN { nTop, nBot, Row(), Col() }"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour Runtime Library file: src/rtl/tclass.prg. Provides functions: HBClass, New, Instance. Contains procedures: Create. This file implements object-oriented classes using Harbour's class system"}, {"role": "assistant", "content": "#pragma -b-\n\n\n#include \"hboo.ch\"\n\nREQUEST HBObject\n\nFUNCTION HBClass()\n\n STATIC s_hClass \n\n LOCAL hClass\n\n IF s_hClass == NIL .AND. __clsLockDef( @s_hClass )\n\n BEGIN SEQUENCE\n\n\n __clsAddMsg( hClass, \"New\" , @New() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"Create\" , @Create() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddData\" , @AddData() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddMultiData\" , @AddMultiData() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddClassData\" , @AddClassData() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddMultiClsData\", @AddMultiClsData(), HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddInline\" , @AddInline() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddMethod\" , @AddMethod() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddClsMethod\" , @AddClsMethod() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddVirtual\" , @AddVirtual() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddDelegate\" , @AddDelegate() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddFriendFunc\" , @AddFriendFunc() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"AddFriendClass\" , @AddFriendClass() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"Instance\" , @Instance() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"SetOnError\" , @SetOnError() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"SetDestructor\" , @SetDestructor() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"InitClass\" , @InitClass() , HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"cSuper\" , {| Self | iif( Empty( ::asSuper ), NIL, ::asSuper[ 1 ]:name ) }, HB_OO_MSG_INLINE )\n __clsAddMsg( hClass, \"hClass\" , 1, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_hClass\" , 1, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"cName\" , 2, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_cName\" , 2, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"aDatas\" , 3, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_aDatas\" , 3, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"aMethods\" , 4, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_aMethods\" , 4, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"aClsDatas\" , 5, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_aClsDatas\" , 5, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"aClsMethods\" , 6, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_aClsMethods\" , 6, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"aInlines\" , 7, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_aInlines\" , 7, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"aVirtuals\" , 8, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_aVirtuals\" , 8, HB_OO_MSG_ASSIGN )\n\n __clsAddMsg( hClass, \"aDelegates\" , 9, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_aDelegates\" , 9, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"asSuper\" , 10, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_asSuper\" , 10, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"sOnError\" , 11, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_sOnError\" , 11, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"sDestructor\" , 12, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_sDestructor\" , 12, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"lModFriendly\" , 13, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_lModFriendly\" , 13, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"asFriendClass\" , 14, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_asFriendClass\" , 14, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"asFriendFunc\" , 15, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_asFriendFunc\" , 15, HB_OO_MSG_ASSIGN )\n __clsAddMsg( hClass, \"sClassFunc\" , 16, HB_OO_MSG_ACCESS )\n __clsAddMsg( hClass, \"_sClassFunc\" , 16, HB_OO_MSG_ASSIGN )\n\n ALWAYS\n\n __clsUnlockDef( @s_hClass, hClass )\n\n END SEQUENCE\n\n ENDIF\n\n RETURN __clsInst( s_hClass )\n\n\nSTATIC FUNCTION New( cClassName, xSuper, sClassFunc, lModuleFriendly )\n\n LOCAL Self := QSelf()\n LOCAL i\n\n DO CASE\n CASE HB_ISSYMBOL( xSuper )\n ::asSuper := { xSuper }\n CASE Empty( xSuper )\n ::asSuper := {}\n CASE HB_ISSTRING( xSuper )\n ::asSuper := { __dynsN2Sym( xSuper ) }\n CASE HB_ISARRAY( xSuper )\n ::asSuper := {}\n FOR EACH i IN xSuper\n DO CASE\n CASE HB_ISSYMBOL( i )\n AAdd( ::asSuper, i )\n CASE HB_ISSTRING( i ) .AND. ! Empty( i )\n AAdd( ::asSuper, __dynsN2Sym( i ) )\n ENDCASE\n NEXT\n ENDCASE\n\n ::cName := hb_asciiUpper( cClassName )\n ::sClassFunc := sClassFunc\n ::lModFriendly := hb_defaultValue( lModuleFriendly, .F. )\n\n ::aDatas := {}\n ::aMethods := {}\n ::aClsDatas := {}\n ::aClsMethods := {}\n ::aInlines := {}\n ::aVirtuals := {}\n ::aDelegates := {}\n ::asFriendClass := {}\n ::asFriendFunc := {}\n\n RETURN QSelf()\n\nSTATIC PROCEDURE Create( )\n\n LOCAL Self := QSelf()\n LOCAL n\n LOCAL nClassBegin\n LOCAL hClass\n LOCAL ahSuper := {}\n\n\n FOR EACH n IN ::asSuper\n IF ( hClass := __clsInstSuper( n ) ) != 0 \n AAdd( ahSuper, hClass )\n ENDIF\n NEXT\n\n ::hClass := hClass := __clsNew( ::cName, Len( ::aDatas ), ahSuper, ::sClassFunc, ::lModFriendly )\n\n IF ! Empty( ahSuper ) .AND. ahSuper[ 1 ] != 0\n __clsAddMsg( hClass, \"SUPER\" , 0, HB_OO_MSG_SUPER, ahSuper[ 1 ], HB_OO_CLSTP_EXPORTED + HB_OO_CLSTP_NONVIRTUAL )\n __clsAddMsg( hClass, \"__SUPER\", 0, HB_OO_MSG_SUPER, ahSuper[ 1 ], HB_OO_CLSTP_EXPORTED + HB_OO_CLSTP_NONVIRTUAL )\n ENDIF\n __clsAddMsg( hClass, \"REALCLASS\", 0, HB_OO_MSG_REALCLASS, 0, HB_OO_CLSTP_EXPORTED )\n\n\n FOR EACH n IN ::aDatas\n __clsAddMsg( hClass, n[ HB_OO_DATA_SYMBOL ] , n:__enumIndex(), ;\n HB_OO_MSG_ACCESS, n[ HB_OO_DATA_VALUE ], n[ HB_OO_DATA_SCOPE ] )\n __clsAddMsg( hClass, \"_\" + n[ HB_OO_DATA_SYMBOL ] , n:__enumIndex(), ;\n HB_OO_MSG_ASSIGN, n[ HB_OO_DATA_TYPE ] , n[ HB_OO_DATA_SCOPE ] )\n NEXT\n\n FOR EACH n IN ::aMethods\n __clsAddMsg( hClass, n[ HB_OO_MTHD_SYMBOL ], n[ HB_OO_MTHD_PFUNCTION ], ;\n HB_OO_MSG_METHOD, , n[ HB_OO_MTHD_SCOPE ] )\n NEXT\n\n nClassBegin := __cls_CntClsData( hClass )\n FOR EACH n IN ::aClsDatas\n __clsAddMsg( hClass, n[ HB_OO_CLSD_SYMBOL ] , n:__enumIndex() + nClassBegin, ;\n HB_OO_MSG_CLSACCESS, n[ HB_OO_CLSD_VALUE ], n[ HB_OO_CLSD_SCOPE ] )\n __clsAddMsg( hClass, \"_\" + n[ HB_OO_CLSD_SYMBOL ], n:__enumIndex() + nClassBegin, ;\n HB_OO_MSG_CLSASSIGN, , n[ HB_OO_CLSD_SCOPE ] )\n NEXT\n\n FOR EACH n IN ::aInlines\n __clsAddMsg( hClass, n[ HB_OO_MTHD_SYMBOL ], n[ HB_OO_MTHD_PFUNCTION ], ;\n HB_OO_MSG_INLINE, , n[ HB_OO_MTHD_SCOPE ] )\n NEXT\n\n FOR EACH n IN ::aVirtuals\n __clsAddMsg( hClass, n, n:__enumIndex(), HB_OO_MSG_VIRTUAL )\n NEXT\n\n FOR EACH n IN ::aDelegates\n __clsAddMsg( ::hClass, n[ HB_OO_DELEG_SYMBOL ], n[ HB_OO_DELEG_MESSAGE ], ;\n HB_OO_MSG_DELEGATE, n[ HB_OO_DELEG_OBJECT ], ;\n n[ HB_OO_DELEG_SCOPE ] )\n NEXT\n\n IF ::sOnError != NIL\n __clsAddMsg( hClass, \"__OnError\", ::sOnError, HB_OO_MSG_ONERROR )\n ENDIF\n\n IF ::sDestructor != NIL\n __clsAddMsg( hClass, \"__Destructor\", ::sDestructor, HB_OO_MSG_DESTRUCTOR )\n ENDIF\n\n \n FOR EACH n IN ::asFriendClass\n __clsAddFriend( ::hClass, n )\n NEXT\n\n \n FOR EACH n IN ::asFriendFunc\n __clsAddFriend( ::hClass, n )\n NEXT\n\n RETURN\n\nSTATIC FUNCTION Instance()\n RETURN __clsInst( QSelf():hClass )\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbmzip' (ZIP file handling): contrib/hbmzip/mziperr.prg. Provides functions: hb_zipErrorStr, hb_unzipErrorStr. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbmzip.ch\"\n\nFUNCTION hb_zipErrorStr( nStatus )\n\n IF ! HB_ISNUMERIC( nStatus )\n RETURN \"ZIP_INVALID\"\n ENDIF\n\n SWITCH nStatus\n CASE ZIP_OK ; RETURN \"ZIP_OK\"\n CASE ZIP_PARAMERROR ; RETURN \"ZIP_PARAMERROR\"\n CASE ZIP_BADZIPFILE ; RETURN \"ZIP_BADZIPFILE\"\n CASE ZIP_INTERNALERROR ; RETURN \"ZIP_INTERNALERROR\"\n CASE 1 ; RETURN \"Z_STREAM_END\"\n CASE 2 ; RETURN \"Z_NEED_DICT\"\n CASE -1 ; RETURN \"Z_ERRNO\"\n CASE -2 ; RETURN \"Z_STREAM_ERROR\"\n CASE -3 ; RETURN \"Z_DATA_ERROR\"\n CASE -4 ; RETURN \"Z_MEM_ERROR\"\n CASE -5 ; RETURN \"Z_BUF_ERROR\"\n CASE -6 ; RETURN \"Z_VERSION_ERROR\"\n ENDSWITCH\n\n RETURN \"ZIP_UNKNOWN_\" + hb_ntos( nStatus )\n\nFUNCTION hb_unzipErrorStr( nStatus )\n\n IF ! HB_ISNUMERIC( nStatus )\n RETURN \"UNZ_INVALID\"\n ENDIF\n\n SWITCH nStatus\n CASE UNZ_OK ; RETURN \"UNZ_OK\"\n CASE UNZ_END_OF_LIST_OF_FILE ; RETURN \"UNZ_END_OF_LIST_OF_FILE\"\n CASE UNZ_PARAMERROR ; RETURN \"UNZ_PARAMERROR\"\n CASE UNZ_BADZIPFILE ; RETURN \"UNZ_BADZIPFILE\"\n CASE UNZ_INTERNALERROR ; RETURN \"UNZ_INTERNALERROR\"\n CASE UNZ_CRCERROR ; RETURN \"UNZ_CRCERROR\"\n CASE 1 ; RETURN \"Z_STREAM_END\"\n CASE 2 ; RETURN \"Z_NEED_DICT\"\n CASE -1 ; RETURN \"Z_ERRNO\"\n CASE -2 ; RETURN \"Z_STREAM_ERROR\"\n CASE -3 ; RETURN \"Z_DATA_ERROR\"\n CASE -4 ; RETURN \"Z_MEM_ERROR\"\n CASE -5 ; RETURN \"Z_BUF_ERROR\"\n CASE -6 ; RETURN \"Z_VERSION_ERROR\"\n ENDSWITCH\n\n RETURN \"UNZ_UNKNOWN_\" + hb_ntos( nStatus )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbmlzo' (LZO compression library): contrib/hbmlzo/tests/test.prg. Contains procedures: Main, ShowResult. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbmlzo\"\n#require \"hbbz2\"\n#require \"hblzf\"\n\n#include \"simpleio.ch\"\n\n#define TEST_STRING \"This is test of LZO extension\"\n#define FMT_STRING \"Compressed %d bytes into %d bytes (%d)\"\n#define FMT2_STRING \"Decompressed %d bytes back into %d bytes (%d)\"\n\nPROCEDURE Main()\n\n LOCAL cStr, cCompressed, cDeCompressed\n LOCAL checksum\n LOCAL nLen, nLenC, nLenD, nResult\n LOCAL k\n LOCAL aRepl := { 10, 100, 1000, 10000, 100000, 1000000 }\n\n \n ?? \"miniLZO -- mini subset of the LZO real-time data compression library\"\n ? \"Ver. \" + ;\n lzo_version_string() + ;\n \" (0x\" + hb_NumToHex( lzo_version() ) + \"), \" + ;\n lzo_version_date()\n\n ?\n cStr := TEST_STRING\n cCompressed := hb_lzo1x_1_compress( @cStr, @nLenC, @nResult )\n ShowResult( @cStr, @cCompressed, @nLenC, @nResult )\n\n FOR EACH k IN aRepl\n cStr := Replicate( TEST_STRING, k )\n\n cCompressed := hb_lzo1x_1_compress( @cStr, @nLenC, @nResult )\n ShowResult( @cStr, @cCompressed, @nLenC, @nResult )\n IF nResult != LZO_E_OK\n RETURN\n ENDIF\n NEXT\n\n ?\n cStr := Replicate( TEST_STRING, 500 )\n nLen := Len( cStr )\n checksum := hb_Adler32( cStr )\n cCompressed := hb_lzo1x_1_compress( @cStr, @nLenC, @nResult )\n ShowResult( @cStr, @cCompressed, @nLenC, @nResult )\n\n \n nLenD := nLenC\n cDeCompressed := hb_lzo1x_decompress_safe( @cCompressed, @nLenD, @nResult )\n\n IF nResult != LZO_E_OK .OR. nLenD != nLen .OR. checksum != hb_Adler32( cDeCompressed )\n ? \"Internal error - decompression failed: \", hb_ntos( nResult )\n ELSE\n ? hb_StrFormat( FMT2_STRING, nLenC, nLenD, nLen )\n ENDIF\n\n \n nLenD := nLen\n cDeCompressed := hb_lzo1x_decompress( @cCompressed, @nLenD, @nResult )\n\n IF nResult != LZO_E_OK .OR. nLenD != nLen .OR. checksum != hb_Adler32( cDeCompressed )\n ? \"Internal error - decompression failed: \", hb_ntos( nResult )\n ELSE\n ? hb_StrFormat( FMT2_STRING, nLenC, nLenD, nLen )\n ENDIF\n\n ?\n ? \"Simple compression test passed.\"\n\n\n RETURN\n\nSTATIC PROCEDURE ShowResult( cStr, cCompressed, nLen, nResult )\n\n IF nResult == LZO_E_OK\n ? hb_StrFormat( FMT_STRING, Len( cStr ), nLen, Len( cCompressed ) )\n ELSEIF nResult == LZO_E_OUT_OF_MEMORY\n ? \"Out of memory..\"\n ELSEIF nResult == LZO_E_NOT_COMPRESSIBLE\n ? \"This block contains incompressible data\", hb_ntos( nLen )\n ELSE\n ? \"Internal error - compression failed:\", hb_ntos( nResult )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/olesrv4.prg. Defines classes: OleObjServer, timerCls, infoCls. Contains procedures: DllMain. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#define CLS_Name \"MyOleObjServer\"\n#define CLS_ID \"{23245C3F-4487-404B-985F-E33886698D23}\"\n\n#include \"hbclass.ch\"\n\nPROCEDURE DllMain()\n\n win_oleServerInit( CLS_ID, CLS_Name, OleObjServer():new() )\n\n RETURN\n\n\nCREATE CLASS OleObjServer\n\n METHOD timer\n METHOD info\n METHOD ref\n\nENDCLASS\n\nMETHOD timer() CLASS OleObjServer\n RETURN timerCls():new()\n\nMETHOD info() CLASS OleObjServer\n RETURN infoCls():new()\n\nMETHOD ref( p1, p2, p3, p4, p5, p6, p7 ) CLASS OleObjServer\n\n p1 := Date()\n p2 := hb_DateTime()\n p3 := .T.\n p4 := { \"A\", \"B\", \"C\" }\n p5 := timerCls():new()\n p6 := 123.456\n p7 := \"text\"\n\n RETURN \"DONE\"\n\n\nCREATE CLASS timerCls\n\n MESSAGE date EXTERN Date()\n MESSAGE time EXTERN Time()\n MESSAGE now EXTERN hb_DateTime()\n\nENDCLASS\n\nCREATE CLASS infoCls\n\n MESSAGE os EXTERN OS()\n MESSAGE ver EXTERN Version()\n MESSAGE compiler EXTERN hb_Compiler()\n MESSAGE build EXTERN hb_BuildDate()\n\nENDCLASS\n\nANNOUNCE GT_SYS\nREQUEST HB_GT_GUI_DEFAULT"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/menuto.prg. Provides functions: ft_Prompt, ft_MenuTo. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"setcurs.ch\"\n#include \"inkey.ch\"\n\n#xtranslate isOkay( ) => ( \\> 0 .AND. \\<= nCount )\n#xtranslate isBetween( , , ) => ( \\>= .AND. \\<= )\n\n\nTHREAD STATIC t_aRow := { {} }\nTHREAD STATIC t_aCol := { {} }\nTHREAD STATIC t_aPrompt := { {} }\nTHREAD STATIC t_aColor := { {} }\nTHREAD STATIC t_aMsgRow := { {} }\nTHREAD STATIC t_aMsgCol := { {} }\nTHREAD STATIC t_aMessage := { {} }\nTHREAD STATIC t_aMsgColor := { {} }\nTHREAD STATIC t_aTrigger := { {} }\nTHREAD STATIC t_aTriggerInkey := { {} }\nTHREAD STATIC t_aTriggerColor := { {} }\nTHREAD STATIC t_aHome := { {} }\nTHREAD STATIC t_aEnd := { {} }\nTHREAD STATIC t_aUp := { {} }\nTHREAD STATIC t_aDown := { {} }\nTHREAD STATIC t_aLeft := { {} }\nTHREAD STATIC t_aRight := { {} }\nTHREAD STATIC t_aExecute := { {} }\nTHREAD STATIC t_nLevel := 1\n\nFUNCTION ft_Prompt( nRow, nCol, cPrompt, cColor, ;\n nMsgRow, nMsgCol, cMessage, cMsgColor, ;\n nTrigger, cTriggerColor, nHome, nEnd, ;\n nUp, nDown, nLeft, nRight, bExecute )\n\n \n __defaultNIL( @cColor, SetColor() )\n\n \n IF cMessage == NIL\n\n nMsgRow := nMsgCol := cMsgColor := NIL\n\n ELSE\n \n __defaultNIL( @nMsgRow, Set( _SET_MESSAGE ) )\n\n \n IF nMsgCol == NIL\n IF Set( _SET_MCENTER )\n nMsgCol := Int( ( MaxCol() + 1 - Len( cPrompt ) ) / 2 )\n ELSE\n nMsgCol := 0\n ENDIF\n ENDIF\n\n \n __defaultNIL( @cMsgColor, cColor )\n ENDIF\n\n \n __defaultNIL( @nTrigger, 1 )\n __defaultNIL( @cTriggerColor, cColor )\n\n \n AAdd( t_aRow[ t_nLevel ], nRow )\n AAdd( t_aCol[ t_nLevel ], nCol )\n AAdd( t_aPrompt[ t_nLevel ], cPrompt )\n AAdd( t_aColor[ t_nLevel ], cColor )\n AAdd( t_aMsgRow[ t_nLevel ], nMsgRow )\n AAdd( t_aMsgCol[ t_nLevel ], nMsgCol )\n AAdd( t_aMessage[ t_nLevel ], cMessage )\n AAdd( t_aMsgColor[ t_nLevel ], cMsgColor )\n AAdd( t_aTrigger[ t_nLevel ], nTrigger )\n AAdd( t_aTriggerInkey[ t_nLevel ], hb_keyCode( Upper( SubStr( cPrompt, nTrigger, 1 ) ) ) )\n AAdd( t_aTriggerColor[ t_nLevel ], cTriggerColor )\n AAdd( t_aHome[ t_nLevel ], nHome )\n AAdd( t_aEnd[ t_nLevel ], nEnd )\n AAdd( t_aUp[ t_nLevel ], nUp )\n AAdd( t_aDown[ t_nLevel ], nDown )\n AAdd( t_aLeft[ t_nLevel ], nLeft )\n AAdd( t_aRight[ t_nLevel ], nRight )\n AAdd( t_aExecute[ t_nLevel ], bExecute )\n\n \n DispBegin()\n hb_DispOutAt( nRow, nCol, cPrompt, cColor )\n hb_DispOutAt( nRow, nCol - 1 + nTrigger, SubStr( cPrompt, nTrigger, 1 ), cTriggerColor )\n DispEnd()\n\n RETURN NIL\n\nFUNCTION ft_MenuTo( bGetSet, cReadVar, lCold )\n\n LOCAL nMenu := t_nLevel++\n LOCAL nActive\n LOCAL nCount := Len( t_aRow[ nMenu ] )\n LOCAL lChoice := .F.\n LOCAL nCursor := Set( _SET_CURSOR, SC_NONE )\n LOCAL nKey, bKey, nScan, lWrap, cScreen, nPrev\n\n IF ! HB_ISLOGICAL( lCold )\n lCold := .F.\n ENDIF\n\n \n __defaultNIL( @cReadVar, \"\" )\n\n cReadVar := Upper( cReadVar )\n\n IF bGetSet == NIL\n bGetSet := {|| 1 }\n ENDIF\n\n \n nActive := Eval( bGetSet )\n\n IF nActive < 1 .OR. nActive > nCount\n nActive := 1\n ENDIF\n\n \n AAdd( t_aRow, {} )\n AAdd( t_aCol, {} )\n AAdd( t_aPrompt, {} )\n AAdd( t_aColor, {} )\n AAdd( t_aMsgRow, {} )\n AAdd( t_aMsgCol, {} )\n AAdd( t_aMessage, {} )\n AAdd( t_aMsgColor, {} )\n AAdd( t_aTrigger, {} )\n AAdd( t_aTriggerInkey, {} )\n AAdd( t_aTriggerColor, {} )\n AAdd( t_aUp, {} )\n AAdd( t_aDown, {} )\n AAdd( t_aLeft, {} )\n AAdd( t_aRight, {} )\n AAdd( t_aExecute, {} )\n\n \n DO WHILE ! lChoice\n\n \n Eval( bGetSet, nActive )\n\n \n lWrap := Set( _SET_WRAP )\n\n \n DispBegin()\n\n IF t_aMessage[ nMenu, nActive ] != NIL\n cScreen := SaveScreen( t_aMsgRow[ nMenu, nActive ], t_aMsgCol[ nMenu, nActive ], ;\n t_aMsgRow[ nMenu, nActive ], t_aMsgCol[ nMenu, nActive ] + ;\n Len( t_aMessage[ nMenu, nActive ] ) - 1 )\n\n hb_DispOutAt( t_aMsgRow[ nMenu, nActive ], t_aMsgCol[ nMenu, nActive ], ;\n t_aMessage[ nMenu, nActive ], t_aMsgColor[ nMenu, nActive ] )\n\n ELSE\n cScreen := NIL\n ENDIF\n\n \n hb_DispOutAt( t_aRow[ nMenu, nActive ], t_aCol[ nMenu, nActive ], ;\n t_aPrompt[ nMenu, nActive ], hb_ColorIndex( t_aColor[ nMenu, nActive ], 1 ) )\n\n hb_DispOutAt( t_aRow[ nMenu, nActive ], ;\n t_aCol[ nMenu, nActive ] - 1 + t_aTrigger[ nMenu, nActive ], ;\n SubStr( t_aPrompt[ nMenu, nActive ], t_aTrigger[ nMenu, nActive ], 1 ), ;\n hb_ColorIndex( t_aTriggerColor[ nMenu, nActive ], 1 ) )\n\n DispEnd()\n\n \n nKey := Inkey( 0 )\n\n \n IF isBetween( nKey, 97, 122 )\n nKey -= 32\n ENDIF\n\n \n nPrev := nActive\n\n DO CASE\n\n \n CASE ( bKey := SetKey( nKey ) ) != NIL\n Eval( bKey, ProcName( 1 ), ProcLine( 1 ), cReadVar )\n\n \n CASE nKey == K_ENTER\n IF t_aExecute[ nMenu, nActive ] != NIL\n Eval( t_aExecute[ nMenu, nActive ] )\n ELSE\n lChoice := .T.\n ENDIF\n\n \n CASE nKey == K_ESC\n lChoice := .T.\n nActive := 0\n\n \n CASE nKey == K_HOME\n nActive := iif( t_aHome[ nMenu, nActive ] == NIL, 1, t_aHome[ nMenu, nActive ] )\n\n \n CASE nKey == K_END\n nActive := iif( t_aEnd[ nMenu, nActive ] == NIL, nCount, t_aEnd[ nMenu, nActive ] )\n\n \n CASE nKey == K_UP\n IF t_aUp[ nMenu, nActive ] == NIL\n IF --nActive < 1\n nActive := iif( lWrap, nCount, 1 )\n ENDIF\n ELSE\n IF isOkay( t_aUp[ nMenu, nActive ] )\n nActive := t_aUp[ nMenu, nActive ]\n ENDIF\n ENDIF\n\n \n CASE nKey == K_DOWN\n IF t_aDown[ nMenu, nActive ] == NIL\n if ++nActive > nCount\n nActive := iif( lWrap, 1, nCount )\n ENDIF\n ELSE\n IF isOkay( t_aDown[ nMenu, nActive ] )\n nActive := t_aDown[ nMenu, nActive ]\n ENDIF\n ENDIF\n\n \n CASE nKey == K_LEFT\n IF t_aLeft[ nMenu, nActive ] == NIL\n IF --nActive < 1\n nActive := iif( lWrap, nCount, 1 )\n ENDIF\n ELSE\n IF isOkay( t_aLeft[ nMenu, nActive ] )\n nActive := t_aLeft[ nMenu, nActive ]\n ENDIF\n ENDIF\n\n \n CASE nKey == K_RIGHT\n IF t_aRight[ nMenu, nActive ] == NIL\n if ++nActive > nCount\n nActive := iif( lWrap, 1, nCount )\n ENDIF\n ELSE\n IF isOkay( t_aRight[ nMenu, nActive ] )\n nActive := t_aRight[ nMenu, nActive ]\n ENDIF\n ENDIF\n\n \n CASE ( nScan := AScan( t_aTriggerInkey[ nMenu ], nKey ) ) > 0\n nActive := nScan\n IF ! lCold\n hb_keyPut( K_ENTER )\n ENDIF\n ENDCASE\n\n \n IF ! lChoice\n DispBegin()\n hb_DispOutAt( t_aRow[ nMenu, nPrev ], t_aCol[ nMenu, nPrev ], ;\n t_aPrompt[ nMenu, nPrev ], t_aColor[ nMenu, nPrev ] )\n\n hb_DispOutAt( t_aRow[ nMenu, nPrev ], t_aCol[ nMenu, nPrev ] - 1 + t_aTrigger[ nMenu, nPrev ], ;\n SubStr( t_aPrompt[ nMenu, nPrev ], t_aTrigger[ nMenu, nPrev ], 1 ), ;\n t_aTriggerColor[ nMenu, nPrev ] )\n\n IF cScreen != NIL\n RestScreen( t_aMsgRow[ nMenu, nPrev ], ;\n t_aMsgCol[ nMenu, nPrev ], ;\n t_aMsgRow[ nMenu, nPrev ], ;\n t_aMsgCol[ nMenu, nPrev ] ;"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/tokensep.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#else\n#define hb_ntos( n ) LTrim( Str( n ) )\n#endif\n\nPROCEDURE Main()\n\n LOCAL cStr := \".,.This.,.is.,.a.,.test!\"\n LOCAL ni\n\n ctinit()\n\n ? \"Begin test of TokenSep()\"\n ?\n\n ? ' Tokenizing the string \"' + cStr + '\"'\n ? ' with skip width == 1 and \".,!\" as tokenizer list:'\n ?\n FOR ni := 1 TO NumToken( cStr, \".,!\", 1 )\n ? ' Token #' + hb_ntos( ni ) + '(\"' + Token( cStr, \".,!\", ni, 1 ) + ;\n '\") is tokenized by \"' + TokenSep( .F. ) + '\" and \"' + TokenSep( .T. ) + '\"'\n NEXT\n\n ?\n ? ' Tokenizing the string \"' + cStr + '\"'\n ? ' with skip width == 3 and \".,!\" as tokenizer list:'\n ?\n FOR ni := 1 TO NumToken( cStr, \".,!\", 3 )\n ? ' Token #' + hb_ntos( ni ) + '(\"' + Token( cStr, \".,!\", ni, 3 ) + ;\n '\") is tokenized by \"' + TokenSep( .F. ) + '\" and \"' + TokenSep( .T. ) + '\"'\n NEXT\n\n ?\n ? \"End test of TokenSep()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/findith.prg. Provides functions: ft_FindITh. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_FindITh( cCheckFor, cCheckIn, nWhichOccurrence, lIgnoreCase )\n\n LOCAL nIthOccurrence\n\n \n IF ! HB_ISLOGICAL( lIgnoreCase ) .OR. lIgnoreCase\n cCheckFor := Upper( cCheckFor )\n cCheckIn := Upper( cCheckIn )\n ENDIF\n\n RETURN iif( nWhichOccurrence == 1, ;\n At( cCheckFor, cCheckIn ), ;\n iif( ( nIthOccurrence := At( cCheckFor, ;\n StrTran( cCheckIn, cCheckFor, ;\n \"\", 1, ;\n nWhichOccurrence - 1 ) ) ) == 0, ;\n 0, ;\n nIthOccurrence + ( ( nWhichOccurrence - 1 )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour source file: src/rdd/hbsix/sxtrig.prg. Provides functions: sx_DefTrigger. This file implements core Record Driver Driver functionality"}, {"role": "assistant", "content": "#include \"hbsxdef.ch\"\n\nFUNCTION sx_DefTrigger( nEvent, nArea, nFieldPos, xTrigVal )\n\n HB_SYMBOL_UNUSED( nArea )\n HB_SYMBOL_UNUSED( nFieldPos )\n HB_SYMBOL_UNUSED( xTrigVal )\n\n SWITCH nEvent\n CASE EVENT_PREUSE\n sx_SetTrigger( TRIGGER_REMOVE )\n EXIT\n CASE EVENT_POSTUSE\n EXIT\n CASE EVENT_UPDATE\n EXIT\n CASE EVENT_APPEND\n EXIT\n CASE EVENT_DELETE\n EXIT\n CASE EVENT_RECALL\n EXIT\n CASE EVENT_PACK\n EXIT\n CASE EVENT_ZAP\n EXIT\n CASE EVENT_PUT\n EXIT\n CASE EVENT_GET\n EXIT\n CASE EVENT_PRECLOSE\n EXIT\n CASE EVENT_POSTCLOSE\n EXIT\n CASE EVENT_PREMEMOPACK\n EXIT\n CASE EVENT_POSTMEMOPACK\n EXIT\n ENDSWITCH\n\n RETURN .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/onidle.prg. Contains procedures: Main, TEST. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbmemory.ch\"\n\nPROCEDURE Main()\n\n LOCAL nH1, nH2, nH3, nH4\n LOCAL n := 0\n LOCAL aSign := { \"|\", \"/\", \"-\", \"\\\" }\n LOCAL nPrev := Seconds()\n\n CLS\n ? \" Time: Memory used: Milliseconds elapsed\"\n ?\n ? \"Can you see it ??? :) Press any key or wait 30 seconds\"\n ?\n ?\n @ 10, 2 SAY \"Memory before TEST() call\" + Str( Memory( HB_MEM_USED ) )\n TEST()\n @ 11, 2 SAY \"Memory after TEST() and before collecting\" + Str( Memory( HB_MEM_USED ) )\n hb_gcAll()\n @ 12, 2 SAY \"Memory after collecting\" + Str( Memory( HB_MEM_USED ) )\n nH1 := hb_idleAdd( {|| hb_DispOutAt( 0, 1, Time() ) } )\n nH2 := hb_idleAdd( {|| TEST(), hb_DispOutAt( 0, 21, Memory( HB_MEM_USED ) ) } )\n nH3 := hb_idleAdd( {|| iif( n == 4, n := 1, n++ ), hb_DispOutAt( 0, 41, aSign[ n ] ) } )\n nH4 := hb_idleAdd( {|| hb_DispOutAt( 0, 61, 1000\n @ 14, 2 SAY \"Delete task 3: \" + hb_ValToStr( nH3 )\n hb_idleDel( nH3 )\n ENDIF\n IF ! Empty( nH2 )\n @ 15, 2 SAY \"Delete task 2: \" + hb_ValToStr( nH2 )\n hb_idleDel( nH2 )\n ENDIF\n IF ! Empty( nH1 )\n @ 16, 2 SAY \"Delete task 1: \" + hb_ValToStr( nH1 )\n hb_idleDel( nH1 )\n ENDIF\n IF ! Empty( nH4 )\n @ 17, 2 SAY \"Delete task 4: \" + hb_ValToStr( nH4 )\n hb_idleDel( nH4 )\n ENDIF\n\n @ 18, 2 SAY \"Memory after idle states\" + Str( Memory( HB_MEM_USED ) )\n hb_gcAll()\n @ 19, 2 SAY \"Memory after collecting\" + Str( Memory( HB_MEM_USED ) )\n\n RETURN\n\nSTATIC PROCEDURE TEST()\n\n LOCAL a, b, c\n LOCAL cb\n\n a := Array( 3 )\n b := Array( 3 )\n c := Array( 3 )\n a[ 1 ] := a\n a[ 2 ] := b\n a[ 3 ] := c\n b[ 1 ] := a\n b[ 2 ] := b\n b[ 3 ] := c\n c[ 1 ] := a\n c[ 2 ] := b\n c[ 3 ] := c\n\n cb := {| x | x := cb }\n Eval( cb )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbtpathy' (Telepath communication library): contrib/hbtpathy/tests/test.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbtpathy\"\n\nPROCEDURE Main()\n\n ? tp_open( 1,,, 9600, 8, \"N\", 1 )\n tp_send( 1, \"Hi there Bob\", 1 ) \n tp_inkey( .5 )\n ? tp_recv( 1 )\n ?\n tp_close( 1 )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/tbwhile.prg. Provides functions: make_dbf. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\nPROCEDURE Main()\n\n LOCAL aFields := {}, cKey := \"O\", cOldColor\n LOCAL nFreeze := 1, lSaveScrn := .T., nRecSel\n LOCAL cColorList := \"N/W, N/BG, B/W, B/BG, B/W, B/BG, R/W, B/R\"\n LOCAL cColorShad := \"N/N\"\n LOCAL GetList := {}\n\n FIELD last, first\n\n IF ! hb_dbExists( \"tbnames.dbf\" )\n make_dbf()\n ENDIF\n\n USE tbnames\n\n IF ! hb_dbExists( \"tbnames.ntx\" )\n INDEX ON last + first TO tbnames\n ENDIF\n\n SET INDEX TO tbnames\n\n \n AAdd( aFields, { \"Last Name\" , {|| tbnames->Last } } )\n AAdd( aFields, { \"First Name\", {|| tbnames->First } } )\n AAdd( aFields, { \"City\" , {|| tbnames->City } } )\n\n cOldColor := SetColor( \"N/BG\" )\n CLS\n @ 5, 10 SAY \"Enter First Letter Of Last Name:\" GET cKey PICTURE \"!\"\n READ\n\n \n nRecSel := ft_BrwsWhl( aFields, {|| tbnames->Last = cKey }, cKey, nFreeze, ;\n lSaveScrn, cColorList, cColorShad, 3, 6, MaxRow() - 2, MaxCol() - 6 )\n \n \n ?\n IF nRecSel == 0\n ? \"Sorry, NO Records Were Selected\"\n ELSE\n ? \"You Selected \" + ;\n tbnames->Last + \" \" + ;\n tbnames->First + \" \" + ;\n tbnames->City\n ENDIF\n ?\n\n WAIT\n SetColor( cOldColor )\n CLS\n\n RETURN\n\nSTATIC FUNCTION make_dbf()\n\n LOCAL x, aData := { ;\n { \"SHAEFER\", \"KATHRYN\", \"415 WEST CITRUS ROAD #150\", \"LOS ANGELES\", \"CA\", \"90030\" }, ;\n { \"OLSON\", \"JAMES\", \"225 NORTH RANCH ROAD\", \"LOS ANGELES\", \"CA\", \"90023\" }, ;\n { \"KAYBEE\", \"JOHN\", \"123 SANDS ROAD\", \"CAMARILLO\", \"CA\", \"93010\" }, ;\n { \"HERMAN\", \"JIM\", \"123 TOON PAGE ROAD\", \"VENTURA\", \"CA\", \"93001\" }, ;\n { \"BURNS\", \"FRANK\", \"123 VIRGINA STREET\", \"OXNARD\", \"CA\", \"93030\" }, ;\n { \"PIERCE\", \"HAWKEYE\", \"123 OLD TOWN ROAD\", \"PORT MUGU\", \"CA\", \"93043\" }, ;\n { \"MORGAN\", \"JESSICA\", \"123 FRONTAGE ROAD\", \"CAMARILLO\", \"CA\", \"93010\" }, ;\n { \"POTTER\", \"ROBERT\", \"123 FIR STREET\", \"OXNARD\", \"CA\", \"93030\" }, ;\n { \"WORTH\", \"MARY\", \"123-1/2 JOHNSON DRIVE\", \"OXNARD\", \"CA\", \"93033\" }, ;\n { \"JOHNSON\", \"SUSAN\", \"123 QUEENS STREET\", \"OXNARD\", \"CA\", \"93030\" }, ;\n { \"SAMSON\", \"SAM\", \"215 MAIN STREET\", \"OXNARD\", \"CA\", \"93030\" }, ;\n { \"NEWNAME\", \"JAMES\", \"215 MAIN STREET\", \"LOS ANGELES\", \"CA\", \"90000\" }, ;\n { \"OLEANDAR\", \"JILL\", \"425 FLORAL PARK DRIVE\", \"FLORAL PARK\", \"NY\", \"10093\" }, ;\n { \"SUGARMAN\", \"CANDY\", \"1541 SWEETHEART ROAD\", \"HERSHEY\", \"PA\", \"10132\" } }\n\n dbCreate( \"tbnames\", { ;\n { \"LAST \", \"C\", 18, 0, }, ;\n { \"FIRST\", \"C\", 9, 0, }, ;\n { \"ADDR \", \"C\", 28, 0, }, ;\n { \"CITY \", \"C\", 21, 0, }, ;\n { \"STATE\", \"C\", 2, 0, }, ;\n { \"ZIP \", \"C\", 9, 0, } } )\n USE tbnames\n FOR x := 1 TO Len( aData )\n APPEND BLANK\n AEval( aData[ x ], {| e, n | FieldPut( n, e ) } )\n NEXT\n USE\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/dynsym.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL nCount := __dynsCount()\n LOCAL nPos\n\n FOR nPos := 1 TO nCount\n ? __dynsGetName( nPos )\n NEXT\n\n nPos := __dynsGetIndex( \"MAIN\" )\n ? \"MAIN\", nPos\n\n ? __dynsGetName( nPos )\n ? __dynsGetName()\n ? __dynsGetName( 0 )\n ? __dynsGetName( 100000 )\n ? __dynsGetName( __dynsGetIndex( \"HB_THISDOESNTEXIST_\" ) )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/olesrv2.prg. Provides functions: get_data. Contains procedures: DllMain. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#define CLS_Name \"MyOleTimeServer\"\n#define CLS_ID \"{5552013F-2990-4D6C-9C96-55A4BDDCE376}\"\n\nPROCEDURE DllMain()\n\n LOCAL hAction\n\n hAction := { => }\n hb_HCaseMatch( hAction, .F. )\n hAction[ \"DATE\" ] := @Date() \n hAction[ \"TIME\" ] := @Time() \n hAction[ \"DATETIME\" ] := @hb_DateTime() \n hAction[ \"VALUE\" ] := NIL \n hAction[ \"GETDATA\" ] := @get_data() \n\n \n win_oleServerInit( CLS_ID, CLS_Name, hAction, .T. )\n\n RETURN\n\n\nSTATIC FUNCTION get_data( ... )\n\n LOCAL hAction := QSelf()\n\n IF hAction[ \"VALUE\" ] == NIL\n RETURN \"(:VALUE IS NOT SET)\"\n ENDIF\n\n RETURN \":VALUE='\" + hAction[ \"VALUE\" ] + \"'\"\n\n\nANNOUNCE GT_SYS\nREQUEST HB_GT_GUI_DEFAULT"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/calendar.prg. Provides functions: ft_Calendar, JDOY. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"box.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\nFUNCTION ft_Calendar( nRow, nCol, cColor, lShadow, lShowHelp )\n\n LOCAL nJump := 0, nKey := 0, cSavColor, cSaveScreen, cSaveCursor\n LOCAL aRetVal[ 8 ]\n LOCAL nHelpRow, cSaveHelp, lHelpIsDisplayed := .F.\n\n __defaultNIL( @nRow, 1 ) \n __defaultNIL( @nCol, 63 ) \n __defaultNIL( @cColor, \"W+/G\" ) \n __defaultNIL( @lShadow, .F. ) \n __defaultNIL( @lShowHelp, .F. ) \n\n nRow := iif( nRow < 1 .OR. nRow > 21, 1, nRow ) \n nCol := iif( nCol < 1 .OR. nCol > 63, 63, nCol ) \n\n cSavColor := SetColor( cColor ) \n cSaveScreen := SaveScreen( nRow - 1, nCol - 1, nRow + 3, nCol + 17 ) \n cSaveCursor := SetCursor( SC_NONE ) \n\n IF lShadow\n hb_DispBox( nRow - 1, nCol - 1, nRow + 2, nCol + 15, HB_B_SINGLE_UNI )\n hb_Shadow( nRow - 1, nCol - 1, nRow + 2, nCol + 15 )\n ENDIF\n\n IF lShowHelp\n nHelpRow := iif( nRow > 10, nRow - 10, nRow + 6 )\n ENDIF\n\n DO WHILE nKey != K_ESC\n\n DO CASE\n CASE nKey == K_HOME\n nJump := nJump - 1\n\n CASE nKey == K_END\n nJump := nJump + 1\n\n CASE nKey == K_UP\n nJump := nJump - 30\n\n CASE nKey == K_DOWN\n nJump := nJump + 30\n\n CASE nKey == K_PGUP\n nJump := nJump - 365\n\n CASE nKey == K_PGDN\n nJump := nJump + 365\n\n CASE nKey == K_RIGHT\n nJump := nJump - 7\n\n CASE nKey == K_LEFT\n nJump := nJump + 7\n\n CASE nKey == K_INS\n nJump := 0\n\n CASE nKey == K_F1\n IF lShowHelp .AND. ! lHelpIsDisplayed\n lHelpIsDisplayed := .T.\n cSaveHelp := SaveScreen( nHelpRow - 1, 1, nHelpRow + 7, 80 )\n ft_XBox( \"L\",,, cColor, cColor, nHelpRow, 1, ;\n \"Home, Up_Arrow or PgUp keys page by day, month or year to a past date.\", ;\n \"End, Dn_Arrow or PgDn keys page by day, month or year to a future date.\", ;\n \"Left_Arrow or Right_Arrow keys page by week to a past or future date.\", ;\n \"Hit Ins to reset to today's date, F1 to get this help, ESC to quit.\" )\n ENDIF\n\n ENDCASE\n\n aRetVal[ 1 ] := Date() + nJump\n aRetVal[ 2 ] := Month( Date() + nJump )\n aRetVal[ 3 ] := Day( Date() + nJump )\n aRetVal[ 4 ] := Year( Date() + nJump )\n aRetVal[ 5 ] := CMonth( Date() + nJump )\n aRetVal[ 6 ] := CDoW( Date() + nJump )\n aRetVal[ 7 ] := JDOY( aRetVal[ 4 ], aRetVal[ 2 ], aRetVal[ 3 ] )\n\n hb_DispOutAt( nRow, nCol, ;\n Left( aRetval[ 6 ], 3 ) + \" \" + ;\n Str( aRetVal[ 3 ], 2, 0 ) + \" \" + ;\n Left( aRetVal[ 5 ], 3 ) + \" \" + ;\n Str( aRetVal[ 4 ], 4, 0 ) )\n\n hb_DispOutAt( nRow + 1, nCol, ;\n Str( aRetVal[ 7 ], 3, 0 ) )\n\n nKey := 0\n DO WHILE nKey == 0\n hb_DispOutAt( nRow + 1, nCol + 3, \" \" + Time() )\n nKey := Inkey( 1 )\n ENDDO\n aRetVal[ 8 ] := Time()\n ENDDO\n\n SetColor( cSavColor ) \n SetCursor( cSaveCursor ) \n RestScreen( nRow - 1, nCol - 1, nRow + 3, nCol + 17, cSaveScreen ) \n IF lHelpIsDisplayed\n RestScreen( nHelpRow - 1, 1, nHelpRow + 7, 80, cSaveHelp )\n ENDIF\n\n RETURN aRetVal\n\nSTATIC FUNCTION JDOY( nYear, nMonth, nDay )\n\n LOCAL cString := \"000031059090120151181212243273304334\"\n\n RETURN VALS( cString, ( nMonth - 1 )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/client.prg. Defines classes: TIPClient. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"error.ch\"\n#include \"fileio.ch\"\n\n#if defined( _SSL_DEBUG_TEMP )\n #include \"simpleio.ch\"\n#endif\n\n#include \"hbssl.ch\"\n#undef __HBEXTREQ__\n#include \"hbssl.hbx\"\n\n#define RCV_BUF_SIZE Int( ::InetRcvBufSize( ::SocketCon ) / 2 )\n#define SND_BUF_SIZE Int( ::InetSndBufSize( ::SocketCon ) / 2 )\n\n\nCREATE CLASS TIPClient\n\n CLASS VAR bInitSocks INIT .F.\n CLASS VAR cCRLF INIT tip_CRLF()\n\n VAR oUrl \n VAR oCredentials \n VAR nStatus INIT 0 \n VAR SocketCon\n VAR bTrace\n\n VAR nDefaultRcvBuffSize\n VAR nDefaultSndBuffSize\n\n VAR nLength INIT -1 \n VAR nRead INIT 0 \n VAR nLastRead INIT 0 \n\n VAR nDefaultPort\n VAR nConnTimeout\n VAR bInitialized INIT .F.\n\n VAR cReply\n VAR nAccessMode\n VAR nWrite INIT 0\n VAR nLastWrite INIT 0\n\n VAR bEof INIT .F.\n VAR isOpen INIT .F.\n\n VAR exGauge \n\n VAR lSSL INIT .F.\n\n VAR lHasSSL INIT tip_SSL()\n VAR ssl_ctx\n VAR ssl\n VAR nSSLError INIT 0\n\n VAR Cargo\n\n \n VAR cProxyHost INIT \"\"\n VAR nProxyPort INIT 0\n VAR cProxyUser\n VAR cProxyPassword\n VAR lProxyXferSSL INIT .F. \n\n METHOD New( oUrl, xTrace, oCredentials )\n METHOD Open( cUrl )\n\n METHOD EnableSSL( lEnable )\n\n METHOD Read( nLen )\n METHOD ReadToFile( cFile, nMode, nSize )\n METHOD Write( cData, nLen, lCommit )\n METHOD Commit()\n METHOD WriteFromFile( cFile )\n METHOD Reset()\n METHOD Close()\n\n METHOD SetProxy( cProxyHost, nProxyPort, cProxyUser, cProxyPassword )\n\n METHOD lastErrorCode() INLINE ::nLastError\n METHOD lastErrorMessage( SocketCon ) INLINE ::inetErrorDesc( SocketCon )\n\n METHOD InetRcvBufSize( SocketCon, nSizeBuff )\n METHOD InetSndBufSize( SocketCon, nSizeBuff )\n\n METHOD InetTimeOut( SocketCon, nConnTimeout )\n\n METHOD HasSSL() INLINE ::lHasSSL\n\n PROTECTED:\n\n VAR nLastError INIT 0\n\n METHOD OpenProxy( cServer, nPort, cProxy, nProxyPort, cResp, cUserName, cPassword, cUserAgent )\n METHOD ReadHTTPProxyResponse( cResponse )\n\n \n METHOD inetRecv( SocketCon, cStr1, len )\n METHOD inetRecvLine( SocketCon, nRet, size )\n METHOD inetRecvAll( SocketCon, cRet, size )\n METHOD inetCount( SocketCon )\n METHOD inetSendAll( SocketCon, cData, nLen )\n METHOD inetErrorCode( SocketCon )\n METHOD inetErrorDesc( SocketCon )\n METHOD inetConnect( cServer, nPort, SocketCon )\n\n METHOD Log( ... )\n\nENDCLASS\n\nMETHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClient\n\n LOCAL oErr\n LOCAL oLog\n LOCAL lSSL\n\n DO CASE\n CASE HB_ISSTRING( xTrace ) .OR. hb_defaultValue( xTrace, .F. )\n oLog := TIPLog():New( iif( HB_ISSTRING( xTrace ), xTrace, NIL ) )\n ::bTrace := {| cMsg | iif( PCount() > 0, oLog:Add( cMsg ), oLog:Close() ) }\n CASE HB_ISEVALITEM( xTrace )\n ::bTrace := xTrace\n ENDCASE\n\n IF HB_ISSTRING( oUrl )\n oUrl := TUrl():New( oUrl )\n ENDIF\n\n SWITCH oURL:cProto\n CASE \"ftp\"\n CASE \"http\"\n CASE \"pop\"\n CASE \"smtp\"\n lSSL := .F.\n EXIT\n CASE \"ftps\"\n CASE \"https\"\n CASE \"pop3s\"\n CASE \"pops\"\n CASE \"smtps\"\n IF ::lHasSSL\n lSSL := .T.\n EXIT\n ENDIF\n OTHERWISE\n oErr := ErrorNew()\n oErr:Args := { Self, oURL:cProto }\n oErr:CanDefault := .F.\n oErr:CanRetry := .F.\n oErr:CanSubstitute := .T.\n oErr:Description := \"unsupported protocol\"\n oErr:GenCode := EG_UNSUPPORTED\n oErr:Operation := ::className() + \":new()\"\n oErr:Severity := ES_ERROR\n oErr:SubCode := 1081\n oErr:SubSystem := \"BASE\"\n Eval( ErrorBlock(), oErr )\n ENDSWITCH\n\n IF ! ::bInitSocks\n hb_inetInit()\n IF ::lHasSSL\n SSL_init()\n RAND_seed( hb_randStr( 20 ) + hb_TToS( hb_DateTime() ) + NetName() )\n ENDIF\n ::bInitSocks := .T.\n ENDIF\n\n IF ::lHasSSL .AND. lSSL\n ::EnableSSL( .T. )\n ENDIF\n\n ::oUrl := oUrl\n ::oCredentials := oCredentials\n\n RETURN Self\n\nMETHOD Open( cUrl ) CLASS TIPClient\n\n LOCAL nPort\n\n IF HB_ISSTRING( cUrl )\n ::oUrl := TUrl():New( cUrl )\n ENDIF\n\n nPort := iif( ::oUrl:nPort == -1, ::nDefaultPort, ::oUrl:nPort )\n\n ::SocketCon := hb_inetCreate()\n\n ::InetTimeOut( ::SocketCon )\n\n IF ::cProxyHost == \"\"\n ::inetConnect( ::oUrl:cServer, nPort, ::SocketCon )\n IF ::inetErrorCode( ::SocketCon ) != 0\n RETURN .F.\n ENDIF\n ELSEIF ! ::OpenProxy( ::oUrl:cServer, nPort, ::cProxyHost, ::nProxyPort,, ::cProxyUser, ::cProxyPassword, \"Mozilla/3.0 compatible\" )\n RETURN .F.\n ENDIF\n ::isOpen := .T.\n\n RETURN .T.\n\nMETHOD EnableSSL( lEnable ) CLASS TIPClient\n\n LOCAL lSuccess\n\n IF ::lSSL == lEnable\n RETURN .T.\n ENDIF\n\n ::lProxyXferSSL := .F.\n\n IF lEnable\n IF ::lHasSSL\n ::ssl_ctx := SSL_CTX_new()\n ::ssl := SSL_new( ::ssl_ctx )\n ::lSSL := .T.\n lSuccess := .T.\n ELSE\n lSuccess := .F.\n ENDIF\n ELSE\n IF ::lHasSSL\n ::lSSL := .F.\n lSuccess := .T.\n ELSE\n lSuccess := .T.\n ENDIF\n ENDIF\n\n RETURN lSuccess\n\nMETHOD OpenProxy( cServer, nPort, cProxy, nProxyPort, cResp, cUserName, cPassword, cUserAgent ) CLASS TIPClient\n\n LOCAL cRequest\n LOCAL lRet := .F.\n LOCAL tmp\n\n ::inetConnect( cProxy, nProxyPort, ::SocketCon )\n\n IF ( tmp := ::inetErrorCode( ::SocketCon ) ) == 0\n cRequest := ;\n \"CONNECT \" + cServer + \":\" + hb_ntos( nPort ) + \" HTTP/1.1\" + Chr( 13 ) + Chr( 10 ) + ;\n \"Proxy-Connection: Keep-Alive\" + Chr( 13 ) + Chr( 10 )\n IF HB_ISSTRING( cUserAgent ) .AND. ! cUserAgent == \"\"\n cRequest += \"User-Agent: \" + cUserAgent + Chr( 13 ) + Chr( 10 )\n ENDIF\n IF HB_ISSTRING( cUserName ) .AND. ! cUserName == \"\"\n cRequest += \"Proxy-Authorization: Basic \" + hb_base64Encode( cUserName + \":\" + hb_defaultValue( cPassword, \"\" ) ) + Chr( 13 ) + Chr( 10 )\n ENDIF\n cRequest += Chr( 13 ) + Chr( 10 )\n ::inetSendAll( ::SocketCon, cRequest )\n cResp := \"\"\n IF ::ReadHTTPProxyResponse( @cResp ) .AND. ;\n ( tmp := At( \" \", cResp ) ) > 0 .AND. ;\n Val( SubStr( cResp, tmp + 1 ) ) == 200\n lRet := .T.\n ELSE\n ::close()\n ENDIF\n ELSE\n cResp := hb_ntos( tmp )\n ENDIF\n\n \n IF lRet .AND. ::lSSL .AND. ::lHasSSL\n __tip_SSLConnectFD( ::ssl, ::SocketCon )\n ::lProxyXferSSL := .T.\n ELSE\n ::lProxyXferSSL := .F.\n ENDIF\n\n RETURN lRet\n\nMETHOD ReadHTTPProxyResponse( cResponse ) CLASS TIPClient\n\n LOCAL cBuffer\n\n DO WHILE .T.\n cBuffer := Space( 1 )\n IF ::inetRecv( ::SocketCon, @cBuffer, hb_BLen( cBuffer ) ) <= 0\n RETURN .F.\n ENDIF\n cResponse += cBuffer\n IF hb_BRight( cResponse, 4 ) == e\"\\r\\n\\r\\n\"\n EXIT\n ENDIF\n ENDDO\n\n RETURN .T.\n\nMETHOD Close() CLASS TIPClient\n\n LOCAL nRet\n\n IF Empty( ::SocketCon )\n nRet := -1\n ELSE\n nRet := hb_inetClose( ::SocketCon )\n\n IF ::lSSL .AND. ::lHasSSL\n SSL_shutdown( ::ssl )\n ::ssl := NIL\n ::ssl_ctx := NIL\n ENDIF\n\n ::SocketCon := NIL\n ::isOpen := .F.\n ::lProxyXferSSL := .F.\n ENDIF\n\n IF HB_ISEVALITEM( ::bTrace )\n \n Eval( ::bTrace )\n ENDIF\n\n RETURN nRet\n\nMETHOD Reset() CLASS TIPClient\n\n ::bInitialized := .F.\n ::bEof := .F.\n\n RETURN .T.\n\nMETHOD Commit() CLASS TIPClient\n RETURN .T.\n\nMETHOD Read( nLen ) CLASS TIPClient\n\n LOCAL cStr0\n LOCAL cStr1\n\n IF ::nLength > 0 .AND. ::nLength == ::nRead\n RETURN NIL\n ENDIF\n\n IF ! HB_ISNUMERIC( nLen ) .OR. nLen <= 0 .OR. ( ::nLength > 0 .AND. nLen > ::nLength - ::nRead )\n nLen := ::nLength - ::nRead\n ENDIF\n\n IF nLen <= 0\n \n cStr1 := Space( RCV_BUF_SIZE )\n cStr0 := \"\"\n DO WHILE ( ::nLastRead := ::inetRecv( ::SocketCon, @cStr1, RCV_BUF_SIZE ) ) > 0\n ::nRead += ::nLastRead"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour test program: tests/langmsg.prg. Provides functions: GET_DAYS, GET_MONTHS, GET_ERR, HB_LANGERRINTR, GET_IERR. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hblang.ch\"\n\nPROCEDURE Main( cLng )\n\n LOCAL i, a, aDay, aMnt, aErr, aInt, cDtFrm, cTrue, cFalse\n\n hb_langSelect( \"en\" )\n aDay := GET_DAYS()\n aMnt := GET_MONTHS()\n aErr := GET_ERR()\n aInt := GET_IERR()\n cDtFrm := hb_langMessage( HB_LANG_ITEM_BASE_TEXT )\n cTrue := hb_langMessage( HB_LANG_ITEM_BASE_TEXT + 1 )\n cFalse := hb_langMessage( HB_LANG_ITEM_BASE_TEXT + 2 )\n\n IF ! Empty( cLng )\n hb_langSelect( Upper( cLng ) )\n ENDIF\n\n ? hb_langName()\n ? \"HB_LANG_ITEM_BASE_ID \", \"[\" + hb_langMessage( HB_LANG_ITEM_BASE_ID ) + \"]\"\n ? \"HB_LANG_ITEM_BASE_MONTH \", \"[\" + hb_langMessage( HB_LANG_ITEM_BASE_MONTH ) + \"]\"\n ? \"HB_LANG_ITEM_BASE_DAY \", \"[\" + hb_langMessage( HB_LANG_ITEM_BASE_DAY ) + \"]\"\n ? \"HB_LANG_ITEM_BASE_NATMSG \", \"[\" + hb_langMessage( HB_LANG_ITEM_BASE_NATMSG ) + \"]\"\n ? \"HB_LANG_ITEM_BASE_ERRDESC\", \"[\" + hb_langMessage( HB_LANG_ITEM_BASE_ERRDESC ) + \"]\"\n ? \"HB_LANG_ITEM_BASE_ERRINTR\", \"[\" + hb_langMessage( HB_LANG_ITEM_BASE_ERRINTR ) + \"]\"\n ? \"HB_LANG_ITEM_BASE_TEXT \", \"[\" + hb_langMessage( HB_LANG_ITEM_BASE_TEXT ) + \"]\"\n ? \"hb_langErrMsg(0)\", hb_langErrMsg( 0 )\n ?\n ? \"date format:\", hb_langMessage( HB_LANG_ITEM_BASE_TEXT ) + \" (\" + cDtFrm + \")\"\n ? \" TRUE val:\", hb_langMessage( HB_LANG_ITEM_BASE_TEXT + 1 ) + \" (\" + cTrue + \")\"\n ? \" FALSE val:\", hb_langMessage( HB_LANG_ITEM_BASE_TEXT + 2 ) + \" (\" + cFalse + \")\"\n ?\n Inkey( 0 )\n\n ? \"Errors:\"\n ?\n a := GET_ERR()\n FOR i := 1 TO Len( a )\n ? PadR( a[ i ][ 1 ], 15 ) + \"|\" + PadR( aErr[ i ][ 2 ], 30 ) + \"|\" + PadR( a[ i ][ 2 ], 32 )\n NEXT\n ?\n Inkey( 0 )\n\n ? \"Internal errors:\"\n ?\n a := GET_IERR()\n FOR i := 1 TO Len( a )\n ? PadR( a[ i ][ 1 ], 15 ) + \"|\" + PadR( aInt[ i ][ 2 ], 30 ) + \"|\" + PadR( a[ i ][ 2 ], 32 )\n NEXT\n ?\n Inkey( 0 )\n\n ? \"Days:\"\n ?\n a := GET_DAYS()\n FOR i := 1 TO Len( a )\n ? \" \" + PadR( aDay[ i ], 15 ) + a[ i ]\n NEXT\n ?\n Inkey( 0 )\n\n ? \"Months:\"\n ?\n a := GET_MONTHS()\n FOR i := 1 TO Len( a )\n ? \" \" + PadR( aMnt[ i ], 15 ) + a[ i ]\n NEXT\n ?\n Inkey( 0 )\n\n RETURN\n\nSTATIC FUNCTION GET_DAYS()\n\n LOCAL i, n, aDays[ 7 ], dt := Date()\n\n FOR i := 1 TO 7\n n := DoW( dt )\n aDays[ n ] := CDoW( dt )\n ++dt\n NEXT\n\n RETURN aDays\n\nSTATIC FUNCTION GET_MONTHS()\n\n LOCAL i, n, aMonths[ 12 ], dt := Date()\n\n dt -= Day( dt ) - 1\n FOR i := 1 TO 12\n n := Month( dt )\n aMonths[ n ] := CMonth( dt )\n dt += 31\n dt -= Day( dt ) - 1\n NEXT\n\n RETURN aMonths\n\nSTATIC FUNCTION GET_ERR()\n RETURN { ;\n { \"EG_ARG \", hb_langErrMsg( 1 ) }, ;\n { \"EG_BOUND \", hb_langErrMsg( 2 ) }, ;\n { \"EG_STROVERFLOW \", hb_langErrMsg( 3 ) }, ;\n { \"EG_NUMOVERFLOW \", hb_langErrMsg( 4 ) }, ;\n { \"EG_ZERODIV \", hb_langErrMsg( 5 ) }, ;\n { \"EG_NUMERR \", hb_langErrMsg( 6 ) }, ;\n { \"EG_SYNTAX \", hb_langErrMsg( 7 ) }, ;\n { \"EG_COMPLEXITY \", hb_langErrMsg( 8 ) }, ;\n { \" \", hb_langErrMsg( 9 ) }, ;\n { \" \", hb_langErrMsg( 10 ) }, ;\n { \"EG_MEM \", hb_langErrMsg( 11 ) }, ;\n { \"EG_NOFUNC \", hb_langErrMsg( 12 ) }, ;\n { \"EG_NOMETHOD \", hb_langErrMsg( 13 ) }, ;\n { \"EG_NOVAR \", hb_langErrMsg( 14 ) }, ;\n { \"EG_NOALIAS \", hb_langErrMsg( 15 ) }, ;\n { \"EG_NOVARMETHOD \", hb_langErrMsg( 16 ) }, ;\n { \"EG_BADALIAS \", hb_langErrMsg( 17 ) }, ;\n { \"EG_DUPALIAS \", hb_langErrMsg( 18 ) }, ;\n { \"EG_NOOBJECT \", hb_langErrMsg( 19 ) }, ;\n { \"EG_CREATE \", hb_langErrMsg( 20 ) }, ;\n { \"EG_OPEN \", hb_langErrMsg( 21 ) }, ;\n { \"EG_CLOSE \", hb_langErrMsg( 22 ) }, ;\n { \"EG_READ \", hb_langErrMsg( 23 ) }, ;\n { \"EG_WRITE \", hb_langErrMsg( 24 ) }, ;\n { \"EG_PRINT \", hb_langErrMsg( 25 ) }, ;\n { \" \", hb_langErrMsg( 26 ) }, ;\n { \" \", hb_langErrMsg( 27 ) }, ;\n { \" \", hb_langErrMsg( 28 ) }, ;\n { \" \", hb_langErrMsg( 29 ) }, ;\n { \"EG_UNSUPPORTED \", hb_langErrMsg( 30 ) }, ;\n { \"EG_LIMIT \", hb_langErrMsg( 31 ) }, ;\n { \"EG_CORRUPTION \", hb_langErrMsg( 32 ) }, ;\n { \"EG_DATATYPE \", hb_langErrMsg( 33 ) }, ;\n { \"EG_DATAWIDTH \", hb_langErrMsg( 34 ) }, ;\n { \"EG_NOTABLE \", hb_langErrMsg( 35 ) }, ;\n { \"EG_NOORDER \", hb_langErrMsg( 36 ) }, ;\n { \"EG_SHARED \", hb_langErrMsg( 37 ) }, ;\n { \"EG_UNLOCKED \", hb_langErrMsg( 38 ) }, ;\n { \"EG_READONLY \", hb_langErrMsg( 39 ) }, ;\n { \"EG_APPENDLOCK \", hb_langErrMsg( 40 ) }, ;\n { \"EG_LOCK \", hb_langErrMsg( 41 ) }, ;\n { \" \", hb_langErrMsg( 42 ) }, ;\n { \" \", hb_langErrMsg( 43 ) }, ;\n { \" \", hb_langErrMsg( 44 ) }, ;\n { \" \", hb_langErrMsg( 45 ) }, ;\n { \"EG_ARRACCESS \", hb_langErrMsg( 46 ) }, ;\n { \"EG_ARRASSIGN \", hb_langErrMsg( 47 ) }, ;\n { \"EG_ARRDIMENSION\", hb_langErrMsg( 48 ) }, ;\n { \"EG_NOTARRAY \", hb_langErrMsg( 49 ) }, ;\n { \"EG_CONDITION \", hb_langErrMsg( 50 ) } }\n\nSTATIC FUNCTION HB_LANGERRINTR( n )\n RETURN hb_langMessage( HB_LANG_ITEM_BASE_ERRINTR + n - 9000 )\n\nSTATIC FUNCTION GET_IERR()\n RETURN { ;\n { \"HB_EI_ERRUNRECOV \", HB_LANGERRINTR( 9000 ) }, ;\n { \"HB_EI_ERRRECFAILURE \", HB_LANGERRINTR( 9001 ) }, ;\n { \"HB_EI_ERRNOBLOCK \", HB_LANGERRINTR( 9002 ) }, ;\n { \"HB_EI_ERRTOOMANY \", HB_LANGERRINTR( 9003 ) }, ;\n { \"HB_EI_RDDINVALID \", HB_LANGERRINTR( 9004 ) }, ;\n { \"HB_EI_CLSINVMETHOD \", HB_LANGERRINTR( 9005 ) }, ;\n { \"HB_EI_XGRABALLOC \", HB_LANGERRINTR( 9006 ) }, ;\n { \"HB_EI_XREALLOCNULL \", HB_LANGERRINTR( 9007 ) }, ;\n { \"HB_EI_XREALLOCINV \", HB_LANGERRINTR( 9008 ) }, ;\n { \"HB_EI_XREALLOC \", HB_LANGERRINTR( 9009 ) }, ;\n { \"HB_EI_XFREEINV \", HB_LANGERRINTR( 9010 ) }, ;\n { \"HB_EI_XFREENULL \", HB_LANGERRINTR( 9011 ) }, ;\n { \"HB_EI_VMBADSTARTUP \", HB_LANGERRINTR( 9012 ) }, ;\n { \"HB_EI_VMNOSTARTUP \", HB_LANGERRINTR( 9013 ) }, ;\n { \"HB_EI_VMBADOPCODE \", HB_LANGERRINTR( 9014 ) }, ;\n { \"HB_EI_VMNOTSYMBOL \", HB_LANGERRINTR( 9015 ) }, ;\n { \"HB_EI_VMINVSYMBOL \", HB_LANGERRINTR( 9016 ) }, ;\n { \"HB_EI_VMNOTCBLOCK \", HB_LANGERRINTR( 9017 ) }, ;\n { \"HB_EI_VMPOPINVITEM \", HB_LANGERRINTR( 9018 ) }, ;\n { \"HB_EI_STACKUFLOW \", HB_LANGERRINTR( 9019 ) }, ;\n { \"HB_EI_ITEMBADCOPY \", HB_LANGERRINTR( 9020 ) }, ;\n { \"HB_EI_MVBADSYMBOL \", HB_LANGERRINTR( 9021 ) }, ;\n { \"HB_EI_XMEMOVERFLOW \", HB_LANGERRINTR( 9022 ) }, ;\n { \"HB_EI_XGRABNULLSIZE \", HB_LANGERRINTR( 9023 ) }, ;\n { \"HB_EI_XREALLOCNULLSIZE\", HB_LANGERRINTR( 9024 ) }, ;\n { \"HB_EI_XALLOCNULLSIZE \", HB_LANGERRINTR( 9025 ) } }"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbexpat' (XML parsing library (Expat)): contrib/hbexpat/unitable.prg. Provides functions: hb_XML_get_unicode_table. This file handles data format parsing and generation"}, {"role": "assistant", "content": "#include \"hbextcdp.ch\"\n\n#define _UNI_NAME_NORM( s ) hb_StrReplace( s, \"-. \" )\n\nFUNCTION hb_XML_get_unicode_table( cCP )\n\n THREAD STATIC t_uni\n\n LOCAL cdp\n\n IF t_uni == NIL\n \n t_uni := { => }\n FOR EACH cdp IN hb_cdpList()\n t_uni[ _UNI_NAME_NORM( hb_cdpUniID( cdp ) ) ] := cdp\n NEXT\n ENDIF\n\n IF ( cCP := _UNI_NAME_NORM( cCP ) ) $ t_uni\n RETURN __hb_XML_cdpU16Map( t_uni[ cCP ] )\n ENDIF\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/win_tcom.prg. Defines classes: win_Com. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"hbwin.ch\"\n\n\nCREATE CLASS win_Com\n\n ACCESS Open() INLINE ::lOpen\n ACCESS PortName() INLINE ::cPortName\n\n PROTECT nPort INIT -1\n PROTECT lOpen INIT .F.\n PROTECT cPortName INIT \"\"\n\n METHOD Init( cPortName, nBaudRate, nParity, nByteSize, nStopBits )\n METHOD QueueSize( nInQueue, nOutQueue )\n METHOD TimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant )\n METHOD Read( cString, nLength )\n METHOD Recv( nLength, nResult )\n METHOD RecvTo( cDelim, nMaxlen )\n METHOD Write( cString )\n METHOD Status( lCTS, lDSR, lRing, lDCD )\n METHOD QueueStatus( lCTSHold, lDSRHold, lDCDHold, lXoffHold, lXoffSent, nInQueue, nOutQueue )\n METHOD SetRTS( lCTS )\n METHOD SetDTR( lDTR )\n METHOD RTSFlow( nRTS )\n METHOD DTRFlow( nDTR )\n METHOD XonXoffFlow( lXonXoff )\n METHOD Purge( lRXBuffer, lTXBuffer )\n METHOD PurgeRX()\n METHOD PurgeTX()\n METHOD Close( nDrain )\n METHOD DebugDCB( nDebug )\n METHOD ErrorText()\n METHOD Error()\n\nENDCLASS\n\n\nMETHOD Init( cPortName, nBaudRate, nParity, nByteSize, nStopBits ) CLASS win_Com\n\n ::cPortName := Upper( cPortName )\n IF Left( ::cPortName, 3 ) == \"COM\"\n ::nPort := Val( SubStr( ::cPortName, 4 ) ) - 1\n IF win_comOpen( ::nPort, nBaudRate, nParity, nByteSize, nStopBits ) != -1\n ::lOpen := .T.\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD QueueSize( nInQueue, nOutQueue ) CLASS win_Com\n RETURN win_comSetQueueSize( ::nPort, nInQueue, nOutQueue )\n\nMETHOD TimeOuts( nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant ) CLASS win_Com\n RETURN win_comSetTimeouts( ::nPort, nReadInterval, nReadMultiplier, nReadConstant, nWriteMultiplier, nWriteConstant )\n\nMETHOD Read( cString, nLength ) CLASS win_Com\n\n cString := Space( nlength )\n\n RETURN win_comRead( ::nPort, @cString )\n\nMETHOD Recv( nLength, nResult ) CLASS win_Com\n RETURN win_comRecv( ::nPort, nLength, @nResult )\n\nMETHOD RecvTo( cDelim, nMaxlen ) CLASS win_Com\n\n LOCAL nResult\n LOCAL cRecv := \"\"\n\n LOCAL cString\n\n DO WHILE .T.\n cString := Space( 1 )\n IF ( nResult := win_comRead( ::nPort, @cString ) ) != -1\n IF nResult == 0\n EXIT\n ELSE\n cRecv += cString\n IF cDelim != NIL .AND. cString == cDelim\n EXIT\n ENDIF\n IF Len( cRecv ) == nMaxlen\n EXIT\n ENDIF\n ENDIF\n ELSE\n EXIT\n ENDIF\n ENDDO\n\n RETURN cRecv\n\nMETHOD Write( cString ) CLASS win_Com\n RETURN win_comWrite( ::nPort, cString )\n\nMETHOD Status( lCTS, lDSR, lRing, lDCD ) CLASS win_Com\n RETURN win_comStatus( ::nPort, @lCTS, @lDSR, @lRing, @lDCD )\n\nMETHOD QueueStatus( lCTSHold, lDSRHold, lDCDHold, lXoffHold, lXoffSent, nInQueue, nOutQueue ) CLASS win_Com\n RETURN win_comQueueStatus( ::nPort, @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )\n\nMETHOD SetRTS( lCTS ) CLASS win_Com\n RETURN win_comSetRTS( ::nPort, lCTS ) \n\nMETHOD SetDTR( lDTR ) CLASS win_Com\n RETURN win_comSetDTR( ::nPort, lDTR ) \n\nMETHOD RTSFlow( nRTS ) CLASS win_Com\n RETURN win_comRTSFlow( ::nPort, nRTS )\n\nMETHOD DTRFlow( nDTR ) CLASS win_Com\n RETURN win_comDTRFlow( ::nPort, nDTR )\n\nMETHOD XonXoffFlow( lXonXoff ) CLASS win_Com\n RETURN win_comXonXoffFlow( ::nPort, lXonXoff )\n\nMETHOD Purge( lRXBuffer, lTXBuffer ) CLASS win_Com\n RETURN win_comPurge( ::nPort, lRXBuffer, lTXBuffer )\n\nMETHOD PurgeRX() CLASS win_Com\n RETURN win_comPurge( ::nPort, .T., .F. )\n\nMETHOD PurgeTX() CLASS win_Com\n RETURN win_comPurge( ::nPort, .F., .T. )\n\nMETHOD Close( nDrain ) CLASS win_Com\n RETURN win_comClose( ::nPort, iif( Empty( nDrain ), 0, nDrain ) )\n\nMETHOD DebugDCB( nDebug ) CLASS win_Com\n RETURN win_comDebugDCB( ::nPort, nDebug )\n\n\nMETHOD ErrorText() CLASS win_Com\n\n LOCAL nFcn := win_comFuncLast( ::nPort )\n LOCAL cString\n LOCAL nError\n LOCAL cMsg\n LOCAL aWinPortFcns := { ;\n \"CreateFile\", ;\n \"GetCommState\", ;\n \"SetCommState\", ;\n \"SetupComm\", ;\n \"GetCommTimeouts\", ;\n \"SetCommTimeouts\", ;\n \"CloseHandle\", ;\n \"WriteFile\", ;\n \"ReadFile\", ;\n \"GetCommModemStatus\", ;\n \"PurgeComm\", ;\n \"ClearCommError\", ;\n \"EscapeCommFunction\", ;\n \"GetCommProperties\" }\n\n IF nFcn >= 1 .AND. nFcn <= Len( aWinPortFcns )\n cString := aWinPortFcns[ nFcn ] + \"(), \"\n ELSE\n cString := \"Function number (\" + hb_ntos( nFcn ) + \") invalid, \"\n ENDIF\n\n \n cMsg := Space( 256 )\n wapi_FormatMessage( NIL, NIL, nError := win_comError( ::nPort ), NIL, @cMsg )\n\n RETURN cString + \"error (\" + hb_ntos( nError ) + \") : \" + cMsg\n\nMETHOD Error() CLASS win_Com\n RETURN win_comError( ::nPort )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbzebra' (Barcode generation library): contrib/hbzebra/tests/harupdf.prg. Provides functions: hb_zebra_draw_hpdf. Contains procedures: Main, DrawBarcode. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbzebra\"\n#require \"hbhpdf\"\n\nPROCEDURE Main()\n\n LOCAL pdf\n LOCAL page\n\n pdf := HPDF_New()\n page := HPDF_AddPage( pdf )\n HPDF_Page_SetSize( page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT )\n HPDF_Page_SetFontAndSize( page, HPDF_GetFont( pdf, \"Helvetica\", NIL ), 12 )\n\n DrawBarcode( page, 20, 1, \"EAN13\", \"477012345678\" )\n DrawBarcode( page, 40, 1, \"EAN8\", \"1234567\" )\n DrawBarcode( page, 60, 1, \"UPCA\", \"01234567891\" )\n DrawBarcode( page, 80, 1, \"UPCE\", \"123456\" )\n DrawBarcode( page, 100, 1, \"CODE39\", \"ABC123\" )\n DrawBarcode( page, 120, 1, \"CODE39\", \"ABC123\", HB_ZEBRA_FLAG_CHECKSUM )\n DrawBarcode( page, 140, 0.5, \"CODE39\", \"ABC123\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE2_5 )\n DrawBarcode( page, 160, 1, \"CODE39\", \"ABC123\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( page, 180, 1, \"ITF\", \"1234\", HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( page, 200, 1, \"ITF\", \"12345678901\", HB_ZEBRA_FLAG_CHECKSUM )\n DrawBarcode( page, 220, 1, \"MSI\", \"1234\" )\n DrawBarcode( page, 240, 1, \"MSI\", \"1234\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( page, 260, 1, \"MSI\", \"1234567\", HB_ZEBRA_FLAG_CHECKSUM )\n DrawBarcode( page, 280, 1, \"CODABAR\", \"40156\", HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( page, 300, 1, \"CODABAR\", \"-1234\", HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( page, 320, 1, \"CODE93\", \"ABC-123\" )\n DrawBarcode( page, 340, 1, \"CODE93\", \"TEST93\" )\n DrawBarcode( page, 360, 1, \"CODE11\", \"12\", HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( page, 380, 1, \"CODE11\", \"1234567890\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( page, 400, 1, \"CODE128\", \"Code 128\" )\n DrawBarcode( page, 420, 1, \"CODE128\", \"1234567890\" )\n DrawBarcode( page, 440, 1, \"CODE128\", \"Wikipedia\" )\n DrawBarcode( page, 460, 1, \"PDF417\", \"Hello, World of Harbour!!! It's 2D barcode PDF417 :)\" )\n DrawBarcode( page, 540, 1, \"DATAMATRIX\", \"Hello, World of Harbour!!! It's 2D barcode DataMatrix :)\" )\n DrawBarcode( page, 580, 1, \"QRCODE\", \"http:\n\n FErase( hb_FNameExtSet( __FILE__, \".pdf\" ) )\n ? HPDF_SaveToFile( pdf, hb_FNameExtSet( __FILE__, \".pdf\" ) )\n\n RETURN\n\nPROCEDURE DrawBarcode( page, nY, nLineWidth, cType, cCode, nFlags )\n\n LOCAL hZebra, nLineHeight, cTxt\n\n nY := HPDF_Page_GetHeight( page ) - nY\n\n SWITCH cType\n CASE \"EAN13\" ; hZebra := hb_zebra_create_ean13( cCode, nFlags ) ; EXIT\n CASE \"EAN8\" ; hZebra := hb_zebra_create_ean8( cCode, nFlags ) ; EXIT\n CASE \"UPCA\" ; hZebra := hb_zebra_create_upca( cCode, nFlags ) ; EXIT\n CASE \"UPCE\" ; hZebra := hb_zebra_create_upce( cCode, nFlags ) ; EXIT\n CASE \"CODE39\" ; hZebra := hb_zebra_create_code39( cCode, nFlags ) ; EXIT\n CASE \"ITF\" ; hZebra := hb_zebra_create_itf( cCode, nFlags ) ; EXIT\n CASE \"MSI\" ; hZebra := hb_zebra_create_msi( cCode, nFlags ) ; EXIT\n CASE \"CODABAR\" ; hZebra := hb_zebra_create_codabar( cCode, nFlags ) ; EXIT\n CASE \"CODE93\" ; hZebra := hb_zebra_create_code93( cCode, nFlags ) ; EXIT\n CASE \"CODE11\" ; hZebra := hb_zebra_create_code11( cCode, nFlags ) ; EXIT\n CASE \"CODE128\" ; hZebra := hb_zebra_create_code128( cCode, nFlags ) ; EXIT\n CASE \"PDF417\" ; hZebra := hb_zebra_create_pdf417( cCode, nFlags ); nLineHeight := nLineWidth\n CASE \"DATAMATRIX\" ; hZebra := hb_zebra_create_datamatrix( cCode, nFlags ); nLineHeight := nLineWidth ; EXIT\n CASE \"QRCODE\" ; hZebra := hb_zebra_create_qrcode( cCode, nFlags ); nLineHeight := nLineWidth ; EXIT\n ENDSWITCH\n\n IF hZebra != NIL\n IF hb_zebra_geterror( hZebra ) == 0\n IF Empty( nLineHeight )\n nLineHeight := 16\n ENDIF\n HPDF_Page_BeginText( page )\n HPDF_Page_TextOut( page, 40, nY - 13, cType )\n cTxt := hb_zebra_getcode( hZebra )\n IF Len( cTxt ) < 20\n HPDF_Page_TextOut( page, 150, nY - 13, cTxt )\n ENDIF\n HPDF_Page_EndText( page )\n hb_zebra_draw_hpdf( hZebra, page, 300, nY, nLineWidth, -nLineHeight )\n ELSE\n ? \"Type\", cType, \"Code\", cCode, \"Error\", hb_zebra_geterror( hZebra )\n ENDIF\n hb_zebra_destroy( hZebra )\n ELSE\n ? \"Invalid barcode type\", cType\n ENDIF\n\n RETURN\n\nSTATIC FUNCTION hb_zebra_draw_hpdf( hZebra, page, ... )\n\n IF hb_zebra_geterror( hZebra ) != 0\n RETURN HB_ZEBRA_ERROR_INVALIDZEBRA\n ENDIF\n\n hb_zebra_draw( hZebra, {| x, y, w, h | HPDF_Page_Rectangle( page, x, y, w, h ) }, ... )\n\n HPDF_Page_Fill( page )\n\n RETURN 0"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/classes.prg. Provides functions: TForm, New, Show. Contains procedures: Main. This test file tests object-oriented programming features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL oForm := TForm():New()\n\n ? oForm:ClassName()\n\n oForm:Show()\n\n RETURN\n\nFUNCTION TForm()\n\n STATIC s_oClass\n\n IF s_oClass == NIL\n s_oClass := HBClass():New( \"TFORM\" ) \n\n s_oClass:AddData( \"cName\" ) \n s_oClass:AddData( \"nTop\" )\n s_oClass:AddData( \"nLeft\" )\n s_oClass:AddData( \"nBottom\" )\n s_oClass:AddData( \"nRight\" )\n\n s_oClass:AddMethod( \"New\", @New() ) \n s_oClass:AddMethod( \"Show\", @Show() )\n\n s_oClass:Create() \n ENDIF\n\n RETURN s_oClass:Instance() \n\nSTATIC FUNCTION New()\n\n LOCAL Self := QSelf()\n\n ::nTop := 10\n ::nLeft := 10\n ::nBottom := 20\n ::nRight := 40\n\n RETURN Self\n\nSTATIC FUNCTION Show()\n\n LOCAL Self := QSelf()\n\n ? \"lets show a form from here :-)\"\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/nwuid.prg. Provides functions: ft_NWUID. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"ftint86.ch\"\n\n\nFUNCTION ft_NWUID( nConn )\n\n LOCAL aRegs[ INT86_MAX_REGS ]\n LOCAL cReqPkt\n LOCAL cRepPkt\n\n IF nConn == NIL\n nConn := ft_NWLStat()\n ENDIF\n\n \n cReqPkt := hb_BChar( 22 ) \n cReqPkt += hb_BChar( nConn )\n cReqPkt := I2Bin( hb_BLen( cReqPkt ) ) + cReqPkt\n\n \n cRepPkt := Space( 63 )\n\n \n aRegs[ AX ] := MAKEHI( 227 ) \n aRegs[ DS ] := cReqPkt\n aRegs[ SI ] := REG_DS\n aRegs[ ES ] := cRepPkt\n aRegs[ DI ] := REG_ES\n\n ft_int86( 33, aRegs )\n\n RETURN AllTrim( StrTran( hb_BSubStr( aRegs[ ES ], 9, 48 ), hb_BChar( 0 ) ) )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/inhprob.prg. Defines classes: One, Two, Three. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nPROCEDURE Main()\n\n LOCAL o := Three():New()\n\n o:CheckIt()\n\n RETURN\n\nCREATE CLASS One\n\n METHOD New() INLINE Self\n METHOD Test() INLINE QOut( \"One\" )\n METHOD CheckIt() INLINE ::Test()\n\nENDCLASS\n\nCREATE CLASS Two FROM One\n\n METHOD Test() INLINE ::super:Test()\n METHOD CheckIt() INLINE ::super:CheckIt()\n\nENDCLASS\n\nCREATE CLASS Three FROM Two\n\n METHOD Test() INLINE QOut( \"Three\" )\n\nENDCLASS"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour header file: include/fileio.ch. Defines 10 constants including: _FILEIO_CH, FC_NORMAL, FC_READONLY, FC_HIDDEN, FC_SYSTEM. Defines keyboard input constants"}, {"role": "assistant", "content": "#ifndef _FILEIO_CH\n#define _FILEIO_CH\n\n\n#define FC_NORMAL 0 \n#define FC_READONLY 1 \n#define FC_HIDDEN 2 \n#define FC_SYSTEM 4 \n\n\n#define HB_FA_ALL 0x00000000\n\n#define HB_FA_READONLY 0x00000001 \n#define HB_FA_HIDDEN 0x00000002 \n#define HB_FA_SYSTEM 0x00000004 \n#define HB_FA_LABEL 0x00000008 \n#define HB_FA_DIRECTORY 0x00000010 \n#define HB_FA_ARCHIVE 0x00000020 \n#define HB_FA_DEVICE 0x00000040 \n#define HB_FA_NORMAL 0x00000080 \n\n#define HB_FA_ANY ( HB_FA_READONLY + HB_FA_HIDDEN + HB_FA_SYSTEM + HB_FA_DIRECTORY + HB_FA_ARCHIVE )\n\n#define HB_FA_TEMPORARY 0x00000100 \n#define HB_FA_SPARSE 0x00000200 \n#define HB_FA_REPARSE 0x00000400 \n#define HB_FA_COMPRESSED 0x00000800 \n#define HB_FA_OFFLINE 0x00001000 \n#define HB_FA_NOTINDEXED 0x00002000 \n#define HB_FA_ENCRYPTED 0x00004000 \n#define HB_FA_VOLCOMP 0x00008000 \n\n\n#define HB_FA_SUID 0x08000000 \n#define HB_FA_SGID 0x04000000 \n#define HB_FA_SVTX 0x02000000 \n#define HB_FA_RUSR 0x01000000 \n#define HB_FA_WUSR 0x00800000 \n#define HB_FA_XUSR 0x00400000 \n#define HB_FA_RGRP 0x00200000 \n#define HB_FA_WGRP 0x00100000 \n#define HB_FA_XGRP 0x00080000 \n#define HB_FA_ROTH 0x00040000 \n#define HB_FA_WOTH 0x00020000 \n#define HB_FA_XOTH 0x00010000 \n\n\n#define FO_READ 0 \n#define FO_WRITE 1 \n#define FO_READWRITE 2 \n\n\n#define HB_FO_CREAT 0x0100 \n#define HB_FO_TRUNC 0x0200 \n#define HB_FO_EXCL 0x0400 \n#define HB_FO_DEFAULTS 0x1000 \n\n\n#define FO_CREAT HB_FO_CREAT \n#define FO_TRUNC HB_FO_TRUNC \n#define FO_EXCL HB_FO_EXCL \n#define FO_DEFAULTS HB_FO_DEFAULTS \n\n\n#define FO_COMPAT 0 \n#define FO_EXCLUSIVE 16 \n#define FO_DENYWRITE 32 \n#define FO_DENYREAD 48 \n#define FO_DENYNONE 64 \n#define FO_SHARED FO_DENYNONE\n\n\n#define FS_SET 0 \n#define FS_RELATIVE 1 \n#define FS_END 2 \n\n\n#define FD_BINARY 1 \n#define FD_RAW FD_BINARY\n#define FD_TEXT 2 \n#define FD_COOKED FD_TEXT\n#define FD_ASCII FD_TEXT\n\n\n#define F_ERROR ( -1 ) \n\n\n#define HB_FLX_EXCLUSIVE 0x0000 \n#define HB_FLX_SHARED 0x0100 \n#define HB_FLX_NO_WAIT 0x0000 \n#define HB_FLX_WAIT 0x0200 \n\n\n#define HB_DISK_AVAIL 0\n#define HB_DISK_FREE 1\n#define HB_DISK_USED 2\n#define HB_DISK_TOTAL 3\n\n\n#define HB_VF_TIMEOUT 1\n#define HB_VF_PORT 2\n#define HB_VF_EOF 3\n#define HB_VF_SHUTDOWN 4\n#define HB_VF_RDHANDLE 5\n#define HB_VF_WRHANDLE 6\n#define HB_VF_IONAME 7\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/dispmsg.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\nPROCEDURE Main()\n\n LOCAL cDosScrn\n LOCAL nDosRow\n LOCAL nDosCol\n LOCAL lColor\n LOCAL nMaxRow\n LOCAL nType\n\n \n LOCAL cNormH, cNormN\n LOCAL cWindH, cWindN\n LOCAL cErrH, cErrN\n\n \n SET SCOREBOARD OFF\n\n lColor := .T.\n\n cNormH := iif( lColor, \"W+/BG\", \"W+/N\" )\n cNormN := iif( lColor, \"N/BG\", \"W/N\" )\n cWindH := iif( lColor, \"W+/B\", \"W+/N\" )\n cWindN := iif( lColor, \"W/B\", \"W/N\" )\n cErrH := iif( lColor, \"W+/R\", \"W+/N\" )\n cErrN := iif( lColor, \"W/R\", \"W/N\" )\n\n cDosScrn := SaveScreen()\n nDosRow := Row()\n nDosCol := Col()\n SetColor( \"W/N\" )\n CLS\n nMaxRow := MaxRow()\n SetBlink( .F. )\n SetColor( cWindN + \"*\" )\n CLS\n SetColor( cNormN )\n\n ft_DispMsg( { { \"[Esc] To Abort Changes [PgDn] To Continue\" }, { cNormN, , cNormH } }, , nMaxRow - 5 )\n\n ft_DispMsg( { { \"[E]dit [P]rint [D]elete\", ;\n \"[Esc]ape [Alt-Q]\" }, ;\n { cErrN, cErrN, cErrH } }, , 2 )\n\n nType := ft_DispMsg( { { ;\n \"Create Or Edit [I]nvoice\", ;\n \"Create Or Edit [O]rder\", ;\n \"Create Or Edit [B]ack Order\", ;\n \"Create Or Edit [Q]uote\", ;\n \"[Esc] To Exit\" }, ;\n { cWindN, , , , , cWindH } }, \"BIOQ\" + hb_BChar( K_ESC ) )\n\n HB_SYMBOL_UNUSED( nType )\n\n SetColor( \"W/N\" )\n SetCursor( SC_NORMAL )\n SetBlink( .T. )\n RestScreen( , , , , cDosScrn )\n SetPos( nDosRow, nDosCol )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charshl.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#else\n#define hb_ntos( n ) LTrim( Str( n ) )\n#define hb_BChar( n ) Chr( n )\n#endif\n\nPROCEDURE Main()\n\n LOCAL ni, cStr\n\n ctinit()\n\n ? \"Begin test of CharShl()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharShl( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 ) =='\n ? ' hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ) + hb_BChar( 0 ) + hb_BChar( 0 ) + hb_BChar( 0 ) ? -->'\n\n ? ' '\n cStr := CharShl( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 )\n FOR ni := 1 TO Len( cStr )\n ?? \"hb_BChar( \" + hb_ntos( Asc( SubStr( cStr, ni, 1 ) ) ) + \" )\"\n IF ni < Len( cStr )\n ?? \" + \"\n ENDIF\n NEXT\n ?\n\n ? \"End test of CharShl()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/calendar.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#include \"inkey.ch\"\n\nPROCEDURE Main()\n\n LOCAL aRet\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n SetColor( \"w+/b\" )\n CLS\n IF ft_NumLock()\n ft_NumLock( .F. )\n ENDIF\n hb_keyPut( K_F1 )\n aRet := ft_Calendar( 10, 40, \"w+/rb\", .T., .T. ) \n @ 1, 0 SAY \"Date :\" + DToC( aRet[ 1 ] )\n @ 2, 0 SAY \"Month Number:\" + Str( aRet[ 2 ], 2, 0 )\n @ 3, 0 SAY \"Day Number :\" + Str( aRet[ 3 ], 2, 0 )\n @ 4, 0 SAY \"Year Number :\" + Str( aRet[ 4 ], 4, 0 )\n @ 5, 0 SAY \"Month :\" + aRet[ 5 ]\n @ 6, 0 SAY \"Day :\" + aRet[ 6 ]\n @ 7, 0 SAY \"Julian Day :\" + Str( aRet[ 7 ], 3, 0 )\n @ 8, 0 SAY \"Current Time:\" + aRet[ 8 ]\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour utility program: utils/hbtest/rt_date.prg. Contains procedures: Main_DATE. This file is part of the test framework"}, {"role": "assistant", "content": "#include \"rt_main.ch\"\n\n\n#include \"rt_vars.ch\"\n\nPROCEDURE Main_DATE()\n\n LOCAL cDate := \"1999-11-25\"\n\n \n HBTEST Year( NIL ) IS \"E 1 BASE 1112 Argument error (YEAR) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST Year( 100 ) IS \"E 1 BASE 1112 Argument error (YEAR) OS:0 #:0 A:1:N:100 F:S\"\n#ifdef __HARBOUR__\n HBTEST Year( @sdDate ) IS 1984 \n#endif\n HBTEST Year( sdDate) IS 1984\n HBTEST Year( sdDateE) IS 0\n HBTEST Str( Year( hb_SToD( \"19990905\" ) ) ) IS \" 1999\"\n\n \n HBTEST Month( NIL ) IS \"E 1 BASE 1113 Argument error (MONTH) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST Month( 100 ) IS \"E 1 BASE 1113 Argument error (MONTH) OS:0 #:0 A:1:N:100 F:S\"\n#ifdef __HARBOUR__\n HBTEST Month( @sdDate ) IS 3 \n#endif\n HBTEST Month( sdDate ) IS 3\n HBTEST Month( sdDateE ) IS 0\n HBTEST Str( Month( hb_SToD( \"19990905\" ) ) ) IS \" 9\"\n\n \n HBTEST Day( NIL ) IS \"E 1 BASE 1114 Argument error (DAY) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST Day( 100 ) IS \"E 1 BASE 1114 Argument error (DAY) OS:0 #:0 A:1:N:100 F:S\"\n#ifdef __HARBOUR__\n HBTEST Day( @sdDate ) IS 25 \n#endif\n HBTEST Day( sdDate ) IS 25\n HBTEST Day( sdDateE ) IS 0\n HBTEST Str( Day( hb_SToD( \"19990905\" ) ) ) IS \" 5\"\n\n \n HBTEST Len( Time() ) IS 8\n\n \n HBTEST DoW( NIL ) IS \"E 1 BASE 1115 Argument error (DOW) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST DoW( 100 ) IS \"E 1 BASE 1115 Argument error (DOW) OS:0 #:0 A:1:N:100 F:S\"\n#ifdef __HARBOUR__\n HBTEST DoW( @sdDate ) IS 1 \n#endif\n HBTEST DoW( sdDate ) IS 1\n HBTEST DoW( sdDateE ) IS 0\n HBTEST DoW( hb_SToD( \"20000222\" ) ) IS 3\n HBTEST DoW( hb_SToD( \"20000223\" ) ) IS 4\n HBTEST DoW( hb_SToD( \"20000224\" ) ) IS 5\n HBTEST DoW( hb_SToD( \"20000225\" ) ) IS 6\n HBTEST DoW( hb_SToD( \"20000226\" ) ) IS 7\n HBTEST DoW( hb_SToD( \"20000227\" ) ) IS 1\n HBTEST DoW( hb_SToD( \"20000228\" ) ) IS 2\n HBTEST DoW( hb_SToD( \"20000229\" ) ) IS 3\n HBTEST DoW( hb_SToD( \"20000230\" ) ) IS 0\n HBTEST DoW( hb_SToD( \"20000231\" ) ) IS 0\n HBTEST DoW( hb_SToD( \"20000301\" ) ) IS 4\n\n \n HBTEST CMonth( NIL ) IS \"E 1 BASE 1116 Argument error (CMONTH) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST CMonth( 100 ) IS \"E 1 BASE 1116 Argument error (CMONTH) OS:0 #:0 A:1:N:100 F:S\"\n#ifdef __HARBOUR__\n HBTEST CMonth( @sdDate ) IS \"March\" \n#endif\n HBTEST CMonth( sdDate ) IS \"March\"\n HBTEST CMonth( sdDateE ) IS \"\"\n HBTEST CMonth( hb_SToD( \"19990101\" ) ) IS \"January\"\n HBTEST CMonth( hb_SToD( \"19990201\" ) ) IS \"February\"\n HBTEST CMonth( hb_SToD( \"19990301\" ) ) IS \"March\"\n HBTEST CMonth( hb_SToD( \"19990401\" ) ) IS \"April\"\n HBTEST CMonth( hb_SToD( \"19990501\" ) ) IS \"May\"\n HBTEST CMonth( hb_SToD( \"19990601\" ) ) IS \"June\"\n HBTEST CMonth( hb_SToD( \"19990701\" ) ) IS \"July\"\n HBTEST CMonth( hb_SToD( \"19990801\" ) ) IS \"August\"\n HBTEST CMonth( hb_SToD( \"19990901\" ) ) IS \"September\"\n HBTEST CMonth( hb_SToD( \"19991001\" ) ) IS \"October\"\n HBTEST CMonth( hb_SToD( \"19991101\" ) ) IS \"November\"\n HBTEST CMonth( hb_SToD( \"19991201\" ) ) IS \"December\"\n\n \n HBTEST CDoW( NIL ) IS \"E 1 BASE 1117 Argument error (CDOW) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST CDoW( 100 ) IS \"E 1 BASE 1117 Argument error (CDOW) OS:0 #:0 A:1:N:100 F:S\"\n#ifdef __HARBOUR__\n HBTEST CDoW( @sdDate ) IS \"Sunday\" \n#endif\n HBTEST CDoW( sdDate ) IS \"Sunday\"\n HBTEST CDoW( sdDateE ) IS \"\"\n HBTEST CDoW( hb_SToD( \"20000222\" ) ) IS \"Tuesday\"\n HBTEST CDoW( hb_SToD( \"20000223\" ) ) IS \"Wednesday\"\n HBTEST CDoW( hb_SToD( \"20000224\" ) ) IS \"Thursday\"\n HBTEST CDoW( hb_SToD( \"20000225\" ) ) IS \"Friday\"\n HBTEST CDoW( hb_SToD( \"20000226\" ) ) IS \"Saturday\"\n HBTEST CDoW( hb_SToD( \"20000227\" ) ) IS \"Sunday\"\n HBTEST CDoW( hb_SToD( \"20000228\" ) ) IS \"Monday\"\n HBTEST CDoW( hb_SToD( \"20000229\" ) ) IS \"Tuesday\"\n HBTEST CDoW( hb_SToD( \"20000230\" ) ) IS \"\"\n HBTEST CDoW( hb_SToD( \"20000231\" ) ) IS \"\"\n HBTEST CDoW( hb_SToD( \"20000301\" ) ) IS \"Wednesday\"\n\n \n HBTEST DToC( NIL ) IS \"E 1 BASE 1118 Argument error (DTOC) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST DToC( 100 ) IS \"E 1 BASE 1118 Argument error (DTOC) OS:0 #:0 A:1:N:100 F:S\"\n HBTEST DToC( \"\" ) IS \"E 1 BASE 1118 Argument error (DTOC) OS:0 #:0 A:1:C: F:S\"\n#ifdef __HARBOUR__\n HBTEST DToC( @sdDate ) IS \"1984-03-25\" \n#endif\n HBTEST DToC( sdDate ) IS \"1984-03-25\"\n HBTEST DToC( sdDateE ) IS \" - - \"\n\n \n HBTEST CToD( NIL ) IS \"E 1 BASE 1119 Argument error (CTOD) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST CToD( 100 ) IS \"E 1 BASE 1119 Argument error (CTOD) OS:0 #:0 A:1:N:100 F:S\"\n HBTEST CToD( \"\" ) IS hb_SToD(\" \")\n#ifdef __HARBOUR__\n HBTEST CToD( @cDate ) IS hb_SToD(\"19991125\") \n#endif\n HBTEST CToD( cDate ) IS hb_SToD(\"19991125\")\n HBTEST CToD( \"1999-11-25/10\" ) IS hb_SToD(\"19991125\")\n\n \n HBTEST DToS( NIL ) IS \"E 1 BASE 1120 Argument error (DTOS) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST DToS( 100 ) IS \"E 1 BASE 1120 Argument error (DTOS) OS:0 #:0 A:1:N:100 F:S\"\n#ifdef __HARBOUR__\n HBTEST DToS( @sdDate ) IS \"19840325\" \n#endif\n HBTEST DToS( sdDate ) IS \"19840325\"\n HBTEST DToS( sdDateE ) IS \" \"\n\n RETURN\n\n\n#include \"rt_init.ch\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour utility program: utils/hbtest/rt_mt.prg. Provides functions: DO_MTTES1. Contains procedures: Main_MT, thFunc. This file is part of the test framework"}, {"role": "assistant", "content": "#include \"rt_main.ch\"\n\n\n#include \"rt_vars.ch\"\n\n#define N_THREADS 5\n#define N_JOBS 1000\n\nPROCEDURE Main_MT()\n\n#ifdef __HARBOUR__\n IF hb_mtvm()\n HBTEST DO_MTTES1() IS \"OK\"\n ENDIF\n#endif\n\n RETURN\n\n#ifdef __HARBOUR__\nSTATIC FUNCTION DO_MTTES1()\n\n LOCAL aThreads, aResults, i, nDigit, nSum, nExpected\n LOCAL mtxJobs, mtxResults\n\n aThreads := {}\n aResults := {}\n mtxJobs := hb_mutexCreate()\n mtxResults := hb_mutexCreate()\n FOR i := 1 TO N_THREADS\n AAdd( aThreads, hb_threadStart( @thFunc(), mtxJobs, mtxResults ) )\n NEXT\n nDigit := 10\n FOR i := 1 TO N_JOBS\n hb_mutexNotify( mtxJobs, nDigit )\n nDigit++\n NEXT\n FOR i := 1 TO N_THREADS\n hb_mutexNotify( mtxJobs, NIL )\n NEXT\n FOR i := 1 TO N_JOBS\n hb_mutexSubscribe( mtxResults,, @nDigit )\n AAdd( aResults, nDigit )\n NEXT\n AEval( aThreads, {| x | hb_threadJoin( x ) } )\n nSum := 0\n FOR EACH nDigit IN aResults\n nSum += nDigit\n NEXT\n nSum := Round( nSum, 2 )\n nExpected := Round( ( 10 + 10 + N_JOBS - 1 ) / 2 / 3\n RETURN \"OK\"\n ENDIF\n\n RETURN \"ERROR, final sum: \" + hb_ntos( nSum ) + ;\n \" expected: \" + hb_ntos( nExpected )\n\nSTATIC PROCEDURE thFunc( mtxJobs, mtxResults )\n\n LOCAL xJob, xResult\n\n DO WHILE .T.\n hb_mutexSubscribe( mtxJobs,, @xJob )\n IF xJob == NIL\n EXIT\n ENDIF\n xResult := xJob / 3\n hb_mutexNotify( mtxResults, xResult )\n ENDDO\n\n RETURN\n\n#endif \n\n\n#include \"rt_init.ch\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour test program: tests/switch.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifdef __XHARBOUR__\n#define OTHERWISE DEFAULT\n#define ENDSWITCH END\n#endif\n\nPROCEDURE Main()\n\n LOCAL a := 1\n MEMVAR m_b\n PRIVATE m_b := \"m_b\"\n\n#ifndef __XHARBOUR__\n SWITCH a\n ENDSWITCH\n#endif\n\n ?\n ? \"1111111111111111111111111111111\"\n SWITCH a\n CASE 1\n ? \"FOUND: 1\"\n ENDSWITCH\n\n ?\n ? \"2222222222222222222222222222222\"\n SWITCH a\n CASE 1\n ? \"FOUND: 1\"\n EXIT\n CASE \"2\"\n ? a\n ENDSWITCH\n\n ?\n ? \"3333333333333333333333333333333\"\n SWITCH a\n CASE 1\n ? \"FOUND: 1\"\n CASE \"2\"\n ? \"FOUND: 2\"\n OTHERWISE\n ? \"other\"\n ENDSWITCH\n\n#ifndef __XHARBOUR__\n ?\n ? \"44444444444444444444444444444444444\"\n SWITCH a\n OTHERWISE\n ? \"OTHERWISE\"\n ENDSWITCH\n#endif\n\n ?\n ? \"55555555555555555555555555555555555\"\n a := \"EE\"\n#ifndef __XHARBOUR__\n SWITCH a\n CASE 11\n ? \"11\"\n EXIT\n\n CASE \"CCCC\" + \"DDDD\"\n ? a + a\n EXIT\n\n CASE \"a&m_b\"\n CASE 1 + 1\n CASE { 11111111, 22222222222 }[ 1 ]\n CASE 1 + 1 + 1\n ? \"3\"\n EXIT\n\n CASE 1 + 1\n ? \"4\"\n EXIT\n CASE 123456789\n CASE 0\n EXIT\n CASE \"AAAA\"\n CASE \"BBBBB\"\n ? a\n EXIT\n CASE Chr( 12 ) + Chr( 15 )\n ? \"Chr()\"\n EXIT\n OTHERWISE\n ? \"NOT FOUND: running OTHER\"\n ENDSWITCH\n#endif\n\n ?\n ? \"666666666666666666666666666666666666666666\"\n a := \"2\"\n SWITCH a\n CASE 1\n ? \"FOUND: 1\"\n ? a\n EXIT\n CASE \"2\"\n SWITCH a + a\n CASE 1\n ? \"Nested FOUND 1\"\n EXIT\n CASE \"22\"\n ? \"Nested FOUND: 22\"\n EXIT\n OTHERWISE\n ? \"Nested OTHERWISE\"\n ENDSWITCH\n ?? \"In CASE 1\"\n ? a\n ENDSWITCH\n\n ? \"=========================================\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'gtwvg' (): contrib/gtwvg/checkbox.prg. Defines classes: WvgCheckBox. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nCREATE CLASS WvgCheckBox INHERIT WvgWindow, WvgDataRef\n\n VAR autosize INIT .F.\n VAR caption INIT \"\"\n VAR pointerFocus INIT .T.\n VAR selection INIT .F.\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD destroy()\n METHOD handleEvent( nMessage, aNM )\n\n METHOD setCaption( xCaption )\n\n ACCESS selected INLINE ::sl_lbClick\n ASSIGN selected( bBlock ) INLINE ::sl_lbClick := bBlock\n\nENDCLASS\n\nMETHOD WvgCheckBox:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::style := WS_CHILD + BS_PUSHBUTTON + BS_AUTOCHECKBOX + BS_NOTIFY\n ::className := \"BUTTON\"\n ::objType := objTypeCheckBox\n\n RETURN Self\n\nMETHOD WvgCheckBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::oParent:AddChild( Self )\n\n ::createControl()\n\n\n IF ::visible\n ::show()\n ENDIF\n ::setPosAndSize()\n\n ::setCaption( ::caption )\n IF ::selection\n ::sendMessage( BM_SETCHECK, BST_CHECKED, 0 )\n ENDIF\n ::editBuffer := ( wvg_Button_GetCheck( ::hWnd ) == BST_CHECKED )\n\n RETURN Self\n\nMETHOD WvgCheckBox:handleEvent( nMessage, aNM )\n\n DO CASE\n\n CASE nMessage == HB_GTE_RESIZED\n IF ::isParentCrt()\n ::rePosition()\n ENDIF\n ::sendMessage( WM_SIZE, 0, 0 )\n\n CASE nMessage == HB_GTE_COMMAND\n IF aNM[ NMH_code ] == BN_CLICKED\n ::editBuffer := ( wvg_Button_GetCheck( ::hWnd ) == BST_CHECKED )\n IF HB_ISBLOCK( ::sl_lbClick )\n IF ::isParentCrt()\n ::oParent:setFocus()\n ENDIF\n Eval( ::sl_lbClick, ::editBuffer, , Self )\n IF ::pointerFocus\n ::setFocus()\n ENDIF\n ENDIF\n ENDIF\n\n CASE nMessage == HB_GTE_CTLCOLOR\n IF HB_ISNUMERIC( ::clr_FG )\n wvg_SetTextColor( aNM[ 1 ], ::clr_FG )\n ENDIF\n IF HB_ISNUMERIC( ::hBrushBG )\n wvg_SetBkMode( aNM[ 1 ], 1 )\n RETURN ::hBrushBG\n ELSE\n RETURN wvg_GetCurrentBrush( aNM[ 1 ] )\n ENDIF\n\n\n ENDCASE\n\n RETURN EVENT_UNHANDELLED\n\nMETHOD PROCEDURE WvgCheckBox:destroy()\n\n ::wvgWindow:destroy()\n\n RETURN\n\nMETHOD WvgCheckBox:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n RETURN Self\n\nMETHOD WvgCheckBox:setCaption( xCaption )\n\n IF HB_ISSTRING( xCaption )\n ::caption := xCaption\n wvg_SendMessageText( ::hWnd, WM_SETTEXT, 0, ::caption )\n ENDIF\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour test program: tests/ipclnt.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbsocket.ch\"\n\n#define ADDRESS \"127.0.0.1\"\n#define PORT 10000\n#define EOT hb_BChar( 4 )\n\nPROCEDURE Main()\n\n LOCAL hSocket\n\n IF Empty( hSocket := hb_socketOpen() )\n ? \"socket create error \" + hb_ntos( hb_socketGetError() )\n ENDIF\n IF ! hb_socketConnect( hSocket, { HB_SOCKET_AF_INET, ADDRESS, PORT } )\n ? \"socket connect error \" + hb_ntos( hb_socketGetError() )\n ENDIF\n\n ? hb_socketSend( hSocket, \"hi\" + EOT )\n ? hb_socketSend( hSocket, \"how\" + EOT )\n ? hb_socketSend( hSocket, \"you doing?\" + EOT )\n ? hb_socketSend( hSocket, \"quit\" + EOT )\n\n hb_socketShutdown( hSocket )\n hb_socketClose( hSocket )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour Runtime Library file: src/rtl/typefile.prg. Contains procedures: __TypeFile. This file implements object-oriented classes using Harbour's class system"}, {"role": "assistant", "content": "#include \"error.ch\"\n#include \"fileio.ch\"\n\n#define BUFFER_LENGTH 8192\n\nPROCEDURE __TypeFile( cFile, lPrint )\n\n LOCAL nHandle\n LOCAL cBuffer\n LOCAL nRead\n LOCAL nHasRead\n LOCAL nSize\n LOCAL nBuffer\n LOCAL oErr\n LOCAL nRetries\n LOCAL aSaveSet[ 2 ]\n LOCAL cDir, cName, cExt\n LOCAL cTmp\n LOCAL cPath\n LOCAL i\n\n hb_default( @lPrint, .F. )\n\n IF ! HB_ISSTRING( cFile )\n oErr := ErrorNew()\n oErr:severity := ES_ERROR\n oErr:genCode := EG_ARG\n oErr:subSystem := \"BASE\"\n oErr:SubCode := 2009\n oErr:Description := ProcName()\n Eval( ErrorBlock(), oErr )\n ENDIF\n\n \n hb_FNameSplit( cFile, @cDir, @cName, @cExt )\n\n IF Empty( cDir )\n\n cTmp := StrTran( Set( _SET_DEFAULT ) + \";\" + Set( _SET_PATH ), \",\", \";\" )\n\n i := Len( cTmp )\n DO WHILE SubStr( cTmp, i, 1 ) == \";\" \n cTmp := Left( cTmp, --i )\n ENDDO\n\n FOR EACH cPath IN hb_ATokens( cTmp, \";\" )\n IF hb_FileExists( cTmp := hb_FNameMerge( cPath, cName, cExt ) )\n cFile := cTmp\n EXIT\n ENDIF\n NEXT\n ENDIF\n\n nRetries := 0\n DO WHILE ( nHandle := FOpen( cFile, FO_READWRITE ) ) == F_ERROR\n oErr := ErrorNew()\n oErr:severity := ES_ERROR\n oErr:genCode := EG_OPEN\n oErr:subSystem := \"BASE\"\n oErr:SubCode := 2011\n oErr:canDefault := .T.\n oErr:canRetry := .T.\n oErr:fileName := cFile\n oErr:OsCode := FError()\n oErr:tries := ++nRetries\n IF ! hb_defaultValue( Eval( ErrorBlock(), oErr ), .T. ) \n RETURN\n ENDIF\n ENDDO\n\n \n IF lPrint\n aSaveSet[ 1 ] := Set( _SET_DEVICE, \"PRINTER\" )\n aSaveSet[ 2 ] := Set( _SET_PRINTER, .T. )\n ENDIF\n\n nSize := FSeek( nHandle, 0, FS_END )\n nBuffer := Min( nSize, BUFFER_LENGTH )\n\n FSeek( nHandle, 0 ) \n\n \n nHasRead := 0\n cBuffer := Space( nBuffer )\n QOut() \n DO WHILE ( nRead := FRead( nHandle, @cBuffer, nBuffer ) ) > 0\n nHasRead += nRead\n QQOut( cBuffer )\n nBuffer := Min( nSize - nHasRead, nBuffer )\n cBuffer := Space( nBuffer )\n ENDDO\n\n FClose( nHandle )\n\n IF lPrint\n Set( _SET_DEVICE, aSaveSet[ 1 ] )\n Set( _SET_PRINTER, aSaveSet[ 2 ] )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Header file for contribution module 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/dmlb.ch. Defines constants: _DMLB_CH, DB_WORKSPACE, DB_ZEROSPACE. Defines database/RDD constants"}, {"role": "assistant", "content": "#ifndef _DMLB_CH\n#define _DMLB_CH\n\n#define DB_WORKSPACE 1\n#define DB_ZEROSPACE 2\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/server.prg. Contains procedures: Main, Progress. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main( cPort )\n\n LOCAL Socket, s\n LOCAL nResponse, cResponse\n LOCAL nTurn := 0, nTurn1 := 0\n LOCAL bCont := .T.\n\n CLS\n\n IF Empty( cPort )\n cPort := \"2000\"\n ENDIF\n\n hb_inetInit()\n\n @ 1, 15 SAY \"H A R B O U R - Inet Api Server Demo\"\n @ 2, 5 SAY \"Contact this server using telnet or the Harbour Inet Client demo\"\n @ 3, 5 SAY \"Press a [KEY] to terminate the program\"\n @ 5, 5 SAY \"Server listening on port \" + cPort + \"...\"\n Socket := hb_inetServer( Val( cPort ) )\n hb_inetTimeout( Socket, 500 )\n\n DO WHILE bCont\n\n @ 6, 5 SAY Space( 70 )\n @ 7, 5 SAY Space( 70 )\n @ 8, 5 SAY Space( 70 )\n @ 9, 5 SAY Space( 70 )\n @ 6, 5\n\n \n DO WHILE bCont\n Progress( @nTurn, 5, 39 )\n s := hb_inetAccept( Socket )\n IF hb_inetErrorCode( Socket ) == 0\n EXIT\n ENDIF\n IF Inkey() != 0\n bCont := .F.\n ENDIF\n ENDDO\n\n IF ! bCont\n EXIT\n ENDIF\n\n hb_inetTimeout( s, 500 )\n\n @ 6, 5 SAY \"Connection from: \" + hb_inetAddress( s ) + \":\" + Str( hb_inetPort( s ), 5 )\n @ 7, 5 SAY \"Receiving: \"\n @ 8, 5\n\n nResponse := hb_inetSend( s, \"Welcome to my server!\" + hb_eol() )\n\n DO WHILE bCont\n \n hb_inetTimeout( s, 250 )\n \n hb_inetPeriodCallback( s, { @Progress(), @nTurn, 6, 39 } )\n \n cResponse := hb_inetRecvLine( s, @nResponse )\n \n \n DO CASE\n CASE hb_inetErrorCode( s ) == 0\n IF Lower( cResponse ) == \"quit\"\n bCont := .F.\n ENDIF\n @ 8, 5 SAY Space( 70 )\n @ 8, 5 SAY cResponse\n cResponse := \"Count: \" + Str( nResponse ) + \" characters\" + hb_eol()\n hb_inetSend( s, cResponse )\n\n CASE hb_inetErrorCode( s ) == -1\n \n Progress( @nTurn1, 7, 17 )\n\n OTHERWISE\n @ 7, 5 SAY \"Received Error \" + Str( hb_inetErrorCode( s ) ) + \": \" + hb_inetErrorDesc( s )\n @ 8, 5 SAY Space( 70 )\n @ 9, 5 SAY Space( 70 )\n @ 9, 5 SAY \"Press a key to continue\"\n Inkey( 0 )\n EXIT\n\n ENDCASE\n\n IF Inkey() != 0\n bCont := .F.\n ENDIF\n ENDDO\n ENDDO\n\n hb_inetCleanup()\n\n RETURN\n\nPROCEDURE Progress( nProgress, nDrow, nDcol )\n\n LOCAL nRow := Row(), nCol := Col()\n\n @ nDrow, nDcol SAY \"[ ]\"\n\n DO CASE\n CASE nProgress == 0\n @ nDrow, nDcol + 1 SAY \"-\"\n CASE nProgress == 1\n @ nDrow, nDcol + 1 SAY \"\\\"\n CASE nProgress == 2\n @ nDrow, nDcol + 1 SAY \"|\"\n CASE nProgress == 3\n @ nDrow, nDcol + 1 SAY \"/\"\n ENDCASE\n\n nProgress++\n\n IF nProgress == 4\n nProgress := 0\n ENDIF\n\n @ nRow, nCol\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/objasign.prg. Provides functions: TNumber, New. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL o := TNumber():New()\n\n ? \"Direct reference : \", o:x\n\n o:x := \"I am a data\"\n ? \"Assign text : \", o:x\n\n o:x := 4\n ? \"Assign 4 : \", o:x\n\n ? \"Post increment : \", o:x++\n ? \"After : \", o:x\n ? \"Pre decrement : \", --o:x\n ? \"After : \", o:x\n\n o:x += 2\n ? \"Plus 2 : \", o:x\n\n o:x -= 3\n ? \"Minus 3 : \", o:x\n\n o:x\n ? \"Times 3 : \", o:x\n\n o:x /= 1.5\n ? \"Divide by 1.5 : \", o:x\n\n o:x %= 4\n ? \"Modulus 4 : \", o:x\n\n o:x ^= 3\n ? \"To the power 3 : \", o:x\n\n ? \"Global stack\"\n ? hb_ValToExp( __dbgVMStkGList() )\n ? \"Statics\"\n ? hb_ValToExp( __dbgVMVarSList() )\n\n RETURN\n\nFUNCTION TNumber() \n\n STATIC oNumber\n\n IF oNumber == NIL\n oNumber := HBClass():New( \"TNumber\" )\n\n oNumber:AddData( \"x\" )\n oNumber:AddMethod( \"New\", @New() )\n oNumber:Create()\n ENDIF\n\n RETURN oNumber:Instance()\n\nSTATIC FUNCTION New()\n\n LOCAL self := QSelf()\n\n ::x := 1\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour header file: include/hbtrace.ch. Defines 10 constants including: HB_TRACE_CH_, HB_TR_ALWAYS, HB_TR_FATAL, HB_TR_ERROR, HB_TR_WARNING. Declares 3 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_TRACE_CH_\n#define HB_TRACE_CH_\n\n\n#define HB_TR_ALWAYS 0\n#define HB_TR_FATAL 1\n#define HB_TR_ERROR 2\n#define HB_TR_WARNING 3\n#define HB_TR_INFO 4\n#define HB_TR_DEBUG 5\n#define HB_TR_LAST 6\n\n#ifdef _HB_TR_NOALWAYS_\n#undef HB_TR_ALWAYS\n#define HB_TR_ALWAYS HB_TR_LAST\n#endif\n\n\n#define HB_TR_DEFAULT HB_TR_WARNING\n\n\n#ifdef HB_TR_LEVEL_ALWAYS\n#define HB_TR_LEVEL HB_TR_ALWAYS\n#endif\n#ifdef HB_TR_LEVEL_FATAL\n#define HB_TR_LEVEL HB_TR_FATAL\n#endif\n#ifdef HB_TR_LEVEL_ERROR\n#define HB_TR_LEVEL HB_TR_ERROR\n#endif\n#ifdef HB_TR_LEVEL_WARNING\n#define HB_TR_LEVEL HB_TR_WARNING\n#endif\n#ifdef HB_TR_LEVEL_INFO\n#define HB_TR_LEVEL HB_TR_INFO\n#endif\n#ifdef HB_TR_LEVEL_DEBUG\n#define HB_TR_LEVEL HB_TR_DEBUG\n#endif\n\n#ifndef HB_TR_LEVEL\n#define HB_TR_LEVEL HB_TR_DEFAULT\n#endif\n\n#xtranslate HB_TRACE_STEALTH( , ) => HB_TRACE( , )\n#xtranslate HB_TRACE( , ( ) ) => HB_TRACE( , )\n#xtranslate HB_TRACE( , ) => ;\n iif( HB_TR_LEVEL >= , hb_traceLogAt( , ), )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbblink' (Blinker function extender): contrib/hbblink/blinker.prg. Provides 53 functions including: BliDbgHan, BliDemDte, BliDemDteBas, BliDemMin, BliErrNum. Contains 10 procedures. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbhrb.ch\"\n#include \"hbmemory.ch\"\n\n#include \"hbblink.ch\"\n\nSTATIC s_cSerialNum := \"\"\nSTATIC s_cDemoDate := \"\"\nSTATIC s_nDemoMinutes := 0\nSTATIC s_nError := 0\nSTATIC s_cErrorParam := \"\"\nSTATIC s_lLibOverrides := .F.\n\nTHREAD STATIC t_nErrorLevel := 0\nTHREAD STATIC t_nErrorMaj := 0\nTHREAD STATIC t_nErrorMin := 0\n\nPROCEDURE hb_BliVerNum( cString )\n\n IF HB_ISSTRING( cString )\n s_cSerialNum := cString\n ENDIF\n\n RETURN\n\nPROCEDURE hb_BliDemDte( dDate )\n\n IF HB_ISDATE( dDate )\n s_cDemoDate := DToS( dDate )\n ENDIF\n\n RETURN\n\nPROCEDURE hb_BliDemMin( nValue )\n\n IF HB_ISNUMERIC( nValue )\n s_nDemoMinutes := nValue\n ENDIF\n\n RETURN\n\nFUNCTION BliDbgHan( nValue )\n\n STATIC s_nDebugHandle := 1\n LOCAL nOldValue := s_nDebugHandle\n\n IF HB_ISNUMERIC( nValue )\n s_nDebugHandle := nValue\n ENDIF\n\n RETURN nOldValue\n\nFUNCTION BliDemDte()\n RETURN s_cDemoDate\n\nFUNCTION BliDemDteBas()\n RETURN s_cDemoDate\n\nFUNCTION BliDemMin( nValue )\n\n LOCAL nOldValue := s_nDemoMinutes\n\n IF HB_ISNUMERIC( nValue )\n s_nDemoMinutes := nValue\n ENDIF\n\n RETURN nOldValue\n\nPROCEDURE BliDisFrg( fhnd )\n\n HB_SYMBOL_UNUSED( fhnd )\n\n RETURN\n\nFUNCTION BliErrNum()\n RETURN s_nError\n\nFUNCTION BliErrPrm()\n RETURN s_cErrorParam\n\nFUNCTION BliErrPrmBas()\n RETURN s_cErrorParam\n\n\nFUNCTION BliLibLib( cLib )\n RETURN iif( s_lLibOverrides, hb_hrbLoad( HB_HRB_BIND_OVERLOAD, cLib ), hb_hrbLoad( cLib ) )\n\n\nFUNCTION BliFunHan( pLib, cFunction )\n RETURN hb_hrbGetFunSym( pLib, cFunction )\n\nFUNCTION BliFunCal( ... )\n\n LOCAL aParams := hb_AParams()\n LOCAL pFunction\n\n IF Len( aParams ) > 0\n pFunction := ATail( aParams )\n ASize( aParams, Len( aParams ) - 1 )\n RETURN hb_hrbDo( pFunction, hb_ArrayToParams( aParams ) )\n ENDIF\n\n RETURN NIL\n\nPROCEDURE BliLibFre( pLib )\n\n hb_hrbUnload( pLib )\n\n RETURN\n\nPROCEDURE BliLibOvr( lValue )\n\n IF HB_ISLOGICAL( lValue )\n s_lLibOverrides := lValue\n ENDIF\n\n RETURN\n\nPROCEDURE BliLstFrg( fhnd )\n\n HB_SYMBOL_UNUSED( fhnd )\n\n RETURN\n\nFUNCTION BliMemAvl()\n RETURN Memory( HB_MEM_CHAR )\n\nFUNCTION BliMemSiz()\n RETURN Memory( HB_MEM_CHAR )\n\nFUNCTION BliMemBlk( nBlockSize )\n\n HB_SYMBOL_UNUSED( nBlockSize )\n\n RETURN Memory( HB_MEM_CHAR )\n\nFUNCTION BliMemPak( nValue )\n\n STATIC s_nGCFrequency := 0\n LOCAL nOldValue := s_nDemoMinutes\n\n IF HB_ISNUMERIC( nValue )\n s_nGCFrequency := nValue\n ENDIF\n\n RETURN nOldValue\n\nFUNCTION BliMemUse()\n RETURN Memory( HB_MEM_USED )\n\nPROCEDURE BliOvlClr()\n RETURN\n\nFUNCTION BliOvlOps()\n RETURN Memory( HB_MEM_CHAR )\n\nPROCEDURE BliOvlRes()\n RETURN\n\nFUNCTION BliOvlSiz()\n RETURN 0\n\nPROCEDURE BliOvlSus( nValue )\n\n HB_SYMBOL_UNUSED( nValue )\n\n RETURN\n\nFUNCTION BliPtrDec( nPointer, nValue )\n RETURN nPointer - nValue\n\nFUNCTION BliPtrInc( nPointer, nValue )\n RETURN nPointer + nValue\n\nFUNCTION BliSerNum()\n RETURN s_cSerialNum\n\nFUNCTION BliSerNumBas()\n RETURN s_cSerialNum\n\nFUNCTION BliStrFrg( cString )\n\n HB_SYMBOL_UNUSED( cString )\n\n RETURN \"\"\n\nFUNCTION BliVerNum()\n RETURN 700\n\nFUNCTION BliCpuRel()\n RETURN hb_ReleaseCPU()\n\nFUNCTION BliMgrSts( nParam )\n\n SWITCH nParam\n CASE BliCacheLoc ; RETURN BliCacheNone\n CASE BliHostMode ; RETURN BliHostNone\n CASE BliMachineMode ; RETURN BliMode286Prot\n CASE BliOverlaySize ; RETURN Memory( HB_MEM_CHAR )\n CASE BliRealMemAvail ; RETURN Memory( HB_MEM_CHAR )\n CASE BliCacheSize\n CASE BliExtMemAvail\n CASE BliOverlayLoc\n CASE BliVirMemAvail \n ENDSWITCH\n\n RETURN 0\n\nFUNCTION SwpAddEnv( nBytes )\n\n HB_SYMBOL_UNUSED( nBytes )\n\n RETURN 32768\n\nFUNCTION SwpAddStr( cPID, cString )\n\n HB_SYMBOL_UNUSED( cPID )\n HB_SYMBOL_UNUSED( cString )\n\n RETURN 1\n\nFUNCTION SwpAddStrBas( cPID, cString )\n\n HB_SYMBOL_UNUSED( cPID )\n HB_SYMBOL_UNUSED( cString )\n\n RETURN 1\n\nFUNCTION SwpCurDir( lValue )\n\n HB_SYMBOL_UNUSED( lValue )\n\n RETURN .T.\n\nFUNCTION SwpDisMsg( lValue )\n\n HB_SYMBOL_UNUSED( lValue )\n\n RETURN .F.\n\nFUNCTION SwpEms320( lValue )\n\n HB_SYMBOL_UNUSED( lValue )\n\n RETURN .F.\n\nFUNCTION SwpErrLev()\n RETURN t_nErrorLevel\n\nFUNCTION SwpErrMaj()\n RETURN t_nErrorMaj\n\nFUNCTION SwpErrMin()\n RETURN t_nErrorMin\n\nFUNCTION SwpFreEms( nLimitKB )\n\n HB_SYMBOL_UNUSED( nLimitKB )\n\n RETURN 0\n\nFUNCTION SwpUseEms( lValue )\n\n HB_SYMBOL_UNUSED( lValue )\n\n RETURN .F.\n\nFUNCTION SwpFreXms( nLimitKB )\n\n HB_SYMBOL_UNUSED( nLimitKB )\n\n RETURN 0\n\nFUNCTION SwpUseXms( lValue )\n\n HB_SYMBOL_UNUSED( lValue )\n\n RETURN .F.\n\nFUNCTION SwpUseUmb( lValue )\n\n HB_SYMBOL_UNUSED( lValue )\n\n RETURN .F.\n\nFUNCTION SwpGetKey( lValue )\n\n HB_SYMBOL_UNUSED( lValue )\n\n RETURN .F.\n\nFUNCTION SwpGetPid( cIDString )\n\n HB_SYMBOL_UNUSED( cIDString )\n\n RETURN .F.\n\nFUNCTION SwpVidMde( lValue )\n\n HB_SYMBOL_UNUSED( lValue )\n\n RETURN .F.\n\nFUNCTION SwpGetStr()\n RETURN \"\"\n\nFUNCTION SwpKeyBrd( cKeyString )\n\n HB_SYMBOL_UNUSED( cKeyString )\n\n RETURN 0\n\nFUNCTION SwpKeyBrdBas( cKeyString )\n\n HB_SYMBOL_UNUSED( cKeyString )\n\n RETURN 0\n\nFUNCTION SwpKeyClr( nValue )\n\n HB_SYMBOL_UNUSED( nValue )\n\n RETURN 0\n\nFUNCTION SwpNobOot( lValue )\n\n HB_SYMBOL_UNUSED( lValue )\n\n RETURN .F.\n\nFUNCTION SwpRunCmd( cCommand, nMem, cRunPath, cTempPath )\n\n HB_SYMBOL_UNUSED( nMem )\n HB_SYMBOL_UNUSED( cRunPath )\n HB_SYMBOL_UNUSED( cTempPath )\n\n IF ! HB_ISSTRING( cCommand ) .OR. Empty( cCommand )\n#if defined( __PLATFORM__UNIX )\n cCommand := GetEnv( \"SHELL\" )\n#else\n cCommand := GetEnv( \"COMSPEC\" )\n#endif\n ENDIF\n\n RETURN ( t_nErrorLevel := hb_run( cCommand ) ) != -1\n\nFUNCTION SwpSetEnv( cString )\n\n LOCAL cPair\n LOCAL tmp\n\n FOR EACH cPair IN hb_ATokens( cString, hb_BChar( 255 ) )\n IF ( tmp := At( \"=\", cPair ) ) > 0\n hb_SetEnv( Left( cPair, tmp - 1 ), SubStr( cPair, tmp + 1 ) )\n ENDIF\n NEXT\n\n RETURN .T.\n\nFUNCTION SwpSetPid( cIDString )\n\n HB_SYMBOL_UNUSED( cIDString )\n\n RETURN .T.\n\nFUNCTION SwpSetPidBas( cIDString )\n\n HB_SYMBOL_UNUSED( cIDString )\n\n RETURN .T.\n\nFUNCTION SwpSetStr( cString )\n\n HB_SYMBOL_UNUSED( cString )\n\n RETURN .T.\n\nFUNCTION SwpSetStrBas( cString )\n\n HB_SYMBOL_UNUSED( cString )\n\n RETURN .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/url.prg. Defines classes: TUrl. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n\nCREATE CLASS TUrl\n\n VAR cAddress INIT \"\"\n VAR cProto INIT \"\"\n VAR cUserid INIT \"\"\n VAR cPassword INIT \"\"\n VAR cServer INIT \"\"\n VAR cPath INIT \"\"\n VAR cQuery INIT \"\"\n VAR cFile INIT \"\"\n VAR nPort INIT -1\n\n METHOD New( cUrl )\n METHOD SetAddress( cUrl )\n METHOD BuildAddress()\n METHOD BuildQuery()\n METHOD AddGetForm( xPostData )\n\n HIDDEN:\n\n CLASS VAR cREuri INIT hb_regexComp( \"(?:(.*):\n CLASS VAR cREServ INIT hb_regexComp( \"(?:([^:@]*):?([^@:]*)@|)([^:]+):?(.*)\" )\n CLASS VAR cREFile INIT hb_regexComp( \"^((?:/.*/)|/)*(.*)$\" )\n\nENDCLASS\n\nMETHOD New( cUrl ) CLASS TUrl\n\n ::SetAddress( cUrl )\n\n RETURN Self\n\nMETHOD SetAddress( cUrl ) CLASS TUrl\n\n LOCAL aMatch, cServer, cPath\n\n IF ! HB_ISSTRING( cUrl )\n RETURN .F.\n ENDIF\n\n ::cAddress := cUrl\n ::cProto := ;\n ::cUserid := ;\n ::cPassword := ;\n ::cServer := ;\n ::cPath := ;\n ::cQuery := ;\n ::cFile := \"\"\n ::nPort := -1\n\n IF cUrl == \"\"\n RETURN .T.\n ENDIF\n\n \n IF Empty( aMatch := hb_regex( ::cREuri, cUrl ) )\n RETURN .F.\n ENDIF\n\n ::cProto := Lower( aMatch[ 2 ] )\n cServer := aMatch[ 3 ]\n cPath := aMatch[ 4 ]\n ::cQuery := aMatch[ 5 ]\n\n \n aMatch := hb_regex( ::cREServ, cServer )\n ::cUserId := aMatch[ 2 ]\n ::cPassword := aMatch[ 3 ]\n ::cServer := aMatch[ 4 ]\n ::nPort := Val( aMatch[ 5 ] )\n IF ::nPort < 1\n ::nPort := -1\n ENDIF\n\n \n aMatch := hb_regex( ::cREFile, cPath )\n ::cPath := aMatch[ 2 ]\n ::cFile := aMatch[ 3 ]\n\n RETURN .T.\n\nMETHOD BuildAddress() CLASS TUrl\n\n LOCAL cRet := \"\"\n\n IF ::cProto != NIL\n ::cProto := Lower( ::cProto )\n ENDIF\n\n IF ! Empty( ::cProto ) .AND. ! ::cServer == \"\"\n cRet := ::cProto + \":\n ENDIF\n\n IF ! ::cUserid == \"\"\n cRet += ::cUserid\n IF ! ::cPassword == \"\"\n cRet += \":\" + ::cPassword\n ENDIF\n cRet += \"@\"\n ENDIF\n\n IF ! ::cServer == \"\"\n cRet += ::cServer\n IF ::nPort > 0\n cRet += \":\" + hb_ntos( ::nPort )\n ENDIF\n ENDIF\n\n IF ::cPath == \"\" .OR. ! Right( ::cPath, 1 ) == \"/\"\n ::cPath += \"/\"\n ENDIF\n\n cRet += ::cPath + ::cFile\n IF ! ::cQuery == \"\"\n cRet += \"?\" + ::cQuery\n ENDIF\n\n RETURN iif( cRet == \"\", NIL, ::cAddress := cRet )\n\nMETHOD BuildQuery() CLASS TUrl\n\n LOCAL cLine\n\n IF ::cPath == \"\" .OR. ! Right( ::cPath, 1 ) == \"/\"\n ::cPath += \"/\"\n ENDIF\n\n cLine := ::cPath + ::cFile\n IF ! ::cQuery == \"\"\n cLine += \"?\" + ::cQuery\n ENDIF\n\n RETURN cLine\n\nMETHOD AddGetForm( xPostData ) CLASS TUrl\n\n LOCAL cData := \"\"\n LOCAL item\n\n DO CASE\n CASE HB_ISHASH( xPostData )\n FOR EACH item IN xPostData\n cData += ;\n tip_URLEncode( AllTrim( hb_CStr( item:__enumKey() ) ) ) + \"=\" + ;\n tip_URLEncode( AllTrim( hb_CStr( item ) ) )\n IF ! item:__enumIsLast()\n cData += \"&\"\n ENDIF\n NEXT\n CASE HB_ISARRAY( xPostData )\n FOR EACH item IN xPostData\n cData += ;\n tip_URLEncode( AllTrim( hb_CStr( item:__enumIndex() ) ) ) + \"=\" + ;\n tip_URLEncode( AllTrim( hb_CStr( item ) ) )\n IF ! item:__enumIsLast()\n cData += \"&\"\n ENDIF\n NEXT\n CASE HB_ISSTRING( xPostData )\n cData := xPostData\n ENDCASE\n\n RETURN iif( cData == \"\", NIL, ;\n ::cQuery += iif( ::cQuery == \"\", \"\", \"&\" ) + cData )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHeader file for contribution module 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/dll.ch. Defines 9 constants including: _DLL_CH, DLL_CDECL, DLL_STDCALL, DLL_SYSTEM, DLL_OSAPI"}, {"role": "assistant", "content": "#ifndef _DLL_CH\n#define _DLL_CH\n\n#define DLL_CDECL 0x08\n#define DLL_STDCALL 0x20\n#define DLL_SYSTEM 0x04\n#if defined( __PLATFORM__WINDOWS )\n#define DLL_OSAPI DLL_STDCALL\n#elif defined( __PLATFORM__OS2 )\n#define DLL_OSAPI DLL_SYSTEM\n#else\n#define DLL_OSAPI DLL_CDECL\n#endif\n\n\n#define DLL_CALLMODE_COPY 0\n#define DLL_CALLMODE_NORMAL DLL_CALLMODE_COPY\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/ct.prg. Provides functions: ctinit, ctexit. Contains procedures: _CTINIT, _CTEXIT. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "STATIC s_bInitialized := .F.\n\nFUNCTION ctinit()\n\n IF ! s_bInitialized\n s_bInitialized := ctcinit()\n ENDIF\n\n RETURN s_bInitialized\n\nINIT PROCEDURE _CTINIT()\n\n IF ! s_bInitialized\n s_bInitialized := ctcinit()\n ENDIF\n\n RETURN\n\nFUNCTION ctexit()\n\n IF s_bInitialized\n ctcexit()\n s_bInitialized := .F.\n ENDIF\n\n RETURN NIL\n\nEXIT PROCEDURE _CTEXIT()\n\n IF s_bInitialized\n ctcexit()\n s_bInitialized := .F.\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/acctqtr.prg. Provides functions: ft_AcctQtr. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_AcctQtr( dGivenDate, nQtrNum )\n\n LOCAL nYTemp, nQTemp, aRetVal\n\n IF HB_ISNUMERIC( dGivenDate )\n nQtrNum := dGivenDate\n dGivenDate := Date()\n ELSEIF ! HB_ISDATE( dGivenDate )\n dGivenDate := Date()\n ENDIF\n\n aRetVal := ft_Qtr( dGivenDate )\n nYTemp := Val( SubStr( aRetVal[ 1 ], 1, 4 ) )\n nQTemp := Val( SubStr( aRetVal[ 1 ], 5, 2 ) )\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n\n IF dGivenDate < aRetVal[ 2 ]\n\n dGivenDate := ft_MAdd( dGivenDate, - 1 )\n aRetVal := ft_Qtr( dGivenDate )\n nQTemp -= 1\n IF nQTemp == 0\n nYTemp -= 1\n nQTemp := 4\n ENDIF\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n\n ELSEIF dGivenDate > aRetVal[ 3 ]\n\n dGivenDate := ft_MAdd( dGivenDate, 1 )\n aRetVal := ft_Qtr( dGivenDate )\n nQTemp += 1\n IF nQTemp == 5\n nYTemp += 1\n nQTemp := 1\n ENDIF\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n\n ENDIF\n\n IF HB_ISNUMERIC( nQtrNum )\n IF nQtrNum < 1 .OR. nQtrNum > 4\n nQtrNum := 4\n ENDIF\n aRetVal := ft_Qtr( dGivenDate, nQtrNum )\n nYTemp := Val( SubStr( aRetVal[ 1 ], 1, 4 ) )\n nQTemp := Val( SubStr( aRetVal[ 1 ], 5, 2 ) )\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n ENDIF\n\n aRetVal[ 1 ] := Str( nYTemp, 4 ) + StrZero( nQTemp, 2 )\n\n RETURN aRetVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnetio' (Network I/O operations): contrib/hbnetio/tests/netiomt1.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbnetio\"\n\n#define NETSERVER \"127.0.0.1\"\n#define NETPORT 2940\n#define NETPASSWD \"toptopsecret\"\n\n\nPROCEDURE Main()\n\n \n ? \"CONNECTING...\"\n ? \"netio_Connect():\", netio_Connect( NETSERVER, NETPORT,, NETPASSWD )\n ?\n \n ? \"Number of connected clients:\", Len( netio_FuncExec( \"netio_conninfo\" ) )\n ? \"SHUTDOWN server:\", netio_FuncExec( \"netio_shutdown\" )\n ?\n\n \n ? \"netio_Disconnect():\", netio_Disconnect( NETSERVER, NETPORT )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/invclr.prg. Provides functions: ft_InvClr. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_InvClr( cDsrdColor )\n\n LOCAL cBackground \n LOCAL cForeground \n LOCAL cModifiers \n\n __defaultNIL( @cDsrdColor, SetColor() )\n\n \n cDsrdColor := Left( cDsrdColor, At( \",\", cDsrdColor + \",\" ) - 1 )\n\n \n cModifiers := ;\n iif( \"*\" $ cDsrdColor, \"*\", \"\" ) + ;\n iif( \"+\" $ cDsrdColor, \"+\", \"\" )\n\n \n cForeground := AllTrim( Left( cDsrdColor, At( \"/\", cDsrdColor ) - 1 ) )\n cBackground := AllTrim( SubStr( cDsrdColor, At( \"/\", cDsrdColor ) + 1 ) )\n\n RETURN ;\n StrTran( StrTran( cBackground, \"+\" ), \"*\" ) + cModifiers + \"/\" + ;\n StrTran( StrTran( cForeground, \"+\" ), \"*\" )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/http_cli.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbssl\"\n#require \"hbtip\"\n\n#if ! defined( __HBSCRIPT__HBSHELL )\nREQUEST __HBEXTERN__HBSSL__\n#endif\n\nPROCEDURE Main( cProxy )\n\n LOCAL cURL := iif( tip_SSL(), \"https\", \"http\" ) + \":\n LOCAL oHTTP := TIPClientHTTP():New( cURL, .T. )\n\n ? \"Proxy:\", cProxy\n ? \"URL:\", cURL\n\n IF HB_ISSTRING( cProxy )\n oHTTP:setProxy( TUrl():New( cProxy ) )\n ENDIF\n oHTTP:setCookie( \"test01=value01\" )\n\n IF oHTTP:Open()\n IF oHTTP:Post( \"test\" )\n ? oHTTP:cReply\n ? hb_ValToExp( oHTTP:hHeaders )\n ELSE\n ? \"Error:\", \"oHTTP:Post()\", oHTTP:lastErrorMessage()\n ENDIF\n oHTTP:Close()\n ELSE\n ? \"Error:\", \"oHTTP:Open()\", oHTTP:lastErrorMessage()\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: MenuModal, ShowMsg, IsShortcut. Harbour Runtime Library file: src/rtl/menusys.prg. Provides functions: MenuModal, ShowMsg, IsShortcut, IsQuick. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"getexit.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\n\n#ifdef HB_COMPAT_C53\n\n\nFUNCTION MenuModal( oTopMenu, nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )\n RETURN HBMenuSys():New( oTopMenu ):modal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )\n\n\nFUNCTION ShowMsg( aMsg, lMode )\n\n HB_SYMBOL_UNUSED( aMsg )\n HB_SYMBOL_UNUSED( lMode )\n\n RETURN .F.\n\n\nFUNCTION IsShortcut( oMenu, nKey, nID )\n\n LOCAL nItem\n LOCAL nTotal\n LOCAL nShortCut\n LOCAL oItem\n LOCAL i\n\n DO CASE\n \n CASE ! oMenu:ClassName() == \"TOPBARMENU\"\n\n RETURN IsQuick( oMenu, nKey, @nID )\n\n \n CASE ( nShortCut := oMenu:getShortCt( nKey ) ) > 0 .AND. ;\n ( oItem := oMenu:getItem( nShortcut ) ):enabled .AND. ;\n ! oItem:isPopUp()\n\n oMenu:select( nShortCut )\n Eval( oItem:data, oItem )\n nID := oItem:ID\n\n RETURN .T.\n\n \n CASE nShortCut == 0\n\n nTotal := oMenu:itemCount\n nItem := oMenu:current\n\n IF nItem == 0\n nItem := 1\n ENDIF\n\n \n FOR i := 1 TO nTotal\n\n IF ( oItem := oMenu:getItem( nItem ) ):enabled .AND. ;\n oItem:isPopUp() .AND. ;\n IsQuick( oItem:data, nKey, @nID )\n\n RETURN .T.\n ENDIF\n\n IF ++nItem > nTotal\n nItem := 1\n ENDIF\n NEXT\n\n ENDCASE\n\n RETURN .F.\n\n\nFUNCTION IsQuick( oMenu, nKey, nID )\n\n LOCAL nItem\n LOCAL nTotal\n LOCAL nShortCut\n LOCAL oItem\n\n IF ( nShortCut := oMenu:getShortCt( nKey ) ) == 0\n\n nTotal := oMenu:itemCount\n\n FOR nItem := 1 TO nTotal\n\n IF ( oItem := oMenu:getItem( nItem ) ):enabled .AND. ;\n oItem:isPopUp() .AND. ;\n IsQuick( oItem:data, nKey, @nID )\n\n RETURN .T.\n ENDIF\n NEXT\n\n ELSEIF !( oItem := oMenu:getItem( nShortCut ) ):isPopUp() .AND. oItem:enabled\n\n oMenu:select( nShortCut )\n Eval( oItem:data, oItem )\n nID := oItem:ID\n\n RETURN .T.\n\n ENDIF\n\n RETURN .F.\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbcairo' (Cairo graphics library wrapper): contrib/hbcairo/tests/hellow.prg. Contains procedures: Main. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbcairo\"\n\nREQUEST HB_CODEPAGE_LTWIN\n\nPROCEDURE Main()\n\n LOCAL hSurface, hCairo, nI\n\n hb_cdpSelect( \"LTWIN\" )\n hSurface := cairo_pdf_surface_create( \"hellow.pdf\", 566.9, 793.7 ) \n hCairo := cairo_create( hSurface )\n\n cairo_select_font_face( hCairo, \"sans-serif\", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD )\n cairo_set_font_size( hCairo, 16 )\n cairo_set_source_rgb( hCairo, 0, 0, 0 ) \n\n cairo_move_to( hCairo, 50, 50 )\n cairo_show_text( hCairo, \"Hello, World!\" )\n\n cairo_set_line_width( hCairo, 1 )\n FOR nI := 1 TO 10\n cairo_set_source_rgb( hCairo, hb_Random(), hb_Random(), hb_Random() )\n cairo_rectangle( hCairo, 100 + nI\n cairo_select_font_face( hCairo, \"sans-serif\", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL )\n cairo_set_font_size( hCairo, 10 )\n cairo_set_source_rgb( hCairo, 0, 0, 0 )\n cairo_move_to( hCairo, 50, 300 )\n cairo_show_text( hCairo, hb_UTF8ToStr( \"Plaukė žąselė per ežerėlį...\" ) )\n\n cairo_show_page( hCairo )\n cairo_destroy( hCairo )\n cairo_surface_destroy( hSurface )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/mt/mttest03.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifdef __XHARBOUR__\n #xtranslate hb_threadStart( ) => StartThread( )\n #xtranslate hb_threadJoin( ) => JoinThread( )\n #command begin sequence => try\n #command always => finally\n#endif\n\nproc main()\n local thID, i\n ? Version()\n ? \"Main start\"\n thID := hb_threadStart( @thFunc(), \"A\", \"B\", \"C\" )\n ? \"Thread ID:\", thID\n ? \"===================\"\n ?\n begin sequence\n for i := 1 to 10\n ?? \"M\"\n hb_idleSleep( 0.050 )\n if i == 5\n ? \"Main QUIT\"\n quit\n endif\n next\n ? \"===================\"\n always\n ? \"Main ALWAYS section\"\n ?\n endsequence\n ? \"End of main\"\nreturn\n\nproc thFunc( ... )\n local i\n ? \"Thread begin\"\n ? \"Parameters:\"\n aeval( hb_aParams(), {| x | qqout( \"\", x ) } )\n ?\n begin sequence\n for i := 1 to 10\n ?? \"t\"\n hb_idleSleep( 0.030 )\n next\n always\n ? \"Thread ALWAYS section\"\n ?\n endsequence\n ? \"Thread end\"\n ?\nreturn\n\nexit proc p\n? \"I'm EXIT procedure\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour header file: include/getexit.ch. Defines 10 constants including: _GETEXIT_CH, GE_NOEXIT, GE_UP, GE_DOWN, GE_TOP"}, {"role": "assistant", "content": "#ifndef _GETEXIT_CH\n#define _GETEXIT_CH\n\n\n#define GE_NOEXIT 0 \n#define GE_UP 1\n#define GE_DOWN 2\n#define GE_TOP 3\n#define GE_BOTTOM 4\n#define GE_ENTER 5\n#define GE_WRITE 6\n#define GE_ESCAPE 7\n#define GE_WHEN 8 \n#define GE_SHORTCUT 9 \n#define GE_MOUSEHIT 10 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/macro.prg. Provides 7 functions including: TValue, New, SubFun, UDF_STATIC, UDF. Contains procedures: Main, TEST_Type. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nMEMVAR cStr, cStr_1, cVar_1, aVar, oVar, OtherVar, SomeVar, Private\nMEMVAR cMainPrivate, GlobalPrivate, BornInRunTimeVar, Public\n\nPROCEDURE Main()\n\n PRIVATE cStr := \"cVar\", cStr_1 := \"cVar_1\", aVar := { \"cVar_1\" }, oVar\n\n PRIVATE cVar_1, cMainPrivate := \"cVar_1\", GlobalPrivate := \"BornInRunTimeVar\"\n\n \n UDF_STATIC()\n UDF2_STATIC()\n\n &cStr_1 := \"Simple \"\n ? M->cVar_1\n\n &( \"cVar\" + \"_1\" ) := \"Macro\"\n ?? M->cVar_1\n\n M->&cStr_1 := \"Aliased\"\n ? M->cVar_1\n\n MEMVAR->&( \"cVar\" + \"_1\" ) := \" Macro\"\n ?? M->cVar_1\n\n cStr := \"cVar_\"\n &cStr.1 := \"Concatenated Macro (Numeric)\"\n ? M->cVar_1\n\n cStr := \"cVar\"\n &cStr._1 := \"Concatenated Macro (String)\"\n ? M->cVar_1\n\n &( aVar[1] ) := \"Array Macro\"\n ? M->cVar_1\n\n oVar := TValue():New()\n oVar:cVal := \"cVar_1\"\n &( oVar:cVal ) := \"Class Macro\"\n ? M->cVar_1\n\n SubFun()\n\n ? '\"cVar_1\" = [' + M->cVar_1 + '] AFTER SubFun() PRIVATE'\n\n ? M->NewPublicVar\n\n TEST_Type()\n\n RETURN\n\nFUNCTION TValue()\n\n STATIC s_oClass\n\n IF s_oClass == NIL\n s_oClass := HBClass():New( \"TValue\" )\n\n s_oClass:AddData( \"cVal\" )\n s_oClass:AddMethod( \"New\", @New() ) \n\n s_oClass:Create()\n\n ENDIF\n\n RETURN s_oClass:Instance()\n\nSTATIC FUNCTION New()\n\n LOCAL Self := QSelf()\n\n RETURN Self\n\nFUNCTION SubFun()\n\n ? '\"cVar_1\" = [' + M->cVar_1 + '] BEFORE SubFun() PRIVATE'\n\n \n PRIVATE PRIVATE := \"I am a Var named PRIVATE \", &cMainPrivate, SomeVar, OtherVar := 1, &GlobalPrivate := \"I was born in Run Time\"\n PUBLIC PUBLIC := \"NewPublicVar\"\n PUBLIC &PUBLIC\n\n ? M->NewPublicVar\n\n M->NewPublicVar := \"Still Alive because I am PUBLIC\"\n\n ? M->PRIVATE + PRIVATE\n ? PRIVATE + M->PRIVATE\n\n ? BornInRunTimeVar\n\n &cMainPrivate := \"In SubFun()\"\n\n ? '\"cVar_1\" = [' + M->cVar_1 + '] in SubFun() PRIVATE'\n\n RETURN NIL\n\nSTATIC PROCEDURE TEST_Type()\n\n LOCAL v1, v2, v1a, v2a\n LOCAL bErr := ErrorBlock( {| e | Break( e ) } ), oE\n\n ?\n ? \"=========== Type() function =================\"\n v1 := \"UDF()\"\n ? \"Test for Type('UDF()') - should be 'UI': \", Type( v1 )\n v2 := \"UDF_STATIC()\"\n ? \"Test for Type('UDF_STATIC()') - should be 'U': \", Type( v2 )\n ? \"Test for &\" + \"'UDF()' - should print 'udf': \", &v1\n ? \"Test for &\" + \"'UDF_STATIC()' - should print 'ERROR: undefined function': \"\n BEGIN SEQUENCE\n ?? &v2\n RECOVER USING oE\n ? \"ERROR: \" + oE:Description\n END SEQUENCE\n ErrorBlock( bErr )\n\n v1 := \"UDF\"\n ? \"Test for Type('UDF') - should be 'U': \", Type( v1 )\n v2 := \"UDF_STATIC\"\n ? \"Test for Type('UDF_STATIC') - should be 'U': \", Type( v2 )\n\n v1a := \"UDF := 1\"\n ? \"Test for Type('UDF := 1') - should be 'N': \", Type( v1a )\n v2a := \"UDF_STATIC := 1\"\n ? \"Test for Type('UDF_STATIC := 1') - should be 'N': \", Type( v2a )\n\n ? \"=== after the assignment ===\"\n v1 := \"UDF\"\n ? \"Test for Type('UDF') - should be 'N': \", Type( v1 )\n v2 := \"UDF_STATIC\"\n ? \"Test for Type('UDF_STATIC') - should be 'N': \", Type( v2 )\n\n v1 := \"UDF()\"\n ? \"Test for Type('UDF()') - should be 'UI': \", Type( v1 )\n v2 := \"UDF_STATIC()\"\n ? \"Test for Type('UDF_STATIC()') - should be 'U': \", Type( v2 )\n\n\n ? \"=== declared public variable ===\"\n PUBLIC UDF2, UDF2_STATIC\n v1 := \"UDF2()\"\n ? \"Test for Type('UDF2()') - should be 'UI': \", Type( v1 )\n v2 := \"UDF2_STATIC()\"\n ? \"Test for Type('UDF2_STATIC()') - should be 'U': \", Type( v2 )\n\n v1 := \"UDF2\"\n ? \"Test for Type('UDF') - should be 'L': \", Type( v1 )\n v2 := \"UDF2_STATIC\"\n ? \"Test for Type('UDF_STATIC') - should be 'L': \", Type( v2 )\n\n ?\n\n RETURN\n\nSTATIC FUNCTION UDF_STATIC()\n\n RETURN \"udf_static\"\n\nFUNCTION UDF()\n\n RETURN \"udf\"\n\nSTATIC FUNCTION UDF2_STATIC()\n\n RETURN \"udf2_static\"\n\nFUNCTION UDF2()\n\n RETURN \"udf2\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/aliaslck.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "proc main()\n local cFile := \"_tst\"\n\n if ! hb_dbExists( cFile )\n dbCreate( cFile, { { \"F\", \"C\", 10, 0 } } )\n use _tst exclusive\n while LastRec() < 100\n dbAppend()\n enddo\n close\n endif\n ? \"Test exclusive access\"\n select 1\n use _tst exclusive alias tst1\n ? \"neterr->\", NetErr(), \"used->\", Used(), \"alias->\", Alias()\n select 2\n use _tst exclusive alias tst2\n ? \"neterr->\", NetErr(), \"used->\", Used(), \"alias->\", Alias()\n if Used()\n ? \"Error, exclusive mode in aliased work areas does not work\"\n else\n ? \"OK\"\n endif\n dbCloseAll()\n wait\n ?\n ? \"Test shared access\"\n select 1\n use _tst shared alias tst1\n ? \"neterr->\", NetErr(), \"used->\", Used(), \"alias->\", Alias()\n setLock(2)\n setLock(4)\n setLock(6)\n setLock(7)\n dspLock()\n select 2\n use _tst shared alias tst2\n ? \"neterr->\", NetErr(), \"used->\", Used(), \"alias->\", Alias()\n setLock(1)\n setLock(2)\n setLock(3)\n setLock(4)\n setLock(5)\n setLock(6)\n setLock(7)\n setLock(8)\n setLock(9)\n dspLock()\n wait\n ?\n select 1\n ? \"unlock all in\", Alias()\n dbUnlock()\n dspLock()\n select 2\n ? \"lock 10 records in\", Alias()\n setLock(1)\n setLock(2)\n setLock(3)\n setLock(4)\n setLock(5)\n setLock(6)\n setLock(7)\n setLock(8)\n setLock(9)\n dspLock()\n wait\n ?\n ? \"unlock 3, 5, 9 in\", Alias()\n dbRUnlock(3)\n dbRUnlock(5)\n dbRUnlock(9)\n dspLock()\n select 1\n ? \"lock 10 records in\", Alias()\n setLock(1)\n setLock(2)\n setLock(3)\n setLock(4)\n setLock(5)\n setLock(6)\n setLock(7)\n setLock(8)\n setLock(9)\n dspLock()\n wait\n dbCloseAll()\n hb_dbDrop( cFile )\nreturn\n\nproc setLock( n )\n ? \"locking record: \" + hb_ntos( n ) + \" ->\", dbRLock( n )\nreturn\n\nproc dspLock()\n local n\n ? Alias(), \"active locks:\"\n for each n in dbRLockList()\n ?? \"\", hb_ntos( n )\n next\nreturn"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour test program: tests/for.prg. Provides functions: ValFrom, ValTo, ValStep. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "STATIC s_nFrom\nSTATIC s_nTo\nSTATIC s_nStep\n\nPROCEDURE Main()\n\n LOCAL array\n LOCAL tmp, n\n\n ? \"Testing Harbour For Next loops.\"\n\n array := { ;\n { 1, 10, 1 }, ;\n { 10, 1, -1 }, ;\n { 1, 10, -1 }, ;\n { 10, 1, 1 }, ;\n { 1, 10, 4 }, ;\n { 10, 1, -4 }, ;\n { 1, 10, -4 }, ;\n { 10, 1, 4 } }\n\n FOR tmp := 1 TO Len( array )\n\n s_nFrom := array[ tmp ][ 1 ]\n s_nTo := array[ tmp ][ 2 ]\n s_nStep := array[ tmp ][ 3 ]\n\n ? ;\n \" From:\", s_nFrom, ;\n \" To:\", s_nTo, ;\n \" Step:\", s_nStep\n\n FOR n := Eval( {|| ValFrom() } ) TO Eval( {|| ValTo() } ) STEP Eval( {|| ValStep() } )\n ? \"Exec\", n\n NEXT\n\n NEXT\n\n RETURN\n\nSTATIC FUNCTION ValFrom()\n\n ? \"From\"\n\n RETURN s_nFrom\n\nSTATIC FUNCTION ValTo()\n\n ? \"To\"\n\n RETURN s_nTo\n\nSTATIC FUNCTION ValStep()\n\n ? \"Step\"\n\n RETURN s_nStep"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/statics2.prg. Contains procedures: Test. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "STATIC uA, uB\n\nPROCEDURE Test()\n\n ? \"INSIDE statics2.prg\"\n ? \" static uA, uB\"\n ?\n ? \" ValType( uA ), ValType( uB ) =>\", ValType( uA ), \",\", ValType( uB )\n ? \" uA, uB =>\", uA, \",\", uB\n uA := \"a\"\n uB := \"b\"\n ? ' uA := \"a\"'\n ? ' uB := \"b\"'\n ? \" uA, uB =>\", uA, \",\", uB\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour Runtime Library file: src/rtl/color53.prg. Provides 14 functions including: GetClrPair, SetClrPair, GetPairPos, GetPairLen, GetClrFore. This file provides utility functions"}, {"role": "assistant", "content": "#ifdef HB_COMPAT_C53\n\nFUNCTION GetClrPair( cColor, nColor )\n\n LOCAL nPos\n\n IF ( nPos := GetPairPos( cColor, nColor ) ) == 0\n RETURN \"\"\n ENDIF\n\n RETURN SubStr( cColor, nPos, GetPairLen( cColor, nColor ) )\n\nFUNCTION SetClrPair( cColor, nColor, cNewColor )\n\n LOCAL nPos\n\n IF ( nPos := GetPairPos( cColor, nColor ) ) == 0\n RETURN \"\"\n ENDIF\n\n RETURN Stuff( cColor, nPos, GetPairLen( cColor, nColor ), cNewColor )\n\nFUNCTION GetPairPos( cColor, nColor )\n\n LOCAL nPos := 1\n LOCAL nSep\n LOCAL n\n\n FOR n := 2 TO nColor\n IF ( nSep := At( \",\", SubStr( cColor, nPos ) ) ) == 0\n RETURN 0\n ENDIF\n nPos += nSep\n NEXT\n\n RETURN nPos\n\nFUNCTION GetPairLen( cColor, nColor )\n\n LOCAL nPos\n LOCAL nLen\n\n IF ( nPos := GetPairPos( cColor, nColor ) ) == 0\n RETURN 0\n ENDIF\n\n RETURN iif( ( nLen := At( \",\", SubStr( cColor, nPos ) ) ) == 0, ;\n Len( cColor ) - nPos + 1, nLen - 1 )\n\nFUNCTION GetClrFore( cColor )\n\n LOCAL nPos\n\n IF ( nPos := At( \"/\", cColor ) ) == 0\n RETURN \"\"\n ENDIF\n\n RETURN Left( cColor, nPos - 1 )\n\nFUNCTION GetClrBack( cColor )\n\n LOCAL nPos\n\n IF ( nPos := At( \"/\", cColor ) ) == 0\n RETURN \"\"\n ENDIF\n\n RETURN SubStr( cColor, nPos + 1 )\n\nFUNCTION RadGrDefCo( cColor )\n RETURN iif( IsDefColor(), ;\n ApplyDefau( cColor, \"W/N\", \"W/N\", \"W+/N\" ), ;\n ApplyDefau( cColor, 3, 1, 4 ) )\n\nFUNCTION RadItDefCo( cColor )\n RETURN iif( IsDefColor(), ;\n ApplyDefau( cColor, \"W/N\", \"W+/N\", \"W+/N\", \"N/W\", \"W/N\", \"W/N\", \"W+/N\" ), ;\n ApplyDefau( cColor, 5, 5, 2, 2, 1, 1, 4 ) )\n\nFUNCTION ListBDefCo( cColor )\n RETURN iif( IsDefColor(), ;\n ApplyDefau( cColor, \"W/N\", \"W+/N\", \"W+/N\", \"N/W\", \"W/N\", \"W/N\", \"W+/N\" ), ;\n ApplyDefau( cColor, 5, 5, 5, 2, 3, 1, 4 ) )\n\nFUNCTION ComboDefCo( cColor )\n RETURN iif( IsDefColor(), ;\n ApplyDefau( cColor, \"W/N\", \"W+/N\", \"W+/N\", \"N/W\", \"W/N\", \"W/N\", \"W+/N\", \"W/N\" ), ;\n ApplyDefau( cColor, 5, 5, 5, 2, 3, 1, 4, 1 ) )\n\nFUNCTION CheckDefCo( cColor )\n RETURN iif( IsDefColor(), ;\n ApplyDefau( cColor, \"W/N\", \"W+/N\", \"W/N\", \"W+/N\" ), ;\n ApplyDefau( cColor, 5, 2, 1, 4 ) )\n\nFUNCTION ButtnDefCo( cColor )\n RETURN iif( IsDefColor(), ;\n ApplyDefau( cColor, \"W/N\", \"N/W\", \"W+/N\", \"W+/N\" ), ;\n ApplyDefau( cColor, 5, 2, 1, 4 ) )\n\nFUNCTION MenuDefCol( cColor )\n RETURN iif( IsDefColor(), ;\n ApplyDefau( cColor, \"N/W\", \"W/N\", \"W+/W\", \"W+/N\", \"N+/W\", \"W/N\" ), ;\n ApplyDefau( cColor, 5, 2, 4, 2, 1, 3 ) )\n\nFUNCTION ApplyDefau( cColor, xClr1, xClr2, xClr3, xClr4, xClr5, xClr6, xClr7, xClr8 )\n\n LOCAL cSetColor\n LOCAL aSetColor\n LOCAL aNewcolor\n LOCAL nColors\n LOCAL cClrDefa\n LOCAL cClrToSet\n LOCAL cClrFore\n LOCAL cClrBack\n LOCAL xNewColor\n LOCAL n\n\n SWITCH PCount()\n CASE 0\n RETURN \"\"\n CASE 1\n RETURN cColor\n ENDSWITCH\n\n cSetColor := SetColor()\n\n aSetColor := { ;\n GetClrPair( cSetColor, 1 ), ;\n GetClrPair( cSetColor, 2 ), ;\n GetClrPair( cSetColor, 3 ), ;\n GetClrPair( cSetColor, 4 ), ;\n GetClrPair( cSetColor, 5 ) }\n\n aNewColor := { ;\n xClr1, ;\n xClr2, ;\n xClr3, ;\n xClr4, ;\n xClr5, ;\n xClr6, ;\n xClr7, ;\n xClr8 }\n\n nColors := PCount() - 1\n cClrDefa := cColor\n\n FOR n := 1 TO nColors\n\n xNewColor := aNewColor[ n ]\n cClrToSet := GetClrPair( cClrDefa, n )\n\n IF \"/\" $ cClrToSet\n\n IF ( cClrFore := GetClrFore( cClrToSet ) ) == \"\"\n cClrFore := GetClrFore( iif( HB_ISNUMERIC( xNewColor ), aSetColor[ xNewColor ], xNewColor ) )\n ENDIF\n IF ( cClrBack := GetClrBack( cClrToSet ) ) == \"\"\n cClrBack := GetClrBack( iif( HB_ISNUMERIC( xNewColor ), aSetColor[ xNewColor ], xNewColor ) )\n ENDIF\n\n cClrDefa := SetClrPair( cClrDefa, n, cClrFore + \"/\" + cClrBack )\n ELSE\n cClrDefa := SetClrPair( cClrDefa, n, iif( HB_ISNUMERIC( xNewColor ), aSetColor[ xNewColor ], xNewColor ) )\n ENDIF\n NEXT\n\n RETURN cClrDefa\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/mimetype.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbtip\"\n\nPROCEDURE Main( cFileName )\n\n IF ! HB_ISSTRING( cFileName )\n ? hb_StrFormat( \"Usage: %1$s \", hb_ProgName() )\n ELSEIF hb_vfExists( cFileName )\n ? cFileName\n ?\n ? \"tip_MimeType()\", tip_MimeType( hb_MemoRead( cFileName ), \"application/octet-stream\" )\n ? \"tip_FileMimeType()\", tip_FileMimeType( cFileName, \"application/octet-stream\" )\n ? \"tip_FileNameMimeType()\", tip_FileNameMimeType( cFileName, \"application/octet-stream\" )\n ELSE\n ? \"File\", cFileName, \"doesn't exist.\"\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/oletst3.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\nPROCEDURE Main()\n\n LOCAL oObject\n\n BEGIN SEQUENCE WITH {|| Break() }\n oObject := CreateObject( \"MyOleServer\" )\n ? oObject:MyMethod( \"Hello\", 123, .T., ;\n { hb_DateTime(), 123.45, { Date(), 2, 3 } } )\n ? oObject:Property1\n oObject:Property1 := \"!!! >>>\" + Upper( oObject:Property1 ) + \"<<< !!!\"\n ? oObject:Property1\n RECOVER\n ? \"Can not access 'MyOleServer' OLE server.\"\n END SEQUENCE\n\n WAIT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/d2e.prg. Provides functions: ft_D2E. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#define _LOG10( num ) ( Log( num ) / Log( 10 ) )\n#define DEFAULT_PRECISION 6\n\nFUNCTION ft_D2E( nDec, nPrecision )\n\n LOCAL nExp\n\n __defaultNIL( @nPrecision, DEFAULT_PRECISION )\n\n IF nDec == 0\n nExp := 0\n ELSEIF Abs( nDec ) < 1\n nExp := Int( _LOG10( nDec ) ) - 1\n ELSE\n nExp := Int( _LOG10( Abs( nDec ) + 0.00001 ) ) \n ENDIF \n\n nDec /= 10 ^ nExp\n\n IF Round( Abs( nDec ), nPrecision ) >= 10\n nDec /= 10\n nExp++\n ENDIF \n\n RETURN LTrim( Str( nDec, nPrecision + 3, nPrecision ) ) + \"E\" + hb_ntos( nExp )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/rangerep.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of RangeRepl()\"\n ?\n\n ? ' RangeRepl( \"0\", \"9\", \"year2002.dbf\", \"?\" ) == \"year????.dbf\" ? --> \"' + ;\n RangeRepl( \"0\", \"9\", \"year2002.dbf\", \"?\" ) + '\"'\n ? ' RangeRepl( \"9\", \"0\", \"year2002.dbf\", \"?\" ) == \"????2??2????\" ? --> \"' + ;\n RangeRepl( \"9\", \"0\", \"year2002.dbf\", \"?\" ) + '\"'\n ? ' RangeRepl( \"0\", \"9\", \"yearcurr.dbf\", \"?\" ) == \"yearcurr.dbf\" ? --> \"' + ;\n RangeRepl( \"0\", \"9\", \"yearcurr.dbf\", \"?\" ) + '\"'\n\n ?\n ? \"End test of RangeRepl()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/htmutil.prg. Defines classes: JWindow. Provides functions: PutCounter. Contains 4 procedures. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"html.ch\"\n\n#include \"html.ch\"\n#include \"hbclass.ch\"\n\nTHREAD STATIC t_aGreek := {}\n\nPROCEDURE BackButton( cImage, oHtm )\n\n __defaultNIL( @cImage, \"back.gif\" )\n\n IF oHtm == NIL\n oHtm := HtmlPageObject()\n ENDIF\n\n IMAGE( cImage ) ;\n URL \"\" ;\n ONCLICK \"history.back()\" ;\n OF oHtm\n\n RETURN\n\nPROCEDURE BackFormButton( cImage, oForm )\n\n LOCAL oBut\n\n IF oForm == NIL\n oForm := HtmlFormObject()\n ENDIF\n\n IF cImage == NIL\n DEFINE BUTTON oBut ;\n NAME \"BackButton\" ;\n VALUE \"go Back\" ;\n ONCLICK \"history.back()\" ;\n IN oForm\n ELSE\n DEFINE IMAGE oBut ;\n NAME \"BackButton\" ;\n SOURCE( cImage ) ;\n ONCLICK \"history.back()\" ;\n IN oForm\n ENDIF\n\n RETURN\n\nFUNCTION PutCounter( oHtm, nNumber, cDir, nDigits, nWidth, bgColor, nBorder )\n\n LOCAL i\n LOCAL cStr := \"\"\n\n IF oHtm == NIL\n oHtm := HtmlPageObject()\n ENDIF\n\n __defaultNIL( @nNumber, 0 )\n __defaultNIL( @cDir, \"/images/counters/\" )\n __defaultNIL( @nWidth, 50 )\n __defaultNIL( @nDigits, Len( hb_ntos( nNumber ) ) )\n __defaultNIL( @nBorder, 1 )\n __defaultNIL( @BGCOLOR, \"black\" )\n\n IF HB_ISNUMERIC( nNumber )\n cStr := StrZero( nNumber, nDigits )\n ENDIF\n\n oHtm:Write( \"
\" )\n DEFINE TABLE ;\n BORDER( nBorder ) ;\n WIDTH( nWidth ) ;\n COLORBG( bgColor ) ;\n OF oHtm\n\n oHtm:newTableRow()\n oHtm:newTableCell( \"center\" )\n\n FOR i := 1 TO Len( cStr )\n IMAGE cDir + SubStr( cStr, i, 1 ) + \".gif\" ;\n BORDER 0 ;\n OF oHtm\n NEXT\n\n oHtm:endTableCell()\n oHtm:endTableRow()\n oHtm:endTable()\n\n oHtm:Write( \"
\" )\n\n RETURN NIL\n\nPROCEDURE HtmlBrowse( oHtm, cAction, lUseLinks )\n\n LOCAL i\n LOCAL n := 0\n LOCAL aFlds := dbStruct()\n LOCAL cAlign\n\n __defaultNIL( @cAction, \"confirm('RECORD: '+this.name+'\\nPlace your action here !!!')\" )\n __defaultNIL( @lUseLinks, .F. )\n\n\n oHtm:defineTable( FCount(), 1, 98 )\n\n oHtm:TableHead( \" ? \" )\n FOR i := 1 TO FCount()\n oHtm:TableHead( aFlds[ i, 1 ] )\n NEXT\n\n WHILE ! Eof()\n\n \n IF n == 0\n oHtm:newTableRow( \"lightyellow\" )\n n := 1\n ELSE\n oHtm:newTableRow( \"#9196A0\" )\n n := 0\n ENDIF\n\n \n oHtm:newTableCell( \"center\" )\n IF lUseLinks\n LINK ( cAction ) ;\n TEXT( hb_ntos( RecNo() ) ) ;\n OF oHtm\n ELSE\n PUSH BUTTON ;\n NAME \"'B\" + hb_ntos( RecNo() ) + \"'\" ;\n CAPTION \"' ? '\" ;\n ONCLICK ( cAction ) ;\n OF oHtm\n ENDIF\n oHtm:EndTableCell()\n\n \n FOR i := 1 TO Len( aFlds )\n cAlign := iif( aFlds[ i, 2 ] == \"N\", \"RIGHT\", \"CENTER\" )\n oHtm:newTableCell( cAlign, , , , \"black\" )\n oHtm:Write( Greek2Html( HtmlAny2Str( FieldGet( i ) ) ) )\n oHtm:EndTableCell()\n NEXT\n oHtm:endTableRow()\n SKIP\n ENDDO\n\n oHtm:endTable()\n\n RETURN\n\n#ifdef MYSQL\n\nPROCEDURE htmlBrowseSql( oHtm, cAction, lUseLinks, cTarget, oServer, oQuery )\n\n LOCAL i\n LOCAL p\n LOCAL n := 0\n LOCAL oCurRow\n\n LOCAL cAlign\n\n __defaultNIL( @cAction, \"confirm('RECORD: '+this.name+'\\nPlace your action here !!!')\" )\n __defaultNIL( @lUseLinks, .F. )\n\n\n oquery := oServer:query( 'Select\n oHtm:TableHead( \" ? \" )\n FOR i := 1 TO oQuery:FCount()\n oHtm:TableHead( oCurRow:FieldName( i ) )\n NEXT\n\n FOR p := 1 TO oQuery:LastRec()\n oCurRow := oQuery:getRow( P )\n \n IF n == 0\n oHtm:newTableRow( \"lightyellow\" )\n n := 1\n ELSE\n oHtm:newTableRow( \"#9196A0\" )\n n := 0\n ENDIF\n\n \n oHtm:newTableCell( \"center\" )\n IF lUseLinks\n LINK( cAction ) ;\n TEXT( hb_ntos( oQuery:RecNo() ) ) ;\n OF oHtm\n ELSE\n PUSH BUTTON ;\n NAME \"'B\" + hb_ntos( oQuery:RecNo() ) + \"'\" ;\n CAPTION \"' ? '\" ;\n ONCLICK( cAction ) ;\n OF oHtm\n ENDIF\n oHtm:EndTableCell()\n\n \n FOR i := 1 TO oquery:FCount()\n\n cAlign := iif( oCurRow:FieldType( i ) == \"N\", \"RIGHT\", \"CENTER\" )\n oHtm:newTableCell( cAlign, , , , \"black\" )\n oHtm:Write( Greek2Html( HtmlAny2Str( oCurRow:FieldGet( i ) ) ) )\n oHtm:EndTableCell()\n NEXT\n oHtm:endTableRow()\n IF ! oquery:Eof()\n oquery:skip()\n ENDIF\n\n NEXT\n oHtm:endTable()\n\n RETURN\n\n#endif\n\nCREATE CLASS JWindow\n\n VAR nH\n VAR Name INIT \"\"\n VAR oHtm\n VAR VarName INIT \"\"\n VAR URL INIT \"\"\n VAR Features INIT \"\"\n\n VAR ScreenX, ScreenY INIT 100\n VAR HEIGHT, WIDTH INIT 300\n VAR innerHeight, innerWidth, outerHeight INIT 0\n VAR alwaysRaised, alwaysLowered INIT .F.\n VAR Menubar, personalBar INIT .F.\n VAR location, directories, copyHistory INIT .F.\n VAR Toolbar INIT .F.\n VAR Status, TitleBar INIT .T.\n VAR Scrollbars, Resizable, dependent INIT .T.\n\n VAR TITLE\n VAR aScriptSRC\n VAR aServerSRC\n VAR BGIMAGE, BGCOLOR, fontColor\n VAR Style\n\n VAR onLoad\n VAR onUnLoad\n\n METHOD New( cVarName, cUrl, cName, x, y, w, h )\n\n METHOD setOnLoad( c ) INLINE ::onLoad := c\n\n METHOD setOnUnLoad( c ) INLINE ::onUnLoad := c\n\n METHOD Alert( c ) INLINE ::QOut( \"Alert('\" + c + \"')\" )\n\n METHOD confirm( c ) INLINE ::QOut( \"confirm('\" + c + \"')\" )\n\n METHOD SetSize( x, y, h, w )\n\n METHOD Write( c )\n\n METHOD lineBreak() INLINE ::QOut( \"
\" )\n\n METHOD Paragraph() INLINE ::QOut( \"

\" )\n\n METHOD Center( l ) INLINE ::QOut( iif( l, \"
\", \"
\" ) )\n\n METHOD bold( l ) INLINE ::QOut( iif( l, \"\", \"\" ) )\n\n METHOD Italic( l ) INLINE ::QOut( iif( l, \"\", \"\" ) )\n\n METHOD ULine( l ) INLINE ::QOut( iif( l, \"\", \"\" ) )\n\n METHOD Put()\n\n METHOD Begin()\n\n METHOD End()\n\n METHOD QOut( c )\n\n METHOD WriteLN( c ) INLINE ::QOut( c )\n\n METHOD SetFeatures( alwaysRaised, alwaysLowered, ;\n Resizable, Menubar, personalBar, ;\n dependent, location, directories, ;\n Scrollbars, Status, TitleBar, Toolbar, copyHistory )\n\n METHOD ImageURL( cImage, cUrl, nHeight, nBorder, ;\n cOnClick, cOnMsover, cOnMsout, ;\n cName, cAlt )\n\nENDCLASS\n\n\nMETHOD New( cVarName, cUrl, cName, x, y, w, h ) CLASS JWindow\n\n __defaultNIL( @cVarName, \"newWin\" )\n __defaultNIL( @cURL, \" \" )\n __defaultNIL( @cName, cVarName )\n __defaultNIL( @x, 100 )\n __defaultNIL( @y, 100 )\n __defaultNIL( @h, 300 )\n __defaultNIL( @w, 300 )\n\n ::nH := HtmlPageHandle()\n ::oHtm := HtmlPageObject()\n ::varName := cVarName\n ::URL := cUrl\n ::Name := cName\n\n ::ScreenX := x\n ::ScreenY := y\n ::height := h\n ::width := w\n\n\n RETURN Self\n\n\nMETHOD SetFeatures( alwaysRaised, alwaysLowered, ;\n Resizable, Menubar, personalBar, ;\n dependent, location, directories, ;\n Scrollbars, Status, TitleBar, Toolbar, copyHistory ) CLASS JWindow\n\n LOCAL cStr := \"\"\n\n __defaultNIL( @alwaysRaised, ::alwaysRaised )\n __defaultNIL( @alwaysLowered, ::alwaysLowered )\n __defaultNIL( @Resizable, ::Resizable )\n __defaultNIL( @Menubar, ::Menubar )\n __defaultNIL( @personalBar, ::personalBar )\n __defaultNIL( @dependent, ::dependent )\n __defaultNIL( @location, ::location )\n __defaultNIL( @directories, ::directories )\n __defaultNIL( @Scrollbars, ::Scrollbars )\n __defaultNIL( @Status, ::Status )\n __defaultNIL( @TitleBar, ::TitleBar )\n __defaultNIL( @Toolbar, ::Toolbar )\n __defaultNIL( @copyHistory, ::copyHistory )\n\n IF alwaysRaised\n cStr += \"alwaysraised=yes,\"\n ELSE\n cStr += \"alwaysraised=no,\"\n ENDIF\n IF alwaysLowered\n cStr += \"alwayslowered=yes,\"\n ELSE\n cStr += \"alwayslowered=no,\"\n ENDIF\n IF Resizable\n cStr += \"resizable=yes,\"\n ELSE\n cStr += \"resizable=no,\"\n ENDIF\n IF Menubar\n cStr += \"menubar=yes,\"\n ELSE\n cStr += \"menubar=no,\"\n ENDIF\n IF personalBar\n cStr += \"personalbar=yes,\"\n ELSE\n cStr += \"personalbar=no,\"\n ENDIF\n IF dependent"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/wordrepl.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of WordRepl()\"\n ?\n\n ? \" Simple tests:\"\n ? ' WordRepl( \"CC\", \"AABBCCDDEE\", \"XX\" ) == \"AABBXXDDEE\"? --> \"' + WordRepl( \"CC\", \"AABBCCDDEE\", \"XX\" ) + '\"'\n ? ' WordRepl( \"aa\", \"1aaaa\", \"ba\" ) == \"1abaa\" ? ------> \"' + WordRepl( \"aa\", \"1aaaa\", \"ba\" ) + '\"'\n ? ' WordRepl( \"aa\", \"1aaaa\", \"ba\", .T. ) == \"1baba\" ? ------> \"' + WordRepl( \"aa\", \"1aaaa\", \"ba\", .T. ) + '\"'\n ?\n\n ? \" Testing CSetAtMupa( .T. ) with lMode == .T.:\"\n CSetAtMupa( .T. )\n ? ' WordRepl( \"aa\", \"1aaaa\", \"ba\" ) == \"1abaa\" ? --> \"' + WordRepl( \"aa\", \"1aaaa\", \"ba\" ) + '\"'\n ? ' WordRepl( \"aa\", \"1aaaa\", \"ba\", .T. ) == \"1bbba\" ? --> \"' + WordRepl( \"aa\", \"1aaaa\", \"ba\", .T. ) + '\"'\n ?\n\n ? \"End test of WordRepl()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/profiler.prg. Contains 5 procedures. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n\nPROCEDURE Main()\n\n LOCAL oProfile := HBProfile():new()\n LOCAL n\n\n \n __SetProfiler( .T. )\n\n \n DrawScreen( \"Doing nothing for a couple of seconds\" )\n DoNothingForTwoSeconds()\n\n \n FOR n := 1 TO 500\n CallMe500Times()\n NEXT\n\n \n oProfile:gather()\n\n \n DrawScreen( \"All methods/functions called one or more times\" )\n MemoEdit( HBProfileReportToString():new( oProfile:callSort() ):generate( {| o | o:nCalls > 0 } ), 1,,,, .F. )\n\n \n DrawScreen( \"All methods/functions called one or more times, sorted by name\" )\n MemoEdit( HBProfileReportToString():new( oProfile:nameSort() ):generate( {| o | o:nCalls > 0 } ), 1,,,, .F. )\n\n \n DrawScreen( \"All methods/functions taking measurable time, sorted by time\" )\n MemoEdit( HBProfileReportToString():new( oProfile:timeSort() ):generate( {| o | o:nTicks > 0 } ), 1,,,, .F. )\n\n \n DrawScreen( \"TBrowse all methods/functions called one or more times\" )\n Browser( HBProfileReportToTBrowse():new( oProfile:callSort() ):generate( {| o | o:nCalls > 0 }, 1 ) )\n\n \n DrawScreen( \"Totals\" )\n @ 2, 0 SAY \" Total Calls: \" + Str( oProfile:totalCalls() )\n @ 3, 0 SAY \" Total Ticks: \" + Str( oProfile:totalTicks() )\n @ 4, 0 SAY \"Total Seconds: \" + Str( oProfile:totalSeconds() )\n\n RETURN\n\nSTATIC PROCEDURE DrawScreen( cTitle )\n\n CLS\n\n @ 0, 0 SAY PadR( cTitle, MaxCol() + 1 ) COLOR \"N/W\"\n\n RETURN\n\nPROCEDURE DoNothingForTwoSeconds()\n\n Inkey( 2 )\n\n RETURN\n\nPROCEDURE CallMe500Times()\n\n RETURN\n\nSTATIC PROCEDURE Browser( oBrowse )\n\n LOCAL lBrowsing := .T.\n\n DO WHILE lBrowsing\n\n oBrowse:forceStable()\n\n SWITCH Inkey( 0 )\n CASE K_ESC\n lBrowsing := .F.\n EXIT\n CASE K_DOWN\n oBrowse:down()\n EXIT\n CASE K_UP\n oBrowse:up()\n EXIT\n CASE K_LEFT\n oBrowse:left()\n EXIT\n CASE K_RIGHT\n oBrowse:right()\n EXIT\n CASE K_PGDN\n oBrowse:pageDown()\n EXIT\n CASE K_PGUP\n oBrowse:pageUp()\n EXIT\n\n \n ENDSWITCH\n\n ENDDO\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour header file: include/rddsys.ch. Defines constants: _RDDSYS_CH, RDT_FULL, RDT_TRANSFER, RDT_HIDDEN. Defines database/RDD constants"}, {"role": "assistant", "content": "#ifndef _RDDSYS_CH\n#define _RDDSYS_CH\n\n\n#define RDT_FULL 1\n#define RDT_TRANSFER 2\n#define RDT_HIDDEN 255\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/encqp.prg. Defines classes: TIPEncoderQP. Provides functions: tip_QPEncode, tip_QPDecode. This file provides network protocol implementations"}, {"role": "assistant", "content": "#pragma -gc3\n\n#include \"hbclass.ch\"\n\nCREATE CLASS TIPEncoderQP INHERIT TIPEncoder\n\n METHOD New() CONSTRUCTOR\n METHOD Encode( cData )\n METHOD Decode( cData )\n\nENDCLASS\n\nMETHOD New() CLASS TIPEncoderQP\n\n ::cName := \"quoted-printable\"\n\n RETURN Self\n\nMETHOD Encode( cData ) CLASS TIPEncoderQP\n RETURN tip_QPEncode( cData )\n\nMETHOD Decode( cData ) CLASS TIPEncoderQP\n RETURN tip_QPDecode( cData )\n\nFUNCTION tip_QPEncode( cData )\n\n LOCAL nPos\n LOCAL c\n LOCAL nLen\n LOCAL cString := \"\"\n LOCAL nLineLen := 0\n\n nLen := hb_BLen( cData )\n FOR nPos := 1 TO nLen\n c := hb_BSubStr( cData, nPos, 1 )\n IF c == Chr( 10 )\n cString += Chr( 13 ) + Chr( 10 )\n nLineLen := 0\n ELSEIF hb_BCode( c ) >= 127 .OR. ;\n c $ '=?!\"#$@[\\]^`{|}~' .OR. ;\n ( hb_BCode( c ) < 32 .AND. ! c $ Chr( 13 ) + Chr( 10 ) + Chr( 9 ) ) .OR. ;\n ( c $ \" \" + Chr( 9 ) .AND. hb_BSubStr( cData, nPos + 1, 1 ) $ Chr( 13 ) + Chr( 10 ) )\n IF nLineLen + 3 > 75\n cString += \"=\" + Chr( 13 ) + Chr( 10 )\n nLineLen := 0\n ENDIF\n cString += \"=\" + hb_NumToHex( hb_BCode( c ), 2 )\n nLineLen += 3\n ELSEIF ! c == Chr( 13 )\n IF nLineLen + 3 > 75\n cString += \"=\" + Chr( 13 ) + Chr( 10 )\n nLineLen := 0\n ENDIF\n cString += c\n nLineLen += 1\n ENDIF\n NEXT\n\n RETURN cString\n\nFUNCTION tip_QPDecode( cData )\n\n LOCAL nPos\n LOCAL c\n LOCAL nLen\n LOCAL cString := \"\"\n\n \n cData := StrTran( cData, \"=\" + Chr( 13 ) + Chr( 10 ) )\n cData := StrTran( cData, \"=\" + Chr( 10 ) ) \n\n nLen := hb_BLen( cData )\n FOR nPos := 1 TO nLen\n c := hb_BSubStr( cData, nPos, 1 )\n IF c == \"=\" .AND. hb_BLen( hb_BSubStr( cData, nPos + 1, 2 ) ) == 2\n cString += hb_BChar( hb_HexToNum( hb_BSubStr( cData, nPos + 1, 2 ) ) )\n nPos += 2\n ELSE\n cString += c\n ENDIF\n NEXT\n\n RETURN cString"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/netpv.prg. Provides functions: ft_NetPV. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_NetPV( nInitialInvestment, nInterestRate, aCashFlow, nNoOfCashFlows )\n\n LOCAL nNetPresentValue := 0\n\n __defaultNIL( @nNoOfCashFlows, Len( aCashFlow ) )\n\n AEval( aCashFlow, ;\n {| nElement, nElementNo | ;\n nNetPresentValue += nElement / ;\n ( ( 1 + ( nInterestRate / 100 ) ) ^ nElementNo ) }, ;\n 1, nNoOfCashFlows )\n\n RETURN nNetPresentValue -= nInitialInvestment"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour header file: tests/clipper.ch. Defines constants: __CLIPPER__, __PLATFORM__DOS. Declares 5 preprocessor translations. Defines color and display constants"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n\n#ifndef __XPP__\n #ifndef __CLIP__\n #ifndef FlagShip\n #define __CLIPPER__\n #endif\n #endif\n#endif\n\n#ifdef __CLIPPER__\n #ifndef __PLATFORM__DOS\n #define __PLATFORM__DOS\n #endif\n#endif\n\n#xtranslate hb_eol() => ( Chr( 13 ) + Chr( 10 ) )\n#xtranslate hb_ps() => \"\\\"\n#xtranslate hb_osFileMask() => \"*.*\"\n#xtranslate hb_run( ) => __Run( )\n\n#xtranslate hb_dbExists( ) => File( )\n#xtranslate hb_dbDrop( ) => FErase( )\n\n#xtranslate HB_ISSTRING( ) => ( ValType( ) $ \"CM\" )\n#xtranslate HB_ISNUMERIC( ) => ( ValType( ) == \"N\" )\n#xtranslate HB_ISLOGICAL( ) => ( ValType( ) == \"L\" )\n#xtranslate HB_ISARRAY( ) => ( ValType( ) == \"A\" )\n#xtranslate HB_ISOBJECT( ) => ( ValType( ) == \"O\" )\n#xtranslate HB_ISBLOCK( ) => ( ValType( ) == \"B\" )\n#xtranslate HB_ISEVALITEM( ) => ( ValType( ) == \"B\" )\n\n#xtranslate hb_keyCode( ) => Asc( )\n#xtranslate hb_keyChar( ) => Chr( )\n#xtranslate hb_keyPut( ) => __Keyboard( Chr( ) )\n#xtranslate hb_keyIns( ) => __Keyboard( Chr( ) )\n\n#xtranslate hb_BPeek( ,

) => Asc( SubStr( ,

, 1 ) )\n#xtranslate hb_BCode( ) => Asc( )\n#xtranslate hb_BChar( ) => Chr( )\n#xtranslate hb_BLen( ) => Len( )\n#xtranslate hb_BSubStr( ,

[, ] ) => SubStr( ,

, )\n#xtranslate hb_BLeft( , ) => Left( , )\n#xtranslate hb_BRight( , ) => Right( , )\n#xtranslate hb_BStrTran( , [, ] ) => StrTran( , , )\n\n#xtranslate hb_ntos( ) => LTrim( Str( ) )\n#xtranslate hb_SToD( [] ) => Eval( {| s, df, dt | df := Set( _SET_DATEFORMAT, \"YYYY/MM/DD\" ), dt := CToD( Stuff( Stuff( s, 7, 0, \"/\" ), 5, 0, \"/\" ) ), Set( _SET_DATEFORMAT, df ), dt }, )\n#xtranslate hb_Compiler() => \"C\"\n#xtranslate hb_cdpIsUTF8( [] ) => .F.\n#xtranslate hb_cdpCharMax() => 255\n#xtranslate hb_IsFunction( c ) => ( Type( c + \"()\" ) == \"UI\" )\n#xtranslate hb_NToColor( ) => LTrim( Str( Int( % 16 ), 2 ) ) + \"/\" + LTrim( Str( Int( / 16 ), 2 ) )\n#xtranslate __mvScope() => -1\n#xtranslate HB_SYMBOL_UNUSED( ) =>\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour header file: include/color.ch. Defines 6 constants including: _COLOR_CH, CLR_STANDARD, CLR_ENHANCED, CLR_BORDER, CLR_BACKGROUND. Defines color and display constants"}, {"role": "assistant", "content": "#ifndef _COLOR_CH\n#define _COLOR_CH\n\n\n#define CLR_STANDARD 0\n#define CLR_ENHANCED 1\n#define CLR_BORDER 2\n#define CLR_BACKGROUND 3\n#define CLR_UNSELECTED 4\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charodd.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CharOdd()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharOdd( \"1A2B3C4D5E\" ) == \"12345\" ? --> \"' + CharOdd( \"1A2B3C4D5E\" ) + '\"'\n ? ' CharOdd( \"1A2B3C4D5\" ) == \"12345\" ? --> \"' + CharOdd( \"1A2B3C4D5\" ) + '\"'\n\n ? \"End test of CharOdd()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hterrsys.prg. Provides functions: SetCorruptFunc, SetErrorFooter. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"error.ch\"\n#include \"cgi.ch\"\n\n#define DEF_ERR_HEADER \"Date : \" + DToC( Date() ) + \"
\" + \"Time : \" + Time() + \"
\"\n\n\n#command ? => ?? Chr( 13 ) + Chr( 10 ) ; ?? \n#command ?? => OutErr( )\n\nREQUEST HardCR\nREQUEST MemoWrit\n\nSTATIC s_bFixCorrupt\nSTATIC s_cErrFooter := \" \"\n\n\nFUNCTION SetCorruptFunc( bFunc )\n\n IF HB_ISBLOCK( bFunc )\n s_bFixCorrupt := bFunc\n ENDIF\n\n RETURN s_bFixCorrupt\n\nFUNCTION SetErrorFooter()\n\n RETURN s_cErrFooter"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charshr.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#else\n#define hb_ntos( n ) LTrim( Str( n ) )\n#define hb_BChar( n ) Chr( n )\n#endif\n\nPROCEDURE Main()\n\n LOCAL ni, cStr\n\n ctinit()\n\n ? \"Begin test of CharShr()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharShr( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 ) =='\n ? ' hb_BChar( 0 ) + hb_BChar( 0 ) + hb_BChar( 0 ) + hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) ? -->'\n\n ? ' '\n cStr := CharShr( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 )\n FOR ni := 1 TO Len( cStr )\n ?? \"hb_BChar( \" + hb_ntos( Asc( SubStr( cStr, ni, 1 ) ) ) + \" )\"\n IF ni < Len( cStr )\n ?? \" + \"\n ENDIF\n NEXT\n ?\n\n ? \"End test of CharShr()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour extra library: extras/hbxlsxml/xlsxml_s.prg. Defines classes: ExcelWriterXML_Sheet. This file provides spreadsheet generation capabilities"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nCREATE CLASS ExcelWriterXML_Sheet\n\n VAR id\n VAR cells INIT { => }\n VAR colWidth INIT { => }\n VAR rowHeight INIT { => }\n VAR URLs INIT { => }\n VAR mergeCells INIT { => }\n VAR comments INIT { => }\n VAR formatErrors INIT { => }\n VAR ldisplayRightToLeft INIT .F.\n\n METHOD new( id )\n METHOD getID()\n METHOD addError( cFunction, cMessage )\n METHOD getErrors()\n METHOD writeFormula( dataType, row, column, xData, style )\n METHOD writeString( row, column, xData, style )\n METHOD writeNumber( row, column, xData, style )\n METHOD writeDateTime( row, column, xData, style )\n METHOD writeData( type, row, column, xData, style, formula )\n METHOD displayRightToLeft()\n METHOD getSheetXML( handle )\n METHOD cellWidth( row, col, width )\n METHOD columnWidth( col, width )\n METHOD cellHeight( row, col, height )\n METHOD setRowHeight( row, height )\n METHOD cellMerge( row, col, width, height )\n METHOD addComment( row, col, comment, author )\n\nENDCLASS\n\nMETHOD ExcelWriterXML_Sheet:new( id )\n\n ::id := id\n\n RETURN SELF\n\nMETHOD ExcelWriterXML_Sheet:getID()\n\n RETURN ::id\n\nMETHOD ExcelWriterXML_Sheet:addError( cFunction, cMessage )\n\n ::formatErrors += { ;\n \"sheet\" => ::id, ;\n \"FUNCTION\" => cFunction, ;\n \"MESSAGE\" => cMessage }\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:getErrors()\n\n RETURN ::formatErrors\n\nMETHOD ExcelWriterXML_Sheet:writeFormula( dataType, row, column, xData, style )\n\n HB_SYMBOL_UNUSED( dataType )\n\n ::writeData( \"String\", row, column, \"\", style, xData )\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:writeString( row, column, xData, style )\n\n ::writeData( \"String\", row, column, xData, style )\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:writeNumber( row, column, xData, style )\n\n IF HB_ISNUMERIC( xData )\n ::writeData( \"Number\", row, column, AllTrim( Str( xData, 18, 6 ) ), style )\n ELSE\n ::writeData( \"String\", row, column, xData, style )\n ENDIF\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:writeDateTime( row, column, xData, style )\n\n IF HB_ISDATE( xData )\n ::writeData( \"DateTime\", row, column, DToC( xData ), style )\n ELSE\n ::writeData( \"String\", row, column, xData, style )\n ENDIF\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:writeData( type, row, column, xData, style, formula )\n\n LOCAL hcol, cell, styleID\n\n IF style != NIL\n IF HB_ISOBJECT( style )\n styleID := style:getID()\n ELSE\n styleID := style\n ENDIF\n ELSE\n styleID := NIL\n ENDIF\n\n cell := { ;\n \"type\" => type, ;\n \"style\" => styleID, ;\n \"data\" => xData, ;\n \"formula\" => formula }\n\n IF hb_HPos( ::cells, row ) > 0\n hcol := ::cells[ row ]\n hcol[ column ] := cell\n ::cells[ row ] := hcol\n ELSE\n hcol := { => }\n hcol[ column ] := cell\n ::cells[ row ] := hcol\n ENDIF\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:displayRightToLeft()\n\n ::ldisplayRightToLeft := .T.\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:getSheetXML( handle )\n\n LOCAL displayRightToLeft, ir, ic, xml, url\n LOCAL column, cell, xData, type, mergecell, comment, style, colIndex, colWidth\n LOCAL row, rowData, rowHeight, formula\n\n displayRightToLeft := iif( ::ldisplayRightToLeft, 'ss:RightToLeft=\"1\"', \"\" )\n\n xml := '\" + hb_eol()\n xml += \" \" + hb_eol()\n\n FWrite( handle, xml )\n xml := \"\"\n\n FOR EACH ic IN ::colWidth\n colIndex := ic:__enumKey()\n colWidth := ic:__enumValue()\n colIndex := hb_ntos( colIndex )\n colWidth := hb_ntos( colWidth )\n xml += ' ' + hb_eol()\n NEXT\n\n FWrite( handle, xml )\n xml := \"\"\n\n FOR EACH ir IN ::cells\n row := ir:__enumKey()\n rowData := ir:__enumValue()\n\n IF hb_HPos( ::rowHeight, row ) > 0\n rowHeight := 'ss:AutoFitHeight=\"0\" ss:Height=\"' + AllTrim( Str( ::rowHeight[ row ], 14, 2 ) ) + '\"'\n ELSE\n rowHeight := \"\"\n ENDIF\n\n xml += ' \" + hb_eol()\n FOR EACH ic IN rowData\n column := ic:__enumKey()\n cell := ic:__enumValue()\n IF Empty( cell[ \"formula\" ] )\n formula := \"\"\n ELSE\n formula := 'ss:Formula=\"' + cell[ \"formula\" ] + '\"'\n ENDIF\n IF Empty( cell[ \"style\" ] )\n style := \"\"\n ELSE\n style := 'ss:StyleID=\"' + cell[ \"style\" ] + '\"'\n ENDIF\n URL := \"\"\n mergeCell := \"\"\n IF hb_HPos( ::mergeCells, row ) > 0\n IF hb_HPos( ::mergeCells[ row ], column ) > 0\n mergeCell := 'ss:MergeAcross=\"' + hb_ntos( ::mergeCells[ row ][ column ][ \"width\" ] ) + '\" ss:MergeDown=\"' + hb_ntos( ::mergeCells[ row ][ column ][ \"height\" ] ) + '\"'\n ENDIF\n ENDIF\n comment := \"\"\n IF hb_HPos( ::comments, row ) > 0\n IF hb_HPos( ::comments[ row ], column ) > 0\n comment := ' ' + hb_eol()\n comment += ' \" + hb_eol()\n comment += ' ' + ::comments[ row ][ column ][ \"comment\" ] + \"\" + hb_eol()\n comment += \" \" + hb_eol()\n comment += \" \" + hb_eol()\n ENDIF\n ENDIF\n comment := \"\"\n type := cell[ \"type\" ]\n xData := cell[ \"data\" ]\n\n xml += \" \" + hb_eol()\n xml += ' '\n xml += StrToHtmlSpecial( xData )\n xml += \"\" + hb_eol()\n xml += comment\n xml += \" \" + hb_eol()\n\n NEXT\n xml += \" \" + hb_eol()\n\n FWrite( handle, xml )\n xml := \"\"\n NEXT\n\n xml += \"
\" + hb_eol()\n xml += \"
\" + hb_eol()\n\n FWrite( handle, xml )\n xml := \"\"\n\n RETURN xml\n\nMETHOD ExcelWriterXML_Sheet:cellWidth( row, col, width )\n\n HB_SYMBOL_UNUSED( row )\n HB_SYMBOL_UNUSED( col )\n\n hb_default( @width, 48 )\n\n ::columnWidth( col, width )\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:columnWidth( col, width )\n\n hb_default( @width, 48 )\n\n ::colWidth[ col ] := width\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:cellHeight( row, col, height )\n\n HB_SYMBOL_UNUSED( col )\n\n hb_default( @height, 12.5 )\n\n ::setRowHeight( row, height )\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:setRowHeight( row, height )\n\n hb_default( @height, 12.5 )\n\n ::rowHeight[ row ] := height\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:cellMerge( row, col, width, height )\n\n LOCAL haux := { => }\n\n IF hb_HPos( ::mergeCells, row ) > 0\n haux := ::mergeCells[ row ]\n ENDIF\n\n haux[ col ] := { ;\n \"width\" => width, ;\n \"height\" => height }\n\n ::mergeCells[ row ] := haux\n\n RETURN NIL\n\nMETHOD ExcelWriterXML_Sheet:addComment( row, col, comment, author )\n\n LOCAL haux := { => }\n\n haux[ col ] := { ;\n \"comment\" => comment, ;\n \"author\" => author }\n\n ::comments[ row ] := haux\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour contribution module 'hbnetio' (Network I/O operations): contrib/hbnetio/tests/netiot02.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbnetio\"\n\n\n#xtranslate net:( [] ) => ;\n netio_FuncExec( # [,] )\n#xtranslate net:[]:( [] ) => ;\n netio_FuncExec( [ # + ] \":\" + # [,] )\n#xtranslate net:[]::( [] ) => ;\n netio_FuncExec( [ # + ] \":\" + # + \":\" + # ;\n [,] )\n\n#xtranslate net:exists: => ;\n netio_ProcExists( # )\n#xtranslate net:exists:[]: => ;\n netio_ProcExists( [ # + ] \":\" + # )\n#xtranslate net:exists:[]:: => ;\n netio_ProcExists( [ # + ] \":\" + # + \":\" + # )\n\n\n#define NETSERVER \"127.0.0.1\"\n#define NETPORT 2941\n#define NETPASSWD \"topsecret\"\n\n\nPROCEDURE Main()\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n \n ? \"CONNECTING...\"\n ? \"netio_Connect():\", netio_Connect( NETSERVER, NETPORT,, NETPASSWD )\n ?\n \n ? \"Date() function is supported:\", net:exists:DATE\n ? \"QOut() function is supported:\", net:exists:QOUT\n ? \"hb_DateTime() function is supported:\", net:exists:HB_DATETIME\n ?\n \n net:QOut( Replicate( \"=\", 70 ) )\n net:QOut( \"This is RPC TEST\", hb_DateTime(), Version() )\n net:QOut( Replicate( \"=\", 70 ) )\n\n \n ? \"SERVER DATE:\", net:Date()\n ? \"SERVER TIME:\", net:Time()\n ? \"SERVER DATETIME:\", net:hb_DateTime()\n ? net:Upper( \"hello world !!!\" )\n ?\n\n \n ? \"netio_Disconnect():\", netio_Disconnect( NETSERVER, NETPORT )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/use.prg. Contains procedures: Main, mkTest. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"simpleio.ch\"\n\n#ifndef __HARBOUR__\n#include \"clipper.ch\"\n#endif\n\nPROCEDURE Main()\n\n ? OS(), Version()\n IF ! hb_dbExists( \"_tst.dbf\" )\n dbCreate( \"_tst\", { { \"F1\", \"C\", 1, 0 } } )\n ENDIF\n IF ! hb_dbExists( \"_tst2.dbf\" )\n dbCreate( \"_tst2\", { { \"F1\", \"C\", 1, 0 } } )\n ENDIF\n\n USE _tst NEW ALIAS \"ONE\" EXCLUSIVE\n ? Select(), Alias(), NetErr(), Used()\n ?\n\n mkTest( .T., \"NORDD\", , \"TWO\", .T., .F. )\n mkTest( .T., \"DBF\", , \"TWO\", .T., .F. )\n mkTest( .T., \"DBF\", \"\", \"TWO\", .T., .F. )\n mkTest( .T., \"DBF\", \"nofile\", \"TWO\", .T., .F. )\n mkTest( .T., \"DBF\", \"_tst2\", \"ONE\", .T., .F. )\n mkTest( .T., \"DBF\", \"_tst\", \"ONE\", .T., .F. )\n mkTest( .T., \"DBF\", \"_tst\", \"TWO\", .T., .F. )\n ?\n dbUseArea( .T., \"DBF\", \"_tst\", \"ONE\", .T., .F. )\n ? Select(), Alias(), NetErr(), Used()\n dbUseArea( .T., \"DBF\", \"_tst\", \"TWO\", .T., .F. )\n ? Select(), Alias(), NetErr(), Used()\n ?\n dbSelectArea( 1 )\n mkTest( .F., \"NORDD\", , \"TWO\", .T., .F. )\n ?\n\n dbCloseAll()\n\n hb_dbDrop( \"_tst.dbf\" )\n hb_dbDrop( \"_tst2.dbf\" )\n\n RETURN\n\nPROCEDURE mkTest( lNewArea, cRdd, cFile, cAlias, lShared, lReadOnly )\n\n LOCAL cbErr := ErrorBlock( {| oErr | Break( oErr ) } ), oErr\n\n NetErr( .F. )\n BEGIN SEQUENCE\n dbUseArea( lNewArea, cRdd, cFile, cAlias, lShared, lReadOnly )\n RECOVER USING oErr\n ? \"Error:\", oErr:subCode, oErr:description, oErr:operation, oErr:osCode\n END SEQUENCE\n ? Select(), Alias(), NetErr(), Used()\n ErrorBlock( cbErr )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/math.prg. Contains procedures: Main, WAIT4. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n SET DECIMAL TO 2\n CLS\n ? \"Test of mathematical functions\"\n ?\n\n ? \"Floor( 1.9 ) = 1 \n ? Space( 5 ), Floor( 1.9 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Floor( 1.1 ) = 1 \n ? Space( 5 ), Floor( 1.1 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Floor( 0.9 ) = 0 \n ? Space( 5 ), Floor( 0.9 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Floor( -0.1 ) = -1 \n ? Space( 7 ), Floor( -0.1 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Floor( -0.9 ) = -1 \n ? Space( 7 ), Floor( -0.9 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Floor( -1.1 ) = -2 \n ? Space( 7 ), Floor( -1.1 ), \" <-- CT for Harbour\"\n ?\n\n WAIT4()\n\n ? \"Ceiling( 1.9 ) = 2 \n ? Space( 7 ), Ceiling( 1.9 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Ceiling( 1.1 ) = 2 \n ? Space( 7 ), Ceiling( 1.1 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Ceiling( 0.9 ) = 1 \n ? Space( 7 ), Ceiling( 0.9 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Ceiling( -0.1 ) = 0 \n ? Space( 8 ), Ceiling( -0.1 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Ceiling( -0.9 ) = 0 \n ? Space( 8 ), Ceiling( -0.9 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Ceiling( -1.1 ) = -1 \n ? Space( 9 ), Ceiling( -1.1 ), \" <-- CT for Harbour\"\n ?\n\n WAIT4()\n\n ? \"Log10( 0.01 ) = -2.00 \n ? Space( 7 ), Log10( 0.01 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Log10( 2 ) = 0.30 \n ? Space( 3 ), Log10( 2 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Log10( 100 ) = 2.00 \n ? Space( 5 ), Log10( 100 ), \" <-- CT for Harbour\"\n ?\n ?\n\n ? \"Sign( 48335 ) = 1 \n ? Space( 6 ), Sign( 48335 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Sign( -258 ) = -1 \n ? Space( 6 ), Sign( -258 ), \" <-- CT for Harbour\"\n ?\n\n WAIT4()\n\n SET DECIMALS TO 0\n ? \"Fact( 1 ) = 1 \n ? Space( 2 ), Fact( 1 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Fact( 5 ) = 120 \n ? Space( 4 ), Fact( 5 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Fact( 21 ) = 51090942171709440000 \n ? Space( 12 ), Fact( 21 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Fact( 25 ) = -1 \n ? Space( 4 ), Fact( 25 ), \" <-- CT for Harbour\"\n ?\n\n ? \"Fact( 0 ) = 1 \n ? Space( 2 ), Fact( 0 ), \" <-- CT for Harbour\"\n ?\n\n ctexit()\n\n RETURN\n\nPROCEDURE WAIT4()\n\n ? \" Press any key\"\n Inkey( 0 )\n CLS\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main, netiosrv_Main. Harbour contribution module 'hbnetio' (Network I/O operations): contrib/hbnetio/utils/hbnetio/hbnetio.prg. Contains procedures: Main, netiosrv_Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n#include \"inkey.ch\"\n\n#include \"hbhrb.ch\"\n#include \"hbsocket.ch\"\n#include \"hbver.ch\"\n\n#include \"hbnetio.ch\"\n\n#define _NETIOSRV_IPV4_DEF \"0.0.0.0\"\n#define _NETIOSRV_PORT_DEF 2941\n\n#define _NETIOMGM_IPV4_DEF \"127.0.0.1\"\n#define _NETIOMGM_PORT_DEF 2940\n\n#define _RPC_FILTER \"HBNETIOSRV_RPCMAIN\"\n\n\n#ifdef HB_EXTERN\nREQUEST __HB_EXTERN__\n#endif\n\n#define _NETIOSRV_cName 1\n#define _NETIOSRV_nPort 2\n#define _NETIOSRV_cIFAddr 3\n#define _NETIOSRV_cRootDir 4\n#define _NETIOSRV_lRPC 5\n#define _NETIOSRV_cRPCFFileName 6\n#define _NETIOSRV_hRPCFHRB 7\n#define _NETIOSRV_lEncryption 8\n#define _NETIOSRV_lAcceptConn 9\n#define _NETIOSRV_lShowConn 10\n#define _NETIOSRV_lQuit 11\n#define _NETIOSRV_pListenSocket 12\n#define _NETIOSRV_hConnection 13\n#define _NETIOSRV_mtxConnection 14\n#define _NETIOSRV_hAllow 15\n#define _NETIOSRV_hBlock 16\n#define _NETIOSRV_mtxFilters 17\n#define _NETIOSRV_hNotifStream 18\n#define _NETIOSRV_mtxNotifStream 19\n#define _NETIOSRV_MAX_ 19\n\n#define _NETIOSRV_CONN_pConnection 1\n#define _NETIOSRV_CONN_nThreadID 2\n#define _NETIOSRV_CONN_tStart 3\n#define _NETIOSRV_CONN_hInfo 4\n#define _NETIOSRV_CONN_MAX_ 4\n\nPROCEDURE Main( ... )\n\n netiosrv_Main( .T., ... )\n\n RETURN\n\nPROCEDURE netiosrv_Main( lUI, ... )\n\n LOCAL netiosrv[ _NETIOSRV_MAX_ ]\n LOCAL netiomgm[ _NETIOSRV_MAX_ ]\n\n LOCAL cParam\n LOCAL cPassword\n LOCAL cPasswordManagement\n\n LOCAL cExt\n LOCAL cFile\n\n IF ! hb_mtvm()\n QOut( \"Multithread support required.\" )\n RETURN\n ENDIF\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n Set( _SET_TIMEFORMAT, \"hh:mm:ss.fff\" )\n\n HB_Logo()\n\n netiosrv[ _NETIOSRV_cName ] := \"Data\"\n netiosrv[ _NETIOSRV_nPort ] := _NETIOSRV_PORT_DEF\n netiosrv[ _NETIOSRV_cIFAddr ] := _NETIOSRV_IPV4_DEF\n netiosrv[ _NETIOSRV_cRootDir ] := hb_DirBase() + \"data\"\n netiosrv[ _NETIOSRV_lRPC ] := .F.\n netiosrv[ _NETIOSRV_lEncryption ] := .F.\n netiosrv[ _NETIOSRV_lAcceptConn ] := .T.\n netiosrv[ _NETIOSRV_lShowConn ] := .F.\n netiosrv[ _NETIOSRV_lQuit ] := .F.\n netiosrv[ _NETIOSRV_hConnection ] := { => }\n netiosrv[ _NETIOSRV_mtxConnection ] := hb_mutexCreate()\n netiosrv[ _NETIOSRV_hAllow ] := { => }\n netiosrv[ _NETIOSRV_hBlock ] := { => }\n netiosrv[ _NETIOSRV_mtxFilters ] := hb_mutexCreate()\n\n netiomgm[ _NETIOSRV_cName ] := \"Management\"\n netiomgm[ _NETIOSRV_nPort ] := _NETIOMGM_PORT_DEF\n netiomgm[ _NETIOSRV_cIFAddr ] := _NETIOMGM_IPV4_DEF\n netiomgm[ _NETIOSRV_cRootDir ] := \"*?:*?:\" \n netiomgm[ _NETIOSRV_lAcceptConn ] := .T.\n netiomgm[ _NETIOSRV_lShowConn ] := .F.\n netiomgm[ _NETIOSRV_hConnection ] := { => }\n netiomgm[ _NETIOSRV_mtxConnection ] := hb_mutexCreate()\n netiomgm[ _NETIOSRV_hAllow ] := { \"127.0.0.1\" => NIL, \"::1\" => NIL } \n netiomgm[ _NETIOSRV_hBlock ] := { => }\n netiomgm[ _NETIOSRV_mtxFilters ] := hb_mutexCreate()\n netiomgm[ _NETIOSRV_hNotifStream ] := { => }\n netiomgm[ _NETIOSRV_mtxNotifStream ] := hb_mutexCreate()\n\n FOR EACH cParam IN { ... }\n DO CASE\n CASE Lower( cParam ) == \"-a\"\n \n CASE Lower( Left( cParam, 5 ) ) == \"-noui\"\n lUI := .F.\n CASE Lower( Left( cParam, 6 ) ) == \"-port=\"\n netiosrv[ _NETIOSRV_nPort ] := Val( SubStr( cParam, 7 ) )\n CASE Lower( Left( cParam, 7 ) ) == \"-iface=\"\n netiosrv[ _NETIOSRV_cIFAddr ] := SubStr( cParam, 8 )\n CASE Lower( Left( cParam, 9 ) ) == \"-rootdir=\"\n netiosrv[ _NETIOSRV_cRootDir ] := SubStr( cParam, 10 )\n CASE Lower( Left( cParam, 6 ) ) == \"-pass=\"\n cPassword := SubStr( cParam, 7 )\n hb_StrClear( @cParam )\n CASE Lower( Left( cParam, 11 ) ) == \"-adminport=\"\n netiomgm[ _NETIOSRV_nPort ] := Val( SubStr( cParam, 12 ) )\n CASE Lower( Left( cParam, 12 ) ) == \"-adminiface=\"\n netiomgm[ _NETIOSRV_cIFAddr ] := SubStr( cParam, 13 )\n CASE Lower( Left( cParam, 11 ) ) == \"-adminpass=\"\n cPasswordManagement := SubStr( cParam, 12 )\n hb_StrClear( @cParam )\n CASE Lower( Left( cParam, 5 ) ) == \"-rpc=\"\n netiosrv[ _NETIOSRV_cRPCFFileName ] := SubStr( cParam, 6 )\n\n hb_FNameSplit( netiosrv[ _NETIOSRV_cRPCFFileName ], NIL, NIL, @cExt )\n\n cExt := Lower( cExt )\n\n SWITCH cExt\n CASE \".prg\"\n CASE \".hb\"\n CASE \".hrb\"\n EXIT\n OTHERWISE\n cExt := FileSig( cFile )\n ENDSWITCH\n\n SWITCH cExt\n CASE \".prg\"\n CASE \".hb\"\n cFile := hb_compileBuf( hb_argv( 0 ), \"-n2\", \"-w\", \"-es2\", \"-q0\", ;\n \"-D\" + \"__HBSCRIPT__HBNETIOSRV\", netiosrv[ _NETIOSRV_cRPCFFileName ] )\n IF cFile != NIL\n netiosrv[ _NETIOSRV_hRPCFHRB ] := hb_hrbLoad( HB_HRB_BIND_FORCELOCAL, cFile )\n ENDIF\n EXIT\n OTHERWISE\n netiosrv[ _NETIOSRV_hRPCFHRB ] := hb_hrbLoad( HB_HRB_BIND_FORCELOCAL, netiosrv[ _NETIOSRV_cRPCFFileName ] )\n EXIT\n ENDSWITCH\n\n netiosrv[ _NETIOSRV_lRPC ] := ! Empty( netiosrv[ _NETIOSRV_hRPCFHRB ] ) .AND. ! Empty( hb_hrbGetFunSym( netiosrv[ _NETIOSRV_hRPCFHRB ], _RPC_FILTER ) )\n IF ! netiosrv[ _NETIOSRV_lRPC ]\n netiosrv[ _NETIOSRV_cRPCFFileName ] := NIL\n netiosrv[ _NETIOSRV_hRPCFHRB ] := NIL\n ENDIF\n CASE Lower( cParam ) == \"-rpc\"\n netiosrv[ _NETIOSRV_lRPC ] := .T.\n CASE Lower( cParam ) == \"--version\"\n RETURN\n CASE Lower( cParam ) == \"-?\" .OR. ;\n Lower( cParam ) == \"-h\" .OR. ;\n Lower( cParam ) == \"-help\" .OR. ;\n Lower( cParam ) == \"--help\"\n HB_Usage()\n RETURN\n OTHERWISE\n netiosrv_LogEvent( hb_StrFormat( \"Warning: Unrecognized command-line parameter ignored: %1$s\", cParam ) )\n ENDCASE\n NEXT\n\n IF netiosrv_ConfLoad( netiosrv, netiomgm )\n netiosrv_LogEvent( hb_StrFormat( \"Configuration loaded: %1$s\", netiosrv_ConfName() ) )\n ENDIF\n\n hb_DirBuild( netiosrv[ _NETIOSRV_cRootDir ] )\n\n netiosrv[ _NETIOSRV_pListenSocket ] := netio_MTServer( ;\n netiosrv[ _NETIOSRV_nPort ], ;\n netiosrv[ _NETIOSRV_cIFAddr ], ;\n netiosrv[ _NETIOSRV_cRootDir ], ;\n iif( Empty( netiosrv[ _NETIOSRV_hRPCFHRB ] ), netiosrv[ _NETIOSRV_lRPC ], hb_hrbGetFunSym( netiosrv[ _NETIOSRV_hRPCFHRB ], _RPC_FILTER ) ), ;\n cPassword, ;\n NIL, ;\n NIL, ;\n {| pConnectionSocket | netiosrv_callback( netiomgm, netiosrv, pConnectionSocket, .F. ) } )\n\n netiosrv[ _NETIOSRV_lEncryption ] := ! Empty( cPassword )\n cPassword := NIL\n\n IF Empty( netiosrv[ _NETIOSRV_pListenSocket ] )\n netiosrv_LogEvent( \"Cannot start server.\" )\n ELSE\n netiosrv_LogEvent( \"Ready to accept connections.\" )\n\n IF ! Empty( cPasswordManagement )\n\n netiomgm[ _NETIOSRV_pListenSocket ] := netio_MTServer( ;\n netiomgm[ _NETIOSRV_nPort ], ;\n netiomgm[ _NETIOSRV_cIFAddr ], ;\n netiomgm[ _NETIOSRV_cRootDir ], ;\n { ;\n \"hbnetiomgm_ping\" => {| ... | .T. }, ;\n \"hbnetiomgm_setclientinfo\" => {| ... | netiomgm_rpc_setclientinfo( netiomgm, ... ) }, ;\n \"hbnetiomgm_sysinfo\" => {| ... | netiomgm_rpc_sysinfo() }, ;\n \"hbnetiomgm_serverconfig\" => {| ... | netiomgm_rpc_serverconfig( netiosrv, netiomgm ) }, ;\n \"hbnetiomgm_clientinfo\" => {| ... | netiomgm_rpc_clientinfo( netiosrv, netiomgm, ... ) }, ;\n \"hbnetiomgm_shutdown\" => {| ... | netiomgm_rpc_shutdown( netiosrv, netiomgm ) }, ;\n \"hbnetiomgm_conninfo\" => {| ... | netiomgm_rpc_conninfo( netiosrv ) }, ;\n \"hbnetiomgm_adminfo\" => {| ... | netiomgm_rpc_conninfo( netiomgm ) }, ;"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/base64.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbtip\"\n\n#include \"fileio.ch\"\n\nPROCEDURE Main( ... )\n\n LOCAL oEncoder, cEncoder := \"base64\"\n LOCAL lDecode := .F., lHelp := .F.\n LOCAL cData, nLen, cBuffer\n\n LOCAL hFileInput, nFileInput := hb_GetStdIn()\n LOCAL hFileOutput, nFileOutput := hb_GetStdOut()\n\n \n FOR EACH cData IN hb_AParams()\n\n SWITCH Lower( cData )\n CASE \"-h\"\n lHelp := .T.\n EXIT\n CASE \"-d\"\n lDecode := .T.\n EXIT\n CASE \"-q\"\n cEncoder := \"quoted-printable\"\n EXIT\n CASE \"-u\"\n cEncoder := \"url\"\n EXIT\n OTHERWISE\n IF hb_vfExists( cData ) .AND. nFileInput == hb_GetStdIn()\n IF ( hFileInput := hb_vfOpen( cData, FO_READ ) ) != NIL\n nFileInput := hb_vfHandle( hFileInput )\n ENDIF\n ELSEIF nFileOutput == hb_GetStdOut()\n IF ( hFileOutput := hb_vfOpen( cData, FO_CREAT + FO_TRUNC + FO_WRITE ) ) != NIL\n nFileOutput := hb_vfHandle( hFileOutput )\n ENDIF\n ELSE\n ? \"Wrong parameter\", cData\n ?\n lHelp := .T.\n ENDIF\n ENDSWITCH\n NEXT\n\n \n IF lHelp\n ? \"Usage:\"\n ? \"base64 [<] file-to-encode [>] encoded-file\"\n ? \"base64 -d [<] encoded-file [>] file-to-decode\"\n ? \"base64 -q [-d] to use quoted printable encoding/decoding\"\n ? \"base64 -u [-d] to use URL encoding/decoding.\"\n ? \"input/output redirection is optional\"\n ?\n RETURN\n ENDIF\n\n \n cData := \"\"\n cBuffer := Space( 1024 )\n DO WHILE ( nLen := FRead( nFileInput, @cBuffer, hb_BLen( cBuffer ) ) ) > 0\n cData += hb_BLeft( cBuffer, nLen )\n ENDDO\n IF hFileInput != NIL\n hb_vfClose( hFileInput )\n ENDIF\n\n \n oEncoder := TIPEncoder():New( cEncoder )\n IF lDecode\n cData := oEncoder:Decode( cData )\n ELSE\n cData := oEncoder:Encode( cData )\n ENDIF\n\n \n FWrite( nFileOutput, cData )\n IF hFileOutput != NIL\n hb_vfClose( hFileOutput )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: MenuItem. Harbour Runtime Library file: src/rtl/tmenuitm.prg. Defines classes: MenuItem. Provides functions: MenuItem, __MIColumn, __MIRow. This file implements menu system classes"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"button.ch\"\n\n#define IS_IN( str, list ) ( \"|\" + ( str ) + \"|\" $ \"|\" + ( list ) + \"|\" )\n\n\n#ifdef HB_COMPAT_C53\n\nCREATE CLASS MenuItem FUNCTION HBMenuItem\n\n EXPORTED:\n\n VAR cargo\n\n METHOD caption( cCaption ) SETGET\n METHOD checked( lChecked ) SETGET\n METHOD data( boData ) SETGET\n METHOD enabled( lEnabled ) SETGET\n METHOD id( nID ) SETGET\n METHOD message( cMessage ) SETGET\n METHOD shortcut( nShortcut ) SETGET\n METHOD style( cStyle ) SETGET\n\n VAR __col INIT -1 AS NUMERIC \n VAR __row INIT -1 AS NUMERIC \n VAR __issep INIT .F. AS LOGICAL \n\n METHOD isPopUp()\n\n METHOD Init( cCaption, boData, nShortcut, cMessage, nID ) \n\n PROTECTED:\n\n VAR cCaption INIT \"\"\n VAR lChecked INIT .F.\n VAR boData\n VAR lEnabled INIT .T.\n VAR nID\n VAR cMessage\n VAR nShortcut\n VAR cStyle INIT hb_UTF8ToStr( \"√\" ) + Chr( 16 ) \n\nENDCLASS\n\nMETHOD caption( cCaption ) CLASS MenuItem\n\n IF cCaption != NIL\n\n ::cCaption := __eInstVar53( Self, \"CAPTION\", cCaption, \"C\", 1001 )\n\n IF ::cCaption == HB_MENU_SEPARATOR_UNI\n ::__issep := .T.\n ::boData := NIL\n ::lChecked := ::lEnabled := .F.\n ELSE\n ::__issep := .F.\n ENDIF\n ENDIF\n\n RETURN ::cCaption\n\nMETHOD checked( lChecked ) CLASS MenuItem\n\n IF lChecked != NIL .AND. ! ::__issep\n ::lChecked := __eInstVar53( Self, \"CHECKED\", lChecked, \"L\", 1001 )\n ENDIF\n\n RETURN ::lChecked\n\nMETHOD data( boData ) CLASS MenuItem\n\n IF boData != NIL\n IF HB_ISEVALITEM( boData )\n ::boData := boData\n ELSE\n ::boData := __eInstVar53( Self, \"DATA\", boData, \"O\", 1001, {|| IS_IN( boData:ClassName(), \"POPUPMENU|HB_POPUPMENU\" ) } )\n ENDIF\n ENDIF\n\n RETURN ::boData\n\nMETHOD enabled( lEnabled ) CLASS MenuItem\n\n IF lEnabled != NIL .AND. ! ::__issep\n ::lEnabled := __eInstVar53( Self, \"ENABLED\", lEnabled, \"L\", 1001 )\n ENDIF\n\n RETURN ::lEnabled\n\nMETHOD id( nID ) CLASS MenuItem\n\n IF nID != NIL\n ::nID := __eInstVar53( Self, \"ID\", nID, \"N\", 1001 )\n ENDIF\n\n RETURN ::nID\n\nMETHOD message( cMessage ) CLASS MenuItem\n\n IF cMessage != NIL\n ::cMessage := __eInstVar53( Self, \"MESSAGE\", cMessage, \"C\", 1001 )\n ENDIF\n\n RETURN ::cMessage\n\nMETHOD shortcut( nShortcut ) CLASS MenuItem\n\n IF nShortcut != NIL\n ::nShortcut := __eInstVar53( Self, \"SHORTCUT\", nShortcut, \"N\", 1001 )\n ENDIF\n\n RETURN ::nShortcut\n\nMETHOD style( cStyle ) CLASS MenuItem\n\n IF cStyle != NIL\n ::cStyle := __eInstVar53( Self, \"STYLE\", cStyle, \"C\", 1001, {|| Len( cStyle ) == 2 } )\n ENDIF\n\n RETURN ::cStyle\n\nMETHOD isPopUp() CLASS MenuItem\n RETURN HB_ISOBJECT( ::data ) .AND. IS_IN( ::data:ClassName(), \"POPUPMENU|HB_POPUPMENU\" )\n\nMETHOD Init( cCaption, boData, nShortcut, cMessage, nID ) CLASS MenuItem\n\n ::data := boData\n ::nID := hb_defaultValue( nID, 0 )\n ::cMessage := hb_defaultValue( cMessage, \"\" )\n ::nShortcut := hb_defaultValue( nShortcut, 0 )\n ::caption := cCaption\n\n RETURN Self\n\nFUNCTION MenuItem( cCaption, boData, nShortcut, cMessage, nID )\n RETURN HBMenuItem():New( cCaption, boData, nShortcut, cMessage, nID )\n\n#ifdef HB_CLP_UNDOC\n\nFUNCTION __MIColumn( o, nColumn )\n\n IF HB_ISOBJECT( o ) .AND. o:ClassName() == \"MENUITEM\"\n\n IF HB_ISNUMERIC( nColumn )\n o:__col := nColumn\n ENDIF\n\n RETURN o:__col\n ENDIF\n\n RETURN -1\n\nFUNCTION __MIRow( o, nRow )\n\n IF HB_ISOBJECT( o ) .AND. o:ClassName() == \"MENUITEM\"\n\n IF HB_ISNUMERIC( nRow )\n o:__row := nRow\n ENDIF\n\n RETURN o:__row\n ENDIF\n\n RETURN -1\n\n#endif\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/t1.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL i := 0\n LOCAL cb := {|| QOut( \"test\" ) }\n\n WHILE i < 1000\n ? i\n Eval( cb )\n i++\n ENDDO\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/expomant.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL n\n\n ctinit()\n\n SET DECIMALS TO 15\n\n FOR n := 1 TO 1000\n ? Str( n, 20, 15 ) + \": \" + Str( Mantissa( n ), 20, 15 ) + \" \" + Str( Exponent( n ), 4 )\n ? Str( Sqrt( n ), 20, 15 ) + \": \" + Str( Mantissa( Sqrt( n ) ), 20, 15 ) + \" \" + Str( Exponent( Sqrt( n ) ), 4 )\n NEXT\n\n ? Str( Infinity( .T. ) ) + Str( Mantissa( Infinity( .T. ) ) ) + Str( Exponent( Infinity( .T. ) ) )\n\n ? \" Infinity( .T. ): \" + Str( Mantissa( Infinity( .T. ) ), 20, 15 ) + \" \"\n ?? Str( Exponent( Infinity( .T. ) ), 4 )\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour Runtime Library file: src/rtl/hbfilehi.prg. Provides 10 functions including: hb_PathNormalize, hb_PathJoin, hb_PathRelativize, s_FN_ToArray, s_FN_FromArray. This file provides file I/O operations"}, {"role": "assistant", "content": "#define _ISDRIVESPEC( cDir ) ( ! Empty( hb_osDriveSeparator() ) .AND. Right( cDir, Len( hb_osDriveSeparator() ) ) == hb_osDriveSeparator() )\n\n\nFUNCTION hb_PathNormalize( cPath )\n\n LOCAL aDir\n LOCAL cDir\n\n IF ! HB_ISSTRING( cPath )\n RETURN \"\"\n ENDIF\n\n IF ! Empty( cPath )\n\n aDir := hb_ATokens( cPath, hb_ps() )\n\n FOR EACH cDir IN aDir DESCEND\n\n IF cDir == \".\" .OR. ;\n ( Empty( cDir ) .AND. ;\n ! cDir:__enumIsLast() .AND. ;\n ( cDir:__enumIndex() > 2 .OR. ;\n ( cDir:__enumIndex() == 2 .AND. ! Empty( aDir[ 1 ] ) ) ) )\n\n hb_ADel( aDir, cDir:__enumIndex(), .T. )\n\n ELSEIF !( cDir == \"..\" ) .AND. ;\n ! Empty( cDir ) .AND. ;\n ! _ISDRIVESPEC( cDir )\n\n IF ! cDir:__enumIsLast() .AND. ;\n aDir[ cDir:__enumIndex() + 1 ] == \"..\"\n hb_ADel( aDir, cDir:__enumIndex() + 1, .T. )\n hb_ADel( aDir, cDir:__enumIndex(), .T. )\n ENDIF\n ENDIF\n NEXT\n\n cPath := \"\"\n FOR EACH cDir IN aDir\n cPath += cDir\n IF ! cDir:__enumIsLast()\n cPath += hb_ps()\n ENDIF\n NEXT\n\n IF Empty( cPath )\n cPath := \".\" + hb_ps()\n ENDIF\n ENDIF\n\n RETURN cPath\n\nFUNCTION hb_PathJoin( cPathA, cPathR )\n\n LOCAL cDirA\n LOCAL cDirR, cDriveR, cNameR, cExtR\n\n IF ! HB_ISSTRING( cPathR )\n RETURN \"\"\n ENDIF\n\n IF ! HB_ISSTRING( cPathA ) .OR. Empty( cPathA )\n RETURN cPathR\n ENDIF\n\n hb_FNameSplit( cPathR, @cDirR, @cNameR, @cExtR, @cDriveR )\n\n IF ! Empty( cDriveR ) .OR. ( ! Empty( cDirR ) .AND. Left( cDirR, 1 ) $ hb_osPathDelimiters() )\n RETURN cPathR\n ENDIF\n\n IF Empty( cDirA := hb_FNameDir( cPathA ) )\n RETURN cPathR\n ENDIF\n\n RETURN hb_FNameMerge( cDirA + cDirR, cNameR, cExtR )\n\nFUNCTION hb_PathRelativize( cPathBase, cPathTarget, lForceRelative )\n\n LOCAL tmp\n\n LOCAL aPathBase\n LOCAL aPathTarget\n\n LOCAL cTestBase\n LOCAL cTestTarget\n\n LOCAL cTargetFileName\n\n IF ! HB_ISSTRING( cPathBase ) .OR. ! HB_ISSTRING( cPathTarget )\n RETURN \"\"\n ENDIF\n\n cPathBase := hb_PathJoin( hb_DirBase(), hb_DirSepAdd( cPathBase ) )\n cPathTarget := hb_PathJoin( hb_DirBase(), cPathTarget )\n\n \n aPathBase := s_FN_ToArray( cPathBase )\n aPathTarget := s_FN_ToArray( cPathTarget, @cTargetFileName )\n\n tmp := 1\n cTestBase := \"\"\n cTestTarget := \"\"\n DO WHILE tmp <= Len( aPathTarget ) .AND. tmp <= Len( aPathBase )\n cTestBase += aPathBase[ tmp ]\n cTestTarget += aPathTarget[ tmp ]\n IF ! hb_FileMatch( cTestBase, cTestTarget )\n EXIT\n ENDIF\n ++tmp\n ENDDO\n\n IF tmp > Len( aPathTarget ) .AND. tmp > Len( aPathBase )\n tmp--\n ENDIF\n\n IF tmp == Len( aPathBase )\n RETURN s_FN_FromArray( aPathTarget, tmp, cTargetFileName, \"\" )\n ENDIF\n\n \n IF ! Empty( hb_osDriveSeparator() ) .AND. ;\n tmp == 1 .AND. ( ;\n Right( aPathBase[ 1 ] , Len( hb_osDriveSeparator() ) ) == hb_osDriveSeparator() .OR. ;\n Right( aPathTarget[ 1 ], Len( hb_osDriveSeparator() ) ) == hb_osDriveSeparator() )\n RETURN cPathTarget\n ENDIF\n\n \n IF hb_defaultValue( lForceRelative, .T. ) .AND. ;\n hb_DirExists( cPathBase + ( cTestTarget := s_FN_FromArray( aPathTarget, tmp, cTargetFileName, Replicate( \"..\" + hb_ps(), Len( aPathBase ) - tmp ) ) ) )\n RETURN cTestTarget\n ENDIF\n\n RETURN cPathTarget\n\nSTATIC FUNCTION s_FN_ToArray( cPath, cFileName )\n\n LOCAL cDir, cName, cExt\n\n hb_FNameSplit( cPath, @cDir, @cName, @cExt )\n\n IF ! Empty( cName ) .OR. ! Empty( cExt )\n cFileName := cName + cExt\n ENDIF\n\n RETURN hb_ATokens( cDir, hb_ps() )\n\nSTATIC FUNCTION s_FN_FromArray( aPath, nFrom, cFileName, cDirPrefix )\n\n LOCAL nTo := Len( aPath )\n LOCAL cDir\n LOCAL tmp\n\n IF nFrom > Len( aPath ) .OR. nTo < 1\n RETURN \"\"\n ENDIF\n\n IF nFrom < 1\n nFrom := 1\n ENDIF\n\n cDir := \"\"\n FOR tmp := nFrom TO nTo\n cDir += aPath[ tmp ]\n IF nFrom < nTo\n cDir += hb_ps()\n ENDIF\n NEXT\n\n RETURN hb_FNameMerge( hb_DirSepDel( hb_DirSepAdd( cDirPrefix ) + cDir ), cFileName )\n\nFUNCTION hb_DirSepAdd( cDir )\n\n IF ! HB_ISSTRING( cDir )\n RETURN \"\"\n ENDIF\n\n IF ! Empty( cDir ) .AND. ;\n ! _ISDRIVESPEC( cDir ) .AND. ;\n ! Right( cDir, 1 ) == hb_ps()\n\n cDir += hb_ps()\n ENDIF\n\n RETURN cDir\n\nFUNCTION hb_DirSepDel( cDir )\n\n IF ! HB_ISSTRING( cDir )\n RETURN \"\"\n ENDIF\n\n IF Empty( hb_osDriveSeparator() )\n DO WHILE Len( cDir ) > 1 .AND. Right( cDir, 1 ) == hb_ps() .AND. ;\n ! cDir == hb_ps() + hb_ps()\n\n cDir := hb_StrShrink( cDir )\n ENDDO\n ELSE\n DO WHILE Len( cDir ) > 1 .AND. Right( cDir, 1 ) == hb_ps() .AND. ;\n ! cDir == hb_ps() + hb_ps() .AND. ;\n ! Right( cDir, Len( hb_osDriveSeparator() ) + 1 ) == hb_osDriveSeparator() + hb_ps()\n\n cDir := hb_StrShrink( cDir )\n ENDDO\n ENDIF\n\n RETURN cDir\n\nFUNCTION hb_DirSepToOS( cFileName )\n\n IF HB_ISSTRING( cFileName )\n RETURN StrTran( cFileName, iif( hb_ps() == \"\\\", \"/\", \"\\\" ), hb_ps() )\n ENDIF\n\n RETURN \"\"\n\nFUNCTION hb_DirBuild( cDir )\n\n LOCAL cDirTemp\n LOCAL cDirItem\n LOCAL tmp\n\n IF ! HB_ISSTRING( cDir )\n RETURN .F.\n ENDIF\n\n cDir := hb_PathNormalize( cDir )\n\n IF ! hb_DirExists( cDir )\n\n cDir := hb_DirSepAdd( cDir )\n\n IF ! hb_osDriveSeparator() == \"\" .AND. ;\n ( tmp := At( hb_osDriveSeparator(), cDir ) ) > 0\n cDirTemp := Left( cDir, tmp )\n cDir := SubStr( cDir, tmp + 1 )\n#ifdef __PLATFORM__WINDOWS\n ELSEIF hb_LeftEq( cDir, \"\\\\\" ) \n cDirTemp := Left( cDir, hb_At( \"\\\", cDir, 3 ) )\n cDir := SubStr( cDir, Len( cDirTemp ) + 1 )\n#endif\n ELSEIF hb_LeftEq( cDir, hb_ps() )\n cDirTemp := Left( cDir, 1 )\n cDir := SubStr( cDir, 2 )\n ELSE\n cDirTemp := \"\"\n ENDIF\n\n FOR EACH cDirItem IN hb_ATokens( cDir, hb_ps() )\n IF ! Right( cDirTemp, 1 ) == hb_ps() .AND. ! cDirTemp == \"\"\n cDirTemp += hb_ps()\n ENDIF\n IF ! cDirItem == \"\" \n cDirTemp += cDirItem\n IF hb_FileExists( cDirTemp )\n RETURN .F.\n ELSEIF ! hb_DirExists( cDirTemp )\n IF hb_DirCreate( cDirTemp ) != 0\n RETURN .F.\n ENDIF\n ENDIF\n ENDIF\n NEXT\n ENDIF\n\n RETURN .T.\n\nFUNCTION hb_DirUnbuild( cDir )\n\n LOCAL tmp\n\n IF ! HB_ISSTRING( cDir )\n RETURN .F.\n ENDIF\n\n IF hb_DirExists( cDir )\n\n cDir := hb_DirSepDel( cDir )\n\n DO WHILE ! Empty( cDir )\n IF hb_DirExists( cDir ) .AND. ;\n hb_DirDelete( cDir ) != 0\n RETURN .F.\n ENDIF\n IF ( tmp := RAt( hb_ps(), cDir ) ) == 0 \n EXIT\n ENDIF\n cDir := Left( cDir, tmp - 1 )\n IF ! hb_osDriveSeparator() == \"\" .AND. ;\n Right( cDir, Len( hb_osDriveSeparator() ) ) == hb_osDriveSeparator()\n EXIT\n ENDIF\n ENDDO\n ENDIF\n\n RETURN .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/nwsem.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#define INITIAL_SEMAPHORE_VALUE 2\n#define WAIT_SECONDS 1\n\nPROCEDURE Main()\n\n LOCAL nInitVal, nRc, nHandle, nValue, nOpenCnt\n\n CLS\n\n nInitVal := INITIAL_SEMAPHORE_VALUE\n ft_NWSemOpen( \"TEST\", nInitVal, @nHandle, @nOpenCnt )\n\n ? \"Waiting ten seconds...\"\n nRc := ft_NWSemWait( nHandle, 180 )\n ? \"Final nRc value = \" + Str( nRc )\n Inkey( 0 )\n IF nRc == 254\n ? \"Couldn't get the semaphore. Try again.\"\n QUIT\n ENDIF\n\n CLS\n\n @ 24, 0 SAY \"Any key to exit\"\n @ 0, 0 SAY \"Handle: \" + Str( nHandle )\n\n ft_NWSemEx( nHandle, @nValue, @nOpenCnt )\n WHILE .T.\n @ 23, 0 SAY \"Semaphore test -> Open at [\" + ;\n hb_ntos( nOpenCnt ) + ;\n \"] stations, value is [\" + ;\n hb_ntos( nValue ) + \"]\"\n\n IF Inkey( WAIT_SECONDS ) != 0\n EXIT\n ENDIF\n\n Tone( nHandle, .5 )\n ft_NWSemEx( nHandle, @nValue, @nOpenCnt )\n ENDDO\n\n ? \"Signal returns: \" + Str( ft_NWSemSig( nHandle ) )\n ? \"Close returns: \" + Str( ft_NWSemClose( nHandle ) )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour extra library: extras/httpsrv/_cookie.prg. Provides functions: uhttpd_CookieNew. This file implements server functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nMEMVAR _COOKIE\n\nFUNCTION uhttpd_CookieNew( cDomain, cPath, nExpireDays, nExpireSecs )\n RETURN uhttpd_Cookie():New( cDomain, cPath, nExpireDays, nExpireSecs )\n\nCLASS uhttpd_Cookie\n\n \n VAR aCookies INIT {} \n VAR cDomain\n VAR cPath INIT \"/\"\n VAR cExpire\n VAR lSecure INIT .F.\n VAR lHttpOnly\n VAR nExpireDays INIT 0\n VAR nExpireSecs INIT 7200 \n VAR lCookiesSent INIT .F.\n\n METHOD SetCookie( cCookieName, xValue, cDomain, cPath, cExpires, lSecure, lHttpOnly )\n METHOD DeleteCookie( cCookieName, cDomain, cPath, lSecure )\n METHOD DeleteAllCookies( cDomain, cPath, lSecure )\n METHOD GetCookie( cCookieName )\n METHOD IsCookie( cCookieName ) INLINE ::GetCookie( cCookieName ) != NIL\n METHOD IsCookies() INLINE ! Empty( ::aaCookieToSet )\n METHOD SetCookieDefaults( cDomain, cPath, nExpireDays, nExpireSecs )\n\nENDCLASS\n\n\nMETHOD SetCookieDefaults( cDomain, cPath, nExpireDays, nExpireSecs ) CLASS uhttpd_Cookie\n\n IF cDomain != NIL\n ::cDomain := cDomain\n ENDIF\n IF cPath != NIL\n ::cPath := cPath\n ENDIF\n IF nExpireDays != NIL\n ::nExpireDays := nExpireDays\n ENDIF\n IF nExpireSecs != NIL\n ::nExpireSecs := nExpireSecs\n ENDIF\n\n RETURN NIL\n\nMETHOD SetCookie( cCookieName, xValue, cDomain, cPath, cExpires, lSecure, lHttpOnly ) CLASS uhttpd_Cookie\n\n LOCAL cStr, nPos, nCookies\n\n __defaultNIL( @cDomain, ::cDomain )\n __defaultNIL( @cPath, ::cPath )\n __defaultNIL( @lHttpOnly, .F. )\n\n IF cExpires == NIL\n cExpires := uhttpd_DateToGMT( Date(), Time(), ::nExpireDays, ::nExpireSecs )\n ENDIF\n\n ::lHttpOnly := lHttpOnly\n\n IF xValue != NIL\n \n \n IF ( nPos := AScan( ::aCookies, {| e | e[ 1 ] == cCookieName } ) ) > 0\n ::aCookies[ nPos ][ 2 ] := uhttpd_UrlEncode( hb_CStr( xValue ) )\n ELSE\n AAdd( ::aCookies, { cCookieName, uhttpd_UrlEncode( hb_CStr( xValue ) ) } )\n ENDIF\n ELSE\n IF ( nPos := AScan( ::aCookies, {| e | e[ 1 ] == cCookieName } ) ) > 0\n hb_ADel( ::aCookies, nPos, .T. )\n ENDIF\n ENDIF\n\n \n cStr := \"\"\n nCookies := Len( ::aCookies )\n AEval( ::aCookies, {| e, i | cStr += e[ 1 ] + \"=\" + e[ 2 ] + iif( i < nCookies, \",\", \"\" ) } )\n\n \n IF cDomain != NIL\n cStr += \"; domain=\" + cDomain\n ENDIF\n IF cPath != NIL\n cStr += \"; path=\" + cPath\n ENDIF\n IF cExpires != NIL\n cStr += \"; expires=\" + cExpires\n ENDIF\n IF HB_ISLOGICAL( lSecure ) .AND. lSecure\n cStr += \"; secure\"\n ENDIF\n\n \n uhttpd_SetHeader( \"Set-Cookie\", cStr )\n\n RETURN NIL\n\nMETHOD DeleteCookie( cCookieName, cDomain, cPath, lSecure ) CLASS uhttpd_Cookie\n\n LOCAL cExpires := uhttpd_DateToGMT( Date() - 1 ) \n\n ::SetCookie( cCookieName, \"\", cDomain, cPath, cExpires, lSecure )\n\n RETURN NIL\n\nMETHOD DeleteAllCookies( cDomain, cPath, lSecure ) CLASS uhttpd_Cookie\n\n LOCAL cCookieName\n\n FOR EACH cCookieName IN _COOKIE:Keys\n \n ::DeleteCookie( cCookieName, cDomain, cPath, lSecure )\n NEXT\n\n RETURN NIL\n\nMETHOD GetCookie( cCookieName ) CLASS uhttpd_Cookie\n\n LOCAL cHeader, cRet\n LOCAL nPos := 1\n\n DO WHILE .T.\n IF ( cHeader := uhttpd_GetHeader( \"Set-Cookie\", @nPos ) ) != NIL\n IF cHeader == cCookieName\n cRet := cHeader\n EXIT\n ELSE\n nPos++\n ENDIF\n ELSE\n EXIT\n ENDIF\n ENDDO\n\n RETURN cRet"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/datecnfg.prg. Provides functions: FT_CAL. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#include \"simpleio.ch\"\n\nPROCEDURE Main()\n\n LOCAL nNum, dDate, aTestData, aTemp, cFY_Start, nDOW_Start\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" ) \n hb_langSelect( \"en\" )\n\n aTemp := ft_DateCnfg() \n cFY_Start := aTemp[ 1 ] \n nDOW_Start := aTemp[ 2 ] \n dDate := Date() - 500\n\n CLS\n ? \"Given Date: \"\n ?? dDate\n ?? \" cFY_Start: \" + cFY_Start\n ?? \" nDOW_Start:\" + Str( nDOW_Start, 2 )\n ? \"---- Fiscal Year Data -----------\"\n\n aTestData := ft_Year( dDate )\n ? \"FYYear \", aTestData[ 1 ] + \" \", aTestData[ 2 ], aTestData[ 3 ]\n\n aTestData := ft_Qtr( dDate )\n ? \"FYQtr \", aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n nNum := Val( SubStr( aTestData[ 1 ], 5, 2 ) )\n aTestData := ft_Qtr( dDate, nNum )\n ? \"FYQtr \" + Str( nNum, 2 ), aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n aTestData := ft_Month( dDate )\n ? \"FYMonth \", aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n nNum := Val( SubStr( aTestData[ 1 ], 5, 2 ) )\n aTestData := ft_Month( dDate, nNum )\n ? \"FYMonth \" + Str( nNum, 2 ), aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n aTestData := ft_Week( dDate )\n ? \"FYWeek \", aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n nNum := Val( SubStr( aTestData[ 1 ], 5, 2 ) )\n aTestData := ft_Week( dDate, nNum )\n ? \"FYWeek \" + Str( nNum, 2 ), aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n aTestData := ft_DayOfYr( dDate )\n ? \"FYDay \", aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n nNum := Val( SubStr( aTestData[ 1 ], 5, 3 ) )\n aTestData := ft_DayOfYr( dDate, nNum )\n ? \"FYDAY \" + Str( nNum, 3 ), aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n ?\n ? \"---- Accounting Year Data -------\"\n\n aTestData := ft_AcctYear( dDate )\n ? \"ACCTYear \", aTestData[ 1 ] + \" \", aTestData[ 2 ], aTestData[ 3 ], ;\n Str( ( aTestData[ 3 ] - aTestData[ 2 ] + 1 ) / 7, 3 ) + \" Weeks\"\n\n aTestData := ft_AcctQtr( dDate )\n ? \"ACCTQtr \", aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ], ;\n Str( ( aTestData[ 3 ] - aTestData[ 2 ] + 1 ) / 7, 3 ) + \" Weeks\"\n\n nNum := Val( SubStr( aTestData[ 1 ], 5, 2 ) )\n aTestData := ft_AcctQtr( dDate, nNum )\n ? \"ACCTQtr \" + Str( nNum, 2 ), aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n aTestData := ft_AcctMonth( dDate )\n ? \"ACCTMonth \", aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ], ;\n Str( ( aTestData[ 3 ] - aTestData[ 2 ] + 1 ) / 7, 3 ) + \" Weeks\"\n\n nNum := Val( SubStr( aTestData[ 1 ], 5, 2 ) )\n aTestData := ft_AcctMonth( dDate, nNum )\n ? \"ACCTMonth\" + Str( nNum, 2 ), aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n aTestData := ft_AcctWeek( dDate )\n ? \"ACCTWeek \", aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n nNum := Val( SubStr( aTestData[ 1 ], 5, 2 ) )\n aTestData := ft_AcctWeek( dDate, nNum )\n ? \"ACCTWeek \" + Str( nNum, 2 ), aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n aTestData := ft_DayOfYr( dDate, , .T. )\n ? \"ACCTDay \", aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n nNum := Val( SubStr( aTestData[ 1 ], 5, 3 ) )\n aTestData := ft_DayOfYr( dDate, nNum, .T. )\n ? \"ACCTDay \" + Str( nNum, 3 ), aTestData[ 1 ], aTestData[ 2 ], aTestData[ 3 ]\n\n WAIT\n\n FT_CAL( dDate )\n FT_CAL( dDate, 1 )\n\n RETURN\n\n\nSTATIC FUNCTION FT_CAL( dGivenDate, nType )\n\n LOCAL nTemp, dTemp, aTemp, cFY_Start, dStart, dEnd\n\n aTemp := ft_DateCnfg()\n cFY_Start := aTemp[ 1 ]\n\n IF dGivenDate == NIL .OR. !( ValType( dGivenDate ) $ \"NDT\" )\n dGivenDate := Date()\n ELSEIF HB_ISNUMERIC( dGivenDate )\n nType := dGivenDate\n dGivenDate := Date()\n ENDIF\n\n nType := iif( HB_ISNUMERIC( nType ), nType, 0 )\n\n IF nType == 0\n IF SubStr( cFY_Start, 6, 5 ) == \"01.01\"\n ? \" Calendar Month Calendar containing \" + DToC( dGivenDate )\n ELSE\n ? \" Fiscal Month Calendar containing \" + DToC( dGivenDate )\n ENDIF\n\n aTemp := ft_Month( dGivenDate )\n dStart := aTemp[ 2 ]\n dEnd := aTemp[ 3 ]\n aTemp[ 2 ] -= ft_DayToBoW( aTemp[ 2 ] )\n aTemp[ 3 ] += 6 - ft_DayToBoW( aTemp[ 3 ] )\n ELSE\n ? \" Accounting Month Calendar containing \" + DToC( dGivenDate )\n aTemp := ft_AcctMonth( dGivenDate )\n ENDIF\n\n ?\n dTemp := aTemp[ 2 ]\n\n FOR nTemp := 0 TO 6\n ?? PadC( CDoW( dTemp + nTemp ), 10 )\n NEXT\n\n ?\n WHILE dTemp <= aTemp[ 3 ]\n FOR nTemp := 1 TO 7\n ?? \" \"\n IF nType == 0 .AND. ( dTemp < dStart .OR. dTemp > dEnd )\n ?? Space( 8 )\n ELSE\n ?? dTemp\n ENDIF\n ?? \" \"\n dTemp++\n NEXT\n ?\n ENDDO\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/menuto.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#include \"ftmenuto.ch\"\n\nPROCEDURE Main()\n\n LOCAL nChoice := 1\n\n CLS\n\n \n @ 1, 1 PROMPT \"Menu choice #1\"\n\n \n @ 3, 1 PROMPT \"Menu choice #2\" COLOR \"W+/R,W+/B\"\n\n \n @ 5, 1 PROMPT \"Menu choice #3\" MESSAGE \"Go to lunch\"\n\n \n @ 7, 1 PROMPT \"Menu choice #4\" MESSAGE \"Drop Dead\" ;\n MSGROW 22 MSGCOL 4 MSGCOLOR \"GR+/N\"\n\n \n @ 11, 1 PROMPT \"Menu choice #6\" TRIGGER 13\n\n \n @ 13, 1 PROMPT \"Menu Choice #7\" TRIGGER 13 TRIGGERCOLOR \"R+/BG,G+/N\"\n\n \n @ 15, 1 PROMPT \"Menu Choice #8\" RIGHT 8 LEFT 8\n\n MENU TO nChoice\n\n ? nChoice\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/tests/xml1.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"xhb\"\n\n#include \"hbxml.ch\"\n\nPROCEDURE Main()\n\n LOCAL cFile := hb_DirBase() + \"test.xml\"\n LOCAL cString\n LOCAL cNote, cDiscount\n LOCAL oDoc, oBook, oIterator, oCurrent\n\n cString := MemoRead( cFile )\n\n IF Empty( cString )\n WAIT \"xml file unavailable\"\n RETURN\n ENDIF\n\n oDoc := TXMLDocument():New( cString, HBXML_STYLE_NOESCAPE )\n IF oDoc:nError != HBXML_ERROR_NONE\n WAIT \"xml file parsing error \" + hb_ntos( oDoc:nError )\n RETURN\n ENDIF\n\n oBook := oDoc:findfirst( \"book\" )\n IF oBook == NIL\n WAIT \"no books found\"\n RETURN\n ENDIF\n\n DO WHILE .T.\n\n IF \"id\" $ oBook:aAttributes\n ? \"book ID : \" + oBook:aAttributes[ \"id\" ]\n ELSE\n ? \"no attribute book ID\"\n ENDIF\n\n cNote := \"\"\n cDiscount := \"\"\n oIterator := TXMLIterator():New( oBook )\n\n DO WHILE .T.\n oCurrent := oIterator:Next()\n IF oCurrent == NIL\n ? \"end branch\"\n WAIT \"values : \" + cNote + \" \" + cDiscount\n EXIT\n ELSE\n ? \"current tag : \" + oCurrent:cName\n IF oCurrent:cName == \"note\"\n cNote := oCurrent:cData\n ELSEIF oCurrent:cName == \"discount\"\n cDiscount := oCurrent:cData\n ENDIF\n ENDIF\n ENDDO\n\n oBook := oDoc:findnext()\n IF oBook == NIL\n WAIT \"no more books found\"\n EXIT\n ENDIF\n\n ENDDO\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hbserv.ch. Defines 10 constants including: HB_SERVICE_CH, HB_SIGNAL_QUIT, HB_SIGNAL_INTERRUPT, HB_SIGNAL_REFRESH, HB_SIGNAL_MATHERR. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_SERVICE_CH\n#define HB_SERVICE_CH\n\n\n#define HB_SIGNAL_QUIT 0x0001\n#define HB_SIGNAL_INTERRUPT 0x0002\n#define HB_SIGNAL_REFRESH 0x0004\n#define HB_SIGNAL_MATHERR 0x0010\n#define HB_SIGNAL_FAULT 0x0020\n#define HB_SIGNAL_USER1 0x0040\n#define HB_SIGNAL_USER2 0x0080\n#define HB_SIGNAL_UNKNOWN 0xf000\n#define HB_SIGNAL_ALL 0xffff\n\n\n#define HB_SERVICE_CONTINUE 1\n#define HB_SERVICE_HANDLED 2\n#define HB_SERVICE_QUIT 3\n\n\n#define HB_SERVICE_OSSIGNAL 1\n#define HB_SERVICE_OSSUBSIG 2\n#define HB_SERVICE_OSERROR 3\n#define HB_SERVICE_ADDRESS 4\n#define HB_SERVICE_PROCESS 5\n#define HB_SERVICE_UID 6\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour header file: include/simpleio.ch. Defines constants: _SIMPLEIO_CH. Declares 4 preprocessor commands. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef _SIMPLEIO_CH\n#define _SIMPLEIO_CH\n\n#command ? [ ] => ( OutStd( hb_eol() ) [, OutStd( ) ] )\n#command ?? [ ] => OutStd( )\n\n#command ACCEPT TO => := StrTran( FReadStr( hb_GetStdIn(), 256 ), hb_eol() )\n#command ACCEPT TO => ? ; ACCEPT TO \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbtest' (Test framework utilities): contrib/hbtest/core.prg. Provides functions: ErrorMessage, XToStr, __StrToExp, __ByteIsDisplayable, __ByteEscape. Contains procedures: hbtest_Setup, hbtest_Call. This file provides utility functions"}, {"role": "assistant", "content": "#include \"error.ch\"\n\n#define TEST_RESULT_COL1_WIDTH 1\n#define TEST_RESULT_COL2_WIDTH 11\n#define TEST_RESULT_COL3_WIDTH 44\n#define TEST_RESULT_COL4_WIDTH 85\n\nTHREAD STATIC t_hParams := { => }\n\nPROCEDURE hbtest_Setup( cName, xValue )\n\n IF HB_ISSTRING( cName ) .AND. ! Empty( cName )\n IF PCount() > 1\n t_hParams[ cName ] := xValue\n ELSEIF cName $ t_hParams\n hb_HDel( t_hParams, cName )\n ENDIF\n ENDIF\n\n RETURN\n\nPROCEDURE hbtest_Call( cBlock, bBlock, xResultExpected )\n\n LOCAL xResult\n LOCAL oError\n LOCAL lPPError\n LOCAL lRTE\n LOCAL lFailed\n\n LOCAL bOut\n\n LOCAL cLangOld\n\n IF HB_ISSTRING( cBlock )\n lPPError := .F.\n ELSE\n cBlock := \"[Preprocessor error]\"\n lPPError := .T.\n ENDIF\n\n cLangOld := hb_langSelect( \"en\" ) \n\n BEGIN SEQUENCE WITH ErrorBlock( {| oError | Break( oError ) } )\n xResult := Eval( bBlock )\n lRTE := .F.\n RECOVER USING oError\n xResult := ErrorMessage( oError )\n lRTE := .T.\n END SEQUENCE\n\n hb_langSelect( cLangOld )\n\n IF lRTE\n lFailed := !( XToStr( xResult, .F. ) == XToStr( xResultExpected, .F. ) )\n ELSE\n IF !( ValType( xResult ) == ValType( xResultExpected ) )\n IF HB_ISSTRING( xResultExpected ) .AND. ValType( xResult ) $ \"ABOHPS\"\n lFailed := !( XToStr( xResult, .F. ) == xResultExpected )\n ELSE\n lFailed := .T.\n ENDIF\n ELSE\n lFailed := !( xResult == xResultExpected )\n ENDIF\n ENDIF\n\n IF lFailed .OR. lPPError .OR. hb_HGetDef( t_hParams, \"showall\", .T. )\n bOut := hb_HGetDef( t_hParams, \"output\", {| cMsg | OutStd( cMsg ) } )\n IF lFailed\n Eval( bOut, ;\n PadR( iif( lFailed, \"!\", \" \" ), TEST_RESULT_COL1_WIDTH ) + \" \" + ;\n PadR( ProcName( 1 ) + \"(\" + hb_ntos( ProcLine( 1 ) ) + \")\", TEST_RESULT_COL2_WIDTH ) + \" \" + ;\n RTrim( cBlock ) + ;\n hb_eol() + ;\n Space( 5 ) + \" Result: \" + XToStr( xResult, .F. ) + ;\n hb_eol() + ;\n Space( 5 ) + \"Expected: \" + XToStr( xResultExpected, .F. ) + ;\n hb_eol() )\n ELSE\n Eval( bOut, ;\n PadR( iif( lFailed, \"!\", \" \" ), TEST_RESULT_COL1_WIDTH ) + \" \" + ;\n PadR( ProcName( 1 ) + \"(\" + hb_ntos( ProcLine( 1 ) ) + \")\", TEST_RESULT_COL2_WIDTH ) + \" \" + ;\n PadR( cBlock, TEST_RESULT_COL3_WIDTH ) + \" -> \" + ;\n PadR( XToStr( xResult, .F. ), TEST_RESULT_COL4_WIDTH ) + \" | \" + ;\n XToStr( xResultExpected, .F. ) + ;\n hb_eol() )\n ENDIF\n ENDIF\n\n RETURN\n\nSTATIC FUNCTION ErrorMessage( oError )\n\n LOCAL cMessage := \"\"\n LOCAL tmp\n\n IF HB_ISNUMERIC( oError:severity )\n SWITCH oError:severity\n CASE ES_WHOCARES ; cMessage += \"M \" ; EXIT\n CASE ES_WARNING ; cMessage += \"W \" ; EXIT\n CASE ES_ERROR ; cMessage += \"E \" ; EXIT\n CASE ES_CATASTROPHIC ; cMessage += \"C \" ; EXIT\n ENDSWITCH\n ENDIF\n IF HB_ISNUMERIC( oError:genCode )\n cMessage += hb_ntos( oError:genCode ) + \" \"\n ENDIF\n IF HB_ISSTRING( oError:subsystem )\n cMessage += oError:subsystem + \" \"\n ENDIF\n IF HB_ISNUMERIC( oError:subCode )\n cMessage += hb_ntos( oError:subCode ) + \" \"\n ENDIF\n IF HB_ISSTRING( oError:description )\n cMessage += oError:description + \" \"\n ENDIF\n IF ! Empty( oError:operation )\n cMessage += \"(\" + oError:operation + \") \"\n ENDIF\n IF ! Empty( oError:filename )\n cMessage += \"<\" + oError:filename + \"> \"\n ENDIF\n IF HB_ISNUMERIC( oError:osCode )\n cMessage += \"OS:\" + hb_ntos( oError:osCode ) + \" \"\n ENDIF\n IF HB_ISNUMERIC( oError:tries )\n cMessage += \"#:\" + hb_ntos( oError:tries ) + \" \"\n ENDIF\n\n IF HB_ISARRAY( oError:Args )\n cMessage += \"A:\" + hb_ntos( Len( oError:Args ) ) + \":\"\n FOR tmp := 1 TO Len( oError:Args )\n cMessage += ValType( oError:Args[ tmp ] ) + \":\" + XToStr( oError:Args[ tmp ], .T. )\n IF tmp < Len( oError:Args )\n cMessage += \";\"\n ENDIF\n NEXT\n cMessage += \" \"\n ENDIF\n\n IF oError:canDefault .OR. ;\n oError:canRetry .OR. ;\n oError:canSubstitute\n\n cMessage += \"F:\"\n IF oError:canDefault\n cMessage += \"D\"\n ENDIF\n IF oError:canRetry\n cMessage += \"R\"\n ENDIF\n IF oError:canSubstitute\n cMessage += \"S\"\n ENDIF\n ENDIF\n\n RETURN cMessage\n\nSTATIC FUNCTION XToStr( xValue, lInString )\n\n SWITCH ValType( xValue )\n CASE \"N\" ; RETURN hb_ntos( xValue )\n CASE \"D\" ; RETURN iif( lInString, \"0d\" + iif( Empty( xValue ), \"00000000\", DToS( xValue ) ), 'hb_SToD( \"' + DToS( xValue ) + '\" )' )\n CASE \"U\" ; RETURN \"NIL\"\n CASE \"C\"\n CASE \"M\"\n xValue := __StrToExp( xValue )\n RETURN iif( lInString, xValue, '\"' + xValue + '\"' )\n CASE \"A\"\n CASE \"H\"\n CASE \"O\"\n IF ! lInString\n RETURN hb_ValToExp( xValue, .T. )\n ENDIF\n EXIT\n ENDSWITCH\n\n RETURN hb_CStr( xValue )\n\nSTATIC FUNCTION __StrToExp( cStr )\n\n LOCAL cResult := \"\"\n\n LOCAL nLen, nPos\n LOCAL cByte\n\n nLen := hb_BLen( cStr )\n FOR nPos := 1 TO nLen\n cByte := hb_BSubStr( cStr, nPos, 1 )\n IF ! __ByteIsDisplayable( cByte ) .OR. cByte == '\"'\n cResult += \"\\\" + __ByteEscape( hb_BCode( cByte ) )\n ELSE\n cResult += cByte\n ENDIF\n NEXT\n\n RETURN cResult\n\nSTATIC FUNCTION __ByteIsDisplayable( cByte )\n RETURN ;\n hb_BCode( cByte ) >= 32 .AND. ;\n hb_BCode( cByte ) < 128\n\nSTATIC FUNCTION __ByteEscape( nByte )\n\n LOCAL cResult\n LOCAL nExp\n\n IF nByte == 0\n RETURN \"0\"\n ELSE\n cResult := \"\"\n FOR nExp := 2 TO 0 STEP -1\n cResult += SubStr( \"01234567\", Int( nByte / ( 8 ^ nExp ) ) + 1, 1 )\n nByte %= 8 ^ nExp\n NEXT\n ENDIF\n\n RETURN cResult"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'gtwvg' (): contrib/gtwvg/3state.prg. Defines classes: Wvg3State. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\n#ifndef __DBG_PARTS__\n#xtranslate hb_traceLog( [] ) =>\n#endif\n\nCREATE CLASS Wvg3State INHERIT WvgWindow, WvgDataRef\n\n VAR autosize INIT .F.\n VAR caption INIT \"\"\n VAR pointerFocus INIT .T.\n VAR selection INIT .F.\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD destroy()\n\n METHOD setCaption( xCaption )\n\n ACCESS selected INLINE ::sl_lbClick\n ASSIGN selected( bBlock ) INLINE ::sl_lbClick := bBlock\n\n METHOD handleEvent( nMessage, aNM )\n\nENDCLASS\n\nMETHOD Wvg3State:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::style := WS_CHILD + BS_AUTO3STATE\n ::className := \"BUTTON\"\n ::objType := objType3State\n\n RETURN Self\n\nMETHOD Wvg3State:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::oParent:AddChild( Self )\n\n ::createControl()\n\n ::SetWindowProcCallback()\n\n IF ::visible\n ::show()\n ENDIF\n\n ::setCaption( ::caption )\n\n IF ::selection\n ::sendMessage( BM_SETCHECK, BST_CHECKED, 0 )\n ENDIF\n\n IF ::visible\n ::show()\n ENDIF\n\n ::editBuffer := wvg_Button_GetCheck( ::hWnd )\n\n RETURN Self\n\nMETHOD Wvg3State:handleEvent( nMessage, aNM )\n\n hb_traceLog( \" %s:handleEvent( %i )\", ::ClassName(), nMessage )\n\n DO CASE\n CASE nMessage == HB_GTE_COMMAND\n IF aNM[ NMH_code ] == BN_CLICKED\n ::editBuffer := wvg_Button_GetCheck( ::hWnd )\n\n IF HB_ISBLOCK( ::sl_lbClick )\n Eval( ::sl_lbClick, ::editBuffer, , Self )\n RETURN 0\n ENDIF\n ENDIF\n\n CASE nMessage == HB_GTE_CTLCOLOR\n IF HB_ISNUMERIC( ::clr_FG )\n wvg_SetTextColor( aNM[ 1 ], ::clr_FG )\n ENDIF\n IF HB_ISNUMERIC( ::hBrushBG )\n wvg_SetBkMode( aNM[ 1 ], 1 )\n RETURN ::hBrushBG\n ELSE\n RETURN wvg_GetCurrentBrush( aNM[ 1 ] )\n ENDIF\n\n ENDCASE\n\n RETURN 1\n\nMETHOD PROCEDURE Wvg3State:destroy()\n\n hb_traceLog( \" %s:destroy()\", ::ClassName() )\n\n ::WvgWindow:destroy()\n\n RETURN\n\nMETHOD Wvg3State:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n RETURN Self\n\nMETHOD Wvg3State:setCaption( xCaption )\n\n IF HB_ISSTRING( xCaption )\n ::caption := xCaption\n wvg_SendMessageText( ::hWnd, WM_SETTEXT, 0, ::caption )\n ENDIF\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/ctrand.prg. Provides functions: Random, Rand. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION Random( lMode )\n RETURN iif( HB_ISLOGICAL( lMode ) .AND. lMode, ;\n hb_RandomInt( -32768, 32767 ), hb_RandomInt( 0, 65535 ) )\n\nFUNCTION Rand( nStart )\n\n IF nStart != NIL\n hb_RandomSeed( nStart )\n ENDIF\n\n RETURN hb_Random()"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/dbtohtml.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbtip\"\n#require \"hbtest\"\n\nPROCEDURE Main()\n\n LOCAL oDoc, oNode, oTable, oRow, oCell\n LOCAL i, j\n\n IF ! hbtest_Table()\n ? \"Error: Test database couldn't be created\"\n RETURN\n ENDIF\n\n oDoc := THtmlDocument():New()\n\n \n oNode := oDoc:head + \"meta\"\n oNode:name := \"Generator\"\n oNode:content := \"THtmlDocument\"\n\n \n oNode := oDoc:body:h1\n oNode:text := \"My address book\"\n\n \n oNode := oDoc:body + \"p\"\n\n \n oNode := oNode + 'font size=\"5\"'\n oNode:text := \"This is a \"\n\n \n oNode := oNode + \"b\"\n\n \n oNode := oNode + 'font color=\"blue\"'\n oNode:text := \"sample \"\n\n \n oNode := oNode - \"font\"\n\n \n oNode := oNode - \"b\"\n\n oNode:text := \"database!\"\n\n \n oNode := oNode - \"font\"\n\n oNode := oNode + \"hr\"\n HB_SYMBOL_UNUSED( oNode )\n\n \n oTable := oDoc:body:table\n oTable:attr := 'border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"'\n\n oRow := oTable + 'tr bgcolor=\"lightcyan\"'\n FOR i := 1 TO FCount()\n oCell := oRow + \"th\"\n oCell:text := FieldName( i )\n oCell := oCell - \"th\"\n HB_SYMBOL_UNUSED( oCell )\n NEXT\n\n oRow := oRow - \"tr\"\n HB_SYMBOL_UNUSED( oRow )\n\n FOR i := 1 TO 10\n oRow := oTable + \"tr\"\n oRow:bgColor := iif( RecNo() % 2 == 0, \"lightgrey\", \"white\" )\n\n FOR j := 1 TO FCount()\n oCell := oRow + \"td\"\n oCell:text := FieldGet( j )\n oCell := oCell - \"td\"\n HB_SYMBOL_UNUSED( oCell )\n NEXT\n\n oRow := oRow - \"tr\"\n HB_SYMBOL_UNUSED( oRow )\n\n dbSkip()\n NEXT\n\n oNode := oDoc:body + \"hr\"\n HB_SYMBOL_UNUSED( oNode )\n oNode := oDoc:body + \"p\"\n\n oNode:text := \"10 records from database \" + Alias()\n\n dbCloseArea()\n\n IF oDoc:writeFile( \"address.html\" )\n ? \"File created:\", \"address.html\"\n ELSE\n ? \"Error:\", FError()\n ENDIF\n\n WAIT\n ? tip_HtmlToStr( oDoc:body:getText() )\n\n hb_run( \"address.html\" )\n\n hb_vfErase( \"address.html\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour header file: include/hbstrict.ch. Defines constants: HB_STRICT_CH_. Declares 1 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_STRICT_CH_\n#define HB_STRICT_CH_\n\n\n#translate if( , , ) => iif()\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour header file: include/hbmemvar.ch. Defines 8 constants including: HB_MEMVAR_CH_, HB_MV_NOT_FOUND, HB_MV_UNKNOWN, HB_MV_ERROR, HB_MV_PUBLIC. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_MEMVAR_CH_\n#define HB_MEMVAR_CH_\n\n\n#define HB_MV_NOT_FOUND -2 \n#define HB_MV_UNKNOWN -1 \n#define HB_MV_ERROR 0 \n#define HB_MV_PUBLIC 1 \n#define HB_MV_PRIVATE_GLOBAL 2 \n#define HB_MV_PRIVATE_LOCAL 4 \n#define HB_MV_PRIVATE 6 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour Runtime Library file: src/rtl/checkbox.prg. Defines classes: CheckBox. Provides functions: _CheckBox_, CheckBox. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"button.ch\"\n#include \"color.ch\"\n#include \"setcurs.ch\"\n\n\n#ifdef HB_COMPAT_C53\n\nCREATE CLASS CheckBox FUNCTION HBCheckBox\n\n EXPORTED:\n\n VAR cargo\n\n METHOD display()\n METHOD hitTest( nMRow, nMCol )\n METHOD killFocus()\n METHOD select( lState )\n METHOD setFocus()\n\n METHOD bitmaps( aBitmaps ) SETGET\n METHOD buffer() SETGET\n METHOD capCol( nCapCol ) SETGET\n METHOD capRow( nCapRow ) SETGET\n METHOD caption( cCaption ) SETGET\n METHOD col( nCol ) SETGET\n METHOD colorSpec( cColorSpec ) SETGET\n METHOD fBlock( bFBlock ) SETGET\n METHOD hasFocus() SETGET\n METHOD message( cMessage ) SETGET\n METHOD row( nRow ) SETGET\n METHOD sBlock( bSBlock ) SETGET\n METHOD style( cStyle ) SETGET\n METHOD typeOut() SETGET\n\n METHOD Init( nRow, nCol, cCaption ) \n\n PROTECTED:\n\n VAR aBitmaps INIT { \"check_f.bmu\", \"check_e.bmu\" }\n VAR lBuffer INIT .F.\n VAR nCapCol\n VAR nCapRow\n VAR cCaption\n VAR nCol\n VAR cColorSpec\n VAR bFBlock\n VAR lHasFocus INIT .F.\n VAR cMessage INIT \"\"\n VAR nRow\n VAR bSBlock\n VAR cStyle INIT hb_UTF8ToStr( \"[√ ]\" )\n\n VAR nCursor\n\nENDCLASS\n\nMETHOD setFocus() CLASS CheckBox\n\n IF ! ::lHasFocus\n ::nCursor := SetCursor( SC_NONE )\n ::lHasFocus := .T.\n ::display()\n\n IF HB_ISEVALITEM( ::bFBlock )\n Eval( ::bFBlock )\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD select( lState ) CLASS CheckBox\n\n LOCAL lOldState := ::lBuffer\n\n ::lBuffer := iif( HB_ISLOGICAL( lState ), lState, ! ::lBuffer )\n\n IF lOldState != ::lBuffer\n ::display()\n\n IF HB_ISEVALITEM( ::bSBlock )\n Eval( ::bSBlock )\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD killFocus() CLASS CheckBox\n\n IF ::lHasFocus\n ::lHasFocus := .F.\n\n IF HB_ISEVALITEM( ::bFBlock )\n Eval( ::bFBlock )\n ENDIF\n\n ::display()\n SetCursor( ::nCursor )\n ENDIF\n\n RETURN Self\n\nMETHOD hitTest( nMRow, nMCol ) CLASS CheckBox\n\n LOCAL nPosAccel\n LOCAL nLenCaption\n\n IF nMRow == ::nRow .AND. ;\n nMCol >= ::nCol .AND. ;\n nMCol < ::nCol + 3\n RETURN HTCLIENT\n ENDIF\n\n nLenCaption := Len( ::cCaption )\n\n IF ( nPosAccel := At( \"&\", ::cCaption ) ) > 0 .AND. ;\n nPosAccel < nLenCaption\n nLenCaption--\n ENDIF\n\n IF nMRow == ::nCapRow .AND. ;\n nMCol >= ::nCapCol .AND. ;\n nMCol < ::nCapCol + nLenCaption\n RETURN HTCAPTION\n ENDIF\n\n RETURN HTNOWHERE\n\nMETHOD display() CLASS CheckBox\n\n LOCAL cColor\n LOCAL cStyle := ::cStyle\n LOCAL cCaption\n LOCAL nPos\n\n DispBegin()\n\n hb_DispOutAt( ::nRow, ::nCol + 1, iif( ::lBuffer, SubStr( cStyle, 2, 1 ), SubStr( cStyle, 3, 1 ) ), ;\n hb_ColorIndex( ::cColorSpec, iif( ::lHasFocus, 1, 0 ) ) )\n\n cColor := hb_ColorIndex( ::cColorSpec, 2 )\n hb_DispOutAt( ::nRow, ::nCol, Left( cStyle, 1 ), cColor )\n hb_DispOutAt( ::nRow, ::nCol + 2, Right( cStyle, 1 ), cColor )\n\n IF ! Empty( cCaption := ::cCaption )\n\n IF ( nPos := At( \"&\", cCaption ) ) == 0\n ELSEIF nPos == Len( cCaption )\n nPos := 0\n ELSE\n cCaption := Stuff( cCaption, nPos, 1, \"\" )\n ENDIF\n\n IF ::lHasFocus\n cColor := hb_ColorIndex( ::cColorSpec, 3 )\n ENDIF\n\n hb_DispOutAt( ::nCapRow, ::nCapCol, cCaption, cColor )\n\n IF ! ::lHasFocus .AND. nPos != 0\n hb_DispOutAt( ::nCapRow, ::nCapCol + nPos - 1, SubStr( cCaption, nPos, 1 ), ;\n hb_ColorIndex( ::cColorSpec, 3 ) )\n ENDIF\n ENDIF\n\n DispEnd()\n\n RETURN Self\n\nMETHOD bitmaps( aBitmaps ) CLASS CheckBox\n\n IF aBitmaps != NIL\n ::aBitmaps := __eInstVar53( Self, \"BITMAPS\", aBitmaps, \"A\", 1001 )\n ENDIF\n\n RETURN ::aBitmaps\n\nMETHOD buffer() CLASS CheckBox\n RETURN ::lBuffer\n\nMETHOD capCol( nCapCol ) CLASS CheckBox\n\n IF nCapCol != NIL\n ::nCapCol := __eInstVar53( Self, \"CAPCOL\", nCapCol, \"N\", 1001 )\n ENDIF\n\n RETURN ::nCapCol\n\nMETHOD capRow( nCapRow ) CLASS CheckBox\n\n IF nCapRow != NIL\n ::nCapRow := __eInstVar53( Self, \"CAPROW\", nCapRow, \"N\", 1001 )\n ENDIF\n\n RETURN ::nCapRow\n\nMETHOD caption( cCaption ) CLASS CheckBox\n\n IF cCaption != NIL\n ::cCaption := __eInstVar53( Self, \"CAPTION\", cCaption, \"C\", 1001 )\n ENDIF\n\n RETURN ::cCaption\n\nMETHOD col( nCol ) CLASS CheckBox\n\n IF nCol != NIL\n ::nCol := __eInstVar53( Self, \"COL\", nCol, \"N\", 1001 )\n ENDIF\n\n RETURN ::nCol\n\nMETHOD colorSpec( cColorSpec ) CLASS CheckBox\n\n IF cColorSpec != NIL\n ::cColorSpec := __eInstVar53( Self, \"COLORSPEC\", cColorSpec, \"C\", 1001, ;\n {|| ! Empty( hb_ColorIndex( cColorSpec, 3 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 4 ) ) } )\n ENDIF\n\n RETURN ::cColorSpec\n\nMETHOD fBlock( bFBlock ) CLASS CheckBox\n\n IF PCount() > 0\n ::bFBlock := iif( bFBlock == NIL, NIL, __eInstVar53( Self, \"FBLOCK\", bFBlock, \"B\", 1001 ) )\n ENDIF\n\n RETURN ::bFBlock\n\nMETHOD hasFocus() CLASS CheckBox\n RETURN ::lHasFocus\n\nMETHOD message( cMessage ) CLASS CheckBox\n\n IF cMessage != NIL\n ::cMessage := __eInstVar53( Self, \"MESSAGE\", cMessage, \"C\", 1001 )\n ENDIF\n\n RETURN ::cMessage\n\nMETHOD row( nRow ) CLASS CheckBox\n\n IF nRow != NIL\n ::nRow := __eInstVar53( Self, \"ROW\", nRow, \"N\", 1001 )\n ENDIF\n\n RETURN ::nRow\n\nMETHOD sBlock( bSBlock ) CLASS CheckBox\n\n IF PCount() > 0\n ::bSBlock := iif( bSBlock == NIL, NIL, __eInstVar53( Self, \"SBLOCK\", bSBlock, \"B\", 1001 ) )\n ENDIF\n\n RETURN ::bSBlock\n\nMETHOD style( cStyle ) CLASS CheckBox\n\n IF cStyle != NIL\n ::cStyle := __eInstVar53( Self, \"STYLE\", cStyle, \"C\", 1001, {|| Len( cStyle ) == 0 .OR. Len( cStyle ) == 4 } )\n ENDIF\n\n RETURN ::cStyle\n\nMETHOD typeOut() CLASS CheckBox\n RETURN .F.\n\nMETHOD Init( nRow, nCol, cCaption ) CLASS CheckBox\n\n LOCAL cColor\n\n __defaultNIL( @cCaption, \"\" )\n\n ::caption := cCaption\n ::capRow := nRow\n ::capCol := nCol + 3 + 1\n ::row := nRow\n ::col := nCol\n\n IF IsDefColor()\n ::cColorSpec := \"W/N,W+/N,W/N,W+/N\"\n ELSE\n cColor := SetColor()\n ::cColorSpec := ;\n hb_ColorIndex( cColor, CLR_UNSELECTED ) + \",\" + ;\n hb_ColorIndex( cColor, CLR_ENHANCED ) + \",\" + ;\n hb_ColorIndex( cColor, CLR_STANDARD ) + \",\" + ;\n hb_ColorIndex( cColor, CLR_BACKGROUND )\n ENDIF\n\n RETURN Self\n\nFUNCTION _CheckBox_( lState, cCaption, cMessage, cColorSpec, bFBlock, bSBlock, cStyle, aBitmaps )\n\n LOCAL o := HBCheckBox():New( Row(), Col(), cCaption )\n\n o:select( lState )\n o:caption := cCaption\n o:message := cMessage\n o:colorSpec := cColorSpec\n o:fBlock := bFBlock\n o:sBlock := bSBlock\n o:style := cStyle\n o:bitmaps := aBitmaps\n\n RETURN o\n\nFUNCTION CheckBox( nRow, nCol, cCaption )\n RETURN HBCheckBox():New( nRow, nCol, cCaption )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/regexrpl.prg. Provides functions: hb_regexReplace. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#define MATCH_STRING 1\n#define MATCH_START 2\n#define MATCH_END 3\n\nFUNCTION hb_regexReplace( cRegex, cString, cReplace, lCaseSensitive, lNewLine, nMaxMatches, nGetMatch )\n\n LOCAL aMatches, aMatch\n LOCAL cReturn\n LOCAL nOffSet := 0\n LOCAL cSearch, nStart, nLenSearch, nLenReplace\n\n aMatches := hb_regexAll( cRegEx, cString, lCaseSensitive, lNewLine, nMaxMatches, nGetMatch, .F. )\n cReturn := cString\n\n IF ! Empty( aMatches )\n FOR EACH aMatch IN aMatches\n IF HB_ISARRAY( aMatch ) .AND. Len( aMatch ) >= 1 .AND. ;\n HB_ISARRAY( aMatch[ 1 ] )\n aMatch := aMatch[ 1 ]\n IF Len( aMatch ) == 3 \n cSearch := aMatch[ MATCH_STRING ]\n nStart := aMatch[ MATCH_START ]\n nLenSearch := Len( cSearch )\n nLenReplace := Len( cReplace )\n cReturn := Stuff( cReturn, nStart - nOffSet, nLenSearch, cReplace )\n nOffSet += nLenSearch - nLenReplace\n ENDIF\n ENDIF\n NEXT\n\n ENDIF\n\n RETURN cReturn"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/mt/mttest12.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "thread static t_var1 := { \"A\", \"B\", \"C\" }\nthread static t_var2 := { \"A\" => \"qwe\", \"B\" => \"asd\" }\nthread static t_var3 := 1235.567\nthread static t_var4 := \"text\"\n\nproc main()\ntestvar(\"initial main thread values\")\naadd( t_var1, \"X\" )\nt_var2[ \"X\" ] := \"zxc\"\nt_var3 += 100000\nt_var4 := upper( t_var4 )\ntestvar(\"modified main thread values\")\nhb_threadJoin( hb_threadStart( @thFunc() ) )\ntestvar(\"modified main thread values\")\nreturn\n\nproc testvar( cMsg )\n? cMsg\n? \"t_var1:\", hb_valtoExp( t_var1 )\n? \"t_var2:\", hb_valtoExp( t_var2 )\n? \"t_var3:\", hb_valtoExp( t_var3 )\n? \"t_var4:\", hb_valtoExp( t_var4 )\nwait\n?\nreturn\n\nproc thFunc()\ntestvar(\"initial child thread values\")\naadd( t_var1, \"Y\" )\nt_var2[ \"Y\" ] := \"abc\"\nt_var3 -= 500000\nt_var4 += \" CHANGED\"\ntestvar(\"modified child thread values\")\nreturn"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/setkeys.prg. Contains procedures: Main, SubMain. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n\nPROCEDURE Main()\n\n LOCAL GetList := {}\n LOCAL alpha, bravo, charlie, k\n LOCAL F8Active := .T.\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n CLS\n\n @ 2, 2 SAY \"Press to popup alert box of current get, not active if empty\"\n @ 3, 2 SAY \"Press to disable all setkeys, except to restore (uses hb_SetKeySave())\"\n @ 4, 2 SAY \"Press to test setkey w/ array, hb_SetKeyCheck(), and hb_SetKeyGet()\"\n @ 5, 2 SAY \"Press to active/deactive \"\n\n alpha := \"alpha \"\n bravo := 123\n charlie := Date()\n\n @ 10, 10 GET alpha\n @ 11, 10 GET bravo\n @ 12, 10 GET charlie\n\n SetKey( K_F10, {|| Alert( Transform( GetActive():varGet(), NIL ) ) }, ;\n {|| ! Empty( GetActive():varGet() ) } )\n SetKey( K_F9, {|| k := hb_SetKeySave( NIL ), ;\n SetKey( K_F9, {|| hb_SetKeySave( k ) } ) } )\n SetKey( K_F8, {|| SubMain() }, {|| F8Active } )\n SetKey( K_F7, {|| F8Active := ! F8Active } )\n\n READ\n ? alpha, bravo, charlie\n\n RETURN\n\nSTATIC PROCEDURE SubMain()\n\n LOCAL n\n LOCAL bF8Action, bF8Active\n LOCAL aKeyArray := { hb_keyCode( \"1\" ), hb_keyCode( \"2\" ), hb_keyCode( \"4\" ), hb_keyCode( \"5\" ) }\n\n bF8Action := hb_SetKeyGet( K_F8, @bF8Active )\n SetKey( K_F8, NIL )\n\n hb_SetKeyArray( aKeyArray, {| x | QOut( hb_keyChar( x ) ) } )\n DO WHILE ( n := Inkey( 0 ) ) != K_ESC\n IF hb_SetKeyCheck( n, ProcName(), ProcLine(), ReadVar() )\n ?? \" hit hot\"\n ELSE\n ? hb_keyChar( n )\n ?? \" hit cold\"\n ENDIF\n ENDDO\n\n hb_SetKeyArray( aKeyArray, NIL )\n SetKey( K_F8, bF8Action, bF8Active )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/ontick.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\nPROCEDURE Main()\n\n CLS\n\n ft_OnTick( {|| OutStd( hb_MilliSeconds(), hb_eol() ) } )\n\n Inkey( 0 )\n\n ft_OnTick( {|| OutStd( hb_MilliSeconds(), hb_eol() ) }, 18 )\n\n Inkey( 0 )\n\n ft_OnTick()\n\n Inkey( 0 )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/oletst4.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\nPROCEDURE Main()\n\n LOCAL oObject, oTime, oInfo\n LOCAL p1, p2, p3, p4, p5, p6, p7\n\n oObject := win_oleCreateObject( \"MyOleObjServer\" )\n\n IF ! Empty( oObject )\n oTime := oObject:timer()\n ? \"TIMER:\"\n ? \" date:\", oTime:date\n ? \" time:\", oTime:time\n ? \" now:\", oTime:now\n oInfo := oObject:info()\n ? \"INFO:\"\n ? \" os:\", oInfo:os\n ? \" ver:\", oInfo:ver\n ? \" compiler:\", oInfo:compiler\n ? \" build:\", oInfo:build\n ?\n ? \"REF:\", oObject:ref( @p1, @p2, @p3, @p4, @p5, @p6, @p7 )\n ? \" p1:\", hb_ValToExp( p1 )\n ? \" p2:\", hb_ValToExp( p2 )\n ? \" p3:\", hb_ValToExp( p3 )\n ? \" p4:\", hb_ValToExp( p4 )\n ? \" p5:\", p5:className() \n ? \" p6:\", hb_ValToExp( p6 )\n ? \" p7:\", hb_ValToExp( p7 )\n ELSE\n ? \"Can not access 'MyOleObjServer' OLE server.\"\n ENDIF\n\n WAIT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour extra library: extras/httpsrv/_cgifunc.prg. Provides 11 functions including: uhttpd_GetVars, uhttpd_SplitUrl, uhttpd_SplitString, uhttpd_URLEncode, uhttpd_URLDecode. This file implements server functionality"}, {"role": "assistant", "content": "#include \"error.ch\"\n#include \"fileio.ch\"\n\n\n#define CRLF ( Chr( 13 ) + Chr( 10 ) )\n#xtranslate Throw( ) => ( Eval( ErrorBlock(), ), Break( ) )\n\nMEMVAR _SERVER, _GET, _POST, _COOKIE, _REQUEST, _HTTP_REQUEST\n\nFUNCTION uhttpd_GetVars( cFields, cSeparator )\n\n LOCAL hHashVars := { => }\n LOCAL aField, cField, aFields\n LOCAL cName, xValue\n\n __defaultNIL( @cSeparator, \"&\" )\n\n aFields := uhttpd_Split( cSeparator, cFields )\n\n FOR EACH cField in aFields\n aField := uhttpd_Split( \"=\", cField, 1 )\n IF Len( aField ) == 1\n hHashVars[ aField[ 1 ] ] := NIL\n LOOP\n ELSEIF Len( aField ) != 2\n LOOP\n ENDIF\n\n cName := LTrim( aField[ 1 ] )\n xValue := uhttpd_UrlDecode( aField[ 2 ] )\n\n \n IF SubStr( cName, Len( cName ) - 1 ) == \"[]\"\n cName := SubStr( cName, 1, Len( cName ) - 2 )\n hHashVars[ cName ] := { xValue }\n ELSE\n \n \n IF hb_HPos( hHashVars, cName ) > 0\n IF ! HB_ISARRAY( hHashVars[ cName ] )\n \n hHashVars[ cName ] := { hHashVars[ cName ] }\n ENDIF\n AAdd( hHashVars[ cName ], xValue )\n ELSE\n hHashVars[ cName ] := xValue\n ENDIF\n\n ENDIF\n NEXT\n\n RETURN hHashVars\n\n\nFUNCTION uhttpd_SplitUrl( cUrl )\n\n LOCAL hUrl := { => }\n LOCAL nPos, cTemp, cUserNamePassword, cHostnamePort\n LOCAL cProto, cHost, cPort, nPort, cUser, cPass, cPath, cQuery, cFragment\n LOCAL cUri\n\n \n hb_HCaseMatch( hUrl, .F. )\n\n cTemp := cUrl\n cUri := \"\"\n\n \n nPos := At( \":\n IF nPos > 0\n cProto := Left( cTemp, nPos - 1 )\n \n cTemp := SubStr( cTemp, nPos + 3 )\n ELSE\n cProto := \"\"\n ENDIF\n\n cUri += cProto + iif( ! Empty( cProto ), \":\n\n \n nPos := At( \"@\", cTemp )\n IF nPos > 0\n cUserNamePassword := Left( cTemp, nPos - 1 )\n \n cTemp := SubStr( cTemp, nPos + 1 )\n \n nPos := At( \":\", cUserNamePassword )\n IF nPos > 0\n cUser := Left( cUserNamePassword, nPos - 1 )\n cPass := SubStr( cUserNamePassword, nPos + 1 )\n ELSE\n cUser := cUserNamePassword\n cPass := \"\"\n ENDIF\n ELSE\n cUser := \"\"\n cPass := \"\"\n ENDIF\n\n \n nPos := RAt( \"#\", cTemp )\n IF nPos > 0\n cFragment := SubStr( cTemp, nPos + 1 )\n\n \n cTemp := SubStr( cTemp, 1, nPos - 1 )\n\n ELSE\n cFragment := \"\"\n ENDIF\n\n \n nPos := RAt( \"?\", cTemp )\n IF nPos > 0\n cQuery := SubStr( cTemp, nPos + 1 )\n\n \n cTemp := SubStr( cTemp, 1, nPos - 1 )\n\n ELSE\n cQuery := \"\"\n ENDIF\n\n \n cUri += cTemp\n\n \n nPos := RAt( \"/\", cTemp )\n IF nPos > 0\n cPath := SubStr( cTemp, nPos )\n\n \n cTemp := SubStr( cTemp, 1, nPos - 1 )\n\n ELSE\n cPath := \"/\"\n ENDIF\n\n \n cHostnamePort := cTemp\n\n \n nPos := At( \":\", cHostnamePort )\n IF nPos > 0\n cHost := Left( cHostnamePort, nPos - 1 )\n cPort := SubStr( cHostnamePort, nPos + 1 )\n nPort := Val( cPort )\n IF nPort <= 0\n nPort := -1\n ENDIF\n ELSE\n cHost := cHostnamePort\n nPort := -1\n ENDIF\n\n \n hUrl[ \"SCHEME\" ] := cProto\n hUrl[ \"HOST\" ] := cHost\n hUrl[ \"PORT\" ] := nPort\n hUrl[ \"USER\" ] := cUser\n hUrl[ \"PASS\" ] := cPass\n hUrl[ \"PATH\" ] := cPath\n hUrl[ \"QUERY\" ] := cQuery\n hUrl[ \"FRAGMENT\" ] := cFragment\n hUrl[ \"URI\" ] := cURI\n\n \n hb_HAutoAdd( hUrl, .F. )\n\n RETURN hUrl\n\n\nFUNCTION uhttpd_SplitString( cString, cDelim, lRemDelim, nCount )\n\n LOCAL nEOLPos\n LOCAL cBuffer := cString\n LOCAL aLines := {}, cLine\n LOCAL nHowMany := 0\n\n __defaultNIL( @cDelim, ( Chr( 13 ) + Chr( 10 ) ) )\n __defaultNIL( @lRemDelim, .T. )\n __defaultNIL( @nCount, -1 )\n\n \n DO WHILE ( nEOLPos := At( cDelim, cBuffer ) ) > 0\n nHowMany++\n IF lRemDelim\n cLine := Left( cBuffer, nEOLPos - 1 )\n ELSE\n cLine := Left( cBuffer, ( nEOLPos + Len( cDelim ) ) - 1 )\n ENDIF\n \n AAdd( aLines, cLine )\n cBuffer := SubStr( cBuffer, nEOLPos + Len( cDelim ) )\n IF nCount > -1\n IF nHowMany >= nCount\n EXIT\n ENDIF\n ENDIF\n ENDDO\n\n \n IF Len( cBuffer ) > 0\n AAdd( aLines, cBuffer )\n ENDIF\n\n RETURN aLines\n\n\nFUNCTION uhttpd_URLEncode( cString, lComplete )\n\n#ifdef HB_USE_HBTIP\n\n __defaultNIL( @lComplete, .T. )\n\n RETURN TIPENCODERURL_ENCODE( cString, lComplete )\n#else\n LOCAL cRet := \"\", i, nVal, cChar\n\n __defaultNIL( @lComplete, .T. )\n\n FOR i := 1 TO Len( cString )\n cChar := SubStr( cString, i, 1 )\n DO CASE\n CASE cChar == \" \"\n cRet += \"+\"\n\n CASE ( cChar >= \"A\" .AND. cChar <= \"Z\" ) .OR. ;\n ( cChar >= \"a\" .AND. cChar <= \"z\" ) .OR. ;\n ( cChar >= \"0\" .AND. cChar <= \"9\" ) .OR. ;\n cChar == \".\" .OR. cChar == \",\" .OR. cChar == \"&\" .OR. ;\n cChar == \"/\" .OR. cChar == \";\" .OR. cChar == \"_\"\n cRet += cChar\n\n CASE iif( ! lComplete, cChar == \":\" .OR. cChar == \"?\" .OR. cChar == \"=\", .F. )\n cRet += cChar\n\n OTHERWISE\n nVal := Asc( cChar )\n cRet += \"%\" + hb_NumToHex( nVal )\n ENDCASE\n NEXT\n\n RETURN cRet\n\n\nFUNCTION uhttpd_URLDecode( cString )\n\n#ifdef HB_USE_HBTIP\n RETURN TIPENCODERURL_DECODE( cString )\n#else\n LOCAL cRet := \"\", i, cChar\n\n FOR i := 1 TO Len( cString )\n cChar := SubStr( cString, i, 1 )\n DO CASE\n CASE cChar == \"+\"\n cRet += \" \"\n\n CASE cChar == \"%\"\n i++\n cRet += Chr( hb_HexToNum( SubStr( cString, i, 2 ) ) )\n i++\n\n OTHERWISE\n cRet += cChar\n\n ENDCASE\n\n NEXT\n\n RETURN cRet\n#endif\n\n\nFUNCTION uhttpd_DateToGMT( dDate, cTime, nDayToAdd, nSecsToAdd )\n\n LOCAL aDays := { \"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\" }\n LOCAL aMonths := { \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" }\n\n __defaultNIL( @dDate, Date() )\n __defaultNIL( @cTime, Time() )\n __defaultNIL( @nDayToAdd, 0 )\n __defaultNIL( @nSecsToAdd, 0 )\n\n \n cTime := uhttpd_AddSecondsToTime( cTime, nSecsToAdd, @nDayToAdd )\n dDate += nDayToAdd\n\n RETURN ;\n aDays[ DoW( dDate ) ] + \", \" + ;\n StrZero( Day( dDate ), 2 ) + \" \" + ;\n aMonths[ Month( dDate ) ] + \" \" + ;\n StrZero( Year( dDate ), 4 ) + \" \" + ;\n cTime + \" GMT\"\n\n\nFUNCTION uhttpd_AddSecondsToTime( cTime, nSecsToAdd, nDaysAdded )\n\n LOCAL nOneDaySeconds := 86400 \n LOCAL cNewTime, nSecs\n\n __defaultNIL( @cTime, Time() )\n __defaultNIL( @nSecsToAdd, 0 )\n \n __defaultNIL( @nDaysAdded, 0 )\n\n IF nSecsToAdd != 0\n nSecs := Secs( cTime ) + nSecsToAdd\n nDaysAdded += Int( nSecs / nOneDaySeconds ) \n nSecs := nSecs - nDaysAdded\n cNewTime := TString( nSecs )\n ELSE\n cNewTime := cTime\n ENDIF\n\n RETURN cNewTime\n\nFUNCTION uhttpd_OutputString( cString, aTranslate, lProtected )\n\n LOCAL cHtml\n\n __defaultNIL( @lProtected, .F. )\n __defaultNIL( @aTranslate, { { '\"', \""\" }, { \" \", \" \" } } )\n\n \n IF lProtected\n cHtml := uhttpd_HtmlSpecialChars( cString )\n ELSE\n cHtml := uhttpd_TranslateStrings( cString, aTranslate )\n ENDIF\n \n\n RETURN cHtml\n\nFUNCTION uhttpd_HtmlSpecialChars( cString, cQuote_style )\n\n LOCAL aTranslations := { ;\n { \"&\", \"&\" }, ;\n { \"<\", \"<\" }, ;\n { \">\", \">\" } }\n\n RETURN uhttpd_HtmlConvertChars( cString, cQuote_style, aTranslations )\n\nFUNCTION uhttpd_HtmlConvertChars( cString, cQuote_style, aTranslations )\n\n __defaultNIL( @cQuote_style, \"ENT_COMPAT\" )\n\n DO CASE\n CASE cQuote_style == \"ENT_COMPAT\"\n AAdd( aTranslations, { '\"', \""\" } )\n CASE cQuote_style == \"ENT_QUOTES\"\n AAdd( aTranslations, { '\"', \""\" } )\n AAdd( aTranslations, { \"'\", \"'\" } )\n CASE cQuote_style == \"ENT_NOQUOTES\"\n ENDCASE\n\n RETURN uhttpd_TranslateStrings( cString, aTranslations )\n\nFUNCTION uhttpd_CRLF2BR( cString )\n\n LOCAL aTranslations := { ;\n { CRLF, \"
\" } }\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour utility program: utils/hbtest/rt_class.prg. Contains procedures: Main_CLASS. This file is part of the test framework"}, {"role": "assistant", "content": "#include \"rt_main.ch\"\n\n\n#include \"rt_vars.ch\"\n\n\n#include \"hbclass.ch\"\n\nMEMVAR objHolder, cDtorResult\n\nPROCEDURE Main_CLASS()\n\n LOCAL oValue, aRef\n\n PRIVATE objHolder, cDtorResult\n\n#ifdef __HARBOUR__\n\n \n HBTEST cDtorResult := \"\" IS \"\"\n HBTEST objHolder := NIL IS NIL\n oValue := DTORCLASS():NEW( 0 )\n HBTEST oValue:type IS 0\n HBTEST oValue := NIL IS NIL\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"No references to self.\"\n\n HBTEST cDtorResult := \"\" IS \"\"\n HBTEST objHolder := NIL IS NIL\n oValue := DTORCLASS():NEW( 1 )\n HBTEST oValue:type IS 1\n HBTEST oValue := NIL IS NIL\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"Reference to self in instance variable.\"\n\n HBTEST cDtorResult := \"\" IS \"\"\n HBTEST objHolder := NIL IS NIL\n oValue := DTORCLASS():NEW( 2 )\n HBTEST oValue:type IS 2\n HBTEST oValue := NIL IS \"E 45 BASE 1301 Object destructor failure (Reference to freed block) OS:0 #:0 \"\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"Reference to self in class variable.\"\n\n HBTEST cDtorResult := \"\" IS \"\"\n HBTEST objHolder := NIL IS NIL\n oValue := DTORCLASS():NEW( 3 )\n HBTEST oValue:type IS 3\n HBTEST oValue := NIL IS \"E 45 BASE 1301 Object destructor failure (Reference to freed block) OS:0 #:0 \"\n HBTEST ValType( objHolder ) IS \"A\"\n HBTEST Len( objHolder ) IS 0\n HBTEST cDtorResult IS \"Reference to self in private memvar.\"\n\n\n HBTEST cDtorResult := \"\" IS \"\"\n HBTEST objHolder := NIL IS NIL\n oValue := DTORCLASS():NEW( 0 )\n HBTEST oValue:type IS 0\n \n aRef := { oValue, NIL }; aRef[ 2 ] := aRef; aRef := NIL\n HBTEST oValue := NIL IS NIL\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"\"\n HBTEST hb_gcAll() IS NIL\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"No references to self.\"\n\n HBTEST cDtorResult := \"\" IS \"\"\n HBTEST objHolder := NIL IS NIL\n oValue := DTORCLASS():NEW( 1 )\n HBTEST oValue:type IS 1\n \n aRef := { oValue, NIL }; aRef[ 2 ] := aRef; aRef := NIL\n HBTEST oValue := NIL IS NIL\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"\"\n HBTEST hb_gcAll() IS NIL\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"Reference to self in instance variable.\"\n\n HBTEST cDtorResult := \"\" IS \"\"\n HBTEST objHolder := NIL IS NIL\n oValue := DTORCLASS():NEW( 2 )\n HBTEST oValue:type IS 2\n \n aRef := { oValue, NIL }; aRef[ 2 ] := aRef; aRef := NIL\n HBTEST oValue := NIL IS NIL\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"\"\n HBTEST hb_gcAll() IS \"E 45 BASE 1302 Object destructor failure (Reference to freed block) OS:0 #:0 \"\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"Reference to self in class variable.\"\n\n HBTEST cDtorResult := \"\" IS \"\"\n HBTEST objHolder := NIL IS NIL\n oValue := DTORCLASS():NEW( 3 )\n HBTEST oValue:type IS 3\n \n aRef := { oValue, NIL }; aRef[ 2 ] := aRef; aRef := NIL\n HBTEST oValue := NIL IS NIL\n HBTEST objHolder IS NIL\n HBTEST cDtorResult IS \"\"\n HBTEST hb_gcAll() IS \"E 45 BASE 1302 Object destructor failure (Reference to freed block) OS:0 #:0 \"\n HBTEST ValType( objHolder ) IS \"A\"\n HBTEST Len( objHolder ) IS 0\n HBTEST cDtorResult IS \"Reference to self in private memvar.\"\n\n\n oValue := IVARSCLASS4():new()\n\n HBTEST oValue:x1 IS \"(x1)\"\n HBTEST oValue:y1 IS \"(y1)\"\n HBTEST oValue:z1 IS \"(z1)\"\n HBTEST oValue:x2 IS \"(x2)\"\n HBTEST oValue:y2 IS \"(y2)\"\n HBTEST oValue:z2 IS \"(z2)\"\n HBTEST oValue:x3 IS \"(x3)\"\n HBTEST oValue:y3 IS \"(y3)\"\n HBTEST oValue:z3 IS \"(z3)\"\n HBTEST oValue:x4 IS \"(x4)\"\n HBTEST oValue:y4 IS \"(y4)\"\n HBTEST oValue:z4 IS \"(z4)\"\n HBTEST INSTANCE_DATA( oValue ) IS \"[12]: (x1) (y1) (z1) (x2) (y2) (z2) (x3) (y3) (z3) (x4) (y4) (z4)\"\n HBTEST __cls_CntClsData( oValue:IVARSCLASS1:classH ) IS 0\n HBTEST __cls_CntClsData( oValue:IVARSCLASS2:classH ) IS 0\n HBTEST __cls_CntClsData( oValue:IVARSCLASS3:classH ) IS 0\n HBTEST __cls_CntClsData( oValue:IVARSCLASS4:classH ) IS 0\n HBTEST __cls_CntClsData( oValue:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:IVARSCLASS1:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:IVARSCLASS2:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:IVARSCLASS3:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:IVARSCLASS4:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:classH ) IS 0\n\n \n HBTEST oValue:x1 := \" X1 \" IS \" X1 \"\n HBTEST oValue:y1 := \" Y1 \" IS \" Y1 \"\n HBTEST oValue:z1 := \" Z1 \" IS \" Z1 \"\n HBTEST oValue:x2 := \" X2 \" IS \" X2 \"\n HBTEST oValue:y2 := \" Y2 \" IS \" Y2 \"\n HBTEST oValue:z2 := \" Z2 \" IS \" Z2 \"\n HBTEST oValue:x3 := \" X3 \" IS \" X3 \"\n HBTEST oValue:y3 := \" Y3 \" IS \" Y3 \"\n HBTEST oValue:z3 := \" Z3 \" IS \" Z3 \"\n HBTEST oValue:x4 := \" X4 \" IS \" X4 \"\n HBTEST oValue:y4 := \" Y4 \" IS \" Y4 \"\n HBTEST oValue:z4 := \" Z4 \" IS \" Z4 \"\n\n HBTEST oValue:x1 IS \" X1 \"\n HBTEST oValue:y1 IS \" Y1 \"\n HBTEST oValue:z1 IS \" Z1 \"\n HBTEST oValue:x2 IS \" X2 \"\n HBTEST oValue:y2 IS \" Y2 \"\n HBTEST oValue:z2 IS \" Z2 \"\n HBTEST oValue:x3 IS \" X3 \"\n HBTEST oValue:y3 IS \" Y3 \"\n HBTEST oValue:z3 IS \" Z3 \"\n HBTEST oValue:x4 IS \" X4 \"\n HBTEST oValue:y4 IS \" Y4 \"\n HBTEST oValue:z4 IS \" Z4 \"\n HBTEST INSTANCE_DATA( oValue ) IS \"[12]: X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 X4 Y4 Z4 \"\n HBTEST __cls_CntClsData( oValue:IVARSCLASS1:classH ) IS 0\n HBTEST __cls_CntClsData( oValue:IVARSCLASS2:classH ) IS 0\n HBTEST __cls_CntClsData( oValue:IVARSCLASS3:classH ) IS 0\n HBTEST __cls_CntClsData( oValue:IVARSCLASS4:classH ) IS 0\n HBTEST __cls_CntClsData( oValue:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:IVARSCLASS1:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:IVARSCLASS2:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:IVARSCLASS3:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:IVARSCLASS4:classH ) IS 0\n HBTEST __cls_CntShrData( oValue:classH ) IS 0\n\n \n HBTEST oValue:IVARSCLASS1:x1 := \"[X1]\" IS \"[X1]\"\n HBTEST oValue:IVARSCLASS1:y1 := \"[Y1]\" IS \"[Y1]\"\n HBTEST oValue:IVARSCLASS1:z1 := \"[Z1]\" IS \"[Z1]\"\n\n HBTEST oValue:x1 IS \"[X1]\"\n HBTEST oValue:y1 IS \"[Y1]\"\n HBTEST oValue:z1 IS \"[Z1]\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour header file: include/hbsetup.ch. Defines constants: HB_SETUP_CH_, HB_CLP_UNDOC, HB_COMPAT_C53, HB_LEGACY_LEVEL4, HB_LEGACY_LEVEL5. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_SETUP_CH_\n#define HB_SETUP_CH_\n\n\n#define HB_CLP_UNDOC \n#define HB_COMPAT_C53 \n\n#ifndef HB_LEGACY_OFF\n#define HB_LEGACY_LEVEL4\n#endif\n\n\n#define HB_LEGACY_LEVEL5\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'gtwvg' (): contrib/gtwvg/activex.prg. Defines classes: WvgActiveXControl. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\n#ifndef __DBG_PARTS__\n#xtranslate hb_traceLog( [] ) =>\n#endif\n\nCREATE CLASS WvgActiveXControl INHERIT WvgWindow\n\n VAR oOLE\n VAR CLSID INIT \"\"\n VAR server INIT NIL\n VAR license INIT NIL\n VAR controlFlags INIT 0\n VAR default INIT .F.\n VAR cancel INIT .F.\n\n VAR interface\n VAR interfaceName\n\n VAR lSubStdEvents INIT .F.\n\n VAR hEvents INIT { => }\n VAR hContainer\n\n VAR ClassName\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible, cCLSID, cLicense )\n METHOD Destroy()\n METHOD execEvent( nEvent, ... )\n METHOD handleEvent( nEvent, aNM )\n METHOD mapEvent( nEvent, bBlock )\n\n METHOD inheritPresParams()\n METHOD presParamsChanged()\n METHOD setInputFocus()\n METHOD subscribeStdEvents()\n METHOD unsubscribeStdEvents()\n METHOD keyDown()\n METHOD click()\n METHOD dblClick()\n METHOD mouseDown()\n METHOD mouseUp()\n METHOD mouseMove()\n METHOD activate()\n\n ERROR HANDLER OnError()\n\nENDCLASS\n\nMETHOD WvgActiveXControl:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::style := WS_CHILD + WS_VISIBLE + WS_CLIPCHILDREN + WS_CLIPSIBLINGS\n ::exStyle := WS_EX_CLIENTEDGE\n ::objType := objTypeActiveX\n ::className := \"WIN_OLEAUTO\"\n\n RETURN Self\n\nMETHOD WvgActiveXControl:Create( oParent, oOwner, aPos, aSize, aPresParams, lVisible, cCLSID, cLicense )\n\n LOCAL hObj, hWnd\n\n ::WvgWindow:create( @oParent, @oOwner, aPos, aSize, aPresParams, lVisible )\n\n __defaultNIL( @cCLSID, ::CLSID )\n __defaultNIL( @cLicense, ::license )\n\n ::CLSID := cCLSID\n ::license := cLicense\n ::hContainer := iif( HB_ISOBJECT( ::oParent ), ::oParent:getHWND(), ::oParent )\n\n IF ! HB_ISNUMERIC( ::hContainer ) .OR. ! HB_ISSTRING( ::CLSID )\n RETURN NIL\n ENDIF\n\n ::hWnd := NIL\n ::nID := iif( HB_ISOBJECT( ::oParent ), ::oParent:GetControlId(), ::getControlID() )\n ::oOLE := win_oleAuto()\n\n win_axInit()\n\n hWnd := wapi_CreateWindowEx( ::exStyle, \"AtlAxWin\", ::CLSID, ::style, ::aPos[ 1 ], ::aPos[ 2 ], ;\n ::aSize[ 1 ], ::aSize[ 2 ], win_N2P( ::hContainer ), 0, NIL, NIL )\n IF Empty( hWnd )\n RETURN NIL\n ENDIF\n ::hWnd := win_P2N( hWnd )\n ::pWnd := hWnd\n\n hObj := __axGetControl( ::pWnd )\n IF Empty( hObj )\n RETURN NIL\n ENDIF\n ::oOLE:__hObj := hObj\n __axDoVerb( ::pWnd, -4 )\n\n IF ! Empty( ::hEvents )\n ::oOle:__hSink := __axRegisterHandler( ::oOle:__hObj, {| nEvent, ... | ::execEvent( nEvent, ... ) } )\n ENDIF\n\n\n IF HB_ISOBJECT( ::oParent )\n ::oParent:addChild( Self )\n ENDIF\n\n ::setPosAndSize()\n IF ::visible\n ::show()\n ELSE\n ::hide()\n ENDIF\n IF ::isParentCrt()\n ::oParent:setFocus()\n ENDIF\n\n RETURN Self\n\nMETHOD PROCEDURE WvgActiveXControl:execEvent( nEvent, ... )\n\n\n IF hb_HHasKey( ::hEvents, nEvent )\n Eval( ::hEvents[ nEvent ], ... )\n ENDIF\n\n RETURN\n\nMETHOD WvgActiveXControl:handleEvent( nEvent, aNM )\n\n LOCAL nHandled := 0\n\n HB_SYMBOL_UNUSED( aNM )\n\n SWITCH nEvent\n\n CASE HB_GTE_RESIZED\n IF ::isParentCrt()\n ::rePosition()\n ENDIF\n IF HB_ISBLOCK( ::sl_resize )\n Eval( ::sl_resize, , , Self )\n ENDIF\n EXIT\n\n CASE HB_GTE_ANY\n EXIT\n\n ENDSWITCH\n\n RETURN nHandled\n\nMETHOD WvgActiveXControl:OnError()\n\n\n RETURN hb_ExecFromArray( ::oOLE, __GetMessage(), hb_AParams() )\n\nMETHOD PROCEDURE WvgActiveXControl:Destroy()\n\n IF ! Empty( ::oOLE )\n IF ! Empty( ::oOLE:__hObj )\n IF wapi_IsWindow( ::pWnd )\n wapi_DestroyWindow( ::pWnd )\n ENDIF\n ::oOle := NIL\n ::hWnd := NIL\n ENDIF\n ENDIF\n RETURN\n\nMETHOD WvgActiveXControl:mapEvent( nEvent, bBlock )\n\n IF HB_ISNUMERIC( nEvent ) .AND. HB_ISBLOCK( bBlock )\n ::hEvents[ nEvent ] := bBlock\n ENDIF\n\n RETURN Self\n\nMETHOD WvgActiveXControl:inheritPresParams()\n RETURN .T.\n\nMETHOD WvgActiveXControl:presParamsChanged()\n RETURN Self\n\nMETHOD WvgActiveXControl:setInputFocus()\n RETURN Self\n\nMETHOD WvgActiveXControl:subscribeStdEvents()\n RETURN NIL\n\nMETHOD WvgActiveXControl:unsubscribeStdEvents()\n RETURN Self\n\nMETHOD WvgActiveXControl:keyDown()\n RETURN Self\n\nMETHOD WvgActiveXControl:click()\n RETURN Self\n\nMETHOD WvgActiveXControl:dblClick()\n RETURN Self\n\nMETHOD WvgActiveXControl:mouseDown()\n RETURN Self\n\nMETHOD WvgActiveXControl:mouseUp()\n RETURN Self\n\nMETHOD WvgActiveXControl:mouseMove()\n RETURN Self\n\nMETHOD WvgActiveXControl:activate()\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: ft_WoY, ft_DoY. Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/woy.prg. Provides functions: ft_WoY, ft_DoY. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_WoY( dInDate )\n\n LOCAL nFirstDays, nDayOffset, nWkNumber, cCentury\n\n IF HB_ISDATE( dInDate )\n\n cCentury := Left( DToS( dInDate ), 4 )\n\n \n nFirstDays := 8 - DoW( hb_SToD( cCentury + \"0101\" ) )\n\n nWkNumber := 1\n\n \n nDayOffset := ( dInDate - hb_SToD( cCentury + \"0101\" ) ) - nFirstDays + 1\n\n \n DO WHILE nDayOffset > 0\n ++nWkNumber\n nDayOffset -= 7\n ENDDO\n\n ELSE\n nWkNumber := NIL\n ENDIF\n\n RETURN nWkNumber\n\nFUNCTION ft_DoY( dInDate )\n\n LOCAL nDayNum\n\n IF HB_ISDATE( dInDate )\n nDayNum := ( dInDate - hb_SToD( Left( DToS( dInDate ), 4 ) + \"0101\" ) ) + 1\n ELSE\n nDayNum := NIL\n ENDIF\n\n RETURN nDayNum"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'gtwvg' (): contrib/gtwvg/paint.prg. Provides 11 functions including: WvtPaintObjects, WvtSetPaint, wvg_SetPaint, wvg_GetPaint, wvg_DelPaint. Contains procedures: wvg_InsertPaint. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"wvtwin.ch\"\n\n#include \"hbgtinfo.ch\"\n\nTHREAD STATIC t_paint_ := { { \"\", {} } }\n\n\nFUNCTION WvtPaintObjects()\n\n LOCAL i, lExe, nLeft, nRight, b, tlbr_, aBlocks, nBlocks\n\n aBlocks := WvtSetPaint()\n\n IF ( nBlocks := Len( aBlocks ) ) > 0\n tlbr_ := wvt_GetPaintRect()\n\n FOR i := 1 TO nBlocks\n lExe := .T.\n\n IF aBlocks[ i ][ 3 ] != NIL .AND. ! Empty( aBlocks[ i ][ 3 ] )\n \n DO CASE\n CASE aBlocks[ i ][ 3 ][ 1 ] == WVT_BLOCK_GRID_V\n b := aBlocks[ i ][ 3 ][ 6 ]\n IF Len( b:aColumnsSep ) == 0\n lExe := .F.\n ELSE\n nLeft := b:aColumnsSep[ 1 ]\n nRight := b:aColumnsSep[ Len( b:aColumnsSep ) ]\n IF tlbr_[ 1 ] > aBlocks[ i ][ 3 ][ 4 ] .OR. ; \n tlbr_[ 3 ] < aBlocks[ i ][ 3 ][ 2 ] .OR. ; \n tlbr_[ 2 ] > nRight + 1 .OR. ; \n tlbr_[ 4 ] < nLeft - 2 \n lExe := .F.\n ENDIF\n ENDIF\n\n CASE aBlocks[ i ][ 3 ][ 1 ] == WVT_BLOCK_GETS\n IF tlbr_[ 1 ] > aBlocks[ i ][ 3 ][ 4 ] .OR. ; \n tlbr_[ 3 ] < aBlocks[ i ][ 3 ][ 2 ] .OR. ; \n tlbr_[ 2 ] > aBlocks[ i ][ 3 ][ 5 ] .OR. ; \n tlbr_[ 4 ] < aBlocks[ i ][ 3 ][ 3 ] \n lExe := .F.\n ENDIF\n\n OTHERWISE\n \n IF tlbr_[ 1 ] > aBlocks[ i ][ 3 ][ 4 ] .OR. ; \n tlbr_[ 3 ] < aBlocks[ i ][ 3 ][ 2 ] .OR. ; \n tlbr_[ 2 ] > aBlocks[ i ][ 3 ][ 5 ] .OR. ; \n tlbr_[ 4 ] < aBlocks[ i ][ 3 ][ 3 ] \n lExe := .F.\n ENDIF\n ENDCASE\n ENDIF\n\n IF lExe\n Eval( aBlocks[ i ][ 2 ] )\n ENDIF\n NEXT\n ENDIF\n\n RETURN 0\n\nFUNCTION WvtSetPaint( a_ )\n\n THREAD STATIC t\n\n LOCAL o\n\n IF t == NIL\n t := {}\n ENDIF\n\n o := t\n\n IF a_ != NIL\n t := a_\n ENDIF\n\n RETURN o\n\nFUNCTION wvg_SetPaint( cID, nAction, xData, aAttr )\n\n LOCAL n, n1, oldData\n\n IF xData != NIL\n IF ( n := AScan( t_paint_, {| e_ | e_[ 1 ] == cID } ) ) > 0\n IF ( n1 := AScan( t_paint_[ n ][ 2 ], {| e_ | e_[ 1 ] == nAction } ) ) > 0\n oldData := t_paint_[ n ][ 2 ][ n1 ][ 2 ]\n t_paint_[ n ][ 2 ][ n1 ][ 2 ] := xData\n t_paint_[ n ][ 2 ][ n1 ][ 3 ] := aAttr\n ELSE\n AAdd( t_paint_[ n ][ 2 ], { nAction, xData, aAttr } )\n ENDIF\n ELSE\n AAdd( t_paint_, { cID, {} } )\n n := Len( t_paint_ )\n AAdd( t_paint_[ n ][ 2 ], { nAction, xData, aAttr } )\n ENDIF\n ENDIF\n\n RETURN oldData\n\nFUNCTION wvg_GetPaint( cID )\n\n LOCAL n\n\n IF ( n := AScan( t_paint_, {| e_ | e_[ 1 ] == cID } ) ) > 0\n RETURN t_paint_[ n ][ 2 ]\n ENDIF\n\n RETURN {}\n\nFUNCTION wvg_DelPaint( cID, nAction )\n\n LOCAL xData, n1, n\n\n IF ( n := AScan( t_paint_, {| e_ | e_[ 1 ] == cID } ) ) > 0\n IF ( n1 := AScan( t_paint_[ n ][ 2 ], {| e_ | e_[ 1 ] == nAction } ) ) > 0\n xData := t_paint_[ n ][ 2 ][ n1 ][ 2 ]\n t_paint_[ n ][ 2 ][ n1 ][ 2 ] := {|| .T. }\n ENDIF\n ENDIF\n\n RETURN xData\n\nFUNCTION wvg_PurgePaint( cID, lDummy )\n\n LOCAL n, aPaint\n\n __defaultNIL( @lDummy, .F. )\n\n IF ( n := AScan( t_paint_, {| e_ | e_[ 1 ] == cID } ) ) > 0\n aPaint := t_paint_[ n ]\n hb_ADel( t_paint_, n, .T. )\n ENDIF\n\n IF lDummy\n WvtSetPaint( {} )\n ENDIF\n\n RETURN aPaint\n\nPROCEDURE wvg_InsertPaint( cID, aPaint, lSet )\n\n LOCAL n\n\n __defaultNIL( @lSet, .F. )\n\n IF ( n := AScan( t_paint_, {| e_ | e_[ 1 ] == cID } ) ) > 0\n t_paint_[ n ] := aPaint\n ELSE\n AAdd( t_paint_, aPaint )\n ENDIF\n\n IF lSet\n WvtSetPaint( aPaint )\n ENDIF\n\n RETURN\n\n\nFUNCTION wvt_SetDlgCoMode( nMode )\n\n STATIC sMode := 0\n\n LOCAL nOldMode\n\n nOldMode := sMode\n IF HB_ISNUMERIC( nMode ) .AND. nMode <= 1 .AND. nMode >= 0\n sMode := nMode\n ENDIF\n\n RETURN nOldMode\n\nFUNCTION wvt_MakeDlgTemplate( nTop, nLeft, nRows, nCols, aOffSet, cTitle, nStyle, ;\n cFaceName, nPointSize, nWeight, lItalic, nHelpId, nExStyle )\n\n LOCAL aDlg := { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }\n LOCAL aXY, nX, nY, nW, nH, nXM, nYM\n LOCAL nBaseUnits, nBaseUnitsX, nBaseUnitsY\n LOCAL aFont\n LOCAL nMode := wvt_SetDlgCoMode()\n\n aFont := wvt_GetFontInfo()\n\n IF nMode == 0\n __defaultNIL( @aOffSet, {} )\n ASize( aOffSet, 4 )\n __defaultNIL( @aOffSet[ 1 ], 0 )\n __defaultNIL( @aOffSet[ 2 ], 0 )\n __defaultNIL( @aOffSet[ 3 ], 0 )\n __defaultNIL( @aOffSet[ 4 ], 0 )\n\n nBaseUnits := wvg_GetDialogBaseUnits()\n nBaseUnitsX := wvg_LOWORD( nBaseUnits )\n nBaseUnitsY := wvg_HIWORD( nBaseUnits )\n\n nW := aFont[ 7 ]\n AAdd( aDlg[ 1 ], iif( HB_ISSTRING( cTitle ), cTitle, \"\" ) )\n\n IF hb_bitAnd( nStyle, DS_SETFONT ) == DS_SETFONT\n AAdd( aDlg[ 1 ], iif( HB_ISNUMERIC( nPointSize ), nPointSize, 8 ) )\n AAdd( aDlg[ 1 ], iif( HB_ISNUMERIC( nWeight ), nWeight, 400 ) )\n AAdd( aDlg[ 1 ], iif( HB_ISLOGICAL( lItalic ), lItalic, .F. ) )\n AAdd( aDlg[ 1 ], iif( HB_ISSTRING( cFaceName ), cFaceName, \"MS Sans Serif\" ) )\n ENDIF\n\n RETURN aDlg\n\nFUNCTION wvt_AddDlgItem( aDlg, nTop, nLeft, nRows, nCols, aOffSet, ;\n cnId, cnDlgClass, nStyle, cText, nHelpId, nExStyle )\n\n LOCAL aXY, nX, nY, nW, nH, nXM, nYM\n LOCAL nBaseUnits, nBaseUnitsX, nBaseUnitsY\n LOCAL nBottom, nRight\n LOCAL nMode := wvt_SetDlgCoMode()\n\n IF nMode == 0\n nBottom := nTop + nRows - 1\n nRight := nLeft + nCols - 1\n\n __defaultNIL( @aOffSet, {} )\n\n ASize( aOffSet, 4 )\n\n __defaultNIL( @aOffSet[ 1 ], 0 )\n __defaultNIL( @aOffSet[ 2 ], 0 )\n __defaultNIL( @aOffSet[ 3 ], 0 )\n __defaultNIL( @aOffSet[ 4 ], 0 )\n\n nBaseUnits := wvg_GetDialogBaseUnits()\n nBaseUnitsX := wvg_LOWORD( nBaseUnits )\n nBaseUnitsY := wvg_HIWORD( nBaseUnits )\n\n aXY := wvt_GetXYFromRowCol( nTop, nLeft )\n nX := aXY[ 1 ] + aOffSet[ 2 ]\n nY := aXY[ 2 ] + aOffSet[ 1 ]\n\n aXY := wvt_GetXYFromRowCol( nBottom + 1, nRight + 1 )\n nW := aXY[ 1 ] + aOffSet[ 4 ] - nX\n nH := aXY[ 2 ] + aOffSet[ 3 ] - nY\n\n nXM := 5.25\n nYM := 10.25\n\n nX := nX\n AAdd( aDlg[ 11 ], iif( HB_ISSTRING( cText ), cText, iif( HB_ISNUMERIC( cText ), cText, \"\" ) ) )\n AAdd( aDlg[ 12 ], 0 )\n\n RETURN aDlg\n\nFUNCTION wvt_CreateDialog( acnDlg, lOnTop, cbDlgProc, ncIcon, nTimerTicks, hMenu )\n\n LOCAL hDlg, cType, xTemplate, nDlgMode\n\n IF HB_ISSTRING( cbDlgProc )\n cbDlgProc := Upper( cbDlgProc )\n ENDIF\n\n cType := ValType( acnDlg )\n nDlgMode := iif( cType == \"C\", 0, iif( cType == \"N\", 1, 2 ) )\n\n IF cType == \"A\"\n xTemplate := wvt__MakeDlgTemplate( acnDlg[ 1 ], acnDlg[ 2 ], acnDlg[ 3 ], acnDlg[ 4 ], ;\n acnDlg[ 5 ], acnDlg[ 6 ], acnDlg[ 7 ], acnDlg[ 8 ], ;\n acnDlg[ 9 ], acnDlg[ 10 ], acnDlg[ 11 ], acnDlg[ 12 ] )\n ELSE\n xTemplate := acnDlg\n ENDIF\n\n hDlg := wvt_CreateDialogDynamic( xTemplate, lOnTop, cbDlgProc, nDlgMode )\n\n IF hDlg != 0\n IF ncIcon != NIL\n wvt_DlgSetIcon( hDlg, ncIcon )\n ENDIF\n\n IF HB_ISNUMERIC( nTimerTicks )\n wvg_SetTimer( hDlg, 1001, nTimerTicks )\n ENDIF\n\n IF hMenu != NIL\n wvg_SetMenu( hDlg, hMenu )\n ENDIF\n ENDIF\n\n RETURN hDlg\n\nFUNCTION wvt_DialogBox( acnDlg, cbDlgProc, hWndParent )\n\n LOCAL nResult, cType, xTemplate, nDlgMode\n\n IF HB_ISSTRING( cbDlgProc )\n cbDlgProc := Upper( cbDlgProc )\n ENDIF\n\n cType := ValType( acnDlg )\n nDlgMode := iif( cType == \"C\", 0, iif( cType == \"N\", 1, 2 ) )\n\n IF cType == \"A\"\n xTemplate := wvt__MakeDlgTemplate( acnDlg[ 1 ], acnDlg[ 2 ], acnDlg[ 3 ], acnDlg[ 4 ], ;\n acnDlg[ 5 ], acnDlg[ 6 ], acnDlg[ 7 ], acnDlg[ 8 ], ;\n acnDlg[ 9 ], acnDlg[ 10 ], acnDlg[ 11 ], acnDlg[ 12 ] )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/wordrem.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of WordRem()\"\n ?\n\n ? \"Simple tests:\"\n ? ' WordRem( \"abcd\", \"0ab1cd\" ) == \"0ab1\" ? ----> \"' + WordRem( \"abcd\", \"0ab1cd\" ) + '\"'\n ? ' WordRem( \"abcd\", \"ab0cd1\" ) == \"0cd1\" ? ----> \"' + WordRem( \"abcd\", \"ab0cd1\" ) + '\"'\n ?\n\n ? \"End test of WordRem()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/tests/pe.prg. Provides functions: MyMemoEdit, Example_Text, Example_Text_Raw. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbmisc\"\n\nPROCEDURE Main( cFile )\n\n LOCAL cText\n LOCAL lEdit := .T.\n\n IF cFile == NIL\n cText := Example_Text()\n ELSE\n IF hb_FileMatch( cFile, __FILE__ )\n lEdit := .F.\n ENDIF\n cText := MemoRead( cFile )\n ENDIF\n\n cText := MyMemoEdit( cText, 0, 0, MaxRow(), MaxCol(), lEdit )\n hb_MemoWrit( hb_FNameExtSet( __FILE__, \".out\" ), cText )\n\n RETURN\n\nSTATIC FUNCTION MyMemoEdit( cText, nTop, nLeft, nBottom, nRight, lEdit )\n\n LOCAL oED\n\n \n oED := EditorNew( nTop, nLeft, nBottom, nRight, 254, , , , Len( cText )\n ? \"Editor not created\"\n ENDIF\n\n RETURN cText\n\nSTATIC FUNCTION Example_Text()\n RETURN StrTran( Example_Text_Raw(), \"~\", hb_BChar( 168 ) )\n\nSTATIC FUNCTION Example_Text_Raw()\n#pragma __cstream | RETURN %s\n\n ~2Lorem ipsum dolor sit amet, consectetur adipiscing elit.~1\n~3 ========================================================\n\n Integer a dolor eu lorem luctus cursus. Proin varius dui quis felis.\n Sed vitae lacus ac mauris cursus vehicula. Nulla sodales fringilla\n lorem. Praesent odio mi, interdum eget, facilisis et, elementum\n luctus, enim. Vivamus sed est. Cras leo dolor, mollis et, suscipit\n sed, interdum ac, elit. Phasellus cursus, arcu nec bibendum cursus,\n dolor mi vestibulum leo, ut cursus orci sem id dolor. Morbi porttitor\n libero nec risus. Duis diam justo, blandit sed, fermentum eu,\n consectetur at, arcu. Quisque felis ipsum, facilisis quis, ultrices\n sed, venenatis aliquam, urna. Cras sit amet risus. Pellentesque\n dictum. In hac habitasse platea dictumst.\n\n Nunc odio elit, mattis et, rutrum id, faucibus vitae, ipsum. Donec\n aliquet sem sed augue. Aliquam erat volutpat. Etiam ultrices, metus\n a tristique ornare, tellus urna congue nunc, vitae iaculis risus\n enim quis magna.\n\n~5This file have to be separated with CR/LF characters~1\n#pragma __endtext"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/big5_gen.prg. Provides functions: array_to_code, hash_to_array, min_size, calc_size, conv_get. This test file tests specific function APIs"}, {"role": "assistant", "content": "proc main()\n local cLine, aVal, aVal2, aValU, aValU2, hVal, aInd, ;\n n, nn, nBG5, nU16, nMin, nMax, nUMin, nUMax, cResult, nBit\n\n aVal := afill( array( 0x10000 ), 0 )\n aValU := afill( array( 0x10000 ), 0 )\n nMin := nUMin := 0xFFFF\n nMax := nUMax := 0x0000\n\n for each cLine in hb_aTokens( hb_memoRead( \"BIG5.TXT\" ), hb_eol() )\n if cLine = \"0x\" .and. ( n := hb_at( \"0x\", cLine, 7 ) ) != 0\n nBG5 := hb_hexToNum( substr( cLine, 3, 4 ) )\n nU16 := hb_hexToNum( substr( cLine, n + 2, 4 ) )\n if nBG5 == 0 .or. nU16 == 0\n ? \"unrecognized line:\", cLine:__enumIndex()\n return\n elseif nBG5 > 0xFFFF .or. nU16 > 0xFFFF\n ? \"wrong character range at line:\", cLine:__enumIndex()\n return\n endif\n aVal[ nBG5 ] := nU16\n if nBG5 > nMax\n nMax := nBG5\n endif\n if nBG5 < nMin\n nMin := nBG5\n endif\n if nU16 > nUMax\n nUMax := nU16\n endif\n if nU16 < nUMin\n nUMin := nU16\n endif\n endif\n next\n\n for n := 1 to len( aVal )\n if aVal[ n ] != 0\n aValU[ aVal[ n ] ] := n\n endif\n next\n\n\n ? \"BIG5->UCS16 tables.\"\n ? \"raw size:\", hb_ntos( ( nMax - nMin + 1 )\n ? \"minimal size:\", hb_ntos( n ), ;\n \"for\", hb_ntos( hb_bitshift( 1, nBit ) ), \"byte blocks, (from: \"+hb_ntos( nMin ) + \")\"\n calc_size( aVal, nMin, nMax, nBit, @hVal, @aInd, @nn )\n aVal2 := hash_to_array( hVal )\n\n\n cResult := ;\n \"\" + hb_eol() + ;\n hb_eol()\n\n cResult += '#include \"hbapi.h\"' + hb_eol()\n cResult += hb_eol()\n cResult += \"#define HB_BIG5_FIRST 0x\" + hb_numToHex( nMin, 4 ) + hb_eol()\n cResult += \"#define HB_BIG5_LAST 0x\" + hb_numToHex( nMax, 4 ) + hb_eol()\n cResult += \"#define HB_BIG5_BITS \" + hb_ntos( nBit ) + hb_eol()\n cResult += hb_eol()\n\n cResult += array_to_code( aInd, \"s_big5index\", nn )\n cResult += hb_eol()\n cResult += array_to_code( aVal2, \"s_big5_ucs16\", 2 )\n cResult += hb_eol()\n cResult += index_func( \"s_big5_to_ucs16\", \"s_big5index\", \"s_big5_ucs16\", ;\n \"HB_BIG5_FIRST\", \"HB_BIG5_LAST\", \"HB_BIG5_BITS\" )\n\n check_conv( aVal, aInd, aVal2, nMin, nMax, nBit )\n\n ?\n ? \"UCS16->BIG5 tables.\"\n ? \"raw size:\", hb_ntos( ( nUMax - nUMin + 1 )\n ? \"minimal size:\", hb_ntos( n ), ;\n \"for\", hb_ntos( hb_bitshift( 1, nBit ) ), \"byte blocks, (from: \"+hb_ntos( nUMin ) + \")\"\n calc_size( aValU, nUMin, nUMax, nBit, @hVal, @aInd, @nn )\n aValU2 := hash_to_array( hVal )\n\n cResult += hb_eol()\n cResult += \"#define HB_U16_FIRST 0x\" + hb_numToHex( nUMin, 4 ) + hb_eol()\n cResult += \"#define HB_U16_LAST 0x\" + hb_numToHex( nUMax, 4 ) + hb_eol()\n cResult += \"#define HB_U16_BITS \" + hb_ntos( nBit ) + hb_eol()\n cResult += hb_eol()\n cResult += array_to_code( aInd, \"s_ucs16index\", nn )\n cResult += hb_eol()\n cResult += array_to_code( aValU2, \"s_ucs16_big5\", 2 )\n cResult += hb_eol()\n cResult += index_func( \"s_ucs16_to_big5\", \"s_ucs16index\", \"s_ucs16_big5\", ;\n \"HB_U16_FIRST\", \"HB_U16_LAST\", \"HB_U16_BITS\" )\n\n check_conv( aValU, aInd, aValU2, nUMin, nUMax, nBit )\n\n hb_memowrit( \"big5.c\", cResult )\nreturn\n\nstatic function array_to_code( aVal, cName, nn )\n local cResult, l, n\n\n cResult := \"static const \" + ;\n iif( nn == 1, \"HB_BYTE\", \"HB_USHORT\" ) + \" \" + ;\n cName + \"[ \" + hb_ntos( len( aVal ) ) + \" ] =\" + hb_eol()\n cResult += \"{\" + hb_eol()\n l := 0\n for n := 1 to len( aVal )\n if ++l > iif( nn == 1, 12, 8 )\n l := 1\n cResult += \",\"\n cResult += hb_eol()\n cResult += \" \"\n elseif n == 1\n cResult += \" \"\n else\n cResult += \", \"\n endif\n cResult += \"0x\"\n cResult += hb_numToHex( aVal[ n ], nn\n cResult += \"};\" + hb_eol()\nreturn cResult;\n\nstatic function hash_to_array( hVal )\n local aVal := {}, cLine, n\n for each cLine in hVal\n for n := 1 to len( cLine ) step( 2 )\n aadd( aVal, bin2w( substr( cLine, n, 2 ) ) )\n next\n next\nreturn aVal\n\nfunction min_size( aVal, nMin, nMax, nBit )\n local n, nM, nS, nSize, nMinX\n nSize := 0xFFFFFF\n nMinX := nMin\n#ifdef DO_START_OPT\n for nM := hb_bitAnd( nMin, 0xFF00 ) to nMin\n#else\n for nM := nMin to nMin\n#endif\n for n := 1 to 16\n nS := calc_size( aVal, nM, nMax, n )\n if nS < nSize\n nSize := nS\n nBit := n\n nMinX := nM\n endif\n next\n next\n nMin := nMinX\nreturn nSize\n\nfunction calc_size( aVal, nMin, nMax, nBit, hVal, aInd, nn )\n local nLine, n, cLine, c\n\n nLine := int( 2 ^ nBit )\n\n cLine := \"\"\n hVal := {=>}\n aInd := {}\n for n := nMin to nMax\n cLine += i2bin( iif( n == 0, 0, aVal[ n ] ) )\n if len( cLine ) == nLine\n cLine := \"\"\n endif\n next\n if ! cLine == \"\"\n for each c in hVal\n if c = cLine\n cLine := c\n exit\n endif\n next\n hVal[ cLine ] := cLine\n aadd( aInd, hb_hpos( hVal, cLine ) - 1 )\n endif\n nn := iif( len( aInd ) > 256, 2, 1 )\n n := len( aInd )\n cResult := \"static HB_USHORT \" + cName + \"( int n )\" + hb_eol() + ;\n \"{\" + hb_eol() + ;\n \" n -= \" + cMin + \";\" + hb_eol() + ;\n \" if( n >= 0 && n <= ( \" + cMax + \" - \" + cMin + \" ) )\" + hb_eol() + ;\n \" {\" + hb_eol() + ;\n \" return \" + cNameConv + \"[ ( \" + cNameInd + ;\n \"[ n >> \" + cBit + \" ] << \" + cBit + \" ) +\" + hb_eol() + ;\n space( len( cNameConv ) + 15 ) + ;\n \"( n & ( ( 1 << \" + cBit + \" ) - 1 ) ) ];\" + hb_eol() + ;\n \" }\" + hb_eol() + ;\n \" return 0;\" + hb_eol() + ;\n \"}\" + hb_eol()\n\nreturn cResult\n\nstatic function conv_get( n, aInd, aVal2, nMin, nMax, nBit )\n local nDiv\n if n >= nMin .and. n <= nMax\n nDiv := 2 ^ nBit\n n -= nMin\n return aVal2[ aInd[ n / nDiv + 1 ]\n ? \"Wrong decoding:\", n, aVal[ n ], nVal, len( aVal ), nMax, hb_eol()\n break\n endif\n next\nreturn nil"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour Runtime Library file: src/debug/tbrwtext.prg. Defines classes: HBBrwText. This file provides utility functions"}, {"role": "assistant", "content": "#pragma -b-\n\n#define HB_CLS_NOTOBJECT \n#include \"hbclass.ch\"\n\nCREATE CLASS HBBrwText\n\n VAR cFileName\n VAR aRows\n VAR nRows\n VAR nLineNoLen\n VAR nActiveLine\n VAR lLineNumbers\n VAR nRow\n VAR nFirstCol\n VAR nCol\n\n VAR oBrw\n\n VAR nLineOffset INIT 1\n VAR nMaxLineLen\n VAR nTabWidth INIT 4\n\n VAR nTop\n VAR nLeft\n VAR nBottom\n VAR nRight\n\n VAR nWidth\n VAR nHeight\n\n METHOD New( nTop, nLeft, nBottom, nRight, cFileName, cColors, lLineNumbers )\n\n METHOD RefreshAll() INLINE ::oBrw:ForceStable():RefreshAll(), Self\n METHOD ForceStable() INLINE ::oBrw:ForceStable(), Self\n METHOD RefreshCurrent() INLINE ::oBrw:RefreshCurrent(), Self\n METHOD GotoLine( n )\n METHOD SetActiveLine( n )\n METHOD GetLine()\n METHOD GetLineText()\n METHOD GetLineColor()\n METHOD Search( cString, lCaseSensitive, nMode )\n\n METHOD GoFirst()\n METHOD GoLast()\n METHOD Skip( n )\n METHOD GoNext()\n METHOD GoPrev()\n\n METHOD Resize( nTop, nLeft, nBottom, nRight )\n\n METHOD Up() INLINE ::oBrw:Up():ForceStable(), Self\n METHOD Down() INLINE ::oBrw:Down():ForceStable(), Self\n METHOD PageUp() INLINE ::oBrw:PageUp():ForceStable(), Self\n METHOD PageDown() INLINE ::oBrw:PageDown():ForceStable(), Self\n METHOD GoTop() INLINE ::oBrw:GoTop():ForceStable(), Self\n METHOD GoBottom() INLINE ::oBrw:GoBottom():ForceStable(), Self\n\n METHOD Home() INLINE iif( ::nLineOffset > 1, ( ::nLineOffset := 1, ::oBrw:RefreshAll():ForceStable() ), ), Self\n METHOD End() INLINE ::nLineOffset := Max( 1, ::nMaxLineLen - ( ::nWidth - iif( ::lLineNumbers, ::nLineNoLen, 0 ) ) + 1 ), ::oBrw:RefreshAll():ForceStable(), Self\n\n METHOD Right() INLINE iif( ::nLineOffset < ::nMaxLineLen + iif( ::lLineNumbers, ::nLineNoLen, 0 ), ( ::nLineOffset++, ::oBrw:RefreshAll():ForceStable() ), ), Self\n METHOD Left() INLINE iif( ::nLineOffset > 1, ( ::nLineOffset--, ::oBrw:RefreshAll():ForceStable() ), ), Self\n\n METHOD RowPos() INLINE ::nRow\n\n METHOD LoadFile( cFileName )\n\n VAR colorSpec IS colorSpec IN oBrw\n\nENDCLASS\n\nMETHOD New( nTop, nLeft, nBottom, nRight, cFileName, cColors, lLineNumbers ) CLASS HBBrwText\n\n LOCAL oCol\n\n ::nTop := nTop\n ::nLeft := nLeft\n ::nBottom := nBottom\n ::nRight := nRight\n\n ::nWidth := nRight - nLeft + 1\n ::nHeight := nBottom - nTop\n\n ::lLineNumbers := lLineNumbers\n\n ::oBrw := HBDbBrowser():New( ::nTop, ::nLeft, ::nBottom, ::nRight )\n\n ::oBrw:colorSpec := cColors\n\n oCol := HBDbColumnNew( \"\", {|| ::GetLineText() } )\n\n oCol:colorBlock := {|| ::GetLineColor() }\n\n ::oBrw:AddColumn( oCol )\n\n ::oBrw:goTopBlock := {|| ::nRow := 1 }\n ::oBrw:goBottomBlock := {|| ::nRow := ::nRows }\n ::oBrw:skipBlock := {| n | ::Skip( n ) }\n\n IF ! Empty( cFileName )\n ::LoadFile( cFileName )\n ENDIF\n\n RETURN Self\n\nMETHOD GotoLine( n ) CLASS HBBrwText\n\n ::oBrw:MoveCursor( n - ::nRow )\n ::RefreshAll()\n\n RETURN Self\n\nMETHOD SetActiveLine( n ) CLASS HBBrwText\n\n ::nActiveLine := n\n ::RefreshAll()\n\n RETURN Self\n\nMETHOD GetLine() CLASS HBBrwText\n RETURN iif( ::lLineNumbers, PadR( hb_ntos( ::nRow ) + \":\", ::nLineNoLen ), \"\" ) + ;\n MemoLine( ::aRows[ ::nRow ], ::nMaxLineLen, 1, ::nTabWidth, .F. )\n\nMETHOD GetLineText() CLASS HBBrwText\n RETURN PadR( SubStr( ::GetLine(), ::nLineOffset ), ::nWidth )\n\nMETHOD GetLineColor() CLASS HBBrwText\n\n LOCAL aColor\n\n IF __dbgIsBreak( __dbg():pInfo, ::cFileName, ::nRow ) >= 0\n aColor := iif( ::nRow == ::nActiveLine, { 4, 4 }, { 3, 3 } )\n ELSE\n aColor := iif( ::nRow == ::nActiveLine, { 2, 2 }, { 1, 1 } )\n ENDIF\n\n RETURN aColor\n\nMETHOD PROCEDURE LoadFile( cFileName ) CLASS HBBrwText\n\n LOCAL nMaxLineLen := 0\n LOCAL cLine\n\n ::cFileName := cFileName\n ::aRows := __dbgTextToArray( MemoRead( cFileName ) )\n ::nRows := Len( ::aRows )\n ::nLineNoLen := Len( hb_ntos( ::nRows ) ) + 2\n\n FOR EACH cLine IN ::aRows\n nMaxLineLen := Max( nMaxLineLen, ;\n Len( RTrim( MemoLine( cLine, Len( cLine ) + 256, 1, ::nTabWidth, .F. ) ) ) )\n NEXT\n ::nMaxLineLen := nMaxLineLen\n ::nLineOffset := 1\n\n RETURN\n\nMETHOD Resize( nTop, nLeft, nBottom, nRight ) CLASS HBBrwText\n\n LOCAL lResize := .F.\n\n IF HB_ISNUMERIC( nTop ) .AND. nTop != ::nTop\n ::nTop := nTop\n lResize := .T.\n ENDIF\n IF HB_ISNUMERIC( nLeft ) .AND. nLeft != ::nLeft\n ::nLeft := nLeft\n lResize := .T.\n ENDIF\n IF HB_ISNUMERIC( nBottom ) .AND. nBottom != ::nBottom\n ::nBottom := nBottom\n lResize := .T.\n ENDIF\n IF HB_ISNUMERIC( nRight ) .AND. nRight != ::nRight\n ::nRight := nRight\n lResize := .T.\n ENDIF\n IF lResize\n ::oBrw:Resize( nTop, nLeft, nBottom, nRight )\n ::nWidth := ::nRight - ::nLeft + 1\n ENDIF\n\n RETURN Self\n\nMETHOD Search( cString, lCaseSensitive, nMode ) CLASS HBBrwText\n\n LOCAL bMove\n LOCAL lFound := .F.\n LOCAL n\n\n IF ! lCaseSensitive\n cString := Upper( cString )\n ENDIF\n\n SWITCH hb_defaultValue( nMode, 0 )\n CASE 0 \n ::GoTop()\n bMove := {|| ::Skip( 1 ) }\n EXIT\n CASE 1 \n bMove := {|| ::Skip( 1 ) }\n EXIT\n CASE 2 \n bMove := {|| ::Skip( -1 ) }\n EXIT\n ENDSWITCH\n\n n := ::nRow\n\n DO WHILE Eval( bMove ) != 0\n IF cString $ iif( lCaseSensitive, ::aRows[ ::nRow ], Upper( ::aRows[ ::nRow ] ) )\n lFound := .T.\n ::oBrw:MoveCursor( ::nRow - n )\n ::RefreshAll()\n EXIT\n ENDIF\n ENDDO\n\n RETURN lFound\n\nMETHOD GoFirst() CLASS HBBrwText\n\n ::nRow := 1\n\n RETURN .T.\n\nMETHOD GoLast() CLASS HBBrwText\n\n ::nRow := ::nRows\n\n RETURN .T.\n\nMETHOD Skip( n ) CLASS HBBrwText\n\n LOCAL nSkipped := 0\n\n IF n > 0\n IF ::nRow < ::nRows\n nSkipped := Min( ::nRows - ::nRow, n )\n ::nRow += nSkipped\n ENDIF\n ELSEIF n < 0\n IF ::nRow > 1\n nSkipped := Max( 1 - ::nRow, n )\n ::nRow += nSkipped\n ENDIF\n ENDIF\n\n RETURN nSkipped\n\nMETHOD GoPrev() CLASS HBBrwText\n\n LOCAL lMoved := .F.\n\n IF ::nRow > 1\n ::nRow--\n lMoved := .T.\n ENDIF\n\n RETURN lMoved\n\nMETHOD GoNext() CLASS HBBrwText\n\n LOCAL lMoved := .F.\n\n IF ::nRow < ::nRows\n ::nRow++\n lMoved := .T.\n ENDIF\n\n RETURN lMoved"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'hbpgsql' (PostgreSQL database client library): contrib/hbpgsql/postgres.ch. Defines 10 constants including: HBPOSTGRES_CH_, CONNECTION_OK, CONNECTION_BAD, CONNECTION_STARTED, CONNECTION_MADE. Defines error handling constants and codes"}, {"role": "assistant", "content": "#ifndef HBPOSTGRES_CH_\n#define HBPOSTGRES_CH_\n\n\n#define CONNECTION_OK 0\n#define CONNECTION_BAD 1\n#define CONNECTION_STARTED 2\n#define CONNECTION_MADE 3\n#define CONNECTION_AWAITING_RESPONSE 4\n#define CONNECTION_AUTH_OK 5\n#define CONNECTION_SETENV 6\n#define CONNECTION_SSL_STARTUP 7\n#define CONNECTION_NEEDED 8\n\n\n#define PGRES_POLLING_FAILED 0\n#define PGRES_POLLING_READING 1\n#define PGRES_POLLING_WRITING 2\n#define PGRES_POLLING_OK 3\n#define PGRES_POLLING_ACTIVE 4\n\n\n#define PGRES_EMPTY_QUERY 0\n#define PGRES_COMMAND_OK 1\n#define PGRES_TUPLES_OK 2\n#define PGRES_COPY_OUT 3\n#define PGRES_COPY_IN 4\n#define PGRES_BAD_RESPONSE 5\n#define PGRES_NONFATAL_ERROR 6\n#define PGRES_FATAL_ERROR 7\n\n\n#define PQTRANS_IDLE 0\n#define PQTRANS_ACTIVE 1\n#define PQTRANS_INTRANS 2\n#define PQTRANS_INERROR 3\n#define PQTRANS_UNKNOWN 4\n\n\n#define HBPG_META_FIELDNAME 1\n#define HBPG_META_FIELDTYPE 2\n#define HBPG_META_FIELDLEN 3\n#define HBPG_META_FIELDDEC 4\n#define HBPG_META_TABLE 5\n#define HBPG_META_TABLECOL 6\n#define HBPG_META_LEN_ 6\n\n\n#define PQERRORS_TERSE 0\n#define PQERRORS_DEFAULT 1\n#define PQERRORS_VERBOSE 2\n\n\n#define PQPING_OK 0 \n#define PQPING_REJECT 1 \n#define PQPING_NO_RESPONSE 2 \n#define PQPING_NO_ATTEMPT 3 \n\n\n#define PG_DIAG_SEVERITY hb_BCode( \"S\" )\n#define PG_DIAG_SQLSTATE hb_BCode( \"C\" )\n#define PG_DIAG_MESSAGE_PRIMARY hb_BCode( \"M\" )\n#define PG_DIAG_MESSAGE_DETAIL hb_BCode( \"D\" )\n#define PG_DIAG_MESSAGE_HINT hb_BCode( \"H\" )\n#define PG_DIAG_STATEMENT_POSITION hb_BCode( \"P\" )\n#define PG_DIAG_INTERNAL_POSITION hb_BCode( \"p\" )\n#define PG_DIAG_INTERNAL_QUERY hb_BCode( \"q\" )\n#define PG_DIAG_CONTEXT hb_BCode( \"W\" )\n#define PG_DIAG_SCHEMA_NAME hb_BCode( \"s\" )\n#define PG_DIAG_TABLE_NAME hb_BCode( \"t\" )\n#define PG_DIAG_COLUMN_NAME hb_BCode( \"c\" )\n#define PG_DIAG_DATATYPE_NAME hb_BCode( \"d\" )\n#define PG_DIAG_CONSTRAINT_NAME hb_BCode( \"n\" )\n#define PG_DIAG_SOURCE_FILE hb_BCode( \"F\" )\n#define PG_DIAG_SOURCE_LINE hb_BCode( \"L\" )\n#define PG_DIAG_SOURCE_FUNCTION hb_BCode( \"R\" )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: StrToHtml. Harbour extra library: extras/hbxlsxml/xlsxml.prg. Defines classes: ExcelWriterXML. Provides functions: StrToHtml. This file provides spreadsheet generation capabilities"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"fileio.ch\"\n\nCREATE CLASS ExcelWriterXML\n\n VAR styles INIT {}\n VAR formatErrors INIT { => }\n VAR sheets INIT {}\n VAR lShowErrorSheet INIT .F.\n VAR overwriteFile INIT .F.\n VAR docFileName\n VAR cDocTitle\n VAR cDocSubject\n VAR cDocAuthor\n VAR cDocCreated\n VAR cDocManager\n VAR cDocCompany\n VAR cDocVersion INIT \"11.9999\"\n\n VAR cError INIT \"\"\n VAR errors INIT .F.\n\n METHOD New( fileName )\n METHOD setOverwriteFile( overwrite )\n METHOD showErrorSheet( show )\n METHOD addError( cFunction, cMessage )\n METHOD getDefaultStyle()\n METHOD addStyle( id )\n METHOD addSheet( id )\n METHOD checkSheetID( id )\n METHOD checkStyleID( id )\n METHOD writeData( target )\n METHOD docTitle( title )\n METHOD docSubject( subject )\n METHOD docAuthor( author )\n METHOD docManager( manager )\n METHOD docCompany( company )\n\nENDCLASS\n\nMETHOD ExcelWriterXML:new( fileName )\n\n LOCAL style\n\n style := ::addStyle( \"DEFAULT\" )\n style:name( \"Normal\" )\n style:alignVertical( \"Bottom\" )\n\n IF Empty( fileName )\n fileName := \"file.xml\"\n ENDIF\n\n ::docFileName := fileName\n ::cDocCreated := DToS( Date() ) + \"T\" + Time() + \"Z\"\n\n RETURN SELF\n\nMETHOD ExcelWriterXML:setOverwriteFile( overwrite )\n\n hb_default( @overwrite, .F. )\n\n ::overwriteFile := overwrite\n\n RETURN NIL\n\nMETHOD ExcelWriterXML:showErrorSheet( show )\n\n hb_default( @show, .T. )\n\n ::lShowErrorSheet := show\n\n RETURN NIL\n\nMETHOD ExcelWriterXML:addError( cFunction, cMessage )\n\n ::formatErrors += { ;\n \"FUNCTION\" => cFunction, ;\n \"MESSAGE\" => cMessage }\n\n RETURN NIL\n\nMETHOD ExcelWriterXML:getDefaultStyle()\n\n RETURN ::styles[ 1 ]\n\nMETHOD ExcelWriterXML:addStyle( id )\n\n LOCAL style\n\n STATIC s_styleNum := 1\n\n IF Empty( id )\n id := NIL\n ENDIF\n\n IF id == NIL\n id := \"CustomStyle\" + hb_ntos( s_styleNum )\n s_styleNum++\n ENDIF\n\n WHILE ! ::checkStyleID( id )\n id := \"CustomStyle\" + hb_ntos( s_styleNum )\n s_styleNum++\n ENDDO\n\n style := ExcelWriterXML_Style():new( id )\n AAdd( ::styles, style )\n\n RETURN style\n\nMETHOD ExcelWriterXML:addSheet( id )\n\n LOCAL sheet\n\n STATIC s_sheetNum := 1\n\n IF id == NIL\n id := \"Sheet\" + hb_ntos( s_sheetNum )\n s_sheetNum++\n ENDIF\n\n WHILE ! ::checkSheetID( id )\n id := \"Sheet\" + hb_ntos( s_sheetNum )\n s_sheetNum++\n ENDDO\n\n sheet := ExcelWriterXML_Sheet():New( id )\n AAdd( ::sheets, sheet )\n\n RETURN sheet\n\nMETHOD ExcelWriterXML:checkSheetID( id )\n\n LOCAL sheet\n\n IF Len( ::sheets ) > 0\n FOR EACH sheet IN ::sheets\n IF id == sheet:getID()\n RETURN .F.\n ENDIF\n NEXT\n ELSE\n RETURN .T.\n ENDIF\n\n RETURN .T.\n\nMETHOD ExcelWriterXML:checkStyleID( id )\n\n LOCAL style\n\n IF Len( ::styles ) > 0\n FOR EACH style IN ::styles\n IF id == style:getID()\n RETURN .F.\n ENDIF\n NEXT\n ELSE\n RETURN .T.\n ENDIF\n\n RETURN .T.\n\nMETHOD ExcelWriterXML:writeData( target )\n\n LOCAL style, sheet, xml := \"\", handle, fileExists, format\n\n LOCAL docTitle := \"\"\n LOCAL docSubject := \"\"\n LOCAL docAuthor := \"\"\n LOCAL docCreated := \"\"\n LOCAL docManager := \"\"\n LOCAL docCompany := \"\"\n\n IF target == NIL\n ::cError := \"Target filename missing!\"\n ::errors := .T.\n RETURN .T.\n ENDIF\n\n fileExists := hb_FileExists( target )\n IF fileExists .AND. ! ::overwriteFile\n ::cError := target + \" exists and overwriteFile is set to false\"\n ::errors := .T.\n RETURN .F.\n ENDIF\n handle := hb_FCreate( target, FC_NORMAL, FO_EXCLUSIVE )\n IF handle == F_ERROR\n ::cError := \"Not able to open \" + target + \" for writing\"\n ::errors := .T.\n RETURN .F.\n ENDIF\n\n IF ::lShowErrorSheet\n format := ::addStyle( \"formatErrorsHeader\" )\n format:setFontBold()\n format:bgColor( \"red\" )\n ENDIF\n\n IF ! Empty( ::cDocTitle ); docTitle := \"\" + StrToHtmlSpecial( ::cDocTitle ) + \"\" + hb_eol(); ENDIF\n IF ! Empty( ::cDocSubject ); docSubject := \"\" + StrToHtmlSpecial( ::cDocSubject ) + \"\" + hb_eol(); ENDIF\n IF ! Empty( ::cDocAuthor ); docAuthor := \"\" + StrToHtmlSpecial( ::cDocAuthor ) + \"\" + hb_eol(); ENDIF\n IF ! Empty( ::cDocCreated ); docCreated := \"\" + StrToHtmlSpecial( ::cDocCreated ) + \"\" + hb_eol(); ENDIF\n IF ! Empty( ::cDocManager ); docManager := \"\" + StrToHtmlSpecial( ::cDocManager ) + \"\" + hb_eol(); ENDIF\n IF ! Empty( ::cDocCompany ); docCompany := \"\" + StrToHtmlSpecial( ::cDocCompany ) + \"\" + hb_eol(); ENDIF\n\n xml := '' + hb_eol()\n xml += '' + hb_eol()\n xml += \"' + hb_eol()\n IF ! Empty( ::cDocTitle ); xml += \" \" + docTitle ; ENDIF\n IF ! Empty( ::cDocSubject ); xml += \" \" + docSubject; ENDIF\n IF ! Empty( ::cDocAuthor ); xml += \" \" + docAuthor ; ENDIF\n IF ! Empty( ::cDocCreated ); xml += \" \" + docCreated; ENDIF\n IF ! Empty( ::cDocManager ); xml += \" \" + docManager; ENDIF\n IF ! Empty( ::cDocCompany ); xml += \" \" + docCompany; ENDIF\n xml += \" \" + ::cDocVersion + \"\" + hb_eol()\n xml += \"\" + hb_eol()\n xml += '' + hb_eol()\n xml += \"\" + hb_eol()\n\n FWrite( handle, xml )\n xml := \"\"\n\n FOR EACH style IN ::styles\n xml += style:getStyleXML()\n NEXT\n xml += \"\" + hb_eol()\n\n FWrite( handle, xml )\n xml := \"\"\n\n IF Len( ::sheets ) == 0\n ::addSheet()\n ENDIF\n IF Len( ::sheets ) > 0\n FOR EACH sheet IN ::sheets\n xml += sheet:getSheetXML( handle )\n IF Len( sheet:getErrors() ) > 0\n ::errors := .T.\n ENDIF\n NEXT\n ENDIF\n IF Len( ::formatErrors ) > 0\n ::errors := .T.\n ENDIF\n\n xml += \"\"\n\n FWrite( handle, xml )\n xml := \"\"\n FClose( handle )\n\n RETURN .T.\n\nMETHOD ExcelWriterXML:docTitle( title )\n\n IF HB_ISSTRING( title )\n ::cDocTitle := title\n ENDIF\n\n RETURN NIL\n\nMETHOD ExcelWriterXML:docSubject( subject )\n\n IF HB_ISSTRING( subject )\n ::cDocSubject := subject\n ENDIF\n\n RETURN NIL\n\nMETHOD ExcelWriterXML:docAuthor( author )\n\n IF HB_ISSTRING( author )\n ::cDocAuthor := author\n ENDIF\n\n RETURN NIL\n\nMETHOD ExcelWriterXML:docManager( manager )\n\n IF HB_ISSTRING( manager )\n ::cDocManager := manager\n ENDIF\n\n RETURN NIL\n\nMETHOD ExcelWriterXML:docCompany( company )\n\n IF HB_ISSTRING( company )\n ::cDocCompany := company\n ENDIF\n\n RETURN NIL\n\nFUNCTION StrToHtml( xtxt )\n\n LOCAL afrm, i, xret := \"\", xpos\n\n afrm := { ;\n { \"á\", \"á\" }, ;\n { \"â\", \"â\" }, ;\n { \"à\", \"à\" }, ;\n { \"ã\", \"ã\" }, ;\n { \"ç\", \"ç\" }, ;\n { \"é\", \"é\" }, ;\n { \"ê\", \"ê\" }, ;\n { \"í\", \"í\" }, ;\n { \"ó\", \"ó\" }, ;\n { \"ô\", \"ô\" }, ;\n { \"õ\", \"õ\" }, ;\n { \"ú\", \"ú\" }, ;\n { \"ü\", \"ü\" }, ;\n { \"Á\", \"Á\" }, ;\n { \"Â\", \"Â\" }, ;\n { \"À\", \"À\" }, ;\n { \"Ã\", \"Ã\" }, ;\n { \"Ç\", \"Ç\" }, ;\n { \"É\", \"É\" }, ;"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hbrpc.ch. Defines 10 constants including: RPC_CH, RPC_LOOP_NONE, RPC_LOOP_SUMMARY, RPC_LOOP_ALLDATA, RPC_LOOP_CONFIRMATION"}, {"role": "assistant", "content": "#ifndef RPC_CH\n#define RPC_CH\n\n#define RPC_LOOP_NONE 0\n#define RPC_LOOP_SUMMARY 1\n#define RPC_LOOP_ALLDATA 2\n#define RPC_LOOP_CONFIRMATION 3\n\n#define RPC_STATUS_ERROR -1\n#define RPC_STATUS_NONE 0\n#define RPC_STATUS_CONNECTING 1\n#define RPC_STATUS_CONNECTED 2\n#define RPC_STATUS_LOGGED 3\n#define RPC_STATUS_WAITING 4\n\n#define RPCS_STATUS_BUSY -2\n#define RPCS_STATUS_ERROR -1\n#define RPCS_STATUS_NONE 0\n#define RPCS_STATUS_CHALLENGE 1\n#define RPCS_STATUS_LOGGED 2\n#define RPCS_STATUS_RUNNING 3\n#define RPCS_STATUS_CLOSED 10\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour header file: include/hbmath.ch. Defines 10 constants including: HB_MATH_CH_, HB_MATH_ERR_UNKNOWN, HB_MATH_ERR_NONE, HB_MATH_ERR_DOMAIN, HB_MATH_ERR_SING. Defines keyboard input constants"}, {"role": "assistant", "content": "#ifndef HB_MATH_CH_\n#define HB_MATH_CH_\n\n\n#define HB_MATH_ERR_UNKNOWN -1\n#define HB_MATH_ERR_NONE 0\n#define HB_MATH_ERR_DOMAIN 1\n#define HB_MATH_ERR_SING 2\n#define HB_MATH_ERR_OVERFLOW 3\n#define HB_MATH_ERR_UNDERFLOW 4\n#define HB_MATH_ERR_TLOSS 5\n#define HB_MATH_ERR_PLOSS 6\n\n\n#define HB_MATH_ERRMODE_DEFAULT 0 \n#define HB_MATH_ERRMODE_CDEFAULT 1 \n#define HB_MATH_ERRMODE_USER 2 \n#define HB_MATH_ERRMODE_USERDEFAULT 3 \n#define HB_MATH_ERRMODE_USERCDEFAULT 4 \n\n\n#define HB_MATHERRORBLOCK_RETVAL 1\n#define HB_MATHERRORBLOCK_HANDLED 2\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'gtwvg' (): contrib/gtwvg/tests/_utils.prg. Provides 14 functions including: wvt_Paint, Wvt_Mouse, WvtSetBlocks, WvtSetObjects, SetMouseCheck. Contains procedures: WvtSetKeys. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n\n#define WVT_OBJ_TYPE 1\n#define WVT_OBJ_ID 2\n#define WVT_OBJ_ROW 3\n#define WVT_OBJ_COL 4\n#define WVT_OBJ_ROWTO 5\n#define WVT_OBJ_COLTO 6\n#define WVT_OBJ_ONDISP 7\n#define WVT_OBJ_ONMOUSEOVER 8\n#define WVT_OBJ_ONBUTTONDOWN 9\n#define WVT_OBJ_ONBUTTONUP 10\n#define WVT_OBJ_TOOLTIP 11\n#define WVT_OBJ_STATE 12\n#define WVT_OBJ_DUMMY 13\n\n#define WVT_OBJ_VRBLS 13\n\n\n#define OBJ_TYPE_BUTTON 1\n\n\n#define OBJ_STATE_HIDE 0\n#define OBJ_STATE_DISP 1\n#define OBJ_STATE_MOUSEOVER 2\n#define OBJ_STATE_BUTTONDOWN 3\n#define OBJ_STATE_BUTTONUP 4\n\nTHREAD STATIC t_keys_ := {, , , , , , , , , , , , , , , , , , , }\nTHREAD STATIC t_pic_ := {, , , , , , , , , , , , , , , , , , , }\n\nPROCEDURE WvtSetKeys( lSet )\n\n IF lSet\n t_keys_[ 2 ] := SetKey( K_F2, {|| WvtNextGets() } )\n t_keys_[ 3 ] := SetKey( K_F3, {|| WvtWindowExpand( 1 ) } )\n t_keys_[ 4 ] := SetKey( K_F4, {|| WvtWindowExpand( -1 ) } )\n t_keys_[ 5 ] := SetKey( K_F5, {|| WvtMyBrowse() } )\n t_keys_[ 6 ] := SetKey( K_F6, {|| wvt_Minimize() } )\n t_keys_[ 7 ] := SetKey( K_F7, {|| WvtPartialScreen() } )\n t_keys_[ 8 ] := SetKey( K_F8, {|| WvtLines() } )\n t_keys_[ 9 ] := SetKey( K_F9, {|| wvt_ChooseFont() } )\n t_keys_[ 10 ] := SetKey( K_F10, {|| wvt_ChooseColor() } )\n ELSE\n SetKey( K_F2, t_keys_[ 2 ] )\n SetKey( K_F3, t_keys_[ 3 ] )\n SetKey( K_F4, t_keys_[ 4 ] )\n SetKey( K_F5, t_keys_[ 5 ] )\n SetKey( K_F6, t_keys_[ 6 ] )\n SetKey( K_F7, t_keys_[ 7 ] )\n SetKey( K_F8, t_keys_[ 8 ] )\n SetKey( K_F9, t_keys_[ 9 ] )\n SetKey( K_F10, t_keys_[ 10 ] )\n ENDIF\n\n RETURN\n\n\nFUNCTION wvt_Paint() \n\n LOCAL aBlocks := WvtSetBlocks()\n\n AEval( aBlocks, {| e | Eval( e ) } )\n\n WvtPaintObjects()\n\n RETURN 0\n\n\nFUNCTION Wvt_Mouse( nKey, nRow, nCol )\n\n LOCAL nLen, aObjects := WvtSetObjects()\n LOCAL nObj\n\n STATIC s_nLastObj := 0\n STATIC s_nLastKey := 0\n\n IF ( nLen := Len( aObjects ) ) == 0\n RETURN NIL\n ENDIF\n\n IF ! SetMouseCheck()\n RETURN NIL\n ENDIF\n\n IF nKey == -1000001\n FOR nObj := 1 TO nLen\n DO CASE\n CASE aObjects[ nObj ][ WVT_OBJ_STATE ] == OBJ_STATE_DISP\n Eval( aObjects[ nObj ][ WVT_OBJ_ONDISP ] )\n CASE aObjects[ nObj ][ WVT_OBJ_STATE ] == OBJ_STATE_MOUSEOVER\n Eval( aObjects[ nObj ][ WVT_OBJ_ONMOUSEOVER ] )\n CASE aObjects[ nObj ][ WVT_OBJ_STATE ] == OBJ_STATE_BUTTONDOWN\n Eval( aObjects[ nObj ][ WVT_OBJ_ONBUTTONDOWN ] )\n CASE aObjects[ nObj ][ WVT_OBJ_STATE ] == OBJ_STATE_BUTTONUP\n Eval( aObjects[ nObj ][ WVT_OBJ_ONDISP ] )\n CASE aObjects[ nObj ][ WVT_OBJ_STATE ] == OBJ_STATE_HIDE\n\n ENDCASE\n NEXT\n RETURN NIL\n ENDIF\n\n nObj := AScan( aObjects, {| e_ | e_[ WVT_OBJ_ROW ] <= nRow .AND. ;\n e_[ WVT_OBJ_ROWTO ] >= nRow .AND. ;\n e_[ WVT_OBJ_COL ] <= nCol .AND. ;\n e_[ WVT_OBJ_COLTO ] >= nCol } )\n IF nObj == 0\n IF s_nLastObj > 0\n aObjects[ s_nLastObj ][ WVT_OBJ_STATE ] := OBJ_STATE_DISP\n Eval( aObjects[ s_nLastObj ][ WVT_OBJ_ONDISP ] )\n s_nLastObj := 0\n ENDIF\n RETURN NIL\n ENDIF\n\n IF s_nLastObj == nObj .AND. s_nLastKey == nKey\n RETURN NIL\n ENDIF\n\n s_nLastObj := nObj\n s_nLastKey := nKey\n\n DO CASE\n CASE nKey == K_MOUSEMOVE\n IF aObjects[ s_nLastObj ][ WVT_OBJ_STATE ] != OBJ_STATE_MOUSEOVER\n aObjects[ s_nLastObj ][ WVT_OBJ_STATE ] := OBJ_STATE_MOUSEOVER\n IF aObjects[ nObj ][ WVT_OBJ_ONMOUSEOVER ] != NIL\n Eval( aObjects[ nObj ][ WVT_OBJ_ONMOUSEOVER ] )\n ENDIF\n ENDIF\n\n CASE nKey == K_LBUTTONDOWN\n aObjects[ s_nLastObj ][ WVT_OBJ_STATE ] := OBJ_STATE_BUTTONDOWN\n IF aObjects[ nObj ][ WVT_OBJ_ONBUTTONDOWN ] != NIL\n Eval( aObjects[ nObj ][ WVT_OBJ_ONBUTTONDOWN ] )\n ENDIF\n\n CASE nKey == K_LBUTTONUP\n aObjects[ s_nLastObj ][ WVT_OBJ_STATE ] := OBJ_STATE_DISP\n IF aObjects[ nObj ][ WVT_OBJ_ONBUTTONUP ] != NIL\n Eval( aObjects[ nObj ][ WVT_OBJ_ONBUTTONUP ] )\n ENDIF\n\n ENDCASE\n\n RETURN NIL\n\n\nFUNCTION WvtSetBlocks( a_ )\n\n LOCAL o\n\n THREAD STATIC t := {}\n\n o := AClone( t )\n\n IF a_ != NIL\n t := AClone( a_ )\n ENDIF\n\n RETURN o\n\n\nFUNCTION WvtSetObjects( aObject )\n\n LOCAL oObjects\n\n THREAD STATIC t_aObjects := {}\n\n oObjects := AClone( t_aObjects )\n\n IF aObject != NIL\n IF Empty( aObject )\n t_aObjects := {}\n ELSE\n IF HB_ISARRAY( aObject[ 1 ] )\n AEval( aObject, {| e_ | AAdd( t_aObjects, e_ ) } )\n ELSE\n ASize( aObject, WVT_OBJ_VRBLS )\n\n hb_default( @aObject[ WVT_OBJ_STATE ], OBJ_STATE_DISP )\n\n AAdd( t_aObjects, aObject )\n ENDIF\n ENDIF\n ENDIF\n\n RETURN oObjects\n\nFUNCTION SetMouseCheck( lYes )\n\n LOCAL lOYes\n STATIC s_lSYes := .T.\n\n lOYes := s_lSYes\n IF lYes != NIL\n s_lSYes := lYes\n ENDIF\n\n RETURN lOYes\n\nFUNCTION WvtWindowExpand( nUnits )\n\n STATIC s_nUnits := 18\n\n s_nUnits += nUnits\n\n wvt_SetFont( \"Courier New\", s_nUnits )\n\n RETURN .T.\n\nFUNCTION VouChoice( aChoices )\n\n LOCAL scr, clr, nChoice\n\n hb_default( @aChoices, { \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\" } )\n\n scr := SaveScreen( 7, 48, 13, 55 )\n clr := SetColor( \"N/W*,GR+/B*,,,GR+/B\" )\n\n nChoice := AChoice( 7, 48, 13, 55, aChoices )\n\n SetColor( clr )\n RestScreen( 7, 48, 13, 55, scr )\n\n RETURN nChoice\n\nFUNCTION Hb_Clear()\n\n CLS\n\n RETURN .F.\n\nFUNCTION MyMenuProcedure( nID )\n\n SWITCH nID\n CASE 101\n Alert( \"Procedure 101\" )\n EXIT\n CASE 102\n Alert( \"Procedure 102\" )\n EXIT\n ENDSWITCH\n\n RETURN .T.\n\nFUNCTION BuildWvgToolBar( oDA, nActiveX )\n\n LOCAL oTBar\n\n hb_default( @nActiveX, 0 )\n\n oTBar := WvgToolBar():new( oDA, , { 0, 0 }, { oDA:currentSize()[ 1 ], 30 }, , .T. )\n\n oTBar:style := WVGTOOLBAR_STYLE_FLAT\n oTBar:borderStyle := WVGFRAME_RECT\n\n oTBar:buttonWidth := 40 \n oTBar:buttonHeight := 26\n\n oTBar:imageWidth := 26\n oTBar:imageHeight := 24\n\n oTBar:showToolTips := .T.\n\n \n oTBar:create()\n\n oTBar:addItem( \"New\" , hb_DirBase() + \"v_new.bmp\" )\n oTBar:addItem( \"Select\" , hb_DirBase() + \"v_selct1.bmp\" )\n oTBar:addItem( \"Calendar\" , hb_DirBase() + \"v_calend.bmp\" )\n oTBar:addItem( \"Tools\" , hb_DirBase() + \"v_lock.bmp\" )\n oTBar:addItem( \"Index\" , hb_DirBase() + \"v_index.bmp\" )\n oTBar:addItem( \"Show\" , hb_DirBase() + \"v_clclt.bmp\" )\n oTBar:addItem( \"Hide\" , hb_DirBase() + \"v_notes1.bmp\" )\n\n RETURN oTBar\n\nFUNCTION SetGT( nIndex, pGT )\n\n LOCAL oldGT\n STATIC s_pGT_ := { NIL, NIL, NIL }\n\n oldGT := s_pGT_[ nIndex ]\n IF PCount() == 2\n s_pGT_[ nIndex ] := pGT\n ENDIF\n\n RETURN oldGT\n\nFUNCTION SetFonts( hFont )\n\n LOCAL oldFont\n\n THREAD STATIC t_ahFonts := {}\n oldFont := t_ahFonts\n IF ! Empty( hFont )\n AAdd( t_ahFonts, hFont )\n ENDIF\n\n RETURN oldFont\n\nFUNCTION SetIcons( hIcon )\n\n LOCAL oldIcon\n\n THREAD STATIC t_ahIcons := {}\n oldIcon := t_ahIcons\n IF ! Empty( hIcon )\n AAdd( t_ahIcons, hIcon )\n ENDIF\n\n RETURN oldIcon\n\nFUNCTION Popups( nID, lDestroy )\n\n THREAD STATIC t_hPop_ := { , , , , , , , , }\n\n LOCAL hPop, hPop1\n LOCAL nPrompt := MF_ENABLED + MF_STRING\n\n IF nID == NIL\n wvt_SetPopupMenu()\n RETURN NIL\n ENDIF\n\n IF lDestroy != NIL\n Wvt_DestroyMenu( t_hPop_[ nID ] )\n RETURN NIL\n ENDIF\n\n hPop := t_hPop_[ nID ]\n\n DO CASE\n CASE nID == 1 \n\n IF hPop == NIL\n hPop := Wvt_CreatePopupMenu()\n Wvt_AppendMenu( hPop, nPrompt, K_F2, \"Second Get Screen\" )\n Wvt_AppendMenu( hPop, nPrompt, K_F3, \"Expand Window\" )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbmzip' (ZIP file handling): contrib/hbmzip/tests/myzip.prg. Contains procedures: Main, ClipInit. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbmzip\"\n\n#include \"simpleio.ch\"\n\nREQUEST HB_CODEPAGE_UTF8EX\n\nPROCEDURE Main( ... )\n\n LOCAL hZip, aDir, aFile, aWild, ;\n cZipName, cPath, cFileName, cExt, cWild, cPassword, cComment, ;\n tmp\n LOCAL lUnicode\n\n IF \"--unicode\" $ hb_CmdLine()\n hb_cdpSelect( \"UTF8EX\" )\n hb_SetTermCP( hb_cdpTerm() )\n Set( _SET_OSCODEPAGE, hb_cdpOS() )\n lUnicode := .T.\n ELSE\n lUnicode := .F.\n ENDIF\n\n aWild := { ... }\n IF Len( aWild ) < 2\n ? \"Usage: myzip [ --pass ] [ --unicode ] [ --comment ] [ ... ]\"\n RETURN\n ENDIF\n\n hb_FNameSplit( aWild[ 1 ], @cPath, @cFileName, @cExt )\n IF Empty( cExt )\n cExt := \".zip\"\n ENDIF\n cZipName := hb_FNameMerge( cPath, cFileName, cExt )\n\n hb_ADel( aWild, 1, .T. )\n\n FOR tmp := Len( aWild ) - 1 TO 1 STEP -1\n IF Lower( aWild[ tmp ] ) == \"--pass\"\n IF Empty( cPassword )\n cPassword := aWild[ tmp + 1 ]\n ENDIF\n aWild[ tmp ] := \"\"\n aWild[ tmp + 1 ] := \"\"\n ELSEIF Lower( aWild[ tmp ] ) == \"--comment\"\n IF Empty( cComment )\n cComment := aWild[ tmp + 1 ]\n ENDIF\n aWild[ tmp ] := \"\"\n aWild[ tmp + 1 ] := \"\"\n ELSEIF Lower( aWild[ tmp ] ) == \"--unicode\"\n \n ENDIF\n NEXT\n\n hZip := hb_zipOpen( cZipName )\n IF ! Empty( hZip )\n ? \"Archive file:\", cZipName\n FOR EACH cWild IN aWild\n IF ! Empty( cWild )\n hb_FNameSplit( cWild, @cPath, @cFileName, @cExt )\n aDir := hb_DirScan( cPath, cFileName + cExt )\n FOR EACH aFile IN aDir\n IF ! cPath + aFile[ 1 ] == cZipName\n ? \"Adding\", cPath + aFile[ 1 ]\n hb_zipStoreFile( hZip, cPath + aFile[ 1 ], cPath + aFile[ 1 ], cPassword,, lUnicode )\n ENDIF\n NEXT\n ENDIF\n NEXT\n hb_zipClose( hZip, cComment )\n ENDIF\n\n RETURN\n\nINIT PROCEDURE ClipInit()\n\n IF \"--unicode\" $ hb_CmdLine()\n hb_cdpSelect( \"UTF8EX\" )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbsqlit3' (SQLite3 database client library): contrib/hbsqlit3/tests/pack.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbsqlit3\"\n\nPROCEDURE Main()\n\n LOCAL db := sqlite3_open_v2( \"new.s3db\", SQLITE_OPEN_READWRITE + SQLITE_OPEN_EXCLUSIVE )\n\n IF ! Empty( db )\n IF sqlite3_exec( db, \"VACUUM\" ) == SQLITE_OK\n ? \"PACK - Done\"\n\n sqlite3_sleep( 3000 )\n ENDIF\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour Runtime Library file: src/debug/dbgtinp.prg. Defines classes: HBDbInput. This file provides utility functions"}, {"role": "assistant", "content": "#pragma -b-\n\n#define HB_CLS_NOTOBJECT \n#include \"hbclass.ch\"\n\n#include \"inkey.ch\"\n#include \"color.ch\"\n#include \"setcurs.ch\"\n\n\nCREATE CLASS HBDbInput\n\n HIDDEN:\n\n VAR nRow AS INTEGER\n VAR nCol AS INTEGER\n VAR nWidth AS INTEGER\n VAR nPos AS INTEGER INIT 1\n VAR nFirst AS INTEGER INIT 1\n VAR nSize AS INTEGER\n VAR cValue AS CHARACTER\n VAR acColor AS ARRAY\n\n EXPORTED:\n\n METHOD new( nRow, nCol, nWidth, cValue, cColor, nSize )\n METHOD applyKey( nKey )\n METHOD getValue()\n METHOD setValue( cValue )\n METHOD display()\n METHOD showCursor()\n METHOD newPos( nRow, nCol )\n METHOD setColor( cColor )\n\nENDCLASS\n\nMETHOD new( nRow, nCol, nWidth, cValue, cColor, nSize ) CLASS HBDbInput\n\n ::nRow := nRow\n ::nCol := nCol\n ::nWidth := nWidth\n ::nSize := iif( HB_ISNUMERIC( nSize ), nSize, nWidth )\n ::cValue := PadR( cValue, ::nSize )\n\n ::setColor( cColor )\n\n RETURN Self\n\nMETHOD SetColor( cColor ) CLASS HBDbInput\n\n ::acColor := { hb_ColorIndex( cColor, CLR_STANDARD ), ;\n hb_ColorIndex( cColor, CLR_ENHANCED ) }\n IF hb_ColorToN( ::acColor[ 2 ] ) == -1\n ::acColor[ 2 ] := ::acColor[ 1 ]\n ENDIF\n\n RETURN Self\n\nMETHOD newPos( nRow, nCol ) CLASS HBDbInput\n\n ::nRow := nRow\n ::nCol := nCol\n\n RETURN Self\n\nMETHOD getValue() CLASS HBDbInput\n RETURN ::cValue\n\nMETHOD setValue( cValue ) CLASS HBDbInput\n\n ::cValue := PadR( cValue, ::nSize )\n ::nPos := Min( ::nSize, Len( RTrim( ::cValue ) ) + 1 )\n\n RETURN Self\n\nMETHOD display() CLASS HBDbInput\n\n IF ::nPos < ::nFirst\n ::nFirst := ::nPos\n ELSEIF ::nPos - ::nFirst >= ::nWidth\n ::nFirst := ::nPos - ::nWidth + 1\n ENDIF\n hb_DispOutAt( ::nRow, ::nCol, SubStr( ::cValue, ::nFirst, ::nWidth ), ;\n ::acColor[ 2 ] )\n\n RETURN Self\n\nMETHOD showCursor() CLASS HBDbInput\n\n SetPos( ::nRow, ::nCol + ::nPos - ::nFirst )\n SetCursor( iif( Set( _SET_INSERT ), SC_INSERT, SC_NORMAL ) )\n\n RETURN Self\n\nMETHOD applyKey( nKey ) CLASS HBDbInput\n\n LOCAL lUpdate := .T.\n\n SWITCH nKey\n CASE K_HOME\n ::nPos := 1\n EXIT\n CASE K_END\n ::nPos := Len( RTrim( ::cValue ) ) + 1\n IF ::nPos > ::nSize\n ::nPos := ::nSize\n ENDIF\n EXIT\n CASE K_LEFT\n IF ::nPos > 1\n ::nPos--\n ENDIF\n EXIT\n CASE K_RIGHT\n IF ::nPos < ::nSize\n ::nPos++\n ENDIF\n EXIT\n CASE K_DEL\n ::cValue := Stuff( ::cValue, ::nPos, 1, \"\" ) + \" \"\n EXIT\n CASE K_BS\n IF ::nPos > 1\n ::cValue := Stuff( ::cValue, --::nPos, 1, \"\" ) + \" \"\n ENDIF\n EXIT\n CASE K_CTRL_Y\n CASE K_CTRL_DEL\n ::cValue := Space( ::nSize )\n ::nPos := 1\n EXIT\n CASE K_INS\n Set( _SET_INSERT, ! Set( _SET_INSERT ) )\n EXIT\n OTHERWISE\n IF hb_keyChar( nKey ) == \"\"\n lUpdate := .F.\n ELSE\n IF Set( _SET_INSERT )\n ::cValue := Left( Stuff( ::cValue, ::nPos, 0, hb_keyChar( nKey ) ), ::nSize )\n ELSE\n ::cValue := Stuff( ::cValue, ::nPos, 1, hb_keyChar( nKey ) )\n ENDIF\n IF ::nPos < ::nSize\n ::nPos++\n ENDIF\n ENDIF\n ENDSWITCH\n\n IF lUpdate\n ::display()\n ENDIF\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour test program: tests/arrays.prg. Provides functions: Test, ReleaseTest. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL a := { 100, 200, \"Third\" }\n LOCAL b := Array( 10000 ) \n\n ? ValType( a )\n ? ValType( { \"A\" } )\n\n AAdd( a, \"new element\" )\n ? Len( a )\n\n ? a[ 1 ]\n ? a[ 2 ]\n ? a[ 3 ]\n ? a[ 4 ]\n\n ? ATail( a )\n\n a[ 3 ] := { \"this\", { \"seems\", \"to\", { \"work\", \"so\", \"well\" } } }\n ? a[ 3 ][ 2 ][ 3 ][ 1 ] \n\n a[ 3, 2 ][ 3, 1 ] := \"Harbour power!\" \n ? a[ 3, 2, 3, 1 ]\n\n ? ValType( b )\n ? Len( b )\n\n b[ 8000 ] := \"Harbour\"\n\n ? b[ 8000 ]\n\n ASize( b, 2000 )\n ? Len( b )\n\n b[ 1000 ] := 10\n Test( b[ 1000 ]++ )\n ? b[ 1000 ]\n\n b[ 1000 ] := 10\n Test( ++b[ 1000 ] )\n ? b[ 1000 ]\n\n b := { 1, { 2, { 4, 5 } } }\n Test( b[ 2 ][ 2 ][ 1 ]++ )\n ? b[ 2 ][ 2 ][ 1 ]\n\n b[ 2 ][ 2 ][ 1 ] := 2\n Test( ++b[ 2 ][ 2 ][ 1 ] )\n ? b[ 2 ][ 2 ][ 1 ]\n\n ReleaseTest()\n\n RETURN\n\nFUNCTION Test( n )\n\n ? n\n\n RETURN NIL\n\nFUNCTION ReleaseTest()\n\n LOCAL a := { 1, 2, 3 }\n\n HB_SYMBOL_UNUSED( a )\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/dates.prg. Contains procedures: Main, TestCentury. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL dDate, dDate2, cMask, cDate\n\n ? \"Testing Harbour dates management on\", Date()\n\n TestCentury()\n\n ?\n ? \"dDate := CToD( '02/04/1999' ) =>\", dDate := CToD( \"02/04/1999\" )\n\n ? \"ValType( dDate ) =\", ValType( dDate )\n\n ? \"Day( dDate ) =\", Day( dDate )\n ? \"Month( dDate ) =\", Month( dDate )\n ? \"Year( dDate ) =\", Year( dDate )\n ?\n\n ? \"dDate + 5 =\", dDate2 := dDate + 5\n ? \"dDate - 5 =\", dDate - 5\n ?\n\n ? \"dDate2 - dDate =\", dDate2 - dDate\n\n ?\n ? dDate, DToS( dDate )\n\n ? \"19990429\", hb_SToD( \"19990429\" )\n\n ?\n Set( _SET_EPOCH, 1950 )\n cMask := \"dd/mm/yyyy\"\n cDate := \"02/04/49\"\n Set( _SET_DATEFORMAT, cMask )\n dDate := CToD( cDate )\n ? cDate, cMask, dDate, DToS( dDate ), DToC( dDate )\n\n ?\n cMask := \"mm/dd/yyyy\"\n Set( _SET_DATEFORMAT, cMask )\n dDate := CToD( cDate )\n ? cDate, cMask, dDate, DToS( dDate ), DToC( dDate )\n\n ?\n cMask := \"yyyy/mm/dd\"\n Set( _SET_DATEFORMAT, cMask )\n dDate := CToD( cDate )\n ? cDate, cMask, dDate, DToS( dDate ), DToC( dDate )\n ?\n ? \"49/02/04\", cMask, CToD( \"49/02/04\" )\n\n TestCentury()\n\n ?\n cMask := \"yyyy/dd/mm\"\n Set( _SET_DATEFORMAT, cMask )\n dDate := CToD( cDate )\n ? cDate, cMask, dDate, DToS( dDate ), DToC( dDate )\n ?\n ? \"49/02/04\", cMask, CToD( \"49/02/04\" )\n\n ?\n cMask := \"ddd/mmm/yy\"\n Set( _SET_DATEFORMAT, cMask )\n dDate := CToD( cDate )\n ? cDate, cMask, dDate, DToS( dDate ), DToC( dDate )\n\n RETURN\n\nPROCEDURE TestCentury()\n\n ?\n ? __SetCentury()\n __SetCentury( \"ON\" )\n ?? __SetCentury()\n __SetCentury( \"OFF\" )\n ?? __SetCentury()\n __SetCentury( \"GIBBERISH\" )\n ?? __SetCentury()\n __SetCentury( .T. )\n ?? __SetCentury()\n __SetCentury( 5 )\n ?? __SetCentury()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/files.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "#define NFILES 1000\n\n\n#define WITH_DBFCDX\n\n\n#ifdef WITH_ADS\n#include \"ads.ch\"\nREQUEST _ADS\n#endif\n\nPROCEDURE Main()\n\n LOCAL aCampos := { ;\n { \"Codigo\", \"C\", 6, 0 }, ;\n { \"Nombre\", \"C\", 35, 0 } }\n\n LOCAL n := 0, h := Array( NFILES )\n\n#ifdef WITH_ADS\n\n rddRegister( \"ADS\", 1 )\n rddSetDefault( \"ADS\" )\n SET SERVER LOCAL\n SET FILETYPE TO CDX\n SET CHARTYPE TO OEM\n SET AXS LOCKING ON\n AdsRightsCheck( .F. )\n\n#endif\n\n CLS\n AFill( h, 0 )\n DO WHILE n < NFILES\n n++\n @ 10, 0 SAY \"Building files.... \" + Str( n )\n dbCreate( \"file\" + hb_ntos( n ), aCampos )\n USE ( \"file\" + hb_ntos( n ) ) NEW\n\n#ifdef WITH_ADS\n INDEX ON CODIGO TAG CODIGO TO ( \"file\" + hb_ntos( n ) )\n#endif\n\n CLOSE DATA\n ENDDO\n\n n := 0\n\n DO WHILE n < NFILES\n n++\n @ 12, 0 SAY \"Opening files.... \" + Str( n )\n USE ( \"file\" + hb_ntos( n ) ) NEW\n\n#ifdef WITH_ADS\n SET ORDER TO TAG CODIGO\n#endif\n\n ENDDO\n\n CLOSE DATA\n\n n := 0\n\n DO WHILE n < NFILES\n n++\n @ 14, 0 SAY \"Deleting files.... \" + Str( n )\n hb_dbDrop( \"file\" + hb_ntos( n ) + \".dbf\" )\n ENDDO\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/thtml.prg. Defines classes: THtmlDocument, THtmlIterator. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"error.ch\"\n#include \"hbclass.ch\"\n#include \"thtml.ch\"\n\n\n#xtrans P_PARSER( ) => { , 0, Len( ), 0 }\n#xtrans :p_str => \\[ 1 ] \n#xtrans :p_pos => \\[ 2 ] \n#xtrans :p_len => \\[ 3 ] \n#xtrans :p_end => \\[ 4 ] \n\n#xtrans P_SEEK( , ) => ( :p_end := :p_pos, :p_pos := hb_At( , :p_str, :p_end + 1 ) )\n#xtrans P_SEEKI( , ) => ( :p_end := :p_pos, :p_pos := hb_AtI( , :p_str, :p_end + 1 ) )\n#xtrans P_PEEK( , ) => ( :p_end := :p_pos, hb_LeftEqI( SubStr( :p_str, :p_pos ), ) )\n#xtrans P_NEXT( ) => ( :p_end := :p_pos, SubStr( :p_str, ++:p_pos, 1 ) )\n#xtrans P_PREV( ) => ( :p_end := :p_pos, SubStr( :p_str, --:p_pos, 1 ) )\n\n\n#define S_DATA 1 \n#define S_NUM 2 \n#define S_SIZE 3 \n#define S_STEP 4 \n\n#xtrans S_STACK() => S_STACK( 64 )\n#xtrans S_STACK( ) => { Array( ), 0, , Max( 32, Int( / 2 ) ) }\n#xtrans S_GROW( ) => ( iif( ++\\[S_NUM] > \\[S_SIZE], ASize( \\[S_DATA], ( \\[S_SIZE] += \\[S_STEP] ) ), ) )\n#xtrans S_SHRINK( ) => ( iif( \\[S_NUM] > 0 .AND. --\\[S_NUM] \\< \\[S_SIZE] - \\[S_STEP], ASize( \\[S_DATA], \\[S_SIZE] -= \\[S_STEP] ), ) )\n#xtrans S_COMPRESS( ) => ( ASize( \\[S_DATA], \\[S_SIZE] := \\[S_NUM] ) )\n#xtrans S_PUSH( , ) => ( S_GROW( ), \\[S_DATA, \\[S_NUM]] := )\n#xtrans S_POP( , @ ) => ( := \\[S_DATA, \\[S_NUM]], \\[S_DATA, \\[S_NUM]] := NIL, S_SHRINK( ) )\n#xtrans S_POP( ) => ( \\[S_DATA, \\[S_NUM]] := NIL, S_SHRINK( ) )\n#xtrans S_TOP( ) => ( \\[S_DATA, \\[S_NUM]] )\n\n\nTHREAD STATIC t_aHA \nTHREAD STATIC t_hHT \nTHREAD STATIC t_cHtmlCP := \"\"\nTHREAD STATIC t_aHtmlUnicEntities \nTHREAD STATIC t_cHtmlUnicChars\n#ifdef HB_LEGACY_LEVEL4\nTHREAD STATIC t_aHtmlAnsiEntities \nTHREAD STATIC t_cHtmlAnsiChars\n#endif\nTHREAD STATIC t_lInit := .F. \n\n#ifdef _DEBUG_\n#xtranslate HIDDEN: => EXPORTED: \n#endif\n\n\nCREATE CLASS THtmlDocument MODULE FRIENDLY\n\n HIDDEN:\n VAR oIterator\n VAR nodes\n\n EXPORTED:\n VAR root READONLY\n VAR head READONLY\n VAR body READONLY\n VAR changed INIT .T.\n\n METHOD new( cHtmlString )\n METHOD readFile( cFileName )\n METHOD writeFile( cFileName )\n\n METHOD collect()\n METHOD toString()\n METHOD getNode( cTagName )\n METHOD getNodes( cTagName )\n METHOD findFirst( cName, cAttrib, cValue, cData )\n METHOD findFirstRegex( cName, cAttrib, cValue, cData )\n METHOD findNext() INLINE ::oIterator:Next()\n\nENDCLASS\n\n\nMETHOD new( cHtmlString ) CLASS THtmlDocument\n\n LOCAL oSubNode, oErrNode, aHead, aBody, nMode := 0\n\n LOCAL cEmptyHtmlDoc := ;\n \"\" + hb_eol() + ;\n \"\" + hb_eol() + ;\n \" \" + hb_eol() + ;\n \" \" + hb_eol() + ;\n \" \" + hb_eol() + ;\n \" \" + hb_eol() + ;\n \"\"\n\n IF ! HB_ISSTRING( cHtmlString )\n ::root := THtmlNode():new( cEmptyHtmlDoc )\n ELSEIF \" 0\n IF ( nPos2 := hb_At( \">\", ::cReply, nPos + 1 ) ) > nPos\n cDigest := hb_MD5( SubStr( ::cReply, nPos, ( nPos2 - nPos ) + 1 ) + ::oUrl:cPassword )\n ::inetSendAll( ::SocketCon, \"APOP \" + ::oUrl:cUserid + \" \" + cDigest + ::cCRLF )\n IF ::GetOK()\n ::isOpen := .T.\n RETURN .T.\n ENDIF\n ENDIF\n ENDIF\n ENDIF\n\n RETURN .F.\n\nMETHOD Close( lAutoQuit ) CLASS TIPClientPOP\n\n ::InetTimeOut( ::SocketCon )\n\n IF hb_defaultValue( lAutoQuit, .T. )\n ::Quit()\n ENDIF\n\n RETURN ::super:Close()\n\nMETHOD Delete( nId ) CLASS TIPClientPOP\n\n ::inetSendAll( ::SocketCon, \"DELE \" + hb_ntos( Int( nId ) ) + ::cCRLF )\n\n RETURN ::GetOk()\n\nMETHOD List() CLASS TIPClientPOP\n\n LOCAL nPos\n LOCAL cStr, cRet\n\n ::inetSendAll( ::SocketCon, \"LIST\" + ::cCRLF )\n IF ! ::GetOk()\n RETURN NIL\n ENDIF\n\n cRet := \"\"\n DO WHILE ! cStr == \".\" .AND. ::inetErrorCode( ::SocketCon ) == 0\n cStr := ::inetRecvLine( ::SocketCon, @nPos, 256 )\n IF ! HB_ISSTRING( cStr ) .OR. cStr == \".\"\n ::bEof := .T.\n ELSE\n cRet += cStr + ::cCRLF\n ENDIF\n ENDDO\n\n IF ::inetErrorCode( ::SocketCon ) != 0\n RETURN NIL\n ENDIF\n\n RETURN cRet\n\nMETHOD Noop() CLASS TIPClientPOP\n\n ::inetSendAll( ::SocketCon, \"NOOP\" + ::cCRLF )\n\n RETURN ::GetOk()\n\nMETHOD Retrieve( nId, nLen ) CLASS TIPClientPOP\n\n LOCAL nPos\n LOCAL cRet, nRetLen, cBuffer, nRead\n LOCAL cEOM := ::cCRLF + \".\" + ::cCRLF \n\n IF ! ::bInitialized\n ::inetSendAll( ::SocketCon, \"RETR \" + hb_ntos( Int( nId ) ) + ::cCRLF )\n IF ! ::GetOk()\n ::bEof := .T.\n RETURN NIL\n ENDIF\n ::bInitialized := .T.\n ENDIF\n\n cRet := \"\"\n nRetLen := 0\n \n DO WHILE ::inetErrorCode( ::SocketCon ) == 0 .AND. ! ::bEof\n\n cBuffer := Space( 1024 )\n\n nRead := ::inetRecv( ::SocketCon, @cBuffer, hb_BLen( cBuffer ) )\n\n cRet += hb_BLeft( cBuffer, nRead )\n\n \n IF ( nPos := hb_BAt( cEOM, cRet, Max( nRetLen - hb_BLen( cEOM ), 1 ) ) ) > 0\n \n cRet := hb_BLeft( cRet, nPos + 1 )\n ::bEof := .T.\n\n ELSEIF HB_ISNUMERIC( nLen ) .AND. nLen < hb_BLen( cRet ) \n EXIT\n ELSE\n nRetLen += nRead\n ENDIF\n ENDDO\n\n IF ::inetErrorCode( ::SocketCon ) != 0\n RETURN NIL\n ENDIF\n\n \n RETURN StrTran( cRet, ::cCRLF + \"..\", ::cCRLF + \".\" )\n\nMETHOD Rset() CLASS TIPClientPOP\n\n ::inetSendAll( ::SocketCon, \"RSET\" + ::cCRLF )\n\n RETURN ::GetOk()\n\nMETHOD Stat() CLASS TIPClientPOP\n\n LOCAL nRead\n\n ::inetSendAll( ::SocketCon, \"STAT\" + ::cCRLF )\n\n RETURN ::inetRecvLine( ::SocketCon, @nRead, 128 )\n\nMETHOD Top( nMsgId ) CLASS TIPClientPOP\n\n LOCAL nPos\n LOCAL cStr, cRet\n\n ::inetSendAll( ::SocketCon, \"TOP \" + hb_ntos( Int( nMsgId ) ) + \" 0\" + ::cCRLF )\n IF ! ::GetOk()\n RETURN NIL\n ENDIF\n\n cRet := \"\"\n DO WHILE ! cStr == \".\" .AND. ::inetErrorCode( ::SocketCon ) == 0\n cStr := ::inetRecvLine( ::SocketCon, @nPos, 512 )\n IF ! HB_ISSTRING( cStr ) .OR. cStr == \".\"\n ::bEof := .T.\n ELSE\n cRet += cStr + ::cCRLF\n ENDIF\n ENDDO\n\n IF ::inetErrorCode( ::SocketCon ) != 0\n RETURN NIL\n ENDIF\n\n RETURN cRet\n\nMETHOD Quit() CLASS TIPClientPOP\n\n ::inetSendAll( ::SocketCon, \"QUIT\" + ::cCRLF )\n\n RETURN ::GetOk()\n\nMETHOD UIDL( nMsgId ) CLASS TIPClientPOP\n\n LOCAL nPos\n LOCAL cStr, cRet\n\n IF HB_ISNUMERIC( nMsgId ) .AND. nMsgId >= 1\n ::inetSendAll( ::SocketCon, \"UIDL \" + hb_ntos( Int( nMsgId ) ) + ::cCRLF )\n ELSE\n ::inetSendAll( ::SocketCon, \"UIDL\" + ::cCRLF )\n ENDIF\n\n IF ! ::GetOk()\n RETURN NIL\n ENDIF\n\n IF Empty( nMsgId )\n cRet := \"\"\n DO WHILE ! cStr == \".\" .AND. ::inetErrorCode( ::SocketCon ) == 0\n cStr := ::inetRecvLine( ::SocketCon, @nPos, 256 )\n IF ! HB_ISSTRING( cStr ) .OR. cStr == \".\"\n ::bEof := .T.\n ELSE\n cRet += cStr + ::cCRLF\n ENDIF\n ENDDO\n ELSE\n \n RETURN SubStr( ::cReply, RAt( Space( 1 ), ::cReply ) + 1 )\n ENDIF\n\n IF ::inetErrorCode( ::SocketCon ) != 0\n RETURN NIL\n ENDIF\n\n RETURN cRet\n\nMETHOD countMail() CLASS TIPClientPop\n\n LOCAL cStat\n\n IF ::isOpen\n ::reset()\n cStat := ::Stat()\n IF HB_ISSTRING( cStat ) .AND. hb_LeftEq( cStat, \"+OK\" )\n RETURN Val( SubStr( cStat, 4, hb_At( \" \", cStat, 5 ) - 4 ) )\n ENDIF\n ENDIF\n\n RETURN -1\n\nMETHOD GetOk() CLASS TIPClientPOP\n\n ::cReply := ::inetRecvLine( ::SocketCon,, 128 )\n\n RETURN ::inetErrorCode( ::SocketCon ) == 0 .AND. ;\n HB_ISSTRING( ::cReply ) .AND. hb_LeftEq( ::cReply, \"+\" )\n\n\nMETHOD Read( nLen ) CLASS TIPClientPOP\n\n \n IF Empty( ::oUrl:cFile )\n RETURN ::List() \n ELSEIF Val( ::oUrl:cFile ) < 0\n RETURN ::Delete( -Val( ::oUrl:cFile ) ) .AND. ::Quit() \n ENDIF\n\n RETURN ::Retrieve( Val( ::oUrl:cFile ), nLen ) \n\nMETHOD retrieveAll( lDelete ) CLASS TIPClientPOP\n\n LOCAL aMails, oMail\n\n IF ::isOpen\n\n hb_default( @lDelete, .F. )\n\n FOR EACH oMail IN aMails := Array( ::countMail() )\n ::reset()\n\n oMail := TIPMail():new()\n oMail:fromString( ::retrieve( oMail:__enumIndex() ) )\n\n IF lDelete\n ::reset()\n ::delete( oMail:__enumIndex() )\n ENDIF\n NEXT\n ENDIF\n\n RETURN aMails\n\nMETHOD getTop( nMsgId ) CLASS TIPClientPOP\n\n LOCAL nPos, cStr, xRet\n\n ::inetSendAll( ::SocketCon, \"TOP \" + hb_ntos( Int( nMsgId ) ) + \" 0\" + ::cCRLF )\n IF ! ::GetOk()\n RETURN NIL\n ENDIF\n\n xRet := cStr := \"\"\n DO WHILE ! cStr == \".\" .AND. ::inetErrorCode( ::SocketCon ) == 0\n cStr := ::inetRecvLine( ::SocketCon, @nPos, 1024 )\n IF HB_ISSTRING( cStr ) .AND. ! cStr == \".\"\n xRet += cStr + ::cCRLF\n ENDIF\n ENDDO\n\n RETURN xRet\n\nMETHOD getMessageRaw( nMsgId ) CLASS TIPClientPOP\n\n LOCAL cLine, nBytes, xRet\n\n ::inetSendAll( ::SocketCon, \"RETR \" + hb_ntos( Int( nMsgId ) ) + ::cCRLF )\n IF ! ::GetOk()\n RETURN NIL\n ENDIF\n\n xRet := \"\"\n DO WHILE ::inetErrorCode( ::SocketCon ) == 0\n cLine := ::inetRecvLine( ::SocketCon, @nBytes, 8192 )\n IF nBytes <= 0 .OR. ! HB_ISSTRING( cLine ) .OR. cLine == \".\"\n EXIT\n ENDIF\n xRet += cLine + ::cCRLF\n ENDDO\n\n RETURN xRet\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/mailassy.prg. Provides functions: hb_MailAssemble, tip_MailAssemble, s_TransCP. This file provides network protocol implementations"}, {"role": "assistant", "content": "#if defined( HB_LEGACY_LEVEL4 )\nFUNCTION hb_MailAssemble( ... )\n RETURN tip_MailAssemble( ... )\n#endif\n\nFUNCTION tip_MailAssemble( ;\n cFrom, ; \n xTo, ; \n xCC, ; \n cBody, ; \n cSubject, ; \n aFiles, ; \n nPriority, ; \n lRead, ; \n cReplyTo, ; \n cCharset, ; \n cEncoding, ; \n lBodyHTML, ; \n bSMIME ) \n\n LOCAL oMail\n LOCAL oAttach\n LOCAL aThisFile\n LOCAL cMimeType\n LOCAL cFile\n LOCAL cData\n LOCAL cContentType\n LOCAL nAttr\n\n LOCAL cCharsetCP\n LOCAL tmp\n\n IF Empty( cFrom ) .OR. ! HB_ISSTRING( cFrom )\n RETURN \"\"\n ENDIF\n IF Empty( xTo ) .OR. ( ! HB_ISSTRING( xTo ) .AND. ! HB_ISARRAY( xTo ) )\n RETURN \"\"\n ENDIF\n\n hb_default( @cBody, \"\" )\n hb_default( @cSubject, \"\" )\n hb_default( @aFiles, {} )\n nPriority := Int( hb_defaultValue( nPriority, 3 ) )\n hb_default( @lRead, .F. )\n hb_default( @cReplyTo, \"\" )\n hb_default( @cCharset, \"UTF-8\" )\n hb_default( @cEncoding, \"quoted-printable\" )\n hb_default( @lBodyHTML, .F. )\n\n \n IF Upper( cCharset ) == \"UTF-8\"\n cCharsetCP := \"UTF8\"\n ELSEIF hb_cdpExists( Lower( cCharset ) )\n cCharsetCP := hb_cdpUniID( Lower( cCharset ) )\n ENDIF\n\n cContentType := iif( lBodyHTML, \"text/html\", \"text/plain\" ) + \"; charset=\" + cCharset\n\n \n IF ! Right( cBody, 2 ) == Chr( 13 ) + Chr( 10 )\n cBody += Chr( 13 ) + Chr( 10 )\n ENDIF\n\n \n IF ! Empty( cCharsetCP )\n xTo := s_TransCP( xTo, cCharsetCP )\n xCC := s_TransCP( xCC, cCharsetCP )\n cFrom := s_TransCP( cFrom, cCharsetCP )\n cBody := s_TransCP( cBody, cCharsetCP )\n cSubject := s_TransCP( cSubject, cCharsetCP )\n ENDIF\n\n oMail := TIPMail():New()\n oMail:SetEncoder( cEncoding )\n oMail:SetCharset( cCharset )\n IF Empty( aFiles )\n oMail:hHeaders[ \"Content-Type\" ] := cContentType\n oMail:SetBody( cBody )\n ELSE\n oAttach := TIPMail():New()\n oAttach:SetEncoder( cEncoding )\n oAttach:SetCharset( cCharset )\n oAttach:hHeaders[ \"Content-Type\" ] := cContentType\n oAttach:SetBody( cBody )\n oMail:Attach( oAttach )\n\n FOR EACH aThisFile IN aFiles\n\n cMimeType := NIL\n nAttr := 0\n\n DO CASE\n CASE HB_ISSTRING( aThisFile )\n cFile := aThisFile\n cData := hb_MemoRead( cFile )\n hb_vfAttrGet( cFile, @nAttr )\n CASE HB_ISARRAY( aThisFile ) .AND. Len( aThisFile ) >= 2\n cFile := aThisFile[ 1 ]\n IF HB_ISSTRING( aThisFile[ 2 ] )\n cData := aThisFile[ 2 ]\n hb_default( @cFile, \"unnamed\" )\n ELSEIF HB_ISSTRING( cFile )\n cData := hb_MemoRead( cFile )\n hb_vfAttrGet( cFile, @nAttr )\n ELSE\n LOOP \n ENDIF\n IF Len( aThisFile ) >= 3 .AND. HB_ISSTRING( aThisFile[ 3 ] )\n cMimeType := aThisFile[ 3 ]\n ENDIF\n OTHERWISE\n LOOP\n ENDCASE\n\n IF cMimeType == NIL\n cMimeType := tip_FileNameMimeType( cFile, \"application/octet-stream\" )\n ENDIF\n cFile := s_TransCP( cFile, cCharsetCP )\n\n oAttach := TIPMail():New()\n oAttach:SetCharset( cCharset )\n oAttach:SetEncoder( iif( hb_LeftEq( cMimeType, \"text/\" ), cEncoding, \"base64\" ) )\n\n IF cMimeType == \"text/html\"\n cMimeType += \"; charset=\" + cCharset\n IF ! Right( cData, 2 ) == Chr( 13 ) + Chr( 10 )\n cData += Chr( 13 ) + Chr( 10 )\n ENDIF\n ENDIF\n \n cMimeType += \"; name=\" + '\"' + hb_FNameNameExt( cFile ) + '\"'\n IF ( nAttr := __tip_FAttrToUmask( nAttr ) ) != 0\n cMimeType += \"; x-unix-mode=\" + '\"' + hb_NumToHex( nAttr, 4 ) + '\"'\n ENDIF\n oAttach:hHeaders[ \"Content-Type\" ] := cMimeType\n \n oAttach:hHeaders[ \"Content-Disposition\" ] := \"attachment; filename=\" + '\"' + hb_FNameNameExt( cFile ) + '\"'\n oAttach:SetBody( cData )\n oMail:Attach( oAttach )\n NEXT\n ENDIF\n\n IF HB_ISEVALITEM( bSMIME ) .AND. ;\n HB_ISSTRING( tmp := Eval( bSMIME, oMail:ToString() ) )\n\n oMail := TIPMail():New()\n oMail:SetCharset( cCharset )\n ELSE\n tmp := NIL\n ENDIF\n\n oMail:SetHeader( cSubject, cFrom, xTo, xCC )\n oMail:hHeaders[ \"Date\" ] := tip_TimeStamp()\n IF ! Empty( cReplyTo )\n oMail:hHeaders[ \"Reply-to\" ] := cReplyTo\n ENDIF\n IF lRead\n oMail:hHeaders[ \"Disposition-Notification-To\" ] := tip_GetRawEmail( cFrom )\n ENDIF\n IF nPriority != 3\n oMail:hHeaders[ \"X-Priority\" ] := hb_ntos( nPriority )\n ENDIF\n\n RETURN iif( HB_ISSTRING( tmp ), oMail:HeadersToString() + tmp, oMail:ToString() )\n\nSTATIC FUNCTION s_TransCP( xData, cCP )\n\n LOCAL tmp\n\n IF ! Empty( cCP )\n DO CASE\n CASE HB_ISSTRING( xData )\n RETURN hb_Translate( xData,, cCP )\n CASE HB_ISARRAY( xData )\n FOR EACH tmp IN xData\n tmp := hb_Translate( tmp,, cCP )\n NEXT\n ENDCASE\n ENDIF\n\n RETURN xData"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour header file: include/hbsxdef.ch. Defines 10 constants including: HB_SIX_DEF_CH_, EVENT_PREUSE, EVENT_POSTUSE, EVENT_UPDATE, EVENT_APPEND. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_SIX_DEF_CH_\n#define HB_SIX_DEF_CH_\n\n\n#define EVENT_PREUSE 1\n#define EVENT_POSTUSE 2\n#define EVENT_UPDATE 3\n#define EVENT_APPEND 4\n#define EVENT_DELETE 5\n#define EVENT_RECALL 6\n#define EVENT_PACK 7\n#define EVENT_ZAP 8\n#define EVENT_PUT 9\n#define EVENT_GET 10\n#define EVENT_PRECLOSE 11\n#define EVENT_POSTCLOSE 12\n#define EVENT_PREMEMOPACK 13\n#define EVENT_POSTMEMOPACK 14\n\n\n#define TRIGGER_ENABLE 1\n#define TRIGGER_DISABLE 2\n#define TRIGGER_REMOVE 3\n#define TRIGGER_INSTALL 4\n#define TRIGGER_PENDING 5 \n\n\n#define BLOB_FILECOMPRESS 1\n#define BLOB_FILEENCRYPT 2\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnetio' (Network I/O operations): contrib/hbnetio/utils/hbnetio/_console.prg. Provides functions: hbnetiocon_GetHidden. Contains 5 procedures. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"color.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\n#include \"hbgtinfo.ch\"\n\nPROCEDURE hbnetiocon_cmdUI( cIP, nPort, cPassword )\n\n LOCAL GetList := {}\n LOCAL hCommands\n LOCAL nSavedRow\n LOCAL nPos\n LOCAL aCommand\n LOCAL cCommand\n\n LOCAL bKeyDown\n LOCAL bKeyUp\n LOCAL bKeyIns\n LOCAL bKeyPaste\n LOCAL bKeyTab\n\n LOCAL aHistory, nHistIndex\n\n LOCAL lQuit\n\n LOCAL netclictrl := __hbshell_plugin()\n LOCAL netclictx\n LOCAL netcliID\n\n LOCAL hConIO := { ;\n \"displine\" => {| c | hbnetiocon_ToConsole( c ) }, ;\n \"gethidden\" => {|| hbnetiocon_GetHidden() } }\n\n Set( _SET_CONFIRM, .F. )\n Set( _SET_SCOREBOARD, .F. )\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n Set( _SET_TIMEFORMAT, \"hh:mm:ss\" )\n\n SetCancel( .F. )\n\n netclictx := Eval( netclictrl[ \"init\" ], hConIO, { ;\n \"--netio.addr=\" + cIP + \":\" + hb_ntos( nPort ), ;\n \"--netio.pass=\" + cPassword } )\n IF ! Empty( netclictx )\n netcliID := netclictrl[ \"id\" ]\n ENDIF\n\n hbnetiocon_ToConsole( \"Type a command or '?' for help.\" )\n\n aHistory := { \"quit\" }\n nHistIndex := Len( aHistory ) + 1\n\n hCommands := { ;\n \"?\" => { \"\", \"Synonym for 'help'.\" , {|| ShowHelp( hCommands ), Eval( netclictrl[ \"cmd\" ], netclictx, \"?\" ) } }, ;\n \"help\" => { \"\", \"Display this help.\" , {|| ShowHelp( hCommands ), Eval( netclictrl[ \"cmd\" ], netclictx, \"?\" ) } }, ;\n \"quit\" => { \"\", \"Exit console.\" , {|| lQuit := .T. } } }\n\n lQuit := .F.\n\n DO WHILE ! lQuit\n\n cCommand := Space( 128 )\n\n QQOut( \"$ \" )\n nSavedRow := Row()\n\n @ nSavedRow, Col() GET cCommand PICTURE \"@S\" + hb_ntos( MaxCol() - Col() + 1 ) COLOR hb_ColorIndex( SetColor(), CLR_STANDARD ) + \",\" + hb_ColorIndex( SetColor(), CLR_STANDARD )\n\n SetCursor( iif( ReadInsert(), SC_INSERT, SC_NORMAL ) )\n\n bKeyIns := SetKey( K_INS, ;\n {|| SetCursor( iif( ReadInsert( ! ReadInsert() ), ;\n SC_NORMAL, SC_INSERT ) ) } )\n bKeyUp := SetKey( K_UP, ;\n {|| iif( nHistIndex > 1, ;\n cCommand := PadR( aHistory[ --nHistIndex ], Len( cCommand ) ), ), ;\n ManageCursor( cCommand ) } )\n bKeyDown := SetKey( K_DOWN, ;\n {|| cCommand := PadR( iif( nHistIndex < Len( aHistory ), ;\n aHistory[ ++nHistIndex ], ;\n ( nHistIndex := Len( aHistory ) + 1, \"\" ) ), Len( cCommand ) ), ;\n ManageCursor( cCommand ) } )\n bKeyPaste := SetKey( K_ALT_V, {|| hb_gtInfo( HB_GTI_CLIPBOARDPASTE, .T. ) } )\n\n bKeyTab := SetKey( K_TAB, {|| CompleteCmd( @cCommand, hCommands ) } )\n\n READ\n\n \n SetPos( nSavedRow, MaxCol() - 1 )\n\n SetKey( K_ALT_V, bKeyPaste )\n SetKey( K_DOWN, bKeyDown )\n SetKey( K_UP, bKeyUp )\n SetKey( K_INS, bKeyIns )\n SetKey( K_TAB, bKeyTab )\n\n QQOut( hb_eol() )\n\n cCommand := AllTrim( cCommand )\n\n IF Empty( cCommand )\n LOOP\n ENDIF\n\n IF Empty( aHistory ) .OR. ! ATail( aHistory ) == cCommand\n IF Len( aHistory ) < 64\n AAdd( aHistory, cCommand )\n ELSE\n ADel( aHistory, 1 )\n aHistory[ Len( aHistory ) ] := cCommand\n ENDIF\n ENDIF\n nHistIndex := Len( aHistory ) + 1\n\n aCommand := hb_ATokens( cCommand, \" \" )\n IF ! Empty( aCommand )\n IF ( nPos := hb_HPos( hCommands, Lower( aCommand[ 1 ] ) ) ) > 0\n Eval( hb_HValueAt( hCommands, nPos )[ 3 ], cCommand )\n ELSE\n IF Left( cCommand, Len( netcliID ) + 1 ) == netcliID + \".\"\n IF ! Eval( netclictrl[ \"cmd\" ], netclictx, SubStr( cCommand, Len( netcliID ) + 2 ) )\n hbnetiocon_ToConsole( hb_StrFormat( \"Error: Unrecognized command '%1$s'.\", cCommand ) )\n ENDIF\n ELSE\n IF ! Eval( netclictrl[ \"cmd\" ], netclictx, cCommand )\n hbnetiocon_ToConsole( hb_StrFormat( \"Error: Unrecognized command '%1$s'.\", cCommand ) )\n ENDIF\n ENDIF\n ENDIF\n ENDIF\n ENDDO\n\n Eval( netclictrl[ \"exit\" ], netclictx )\n\n RETURN\n\n\nSTATIC PROCEDURE ManageCursor( cCommand )\n\n hb_keyPut( K_HOME )\n IF ! Empty( cCommand )\n hb_keyPut( K_END )\n ENDIF\n\n RETURN\n\n\nSTATIC PROCEDURE CompleteCmd( cCommand, hCommands )\n\n LOCAL s := Lower( AllTrim( cCommand ) )\n LOCAL n\n\n \n IF Len( s ) > 1\n FOR EACH n IN hCommands\n IF s == Lower( Left( n:__enumKey(), Len( s ) ) )\n cCommand := PadR( n:__enumKey(), Len( cCommand ) )\n ManageCursor( cCommand )\n RETURN\n ENDIF\n NEXT\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE ShowHelp( hCommands )\n\n LOCAL aTexts := {}\n LOCAL n, c, m\n\n m := 8\n hb_HEval( hCommands, {| k, l | m := Max( m, Len( k + iif( Empty( l[ 1 ] ), \"\", \" \" + l[ 1 ] ) ) ) } )\n\n AAdd( aTexts, \"Commands:\" )\n\n \n FOR EACH n IN hCommands\n AAdd( aTexts, \" \" + PadR( n:__enumKey() + iif( Empty( n[ 1 ] ), \"\", \" \" + n[ 1 ] ), m ) + \" - \" + n[ 2 ] )\n NEXT\n AAdd( aTexts, \"\" )\n\n AAdd( aTexts, \"Keyboard shortcuts:\" )\n AAdd( aTexts, PadR( \" \", m ) + \" - Move up on historic list.\" )\n AAdd( aTexts, PadR( \" \", m ) + \" - Move down on historic list.\" )\n AAdd( aTexts, PadR( \" \", m ) + \" - Complete command.\" )\n AAdd( aTexts, PadR( \" \", m ) + \" - Paste from clipboard.\" )\n AAdd( aTexts, \"\" )\n\n c := 0\n m := MaxRow()\n\n FOR EACH n IN aTexts\n hbnetiocon_ToConsole( n )\n\n IF ++c == m\n c := 0\n QQOut( \"Press any key to continue...\" )\n Inkey( 0 )\n\n Scroll( Row(), 0, Row(), MaxCol() )\n SetPos( Row(), 0 )\n ENDIF\n NEXT\n\n RETURN\n\nSTATIC PROCEDURE hbnetiocon_ToConsole( cText )\n\n QQOut( cText + hb_eol() )\n\n RETURN\n\nSTATIC FUNCTION hbnetiocon_GetHidden()\n\n LOCAL GetList := {}\n LOCAL cPassword := Space( 128 )\n LOCAL nSavedRow\n LOCAL bKeyPaste\n\n QQOut( \"Enter password: \" )\n\n nSavedRow := Row()\n\n AAdd( GetList, hb_Get():New( Row(), Col(), {| v | iif( PCount() == 0, cPassword, cPassword := v ) }, \"cPassword\", \"@S\" + hb_ntos( MaxCol() - Col() + 1 ), hb_ColorIndex( SetColor(), CLR_STANDARD ) + \",\" + hb_ColorIndex( SetColor(), CLR_STANDARD ) ) )\n ATail( GetList ):hideInput( .T. )\n ATail( GetList ):postBlock := {|| ! Empty( cPassword ) }\n ATail( GetList ):display()\n\n SetCursor( iif( ReadInsert(), SC_INSERT, SC_NORMAL ) )\n bKeyPaste := SetKey( K_ALT_V, {|| hb_gtInfo( HB_GTI_CLIPBOARDPASTE, .T. ) } )\n\n READ\n\n \n SetPos( nSavedRow, MaxCol() - 1 )\n SetKey( K_ALT_V, bKeyPaste )\n\n QQOut( hb_eol() )\n\n RETURN AllTrim( cPassword )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/pickday.prg. Provides functions: ft_PickDay. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_PickDay()\n\n LOCAL days := { \"SUNDAY\", \"MONDAY\", \"TUESDAY\", \"WEDNESDAY\", \"THURSDAY\", ;\n \"FRIDAY\", \"SATURDAY\" }\n LOCAL sel := 0\n LOCAL oldscrn := SaveScreen( 8, 35, 16, 45 ), oldcolor := SetColor( \"+w/r\" )\n\n hb_DispBox( 8, 35, 16, 45, hb_UTF8ToStrBox( \"┌─┐│┘─└│ \" ) )\n \n DO WHILE sel == 0\n sel := AChoice( 9, 36, 15, 44, days )\n ENDDO\n \n RestScreen( 8, 35, 16, 45, oldscrn )\n SetColor( oldcolor )\n\n RETURN days[ sel ]"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/eltime.prg. Provides functions: ft_ElTime. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_ElTime( cTIME1, cTIME2 )\n\n LOCAL nDELSECS, nHRS, nMINS, nSECS, nSECS1, nSECS2\n\n nSECS1 := ( Val( SubStr( cTIME1, 1, 2 ) )\n Right( \"00\" + hb_ntos( nHRS ), 2 ) + ;\n \":\" + ;\n Right( \"00\" + hb_ntos( nMINS ), 2 ) + ;\n \":\" + ;\n Right( \"00\" + hb_ntos( nSECS ), 2 )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/tcgi.prg. Defines classes: TCgi. Provides functions: ParseString, CgiParseVar. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"cgi.ch\"\n\nCREATE CLASS TCgi INHERIT THtml\n\n VAR nH\n VAR Server_Software\n VAR Server_Name\n VAR Gateway_Interface\n VAR Server_Protocol\n VAR Server_Port\n VAR Request_Method\n VAR Http_Accept\n VAR Http_User_agent\n VAR Http_Referer\n VAR Path_Info\n VAR Path_Translated\n VAR Script_Name\n VAR Query_String\n VAR Remote_Host\n VAR Remote_Addr\n VAR ipAddress\n VAR Remote_User\n VAR Auth_Type\n VAR Auth_User\n VAR Auth_Pass\n VAR Content_Type\n VAR Content_Length\n VAR Annotation_Server\n\n VAR aQueryFields INIT {}\n\n METHOD New( cInBuffer )\n METHOD Field( cQueryName )\n METHOD ToObject()\n\nENDCLASS\n\nMETHOD New( cInBuffer ) CLASS TCgi\n\n LOCAL i\n LOCAL aTemp\n LOCAL aVar\n\n ::nH := HtmlPageHandle()\n\n ::Server_Software := GetEnv( \"SERVER_SOFTWARE\" )\n ::Server_Name := GetEnv( \"SERVER_NAME\" )\n ::Gateway_Interface := GetEnv( \"GATEWAY_INTERFACE\" )\n ::Server_Protocol := GetEnv( \"SERVER_PROTOCOL\" )\n ::Server_Port := GetEnv( \"SERVER_PORT\" )\n ::Request_Method := GetEnv( \"REQUEST_METHOD\" )\n ::Http_Accept := GetEnv( \"HTTP_ACCEPT\" )\n ::Http_User_agent := GetEnv( \"HTTP_USER_AGENT\" )\n ::Http_Referer := GetEnv( \"HTTP_REFERER\" )\n ::Path_Info := GetEnv( \"PATH_INFO\" )\n ::Path_Translated := GetEnv( \"PATH_TRANSLATED\" )\n ::Script_Name := GetEnv( \"SCRIPT_NAME\" )\n ::Query_String := GetEnv( \"QUERY_STRING\" )\n ::Remote_Host := GetEnv( \"REMOTE_HOST\" )\n ::Remote_Addr := GetEnv( \"REMOTE_ADDR\" )\n ::ipAddress := GetEnv( \"REMOTE_ADDR\" )\n ::Remote_User := GetEnv( \"REMOTE_USER\" )\n ::Auth_Type := GetEnv( \"AUTH_TYPE\" )\n ::Auth_User := GetEnv( \"AUTH_USER\" )\n ::Auth_Pass := GetEnv( \"AUTH_PASS\" )\n ::Content_Type := GetEnv( \"CONTENT_TYPE\" )\n ::Content_Length := GetEnv( \"CONTENT_LENGTH\" )\n ::Annotation_Server := GetEnv( \"ANNOTATION_SERVER\" )\n\n IF cInBuffer != NIL\n ::Query_String := RTrim( cInBuffer )\n ELSE\n IF \"POST\" $ Upper( ::Request_Method )\n ::Query_String := RTrim( FReadStr( STD_IN, Val( ::CONTENT_LENGTH ) ) )\n ENDIF\n ENDIF\n\n IF ! Empty( ::Query_String )\n\n ::aQueryFields := {}\n\n aTemp := hb_ATokens( ::Query_String, \"&\" ) \n\n FOR i := 1 TO Len( aTemp )\n aVar := hb_ATokens( aTemp[ i ], \"=\" )\n IF Len( aVar ) == 2\n AAdd( ::aQueryFields, { aVar[ 1 ], HtmlDecodeUrl( aVar[ 2 ] ) } )\n ENDIF\n NEXT\n\n ENDIF\n\n RETURN ::ToObject()\n\n\nMETHOD ToObject() CLASS TCgi\n\n LOCAL i\n LOCAL nScope := 1\n LOCAL aDb\n LOCAL oNew\n\n STATIC s_n := 0\n\n \n aDb := HBClass():New( \"NewCgi\" + StrZero( ++s_n, 3 ), { \"TCgi\" } )\n\n FOR i := 1 TO Len( ::aQueryFields )\n\n IF ::aQueryFields[ i, 2 ] == NIL .OR. Empty( ::aQueryFields[ i, 2 ] )\n ::aQueryFields[ i, 2 ] := \"\"\n ENDIF\n\n adb:AddData( ::aQueryFields[ i, 1 ], ::aQueryFields[ i, 2 ], , nScope )\n NEXT\n\n adb:Create()\n oNew := adb:Instance()\n oNew:aQueryFields := ::aQueryFields\n oNew:Server_Software := ::Server_Software\n oNew:Server_Name := ::Server_Name\n oNew:Gateway_Interface := ::Gateway_Interface\n oNew:Server_Protocol := ::Server_Protocol\n oNew:Server_Port := ::Server_Port\n oNew:Request_Method := ::Request_Method\n oNew:Http_Accept := ::Http_Accept\n oNew:Http_User_agent := ::Http_User_agent\n oNew:Http_Referer := ::Http_Referer\n oNew:Path_Info := ::Path_Info\n oNew:Path_Translated := ::Path_Translated\n oNew:Script_Name := ::Script_Name\n oNew:Query_String := ::Query_String\n oNew:Remote_Host := ::Remote_Host\n oNew:Remote_Addr := ::Remote_Addr\n oNew:ipAddress := ::ipAddress\n oNew:Remote_User := ::Remote_User\n oNew:Auth_Type := ::Auth_Type\n oNew:Content_Type := ::Content_Type\n oNew:Content_Length := ::Content_Length\n oNew:Annotation_Server := ::Annotation_Server\n oNew:nH := iif( HtmlPageHandle() == NIL, STD_OUT, HtmlPageHandle() )\n\n RETURN oNew\n\nMETHOD Field( cQueryName ) CLASS TCgi\n\n LOCAL cRet := \"\"\n LOCAL nRet\n\n __defaultNIL( @cQueryName, \"\" )\n\n nRet := AScan( ::aQueryFields, {| x | Upper( x[ 1 ] ) == Upper( cQueryName ) } )\n\n IF nRet > 0\n cRet := ::aQueryFields[ nRet, 2 ]\n ENDIF\n\n RETURN cRet\n\nFUNCTION ParseString( cString, cDelim, nRet )\n\n LOCAL cBuf\n LOCAL aElem\n LOCAL nPosFim\n LOCAL nSize\n LOCAL i\n\n nSize := Len( cString ) - Len( StrTran( cString, cDelim ) ) + 1\n aElem := Array( nSize )\n\n cBuf := cString\n FOR i := 1 TO nSize\n nPosFim := At( cDelim, cBuf )\n\n IF nPosFim > 0\n aElem[ i ] := SubStr( cBuf, 1, nPosFim - 1 )\n ELSE\n aElem[ i ] := cBuf\n ENDIF\n\n cBuf := SubStr( cBuf, nPosFim + 1, Len( cBuf ) )\n\n NEXT\n\n RETURN aElem[ nRet ]\n\n\nFUNCTION CgiParseVar( cEnvVar )\n\n cEnvVar := HtmlDecodeUrl( cEnvVar )\n\n IF \"=\" $ cEnvVar .AND. Len( cEnvVar ) > At( \"=\", cEnvVar )\n cEnvVar := AllTrim( SubStr( cEnvVar, At( \"=\", cEnvVar ) + 1 ) )\n ELSE\n cEnvVar := \"\"\n ENDIF\n\n RETURN cEnvVar"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/wordone.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of WordOne()\"\n ?\n\n ? \"Simple tests:\"\n ? ' WordOne( \"12ABAB12\" ) == \"12AB12\" ? --> \"' + WordOne( \"12ABAB12\" ) + '\"'\n ? ' WordOne( \"1AAAA2\" ) == \"1AAAA2\" ? --> \"' + WordOne( \"1AAAA2\" ) + '\"'\n ? ' WordOne( \"12\", \"1212ABAB\" ) == \"12ABAB\" ? --> \"' + WordOne( \"12\", \"1212ABAB\" ) + '\"'\n ?\n\n ? \"End test of WordOne()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour header file: extras/rddado/adordd.ch. Defines 10 constants including: _ADORDD_CH, adOpenForwardOnly, adOpenKeyset, adOpenDynamic, adOpenStatic. Declares 2 preprocessor commands. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef _ADORDD_CH\n#define _ADORDD_CH\n\n\n#define adOpenForwardOnly 0\n#define adOpenKeyset 1\n#define adOpenDynamic 2\n#define adOpenStatic 3\n\n\n#define adLockReadOnly 1\n#define adLockPessimistic 2\n#define adLockOptimistic 3\n#define adLockBatchOptimistic 4\n\n\n#define adEmpty 0\n#define adTinyInt 16\n#define adSmallInt 2\n#define adInteger 3\n#define adBigInt 20\n#define adUnsignedTinyInt 17\n#define adUnsignedSmallInt 18\n#define adUnsignedInt 19\n#define adUnsignedBigInt 21\n#define adSingle 4\n#define adDouble 5\n#define adCurrency 6\n#define adDecimal 14\n#define adNumeric 131\n#define adBoolean 11\n#define adError 10\n#define adUserDefined 132\n#define adVariant 12\n#define adIDispatch 9\n#define adIUnknown 13\n#define adGUID 72\n#define adDate 7\n#define adDBDate 133\n#define adDBTime 134\n#define adDBTimeStamp 135\n#define adBSTR 8\n#define adChar 129\n#define adVarChar 200\n#define adLongVarChar 201\n#define adWChar 130\n#define adVarWChar 202\n#define adLongVarWChar 203\n#define adBinary 128\n#define adVarBinary 204\n#define adLongVarBinary 205\n#define adChapter 136\n#define adFileTime 64\n#define adPropVariant 138\n#define adVarNumeric 139\n#define adArray \n\n#define adRecDeleted 4\n\n#define adUseNone 1\n#define adUseServer 2\n#define adUseClient 3\n#define adUseClientBatch 3\n\n#define adKeyForeign 2\n\n\n#define adStateClosed 0\n#define adStateOpen 1\n#define adStateConnecting 2\n#define adStateExecuting 4\n#define adStateFetching 8\n\n\n#define adSchemaProviderSpecific -1\n#define adSchemaAsserts 0\n#define adSchemaCatalogs 1\n#define adSchemaCharacterSets 2\n#define adSchemaCollations 3\n#define adSchemaColumns 4\n#define adSchemaCheckConstraints 5\n#define adSchemaConstraintColumnUsage 6\n#define adSchemaConstraintTableUsage 7\n#define adSchemaKeyColumnUsage 8\n#define adSchemaReferentialContraints 9\n#define adSchemaReferentialConstraints 9\n#define adSchemaTableConstraints 10\n#define adSchemaColumnsDomainUsage 11\n#define adSchemaIndexes 12\n#define adSchemaColumnPrivileges 13\n#define adSchemaTablePrivileges 14\n#define adSchemaUsagePrivileges 15\n#define adSchemaProcedures 16\n#define adSchemaSchemata 17\n#define adSchemaSQLLanguages 18\n#define adSchemaStatistics 19\n#define adSchemaTables 20\n#define adSchemaTranslations 21\n#define adSchemaProviderTypes 22\n#define adSchemaViews 23\n#define adSchemaViewColumnUsage 24\n#define adSchemaViewTableUsage 25\n#define adSchemaProcedureParameters 26\n#define adSchemaForeignKeys 27\n#define adSchemaPrimaryKeys 28\n#define adSchemaProcedureColumns 29\n#define adSchemaDBInfoKeywords 30\n#define adSchemaDBInfoLiterals 31\n#define adSchemaCubes 32\n#define adSchemaDimensions 33\n#define adSchemaHierarchies 34\n#define adSchemaLevels 35\n#define adSchemaMeasures 36\n#define adSchemaProperties 37\n#define adSchemaMembers 38\n#define adSchemaTrustees 39\n#define adSchemaFunctions 40\n#define adSchemaActions 41\n#define adSchemaCommands 42\n#define adSchemaSets 43\n\n\n#define adAddNew 0x1000400 \n#define adApproxPosition 0x0004000 \n#define adBookmark 0x0002000 \n#define adDelete 0x1000800 \n#define adFind 0x0080000 \n#define adHoldRecords 0x0000100 \n#define adIndex 0x0100000 \n#define adMovePrevious 0x0000200 \n#define adNotify 0x0040000 \n#define adResync 0x0020000 \n#define adSeek 0x0200000 \n#define adUpdate 0x1008000 \n#define adUpdateBatch 0x0010000\n\n\n#define adCmdUnspecified -1\n#define adCmdUnknown 8\n#define adCmdText 1\n#define adCmdTable 2\n#define adCmdStoredProc 4\n#define adCmdFile 256\n#define adCmdTableDirect 512\n\n#command USE <(db)> [VIA ] [ALIAS ] [] ;\n [] [] [] ;\n [CODEPAGE ] [INDEX <(index1)> [, <(indexN)>]] ;\n [ TABLE ] ;\n [ ];\n [ FROM ] ;\n [ QUERY ] ;\n [ USER PASSWORD ]=> ;\n [ hb_adoSetTable( ) ; ] ;\n [ hb_adoSetEngine( <(dbEngine)> ) ; ] ;\n [ hb_adoSetServer( ) ; ] ;\n [ hb_adoSetQuery( ) ; ] ;\n [ hb_adoSetUser( ); hb_adoSetPassword( ) ; ] ;\n dbUseArea( <.nw.>, , <(db)>, <(a)>, ;\n iif( <.sh.> .OR. <.ex.>, ! <.ex.>, NIL ), <.ro.> [, ] ) ;\n [; dbSetIndex( <(index1)> )] ;\n [; dbSetIndex( <(indexN)> )]\n\n#command LOCATE [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] [] [ALL] => ;\n [ hb_adoSetLocateFor( <(for)> ); ] ;\n __dbLocate( <{for}>, <{while}>, , , <.rest.> )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/elapsed.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\nPROCEDURE Main()\n\n LOCAL dStart, dEnd, cTimeStart, cTimeEnd, n, aDataTest\n\n dStart := hb_SToD( \"19901128\" )\n dEnd := hb_SToD( \"19901130\" )\n cTimeStart := \"08:00:00\"\n cTimeEnd := \"12:10:30\"\n\n aDataTest := ft_Elapsed( dStart, dEnd, cTimeStart, cTimeEnd )\n FOR n := 1 TO 4\n ? aDataTest[ n, 1 ], Str( aDataTest[ n, 2 ], 12, 4 )\n ?? \" \"\n ?? iif( n == 1, \"Days\", iif( n == 2, \"Hours\", iif( n == 3, \"Mins.\", \"Secs.\" ) ) )\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour Runtime Library file: src/rtl/memoedit.prg. Defines classes: HBMemoEditor. Provides functions: MemoEdit. This file handles database operations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"inkey.ch\"\n#include \"memoedit.ch\"\n#include \"setcurs.ch\"\n#include \"hbgtinfo.ch\"\n\n\nCREATE CLASS HBMemoEditor INHERIT HBEditor\n\n VAR lCallKeyboardHook AS LOGICAL INIT .F. \n\n VAR xUserFunction \n\n METHOD MemoInit( xUserFunction ) \n METHOD Edit() \n METHOD KeyboardHook( nKey ) \n METHOD IdleHook() \n\n METHOD HandleUserKey( nKey, nUdfReturn ) \n METHOD xDo( nStatus ) \n\n METHOD MoveCursor( nKey ) \n METHOD InsertState( lInsState ) \n\n PROTECTED:\n\n METHOD UserFunctionIsValid()\n\nENDCLASS\n\nMETHOD UserFunctionIsValid() CLASS HBMemoEditor\n#ifdef HB_CLP_STRICT\n RETURN HB_ISSTRING( ::xUserFunction )\n#else\n RETURN HB_ISSTRING( ::xUserFunction ) .OR. HB_ISEVALITEM( ::xUserFunction )\n#endif\n\nMETHOD MemoInit( xUserFunction ) CLASS HBMemoEditor\n\n LOCAL nUdfReturn\n\n \n ::xUserFunction := xUserFunction\n\n IF ::UserFunctionIsValid()\n\n DO WHILE .T.\n SWITCH nUdfReturn := ::xDo( ME_INIT )\n \n \n CASE K_INS\n CASE ME_TOGGLEWRAP\n CASE ME_TOGGLESCROLL\n \n \n ::HandleUserKey( , nUdfReturn )\n LOOP\n ENDSWITCH\n EXIT\n ENDDO\n ENDIF\n\n RETURN Self\n\nMETHOD Edit() CLASS HBMemoEditor\n\n LOCAL nKey, nKeyStd\n\n \n LOCAL hConfigurableKeys := { K_CTRL_Y =>, K_CTRL_T =>, K_CTRL_B =>, ;\n K_CTRL_V =>, K_ALT_W =>, K_ESC => }\n LOCAL bKeyBlock\n\n \n IF ::lEditAllow .AND. ::UserFunctionIsValid()\n\n DO WHILE ! ::lExitEdit\n\n \n IF ( nKey := Inkey(, hb_bitOr( Set( _SET_EVENTMASK ), HB_INKEY_EXT ) ) ) == 0\n ::IdleHook()\n nKey := Inkey( 0, hb_bitOr( Set( _SET_EVENTMASK ), HB_INKEY_EXT ) )\n ENDIF\n nKeyStd := hb_keyStd( nKey )\n\n IF ( bKeyBlock := SetKey( nKeyStd ) ) != NIL\n Eval( bKeyBlock )\n LOOP\n ENDIF\n\n \n IF nKeyStd $ hConfigurableKeys\n ::HandleUserKey( nKey, ::xDo( iif( ::lDirty, ME_UNKEYX, ME_UNKEY ) ) )\n ELSE\n ::super:Edit( nKey )\n ENDIF\n ENDDO\n ELSE\n \n \n ::super:Edit()\n ENDIF\n\n RETURN Self\n\n\nMETHOD KeyboardHook( nKey ) CLASS HBMemoEditor\n\n LOCAL nYesNoKey\n LOCAL cBackScr\n LOCAL nRow\n LOCAL nCol\n\n IF ::UserFunctionIsValid() .AND. ! ::lCallKeyboardHook \n\n ::lCallKeyboardHook := .T.\n ::HandleUserKey( nKey, ::xDo( iif( ::lDirty, ME_UNKEYX, ME_UNKEY ) ) )\n ::lCallKeyboardHook := .F.\n\n ELSEIF hb_keyStd( nKey ) == K_ESC\n\n IF ::lDirty .AND. Set( _SET_SCOREBOARD )\n cBackScr := SaveScreen( 0, MaxCol() - 19, 0, MaxCol() )\n\n nRow := Row()\n nCol := Col()\n hb_DispOutAt( 0, MaxCol() - 19, \"Abort Edit? (Y/N)\" )\n SetPos( 0, MaxCol() - 2 )\n\n nYesNoKey := Inkey( 0 )\n\n RestScreen( 0, MaxCol() - 19, 0, MaxCol(), cBackScr )\n SetPos( nRow, nCol )\n\n IF Upper( hb_keyChar( nYesNoKey ) ) == \"Y\"\n hb_keySetLast( K_ESC ) \n ::lSaved := .F.\n ::lExitEdit := .T.\n ENDIF\n ELSE\n ::lSaved := .F.\n ::lExitEdit := .T.\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD IdleHook() CLASS HBMemoEditor\n\n IF ::UserFunctionIsValid()\n ::xDo( ME_IDLE )\n ENDIF\n\n RETURN Self\n\nMETHOD HandleUserKey( nKey, nUdfReturn ) CLASS HBMemoEditor\n\n SWITCH nUdfReturn\n CASE ME_DEFAULT\n\n \n IF HB_ISNUMERIC( nKey )\n \n \n IF hb_keyStd( nKey ) == K_ESC\n ::lSaved := .F.\n ::lExitEdit := .T.\n ELSE\n ::super:Edit( nKey )\n ENDIF\n ELSE\n RETURN .F.\n ENDIF\n EXIT\n\n CASE ME_DATA\n IF HB_ISNUMERIC( nKey )\n \n IF HB_ULen( hb_keyChar( nKey ) ) > 0\n ::super:Edit( nKey )\n ENDIF\n ELSE\n RETURN .F.\n ENDIF\n EXIT\n\n CASE ME_TOGGLEWRAP\n ::lWordWrap := ! ::lWordWrap\n EXIT\n\n CASE ME_TOGGLESCROLL\n \n EXIT\n\n CASE ME_WORDRIGHT\n ::super:MoveCursor( K_CTRL_RIGHT )\n EXIT\n\n CASE ME_BOTTOMRIGHT\n ::super:MoveCursor( K_CTRL_END )\n EXIT\n\n#ifndef HB_CLP_STRICT\n CASE ME_PASTE \n hb_gtInfo( HB_GTI_CLIPBOARDPASTE, .T. )\n EXIT\n#endif\n\n CASE ME_IGNORE\n \n EXIT\n\n OTHERWISE\n\n \n IF ( nUdfReturn >= 1 .AND. nUdfReturn <= 31 ) .OR. nUdfReturn == K_ALT_W\n ::super:Edit( nUdfReturn )\n ELSE\n RETURN .F.\n ENDIF\n\n ENDSWITCH\n\n RETURN .T.\n\nMETHOD xDo( nStatus ) CLASS HBMemoEditor\n\n LOCAL nOldRow := ::Row()\n LOCAL nOldCol := ::Col()\n LOCAL nOldCur := SetCursor()\n\n LOCAL xResult := Do( ::xUserFunction, nStatus, ::nRow, ::nCol - 1 )\n\n SetPos( nOldRow, nOldCol )\n SetCursor( nOldCur )\n\n RETURN hb_defaultValue( xResult, ME_DEFAULT )\n\nMETHOD MoveCursor( nKey ) CLASS HBMemoEditor\n\n IF nKey == K_CTRL_W\n ::lSaved := .T.\n ::lExitEdit := .T.\n RETURN .F.\n ENDIF\n\n RETURN ::super:MoveCursor( nKey )\n\nMETHOD InsertState( lInsState ) CLASS HBMemoEditor\n\n IF HB_ISLOGICAL( lInsState ) .AND. ::lEditAllow\n Set( _SET_INSERT, lInsState )\n SetCursor( iif( lInsState, SC_INSERT, SC_NORMAL ) )\n IF Set( _SET_SCOREBOARD )\n hb_DispOutAt( 0, MaxCol() - 19, iif( lInsState, \"\", \" \" ) )\n ENDIF\n ENDIF\n\n RETURN Self\n\n\nFUNCTION MemoEdit( ;\n cString, ;\n nTop, ;\n nLeft, ;\n nBottom, ;\n nRight, ;\n lEditMode, ;\n xUserFunction, ;\n nLineLength, ;\n nTabSize, ;\n nTextBuffRow, ;\n nTextBuffColumn, ;\n nWindowRow, ;\n nWindowColumn )\n\n LOCAL oEd\n\n LOCAL nOldCursor\n\n hb_default( @nLeft , 0 )\n hb_default( @nRight , MaxCol() )\n hb_default( @nLineLength , nRight - nLeft )\n hb_default( @nTextBuffColumn , 0 )\n hb_default( @nWindowColumn , nTextBuffColumn )\n hb_default( @cString , \"\" )\n\n oEd := HBMemoEditor():New( cString, ;\n hb_defaultValue( nTop, 0 ), ;\n nLeft, ;\n hb_defaultValue( nBottom, MaxRow() ), ;\n nRight, ;\n hb_defaultValue( lEditMode, .T. ), ;\n nLineLength, ;\n hb_defaultValue( nTabSize, 4 ), ;\n hb_defaultValue( nTextBuffRow, 1 ), ;\n nTextBuffColumn, ;\n hb_defaultValue( nWindowRow, 0 ), ;\n nWindowColumn )\n oEd:MemoInit( xUserFunction )\n oEd:display()\n\n \n IF ! HB_ISLOGICAL( xUserFunction )\n nOldCursor := SetCursor()\n oEd:InsertState( Set( _SET_INSERT ) )\n oEd:Edit()\n IF oEd:Saved()\n cString := oEd:GetText( .T. )\n ENDIF\n SetCursor( nOldCursor )\n ENDIF\n\n RETURN cString"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbssl' (OpenSSL wrapper for SSL/TLS encryption): contrib/hbssl/ssl_hbcon.prg. Provides functions: hb_SSL_new, hb_SSL_connect_socket, hb_SSL_connect_inet. This file implements security and encryption functions"}, {"role": "assistant", "content": "FUNCTION hb_SSL_new()\n\n STATIC s_onceControl\n\n \n hb_threadOnce( @s_onceControl, {|| SSL_init(), ;\n RAND_seed( hb_randStr( 20 ) + hb_TToS( hb_DateTime() ) ) } )\n\n \n RETURN SSL_new( SSL_CTX_new() )\n\n\nFUNCTION hb_SSL_connect_socket( pSocket, nTimeout, cInfo )\n\n LOCAL nErr\n LOCAL ssl\n\n ssl := hb_SSL_new()\n IF ! Empty( pSocket := hb_socketNewSSL_connect( @pSocket, ssl, nTimeout ) )\n cInfo := \"SSL connected with \" + SSL_get_cipher( ssl ) + \" encryption.\"\n RETURN .T.\n ENDIF\n\n nErr := ERR_get_error()\n cInfo := hb_StrFormat( \"SSL connection error [%d] %s\", ;\n nErr, ERR_error_string( nErr ) )\n RETURN .F.\n\n\nFUNCTION hb_SSL_connect_inet( pInetSock, nTimeout, cInfo )\n\n LOCAL nResult, nErr\n LOCAL ssl\n\n ssl := hb_SSL_new()\n IF ( nResult := hb_inetSSL_CONNECT( pInetSock, ssl, nTimeout ) ) == 1\n cInfo := \"SSL connected with \" + SSL_get_cipher( ssl ) + \" encryption.\"\n RETURN .T.\n ENDIF\n\n nErr := ERR_get_error()\n cInfo := hb_StrFormat( \"SSL connection error [%d:%d] %s\", ;\n nResult, nErr, ERR_error_string( nErr ) )\n RETURN .F."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/olesrv1.prg. Defines classes: OleNetioSrv. Contains procedures: DllMain. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#define CLS_Name \"MyOleRPCServer\"\n#define CLS_ID \"{23245C3F-4487-404B-985F-E33886698D23}\"\n\n#include \"hbclass.ch\"\n\n\nPROCEDURE DllMain()\n\n \n win_oleServerInit( CLS_ID, CLS_Name, {|| OleNetioSrv():new() }, .T. )\n\n RETURN\n\n\nCREATE CLASS OleNetioSrv\n\n HIDDEN:\n\n VAR pConn\n\n EXPORTED:\n\n METHOD Eval( cMethodName, ... )\n\nENDCLASS\n\nMETHOD Eval( cMethodName, ... ) CLASS OleNetioSrv\n\n LOCAL xRetVal, oErr\n\n BEGIN SEQUENCE WITH {| oErr | Break( oErr ) }\n SWITCH cMethodName\n CASE \"CONNECT\"\n xRetVal := ! Empty( ::pConn := netio_GetConnection( ... ) )\n EXIT\n CASE \"DISCONNECT\"\n ::pConn := NIL\n xRetVal := .T.\n EXIT\n CASE \"PROCEXISTS\"\n xRetVal := netio_ProcExists( ::pConn, ... )\n EXIT\n CASE \"PROCEXEC\"\n xRetVal := netio_ProcExec( ::pConn, ... )\n EXIT\n CASE \"PROCEXECW\"\n xRetVal := netio_ProcExecW( ::pConn, ... )\n EXIT\n CASE \"FUNCEXEC\"\n xRetVal := netio_FuncExec( ::pConn, ... )\n EXIT\n OTHERWISE\n \n xRetVal := netio_FuncExec( ::pConn, cMethodName, ... )\n ENDSWITCH\n RECOVER USING oErr\n xRetVal := oErr\n END SEQUENCE\n\n RETURN xRetVal\n\n\nANNOUNCE GT_SYS\nREQUEST HB_GT_GUI_DEFAULT"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'gtwvg' (): contrib/gtwvg/drawarea.prg. Defines classes: WvgDrawingArea. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nCREATE CLASS WvgDrawingArea INHERIT WvgWindow\n\n VAR caption INIT \"\"\n VAR clipParent INIT .T.\n VAR clipSiblings INIT .T.\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD destroy()\n METHOD handleEvent( nMessage, aNM )\n\nENDCLASS\n\nMETHOD WvgDrawingArea:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::style := WS_CHILD\n ::exStyle := 0\n ::className := \"DrawingArea\"\n ::objType := objTypeDA\n ::visible := .T.\n\n RETURN Self\n\nMETHOD WvgDrawingArea:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n HB_SYMBOL_UNUSED( lVisible )\n\n ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, .T. )\n\n ::oParent:addChild( Self )\n\n wvg_RegisterClass_ByName( ::className() )\n\n ::createControl()\n\n ::SetWindowProcCallback()\n ::show()\n\n RETURN Self\n\nMETHOD WvgDrawingArea:handleEvent( nMessage, aNM )\n\n DO CASE\n CASE nMessage == HB_GTE_RESIZED\n IF HB_ISBLOCK( ::sl_resize )\n Eval( ::sl_resize, , , Self )\n ENDIF\n AEval( ::aChildren, {| o | o:handleEvent( HB_GTE_RESIZED, { 0, 0, 0, 0, 0 } ) } )\n RETURN EVENT_HANDELLED\n\n CASE nMessage == HB_GTE_CTLCOLOR\n IF HB_ISNUMERIC( ::clr_FG )\n wvg_SetTextColor( aNM[ 1 ], ::clr_FG )\n ENDIF\n IF HB_ISNUMERIC( ::hBrushBG )\n wvg_SetBkMode( aNM[ 1 ], 1 )\n wvg_FillRect( aNM[ 1 ], { 0, 0, ::currentSize()[ 1 ], ::currentSize()[ 2 ] }, ::hBrushBG )\n RETURN EVENT_HANDELLED\n ENDIF\n\n ENDCASE\n\n RETURN EVENT_UNHANDELLED\n\nMETHOD PROCEDURE WvgDrawingArea:destroy()\n\n ::wvgWindow:destroy()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/rddtest/rddtst.prg. Provides 6 functions including: test_init, test_close, rdd_state, itm2str, rddtst_wr. Contains procedures: main, main, rdd_retval. This file handles database operations"}, {"role": "assistant", "content": "#ifndef N_LOOP\n #define N_LOOP 15\n#endif\n\n#ifndef EOL\n #define EOL chr( 13 ) + chr( 10 )\n#endif\n\n#command ? => outstd(EOL)\n#command ? => outstd(, EOL)\n#command ?? =>\n#command ?? => outstd()\n\n\n#ifdef _TEST_CREATE_\n #command RDDTESTC <*x*> => ; rddtst_wr( # )\n #command RDDTESTF => rddtst_wr( #, )\n #command RDDTEST <*x*> => RDDTESTC \n #command RDDTEST => RDDTESTF \n#else\n #command RDDTESTC , <*x*> => ; rddtst_tst( #, )\n #command RDDTESTF , , => rddtst_tst( #, , , )\n \n#endif\n#define _DBNAME \"_tst\"\n\nREQUEST DBFCDX\nfield FSTR, FNUM\n\n#include \"fileio.ch\"\n\n#ifdef _TEST_CREATE_\n static s_hMake := F_ERROR\n#endif\nstatic s_nTested := 0\nstatic s_nErrors := 0\n\n\nstatic aBadRetFunc:={ \"DBSKIP\", \"DBGOTO\", \"DBDELETE\", \"DBRECALL\", ;\n \"DBUNLOCK\", \"DBCOMMIT\" }\n\n#ifdef _TEST_SCOPE_\n#include \"ord.ch\"\n#include \"dbinfo.ch\"\n#endif\n\n#ifdef __HARBOUR__\n#ifdef _TEST_ADS_\n#include \"ads.ch\"\nREQUEST ADS\ninit proc adstest_init()\nrddRegister( \"ADS\", 1 )\nAdsSetServerType( ADS_LOCAL_SERVER )\n\nreturn\n#endif\n#endif\n\n\n#ifdef _TEST_CREATE_\n procedure main( cOutFile, rdd )\n test_init( rdd, cOutFile )\n test_main()\n test_close()\n return\n#else\n procedure main( rdd )\n test_init( rdd )\n test_main()\n test_close()\n return\n#endif\n\nstatic function test_init(rdd,cOutFile)\nlocal n, cOut, aDb := { { \"FSTR\", \"C\", 10, 0 }, { \"FNUM\", \"N\", 10, 0 } }\n\nif empty(rdd)\n #ifdef _TESTRDD\n rdd := _TESTRDD\n #else\n rdd := \"DBFCDX\"\n #endif\nendif\nrddSetDefault(rdd)\n#ifdef _TEST_CREATE_\n if empty( cOutFile )\n ? \"Syntax: []\"\n quit\n elseif ( s_hMake := fcreate( cOutFile ) ) == F_ERROR\n ? \"Cannot create file: \", cOutFile\n quit\n endif\n cOut:=\"\"\n #ifdef _TEST_ADS_\n cOut += '#define _TEST_ADS_'+EOL\n #endif\n cOut +=;\n 'REQUEST ' + rdd + EOL +;\n '#define _TESTRDD \"' + rdd + '\"' + EOL +;\n '#include \"rddtst.prg\"' + EOL +;\n EOL +;\n 'FUNCTION test_main()' + EOL +;\n EOL\n if ! fwrite( s_hMake, cOut ) == len( cOut )\n ? \"write error.\"\n quit\n endif\n#endif\n\naeval( directory( \"./\" + _DBNAME + \".??x\" ), {| x | ferase( x[ 1 ] ) } )\naeval( directory( \"./TG_?.??x\" ), {| x | ferase( x[ 1 ] ) } )\nferase( \"./\"+_DBNAME+\".dbf\" )\n? \"RDD: \" + rdd\n? \"creating databse and index...\"\ndbcreate( _DBNAME, aDb )\n\nreturn nil\n\n\nstatic function test_close()\nlocal cOut\n#ifdef _TEST_CREATE_\n if s_hMake != F_ERROR\n cOut :=EOL +;\n 'RETURN NIL' + EOL\n if ! fwrite( s_hMake, cOut ) == len( cOut )\n ? \"write error.\"\n quit\n endif\n fclose( s_hMake )\n endif\n#else\n ?\n ? \"Number of tests: \" + ltrim( str( s_nTested ) )\n ? \"Number of errors: \" + ltrim( str( s_nErrors ) )\n#endif\ndbclosearea()\naeval( directory( \"./\" + _DBNAME + \".??x\" ), {| x | ferase( x[ 1 ] ) } )\naeval( directory( \"./TG_?.??x\" ), {| x | ferase( x[ 1 ] ) } )\nferase( \"./\" + _DBNAME + \".dbf\" )\n?\nreturn nil\n\nstatic procedure rdd_retval()\nreturn\n\nstatic function rdd_state()\nreturn { recno(), bof(), eof(), found() }\n\n\nstatic function itm2str( itm )\nlocal cStr := \"\", i\nif itm == NIL\n cStr += \"NIL\"\nelseif valtype( itm ) == \"C\"\n cStr += '\"' + strtran( itm, '\"', '\" + chr( 34 ) + \"') + '\"'\nelseif valtype( itm ) == \"N\"\n cStr += ltrim( str( itm ) )\nelseif valtype( itm ) == \"L\"\n cStr += iif( itm, \".T.\", \".F.\" )\nelseif valtype( itm ) == \"D\"\n cStr += \"CTOD(\" + DTOC( itm ) + \")\"\nelseif valtype( itm ) == \"B\"\n cStr += \"{||\" + itm2str( eval( itm ) ) + \"}\"\nelseif valtype( itm ) == \"A\"\n cStr += \"{\"\n for i:=1 to len( itm )\n cStr += iif( i == 1, \"\", \",\" ) + itm2str( itm[ i ] )\n next\n cStr += \"}\"\nendif\nreturn cStr\n\n\n#ifdef _TEST_CREATE_\n static function rddtst_wr( cAction, xRet )\n local aState, cOut\n\n if ascan( aBadRetFunc, {| x | upper( cAction ) = x + \"(\" } ) != 0\n xRet := NIL\n endif\n aState := rdd_state()\n if pcount() > 1\n cOut:=\"RDDTESTF \" + itm2str( xRet ) + \", \" + itm2str( aState ) + \", \" + cAction + EOL\n else\n cOut:=\"RDDTESTC \" + itm2str( aState ) + \", \" + cAction + EOL\n endif\n if ! fwrite( s_hMake, cOut ) == len( cOut )\n ? \"write error.\"\n quit\n endif\n return nil\n#else\n \n static function rddtst_tst( cAction, aExState, xRet, xExRet )\n local aState, lOK := ( .T. ), s1, s2, i\n\n aState := rdd_state()\n if pcount() >= 4\n if ascan( aBadRetFunc, {| x | upper( cAction ) = x + \"(\" } ) != 0\n xRet := NIL\n endif\n if ! valtype( xRet ) == valtype( xExRet ) .or.;\n ! iif( valtype( xRet ) == \"B\", eval( xRet ) == eval( xExRet ), xRet == xExRet )\n lOK := ( .F. )\n endif\n s1 := itm2str( xRet )\n s2 := itm2str( xExRet )\n s1 := padr( s1, max( len( s1 ), len( s2 ) ) + 1 )\n s2 := padr( s2, len( s1 ) )\n else\n s1 := s2 := \"\"\n endif\n if ! empty( aExState ) .and. lOK\n for i := 1 to len( aExState )\n if ! valtype( aState[ i ] ) == valtype( aExState[ i ] ) .or. ! aState[ i ] == aExState[ i ]\n lOK := ( .F. )\n exit\n endif\n next\n endif\n ?\n ?? iif( lOK, \"OK \", \"ERR \" ) + cAction + \" => \" + s1 + itm2str( aState )\n if ! lOK\n ?\n ?? \" \" + cAction + \" => \" + s2 + itm2str( aExState )\n s_nErrors++\n endif\n s_nTested++\n return nil\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charrlr.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#else\n#define hb_ntos( n ) LTrim( Str( n ) )\n#define hb_BChar( n ) Chr( n )\n#endif\n\nPROCEDURE Main()\n\n LOCAL ni, cStr\n\n ctinit()\n\n ? \"Begin test of CharRlr()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharRlr( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 ) =='\n ? ' hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ) + hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) ? -->'\n\n ? ' '\n cStr := CharRlr( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 )\n FOR ni := 1 TO Len( cStr )\n ?? \"hb_BChar( \" + hb_ntos( Asc( SubStr( cStr, ni, 1 ) ) ) + \" )\"\n IF ni < Len( cStr )\n ?? \" + \"\n ENDIF\n NEXT\n ?\n\n ? \"End test of CharRlr()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/dbgfx.prg. Provides functions: hb_ToOutDebugOnOff, hb_ToLogFileOnOff, hb_EmptyLogFileOnOff. Contains procedures: hb_ToOutDebug, hb_ToLogFile. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n\nSTATIC s_lToOutDebug := .T.\nSTATIC s_lToLogFile := .T.\nSTATIC s_lEmptyLogFile := .T.\n\nFUNCTION hb_ToOutDebugOnOff( lOnOff )\n\n LOCAL lOld := s_lToOutDebug\n\n IF HB_ISLOGICAL( lOnOff )\n s_lToOutDebug := lOnOff\n ENDIF\n\n RETURN lOld\n\nPROCEDURE hb_ToOutDebug( ... )\n\n IF s_lToOutDebug\n hb_OutDebug( sprintf( ... ) )\n ENDIF\n\n RETURN\n\nFUNCTION hb_ToLogFileOnOff( lOnOff )\n\n LOCAL lOld := s_lToLogFile\n\n IF HB_ISLOGICAL( lOnOff )\n s_lToLogFile := lOnOff\n ENDIF\n\n RETURN lOld\n\nFUNCTION hb_EmptyLogFileOnOff( lOnOff )\n\n LOCAL lOld := s_lEmptyLogFile\n\n IF HB_ISLOGICAL( lOnOff )\n s_lEmptyLogFile := lOnOff\n ENDIF\n\n RETURN lOld\n\nPROCEDURE hb_ToLogFile( cLogFile, ... )\n\n LOCAL nHandle\n\n IF ! s_lToLogFile\n RETURN\n ENDIF\n\n __defaultNIL( @cLogFile, \"logfile.log\" )\n\n IF cLogFile != NIL\n\n IF ! s_lEmptyLogFile .AND. hb_FileExists( cLogFile )\n nHandle := FOpen( cLogFile, FO_READWRITE + FO_SHARED )\n ELSE\n nHandle := FCreate( cLogFile )\n s_lEmptyLogFile := .F.\n \n IF FError() == 0 .AND. nHandle != F_ERROR\n FClose( nHandle )\n nHandle := FOpen( cLogFile, FO_READWRITE + FO_SHARED )\n ENDIF\n ENDIF\n\n \n IF nHandle != F_ERROR\n FSeek( nHandle, 0, FS_END )\n FWrite( nHandle, sprintf( ... ) )\n FWrite( nHandle, hb_eol() )\n FClose( nHandle )\n ENDIF\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: ft_Pending. Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/pending.prg. Provides functions: ft_Pending. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_Pending( cMsg, nRow, nCol, nWait, cColor )\n\n THREAD STATIC t_nRow1 := 24\n THREAD STATIC t_nCol1 := 0\n THREAD STATIC t_nWait1 := 5\n THREAD STATIC t_cColor1 := \"W+/R,X\"\n\n THREAD STATIC t_nLast_Time := 0\n\n LOCAL nThis_Time\n\n IF cMsg != NIL\n\n t_nRow1 := iif( nRow != NIL, nRow, t_nRow1 ) \n t_nCol1 := iif( nCol != NIL, nCol, t_nCol1 ) \n t_nWait1 := iif( nWait != NIL, nWait, t_nWait1 ) \n t_cColor1 := iif( cColor != NIL, cColor, t_cColor1 ) \n\n nThis_Time := Seconds() \n\n IF t_nLast_Time == 0\n t_nLast_Time := nThis_Time - t_nWait1 \n ENDIF\n\n IF ( nThis_Time - t_nLast_Time ) < 0.1 \n t_nLast_Time := nThis_Time + t_nWait1 \n Inkey( t_nWait1 ) \n ELSE\n t_nLast_Time := nThis_Time \n ENDIF\n\n hb_Scroll( t_nRow1, 0, t_nRow1, 80 ) \n\n hb_DispOutAt( t_nRow1, t_nCol1, cMsg, t_cColor1 ) \n\n ENDIF\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/xcstr.prg. Provides 12 functions including: CStrToVal, StringToLiteral, ValToPrg, PrgExpToVal, ValToArray. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"error.ch\"\n\n#include \"hbclass.ch\"\n\n\n#define CRLF Chr( 13 ) + Chr( 10 )\n\n#xtranslate Throw( ) => ( Eval( ErrorBlock(), ), Break( ) )\n\n\nFUNCTION CStrToVal( cExp, cType )\n\n IF ! HB_ISSTRING( cExp )\n Throw( xhb_ErrorNew( \"CSTR\", 0, 3101, ProcName(), \"Argument error\", { cExp, cType } ) )\n ENDIF\n\n SWITCH cType\n CASE \"C\"\n RETURN cExp\n\n CASE \"P\"\n RETURN hb_HexToNum( cExp )\n\n CASE \"D\"\n IF IsDigit( SubStr( cExp, 3, 1 ) ) .AND. IsDigit( SubStr( cExp, 5, 1 ) )\n RETURN hb_SToD( cExp )\n ELSE\n RETURN CToD( cExp )\n ENDIF\n\n CASE \"T\"\n IF IsDigit( SubStr( cExp, 3, 1 ) ) .AND. ;\n IsDigit( SubStr( cExp, 5, 1 ) ) .AND. ;\n IsDigit( SubStr( cExp, 7, 1 ) )\n RETURN hb_SToT( cExp )\n ELSE\n RETURN hb_StrToTS( cExp )\n ENDIF\n\n CASE \"L\"\n RETURN SubStr( cExp, 1, 1 ) $ \"TY\" .OR. SubStr( cExp, 2, 1 ) $ \"TY\"\n\n CASE \"N\"\n RETURN Val( cExp )\n\n CASE \"U\"\n RETURN NIL\n\n \n OTHERWISE\n Throw( xhb_ErrorNew( \"CSTRTOVAL\", 0, 3101, ProcName(), \"Argument error\", { cExp, cType } ) )\n ENDSWITCH\n\n RETURN NIL\n\n\nFUNCTION StringToLiteral( cString )\n\n LOCAL lDouble := .F.\n LOCAL lSingle := .F.\n\n IF hb_regexHas( \"\\n|\\r\", cString ) .OR. ;\n ( ( lDouble := '\"' $ cString ) .AND. ;\n ( lSingle := \"'\" $ cString ) .AND. ;\n hb_regexHas( \"\\[|\\]\", cString ) )\n\n cString := StrTran( cString, '\"', '\\\"' )\n cString := StrTran( cString, Chr( 10 ), \"\\n\" )\n cString := StrTran( cString, Chr( 13 ), \"\\r\" )\n\n \n RETURN 'E\"' + cString + '\"'\n ELSEIF ! lDouble\n RETURN '\"' + cString + '\"'\n ELSEIF ! lSingle\n RETURN \"'\" + cString + \"'\"\n ENDIF\n\n RETURN \"[\" + cString + \"]\"\n\n\nFUNCTION ValToPrg( xVal, cName, nPad, hRefs )\n\n LOCAL aVar, cRet, cPad, cRef, pRef\n\n \n SWITCH ValType( xVal )\n CASE \"C\"\n RETURN StringToLiteral( xVal )\n\n CASE \"D\"\n RETURN \"hb_SToD( '\" + DToS( xVal ) + \"' )\"\n\n CASE \"T\"\n RETURN 't\"' + hb_TSToStr( xVal, .T. ) + '\"'\n\n CASE \"L\"\n RETURN iif( xVal, \".T.\", \".F.\" )\n\n CASE \"N\"\n RETURN hb_ntos( xVal )\n\n CASE \"A\"\n pRef := __vmItemId( xVal )\n IF cName == NIL\n nPad := 0\n cName := \"M->__ValToPrg_Array\"\n hRefs := { => }\n cRet := cName + \" := \"\n ELSEIF ! ( cRef := hb_HGetDef( hRefs, pRef ) ) == NIL\n RETURN cRef + \" \"\n ELSE\n cRet := \"\"\n ENDIF\n\n hRefs[ pRef ] := cName\n\n cRet += \"Array(\" + hb_ntos( Len( xVal ) ) + \")\" + CRLF\n\n nPad += 3\n cPad := Space( nPad )\n\n FOR EACH aVar IN xVal\n cRef := cName + \"[\" + hb_ntos( aVar:__EnumIndex() ) + \"]\"\n cRet += cPad + cRef + \" := \" + ValToPrg( aVar, cRef, nPad, hRefs )\n IF ! Right( cRet, Len( CRLF ) ) == CRLF\n cRet += CRLF\n ENDIF\n NEXT\n\n nPad -= 3\n RETURN cRet\n\n CASE \"H\"\n pRef := __vmItemId( xVal )\n IF cName == NIL\n nPad := 0\n cName := \"M->__ValToPrg_Hash\"\n hRefs := { => }\n cRet := cName + \" := \"\n ELSEIF ! ( cRef := hb_HGetDef( hRefs, pRef ) ) == NIL\n RETURN cRef + \" \"\n ELSE\n cRet := \"\"\n ENDIF\n\n hRefs[ pRef ] := cName\n\n cRet += \"{ => }\" + CRLF\n\n nPad += 3\n cPad := Space( nPad )\n\n FOR EACH aVar IN xVal\n cRef := cName + \"[\" + ValToPrg( aVar:__EnumKey() ) + \"]\"\n cRet += cPad + cRef + \" := \" + ValToPrg( aVar, cRef, nPad, hRefs )\n IF ! Right( cRet, Len( CRLF ) ) == CRLF\n cRet += CRLF\n ENDIF\n NEXT\n\n nPad -= 3\n RETURN cRet\n\n CASE \"B\"\n \n RETURN \"{|| }\"\n\n CASE \"P\"\n RETURN \"0x\" + hb_NumToHex( xVal )\n\n CASE \"O\"\n \n pRef := __vmItemId( xVal )\n IF cName == NIL\n cName := \"M->__ValToPrg_Object\"\n nPad := 0\n hRefs := { => }\n cRet := cName + \" := \"\n ELSEIF ! ( cRef := hb_HGetDef( hRefs, pRef ) ) == NIL\n RETURN cRef + \" \"\n ELSE\n cRet := \"\"\n ENDIF\n\n hRefs[ pRef ] := cName\n\n cRet += xVal:ClassName + \"():New()\" + CRLF\n\n nPad += 3\n cPad := Space( nPad )\n\n FOR EACH aVar IN __objGetValueList( xVal )\n cRef := cName + \":\" + aVar[ 1 ]\n cRet += cPad + cRef + \" := \" + ValToPrg( aVar[ 2 ], cRef, nPad, hRefs )\n IF ! Right( cRet, Len( CRLF ) ) == CRLF\n cRet += CRLF\n ENDIF\n NEXT\n\n nPad -= 3\n RETURN cRet\n\n OTHERWISE\n \n IF xVal == NIL\n cRet := \"NIL\"\n ELSE\n Throw( xhb_ErrorNew( \"VALTOPRG\", 0, 3103, ProcName(), \"Unsupported type: \" + ValType( xVal ), { xVal } ) )\n ENDIF\n ENDSWITCH\n\n \n RETURN cRet\n\n\nFUNCTION PrgExpToVal( cExp )\n\n RETURN Eval( hb_macroBlock( cExp ) )\n\n\nFUNCTION ValToArray( xVal )\n\n IF HB_ISARRAY( xVal )\n RETURN xVal\n ENDIF\n\n RETURN { xVal }\n\n\nFUNCTION ValToBlock( xVal )\n\n IF HB_ISBLOCK( xVal )\n RETURN xVal\n ENDIF\n\n RETURN {|| xVal }\n\n\nFUNCTION ValToCharacter( xVal )\n\n IF HB_ISSTRING( xVal )\n RETURN xVal\n ENDIF\n\n RETURN LTrim( CStr( xVal ) )\n\n\nFUNCTION ValToDate( xVal )\n\n SWITCH ValType( xVal )\n CASE \"A\"\n CASE \"H\"\n CASE \"L\"\n CASE \"O\"\n CASE \"U\"\n EXIT\n\n CASE \"B\"\n RETURN ValToDate( Eval( xVal ) )\n\n CASE \"C\"\n RETURN iif( IsDigit( SubStr( xVal, 3, 1 ) ) .AND. ;\n IsDigit( SubStr( xVal, 5, 1 ) ), hb_SToD( xVal ), ;\n CToD( xVal ) )\n\n CASE \"D\"\n RETURN xVal\n\n CASE \"T\"\n RETURN hb_TToD( xVal )\n\n CASE \"N\"\n RETURN d\"1900-01-01\" + xVal\n\n CASE \"P\"\n RETURN d\"1900-01-01\" + hb_HexToNum( hb_NumToHex( xVal ) )\n\n OTHERWISE\n Throw( xhb_ErrorNew( \"VALTODATE\", 0, 3103, ProcName(), \"Unsupported type\", { xVal } ) )\n ENDSWITCH\n\n RETURN hb_SToD()\n\n\nFUNCTION ValToTimeStamp( xVal )\n\n SWITCH ValType( xVal )\n CASE \"A\"\n CASE \"H\"\n CASE \"L\"\n CASE \"O\"\n CASE \"U\"\n EXIT\n\n CASE \"B\"\n RETURN ValToTimeStamp( Eval( xVal ) )\n\n CASE \"C\"\n RETURN iif( IsDigit( SubStr( xVal, 3, 1 ) ) .AND. ;\n IsDigit( SubStr( xVal, 5, 1 ) ) .AND. ;\n IsDigit( SubStr( xVal, 7, 1 ) ), hb_SToT( xVal ), ;\n hb_StrToTS( xVal ) )\n\n CASE \"D\"\n RETURN hb_DToT( xVal )\n\n CASE \"T\"\n RETURN xVal\n\n CASE \"N\"\n RETURN t\"1900-01-01\" + xVal\n\n CASE \"P\"\n RETURN t\"1900-01-01\" + hb_HexToNum( hb_NumToHex( xVal ) )\n\n OTHERWISE\n Throw( xhb_ErrorNew( \"VALTODATE\", 0, 3103, ProcName(), \"Unsupported type\", { xVal } ) )\n ENDSWITCH\n\n RETURN hb_SToD()\n\n\nFUNCTION ValToHash( xVal )\n\n IF HB_ISHASH( xVal )\n RETURN xVal\n ENDIF\n\n RETURN { ValToCharacter( xVal ) => xVal }\n\n\nFUNCTION ValToLogical( xVal )\n\n SWITCH ValType( xVal )\n CASE \"A\"\n CASE \"D\"\n CASE \"T\"\n CASE \"H\"\n CASE \"N\"\n CASE \"O\"\n CASE \"P\"\n RETURN ! Empty( xVal )\n\n CASE \"B\"\n RETURN ValToLogical( Eval( xVal ) )\n\n CASE \"C\"\n IF Left( xVal, 1 ) == \".\" .AND. SubStr( xVal, 3, 1 ) == \".\" .AND. Upper( SubStr( xVal, 2, 1 ) ) $ \"TFYN\"\n RETURN Upper( SubStr( xVal, 2, 1 ) ) $ \"TY\"\n ELSEIF Len( xVal ) == 1 .AND. Upper( xVal ) $ \"TFYN\"\n RETURN Upper( xVal ) $ \"TY\"\n ELSE\n RETURN ! Empty( xVal )\n ENDIF\n EXIT\n\n CASE \"L\"\n RETURN xVal\n\n CASE \"U\"\n RETURN .F.\n\n OTHERWISE\n Throw( xhb_ErrorNew( \"VALTOLOGICAL\", 0, 3103, ProcName(), \"Unsupported type\", { xVal } ) )\n ENDSWITCH\n\n RETURN .F.\n\n\nFUNCTION ValToNumber( xVal )\n\n SWITCH ValType( xVal )\n CASE \"A\"\n CASE \"H\"\n RETURN Len( xVal )\n\n CASE \"B\"\n RETURN ValToNumber( Eval( xVal ) )\n\n CASE \"C\"\n RETURN Val( xVal )\n\n CASE \"D\"\n CASE \"T\"\n RETURN xVal - 0d19000101\n\n CASE \"L\"\n RETURN iif( xVal, 1, 0 )\n\n CASE \"O\"\n RETURN xVal:hClass\n\n CASE \"N\"\n RETURN xVal\n\n CASE \"P\"\n RETURN xVal - 0\n\n CASE \"U\"\n RETURN 0\n\n OTHERWISE"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/chareven.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CharEven()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharEven( \" 1 2 3 4 5\" ) == \"12345\" ? --> \"' + CharEven( \" 1 2 3 4 5\" ) + '\"'\n ? ' CharEven( \" 1 2 3 4 \" ) == \"1234\" ? --> \"' + CharEven( \" 1 2 3 4 \" ) + '\"'\n ? ' CharEven( \" \" ) == \"\" ? --> \"' + CharEven( \" \" ) + '\"'\n\n ? \"End test of CharEven()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/tests/numtxtru.prg. Contains procedures: Main, Test. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbmisc\"\n\n#include \"inkey.ch\"\n\nREQUEST HB_CODEPAGE_UTF8EX\n\nPROCEDURE Main()\n\n CLS\n\n hb_cdpSelect( \"UTF8EX\" )\n hb_SetTermCP( \"UTF8EX\" )\n\n ? \"Press ESC to break\"\n ? \"Russian\"\n Test( \"ru\" )\n ? \"Ukrainian\"\n Test( \"uk\" )\n ? \"Belorussian\"\n Test( \"be\" )\n\n RETURN\n\nPROCEDURE Test( cLang )\n\n LOCAL nTemp\n\n FOR nTemp := 1 TO 1000000000\n OutStd( ;\n PadR( MnyToTxtRU( nTemp + ( nTemp % 100 ) * 0.01, cLang, , 3 ), 100 ) + \" \" + ;\n PadR( NumToTxtRU( nTemp, cLang, , .T. ), 100 ) + \" \" + ;\n PadR( DateToTxtRU( Date() + nTemp, cLang, .T. ), 50 ) + hb_eol() )\n IF nTemp % 1000 == 0\n ? nTemp\n ENDIF\n IF nTemp % 10000 == 0\n IF Inkey() == K_ESC\n EXIT\n ENDIF\n ENDIF\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbtinymt' (Tiny Mersenne Twister PRNG): contrib/hbtinymt/tests/test64.prg. Contains procedures: Main, TestMatrix. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbtinymt\"\n\nPROCEDURE Main()\n\n SET DECIMAL TO 0\n\n IF tinymt64_init( 0x123, 0x234, 0x345 )\n TestMatrix( \"64-bit unsigned integers r, where 0 <= r < 2^64\", {|| PadL( tinymt64_generate_uint64(), 22 ) } )\n ENDIF\n\n SET DECIMAL TO 22\n\n IF tinymt64_init_by_array( { 0x123, 0x234, 0x345 } )\n TestMatrix( \"Double numbers r, where 0.0 <= r < 1.0\", {|| PadL( tinymt64_generate_double(), 30 ) } )\n TestMatrix( \"Double numbers r, where 0.0 <= r < 1.0\", {|| PadL( tinymt64_generate_double01(), 30 ) } )\n TestMatrix( \"Double numbers r, where 1.0 <= r < 2.0\", {|| PadL( tinymt64_generate_double12(), 30 ) } )\n TestMatrix( \"Double numbers r, where 0.0 < r <= 1.0\", {|| PadL( tinymt64_generate_doubleOC(), 30 ) } )\n TestMatrix( \"Double numbers r, where 0.0 < r < 1.0\", {|| PadL( tinymt64_generate_doubleOO(), 30 ) } )\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE TestMatrix( cDescription, bBlock )\n\n LOCAL i, j\n\n ? cDescription\n FOR i := 1 TO 10\n FOR j := 1 TO 5\n ? Eval( bBlock )\n NEXT\n ?\n NEXT\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/parseini.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main( cName )\n\n LOCAL hIni, aSect, cIni\n LOCAL cSection\n LOCAL cKey\n LOCAL nRow := 1\n\n SET COLOR TO w+/b\n CLS\n @ nRow++, 20 SAY \"H A R B O U R - .ini file parser test\"\n @ nRow++, 5 SAY \"Call from command line using a .ini filename as the only parameter\"\n nRow++\n\n IF Empty( cName )\n cName := \"parseini.ini\"\n @ nRow++, 5 SAY \"Using default parseini.ini file\"\n ENDIF\n\n hIni := hb_iniRead( cName )\n\n @ nRow, 0\n\n ? \"Content of \" + cName\n\n IF Empty( hIni )\n ? \"Not a valid .ini file!\"\n ELSE\n FOR EACH cSection IN hIni:Keys\n ?\n ? \"Section [\" + cSection + \"]\"\n aSect := hIni[ cSection ]\n\n FOR EACH cKey IN aSect:Keys\n ? cKey + \" = \" + aSect[ cKey ]\n NEXT\n NEXT\n ENDIF\n\n ?\n ? \"Adding section 'Added', with key NEW = new\"\n hIni[ \"Added\" ] := { => }\n hIni[ \"Added\" ][ \"NEW\" ] := \"new\"\n\n ? \"Writing output to parseini_out.ini\"\n IF hb_iniWrite( \"parseini_out.ini\", hIni, \"#Generated file; don't touch\", \"#End of file\" )\n ? \"File written\"\n ELSE\n ? \"Can't write file\"\n ENDIF\n ?\n ? \"Press any key to next text.\"\n Inkey( 0 )\n\n nRow := 3\n @ nRow, 0 CLEAR\n ?\n ? \"REPEATING TESTS WITHOUT AUTOMATIC MAIN SECTION\"\n ?\n\n hIni := hb_iniRead( cName,; \n ,; \n , .F. )\n\n ? \"Content of \" + cName\n\n IF Empty( hIni )\n ? \"Not a valid .ini file!\"\n ELSE\n FOR EACH cSection IN hIni:Keys\n \n aSect := hIni[ cSection ]\n\n IF HB_ISHASH( aSect )\n \n ?\n ? \"Section [\" + cSection + \"]\"\n\n FOR EACH cKey IN aSect:Keys\n ? cKey + \" = \" + aSect[ cKey ]\n NEXT\n ELSE\n \n ? \"TOPLEVEL option:\", cSection + \" = \" + aSect\n ENDIF\n NEXT\n ENDIF\n\n ?\n ? \"Adding section 'Added', with key NEW = new\"\n hIni[ \"Added\" ] := { => }\n hIni[ \"Added\" ][ \"NEW\" ] := \"new\"\n\n ? \"Writing output to parseini_out1.ini\"\n IF hb_iniWrite( \"parseini_out1.ini\", hIni,;\n \"#Generated file without main auto section; don't touch\", \"#End of file\",;\n .F. )\n ? \"File written\"\n ELSE\n ? \"Can't write file\"\n ENDIF\n ?\n ? \"Press any key to next text.\"\n Inkey( 0 )\n\n nRow := 3\n @ nRow, 0 CLEAR\n ?\n ? \"WRITING INI TO A STRING\"\n ?\n\n cIni := hb_iniWriteStr( hIni )\n\n ? \"Content of hIni : \"\n ?\n ? cIni\n ?\n ? \"Press any key to next text.\"\n Inkey( 0 )\n\n nRow := 3\n @ nRow, 0 CLEAR\n ?\n ? \"READING INI FILE FROM A STRING\"\n ?\n\n hIni := hb_iniReadStr( cIni,; \n ,; \n , .F. )\n\n ? \"Content: \"\n\n IF Empty( hIni )\n ? \"Not a valid .ini file!\"\n ELSE\n FOR EACH cSection IN hIni:Keys\n \n aSect := hIni[ cSection ]\n\n IF HB_ISHASH( aSect )\n \n ?\n ? \"Section [\" + cSection + \"]\"\n\n FOR EACH cKey IN aSect:Keys\n ? cKey + \" = \" + aSect[ cKey ]\n NEXT\n ELSE\n \n ? \"TOPLEVEL option:\", cSection + \" = \" + aSect\n ENDIF\n NEXT\n ENDIF\n\n ?\n ? \"Press any key to next text.\"\n Inkey( 0 )\n\n nRow := 3\n @ nRow, 0 CLEAR\n ?\n ? \"WRITING INI FILE TO A STRING \"\n ?\n\n cIni := hb_iniWriteStr( hb_iniRead( cName ) )\n\n ? \"Content of \" + cName\n ?\n ? cIni\n ?\n ? \"Press any key to next text.\"\n Inkey( 0 )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour source file: src/rdd/hbsix/sxcompat.prg. Provides 16 functions including: sxChar, sxNum, sxDate, sxLog, sx_Compress. This file implements core Record Driver Driver functionality"}, {"role": "assistant", "content": "#include \"dbinfo.ch\"\n#include \"dbstruct.ch\"\n#include \"fileio.ch\"\n#include \"ord.ch\"\n#include \"hbsxdef.ch\"\n\nFUNCTION sxChar( nLen, xKeyVal )\n\n SWITCH ValType( xKeyVal )\n CASE \"C\"\n CASE \"M\"\n EXIT\n CASE \"N\"\n xKeyVal := Str( xKeyVal )\n EXIT\n CASE \"D\"\n xKeyVal := DToS( xKeyVal )\n EXIT\n CASE \"T\"\n xKeyVal := hb_TToS( xKeyVal )\n EXIT\n CASE \"L\"\n xKeyVal := iif( xKeyVal, \"T\", \"F\" )\n EXIT\n OTHERWISE\n xKeyVal := iif( HB_ISNUMERIC( nLen ), \"\", Space( 10 ) )\n EXIT\n ENDSWITCH\n\n IF HB_ISNUMERIC( nLen )\n xKeyVal := PadR( LTrim( xKeyVal ), nLen )\n ENDIF\n\n RETURN xKeyVal\n\nFUNCTION sxNum( xKeyVal )\n\n SWITCH ValType( xKeyVal )\n CASE \"N\"\n EXIT\n CASE \"C\"\n CASE \"M\"\n xKeyVal := Val( xKeyVal )\n EXIT\n CASE \"T\"\n CASE \"D\"\n xKeyVal := xKeyVal - hb_SToD()\n EXIT\n CASE \"L\"\n xKeyVal := iif( xKeyVal, 1, 0 )\n EXIT\n OTHERWISE\n xKeyVal := 0.00\n EXIT\n ENDSWITCH\n\n RETURN xKeyVal\n\nFUNCTION sxDate( xKeyVal )\n\n SWITCH ValType( xKeyVal )\n CASE \"D\"\n EXIT\n CASE \"T\"\n xKeyVal := hb_TToD( xKeyVal )\n EXIT\n CASE \"C\"\n CASE \"M\"\n xKeyVal := CToD( xKeyVal )\n EXIT\n CASE \"N\"\n xKeyVal := hb_SToD() + xKeyVal\n EXIT\n OTHERWISE\n xKeyVal := hb_SToD()\n EXIT\n ENDSWITCH\n\n RETURN xKeyVal\n\nFUNCTION sxLog( xKeyVal )\n\n SWITCH ValType( xKeyVal )\n CASE \"L\"\n EXIT\n CASE \"C\"\n CASE \"M\"\n SWITCH xKeyVal\n CASE \"T\"; CASE \"t\"; CASE \"Y\"; CASE \"y\"\n CASE \".T.\"; CASE \".t.\"; CASE \".Y.\"; CASE \".y.\"\n xKeyVal := .T.\n EXIT\n OTHERWISE\n xKeyVal := .F.\n EXIT\n ENDSWITCH\n EXIT\n CASE \"N\"\n xKeyVal := xKeyVal != 0\n EXIT\n OTHERWISE\n xKeyVal := .F.\n EXIT\n ENDSWITCH\n\n RETURN xKeyVal\n\nFUNCTION sx_Compress( xVal )\n\n LOCAL xRetVal\n\n SWITCH ValType( xVal )\n CASE \"C\"\n CASE \"M\"\n RETURN _sx_StrCompress( xVal )\n CASE \"A\"\n xRetVal := Array( Len( xVal ) )\n AEval( xVal, {| x, i | xRetVal[ i ] := sx_Compress( x ) } )\n RETURN xRetVal\n ENDSWITCH\n\n RETURN xVal\n\nFUNCTION sx_Decompress( xVal )\n\n LOCAL xRetVal\n\n SWITCH ValType( xVal )\n CASE \"C\"\n CASE \"M\"\n RETURN _sx_StrDecompress( xVal )\n CASE \"A\"\n xRetVal := Array( Len( xVal ) )\n AEval( xVal, {| x, i | xRetVal[ i ] := sx_Decompress( x ) } )\n RETURN xRetVal\n ENDSWITCH\n\n RETURN xVal\n\nFUNCTION sx_TagInfo( cIndex )\n\n LOCAL aInfo, nOrds, nFirst, i\n\n IF Used() .AND. ( nOrds := ordCount( cIndex ) ) > 0\n aInfo := Array( nOrds, 6 )\n IF HB_ISSTRING( cIndex )\n nFirst := dbOrderInfo( DBOI_BAGORDER, cIndex )\n nOrds += nFirst - 1\n ELSE\n nFirst := 1\n ENDIF\n FOR i := nFirst TO nOrds\n aInfo[ i ][ 1 ] := ordName( i )\n aInfo[ i ][ 2 ] := ordKey( i )\n aInfo[ i ][ 3 ] := ordFor( i )\n aInfo[ i ][ 4 ] := ordIsUnique( i )\n aInfo[ i ][ 5 ] := ordDescend( i )\n aInfo[ i ][ 6 ] := ordCustom( i )\n NEXT\n RETURN aInfo\n ENDIF\n\n RETURN {}\n\nFUNCTION sx_TagCount( xIndex )\n\n LOCAL nTags := 0, cIndex, nOrder\n\n IF Used()\n DO CASE\n CASE HB_ISNUMERIC( xIndex )\n IF ( nOrder := sx_TagOrder( 1, xIndex ) ) != 0\n cIndex := dbOrderInfo( DBOI_FULLPATH,, nOrder )\n ENDIF\n CASE HB_ISSTRING( xIndex ) .AND. ! Empty( xIndex )\n cIndex := xIndex\n OTHERWISE\n cIndex := dbOrderInfo( DBOI_FULLPATH )\n ENDCASE\n IF ! Empty( cIndex )\n nTags := ordCount( cIndex )\n ENDIF\n ENDIF\n\n RETURN nTags\n\nFUNCTION sx_Tags( xIndex )\n\n LOCAL aTagNames := {}, nOrder, nTags\n\n IF Used()\n DO CASE\n CASE HB_ISNUMERIC( xIndex )\n nOrder := sx_TagOrder( 1, xIndex )\n CASE HB_ISSTRING( xIndex ) .AND. ! Empty( xIndex )\n nOrder := dbOrderInfo( DBOI_BAGORDER, xIndex )\n OTHERWISE\n nOrder := ordNumber()\n ENDCASE\n IF nOrder != 0\n nTags := ordCount( dbOrderInfo( DBOI_FULLPATH,, nOrder ) )\n DO WHILE --nTags >= 0\n AAdd( aTagNames, ordName( nOrder++ ) )\n ENDDO\n ENDIF\n ENDIF\n\n RETURN aTagNames\n\nFUNCTION sx_SetTag( xTag, xIndex )\n\n LOCAL lRet := .F., nOrder := 0, nOldOrd, cIndex\n\n IF Used() .AND. ValType( xTag ) $ \"CN\"\n IF HB_ISNUMERIC( xTag )\n IF Empty( xIndex ) .OR. ! ValType( xIndex ) $ \"CN\"\n nOrder := xTag\n ELSEIF HB_ISSTRING( xIndex )\n IF xTag >= 1 .AND. xTag <= ordCount( xIndex )\n nOrder := dbOrderInfo( DBOI_BAGORDER, xIndex ) + xTag - 1\n ENDIF\n ELSE\n nOrder := sx_TagOrder( xTag, xIndex )\n ENDIF\n ELSE\n IF Empty( xIndex ) .OR. ! ValType( xIndex ) $ \"CN\"\n nOrder := ordNumber( xTag )\n ELSEIF HB_ISSTRING( xIndex )\n nOrder := sx_TagOrder( xTag, xIndex )\n ELSE\n nOrder := sx_TagOrder( 1, xIndex )\n IF nOrder != 0\n cIndex := dbOrderInfo( DBOI_FULLPATH,, nOrder )\n IF Empty( cIndex )\n nOrder := 0\n ELSE\n nOrder := sx_TagOrder( xTag, cIndex )\n ENDIF\n ENDIF\n ENDIF\n ENDIF\n IF nOrder != 0\n nOldOrd := ordNumber()\n ordSetFocus( nOrder )\n lRet := nOrder == ordNumber()\n IF ! lRet\n ordSetFocus( nOldOrd )\n ENDIF\n ELSEIF Empty( xTag )\n ordSetFocus( 0 )\n lRet := .T.\n ENDIF\n ENDIF\n\n RETURN lRet\n\nFUNCTION sx_KillTag( xTag, xIndex )\n\n LOCAL lRet := .F., nOrder, cIndex\n\n IF HB_ISLOGICAL( xTag )\n IF xTag\n DO CASE\n CASE Empty( xIndex )\n cIndex := sx_IndexName()\n CASE HB_ISNUMERIC( xIndex )\n cIndex := sx_IndexName( 1, xIndex )\n CASE HB_ISSTRING( xIndex )\n nOrder := dbOrderInfo( DBOI_BAGORDER, xIndex )\n IF nOrder != 0\n cIndex := dbOrderInfo( DBOI_FULLPATH,, nOrder )\n ENDIF\n ENDCASE\n IF ! Empty( cIndex )\n IF ordBagClear( cIndex )\n lRet := FErase( cIndex ) != F_ERROR\n ENDIF\n ENDIF\n ENDIF\n ELSE\n IF HB_ISNUMERIC( xTag )\n IF Empty( xIndex ) .OR. ! ValType( xIndex ) $ \"CN\"\n nOrder := xTag\n ELSEIF HB_ISSTRING( xIndex )\n IF xTag >= 1 .AND. xTag <= ordCount( xIndex )\n nOrder := dbOrderInfo( DBOI_BAGORDER, xIndex ) + xTag - 1\n ELSE\n nOrder := 0\n ENDIF\n ELSE\n nOrder := sx_TagOrder( xTag, xIndex )\n ENDIF\n ELSE\n IF Empty( xIndex ) .OR. ! ValType( xIndex ) $ \"CN\"\n nOrder := ordNumber( xTag )\n ELSEIF HB_ISSTRING( xIndex )\n nOrder := sx_TagOrder( xTag, xIndex )\n ELSE\n IF ( nOrder := sx_TagOrder( 1, xIndex ) ) != 0\n cIndex := dbOrderInfo( DBOI_FULLPATH,, nOrder )\n IF Empty( cIndex )\n nOrder := 0\n ELSE\n nOrder := sx_TagOrder( xTag, cIndex )\n ENDIF\n ENDIF\n ENDIF\n ENDIF\n IF nOrder != 0\n lRet := ordDestroy( nOrder )\n ENDIF\n ENDIF\n\n RETURN lRet\n\nFUNCTION sx_FileOrder()\n RETURN dbOrderInfo( DBOI_BAGNUMBER )\n\nFUNCTION sx_SetFileOrd( nIndex )\n RETURN iif( HB_ISNUMERIC( nIndex ), ;\n ordSetFocus( sx_TagOrder( 1, nIndex ) ), ;\n ordSetFocus() )\n\nFUNCTION rdd_Count()\n RETURN Len( rddList() )\n\nFUNCTION rdd_Name( nRDD )\n\n LOCAL aRDD\n\n IF HB_ISNUMERIC( nRDD ) .AND. nRDD >= 1\n aRDD := rddList()\n IF nRDD <= Len( aRDD )\n RETURN aRDD[ nRDD ]\n ENDIF\n ENDIF\n\n RETURN \"\"\n\nFUNCTION rdd_Info( xID )\n\n LOCAL cRDD\n\n DO CASE\n CASE HB_ISNUMERIC( xID )\n IF ! Alias( xID ) == \"\"\n ( xID )->( rddName() )\n ENDIF\n CASE HB_ISSTRING( xID )\n cRDD := Upper( AllTrim( xID ) )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour Runtime Library file: src/rtl/altd.prg. Contains procedures: AltD. This file provides utility functions"}, {"role": "assistant", "content": "#define ALTD_DISABLE 0\n#define ALTD_ENABLE 1\n\nPROCEDURE AltD( nAction )\n\n IF PCount() == 0\n\n \n __dbgInvokeDebug( Set( _SET_DEBUG ) )\n\n ELSEIF HB_ISNUMERIC( nAction )\n\n SWITCH nAction\n CASE ALTD_DISABLE\n Set( _SET_DEBUG, .F. )\n EXIT\n CASE ALTD_ENABLE\n Set( _SET_DEBUG, .T. )\n EXIT\n ENDSWITCH\n\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbgt' (): contrib/hbgt/tests/test.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbgt\"\n#require \"hbtest\"\n\nPROCEDURE Main()\n\n HBTEST gt_AscPos( \"Harbour\", 1 ) IS 72\n HBTEST gt_AtDiff( \"This Is Harbour\", \"This Is Clipper\" ) IS 9\n HBTEST gt_CharEven( \"The_Power_Of_Harbour\" ) IS \"h_oe_fHror\"\n HBTEST gt_CharOdd( \"The_Power_Of_Harbour\" ) IS \"TePwrO_abu\"\n HBTEST gt_ChrCount( \"s\", \"she sells shells by the sea shore\" ) IS 7\n HBTEST gt_ChrTotal( \"sl\", \"she sells shells by the sea shore\" ) IS 11\n HBTEST gt_CharMix( \"CLIPPER\", \"harbour\" ) IS \"ChLaIrPbPoEuRr\"\n HBTEST gt_AsciiSum( \"harbour\" ) IS 755\n HBTEST gt_ChrFirst( \"Ho\", \"the power of Harbour\" ) IS 111\n HBTEST gt_StrCount( \"the\", \"the cat sat on the mat\" ) IS 2\n HBTEST gt_StrCSPN( \"this is a test\", \"as \" ) IS 3\n HBTEST gt_StrCSPN( \"this is a test\", \"elnjpq\" ) IS 11\n HBTEST gt_StrDiff( \"the cat\", \"the rat\" ) IS \"rat\"\n HBTEST gt_StrExpand( \"Harbour\", 2, \"-\" ) IS \"H--a--r--b--o--u--r\"\n HBTEST gt_StrLeft( \"this is a test\", \"hsit \" ) IS 8\n HBTEST gt_StrPBRK( \"this is a test\", \"sa \" ) IS \"s is a test\"\n HBTEST gt_StrRight( \"this is a test\", \"teas \" ) IS 8\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbodbc' (ODBC database connectivity): contrib/hbodbc/tests/todbc.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbodbc\"\n\nPROCEDURE Main()\n\n LOCAL dsFunctions := TODBC():New( \"DBQ=\" + hb_FNameMerge( hb_DirBase(), \"test.mdb\" ) + \";Driver={Microsoft Access Driver (*.mdb)}\" )\n\n LOCAL aOrders\n LOCAL nOp\n LOCAL i\n\n SET COLOR TO \"W+/B\"\n CLS\n\n DO WHILE .T.\n\n @ 0, 0 SAY PadC( \"- TODBC Demonstration -\", MaxCol() + 1 ) COLOR \"B/W\"\n\n dsFunctions:SetSQL( \"SELECT * FROM test\" )\n dsFunctions:Open()\n\n @ 3, 24 TO Len( dsFunctions:Fields ) + 4, 55\n\n aOrders := {}\n FOR i := 1 TO Len( dsFunctions:Fields )\n AAdd( aOrders, dsFunctions:Fields[ i ]:FieldName )\n @ i + 3, 25 PROMPT PadC( \"ORDER BY \" + aOrders[ i ], 30 )\n NEXT\n\n MENU TO nOp\n\n IF nOp == 0\n EXIT\n ENDIF\n\n dsFunctions:Close()\n\n dsFunctions:SetSQL( \"SELECT * FROM test ORDER BY \" + aOrders[ nOp ] )\n dsFunctions:Open()\n\n @ 14, 5 SAY \" \" + ;\n PadR( dsFunctions:FieldByName( \"First\" ):FieldName, 10 ) + \" \" + ;\n PadR( dsFunctions:FieldByName( \"Last\" ):FieldName, 10 ) + \" \" + ;\n PadR( dsFunctions:FieldByName( \"Street\" ):FieldName, 25 ) + \" \" + ;\n PadR( dsFunctions:FieldByName( \"City\" ):FieldName, 40 ) ;\n COLOR \"B/W\"\n\n dsFunctions:Skip() \n\n DO WHILE ! dsFunctions:Eof()\n ? \" \" + ;\n PadR( dsFunctions:FieldByName( \"First\" ):Value, 10 ), \"|\", ;\n PadR( dsFunctions:FieldByName( \"Last\" ):Value, 10 ), \"|\", ;\n PadR( dsFunctions:FieldByName( \"Street\" ):Value, 25 ), \"|\", ;\n PadR( dsFunctions:FieldByName( \"City\" ):Value, 40 )\n dsFunctions:Skip()\n ENDDO\n\n @ MaxRow(), 0\n @ MaxRow(), 1 SAY \"Statement:\" COLOR \"GR+/B\"\n @ MaxRow(), Col() + 1 SAY dsFunctions:cSQL\n\n dsFunctions:Close()\n\n ENDDO\n dsFunctions:Destroy()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/tests/readfile.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbmisc\"\n\nPROCEDURE Main( cFile )\n\n LOCAL oFile := TFileRead():New( cFile )\n\n oFile:Open()\n IF oFile:Error()\n ? oFile:ErrorMsg( \"FileRead:\" )\n ELSE\n DO WHILE oFile:MoreToRead()\n ? oFile:ReadLine()\n ENDDO\n oFile:Close()\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/mutexwin.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\nSTATIC s_hMutex\n\nPROCEDURE Main()\n\n LOCAL cAppName\n\n \n hb_FNameSplit( hb_ProgName(), NIL, @cAppName )\n\n s_hMutex := wapi_CreateMutex( NIL, NIL, cAppName )\n IF ! Empty( s_hMutex ) .AND. wapi_GetLastError() == 0\n ? cAppName, \"=> Hello World! OK.\"\n ELSE\n ? cAppName, \"=> Application is running. Error\", wapi_GetLastError()\n ENDIF\n\n WAIT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hbxml.ch. Defines 10 constants including: HB_XML_CH, HBXML_STYLE_NOINDENT, HBXML_STYLE_INDENT, HBXML_STYLE_TAB, HBXML_STYLE_THREESPACES. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_XML_CH\n#define HB_XML_CH\n\n\n#define HBXML_STYLE_NOINDENT 0 \n#define HBXML_STYLE_INDENT 1 \n#define HBXML_STYLE_TAB 2 \n#define HBXML_STYLE_THREESPACES 4 \n#define HBXML_STYLE_NOESCAPE 8\n#define HBXML_STYLE_NONEWLINE 16 \n\n\n#define HBXML_STATUS_ERROR 0\n#define HBXML_STATUS_OK 1\n#define HBXML_STATUS_MORE 2\n#define HBXML_STATUS_DONE 3\n#define HBXML_STATUS_UNDEFINED 4\n#define HBXML_STATUS_MALFORMED 5\n\n\n#define HBXML_ERROR_NONE 0\n#define HBXML_ERROR_IO 1\n#define HBXML_ERROR_NOMEM 2\n#define HBXML_ERROR_OUTCHAR 3\n#define HBXML_ERROR_INVNODE 4\n#define HBXML_ERROR_INVATT 5\n#define HBXML_ERROR_MALFATT 6\n#define HBXML_ERROR_INVCHAR 7\n#define HBXML_ERROR_NAMETOOLONG 8\n#define HBXML_ERROR_ATTRIBTOOLONG 9\n#define HBXML_ERROR_VALATTOOLONG 10\n#define HBXML_ERROR_UNCLOSED 11\n#define HBXML_ERROR_UNCLOSEDENTITY 12\n#define HBXML_ERROR_WRONGENTITY 13\n\n\n#define HBXML_TYPE_TAG 0\n#define HBXML_TYPE_COMMENT 1\n#define HBXML_TYPE_PI 2\n#define HBXML_TYPE_DIRECTIVE 3\n#define HBXML_TYPE_DATA 4\n#define HBXML_TYPE_CDATA 5\n#define HBXML_TYPE_DOCUMENT 6\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/langapi.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "REQUEST HB_LANG_HU\nREQUEST HB_LANG_KO\n\nPROCEDURE Main()\n\n ? \"Prev:\", hb_langSelect()\n ? hb_langName()\n ? NationMsg( 1 )\n ? CMonth( Date() )\n ? CDoW( Date() )\n ? \"---------\"\n\n ? \"Prev:\", hb_langSelect( \"hu\" )\n ? hb_langName()\n ? NationMsg( 1 )\n ? CMonth( Date() )\n ? CDoW( Date() )\n ? \"---------\"\n\n ? \"Prev:\", hb_langSelect( \"ko\" )\n ? hb_langName()\n ? NationMsg( 1 )\n ? CMonth( Date() )\n ? CDoW( Date() )\n ? \"---------\"\n\n ? \"Prev:\", hb_langSelect( \"NOTHERE\" )\n ? hb_langName()\n ? NationMsg( 1 )\n ? CMonth( Date() )\n ? CDoW( Date() )\n ? \"---------\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/nwsem.prg. Provides 8 functions including: ft_NWSemOpen, ft_NWSemEx, ft_NWSemWait, ft_NWSemSig, ft_NWSemClose. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"ftint86.ch\"\n\n#define WAIT_SEMAPHORE 2\n#define SIGNAL_SEMAPHORE 3\n#define CLOSE_SEMAPHORE 4\n\n\nFUNCTION ft_NWSemOpen( cName, nInitVal, nHandle, nOpenCnt )\n\n LOCAL aRegs[ INT86_MAX_REGS ], cRequest, nRet\n\n __defaultNIL( @cName, \"\" )\n __defaultNIL( @nInitVal, 0 )\n __defaultNIL( @nHandle, 0 )\n __defaultNIL( @nOpenCnt, 0 )\n\n cName := iif( hb_BLen( cName ) > 127, hb_BSubStr( cName, 1, 127 ), cName )\n cRequest := hb_BChar( Len( cName ) ) + cName\n\n aRegs[ AX ] := MAKEHI( 197 ) \n aRegs[ DS ] := cRequest\n aRegs[ DX ] := REG_DS\n aRegs[ CX ] := nInitVal\n\n ft_int86( 33, aRegs )\n\n nHandle := Bin2L( I2Bin( aRegs[ CX ] ) + I2Bin( aRegs[ DX ] ) )\n nOpenCnt := LOWBYTE( aRegs[ BX ] )\n\n nRet := LOWBYTE( aRegs[ AX ] )\n\n RETURN iif( nRet < 0, nRet + 256, nRet )\n\n\nFUNCTION ft_NWSemEx( nHandle, nValue, nOpenCnt )\n\n LOCAL aRegs[ INT86_MAX_REGS ], nRet\n\n __defaultNIL( @nHandle, 0 )\n __defaultNIL( @nValue, 0 )\n __defaultNIL( @nOpenCnt, 0 )\n\n aRegs[ AX ] := MAKEHI( 197 ) + 1 \n aRegs[ CX ] := Bin2I( hb_BSubStr( L2Bin( nHandle ), 1, 2 ) )\n aRegs[ DX ] := Bin2I( hb_BSubStr( L2Bin( nHandle ), 3, 2 ) )\n\n ft_int86( 33, aRegs )\n\n nValue := aRegs[ CX ]\n nOpenCnt := LOWBYTE( aRegs[ DX ] )\n nRet := LOWBYTE( aRegs[ AX ] )\n\n RETURN iif( nRet < 0, nRet + 256, nRet )\n\nFUNCTION ft_NWSemWait( nHandle, nTimeout )\n\n RETURN _ftnwsem( WAIT_SEMAPHORE, nHandle, nTimeout )\n\nFUNCTION ft_NWSemSig( nHandle )\n\n RETURN _ftnwsem( SIGNAL_SEMAPHORE, nHandle )\n\nFUNCTION ft_NWSemClose( nHandle )\n\n RETURN _ftnwsem( CLOSE_SEMAPHORE, nHandle )\n\n\nSTATIC FUNCTION _ftnwsem( nOp, nHandle, nTimeout )\n\n LOCAL aRegs[ INT86_MAX_REGS ], nRet\n\n __defaultNIL( @nOp, SIGNAL_SEMAPHORE )\n __defaultNIL( @nHandle, 0 )\n __defaultNIL( @nTimeout, 0 )\n\n aRegs[ AX ] := MAKEHI( 197 ) + nOp\n aRegs[ CX ] := Bin2I( hb_BSubStr( L2Bin( nHandle ), 1, 2 ) )\n aRegs[ DX ] := Bin2I( hb_BSubStr( L2Bin( nHandle ), 3, 2 ) )\n aRegs[ BP ] := nTimeout\n\n ft_int86( 33, aRegs )\n nRet := LOWBYTE( aRegs[ AX ] )\n nRet := iif( nRet < 0, nRet + 256, nRet )\n\n RETURN nRet\n\nFUNCTION ft_NWSemLock( cSemaphore, nHandle )\n\n LOCAL nOpenCnt := 0\n LOCAL nRc := ft_NWSemOpen( cSemaphore, 0, @nHandle, @nOpenCnt )\n\n IF nRc == 0\n IF nOpenCnt != 1\n ft_NWSemClose( nHandle )\n ENDIF\n ENDIF\n\n RETURN nOpenCnt == 1\n\nFUNCTION ft_NWSemUnlock( nHandle )\n\n RETURN ft_NWSemClose( nHandle ) == 0"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour header file: include/hbpers.ch. Defines constants: HB_PERS_CH_. Declares 4 preprocessor commands. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_PERS_CH_\n#define HB_PERS_CH_\n\n#xcommand OBJECT AS => ;\n Self := hb_SetObject( Self, {|| ():New() } )\n\n#xcommand ENDOBJECT => Self := hb_EndObject()\n\n#xcommand ARRAY LEN => := Array( )\n\n#xcommand ENDARRAY => \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hblognet.prg. Defines classes: HB_LogEmail, HB_LogInetPort. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#define CRLF Chr( 13 ) + Chr( 10 )\n\nCREATE CLASS HB_LogEmail INHERIT HB_LogChannel\n\n VAR cServer\n VAR cAddress INIT \"log@example.org\"\n VAR cSubject INIT \"Log message from xHarbour application\"\n VAR cSendTo\n VAR cHelo INIT \"xHarbour Email Logger\"\n VAR nPort INIT 25\n\n VAR cPrefix\n VAR cPostfix\n\n METHOD New( nLevel, cHelo, cServer, cSendTo, cSubject, cFrom )\n METHOD Open( cName )\n METHOD Close( cName )\n\n PROTECTED:\n METHOD Send( nStyle, cMessage, cName, nPriority )\n\n HIDDEN:\n METHOD GetOk( skCon )\n METHOD Prepare( nStyle, cMessage, cName, nPriority )\n\nENDCLASS\n\nMETHOD New( nLevel, cHelo, cServer, cSendTo, cSubject, cFrom ) CLASS HB_LogEmail\n\n LOCAL nPos\n\n ::Super:New( nLevel )\n\n nPos := At( \":\", cServer )\n IF nPos > 0\n ::nPort := Val( SubStr( cServer, nPos + 1 ) )\n cServer := SubStr( cServer, 1, nPos - 1 )\n ENDIF\n\n ::cServer := cServer\n ::cSendTo := cSendTo\n\n IF cHelo != NIL\n ::cHelo := cHelo\n ENDIF\n\n IF cSubject != NIL\n ::cSubject := cSubject\n ENDIF\n\n IF cFrom != NIL\n ::cAddress := cFrom\n ENDIF\n\n RETURN Self\n\n\nMETHOD Open( cName ) CLASS HB_LogEmail\n\n HB_SYMBOL_UNUSED( cName )\n hb_inetInit()\n\n RETURN .T.\n\n\nMETHOD Close( cName ) CLASS HB_LogEmail\n\n HB_SYMBOL_UNUSED( cName )\n hb_inetCleanup()\n\n RETURN .T.\n\n\nMETHOD Send( nStyle, cMessage, cName, nPriority ) CLASS HB_LogEmail\n\n LOCAL skCon := hb_inetCreate()\n\n hb_inetTimeout( skCon, 10000 )\n\n hb_inetConnect( ::cServer, ::nPort, skCon )\n\n IF hb_inetErrorCode( skCon ) != 0 .OR. ! ::GetOk( skCon )\n RETURN .F.\n ENDIF\n\n hb_inetSendAll( skCon, \"HELO \" + ::cHelo + CRLF )\n IF ! ::GetOk( skCon )\n RETURN .F.\n ENDIF\n\n hb_inetSendAll( skCon, \"MAIL FROM: <\" + ::cAddress + \">\" + CRLF )\n IF ! ::GetOk( skCon )\n RETURN .F.\n ENDIF\n\n hb_inetSendAll( skCon, \"RCPT TO: <\" + ::cSendTo + \">\" + CRLF )\n IF ! ::GetOk( skCon )\n RETURN .F.\n ENDIF\n\n hb_inetSendAll( skCon, \"DATA\" + CRLF )\n IF ! ::GetOk( skCon )\n RETURN .F.\n ENDIF\n\n cMessage := ::Prepare( nStyle, cMessage, cName, nPriority )\n\n hb_inetSendAll( skCon, cMessage + CRLF + \".\" + CRLF )\n IF ! ::GetOk( skCon )\n RETURN .F.\n ENDIF\n\n hb_inetSendAll( skCon, \"QUIT\" + CRLF )\n\n RETURN ::GetOk( skCon ) \n\n\nMETHOD GetOk( skCon ) CLASS HB_LogEmail\n\n LOCAL nLen, cReply\n\n cReply := hb_inetRecvLine( skCon, @nLen, 128 )\n IF hb_inetErrorCode( skcon ) != 0 .OR. SubStr( cReply, 1, 1 ) == \"5\"\n RETURN .F.\n ENDIF\n\n RETURN .T.\n\nMETHOD Prepare( nStyle, cMessage, cName, nPriority ) CLASS HB_LogEmail\n\n LOCAL cPre\n\n cPre := \"FROM: \" + ::cAddress + CRLF + ;\n \"TO: \" + ::cSendTo + CRLF + ;\n \"Subject:\" + ::cSubject + CRLF + CRLF\n\n IF ! Empty( ::cPrefix )\n cPre += ::cPrefix + CRLF + CRLF\n ENDIF\n\n cPre += ::Format( nStyle, cMessage, cName, nPriority )\n\n IF ! Empty( ::cPostfix )\n cPre += CRLF + CRLF + ::cPostfix + CRLF\n ENDIF\n\n RETURN cPre\n\n\nCREATE CLASS HB_LogInetPort FROM HB_LogChannel\n\n VAR nPort INIT 7761\n VAR aListeners INIT {}\n VAR skIn\n\n VAR bTerminate INIT .F.\n VAR nThread\n VAR mtxBusy\n\n METHOD New( nLevel, nPort )\n METHOD Open( cName )\n METHOD Close( cName )\n\n PROTECTED:\n METHOD Send( nStyle, cMessage, cName, nPriority )\n\n HIDDEN:\n METHOD AcceptCon()\n\nENDCLASS\n\nMETHOD New( nLevel, nPort ) CLASS HB_LogInetPort\n\n ::Super:New( nLevel )\n\n IF nPort != NIL\n ::nPort := nPort\n ENDIF\n\n RETURN Self\n\nMETHOD Open( cName ) CLASS HB_LogInetPort\n\n HB_SYMBOL_UNUSED( cName )\n\n hb_inetInit()\n\n ::skIn := hb_inetServer( ::nPort )\n\n IF ::skIn == NIL\n RETURN .F.\n ENDIF\n\n ::mtxBusy := hb_mutexCreate()\n ::nThread := hb_threadStart( Self, \"AcceptCon\" )\n\n RETURN .T.\n\nMETHOD Close( cName ) CLASS HB_LogInetPort\n\n LOCAL sk\n\n HB_SYMBOL_UNUSED( cName )\n\n IF ::skIn == NIL\n RETURN .F.\n ENDIF\n\n \n ::bTerminate := .T.\n hb_threadJoin( ::nThread )\n\n hb_inetClose( ::skIn )\n\n \n DO WHILE Len( ::aListeners ) > 0\n sk := ATail( ::aListeners )\n ASize( ::aListeners, Len( ::aListeners ) - 1 )\n hb_inetClose( sk )\n ENDDO\n\n hb_inetCleanup()\n\n RETURN .T.\n\nMETHOD Send( nStyle, cMessage, cName, nPriority ) CLASS HB_LogInetPort\n\n LOCAL sk, nCount\n\n \n hb_mutexLock( ::mtxBusy )\n\n \n cMessage := ::Format( nStyle, cMessage, cName, nPriority )\n\n nCount := 1\n DO WHILE nCount <= Len( ::aListeners )\n sk := ::aListeners[ nCount ]\n hb_inetSendAll( sk, cMessage + CRLF )\n \n IF hb_inetErrorCode( sk ) != 0\n hb_ADel( ::aListeners, nCount, .T. )\n ELSE\n nCount++\n ENDIF\n ENDDO\n\n hb_mutexUnlock( ::mtxBusy )\n\n RETURN .T.\n\nMETHOD AcceptCon() CLASS HB_LogInetPort\n\n LOCAL sk\n\n hb_inetTimeout( ::skIn, 250 )\n DO WHILE ! ::bTerminate\n sk := hb_inetAccept( ::skIn )\n \n IF sk != NIL\n hb_mutexLock( ::mtxBusy )\n AAdd( ::aListeners, sk )\n hb_mutexUnlock( ::mtxBusy )\n ENDIF\n ENDDO\n\n RETURN .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'sddsqlt3' (): contrib/sddsqlt3/tests/test.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"rddsql\"\n#require \"sddsqlt3\"\n\n#include \"simpleio.ch\"\n\nREQUEST SDDSQLITE3, SQLMIX\n\nPROCEDURE Main()\n\n LOCAL tmp\n\n#if defined( __HBSCRIPT__HBSHELL )\n rddRegister( \"SQLBASE\" )\n rddRegister( \"SQLMIX\" )\n hb_SDDSQLITE3_Register()\n#endif\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n rddSetDefault( \"SQLMIX\" )\n\n AEval( rddList(), {| X | QOut( X ) } )\n\n ? \"-1-\"\n ? \"Connect:\", tmp := rddInfo( RDDI_CONNECT, { \"SQLITE3\", hb_DirBase() + \"test.sqlite3\" } )\n IF tmp == 0\n ? \"Unable connect to the server\"\n ENDIF\n ? \"-2-\"\n ? \"Use:\", dbUseArea( .T., , \"select * from t1\", \"t1\" )\n ? \"-3-\"\n ? \"Alias:\", Alias()\n ? \"-4-\"\n ? \"DB struct:\", hb_ValToExp( dbStruct() )\n ? \"-5-\"\n FOR tmp := 1 TO FCount()\n ? FieldName( tmp ), hb_FieldType( tmp )\n NEXT\n ? \"-6-\"\n Inkey( 0 )\n Browse()\n\n INDEX ON FIELD->AGE TO age\n dbGoTop()\n Browse()\n dbCloseArea()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/scrmark.prg. Provides functions: ScreenMark. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ScreenMark( cSearch, xAttr, lUpperLower, lAll, cForward, cTrailing )\n\n LOCAL lFound := .F.\n LOCAL nCount := 1\n LOCAL nAt, nLen, nLast, nRow, nCol, nEnd, nCols\n LOCAL cScreen\n\n hb_default( @lUpperLower, .F. )\n hb_default( @lAll, .F. )\n\n IF ! HB_ISSTRING( cForward ) .OR. cForward == \"\"\n cForward := NIL\n ENDIF\n IF ! HB_ISSTRING( cTrailing ) .OR. cTrailing == \"\"\n cTrailing := NIL\n ENDIF\n\n nCols := MaxCol()\n cScreen := ScreenText( 0, 0, MaxRow(), nCols++ )\n nLen := Len( cSearch )\n nLast := Len( cScreen ) - nLen + 1\n\n IF ! lUpperLower\n cSearch := Upper( cSearch )\n cScreen := Upper( cScreen )\n ENDIF\n\n DO WHILE ( nAt := AtNum( cSearch, cScreen, nCount ) ) != 0\n\n IF ( nAt == 1 .OR. cForward == NIL .OR. ;\n SubStr( cScreen, nAt, 1 ) $ cForward ) .AND. ;\n ( nAt == nLast .OR. cTrailing == NIL .OR. ;\n SubStr( cScreen, nAt + nLen ) $ cTrailing )\n\n lFound := .T.\n --nAt\n nRow := Int( nAt / nCols )\n nCol := Int( nAt % nCols )\n nEnd := nCol + Len( cSearch ) - 1\n ColorWin( nRow, nCol, nRow, nEnd, xAttr )\n DO WHILE nEnd >= nCols\n nEnd -= nCols\n nCol := 0\n ++nRow\n ColorWin( nRow, nCol, nRow, nEnd, xAttr )\n ENDDO\n IF ! lAll\n EXIT\n ENDIF\n ENDIF\n nCount++\n ENDDO\n\n RETURN lFound"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/dfile.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#include \"inkey.ch\"\n\nPROCEDURE Main( cInFile )\n\n LOCAL nKey\n LOCAL nNColor := 7\n LOCAL nHColor := 15\n LOCAL nColSkip := 5\n LOCAL nRMargin := 132\n LOCAL cExitKeys := PadR( \"AABBC\", 12 )\n LOCAL lBrowse := .F.\n LOCAL nStart := 1\n LOCAL nBuffSize := 4096\n LOCAL GetList := {}\n\n LOCAL aExitKeys\n LOCAL tmp\n\n CLS\n\n hb_default( @cInFile, __FILE__ )\n\n cInFile := PadR( cInFile, 128 )\n\n @ 0, 0 SAY \"ENTER FILENAME: \" GET cInFile PICTURE \"@S30\"\n @ 1, 0 SAY \" FOREGROUND: \" GET nNColor PICTURE \"999\"\n @ 2, 0 SAY \" HIGHLIGHT: \" GET nHColor PICTURE \"999\"\n @ 3, 0 SAY \" EXIT KEYS: \" GET cEXitKeys\n @ 4, 0 SAY \" BUFFER SIZE: \" GET nBUffSize PICTURE \"9999\"\n @ 1, 40 SAY \"COLUMN INCREMENT: \" GET nCOlSkip PICTURE \"999\"\n @ 2, 40 SAY \" MAX LINE SIZE: \" GET nRMargin PICTURE \"999\"\n @ 3, 40 SAY \" BROWSE MODE? \" GET lBRowse PICTURE \"Y\"\n\n READ\n\n \n aExitKeys := {}\n FOR EACH tmp IN cExitKeys\n AAdd( aExitKeys, hb_keyCode( tmp ) )\n NEXT\n\n AAdd( aExitKeys, K_F3 )\n\n @ 4, 9 TO 11, 71\n\n ft_DFSetup( AllTrim( cInFile ), 5, 10, 10, 70, nStart, ;\n nNColor, nHColor, aExitKeys, ;\n lBrowse, nColSkip, nRMargin, nBuffSize )\n\n nKey := ft_DispFile()\n\n ft_DFClose()\n\n @ 20, 0 SAY \"Key pressed was: \" + \"[\" + hb_keyChar( nKey ) + \"] (\" + hb_ntos( nKey ) + \")\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/token2.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL cStr1 := \"A,BB,CCC,DDDD,EEEEE,FFFFFF\"\n\n \n LOCAL cStr3 := \"0123456789ABCDEFGHIJKLM\"\n LOCAL cStr4 := \"08:09:10:11:12\"\n LOCAL cStr5 := \"05:00+20:00+35:00+50:00\"\n\n LOCAL cTE1, cTE2\n\n ctinit()\n\n ? \"Begin test of incremental tokenizer function family\"\n ?\n\n \n ? ' Incremental tokenizing the string \"' + cStr1 + '\"'\n ? ' TokenInit( @cStr1, \",\", 1 ) == .T. ? ----> ' + LToC( TokenInit( @cStr1, \",\", 1 ) )\n ? ' TokenNum() == 6 ? -----------------------> ' + Str( TokenNum() )\n ? ' TokenEnd() ? --------------------------> ' + LToC( TokenEnd() )\n WHILE ! TokenEnd()\n ? ' TokenNext(@cStr1) -----------------> \"' + TokenNext( @cStr1 ) + '\"'\n ? ' TokenEnd() ? -----------------------> ' + LToC( TokenEnd() )\n ENDDO\n ?\n ? ' rewind with TokenInit() == .T. ? --------> ' + LToC( TokenInit() )\n ? ' TokenEnd() ? --------------------------> ' + LToC( TokenEnd() )\n WHILE ! TokenEnd()\n ? ' TokenNext( @cStr1 ) ----------------> \"' + TokenNext( @cStr1 ) + '\"'\n ? ' TokenEnd() ? -----------------------> ' + LToC( TokenEnd() )\n ENDDO\n ?\n ? ' access tokens directly with tokennext'\n ? ' TokenNext( @cStr1, 2 ) == \"BB\" ? ------> \"' + TokenNext( @cStr1, 2 ) + '\"'\n ? ' TokenNext( @cStr1, 4 ) == \"DDDD\" ? ----> \"' + TokenNext( @cStr1, 4 ) + '\"'\n ?\n\n ? \"...Press any key...\"\n ?\n Inkey( 0 )\n\n ? ' Incremental tokenizing the string \"' + cStr3 + '\" with the'\n ? ' token environment of cStr1 !'\n ? ' rewind with TokenInit() == .T. ? ------> ' + LToC( TokenInit() )\n ? ' TokenEnd() ? -------------------------> ' + LToC( TokenEnd() )\n WHILE ! TokenEnd()\n ? ' TokenNext( @cStr3 ) ------------------> \"' + TokenNext( @cStr3 ) + '\"'\n ? ' TokenEnd() ? -------------------------> ' + LToC( TokenEnd() )\n ENDDO\n ?\n ? ' rewind with TokenInit() == .T. ? ------> ' + LToC( TokenInit() )\n ? ' TokenEnd() ? -------------------------> ' + LToC( TokenEnd() )\n WHILE ! TokenEnd()\n ? ' start / end with TokenAt(.F./.T.)-----> ' + Str( TokenAt() ) + ' ' + Str( TokenAt( .T. ) )\n TokenNext( @cStr1 )\n ? ' TokenEnd() ? -------------------------> ' + LToC( TokenEnd() )\n ENDDO\n ?\n ? ' access tokens directly with tokenat'\n ? ' TokenAt( .F., 2 ) == 3 ? ---------------> ' + Str( TokenAt( .F., 2 ) )\n ? ' TokenAt( .T., 4 ) == 14 ? --------------> ' + Str( TokenAt( .T., 4 ) )\n ?\n\n ? \"...Press any key...\"\n ?\n Inkey( 0 )\n\n ? ' Save global token environment with savetoken'\n cTE1 := SaveToken()\n ? ' tokeninit a different string, cStr4 := \"' + cStr4 + '\", with TokenInit()'\n ? ' TokenInit( @cStr4, \":\", 1 ) == .T. ? ----> ' + LToC( TokenInit( @cStr4, \":\", 1 ) )\n ? ' TokenNum() == 5 ? ---------------------> ' + Str( TokenNum() )\n ? ' TokenNext() == \"08\" ? ------------------> \"' + TokenNext( @cStr4 ) + '\"'\n ? ' Now restore global token environment with resttoken and rewind it'\n RestToken( cTE1 )\n TokenInit()\n ? ' TokenNum() == 6 ? ----------------------> ' + Str( TokenNum() )\n ? ' TokenEnd() ? -------------------------> ' + LToC( TokenEnd() )\n WHILE ! TokenEnd()\n ? ' TokenNext( @cStr1 ) -----------------> \"' + TokenNext( @cStr1 ) + '\"'\n ? ' TokenEnd() ? -------------------------> ' + LToC( TokenEnd() )\n ENDDO\n ? ' Release global TE with TokenExit() ----> ' + LToC( TokenExit() )\n ?\n\n ? \"...Press any key...\"\n ?\n Inkey( 0 )\n\n ? ' Now tokenize cStr4 := \"' + cStr4 + '\" and'\n ? ' cStr5 := \"' + cStr5 + '\"'\n ? ' and store the token environment locally to cTE1 and cTE2:'\n ? ' TokenInit( @cStr4, \":\", 1, @cTE1 ) == .T. ? -> ' + LToC( TokenInit( @cStr4, \":\", 1, @cTE1 ) )\n ? ' TokenInit( @cStr5, \"+\", 1, @cTE2 ) == .T. ? -> ' + LToC( TokenInit( @cStr5, \"+\", 1, @cTE2 ) )\n ? ' TokenNum( @cTE1 ) == 5 ? --------------------> ' + Str( TokenNum( @cTE1 ) )\n ? ' TokenNum( @cTE2 ) == 4 ? --------------------> ' + Str( TokenNum( @cTE2 ) )\n ? ' TokenEnd( @cTE1 ) ? ---------------------> ' + LToC( TokenEnd( @cTE1 ) )\n ? ' TokenEnd( @cTE2 ) ? ---------------------> ' + LToC( TokenEnd( @cTE2 ) )\n WHILE ! TokenEnd( @cTE1 ) .AND. ! TokenEnd( @cTE2 )\n ? ' next train at ' + TokenNext( cStr4,, @cTE1 ) + \":\" + TokenNext( cStr5,, @cTE2 )\n ? ' compiled with TokenNext( cStr4,, @cTE1 ) + \":\" + TokenNext( cStr5,, @cTE2 )'\n ? ' TokenEnd( @cTE1 ) ? ---------------------> ' + LToC( TokenEnd( @cTE1 ) )\n ? ' TokenEnd( @cTE2 ) ? ---------------------> ' + LToC( TokenEnd( @cTE2 ) )\n ENDDO\n\n ?\n ? \"End test of incremental tokenizer function family\"\n ?\n\n ? \"...Press any key...\"\n ?\n Inkey( 0 )\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/funcarr.prg. Provides functions: aFunc. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL a\n\n ? \"Direct reference : \", aFunc()[ 1 ]\n\n a := aFunc()\n ? \"Ref via array : \", a[ 1 ]\n\n aFunc()[ 1 ] := \"Something different\"\n ? \"Assign new text : \", aFunc()[ 1 ]\n\n aFunc()[ 1 ] := 4\n ? \"Assign 4 : \", aFunc()[ 1 ]\n\n ? \"Post increment : \", aFunc()[ 1 ]++\n ? \"After : \", aFunc()[ 1 ]\n ? \"Pre decrement : \", --aFunc()[ 1 ]\n ? \"After : \", aFunc()[ 1 ]\n\n aFunc()[ 1 ] += 2\n ? \"Plus 2 : \", aFunc()[ 1 ]\n\n aFunc()[ 1 ] -= 3\n ? \"Minus 3 : \", aFunc()[ 1 ]\n\n aFunc()[ 1 ]\n ? \"Times 3 : \", aFunc()[ 1 ]\n\n aFunc()[ 1 ] /= 1.5\n ? \"Divide by 1.5 : \", aFunc()[ 1 ]\n\n aFunc()[ 1 ] %= 4\n ? \"Modulus 4 : \", aFunc()[ 1 ]\n\n aFunc()[ 1 ] ^= 3\n ? \"To the power 3 : \", aFunc()[ 1 ]\n\n ? \"Global stack\"\n ? hb_ValToExp( __dbgVMStkGList() ) \n ? \"Statics\"\n ? hb_ValToExp( __dbgVMVarSList() )\n\n RETURN\n\nFUNCTION aFunc()\n\n STATIC s_aArray := { [Test] }\n\n RETURN s_aArray"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/prn3.prg. Contains procedures: Main, Dump. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\n#include \"simpleio.ch\"\n\nPROCEDURE Main()\n\n Dump( win_printerList( .F., .F. ) )\n Dump( win_printerList( .F., .T. ) )\n Dump( win_printerList( .T., .F. ) )\n Dump( win_printerList( .T., .T. ) )\n\n ? \"WIN_PRINTERGETDEFAULT:\", \">\" + win_printerGetDefault() + \"<\"\n ? \"WIN_PRINTERSTATUS:\", win_printerStatus()\n\n RETURN\n\nSTATIC PROCEDURE Dump( a )\n\n LOCAL b, c\n\n ? \"==================\"\n FOR EACH b IN a\n ?\n IF HB_ISARRAY( b )\n FOR EACH c IN b\n ?? c:__enumIndex(), c\n IF c:__enumIndex() == 2\n ?? \">>\" + win_printerPortToName( c ) + \"<<\", \"|>>\" + win_printerPortToName( c, .T. ) + \"<<|\"\n ENDIF\n ?\n NEXT\n ? \"-----\"\n ELSE\n ? b, win_printerExists( b ), win_printerStatus( b )\n ENDIF\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: TimeToSec, Millisec. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/cttime.prg. Provides functions: TimeToSec, Millisec. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION TimeToSec( cTime )\n\n LOCAL nSec := 0\n LOCAL nLen, i, aLim, aMod, nInd, n\n\n IF cTime == NIL\n nSec := Seconds()\n ELSEIF HB_ISSTRING( cTime )\n nLen := Len( cTime )\n IF ( nLen + 1 ) % 3 == 0 .AND. nLen <= 11\n nInd := 1\n aLim := { 24, 60, 60, 100 }\n aMod := { 3600, 60, 1, 1 / 100 }\n FOR i := 1 TO nLen STEP 3\n IF IsDigit( SubStr( cTime, i , 1 ) ) .AND. ;\n IsDigit( SubStr( cTime, i + 1, 1 ) ) .AND. ;\n ( i == nLen - 1 .OR. SubStr( cTime, i + 2, 1 ) == \":\" ) .AND. ;\n ( n := Val( SubStr( cTime, i, 2 ) ) ) < aLim[ nInd ]\n nSec += n\n h := \"\"\n ENDIF\n\n n := Int( n % 86400 )\n\n FOR i := 1 TO 3\n h := StrZero( n % 60, 2 ) + iif( h == \"\", \"\", \":\" + h )\n n := Int( n / 60 )\n NEXT\n\n RETURN h\n\nFUNCTION Millisec( nDelay )\n\n hb_idleSleep( nDelay / 1000 )\n\n RETURN \"\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour Runtime Library file: src/rtl/achoice.prg. Provides functions: AChoice. This file provides utility functions"}, {"role": "assistant", "content": "#include \"achoice.ch\"\n#include \"color.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\n#define INRANGE( xLo, xVal, xHi ) ( xVal >= xLo .AND. xVal <= xHi )\n#define BETWEEN( xLo, xVal, xHi ) Min( Max( xLo, xVal ), xHi )\n\n\nFUNCTION AChoice( nTop, nLeft, nBottom, nRight, acItems, xSelect, xUserFunc, nPos, nHiLiteRow )\n\n LOCAL nNumCols \n LOCAL nNumRows \n LOCAL nRowsClr \n LOCAL alSelect \n LOCAL nNewPos := 0 \n LOCAL lFinished \n LOCAL nKey := 0 \n LOCAL nMode \n LOCAL nAtTop \n LOCAL nItems := 0 \n LOCAL nGap \n\n \n LOCAL lUserFunc \n LOCAL nUserFunc \n LOCAL nSaveCsr\n LOCAL nFrstItem := 0\n LOCAL nLastItem := 0\n\n LOCAL bAction\n LOCAL cKey\n LOCAL nAux\n\n nTop := Int( hb_defaultValue( nTop, 0 ) )\n nBottom := Int( hb_defaultValue( nBottom, 0 ) )\n\n hb_default( @nLeft, 0 )\n hb_default( @nRight, 0 )\n\n IF nRight > MaxCol()\n nRight := MaxCol()\n ENDIF\n\n IF nBottom > MaxRow()\n nBottom := MaxRow()\n ENDIF\n\n IF ! HB_ISARRAY( acItems ) .OR. Len( acItems ) == 0\n SetPos( nTop, nRight + 1 )\n RETURN 0\n ENDIF\n\n nSaveCsr := SetCursor( SC_NONE )\n\n ColorSelect( CLR_STANDARD )\n\n \n IF Empty( xUserFunc ) .AND. ValType( xSelect ) $ \"CBS\"\n xUserFunc := xSelect\n xSelect := NIL\n ENDIF\n\n lUserFunc := ! Empty( xUserFunc ) .AND. ValType( xUserFunc ) $ \"CBS\"\n\n IF ! HB_ISARRAY( xSelect ) .AND. ! HB_ISLOGICAL( xSelect )\n xSelect := .T. \n ENDIF\n\n hb_default( @nPos, 1 ) \n hb_default( @nHiLiteRow, 0 ) \n\n nNumCols := nRight - nLeft + 1\n nNumRows := nBottom - nTop + 1\n\n IF HB_ISARRAY( xSelect )\n alSelect := xSelect\n ELSE\n alSelect := Array( Len( acItems ) )\n AFill( alSelect, xSelect )\n ENDIF\n\n IF ( nMode := Ach_Limits( @nFrstItem, @nLastItem, @nItems, alSelect, acItems ) ) == AC_NOITEM\n nPos := 0\n ENDIF\n\n \n nPos := BETWEEN( nFrstItem, nPos, nLastItem )\n\n \n nHiLiteRow := BETWEEN( 0, nHiLiteRow, nNumRows - 1 )\n\n \n nAtTop := BETWEEN( 1, Max( 1, nPos - nHiLiteRow ), nItems )\n\n \n IF ( nAtTop + nNumRows - 1 ) > nItems\n nAtTop := Max( 1, nItems - nNumrows + 1 )\n ENDIF\n\n DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, nItems )\n\n lFinished := ( nMode == AC_NOITEM )\n IF lFinished .AND. lUserFunc\n Do( xUserFunc, nMode, nPos, nPos - nAtTop )\n ENDIF\n DO WHILE ! lFinished\n\n IF nMode != AC_EXCEPT .AND. nMode != AC_NOITEM\n nKey := Inkey( 0 )\n nMode := AC_IDLE\n ENDIF\n\n DO CASE\n CASE ( bAction := SetKey( nKey ) ) != NIL\n\n Eval( bAction, ProcName( 1 ), ProcLine( 1 ), \"\" )\n IF NextKey() == 0\n hb_keySetLast( 255 )\n nKey := 0\n ENDIF\n\n nRowsClr := Min( nNumRows, nItems )\n\n IF ( nMode := Ach_Limits( @nFrstItem, @nLastItem, @nItems, alSelect, acItems ) ) == AC_NOITEM\n nPos := 0\n nAtTop := Max( 1, nPos - nNumRows + 1 )\n ELSE\n DO WHILE nPos < nLastItem .AND. ! Ach_Select( alSelect, nPos )\n nPos++\n ENDDO\n\n IF nPos > nLastItem\n nPos := BETWEEN( nFrstItem, nPos, nLastItem )\n ENDIF\n\n nAtTop := Min( nAtTop, nPos )\n\n IF nAtTop + nNumRows - 1 > nItems\n nAtTop := BETWEEN( 1, nPos - nNumRows + 1, nItems - nNumRows + 1 )\n ENDIF\n\n IF nAtTop < 1\n nAtTop := 1\n ENDIF\n ENDIF\n\n DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, nRowsClr )\n\n CASE ( nKey == K_ESC .OR. nMode == AC_NOITEM ) .AND. ! lUserFunc\n\n IF nPos != 0\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, .T., .F., nNumCols )\n ENDIF\n\n nMode := AC_IDLE\n nPos := 0\n lFinished := .T.\n\n CASE nKey == K_LDBLCLK .OR. nKey == K_LBUTTONDOWN\n nAux := HitTest( nTop, nLeft, nBottom, nRight, MRow(), MCol() )\n IF nAux != 0 .AND. ( nNewPos := nAtTop + nAux - 1 ) <= nItems\n IF Ach_Select( alSelect, nNewPos )\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .F., nNumCols )\n nPos := nNewPos\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .T., nNumCols )\n IF nKey == K_LDBLCLK\n hb_keyIns( K_ENTER )\n ENDIF\n ENDIF\n ENDIF\n\n#ifdef HB_CLP_STRICT\n CASE nKey == K_UP\n#else\n CASE nKey == K_UP .OR. nKey == K_MWFORWARD\n#endif\n\n IF nPos == nFrstItem\n nMode := AC_HITTOP\n IF nAtTop > Max( 1, nPos - nNumRows + 1 )\n nAtTop := Max( 1, nPos - nNumRows + 1 )\n DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems )\n ENDIF\n ELSE\n nNewPos := nPos - 1\n DO WHILE ! Ach_Select( alSelect, nNewPos )\n nNewPos--\n ENDDO\n IF INRANGE( nAtTop, nNewPos, nAtTop + nNumRows - 1 )\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .F., nNumCols )\n nPos := nNewPos\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .T., nNumCols )\n ELSE\n DispBegin()\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .F., nNumCols )\n Scroll( nTop, nLeft, nBottom, nRight, nNewPos - ( nAtTop + nNumRows - 1 ) )\n nAtTop := nNewPos\n nPos := Max( nPos, nAtTop + nNumRows - 1 )\n DO WHILE nPos > nNewPos\n IF nTop + nPos - nAtTop <= nBottom\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .F., nNumCols )\n ENDIF\n nPos--\n ENDDO\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .T., nNumCols )\n DispEnd()\n ENDIF\n ENDIF\n\n#ifdef HB_CLP_STRICT\n CASE nKey == K_DOWN\n#else\n CASE nKey == K_DOWN .OR. nKey == K_MWBACKWARD\n#endif\n\n \n IF nPos == nLastItem\n nMode := AC_HITBOTTOM\n IF nAtTop < Min( nPos, nItems - nNumRows + 1 )\n nAtTop := Min( nPos, nItems - nNumRows + 1 )\n DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems )\n ENDIF\n ELSE\n\n nNewPos := nPos + 1\n\n DO WHILE ! Ach_Select( alSelect, nNewPos )\n nNewPos++\n ENDDO\n\n IF INRANGE( nAtTop, nNewPos, nAtTop + nNumRows - 1 )\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .F., nNumCols )\n nPos := nNewPos\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .T., nNumCols )\n ELSE\n DispBegin()\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .F., nNumCols )\n Scroll( nTop, nLeft, nBottom, nRight, nNewPos - ( nAtTop + nNumRows - 1 ) )\n nAtTop := nNewPos - nNumRows + 1\n nPos := Max( nPos, nAtTop )\n DO WHILE nPos < nNewPos\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .F., nNumCols )\n nPos++\n ENDDO\n DispLine( acItems[ nPos ], nTop + nPos - nAtTop, nLeft, Ach_Select( alSelect, nPos ), .T., nNumCols )\n DispEnd()\n ENDIF\n ENDIF\n\n CASE nKey == K_CTRL_PGUP .OR. ( nKey == K_HOME .AND. ! lUserFunc )\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/tipwget.prg. Provides functions: ShowGauge. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbssl\"\n#require \"hbtip\"\n\n#if ! defined( __HBSCRIPT__HBSHELL )\nREQUEST __HBEXTERN__HBSSL__\n#endif\n\n#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"tip.ch\"\n\nPROCEDURE Main( cURL, cFile )\n\n LOCAL bWrite := .F.\n LOCAL oURL, oClient\n LOCAL cData\n\n ? \"Harbour - TIP (class based internet client protocol) test\"\n\n IF ! HB_ISSTRING( cURL ) .OR. Empty( cURL )\n ? hb_StrFormat( \"Usage: %1$s [dumpToOrFromFileName]\", hb_ProgName() )\n RETURN\n ENDIF\n\n IF Empty( oURL := TUrl():New( cURL ) )\n ? \"Invalid URL\", cURL\n RETURN\n ENDIF\n\n SWITCH Lower( oURL:cProto )\n CASE \"ftp\"\n oClient := TIPClientFTP():New( oURL )\n EXIT\n CASE \"http\"\n CASE \"https\"\n oClient := TIPClientHTTP():New( oURL )\n EXIT\n CASE \"pop\"\n CASE \"pops\"\n oClient := TIPClientPOP():New( oURL )\n EXIT\n CASE \"smtp\"\n CASE \"smtps\"\n oClient := TIPClientSMTP():New( oURL )\n EXIT\n ENDSWITCH\n\n IF Empty( oClient )\n ? \"Invalid URL\", cURL\n RETURN\n ENDIF\n oClient:nConnTimeout := 2000 \n\n oURL:cUserid := StrTran( oURL:cUserid, \"&at;\", \"@\" )\n\n ? \"Connecting to\", oURL:cProto + \":\n IF oClient:Open()\n ? \"Connection status:\", iif( Empty( oClient:cReply ), \"\", oClient:cReply )\n\n IF HB_ISSTRING( cFile ) .AND. hb_LeftEq( cFile, \"+\" )\n cFile := SubStr( cFile, 2 )\n bWrite := .T.\n ENDIF\n\n ?\n oClient:exGauge := {| done, size | ShowGauge( done, size ) }\n\n IF oClient:nAccessMode == TIP_WO .OR. ( oClient:nAccessMode == TIP_RW .AND. bWrite )\n IF oClient:WriteFromFile( cFile )\n ? \"Data successfully sent\"\n ELSE\n ? \"Error: Data not sent\", oClient:lastErrorMessage()\n ENDIF\n ELSE\n IF HB_ISSTRING( cFile )\n IF ( cData := oClient:Read() ) == \"\"\n ? \"Error: file could not be retrieved\", oClient:lastErrorMessage()\n ELSE\n ? \"First 80 characters:\", hb_ValToExp( hb_BLeft( cData, 80 ) ) )\n ENDIF\n ELSEIF oClient:ReadToFile( cFile )\n ? \"File\", cFile, \"written.\"\n ? \"Server replied\", oClient:cReply\n ELSE\n ? \"Error: Generic error in writing\", cFile\n ENDIF\n ENDIF\n\n oClient:Close()\n ? \"Done:\", iif( Empty( oClient:cReply ), \"(no goodbye message)\", oClient:cReply )\n ELSE\n ? \"Could not open URI\", cURL\n IF ! Empty( oClient:cReply )\n ? oClient:cReply\n ENDIF\n ENDIF\n\n RETURN\n\nSTATIC FUNCTION ShowGauge( nSent, nSize )\n\n SetPos( Row(), 0 )\n ?? \"Sending:\", nSent, \"/\", nSize\n\n RETURN hb_keyStd( Inkey() ) != K_ESC"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/extend1.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL uVar\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n ? \"Testing Harbour Extended system:\"\n ? \"================================\"\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n\n WAIT \"Press any key to continue...\"\n\n ? \"Strings:\"\n ? \"========\"\n ?\n ? ' _parc() and _retc() with Strings1( \"Hello\" ) =>', Strings1( \"Hello\" )\n ? ' _parc() and _retc() with Strings2( { \"Hello\" } ) =>', Strings2( { \"Hello\" } )\n ? ' _retclen() with Strings3( \"Hello word\", 5 ) =>', Strings3( \"Hello\", 5 )\n ? ' _parclen() with Strings4( \"Hello word\" ) => ', Strings4( \"Hello word\" )\n uVar := \"Hello word\"\n ? ' uVar := \"Hello word\"'\n Strings5( @uVar, \"Harbour power!!!\" )\n ? ' _storc() with Strings5( @uVar, \"Harbour power!!!\" ) => ', uVar\n Strings6( @uVar, \"Harbour power!!!\", 7 )\n ? ' _storclen() with Strings6( @uVar, \"Harbour power!!!\", 7 ) => ', uVar\n uVar := { \"Hello word\" }\n ? ' uVar := { \"Hello word\" }'\n Strings7( uVar, \"Harbour power!!!\" )\n ? ' _storc() with Strings7( uVar, \"Harbour power!!!\" ) => ', uVar[ 1 ]\n Strings8( uVar, \"Harbour power!!!\", 7 )\n ? ' _storclen() with Strings8( uVar, \"Harbour power!!!\", 7 ) => ', uVar[ 1 ]\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n\n WAIT \"Press any key to continue...\"\n\n ? \"Logicals:\"\n ? \"=========\"\n ?\n ? ' _parl() and _retl() with Logical1( .T. ) =>', Logical1( .T. )\n ? ' _parl() and _parl() with Logical2( { .T. } ) =>', Logical2( { .T. } )\n uVar := .T.\n ? ' uVar := .T.'\n Logical3( @uVar, .F. )\n ? ' _storl() with Logical3( @uVar, .F. ) => ', uVar\n uVar := { .T. }\n ? ' uVar := { .T. }'\n Logical4( uVar, .F. )\n ? ' _storl() with Logical4( uVar, .F. ) => ', uVar[ 1 ]\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n\n WAIT \"Press any key to continue...\"\n\n ? \"Dates: (SET CENTURY ON)\"\n ? \"=======================\"\n ?\n ? ' _pards() and _retds() with Date1( CToD( \"2000-01-01\" ) ) =>', Date1( CToD( \"2000-01-01\" ) )\n ? ' _pards() and retds() with Date2( { CToD( \"2000-01-01\" ) } ) =>', Date2( { CToD( \"2000-01-01\" ) } )\n uVar := CToD( \"2000-01-01\" )\n ? ' uVar := CToD( \"2000-01-01\" )'\n Date3( @uVar, CToD( \"1999-12-31\" ) )\n ? ' _stords() with Date3( @uVar, CToD( \"1999-12-31\" ) ) => ', uVar\n uVar := { CToD( \"2000-01-01\" ) }\n ? ' uVar := { CToD( \"2000-01-01\" ) }'\n Date4( uVar, CToD( \"1999-12-31\" ) )\n ? ' _stords() with Date4( uVar, CToD( \"1999-12-31\" ) ) => ', uVar[ 1 ]\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n\n WAIT \"Press any key to continue...\"\n\n ? \"Numbers:\"\n ? \"========\"\n ?\n ? ' _parni() and _retni() with Int1( 1 ) =>', Int1( 1 )\n ? ' _parni() and _retni() with Int2( { 1 } ) =>', Int2( { 1 } )\n ? ' _parnl() and _retnl() with Long1( 123456789 ) =>', Long1( 123456789 )\n ? ' _parnl() and _retnl() with Long2( { 123456789 } ) =>', Long2( { 123456789 } )\n ? ' _parnd() and _retnd() with Double1( 1234567.89 ) =>', Double1( 1234567.89 )\n ? ' _parnd() and _retnd() with Double2( { 1234567.89 } ) =>', Double2( { 1234567.89 } )\n uVar := 100\n ? ' uVar := 100'\n Int3( @uVar, 200 )\n ? ' _storni() with Int3( @uVar, 200 ) => ', uVar\n uVar := { 100 }\n ? ' uVar := { 100 }'\n Int4( uVar, 200 )\n ? ' _storni() with Int4( uVar, 200 ) => ', uVar[ 1 ]\n uVar := 123456789\n ? ' uVar := 123456789'\n Long3( @uVar, 987654321 )\n ? ' _stornl() with Long3( @uVar, 987654321 ) => ', uVar\n uVar := { 123456789 }\n ? ' uVar := { 123456789 }'\n Long4( uVar, 987654321 )\n ? ' _stornl() with Long4( uVar, 987654321 ) => ', uVar[ 1 ]\n uVar := 1234567.89\n ? ' uVar := 1234567.89'\n Double3( @uVar, 9876543.21 )\n ? ' _stornd() with Double3( @uVar, 9876543.21 ) => ', uVar\n uVar := { 1234567.89 }\n ? ' uVar := { 1234567.89 }'\n Double4( uVar, 9876543.21 )\n ? ' _stornl() with Double4( uVar, 9876543.21 ) => ', uVar[ 1 ]\n ?\n ?\n ?\n\n WAIT \"Press any key to continue...\"\n\n ? \"Nil:\"\n ? \"====\"\n ?\n ? ' _ret() with Nil1() =>', Nil1()\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n\n WAIT \"Press any key to continue...\"\n\n ? \"Arrays:\"\n ? \"=======\"\n ?\n ? ' _reta() with Len( Arrays1( 100 ) ) =>', Len( Arrays1( 100 ) )\n ? ' _parinfa() with Arrays2( { 1, \"a\", .T. }, 0 ) =>', Arrays2( { 1, \"a\", .T. }, 0 )\n ? ' _parinfa() with Arrays2( { 1, \"a\", .T. }, 2 ) =>', Arrays2( { 1, \"a\", .T. }, 2 ), \"( IT_STRING )\"\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n\n WAIT \"Press any key to continue...\"\n\n ? \"Parameters info:\"\n ? \"================\"\n ?\n ? ' _pcount() with Params1( 1, \"a\", .T., 10 ) =>', Params1( 1, \"a\", .T., 10 )\n ? ' _parinfo() with Params2( 1, \"a\", .T., 0 ) =>', Params2( 1, \"a\", .T., 0 )\n ? ' _parinfo() with Params2( 1, \"a\", .T., 3 ) =>', Params2( 1, \"a\", .T., 3 ), \"( IT_LOGICAL )\"\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n ?\n\n WAIT \"Press any key to continue...\"\n\n ? \"Undocumented features:\"\n ? \"======================\"\n ?\n ? ' _parc( -1, ...) with Undoc2() =>', Undoc2()\n ? ' _parclen( -1, ...) with Undoc3() =>', Undoc3()\n ? ' _pards( -1, ...) with Undoc4( CToD( \"2000-01-01\" ) ) =>', Undoc4( CToD( \"2000-01-01\" ) )\n ? ' _parl( -1, ...) with Undoc5( .T. ) =>', Undoc5( .T. )\n ? ' _parnd( -1, ...) with Undoc6( 1234567.89 ) =>', Undoc6( 1234567.89 )\n ? ' _parni( -1, ...) with Undoc7( 1234 ) =>', Undoc7( 1234 )\n ? ' _parnl( -1, ...) with Undoc8( 123456789 ) =>', Undoc8( 123456789 )\n ? ' _parinfa( -1, ...) with Undoc9( 10 ) =>', Undoc9( 10 )\n ? ' _parinfo( -1 ) with Undoc10() =>', Undoc10(), \"( IT_STRING )\"\n ? ' _storc( szText, -1, ... ) with Undoc11( \"Hello word\" ) =>', Undoc11( \"Hello word\" )\n ? ' _storclen( szText, -1, ... ) with Undoc12( \"Hello word\", 7 ) =>', Undoc12( \"Hello word\", 7 )\n ? ' _stords( szDate, -1, ... ) with Undoc13( CToD( \"2000-01-01\" ) ) =>', Undoc13( CToD( \"2000-01-01\" ) )\n ? ' _storl( iLogical, -1 ) with Undoc14( .T. ) =>', Undoc14( .T. )\n ? ' _storni( iValue, -1 ) with Undoc15( 1234 ) =>', Undoc15( 1234 )\n ? ' _stornl( lValue, -1 ) with Undoc16( 123456789 ) =>', Undoc16( 123456789 )\n ? ' _stornd( dValue, -1 ) with Undoc17( 1234567.89 ) =>', Undoc17( 1234567.89 )\n ?\n ?\n ?\n ?\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/memfile.prg. Provides functions: __mvScope. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "MEMVAR m_cLongerNameThen10Chars\n#ifdef __HARBOUR__\nMEMVAR m_cLongerN\n#endif\nMEMVAR m_cString\nMEMVAR m_nDouble\nMEMVAR m_nDoubleH\nMEMVAR m_nInt\nMEMVAR m_nLong\nMEMVAR m_dDate\nMEMVAR m_lLogicT\nMEMVAR m_lLogicF\nMEMVAR m_xStayHer\n\nPROCEDURE Main()\n\n PRIVATE m_cLongerNameThen10Chars := \"Long String Name!\"\n PRIVATE m_cString := \"This is a\" + Chr( 0 ) + \"string to save.\"\n PRIVATE m_nDouble := 100.0000\n PRIVATE m_nDoubleH := 5000000000\n PRIVATE m_nInt := 35\n PRIVATE m_nLong := 3000000\n PRIVATE m_dDate := Date()\n PRIVATE m_lLogicT := .F.\n PRIVATE m_lLogicF := .T.\n\n SAVE TO memfile ALL\n SAVE TO memsome ALL LIKE \"m_nDouble*\"\n\n CLEAR MEMORY\n\n SAVE TO memempt ALL\n\n PRIVATE m_xStayHer := \"CONST\"\n\n RESTORE FROM memfile ADDITIVE\n\n ? m_xStayHer\n ? m_cLongerN \n ? m_cString\n ? m_nDouble\n ? m_nDoubleH\n ? m_nInt\n ? m_nLong\n ? m_dDate\n ? m_lLogicF\n ? m_lLogicT\n\n RESTORE FROM memfile\n\n\n ? m_cLongerN \n ? m_cString\n ? m_nDouble\n ? m_nDoubleH\n ? m_nInt\n ? m_nLong\n ? m_dDate\n ? m_lLogicF\n ? m_lLogicT\n\n ? __MRestore( \"memfile\", .F., \"m_nDouble*\", .T. )\n ? m_nDouble\n ? m_nDoubleH\n ? __mvScope( \"m_nInt\" )\n\n FErase( \"memempt.mem\" )\n FErase( \"memfile.mem\" )\n FErase( \"memsome.mem\" )\n\n RETURN\n\n#ifndef __HARBOUR__\nFUNCTION __mvScope()\n RETURN -1\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/dfile.prg. Provides functions: ft_DFSetup, ft_DFClose. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n\nTHREAD STATIC t_nHandle := F_ERROR\n\nFUNCTION ft_DFSetup( cInFile, nTop, nLeft, nBottom, nRight, ;\n nStart, nCNormal, nCHighlight, cExitKeys, ;\n lBrowse, nColSkip, nRMargin, nBuffSize )\n\n LOCAL rval\n\n IF hb_FileExists( cInFile )\n\n hb_default( @nTop , 0 )\n hb_default( @nLeft , 0 )\n hb_default( @nBottom , MaxRow() )\n hb_default( @nRight , MaxCol() )\n hb_default( @nCNormal , 7 )\n hb_default( @nCHighlight , 15 )\n hb_default( @nStart , 1 )\n hb_default( @nColSkip , 1 )\n hb_default( @lBrowse , .F. )\n hb_default( @nRMargin , 255 )\n hb_default( @nBuffSize , 4096 )\n\n IF HB_ISARRAY( cExitKeys ) \n IF Len( cExitKeys ) > 25\n ASize( cExitKeys, 25 )\n ENDIF\n ELSEIF HB_ISSTRING( cExitKeys )\n cExitKeys := Left( cExitKeys, 25 )\n ELSE\n cExitKeys := {}\n ENDIF\n\n t_nHandle := FOpen( cInFile )\n\n rval := FError()\n\n IF rval == 0\n rval := _ft_DFInit( t_nHandle, nTop, nLeft, nBottom, nRight, ;\n nStart, nCNormal, nCHighlight, cExitKeys, ;\n lBrowse, nColSkip, nRMargin, nBuffSize )\n ENDIF\n ELSE\n rval := 2 \n ENDIF\n\n RETURN rval\n\nFUNCTION ft_DFClose()\n\n IF t_nHandle != F_ERROR\n _ft_DFClos()\n\n FClose( t_nHandle )\n\n t_nHandle := F_ERROR\n ENDIF\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour test program: tests/usrrdd/exarr.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "REQUEST ARRAYRDD\n\n#define USE_DBCREATE_EXTENSIONS\n\nPROCEDURE Main()\n\n LOCAL aStruct\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n SET DELETED OFF\n CLS\n\n ? \"Create a new dbf in memory using dbCreate() command\"\n aStruct := { ;\n { \"NAME\" , \"C\", 40, 0 }, ;\n { \"ADDRESS\" , \"C\", 40, 0 }, ;\n { \"BIRTHDAY\" , \"D\", 8, 0 }, ;\n { \"AGE\" , \"N\", 3, 0 } }\n\n#ifndef USE_DBCREATE_EXTENSIONS\n ? \"Create it\"\n dbCreate( \"arrtest.dbf\", aStruct, \"ARRAYRDD\" )\n WAIT\n ? \"Open it\"\n USE arrtest.dbf VIA \"ARRAYRDD\"\n WAIT\n#else\n ? \"Create it and leave opened\"\n dbCreate( \"arrtest.dbf\", aStruct, \"ARRAYRDD\", .T., \"arrtest\" )\n WAIT\n#endif\n\n ? \"Show structure\"\n ? hb_ValToExp( dbStruct() )\n WAIT\n\n ? \"ALIAS\", Alias(), \"RECNO\", RecNo(), ;\n \"BOF\", Bof(), \"EOF\", Eof(), \"LASTREC\", LastRec()\n ? RecNo(), '\"' + FIELD->NAME + '\"'\n dbGoBottom()\n ? RecNo(), '\"' + FIELD->NAME + '\"'\n dbGoTop()\n ? RecNo(), '\"' + FIELD->NAME + '\"'\n WAIT\n\n ? \"Adding some data\"\n dbAppend()\n field->name := \"Giudice Francesco Saverio\"\n field->address := \"Main Street 10\"\n field->birthday := hb_SToD( \"19670103\" )\n field->age := 39\n\n ? RecNo(), '\"' + FIELD->NAME + '\"'\n\n dbAppend()\n field->name := \"Mouse Mickey\"\n field->address := \"Main Street 20\"\n field->birthday := hb_SToD( \"19400101\" )\n field->age := 66\n\n WHILE ! Eof()\n ? RecNo(), '\"' + FIELD->NAME + '\"'\n IF RecNo() == 20\n Inkey( 0 )\n ENDIF\n dbSkip()\n ENDDO\n ? \"ALIAS\", Alias(), \"RECNO\", RecNo(), ;\n \"BOF\", Bof(), \"EOF\", Eof(), \"LASTREC\", LastRec()\n WAIT\n dbGoBottom()\n ? \"ALIAS\", Alias(), \"RECNO\", RecNo(), ;\n \"BOF\", Bof(), \"EOF\", Eof(), \"LASTREC\", LastRec()\n WAIT\n WHILE ! Bof()\n ? RecNo(), '[' + FIELD->NAME + ']'\n IF RecNo() == LastRec() - 20\n Inkey( 0 )\n ENDIF\n dbSkip( -1 )\n ENDDO\n ? \"ALIAS\", Alias(), \"RECNO\", RecNo(), ;\n \"BOF\", Bof(), \"EOF\", Eof(), \"LASTREC\", LastRec()\n WAIT\n\n ? \"Show it - Please don't press any key except movement keys and ESC\"\n ? \" to exit from Browse(), otherwise you will get an error\"\n ? \" due to missing index support\"\n WAIT\n Browse()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHeader file for contribution module 'hbbz2' (BZ2 compression library): contrib/hbbz2/hbbz2.ch. Defines 10 constants including: HB_BZ2_CH_, HB_BZ_OK, HB_BZ_RUN_OK, HB_BZ_FLUSH_OK, HB_BZ_FINISH_OK. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_BZ2_CH_\n#define HB_BZ2_CH_\n\n#define HB_BZ_OK 0\n#define HB_BZ_RUN_OK 1\n#define HB_BZ_FLUSH_OK 2\n#define HB_BZ_FINISH_OK 3\n#define HB_BZ_STREAM_END 4\n#define HB_BZ_SEQUENCE_ERROR ( -1 )\n#define HB_BZ_PARAM_ERROR ( -2 )\n#define HB_BZ_MEM_ERROR ( -3 )\n#define HB_BZ_DATA_ERROR ( -4 )\n#define HB_BZ_DATA_ERROR_MAGIC ( -5 )\n#define HB_BZ_IO_ERROR ( -6 )\n#define HB_BZ_UNEXPECTED_EOF ( -7 )\n#define HB_BZ_OUTBUFF_FULL ( -8 )\n#define HB_BZ_CONFIG_ERROR ( -9 )\n\n#define HB_BZ_COMPRESSION_SPEED 1\n#define HB_BZ_COMPRESSION_SIZE 9\n#define HB_BZ_COMPRESSION_DEFAULT 9\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: TMySQLRow, TMySQLQuery. Harbour contribution module 'hbmysql' (MySQL database client library): contrib/hbmysql/tmysql.prg. Defines classes: TMySQLRow, TMySQLQuery. This file handles database operations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"dbstruct.ch\"\n\n#include \"mysql.ch\"\n\n\nCREATE CLASS TMySQLRow\n\n VAR aRow \n VAR aDirty \n VAR aOldValue \n\n VAR aOriValue \n\n VAR aFieldStruct \n VAR cTable \n\n METHOD New( aRow, aFStruct, cTableName ) \n\n METHOD FieldGet( cnField ) \n METHOD FieldPut( cnField, Value ) \n METHOD FieldName( nNum )\n METHOD FieldPos( cFieldName )\n\n METHOD FieldLen( nNum ) \n METHOD FieldDec( nNum, lFormat ) \n METHOD FieldType( nNum ) \n\n METHOD MakePrimaryKeyWhere() \n\nENDCLASS\n\n\nMETHOD New( aRow, aFStruct, cTableName ) CLASS TMySQLRow\n\n hb_default( @cTableName, \"\" )\n hb_default( @aFStruct, {} )\n\n ::aRow := aRow\n ::aOriValue := AClone( aRow ) \n\n ::aFieldStruct := aFStruct\n ::cTable := cTableName\n\n ::aDirty := Array( Len( ::aRow ) )\n ::aOldValue := Array( Len( ::aRow ) )\n\n AFill( ::aDirty, .F. )\n\n RETURN Self\n\nMETHOD FieldGet( cnField ) CLASS TMySQLRow\n\n LOCAL nNum := iif( HB_ISSTRING( cnField ), ::FieldPos( cnField ), cnField )\n\n IF nNum > 0 .AND. nNum <= Len( ::aRow )\n\n \n IF ::FieldType( nNum ) == \"C\"\n RETURN PadR( ::aRow[ nNum ], ::aFieldStruct[ nNum ][ MYSQL_FS_LENGTH ] )\n ELSE\n RETURN ::aRow[ nNum ]\n ENDIF\n ENDIF\n\n RETURN NIL\n\nMETHOD FieldPut( cnField, Value ) CLASS TMySQLRow\n\n LOCAL nNum := iif( HB_ISSTRING( cnField ), ::FieldPos( cnField ), cnField )\n\n IF nNum > 0 .AND. nNum <= Len( ::aRow )\n\n IF ValType( Value ) == ValType( ::aRow[ nNum ] ) .OR. ::aRow[ nNum ] == NIL\n\n \n IF HB_ISSTRING( Value )\n Value := RTrim( Value )\n ENDIF\n\n \n IF ! ::aDirty[ nNum ]\n ::aOldValue[ nNum ] := ::aRow[ nNum ]\n ::aDirty[ nNum ] := .T.\n ENDIF\n\n ::aRow[ nNum ] := Value\n\n RETURN Value\n ENDIF\n ENDIF\n\n RETURN NIL\n\n\nMETHOD FieldPos( cFieldName ) CLASS TMySQLRow\n\n LOCAL cUpperName := Upper( cFieldName )\n\n RETURN AScan( ::aFieldStruct, {| aItem | Upper( aItem[ MYSQL_FS_NAME ] ) == cUpperName } )\n\n\nMETHOD FieldName( nNum ) CLASS TMySQLRow\n RETURN iif( nNum >= 1 .AND. nNum <= Len( ::aFieldStruct ), ::aFieldStruct[ nNum ][ MYSQL_FS_NAME ], \"\" )\n\nMETHOD FieldLen( nNum ) CLASS TMySQLRow\n RETURN iif( nNum >= 1 .AND. nNum <= Len( ::aFieldStruct ), ::aFieldStruct[ nNum ][ MYSQL_FS_LENGTH ], 0 )\n\n\nMETHOD FieldDec( nNum, lFormat ) CLASS TMySQLRow\n\n hb_default( @lFormat, .F. )\n\n IF nNum >= 1 .AND. nNum <= Len( ::aFieldStruct )\n\n IF ! lFormat .AND. ( ::aFieldStruct[ nNum ][ MYSQL_FS_TYPE ] == MYSQL_TYPE_FLOAT .OR. ;\n ::aFieldStruct[ nNum ][ MYSQL_FS_TYPE ] == MYSQL_TYPE_DOUBLE )\n RETURN Set( _SET_DECIMALS )\n ELSE\n RETURN ::aFieldStruct[ nNum ][ MYSQL_FS_DECIMALS ]\n ENDIF\n ENDIF\n\n RETURN 0\n\nMETHOD FieldType( nNum ) CLASS TMySQLRow\n\n IF nNum >= 1 .AND. nNum <= Len( ::aFieldStruct )\n\n SWITCH ::aFieldStruct[ nNum ][ MYSQL_FS_TYPE ]\n CASE MYSQL_TYPE_TINY\n CASE MYSQL_TYPE_SHORT\n CASE MYSQL_TYPE_LONG\n CASE MYSQL_TYPE_LONGLONG\n CASE MYSQL_TYPE_FLOAT\n CASE MYSQL_TYPE_DOUBLE\n CASE MYSQL_TYPE_NEWDECIMAL\n CASE MYSQL_TYPE_INT24\n RETURN \"N\"\n\n CASE MYSQL_TYPE_VAR_STRING\n CASE MYSQL_TYPE_STRING\n CASE MYSQL_TYPE_DATETIME\n RETURN \"C\"\n\n CASE MYSQL_TYPE_DATE\n RETURN \"D\"\n\n CASE MYSQL_TYPE_BLOB\n CASE MYSQL_TYPE_MEDIUM_BLOB\n RETURN \"M\"\n\n ENDSWITCH\n ENDIF\n\n RETURN \"U\"\n\n\nMETHOD MakePrimaryKeyWhere() CLASS TMySQLRow\n\n LOCAL ni, cWhere := \"\"\n\n FOR nI := 1 TO Len( ::aFieldStruct )\n\n \n IF hb_bitAnd( ::aFieldStruct[ nI ][ MYSQL_FS_FLAGS ], PRI_KEY_FLAG ) == PRI_KEY_FLAG .OR. ;\n hb_bitAnd( ::aFieldStruct[ nI ][ MYSQL_FS_FLAGS ], MULTIPLE_KEY_FLAG ) == MULTIPLE_KEY_FLAG\n\n IF ! Empty( cWhere )\n cWhere += \" AND \"\n ENDIF\n\n cWhere += ::aFieldStruct[ nI ][ MYSQL_FS_NAME ] + \"=\"\n\n \n IF ::aDirty[ nI ]\n cWhere += ClipValue2SQL( ::aOldValue[ nI ] )\n ELSE\n cWhere += ClipValue2SQL( ::aRow[ nI ] )\n ENDIF\n ENDIF\n NEXT\n\n IF ! Empty( cWhere )\n cWhere := \" WHERE \" + cWhere\n ENDIF\n\n RETURN cWhere\n\n\nCREATE CLASS TMySQLQuery\n\n VAR nSocket \n VAR nResultHandle \n\n VAR cQuery \n\n VAR nNumRows \n VAR nCurRow \n\n VAR lBof\n VAR lEof\n\n VAR lFieldAsData \n \n \n VAR aRow \n\n VAR nNumFields \n VAR aFieldStruct \n\n VAR lError \n\n METHOD New( nSocket, cQuery ) \n METHOD Destroy()\n METHOD End() INLINE ::Destroy()\n METHOD Refresh() \n\n METHOD GetRow( nRow ) \n\n METHOD Skip( nRows ) \n\n METHOD Bof() INLINE ::lBof\n METHOD Eof() INLINE ::lEof\n METHOD RecNo() INLINE ::nCurRow\n METHOD LastRec() INLINE ::nNumRows\n METHOD GoTop() INLINE ::GetRow( 1 )\n METHOD GoBottom() INLINE ::GetRow( ::nNumRows )\n METHOD GoTO( nRow ) INLINE ::GetRow( nRow )\n\n METHOD FCount()\n\n METHOD NetErr() INLINE ::lError \n METHOD Error() \n\n METHOD FieldName( nNum )\n METHOD FieldPos( cFieldName )\n METHOD FieldGet( cnField )\n\n METHOD FieldLen( nNum ) \n METHOD FieldDec( nNum, lFormat ) \n METHOD FieldType( nNum ) \n\nENDCLASS\n\n\nMETHOD New( nSocket, cQuery ) CLASS TMySQLQuery\n\n LOCAL nI, aField\n\n ::nSocket := nSocket\n ::cQuery := cQuery\n\n ::lError := .F.\n ::aFieldStruct := {}\n ::nCurRow := 1\n ::nResultHandle := NIL\n ::nNumFields := 0\n ::nNumRows := 0\n ::lBof := .T.\n ::lEof := .T.\n\n ::lFieldAsData := .T. \n ::aRow := {} \n\n IF mysql_query( nSocket, cQuery ) == 0\n\n \n IF ! Empty( ::nResultHandle := mysql_store_result( nSocket ) )\n\n ::nNumRows := mysql_num_rows( ::nResultHandle )\n ::nNumFields := mysql_num_fields( ::nResultHandle )\n ::aRow := Array( ::nNumFields )\n\n FOR nI := 1 TO ::nNumFields\n aField := mysql_fetch_field( ::nResultHandle )\n AAdd( ::aFieldStruct, aField )\n IF ::lFieldAsData\n __objAddData( Self, ::aFieldStruct[ nI ][ MYSQL_FS_NAME ] )\n ENDIF\n NEXT\n\n ::getRow( ::nCurRow )\n ELSE\n ::nResultHandle := NIL\n ENDIF\n ELSE\n ::lError := .T.\n ENDIF\n\n RETURN Self\n\nMETHOD Refresh() CLASS TMySQLQuery\n\n \n ::nResultHandle := NIL\n\n ::lError := .F.\n\n IF mysql_query( ::nSocket, ::cQuery ) == 0\n\n \n ::nResultHandle := mysql_store_result( ::nSocket )\n ::nNumRows := mysql_num_rows( ::nResultHandle )\n\n \n IF ::nCurRow > ::nNumRows\n ::nCurRow := ::nNumRows\n ENDIF\n\n ::getRow( ::nCurRow )\n\n ELSE\n ::lError := .T.\n\n ENDIF\n\n RETURN ! ::lError\n\n\nMETHOD Skip( nRows ) CLASS TMySQLQuery\n\n LOCAL lBof\n\n \n hb_default( @nRows, 1 )\n\n ::lBof := Empty( ::LastRec() )\n\n IF nRows == 0\n \n\n ELSEIF nRows < 0\n \n IF ( ::RecNo() + nRows ) < 1\n nRows := - ::RecNo() + 1\n \n ::lBof := .T. \n ENDIF\n ELSE\n \n IF ( ::RecNo() + nRows ) > ::LastRec()\n nRows := ::LastRec() - ::RecNo() + 1\n ENDIF\n ENDIF\n\n ::nCurRow := ::nCurRow + nRows\n\n \n lBof := ::Bof()\n\n \n ::getRow( ::nCurrow )\n\n IF lBof\n ::lBof := .T.\n ENDIF\n\n RETURN NIL\n\n\nMETHOD GetRow( nRow ) CLASS TMySQLQuery\n\n LOCAL oRow := NIL\n LOCAL i\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour header file: include/common.ch. Defines constants: HB_COMMON_CH_, TRUE, FALSE, YES, NO. Declares 2 preprocessor commands. Declares 5 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_COMMON_CH_\n#define HB_COMMON_CH_\n\n#if defined( HB_LEGACY_LEVEL4 )\n #include \"hbhash.ch\"\n#endif\n\n\n#define TRUE .T.\n#define FALSE .F.\n#define YES .T.\n#define NO .F.\n\n\n#translate ISNIL( ) => ( == NIL )\n#translate ISARRAY( ) => HB_ISARRAY( )\n#translate ISBLOCK( ) => HB_ISBLOCK( )\n#translate ISCHARACTER( ) => HB_ISSTRING( )\n#translate ISDATE( ) => HB_ISDATE( )\n#translate ISLOGICAL( ) => HB_ISLOGICAL( )\n#translate ISMEMO( ) => HB_ISMEMO( )\n#translate ISNUMBER( ) => HB_ISNUMERIC( )\n#translate ISOBJECT( ) => HB_ISOBJECT( )\n\n\n#xcommand DEFAULT TO [, TO ] => ;\n IF == NIL ; := ; END ;\n [; IF == NIL ; := ; END ]\n\n#command UPDATE IF TO => ;\n IF ; := ; END\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hjwindow.prg. Defines classes: TJSWindow. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"cgi.ch\"\n\nCREATE CLASS TJSWindow\n\n VAR nH\n VAR Name INIT \"\"\n VAR oHtm\n VAR VarName INIT \"\"\n VAR URL INIT \"\"\n VAR Features INIT \"\"\n\n VAR ScreenX, ScreenY INIT 100\n VAR HEIGHT, WIDTH INIT 300\n VAR innerHeight, innerWidth, outerHeight INIT 0\n VAR alwaysRaised, alwaysLowered INIT .F.\n VAR Menubar, personalBar INIT .F.\n VAR location, directories, copyHistory INIT .F.\n VAR Toolbar INIT .F.\n VAR Status, TitleBar INIT .T.\n VAR Scrollbars, Resizable, dependent INIT .T.\n\n VAR TITLE\n VAR aScriptSRC\n VAR aServerSRC\n VAR BGIMAGE, BGCOLOR, fontColor\n VAR Style\n\n VAR onLoad\n VAR onUnLoad\n\n METHOD New( cVarName, cUrl, cName, x, y, w, h )\n METHOD setOnLoad( c ) INLINE ::onLoad := c\n METHOD setOnUnLoad( c ) INLINE ::onUnLoad := c\n METHOD Alert( c ) INLINE ::QOut( \"Alert('\" + c + \"')\" )\n METHOD confirm( c ) INLINE ::QOut( \"confirm('\" + c + \"')\" )\n METHOD SetSize( x, y, h, w )\n METHOD Write( c )\n METHOD lineBreak() INLINE ::QOut( \"
\" )\n METHOD Paragraph() INLINE ::QOut( \"

\" )\n METHOD Center( l ) INLINE ::QOut( iif( l, \"
\", \"
\" ) )\n METHOD bold( l ) INLINE ::QOut( iif( l, \"\", \"\" ) )\n METHOD Italic( l ) INLINE ::QOut( iif( l, \"\", \"\" ) )\n METHOD ULine( l ) INLINE ::QOut( iif( l, \"\", \"\" ) )\n METHOD Put()\n METHOD Begin()\n METHOD End()\n\n METHOD QOut( c )\n METHOD WriteLN( c ) INLINE ::QOut( c )\n METHOD SetFeatures( alwaysRaised, alwaysLowered, ;\n Resizable, Menubar, personalBar, ;\n dependent, location, directories, ;\n Scrollbars, Status, TitleBar, Toolbar, copyHistory )\n METHOD ImageURL( cImage, cUrl, nHeight, nBorder, ;\n cOnClick, cOnMsover, cOnMsout, ;\n cName, cAlt )\n\nENDCLASS\n\n\nMETHOD New( cVarName, cUrl, cName, x, y, w, h ) CLASS TJSWindow\n\n __defaultNIL( @cVarName, \"newWin\" )\n __defaultNIL( @cURL, \" \" )\n __defaultNIL( @cName, cVarName )\n __defaultNIL( @x, 100 )\n __defaultNIL( @y, 100 )\n __defaultNIL( @h, 300 )\n __defaultNIL( @w, 300 )\n\n ::nH := HtmlPageHandle()\n ::oHtm := HtmlPageObject()\n ::varName := cVarName\n ::URL := cUrl\n ::Name := cName\n\n ::ScreenX := x\n ::ScreenY := y\n ::height := h\n ::width := w\n\n RETURN Self\n\n\nMETHOD SetFeatures( alwaysRaised, alwaysLowered, ;\n Resizable, Menubar, personalBar, ;\n dependent, location, directories, ;\n Scrollbars, Status, TitleBar, Toolbar, copyHistory ) CLASS TJSWindow\n\n LOCAL cStr := \"\"\n\n __defaultNIL( @alwaysRaised, ::alwaysRaised )\n __defaultNIL( @alwaysLowered, ::alwaysLowered )\n __defaultNIL( @Resizable, ::Resizable )\n __defaultNIL( @Menubar, ::Menubar )\n __defaultNIL( @personalBar, ::personalBar )\n __defaultNIL( @dependent, ::dependent )\n __defaultNIL( @location, ::location )\n __defaultNIL( @directories, ::directories )\n __defaultNIL( @Scrollbars, ::Scrollbars )\n __defaultNIL( @Status, ::Status )\n __defaultNIL( @TitleBar, ::TitleBar )\n __defaultNIL( @Toolbar, ::Toolbar )\n __defaultNIL( @copyHistory, ::copyHistory )\n\n IF alwaysRaised\n cStr += \"alwaysraised=yes,\"\n ELSE\n cStr += \"alwaysraised=no,\"\n ENDIF\n IF alwaysLowered\n cStr += \"alwayslowered=yes,\"\n ELSE\n cStr += \"alwayslowered=no,\"\n ENDIF\n IF Resizable\n cStr += \"resizable=yes,\"\n ELSE\n cStr += \"resizable=no,\"\n ENDIF\n IF Menubar\n cStr += \"menubar=yes,\"\n ELSE\n cStr += \"menubar=no,\"\n ENDIF\n IF personalBar\n cStr += \"personalbar=yes,\"\n ELSE\n cStr += \"personalbar=no,\"\n ENDIF\n IF dependent\n cStr += \"dependent=yes,\"\n ELSE\n cStr += \"dependent=no,\"\n ENDIF\n IF location\n cStr += \"location=yes,\"\n ELSE\n cStr += \"location=no,\"\n ENDIF\n IF directories\n cStr += \"directories=yes,\"\n ELSE\n cStr += \"directories=no,\"\n ENDIF\n IF Scrollbars\n cStr += \"scrollbars=yes,\"\n ELSE\n cStr += \"scrollbars=no,\"\n ENDIF\n IF Status\n cStr += \"status=yes,\"\n ELSE\n cStr += \"status=no,\"\n ENDIF\n IF TitleBar\n cStr += \"titlebar=yes,\"\n ELSE\n cStr += \"titlebar=no,\"\n ENDIF\n IF Toolbar\n cStr += \"toolbar=yes,\"\n ELSE\n cStr += \"toolbar=no,\"\n ENDIF\n IF copyHistory\n cStr += \"copyHistory=yes,\"\n ELSE\n cStr += \"copyHistory=no,\"\n ENDIF\n\n ::features += iif( Empty( ::Features ), cStr + \",\", cStr )\n\n RETURN Self\n\n\nMETHOD SetSize( x, y, h, w ) CLASS TJSWindow\n\n LOCAL cStr := \"\"\n\n __defaultNIL( @x, ::ScreenX )\n __defaultNIL( @y, ::ScreenY )\n __defaultNIL( @h, ::height )\n __defaultNIL( @w, ::width )\n\n ::ScreenX := x\n ::ScreenY := y\n ::height := h\n ::width := w\n\n cStr := \"screenX=\" + hb_ntos( ::screenX ) + \",\"\n\n cStr += \"screenY=\" + hb_ntos( ::screenY ) + \",\"\n cStr += \"height=\" + hb_ntos( ::height ) + \",\"\n cStr += \"width=\" + hb_ntos( ::width )\n\n ::features += iif( Empty( ::Features ), cStr + \",\", cStr )\n\n RETURN Self\n\n\nMETHOD Put() CLASS TJSWindow\n\n LOCAL cStr := \"\"\n\n IF ::nH == NIL\n ::nH := HtmlPageHandle()\n IF ::nH == NIL\n RETURN Self\n ENDIF\n ENDIF\n\n IF Empty( ::features )\n ::setSize()\n ::setFeatures()\n ENDIF\n\n hb_default( @::name, \"newWin\" )\n\n cStr += ::varName + \" = window.open('\" + ;\n ::URL + \"', '\" + ;\n ::varName + \"', '\" + ;\n ::features + \"')\"\n\n HtmlJSCmd( ::nH, cStr )\n\n RETURN Self\n\n\nMETHOD Write( c ) CLASS TJSWindow\n\n HtmlJSCmd( ::nH, ::varName + \".document.write('\" + c + \"')\" + CRLF() )\n\n RETURN Self\n\n\nMETHOD QOut( c ) CLASS TJSWindow\n\n FWrite( ::nH, ::varName + \".document.write('\" + c + \"')\" + CRLF() )\n\n RETURN Self\n\n\nMETHOD Begin() CLASS TJSWindow\n\n LOCAL i\n\n FWrite( ::nH, \"\" + crlf() )\n\n RETURN Self\n\n\nMETHOD End() CLASS TJSWindow\n\n HtmlJSCmd( ::nH, ::varName + \".document.write('')\" + CRLF() )\n\n RETURN Self\n\n\nMETHOD ImageURL( cImage, cUrl, nHeight, nBorder, ;\n cOnClick, cOnMsover, cOnMsout, ;\n cName, cAlt ) CLASS TJSWindow\n\n LOCAL cStr := \"\"\n\n __defaultNIL( @cUrl, \"\" )\n\n IF cName != NIL\n cStr += ' name= \"' + cName + '\"' + CRLF()\n ENDIF\n IF cAlt != NIL\n cStr += ' alt= \"' + cAlt + '\"' + CRLF()\n ENDIF\n\n IF nBorder != NIL\n cStr += \" border= \" + hb_ntos( nBorder ) + CRLF()\n ENDIF\n\n IF nHeight != NIL\n cStr += \" height= \" + hb_ntos( nHeight ) + \"% \" + CRLF()\n ENDIF\n\n IF cOnClick != NIL\n cStr += ' onClick=\"' + cOnClick + '\"' + CRLF()\n ENDIF\n IF cOnMsOver != NIL\n cStr += ' onMouseOver=\"' + cOnMsOver + '\"' + CRLF()\n ENDIF\n IF cOnMsOut != NIL\n cStr += ' onMouseOut=\"' + cOnMsOut + '\"' + CRLF()\n ENDIF\n\n IF cURL != NIL\n ::QOut( '
' )\n ELSE\n ::QOut( '( RecCount() )\n ? \"Used:\", TESTDBF->( Used() )\n ? \"Select:\", TESTDBF->( Select() )\n ? \"RecSize:\", TESTDBF->( RecSize() )\n ? \"RecNo:\", TESTDBF->( RecNo() )\n ? \"NetErr:\", TESTDBF->( NetErr() )\n\n ? \"Press any key to continue...\"\n Inkey( 0 )\n CLS\n\n aArray := rddList( 0 )\n ? \"Rdd's: \"\n FOR nI := 1 TO Len( aArray )\n ?? aArray[ nI ], \"\"\n NEXT\n ? \"RddName:\", TESTDBF->( rddName() )\n ? \"lUpdate:\", TESTDBF->( LUpdate() )\n ? \"Header:\", TESTDBF->( Header() )\n ? \"FieldPos( 'LAST' ):\", TESTDBF->( FieldPos( \"LAST\" ) )\n ? \"FieldName( 2 ):\", TESTDBF->( FieldName( 2 ) )\n ? \"Dbf():\", TESTDBF->( Dbf() )\n ? \"Alias( 1 ):\", Alias( 1 )\n ? \"dbTableExt():\", TESTDBF->( dbTableExt() )\n aArray := TESTDBF->( dbStruct() )\n ? \"dbStruct:\"\n FOR nI := 1 TO Len( aArray )\n ? PadR( aArray[ nI ][ 1 ], 10 ), aArray[ nI ][ 2 ], aArray[ nI ][ 3 ], aArray[ nI ][ 4 ]\n NEXT\n\n ? \"Press any key to continue...\"\n Inkey( 0 )\n CLS\n\n ? \"dbGoTop():\"\n dbGoTop()\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( -1 ):\"\n dbSkip( -1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( -1 ):\"\n dbSkip( -1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( 1 ):\"\n dbSkip( 1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( 1 ):\"\n dbSkip( 1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbGoTop():\"\n dbGoTop()\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( 1 ):\"\n dbSkip( 1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( 1 ):\"\n dbSkip( 1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( -1 ):\"\n dbSkip( -1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( -1 ):\"\n dbSkip( -1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n Inkey( 0 )\n CLS\n\n ? \"dbGoBottom():\"\n dbGoBottom()\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( 1 ):\"\n dbSkip( 1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( 1 ):\"\n dbSkip( 1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( -1 ):\"\n dbSkip( -1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"dbSkip( -1 ):\"\n dbSkip( -1 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n\n ? \"Press any key to continue...\"\n Inkey( 0 )\n CLS\n\n ? \"dbGoto( 490 ):\"\n dbGoto( 490 )\n ? \"Bof Eof Found Deleted RecNo:\", TESTDBF->( Bof() ), TESTDBF->( Eof() ), ;\n TESTDBF->( Found() ), TESTDBF->( Deleted() ), TESTDBF->( Deleted() ), ;\n TESTDBF->( RecNo() )\n ? \"FCount:\", TESTDBF->( FCount() )\n FOR nI := 1 TO TESTDBF->( FCount() )\n ? \"FieldGet( \" + hb_ntos( nI ) + \" ):\", TESTDBF->( FieldGet( nI ) )\n NEXT\n\n ? \"Press any key to continue...\"\n Inkey( 0 )\n CLS\n\n ? \"WHILE ! TESTDBF->( Eof() )\"\n ? \" ? TESTDBF->FIRST, TESTDBF->( RecNo() )\"\n ? \" TESTDBF->( dbSkip() )\"\n ? \"ENDDO\"\n ? \"\"\n WHILE ! TESTDBF->( Eof() )\n ? TESTDBF->FIRST, TESTDBF->( RecNo() )\n TESTDBF->( dbSkip() )\n ENDDO\n\n ? \"Press any key to continue...\"\n Inkey( 0 )\n CLS\n\n ? \"SET FILTER TO TESTDBF->AGE == 21\"\n ? \"? TESTDBF->( dbFilter() )\"\n ? \"TESTDBF->( dbGoTop() )\"\n ? \"WHILE ! TESTDBF->( Eof() )\"\n ? \" ? TESTDBF->FIRST, TESTDBF->AGE, TESTDBF->( RecNo() )\"\n ? \" TESTDBF->( dbSkip() )\"\n ? \"ENDDO\"\n ? \"SET FILTER TO\"\n ? \"\"\n SET FILTER TO TESTDBF->AGE == 21\n ? TESTDBF->( dbFilter() )\n TESTDBF->( dbGoTop() )\n WHILE ! TESTDBF->( Eof() )\n ? TESTDBF->FIRST, TESTDBF->AGE, TESTDBF->( RecNo() )\n TESTDBF->( dbSkip() )\n ENDDO\n SET FILTER TO\n\n ? \"Press any key to continue...\"\n Inkey( 0 )\n CLS\n\n ? \"TESTDBF->( Found() )\"\n ? \"LOCATE FOR TESTDBF->AGE == 23\"\n ? \"WHILE TESTDBF->( Found() )\"\n ? \" ? TESTDBF->FIRST, TESTDBF->AGE, TESTDBF->( RecNo() )\"\n ? \" CONTINUE\"\n ? \"ENDDO\"\n TESTDBF->( Found() )\n LOCATE FOR TESTDBF->AGE == 23\n WHILE TESTDBF->( Found() )\n ? TESTDBF->FIRST, TESTDBF->AGE, TESTDBF->( RecNo() )\n CONTINUE\n ENDDO\n\n ? \"Press any key to continue...\"\n Inkey( 0 )\n CLS\n\n ? \"TESTDBF->( dbEval( {|| QOut( TESTDBF->FIRST, TESTDBF->AGE ) }, ;\"\n ? \" {|| TESTDBF->AGE == 23 } ) )\"\n ? \"\"\n ? \"dbCommit()\"\n TESTDBF->( dbEval( {|| QOut( TESTDBF->FIRST, TESTDBF->AGE ) }, ;\n {|| TESTDBF->AGE == 23 } ) )\n TESTDBF->( dbCommit() )\n\n ? \"Press any key to continue...\"\n Inkey( 0 )\n CLS\n\n ? 'dbCreate( \"newrdd\", { ;'\n ? ' { \"First_Name\", \"C\", 20, 0 }, ;'\n ? ' { \"Age\", \"N\", 3, 0 }, ;'\n ? ' { \"Date\", \"D\", 8, 0 }, ;'\n ? ' { \"Rate\", \"N\", 6, 2 }, ;'\n ? ' { \"Memo\", \"M\", 10, 0 }, ;'\n ? ' { \"Student\", \"L\", 1, 0 } },, .T., \"newrdd\" )'\n ? 'SET CENTURY ON'\n dbCreate( \"newrdd\", { ;\n { \"First_Name\", \"C\", 20, 0 }, ;\n { \"Age\", \"N\", 3, 0 }, ;\n { \"Date\", \"D\", 8, 0 }, ;\n { \"Rate\", \"N\", 6, 2 }, ;\n { \"Memo\", \"M\", 10, 0 }, ;\n { \"Student\", \"L\", 1, 0 } }, \"DBFCDX\", .T., \"newrdd\" )\n SET CENTURY ON\n ? \"lUpdate:\", NEWRDD->( LUpdate() )\n\n ? \"Press any key to continue...\"\n Inkey( 0 )\n CLS\n\n ? 'Select( \"TESTDBF\" )'\n ? \"SET FILTER TO TESTDBF->SALARY > 120000\"\n ? \"TESTDBF->( dbGoTop() )\"\n ? \"WHILE ! TESTDBF->( Eof() )\"\n ? \" NEWRDD->( dbAppend() )\"\n ? \" NEWRDD->FIRST_NAME := TESTDBF->FIRST\"\n ? \" NEWRDD->AGE := TESTDBF->AGE\"\n ? \" NEWRDD->DATE := TESTDBF->HIREDATE\"\n ? \" NEWRDD->RATE := Val( Right( hb_ntos( Seconds() ), 5 ) )\"\n ? \" NEWRDD->MEMO := TESTDBF->FIRST + Chr( 13 ) + Chr( 10 ) + ;\"\n ? \" TESTDBF->LAST + Chr( 13 ) + Chr( 10 ) + ;\"\n ? \" TESTDBF->STREET\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/inline.prg. Provides functions: TForm, New. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL oForm := TForm():New()\n\n ? oForm:ClassName()\n oForm:cText := \"Let's show a form here :-)\"\n\n oForm:Show()\n\n RETURN\n\nFUNCTION TForm()\n\n STATIC s_oClass\n\n IF s_oClass == NIL\n s_oClass := HBClass():New( \"TFORM\" ) \n\n s_oClass:AddData( \"cText\" ) \n s_oClass:AddData( \"nTop\" )\n s_oClass:AddData( \"nLeft\" )\n s_oClass:AddData( \"nBottom\" )\n s_oClass:AddData( \"nRight\" )\n\n s_oClass:AddMethod( \"New\", @New() ) \n s_oClass:AddInline( \"Show\", {| self | QOut( self:cText ) } )\n\n s_oClass:Create() \n ENDIF\n\n RETURN s_oClass:Instance() \n\nSTATIC FUNCTION New()\n\n LOCAL Self := QSelf()\n\n ::nTop := 10\n ::nLeft := 10\n ::nBottom := 20\n ::nRight := 40\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/vertmenu.prg. Contains 12 procedures. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\nPROCEDURE Main()\n\n LOCAL datamenu := { ;\n { \"Customers\", , {|| cust() } }, ;\n { \"Invoices\", , {|| inv() } }, ;\n { \"Vendors\", , {|| vendors() } }, ;\n { \"Exit\", \"Return to Main Menu\" } }\n\n LOCAL repmenu := { ;\n { \"Customer List\", , {|| custrep() } }, ;\n { \"Past Due\", , {|| pastdue() } }, ;\n { \"Weekly Sales\", , {|| weeksales() } }, ;\n { \"Monthly P&L\", , {|| monthpl() } }, ;\n { \"Vendor List\", , {|| vendorrep() } }, ;\n { \"Exit\", \"Return to Main Menu\" } }\n\n LOCAL maintmenu := { ;\n { \"Reindex\", \"Rebuild index files\", {|| re_ntx() } }, ;\n { \"Backup\", \"Backup data files\" , {|| backup() } }, ;\n { \"Compress\", \"Compress data files\", {|| compress() } }, ;\n { \"Exit\", \"Return to Main Menu\" } }\n\n LOCAL MAINMENU := { ;\n { \"DATA ENTRY\", \"ENTER DATA\", {|| ft_Menu2( datamenu ) } }, ;\n { \"Reports\", \"Hard copy\", {|| ft_Menu2( repmenu ) } }, ;\n { \"Maintenance\", \"Reindex files, etc.\", {|| ft_Menu2( maintmenu ) } }, ;\n { \"Quit\", \"See ya later\" } }\n\n CLS\n\n ft_Menu2( mainmenu )\n\n RETURN\n\n\nSTATIC PROCEDURE cust() ; RETURN\nSTATIC PROCEDURE inv() ; RETURN\nSTATIC PROCEDURE vendors() ; RETURN\nSTATIC PROCEDURE custrep() ; RETURN\nSTATIC PROCEDURE pastdue() ; RETURN\nSTATIC PROCEDURE weeksales() ; RETURN\nSTATIC PROCEDURE monthpl() ; RETURN\nSTATIC PROCEDURE vendorrep() ; RETURN\nSTATIC PROCEDURE re_ntx() ; RETURN\nSTATIC PROCEDURE backup() ; RETURN\nSTATIC PROCEDURE compress() ; RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/tests/test.prg. Contains procedures: Main. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbgd\"\n\n#define IMAGES_OUT \"imgs_out\" + hb_ps()\n\nPROCEDURE Main()\n\n LOCAL im, im2, col, i\n\n im := gdImageCreateTrueColor( 100, 100 )\n col := gdImageColorAllocate( im, 255, 255, 255 )\n\n FOR i := 0 TO 99 STEP 10\n gdImageLine( im, i, 0, i, 99, col )\n gdImageLine( im, 0, i, 99, i, col )\n NEXT\n\n gdImagePng( im, IMAGES_OUT + \"gdtest.png\" )\n\n im2 := gdImageSquareToCircle( im, 400 )\n\n gdImagePng( im2, IMAGES_OUT + \"gdtest_squared.png\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/year.prg. Provides functions: ft_Year. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_Year( dGivenDate )\n\n LOCAL aRetVal[ 3 ]\n\n LOCAL cFY_Start := ft_DateCnfg()[ 1 ]\n\n IF ! HB_ISDATE( dGivenDate )\n dGivenDate := Date()\n ENDIF\n\n aRetVal[ 2 ] := hb_SToD( ;\n StrZero( Year( dGivenDate ) - iif( Month( dGivenDate ) < Month( hb_CToD( cFY_Start, \"yyyy.mm.dd\" ) ), 1, 0 ), 4 ) + ;\n SubStr( cFY_Start, 6, 2 ) + ;\n SubStr( cFY_Start, 9, 6 ) )\n aRetval[ 3 ] := ft_MAdd( aRetVal[ 2 ], 12 ) - 1\n aRetVal[ 1 ] := Str( Year( aRetVal[ 3 ] ), 4 ) \n\n RETURN aRetVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbhttpd' (Multithreaded HTTP/HTTPS server framework): contrib/hbhttpd/widgets.prg. Defines classes: UWMain, UWLayoutGrid, UWHtml, UWLabel, UWForm. Provides 12 functions including: UWMainNew, UWLayoutGridNew, UWHtmlNew, UWLabelNew, UWFormNew. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#pragma -km+\n\nMEMVAR session, server, get, post\n\n\nCREATE CLASS UWMain\n\n VAR aChilds INIT {}\n\n METHOD Add( oWidget )\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWMainNew()\n\n LOCAL oW := UWMain()\n\n session[ \"_uthis\" ][ \"main\" ] := oW\n\n RETURN oW\n\nMETHOD Paint() CLASS UWMain\n\n UWrite( '' )\n UWrite( '' )\n UWrite( '' )\n UWrite( '' )\n AEval( ::aChilds, {| x | x:Paint() } )\n UWrite( '' )\n\n RETURN Self\n\nMETHOD Add( oWidget ) CLASS UWMain\n\n AAdd( ::aChilds, oWidget )\n\n RETURN Self\n\n\nCREATE CLASS UWLayoutGrid\n\n VAR aChilds INIT { { {} } } \n\n METHOD Add( oWidget, nRow, nCol )\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWLayoutGridNew()\n RETURN UWLayoutGrid()\n\nMETHOD Paint() CLASS UWLayoutGrid\n\n LOCAL aRow, aCell\n\n UWrite( '' )\n FOR EACH aRow IN ::aChilds\n UWrite( '' )\n FOR EACH aCell IN aRow\n UWrite( '' )\n NEXT\n UWrite( '' )\n NEXT\n UWrite( '
' )\n AEval( aCell, {| o | o:Paint() } )\n UWrite( '
' )\n\n RETURN Self\n\nMETHOD Add( oWidget, nRow, nCol ) CLASS UWLayoutGrid\n\n LOCAL nI, nJ, aI\n\n IF nRow > Len( ::aChilds )\n FOR nI := Len( ::aChilds ) + 1 TO nRow\n aI := Array( Len( ::aChilds[ 1 ] ) )\n FOR nJ := 1 TO Len( ::aChilds[ 1 ] )\n aI[ nJ ] := {}\n NEXT\n AAdd( ::aChilds, aI )\n NEXT\n ENDIF\n IF nCol > Len( ::aChilds[ 1 ] )\n FOR nI := Len( ::aChilds[ 1 ] ) + 1 TO nCol\n AEval( ::aChilds, {| x | AAdd( x, {} ) } )\n NEXT\n ENDIF\n AAdd( ::aChilds[ nRow ][ nCol ], oWidget )\n\n RETURN Self\n\n\nCREATE CLASS UWHtml\n\n VAR cText\n\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWHtmlNew( cText )\n\n LOCAL oW := UWHtml()\n\n oW:cText := cText\n\n RETURN oW\n\nMETHOD Paint() CLASS UWHtml\n\n UWrite( ::cText )\n\n RETURN Self\n\n\nCREATE CLASS UWLabel\n\n VAR cText\n VAR cID\n VAR cStyle\n\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWLabelNew( cText, cID, cStyle )\n\n LOCAL oW := UWLabel()\n\n oW:cText := cText\n SetWId( oW, cID )\n oW:cStyle := cStyle\n\n RETURN oW\n\nMETHOD Paint() CLASS UWLabel\n\n UWrite( '' + ;\n UHtmlEncode( ::cText ) + '' )\n\n RETURN Self\n\n\nCREATE CLASS UWForm\n\n VAR cAction\n VAR cMethod INIT \"POST\"\n VAR aChilds INIT {}\n\n METHOD Add( oWidget )\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWFormNew( cAction )\n\n LOCAL oW := UWForm()\n\n oW:cAction := cAction\n\n RETURN oW\n\nMETHOD Add( oWidget ) CLASS UWForm\n\n AAdd( ::aChilds, oWidget )\n\n RETURN Self\n\nMETHOD Paint() CLASS UWForm\n\n UWrite( '
' )\n AEval( ::aChilds, {| x | x:Paint() } )\n UWrite( '
' )\n\n RETURN Self\n\n\nCREATE CLASS UWInput\n\n VAR cName\n VAR cValue\n VAR cID\n VAR cStyle\n\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWInputNew( cName, cValue, cID, cStyle )\n\n LOCAL oW := UWInput()\n\n oW:cName := cName\n oW:cValue := cValue\n SetWId( oW, cID )\n oW:cStyle := cStyle\n\n RETURN oW\n\nMETHOD Paint() CLASS UWInput\n\n UWrite( '' )\n\n RETURN Self\n\n\nCREATE CLASS UWPassword\n\n VAR cName\n VAR cValue\n\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWPasswordNew( cName )\n\n LOCAL oW := UWPassword()\n\n oW:cName := cName\n\n RETURN oW\n\nMETHOD Paint() CLASS UWPassword\n\n UWrite( '' )\n\n RETURN Self\n\n\nCREATE CLASS UWSubmit\n\n VAR cName\n VAR cValue\n\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWSubmitNew( cName, cValue )\n\n LOCAL oW := UWSubmit()\n\n oW:cName := cName\n oW:cValue := cValue\n\n RETURN oW\n\nMETHOD Paint() CLASS UWSubmit\n\n UWrite( '' )\n\n RETURN Self\n\n\nCREATE CLASS UWSeparator\n\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWSeparatorNew()\n RETURN UWSeparator()\n\nMETHOD Paint() CLASS UWSeparator\n\n UWrite( '
' )\n\n RETURN Self\n\n\nCREATE CLASS UWMenu\n\n VAR aItems INIT {}\n\n METHOD AddItem( cTitle, cLink )\n METHOD Paint()\n\nENDCLASS\n\nFUNCTION UWMenuNew()\n RETURN UWMenu()\n\nMETHOD AddItem( cTitle, cLink ) CLASS UWMenu\n\n AAdd( ::aItems, { cTitle, cLink } )\n\n RETURN Self\n\nMETHOD Paint() CLASS UWMenu\n\n LOCAL nI\n\n UWrite( '
' )\n FOR nI := 1 TO Len( ::aItems )\n IF nI != 1\n UWrite( ' | ' )\n ENDIF\n UWrite( '' + UHtmlEncode( ::aItems[ nI ][ 1 ] ) + '' )\n NEXT\n UWrite( '
' )\n\n RETURN Self\n\n\nCREATE CLASS UWBrowse\n\n VAR aColumns INIT {}\n VAR nPageSize INIT 0\n VAR nPos INIT 0\n\n METHOD AddColumn( nID, cTitle, cField, lRaw )\n METHOD Output()\n\nENDCLASS\n\nFUNCTION UWBrowseNew()\n RETURN UWBrowse()\n\nMETHOD AddColumn( nID, cTitle, cField, lRaw ) CLASS UWBrowse\n\n AAdd( ::aColumns, { nID, cTitle, cField, ! Empty( lRaw ) } )\n\n RETURN Self\n\nMETHOD Output() CLASS UWBrowse\n\n LOCAL cRet := \"\", nI, xI, xField, nPos, cUrl, cI, lValidate\n\n cRet += ''\n\n \n cRet += ''\n FOR nI := 1 TO Len( ::aColumns )\n cRet += ''\n NEXT\n cRet += ''\n\n \n nPos := 0\n dbGoTop()\n IF ::nPageSize > 0 .AND. ::nPos > 0\n dbSkip( ::nPos )\n ENDIF\n DO WHILE ! Eof()\n cRet += ''\n FOR nI := 1 TO Len( ::aColumns )\n xField := ::aColumns[ nI ][ 3 ]\n DO CASE\n CASE HB_ISSTRING( xField )\n xI := FieldGet( FieldPos( xField ) )\n CASE HB_ISEVALITEM( xField )\n xI := Eval( xField )\n ENDCASE\n SWITCH ValType( xI )\n CASE \"C\" ; xI := RTrim( xI ); EXIT\n CASE \"N\" ; xI := Str( xI ); EXIT\n CASE \"D\" ; xI := DToC( xI ); EXIT\n OTHERWISE ; xI := \"ValType()==\" + ValType( xI )\n ENDSWITCH\n IF ! ::aColumns[ nI ][ 4 ]\n xI := UHtmlEncode( xI )\n ENDIF\n cRet += ''\n NEXT\n cRet += ''\n dbSkip()\n IF ++nPos >= ::nPageSize\n EXIT\n ENDIF\n ENDDO\n cRet += '
' + UHtmlEncode( ::aColumns[ nI ][ 2 ] ) + '
' + xI + '
'\n IF ! Eof() .OR. ::nPos > 0\n cUrl := server[ \"REQUEST_URI\" ]\n IF ( nI := At( \"?_ucs=\", cUrl ) ) == 0\n nI := At( \"&_ucs=\", cUrl )\n ENDIF\n IF ( lValidate := nI > 0 )\n cUrl := Left( cUrl, nI - 1 )\n ENDIF\n IF ( nI := At( \"?_pos=\", cUrl ) ) == 0\n nI := At( \"&_pos=\", cUrl )\n ENDIF\n IF nI > 0\n cUrl := Left( cUrl, nI - 1 )\n ENDIF\n cUrl += iif( \"?\" $ cUrl, \"&\", \"?\" ) + \"_pos=\"\n cRet := '
' + cRet\n IF ! Eof()\n cI := cUrl + hb_ntos( ::nPos + ::nPageSize )\n cRet := '>>' + cRet\n ENDIF\n IF ::nPos > 0\n cI := cUrl + hb_ntos( Max( 0, ::nPos - ::nPageSize ) )\n cRet := '<<  ' + cRet\n ENDIF\n ENDIF\n\n RETURN cRet\n\n\nCREATE CLASS UWOption\n\n VAR aOption INIT {}\n VAR cValue\n\n METHOD Add( cTitle, cCode, lRaw )\n METHOD Output()\n\nENDCLASS\n\nFUNCTION UWOptionNew()\n RETURN UWOption()\n\nMETHOD Add( cTitle, cCode, lRaw ) CLASS UWOption\n\n AAdd( ::aOption, { iif( Empty( lRaw ), UHtmlEncode( cTitle ), cTitle ), cCode } )\n\n RETURN Self\n\nMETHOD Output() CLASS UWOption\n\n LOCAL cRet := \"\"\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: ft_AEMinLen. Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/aeminlen.prg. Provides functions: ft_AEMinLen. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_AEMinLen( aArray, nDimension, nStart, nCount )\n\n LOCAL i, nLast, nMinlen := NIL, nLen\n\n __defaultNIL( @nDimension, 1 )\n __defaultNIL( @nStart, 1 )\n __defaultNIL( @nCount, Len( aArray ) - nStart + 1 )\n\n nLast := Min( nStart + nCount - 1, Len( aArray ) )\n\n FOR i := nStart TO nLast\n\n SWITCH ValType( aArray[ i ] )\n CASE \"C\"\n nLen := Len( aArray[ i ] )\n EXIT\n CASE \"A\"\n nLen := Len( LTrim( Transform( aArray[ i ][ nDimension ], \"@X\" ) ) )\n EXIT\n OTHERWISE\n nLen := Len( LTrim( Transform( aArray[ i ], \"@X\" ) ) )\n ENDSWITCH\n\n nMinlen := iif( nMinLen == NIL, nLen, Min( nMinlen, nLen ) )\n NEXT\n\n IF nMinLen == NIL\n nMinLen := 65519 \n ENDIF\n\n RETURN nMinlen"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: Two, Three, Four. Harbour test program: tests/procname.prg. Provides functions: Two, Three, Four, Five. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n Two()\n\n RETURN\n\nFUNCTION Two()\n\n Three()\n\n RETURN NIL\n\nFUNCTION Three()\n\n Four()\n\n RETURN NIL\n\nFUNCTION Four()\n\n Five()\n\n RETURN NIL\n\nFUNCTION Five()\n\n LOCAL n := 0\n\n WHILE ! Empty( ProcName( n ) )\n ?? \"Called from: \", ProcName( n ), ProcLine( n++ ), hb_eol()\n ENDDO\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: test_main. Harbour test program: tests/rddtest/ntxcl53.prg. Provides functions: test_main. This test file tests specific function APIs"}, {"role": "assistant", "content": "REQUEST dbfntx\n#define _TESTRDD \"dbfntx\"\n#include \"rddtst.prg\"\n\nFUNCTION test_main()\n\nRDDTESTC {0,.t.,.t.,.f.}, LOCAL n\nRDDTESTF \"DBFNTX\", {0,.t.,.t.,.f.}, RDDSETDEFAULT()\nRDDTESTC {1,.t.,.t.,.f.}, USE \"_tst\" SHARED\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE OFF\nRDDTESTC {1,.t.,.t.,.f.}, INDEX on FNUM to TG_N\nRDDTESTC {1,.t.,.t.,.f.}, INDEX on FSTR to TG_C\nRDDTESTF \"TG_C\", {1,.t.,.t.,.f.}, ORDSETFOCUS()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .F.,.F.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .F.,.T.)\nRDDTESTC {1,.t.,.t.,.f.}, SET DELETE OFF\nRDDTESTC {15,.f.,.f.,.f.}, for n:=1 to 15 ; dbappend() ; replace FNUM with int((n+2)/3) ; replace FSTR with chr(FNUM+48) ; next\nRDDTESTF NIL, {15,.f.,.f.,.f.}, dbcommit()\nRDDTESTF NIL, {15,.f.,.f.,.f.}, dbunlock()\nRDDTESTF \"TG_C\", {15,.f.,.f.,.f.}, ORDSETFOCUS(1)\nRDDTESTF \"TG_C\", {15,.f.,.f.,.f.}, ORDSETFOCUS()\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(0,.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(0,.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(0.5,.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(0.5,.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(1.0,.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(1.0,.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(2.0,.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(2.0,.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(2.5,.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(2.5,.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(5.0,.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(5.0,.T.,.T.)\nRDDTESTF \"TG_C\", {1,.f.,.f.,.f.}, ORDSETFOCUS(2)\nRDDTESTF \"TG_C\", {1,.f.,.f.,.f.}, ORDSETFOCUS()\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTC {13,.f.,.f.,.f.}, INDEX on FSTR to TG_C DESCEND\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {13,.f.,.f.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {13,.f.,.f.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTC {1,.f.,.f.,.f.}, INDEX on FSTR to TG_C\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {2,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {10,.f.,.f.,.f.}, DBSKIP(-5)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(10)\nRDDTESTF NIL, {11,.f.,.f.,.f.}, DBSKIP(-5)\nRDDTESTF NIL, {16,.t.,.t.,.f.}, DBGOTO(16)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {2,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {4,.f.,.f.,.f.}, DBGOTO(4)\nRDDTESTF NIL, {5,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {4,.f.,.f.,.f.}, DBGOTO(4)\nRDDTESTF NIL, {3,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBGOTO(6)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBGOTO(6)\nRDDTESTF NIL, {5,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBGOTO(7)\nRDDTESTF NIL, {8,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBGOTO(7)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBGOTO(12)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBGOTO(12)\nRDDTESTF NIL, {11,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBGOTO(13)\nRDDTESTF NIL, {14,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBGOTO(13)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {14,.f.,.f.,.f.}, DBGOTO(14)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {16,.t.,.t.,.f.}, DBGOTO(16)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF \"TG_C\", {15,.f.,.f.,.f.}, ORDSETFOCUS(0)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTOP()"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/nconvert.prg. Provides 8 functions including: IsBin, IsOctal, IsDec, IsHexa, DecToBin. This file provides utility functions"}, {"role": "assistant", "content": "FUNCTION IsBin( cString )\n\n LOCAL nX\n\n cString := AllTrim( cString )\n FOR nX := 1 TO Len( cString )\n IF ! SubStr( cString, nX, 1 ) $ \"01\"\n RETURN .F.\n ENDIF\n NEXT\n\n RETURN .T.\n\nFUNCTION IsOctal( cString )\n\n LOCAL nX\n\n cString := AllTrim( cString )\n FOR nX := 1 TO Len( cString )\n IF ! SubStr( cString, nX, 1 ) $ \"01234567\"\n RETURN .F.\n ENDIF\n NEXT\n\n RETURN .T.\n\nFUNCTION IsDec( cString )\n\n LOCAL nX\n\n cString := AllTrim( cString )\n FOR nX := 1 TO Len( cString )\n IF ! SubStr( cString, nX, 1 ) $ \"0123456789\"\n RETURN .F.\n ENDIF\n NEXT\n\n RETURN .T.\n\nFUNCTION IsHexa( cString )\n\n LOCAL nX\n\n cString := AllTrim( cString )\n FOR nX := 1 TO Len( cString )\n IF ! SubStr( cString, nX, 1 ) $ \"0123456789ABCDEF\"\n RETURN .F.\n ENDIF\n NEXT\n\n RETURN .T.\n\nFUNCTION DecToBin( nNumber )\n\n LOCAL cNewString := \"\"\n LOCAL nTemp\n\n DO WHILE nNumber > 0\n nTemp := nNumber % 2\n cNewString := SubStr( \"01\", nTemp + 1, 1 ) + cNewString\n nNumber := Int( ( nNumber - nTemp ) / 2 )\n ENDDO\n\n RETURN cNewString\n\nFUNCTION DecToOctal( nNumber )\n\n LOCAL cNewString := \"\"\n LOCAL nTemp\n\n DO WHILE nNumber > 0\n nTemp := nNumber % 8\n cNewString := SubStr( \"01234567\", nTemp + 1, 1 ) + cNewString\n nNumber := Int( ( nNumber - nTemp ) / 8 )\n ENDDO\n\n RETURN cNewString\n\nFUNCTION DecToHexa( nNumber )\n\n LOCAL cNewString := \"\"\n LOCAL nTemp\n\n DO WHILE nNumber > 0\n nTemp := nNumber % 16\n cNewString := SubStr( \"0123456789ABCDEF\", nTemp + 1, 1 ) + cNewString\n nNumber := Int( ( nNumber - nTemp ) / 16 )\n ENDDO\n\n RETURN cNewString\n\nFUNCTION BinToDec( cString )\n\n LOCAL nNumber := 0, nX\n LOCAL cNewString := AllTrim( cString )\n LOCAL nLen := Len( cNewString )\n\n FOR nX := 1 TO nLen\n nNumber += ( At( SubStr( cNewString, nX, 1 ), \"01\" ) - 1 )\n nNumber += ( At( SubStr( cNewString, nX, 1 ), \"01234567\" ) - 1 )\n nNumber += ( At( SubStr( cNewString, nX, 1 ), \"0123456789ABCDEF\" ) - 1 )\n LOCAL cRoman := \"\"\n\n DO WHILE nNumber >= 1000\n cRoman += \"M\"\n nNumber -= 1000\n ENDDO\n DO WHILE nNumber >= 900\n cRoman += \"CM\"\n nNumber -= 900\n ENDDO\n DO WHILE nNumber >= 500\n cRoman += \"D\"\n nNumber -= 500\n ENDDO\n DO WHILE nNumber >= 400\n cRoman += \"CD\"\n nNumber -= 400\n ENDDO\n DO WHILE nNumber >= 100\n cRoman += \"C\"\n nNumber -= 100\n ENDDO\n DO WHILE nNumber >= 90\n cRoman += \"XC\"\n nNumber -= 90\n ENDDO\n DO WHILE nNumber >= 50\n cRoman += \"L\"\n nNumber -= 50\n ENDDO\n DO WHILE nNumber >= 40\n cRoman += \"XL\"\n nNumber -= 40\n ENDDO\n DO WHILE nNumber >= 10\n cRoman += \"X\"\n nNumber -= 10\n ENDDO\n DO WHILE nNumber >= 9\n cRoman += \"IX\"\n nNumber -= 9\n ENDDO\n DO WHILE nNumber >= 5\n cRoman += \"V\"\n nNumber -= 5\n ENDDO\n DO WHILE nNumber >= 4\n cRoman += \"IV\"\n nNumber -= 4\n ENDDO\n DO WHILE nNumber >= 1\n cRoman += \"I\"\n --nNumber\n ENDDO\n\n RETURN cRoman"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour header file: include/hbdyn.ch. Defines 10 constants including: HBDYN_CH_, HB_DYN_CALLCONV_CDECL, HB_DYN_CALLCONV_STDCALL, HB_DYN_CALLCONV_SYSCALL, HB_DYN_ENC_ASCII. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HBDYN_CH_\n#define HBDYN_CH_\n\n\n#define HB_DYN_CALLCONV_CDECL 0x0000000 \n#define HB_DYN_CALLCONV_STDCALL 0x0100000 \n#define HB_DYN_CALLCONV_SYSCALL 0x0200000 \n\n\n#define HB_DYN_ENC_ASCII 0x0000000\n#define HB_DYN_ENC_UTF8 0x0010000\n#define HB_DYN_ENC_UTF16 0x0020000\n#define HB_DYN_ENC_RAW 0x0040000\n\n\n#define HB_DYC_OPT_NONE 0x0000000\n#define HB_DYC_OPT_NULLTERM 0x1000000\n\n\n#define HB_DYN_CTYPE_DEFAULT 0x0000000\n#define HB_DYN_CTYPE_CHAR 0x0000001\n#define HB_DYN_CTYPE_CHAR_UNSIGNED 0x0000011\n#define HB_DYN_CTYPE_CHAR_PTR 0x0000101\n#define HB_DYN_CTYPE_CHAR_UNSIGNED_PTR 0x0000111\n#define HB_DYN_CTYPE_SHORT 0x0000002\n#define HB_DYN_CTYPE_SHORT_UNSIGNED 0x0000012\n#define HB_DYN_CTYPE_SHORT_PTR 0x0000102\n#define HB_DYN_CTYPE_SHORT_UNSIGNED_PTR 0x0000112\n#define HB_DYN_CTYPE_INT 0x0000003\n#define HB_DYN_CTYPE_INT_UNSIGNED 0x0000013\n#define HB_DYN_CTYPE_INT_PTR 0x0000103\n#define HB_DYN_CTYPE_INT_UNSIGNED_PTR 0x0000113\n#define HB_DYN_CTYPE_LONG 0x0000004\n#define HB_DYN_CTYPE_LONG_UNSIGNED 0x0000014\n#define HB_DYN_CTYPE_LONG_PTR 0x0000104\n#define HB_DYN_CTYPE_LONG_UNSIGNED_PTR 0x0000114\n#define HB_DYN_CTYPE_LLONG 0x0000005\n#define HB_DYN_CTYPE_LLONG_UNSIGNED 0x0000015\n#define HB_DYN_CTYPE_LLONG_PTR 0x0000105\n#define HB_DYN_CTYPE_LLONG_UNSIGNED_PTR 0x0000115\n#define HB_DYN_CTYPE_FLOAT 0x0000006\n#define HB_DYN_CTYPE_FLOAT_PTR 0x0000106\n#define HB_DYN_CTYPE_DOUBLE 0x0000007\n#define HB_DYN_CTYPE_DOUBLE_PTR 0x0000107\n#define HB_DYN_CTYPE_BOOL 0x0000008\n#define HB_DYN_CTYPE_BOOL_PTR 0x0000108\n#define HB_DYN_CTYPE_VOID 0x0000009\n#define HB_DYN_CTYPE_VOID_PTR 0x0000109\n#define HB_DYN_CTYPE_STRUCTURE 0x000000A\n#define HB_DYN_CTYPE_STRUCTURE_PTR 0x000010A\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/dbeval.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL nCount\n\n USE test\n\n dbGoto( 4 )\n ? RecNo()\n COUNT TO nCount\n ? RecNo(), nCount\n COUNT TO nCount NEXT 10\n ? RecNo(), nCount\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/fileio2.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL h\n LOCAL cstr := \" \"\n\n h := FCreate( \"test.txt\" )\n ? \"create handle\", h\n\n FWrite( h, \"This test worked if you can see this\" )\n\n FClose( h )\n\n h := FOpen( \"test.txt\" )\n ? \"open handle\", h\n ?\n \n DO WHILE Asc( cstr ) != 0\n cstr := FReadStr( h, 1 )\n ?? cstr\n ENDDO\n\n FClose( h )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: GenerateXML. Harbour contribution module 'hbdoc' (Documentation generation utilities): contrib/hbdoc/_xml.prg. Defines classes: GenerateXML. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nCREATE CLASS GenerateXML INHERIT TPLGenerate\n\n EXPORTED:\n\n METHOD NewIndex( cDir, cFilename, cTitle, cLang )\n METHOD NewDocument( cDir, cFilename, cTitle, cLang )\n METHOD AddEntry( oEntry )\n METHOD AddIndex( oEntry ) HIDDEN\n METHOD BeginSection( cSection, cFilename )\n METHOD EndSection( cSection, cFilename )\n METHOD Generate()\n\n HIDDEN:\n\n METHOD WriteEntry( cCaption, cContent, lPreformatted )\n\nENDCLASS\n\nMETHOD NewDocument( cDir, cFilename, cTitle, cLang ) CLASS GenerateXML\n\n ::super:NewDocument( cDir, cFilename, cTitle, \".xml\", cLang )\n ::cFile += ;\n '' + hb_eol() + ;\n '' + hb_eol()\n\n RETURN Self\n\nMETHOD NewIndex( cDir, cFilename, cTitle, cLang ) CLASS GenerateXML\n\n ::super:NewIndex( cDir, cFilename, cTitle, \".xml\", cLang )\n ::cFile += ;\n '' + hb_eol() + ;\n '' + hb_eol()\n\n RETURN Self\n\nMETHOD BeginSection( cSection, cFilename ) CLASS GenerateXML\n\n IF ::Depth == 0\n ::cFile += Replicate( Chr( 9 ), ::Depth ) + '
' + hb_eol()\n ELSE\n ::cFile += Replicate( Chr( 9 ), ::Depth ) + '
' + hb_eol()\n ENDIF\n ::Depth++\n\n RETURN Self\n\nMETHOD EndSection( cSection, cFilename ) CLASS GenerateXML\n\n HB_SYMBOL_UNUSED( cSection )\n HB_SYMBOL_UNUSED( cFilename )\n ::Depth--\n ::cFile += Replicate( Chr( 9 ), ::Depth ) + '
' + hb_eol()\n\n RETURN Self\n\nMETHOD AddIndex( oEntry ) CLASS GenerateXML\n\n ::WriteEntry( \"ENTRY\", oEntry:fld[ \"NAME\" ] + \" - \" + oEntry:fld[ \"ONELINER\" ], .F. )\n\n RETURN Self\n\nMETHOD AddEntry( oEntry ) CLASS GenerateXML\n\n LOCAL item\n\n IF ::IsIndex()\n ::AddIndex( oEntry )\n ELSE\n ::cFile += '' + hb_eol()\n ::Depth++\n FOR EACH item IN FieldIDList()\n ::WriteEntry( item, oEntry:fld[ item ], oEntry:IsPreformatted( item ) )\n NEXT\n ::Depth--\n ::cFile += '' + hb_eol()\n ENDIF\n\n RETURN Self\n\nMETHOD Generate() CLASS GenerateXML\n\n ::cFile += '' + hb_eol()\n\n ::super:Generate()\n\n RETURN Self\n\nMETHOD PROCEDURE WriteEntry( cCaption, cContent, lPreformatted ) CLASS GenerateXML\n\n IF ! Empty( cContent )\n\n IF hb_eol() $ cContent\n cContent := hb_eol() + cContent\n ENDIF\n\n ::cFile += ;\n Replicate( Chr( 9 ), ::Depth ) + \"<\" + cCaption + iif( lPreformatted, ' preformatted=\"yes\"', \"\" ) + \">\" + ;\n hb_StrReplace( cContent, { ;\n \"&\" => \"&\", ;\n '\"' => \""\", ;\n \"<\" => \"<\", ;\n \">\" => \">\" } ) + ;\n \"\" + hb_eol()\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/ctdisk.ch. Defines 10 constants including: _CTDISK_CH, FA_NORMAL, FA_READONLY, FA_HIDDEN, FA_SYSTEM. Defines keyboard input constants"}, {"role": "assistant", "content": "#ifndef _CTDISK_CH\n#define _CTDISK_CH\n\n#define FA_NORMAL 0 \n#define FA_READONLY 1 \n#define FA_HIDDEN 2 \n#define FA_SYSTEM 4 \n#define FA_VOLUME 8 \n#define FA_DIRECTORY 16 \n#define FA_ARCHIVE 32 \n\n#define FA_DEVICE 64 \n#define FA_TEMPORARY 256 \n#define FA_SPARSE 512 \n#define FA_REPARSE 1024 \n#define FA_COMPRESSED 2048 \n#define FA_OFFLINE 4096 \n#define FA_NOTINDEXED 8192 \n#define FA_ENCRYPTED 16384 \n#define FA_VOLCOMP 32768 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/nums.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL a := 0 \n LOCAL b := 123 \n LOCAL c := 50000 \n LOCAL d := 12000.123 \n LOCAL e := 0xABAB \n LOCAL f := .12\n\n ? a\n ? b\n ? c\n ? d\n ? e\n ? f\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Header file for contribution module 'gtwvg': contrib/gtwvg/hbgtwvg.ch. Defines 10 constants including: _HBGTWVG_CH, HB_GTE_ACTIVATE, HB_GTE_SETFOCUS, HB_GTE_KILLFOCUS, HB_GTE_CLOSE. Defines color and display constants"}, {"role": "assistant", "content": "#ifndef _HBGTWVG_CH\n#define _HBGTWVG_CH\n\n\n#ifndef HB_LEGACY_LEVEL4\n#define HB_GTE_ACTIVATE 1\n#define HB_GTE_SETFOCUS 2\n#define HB_GTE_KILLFOCUS 3\n#define HB_GTE_CLOSE 4\n#define HB_GTE_RESIZED 5\n#endif\n#define HB_GTE_MOUSE 6\n#define HB_GTE_KEYBOARD 7\n#define HB_GTE_TIMER 8\n#define HB_GTE_MENU 9\n#define HB_GTE_NOTIFY 10\n#define HB_GTE_COMMAND 11\n#define HB_GTE_CTLCOLOR 12\n#define HB_GTE_PAINT 13\n#define HB_GTE_GUIPARTS 14\n#define HB_GTE_HSCROLL 15\n#define HB_GTE_VSCROLL 16\n#define HB_GTE_ANY 17\n#define HB_GTE_KEYTOITEM 18\n#define HB_GTE_CREATED 19\n#define HB_GTE_CLOSED 20\n\n#define HB_GTI_EXTENDED 100\n\n#define HB_GTI_SETFONT ( HB_GTI_EXTENDED + 1 )\n#define HB_GTI_PRESPARAMS ( HB_GTI_EXTENDED + 2 )\n#define HB_GTI_ENABLE ( HB_GTI_EXTENDED + 3 )\n#define HB_GTI_DISABLE ( HB_GTI_EXTENDED + 4 )\n#define HB_GTI_SETFOCUS ( HB_GTI_EXTENDED + 5 )\n#define HB_GTI_DEFERPAINT ( HB_GTI_EXTENDED + 6 )\n#define HB_GTI_ACTIVATESELECTCOPY ( HB_GTI_EXTENDED + 7 )\n#define HB_GTI_SETPOSANDSIZE ( HB_GTI_EXTENDED + 8 )\n#define HB_GTI_REFRESH ( HB_GTI_EXTENDED + 9 )\n#define HB_GTI_NOTIFIERBLOCKGUI ( HB_GTI_EXTENDED + 10 )\n#define HB_GTI_MAXIMIZABLE ( HB_GTI_EXTENDED + 11 )\n#define HB_GTI_BORDERSIZES ( HB_GTI_EXTENDED + 12 )\n\n\n#define HB_GTI_PP_EXSTYLE 1\n#define HB_GTI_PP_STYLE 2\n#define HB_GTI_PP_X 3\n#define HB_GTI_PP_Y 4\n#define HB_GTI_PP_WIDTH 5\n#define HB_GTI_PP_HEIGHT 6\n#define HB_GTI_PP_PARENT 7\n#define HB_GTI_PP_VISIBLE 8\n#define HB_GTI_PP_ROWCOLS 9\n#define HB_GTI_PP_WNDTYPE 10\n\n#define HB_GTI_PP_SIZE 10\n\n#define HB_WNDTYPE_CRT 0\n#define HB_WNDTYPE_DIALOG 1\n\n#define HB_GTI_SPEC 1000\n\n\n#define HB_GTS_WINDOWHANDLE 1\n#define HB_GTS_CENTERWINDOW 2\n#define HB_GTS_PROCESSMESSAGES 3\n#define HB_GTS_KEYBOARD 4\n#define HB_GTS_RESETWINDOW 5\n#define HB_GTS_WNDSTATE 6\n#define HB_GTS_SETTIMER 7\n#define HB_GTS_KILLTIMER 8\n#define HB_GTS_SETPOSITION 9\n#define HB_GTS_SHOWWINDOW 10\n#define HB_GTS_UPDATEWINDOW 11\n#define HB_GTS_SYSTRAYICON 12\n#define HB_GTS_FACTOR 13\n\n\n#define HB_GTS_WS_SETONTOP 1\n#define HB_GTS_WS_SETASNORMAL 2\n#define HB_GTS_WS_MINIMIZED 3\n#define HB_GTS_WS_MAXIMIZED 4\n#define HB_GTS_WS_HIDDEN 5\n#define HB_GTS_WS_NORMAL 6\n\n\n#define HB_GTS_NIT_FILE 0\n#define HB_GTS_NIT_RESOURCEBYNAME 1\n#define HB_GTS_NIT_RESOURCEBYID 2\n\n\n#define HB_GTS_SW_HIDE 0\n#define HB_GTS_SW_NORMAL 1\n#define HB_GTS_SW_MINIMIZED 2\n#define HB_GTS_SW_MAXIMIZED 3\n#define HB_GTS_SW_RESTORE 9\n\n#define HB_GTI_GUI 1001\n\n\n#define GOBJ_OBJSTATE_ENABLED 1\n#define GOBJ_OBJSTATE_DISABLED 2\n#define GOBJ_OBJSTATE_HIDDEN 3\n#define GOBJ_OBJSTATE_HILIGHTED 4\n\n#define GOBJ_OBJDATA_TEXT 1\n#define GOBJ_OBJDATA_PICTURE 2\n#define GOBJ_OBJDATA_HFONT 3\n#define GOBJ_OBJDATA_HPEN 4\n#define GOBJ_OBJDATA_HBRUSH 5\n#define GOBJ_OBJDATA_COLORTEXT 6\n#define GOBJ_OBJDATA_COLORBK 7\n#define GOBJ_OBJDATA_IMAGE 8\n#define GOBJ_OBJDATA_BLOCK 9\n#define GOBJ_OBJDATA_PICTUREEX 10\n\n#define GOBJ_IMAGESOURCE_SLOT 1\n#define GOBJ_IMAGESOURCE_RESOURCE 2\n#define GOBJ_IMAGESOURCE_FILE 3\n\n\n#define GOBJ_OBJTYPE_BOXRAISED 1\n#define GOBJ_OBJTYPE_BOXRECESSED 2\n#define GOBJ_OBJTYPE_BOXGET 3\n#define GOBJ_OBJTYPE_BOXGROUP 4\n#define GOBJ_OBJTYPE_BOXGROUPRAISED 5\n#define GOBJ_OBJTYPE_PICTURE 6\n#define GOBJ_OBJTYPE_LINE 7\n#define GOBJ_OBJTYPE_LINEEX 8\n#define GOBJ_OBJTYPE_LABEL 9\n#define GOBJ_OBJTYPE_LABELEX 10\n#define GOBJ_OBJTYPE_OUTLINE 11\n#define GOBJ_OBJTYPE_ELLIPSE 12\n#define GOBJ_OBJTYPE_RECTANGLE 13\n#define GOBJ_OBJTYPE_ROUNDRECT 14\n#define GOBJ_OBJTYPE_COLORRECT 15\n#define GOBJ_OBJTYPE_SHADEDRECT 16\n#define GOBJ_OBJTYPE_TEXTBOX 17\n#define GOBJ_OBJTYPE_OUTLINEEX 18\n#define GOBJ_OBJTYPE_GRIDVERT 19\n#define GOBJ_OBJTYPE_GRIDHORZ 20\n#define GOBJ_OBJTYPE_LABEL_EX2 21\n\n#define GOBJ_OBJTYPE_OBJECT 25 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main, GetArray, PrintArray. Harbour test program: tests/codebl.prg. Provides 11 functions including: TestBlocks, myout, DetachWithRefer, MakeBlock, DoThing. Contains procedures: Main, GetArray, PrintArray. This test file tests specific function APIs"}, {"role": "assistant", "content": "STATIC s_cbStatic\n\nPROCEDURE Main()\n\n LOCAL a := TestBlocks()\n LOCAL cb\n\n ? Eval( a[ 1 ] ) \n ? Eval( a[ 2 ], 42 ) \n ? Eval( a[ 1 ] ) \n ? Eval( a[ 2 ], 15 ) \n\n myout( 15, Eval( a[ 1 ] ) ) \n myout( 14, Eval( a[ 1 ] ) ) \n myout( 42, Eval( a[ 2 ], 42 ) ) \n myout( 14, Eval( a[ 2 ], 42 ) ) \n myout( 42, Eval( a[ 1 ] ) ) \n myout( 14, Eval( a[ 1 ] ) ) \n\n GetArray( @a )\n PrintArray( @a )\n\n ? \"Test for variables passed by reference in a codeblock\"\n DetachWithRefer()\n\n ? \"Test for indirect detaching of local variables\"\n DetachToStatic( 1 )\n myout( 2, Eval( s_cbStatic, 1 ) )\n myout( 3, Eval( s_cbStatic, 2 ) )\n cb := s_cbStatic\n DetachToStatic( 100 )\n myout( 200, Eval( s_cbStatic, 100 ) )\n myout( 300, Eval( s_cbStatic, 200 ) )\n myout( 4, Eval( cb, 3 ) )\n\n ReferParam()\n\n RETURN\n\nSTATIC FUNCTION TestBlocks()\n\n LOCAL nFoo := 23\n\n RETURN { {|| nFoo }, {| n | nFoo := n } }\n\nSTATIC FUNCTION myout( nExpected, nGot )\n\n ? nExpected, nGot\n\n RETURN NIL\n\n\nSTATIC PROCEDURE GetArray( a )\n\n LOCAL i\n\n a := Array( 100 )\n FOR i := 1 TO 100\n IF ( i % 6 ) == 0\n a[ i - 2 ] := NIL\n a[ i - 4 ] := NIL\n ENDIF\n a[ i ] := TestBlocks()\n NEXT\n\n RETURN\n\nSTATIC PROCEDURE PrintArray( a )\n\n LOCAL i\n\n FOR i := 1 TO 100\n IF a[ i ] != NIL\n Eval( a[ i ][ 2 ], i )\n myout( i, Eval( a[ i ][ 1 ] ) )\n ENDIF\n NEXT\n\n RETURN\n\n\nSTATIC FUNCTION DetachWithRefer()\n\n LOCAL nTest\n LOCAL bBlock1 := MakeBlock()\n LOCAL bBlock2 := {|| DoThing( @nTest ), QOut( nTest ) }\n\n Eval( bBlock1 )\n Eval( bBlock2 )\n\n RETURN NIL\n\nSTATIC FUNCTION MakeBlock()\n\n LOCAL nTest\n\n RETURN {|| DoThing( @nTest ), QOut( nTest ) }\n\nSTATIC FUNCTION DoThing( n )\n\n n := 42\n\n RETURN NIL\n\n\nSTATIC FUNCTION DetachToStatic( n )\n\n s_cbStatic := {| x | n + x }\n\n RETURN NIL\n\n\nSTATIC FUNCTION ReferParam()\n\n LOCAL bResult\n\n ? \"Test for codeblock parameter passed by reference\"\n\n PassByValue( {| lEnd | ;\n bResult := GetBlock( @lEnd ), ;\n SetByRef( @lEnd ) } )\n \n \n ? \"Printed value in Clipper .T. =\", Eval( bResult )\n ?\n \n \n PassByRef( {| lEnd | ;\n bResult := GetBlock( @lEnd ), ;\n SetByRef( @lEnd ) } )\n \n \n ? \"Printed value in Clipper .T. =\", Eval( bResult )\n ?\n\n ? \"2nd test for codeblock parameter passed by reference\"\n\n PassByValue( {| lEnd | ;\n SetByRef( @lEnd ), ;\n bResult := GetBlock( @lEnd ) } )\n \n ? \"Printed value in Clipper .F. =\", Eval( bResult )\n ?\n\n PassByRef( {| lEnd | ;\n SetByRef( @lEnd ), ;\n bResult := GetBlock( @lEnd ) } )\n \n ? \"Printed value in Clipper .F. =\", Eval( bResult )\n ?\n\n RETURN NIL\n\nSTATIC FUNCTION PassByValue( bBlock )\n\n LOCAL lSomeVar := .T.\n\n Eval( bBlock, lSomeVar )\n ? \"lSomeVar value in Clipper .T. =\", lSomeVar\n\n RETURN .T.\n\nSTATIC FUNCTION PassByRef( bBlock )\n\n LOCAL lSomeVar := .T.\n\n Eval( bBlock, @lSomeVar )\n ? \"lSomeVar value in Clipper .F. =\", lSomeVar\n\n RETURN .T.\n\nSTATIC FUNCTION SetByRef( lVar )\n\n lVar := .F.\n\n RETURN NIL\n\nSTATIC FUNCTION GetBlock( lVar )\n RETURN {|| lVar }"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: TStream, TStreamFileReader, TStreamFileWriter. Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/stream.prg. Defines classes: TStream, TStreamFileReader, TStreamFileWriter. Provides functions: FileReader, FileWriter. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"fileio.ch\"\n\n#xtranslate Throw( ) => ( Eval( ErrorBlock(), ), Break( ) )\n\n#define BUFFER_SIZE 16384\n\nFUNCTION FileReader( cFile, nMode )\n RETURN TStreamFileReader():New( cFile, nMode )\n\nFUNCTION FileWriter( cFile, nMode )\n RETURN TStreamFileWriter():New( cFile, nMode )\n\nCREATE CLASS TStream\n\n VAR lCanRead INIT .F.\n VAR lCanWrite INIT .F.\n VAR lCanSeek INIT .F.\n\n VAR nLength INIT 0\n VAR nPosition INIT 0\n\n\n METHOD Close() VIRTUAL\n METHOD Flush() VIRTUAL\n METHOD Seek( nOffset, Origin ) VIRTUAL\n\n METHOD Read( sBuffer, nOffset, nCount ) VIRTUAL\n METHOD ReadByte() VIRTUAL\n\n METHOD Write( sBuffer, nOffset, nCount ) VIRTUAL\n METHOD WriteByte() VIRTUAL\n\n METHOD CopyTo( oTargetStream )\n\nENDCLASS\n\nMETHOD PROCEDURE CopyTo( oTargetStream ) CLASS TStream\n\n LOCAL nBytesToRead := ::nLength\n LOCAL sBuffer := Space( BUFFER_SIZE )\n LOCAL nRead\n LOCAL nPosition\n\n IF ! oTargetStream:lCanWrite\n Throw( xhb_ErrorNew( \"Stream\", 0, 1001, ProcName(), \"Target not writable.\", hb_AParams() ) )\n ENDIF\n\n \n nPosition := ::nPosition\n\n ::Seek( 0, FS_SET )\n oTargetStream:Seek( 0, FS_SET )\n\n DO WHILE nBytesToRead > 0\n nRead := ::Read( @sBuffer, 0, BUFFER_SIZE )\n oTargetStream:Write( sBuffer, 0, nRead )\n nBytesToRead -= nRead\n ENDDO\n\n \n oTargetStream:Write( \"\", 0, 0 )\n\n \n ::Seek( nPosition, FS_SET )\n\n RETURN\n\nCREATE CLASS TStreamFileReader FROM TStream\n\n VAR cFile\n VAR Handle\n\n METHOD New( cFile, nMode ) CONSTRUCTOR\n\n METHOD Close() INLINE iif( ::Handle > 0, FClose( ::Handle ), ), ::Handle := -2\n METHOD Seek( nOffset Origin ) INLINE FSeek( ::Handle, nOffset, Origin )\n\n METHOD Read( sBuffer, nOffset, nCount )\n METHOD ReadByte()\n\n DESTRUCTOR Finalize\n\nENDCLASS\n\nMETHOD New( cFile, nMode ) CLASS TStreamFileReader\n\n ::lCanRead := .T.\n\n ::cFile := cFile\n\n IF nMode == NIL\n nMode := 2\n ENDIF\n\n ::Handle := FOpen( cFile, nMode )\n IF ::Handle == F_ERROR\n Throw( xhb_ErrorNew( \"Stream\", 0, 1004, ProcName(), \"Open Error: \" + Str( FError() ), hb_AParams() ) )\n ENDIF\n\n ::nPosition := 0\n ::nLength := FSeek( ::Handle, 0, FS_END )\n\n FSeek( ::Handle, 0, FS_SET )\n\n RETURN Self\n\nMETHOD PROCEDURE Finalize CLASS TStreamFileReader\n\n ::Close()\n\n RETURN\n\nMETHOD Read( sBuffer, nOffset, nCount ) CLASS TStreamFileReader\n\n LOCAL nRead\n\n\n nRead := FRead( ::Handle, @sBuffer, nCount, nOffset )\n\n ::nPosition += nRead\n\n RETURN nRead\n\nMETHOD ReadByte() CLASS TStreamFileReader\n\n LOCAL sBuffer := \" \"\n\n IF FRead( ::Handle, @sBuffer, 1 ) == 1\n ::nPosition++\n RETURN sBuffer\n ENDIF\n\n RETURN \"\"\n\nCREATE CLASS TStreamFileWriter FROM TStream\n\n VAR cFile\n VAR Handle\n\n METHOD New( cFile, nMode ) CONSTRUCTOR\n\n METHOD Close() INLINE iif( ::Handle > 0, FClose( ::Handle ), ), ::Handle := -2\n METHOD Seek( nOffset Origin ) INLINE ::nPosition := FSeek( ::Handle, nOffset, Origin )\n\n METHOD Write( sBuffer, nOffset, nCount )\n METHOD WriteByte( cByte )\n\n DESTRUCTOR Finalize\n\nENDCLASS\n\nMETHOD New( cFile, nMode ) CLASS TStreamFileWriter\n\n ::lCanWrite := .T.\n\n ::cFile := cFile\n\n IF hb_FileExists( cFile )\n __defaultNIL( @nMode, FO_READWRITE )\n\n ::Handle := FOpen( cFile, nMode )\n IF ::Handle == F_ERROR\n Throw( xhb_ErrorNew( \"Stream\", 0, 1004, ProcName(), \"Open Error: \" + Str( FError() ), hb_AParams() ) )\n ENDIF\n\n ::nLength := FSeek( ::Handle, 0, FS_END )\n ::nPosition := ::nLength\n ELSE\n __defaultNIL( @nMode, FC_NORMAL )\n\n ::Handle := FCreate( cFile, nMode )\n IF ::Handle == F_ERROR\n Throw( xhb_ErrorNew( \"Stream\", 0, 1004, ProcName(), \"Create Error: \" + Str( FError() ), hb_AParams() ) )\n ENDIF\n\n ::nPosition := 0\n ::nLength := 0\n ENDIF\n\n RETURN Self\n\nMETHOD PROCEDURE Finalize CLASS TStreamFileWriter\n\n ::Close()\n\n RETURN\n\nMETHOD Write( sBuffer, nOffset, nCount ) CLASS TStreamFileWriter\n\n LOCAL nWritten\n\n nWritten := FWrite( ::Handle, sBuffer, nCount, nOffset )\n\n ::nPosition += nWritten\n\n IF nWritten != nCount\n Throw( xhb_ErrorNew( \"Stream\", 0, 1003, ProcName(), \"Write failed - written:\" + Str( nWritten ) + \" bytes\", hb_AParams() ) )\n ENDIF\n\n RETURN nWritten\n\nMETHOD PROCEDURE WriteByte( cByte ) CLASS TStreamFileWriter\n\n LOCAL nWritten := FWrite( ::Handle, cByte, 1 )\n\n ::nPosition += nWritten\n\n IF nWritten != 1\n Throw( xhb_ErrorNew( \"Stream\", 0, 1006, ProcName(), \"Write failed\", hb_AParams() ) )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/trpc.prg. Defines classes: TRPCFunction, TRPCServeCon. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"hbrpc.ch\"\n\n\nCREATE CLASS TRPCFunction\n\n VAR cName\n VAR aParameters\n VAR cReturn\n VAR cSerial\n VAR nAuthLevel\n\n VAR oExecutable\n VAR oMethod\n\n VAR aCall\n\n CLASS VAR cPattern INIT hb_regexComp( \"^C:[0-9]{1,6}$|^A$|^O$|^D$|^N$|^NI$\" )\n\n METHOD New( cFname, cSerial, nAuthLevel, oExec, oMeth ) CONSTRUCTOR\n METHOD SetCallable( oExec, oMeth )\n METHOD CheckTypes( aParams )\n METHOD CheckParam( cParam )\n METHOD Describe()\n METHOD Run( aParams, oClient )\n\nENDCLASS\n\nMETHOD New( cFname, cSerial, nAuthLevel, oExec, oMeth ) CLASS TRPCFunction\n\n LOCAL cParam\n LOCAL aParams, aFuncDef\n\n \n aFuncDef := hb_regex( \"^([a-zA-Z0-9_-]+)\\(([^)]*)\\) *(-->)? *(.*)$\", cFname )\n IF Empty( aFuncDef )\n Alert( \"Invalid function defintion\" )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n ::cName := aFuncDef[ 2 ]\n cParam := aFuncDef[ 3 ]\n ::cReturn := iif( Len( aFuncDef ) == 4, aFuncDef[ 4 ], aFuncDef[ 5 ] )\n\n \n IF Len( RTrim( cParam ) ) > 0\n aParams := hb_ATokens( cParam, \",\" )\n ::aParameters := {}\n FOR EACH cParam IN aParams\n cParam := AllTrim( Upper( cParam ) )\n ::CheckParam( cParam )\n AAdd( ::aParameters, cParam )\n NEXT\n ELSE\n ::aParameters := {}\n ENDIF\n\n \n ::CheckParam( ::cReturn )\n\n \n IF ! hb_regexMatch( \"[0-9]{8}\\..\", cSerial )\n Alert( \"Serial value not valid\" )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n \n IF nAuthLevel < 1\n Alert( \"Authorization level must be at least 1\" )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n ::cSerial := cSerial\n ::nAuthLevel := nAuthLevel\n\n \n IF oExec != NIL\n ::SetCallable( oExec, oMeth )\n ENDIF\n\n RETURN Self\n\nMETHOD SetCallable( oExec, oMeth ) CLASS TRPCFunction\n\n \n IF HB_ISOBJECT( oExec )\n ::aCall := Array( Len( ::aParameters ) + 3 )\n ::aCall[ 2 ] := oMeth\n ELSE\n ::aCall := Array( Len( ::aParameters ) + 2 )\n ENDIF\n\n ::aCall[ 1 ] := oExec\n\n RETURN .T.\n\nMETHOD Run( aParams, oClient ) CLASS TRPCFunction\n\n LOCAL nStart, nCount, xRet\n\n IF ! ::CheckTypes( aParams )\n RETURN NIL\n ENDIF\n\n nStart := iif( HB_ISOBJECT( ::aCall[ 1 ] ), 3, 2 )\n\n FOR nCount := 1 TO Len( aParams )\n ::aCall[ nStart ] := aParams[ nCount ]\n nStart++\n NEXT\n\n ::aCall[ nStart ] := oClient\n\n xRet := hb_ExecFromArray( ::aCall )\n\n RETURN xRet\n\nMETHOD CheckParam( cParam ) CLASS TRPCFunction\n\n IF ! hb_regexMatch( ::cPattern, cParam )\n Alert( \"TRPCFunction:CheckParam() wrong parameter specification: \" + cParam )\n QUIT\n ENDIF\n\n RETURN .T.\n\nMETHOD CheckTypes( aParams ) CLASS TRPCFunction\n\n LOCAL oElem, i := 0\n\n IF ! HB_ISARRAY( aParams )\n RETURN .F.\n ENDIF\n\n IF Len( aParams ) != Len( ::aParameters )\n RETURN .F.\n ENDIF\n\n FOR EACH oElem in ::aParameters\n i++\n IF !( ValType( aParams[ i ] ) == oElem[ 1 ] )\n RETURN .F.\n ENDIF\n NEXT\n\n RETURN .T.\n\nMETHOD Describe() CLASS TRPCFunction\n\n LOCAL cRet := ::cName + \"(\"\n LOCAL nCount\n\n IF Len( ::aParameters ) > 0\n FOR nCount := 1 TO Len( ::aParameters ) - 1\n cRet += ::aParameters[ nCount ] + \",\"\n NEXT\n cRet += ATail( ::aParameters )\n ENDIF\n\n cRet += \")-->\" + ::cReturn\n\n RETURN cRet + \"/\" + ::cSerial\n\n\nCREATE CLASS TRPCServeCon\n\n \n VAR oServer\n\n \n VAR skRemote\n VAR mtxBusy\n VAR thSelf INIT NIL\n\n \n VAR nAuthLevel\n\n \n VAR cUserId\n\n \n VAR lAllowProgress\n\n METHOD New( oParent, skIn ) CONSTRUCTOR\n METHOD Destroy()\n\n \n METHOD Start()\n METHOD Stop()\n METHOD Run()\n\n \n METHOD SendProgress( nProgress, oData )\n METHOD IsCanceled() INLINE ::lCanceled\n\n METHOD GetStatus() INLINE ::nStatus\n HIDDEN:\n \n VAR nStatus INIT RPCS_STATUS_NONE\n \n VAR bEncrypted\n \n VAR nChallengeCRC\n \n VAR cChallengeUserid\n VAR cCryptKey\n\n \n VAR thFunction INIT NIL\n VAR lCanceled INIT .F.\n\n METHOD RecvAuth( lEncrypt )\n METHOD RecvChallenge()\n METHOD RecvFunction( bComp, bMode )\n METHOD FuncCall( cData )\n METHOD FuncLoopCall( cMode, cData )\n METHOD FuncForeachCall( cMode, cData )\n METHOD LaunchChallenge( cUserid, cPassword )\n METHOD LaunchFunction( cFuncName, aParams, nMode, aDesc )\n METHOD FunctionRunner( cFuncName, oFunc, nMode, aParams, aDesc )\n METHOD SendResult( oRet, cFuncName )\n\n METHOD Encrypt( cDataIn )\n METHOD Decrypt( cDataIn )\n\nENDCLASS\n\nMETHOD New( oParent, skIn ) CLASS TRPCServeCon\n\n ::oServer := oParent\n ::skRemote := skIn\n ::mtxBusy := hb_mutexCreate()\n ::bEncrypted := .F.\n ::nAuthLevel := 0\n ::nChallengeCRC := -1\n\n RETURN Self\n\nMETHOD Destroy() CLASS TRPCServeCon\n\n hb_mutexLock( ::mtxBusy )\n \n IF ::thFunction != NIL\n ::lCanceled := .T.\n hb_mutexUnlock( ::mtxBusy )\n hb_threadJoin( ::thFunction )\n hb_mutexLock( ::mtxBusy )\n ENDIF\n\n ::skRemote := NIL\n hb_mutexUnlock( ::mtxBusy )\n\n RETURN .T.\n\nMETHOD Start() CLASS TRPCServeCon\n\n LOCAL lRet := .F.\n\n hb_mutexLock( ::mtxBusy )\n IF ::thSelf == NIL\n ::thSelf := StartThread( Self, \"RUN\" )\n lRet := .T.\n ENDIF\n hb_mutexUnlock( ::mtxBusy )\n\n RETURN lRet\n\nMETHOD Stop() CLASS TRPCServeCon\n\n LOCAL lRet := .F.\n\n hb_mutexLock( ::mtxBusy )\n IF hb_threadID( ::thSelf ) != 0\n hb_threadQuitRequest( ::thSelf )\n lRet := .T.\n hb_mutexUnlock( ::mtxBusy )\n hb_threadJoin( ::thSelf )\n ::thSelf := NIL\n ELSE\n hb_mutexUnlock( ::mtxBusy )\n ENDIF\n\n RETURN lRet\n\nMETHOD Run() CLASS TRPCServeCon\n\n LOCAL cCode := Space( 6 )\n LOCAL lBreak := .F.\n LOCAL aData\n LOCAL nSafeStatus\n\n DO WHILE hb_inetErrorCode( ::skRemote ) == 0 .AND. ! lBreak\n\n \n hb_inetRecvAll( ::skRemote, @cCode, 6 )\n IF hb_inetErrorCode( ::skRemote ) != 0\n EXIT\n ENDIF\n\n hb_mutexLock( ::mtxBusy )\n nSafeStatus := ::nStatus\n hb_mutexUnlock( ::mtxBusy )\n\n DO CASE\n\n \n CASE cCode == \"XHBR00\"\n hb_inetSendAll( ::skRemote, ;\n \"XHBR10\" + hb_Serialize( ::oServer:cServerName ) )\n\n \n CASE cCode == \"XHBR90\"\n IF nSafeStatus == RPCS_STATUS_NONE\n lBreak := ! ::RecvAuth( .F. )\n IF ! lBreak\n nSafeStatus := RPCS_STATUS_LOGGED\n ENDIF\n ELSE\n nSafeStatus := RPCS_STATUS_ERROR\n ENDIF\n\n \n CASE cCode == \"XHBR93\"\n IF nSafeStatus == RPCS_STATUS_NONE\n lBreak := ! ::RecvAuth( .T. )\n IF ! lBreak\n nSafeStatus := RPCS_STATUS_CHALLENGE\n ENDIF\n ELSE\n nSafeStatus := RPCS_STATUS_ERROR\n ENDIF\n\n \n CASE cCode == \"XHBR95\"\n IF nSafeStatus == RPCS_STATUS_CHALLENGE\n lBreak := ! ::RecvChallenge()\n IF ! lBreak\n nSafeStatus := RPCS_STATUS_LOGGED\n ENDIF\n ELSE\n nSafeStatus := RPCS_STATUS_ERROR\n ENDIF\n\n \n CASE cCode == \"XHBR92\"\n ::oServer:OnClientLogout( Self )\n lBreak := .T.\n\n \n CASE cCode == \"XHBR20\"\n IF nSafeStatus == RPCS_STATUS_LOGGED\n aData := ::RecvFunction( .F., .F. )\n IF aData != NIL\n lBreak := ! ::FuncCall( aData[ 2 ] )\n ELSE\n lBreak := .T.\n ENDIF\n ELSEIF nSafeStatus == RPCS_STATUS_RUNNING\n nSafeStatus := RPCS_STATUS_BUSY\n ELSE\n nSafeStatus := RPCS_STATUS_ERROR\n ENDIF\n\n\n CASE cCode == \"XHBR21\"\n IF nSafeStatus == RPCS_STATUS_LOGGED\n aData := ::RecvFunction( .T., .F. )\n IF aData != NIL\n lBreak := ! ::FuncCall( aData[ 2 ] )\n ELSE\n lBreak := .T.\n ENDIF\n ELSEIF nSafeStatus == RPCS_STATUS_RUNNING\n nSafeStatus := RPCS_STATUS_BUSY\n ELSE\n nSafeStatus := RPCS_STATUS_ERROR\n ENDIF\n\n \n CASE cCode == \"XHBR22\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/savearr.prg. Provides functions: ft_SaveArr, _ftsavesub, ft_RestArr, _ftrestsub. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_SaveArr( aArray, cFileName, nErrorCode )\n\n LOCAL nHandle, lRet\n\n nHandle := FCreate( cFileName )\n nErrorCode := FError()\n IF nErrorCode == 0\n lRet := _ftsavesub( aArray, nHandle, @nErrorCode )\n FClose( nHandle )\n IF lRet .AND. FError() != 0\n nErrorCode := FError()\n lRet := .F.\n ENDIF\n ELSE\n lRet := .F.\n ENDIF\n\n RETURN lRet\n\nSTATIC FUNCTION _ftsavesub( xMemVar, nHandle, nErrorCode )\n\n LOCAL cValType, nLen, cString\n\n LOCAL lRet := .T.\n\n cValType := ValType( xMemVar )\n FWrite( nHandle, cValType, 1 )\n IF FError() == 0\n SWITCH cValType\n CASE \"A\"\n nLen := Len( xMemVar )\n FWrite( nHandle, L2Bin( nLen ), 4 )\n IF FError() == 0\n AEval( xMemVar, {| xMemVar1 | lRet := _ftsavesub( xMemVar1, nHandle ) } )\n ELSE\n lRet := .F.\n ENDIF\n EXIT\n CASE \"B\"\n lRet := .F.\n EXIT\n CASE \"C\"\n nLen := Len( xMemVar )\n FWrite( nHandle, L2Bin( nLen ), 4 )\n FWrite( nHandle, xMemVar )\n EXIT\n CASE \"D\"\n nLen := 8\n FWrite( nHandle, L2Bin( nLen ), 4 )\n FWrite( nHandle, DToC( xMemVar ) )\n EXIT\n CASE \"L\"\n nLen := 1\n FWrite( nHandle, L2Bin( nLen ), 4 )\n FWrite( nHandle, iif( xMemVar, \"T\", \"F\" ) )\n EXIT\n CASE \"N\"\n cString := Str( xMemVar )\n nLen := Len( cString )\n FWrite( nHandle, L2Bin( nLen ), 4 )\n FWrite( nHandle, cString )\n EXIT\n ENDSWITCH\n ELSE\n lRet := .F.\n ENDIF\n nErrorCode := FError()\n\n RETURN lRet\n\nFUNCTION ft_RestArr( cFileName, nErrorCode )\n\n LOCAL nHandle, aArray\n\n nHandle := FOpen( cFileName )\n nErrorCode := FError()\n IF nErrorCode == 0\n aArray := _ftrestsub( nHandle, @nErrorCode )\n FClose( nHandle )\n ELSE\n aArray := {}\n ENDIF\n\n RETURN aArray\n\nSTATIC FUNCTION _ftrestsub( nHandle, nErrorCode )\n\n LOCAL cValType, nLen, cLenStr, xMemVar, cMemVar, nk\n\n cValType := \" \"\n FRead( nHandle, @cValType, 1 )\n cLenStr := Space( 4 )\n FRead( nHandle, @cLenStr, 4 )\n nLen := Bin2L( cLenStr )\n nErrorCode := FError()\n IF nErrorCode == 0\n SWITCH cValType\n CASE \"A\"\n xMemVar := {}\n FOR nk := 1 TO nLen\n AAdd( xMemVar, _ftrestsub( nHandle ) ) \n NEXT\n EXIT\n CASE \"C\"\n xMemVar := Space( nLen )\n FRead( nHandle, @xMemVar, nLen )\n EXIT\n CASE \"D\"\n cMemVar := Space( 8 )\n FRead( nHandle, @cMemVar, 8 )\n xMemVar := CToD( cMemVar ) \n EXIT\n CASE \"L\"\n cMemVar := \" \"\n FRead( nHandle, @cMemVar, 1 )\n xMemVar := ( cMemVar == \"T\" )\n EXIT\n CASE \"N\"\n cMemVar := Space( nLen )\n FRead( nHandle, @cMemVar, nLen )\n xMemVar := Val( cMemVar )\n EXIT\n ENDSWITCH\n nErrorCode := FError()\n ENDIF\n\n RETURN xMemVar"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/easter.prg. Provides functions: ft_Easter. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_Easter( nYear )\n\n LOCAL nGold, nCent, nCorx, nCorz, nSunday, nEpact, nMoon\n LOCAL nMonth := 0, nDay := 0\n\n IF HB_ISSTRING( nYear )\n nYear := Val( nYear )\n ENDIF\n\n IF HB_ISDATE( nYear )\n nYear := Year( nYear )\n ENDIF\n\n IF HB_ISNUMERIC( nYear )\n IF nYear > 1582\n\n \n nGold := nYear % 19 + 1\n\n \n nCent := Int( nYear / 100 ) + 1\n\n \n nCorx := Int( ( 3\n RETURN hb_SToD( Str( nYear, 4 ) + PadL( nMonth, 2, \"0\" ) + PadL( Int( nDay ), 2, \"0\" ) )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour header file: include/hbsix.ch. Defines constants: HB_SIX_CH_. Declares 5 preprocessor commands. Declares 5 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_SIX_CH_\n#define HB_SIX_CH_\n\n#include \"hbsxdef.ch\"\n\n\n#xtranslate Sx_IndexFilter( [] ) => ordFor( [] )\n#xtranslate Sx_TagName([]) => iif( Used(), ordName( [] ), \"\" )\n#xtranslate Sx_SetTagOrder( [] [,] ) => sx_SetTag( [] [,] )\n#xtranslate Sx_SetTagOrd( [] [,] ) => sx_SetTag( [] [,] )\n#xtranslate Sx_SetTagNo( [] ) => sx_SetTag( [], iif( ordNumber()>0, ordBagName(), ordBagName(1) ) )\n#xtranslate Sx_SetTagNo( , ) => sx_SetTag( , )\n#xtranslate _sxCondSet( [] ) => ordCondSet( [] )\n#xtranslate SetRDD( [] ) => rddSetDefault( [] )\n\n#command SET DIRTYREAD ON => sx_SetTurbo( .T. )\n#command SET DIRTYREAD OFF => sx_SetTurbo( .F. )\n#xtranslate Sx_SetDirty( [] ) => sx_SetTurbo( [] )\n#xtranslate Sx_DirtyArea( [] ) => sx_TurboArea( [] )\n\n\n#command USE <(db)> [VIA ] [ALIAS ] [] ;\n [] [] [] ;\n [CODEPAGE ] [INDEX <(index1)> [, <(indexN)>]] ;\n [TRIGGER ] [PASSWORD ] => ;\n [sx_SetTrigger( TRIGGER_PENDING, , );] <-trig-> ;\n [sx_SetPass( , 1, );] <-pass-> ;\n dbUseArea( <.nw.>, , <(db)>, <(a)>, ;\n iif( <.sh.> .OR. <.ex.>, ! <.ex.>, NIL ), <.ro.> [, ] ) ;\n [; dbSetIndex( <(index1)> )] ;\n [; dbSetIndex( <(indexN)> )]\n\n\n#command SORT [TO <(f)>] [ON ] ;\n [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] [] [ALL] [VIA ] ;\n [CODEPAGE ] [] [NOOPTIMIZE] => ;\n sx_SortOption(<.cur.>); ;\n __dbSort( <(f)>, { <(fields)> }, ;\n <{for}>, <{while}>, , , <.rest.>, ,, )\n\n\n#xcommand WILDSEEK => sx_WildSeek( )\n#xcommand WILDSEEKNEXT => sx_WildSeek( , .T. )\n\n\n#command CLEAR ORDER => sx_ClearOrder( )\n#command SET TAGORDER TO => ordSetFocus( )\n#command SET TAGORDER TO => ordSetFocus( 0 )\n#command SET ORDER TO TAG <(tag)> [OF <(bag)>] => ;\n ordSetFocus( <(tag)> [, <(bag)>] )\n#command SET TAG TO [OF <(bag)>] => ;\n ordSetFocus( <(tag)> [, <(bag)>] )\n#command SET TAG TO => ordSetFocus( 0 )\n\n#command REINDEX OPTION [STEP ] => ;\n REINDEX EVAL [EVERY ]\n#command DELETE TAG <(tag1)> [OF <(bag1)>] [, <(tagN)> [OF <(bagN)>]] => ;\n ordDestroy( <(tag1)>, <(bag1)> )[ ; ordDestroy( <(tagN)>, <(bagN)> )]\n#command DELETE TAG ALL [OF <(bag)>] => sx_KillTag( .T., <(bag)> )\n\n\n#command CLEAR SCOPE => sx_ClrScope()\n#xcommand SET SCOPETOP TO => sx_SetScope( 0, )\n#xcommand SET SCOPETOP TO => sx_ClrScope( 0 )\n#xcommand SET SCOPEBOTTOM TO => sx_SetScope( 1, )\n#xcommand SET SCOPEBOTTOM TO => sx_ClrScope( 1 )\n#command SET SCOPE TO => sx_ClrScope()\n#command SET SCOPE TO => sx_SetScope( 0, ) ;\n ; sx_SetScope( 1, )\n\n\n#command SET TURBOREAD ON => sx_SetTurbo( .T. )\n#command SET TURBOREAD OFF => sx_SetTurbo( .F. )\n\n\n#command MEMOPACK [BLOCK ] [OPTION [STEP ]] => ;\n sx_MemoPack( , <{opt}>, )\n#command SET MEMOBLOCK TO => sx_SetMemoBlock( )\n\n\n#command SUBINDEX ON TO <(file)> ;\n [OPTION [STEP ]] ;\n [] ;\n [] ;\n [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] [] [] ;\n [EVAL ] [EVERY ] [] ;\n [] [] ;\n [] [] ;\n [] [] ;\n [] [] => ;\n INDEX ON TO <(file)> USECURRENT ;\n [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] ;\n [EVAL ] [EVERY ] ;\n [<-cust-> CUSTOM] ;\n [<-filter-> USEFILTER]\n\n#command SUBINDEX ON TAG <(tag)> [OF <(bag)>] [TO <(bag)>] ;\n [OPTION [STEP ]] ;\n [] ;\n [] ;\n [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] [] [] ;\n [EVAL ] [EVERY ] [] ;\n [] [] ;\n [] [] ;\n [] [] ;\n [] [] => ;\n INDEX ON TAG <(tag)> [TO <(bag)>] USECURRENT ;\n [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] ;\n [EVAL ] [EVERY ] ;\n [<-cust-> CUSTOM] ;\n [<-filter-> USEFILTER]\n\n#command INDEX ON [TAG <(tag)>] TO <(bag)> ;\n [OPTION [STEP ]] ;\n [] ;\n [] ;\n [] ;\n [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] [] [] ;\n [EVAL ] [EVERY ] [] ;\n [] [] ;\n [] [] [] ;\n [] [] ;\n [] [] => ;\n ordCondSet( <\"for\">, <{for}>, [<.all.>], <{while}>, ;\n <{eval}>, , RecNo(), , , ;\n [<.rest.>], [<.descend.>],, ;\n [<.add.>], [<.cur.>], [<.cust.>], [<.noopt.>], ;\n <\"while\">, [<.mem.>], [<.filter.>], [<.ex.>] ) ;;\n ordCreate( <(bag)>, <(tag)>, <\"key\">, <{key}>, [<.unique.>] )\n\n#command INDEX ON TAG <(tag)> [OF <(bag)>] [TO <(bag)>] ;\n [OPTION [STEP ]] ;\n [] ;\n [] ;\n [] ;\n [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] [] [] ;\n [EVAL ] [EVERY ] [] ;\n [] [] ;\n [] [] [] ;\n [] [] ;\n [] [] => ;\n ordCondSet( <\"for\">, <{for}>, [<.all.>], <{while}>, ;\n <{eval}>, , RecNo(), , , ;\n [<.rest.>], [<.descend.>],, ;\n [<.add.>], [<.cur.>], [<.cust.>], [<.noopt.>], ;\n <\"while\">, [<.mem.>], [<.filter.>], [<.ex.>] ) ;;\n ordCreate( <(bag)>, <(tag)>, <\"key\">, <{key}>, [<.unique.>] )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: hdbcSQLTConnection, hdbcSQLTStatement, hdbcSQLTPreparedStatement. Harbour contribution module 'hbsqlit3' (SQLite3 database client library): contrib/hbsqlit3/hdbc.prg. Defines classes: hdbcSQLTConnection, hdbcSQLTStatement, hdbcSQLTPreparedStatement, hdbcSQLTResultSet. This file handles database operations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"error.ch\"\n#include \"hbsqlit3.ch\"\n\n#define _TODO_ NIL\n\nCREATE CLASS hdbcSQLTConnection\n\n PROTECTED:\n\n VAR pDb\n VAR lTrans\n VAR lTrace INIT .F.\n VAR pTrace\n\n EXPORTED:\n\n METHOD new( cDBFile, lCreateIfNotExist )\n METHOD close()\n\n METHOD startTransaction()\n \n METHOD commit()\n METHOD rollback()\n\n METHOD getMetadata()\n\n METHOD createStatement()\n METHOD prepareStatement( cSql )\n\nENDCLASS\n\nMETHOD new( cDBFile, lCreateIfNotExist ) CLASS hdbcSQLTConnection\n\n ::pDB := sqlite3_open( cDbFile, lCreateIfNotExist )\n\n IF sqlite3_errcode( ::pDb ) != SQLITE_OK\n raiseError( sqlite3_errmsg( ::pDb ) )\n ENDIF\n\n RETURN Self\n\nMETHOD close() CLASS hdbcSQLTConnection\n\n ::pDb := NIL\n\n RETURN NIL\n\nMETHOD startTransaction() CLASS hdbcSQLTConnection\n\n IF sqlite3_exec( ::pDB, \"BEGIN TRANSACTION\" ) != SQLITE_OK\n raiseError( sqlite3_errmsg( ::pDb ) )\n ENDIF\n\n RETURN NIL\n\nMETHOD commit() CLASS hdbcSQLTConnection\n\n IF sqlite3_exec( ::pDB, \"COMMIT\" ) != SQLITE_OK\n raiseError( sqlite3_errmsg( ::pDb ) )\n ENDIF\n\n RETURN NIL\n\nMETHOD rollback() CLASS hdbcSQLTConnection\n\n IF sqlite3_exec( ::pDB, \"ROLLBACK\" ) != SQLITE_OK\n raiseError( sqlite3_errmsg( ::pDb ) )\n ENDIF\n\n RETURN NIL\n\nMETHOD createStatement() CLASS hdbcSQLTConnection\n\n RETURN hdbcSQLTStatement():new( ::pDB )\n\nMETHOD prepareStatement( cSql ) CLASS hdbcSQLTConnection\n\n RETURN hdbcSQLTPreparedStatement():new( ::pDB, cSql )\n\nMETHOD getMetadata() CLASS hdbcSQLTConnection\n\n RETURN hdbcSQLTDatabaseMetaData():new( ::pDB )\n\nCREATE CLASS hdbcSQLTStatement\n\n PROTECTED:\n\n VAR pDB\n VAR cSql\n VAR oRs\n\n EXPORTED:\n\n VAR pRes\n\n METHOD new( pDB, cSql )\n METHOD executeQuery( cSql )\n METHOD executeUpdate( cSql )\n METHOD close()\n\nENDCLASS\n\nMETHOD new( pDB, cSql ) CLASS hdbcSQLTStatement\n\n ::pDB := pDB\n ::cSql := cSql\n\n RETURN self\n\nMETHOD executeQuery( cSql ) CLASS hdbcSQLTStatement\n\n ::pRes := sqlite3_prepare( ::pDB, cSql )\n\n IF ! HB_ISPOINTER( ::pRes )\n raiseError( sqlite3_errmsg( ::pDb ) )\n ELSE\n ::oRs := hdbcSQLTResultSet():new( ::pDB, Self )\n ENDIF\n\n return ::oRs\n\nMETHOD executeUpdate( cSql ) CLASS hdbcSQLTStatement\n\n LOCAL nRows\n\n IF sqlite3_exec( ::pDB, cSql ) != SQLITE_OK\n raiseError( sqlite3_errmsg( ::pDb ) )\n ELSE\n nRows := sqlite3_changes( ::pDB )\n ENDIF\n\n RETURN nRows\n\nMETHOD close() CLASS hdbcSQLTStatement\n\n IF ! HB_ISNIL( ::pRes )\n\n sqlite3_finalize( ::pRes )\n\n ::pRes := NIL\n\n ENDIF\n\n RETURN NIL\n\nCREATE CLASS hdbcSQLTPreparedStatement\n\n PROTECTED:\n\n VAR pDB\n VAR cSql\n VAR pRes\n VAR oRs\n VAR cName INIT \"hdbcsqle\"\n\n VAR lPrepared INIT .F.\n VAR nParams INIT 0\n VAR aParams INIT Array( 128 )\n\n EXPORTED:\n\n METHOD new( pDB, cSql )\n METHOD executeQuery()\n METHOD executeUpdate()\n METHOD close()\n\n METHOD setString( nParam, xValue )\n METHOD SetNumber( n, x ) INLINE ::setString( n, Str( x ) )\n METHOD SetDate( n, x ) INLINE ::setString( n, DToS( x ) )\n METHOD SetBoolean( n, x ) INLINE ::setString( n, iif( x, \"t\", \"f\" ) )\n\nENDCLASS\n\nMETHOD new( pDB, cSql ) CLASS hdbcSQLTPreparedStatement\n\n ::pDB := pDB\n ::cSql := cSql\n\n RETURN self\n\nMETHOD executeQuery() CLASS hdbcSQLTPreparedStatement\n\n IF ! ::lPrepared\n ::aParams := ASize( ::aParams, ::nParams )\n \n ENDIF\n\n if ::lPrepared\n \n ENDIF\n\n RETURN _TODO_\n\nMETHOD executeUpdate() CLASS hdbcSQLTPreparedStatement\n\n IF ! ::lPrepared\n ::aParams := ASize( ::aParams, ::nParams )\n \n ENDIF\n\n if ::lPrepared\n \n ENDIF\n\n RETURN _TODO_\n\nMETHOD setString( nParam, xValue ) CLASS hdbcSQLTPreparedStatement\n\n ::aParams[ nParam ] := xValue\n\n IF ! ::lPrepared\n IF nParam > ::nParams\n ::nParams := nParam\n ENDIF\n ENDIF\n\n RETURN NIL\n\nMETHOD close() CLASS hdbcSQLTPreparedStatement\n\n IF ! Empty( ::pRes )\n\n sqlite3_finalize( ::pRes )\n\n ::pRes := NIL\n\n ENDIF\n\n RETURN NIL\n\nCREATE CLASS hdbcSQLTResultSet\n\n PROTECTED:\n\n VAR pDB\n VAR pStmt\n VAR pRes\n\n VAR lBeforeFirst INIT .T.\n VAR lAfterLast INIT .F.\n\n VAR nRow INIT 0\n\n VAR cTableName\n VAR aPrimaryKeys\n VAR cPrimaryWhere\n VAR aBuffer\n VAR nCurrentRow\n VAR hColNames\n\n EXPORTED:\n\n VAR nRows INIT 0\n\n METHOD new( pDB, pStmt )\n METHOD close()\n\n METHOD beforeFirst()\n METHOD first() INLINE ::absolute( 1 )\n METHOD previous() INLINE ::relative( - 1 )\n METHOD next() INLINE ( sqlite3_step( ::pRes ) == SQLITE_ROW ) \n METHOD last() INLINE ::absolute( ::nRows )\n METHOD afterLast()\n\n METHOD relative( nMove )\n METHOD absolute( nMove )\n\n METHOD isBeforeFirst() INLINE ::lBeforeFirst\n METHOD isFirst() INLINE ( ::nRow == 1 )\n METHOD isLast() INLINE ( ::nRow == ::nRows )\n METHOD isAfterLast() INLINE ::lAfterLast\n METHOD getRow() INLINE ::nRow\n METHOD findColumn( cField )\n\n METHOD getString( nField )\n METHOD getNumber( nField ) INLINE Val( ::getString( nField ) )\n METHOD getDate( nField ) INLINE hb_SToD( StrTran( ::getString( nField ), \"-\" ) )\n METHOD getBoolean( nField ) INLINE ( ::getString( nField ) == \"t\" )\n\n METHOD getMetaData()\n\n METHOD setTableName( cTable ) INLINE ::cTableName := cTable\n METHOD setPrimaryKeys( aKeys ) INLINE ::aPrimaryKeys := aKeys\n\n METHOD moveToInsertRow()\n METHOD moveToCurrentRow()\n METHOD insertRow()\n METHOD updateRow()\n METHOD deleteRow()\n\n METHOD updateBuffer( nField, xValue, cType )\n METHOD updateString( nField, cValue ) INLINE ::updateBuffer( nField, cValue, \"C\" )\n METHOD updateNumber( nField, nValue ) INLINE ::updateBuffer( nField, hb_ntos( nValue ), \"N\" )\n METHOD updateDate( nField, dValue ) INLINE ::updateBuffer( nField, DToS( dValue ), \"D\" )\n METHOD updateBoolean( nField, lValue ) INLINE ::updateBuffer( nField, iif( lValue, \"t\", \"f\" ), \"L\" )\n\nENDCLASS\n\nMETHOD new( pDB, pStmt ) CLASS hdbcSQLTResultSet\n\n ::pDB := pDB\n ::pStmt := pStmt\n ::pRes := pStmt:pRes \n\n ::nRows := 100\n\n if ::nRows != 0\n ::nRow := 0\n ::lBeforeFirst := .T.\n ::lAfterLast := .F.\n ENDIF\n\n RETURN Self\n\nMETHOD close() CLASS hdbcSQLTResultSet\n\n RETURN NIL\n\nMETHOD beforeFirst() CLASS hdbcSQLTResultSet\n\n ::nRow := 0\n ::lBeforeFirst := .T.\n ::lAfterLast := .F.\n\n RETURN NIL\n\nMETHOD afterLast() CLASS hdbcSQLTResultSet\n\n ::nRow := ::nRows + 1\n ::lBeforeFirst := .F.\n ::lAfterLast := .T.\n\n RETURN NIL\n\nMETHOD relative( nMove ) CLASS hdbcSQLTResultSet\n\n LOCAL nRowNew := ::nRow + nMove\n\n IF nRowNew >= 1 .AND. nRowNew <= ::nRows\n\n ::nRow := nRowNew\n ::lBeforeFirst := .F.\n ::lAfterLast := .F.\n\n RETURN .T.\n\n ELSE\n\n IF nRowNew < 1\n ::nRow := 0\n ::lBeforeFirst := .T.\n ELSE\n ::nRow := ::nRows + 1\n ::lAfterLast := .T.\n ENDIF\n\n ENDIF\n\n RETURN .F.\n\nMETHOD absolute( nMove ) CLASS hdbcSQLTResultSet\n\n IF nMove > 0\n IF nMove <= ::nRows\n ::nRow := nMove\n ::lBeforeFirst := .F.\n ::lAfterLast := .F.\n RETURN .T.\n ENDIF\n ELSEIF nMove < 0\n IF -nMove <= ::nRows\n ::nRow := ::nRows + nMove\n ::lBeforeFirst := .F.\n ::lAfterLast := .F.\n RETURN .T.\n ENDIF\n ENDIF\n\n RETURN .F.\n\nMETHOD findColumn( cField ) CLASS hdbcSQLTResultSet\n\n LOCAL nCount\n LOCAL nMax\n\n IF ! HB_ISHASH( ::hColNames )\n ::hColNames := { => }\n nMax := sqlite3_column_count( ::pRes )\n FOR nCount := 1 TO nMax\n ::hColNames[ Lower( sqlite3_column_name( ::pRes, nCount ) ) ] := nCount\n NEXT\n ENDIF\n\n nCount := ::hColNames[ cField ]\n\n RETURN nCount\n\nMETHOD getString( nField ) CLASS hdbcSQLTResultSet\n\n IF HB_ISSTRING( nField )\n nField := ::findColumn( nField )\n ENDIF\n\n RETURN sqlite3_column_text( ::pRes, nField )\n\nMETHOD getMetaData() CLASS hdbcSQLTResultSet\n\n RETURN hdbcSQLTResultSetMetaData():new( ::pRes )\n\nMETHOD moveToInsertRow() CLASS hdbcSQLTResultSet\n\n ::nCurrentRow := ::nRow\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/showtime.prg. Provides functions: ShowTime. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ShowTime( nRow, nCol, lNoSec, cColor, l12, lAmPm )\n\n THREAD STATIC t_hTimer\n\n IF HB_ISNUMERIC( nRow ) .AND. nRow >= 0 .AND. nRow <= MaxRow( .T. )\n IF t_hTimer != NIL\n hb_idleDel( t_hTimer )\n ENDIF\n t_hTimer := hb_idleAdd( {|| __hbct_DspTime( nRow, nCol, lNoSec, cColor, ;\n l12, lAmPm ) } )\n ELSEIF t_hTimer != NIL\n hb_idleDel( t_hTimer )\n t_hTimer := NIL\n ENDIF\n\n RETURN \"\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbtinymt' (Tiny Mersenne Twister PRNG): contrib/hbtinymt/tests/test32.prg. Contains procedures: Main, TestMatrix. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbtinymt\"\n\nPROCEDURE Main()\n\n SET DECIMAL TO 0\n\n IF tinymt32_init( 0x123, 0x234, 0x345 )\n TestMatrix( \"32-bit unsigned integers r, where 0 <= r < 2^32\", {|| PadL( tinymt32_generate_uint32(), 11 ) } )\n ENDIF\n\n SET DECIMAL TO 12\n\n IF tinymt32_init_by_array( { 0x123, 0x234, 0x345 } )\n TestMatrix( \"Float numbers r, where 0.0 <= r < 1.0\", {|| PadL( tinymt32_generate_float(), 15 ) } )\n TestMatrix( \"Float numbers r, where 0.0 <= r < 1.0\", {|| PadL( tinymt32_generate_float01(), 15 ) } )\n TestMatrix( \"Float numbers r, where 1.0 <= r < 2.0\", {|| PadL( tinymt32_generate_float12(), 15 ) } )\n TestMatrix( \"Float numbers r, where 0.0 < r <= 1.0\", {|| PadL( tinymt32_generate_floatOC(), 15 ) } )\n TestMatrix( \"Float numbers r, where 0.0 < r < 1.0\", {|| PadL( tinymt32_generate_floatOO(), 15 ) } )\n TestMatrix( \"32-bit precision double numbers r, where 0.0 <= r < 1.0\", {|| PadL( tinymt32_generate_32double(), 15 ) } )\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE TestMatrix( cDescription, bBlock )\n\n LOCAL i, j\n\n ? cDescription\n FOR i := 1 TO 10\n FOR j := 1 TO 5\n ?? Eval( bBlock )\n NEXT\n ?\n NEXT\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'hbblink' (Blinker function extender): contrib/hbblink/hbblink.ch. Defines 10 constants including: BLINKER_CH_, BliCacheLoc, BliCacheSize, BliExtMemAvail, BliHostMode. Declares 3 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef BLINKER_CH_\n#define BLINKER_CH_\n\n#xtranslate BLINKER EXECUTABLE SERIAL => INIT PROCEDURE _init_hb_blivernum() ; hb_BliVerNum( ) ; RETURN\n#xtranslate BLINKER DEMONSTRATION DATE => INIT PROCEDURE _init_hb_blidemdte() ; hb_BliDemDte( hb_SToD( ) ) ; RETURN\n#xtranslate BLINKER DEMONSTRATION MINUTES => INIT PROCEDURE _init_hb_blidemmin() ; hb_BliDemMin( ) ; RETURN\n\n\n#define BliCacheLoc 1 \n#define BliCacheSize 2 \n#define BliExtMemAvail 3 \n#define BliHostMode 4 \n#define BliMachineMode 5 \n#define BliOverlayLoc 6 \n#define BliOverlaySize 7 \n#define BliRealMemAvail 8 \n#define BliVirMemAvail 9 \n\n\n#define BliCacheNone 0 \n#define BliCacheEMS 1 \n#define BliCacheXMS 2 \n\n\n#define BliHostNone 0\n#define BliHostDPMI 1\n#define BliHostVCPI 2\n#define BliHostXMS 3\n\n\n#define BliModeReal 0\n#define BliMode286Prot 1\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour source file: src/rdd/dbjoin.prg. Provides functions: __dbJoin, __FieldTwo, __JoinList. Contains procedures: __doJoinList. This file implements core Record Driver Driver functionality"}, {"role": "assistant", "content": "#include \"dbstruct.ch\"\n\n\nFUNCTION __dbJoin( cAlias, cFile, aFields, bFor, cRDD, nConnection, cCodePage )\n\n LOCAL nMaster := Select()\n LOCAL nDetail := Select( cAlias )\n LOCAL nResult\n LOCAL aStruct\n LOCAL aJoinList\n\n LOCAL oError\n LOCAL lError := .F.\n\n dbSelectArea( nMaster )\n IF Empty( aStruct := __FieldTwo( cAlias, aFields ) )\n \n RETURN .F.\n ENDIF\n\n BEGIN SEQUENCE\n\n dbCreate( cFile, aStruct, cRDD, .T., \"\", , cCodePage, nConnection )\n nResult := Select()\n aJoinList := __JoinList( nMaster, nDetail, nResult, aStruct )\n\n dbSelectArea( nMaster )\n dbGoTop()\n DO WHILE ! Eof()\n\n dbSelectArea( nDetail )\n dbGoTop()\n DO WHILE ! Eof()\n\n dbSelectArea( nMaster )\n IF Eval( bFor )\n __doJoinList( aJoinList )\n ENDIF\n\n dbSelectArea( nDetail )\n dbSkip()\n ENDDO\n\n dbSelectArea( nMaster )\n dbSkip()\n ENDDO\n\n RECOVER USING oError\n lError := .T.\n END SEQUENCE\n\n IF nResult != NIL\n dbSelectArea( nResult )\n dbCloseArea()\n ENDIF\n\n dbSelectArea( nMaster )\n\n IF lError\n Break( oError )\n ENDIF\n\n RETURN .T.\n\nSTATIC FUNCTION __FieldTwo( cAlias, aFields )\n\n LOCAL aFldTemp\n LOCAL bFind\n LOCAL aStruct\n LOCAL cField\n\n IF Empty( aFields )\n RETURN dbStruct()\n ENDIF\n\n aFldTemp := {}\n AEval( aFields, {| cFld | AAdd( aFldTemp, RTrim( Upper( cFld ) ) ) } )\n\n aFields := aFldTemp\n\n aStruct := {}\n bFind := {| cFld | cFld == cField }\n AEval( dbStruct(), {| aFld | cField := aFld[ DBS_NAME ], ;\n iif( AScan( aFields, bFind ) == 0, NIL, AAdd( aStruct, aFld ) ) } )\n\n dbSelectArea( cAlias )\n bFind := {| cFld | \"->\" $ cFld .AND. SubStr( cFld, At( \"->\", cFld ) + 2 ) == cField }\n AEval( dbStruct(), {| aFld | cField := aFld[ DBS_NAME ], ;\n iif( AScan( aFields, bFind ) == 0, NIL, AAdd( aStruct, aFld ) ) } )\n\n RETURN aStruct\n\nSTATIC FUNCTION __JoinList( nMaster, nDetail, nResult, aStruct )\n\n LOCAL aList := {}\n LOCAL nPos\n LOCAL i\n\n FOR i := 1 TO Len( aStruct )\n DO CASE\n CASE ( nPos := ( nMaster )->( FieldPos( aStruct[ i ][ DBS_NAME ] ) ) ) != 0\n AAdd( aList, { nResult, nMaster, nPos, i } )\n CASE ( nPos := ( nDetail )->( FieldPos( aStruct[ i ][ DBS_NAME ] ) ) ) != 0\n AAdd( aList, { nResult, nDetail, nPos, i } )\n ENDCASE\n NEXT\n\n RETURN aList\n\nSTATIC PROCEDURE __doJoinList( aList )\n\n LOCAL aJoin\n\n IF Len( aList ) > 0\n\n ( aList[ 1 ][ 1 ] )->( dbAppend() )\n\n FOR EACH aJoin IN aList\n ( aJoin[ 1 ] )->( FieldPut( aJoin[ 4 ], ( aJoin[ 2 ] )->( FieldGet( aJoin[ 3 ] ) ) ) )\n NEXT\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour Runtime Library file: src/rtl/tbcolumn.prg. Defines classes: TBColumn. Provides functions: TBColumnNew. This file implements object-oriented classes using Harbour's class system"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"tbrowse.ch\"\n\n\nCREATE CLASS TBColumn\n\n EXPORTED:\n\n \n VAR cargo \n VAR nWidth PROTECTED \n VAR bBlock PROTECTED \n VAR aDefColor PROTECTED INIT { 1, 2 } \n VAR bColorBlock PROTECTED INIT {|| NIL } \n VAR cHeading PROTECTED INIT \"\" \n VAR cHeadSep PROTECTED \n VAR cColSep PROTECTED \n VAR cFootSep PROTECTED \n VAR cFooting PROTECTED INIT \"\" \n VAR picture \n#ifdef HB_COMPAT_C53\n VAR bPreBlock PROTECTED \n VAR bPostBlock PROTECTED \n VAR aSetStyle PROTECTED INIT { .F., .F., .F. } \n#endif\n \n\n METHOD block( bBlock ) SETGET \n METHOD colorBlock( bColorBlock ) SETGET \n METHOD defColor( aDefColor ) SETGET \n METHOD colSep( cColSep ) SETGET \n METHOD heading( cHeading ) SETGET \n METHOD footing( cFooting ) SETGET \n METHOD headSep( cHeadSep ) SETGET \n METHOD footSep( cFootSep ) SETGET \n METHOD width( nWidth ) SETGET \n#ifdef HB_COMPAT_C53\n METHOD preBlock( bPreBlock ) SETGET \n METHOD postBlock( bPostBlock ) SETGET \n METHOD setStyle( nStyle, lNewValue )\n#endif\n\n METHOD Init( cHeading, bBlock ) \n\nENDCLASS\n\nMETHOD block( bBlock ) CLASS TBColumn\n\n IF bBlock != NIL\n ::bBlock := __eInstVar53( Self, \"BLOCK\", bBlock, \"B\", 1001 )\n ENDIF\n\n RETURN ::bBlock\n\nMETHOD colorBlock( bColorBlock ) CLASS TBColumn\n\n IF bColorBlock != NIL\n ::bColorBlock := __eInstVar53( Self, \"COLORBLOCK\", bColorBlock, \"B\", 1001 )\n ENDIF\n\n RETURN ::bColorBlock\n\nMETHOD defColor( aDefColor ) CLASS TBColumn\n\n IF aDefColor != NIL\n ::aDefColor := __eInstVar53( Self, \"DEFCOLOR\", aDefColor, \"A\", 1001 )\n ENDIF\n\n RETURN ::aDefColor\n\nMETHOD colSep( cColSep ) CLASS TBColumn\n\n IF cColSep != NIL\n ::cColSep := __eInstVar53( Self, \"COLSEP\", cColSep, \"C\", 1001 )\n ENDIF\n\n RETURN ::cColSep\n\nMETHOD heading( cHeading ) CLASS TBColumn\n\n IF cHeading != NIL\n ::cHeading := __eInstVar53( Self, \"HEADING\", cHeading, \"C\", 1001 )\n ENDIF\n\n RETURN ::cHeading\n\nMETHOD footing( cFooting ) CLASS TBColumn\n\n IF cFooting != NIL\n ::cFooting := __eInstVar53( Self, \"FOOTING\", cFooting, \"C\", 1001 )\n ENDIF\n\n RETURN ::cFooting\n\nMETHOD headSep( cHeadSep ) CLASS TBColumn\n\n IF cHeadSep != NIL\n ::cHeadSep := __eInstVar53( Self, \"HEADSEP\", cHeadSep, \"C\", 1001 )\n ENDIF\n\n RETURN ::cHeadSep\n\nMETHOD footSep( cFootSep ) CLASS TBColumn\n\n IF cFootSep != NIL\n ::cFootSep := __eInstVar53( Self, \"FOOTSEP\", cFootSep, \"C\", 1001 )\n ENDIF\n\n RETURN ::cFootSep\n\nMETHOD width( nWidth ) CLASS TBColumn\n\n IF nWidth != NIL\n ::nWidth := __eInstVar53( Self, \"WIDTH\", nWidth, \"N\", 1001 )\n ENDIF\n\n RETURN ::nWidth\n\n#ifdef HB_COMPAT_C53\n\nMETHOD preBlock( bPreBlock ) CLASS TBColumn\n\n IF bPreBlock != NIL\n ::bPreBlock := __eInstVar53( Self, \"PREBLOCK\", bPreBlock, \"B\", 1001 )\n ENDIF\n\n RETURN ::bPreBlock\n\nMETHOD postBlock( bPostBlock ) CLASS TBColumn\n\n IF bPostBlock != NIL\n ::bPostBlock := __eInstVar53( Self, \"POSTBLOCK\", bPostBlock, \"B\", 1001 )\n ENDIF\n\n RETURN ::bPostBlock\n\nMETHOD setStyle( nStyle, lNewValue ) CLASS TBColumn\n\n \n IF nStyle > Len( ::aSetStyle ) .AND. nStyle <= 4096 \n ASize( ::aSetStyle, nStyle )\n ENDIF\n\n IF HB_ISLOGICAL( lNewValue )\n ::aSetStyle[ nStyle ] := lNewValue\n ENDIF\n\n RETURN ::aSetStyle[ nStyle ]\n\n#endif\n\nMETHOD Init( cHeading, bBlock ) CLASS TBColumn\n\n ::cHeading := cHeading \n ::bBlock := bBlock \n\n RETURN Self\n\nFUNCTION TBColumnNew( cHeading, bBlock )\n RETURN TBColumn():New( cHeading, bBlock )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/clrsel.prg. Provides functions: ft_ClrSel, _ftHiLite, _ftColours, _ftShowIt. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"setcurs.ch\"\n#include \"inkey.ch\"\n\n#define C_NAME 1\n#define C_CLR 2\n#define C_TYPE 3\n#define C_CHAR 4\n\n#translate Single( , , , ) => hb_DispBox( , , , , hb_UTF8ToStrBox( \"┌─┐│┘─└│\" ) )\n#translate Double( , , , ) => hb_DispBox( , , , , hb_UTF8ToStrBox( \"╔═╗║╝═╚║\" ) )\n#translate BkGrnd( , , , , ) => hb_DispBox( , , , , Replicate( , 9 ) )\n\n\nFUNCTION ft_ClrSel( aClrs, lColour, cChr )\n\n LOCAL aClrOld := AClone( aClrs )\n LOCAL aOptions\n LOCAL nB, nT, nL, nR\n LOCAL nChoice := 1\n LOCAL nLen := 0\n LOCAL aPrompt := {}\n LOCAL aClrPal\n LOCAL aClrTab := { \"N\", \"B\", \"G\", \"BG\", \"R\", \"RB\", \"GR\", \"W\" }\n LOCAL aClrBW := { \"N\", \"B\", \"W\" }\n LOCAL nRowSav := Row()\n LOCAL nColSav := Col()\n LOCAL aEnvSav := ft_SaveSets()\n LOCAL cScrSav := SaveScreen( 0, 0, MaxRow(), MaxCol() )\n\n __defaultNIL( @lColour, IsColor() )\n __defaultNIL( @cChr, hb_UTF8ToStr( \"■■\" ) )\n\n cChr := PadR( cChr, 2 )\n\n SetCursor( SC_NONE )\n SetColor( iif( lColour, \"GR+/N,,N/N\", \"W+/N,,N/N\" ) )\n hb_Scroll()\n\n \n aClrPal := _ftInitPal( iif( lColour, aClrTab, aClrBW ) )\n\n \n _ftShowPal( aClrPal, cChr )\n\n \n AEval( aClrs, {| aOpt | nLen := Max( nLen, Len( aOpt[ C_NAME ] ) ) } )\n nLen := Min( Max( nLen, 1 ), 20 ) + 2\n\n \n aPrompt := Array( Len( aClrs ) )\n AEval( aClrs, ;\n {| aOpt, nE | aPrompt[ nE ] := \" \" + SubStr( aOpt[ C_NAME ], 1, nLen - 2 ) + \" \" };\n )\n\n \n nT := Max( Int( ( 18 - Len( aPrompt ) ) / 2 ) - 1, 1 )\n nB := Min( nT + Len( aPrompt ) + 1, 17 )\n nL := Max( Int( ( 27 - nLen ) / 2 ) - 2, 1 )\n nR := Min( nL + nLen + 3, 26 )\n\n \n SetColor( iif( lColour, \"N/W,W+/R\", \"N/W,W+/N\" ) )\n hb_Scroll( nT, nL, nB, nR )\n\n \n DO WHILE nChoice != 0\n Double( nT, nL + 1, nB, nR - 1 )\n nChoice := AChoice( nt + 1, nL + 2, nB - 1, nR - 2, aPrompt,,, nChoice )\n IF nChoice != 0\n _ftHiLite( Row(), nL + 2, aPrompt[ nChoice ], nLen )\n Single( nT, nL + 1, nB, nR - 1 )\n aClrs[ nChoice ] := _ftColours( aClrs[ nChoice ], aClrPal, lColour )\n ENDIF\n ENDDO\n\n aOptions := { \"Save New Colours\", \"Restore Original\" }\n IF ! _ftIdentArr( aClrs, aClrOld )\n nChoice := Alert( \"Colors have been modified...\", aOptions )\n ELSE\n nChoice := 1\n ENDIF\n\n ft_RestSets( aEnvSav )\n RestScreen( 0, 0, MaxRow(), MaxCol(), cScrSav )\n SetPos( nRowSav, nColSav )\n\n RETURN iif( nChoice == 1, aClrs, aClrOld )\n\n\nSTATIC FUNCTION _ftHiLite( nRow, nCol, cStr, nLen )\n\n LOCAL aClr := _ftChr2Arr( SetColor() )\n\n hb_DispOutAt( nRow, nCol, PadR( cStr, nLen ), aClr[ 2 ] ) \n\n RETURN NIL\n\n\nSTATIC FUNCTION _ftColours( aOpt, aClrPal, lColour )\n\n LOCAL nB, nT, nL, nR\n LOCAL nX\n LOCAL aClrs := {}\n LOCAL cClr\n LOCAL nChoice := 1\n LOCAL aPrompt\n LOCAL nLen := 0\n LOCAL cColour := SetColor()\n LOCAL cScrSav := SaveScreen( 18, 0, MaxRow(), MaxCol() )\n\n ASize( aOpt, 4 ) \n __defaultNIL( @aOpt[ C_CHAR ], \"\" )\n __defaultNIL( @aOpt[ C_TYPE ], \"W\" )\n aOpt[ C_CLR ] := Upper( aOpt[ C_CLR ] ) \n aOpt[ C_TYPE ] := Upper( aOpt[ C_TYPE ] )\n\n __defaultNIL( @lColour, IsColor() )\n\n \n nChoice := 1\n DO CASE\n CASE aOpt[ C_TYPE ] == \"D\"\n aPrompt := { \" Color \", \" Character \" }\n CASE aOpt[ C_TYPE ] == \"M\"\n aPrompt := { \" Prompt \", \" Message \", \" HotKey \", ;\n \" LightBar \", \" LightBar HotKey \" }\n CASE aOpt[ C_TYPE ] == \"A\" .OR. aOpt[ C_TYPE ] == \"B\"\n aPrompt := { \" Standard \", \" Selected \", \" Border \", \" Unavailable \" }\n OTHERWISE\n aPrompt := { \" Standard \", \" Selected \", \" Border \", \" Unselected \" }\n ENDCASE\n\n IF !( aOpt[ C_TYPE ] == \"T\" ) \n \n AEval( aPrompt, {| cPrompt | nLen := Max( nLen, Len( cPrompt ) ) } )\n nLen := Max( nLen, Len( aOpt[ C_NAME ] ) + 2 )\n nT := iif( aOpt[ C_TYPE ] == \"M\", 18, 19 )\n nB := nT + Len( aPrompt ) + 1\n nL := Max( Int( ( 27 - nLen ) / 2 ) - 2, 1 )\n nR := Min( nL + nLen + 3, 26 )\n\n \n SetColor( \"N/W\" )\n hb_Scroll( nT, nL, nB, nR )\n ENDIF\n\n DO WHILE .T.\n\n \n _ftShowIt( aOpt )\n\n IF !( aOpt[ C_TYPE ] == \"T\" ) \n SetColor( iif( lColour, \"N/W,W+/R,,,N/W\", \"N/W,W+/N,,,N/W\" ) )\n Double( nT, nL + 1, nB, nR - 1 )\n hb_DispOutAt( nT, nL + 2, PadC( \" \" + aOpt[ C_NAME ] + \" \", nR - nL - 3, hb_UTF8ToStr( \"═\" ) ) )\n FOR nX := 1 TO Len( aPrompt )\n @ nX + nT, nL + 2 PROMPT PadR( aPrompt[ nX ], nR - nL - 3 )\n NEXT\n MENU TO nChoice\n\n DO CASE\n CASE nChoice == 0\n EXIT\n CASE nChoice == 2 .AND. aOpt[ C_TYPE ] == \"D\"\n \n aOpt := _ftDeskChar( aOpt )\n LOOP\n CASE nChoice == 4 .AND. !( aOpt[ C_TYPE ] == \"M\" )\n nChoice := 5 \n ENDCASE\n ENDIF\n\n \n aClrs := _ftChr2Arr( aOpt[ C_CLR ] ) \n ASize( aClrs, 5 ) \n \n AEval( aClrs, {| v, e | aClrs[ e ] := iif( Empty( v ), NIL, AllTrim( v ) ) } )\n __defaultNIL( @aClrs[ 1 ], \"W/N\" )\n __defaultNIL( @aClrs[ 2 ], \"N/W\" ) \n __defaultNIL( @aClrs[ 3 ], \"N/N\" ) \n __defaultNIL( @aClrs[ 4 ], \"N/N\" )\n __defaultNIL( @aClrs[ 5 ], \"N/W\" )\n cClr := aClrs[ nChoice ] \n\n \n IF !( aOpt[ C_TYPE ] == \"T\" )\n Single( nT, nL + 1, nB, nR - 1 )\n hb_DispOutAt( nT, nL + 2, PadC( \" \" + aOpt[ C_NAME ] + \" \", nR - nL - 3, hb_UTF8ToStr( \"─\" ) ) )\n ENDIF\n cClr := _ftClrSel( aClrPal, cClr, nChoice, aOpt ) \n aClrs[ nChoice ] := cClr \n aOpt[ C_CLR ] := _ftArr2Chr( aClrs ) \n\n IF aOpt[ C_TYPE ] == \"T\"\n EXIT\n ENDIF\n\n ENDDO\n\n \n RestScreen( 18, 0, MaxRow(), MaxCol(), cScrSav )\n SetColor( cColour )\n\n RETURN aOpt\n\n\nSTATIC FUNCTION _ftShowIt( aOpt )\n\n LOCAL aClr := _ftChr2Arr( aOpt[ C_CLR ] )\n\n IF !( aOpt[ C_TYPE ] == \"M\" ) \n SetColor( aOpt[ C_CLR ] ) \n ENDIF\n\n DispBegin()\n\n SWITCH aOpt[ C_TYPE ]\n\n CASE \"D\" \n SetColor( aClr[ 1 ] )\n BkGrnd( 19, 43, 22, 64, aOpt[ C_CHAR ] )\n EXIT\n\n CASE \"T\" \n SetColor( aClr[ 1 ] )\n hb_DispOutAt( 20, 8, PadC( \"This is an example of how the text shall look\", 63 ) )\n EXIT\n\n CASE \"M\" \n SetColor( \"W/N\" )\n BkGrnd( 19, 41, 23, 66, hb_UTF8ToStrBox( \"▒\" ) )\n SetColor( aClr[ 1 ] )\n Single( 19, 43, 22, 60 )\n hb_DispOutAt( 18, 41, \" Report Inquiry Quit \" )\n hb_DispOutAt( 21, 44, \" eXit \" )\n SetColor( aClr[ 4 ] )\n hb_DispOutAt( 18, 43, \" Report \" )\n hb_DispOutAt( 20, 44, \" Product List \" )\n SetColor( aClr[ 3 ] )\n hb_DispOutAt( 18, 52, \"I\" )\n hb_DispOutAt( 18, 61, \"Q\" )\n hb_DispOutAt( 21, 46, \"X\" )\n SetColor( aClr[ 5 ] )\n hb_DispOutAt( 18, 44, \"R\" )\n hb_DispOutAt( 20, 45, \"P\" )\n SetColor( aClr[ 2 ] )\n hb_DispOutAt( 24, 41, PadC( \"Inventory Report\", 26 ) )\n EXIT\n\n CASE \"G\" \n SetColor( aClr[ 1 ] )\n hb_Scroll( 19, 41, 24, 66 )\n Single( 19, 42, 24, 65 )\n hb_DispOutAt( 20, 43, \" Invoice Entry \" )\n hb_DispOutAt( 21, 42, hb_UTF8ToStr( \"├──────────────────────┤\" ) )\n hb_DispOutAt( 22, 43, \" Amount \" )\n hb_DispOutAt( 23, 43, \" Date \" )\n SetColor( aClr[ 2 ] )\n hb_DispOutAt( 22, 53, \" 199.95\" )\n SetColor( aClr[ 5 ] )\n hb_DispOutAt( 23, 53, DToC( 0d19910915 ) )\n EXIT\n\n CASE \"W\" \n SetColor( aClr[ 1 ] )\n hb_Scroll( 18, 40, 24, 66 )\n Single( 18, 41, 24, 65 )\n hb_DispOutAt( 19, 42, \" \" )\n hb_DispOutAt( 20, 42, \" Test Message \" )\n hb_DispOutAt( 21, 42, \" \" )\n hb_DispOutAt( 22, 41, hb_UTF8ToStr( \"├───────────────────────┤\" ) )\n SetColor( aClr[ 2 ] )\n hb_DispOutAt( 23, 44, \" Accept \" )\n SetColor( aClr[ 5 ] )\n hb_DispOutAt( 23, 55, \" Reject \" )\n EXIT\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour test program: tests/ppapi.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "REQUEST __pp_StdRules\n\nPROCEDURE Main()\n\n LOCAL cString, l_pp\n LOCAL i, j, aScript\n\n l_pp := __pp_Init()\n\n CLS\n\n ? \"Testing Harbour run-time preprocessing\"\n ? \"======================================\"\n ?\n\n cString := \"@ 10, 10 SAY 'Hello!'\"\n ? cString\n ? __pp_Process( l_pp, cString )\n ?\n\n cString := \"? 'Hello mom'\"\n ? cString\n ? __pp_Process( l_pp, cString )\n ?\n\n cString := 'SET RELATION TO Something INTO MySelf'\n ? cString\n ? __pp_Process( l_pp, cString )\n ?\n\n cString := 'SET RELATION ADDITIVE TO Something INTO YourSelf'\n ? cString\n ? __pp_Process( l_pp, cString )\n ?\n\n cString := \"#xcommand DEFAULT := => IF == NIL ; := ; END\"\n ? cString\n IF __pp_AddRule( l_pp, cString )\n ? \"Rule added successfully !\"\n ELSE\n ? \"Rule addition failed ...\"\n ENDIF\n\n cString := 'DEFAULT x := 100'\n ? cString\n ? __pp_Process( l_pp, cString )\n ?\n\n WAIT \"Press any key...\"\n\n CLS\n\n aScript := { ;\n 'cMyDatabase := \"dontknow.dbf\"', ;\n 'USE ( cMyDatabase )', ;\n 'GO TOP', ;\n '', ;\n '? MYFIELD, YOURFIELD', ;\n '', ;\n 'WAIT \"Press any key...\"', ;\n '', ;\n 'CLOSE ALL' }\n\n FOR j := 1 TO 2\n ? iif( j == 1, \"Before\", \"After\" ) + \" __pp_Process()\"\n ? \"===================\"\n ?\n FOR i := 1 TO Len( aScript )\n ? iif( j == 1, aScript[ i ], __pp_Process( l_pp, aScript[ i ] ) )\n NEXT\n ?\n WAIT \"Press any key...\"\n CLS\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Header file for contribution module 'hbfoxpro' (FoxPro file format support): contrib/hbfoxpro/hbfoxpro.ch. Defines constants: HBFOXPRO_CH_. Declares 5 preprocessor commands. Declares 5 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HBFOXPRO_CH_\n#define HBFOXPRO_CH_\n\n\n#xtranslate . => :\n#translate THIS. => Self:\n\n\n#xtranslate .NULL. => NIL\n\n\n#xtranslate __FP_DIM( ) => \n#xtranslate __FP_DIM( ( ) ) => \\[ \\]\n\n#command PUBLIC [, ] => ;\n <@> PUBLIC __FP_DIM( ) [, __FP_DIM( ) ]\n#command PRIVATE [, ] => ;\n <@> PRIVATE __FP_DIM( ) [, __FP_DIM( ) ]\n#command DIMENSIONS ( ) [, ( ) ] => ;\n PRIVATE \\[ \\] [, \\[ \\] ]\n\n\n#translate FIELD-> => _FIELD->\n\n\n#command DISPLAY [FIELDS ] [] ;\n [] [TO FILE <(f)>] ;\n [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] [] [] => ;\n __dbList( <.off.>, { <{v}> }, <.all.>, ;\n <{for}>, <{while}>, , ;\n , <.rest.>, <.prn.>, <(f)> )\n\n\n#command SEEK [] [] ;\n [TAG ] [IN ] => ;\n __fox_Seek( , iif( <.soft.>, .T., NIL ), ;\n iif( <.last.>, .T., NIL ), ;\n <(wa)>, <(tag)> )\n#command SET FILTER TO IN [NOOPTIMIZE] => ;\n ->( dbSetFilter( <{exp}>, <\"exp\"> ) )\n#command SKIP [] IN => ->( dbSkip( ) )\n#command UNLOCK IN => ->( dbUnlock() )\n#command GO TOP IN => ->( dbGoTop() )\n#command GO BOTTOM IN => ->( dbGoBottom() )\n#command GOTO IN => ->( dbGoto( ) )\n\n#xtranslate SEEK( , ) => ()->( dbSeek( ) )\n#xtranslate RECCOUNT( ) => ()->( RecCount() )\n#xtranslate RECSIZE( ) => ()->( RecSize() )\n#xtranslate FCOUNT( ) => ()->( FCount() )\n#xtranslate RECNO( ) => ()->( RecNo() )\n#xtranslate RLOCK( ) => ()->( RLock() )\n\n#xtranslate USED( ) => __fox_Used( )\n\n#xtranslate At( , , ) => fox_At( , , )\n\n\n#command SCAN [FOR ] [WHILE ] [NEXT ] ;\n [RECORD ] [] [ALL] [NOOPTIMIZE] => ;\n __dbLocate( <{for}>, <{while}>, , , <.rest.> ) ;;\n WHILE Found()\n#command ENDSCAN => __dbContinue(); ENDDO\n\n#command EJECT PAGE => __Eject()\n#command FLUSH => dbCommitAll()\n#command REGIONAL [] => LOCAL \n#command CD <(path)> => hb_cwd( <(path)> )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/define.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifndef TEST\n#warning Warning: This sample must be tested using /dTEST compiler flag\n#endif\n\n#define FIRST\n#define SECOND\n#define THIRD\n\nPROCEDURE Main()\n\n ? \"testing Harbour /d compiler flag\"\n\n #ifdef TEST\n ? \"Fine, you have just tested the /d compiler flag\"\n #else\n ? \"Please use /dTEST compiler flag\"\n ? \"Or run 'set HB_USER_PRGFLAGS=/dTEST' if you are using the GNU Make System\"\n #endif\n\n #ifdef FIRST\n ? \"FIRST is defined\"\n\n #ifdef SECOND\n ? \"FIRST and SECOND are defined\"\n\n #ifdef THIRD\n ? \"FIRST, SECOND and THIRD are defined\"\n #else\n ? \"THIRD is not defined\"\n #endif\n\n #else\n ? \"SECOND is not defined\"\n #endif\n\n #else\n ? \"FIRST is not defined\"\n #endif\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/ains.prg. Contains procedures: Main, aDump. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n#include \"clipper.ch\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL aFirst\n LOCAL aSecond\n LOCAL aMore\n\n aFirst := AClone( { 1, 2, 4 } )\n AIns( aFirst, 3 )\n aFirst[ 3 ] := \"3\"\n ?? \"Testing AIns() ... \"\n aDump( aFirst )\n\n aSecond := { 1, 2, 4 }\n ASize( aSecond, 4 )\n ?? \"Testing ASize() ... \"\n aDump( aSecond )\n\n aSecond := { 1, 2, 4 }\n ASize( aSecond, 4 )\n AIns( aSecond, 3 )\n aSecond[ 3 ] := \"3\"\n ?? \"Testing ASize() + AIns() ... \"\n aDump( aSecond )\n\n aSecond := { 1, 2, 3, 3, 4, 5 }\n ADel( aSecond, 3 )\n ?? \"Testing ADel() ... \"\n aDump( aSecond )\n\n aSecond := { 1, 2, 3, 3, 4, 5 }\n ADel( aSecond, 3 )\n ASize( aSecond, Len( aSecond ) - 1 )\n ?? \"Testing ASize() + ADel() ... \"\n aDump( aSecond )\n\n AFill( aSecond, \"!\" )\n ?? \"Testing AFill() ... \"\n aDump( aSecond )\n\n aMore := { 1, 2, 3, 4, 5, 6 }\n AFill( aMore, \"X\", 3 )\n ?? \"Testing AFill() with start ... \"\n aDump( aMore )\n\n aMore := { 1, 2, 3, 4, 5, 6 }\n AFill( aMore, \"X\", 3, 2 )\n ?? \"Testing AFill() with start and count ... \"\n aDump( aMore )\n\n aMore := { { 1, 2 }, { 3, 4 } }\n ADel( aMore, 1 )\n aDump( aMore )\n\n RETURN\n\nPROCEDURE aDump( aShow )\n\n LOCAL n\n\n ?? \"Len=\", hb_ntos( Len( aShow ) )\n ?? \": \"\n FOR n := 1 TO Len( aShow )\n\n ?? \"[\"\n ?? hb_ntos( n )\n ?? \"]= \"\n ?? ValType( aShow[ n ] )\n ?? \":\"\n IF HB_ISARRAY( aShow[ n ] ) \n ?\n ?? \"[\"\n aDump( aShow[ n ] )\n ?? \"]\"\n ELSE\n ?? iif( HB_ISNUMERIC( aShow[ n ] ), hb_ntos( aShow[ n ] ), aShow[ n ] )\n ENDIF\n\n IF n != Len( aShow )\n ?? \", \"\n ENDIF\n\n NEXT\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tempfile.prg. Provides functions: TempFile. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n\nFUNCTION TempFile( cDir, cExt, nAttr )\n\n LOCAL cName\n LOCAL fhnd\n\n IF HB_ISSTRING( cDir )\n cDir := hb_DirSepAdd( cDir )\n ENDIF\n\n IF HB_ISSTRING( cExt ) .AND. !( Left( cExt, 1 ) == \".\" )\n cExt := \".\" + cExt\n ENDIF\n\n hb_default( @nAttr, SetFCreate() )\n\n fhnd := hb_FTempCreateEx( @cName, cDir,, cExt, nAttr )\n\n IF fhnd != F_ERROR\n FClose( fhnd )\n RETURN cName\n ENDIF\n\n RETURN \"\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour test program: tests/gtstd.prg. Provides functions: PosNow. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n#define hb_ntos( n ) LTrim( Str( n ) )\n#endif\n\nPROCEDURE Main()\n\n LOCAL n\n\n PosNow()\n ?? \"Output test. First line, no newlines.\"\n\n ? \"Press a key to continue: \"\n ?? Inkey( 0 )\n\n ? \"This is row \" + hb_ntos( Row() )\n\n @ 7, 30 SAY \"@ 7, 30\"\n @ 7, 10 SAY \"@ 7, 10\"\n @ 7, 60 SAY \"@ 7, 60\"\n @ 7, 75 SAY \"9876543210\"\n @ 6, 10 SAY \"@ 6, 10..\"\n PosNow()\n\n ?\n ? \"Scroll test: pre = \"\n PosNow()\n\n ?? \" post = \"\n PosNow()\n\n ?\n ? \"Press key to test CLS\"\n Inkey( 0 )\n CLS\n\n PosNow()\n\n ?\n ? \"Press key to test FOR n := 100 TO 120; Tone( n, 1 ); NEXT\"\n Inkey( 0 )\n FOR n := 100 TO 120\n Tone( n, 1 )\n NEXT\n\n ? \"Done..\"\n ? \"Testing long string via QOUT. 50 characters follow here: 98765432109876543210987654321098765432109876543210\"\n ? \"Done.. testing end of screen scroll\"\n\n FOR n := 1 TO 25\n ? \"This line is on row \"\n ?? hb_ntos( Row() )\n Inkey( 0 )\n NEXT\n\n RETURN\n\nFUNCTION PosNow()\n\n ?? \"[\" + hb_ntos( Row() ) + \",\" + hb_ntos( Col() ) + \"]\"\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/popadder.prg. Provides functions: ft_Adder, _ftAddScreen. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"box.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n#include \"achoice.ch\"\n\n\n#define W_BORDER 1\n#define W_ACCENT 2\n#define W_PROMPT 3\n#define W_SCREEN 4\n#define W_TITLE 5\n#define W_VARIAB 6\n#define W_CURR NIL\n\n\n#define STD_ACCENT 1\n#define STD_ERROR 2\n#define STD_PROMPT 3\n#define STD_SCREEN 4\n#define STD_TITLE 5\n#define STD_VARIABLE 6\n#define STD_BORDER 7\n\n#define FT_B_DOUBLE HB_B_DOUBLE_UNI + \" \"\n#define FT_B_SINGLE HB_B_SINGLE_UNI + \" \"\n\n\n#define nTotal aAdder[ 1 ]\n#define nNumTotal aAdder[ 2 ]\n#define nSavTotal aAdder[ 3 ]\n#define cTotPict aAdder[ 4 ]\n#define lClAdder aAdder[ 5 ]\n#define lDecSet aAdder[ 6 ]\n#define nDecDigit aAdder[ 7 ]\n#define nMaxDeci aAdder[ 8 ]\n#define lMultDiv aAdder[ 9 ]\n#define nAddMode aAdder[ 10 ]\n#define lSubRtn aAdder[ 11 ]\n#define lTotalOk aAdder[ 12 ]\n#define lAddError aAdder[ 13 ]\n#define lTape aAdder[ 14 ]\n#define lNewNum aAdder[ 15 ]\n#define nSavSubTot aAdder[ 16 ]\n#define lDivError aAdder[ 17 ]\n#define aTrans aAdder[ 18 ]\n#define nTopOS aAdder[ 19 ]\n#define nLeftOS aAdder[ 20 ]\n#define nAddSpace aAdder[ 21 ]\n#define nTapeSpace aAdder[ 22 ]\n#define cTapeScr aAdder[ 23 ]\n\n\nTHREAD STATIC t_lAdderOpen := .F.\nTHREAD STATIC t_aKeys\nTHREAD STATIC t_aWindow\nTHREAD STATIC t_nWinColor\nTHREAD STATIC t_aWinColor\nTHREAD STATIC t_aStdColor\n\n\nFUNCTION ft_Adder()\n\n LOCAL nOldDecim, cMoveTotSubTot, cTotal, lDone, nKey\n LOCAL oGet := GetActive()\n LOCAL nOldCurs := SetCursor( SC_NONE )\n LOCAL nOldRow := Row()\n LOCAL nOldCol := Col()\n LOCAL bOldF10 := SetKey( K_F10, NIL )\n LOCAL nOldLastKey := LastKey()\n LOCAL lShowRight := .T.\n LOCAL aAdder := Array( 23 )\n LOCAL tmp, tmp1\n\n LOCAL lAC_exit_ok\n\n \n IF t_lAdderOpen\n RETURN NIL\n ELSE\n t_lAdderOpen := .T.\n ENDIF\n\n aTrans := { \" 0.00 C \" }\n nOldDecim := Set( _SET_DECIMALS, 9 )\n cTotPict := \"999999999999999.99\"\n cTapeScr := \"\"\n nTotal := nNumTotal := nSavTotal := nDecDigit := 0\n lDone := .F. \n nMaxDeci := 2 \n nSavSubTot := 0\n lNewNum := .F.\n nAddMode := 1 \n lMultDiv := .F. \n lClAdder := .F. \n lDecSet := .F. \n lSubRtn := lTotalOk := lTape := lAddError := lDivError := .F.\n\n nTopOS := Int( ( MaxRow() - 24 ) / 2 ) \n nLeftOS := Int( ( MaxCol() - 79 ) / 2 ) \n nAddSpace := iif( lShowRight, 40, 0 ) + nLeftOS\n nTapeSpace := iif( lShowRight, 0, 40 ) + nLeftOS\n\n \n t_aKeys := {}\n t_aWindow := {}\n t_nWinColor := 0\n\n _ftAddScreen( aAdder )\n\n \n _ftChangeDec( aAdder, 2 )\n hb_DispOutAt( 4 + nTopOS, 7 + nAddSpace, Transform( nTotal, cTotPict ) )\n\n DO WHILE ! lDone \n nKey := _ftInkey( 0, \"nKey\" )\n DO CASE\n CASE hb_keyChar( nKey ) $ \"1234567890.\"\n _ftProcessNumb( aAdder, nKey )\n CASE nKey == hb_keyCode( \"+\" ) \n _ftAddSub( aAdder, nKey )\n CASE nKey == hb_keyCode( \"-\" ) \n _ftAddSub( aAdder, nKey )\n CASE nKey == hb_keyCode( \"*\" ) \n _ftMultDiv( aAdder, nKey )\n CASE nKey == hb_keyCode( \"/\" ) \n _ftMultDiv( aAdder, nKey )\n CASE nKey == K_ENTER \n _ftAddTotal( aAdder )\n CASE nKey == K_ESC \n Set( _SET_DECIMALS, nOldDecim )\n SetCursor( nOldCurs )\n IF lTape\n RestScreen( 4 + nTopOS, 6 + nTapeSpace, 22 + nTopOS, 35 + nTapeSpace, cTapeScr )\n ENDIF\n _ftPopWin()\n SetPos( nOldRow, nOldCol )\n _ftSetLastKey( nOldLastKey )\n SetKey( K_F10, bOldF10 )\n t_lAdderOpen := .F. \n lDone := .T.\n CASE nKey == hb_keyCode( \"D\" ) .OR. nKey == hb_keyCode( \"d\" ) \n _ftChangeDec( aAdder )\n CASE nKey == hb_keyCode( \"T\" ) .OR. nKey == hb_keyCode( \"t\" ) \n _ftDisplayTape( aAdder, nKey )\n CASE nKey == hb_keyCode( \"M\" ) .OR. nKey == hb_keyCode( \"m\" ) \n IF lTape\n RestScreen( 4 + nTopOS, 6 + nTapeSpace, 22 + nTopOS, 35 + nTapeSpace, cTapeScr )\n ENDIF\n IF !( __XSaveGetChar( SaveScreen( 6 + nTopOS, 26 + nAddSpace, 6 + nTopOS, 27 + nAddSpace ), 0 ) == \" \" )\n IF __XSaveGetChar( SaveScreen( 6 + nTopOS, 19 + nAddSpace, 6 + nTopOS, 20 + nAddSpace ), 0 ) == \"S\"\n cMoveTotSubTot := \"S\"\n ELSE\n cMoveTotSubTot := \"T\"\n ENDIF\n ELSE\n cMoveTotSubTot := \" \"\n ENDIF\n tmp := SaveScreen( 4 + nTopOS, 8 + nAddSpace, 4 + nTopOS, 25 + nAddSpace )\n cTotal := \"\"\n FOR tmp1 := 0 TO 16\n cTotal += __XSaveGetChar( tmp, tmp1 )\n NEXT\n _ftPopWin() \n lShowRight := ! lShowRight\n nAddSpace := iif( lShowRight, 40, 0 ) + nLeftOS\n nTapeSpace := iif( lShowRight, 0, 40 ) + nLeftOS\n _ftAddScreen( aAdder )\n _ftDispTotal( aAdder )\n IF lTape\n lTape := .F.\n _ftDisplayTape( aAdder, nKey )\n ENDIF\n hb_DispOutAt( 4 + nTopOS, 8 + nAddSpace, cTotal )\n IF ! Empty( cMoveTotSubTot )\n _ftSetWinColor( W_CURR, W_SCREEN )\n hb_DispOutAt( 6 + nTopOS, 18 + nAddSpace, iif( cMoveTotSubTot == \"T\", \" \", ;\n \"\" ) )\n _ftSetWinColor( W_CURR, W_PROMPT )\n ENDIF\n CASE ( nKey == hb_keyCode( \"S\" ) .OR. nKey == hb_keyCode( \"s\" ) ) .AND. lTape \n IF Len( aTrans ) > 16 \n SetColor( \"GR+/W\" )\n hb_DispOutAt( 21 + nTopOS, 8 + nTapeSpace, \" \" + Chr( 24 ) + Chr( 25 ) + \"-SCROLL -QUIT \" )\n SetColor( \"N/W,W+/N\" )\n lAC_exit_ok := .F.\n AChoice( 5 + nTopOS, 7 + nTapeSpace, 20 + nTopOS, 32 + nTapeSpace, aTrans, .T., ;\n {| nMode, cur_elem, rel_pos | _ftAdderTapeUDF( nMode, cur_elem, rel_pos, @lAC_exit_ok ) }, Len( aTrans ), 20 )\n SetColor( \"R+/W\" )\n hb_DispBox( 21 + nTopOS, 8 + nTapeSpace, 21 + nTopOS, 30 + nTapeSpace, HB_B_SINGLE_UNI )\n _ftSetWinColor( W_CURR, W_PROMPT )\n CLEAR TYPEAHEAD\n ELSE\n _ftError( \"there are \" + iif( Len( aTrans ) > 0, \"only \" + ;\n hb_ntos( Len( aTrans ) ), \"no\" ) + ;\n \" transactions entered so far.\" + ;\n \" No need to scroll!\" )\n ENDIF\n CASE nKey == K_DEL \n _ftClearAdder( aAdder )\n CASE nKey == K_F1 \n _ftAddHelp()\n CASE nKey == K_F10 \n IF lTotalOk \n IF oGet != NIL .AND. oGet:type == \"N\"\n Set( _SET_DECIMALS, nOldDecim )\n SetCursor( nOldCurs )\n IF lTape\n RestScreen( 4 + nTopOS, 6 + nTapeSpace, 22 + nTopOS, 35 + nTapeSpace, cTapeScr )\n ENDIF\n _ftPopWin()\n SetPos( nOldRow, nOldCol )\n _ftSetLastKey( nOldLastKey )\n SetKey( K_F10, bOldF10 )\n oGet:VARPUT( nSavTotal )\n t_lAdderOpen := .F. \n lDone := .T.\n ELSE\n _ftError( \"but I can not return the total from the \" + ;\n \"adder to this variable. You must quit the adder using\" + ;\n \" the key and then enter the total manually.\" )\n ENDIF\n ELSE\n _ftError( \"the calculation is not finished yet! You must have\" + ;\n \" a TOTAL before you can return it to the program.\" )\n ENDIF\n ENDCASE\n ENDDO\n\n \n t_aKeys := t_aWindow := t_aWinColor := t_aStdColor := NIL\n\n RETURN NIL\n\n\nSTATIC FUNCTION _ftAddScreen( aAdder )\n\n LOCAL nCol\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/commouse.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbcom.ch\"\n\nPROCEDURE Main( cParam )\n\n LOCAL nPort, cBuf, cBuffer, nLen, nType, lL, lM, lR, nX, nY\n\n IF cParam == NIL\n ? \"Usage: commouse [ nPort | cDevice ]\"\n RETURN\n ENDIF\n\n nPort := Val( cParam )\n IF nPort == 0\n ? \"Using device:\", cParam\n nPort := 1\n hb_comSetDevice( nPort, cParam )\n ELSE\n ? \"Using port number:\", nPort\n ENDIF\n\n IF ! hb_comOpen( nPort )\n ? \"Unable to open port. Error:\", hb_comGetError( nPort ), \" OS error:\", hb_comGetOSError( nPort )\n RETURN\n ENDIF\n\n IF ! hb_comInit( nPort, 1200, \"N\", 8, 1 )\n ? \"Unable to initialize port. Error:\", hb_comGetError( nPort ), \" OS error:\", hb_comGetOSError( nPort )\n hb_comClose( nPort )\n RETURN\n ENDIF\n\n hb_comMCR( nPort, , HB_COM_MCR_DTR + HB_COM_MCR_RTS )\n hb_idleSleep( 0.1 )\n hb_comFlush( nPort )\n hb_comMCR( nPort, , , HB_COM_MCR_DTR + HB_COM_MCR_RTS )\n\n cBuf := Space( 256 )\n IF ( nLen := hb_comRecv( nPort, @cBuf,, 500 ) ) > 0\n IF hb_BCode( cBuf ) == 0xCD\n ? \"Bingo: 2 button mouse detected!\"\n nType := 2\n cBuffer := hb_BSubStr( cBuf, 2, nLen - 1 )\n ELSE\n cBuffer := hb_BLeft( cBuf, nLen )\n ENDIF\n ELSE\n cBuffer := \"\"\n ENDIF\n\n IF nType == NIL\n ? \"Mouse not detected, assuming 3 button mouse\"\n nType := 3\n ENDIF\n\n ? \"Press any key to exit...\"\n DO WHILE ( nLen := Inkey() ) == 0\n IF ( nLen := hb_comRecv( nPort, @cBuf ) ) > 0\n cBuffer += hb_BLeft( cBuf, nLen )\n ENDIF\n IF hb_BLen( cBuffer ) == 0\n hb_idleSleep( 0.05 )\n LOOP\n ENDIF\n IF nType == 2\n IF hb_bitAnd( hb_BCode( cBuffer ), 0xC0 ) != 0xC0\n cBuffer := hb_BSubStr( cBuffer, 2 )\n ELSEIF hb_BLen( cBuffer ) >= 3\n lR := hb_bitAnd( hb_BCode( cBuffer ), 0x10 ) != 0\n lL := hb_bitAnd( hb_BCode( cBuffer ), 0x20 ) != 0\n nX := hb_bitAnd( hb_BCode( cBuffer ), 3 )\n ? \"dX,dY:\", Str( nX, 4 ), Str( nY, 4 ), \" \"\n IF lL\n ?? \"LEFT \"\n ENDIF\n IF lR\n ?? \"RIGHT\"\n ENDIF\n cBuffer := hb_BSubStr( cBuffer, 4 )\n ENDIF\n ELSEIF nType == 3\n IF hb_bitAnd( hb_BCode( cBuffer ), 0xC0 ) != 0x80\n cBuffer := hb_BSubStr( cBuffer, 2 )\n ELSEIF hb_BLen( cBuffer ) >= 4\n lR := hb_bitAnd( hb_BCode( cBuffer ), 1 ) == 0\n lM := hb_bitAnd( hb_BCode( cBuffer ), 2 ) == 0\n lL := hb_bitAnd( hb_BCode( cBuffer ), 4 ) == 0\n nI := hb_BCode( hb_BSubStr( cBuffer, 2 ) )\n IF nI > 127\n nI -= 256\n ENDIF\n nX := nI\n nI := hb_BCode( hb_BSubStr( cBuffer, 4 ) )\n IF nI > 127\n nI -= 256\n ENDIF\n nX += nI\n nI := hb_BCode( hb_BSubStr( cBuffer, 3 ) )\n IF nI > 127\n nI -= 256\n ENDIF\n nY := - nI\n nI := hb_BCode( hb_BSubStr( cBuffer, 5 ) )\n IF nI > 127\n nI -= 256\n ENDIF\n nY -= nI\n ? \"dX,dY:\", Str( nX, 4 ), Str( nY, 4 ), \" \"\n IF lL\n ?? \"LEFT \"\n ENDIF\n IF lM\n ?? \"MIDDLE \"\n ENDIF\n IF lR\n ?? \"RIGHT\"\n ENDIF\n cBuffer := hb_BSubStr( cBuffer, 5 )\n ENDIF\n\n ENDIF\n ENDDO\n hb_comClose( nPort )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'gtwvg' (): contrib/gtwvg/toolbar.prg. Defines classes: WvgToolBar, WvgToolBarButton. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nCREATE CLASS WvgToolBar INHERIT WvgWindow \n\n VAR appearance\n VAR style INIT WVGTOOLBAR_STYLE_STANDARD\n VAR allowCustomize INIT .T.\n VAR enabled INIT .T.\n VAR showToolTips INIT .T.\n VAR borderStyle INIT WVGFRAME_NONE\n VAR wrappable INIT .T.\n VAR buttonWidth INIT 0\n VAR buttonHeight INIT 0\n VAR textAlign INIT WVGALIGN_BOTTOM\n VAR imageWidth INIT 0\n VAR imageHeight INIT 0\n VAR transparentColor INIT 0\n\n VAR aItems INIT {}\n VAR hImageList\n VAR lSized INIT .F.\n\n VAR sl_change\n VAR sl_buttonMenuClick\n VAR sl_buttonDropDown\n\n METHOD numItems() INLINE Len( ::aItems )\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD handleEvent( nMessage, aNM )\n METHOD destroy()\n METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD sendToolbarMessage( nMsg, p1, p2 )\n METHOD addItem( cCaption, xImage, xDisabledImage, xHotImage, cDLL, nStyle, cKey, nMapRGB )\n METHOD delItem()\n\n METHOD getItem()\n METHOD clear()\n METHOD customize()\n METHOD loadImageSet()\n METHOD saveToolbar()\n METHOD restToolbar()\n METHOD setPosAndSize()\n METHOD setSize()\n\n METHOD buttonClick( xParam ) SETGET\n METHOD change( xParam ) SETGET\n METHOD buttonMenuClick( xParam ) SETGET\n METHOD buttonDropDown( xParam ) SETGET\n\nENDCLASS\n\nMETHOD WvgToolBar:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::WvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n\n ::exStyle := TBSTYLE_EX_DOUBLEBUFFER + TBSTYLE_EX_MIXEDBUTTONS\n ::className := TOOLBARCLASSNAME\n ::objType := objTypeToolBar\n\n RETURN Self\n\nMETHOD WvgToolBar:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n IF ::style == WVGTOOLBAR_STYLE_FLAT\n ::style := TBSTYLE_FLAT\n ELSEIF ::style == WVGTOOLBAR_STYLE_VERTICAL\n ::style := CCS_VERT\n ELSE\n ::style := 0\n ENDIF\n ::style += WS_CHILD\n\n IF ::wrappable\n ::style += TBSTYLE_WRAPABLE\n ENDIF\n IF ::showToolTips\n ::style += TBSTYLE_TOOLTIPS\n ENDIF\n IF ::borderStyle == WVGFRAME_RECT\n ::style += WS_BORDER\n ENDIF\n\n ::oParent:AddChild( Self )\n\n ::createControl()\n\n\n IF ! Empty( ::hWnd )\n ::SendToolbarMessage( TB_BUTTONSTRUCTSIZE )\n ::hImageList := wapi_ImageList_Create( ::imageWidth, ::imageHeight, ILC_COLOR32 + ILC_MASK, 0, 1 )\n ::SendToolbarMessage( TB_SETIMAGELIST, ::hImageList )\n\n ::SendToolbarMessage( TB_BUTTONSTRUCTSIZE )\n ENDIF\n\n IF ::visible\n ::show()\n ENDIF\n\n RETURN Self\n\nMETHOD WvgToolBar:handleEvent( nMessage, aNM )\n\n LOCAL nObj, aNMMouse\n\n SWITCH nMessage\n\n CASE HB_GTE_RESIZED\n IF ::isParentCrt()\n ::rePosition()\n ENDIF\n ::sendMessage( WM_SIZE, 0, 0 )\n RETURN EVENT_HANDELLED\n\n CASE HB_GTE_COMMAND\n EXIT\n\n CASE HB_GTE_NOTIFY\n aNMMouse := wvg_GetNMMouseInfo( aNM[ 2 ] )\n\n DO CASE\n\n CASE aNMMouse[ NMH_code ] == NM_CLICK\n IF ( nObj := AScan( ::aItems, {| e_ | e_[ 1 ] == aNMMouse[ NMH_dwItemSpec ] } ) ) > 0\n IF HB_ISBLOCK( ::sl_lbClick )\n IF ::isParentCrt()\n ::oParent:setFocus()\n ENDIF\n Eval( ::sl_lbClick, ::aItems[ nObj ][ 2 ], , Self )\n\n ENDIF\n ENDIF\n RETURN EVENT_HANDELLED\n\n OTHERWISE\n RETURN EVENT_UNHANDELLED\n\n ENDCASE\n\n EXIT\n ENDSWITCH\n\n RETURN EVENT_UNHANDELLED\n\nMETHOD PROCEDURE WvgToolBar:destroy()\n\n LOCAL i, nItems\n\n IF ( nItems := Len( ::aItems ) ) > 0\n FOR i := 1 TO nItems\n IF ::aItems[ i, 2 ]:image != NIL\n wvg_DeleteObject( ::aItems[ i, 2 ]:image )\n ENDIF\n IF ::aItems[ i, 2 ]:disabledImage != NIL\n wvg_DeleteObject( ::aItems[ i, 2 ]:disabledImage )\n ENDIF\n IF ::aItems[ i, 2 ]:hotImage != NIL\n wvg_DeleteObject( ::aItems[ i, 2 ]:hotImage )\n ENDIF\n NEXT\n ENDIF\n\n IF ! Empty( ::hImageList )\n wapi_ImageList_Destroy( ::hImageList )\n ENDIF\n\n ::wvgWindow:destroy()\n\n RETURN\n\nMETHOD WvgToolBar:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n RETURN Self\n\nMETHOD WvgToolBar:sendToolbarMessage( nMsg, p1, p2 )\n RETURN wvg_SendToolBarMessage( ::pWnd, nMsg, p1, p2 )\n\nMETHOD WvgToolBar:addItem( cCaption, xImage, xDisabledImage, xHotImage, cDLL, nStyle, cKey, nMapRGB )\n\n LOCAL oBtn, pBitmap, nBtn\n\n HB_SYMBOL_UNUSED( xDisabledImage )\n HB_SYMBOL_UNUSED( xHotImage )\n HB_SYMBOL_UNUSED( cDLL )\n\n \n IF ! ::lSized\n ::lSized := .T.\n ENDIF\n\n oBtn := WvgToolBarButton():new( cCaption, nStyle, cKey )\n\n oBtn:index := ::numItems + 1\n oBtn:command := 100 + oBtn:index\n\n SWITCH ValType( xImage )\n CASE \"C\"\n IF \".\" $ xImage .OR. ;\n \"/\" $ xImage .OR. ;\n \"\\\" $ xImage .OR. ;\n \":\" $ xImage .OR. ;\n hb_FileExists( xImage )\n pBitmap := wvg_PrepareBitmapFromFile( xImage, ::imageWidth, ::imageHeight, .T., ::hWnd )\n ELSE\n pBitmap := wvg_PrepareBitmapFromResourceName( xImage, ::imageWidth, ::imageHeight, .T., ::hWnd )\n ENDIF\n EXIT\n\n CASE \"N\"\n pBitmap := wvg_PrepareBitmapFromResourceId( xImage, ::imageWidth, ::imageHeight, .T., ::hWnd )\n EXIT\n\n CASE \"P\"\n pBitmap := xImage\n EXIT\n\n ENDSWITCH\n\n IF ! Empty( pBitmap )\n \n\n IF HB_ISNUMERIC( nMapRGB )\n nBtn := wapi_ImageList_AddMasked( ::hImageList, pBitmap, nMapRGB )\n ELSE\n nBtn := wapi_ImageList_Add( ::hImageList, pBitmap )\n ENDIF\n IF ! HB_ISPOINTER( xImage )\n wvg_DeleteObject( pBitmap )\n ENDIF\n\n wvg_AddToolBarButton( ::pWnd, nBtn, oBtn:caption, oBtn:command, 1, ::showToolTips )\n\n \n ::SendToolbarMessage( TB_SETBUTTONSIZE, ::buttonWidth, ::buttonHeight )\n\n ::sendToolbarMessage( TB_AUTOSIZE )\n ELSE\n wvg_AddToolBarButton( ::pWnd, , , oBtn:command, 3, .F. )\n\n ENDIF\n\n AAdd( ::aItems, { oBtn:command, oBtn } )\n\n RETURN oBtn\n\nMETHOD WvgToolBar:delItem()\n RETURN Self\n\nMETHOD WvgToolBar:getItem()\n RETURN Self\n\nMETHOD WvgToolBar:clear()\n RETURN Self\n\nMETHOD WvgToolBar:customize()\n RETURN Self\n\nMETHOD WvgToolBar:loadImageSet()\n RETURN Self\n\nMETHOD WvgToolBar:saveToolbar()\n RETURN Self\n\nMETHOD WvgToolBar:restToolbar()\n RETURN Self\n\nMETHOD WvgToolBar:setPosAndSize()\n RETURN Self\n\nMETHOD WvgToolBar:setSize()\n\n ::sendMessage( TB_AUTOSIZE, 0, 0 )\n\n RETURN Self\n\nMETHOD WvgToolBar:buttonClick( xParam )\n\n IF HB_ISBLOCK( xParam ) .OR. HB_ISNIL( xParam )\n ::sl_lbClick := xParam\n ENDIF\n\n RETURN Self\n\nMETHOD WvgToolBar:change( xParam )\n\n IF HB_ISBLOCK( xParam ) .OR. HB_ISNIL( xParam )\n ::sl_change := xParam\n ENDIF\n\n RETURN Self\n\nMETHOD WvgToolBar:buttonMenuClick( xParam )\n\n IF HB_ISBLOCK( xParam ) .OR. HB_ISNIL( xParam )\n ::sl_buttonMenuClick := xParam\n ENDIF\n\n RETURN Self\n\nMETHOD WvgToolBar:buttonDropDown( xParam )\n\n IF HB_ISBLOCK( xParam ) .OR. HB_ISNIL( xParam )\n ::sl_buttonDropDown := xParam\n ENDIF\n\n RETURN Self\n\n\nCREATE CLASS WvgToolBarButton\n\n VAR enabled INIT .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charone.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CharOne()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharOne( \"112333a123\" ) == \"123a123\"? --> \"' + CharOne( \"112333a123\" ) + '\"'\n ? ' CharOne( \"122333a123\" ) == \"123a123\"? --> \"' + CharOne( \"122333a123\" ) + '\"'\n ? ' CharOne( \"A B CCCD\" ) == \"A B CD\"? ---> \"' + CharOne( \"A B CCCD\" ) + '\"'\n ? ' CharOne( \" \", \"A B A B\" ) == \"A B A B\"? --> \"' + CharOne( \" \", \"A B A B\" ) + '\"'\n ? ' CharOne( \"o\", \"122oooB12o\" ) == \"122oB12o\"? -> \"' + CharOne( \"o\", \"122oooB12o\" ) + '\"'\n ?\n\n ? \"End test of CharOne()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/ntx.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n#include \"clipper.ch\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL i := 0\n FIELD Last, First\n\n USE test\n INDEX ON Left( Last, 8 ) + Left( First, 8 ) TO test1\n INDEX ON Left( Last, 8 ) TO test2\n INDEX ON Last TO test3\n SET INDEX TO test1, test2, test3\n\n SET ORDER TO 1\n ? IndexKey()\n Inkey( 0 )\n GO TOP\n DO WHILE ! Eof()\n ? ++i, Last, First\n SKIP\n ENDDO\n\n ? \"------------\"\n Inkey( 0 )\n SKIP -1\n\n DO WHILE ! Bof()\n ? i-- , Last, First\n SKIP -1\n ENDDO\n\n i := 0\n SET ORDER TO 2\n ? IndexKey()\n Inkey( 0 )\n GO TOP\n DO WHILE ! Eof()\n ? ++i, Last, First\n SKIP\n ENDDO\n\n ? \"------------\"\n Inkey( 0 )\n SKIP -1\n\n DO WHILE ! Bof()\n ? i-- , Last, First\n SKIP -1\n ENDDO\n\n i := 0\n SET ORDER TO 3\n ? IndexKey()\n Inkey( 0 )\n GO TOP\n DO WHILE ! Eof()\n ? ++i, Last, First\n SKIP\n ENDDO\n\n ? \"------------\"\n Inkey( 0 )\n SKIP -1\n\n DO WHILE ! Bof()\n ? i-- , Last, First\n SKIP -1\n ENDDO\n\n USE\n\n hb_dbDrop( \"test1.ntx\" )\n hb_dbDrop( \"test2.ntx\" )\n hb_dbDrop( \"test3.ntx\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: ArrayToText. Harbour Runtime Library file: src/rtl/tpersist.prg. Defines classes: HBPersistent. Provides functions: ArrayToText. This file implements object-oriented classes using Harbour's class system"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nREQUEST Array\n\n#define _INDENT 3\n\nCREATE CLASS HBPersistent\n\n METHOD CreateNew() INLINE Self\n METHOD LoadFromFile( cFileName, lIgnoreErrors ) INLINE ::LoadFromText( hb_MemoRead( cFileName ), lIgnoreErrors )\n METHOD LoadFromText( cObjectText, lIgnoreErrors )\n METHOD SaveToText( cObjectName, nIndent )\n METHOD SaveToFile( cFileName ) INLINE hb_MemoWrit( cFileName, ::SaveToText() )\n\nENDCLASS\n\nMETHOD LoadFromText( cObjectText, lIgnoreErrors ) CLASS HBPersistent\n\n LOCAL nPos\n LOCAL cLine\n LOCAL cProp\n LOCAL cInd\n LOCAL uValue\n LOCAL aWords\n LOCAL lStart := .T.\n LOCAL aObjects := { Self }\n LOCAL bError\n\n IF Empty( cObjectText )\n RETURN .F.\n ENDIF\n\n bError := iif( hb_defaultValue( lIgnoreErrors, .F. ), ;\n {| e | Break( e ) }, ErrorBlock() )\n\n FOR EACH cLine IN hb_ATokens( StrTran( cObjectText, Chr( 13 ) ), Chr( 10 ) )\n\n cLine := AllTrim( cLine )\n\n BEGIN SEQUENCE WITH bError\n\n cProp := NIL\n\n IF Empty( cLine ) .OR. hb_LeftEq( cLine, \"\n \n ELSEIF hb_LeftEq( cLine, \"::\" )\n\n IF ( nPos := At( \":=\", cLine ) ) > 0\n cProp := RTrim( SubStr( cLine, 3, nPos - 3 ) )\n uValue := &( LTrim( SubStr( cLine, nPos + 2 ) ) )\n ELSEIF ( nPos := At( \"=\", cLine ) ) > 0 \n cProp := RTrim( SubStr( cLine, 3, nPos - 3 ) )\n uValue := &( LTrim( SubStr( cLine, nPos + 1 ) ) )\n ENDIF\n ELSE\n aWords := hb_ATokens( hb_asciiUpper( cLine ) )\n SWITCH aWords[ 1 ]\n CASE \"OBJECT\"\n IF lStart\n lStart := .F.\n ELSEIF aWords[ Len( aWords ) - 1 ] == \"AS\" .AND. hb_LeftEq( aWords[ 2 ], \"::\" )\n cProp := SubStr( AllTrim( SubStr( cLine, 7, RAt( \" AS \", cLine ) - 7 ) ), 3 )\n uValue := &( aTail( aWords ) )():CreateNew()\n ENDIF\n EXIT\n CASE \"ENDOBJECT\"\n ASize( aObjects, Len( aObjects ) - 1 )\n EXIT\n CASE \"ARRAY\"\n IF hb_LeftEq( aWords[ 2 ], \"::\" )\n cProp := SubStr( AllTrim( SubStr( cLine, 6, RAt( \" LEN \", cLine ) - 6 ) ), 3 )\n uValue := Array( Val( ATail( aWords ) ) )\n ENDIF\n EXIT\n ENDSWITCH\n ENDIF\n\n IF ! Empty( cProp )\n IF ( nPos := At( \"[\", cProp ) ) > 0\n cInd := hb_StrReplace( SubStr( cProp, nPos + 1, Len( cProp ) - nPos - 1 ), ;\n { \" \" => \"\", \"][\" => \",\" } )\n cProp := Left( cProp, nPos - 1 )\n ATail( aObjects ):&cProp[ &cInd ] := uValue\n ELSE\n ATail( aObjects ):&cProp := uValue\n ENDIF\n ENDIF\n\n END SEQUENCE\n\n IF Empty( aObjects )\n EXIT\n ENDIF\n NEXT\n\n RETURN .T.\n\nMETHOD SaveToText( cObjectName, nIndent ) CLASS HBPersistent\n\n LOCAL oNew := &( ::ClassName() + \"()\" ):CreateNew()\n LOCAL cProp\n LOCAL uValue\n LOCAL uNewValue\n LOCAL cObject\n LOCAL cType\n LOCAL lSpacer := .T.\n\n IF ! HB_ISSTRING( cObjectName )\n cObjectName := \"o\" + ::ClassName()\n ENDIF\n\n IF HB_ISNUMERIC( nIndent )\n nIndent += _INDENT\n ELSE\n nIndent := 0\n ENDIF\n\n cObject := iif( nIndent > 0, hb_eol(), \"\" ) + Space( nIndent ) + ;\n \"OBJECT \" + iif( nIndent != 0, \"::\", \"\" ) + cObjectName + \" AS \" + ;\n ::ClassName() + hb_eol()\n\n FOR EACH cProp IN __clsGetProperties( ::ClassH )\n\n uValue := Self:&cProp\n uNewValue := oNew:&cProp\n\n IF !( ( cType := ValType( uValue ) ) == ValType( uNewValue ) ) .OR. ;\n !( uValue == uNewValue )\n\n SWITCH cType\n CASE \"A\"\n cObject += ArrayToText( uValue, cProp, nIndent + _INDENT )\n lSpacer := .T.\n EXIT\n\n CASE \"O\"\n IF __objDerivedFrom( uValue, \"HBPersistent\" )\n cObject += uValue:SaveToText( cProp, nIndent )\n lSpacer := .T.\n ENDIF\n EXIT\n\n CASE \"B\"\n CASE \"P\"\n \n EXIT\n\n OTHERWISE\n IF lSpacer\n lSpacer := .F.\n cObject += hb_eol()\n ENDIF\n cObject += Space( nIndent + _INDENT ) + \"::\" + ;\n cProp + \" := \" + hb_ValToExp( uValue ) + ;\n hb_eol()\n ENDSWITCH\n\n ENDIF\n\n NEXT\n\n cObject += hb_eol() + Space( nIndent ) + \"ENDOBJECT\" + hb_eol()\n\n RETURN cObject\n\nSTATIC FUNCTION ArrayToText( aArray, cName, nIndent )\n\n LOCAL cArray := hb_eol() + Space( nIndent ) + \"ARRAY ::\" + cName + ;\n \" LEN \" + hb_ntos( Len( aArray ) ) + hb_eol()\n LOCAL uValue\n\n FOR EACH uValue IN aArray\n\n SWITCH ValType( uValue )\n CASE \"A\"\n cArray += ArrayToText( uValue, cName + ;\n \"[ \" + hb_ntos( uValue:__enumIndex() ) + \" ]\", ;\n nIndent + _INDENT ) + hb_eol()\n EXIT\n\n CASE \"O\"\n IF __objDerivedFrom( uValue, \"HBPersistent\" )\n cArray += uValue:SaveToText( cName + ;\n \"[ \" + hb_ntos( uValue:__enumIndex() ) + \" ]\", nIndent )\n ENDIF\n EXIT\n\n CASE \"B\"\n CASE \"P\"\n \n EXIT\n\n OTHERWISE\n IF uValue:__enumIsFirst()\n cArray += hb_eol()\n ENDIF\n cArray += Space( nIndent + _INDENT ) + \"::\" + cName + ;\n \"[ \" + hb_ntos( uValue:__enumIndex() ) + \" ] := \" + ;\n hb_ValToExp( uValue ) + hb_eol()\n ENDSWITCH\n NEXT\n\n cArray += hb_eol() + Space( nIndent ) + \"ENDARRAY\" + hb_eol()\n\n RETURN cArray"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/asciisum.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of AsciiSum()\"\n ?\n\n ? ' AsciiSum( Replicate( \"A\", 10000 ) ) == 650000 ? --> ' + Str( AsciiSum( Replicate( \"A\", 10000 ) ) )\n ? ' AsciiSum( \"0123456789\" ) == 525 ? --> ' + Str( AsciiSum( \"0123456789\" ) )\n ? ' AsciiSum( NIL ) == 0 ? --> ' + Str( AsciiSum( NIL ) )\n\n ?\n ? \"End test of AsciiSum()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'gtwvg' (): contrib/gtwvg/menubar.prg. Defines classes: WvgMenuBar. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nCREATE CLASS WvgMenuBar INHERIT wvgWindow\n\n CLASS VAR nMenuItemID INIT 0\n\n VAR hMenu\n VAR pMenu\n\n \n VAR sl_beginMenu\n VAR sl_endMenu\n VAR sl_itemMarked\n VAR sl_itemSelected\n VAR sl_drawItem\n VAR sl_measureItem\n VAR sl_onMenuKey\n\n VAR aMenuItems INIT {}\n\n VAR nPass INIT 0\n\n VAR caption INIT \"\"\n VAR nItemID INIT 0\n VAR aIds INIT {}\n\n VAR className INIT \"MENUBAR\"\n\n METHOD numItems() INLINE Len( ::aMenuItems )\n\n METHOD new( oParent, aPresParams, lVisible )\n METHOD create( oParent, aPresParams, lVisible )\n METHOD configure( oParent, aPresParams, lVisible )\n METHOD destroy()\n METHOD delAllItems()\n METHOD delItem( nItemNum )\n METHOD addItem( aItem, p2, p3, p4 )\n METHOD findMenuItemById( nId )\n METHOD findMenuPosById( nId )\n METHOD checkItem( nItemNum, lCheck )\n METHOD enableItem( nItemNum )\n METHOD disableItem( nItemNum )\n\n METHOD getItem( nItemNum )\n METHOD insItem( nItemNum, aItem )\n METHOD isItemChecked( nItemNum )\n METHOD isItemEnabled( nItemNum )\n METHOD selectItem( nItemNum )\n METHOD setItem( nItemNum, aItem )\n\n \n METHOD beginMenu( xParam ) SETGET\n METHOD endMenu( xParam ) SETGET\n METHOD itemMarked( xParam ) SETGET\n METHOD itemSelected( xParam ) SETGET\n METHOD drawItem( xParam ) SETGET\n METHOD measureItem( xParam ) SETGET\n METHOD onMenuKey( xParam ) SETGET\n\n PROTECTED:\n METHOD putItem( aItem, nPos, lInsert )\n\nENDCLASS\n\nMETHOD WvgMenuBar:new( oParent, aPresParams, lVisible )\n\n __defaultNIL( @oParent, ::oParent )\n __defaultNIL( @aPresParams, ::aPresParams )\n __defaultNIL( @lVisible, ::visible )\n\n ::oParent := oParent\n ::aPresParams := aPresParams\n ::visible := lVisible\n\n ::wvgWindow:new( ::oParent, , , , ::aPresParams, ::visible )\n\n RETURN Self\n\nMETHOD WvgMenuBar:create( oParent, aPresParams, lVisible )\n\n __defaultNIL( @oParent, ::oParent )\n __defaultNIL( @aPresParams, ::aPresParams )\n __defaultNIL( @lVisible, ::visible )\n\n ::oParent := oParent\n ::aPresParams := aPresParams\n ::visible := lVisible\n\n ::wvgWindow:create( ::oParent, , , , ::aPresParams, ::visible )\n\n ::hMenu := wvg_CreateMenu()\n\n IF ::hMenu != 0\n \n \n ::oParent:oMenu := Self\n\n ::pMenu := win_N2P( ::hMenu )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgMenuBar:configure( oParent, aPresParams, lVisible )\n\n __defaultNIL( @oParent, ::oParent )\n __defaultNIL( @aPresParams, ::aPresParams )\n __defaultNIL( @lVisible, ::visible )\n\n ::oParent := oParent\n ::aPresParams := aPresParams\n ::visible := lVisible\n\n RETURN Self\n\nMETHOD WvgMenuBar:destroy()\n\n IF ! Empty( ::hMenu )\n ::DelAllItems()\n\n IF ! wvg_DestroyMenu( ::hMenu )\n ENDIF\n\n ::hMenu := 0\n ENDIF\n\n RETURN .T.\n\nMETHOD WvgMenuBar:delAllItems()\n\n LOCAL lResult := .T., nItems\n\n nItems := ::numItems()\n DO WHILE nItems > 0 .AND. lResult\n lResult := ::DelItem( nItems )\n nItems--\n ENDDO\n\n RETURN lResult\n\nMETHOD WvgMenuBar:delItem( nItemNum )\n\n LOCAL lResult := .F.\n\n IF nItemNum > 0 .AND. nItemNum <= ::numItems()\n IF ::aMenuItems[ nItemNum ][ WVT_MENU_TYPE ] == MF_POPUP\n ::aMenuItems[ nItemNum ][ WVT_MENU_MENUOBJ ]:Destroy()\n ENDIF\n\n IF ( lResult := wvg_DeleteMenu( ::hMenu, nItemNum - 1, MF_BYPOSITION ) ) \n hb_ADel( ::aMenuItems, nItemNum, .T. )\n ELSE\n ENDIF\n ENDIF\n\n RETURN lResult\n\n\nMETHOD WvgMenuBar:addItem( aItem, p2, p3, p4 )\n\n LOCAL xCaption, bAction, nStyle, nAttrib\n\n IF PCount() == 1 .AND. HB_ISARRAY( aItem )\n ASize( aItem, 4 )\n xCaption := aItem[ 1 ]\n bAction := aItem[ 2 ]\n nStyle := aItem[ 3 ]\n nAttrib := aItem[ 4 ]\n ELSE\n xCaption := aItem\n bAction := p2\n nStyle := p3\n nAttrib := p4\n ENDIF\n\n RETURN ::putItem( { xCaption, bAction, nStyle, nAttrib }, -1, .T. )\n\nMETHOD WvgMenuBar:putItem( aItem, nPos, lInsert )\n\n LOCAL nItemIndex, cCaption\n LOCAL xCaption, bAction, nStyle, nAttrib\n\n __defaultNIL( @lInsert, .T. )\n\n ASize( aItem, 4 )\n\n xCaption := aItem[ 1 ]\n bAction := aItem[ 2 ]\n nStyle := aItem[ 3 ]\n nAttrib := aItem[ 4 ]\n\n \n SWITCH ValType( xCaption )\n CASE \"U\" \n aItem := { MF_SEPARATOR, 0, 0, , nStyle, nAttrib }\n EXIT\n\n CASE \"C\"\n IF Left( xCaption, 1 ) == \"-\"\n aItem := { MF_SEPARATOR, 0, 0, , nStyle, nAttrib }\n ELSE\n aItem := { MF_STRING, ++::nMenuItemID, xCaption, bAction, nStyle, nAttrib }\n ENDIF\n EXIT\n\n CASE \"O\"\n cCaption := iif( bAction == NIL, xCaption:title, bAction )\n aItem := { MF_POPUP, xCaption:hMenu, cCaption, xCaption, nStyle, nAttrib }\n EXIT\n\n CASE \"N\" \n EXIT\n\n ENDSWITCH\n\n IF nPos <= 0\n AAdd( ::aMenuItems, aItem )\n nItemIndex := Len( ::aMenuItems )\n wvg_AppendMenu( ::hMenu, ;\n aItem[ 1 ], ;\n aItem[ 2 ], ;\n iif( HB_ISSTRING( aItem[ 3 ] ), StrTran( aItem[ 3 ], \"~\", \"&\" ), aItem[ 3 ] ) )\n ELSE\n nItemIndex := nPos\n IF lInsert\n ::aMenuItems := hb_AIns( ::aMenuItems, nPos, aItem, .T. )\n wvg_InsertMenu( ::hMenu, ;\n nItemIndex - 1, ;\n aItem[ 1 ] + MF_BYPOSITION, ;\n aItem[ 2 ], ;\n iif( HB_ISSTRING( aItem[ 3 ] ), StrTran( aItem[ 3 ], \"~\", \"&\" ), aItem[ 3 ] ) )\n ELSE\n IF HB_ISSTRING( xCaption )\n aItem[ 2 ] := ::aMenuItems[ nItemIndex ][ 2 ]\n ENDIF\n ::aMenuItems[ nItemIndex ] := aItem\n wvg_SetMenuItem( ::hMenu, ;\n nItemIndex - 1, ;\n aItem[ 2 ], ;\n iif( HB_ISSTRING( aItem[ 3 ] ), StrTran( aItem[ 3 ], \"~\", \"&\" ), aItem[ 3 ] ), ;\n HB_ISSTRING( xCaption ) )\n ENDIF\n ENDIF\n\n IF ++::nPass == 1\n IF ::oParent:className() $ \"WVGCRT,WVGDIALOG\"\n wvg_SetMenu( ::oParent:getHWND(), ::hMenu )\n ENDIF\n ELSE\n IF ::oParent:className() $ \"WVGCRT,WVGDIALOG\"\n wvg_DrawMenuBar( ::oParent:getHWND() )\n ENDIF\n ENDIF\n\n RETURN nItemIndex\n\nMETHOD WvgMenuBar:findMenuItemById( nId )\n\n LOCAL x, aResult := {}\n\n IF ! Empty( nId )\n x := ::numItems()\n\n DO WHILE x > 0 .AND. Empty( aResult )\n IF ::aMenuItems[ x ][ WVT_MENU_TYPE ] == MF_POPUP\n aResult := ::aMenuItems[ x ][ WVT_MENU_MENUOBJ ]:findMenuItemById( nId )\n\n ELSEIF ::aMenuItems[ x ][ WVT_MENU_IDENTIFIER ] == nId\n aResult := { x, ::aMenuItems[ x ][ WVT_MENU_ACTION ], ::sl_itemSelected, Self }\n\n ENDIF\n x--\n ENDDO\n ENDIF\n\n RETURN aResult\n\nMETHOD WvgMenuBar:findMenuPosById( nId )\n\n LOCAL x, nPos\n\n IF ! Empty( nId )\n x := ::numItems()\n\n DO WHILE x > 0 .AND. Empty( nPos )\n IF ::aMenuItems[ x ][ WVT_MENU_TYPE ] == MF_POPUP\n nPos := ::aMenuItems[ x ][ WVT_MENU_MENUOBJ ]:findMenuPosById( nId )\n\n ELSEIF ::aMenuItems[ x ][ WVT_MENU_IDENTIFIER ] == nId\n nPos := x\n\n ENDIF\n x--\n ENDDO\n ENDIF\n\n RETURN nPos\n\nMETHOD WvgMenuBar:checkItem( nItemNum, lCheck )\n\n LOCAL nRet := -1\n\n __defaultNIL( @lCheck, .T. )\n\n IF ! Empty( ::hMenu ) .AND. HB_ISNUMERIC( nItemNum )\n nRet := wvg_CheckMenuItem( ::hMenu, nItemNum - 1, MF_BYPOSITION + iif( lCheck, MF_CHECKED, MF_UNCHECKED ) )\n ENDIF\n\n RETURN iif( nRet == -1, .F., .T. )\n\nMETHOD WvgMenuBar:enableItem( nItemNum )\n\n LOCAL lSuccess := .F.\n\n IF ! Empty( ::hMenu ) .AND. HB_ISNUMERIC( nItemNum )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbcurl' (libcurl wrapper for HTTP/FTP/SMTP operations): contrib/hbcurl/tests/multi.prg. Provides functions: CurGet. Contains 4 procedures. This file provides network protocol implementations"}, {"role": "assistant", "content": "#define REMOTE_1 \"https:\n#define REMOTE_2 \"https:\n#define REMOTE_3 \"https:\n\n#require \"hbcurl\"\n\n#include \"inkey.ch\"\n\nPROCEDURE Main( cRemote4 )\n LOCAL hMulti\n LOCAL hEasy, aResult, nKey := 0\n LOCAL aUrls := { REMOTE_1, REMOTE_2, REMOTE_3 }\n LOCAL aHandles, i, nErr, nRun := 0, nLastRun := 0\n\n \n IF ! Empty( cRemote4 )\n AAdd( aUrls, cRemote4 )\n ENDIF\n\n \n aHandles := Array( Len( aUrls ) )\n\n curl_global_init()\n\n hMulti := curl_multi_init()\n\n FOR i := 1 TO Len( aUrls )\n hEasy := curl_easy_init()\n IF hEasy != NIL\n curl_easy_setopt( hEasy, HB_CURLOPT_URL, aUrls[ i ] )\n curl_easy_setopt( hEasy, HB_CURLOPT_DOWNLOAD )\n curl_easy_setopt( hEasy, HB_CURLOPT_DL_BUFF_SETUP )\n\n curl_easy_setopt( hEasy, HB_CURLOPT_SSL_OPTIONS, HB_CURLSSLOPT_NATIVE_CA )\n curl_multi_add_handle( hMulti, hEasy )\n aHandles[ i ] := hEasy\n ENDIF\n NEXT\n\n CLS\n\n nErr := curl_multi_perform( hMulti, @nLastRun )\n\n IF nErr != HB_CURLM_OK\n ? \"curl_multi_perform() failed, err=\", nErr\n Cleanup( aHandles, hMulti )\n RETURN\n ENDIF\n\n SetPos( 3, 0 )\n\n DO WHILE curl_multi_perform( hMulti, @nRun ) == HB_CURLM_OK\n\n aResult := CurGet()\n @ 1, 1 SAY Time()\n @ 2, 1 SAY \"downloading... (\" + hb_ntos( nRun ) + \" transfers left)\"\n CurSet( aResult )\n\n IF nRun < nLastRun\n FOR i := 1 TO nLastRun - nRun\n\n \n aResult := curl_multi_info_read( hMulti, aHandles )\n\n IF aResult # NIL\n \n ? \"HB_CURLMSG_RESP_LEN :\", aResult[ HB_CURLMSG_RESP_LEN ]\n ? \"HB_CURLMSG_RESP_RESPONSE_CODE:\", aResult[ HB_CURLMSG_RESP_RESPONSE_CODE ]\n ? \"HB_CURLMSG_RESP_MSG :\", aResult[ HB_CURLMSG_RESP_MSG ]\n ? \"HB_CURLMSG_RESP_RESULT :\", aResult[ HB_CURLMSG_RESP_RESULT ]\n ? \"HB_CURLMSG_RESP_HPOS :\", aResult[ HB_CURLMSG_RESP_HPOS ]\n IF aResult[ HB_CURLMSG_RESP_HPOS ] > 0\n ? \"URL :\", aUrls[ aResult[ HB_CURLMSG_RESP_HPOS ] ]\n IF ! Empty( curl_easy_getinfo( aResult[ HB_CURLMSG_RESP_HANDLE ], HB_CURLINFO_REDIRECT_URL ) )\n ? \"HB_CURLINFO_REDIRECT_URL :\", curl_easy_getinfo( aResult[ HB_CURLMSG_RESP_HANDLE ], HB_CURLINFO_REDIRECT_URL )\n ENDIF\n ENDIF\n ? \"--\"\n ENDIF\n NEXT\n ENDIF\n\n IF nRun == 0 .OR. nKey == K_ESC\n EXIT\n ENDIF\n\n nLastRun := nRun\n\n nKey := Inkey( 0.1 )\n\n ENDDO\n\n PrintAllDownloaded( aHandles )\n\n Cleanup( aHandles, hMulti )\n\n RETURN\n\nSTATIC PROCEDURE PrintAllDownloaded( aHandles )\n LOCAL h\n\n FOR EACH h IN aHandles\n\n IF h == NIL\n LOOP\n ENDIF\n\n ? \"Transfer #\" + hb_ntos( h:__enumIndex ) + \" (\" + hb_ntos( curl_easy_getinfo( h, HB_CURLINFO_RESPONSE_CODE ) ) + \"): \"\n IF curl_easy_getinfo( h, HB_CURLINFO_RESPONSE_CODE ) == 0\n ?? \"aborted\"\n ELSE\n ?? Left( curl_easy_dl_buff_get( h ), 40 ) + IIF( Len( curl_easy_dl_buff_get( h ) ) > 40, \"...\", \"\" )\n ENDIF\n NEXT\n\n RETURN\n\n\nSTATIC PROCEDURE Cleanup( aHandles, hMulti )\n LOCAL h\n\n FOR EACH h IN aHandles\n\n IF h == NIL\n LOOP\n ENDIF\n\n curl_multi_remove_handle( hMulti, h )\n curl_easy_cleanup( h )\n\n NEXT\n\n curl_multi_cleanup( hMulti )\n\n curl_global_cleanup()\n\n RETURN\n\nSTATIC FUNCTION CurGet()\n RETURN { Row(), Col() }\n\nSTATIC PROCEDURE CurSet( a )\n\n SetPos( a[ 1 ], a[ 2 ] )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/achoice.prg. Provides functions: cUserFunction. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"achoice.ch\"\n#include \"inkey.ch\"\n\n#ifndef __HARBOUR__\n#define hb_ntos( n ) LTrim( Str( n ) )\n#endif\n\nPROCEDURE Main()\n\n LOCAL aPrompts := { ;\n \"AGRI-PLANTS\" , ;\n \"ALAN R. SMITH GREENHOUSES\" , ;\n \"ALLAN MURRAY NURSERY, INC.\" , ;\n \"APOPKA FOREST\" , ;\n \"LIGHT HOUSE NURSERIES\" , ;\n \"BAUCOM'S\" , ;\n \"BAY HILL NURSERY, INC.\" , ;\n \"BAYWOOD NURSERIES\" , ;\n \"BIG OAK NURSERY\" , ;\n \"C & N NURSERY\" , ;\n \"CHARLES QUALITY PLANTS\" , ;\n \"CONNELL FARMS\" , ;\n \"DEWAR NURSERIES, INC.\" , ;\n \"DIAMOND T NURSERY\" , ;\n \"DISTINCTIVE PALMS NURSERIES\" , ;\n \"DONKAY NURSERY\" , ;\n \"DOUG INGRAM & SONS NURSERY\" , ;\n \"DRIFTWOOD GARDENS, INC.\" , ;\n \"ELVA PLANT NURSERY, INC.\" , ;\n \"ERINON\" , ;\n \"EVANS NURSERY\" , ;\n \"FANCY PLANTS\" , ;\n \"FL.PLANT GROWERSCOOP\" , ;\n \"FLORIDA CACTUS INC.\" , ;\n \"FLOWERING TREE GROWERS, INC.\" , ;\n \"FLOWERWOOD NURSERY\" , ;\n \"FOLIAGE FACTORY TOO\" , ;\n \"GATOR GROWERS NURSERY, INC.\" , ;\n \"GAZEBO LANDSCAPE DESIGN, INC.\" , ;\n \"GEM ORNAMENTALS\" , ;\n \"GRANNY'S GARDEN\" , ;\n \"GRAY'S ORNAMENTALS\" , ;\n \"GREEN MASTERS INC.\" , ;\n \"GREEN MEADOW NURSERY\" , ;\n \"PIXLEY'S PLANT PLACE\" , ;\n \"HARRISON'S NURSERY, INC.\" , ;\n \"G & G FOLIAGE\" , ;\n \"IVEY'S NURSERY, INC.\" , ;\n \"JB NURSERIES, INC.\" , ;\n \"JON'S NURSERY\" , ;\n \"JONES & JONES NURSERY, INC.\" , ;\n \"KAGER'S NURSERY\" , ;\n \"KIRKLAND'S NURSERY\" , ;\n \"LAND OF BROMELIADS\" , ;\n \"LANDSCAPE NURSERY, INC.\" , ;\n \"LIEWALD'S NURSERY INC.\" , ;\n \"LLOYD & RINGS NURSERY\" , ;\n \"LONG VAN DOUNG\" , ;\n \"MAPEL'S LANDSCAPE NURSERY\" , ;\n \"MILESTONE AGRICULTURE, INC.\" , ;\n \"MOJICA NURSERY & FRUITS\" , ;\n \"NELSON'S ROSES\" , ;\n \"PARK GARDENS\" , ;\n \"PAUL LUKAS INC.\" , ;\n \"PECKETT'S INC.\" , ;\n \"PENANG NURSERY, INC.\" , ;\n \"PINES III NURERIES\" , ;\n \"PINEVIEW NURSERY\" , ;\n \"POUL JENSEN NURSERY\" , ;\n \"R.P. WELKER\" , ;\n \"RICHARD ROGERS NURSERY, INC.\" , ;\n \"SPRING HILL NURSERY\" , ;\n \"T.O. MAHAFFEY, JR.\" , ;\n \"TUCKER NURSERY\" , ;\n \"TURTLE POND NURSERY\" , ;\n \"TUTTLE'S NURSERY INC.\" , ;\n \"VALLEY CACTUS\" , ;\n \"WHISPER WINDS, INC.\" , ;\n \"WHITE ROSE NURSERIES INC.\" , ;\n \"WOODWAY\" , ;\n \"FLORI-DESIGN\" , ;\n \"GREEN ACRES FOLIAGE, INC\" , ;\n \"FLORAL EXPO\" , ;\n \"TORRES NURSERY\" , ;\n \"DARRYL KOON\" , ;\n \"TRISTAR NURSERY\" , ;\n \"KAY WEST NURSERY\" , ;\n \"JAYMAR NURSERY\" , ;\n \"J D F LANDSCAPE NURSERY\" , ;\n \"DEROOSE PLANTS, INC.\" , ;\n \"THE TREEHOUSE\" , ;\n \"COSTELLO'S ARECAS, INC.\" , ;\n \"FLORICO FOLIAGE\" , ;\n \"THE NATIVES\" , ;\n \"GREENS NURSERY\" , ;\n \"STEWART NURSERIES\" , ;\n \"G & T FOLIAGE, INC.\" , ;\n \"GOOD TIMES NURSERY\" , ;\n \"CONCEPTS IN GREENERY, INC.\" , ;\n \"DUNN BROTHERS CITRUS, INC.\" , ;\n \"JOHN PLANK GREENHOUSES\" , ;\n \"GREENER PASTURES NURSERY\" , ;\n \"MULVEHILL NURSERY\" , ;\n \"A NU LEAF\" , ;\n \"IVY DESIGNS, INC.\" , ;\n \"B & C TROPICALS\" , ;\n \"SPANISH RIVER NURSERY, INC.\" , ;\n \"JACK CHRISTMAS & ASSOCIATES\" , ;\n \"SPECIALIST GROWERS\" , ;\n \"HOMRICH NURSERY, INC.\" , ;\n \"COUNTRYSIDE FOLIAGE, INC.\" , ;\n \"RFJ COMPANY\" , ;\n \"LAKE BRANTLEY PLANT CORP.\" , ;\n \"MARISTYME\" , ;\n \"MERISTEM NURSERY, INC.\" , ;\n \"TROPIC DECOR - EARL WILSON\" , ;\n \"URQUHART'S NURSERY\" , ;\n \"ACE PLANT NURSERY\" , ;\n \"HATTAWAYS GREENHOUSE, INC.\" , ;\n \"Florida Plant Growers\" , ;\n \"Junior Nursery\" , ;\n \"Fox's Nurseries, Inc.\" , ;\n \"Vaughan Nursery\" , ;\n \"MERRYGRO FARMS\" , ;\n \"ALL SEASONS NURSERY\" , ;\n \"BENCHMARK FOLIAGE\" , ;\n \"SAMMY'S NURSERY\" , ;\n \"SUNSHINE GROWERS\" , ;\n \"Blooming-Fields Nursery\" }\n\n LOCAL aPermits := {}\n LOCAL x\n LOCAL nChoice\n LOCAL ncntr\n\n CLS\n\n SetColor( \"GB+/B,GR+/R,,,W/N\" )\n\n SET CURSOR ON\n\n ASize( aPermits, Len( aPrompts ) )\n\n FOR x := 1 TO Len( aPrompts )\n aPermits[ x ] := !( \"V\" $ aPrompts[ x ] )\n NEXT\n\n#define TEST1\n#ifdef TEST1\n FOR ncntr := 1 TO 17\n aPermits[ nCntr ] := .F.\n aPermits[ Len( aPrompts ) - nCntr + 1 ] := .F.\n NEXT\n aPermits[ 32 ] := .F.\n aPermits[ 33 ] := .F.\n aPermits[ 34 ] := .F.\n#endif\n\n nChoice := AChoice( 5, 10, 20, 70, aPrompts, aPermits, \"cUserFunction\" )\n\n SetPos( 0, 0 )\n\n ? nChoice\n\n IF nChoice > 0\n ? aPrompts[ nChoice ]\n ENDIF\n SetPos( MaxRow() - 2, 0 )\n\n RETURN\n\n\nFUNCTION cUserFunction( nMode, nCurElement, nRowPos )\n\n LOCAL nRetVal := AC_CONT \n LOCAL nKey := LastKey()\n\n LOCAL nRow := Row()\n LOCAL nCol := Col()\n\n HB_SYMBOL_UNUSED( nRowPos )\n\n @ 0, 20 SAY Str( nRow, 3 ) + \" \" + Str( nCol, 3 )\n\n DO CASE\n \n CASE nMode == AC_IDLE\n @ 0, 0 SAY PadR( hb_ntos( nCurElement ), 10 )\n nRetVal := AC_CONT \n CASE nMode == AC_HITTOP \n @ 0, 0 SAY \"Hit Top \"\n \n CASE nMode == AC_HITBOTTOM \n @ 0, 0 SAY \"Hit Bottom\"\n \n CASE nMode == AC_EXCEPT \n @ 0, 0 SAY \"Exception \"\n DO CASE\n CASE nKey == K_ENTER \n nRetVal := AC_SELECT\n CASE nKey == K_ESC \n nRetVal := AC_ABORT\n OTHERWISE\n nRetVal := AC_GOTO \n ENDCASE\n ENDCASE\n\n RETURN nRetVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hblogdef.ch. Defines 8 constants including: HB_LOGDEF_CH, HB_LOG_DEFAULT, HB_LOG_CRITICAL, HB_LOG_ERROR, HB_LOG_WARNING. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_LOGDEF_CH\n#define HB_LOGDEF_CH\n\n#define HB_LOG_DEFAULT -1\n#define HB_LOG_CRITICAL 1\n#define HB_LOG_ERROR 2\n#define HB_LOG_WARNING 3\n#define HB_LOG_WARN 3\n#define HB_LOG_INFO 4\n#define HB_LOG_DEBUG 5\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour header file: extras/template/hbtpl.ch. Defines constants: HBTPL_CH, HBTPL_MYCONSTANT. Declares 1 preprocessor commands. Defines communication constants"}, {"role": "assistant", "content": "#ifndef HBTPL_CH\n#define HBTPL_CH\n\n\n#define HBTPL_MYCONSTANT 100\n\n\n#command HBTPL_PRINT => ? \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour Runtime Library file: src/rtl/tlabel.prg. Defines classes: HBLabelForm. This file defines UI widget classes for graphical interfaces"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"error.ch\"\n#include \"fileio.ch\"\n#include \"inkey.ch\"\n\n#define _LF_SAMPLES 2 \n#define _LF_YN 12 \n\n#define LBL_REMARK 1 \n#define LBL_HEIGHT 2 \n#define LBL_WIDTH 3 \n#define LBL_LMARGIN 4 \n#define LBL_LINES 5 \n#define LBL_SPACES 6 \n#define LBL_ACROSS 7 \n#define LBL_FIELDS 8 \n\n#define LBL_COUNT 8 \n\n\n#define LF_EXP 1 \n#define LF_TEXT 2 \n#define LF_BLANK 3 \n\n#define LF_COUNT 3 \n\n#define BUFFSIZE 1034 \n#define FILEOFFSET 74 \n#define FIELDSIZE 60\n#define REMARKOFFSET 2\n#define REMARKSIZE 60\n#define HEIGHTOFFSET 62\n#define HEIGHTSIZE 2\n#define WIDTHOFFSET 64\n#define WIDTHSIZE 2\n#define LMARGINOFFSET 66\n#define LMARGINSIZE 2\n#define LINESOFFSET 68\n#define LINESSIZE 2\n#define SPACESOFFSET 70\n#define SPACESSIZE 2\n#define ACROSSOFFSET 72\n#define ACROSSSIZE 2\n\nCREATE CLASS HBLabelForm\n\n VAR aLabelData AS ARRAY INIT {}\n VAR aBandToPrint AS ARRAY\n VAR cBlank AS STRING INIT \"\"\n VAR lOneMoreBand AS LOGICAL INIT .T.\n VAR nCurrentCol AS NUMERIC \n\n METHOD Init( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, ;\n bWhile, nNext, nRecord, lRest, lSample )\n\n METHOD ExecuteLabel()\n METHOD SampleLabels()\n METHOD LoadLabel( cLblFile )\n\nENDCLASS\n\nMETHOD Init( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, ;\n bWhile, nNext, nRecord, lRest, lSample ) CLASS HBLabelForm\n\n LOCAL lPrintOn := .F. \n LOCAL lConsoleOn \n LOCAL cExtraFile, lExtraState \n LOCAL xBreakVal, lBroke := .F.\n LOCAL err\n LOCAL OldMargin\n\n ::aBandToPrint := {} \n ::nCurrentCol := 1\n\n \n IF cLBLName == NIL\n err := ErrorNew()\n err:severity := ES_ERROR\n err:genCode := EG_ARG\n err:subSystem := \"FRMLBL\"\n Eval( ErrorBlock(), err )\n ELSE\n \n IF Set( _SET_DEFEXTENSIONS )\n cLBLName := hb_FNameExtSetDef( cLBLName, \".lbl\" )\n ENDIF\n ENDIF\n\n __defaultNIL( @lPrinter, .F. )\n __defaultNIL( @lSample, .F. )\n\n \n IF lPrinter \n lPrintOn := Set( _SET_PRINTER, lPrinter )\n ENDIF\n\n lConsoleOn := Set( _SET_CONSOLE )\n Set( _SET_CONSOLE, ! lNoConsole .AND. lConsoleOn )\n\n IF ! Empty( cAltFile ) \n lExtraState := Set( _SET_EXTRA, .T. )\n cExtraFile := Set( _SET_EXTRAFILE, cAltFile )\n ENDIF\n\n OldMargin := Set( _SET_MARGIN, 0 )\n\n BEGIN SEQUENCE\n\n ::aLabelData := ::LoadLabel( cLBLName ) \n\n \n ::aLabelData[ LBL_LMARGIN ] += OldMargin\n\n ASize( ::aBandToPrint, Len( ::aLabelData[ LBL_FIELDS ] ) )\n AFill( ::aBandToPrint, Space( ::aLabelData[ LBL_LMARGIN ] ) )\n\n \n ::cBlank := Space( ::aLabelData[ LBL_WIDTH ] + ::aLabelData[ LBL_SPACES ] )\n\n \n IF lSample\n ::SampleLabels()\n ENDIF\n\n \n dbEval( {|| ::ExecuteLabel() }, bFor, bWhile, nNext, nRecord, lRest )\n\n \n IF ::lOneMoreBand\n \n AEval( ::aBandToPrint, {| BandLine | PrintIt( BandLine ) } )\n ENDIF\n\n RECOVER USING xBreakVal\n\n lBroke := .T.\n\n END SEQUENCE\n\n \n ::aLabelData := {} \n ::aBandToPrint := {}\n ::nCurrentCol := 1\n ::cBlank := \"\"\n ::lOneMoreBand := .T.\n\n \n Set( _SET_PRINTER, lPrintOn ) \n Set( _SET_CONSOLE, lConsoleOn ) \n\n IF ! Empty( cAltFile ) \n Set( _SET_EXTRAFILE, cExtraFile )\n Set( _SET_EXTRA, lExtraState )\n ENDIF\n\n IF lBroke\n BREAK xBreakVal \n ENDIF\n\n Set( _SET_MARGIN, OldMargin )\n\n RETURN Self\n\nMETHOD ExecuteLabel() CLASS HBLabelForm\n\n LOCAL nField, aField, nMoreLines, aBuffer := {}, cBuffer\n LOCAL item\n\n \n FOR EACH aField IN ::aLabelData[ LBL_FIELDS ]\n\n IF aField != NIL\n\n cBuffer := ;\n PadR( Eval( aField[ LF_EXP ] ), ::aLabelData[ LBL_WIDTH ] ) + ;\n Space( ::aLabelData[ LBL_SPACES ] )\n\n IF aField[ LF_BLANK ]\n IF ! Empty( cBuffer )\n AAdd( aBuffer, cBuffer )\n ENDIF\n ELSE\n AAdd( aBuffer, cBuffer )\n ENDIF\n ELSE\n AAdd( aBuffer, NIL )\n ENDIF\n NEXT\n\n ASize( aBuffer, Len( ::aLabelData[ LBL_FIELDS ] ) )\n\n \n FOR nField := 1 TO Len( ::aLabelData[ LBL_FIELDS ] )\n ::aBandToPrint[ nField ] += ;\n iif( aBuffer[ nField ] == NIL, ::cBlank, aBuffer[ nField ] )\n NEXT\n\n IF ::nCurrentCol == ::aLabelData[ LBL_ACROSS ]\n\n \n FOR EACH item IN ::aBandToPrint\n item := RTrim( item )\n NEXT\n\n ::lOneMoreBand := .F.\n ::nCurrentCol := 1\n\n \n AEval( ::aBandToPrint, {| BandLine | PrintIt( BandLine ) } )\n\n nMoreLines := ::aLabelData[ LBL_HEIGHT ] - Len( ::aBandToPrint )\n FOR nField := 1 TO nMoreLines\n PrintIt()\n NEXT\n\n \n FOR nField := 1 TO ::aLabelData[ LBL_LINES ]\n PrintIt()\n NEXT\n\n \n AFill( ::aBandToPrint, Space( ::aLabelData[ LBL_LMARGIN ] ) )\n ELSE\n ::lOneMoreBand := .T.\n ::nCurrentCol++\n ENDIF\n\n RETURN Self\n\nMETHOD SampleLabels() CLASS HBLabelForm\n\n LOCAL cKey, lMoreSamples := .T., nField\n LOCAL aBand := {}\n\n \n ASize( aBand, ::aLabelData[ LBL_HEIGHT ] )\n AFill( aBand, Space( ::aLabelData[ LBL_LMARGIN ] ) + ;\n Replicate( Replicate( \"*\", ::aLabelData[ LBL_WIDTH ] ) + ;\n Space( ::aLabelData[ LBL_SPACES ] ), ::aLabelData[ LBL_ACROSS ] ) )\n\n \n DO WHILE lMoreSamples\n\n \n AEval( aBand, {| BandLine | PrintIt( BandLine ) } )\n\n \n FOR nField := 1 TO ::aLabelData[ LBL_LINES ]\n PrintIt()\n NEXT\n\n \n DispOutAt( Row(), 0, __natMsg( _LF_SAMPLES ) + \" (\" + __natMsg( _LF_YN ) + \")\" )\n cKey := hb_keyChar( Inkey( 0 ) )\n DispOut( cKey )\n IF Row() == MaxRow()\n Scroll( 0, 0, MaxRow(), MaxCol(), 1 )\n SetPos( MaxRow(), 0 )\n ELSE\n SetPos( Row() + 1, 0 )\n ENDIF\n IF __natIsNegative( cKey ) \n lMoreSamples := .F.\n ENDIF\n ENDDO\n\n RETURN Self\n\nMETHOD LoadLabel( cLblFile ) CLASS HBLabelForm\n\n LOCAL i \n LOCAL cBuff := Space( BUFFSIZE ) \n LOCAL nHandle \n LOCAL nOffset := FILEOFFSET \n LOCAL cFieldText \n LOCAL err \n\n LOCAL cPath \n\n \n LOCAL aLabel[ LBL_COUNT ]\n\n aLabel[ LBL_REMARK ] := Space( 60 ) \n aLabel[ LBL_HEIGHT ] := 5 \n aLabel[ LBL_WIDTH ] := 35 \n aLabel[ LBL_LMARGIN ] := 0 \n aLabel[ LBL_LINES ] := 1 \n aLabel[ LBL_SPACES ] := 0 \n aLabel[ LBL_ACROSS ] := 1 \n aLabel[ LBL_FIELDS ] := {} \n\n \n IF ( nHandle := FOpen( cLblFile ) ) == F_ERROR .AND. ;\n Empty( hb_FNameDir( cLblFile ) )\n\n \n FOR EACH cPath IN hb_ATokens( StrTran( Set( _SET_DEFAULT ), \",\", \";\" ), \";\" )\n IF ( nHandle := FOpen( hb_DirSepAdd( cPath ) + cLblFile ) ) != F_ERROR\n EXIT\n ENDIF\n NEXT\n ENDIF\n\n \n IF nHandle == F_ERROR\n err := ErrorNew()\n err:severity := ES_ERROR\n err:genCode := EG_OPEN\n err:subSystem := \"FRMLBL\"\n err:osCode := FError()\n err:filename := cLblFile\n Eval( ErrorBlock(), err )\n ELSE\n IF FRead( nHandle, @cBuff, BUFFSIZE ) > 0 .AND. FError() == 0\n \n aLabel[ LBL_REMARK ] := hb_BSubStr( cBuff, REMARKOFFSET, REMARKSIZE )\n aLabel[ LBL_HEIGHT ] := Bin2W( hb_BSubStr( cBuff, HEIGHTOFFSET, HEIGHTSIZE ) )\n aLabel[ LBL_WIDTH ] := Bin2W( hb_BSubStr( cBuff, WIDTHOFFSET, WIDTHSIZE ) )\n aLabel[ LBL_LMARGIN ] := Bin2W( hb_BSubStr( cBuff, LMARGINOFFSET, LMARGINSIZE ) )\n aLabel[ LBL_LINES ] := Bin2W( hb_BSubStr( cBuff, LINESOFFSET, LINESSIZE ) )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/hrbext.prg. Provides functions: Msg, Msg2. Contains procedures: MsgInit. This test file tests specific function APIs"}, {"role": "assistant", "content": "FUNCTION Msg()\n\n ? \"Function called from .hrb\"\n\n RETURN .T.\n\nFUNCTION Msg2()\n RETURN Msg()\n\nINIT PROCEDURE MsgInit()\n\n ? \"INIT PROCEDURE in .hrb\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbzebra' (Barcode generation library): contrib/hbzebra/tests/gtgfx.prg. Provides functions: hb_zebra_draw_gfx. Contains procedures: Main, DrawBarcode. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbzebra\"\n\n#include \"hbgtinfo.ch\"\n#include \"hbgfx.ch\"\n\n#define _SCALE_ 2 \n\nPROCEDURE Main()\n\n SetMode( 21\n SetColor( \"B*/W\" ) \n\n CLS\n\n DrawBarcode( 1, 32, 1, \"EAN13\", \"477012345678\" )\n DrawBarcode( 2, 32, 1, \"EAN8\", \"1234567\" )\n DrawBarcode( 3, 32, 1, \"UPCA\", \"01234567891\" )\n DrawBarcode( 4, 32, 1, \"UPCE\", \"123456\" )\n DrawBarcode( 5, 32, 1, \"CODE39\", \"ABC123\" )\n DrawBarcode( 6, 32, 1, \"CODE39\", \"ABC123\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( 7, 32, 1, \"ITF\", \"12345678901\", HB_ZEBRA_FLAG_CHECKSUM )\n DrawBarcode( 8, 32, 1, \"MSI\", \"1234567\", HB_ZEBRA_FLAG_CHECKSUM )\n DrawBarcode( 9, 32, 1, \"CODABAR\", \"40156\", HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( 10, 32, 1, \"CODE93\", \"ABC-123\" )\n DrawBarcode( 11, 32, 1, \"CODE11\", \"1234567890\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( 12, 32, 1, \"CODE128\", \"Code 128\" )\n DrawBarcode( 13, 32, 1, \"PDF417\", \"Hello, World of Harbour!!! It's 2D barcode PDF417 :)\" )\n DrawBarcode( 17, 32, 1, \"DATAMATRIX\", \"Hello, World of Harbour!!! It's 2D barcode DataMatrix :)\" )\n DrawBarcode( 19, 32, 1, \"QRCODE\", \"https:\n\n WAIT\n\n RETURN\n\nSTATIC PROCEDURE DrawBarcode( nY, nX, nLineWidth, cType, cCode, nFlags )\n\n LOCAL hZebra, nLineHeight, cTxt, nYPixel\n LOCAL nColor := hb_gfxMakeColor( 0, 0, 0 ) \n\n IF nLineWidth < 1 \n nLineWidth := 1\n ENDIF\n\n SWITCH cType\n CASE \"EAN13\" ; hZebra := hb_zebra_create_ean13( cCode, nFlags ) ; EXIT\n CASE \"EAN8\" ; hZebra := hb_zebra_create_ean8( cCode, nFlags ) ; EXIT\n CASE \"UPCA\" ; hZebra := hb_zebra_create_upca( cCode, nFlags ) ; EXIT\n CASE \"UPCE\" ; hZebra := hb_zebra_create_upce( cCode, nFlags ) ; EXIT\n CASE \"CODE39\" ; hZebra := hb_zebra_create_code39( cCode, nFlags ) ; EXIT\n CASE \"ITF\" ; hZebra := hb_zebra_create_itf( cCode, nFlags ) ; EXIT\n CASE \"MSI\" ; hZebra := hb_zebra_create_msi( cCode, nFlags ) ; EXIT\n CASE \"CODABAR\" ; hZebra := hb_zebra_create_codabar( cCode, nFlags ) ; EXIT\n CASE \"CODE93\" ; hZebra := hb_zebra_create_code93( cCode, nFlags ) ; EXIT\n CASE \"CODE11\" ; hZebra := hb_zebra_create_code11( cCode, nFlags ) ; EXIT\n CASE \"CODE128\" ; hZebra := hb_zebra_create_code128( cCode, nFlags ) ; EXIT\n CASE \"PDF417\" ; hZebra := hb_zebra_create_pdf417( cCode, nFlags ); nLineHeight := nLineWidth\n CASE \"DATAMATRIX\" ; hZebra := hb_zebra_create_datamatrix( cCode, nFlags ); nLineHeight := nLineWidth ; EXIT\n CASE \"QRCODE\" ; hZebra := hb_zebra_create_qrcode( cCode, nFlags ); nLineHeight := nLineWidth ; EXIT\n ENDSWITCH\n\n nY\n cTxt := Left( cTxt, nX - 12 - 4 ) + \"...\"\n ENDIF\n hb_dispOutAt( nY, nx - 20, cTxt )\n hb_zebra_draw_gfx( hZebra, nColor, nX\n ? \"Type\", cType, \"Code\", cCode, \"Error\", hb_zebra_geterror( hZebra )\n ENDIF\n hb_zebra_destroy( hZebra )\n ELSE\n ? \"Invalid barcode type\", cType\n ENDIF\n\n RETURN\n\nSTATIC FUNCTION hb_zebra_draw_gfx( hZebra, nColor, ... )\n\n IF hb_zebra_geterror( hZebra ) != 0\n RETURN HB_ZEBRA_ERROR_INVALIDZEBRA\n ENDIF\n\n RETURN hb_zebra_draw( hZebra, {| x, y, w, h | hb_gfxfilledRect( y, x, y + h, x + w, nColor ) }, ... )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour header file: include/hbstdgen.ch. Defines 10 constants including: HB_VER_H_, HB_SETUP_CH_, HB_STD_CH_, HB_VER_MAJOR, HB_VER_MINOR. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#include \"hbver.h\" \n#include \"hbsetup.ch\" \n#include \"std.ch\" \n\n\n#undef HB_VER_H_\n#undef HB_SETUP_CH_\n#undef HB_STD_CH_\n\n#undef HB_VER_MAJOR\n#undef HB_VER_MINOR\n#undef HB_VER_RELEASE\n#undef HB_VER_STATUS\n\n#undef __DATE__\n#undef __TIME__\n#undef __HB_MAIN__\n#undef __ARCH16BIT__\n#undef __ARCH32BIT__\n#undef __ARCH64BIT__\n#undef __LITTLE_ENDIAN__\n#undef __BIG_ENDIAN__\n#undef __PDP_ENDIAN__"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/shfileop.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\n#include \"simpleio.ch\"\n\nPROCEDURE Main()\n\n LOCAL a\n LOCAL lAbort\n LOCAL tmp\n\n ? \"0x\" + hb_NumToHex( win_SHFileOperation( NIL, WIN_FO_COPY, { __FILE__, \"olesrv1.prg\" }, { \"testcopy1\" }, ;\n NIL, @lAbort, ;\n NIL, \"Harbour SHFile 1\" ) )\n ? lAbort\n\n hb_MemoWrit( \"rename.txt\", \"hello1\" )\n hb_MemoWrit( \"rename1.txt\", \"hello2\" )\n\n a := {}\n ? \"0x\" + hb_NumToHex( win_SHFileOperation( NIL, WIN_FO_RENAME, { \"rename.txt\" }, { \"rename1.txt\" }, ;\n WIN_FOF_WANTMAPPINGHANDLE, @lAbort, ;\n a, \"Harbour SHFile 2\" ) )\n ? lAbort\n FOR EACH tmp IN a\n ? tmp[ 1 ], tmp[ 2 ]\n FErase( tmp[ 1 ] )\n FErase( tmp[ 2 ] )\n NEXT\n\n FErase( \"rename1.txt\" )\n\n ? \"0x\" + hb_NumToHex( win_SHFileOperation( NIL, WIN_FO_COPY, __FILE__ + Chr( 0 ) + \"olesrv1.prg\" + Chr( 0 ), \"testcopy2\", ;\n NIL, @lAbort, ;\n NIL, \"Harbour SHFile 3\" ) )\n ? lAbort\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/tests/twirler.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbmisc\"\n\nPROCEDURE Main()\n\n LOCAL counter := 0, start_time, stop_time\n LOCAL twirl1 := Twirler():new( 2, 5, \"One: \" )\n LOCAL twirl2 := Twirler():new( 2, 15, \"Two: \", , 0.1 )\n LOCAL twirl3 := Twirler():new( 2, 30, \"Three: \", , 0.25 )\n LOCAL twirl4 := Twirler():new( 3, 5, \"Four: \", \"^)v(\", 0.2 )\n LOCAL twirl5 := Twirler():new( 3, 15, \"Five: \", \"^)v(\", 0.2 )\n LOCAL twirl6 := Twirler():new( 4, 5, \"Six: \", \".oOo\", 0.2 )\n LOCAL twirl7 := Twirler():new( 4, 15, \"Seven: \", \".oOo\", 0.2 )\n\n CLS\n SET CURSOR OFF\n @ 1, 1 SAY \"Twirler test program - press any key to stop\"\n twirl1:show()\n twirl2:show()\n twirl3:show()\n twirl4:show()\n twirl5:show()\n twirl6:show()\n twirl7:show()\n start_time := Seconds()\n WHILE Inkey() == 0\n counter++\n twirl1:twirl()\n twirl2:twirl()\n twirl3:twirl()\n twirl4:twirl()\n twirl6:twirl()\n IF counter % 5 == 0\n twirl5:twirl()\n IF counter % 10 == 0\n twirl7:twirl()\n ENDIF\n ENDIF\n ENDDO\n stop_time := Seconds()\n twirl7:hide()\n twirl6:hide()\n twirl5:hide()\n twirl4:hide()\n twirl3:hide()\n twirl2:hide()\n twirl1:hide()\n @ 2, 5 SAY counter\n @ 3, 5 SAY stop_time - start_time\n SET CURSOR ON\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/clsscast.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "#xtranslate QQOUT([]) => [OUTSTD()]\n#xtranslate QOUT([]) => OUTSTD(hb_eol())[;OUTSTD()]\n\n#include \"hbclass.ch\"\n\nproc main()\nlocal o:=myclass4():new(), i, cbErr\n\n? DATE(), TIME(), VERSION(), OS()\n?\n\n? \"myclass1 shared class vars:\", str( __CLS_CNTSHRDATA(o:myclass1:classH), 3), \" => should be: 3\"\n? \"myclass2 shared class vars:\", str( __CLS_CNTSHRDATA(o:myclass2:classH), 3), \" => should be: 3\"\n? \"myclass3 shared class vars:\", str( __CLS_CNTSHRDATA(o:myclass3:classH), 3), \" => should be: 3\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"myclass4 shared class vars:\", str( __CLS_CNTSHRDATA(o:myclass4:classH), 3), \" => should be: 3\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \"myclass4 shared class vars:\", str( __CLS_CNTSHRDATA(o:classH), 3), \" => should be: 3\"\n?\n\n\n? \"instance variables [\"+ltrim(str(len(o)))+\"]:\"; ?\nfor i:=1 to len(o); ?? \"\",o[i]; next\n? \" => shoule be [0]:\"\n?\n? \"[1] MYCLASS1 VARS:\", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, \" => should be: (x1) (y1) (z1)\"\n? \"[2] MYCLASS1 VARS:\", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, \" => should be: (x1) (y1) (z1)\"\n? \"[2] MYCLASS2 VARS:\", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, \" => should be: (x2) (y2) (z2)\"\n? \"[3] MYCLASS1 VARS:\", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, \" => should be: (x1) (y1) (z1)\"\n? \"[3] MYCLASS2 VARS:\", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, \" => should be: (x2) (y2) (z2)\"\n? \"[3] MYCLASS3 VARS:\", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, \" => should be: (x3) (y3) (z3)\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"[4] MYCLASS1 VARS:\", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, \" => should be: (x1) (y1) (z1)\"\n ? \"[4] MYCLASS2 VARS:\", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, \" => should be: (x2) (y2) (z2)\"\n ? \"[4] MYCLASS3 VARS:\", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, \" => should be: (x3) (y3) (z3)\"\n ? \"[4] MYCLASS4 VARS:\", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, \" => should be: (x4) (y4) (z4)\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \" MYCLASS1 VARS:\", o:x1, o:y1, o:z1, \" => should be: (x1) (y1) (z1)\"\n? \" MYCLASS2 VARS:\", o:x2, o:y2, o:z2, \" => should be: (x2) (y2) (z2)\"\n? \" MYCLASS3 VARS:\", o:x3, o:y3, o:z3, \" => should be: (x3) (y3) (z3)\"\n? \" MYCLASS4 VARS:\", o:x4, o:y4, o:z4, \" => should be: (x4) (y4) (z4)\"\n?\n? \"initialization...\"\no:x1:=\" X1 \"; o:y1:=\" Y1 \"; o:z1:=\" Z1 \"\no:x2:=\" X2 \"; o:y2:=\" Y2 \"; o:z2:=\" Z2 \"\no:x3:=\" X3 \"; o:y3:=\" Y3 \"; o:z3:=\" Z3 \"\no:x4:=\" X4 \"; o:y4:=\" Y4 \"; o:z4:=\" Z4 \"\n\n? \"[1] MYCLASS1 VARS:\", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, \" => should be: X1 Y1 Z1\"\n? \"[2] MYCLASS1 VARS:\", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, \" => should be: X1 Y1 Z1\"\n? \"[2] MYCLASS2 VARS:\", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, \" => should be: X2 Y2 Z2\"\n? \"[3] MYCLASS1 VARS:\", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, \" => should be: X1 Y1 Z1\"\n? \"[3] MYCLASS2 VARS:\", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, \" => should be: X2 Y2 Z2\"\n? \"[3] MYCLASS3 VARS:\", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, \" => should be: X3 Y3 Z3\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"[4] MYCLASS1 VARS:\", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, \" => should be: X1 Y1 Z1\"\n ? \"[4] MYCLASS2 VARS:\", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, \" => should be: X2 Y2 Z2\"\n ? \"[4] MYCLASS3 VARS:\", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, \" => should be: X3 Y3 Z3\"\n ? \"[4] MYCLASS4 VARS:\", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, \" => should be: X4 Y4 Z4\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \" MYCLASS1 VARS:\", o:x1, o:y1, o:z1, \" => should be: X1 Y1 Z1\"\n? \" MYCLASS2 VARS:\", o:x2, o:y2, o:z2, \" => should be: X2 Y2 Z2\"\n? \" MYCLASS3 VARS:\", o:x3, o:y3, o:z3, \" => should be: X3 Y3 Z3\"\n? \" MYCLASS4 VARS:\", o:x4, o:y4, o:z4, \" => should be: X4 Y4 Z4\"\n?\n\n? \"instance variables [\"+ltrim(str(len(o)))+\"]:\"; ?\nfor i:=1 to len(o); ?? \"\",o[i]; next\n? \" => shoule be [0]:\"\n?\n\n? \"Setting MYCLASS1 class variables...\"\no:myclass1:x1:=\"[X1]\"\no:myclass1:y1:=\"[Y1]\"\no:myclass1:z1:=\"[Z1]\"\n? \"[1] MYCLASS1 VARS:\", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, \" => should be: [X1] [Y1] [Z1]\"\n? \"[2] MYCLASS1 VARS:\", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, \" => should be: [X1] [Y1] [Z1]\"\n? \"[2] MYCLASS2 VARS:\", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, \" => should be: X2 Y2 Z2\"\n? \"[3] MYCLASS1 VARS:\", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, \" => should be: [X1] [Y1] [Z1]\"\n? \"[3] MYCLASS2 VARS:\", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, \" => should be: X2 Y2 Z2\"\n? \"[3] MYCLASS3 VARS:\", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, \" => should be: X3 Y3 Z3\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"[4] MYCLASS1 VARS:\", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, \" => should be: [X1] [Y1] [Z1]\"\n ? \"[4] MYCLASS2 VARS:\", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, \" => should be: X2 Y2 Z2\"\n ? \"[4] MYCLASS3 VARS:\", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, \" => should be: X3 Y3 Z3\"\n ? \"[4] MYCLASS4 VARS:\", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, \" => should be: X4 Y4 Z4\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \" MYCLASS1 VARS:\", o:x1, o:y1, o:z1, \" => should be: [X1] [Y1] [Z1]\"\n? \" MYCLASS2 VARS:\", o:x2, o:y2, o:z2, \" => should be: X2 Y2 Z2\"\n? \" MYCLASS3 VARS:\", o:x3, o:y3, o:z3, \" => should be: X3 Y3 Z3\"\n? \" MYCLASS4 VARS:\", o:x4, o:y4, o:z4, \" => should be: X4 Y4 Z4\"\n?\n\n? \"Setting MYCLASS2 class variables...\"\no:myclass2:x1:=\"{X1}\"\no:myclass2:y1:=\"{Y1}\"\no:myclass2:z1:=\"{Z1}\"\no:myclass2:x2:=\"{X2}\"\no:myclass2:y2:=\"{Y2}\"\no:myclass2:z2:=\"{Z2}\"\n? \"[1] MYCLASS1 VARS:\", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, \" => should be: {X1} {Y1} {Z1}\"\n? \"[2] MYCLASS1 VARS:\", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, \" => should be: {X1} {Y1} {Z1}\"\n? \"[2] MYCLASS2 VARS:\", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, \" => should be: {X2} {Y2} {Z2}\"\n? \"[3] MYCLASS1 VARS:\", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, \" => should be: {X1} {Y1} {Z1}\"\n? \"[3] MYCLASS2 VARS:\", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, \" => should be: {X2} {Y2} {Z2}\"\n? \"[3] MYCLASS3 VARS:\", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, \" => should be: X3 Y3 Z3\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"[4] MYCLASS1 VARS:\", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, \" => should be: {X1} {Y1} {Z1}\"\n ? \"[4] MYCLASS2 VARS:\", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, \" => should be: {X2} {Y2} {Z2}\"\n ? \"[4] MYCLASS3 VARS:\", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, \" => should be: X3 Y3 Z3\"\n ? \"[4] MYCLASS4 VARS:\", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, \" => should be: X4 Y4 Z4\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \" MYCLASS1 VARS:\", o:x1, o:y1, o:z1, \" => should be: {X1} {Y1} {Z1}\"\n? \" MYCLASS2 VARS:\", o:x2, o:y2, o:z2, \" => should be: {X2} {Y2} {Z2}\"\n? \" MYCLASS3 VARS:\", o:x3, o:y3, o:z3, \" => should be: X3 Y3 Z3\"\n? \" MYCLASS4 VARS:\", o:x4, o:y4, o:z4, \" => should be: X4 Y4 Z4\"\n?\n\n? \"Setting MYCLASS3 class variables...\"\no:myclass3:x1:=\"\"\no:myclass3:y1:=\"\"\no:myclass3:z1:=\"\"\no:myclass3:x2:=\"\"\no:myclass3:y2:=\"\"\no:myclass3:z2:=\"\"\no:myclass3:x3:=\"\"\no:myclass3:y3:=\"\"\no:myclass3:z3:=\"\"\n? \"[1] MYCLASS1 VARS:\", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, \" => should be: \"\n? \"[2] MYCLASS1 VARS:\", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, \" => should be: \"\n? \"[2] MYCLASS2 VARS:\", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, \" => should be: \""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/checkbox.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL GetList := {}\n\n LOCAL cItem := \"Windows\"\n LOCAL lx := .F.\n LOCAL ly := .F.\n\n LOCAL aItems[ 3 ]\n\n aItems[ 1 ] := RadioButto( 3, 3, \"&Windows\" )\n aItems[ 2 ] := RadioButto( 4, 3, \"&Linux\" )\n aItems[ 3 ] := RadioButto( 5, 3, \"&OS X\" )\n\n CLS\n SetColor( \"W/B+,R/B,G+/R,B+/R+,BG/N+,W/BG,RB/BG\" )\n\n @ 2, 2, 6, 40 GET cItem RADIOGROUP aItems COLOR \"W/B+,R/B,G/B+\" MESSAGE \"Select your OS\"\n\n @ 8, 3 SAY \"Married\"\n @ 8, 12 GET lx CHECKBOX COLOR \"W/B+,W/B,W+/R,W/G+\" MESSAGE \"Are you married?\"\n @ 9, 3 SAY \"Singer\"\n @ 9, 12 GET ly CHECKBOX COLOR \"W/B+,W/B,W+/R,W/G+\" MESSAGE \"Are you a singer?\"\n\n READ MSG AT MaxRow(), 0, MaxCol() MSG COLOR \"W/B+\"\n\n ? \"Is the person married:\", iif( lx, \"Yes\", \"No\" )\n ? \"Is the person a singer:\", iif( ly, \"Yes\", \"No\" )\n ? \"Your OS is\", cItem\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/hrb.prg. Provides functions: Msg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbhrb.ch\"\n\nPROCEDURE Main( n )\n\n LOCAL pHrb\n LOCAL cExe := \"Msg2()\"\n\n n := iif( n == NIL, 0, Val( n ) )\n\n IF ! hb_FileExists( \"hrbext.hrb\" )\n hb_run( \"harbour hrbext.prg -gh\" )\n ENDIF\n\n ? \"calling Msg ... From exe here !\"\n Msg()\n ? \"=========================\"\n\n\n ? \"Loading( \" + iif( n == 0, \"HB_HRB_BIND_DEFAULT\", iif( n == 1, \"HB_HRB_BIND_LOCAL\", \"HB_HRB_BIND_OVERLOAD\" ) ) + \", 'hrbext.hrb' )\"\n pHrb := hb_hrbLoad( n, \"hrbext.hrb\" )\n\n ? \"=========================\"\n\n ? \"calling Msg ... DEFAULT=From exe, LOCAL=From exe, OVERLOAD=From hrb\"\n Msg()\n ? \"=========================\"\n\n ? \"calling Msg ... DEFAULT=From exe, LOCAL=From hrb, OVERLOAD=From hrb\"\n &cExe \n ? \"=========================\"\n\n hb_hrbUnload( pHrb ) \n\n ? \"calling Msg ... DEFAULT=From exe, LOCAL=From exe, OVERLOAD=From hrb\"\n Msg() \n ? \"=========================\"\n\n ? \"END\"\n\n RETURN\n\nFUNCTION Msg()\n\n ? \"Function called from .exe\"\n\n RETURN .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/htjlist.prg. Defines classes: TJSList. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"cgi.ch\"\n\nCREATE CLASS TJSList\n\n VAR nH INIT STD_OUT\n VAR aScript INIT {}\n VAR aItems INIT {}\n VAR cScript INIT \"\"\n VAR nTimes INIT 0\n VAR nItems INIT 0\n VAR cMainNode INIT \"\"\n VAR cCurrentNode INIT \"\"\n VAR Style INIT _WHITE_BLACK_STYLE\n VAR FONT INIT \"Verdana\"\n VAR Size INIT 2\n VAR BGCOLOR INIT \"white\"\n VAR FontColor INIT \"black\"\n\n METHOD New( name, lOpen, width, height, bgColor, ;\n FONT, fntColor, fntSize, cMinusImg, cPlusImg )\n METHOD NewNode( name, lOpen, width, height, bgColor )\n METHOD SetFont( name, font, fntColor, fntSize )\n METHOD AddItem( name, url, bgColor )\n METHOD AddLink( name, url, img, bgColor )\n METHOD EndNode( name, caption )\n METHOD Build( xPos, yPos )\n METHOD Put( cFile )\n\nENDCLASS\n\n\nMETHOD New( name, lOpen, width, height, bgColor, ;\n FONT, fntColor, fntSize, cMinusImg, cPlusImg ) CLASS TJSList\n\n LOCAL cStr\n\n __defaultNIL( @name, \"l\" )\n __defaultNIL( @lOpen, .F. )\n __defaultNIL( @WIDTH, 200 )\n __defaultNIL( @HEIGHT, 22 )\n __defaultNIL( @BGCOLOR, \"white\" )\n __defaultNIL( @FONT, \"Verdana\" )\n __defaultNIL( @fntColor, \"black\" )\n __defaultNIL( @fntSize, 2 )\n __defaultNIL( @cMinusImg, \"minus.gif\" )\n __defaultNIL( @cPlusImg, \"plus.gif\" )\n\n ::font := FONT\n ::size := fntSize\n ::fontColor := fntColor\n ::bgColor := BGCOLOR\n\n ::nItems := 0\n ::aSCript := {}\n\n cStr := \"\" + CRLF() + \"\" + CRLF() + ;\n \"\" + CRLF() + ;\n '' + CRLF() + ;\n CRLF() + ;\n '' + CRLF() + ;\n CRLF() + ;\n '\" + CRLF()\n cStr += '\" + CRLF()\n cStr += '\" + CRLF()\n\n AAdd( ::aScript, cStr )\n cStr := \"\"\n\n cStr += \"Collapsable Lists: Basic Example\" + CRLF()\n cStr += \"\" + CRLF()\n cStr += '' + CRLF()\n cStr += '
' + CRLF()\n\n FOR i := 0 TO ::nItems\n cStr += '
' + CRLF()\n NEXT\n cStr += \"\" + CRLF()\n\n AAdd( ::aScript, cStr )\n\n RETURN Self\n\nMETHOD Put( cFile ) CLASS TJSList\n\n IF cFile == NIL\n ::nH := STD_OUT\n ELSE\n ::nH := FCreate( cFile )\n ENDIF\n\n AEval( ::aScript, {| e | FWrite( ::nH, e ) } )\n\n FClose( ::nH )\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour OOP classes for the functionality described: Harbour test program: tests/clsnv.prg. Defines classes: myclass1, myclass2, myclass3. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#xtranslate QQOut([]) => [OutStd()]\n#xtranslate QOut([]) => OutStd(hb_eol())[;OutStd()]\n\n#include \"hbclass.ch\"\n\nPROCEDURE Main()\n\n LOCAL o := myclass3():new()\n\n ? Date(), Time(), Version(), OS()\n ?\n\n o:m1()\n o:m2()\n o:m3()\n\n RETURN\n\nCREATE CLASS myclass1\n hidden:\n var a init \"(a1)\"\n\n class var b init \"(b1)\"\n\n METHOD x\n protected:\n var c init \"(c1)\"\n class var d init \"(d1)\"\n METHOD y\n exported:\n var e init \"(e1)\"\n class var f init \"(f1)\"\n METHOD z\n METHOD m1\n\nENDCLASS\n\nMETHOD m1\n\n ? \"Method: MYCLASS1:M1()\"\n ? \" a =>\", ::a, \", should be: (a1)\"\n ? \" b =>\", ::b, \", should be: (b1)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n ? \" execute ::x(), should be: MYCLASS1:X()\"\n ::x()\n ? \" execute ::y(), should be: MYCLASS3:Y()\"\n ::y()\n ? \" execute ::z(), should be: MYCLASS3:Z()\"\n ::z()\n\n RETURN Self\n\nMETHOD x\n\n ? \" Method: MYCLASS1:X()\"\n ? \" a =>\", ::a, \", should be: (a1)\"\n ? \" b =>\", ::b, \", should be: (b1)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n\n RETURN Self\n\nMETHOD y\n\n ? \" Method: MYCLASS1:Y()\"\n ? \" a =>\", ::a, \", should be: (a1)\"\n ? \" b =>\", ::b, \", should be: (b1)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n\n RETURN Self\n\nMETHOD z\n\n ? \" Method: MYCLASS1:Z()\"\n ? \" a =>\", ::a, \", should be: (a1)\"\n ? \" b =>\", ::b, \", should be: (b1)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n\n RETURN Self\n\n CREATE CLASS myclass2\n hidden:\n var a init \"(a2)\"\n\nCLASS var b init \"(b2)\"\n\n METHOD x\n protected:\n var c init \"(c2)\"\n CLASS var d init \"(d2)\"\n METHOD y\n exported:\n var e init \"(e2)\"\n CLASS var f init \"(f2)\"\n METHOD z\n METHOD m2\n\nENDCLASS\n\nMETHOD m2\n\n ? \"Method: MYCLASS2:M2()\"\n ? \" a =>\", ::a, \", should be: (a2)\"\n ? \" b =>\", ::b, \", should be: (b2)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n ? \" execute ::x(), should be: MYCLASS2:X()\"\n ::x()\n ? \" execute ::y(), should be: MYCLASS3:Y()\"\n ::y()\n ? \" execute ::z(), should be: MYCLASS3:Z()\"\n ::z()\n\n RETURN Self\n\nMETHOD x\n\n ? \" Method: MYCLASS2:X()\"\n ? \" a =>\", ::a, \", should be: (a2)\"\n ? \" b =>\", ::b, \", should be: (b2)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n\n RETURN Self\n\nMETHOD y\n\n ? \" Method: MYCLASS2:Y()\"\n ? \" a =>\", ::a, \", should be: (a2)\"\n ? \" b =>\", ::b, \", should be: (b2)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n\n RETURN Self\n\nMETHOD z\n\n ? \" Method: MYCLASS2:Z()\"\n ? \" a =>\", ::a, \", should be: (a2)\"\n ? \" b =>\", ::b, \", should be: (b2)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n\n RETURN Self\n\nCREATE CLASS myclass3 FROM myclass1, myclass2\n hidden:\n var a init \"(a3)\"\n\n class var b init \"(b3)\"\n\n METHOD x\n protected:\n var c init \"(c3)\"\n class var d init \"(d3)\"\n METHOD y\n exported:\n var e init \"(e3)\"\n class var f init \"(f3)\"\n METHOD z\n METHOD m3\n\nENDCLASS\n\nMETHOD m3\n\n ? \"Method: MYCLASS3:M3()\"\n ? \" a =>\", ::a, \", should be: (a3)\"\n ? \" b =>\", ::b, \", should be: (b3)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n ? \" execute ::x(), should be: MYCLASS3:X()\"\n ::x()\n ? \" execute ::y(), should be: MYCLASS3:Y()\"\n ::y()\n ? \" execute ::z(), should be: MYCLASS3:Z()\"\n ::z()\n\n RETURN Self\n\nMETHOD x\n\n ? \" Method: MYCLASS3:X()\"\n ? \" a =>\", ::a, \", should be: (a3)\"\n ? \" b =>\", ::b, \", should be: (b3)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n\n RETURN Self\n\nMETHOD y\n\n ? \" Method: MYCLASS3:Y()\"\n ? \" a =>\", ::a, \", should be: (a3)\"\n ? \" b =>\", ::b, \", should be: (b3)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n\n RETURN Self\n\nMETHOD z\n\n ? \" Method: MYCLASS3:Z()\"\n ? \" a =>\", ::a, \", should be: (a3)\"\n ? \" b =>\", ::b, \", should be: (b3)\"\n ? \" c =>\", ::c, \", should be: (c3)\"\n ? \" d =>\", ::d, \", should be: (d3)\"\n ? \" e =>\", ::e, \", should be: (e3)\"\n ? \" f =>\", ::f, \", should be: (f3)\"\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/rddtest/rddmktst.prg. Provides functions: test_main. This file handles database operations"}, {"role": "assistant", "content": "#ifdef _TEST_ADS_\n #undef _TEST_DESCEND_\n #undef _TEST_UNIQUE_\n#endif\n\n#define _TEST_CREATE_\n\n#include \"rddtst.prg\"\n\n#ifndef _TEST_CMPDIDX_\n #command RDDTEST INDEX on tag to [ FOR ] [ ] => ;\n RDDTEST INDEX on to [ FOR ] [ ]\n#endif\n\n\nfunction test_main()\nRDDTEST LOCAL n\n\nRDDTEST RDDSETDEFAULT()\n\nRDDTEST USE _DBNAME SHARED\n\n\nRDDTEST DBGOTOP()\nRDDTEST DBGOBOTTOM()\nRDDTEST DBSKIP(0)\nRDDTEST DBGOTO(0)\nRDDTEST DBSKIP(1)\nRDDTEST DBSKIP(-1)\nRDDTEST DBSKIP(0)\nRDDTEST SET DELETE ON\nRDDTEST DBGOTOP()\nRDDTEST DBGOBOTTOM()\nRDDTEST DBSKIP(0)\nRDDTEST DBGOTO(0)\nRDDTEST DBSKIP(1)\nRDDTEST DBSKIP(-1)\nRDDTEST DBSKIP(0)\nRDDTEST SET DELETE OFF\n\nRDDTEST INDEX on FNUM tag TG_N to _DBNAME\nRDDTEST INDEX on FSTR tag TG_C to _DBNAME\n\nRDDTEST ORDSETFOCUS()\n\nRDDTEST DBGOTOP()\nRDDTEST DBGOBOTTOM()\nRDDTEST DBSKIP(0)\nRDDTEST DBGOTO(0)\nRDDTEST DBSKIP(1)\nRDDTEST DBSKIP(-1)\nRDDTEST DBSKIP(0)\nRDDTEST SET DELETE ON\nRDDTEST DBGOTOP()\nRDDTEST DBGOBOTTOM()\nRDDTEST DBSKIP(0)\nRDDTEST DBGOTO(0)\nRDDTEST DBSKIP(1)\nRDDTEST DBSKIP(-1)\nRDDTEST DBSKIP(0)\n\nRDDTEST DBGOTO(0)\nRDDTEST DBSEEK('', .t.,.f.)\nRDDTEST DBSEEK('', .t.,.t.)\nRDDTEST DBSEEK('', .f.,.f.)\nRDDTEST DBSEEK('', .f.,.t.)\n\nRDDTEST SET DELETE OFF\n\nRDDTEST ;\n for n := 1 to N_LOOP ;;\n dbappend() ;;\n replace FNUM with int( ( n + 2 ) / 3 ) ;;\n replace FSTR with chr( FNUM +48 ) ;;\n next\n\nRDDTEST dbcommit()\nRDDTEST dbunlock()\n\n\nRDDTEST ORDSETFOCUS(1)\nRDDTEST ORDSETFOCUS()\nRDDTEST DBSEEK(0,.t.,.f.)\nRDDTEST DBSEEK(0,.t.,.t.)\nRDDTEST DBSEEK(0.5,.t.,.f.)\nRDDTEST DBSEEK(0.5,.t.,.t.)\nRDDTEST DBSEEK(1.0,.t.,.f.)\nRDDTEST DBSEEK(1.0,.t.,.t.)\nRDDTEST DBSEEK(2.0,.t.,.f.)\nRDDTEST DBSEEK(2.0,.t.,.t.)\nRDDTEST DBSEEK(2.5,.t.,.f.)\nRDDTEST DBSEEK(2.5,.t.,.t.)\nRDDTEST DBSEEK(5.0,.t.,.f.)\nRDDTEST DBSEEK(5.0,.t.,.t.)\nRDDTEST ORDSETFOCUS(2)\nRDDTEST ORDSETFOCUS()\n\nRDDTEST DBSEEK('', .t.,.f.)\nRDDTEST DBSEEK('', .t.,.t.)\nRDDTEST DBSEEK(' ',.t.,.f.)\nRDDTEST DBSEEK(' ',.t.,.t.)\nRDDTEST DBSEEK('0',.t.,.f.)\nRDDTEST DBSEEK('0',.t.,.t.)\nRDDTEST DBSEEK('1',.t.,.f.)\nRDDTEST DBSEEK('1',.t.,.t.)\nRDDTEST DBSEEK('2',.t.,.f.)\nRDDTEST DBSEEK('2',.t.,.t.)\nRDDTEST DBSEEK('3',.t.,.f.)\nRDDTEST DBSEEK('3',.t.,.t.)\nRDDTEST DBSEEK('4',.t.,.f.)\nRDDTEST DBSEEK('4',.t.,.t.)\nRDDTEST DBSEEK('5',.t.,.f.)\nRDDTEST DBSEEK('5',.t.,.t.)\nRDDTEST DBSEEK('6',.t.,.f.)\nRDDTEST DBSEEK('6',.t.,.t.)\n\n#ifdef _TEST_SCOPE_\nRDDTEST ORDSCOPE(TOPSCOPE,'3')\nRDDTEST ORDSCOPE(BOTTOMSCOPE,'4')\nRDDTEST DBORDERINFO(DBOI_SCOPETOP)\nRDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)\nRDDTEST DBSEEK('', .t.,.f.)\nRDDTEST DBSEEK('', .t.,.t.)\nRDDTEST DBSEEK(' ',.t.,.f.)\nRDDTEST DBSEEK(' ',.t.,.t.)\nRDDTEST DBSEEK('0',.t.,.f.)\nRDDTEST DBSEEK('0',.t.,.t.)\nRDDTEST DBSEEK('1',.t.,.f.)\nRDDTEST DBSEEK('1',.t.,.t.)\nRDDTEST DBSEEK('2',.t.,.f.)\nRDDTEST DBSEEK('2',.t.,.t.)\nRDDTEST DBSEEK('3',.t.,.f.)\nRDDTEST DBSEEK('3',.t.,.t.)\nRDDTEST DBSEEK('4',.t.,.f.)\nRDDTEST DBSEEK('4',.t.,.t.)\nRDDTEST DBSEEK('5',.t.,.f.)\nRDDTEST DBSEEK('5',.t.,.t.)\nRDDTEST DBSEEK('6',.t.,.f.)\nRDDTEST DBSEEK('6',.t.,.t.)\n\nRDDTEST ORDSCOPE(TOPSCOPE,'3')\nRDDTEST ORDSCOPE(BOTTOMSCOPE,'2')\nRDDTEST DBORDERINFO(DBOI_SCOPETOP)\nRDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)\nRDDTEST DBSEEK('',.t.,.f.)\nRDDTEST DBSEEK('',.t.,.t.)\nRDDTEST DBSEEK('1',.t.,.f.)\nRDDTEST DBSEEK('1',.t.,.t.)\nRDDTEST DBSEEK('2',.t.,.f.)\nRDDTEST DBSEEK('2',.t.,.t.)\nRDDTEST DBSEEK('3',.t.,.f.)\nRDDTEST DBSEEK('3',.t.,.t.)\nRDDTEST DBSEEK('4',.t.,.f.)\nRDDTEST DBSEEK('4',.t.,.t.)\n#endif\n\n#ifdef _TEST_DESCEND_\nRDDTEST ORDDESCEND()\nRDDTEST ORDDESCEND(,,.t.)\nRDDTEST ORDDESCEND()\n#endif\n#ifdef _TEST_SCOPE_\nRDDTEST DBORDERINFO(DBOI_SCOPETOP)\nRDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)\nRDDTEST ORDSCOPE(TOPSCOPE,NIL)\nRDDTEST ORDSCOPE(BOTTOMSCOPE,NIL)\nRDDTEST DBORDERINFO(DBOI_SCOPETOP)\nRDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)\n#endif\nRDDTEST DBSEEK('', .t.,.f.)\nRDDTEST DBSEEK('', .t.,.t.)\nRDDTEST DBSEEK(' ',.t.,.f.)\nRDDTEST DBSEEK(' ',.t.,.t.)\nRDDTEST DBSEEK('0',.t.,.f.)\nRDDTEST DBSEEK('0',.t.,.t.)\nRDDTEST DBSEEK('1',.t.,.f.)\nRDDTEST DBSEEK('1',.t.,.t.)\nRDDTEST DBSEEK('2',.t.,.f.)\nRDDTEST DBSEEK('2',.t.,.t.)\nRDDTEST DBSEEK('3',.t.,.f.)\nRDDTEST DBSEEK('3',.t.,.t.)\nRDDTEST DBSEEK('4',.t.,.f.)\nRDDTEST DBSEEK('4',.t.,.t.)\nRDDTEST DBSEEK('5',.t.,.f.)\nRDDTEST DBSEEK('5',.t.,.t.)\nRDDTEST DBSEEK('6',.t.,.f.)\nRDDTEST DBSEEK('6',.t.,.t.)\n#ifdef _TEST_SCOPE_\nRDDTEST ORDSCOPE(TOPSCOPE,'4')\nRDDTEST ORDSCOPE(BOTTOMSCOPE,'3')\nRDDTEST DBORDERINFO(DBOI_SCOPETOP)\nRDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)\nRDDTEST DBSEEK('', .t.,.f.)\nRDDTEST DBSEEK('', .t.,.t.)\nRDDTEST DBSEEK(' ',.t.,.f.)\nRDDTEST DBSEEK(' ',.t.,.t.)\nRDDTEST DBSEEK('0',.t.,.f.)\nRDDTEST DBSEEK('0',.t.,.t.)\nRDDTEST DBSEEK('1',.t.,.f.)\nRDDTEST DBSEEK('1',.t.,.t.)\nRDDTEST DBSEEK('2',.t.,.f.)\nRDDTEST DBSEEK('2',.t.,.t.)\nRDDTEST DBSEEK('3',.t.,.f.)\nRDDTEST DBSEEK('3',.t.,.t.)\nRDDTEST DBSEEK('4',.t.,.f.)\nRDDTEST DBSEEK('4',.t.,.t.)\nRDDTEST DBSEEK('5',.t.,.f.)\nRDDTEST DBSEEK('5',.t.,.t.)\nRDDTEST DBSEEK('6',.t.,.f.)\nRDDTEST DBSEEK('6',.t.,.t.)\n\nRDDTEST ORDSCOPE(TOPSCOPE,'3')\nRDDTEST ORDSCOPE(BOTTOMSCOPE,'4')\nRDDTEST DBORDERINFO(DBOI_SCOPETOP)\nRDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)\nRDDTEST DBSEEK('', .t.,.f.)\nRDDTEST DBSEEK('', .t.,.t.)\nRDDTEST DBSEEK(' ',.t.,.f.)\nRDDTEST DBSEEK(' ',.t.,.t.)\nRDDTEST DBSEEK('0',.t.,.f.)\nRDDTEST DBSEEK('0',.t.,.t.)\nRDDTEST DBSEEK('1',.t.,.f.)\nRDDTEST DBSEEK('1',.t.,.t.)\nRDDTEST DBSEEK('2',.t.,.f.)\nRDDTEST DBSEEK('2',.t.,.t.)\nRDDTEST DBSEEK('3',.t.,.f.)\nRDDTEST DBSEEK('3',.t.,.t.)\nRDDTEST DBSEEK('4',.t.,.f.)\nRDDTEST DBSEEK('4',.t.,.t.)\nRDDTEST DBSEEK('5',.t.,.f.)\nRDDTEST DBSEEK('5',.t.,.t.)\nRDDTEST DBSEEK('6',.t.,.f.)\nRDDTEST DBSEEK('6',.t.,.t.)\n#endif\n\nRDDTEST INDEX on FSTR tag TG_C to _DBNAME DESCEND\nRDDTEST DBSEEK('',.t.,.f.)\nRDDTEST DBSEEK('',.t.,.t.)\nRDDTEST DBSEEK(' ',.t.,.f.)\nRDDTEST DBSEEK(' ',.t.,.t.)\nRDDTEST DBSEEK('0',.t.,.f.)\nRDDTEST DBSEEK('0',.t.,.t.)\nRDDTEST DBSEEK('1',.t.,.f.)\nRDDTEST DBSEEK('1',.t.,.t.)\nRDDTEST DBSEEK('2',.t.,.f.)\nRDDTEST DBSEEK('2',.t.,.t.)\nRDDTEST DBSEEK('3',.t.,.f.)\nRDDTEST DBSEEK('3',.t.,.t.)\nRDDTEST DBSEEK('4',.t.,.f.)\nRDDTEST DBSEEK('4',.t.,.t.)\nRDDTEST DBSEEK('5',.t.,.f.)\nRDDTEST DBSEEK('5',.t.,.t.)\nRDDTEST DBSEEK('6',.t.,.f.)\nRDDTEST DBSEEK('6',.t.,.t.)\n\n#ifdef _TEST_SCOPE_\nRDDTEST ORDSCOPE(TOPSCOPE,'4')\nRDDTEST ORDSCOPE(BOTTOMSCOPE,'3')\nRDDTEST DBORDERINFO(DBOI_SCOPETOP)\nRDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)\nRDDTEST DBSEEK('', .t.,.f.)\nRDDTEST DBSEEK('', .t.,.t.)\nRDDTEST DBSEEK(' ',.t.,.f.)\nRDDTEST DBSEEK(' ',.t.,.t.)\nRDDTEST DBSEEK('0',.t.,.f.)\nRDDTEST DBSEEK('0',.t.,.t.)\nRDDTEST DBSEEK('1',.t.,.f.)\nRDDTEST DBSEEK('1',.t.,.t.)\nRDDTEST DBSEEK('2',.t.,.f.)\nRDDTEST DBSEEK('2',.t.,.t.)\nRDDTEST DBSEEK('3',.t.,.f.)\nRDDTEST DBSEEK('3',.t.,.t.)\nRDDTEST DBSEEK('4',.t.,.f.)\nRDDTEST DBSEEK('4',.t.,.t.)\nRDDTEST DBSEEK('5',.t.,.f.)\nRDDTEST DBSEEK('5',.t.,.t.)\nRDDTEST DBSEEK('6',.t.,.f.)\nRDDTEST DBSEEK('6',.t.,.t.)\n#endif\n\n\nRDDTEST INDEX on FSTR tag TG_C to _DBNAME\nRDDTEST DBGOTOP()\nRDDTEST DBSKIP(0)\nRDDTEST DBSKIP(-1)\nRDDTEST DBSKIP(0)\nRDDTEST DBGOBOTTOM()\nRDDTEST DBSKIP(0)\nRDDTEST DBSKIP(1)\nRDDTEST DBSKIP(0)\n\nRDDTEST DBGOTO(1)\nRDDTEST DBSKIP(-1)\nRDDTEST DBSKIP(1)\nRDDTEST DBSKIP(5)\nRDDTEST DBSKIP(5)\nRDDTEST DBSKIP(5)\nRDDTEST DBSKIP(-1)\nRDDTEST DBSKIP(-5)\nRDDTEST DBSKIP(10)\nRDDTEST DBSKIP(-5)\nRDDTEST DBGOTO(16)\nRDDTEST DBSKIP(-1)\n\n#ifdef _TEST_SCOPE_\nRDDTEST ORDSCOPE(TOPSCOPE,'3')\nRDDTEST ORDSCOPE(BOTTOMSCOPE,'4')\nRDDTEST DBORDERINFO(DBOI_SCOPETOP)\nRDDTEST DBORDERINFO(DBOI_SCOPEBOTTOM)\n#endif\nRDDTEST DBGOTO(1)\nRDDTEST DBSKIP(1)\nRDDTEST DBGOTO(1)\nRDDTEST DBSKIP(-1)\n\nRDDTEST DBGOTO(4)\nRDDTEST DBSKIP(1)\nRDDTEST DBGOTO(4)\nRDDTEST DBSKIP(-1)\n\nRDDTEST DBGOTO(6)\nRDDTEST DBSKIP(1)\nRDDTEST DBGOTO(6)\nRDDTEST DBSKIP(-1)\n\nRDDTEST DBGOTO(7)\nRDDTEST DBSKIP(1)\nRDDTEST DBGOTO(7)\nRDDTEST DBSKIP(-1)\n\nRDDTEST DBGOTO(12)\nRDDTEST DBSKIP(1)\nRDDTEST DBGOTO(12)\nRDDTEST DBSKIP(-1)\n\nRDDTEST DBGOTO(13)\nRDDTEST DBSKIP(1)\nRDDTEST DBGOTO(13)\nRDDTEST DBSKIP(-1)\n\nRDDTEST DBGOTO(14)\nRDDTEST DBSKIP(-1)\nRDDTEST DBGOTO(16)\nRDDTEST DBSKIP(-1)\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/multiarg.prg. Provides functions: ShoutArg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n ShoutArg( 1, \"1\", 2.5, .T. )\n ShoutArg( 2, \"1\", 2.5, .T. )\n ShoutArg( 3, \"1\", 2.5, .T. )\n ShoutArg( 4, \"1\", 2.5, .T. )\n ShoutArg( 5, \"1\", 2.5, .T. )\n\n RETURN\n\nFUNCTION ShoutArg( nArg, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 )\n\n HB_SYMBOL_UNUSED( x1 )\n HB_SYMBOL_UNUSED( x2 )\n HB_SYMBOL_UNUSED( x3 )\n HB_SYMBOL_UNUSED( x4 )\n HB_SYMBOL_UNUSED( x5 )\n HB_SYMBOL_UNUSED( x6 )\n HB_SYMBOL_UNUSED( x7 )\n HB_SYMBOL_UNUSED( x8 )\n HB_SYMBOL_UNUSED( x9 )\n HB_SYMBOL_UNUSED( x10 )\n\n ? nArg, \"==\", hb_PValue( nArg )\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/restsets.prg. Provides functions: ft_RestSets. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#define FT_EXTRA_SETS 2\n#define FT_SET_CENTURY _SET_COUNT + 1\n#define FT_SET_BLINK _SET_COUNT + 2\n\nFUNCTION ft_RestSets( aOldSets )\n\n AEval( aOldSets, ;\n {| xElement, nElementNo | ;\n Set( nElementNo, xElement ) }, ;\n 1, _SET_COUNT )\n\n ft_SetCentury( aOldSets[ FT_SET_CENTURY ] )\n SetBlink( aOldSets[ FT_SET_BLINK ] )\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour Runtime Library file: src/rtl/getsys.prg. Provides 14 functions including: ReadModal, ReadModal, GetActive, GetPreValidate, GetPreValidate. Contains 7 procedures. This file implements the GET system for input field handling"}, {"role": "assistant", "content": "#ifdef HB_COMPAT_C53\n\n#include \"inkey.ch\"\n\n#define SLUPDATED 1\n#define SOACTIVEGET 8\n#define SXREADVAR 9\n\nFUNCTION ReadModal( GetList, nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )\n#else\nFUNCTION ReadModal( GetList )\n#endif\n\n LOCAL oGetList\n LOCAL oSaveGetList\n\n IF Empty( GetList )\n SetPos( MaxRow() - 1, 0 )\n RETURN .F.\n ENDIF\n\n oGetList := HBGetList():New( GetList )\n\n oSaveGetList := __GetListActive()\n#ifdef HB_COMPAT_C53\n\n\n#endif\n\n __GetListSetActive( oGetList )\n __GetListLast( oGetList )\n\n#ifdef HB_COMPAT_C53\n oGetList:ReadModal( nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )\n#else\n oGetList:ReadModal()\n#endif\n\n __GetListSetActive( oSaveGetList )\n#ifdef HB_COMPAT_C53\n\n\n#endif\n\n SetPos( MaxRow() - 1, 0 )\n\n RETURN oGetList:Updated()\n\n#ifdef HB_COMPAT_C53\nPROCEDURE GetReader( oGet, oGetList, oMenu, aMsg )\n\n HB_SYMBOL_UNUSED( oGetList )\n\n oGet:Reader( oMenu, aMsg )\n\n RETURN\n#else\nPROCEDURE GetReader( oGet )\n\n oGet:Reader()\n\n RETURN\n#endif\n\nFUNCTION GetActive( oGet )\n\n LOCAL oGetList := __GetListActive()\n\n LOCAL oGetActiveOld\n\n THREAD STATIC t_oGetActive\n\n IF oGetList == NIL\n \n IF PCount() > 0\n oGetActiveOld := t_oGetActive\n t_oGetActive := oGet\n RETURN oGetActiveOld\n ELSE\n RETURN t_oGetActive\n ENDIF\n ELSE\n IF PCount() > 0\n RETURN oGetList:GetActive( oGet )\n ELSE\n RETURN oGetList:GetActive()\n ENDIF\n ENDIF\n\n RETURN NIL\n\nPROCEDURE GetDoSetKey( bKeyBlock, oGet )\n\n LOCAL oGetList := __GetListActive()\n\n IF oGetList != NIL\n oGetList:GetDoSetKey( bKeyBlock, oGet )\n ENDIF\n\n RETURN\n\n#ifdef HB_COMPAT_C53\nPROCEDURE GetApplyKey( oGet, nKey, oGetList, oMenu, aMsg )\n\n IF ! HB_ISOBJECT( oGetList )\n oGetList := __GetListActive()\n ENDIF\n#else\nPROCEDURE GetApplyKey( oGet, nKey )\n\n LOCAL oGetList := __GetListActive()\n#endif\n\n IF oGetList != NIL\n#ifdef HB_COMPAT_C53\n oGetList:GetApplyKey( nKey, oGet, oMenu, aMsg )\n#else\n oGetList:GetApplyKey( nKey, oGet )\n#endif\n ENDIF\n\n RETURN\n\n#ifdef HB_COMPAT_C53\nFUNCTION GetPreValidate( oGet, aMsg )\n#else\nFUNCTION GetPreValidate( oGet )\n#endif\n LOCAL oGetList := __GetListActive()\n\n IF oGetList != NIL\n#ifdef HB_COMPAT_C53\n RETURN oGetList:GetPreValidate( oGet, aMsg )\n#else\n RETURN oGetList:GetPreValidate( oGet )\n#endif\n ENDIF\n\n RETURN .F.\n\n#ifdef HB_COMPAT_C53\nFUNCTION GetPostValidate( oGet, aMsg )\n#else\nFUNCTION GetPostValidate( oGet )\n#endif\n\n LOCAL oGetList := __GetListActive()\n\n IF oGetList != NIL\n#ifdef HB_COMPAT_C53\n RETURN oGetList:GetPostValidate( oGet, aMsg )\n#else\n RETURN oGetList:GetPostValidate( oGet )\n#endif\n ENDIF\n\n RETURN .F.\n\nFUNCTION ReadExit( lExit )\n RETURN Set( _SET_EXIT, lExit )\n\nFUNCTION ReadInsert( lInsert )\n RETURN Set( _SET_INSERT, lInsert )\n\nFUNCTION Updated()\n\n LOCAL oGetList := __GetListLast()\n\n RETURN iif( oGetList != NIL, oGetList:Updated(), .F. )\n\nPROCEDURE __KillRead()\n\n LOCAL oGetList := __GetListActive()\n\n IF oGetList != NIL\n oGetList:KillRead( .T. )\n ENDIF\n\n RETURN\n\nFUNCTION ReadUpdated( lUpdated )\n\n LOCAL oGetList := __GetListLast()\n\n IF oGetList != NIL\n IF PCount() > 0\n RETURN oGetList:ReadUpdated( lUpdated )\n ELSE\n RETURN oGetList:ReadUpdated()\n ENDIF\n ENDIF\n\n RETURN .F.\n\nFUNCTION ReadKill( lKill )\n\n LOCAL oGetList := __GetListActive()\n\n IF oGetList != NIL\n IF PCount() > 0\n RETURN oGetList:KillRead( lKill )\n ELSE\n RETURN oGetList:KillRead()\n ENDIF\n ENDIF\n\n RETURN .F.\n\nFUNCTION ReadFormat( bFormat )\n\n LOCAL oGetList := __GetListActive()\n\n IF oGetList != NIL\n IF PCount() > 0\n RETURN oGetList:SetFormat( bFormat )\n ELSE\n RETURN oGetList:SetFormat()\n ENDIF\n ENDIF\n\n RETURN NIL\n\nPROCEDURE __SetFormat( bFormat )\n\n LOCAL oGetList := __GetListActive()\n\n IF oGetList != NIL\n IF HB_ISEVALITEM( bFormat )\n oGetList:SetFormat( bFormat )\n ELSE\n oGetList:SetFormat()\n ENDIF\n ENDIF\n\n RETURN\n\n#define SCORE_ROW 0\n#define SCORE_COL 60\n\n#define _GET_RANGE_FROM 10\n#define _GET_RANGE_TO 11\n\nFUNCTION RangeCheck( oGet, xDummy, xLow, xHigh )\n\n LOCAL xValue\n LOCAL cMessage\n LOCAL nKey\n\n HB_SYMBOL_UNUSED( xDummy )\n\n IF ! oGet:changed\n RETURN .T.\n ENDIF\n\n xValue := oGet:varGet()\n\n IF xValue >= xLow .AND. xValue <= xHigh\n RETURN .T.\n ENDIF\n\n IF Set( _SET_SCOREBOARD )\n\n cMessage := Left( __natMsg( _GET_RANGE_FROM ) + LTrim( Transform( xLow, \"\" ) ) + ;\n __natMsg( _GET_RANGE_TO ) + LTrim( Transform( xHigh, \"\" ) ), MaxCol() )\n\n hb_DispOutAt( SCORE_ROW, Min( 60, MaxCol() - Len( cMessage ) ), cMessage )\n\n DO WHILE ( nKey := Inkey( 0 ) ) == 0\n ENDDO\n hb_keyIns( nKey )\n\n hb_DispOutAt( SCORE_ROW, Min( 60, MaxCol() - Len( cMessage ) ), Space( Len( cMessage ) ) )\n\n ENDIF\n\n RETURN .F."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/scancode.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#define SCANCODE_ESCAPE ( hb_BChar( 27 ) + hb_BChar( 1 ) )\n\nPROCEDURE Main()\n\n LOCAL cKey\n\n CLS\n ? \"Press any key, ESCape to exit:\"\n\n DO WHILE .T.\n cKey := ft_ScanCode()\n ? Str( hb_BCode( hb_BSubStr( cKey, 1, 1 ) ), 3 ) + \", \" + Str( hb_BCode( hb_BSubStr( cKey, 2, 1 ) ), 3 )\n IF cKey == SCANCODE_ESCAPE\n EXIT\n ENDIF\n ENDDO\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/clsccast.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "#define EOL chr(10)\n#xtranslate QQOUT([]) => [OUTSTD()]\n#xtranslate QOUT([]) => OUTSTD(EOL)[;OUTSTD()]\n\n#include \"hbclass.ch\"\n\nproc main()\nlocal o:=myclass4():new(), i, cbErr\n\n? DATE(), TIME(), VERSION(), OS()\n?\n\n? \"myclass1 class vars:\", str( __CLS_CNTCLSDATA(o:myclass1:classH), 3), \" => should be: 3\"\n? \"myclass2 class vars:\", str( __CLS_CNTCLSDATA(o:myclass2:classH), 3), \" => should be: 6\"\n? \"myclass3 class vars:\", str( __CLS_CNTCLSDATA(o:myclass3:classH), 3), \" => should be: 9\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"myclass4 class vars:\", str( __CLS_CNTCLSDATA(o:myclass4:classH), 3), \" => should be: 12\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \"myclass4 class vars:\", str( __CLS_CNTCLSDATA(o:classH), 3), \" => should be: 12\"\n?\n\n\n? \"instance variables [\"+ltrim(str(len(o)))+\"]:\"; ?\nfor i:=1 to len(o); ?? \"\",o[i]; next\n? \" => shoule be [0]:\"\n?\n? \"initialization...\"\no:x1:=\" X1 \"; o:y1:=\" Y1 \"; o:z1:=\" Z1 \"\no:x2:=\" X2 \"; o:y2:=\" Y2 \"; o:z2:=\" Z2 \"\no:x3:=\" X3 \"; o:y3:=\" Y3 \"; o:z3:=\" Z3 \"\no:x4:=\" X4 \"; o:y4:=\" Y4 \"; o:z4:=\" Z4 \"\n\n? \"[1] MYCLASS1 VARS:\", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, \" => should be: (x1) (y1) (z1)\"\n? \"[2] MYCLASS1 VARS:\", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, \" => should be: (x1) (y1) (z1)\"\n? \"[2] MYCLASS2 VARS:\", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, \" => should be: (x2) (y2) (z2)\"\n? \"[3] MYCLASS1 VARS:\", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, \" => should be: (x1) (y1) (z1)\"\n? \"[3] MYCLASS2 VARS:\", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, \" => should be: (x2) (y2) (z2)\"\n? \"[3] MYCLASS3 VARS:\", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, \" => should be: (x3) (y3) (z3)\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"[4] MYCLASS1 VARS:\", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, \" => should be: X1 Y1 Z1\"\n ? \"[4] MYCLASS2 VARS:\", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, \" => should be: X2 Y2 Z2\"\n ? \"[4] MYCLASS3 VARS:\", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, \" => should be: X3 Y3 Z3\"\n ? \"[4] MYCLASS4 VARS:\", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, \" => should be: X4 Y4 Z4\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \" MYCLASS1 VARS:\", o:x1, o:y1, o:z1, \" => should be: X1 Y1 Z1\"\n? \" MYCLASS2 VARS:\", o:x2, o:y2, o:z2, \" => should be: X2 Y2 Z2\"\n? \" MYCLASS3 VARS:\", o:x3, o:y3, o:z3, \" => should be: X3 Y3 Z3\"\n? \" MYCLASS4 VARS:\", o:x4, o:y4, o:z4, \" => should be: X4 Y4 Z4\"\n?\n\n? \"instance variables [\"+ltrim(str(len(o)))+\"]:\"; ?\nfor i:=1 to len(o); ?? \"\",o[i]; next\n? \" => shoule be [0]:\"\n?\n\n? \"Setting MYCLASS1 class variables...\"\no:myclass1:x1:=\"[X1]\"\no:myclass1:y1:=\"[Y1]\"\no:myclass1:z1:=\"[Z1]\"\n? \"[1] MYCLASS1 VARS:\", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, \" => should be: [X1] [Y1] [Z1]\"\n? \"[2] MYCLASS1 VARS:\", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, \" => should be: (x1) (y1) (z1)\"\n? \"[2] MYCLASS2 VARS:\", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, \" => should be: (x2) (y2) (z2)\"\n? \"[3] MYCLASS1 VARS:\", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, \" => should be: (x1) (y1) (z1)\"\n? \"[3] MYCLASS2 VARS:\", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, \" => should be: (x2) (y2) (z2)\"\n? \"[3] MYCLASS3 VARS:\", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, \" => should be: (x3) (y3) (z3)\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"[4] MYCLASS1 VARS:\", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, \" => should be: X1 Y1 Z1\"\n ? \"[4] MYCLASS2 VARS:\", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, \" => should be: X2 Y2 Z2\"\n ? \"[4] MYCLASS3 VARS:\", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, \" => should be: X3 Y3 Z3\"\n ? \"[4] MYCLASS4 VARS:\", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, \" => should be: X4 Y4 Z4\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \" MYCLASS1 VARS:\", o:x1, o:y1, o:z1, \" => should be: X1 Y1 Z1\"\n? \" MYCLASS2 VARS:\", o:x2, o:y2, o:z2, \" => should be: X2 Y2 Z2\"\n? \" MYCLASS3 VARS:\", o:x3, o:y3, o:z3, \" => should be: X3 Y3 Z3\"\n? \" MYCLASS4 VARS:\", o:x4, o:y4, o:z4, \" => should be: X4 Y4 Z4\"\n?\n\n? \"Setting MYCLASS2 class variables...\"\no:myclass2:x1:=\"{X1}\"\no:myclass2:y1:=\"{Y1}\"\no:myclass2:z1:=\"{Z1}\"\no:myclass2:x2:=\"{X2}\"\no:myclass2:y2:=\"{Y2}\"\no:myclass2:z2:=\"{Z2}\"\n? \"[1] MYCLASS1 VARS:\", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, \" => should be: [X1] [Y1] [Z1]\"\n? \"[2] MYCLASS1 VARS:\", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, \" => should be: {X1} {Y1} {Z1}\"\n? \"[2] MYCLASS2 VARS:\", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, \" => should be: {X2} {Y2} {Z2}\"\n? \"[3] MYCLASS1 VARS:\", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, \" => should be: (x1) (y1) (z1)\"\n? \"[3] MYCLASS2 VARS:\", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, \" => should be: (x2) (y2) (z2)\"\n? \"[3] MYCLASS3 VARS:\", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, \" => should be: (x3) (y3) (z3)\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"[4] MYCLASS1 VARS:\", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, \" => should be: X1 Y1 Z1\"\n ? \"[4] MYCLASS2 VARS:\", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, \" => should be: X2 Y2 Z2\"\n ? \"[4] MYCLASS3 VARS:\", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, \" => should be: X3 Y3 Z3\"\n ? \"[4] MYCLASS4 VARS:\", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, \" => should be: X4 Y4 Z4\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \" MYCLASS1 VARS:\", o:x1, o:y1, o:z1, \" => should be: X1 Y1 Z1\"\n? \" MYCLASS2 VARS:\", o:x2, o:y2, o:z2, \" => should be: X2 Y2 Z2\"\n? \" MYCLASS3 VARS:\", o:x3, o:y3, o:z3, \" => should be: X3 Y3 Z3\"\n? \" MYCLASS4 VARS:\", o:x4, o:y4, o:z4, \" => should be: X4 Y4 Z4\"\n?\n\n? \"Setting MYCLASS3 class variables...\"\no:myclass3:x1:=\"\"\no:myclass3:y1:=\"\"\no:myclass3:z1:=\"\"\no:myclass3:x2:=\"\"\no:myclass3:y2:=\"\"\no:myclass3:z2:=\"\"\no:myclass3:x3:=\"\"\no:myclass3:y3:=\"\"\no:myclass3:z3:=\"\"\n? \"[1] MYCLASS1 VARS:\", o:myclass1:x1, o:myclass1:y1, o:myclass1:z1, \" => should be: [X1] [Y1] [Z1]\"\n? \"[2] MYCLASS1 VARS:\", o:myclass2:x1, o:myclass2:y1, o:myclass2:z1, \" => should be: {X1} {Y1} {Z1}\"\n? \"[2] MYCLASS2 VARS:\", o:myclass2:x2, o:myclass2:y2, o:myclass2:z2, \" => should be: {X2} {Y2} {Z2}\"\n? \"[3] MYCLASS1 VARS:\", o:myclass3:x1, o:myclass3:y1, o:myclass3:z1, \" => should be: \"\n? \"[3] MYCLASS2 VARS:\", o:myclass3:x2, o:myclass3:y2, o:myclass3:z2, \" => should be: \"\n? \"[3] MYCLASS3 VARS:\", o:myclass3:x3, o:myclass3:y3, o:myclass3:z3, \" => should be: \"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"[4] MYCLASS1 VARS:\", o:myclass4:x1, o:myclass4:y1, o:myclass4:z1, \" => should be: X1 Y1 Z1\"\n ? \"[4] MYCLASS2 VARS:\", o:myclass4:x2, o:myclass4:y2, o:myclass4:z2, \" => should be: X2 Y2 Z2\"\n ? \"[4] MYCLASS3 VARS:\", o:myclass4:x3, o:myclass4:y3, o:myclass4:z3, \" => should be: X3 Y3 Z3\"\n ? \"[4] MYCLASS4 VARS:\", o:myclass4:x4, o:myclass4:y4, o:myclass4:z4, \" => should be: X4 Y4 Z4\"\nrecover\n ? \"ERROR: no selfclass casting\"\nend\nerrorBlock(cbErr)\n? \" MYCLASS1 VARS:\", o:x1, o:y1, o:z1, \" => should be: X1 Y1 Z1\"\n? \" MYCLASS2 VARS:\", o:x2, o:y2, o:z2, \" => should be: X2 Y2 Z2\"\n? \" MYCLASS3 VARS:\", o:x3, o:y3, o:z3, \" => should be: X3 Y3 Z3\"\n? \" MYCLASS4 VARS:\", o:x4, o:y4, o:z4, \" => should be: X4 Y4 Z4\"\n?\n\n\n? \"Setting MYCLASS4 class variables...\"\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n o:myclass4:x1:=\"|X1|\"\n o:myclass4:y1:=\"|Y1|\"\n o:myclass4:z1:=\"|Z1|\"\n o:myclass4:x2:=\"|X2|\"\n o:myclass4:y2:=\"|Y2|\"\n o:myclass4:z2:=\"|Z2|\"\n o:myclass4:x3:=\"|X3|\"\n o:myclass4:y3:=\"|Y3|\"\n o:myclass4:z3:=\"|Z3|\"\n o:myclass4:x4:=\"|X4|\"\n o:myclass4:y4:=\"|Y4|\"\n o:myclass4:z4:=\"|Z4|\"\nrecover"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour header file: include/hbgfx.ch. Defines constants: _HBGFX_CH_. Declares 5 preprocessor translations. Defines color and display constants"}, {"role": "assistant", "content": "#ifndef _HBGFX_CH_\n#define _HBGFX_CH_\n\n#include \"hbgfxdef.ch\"\n\n\n#xtranslate hb_gfxAcquireScreen() => hb_gfxPrimitive( HB_GFX_ACQUIRESCREEN )\n#xtranslate hb_gfxReleaseScreen() => hb_gfxPrimitive( HB_GFX_RELEASESCREEN )\n#xtranslate hb_gfxMakeColor( , , [, ] ) => hb_gfxPrimitive( HB_GFX_MAKECOLOR, , , [, ] )\n#xtranslate hb_gfxGetClip( , , , ) => := hb_gfxPrimitive( HB_GFX_CLIPTOP ); := hb_gfxPrimitive( HB_GFX_CLIPLEFT ); := hb_gfxPrimitive( HB_GFX_CLIPBOTTOM ); := hb_gfxPrimitive( HB_GFX_CLIPRIGHT )\n#xtranslate hb_gfxSetClip( , , , ) => hb_gfxPrimitive( HB_GFX_SETCLIP, , , , )\n#xtranslate hb_gfxDrawingMode( [] ) => hb_gfxPrimitive( HB_GFX_DRAWINGMODE[, ] )\n#xtranslate hb_gfxGetPixel( , ) => hb_gfxPrimitive( HB_GFX_GETPIXEL, , )\n#xtranslate hb_gfxPutPixel( , , ) => hb_gfxPrimitive( HB_GFX_PUTPIXEL, , , )\n#xtranslate hb_gfxLine( , , , , ) => hb_gfxPrimitive( HB_GFX_LINE, , , , , )\n#xtranslate hb_gfxRect( , , , , ) => hb_gfxPrimitive( HB_GFX_RECT, , , , , )\n#xtranslate hb_gfxFilledRect( , , , , ) => hb_gfxPrimitive( HB_GFX_FILLEDRECT, , , , , )\n#xtranslate hb_gfxCircle( , , , ) => hb_gfxPrimitive( HB_GFX_CIRCLE, , , , )\n#xtranslate hb_gfxFilledCircle( , , , ) => hb_gfxPrimitive( HB_GFX_FILLEDCIRCLE, , , , )\n#xtranslate hb_gfxEllipse( , , , , ) => hb_gfxPrimitive( HB_GFX_ELLIPSE, , , , , )\n#xtranslate hb_gfxFilledEllipse( , , , , ) => hb_gfxPrimitive( HB_GFX_FILLEDELLIPSE, , , , , )\n#xtranslate hb_gfxFloodFill( , , ) => hb_gfxPrimitive( HB_GFX_FLOODFILL, , , )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/datetime.prg. Provides 7 functions including: addmtest, bomtest, boqtest, boytest, ctodowtest. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\n#include \"hbextlng.ch\"\n\nPROCEDURE Main( cLang )\n\n LOCAL cScr\n LOCAL nChoice := 1\n LOCAL c := .T.\n LOCAL farr := { ;\n \"AddMonth( dDate ) Add a month to dDate \", ;\n \"BoM() Beginning of month \", ;\n \"BoQ() Returns first date of qtr \", ;\n \"BoY() Beginning of year \", ;\n \"CToDoW() Day name to day number \", ;\n \"CToMonth() Month name to number \", ;\n \"DaysInMonth() number of days in xMonth \", ;\n \"DaysToMonth(dDate) Returns num days to month \", ;\n \"DMY( dDate, lmode) date as DD month YY \", ;\n \"DoY( dDate ) Returns day of the year \", ;\n \"EoM( dDate ) Returns last day of month \", ;\n \"EoQ( dDate ) Returns last date of qtr \", ;\n \"EoY( dDate ) Returns last day of year \", ;\n \"IsLeap( dDate ) Returns .T. if leap year \", ;\n \"LastDayOM( dDate ) Returns num days in month \", ;\n \"MDY( dDate ) Returns stg Month DD, YY \", ;\n \"NToCDoW( nDay ) Returns name of day \", ;\n \"NToCMonth( nMth ) Returns name of month \", ;\n \"Quarter(date) Returns qtr number of date\", ;\n \"SToD( ansi date) Returns Clipper date \", ;\n \"Week( dDate, lSWN ) Returns numbef of week \", }\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n IF HB_ISSTRING( cLang )\n hb_langSelect( cLang )\n ENDIF\n\n CLS\n\n DO WHILE c\n cScr := SaveScreen( 2, 5, 24, 66 )\n\n @ 2, 5 TO 24, 66\n nChoice := AChoice( 3, 7, 23, 65, farr,,, nChoice )\n\n IF Empty( nChoice )\n RETURN\n ENDIF\n\n @ 0, 0 CLEAR TO MaxRow(), MaxCol()\n\n DO CASE\n CASE nChoice == 1\n addmtest()\n CASE nChoice == 2\n bomtest()\n CASE nChoice == 3\n boqtest()\n CASE nChoice == 4\n boytest()\n CASE nChoice == 5\n ctodowtest()\n CASE nChoice == 6\n ctomonthtest()\n CASE nChoice == 7\n dInMonthtest()\n CASE nChoice == 8\n d2month()\n CASE nChoice == 9\n dmytest()\n CASE nChoice == 10\n doytest()\n CASE nChoice == 11\n eomtest()\n CASE nChoice == 12\n eoqtest()\n CASE nChoice == 13\n eoytest()\n CASE nChoice == 14\n isleaptest()\n CASE nChoice == 15\n lastdayomtest()\n CASE nChoice == 16\n mdytest()\n CASE nChoice == 17\n ntocdowtest()\n CASE nChoice == 18\n ntocmthtest()\n CASE nChoice == 19\n qtrtest()\n CASE nChoice == 20\n stodtest()\n CASE nChoice == 21\n weektest()\n ENDCASE\n\n RestScreen( 2, 5, 24, 66, cScr )\n ENDDO\n\n RETURN\n\n\nFUNCTION addmtest()\n\n \n LOCAL getlist := {}\n LOCAL dDate := hb_SToD()\n LOCAL c := .T.\n LOCAL mnth := 0\n LOCAL nKey\n\n DO WHILE c\n @ 5, 10 SAY \"AddMonth(dDate) returns the date incremented by\"\n @ 6, 10 SAY \"the number of days in months.\"\n @ 7, 10 SAY \"Insert a date\"\n @ 8, 10 SAY \"How many months\"\n @ 7, 60 GET dDate\n @ 8, 60 GET mnth PICTURE \"99\"\n\n SET CONFIRM ON\n SET ESCAPE ON\n READ\n SET ESCAPE OFF\n SET CONFIRM ON\n\n nKey := LastKey()\n\n IF nKey == K_ESC\n c := .F.\n ELSE\n\n @ 11, 39 SAY \"The returned date is \" + DToC( AddMonth( dDate, mnth ) )\n\n SET CURSOR OFF\n Inkey( 0 )\n SET CURSOR ON\n\n ENDIF\n\n ENDDO\n\n @ 0, 0 CLEAR\n\n RETURN NIL\n\n\nFUNCTION bomtest()\n\n \n LOCAL getlist := {}\n LOCAL dDate := hb_SToD()\n LOCAL c := .T.\n LOCAL nKey\n\n DO WHILE c\n @ 5, 10 SAY \"BoM(dDate) returns the date of the first day of dDate\"\n @ 6, 10 SAY \"If dDate is 2002-10-15 (that's in yyyy-mm-dd), BoM()\"\n @ 7, 10 SAY \"should return 2002-10-01. Test it, Insert a date\"\n @ 9, 10 GET dDate\n\n SET CONFIRM ON\n SET ESCAPE ON\n READ\n SET ESCAPE OFF\n SET CONFIRM ON\n\n nKey := LastKey()\n\n IF nKey == K_ESC\n c := .F.\n ELSE\n @ 11, 10 SAY \"The returned date is \" + DToC( BoM( dDate ) )\n\n SET CURSOR OFF\n Inkey( 0 )\n SET CURSOR ON\n\n ENDIF\n\n ENDDO\n\n @ 0, 0 CLEAR\n\n RETURN NIL\n\n\nFUNCTION boqtest()\n\n \n LOCAL getlist := {}\n LOCAL dDate := hb_SToD()\n LOCAL c := .T.\n LOCAL nKey\n\n DO WHILE c\n @ 5, 10 SAY \"BoQ(dDate) returns the date of the first day of the\"\n @ 6, 10 SAY \"quarter in which dDate is situated. If dDate is\"\n @ 7, 10 SAY \"2002-10-15 (that's in yyyy-mm-dd), BoQ() should return\"\n @ 8, 10 SAY \"2002-09-01. Test it, Insert a date\"\n\n @ 9, 10 GET dDate\n\n SET CONFIRM ON\n SET ESCAPE ON\n READ\n SET ESCAPE OFF\n SET CONFIRM ON\n\n nKey := LastKey()\n\n IF nKey == K_ESC\n c := .F.\n ELSE\n @ 11, 10 SAY \"The returned date is \" + DToC( BoQ( dDate ) )\n\n SET CURSOR OFF\n Inkey( 0 )\n SET CURSOR ON\n\n ENDIF\n\n ENDDO\n\n @ 0, 0 CLEAR\n\n RETURN NIL\n\n\nFUNCTION boytest()\n\n \n LOCAL getlist := {}\n LOCAL dDate := hb_SToD()\n LOCAL c := .T.\n LOCAL nkey\n\n DO WHILE c\n @ 5, 10 SAY \"BoY(dDate) returns the date of the first day of dDate\"\n @ 6, 10 SAY \"If dDate is 2002-10-15 (that's in yyyy-mm-dd), BoY()\"\n @ 7, 10 SAY \"should return 2002-01-01. Test it, Insert a date\"\n @ 9, 10 GET dDate\n\n SET CONFIRM ON\n SET ESCAPE ON\n READ\n SET ESCAPE OFF\n SET CONFIRM ON\n\n nKey := LastKey()\n\n IF nKey == K_ESC\n c := .F.\n ELSE\n @ 11, 10 SAY \"The returned date is \" + DToC( BoY( dDate ) )\n\n SET CURSOR OFF\n Inkey( 0 )\n SET CURSOR ON\n\n dDate := hb_SToD()\n\n ENDIF\n\n ENDDO\n\n @ 0, 0 CLEAR\n\n RETURN NIL\n\n\nFUNCTION ctodowtest()\n\n \n LOCAL getlist := {}\n LOCAL cDow := Space( 9 )\n LOCAL nkey\n LOCAL c := .T.\n\n DO WHILE c\n @ 5, 10 SAY \"CToDoW(dDate) receives the name of a day of the week and \"\n @ 6, 10 SAY \"returns a number representing its position in the week\"\n @ 7, 10 SAY \"Sunday returns 1. Test it, Insert a day\"\n @ 9, 10 GET cDow\n\n SET CONFIRM ON\n SET ESCAPE ON\n READ\n SET ESCAPE OFF\n SET CONFIRM ON\n\n nKey := LastKey()\n\n IF nKey == K_ESC\n c := .F.\n ELSE\n @ 11, 10 SAY \"The day number is \" + Str( CToDoW( Upper( AllTrim( cDow ) ) ) )\n\n SET CURSOR OFF\n Inkey( 0 )\n SET CURSOR ON\n\n cDow := Space( 9 )\n\n ENDIF\n\n ENDDO\n\n @ 0, 0 CLEAR\n\n RETURN NIL\n\n\nFUNCTION ctomonthtest()\n\n \n LOCAL getlist := {}\n LOCAL cDom := Space( 9 )\n LOCAL c := .T.\n LOCAL nKey\n\n DO WHILE c\n @ 5, 10 SAY \"CToMonth(dDate) receives the name of a month and returns\"\n @ 6, 10 SAY \"a number representing its position in the month. April\"\n @ 7, 10 SAY \"returns 4. Test it, Insert a month\"\n @ 9, 10 GET cDom PICTURE \"!!!!!!!!!\"\n\n SET CONFIRM ON\n SET ESCAPE ON\n READ\n SET ESCAPE OFF\n SET CONFIRM ON\n\n cDom := AllTrim( cDom )\n\n nKey := LastKey()\n\n IF nKey == K_ESC\n c := .F.\n ELSE\n @ 11, 10 SAY \"The day number is \" + Str( CToMonth( cDom ) )\n\n SET CURSOR OFF\n Inkey( 0 )\n SET CURSOR ON\n\n cDom := Space( 9 )\n ENDIF\n\n ENDDO\n\n @ 0, 0 CLEAR\n\n RETURN NIL\n\n\nFUNCTION dInMonthtest()\n\n \n LOCAL getlist := {}\n LOCAL cMonth := Space( 9 )\n LOCAL c := .T.\n LOCAL nMonth\n LOCAL nKey\n LOCAL cLeap := Space( 1 )\n\n DO WHILE c\n @ 5, 10 SAY \"DaysInMonth() receives either the number of a month or\"\n @ 6, 10 SAY \"its name and returns the number of days in the month. \"\n @ 7, 10 SAY \"April returns 30. Test it. Insert a month number\"\n @ 8, 10 SAY \"Is it a leap year?\"\n @ 7, 60 GET cMonth PICTURE \"XXXXXXXXX\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/dispmsg.prg. Provides functions: ft_DispMsg. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"setcurs.ch\"\n\n\nFUNCTION ft_DispMsg( aInfo, cKey, nBoxTop, nBoxLeft, cnBoxString, lShadow )\n\n LOCAL xRtnVal := .F.\n LOCAL nWidest := 0\n LOCAL nBoxRight\n LOCAL nBoxBottom\n LOCAL cOldScreen\n LOCAL cOldCursor\n LOCAL cOldColor\n LOCAL i\n LOCAL j\n LOCAL nOption\n LOCAL x\n LOCAL y\n LOCAL aPos := {}\n LOCAL nLeft\n LOCAL aLeft\n\n FOR i := 1 TO Len( aInfo[ 1 ] )\n AAdd( aPos, {} )\n NEXT\n\n FOR i := 1 TO Len( aInfo[ 1 ] )\n\n DO WHILE At( \"[\", aInfo[ 1, i ] ) > 0\n x := At( \"[\", aInfo[ 1, i ] )\n y := At( \"]\", aInfo[ 1, i ] ) - 2\n AAdd( aPos[ i ], { x, y } )\n aInfo[ 1, i ] := StrTran( aInfo[ 1, i ], \"[\", \"\", 1, 1 )\n aInfo[ 1, i ] := StrTran( aInfo[ 1, i ], \"]\", \"\", 1, 1 )\n ENDDO\n\n NEXT\n\n AEval( aInfo[ 1 ], {| x | nWidest := Max( nWidest, Len( x ) ) } )\n\n \n IF nBoxLeft == NIL\n nLeft := Round( ( MaxCol() - nWidest ) / 2, 0 )\n ELSE\n nLeft := nBoxLeft + 2\n ENDIF\n\n\n IF nBoxLeft == NIL\n nBoxLeft := nLeft - 2\n ENDIF\n nBoxRight := nBoxLeft + nWidest + 3\n\n IF nBoxTop == NIL\n nBoxTop := ( MaxRow() - Len( aInfo[ 1 ] ) - 2 ) / 2 + 1\n ENDIF\n nBoxBottom := nBoxTop + Len( aInfo[ 1 ] ) + 1\n\n \n IF cnBoxString == NIL .OR. cnBoxString == 2\n cnBoxString := hb_UTF8ToStrBox( \"╔═╗║╝═╚║ \" )\n ELSEIF cnBoxString == 1\n cnBoxString := hb_UTF8ToStrBox( \"┌─┐│┘─└│ \" )\n ENDIF\n\n __defaultNIL( @lShadow, .T. )\n\n cOldScreen := SaveScreen( nBoxTop, nBoxLeft, nBoxBottom + 1, nBoxRight + 2 )\n\n cOldCursor := SetCursor( SC_NONE )\n\n \n cOldColor := SetColor( aInfo[ 2, Len( aInfo[ 2 ] ) ] )\n\n hb_DispBox( nBoxTop, nBoxLeft, nBoxBottom, nBoxRight, cnBoxString, ;\n aInfo[ 2, Len( aInfo[ 2 ] ) ] )\n IF lShadow\n hb_Shadow( nBoxTop, nBoxLeft, nBoxBottom, nBoxRight )\n ENDIF\n\n \n aLeft := Array( Len( aInfo[ 1 ] ) )\n FOR i := 1 TO Len( aInfo[ 1 ] )\n IF Len( aInfo[ 1, i ] ) == nWidest\n aLeft[ i ] := nLeft\n ELSE\n aLeft[ i ] := nLeft + Round( ( nWidest - Len( aInfo[ 1, i ] ) ) / 2, 0 )\n ENDIF\n NEXT\n\n \n FOR i := 2 TO Len( aInfo[ 2 ] )\n IF aInfo[ 2, i ] == NIL\n aInfo[ 2, i ] := aInfo[ 2, i - 1 ]\n ENDIF\n NEXT\n\n \n FOR i := 1 TO Len( aInfo[ 1 ] )\n hb_DispOutAt( nBoxTop + i, aLeft[ i ], aInfo[ 1, i ], aInfo[ 2, i ] )\n NEXT\n\n \n FOR i := 1 TO Len( aPos )\n FOR j := 1 TO Len( aPos[ i ] )\n\n ft_SetAttr( nBoxTop + i, ;\n aPos[ i, j, 1 ] + aLeft[ i ] - 1, ;\n nBoxTop + i, ;\n aPos[ i, j, 2 ] + aLeft[ i ] - 1, ;\n ft_Color2N( aInfo[ 2, Len( aInfo[ 2 ] ) ] ) )\n NEXT\n NEXT\n\n IF cKey != NIL\n IF Len( cKey ) == 1\n nOption := ft_SInkey( 0 )\n IF Upper( Chr( nOption ) ) == cKey\n xRtnVal := .T.\n ENDIF\n ELSE\n nOption := 0\n DO WHILE hb_BAt( Upper( Chr( nOption ) ), Upper( cKey ) ) == 0\n nOption := ft_SInkey( 0 )\n ENDDO\n xRtnVal := nOption\n ENDIF\n RestScreen( nBoxTop, nBoxLeft, nBoxBottom + 1, nBoxRight + 2, cOldScreen )\n ENDIF\n\n SetColor( cOldColor )\n SetCursor( cOldCursor )\n\n RETURN xRtnVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/setatlik.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL cWildcard := \" \"\n\n ctinit()\n\n ? \"Begin test of SetAtLike()\"\n ? \" Default mode should be 0, is................................\", SetAtLike()\n ? \" Setting mode to 1, return value should be 0, is.............\", SetAtLike( 1 )\n ? \" Mode setting should now be 1, is............................\", SetAtLike()\n ? \" Setting mode to 0 again, return value should still be 1, is \", SetAtLike( 0 )\n ?\n SetAtLike( , @cWildcard )\n ? \" Default wildcard character should be '?', is................\", cWildcard\n SetAtLike( , \"#\" )\n SetAtLike( , @cWildcard )\n ? \" Setting wildcard to '#' and calling SetAtLike( , @cWildcard )\"\n ? \" should yield '#' for cWildcard, does......................\", cWildcard\n ? \"End test of SetAtLike()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour test program: tests/mt/mttest06.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "#define N_THREADS 5\n#define N_COUNT 1000000\n#define N_INIT 100\n\nmemvar m_var\n\nproc main()\n local aThreads := {}, i, nSum\n\n ? Version()\n private m_var := N_INIT\n ? \"Starting threads: \"\n for i :=1 to N_THREADS\n aadd( aThreads, hb_threadStart( @thFunc() ) )\n ?? \"<\" + hb_ntos( i ) + \">\"\n next\n ? \"Waiting for threads...\"\n nSum := 0\n aEval( aThreads, {| x | hb_threadJoin( x, @i ), nSum += i } )\n ? \"Threads joined\"\n ? \"Sum of results:\", nSum\n ? \" should be:\", N_THREADS\n iif( nSum == N_THREADS * ( N_INIT + N_COUNT ), \"OK\", \"ERROR\" )\nreturn\n\nstatic func thFunc()\n private m_var := N_INIT - 10\nreturn do()\n\nstatic func do()\n local i\n private m_var := m_var + 10\n for i := 1 to N_COUNT\n ++m_var\n next\nreturn m_var"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Header file for contribution module 'hbtpathy' (Telepath communication library): contrib/hbtpathy/telepath.ch. Defines 10 constants including: TELEPATH_CH_, TP_MAXPORTS, TE_PARAM, TE_NOPORT, TE_CLOSED. Defines file I/O constants"}, {"role": "assistant", "content": "#ifndef TELEPATH_CH_\n#define TELEPATH_CH_\n\n#define TP_MAXPORTS 8\n\n\n#define TE_PARAM -1 \n#define TE_NOPORT -2 \n#define TE_CLOSED -3 \n#define TE_CONFL -4 \n#define TE_TMOUT -5 \n#define TE_NDCD -6 \n#define TE_ESCAPE -7 \n#define TE_LENGTH -8 \n#define TE_CANCEL -9 \n#define TE_NOHDL -10 \n\n#define TE_UCANCEL -50 \n#define TE_RCANCEL -51 \n#define TE_STARTTM -52 \n#define TE_BLOCKTM -53 \n#define TE_ACKTM -54 \n#define TE_SENDTM -55 \n#define TE_CLEARTM -56 \n#define TE_NAK -57 \n#define TE_BADACK -58 \n#define TE_BADBLK -59 \n#define TE_LONGBLK -60 \n#define TE_ERRMAX -61 \n#define TE_DUPBLK -62 \n#define TE_PROTO -63 \n#define TE_CKSUM -64 \n#define TE_HDRTM -65 \n\n#define TE_DISKFULL -100 \n#define TE_NOFILE -102 \n#define TE_NOPATH -103 \n#define TE_MFILE -104 \n#define TE_ACCESS -105 \n\n\n#define TXS_START 1 \n#define TXS_SFILE 2 \n#define TXS_NEWNAME 3 \n#define TXS_SDATA 4 \n#define TXS_BLOCK 5 \n#define TXS_ERROR 6 \n#define TXS_ABFILE 7 \n#define TXS_ABORT 8 \n#define TXS_WEND 9 \n#define TXS_EFILE 10 \n#define TXS_END 11 \n\n#define TP_32MAGIC 0x2144DF1C\n\n\n#define THS_RDSR 1 \n#define THS_RCTS 2 \n#define THS_RXOFF 4 \n#define THS_RDCD 8 \n#define THS_ADTR 16 \n#define THS_CDTR 32 \n#define THS_ARTS 64 \n#define THS_CRTS 128 \n#define THS_SXOFF 256 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbdoc' (Documentation generation utilities): contrib/hbdoc/_html.prg. Defines classes: GenerateHTML. Provides functions: GitRev. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"hbver.ch\"\n\n#define EXTENSION \".html\"\n\n#define STYLEFILE \"hbdoc.css\"\n\nCREATE CLASS GenerateHTML INHERIT TPLGenerate\n\n HIDDEN:\n\n METHOD RecreateStyleDocument( cStyleFile )\n METHOD OpenTagInline( cText, ... )\n METHOD OpenTag( cText, ... )\n METHOD Tagged( cText, cTag, ... )\n METHOD CloseTagInline( cText )\n METHOD CloseTag( cText )\n METHOD AppendInline( cText, cFormat, lCode )\n METHOD Append( cText, cFormat, lCode )\n METHOD Space() INLINE ::cFile += \", \", Self\n METHOD Spacer() INLINE ::cFile += hb_eol(), Self\n METHOD Newline() INLINE ::cFile += \"
\" + hb_eol(), Self\n METHOD NewFile()\n\n CLASS VAR lCreateStyleDocument AS LOGICAL INIT .T.\n VAR TargetFilename AS STRING INIT \"\"\n\n EXPORTED:\n\n METHOD NewIndex( cDir, cFilename, cTitle, cLang )\n METHOD NewDocument( cDir, cFilename, cTitle, cLang )\n METHOD AddEntry( oEntry )\n METHOD AddReference( oEntry, cReference, cSubReference )\n METHOD BeginSection( cSection, cFilename )\n METHOD EndSection( cSection, cFilename )\n METHOD Generate()\n\n METHOD WriteEntry( cField, cContent, lPreformatted ) HIDDEN\n\n VAR nStart INIT hb_MilliSeconds()\n VAR nIndent INIT 0\n\nENDCLASS\n\nMETHOD NewFile() CLASS GenerateHTML\n\n ::cFile += \"\" + hb_eol()\n\n ::OpenTag( \"html\", \"lang\", StrTran( ::cLang, \"_\", \"-\" ) )\n ::Spacer()\n\n ::OpenTag( \"meta\", \"charset\", \"utf-8\" )\n ::OpenTag( \"meta\", \"name\", \"referrer\", \"content\", \"origin\" )\n ::OpenTag( \"meta\", \"name\", \"viewport\", \"content\", \"initial-scale=1\" )\n ::Spacer()\n\n ::OpenTag( \"meta\", \"name\", \"generator\", \"content\", \"hbdoc\" )\n ::OpenTag( \"meta\", \"name\", \"keywords\", \"content\", ;\n \"Harbour, Clipper, xBase, database, Free Software, GPL, compiler, cross-platform, 32-bit, 64-bit\" )\n ::Spacer()\n\n IF ::lCreateStyleDocument\n ::lCreateStyleDocument := .F.\n ::RecreateStyleDocument( STYLEFILE )\n ENDIF\n\n ::Append( ::cTitle, \"title\" )\n ::Spacer()\n\n ::OpenTag( \"link\", \"rel\", \"stylesheet\", \"href\", STYLEFILE )\n ::Spacer()\n\n ::OpenTag( \"body\" )\n ::Spacer()\n\n ::OpenTag( \"header\" )\n ::Append( ::cTitle, \"h1\" )\n ::CloseTag( \"header\" )\n ::Spacer()\n\n ::OpenTag( \"main\" )\n\n RETURN Self\n\nSTATIC FUNCTION GitRev()\n\n LOCAL cStdOut := \"\"\n\n hb_processRun( \"git rev-parse --short HEAD\",, @cStdOut )\n\n RETURN hb_StrReplace( cStdOut, Chr( 13 ) + Chr( 10 ) )\n\nMETHOD Generate() CLASS GenerateHTML\n\n LOCAL cRevision := GitRev()\n\n ::Spacer()\n ::CloseTag( \"main\" )\n\n ::Spacer()\n ::OpenTag( \"footer\" )\n ::Append( \"Generated by hbdoc on \" + hb_TToC( hb_DateTime() - ( hb_UTCOffset() / 86400 ), \"yyyy-mm-dd\", \"hh:mm\" ) + \" UTC\", \"div\" )\n\n ::OpenTagInline( \"div\" )\n ::AppendInline( \"Based on commit \" )\n #if defined( HB_VERSION_URL_BASE )\n ::OpenTagInline( \"a\", \"href\", hb_Version( HB_VERSION_URL_BASE ) + \"tree/\" + cRevision )\n #endif\n ::AppendInline( cRevision )\n #if defined( HB_VERSION_URL_BASE )\n ::CloseTagInline( \"a\" )\n #endif\n ::CloseTag( \"div\" )\n\n ::CloseTag( \"footer\" )\n\n ::super:Generate()\n\n\n RETURN Self\n\nMETHOD NewDocument( cDir, cFilename, cTitle, cLang ) CLASS GenerateHTML\n\n ::super:NewDocument( cDir, cFilename, cTitle, EXTENSION, cLang )\n ::NewFile()\n\n RETURN Self\n\nMETHOD NewIndex( cDir, cFilename, cTitle, cLang ) CLASS GenerateHTML\n\n ::super:NewIndex( cDir, cFilename, cTitle, EXTENSION, cLang )\n ::NewFile()\n\n RETURN Self\n\nMETHOD BeginSection( cSection, cFilename ) CLASS GenerateHTML\n\n cSection := SymbolToHTMLID( cSection )\n\n IF ::IsIndex()\n IF cFilename == ::cFilename\n ::OpenTagInline( \"div\", \"id\", cSection ):AppendInline( cSection, \"h\" + hb_ntos( ::Depth + 2 ) ):CloseTag( \"div\" )\n ELSE\n ::OpenTag( \"a\", \"href\", cFilename + ::cExtension + \"#\" + cSection ):Append( cSection, \"h\" + hb_ntos( ::Depth + 2 ) ):CloseTag( \"a\" )\n ENDIF\n ELSE\n ::OpenTagInline( \"div\", \"id\", cSection ):AppendInline( cSection, \"h\" + hb_ntos( ::Depth + 2 ) ):CloseTag( \"div\" )\n ENDIF\n ::TargetFilename := cFilename\n ::Depth++\n\n RETURN Self\n\nMETHOD EndSection( cSection, cFilename ) CLASS GenerateHTML\n\n HB_SYMBOL_UNUSED( cSection )\n HB_SYMBOL_UNUSED( cFilename )\n ::Depth--\n\n RETURN Self\n\nMETHOD AddReference( oEntry, cReference, cSubReference ) CLASS GenerateHTML\n\n IF HB_ISOBJECT( oEntry ) .AND. oEntry:ClassName() == \"ENTRY\"\n ::OpenTag( \"a\", \"href\", ::TargetFilename + ::cExtension + \"#\" + oEntry:_filename ):Append( oEntry:fld[ \"NAME\" ] ):CloseTag( \"a\" ):Append( oEntry:fld[ \"ONELINER\" ] ):Newline()\n ELSE\n IF HB_ISSTRING( cSubReference )\n ::OpenTag( \"a\", \"href\", cReference + ::cExtension + \"#\" + cSubReference ):Append( oEntry ):CloseTag( \"a\" ):Newline()\n ELSE\n ::OpenTag( \"a\", \"href\", cReference + ::cExtension ):Append( oEntry ):CloseTag( \"a\" ):Newline()\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD AddEntry( oEntry ) CLASS GenerateHTML\n\n LOCAL item\n LOCAL cEntry\n\n ::Spacer()\n ::OpenTag( \"section\", \"id\", SymbolToHTMLID( oEntry:_filename ) )\n\n FOR EACH item IN FieldIDList()\n IF item == \"NAME\"\n cEntry := oEntry:fld[ \"NAME\" ]\n IF \"(\" $ cEntry .OR. Upper( cEntry ) == cEntry \n ::OpenTagInline( \"h4\" ):OpenTagInline( \"code\" ):AppendInline( cEntry ):CloseTagInline( \"code\" ):CloseTag( \"h4\" )\n ELSE\n ::OpenTagInline( \"h4\" ):AppendInline( cEntry ):CloseTag( \"h4\" )\n ENDIF\n ELSEIF oEntry:IsField( item ) .AND. oEntry:IsOutput( item ) .AND. Len( oEntry:fld[ item ] ) > 0\n ::WriteEntry( item, oEntry:fld[ item ], oEntry:IsPreformatted( item ) )\n ENDIF\n NEXT\n\n ::CloseTag( \"section\" )\n\n RETURN Self\n\nMETHOD PROCEDURE WriteEntry( cField, cContent, lPreformatted ) CLASS GenerateHTML\n\n STATIC s_class := { ;\n \"NAME\" => \"d-na\", ;\n \"ONELINER\" => \"d-ol\", ;\n \"EXAMPLES\" => \"d-ex\", ;\n \"TESTS\" => \"d-te\" }\n\n LOCAL cTagClass\n LOCAL cCaption\n LOCAL lFirst\n LOCAL tmp, tmp1\n LOCAL cLine\n LOCAL lCode, lTable, lTablePrev, cHeaderClass\n\n IF ! Empty( cContent )\n\n cTagClass := hb_HGetDef( s_class, cField, \"d-it\" )\n\n IF ! HB_ISNULL( cCaption := FieldCaption( cField ) )\n ::Tagged( cCaption, \"div\", \"class\", \"d-d\" )\n ENDIF\n\n DO CASE\n CASE lPreformatted \n\n ::OpenTag( \"pre\", \"class\", cTagClass )\n ::Append( cContent,, .T. )\n ::CloseTag( \"pre\" )\n\n CASE cField == \"SEEALSO\"\n\n ::OpenTagInline( \"div\", \"class\", cTagClass )\n lFirst := .T.\n FOR EACH tmp IN hb_ATokens( cContent, \",\" )\n tmp := AllTrim( tmp )\n IF ! HB_ISNULL( tmp )\n \n tmp1 := Parse( tmp, \"(\" )\n IF lFirst\n lFirst := .F.\n ELSE\n ::Space()\n ENDIF\n ::OpenTagInline( \"code\" ):OpenTagInline( \"a\", \"href\", \"#\" + SymbolToHTMLID( tmp1 ) ):AppendInline( tmp ):CloseTagInline( \"a\" ):CloseTagInline( \"code\" )\n ENDIF\n NEXT\n ::CloseTag( \"div\" )\n\n CASE cField == \"SYNTAX\"\n\n ::OpenTagInline( \"div\", \"class\", cTagClass )\n DO WHILE ! HB_ISNULL( cContent )\n ::OpenTagInline( \"code\" )\n ::AppendInline( Indent( Parse( @cContent, hb_eol() ), 0, -1,, .T. ),, .F. )\n ::CloseTagInline( \"code\" )\n ENDDO\n ::CloseTag( \"div\" )\n\n OTHERWISE\n\n ::OpenTag( \"div\", \"class\", cTagClass )\n ::nIndent++\n\n lTable := .F.\n\n DO WHILE ! HB_ISNULL( cContent )\n\n lCode := .F.\n lTablePrev := lTable\n\n tmp1 := \"\"\n DO WHILE ! HB_ISNULL( cContent )\n\n cLine := Parse( @cContent, hb_eol() )\n\n DO CASE\n CASE hb_LeftEq( LTrim( cLine ), \"```\" )\n IF lCode\n EXIT\n ELSE\n lCode := .T.\n ENDIF\n CASE cLine == \"\"\n lCode := .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour Runtime Library file: src/rtl/tgetint.prg. Provides functions: __Get, __GetA. This file implements object-oriented classes using Harbour's class system"}, {"role": "assistant", "content": "REQUEST HB_PValue\n\nFUNCTION __Get( bSetGet, cVarName, cPicture, bValid, bWhen )\n\n LOCAL oGet\n\n IF ! HB_ISSTRING( cVarName )\n RETURN NIL\n ENDIF\n\n IF ! HB_ISEVALITEM( bSetGet )\n IF FieldPos( cVarName ) > 0\n bSetGet := FieldWBlock( cVarName, Select() )\n ELSEIF ( bSetGet := MemVarBlock( cVarName ) ) == NIL\n \n bSetGet := hb_macroBlock( \"iif(HB_PValue(1)==NIL,\" + cVarName + \",\" + cVarName + \":=hb_PValue(1))\" )\n ENDIF\n ENDIF\n\n \n Eval( bSetGet )\n\n oGet := GetNew( ,, bSetGet, cVarName, cPicture )\n\n oGet:PreBlock := bWhen\n oGet:PostBlock := bValid\n\n RETURN oGet\n\nFUNCTION __GetA( bGetArray, cVarName, cPicture, bValid, bWhen, aIndex )\n\n LOCAL oGet\n\n IF ! HB_ISSTRING( cVarName ) .OR. ! HB_ISARRAY( aIndex )\n RETURN NIL\n ENDIF\n\n IF ! HB_ISEVALITEM( bGetArray )\n \n IF FieldPos( cVarName ) > 0\n bGetArray := FieldWBlock( cVarName, Select() )\n ELSE\n DO WHILE ( bGetArray := MemVarBlock( cVarName ) ) == NIL\n __mvGet( cVarName )\n ENDDO\n ENDIF\n ENDIF\n\n IF ! ValType( Eval( bGetArray ) ) $ \"AH\"\n RETURN NIL\n ENDIF\n\n oGet := GetNew( ,, bGetArray, cVarName, cPicture )\n oGet:SubScript := aIndex\n\n oGet:PreBlock := bWhen\n oGet:PostBlock := bValid\n\n RETURN oGet"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour contribution module 'gtwvw' (): contrib/gtwvw/tests/inpfocus.prg. Provides 10 functions including: CreateToolbar, CreateStatusbar, MenuAction, OpenNewWindow, CloseLastWindow. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"gtwvw\"\n\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\n\n#define MB_OK 0\n#define MB_OKCANCEL 1\n#define MB_ABORTRETRYIGNORE 2\n#define MB_YESNOCANCEL 3\n#define MB_YESNO 4\n#define MB_RETRYCANCEL 5\n\n\n#define MB_ICONHAND 16 \n#define MB_ICONQUESTION 32 \n#define MB_ICONEXCLAMATION 48 \n#define MB_ICONASTERISK 64 \n\n\n#define STD_DELETE 5\n#define STD_FILENEW 6\n\n\n#define VIEW_PARENTFOLDER 8\n\n\n#define IDM_OPENWIN 100\n#define IDM_CLOSEWIN 101\n#define IDM_ARRANGEWIN 102\n\n\n#define _MAX_WINNUM 10\n\n\nSTATIC s_akeyhandlers[ _MAX_WINNUM ]\n\nPROCEDURE Main()\n\n LOCAL ch\n\n#if defined( __HBSCRIPT__HBSHELL ) .AND. defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVW\" )\n#endif\n\n IF ! SetMode( 25, 80 )\n wvw_MessageBox( 0, \"Cannot set to (25,80) screen\", \"Warning\", MB_OK + MB_ICONEXCLAMATION )\n ENDIF\n SetColor( \"W*/N+\" )\n CLS\n SetCursor( SC_NONE )\n @ 0, 0 SAY PadC( \"This will demonstrate how to handle input on non-topmost window\", MaxCol() + 1 )\n @ 1, 0 SAY PadC( \"(Sorry that currently caret is shown on topmost window only)\", MaxCol() + 1 )\n\n CreateToolbar( 0 )\n CreateStatusbar( 0 )\n\n ch := Inkey( 0 )\n DO WHILE ch != K_ESC\n IF ch == wvw_SetMenuKeyEvent( 0 )\n MenuAction( 0, wvw_GetLastMenuEvent( 0 ) )\n ENDIF\n ch := Inkey( 0 )\n ENDDO\n\n wvw_MessageBox( 0, \"Thanks for trying this program\", \"Goodbye\", MB_OK )\n\n \n RETURN \n\n\nSTATIC FUNCTION CreateToolbar( nWinNum )\n\n LOCAL nSysBitmap := 1 \n LOCAL lDisplayText := .F. \n LOCAL hWndTB\n\n wvw_tbDestroy( nWinNum ) \n\n hWndTB := wvw_tbCreate( nWinNum, lDisplayText, NIL, nSysBitmap )\n\n IF hWndTB == 0\n wvw_MessageBox( nWinNum, \"FAILED to create toolbar\", \"Error\", MB_OK + MB_ICONEXCLAMATION )\n RETURN .F.\n ENDIF\n\n \n wvw_tbAddButton( nWinNum, IDM_OPENWIN, STD_FILENEW, \"Open a new typewriter window\", 1 )\n wvw_tbAddButton( nWinNum, IDM_CLOSEWIN, STD_DELETE, \"Close last window\", 1 )\n wvw_tbAddButton( nWinNum, IDM_ARRANGEWIN, VIEW_PARENTFOLDER, \"Reposition all windows\", 2 )\n\n RETURN .T. \n\nSTATIC FUNCTION CreateStatusbar( nWinNum )\n\n LOCAL hWndSB\n\n wvw_sbDestroy( nWinNum ) \n hWndSB := wvw_sbCreate( nWinNum )\n IF hWndSB == 0\n wvw_MessageBox( nWinNum, \"FAILED to create statusbar\", \"Error\", MB_OK + MB_ICONEXCLAMATION )\n RETURN .F.\n ENDIF\n\n RETURN .T. \n\n\nSTATIC FUNCTION MenuAction( nWinNum, nCommand )\n\n DO CASE\n CASE nCommand == IDM_OPENWIN\n OpenNewWindow()\n CASE nCommand == IDM_CLOSEWIN\n CloseLastWindow()\n CASE nCommand == IDM_ARRANGEWIN\n wvw_XReposWindow()\n OTHERWISE\n wvw_MessageBox( nWinNum, \"Unknown menu command\", \"Internal Error\", MB_OK + MB_ICONEXCLAMATION )\n ENDCASE\n\n RETURN NIL\n\n\nSTATIC FUNCTION OpenNewWindow()\n\n LOCAL nWinNum := wvw_nNumWindows()\n LOCAL ctitle, nrow1, ncol1, nrow2, ncol2\n LOCAL ch\n\n IF nWinNum > _MAX_WINNUM\n wvw_MessageBox( nWinNum - 1, \"Sorry, I don't think you can handle that many of windows :-)\", ;\n \"Sorry\", MB_OK + MB_ICONASTERISK )\n RETURN .F.\n ENDIF\n\n \n ctitle := \"Win #\" + hb_ntos( nWinNum )\n nrow1 := 4 + ( nWinNum - 1 )\n ncol1 := 1 + ( nWinNum - 1 )\n SetColor( \"W+/N\" )\n IF wvw_nOpenWindow( ctitle, nrow1, ncol1, nrow2, ncol2, NIL, 0 ) != nWinNum\n \n wvw_MessageBox( 0, \"Something horrible has happened, program aborted\", ;\n \"Internal Error\", MB_OK + MB_ICONHAND )\n QUIT\n ENDIF\n wvw_NoClose( nWinNum ) \n\n \n IF nWinNum > 1\n s_akeyhandlers[ nWinNum - 1 ] := {| n, ch | KeyHandler( n, ch ) }\n ENDIF\n\n \n SetCursor( SC_NORMAL )\n ch := Inkey( 0 )\n DO WHILE ch != K_ESC\n typing( ch )\n ch := Inkey( 0 )\n ENDDO\n\n \n wvw_lCloseWindow()\n\n \n IF nWinNum > 1\n s_akeyhandlers[ nWinNum - 1 ] := NIL\n ELSEIF nWinNum == 1\n SetCursor( SC_NONE )\n ENDIF\n\n RETURN .T. \n\n\nSTATIC FUNCTION CloseLastWindow()\n\n LOCAL nWinNum := wvw_nNumWindows() - 1\n\n wvw_nSetCurWindow( nWinNum )\n hb_keyPut( K_ESC )\n\n RETURN NIL\n\nSTATIC FUNCTION KeyHandler( nWinNum, ch )\n\n LOCAL nOldWin := wvw_nSetCurWindow( nWinNum )\n\n typing( ch )\n wvw_nSetCurWindow( nOldWin )\n\n RETURN NIL\n\nSTATIC FUNCTION typing( ch )\n\n IF ch >= 0 .AND. ch <= 255 \n ?? hb_keyChar( ch )\n IF ch == K_ENTER\n ?? Chr( 10 )\n ELSEIF ch == K_BS\n ?? \" \" + Chr( 8 )\n ENDIF\n ENDIF\n\n RETURN NIL\n\n\n#define WM_COMMAND 0x0111\n#define WM_CHAR 0x0102\n\n\nFUNCTION WVW_INPUTFOCUS( nWinNum, hWnd, message, wParam, lParam )\n\n LOCAL wParamLow := wvw_LOWORD( wParam )\n LOCAL nCommand, ch\n\n HB_SYMBOL_UNUSED( hWnd )\n HB_SYMBOL_UNUSED( lParam )\n\n\n IF message == WM_COMMAND .AND. nWinNum == 0 \n nCommand := wParamLow\n MenuAction( 0, nCommand )\n RETURN .T.\n ENDIF\n\n \n IF nWinNum == 0\n RETURN .F.\n ENDIF\n\n \n DO CASE\n CASE message == WM_CHAR\n ch := wParam\n Eval( s_akeyhandlers[ nWinNum ], nWinNum, ch )\n RETURN .T.\n OTHERWISE\n \n RETURN .T.\n ENDCASE\n\n\n RETURN .F. \n\n\nSTATIC FUNCTION winMaxRow( nWinNum )\n\n LOCAL nOldWin := wvw_nSetCurWindow( nWinNum )\n LOCAL nmaxrow := MaxRow()\n\n wvw_nSetCurWindow( nOldWin )\n\n RETURN nmaxrow\n\n\nSTATIC FUNCTION winMaxCol( nWinNum )\n\n LOCAL nOldWin := wvw_nSetCurWindow( nWinNum )\n LOCAL nmaxCol := MaxCol()\n\n wvw_nSetCurWindow( nOldWin )\n\n RETURN nmaxCol"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbsqlit3' (SQLite3 database client library): contrib/hbsqlit3/errstr.prg. Provides functions: hb_sqlite3_errstr_short. This file handles database operations"}, {"role": "assistant", "content": "#include \"hbsqlit3.ch\"\n\nFUNCTION hb_sqlite3_errstr_short( nError )\n\n IF ! HB_ISNUMERIC( nError )\n RETURN \"HB_SQLITE_INVALID\"\n ENDIF\n\n SWITCH nError\n CASE SQLITE_OK ; RETURN \"SQLITE_OK\"\n CASE SQLITE_ERROR ; RETURN \"SQLITE_ERROR\"\n CASE SQLITE_INTERNAL ; RETURN \"SQLITE_INTERNAL\"\n CASE SQLITE_PERM ; RETURN \"SQLITE_PERM\"\n CASE SQLITE_ABORT ; RETURN \"SQLITE_ABORT\"\n CASE SQLITE_BUSY ; RETURN \"SQLITE_BUSY\"\n CASE SQLITE_LOCKED ; RETURN \"SQLITE_LOCKED\"\n CASE SQLITE_NOMEM ; RETURN \"SQLITE_NOMEM\"\n CASE SQLITE_READONLY ; RETURN \"SQLITE_READONLY\"\n CASE SQLITE_INTERRUPT ; RETURN \"SQLITE_INTERRUPT\"\n CASE SQLITE_IOERR ; RETURN \"SQLITE_IOERR\"\n CASE SQLITE_CORRUPT ; RETURN \"SQLITE_CORRUPT\"\n CASE SQLITE_NOTFOUND ; RETURN \"SQLITE_NOTFOUND\"\n CASE SQLITE_FULL ; RETURN \"SQLITE_FULL\"\n CASE SQLITE_CANTOPEN ; RETURN \"SQLITE_CANTOPEN\"\n CASE SQLITE_PROTOCOL ; RETURN \"SQLITE_PROTOCOL\"\n CASE SQLITE_EMPTY ; RETURN \"SQLITE_EMPTY\"\n CASE SQLITE_SCHEMA ; RETURN \"SQLITE_SCHEMA\"\n CASE SQLITE_TOOBIG ; RETURN \"SQLITE_TOOBIG\"\n CASE SQLITE_CONSTRAINT ; RETURN \"SQLITE_CONSTRAINT\"\n CASE SQLITE_MISMATCH ; RETURN \"SQLITE_MISMATCH\"\n CASE SQLITE_MISUSE ; RETURN \"SQLITE_MISUSE\"\n CASE SQLITE_NOLFS ; RETURN \"SQLITE_NOLFS\"\n CASE SQLITE_AUTH ; RETURN \"SQLITE_AUTH\"\n CASE SQLITE_FORMAT ; RETURN \"SQLITE_FORMAT\"\n CASE SQLITE_RANGE ; RETURN \"SQLITE_RANGE\"\n CASE SQLITE_NOTADB ; RETURN \"SQLITE_NOTADB\"\n CASE SQLITE_ROW ; RETURN \"SQLITE_ROW\"\n CASE SQLITE_DONE ; RETURN \"SQLITE_DONE\"\n ENDSWITCH\n\n RETURN \"HB_SQLITE_UNKNOWN_\" + hb_ntos( nError )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/tests/antialia.prg. Contains procedures: Main. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbgd\"\n\n#define IMAGES_IN \"imgs_in\" + hb_ps()\n#define IMAGES_OUT \"imgs_out\" + hb_ps()\n\nPROCEDURE Main()\n\n LOCAL im\n LOCAL white, blue\n\n\n im := gdImageCreatePalette( 100, 100 ) \n\n \n blue := gdImageColorAllocate( im, 0, 0, 255 )\n\n \n gdImageLine( im, 0, 0, 99, 40, blue )\n\n \n gdImageSetAntiAliased( im, blue )\n\n \n gdImageLine( im, 0, 40, 99, 80, gdAntiAliased )\n\n \n gdImageJpeg( im, IMAGES_OUT + \"antialiasedpal.jpg\" )\n\n \n im := gdImageCreateTrueColor( 100, 100 )\n\n \n white := gdTrueColor( 255, 255, 255 )\n gdImageFilledRectangle( im, 0, 0, 100, 100, white )\n\n \n blue := gdImageColorAllocate( im, 0, 0, 255 )\n\n \n gdImageLine( im, 0, 0, 99, 40, blue )\n\n \n gdImageSetAntiAliased( im, blue )\n\n \n gdImageLine( im, 0, 40, 99, 80, gdAntiAliased )\n\n \n gdImageJpeg( im, IMAGES_OUT + \"antialiasedtrue.jpg\" )\n\n ?\n ? \"Look at \" + IMAGES_OUT + \" folder for output images\"\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/mt/mttest04.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifdef __XHARBOUR__\n #xtranslate hb_threadStart( ) => StartThread( )\n #xtranslate hb_threadJoin( ) => JoinThread( )\n#endif\n\n#define N_THREADS 5\n\nstatic s_nVar1 := 0\nstatic s_nVar2 := 0\nstatic s_aCounters\nstatic s_hMutex\n\nproc main()\n local aThreads, i, lEnd, nSum\n ? Version()\n ? \"Main start\"\n s_aCounters := array( N_THREADS )\n aFill( s_aCounters, 0 )\n aThreads := {}\n s_hMutex := hb_mutexCreate()\n lEnd := .F.\n ? \"Starting threads: \"\n for i := 1 to N_THREADS\n aadd( aThreads, hb_threadStart( @thFunc(), i, @lEnd ) )\n ?? \"<\" + hb_ntos( i ) + \">\"\n next\n ? \"Wait 5 seconds or hit any key...\"\n inkey( 5 )\n lEnd := .T.\n ? \"Waiting for threads...\"\n aEval( aThreads, {| x | hb_threadJoin( x ) } )\n ? \"Threads joined\"\n nSum := 0\n aEval( s_aCounters, {| x | nSum += x } )\n ? \"Sum of thread local counters:\", nSum\n ? \"Protected item result.......:\", s_nVar2, ;\n iif( nSum == s_nVar2, \"OK\", \"ERROR\" )\n ? \"Unprotected item result.....:\", s_nVar1, \"*\"\n ? \" * - can be different then local sum on real multi-CPU systems\"\n ? \"End of main\"\nreturn\n\nproc thFunc( nThread, lEnd )\n while ! lEnd\n s_nVar1++\n hb_mutexLock( s_hMutex )\n s_nVar2++\n hb_mutexUnLock( s_hMutex )\n s_aCounters[ nThread ]++\n enddo\nreturn"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charadd.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#else\n#define hb_BChar( n ) Chr( n )\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CharAdd()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharAdd( \"012345678\", hb_BChar( 1 ) ) == \"123456789\" ? -> \"' + CharAdd( \"012345678\", hb_BChar( 1 ) ) + '\"'\n ? ' CharAdd( \"012345678\", hb_BChar( 1 ) + hb_BChar( 2 ) ) == \"133557799\" ? -> \"' + CharAdd( \"012345678\", hb_BChar( 1 ) + hb_BChar( 2 ) ) + '\"'\n ? ' CharAdd( \"123456789\", hb_BChar( 255 ) ) == \"012345678\" ? -> \"' + CharAdd( \"123456789\", hb_BChar( 255 ) ) + '\"'\n ? ' CharAdd( \"123456789\", hb_BChar( 255 ) + hb_BChar( 254 ) ) == \"002244668\" ? -> \"' + CharAdd( \"123456789\", hb_BChar( 255 ) + hb_BChar( 254 ) ) + '\"'\n\n ? \"End test of CharAdd()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbcups' (CUPS printing system wrapper): contrib/hbcups/tests/test.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbcups\"\n\nPROCEDURE Main( cFile )\n\n LOCAL i\n LOCAL aPrinter\n\n hb_default( @cFile, __FILE__ )\n\n IF Empty( cupsGetDefault() )\n ? \"No default printer configured\"\n ELSE\n ? \"Default printer:\", cupsGetDefault()\n ENDIF\n\n ?\n ? \"Cups Printer List:\"\n\n FOR EACH i IN cupsGetDests()\n ? i:__enumIndex(), i\n NEXT\n\n IF Empty( cupsGetDefault() )\n WAIT\n CLS\n aPrinter := cupsGetDests()\n i := AChoice( 2, 5, 30, Len( aPrinter ) + 2, aPrinter )\n ? \"Printing... Job ID:\", cupsPrintFile( aPrinter[ i ], cFile, \"Harbour CUPS Printing\" )\n ELSE\n ? \"Printing... Job ID:\", cupsPrintFile( cupsGetDefault(), cFile, \"Harbour CUPS Printing\", { \"sides=one-sided\" } )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/stringp.prg. Provides functions: ToChar, Debug. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hboo.ch\"\n\n\nFUNCTION ToChar( xTxt, cSeparator, lDebug )\n\n LOCAL cOut\n LOCAL n\n LOCAL nLen\n LOCAL aData\n\n hb_default( @cSeparator, \" \" )\n hb_default( @lDebug, .F. )\n\n SWITCH ValType( xTxt )\n CASE \"C\"\n CASE \"M\" ; RETURN iif( lDebug, '\"' + xTxt + '\"', xTxt )\n CASE \"N\" ; RETURN hb_ntos( xTxt )\n CASE \"U\" ; RETURN iif( lDebug, \"NIL\", \"\" )\n CASE \"D\" ; RETURN hb_DToC( xTxt, \"yyyy-mm-dd\" )\n CASE \"L\" ; RETURN iif( lDebug, iif( xTxt, \".T.\", \".F.\" ), iif( xTxt, \"True\", \"False\" ) )\n CASE \"B\" ; RETURN iif( lDebug, \"Block\", Eval( xTxt ) )\n\n CASE \"A\"\n cOut := \"\"\n IF lDebug\n cOut += \"{\"\n ENDIF\n nLen := Len( xTxt )\n FOR n := 1 TO nLen \n cOut += ToChar( xTxt[ n ], cSeparator, lDebug )\n IF n != nLen\n cOut += cSeparator\n ENDIF\n NEXT\n IF lDebug\n cOut += \"}\"\n ENDIF\n EXIT\n\n CASE \"O\"\n IF lDebug\n cOut := xTxt:ClassName() + \"(#\" + ToChar( xTxt:ClassH() ) + \"):{\"\n aData := __objGetValueList( xTxt )\n nLen := Len( aData )\n FOR n := 1 TO nLen \n cOut += aData[ n ][ HB_OO_DATA_SYMBOL ] + \":\" + ;\n ToChar( aData[ n ][ HB_OO_DATA_VALUE ], cSeparator, lDebug )\n IF n != nLen\n cOut += cSeparator\n ENDIF\n NEXT\n cOut += \"}\"\n ELSE\n cOut := ToChar( xTxt:Run(), cSeparator, lDebug )\n ENDIF\n EXIT\n\n ENDSWITCH\n\n RETURN cOut\n\n\nFUNCTION Debug( xItem )\n\n ? ToChar( xItem, \", \", .T. )\n\n RETURN xItem"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour extra library: extras/httpsrv/modules/tableservletdb.prg. Defines classes: TableManager, BasicXML. Provides functions: HRBMAIN. This file implements server functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#define TABLE_NAME_PATH \"..\" + hb_ps() + \"..\" + hb_ps() + \"..\" + hb_ps() + \"tests\" + hb_ps() + \"test.dbf\"\n#define SIMULATE_SLOW_REPLY\n\nMEMVAR _REQUEST \n\nFUNCTION HRBMAIN()\n\n LOCAL cXml, cPage, cCount, nCount\n LOCAL oTM\n LOCAL hGets := _REQUEST\n\n hb_default( @hGets, { => } )\n\n IF hb_HHasKey( hGets, \"page\" )\n\n cPage := hGets[ \"page\" ]\n\n oTM := TableManager():New()\n IF oTM:Open()\n oTM:Read()\n cXml := oTM:getXmlData( Val( cPage ) )\n oTM:Close()\n ENDIF\n\n ELSEIF hb_HHasKey( hGets, \"count\" )\n\n cCount := hGets[ \"count\" ]\n\n IF cCount == \"true\"\n oTM := TableManager():New()\n IF oTM:Open()\n nCount := oTM:getLastRec()\n cXml := oTM:getXmlCount( nCount )\n oTM:Close()\n ENDIF\n ENDIF\n ENDIF\n\n IF ! Empty( cXml )\n uhttpd_SetHeader( \"Content-Type\", \"text/xml\" )\n \n uhttpd_SetHeader( \"Cache-Control\", \"no-cache, must-revalidate\" )\n uhttpd_SetHeader( \"Expires\", \"Mon, 26 Jul 1997 05:00:00 GMT\" )\n uhttpd_Write( cXml )\n ELSE\n uhttpd_SetHeader( \"Content-Type\", \"text/xml\" )\n uhttpd_Write( '' )\n uhttpd_Write( \"No Data\" )\n ENDIF\n\n RETURN .T. \n\n\nCREATE CLASS TableManager\n\n CLASS VAR ROWS_PER_PAGE INIT 23\n\n VAR aData INIT {}\n\n VAR cTable INIT TABLE_NAME_PATH\n VAR lOpened INIT .F.\n\n METHOD New()\n METHOD Open()\n METHOD Close() INLINE iif( ::lOpened, ( table->( dbCloseArea() ), ::lOpened := .F. ), )\n METHOD Read()\n METHOD getLastRec() INLINE table->( LastRec() )\n METHOD getXmlData( page )\n METHOD getXmlCount( ncount )\n METHOD xmlEncode( input )\n\nENDCLASS\n\nMETHOD New() CLASS TableManager\n\n RETURN Self\n\nMETHOD Open() CLASS TableManager\n\n LOCAL cDBF := ::cTable\n\n \n IF ! ::lOpened\n\n CLOSE ALL\n USE ( cDBF ) ALIAS table SHARED NEW\n \n ::lOpened := Used()\n\n ENDIF\n\n RETURN ::lOpened\n\nMETHOD Read() CLASS TableManager\n\n LOCAL hMap, lOk := .F.\n\n#ifdef SIMULATE_SLOW_REPLY\n \n hb_idleSleep( 0.5 )\n#endif\n\n IF ::lOpened\n\n table->( dbGoTop() )\n \n DO WHILE table->( ! Eof() ) \n\n hMap := { => }\n hMap[ \"recno\" ] := StrZero( table->( RecNo() ), 4 )\n hMap[ \"name\" ] := RTrim( table->first ) + \" \" + RTrim( table->last )\n hMap[ \"address\" ] := RTrim( table->street )\n hMap[ \"city\" ] := RTrim( table->city )\n hMap[ \"state\" ] := table->state\n hMap[ \"zip\" ] := table->zip\n AAdd( ::aData, hMap )\n table->( dbSkip() )\n ENDDO\n\n lOk := .T.\n\n ENDIF\n\n RETURN lOK\n\n\nMETHOD getXmlData( page ) CLASS TableManager\n\n LOCAL startIndex, stopIndex\n LOCAL xml, i, map, key, cString\n\n \n startIndex := ( page - 1 )\n xml:append( '' )\n\n \n xml:append( \"\" )\n\n \n xml:append( \"
\" )\n xml:append( 'RecNo' )\n xml:append( 'Name' )\n xml:append( 'Address' )\n xml:append( 'City' )\n xml:append( 'State' )\n xml:append( 'Zip' )\n xml:append( \"
\" )\n\n \n FOR i := startIndex + 1 TO stopIndex\n map := ::aData[ i ]\n\n \n xml:append( \"\" )\n\n \n FOR EACH KEY IN map:Keys\n\n cString := ''\n cString += ::xmlEncode( hb_CStr( map[ key ] ) )\n cString += \"\"\n\n xml:append( cString )\n\n NEXT\n\n \n xml:append( \"\" )\n\n NEXT\n\n \n xml:append( \"
\" )\n\n RETURN xml:toString()\n\nMETHOD getXmlCount( nCount ) CLASS TableManager\n\n LOCAL xml, n\n LOCAL nPages := nCount / ::ROWS_PER_PAGE\n\n IF Int( nPages ) < nPages\n nPages ++\n ENDIF\n\n xml := BasicXML():New()\n\n xml:append( '' )\n\n xml:append( \"\" )\n FOR n := 1 TO nPages\n xml:append( \"\" + hb_ntos( n ) + \"\" )\n NEXT\n xml:append( \"\" )\n\n RETURN xml:toString()\n\n\nMETHOD xmlEncode( input ) CLASS TableManager\n\n LOCAL out, i, c\n\n IF input == NIL\n RETURN INPUT\n ENDIF\n\n \n out := \"\"\n\n FOR i := 1 TO Len( input )\n c := SubStr( input, i, 1 )\n SWITCH c\n CASE \"&\"\n out += \"&\"\n EXIT\n CASE \"'\"\n out += \"'\"\n EXIT\n CASE '\"'\n out += \""\"\n EXIT\n CASE \"<\"\n out += \"<\"\n EXIT\n CASE \">\"\n out += \">\"\n EXIT\n CASE Chr( 9 ) \n CASE Chr( 13 ) \n CASE Chr( 10 ) \n out += c\n EXIT\n OTHERWISE\n \n IF Asc( c ) <= 0x1F .OR. Asc( c ) >= 0x80\n out += \"&#x\" + hb_NumToHex( Asc( c ) ) + \";\"\n ELSE\n out += c\n ENDIF\n EXIT\n ENDSWITCH\n NEXT\n\n RETURN out\n\nCREATE CLASS BasicXML\n\n VAR aData INIT {}\n\n METHOD New() CONSTRUCTOR\n METHOD append( cString ) INLINE AAdd( ::aData, cString )\n METHOD ToString()\n\nENDCLASS\n\nMETHOD New() CLASS BasicXML\n\n RETURN Self\n\nMETHOD ToString() CLASS BasicXML\n\n LOCAL s := \"\"\n\n AEval( ::aData, {| c | s += c + iif( Right( c, 1 ) == \">\", hb_eol(), \"\" ) } )\n\n RETURN s"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour utility program: utils/hbtest/rt_array.prg. Contains procedures: Main_ARRAY. This file is part of the test framework"}, {"role": "assistant", "content": "#include \"rt_main.ch\"\n\n\n#include \"rt_vars.ch\"\n\nPROCEDURE Main_ARRAY()\n\n \n#ifndef __XPP__\n HBTEST ACopy() IS NIL\n#endif\n HBTEST ACopy( {}, \"C\" ) IS NIL\n HBTEST ACopy( \"C\", {} ) IS NIL\n HBTEST ACopy( {}, {} ) IS \"{.[0].}\"\n HBTEST ACopy( {}, ErrorNew() ) IS \"ERROR Object\"\n HBTEST ACopy( ErrorNew(), {} ) IS \"{.[0].}\"\n#ifndef __XPP__\n HBTEST AClone() IS NIL\n#endif\n HBTEST AClone( NIL ) IS NIL\n HBTEST AClone( {} ) IS \"{.[0].}\"\n HBTEST AClone( ErrorNew() ) IS NIL\n#ifndef __XPP__\n HBTEST AEval() IS \"E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 \"\n HBTEST AEval( NIL ) IS \"E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:1:U:NIL \"\n HBTEST AEval( {} ) IS \"E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:1:A:{.[0].} \"\n#endif\n HBTEST AEval( {}, NIL ) IS \"E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:2:A:{.[0].};U:NIL \"\n HBTEST AEval( {}, {|| NIL } ) IS \"{.[0].}\"\n HBTEST AEval( ErrorNew(), {|| NIL } ) IS \"ERROR Object\"\n#ifndef __XPP__\n HBTEST AScan() IS 0\n HBTEST AScan( NIL ) IS 0\n HBTEST AScan( \"A\" ) IS 0\n HBTEST AScan( {} ) IS 0\n#endif\n HBTEST AScan( {}, \"\" ) IS 0\n HBTEST AScan( ErrorNew(), \"NOT_FOUND\" ) IS 0\n#ifndef __XPP__\n HBTEST ASort() IS NIL\n#endif\n HBTEST ASort( 10 ) IS NIL\n HBTEST ASort( {} ) IS \"{.[0].}\"\n HBTEST ASort( ErrorNew() ) IS NIL\n#ifdef HB_CLP_STRICT\n#ifndef __XPP__\n HBTEST AFill() IS \"E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:4:U:NIL;B:{||...};U:NIL;U:NIL \"\n#endif\n HBTEST AFill( NIL ) IS \"E 1 BASE 2017 Argument error (AEVAL) OS:0 #:0 A:4:U:NIL;B:{||...};U:NIL;U:NIL \"\n#else\n#ifndef __XPP__\n HBTEST AFill() IS \"E 1 BASE 6004 Argument error (AFILL) OS:0 #:0 \"\n#endif\n HBTEST AFill( NIL ) IS \"E 1 BASE 6004 Argument error (AFILL) OS:0 #:0 A:1:U:NIL \"\n#endif\n HBTEST AFill( {} ) IS \"{.[0].}\"\n HBTEST AFill( {}, 1 ) IS \"{.[0].}\"\n HBTEST AFill( ErrorNew() ) IS \"ERROR Object\"\n HBTEST AFill( ErrorNew(), 1 ) IS \"ERROR Object\"\n#ifndef __XPP__\n HBTEST ADel() IS NIL\n HBTEST ADel( NIL ) IS NIL\n HBTEST ADel( { 1 } ) IS \"{.[1].}\"\n#endif\n HBTEST ADel( { 1 }, 0 ) IS \"{.[1].}\"\n HBTEST ADel( { 1 }, 100 ) IS \"{.[1].}\"\n HBTEST ADel( { 1 }, 1 ) IS \"{.[1].}\"\n HBTEST ADel( { 1 }, -1 ) IS \"{.[1].}\"\n HBTEST ADel( { 1 }, 0 ) IS \"{.[1].}\"\n HBTEST ADel( { 1 }, NIL ) IS \"{.[1].}\"\n#ifndef __XPP__\n HBTEST ADel( ErrorNew() ) IS \"ERROR Object\"\n#endif\n HBTEST ADel( ErrorNew(), 0 ) IS \"ERROR Object\"\n HBTEST ADel( ErrorNew(), 100 ) IS \"ERROR Object\"\n HBTEST ADel( ErrorNew(), 1 ) IS \"ERROR Object\"\n HBTEST ADel( ErrorNew(), -1 ) IS \"ERROR Object\"\n HBTEST ADel( ErrorNew(), 0 ) IS \"ERROR Object\"\n HBTEST ADel( ErrorNew(), NIL ) IS \"ERROR Object\"\n#ifndef __XPP__\n HBTEST AIns() IS NIL\n HBTEST AIns( NIL ) IS NIL\n HBTEST AIns( { 1 } ) IS \"{.[1].}\"\n#endif\n HBTEST AIns( { 1 }, 0 ) IS \"{.[1].}\"\n HBTEST AIns( { 1 }, 100 ) IS \"{.[1].}\"\n HBTEST AIns( { 1 }, 1 ) IS \"{.[1].}\"\n HBTEST AIns( { 1 }, -1 ) IS \"{.[1].}\"\n HBTEST AIns( { 1 }, 0 ) IS \"{.[1].}\"\n HBTEST AIns( { 1 }, NIL ) IS \"{.[1].}\"\n#ifndef __XPP__\n HBTEST AIns( ErrorNew() ) IS \"ERROR Object\"\n#endif\n HBTEST AIns( ErrorNew(), 0 ) IS \"ERROR Object\"\n HBTEST AIns( ErrorNew(), 100 ) IS \"ERROR Object\"\n HBTEST AIns( ErrorNew(), 1 ) IS \"ERROR Object\"\n HBTEST AIns( ErrorNew(), -1 ) IS \"ERROR Object\"\n HBTEST AIns( ErrorNew(), 0 ) IS \"ERROR Object\"\n HBTEST AIns( ErrorNew(), NIL ) IS \"ERROR Object\"\n#ifndef __XPP__\n HBTEST ATail() IS NIL\n#endif\n HBTEST ATail( NIL ) IS NIL\n HBTEST ATail( \"\" ) IS NIL\n HBTEST ATail( {} ) IS NIL\n HBTEST ATail( { 1, 2 } ) IS 2\n HBTEST ATail( ErrorNew() ) IS NIL\n#ifndef __XPP__\n#ifdef HB_COMPAT_C53\n HBTEST ASize() IS \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 \"\n HBTEST ASize( NIL ) IS \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 \", \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:1:U:NIL \"\n HBTEST ASize( {} ) IS \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 \", \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:1:A:{.[0].} \"\n HBTEST ASize( ErrorNew() ) IS \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 \", \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:1:O:ERROR Object \"\n#else\n HBTEST ASize() IS NIL\n HBTEST ASize( NIL ) IS NIL\n HBTEST ASize( {} ) IS NIL\n HBTEST ASize( ErrorNew() ) IS NIL\n#endif\n#endif\n#ifdef HB_COMPAT_C53\n HBTEST ASize( NIL, 0 ) IS \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 \", \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:2:U:NIL;N:0 \"\n HBTEST ASize( NIL, 1 ) IS \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 \", \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:2:U:NIL;N:1 \"\n HBTEST ASize( NIL, -1 ) IS \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 \", \"E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:2:U:NIL;N:-1 \"\n#else\n HBTEST ASize( NIL, 0 ) IS NIL\n HBTEST ASize( NIL, 1 ) IS NIL\n HBTEST ASize( NIL, -1 ) IS NIL\n#endif\n HBTEST ASize( {}, 0 ) IS \"{.[0].}\"\n HBTEST ASize( ErrorNew(), 0 ) IS \"ERROR Object\"\n HBTEST ASize( {}, 1 ) IS \"{.[1].}\"\n HBTEST ASize( { 1, 2 }, 1 ) IS \"{.[1].}\"\n HBTEST ASize( { 1, \"AAAA\" }, 1 ) IS \"{.[1].}\"\n HBTEST ASize( { \"BBB\", \"AAAA\" }, 0 ) IS \"{.[0].}\"\n HBTEST ASize( ErrorNew(), 1 ) IS \"ERROR Object\"\n HBTEST ASize( {}, -1 ) IS \"{.[0].}\"\n HBTEST ASize( { 1 }, -1 ) IS \"{.[0].}\"\n#ifdef __HARBOUR__\n HBTEST ASize( { 1 }, 5000 ) IS \"{.[5000].}\"\n#else\n HBTEST ASize( { 1 }, 5000 ) IS \"{.[1].}\"\n#endif\n HBTEST ASize( ErrorNew(), -1 ) IS \"ERROR Object\"\n HBTEST ASize( ErrorNew(), 100 ) IS \"ERROR Object\"\n HBTEST AAdd( NIL, NIL ) IS \"E 1 BASE 1123 Argument error (AADD) OS:0 #:0 A:2:U:NIL;U:NIL F:S\"\n HBTEST AAdd( {}, NIL ) IS NIL\n HBTEST AAdd( {}, \"A\" ) IS \"A\"\n HBTEST AAdd( ErrorNew(), NIL ) IS NIL\n HBTEST AAdd( ErrorNew(), \"A\" ) IS \"A\"\n#ifndef __XPP__\n HBTEST Array() IS NIL\n#endif\n HBTEST Array( 0 ) IS \"{.[0].}\"\n#ifdef __HARBOUR__\n HBTEST Array( 5000 ) IS \"{.[5000].}\"\n#else\n HBTEST Array( 5000 ) IS \"E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 \"\n#endif\n HBTEST Array( 1 ) IS \"{.[1].}\"\n HBTEST Array( -1 ) IS \"E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 \"\n#ifdef __HARBOUR__\n \n #pragma -ko-\n#endif\n HBTEST Array( 1, 0, -10 ) IS \"E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 \", \"E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 A:3:N:1;N:0;N:-10 \""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour test program: tests/clsscope.prg. This test file tests object-oriented programming features"}, {"role": "assistant", "content": "#command ? => OUTSTD(hb_eol())\n#xtranslate QOUT() => OUTSTD(hb_eol(),)\n\n#include \"hbclass.ch\"\n\n#xcommand MAKE_TEST(,) ;\n => begin sequence ;;\n ? \" hVar:= \", :hVar:= ;;\n end sequence ;;\n begin sequence ;;\n ? \" hVar \", :hVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" hrVar:=\", :hrVar:= ;;\n end sequence ;;\n begin sequence ;;\n ? \" hrVar \", :hrVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" pVar:= \", :pVar:= ;;\n end sequence ;;\n begin sequence ;;\n ? \" pVar \", :pVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" prVar:=\", :prVar:= ;;\n end sequence ;;\n begin sequence ;;\n ? \" prVar \", :prVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" eVar:= \", :eVar:= ;;\n end sequence ;;\n begin sequence ;;\n ? \" eVar \", :eVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" erVar:=\", :erVar:= ;;\n end sequence ;;\n begin sequence ;;\n ? \" erVar \", :erVar ;;\n end sequence\n\n\n#xcommand MAKE_TESTBLOCK(,,) ;\n => begin sequence ;;\n ({| self | qout(\" hVar:= \", ::hVar:=)},) ;;\n end sequence ;;\n begin sequence ;;\n ({| self | qout(\" hrVar:=\", ::hrVar:=)},) ;;\n end sequence ;;\n begin sequence ;;\n ({| self | qout(\" pVar:= \", ::pVar:=)},) ;;\n end sequence ;;\n begin sequence ;;\n ({| self | qout(\" prVar:=\", ::prVar:=)},) ;;\n end sequence ;;\n begin sequence ;;\n ({| self | qout(\" eVar:= \", ::eVar:=)},) ;;\n end sequence ;;\n begin sequence ;;\n ({| self | qout(\" erVar:=\", ::erVar:=)},) ;;\n end sequence\n\n\n#xcommand MAKE_TESTINLINE(,) ;\n => begin sequence ;;\n ? \" hVar:= \", :hVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" hrVar:=\", :hrVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" pVar:= \", :pVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" prVar:=\", :prVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" eVar:= \", :eVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" erVar:=\", :erVar ;;\n end sequence\n\n\n#xcommand MAKE_TESTINLINE0([,]) ;\n => begin sequence ;;\n ? \" hVar:= \", :b0hVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" hrVar:=\", :b0hrVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" pVar:= \", :b0pVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" prVar:=\", :b0prVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" eVar:= \", :b0eVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" erVar:=\", :b0erVar ;;\n end sequence\n\n#xcommand MAKE_TESTINLINE1([,]) ;\n => begin sequence ;;\n ? \" hVar:= \", :b1hVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" hrVar:=\", :b1hrVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" pVar:= \", :b1pVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" prVar:=\", :b1prVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" eVar:= \", :b1eVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" erVar:=\", :b1erVar ;;\n end sequence\n\n#xcommand MAKE_TESTINLINE2([,]) ;\n => begin sequence ;;\n ? \" hVar:= \", :b2hVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" hrVar:=\", :b2hrVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" pVar:= \", :b2pVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" prVar:=\", :b2prVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" eVar:= \", :b2eVar ;;\n end sequence ;;\n begin sequence ;;\n ? \" erVar:=\", :b2erVar ;;\n end sequence\n\n\nproc main()\nLOCAL cbErr, self, o\n\n? DATE(), TIME(), VERSION(), OS()\n?\n\no:=clsX():new()\nself:=cls2():new()\ncbErr := errorBlock( {| oErr | errHandler( oErr ) } )\n\n\n? \"Class Access:\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbodbc' (ODBC database connectivity): contrib/hbodbc/browse.prg. Provides functions: BrowseODBC, Skipped, ODBCFGet. Contains procedures: StatLine. This file handles database operations"}, {"role": "assistant", "content": "#include \"box.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\nFUNCTION BrowseODBC( nTop, nLeft, nBottom, nRight, oDataSource )\n\n LOCAL oBrw\n LOCAL cOldScreen\n LOCAL n, nOldCursor\n LOCAL nKey := 0\n LOCAL lExit := .F.\n LOCAL bAction\n LOCAL oColumn\n\n \n IF PCount() < 4\n nTop := 1\n nLeft := 0\n nBottom := MaxRow()\n nRight := MaxCol()\n ENDIF\n\n nOldCursor := SetCursor( SC_NONE )\n cOldScreen := SaveScreen( nTop, nLeft, nBottom, nRight )\n\n hb_DispBox( nTop, nLeft, nBottom, nRight, HB_B_SINGLE_UNI )\n hb_DispOutAt( nTop + 1, nLeft + 1, Space( nRight - nLeft - 1 ) )\n\n oBrw := TBrowseNew( nTop + 2, nLeft + 1, nBottom - 1, nRight - 1 )\n\n oBrw:SkipBlock := {| nRecs | Skipped( nRecs, oDataSource ) }\n oBrw:GoTopBlock := {|| oDataSource:first() }\n oBrw:GoBottomBlock := {|| oDataSource:last() }\n\n oBrw:HeadSep := \"-\"\n\n \n FOR n := 1 TO Len( oDataSource:Fields )\n oColumn := TBColumn():New( oDataSource:Fields[ n ]:FieldName, ODBCFget( oDataSource:Fields[ n ]:FieldName, oDataSource ) )\n oBrw:AddColumn( oColumn )\n NEXT\n\n oBrw:Configure()\n oBrw:ForceStable()\n\n DO WHILE ! lExit\n\n DO WHILE .T.\n nKey := Inkey()\n IF oBrw:stabilize() .OR. nKey != 0\n EXIT\n ENDIF\n ENDDO\n\n IF nKey == 0\n\n oBrw:forceStable()\n Statline( oBrw, oDataSource )\n\n nKey := Inkey( 0 )\n\n IF ( bAction := SetKey( nKey ) ) != NIL\n Eval( bAction, ProcName( 1 ), ProcLine( 1 ), \"\" )\n LOOP\n ENDIF\n ENDIF\n\n DO CASE\n CASE nKey == K_ESC\n lExit := .T.\n\n CASE nKey == K_UP\n oBrw:Up()\n\n CASE nKey == K_DOWN\n oBrw:Down()\n\n CASE nKey == K_END\n oBrw:End()\n\n CASE nKey == K_HOME\n oBrw:Home()\n\n CASE nKey == K_LEFT\n oBrw:Left()\n\n CASE nKey == K_RIGHT\n oBrw:Right()\n\n CASE nKey == K_PGUP\n oBrw:PageUp()\n\n CASE nKey == K_PGDN\n oBrw:PageDown()\n\n CASE nKey == K_CTRL_PGUP\n oBrw:GoTop()\n\n CASE nKey == K_CTRL_PGDN\n oBrw:GoBottom()\n\n CASE nKey == K_CTRL_LEFT\n oBrw:panLeft()\n\n CASE nKey == K_CTRL_RIGHT\n oBrw:panRight()\n\n CASE nKey == K_CTRL_HOME\n oBrw:panHome()\n\n CASE nKey == K_CTRL_END\n oBrw:panEnd()\n\n ENDCASE\n ENDDO\n\n RestScreen( nTop, nLeft, nBottom, nRight, cOldScreen )\n SetCursor( nOldCursor )\n\n RETURN .T.\n\nSTATIC PROCEDURE StatLine( oBrw, oDataSource )\n\n LOCAL nTop := oBrw:nTop - 1\n LOCAL nRight := oBrw:nRight\n\n hb_DispOutAt( nTop, nRight - 27, \"Record \" )\n\n IF oDataSource:LastRec() == 0\n hb_DispOutAt( nTop, nRight - 20, \" \" )\n ELSEIF oDataSource:RecNo() == oDataSource:LastRec() + 1\n hb_DispOutAt( nTop, nRight - 40, \" \" )\n hb_DispOutAt( nTop, nRight - 20, \" \" )\n ELSE\n hb_DispOutAt( nTop, nRight - 20, PadR( hb_ntos( oDataSource:RecNo() ) + \"/\" + ;\n hb_ntos( oDataSource:LastRec() ), 16 ) + ;\n iif( oBrw:hitTop, \"\", \" \" ) + ;\n iif( oBrw:hitBottom, \"\", \" \" ) )\n ENDIF\n\n RETURN\n\nSTATIC FUNCTION Skipped( nRecs, oDataSource )\n\n LOCAL nSkipped := 0\n\n IF ! oDataSource:Eof()\n DO CASE\n CASE nRecs == 0\n \n CASE nRecs > 0\n DO WHILE nSkipped < nRecs\n IF ! oDataSource:Eof()\n oDataSource:next()\n IF oDataSource:Eof()\n oDataSource:prior()\n EXIT\n ENDIF\n nSkipped++\n ENDIF\n ENDDO\n CASE nRecs < 0\n DO WHILE nSkipped > nRecs\n IF ! oDataSource:Bof()\n oDataSource:prior()\n IF oDataSource:Bof()\n EXIT\n ENDIF\n nSkipped--\n ENDIF\n ENDDO\n ENDCASE\n ENDIF\n\n RETURN nSkipped\n\nSTATIC FUNCTION ODBCFGet( cFieldName, oDataSource )\n\n IF HB_ISSTRING( cFieldName )\n \n RETURN {| x | iif( x == NIL, oDataSource:FieldByName( cFieldName ):value, NIL ) }\n ENDIF\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour Runtime Library file: src/rtl/text.prg. Contains procedures: __TextSave, __TextRestore. This file provides utility functions"}, {"role": "assistant", "content": "THREAD STATIC t_cFile\nTHREAD STATIC t_lOldPrinter\nTHREAD STATIC t_lOldExtra\nTHREAD STATIC t_cOldExtraFile\n\nPROCEDURE __TextSave( cFile )\n\n t_cFile := cFile\n\n IF t_cFile == \"PRINTER\"\n t_lOldPrinter := Set( _SET_PRINTER, .T. )\n ELSE\n t_lOldExtra := Set( _SET_EXTRA, .T. )\n t_cOldExtraFile := Set( _SET_EXTRAFILE, cFile )\n ENDIF\n\n RETURN\n\nPROCEDURE __TextRestore()\n\n IF t_cFile == \"PRINTER\"\n Set( _SET_PRINTER, t_lOldPrinter )\n ELSE\n Set( _SET_EXTRAFILE, t_cOldExtraFile )\n Set( _SET_EXTRA, t_lOldExtra )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/statinit.prg. Provides functions: Hello. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "MEMVAR p_cMyPubVar\n\nSTATIC s_bBlock1 := {|| Hello() }\nSTATIC s_bBlock2 := {|| p_cMyPubVar }\n\nPROCEDURE Main()\n\n PUBLIC p_cMyPubVar := \"Printed from a PUBLIC var from a codeblock assigned to a static variable.\"\n\n Eval( s_bBlock1 )\n ? Eval( s_bBlock2 )\n\n RETURN\n\nFUNCTION Hello()\n\n ? \"Printed from a codeblock assigned to a static variable.\"\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/tokenupp.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL cStr := \".,.This.,.is.,.a.,.test!\"\n\n ctinit()\n\n ? \"Begin test of TokenUpper()\"\n ?\n\n ? \" Simple tests:\"\n ? ' TokenUpper( \"Hello, world, here I am!\" ) == \"Hello, World, Here I Am!\" ?'\n ? ' -> \"' + TokenUpper( \"Hello, world, here I am!\" ) + '\"'\n ? ' TokenUpper( \"Hello, world, here I am!\",, 3 ) == \"Hello, World, Here I am!\" ?'\n ? ' -> \"' + TokenUpper( \"Hello, world, here I am!\",, 3 ) + '\"'\n ? ' TokenUpper( \"Hello, world, here I am!\", \",\", 3 ) == \"Hello, world, here I am!\" ?'\n ? ' -> \"' + TokenUpper( \"Hello, world, here I am!\", \",\", 3 ) + '\"'\n ? ' TokenUpper( \"Hello, world, here I am!\", \" w\" ) == \"Hello, wOrld, Here I Am!\" ?'\n ? ' -> \"' + TokenUpper( \"Hello, world, here I am!\", \" w\" ) + '\"'\n ?\n\n ? ' Uppercase the tokens in the string \"' + cStr + '\"'\n ? ' with CSetRef( .T. ) and \"@\"'\n CSetRef( .T. )\n ?\n ? ' --> return value of TokenUpper( @cStr ): ', TokenUpper( @cStr )\n ? ' --> cStr is now: \"' + cStr + '\"'\n\n ?\n ? \"End test of TokenUpper()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/directry.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"directry.ch\"\n\nPROCEDURE Main( filespec, attribs, cshort )\n\n LOCAL aDir\n LOCAL x, lShort := .F.\n\n IF ! cshort == NIL .AND. ( Upper( cShort ) == \"TRUE\" .OR. Upper( cShort ) == \".T.\" )\n lShort := .T.\n ENDIF\n\n\n aDir := Directory( filespec, attribs, lShort )\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n FOR x := 1 TO Len( aDir )\n ? ;\n PadR( aDir[ x, F_NAME ], 20 ), \"|\", ;\n Transform( aDir[ x, F_SIZE ], \"9,999,999,999\" ), \"|\", ;\n aDir[ x, F_DATE ], \"|\", ;\n aDir[ x, F_TIME ], \"|\", ;\n aDir[ x, F_ATTR ]\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: xpp_Get. Harbour contribution module 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/tgetx.prg. Defines classes: xpp_Get. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nCREATE CLASS xpp_Get INHERIT Get\n\n EXPORTED:\n\n METHOD posInBuffer( nRow, nCol )\n\n METHOD _end()\n METHOD _assign()\n METHOD _delete()\n\nENDCLASS\n\n\nMETHOD posInBuffer( nRow, nCol ) CLASS xpp_Get\n\n IF ::hasFocus .AND. ;\n nRow == ::nRow .AND. ;\n nCol >= ::nCol + ::nPos - 1 .AND. ;\n nCol <= ::nCol + ::nDispLen\n\n RETURN nCol - ::nCol + 1\n ENDIF\n\n RETURN 0\n\nMETHOD _end() CLASS xpp_Get\n RETURN ::end()\n\nMETHOD _assign() CLASS xpp_Get\n RETURN ::assign()\n\nMETHOD _delete() CLASS xpp_Get\n RETURN ::delete()"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/mouse1.prg. Provides functions: ft_MDblClk, ft_MInRegion, ft_MMickeys. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "THREAD STATIC t_lCrsState := .F.\nTHREAD STATIC t_lMInit := .F.\n\nFUNCTION ft_MDblClk( nClick, nButton, nInterval, nRow, nCol, nStart )\n\n LOCAL nVert, nHorz \n LOCAL lDouble \n LOCAL lDone \n LOCAL nPrs \n\n __defaultNIL( @nClick, 1 )\n __defaultNIL( @nButton, 0 )\n __defaultNIL( @nInterval, 0.5 )\n __defaultNIL( @nRow, MRow() )\n __defaultNIL( @nCol, MCol() )\n __defaultNIL( @nStart, Seconds() )\n\n nVert := nRow\n nHorz := nCol\n lDouble := lDone := ( nClick == 0 )\n\n \n DO WHILE ! lDone\n\n ft_MButPrs( nButton, @nPrs, @nVert, @nHorz )\n nVert := Int( nVert / 8 )\n nHorz := Int( nHorz / 8 )\n\n lDouble := ( nPrs > 0 )\n ldone := Seconds() - nStart >= nInterval .OR. lDouble\n\n ENDDO\n\n \n lDouble := lDouble .AND. ( nVert == nRow .AND. nHorz == nCol )\n\n \n IF nClick > 0\n nStart := Seconds()\n ENDIF\n\n \n IF lDouble\n\n lDouble := lDone := .F.\n\n DO WHILE ! lDone\n\n ft_MButPrs( nButton, @nPrs, @nVert, @nHorz )\n nVert := Int( nVert / 8 )\n nHorz := Int( nHorz / 8 )\n\n lDouble := ( nPrs > 0 )\n lDone := Seconds() - nStart >= nInterval .OR. lDouble\n\n ENDDO\n\n \n lDouble := lDouble .AND. nVert == nRow .AND. nHorz == nCol\n\n ENDIF\n\n RETURN lDouble\n\nFUNCTION ft_MInRegion( nTR, nLC, nBR, nRC )\n RETURN ;\n MRow() >= nTR .AND. MRow() <= nBR .AND. ;\n MCol() >= nLC .AND. MCol() <= nRC\n\nFUNCTION ft_MMickeys( nX, nY )\n\n nX := MRow()"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/xhbmisc.prg. Provides functions: Occurs. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION Occurs( s1, s2 )\n\n LOCAL nCount := 0\n LOCAL nPos := 0\n\n IF HB_ISSTRING( s1 ) .AND. HB_ISSTRING( s2 )\n#if defined( HB_CLP_STRICT )\n DO WHILE ( nPos := hb_At( s1, s2, nPos + 1 ) ) != 0\n nCount++\n ENDDO\n#else\n DO WHILE ( nPos := hb_At( s1, s2, nPos ) ) != 0\n nCount++\n nPos += Len( s1 )\n ENDDO\n#endif\n ENDIF\n\n RETURN nCount"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'gtwvg' (): contrib/gtwvg/parthdlr.prg. Defines classes: WvgPartHandler. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nCREATE CLASS WvgPartHandler\n\n VAR cargo\n\n METHOD new( oParent, oOwner )\n METHOD create( oParent, oOwner )\n METHOD configure( oParent, oOwner )\n METHOD destroy()\n METHOD handleEvent( hEvent, mp1, mp2 )\n METHOD status()\n\n METHOD removeChild( oChild )\n METHOD addChild( oWvg )\n METHOD childFromName( nNameId )\n METHOD childList()\n METHOD delChild( oWvg )\n METHOD setName( nNameId )\n METHOD setOwner( oWvg )\n METHOD setParent( oWvg )\n\n METHOD notifier( nEvent, xParams )\n METHOD controlWndProc( hWnd, nMessage, nwParam, nlParam )\n\n VAR aChildren INIT {}\n VAR nNameId\n VAR oParent\n VAR oOwner\n VAR nStatus INIT 0\n\n \n VAR sb_notifier\n METHOD notifierBlock( ... ) SETGET\n\nENDCLASS\n\nMETHOD WvgPartHandler:new( oParent, oOwner )\n\n ::oParent := oParent\n ::oOwner := oOwner\n\n RETURN Self\n\nMETHOD WvgPartHandler:create( oParent, oOwner )\n\n __defaultNIL( @oParent, ::oParent )\n __defaultNIL( @oOwner, ::oOwner )\n\n ::oParent := oParent\n ::oOwner := oOwner\n\n RETURN Self\n\nMETHOD WvgPartHandler:configure( oParent, oOwner )\n\n __defaultNIL( @oParent, ::oParent )\n __defaultNIL( @oOwner, ::oOwner )\n\n ::oParent := oParent\n ::oOwner := oOwner\n\n RETURN Self\n\nMETHOD WvgPartHandler:destroy()\n\n ::hChildren := NIL\n ::nNameId := NIL\n ::oParent := NIL\n ::oOwner := NIL\n\n RETURN Self\n\nMETHOD WvgPartHandler:handleEvent( hEvent, mp1, mp2 )\n\n HB_SYMBOL_UNUSED( hEvent )\n HB_SYMBOL_UNUSED( mp1 )\n HB_SYMBOL_UNUSED( mp2 )\n\n RETURN Self\n\nMETHOD WvgPartHandler:status()\n RETURN ::nStatus\n\nMETHOD WvgPartHandler:addChild( oWvg )\n\n oWvg:nNameID := oWvg:nID\n AAdd( ::aChildren, oWvg )\n\n RETURN Self\n\nMETHOD WvgPartHandler:childFromName( nNameId )\n\n LOCAL i, oWvg\n\n FOR i := 1 TO Len( ::aChildren )\n IF ::aChildren[ i ]:nNameID != NIL .AND. ::aChildren[ i ]:nNameID == nNameID\n oWvg := ::aChildren[ i ]\n ENDIF\n NEXT\n\n RETURN oWvg\n\nMETHOD WvgPartHandler:childList()\n RETURN ::aChildren\n\nMETHOD WvgPartHandler:removeChild( oChild )\n\n LOCAL n\n\n IF ( n := AScan( ::aChildren, {| o | o == oChild } ) ) > 0\n hb_ADel( ::aChildren, n, .T. )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgPartHandler:delChild( oWvg )\n\n LOCAL n\n\n n := AScan( ::aChildren, {| o | o == oWvg } )\n IF n > 0\n oWvg:destroy()\n hb_ADel( ::aChildren, n, .T. )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgPartHandler:setName( nNameId )\n\n LOCAL nOldNameId := ::nNameId\n\n IF HB_ISNUMERIC( nNameId )\n ::nNameID := nNameId\n ENDIF\n\n RETURN nOldNameId\n\nMETHOD WvgPartHandler:setOwner( oWvg )\n\n LOCAL oOldXbp := ::oOwner\n\n IF HB_ISOBJECT( oWvg )\n ::oOwner := oWvg\n ENDIF\n\n RETURN oOldXbp\n\nMETHOD WvgPartHandler:setParent( oWvg )\n\n LOCAL oOldXbp := ::oParent\n\n IF HB_ISOBJECT( oWvg )\n ::oParent := oWvg\n ENDIF\n\n RETURN oOldXbp\n\nMETHOD PROCEDURE WvgPartHandler:notifierBlock( ... )\n\n LOCAL a_ := hb_AParams()\n\n IF ! Empty( a_ ) .AND. HB_ISBLOCK( a_[ 1 ] )\n ::sb_notifier := a_[ 1 ]\n\n ELSEIF ! Empty( a_ ) .AND. HB_ISBLOCK( ::sb_notifier ) .AND. HB_ISNUMERIC( a_[ 1 ] ) .AND. HB_ISARRAY( a_[ 2 ] )\n Eval( ::sb_notifier, a_[ 1 ], a_[ 2 ], Self )\n\n ENDIF\n\n RETURN\n\n\nMETHOD WvgPartHandler:notifier( nEvent, xParams )\n\n LOCAL aPos, aMenuItem, nIndex, nCtrlID, oObj\n LOCAL nReturn := 0\n\n DO CASE\n CASE nEvent == HB_GTE_MOUSE\n\n DO CASE\n CASE xParams[ 1 ] == WM_MOUSEHOVER\n aPos := { xParams[ 3 ], xParams[ 4 ] }\n CASE xParams[ 1 ] == WM_MOUSELEAVE\n \n OTHERWISE\n aPos := iif( ::mouseMode == 2, { xParams[ 3 ], xParams[ 4 ] }, { xParams[ 5 ], xParams[ 6 ] } )\n ENDCASE\n\n SWITCH xParams[ 1 ]\n CASE WM_MOUSEHOVER\n IF HB_ISBLOCK( ::sl_enter )\n Eval( ::sl_enter, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_MOUSELEAVE\n IF HB_ISBLOCK( ::sl_leave )\n Eval( ::sl_leave, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_RBUTTONDOWN\n IF HB_ISBLOCK( ::sl_rbDown )\n Eval( ::sl_rbDown, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_LBUTTONDOWN\n IF HB_ISBLOCK( ::sl_lbDown )\n Eval( ::sl_lbDown, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_RBUTTONUP\n IF HB_ISBLOCK( ::sl_rbUp )\n Eval( ::sl_rbUp, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_LBUTTONUP\n IF HB_ISBLOCK( ::sl_lbUp )\n Eval( ::sl_lbUp, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_RBUTTONDBLCLK\n IF HB_ISBLOCK( ::sl_rbDblClick )\n Eval( ::sl_rbDblClick, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_LBUTTONDBLCLK\n IF HB_ISBLOCK( ::sl_lbDblClick )\n Eval( ::sl_lbDblClick, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_MBUTTONDOWN\n IF HB_ISBLOCK( ::sl_mbDown )\n Eval( ::sl_mbDown, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_MBUTTONUP\n IF HB_ISBLOCK( ::sl_mbClick )\n Eval( ::sl_mbClick, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_MBUTTONDBLCLK\n IF HB_ISBLOCK( ::sl_mbDblClick )\n Eval( ::sl_mbDblClick, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_MOUSEMOVE\n IF HB_ISBLOCK( ::sl_motion )\n Eval( ::sl_motion, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_MOUSEWHEEL\n IF HB_ISBLOCK( ::sl_wheel )\n Eval( ::sl_wheel, aPos, , Self )\n ENDIF\n EXIT\n CASE WM_NCMOUSEMOVE\n EXIT\n ENDSWITCH\n\n CASE nEvent == HB_GTE_KEYBOARD\n IF HB_ISBLOCK( ::keyboard )\n Eval( ::keyboard, xParams, , Self )\n ENDIF\n\n CASE nEvent == HB_GTE_SETFOCUS\n\n IF HB_ISBLOCK( ::sl_setInputFocus )\n Eval( ::sl_setInputFocus, , , Self )\n ENDIF\n ::lHasInputFocus := .T.\n\n CASE nEvent == HB_GTE_KILLFOCUS\n IF HB_ISBLOCK( ::sl_killInputFocus )\n Eval( ::sl_killInputFocus, , , Self )\n ENDIF\n ::lHasInputFocus := .F.\n\n CASE nEvent == HB_GTE_PAINT\n\n CASE nEvent == HB_GTE_GUIPARTS\n \n AEval( ::aChildren, {| o | wvg_InvalidateRect( o:hWnd ) } )\n\n CASE nEvent == HB_GTE_CLOSE\n IF HB_ISBLOCK( ::close )\n nReturn := Eval( ::close, , , Self )\n ENDIF\n\n CASE nEvent == HB_GTE_MENU\n DO CASE\n CASE xParams[ 1 ] == 0 \n IF HB_ISOBJECT( ::oMenu )\n IF ! Empty( aMenuItem := ::oMenu:FindMenuItemById( xParams[ 2 ] ) )\n DO CASE\n CASE HB_ISBLOCK( aMenuItem[ 2 ] )\n Eval( aMenuItem[ 2 ], aMenuItem[ 1 ], , aMenuItem[ 4 ] )\n CASE HB_ISBLOCK( aMenuItem[ 3 ] )\n Eval( aMenuItem[ 3 ], aMenuItem[ 1 ], , aMenuItem[ 4 ] )\n ENDCASE\n ENDIF\n ENDIF\n\n CASE xParams[ 1 ] == 1 .AND. HB_ISOBJECT( ::oMenu ) \n IF HB_ISBLOCK( ::oMenu:sl_beginMenu )\n Eval( ::oMenu:sl_beginMenu, , , Self )\n ENDIF\n\n CASE xParams[ 1 ] == 2 .AND. HB_ISOBJECT( ::oMenu ) \n IF HB_ISBLOCK( ::oMenu:sl_endMenu )\n Eval( ::oMenu:sl_endMenu, , , Self )\n ENDIF\n\n ENDCASE\n\n CASE nEvent == HB_GTE_NOTIFY\n nCtrlID := xParams[ 1 ]\n IF ( nIndex := AScan( ::aChildren, {| o | o:nID == nCtrlID } ) ) > 0\n RETURN ::aChildren[ nIndex ]:handleEvent( HB_GTE_NOTIFY, xParams )\n ENDIF\n\n CASE nEvent == HB_GTE_COMMAND\n nCtrlID := xParams[ 2 ]\n IF ( nIndex := AScan( ::aChildren, {| o | o:nID == nCtrlID } ) ) > 0\n RETURN ::aChildren[ nIndex ]:handleEvent( HB_GTE_COMMAND, xParams )\n ENDIF\n\n CASE nEvent == HB_GTE_CTLCOLOR\n oObj := ::findObjectByHandle( xParams[ 2 ] )\n IF HB_ISOBJECT( oObj )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour Runtime Library file: src/debug/dbgthsh.prg. Defines classes: HBDbHash. Provides functions: __dbgHashes, GetTopPos, GetBottomPos, HashBrowseSkip, HashKeyString. This file provides utility functions"}, {"role": "assistant", "content": "#pragma -b-\n\n#define HB_CLS_NOTOBJECT \n#include \"hbclass.ch\"\n\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\nCREATE CLASS HBDbHash\n\n VAR aWindows INIT {}\n VAR TheHash\n VAR hashName\n VAR nCurWindow INIT 0\n VAR lEditable\n\n METHOD New( hHash, cVarName, lEditable )\n\n METHOD addWindows( hHash, nRow )\n METHOD doGet( oBrowse, pItem, nSet )\n METHOD SetsKeyPressed( nKey, oBrwSets, oWnd, cName, hHash )\n\nENDCLASS\n\nMETHOD New( hHash, cVarName, lEditable ) CLASS HBDbHash\n\n ::hashName := cVarName\n ::TheHash := hHash\n ::lEditable := hb_defaultValue( lEditable, .T. )\n\n ::addWindows( ::TheHash )\n\n RETURN Self\n\nMETHOD addWindows( hHash, nRow ) CLASS HBDbHash\n\n LOCAL oBrwSets\n LOCAL nSize := Len( hHash )\n LOCAL oWndSets\n LOCAL nColWidth\n LOCAL oCol\n LOCAL nKeyLen\n\n IF nSize < MaxRow() - 2\n IF HB_ISNUMERIC( nRow )\n oWndSets := HBDbWindow():New( GetTopPos( nRow ), 5, getBottomPos( nRow + nSize + 1 ), MaxCol() - 5, ;\n ::hashName + \"[1..\" + hb_ntos( nSize ) + \"]\", \"N/W\" )\n ELSE\n oWndSets := HBDbWindow():New( 1, 5, 2 + nSize, MaxCol() - 5, ;\n ::hashName + \"[1..\" + hb_ntos( nSize ) + \"]\", \"N/W\" )\n ENDIF\n ELSE\n oWndSets := HBDbWindow():New( 1, 5, MaxRow() - 2, MaxCol() - 5, ;\n ::hashName + \"[1..\" + hb_ntos( nSize ) + \"]\", \"N/W\" )\n ENDIF\n ::nCurWindow++\n oWndSets:lFocused := .T.\n AAdd( ::aWindows, oWndSets )\n\n oBrwSets := HBDbBrowser():New( oWndSets:nTop + 1, oWndSets:nLeft + 1, oWndSets:nBottom - 1, oWndSets:nRight - 1 )\n oBrwSets:ColorSpec := __dbg():ClrModal()\n oBrwSets:Cargo := { 1, {} } \n AAdd( oBrwSets:Cargo[ 2 ], hHash )\n\n oBrwSets:AddColumn( oCol := HBDbColumnNew( \"\", {|| ::hashName + \"[\" + HashKeyString( hHash, oBrwSets:cargo[ 1 ] ) + \"]\" } ) )\n\n \n nKeyLen := 0\n hb_HEval( hHash, {| k, v, p | HB_SYMBOL_UNUSED( k ), HB_SYMBOL_UNUSED( v ), nKeyLen := Max( nKeyLen, Len( ::hashName + HashKeyString( hHash, p ) ) + 2 ) } )\n oCol:width := nKeyLen\n oCol:DefColor := { 1, 2 }\n nColWidth := oCol:Width\n\n oBrwSets:AddColumn( oCol := HBDbColumnNew( \"\", {|| __dbgValToExp( hb_HValueAt( hHash, oBrwSets:cargo[ 1 ] ) ) } ) )\n\n oCol:width := oWndSets:nRight - oWndSets:nLeft - nColWidth - 2\n oCol:DefColor := { 1, 3 }\n\n oBrwSets:goTopBlock := {|| oBrwSets:cargo[ 1 ] := 1 }\n oBrwSets:goBottomBlock := {|| oBrwSets:cargo[ 1 ] := Len( oBrwSets:cargo[ 2 ][ 1 ] ) }\n oBrwSets:skipBlock := {| nPos | nPos := HashBrowseSkip( nPos, oBrwSets ), ;\n oBrwSets:cargo[ 1 ] := oBrwSets:cargo[ 1 ] + nPos, nPos }\n oBrwSets:colPos := 2\n\n ::aWindows[ ::nCurWindow ]:bPainted := {|| oBrwSets:forcestable() }\n ::aWindows[ ::nCurWindow ]:bKeyPressed := ;\n {| nKey | ::SetsKeyPressed( nKey, oBrwSets, ::aWindows[ ::nCurWindow ], ::hashName, hHash ) }\n\n ::aWindows[ ::nCurWindow ]:ShowModal()\n\n RETURN Self\n\nMETHOD PROCEDURE doGet( oBrowse, pItem, nSet ) CLASS HBDbHash\n\n LOCAL oErr\n LOCAL cValue\n\n \n oBrowse:forceStable()\n \n\n cValue := __dbgValToExp( hb_HValueAt( pItem, nSet ) )\n\n IF __dbgInput( Row(), oBrowse:nLeft + oBrowse:GetColumn( 1 ):width + 1, ;\n oBrowse:getColumn( 2 ):Width, @cValue, ;\n __dbgExprValidBlock(), __dbgColors()[ 2 ], 256 )\n BEGIN SEQUENCE WITH __BreakBlock()\n hb_HValueAt( pItem, nSet, &cValue )\n RECOVER USING oErr\n __dbgAlert( oErr:description )\n END SEQUENCE\n ENDIF\n\n RETURN\n\nMETHOD SetsKeyPressed( nKey, oBrwSets, oWnd, cName, hHash ) CLASS HBDbHash\n\n LOCAL nSet := oBrwSets:cargo[ 1 ]\n LOCAL cOldname := ::hashName\n LOCAL uValue\n\n SWITCH nKey\n CASE K_UP\n oBrwSets:Up()\n EXIT\n\n CASE K_DOWN\n oBrwSets:Down()\n EXIT\n\n CASE K_HOME\n CASE K_CTRL_PGUP\n CASE K_CTRL_HOME\n oBrwSets:GoTop()\n EXIT\n\n CASE K_END\n CASE K_CTRL_PGDN\n CASE K_CTRL_END\n oBrwSets:GoBottom()\n EXIT\n\n CASE K_PGDN\n oBrwSets:pageDown()\n EXIT\n\n CASE K_PGUP\n oBrwSets:PageUp()\n EXIT\n\n CASE K_ENTER\n uValue := hb_HValueAt( hHash, nSet )\n\n IF HB_ISHASH( uValue )\n IF Len( uValue ) == 0\n __dbgAlert( \"Hash is empty\" )\n ELSE\n SetPos( ownd:nBottom, ownd:nLeft )\n ::aWindows[ ::nCurwindow ]:lFocused := .F.\n\n ::hashName := ::hashName + \"[\" + HashKeyString( hHash, nSet ) + \"]\"\n ::AddWindows( hb_HValueAt( hHash, nSet ), oBrwSets:RowPos + oBrwSets:nTop )\n ::hashName := cOldName\n\n hb_ADel( ::aWindows, ::nCurWindow, .T. )\n IF ::nCurwindow == 0\n ::nCurwindow := 1\n ELSE\n ::nCurwindow--\n ENDIF\n ENDIF\n ELSEIF HB_ISPOINTER( uValue ) .OR. ! ::lEditable\n __dbgAlert( \"Value cannot be edited\" )\n ELSE\n oBrwSets:RefreshCurrent()\n DO CASE\n CASE HB_ISOBJECT( uValue )\n __dbgObject( uValue, cName + \"[\" + HashKeyString( hHash, nSet ) + \"]\" )\n CASE HB_ISARRAY( uValue )\n IF Len( uValue ) == 0\n __dbgAlert( \"Array is empty\" )\n ELSE\n __dbgArrays( uValue, cName + \"[\" + HashKeyString( hHash, nSet ) + \"]\" )\n ENDIF\n OTHERWISE\n ::doGet( oBrwSets, hHash, nSet )\n ENDCASE\n oBrwSets:RefreshCurrent()\n oBrwSets:ForceStable()\n ENDIF\n EXIT\n\n ENDSWITCH\n\n oBrwSets:forcestable()\n\n ::aWindows[ ::nCurwindow ]:SetCaption( cName + \"[\" + hb_ntos( oBrwSets:cargo[ 1 ] ) + \"..\" + ;\n hb_ntos( Len( hHash ) ) + \"]\" )\n\n RETURN Self\n\nFUNCTION __dbgHashes( hHash, cVarName, lEditable )\n RETURN HBDbHash():New( hHash, cVarName, lEditable )\n\nSTATIC FUNCTION GetTopPos( nPos )\n RETURN iif( ( MaxRow() - nPos ) < 5, MaxRow() - nPos, nPos )\n\nSTATIC FUNCTION GetBottomPos( nPos )\n RETURN iif( nPos < MaxRow() - 2, nPos, MaxRow() - 2 )\n\nSTATIC FUNCTION HashBrowseSkip( nPos, oBrwSets )\n RETURN ;\n iif( oBrwSets:cargo[ 1 ] + nPos < 1, -oBrwSets:cargo[ 1 ] + 1, ;\n iif( oBrwSets:cargo[ 1 ] + nPos > Len( oBrwSets:cargo[ 2 ][ 1 ] ), ;\n Len( oBrwSets:cargo[ 2 ][ 1 ] ) - oBrwSets:cargo[ 1 ], nPos ) )\n\nSTATIC FUNCTION HashKeyString( hHash, nAt )\n RETURN __dbgValToExp( hb_HKeyAt( hHash, nAt ) )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour header file: include/hbclass.ch. Defines 10 constants including: HB_CLASS_CH_, HB_CLS_FWO, HB_CLS_CSY, HB_CLS_VO, HB_CLS_TOP. Declares 5 preprocessor commands. Declares 5 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_CLASS_CH_\n#define HB_CLASS_CH_\n\n#include \"hboo.ch\"\n\n\n#ifndef HB_CLS_FWO\n#ifndef HB_CLS_CSY\n#ifndef HB_CLS_VO\n#ifndef HB_CLS_TOP\n\n\n#define HB_CLS_FWO\n#define HB_CLS_CSY\n#define HB_CLS_VO\n#define HB_CLS_TOP\n#define HB_CLS_XPP\n\n#endif\n#endif\n#endif\n#endif\n\n\n#ifdef HB_CLP_STRICT\n #ifndef HB_CLS_NO_DECORATION\n #define HB_CLS_NO_DECORATION\n #endif\n #ifndef HB_CLS_PARAM_LIST\n #define HB_CLS_PARAM_LIST\n #endif\n#endif\n\n\n#if __pragma( WARNINGLEVEL ) < 3\n #ifndef HB_CLS_NO_PARAMS_ERR\n #define HB_CLS_NO_PARAMS_ERR\n #endif\n#endif\n\n\n#ifdef HB_CLS_NO_DECORATION\n #xtranslate __HB_CLS_MTHNAME => \n#else\n #xtranslate __HB_CLS_MTHNAME => _\n#endif\n\n\n#ifndef HB_CLS_PARAM_LIST\n #define HB_CLS_PARAM_LIST ...\n#endif\n\n\n#ifdef HB_CLS_NO_DECLARATIONS\n #xcommand _HB_CLASS =>\n #xcommand _HB_CLASS =>\n #xcommand _HB_MEMBER =>\n #xcommand DECLARE <*decl*> =>\n #xtranslate AS =>\n #xtranslate AS CLASS =>\n#endif\n\n\n#ifdef HB_CLS_NOTOBJECT\n #xtranslate __HB_CLS_PAR([]) => { }\n#else\n #xtranslate __HB_CLS_PAR([]) => iif( <.cls.>, { }, { @HBObject() } )\n#endif\n\n\n#ifdef HB_CLS_NOAUTOINIT\n #define __HB_CLS_NOINI .T.\n#else\n #define __HB_CLS_NOINI .F.\n#endif\n\n\n#ifdef HB_CLS_NO_PARAMS_ERR\n #xtranslate __HB_CLS_PARAMS() => __HB_CLS_ASID()\n#else\n #xtranslate __HB_CLS_PARAMS() => \n#endif\n\n\n#ifdef HB_CLS_NO_OO_ERR\n #xtranslate __HB_CLS_ERR([]) =>\n #xtranslate __HB_CLS_WARN([]) =>\n#else\n #xtranslate __HB_CLS_ERR([]) => ;#error [ ] ; #line\n #xtranslate __HB_CLS_WARN([]) => ;#warning [ ] ; #line\n#endif\n\n\n#translate @:([]) => ;\n ::realclass:([ ])\n\n\n#xtranslate :Super( ): => ::\n\n\n#xtranslate __HB_CLS_OPT(
,) => \n#xtranslate __HB_CLS_OPT() => \n\n#xtranslate __HB_CLS_ASSTRING( ) => <(FuncName)>\n#xtranslate __HB_CLS_ASSTRING( ([]) ) => <(FuncName)>\n#xtranslate __HB_CLS_ASFUNC( ) => ()\n#xtranslate __HB_CLS_ASFUNC( ([]) ) => ([ ])\n#xtranslate __HB_CLS_ASID( ) => \n#xtranslate __HB_CLS_ASID( ([]) ) => \n#xtranslate __HB_CLS_ASARGS( ) =>\n#xtranslate __HB_CLS_ASARGS( ([]) ) => [ ]\n#xtranslate __HB_CLS_ASARGSOPT( ) =>\n#xtranslate __HB_CLS_ASARGSOPT( ([]) ) => [, ]\n\n\n#xtranslate __HB_CLS_SCOPE( ) => ) __HB_CLS_ERR( Can not use multiple scope qualifiers! )\n#xtranslate __HB_CLS_SCOPE( .T., .F., .F. ) => HB_OO_CLSTP_EXPORTED\n#xtranslate __HB_CLS_SCOPE( .F., .T., .F. ) => HB_OO_CLSTP_PROTECTED\n#xtranslate __HB_CLS_SCOPE( .F., .F., .T. ) => HB_OO_CLSTP_HIDDEN\n#xtranslate __HB_CLS_SCOPE( .F., .F., .F. ) => nScope \n\n\n#xcommand CLASS [METACLASS ] ;\n [ [,] ] ;\n [ ] ;\n [ ] [ FUNCTION ] => ;\n _HB_CLASS ;;\n function __HB_CLS_OPT( [,] ) ( HB_CLS_PARAM_LIST ) ;;\n STATIC s_oClass ;;\n LOCAL nScope, oClass, oInstance ;;\n IF s_oClass == NIL .AND. __clsLockDef( @s_oClass ) ;;\n BEGIN SEQUENCE ;;\n nScope := HB_OO_CLSTP_EXPORTED ; HB_SYMBOL_UNUSED( nScope ) ;;\n oClass := iif( <.metaClass.>, <(metaClass)>, HBClass():new( <(ClassName)>, __HB_CLS_PAR( [ @() ] [ , @() ] ), @__HB_CLS_OPT([__HB_CLS_ASID(),] )() [, <.modulfriend.> ] ) ) ;;;\n #undef _CLASS_NAME_ ; #define _CLASS_NAME_ ;;\n #undef _CLASS_MODE_ ; #define _CLASS_MODE_ _CLASS_DECLARATION_\n\n#xcommand ENDCLASS [] => ;\n oClass:Create() ; [<-lck-> __clsLock( oClass:hClass ) ] ;;\n ALWAYS ;;\n __clsUnlockDef( @s_oClass, oClass ) ;;\n END SEQUENCE ;;\n oInstance := oClass:Instance() ;;\n IF __objHasMsg( oInstance, \"InitClass\" ) ;;\n oInstance:InitClass( HB_CLS_PARAM_LIST ) ;;\n END ;;\n RETURN oInstance ;;\n END ;;\n RETURN s_oClass:Instance() AS CLASS _CLASS_NAME_ ;;\n #undef _CLASS_MODE_ ; #define _CLASS_MODE_ _CLASS_IMPLEMENTATION_\n\n\n#xcommand DECLARED METHOD CLASS => ;\n static __HB_CLS_MTHNAME ;;\n local Self AS CLASS := QSelf() AS CLASS \n\n#xcommand __HB_CLS_DECLARE_METHOD => ;\n #xcommand METHOD \\ CLASS _CLASS_IMPLEMENTATION_ => ;\n DECLARED METHOD \\ CLASS \n\n#xcommand __HB_CLS_DECLARE_METHOD => ;\n #xcommand METHOD \\ CLASS _CLASS_IMPLEMENTATION_ => ;\n DECLARED METHOD \\ CLASS ;;\n #xcommand METHOD \\ (\\[ \\] ) CLASS _CLASS_IMPLEMENTATION_ => ;\n DECLARED METHOD \\ (\\[ \\] ) CLASS \n\n#xcommand METHOD CLASS _CLASS_IMPLEMENTATION_ => ;\n __HB_CLS_WARN( Method \\<> not declared or declaration mismatch in class \\<> ) ;;\n DECLARED METHOD CLASS \n\n#xcommand METHOD [ ] [ AS ] [ ] [] [Main Page\n\n\n\n#pragma __endtext\n\n IF Empty( cAction )\n \n oCookie := uhttpd_CookieNew( \"localhost\", \"/\", 1, 0 )\n \n oCookie:DeleteCookie( \"mycookie\" )\n\n cHtml := StrTran( cHtml, \"<%COOKIE_VALUE%>\", cCookie )\n ELSEIF cAction == \"gotoinfo\"\n \n oCookie := uhttpd_CookieNew( \"localhost\", \"/\", 1, 0 )\n oCookie:SetCookie( \"mycookie\", cCookie )\n uhttpd_SetHeader( \"Location\", \"/info\" )\n \n RETURN NIL\n ENDIF\n\n RETURN cHtml"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/round.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL n, value := -5\n\n FOR n := 1 TO 100\n ? ;\n value, ;\n Round( value, 3 ),;\n Round( value, 2 ),;\n Round( value, 1 ),;\n Round( value, 0 )\n value += 0.001\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Header file for contribution module 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/hbxpp.ch. Defines constants: B_THIN, B_FAT, HB_B_THIN_UNI, HB_B_FAT_UNI. Declares 2 preprocessor commands. Declares 5 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifdef __XPP__\n\n\n#else\n#ifdef __HARBOUR__\n\n\n#include \"hbclass.ch\"\n\n#if ! defined( XPP_OP_OVERLOAD_OFF )\n #pragma -ks+\n REQUEST xpp_op_Overload\n#endif\n\n#xtranslate IsPrinter( [] ) => hb_IsPrinter( )\n#xtranslate DispOutAt( ) => hb_DispOutAt( )\n#xtranslate AAdd( , ,

) => hb_AIns( , ,

, .T. )\n\n#xtranslate TBColumn() => xpp_TBColumn()\n#xtranslate TBrowse() => xpp_TBrowse()\n#xtranslate Get() => xpp_Get()\n\n\n#define B_THIN ( Chr( 219 ) + Chr( 223 ) + Chr( 219 ) + Chr( 219 ) + ;\n Chr( 219 ) + Chr( 220 ) + Chr( 219 ) + Chr( 219 ) )\n\n#define B_FAT ( Chr( 219 ) + Chr( 219 ) + Chr( 219 ) + Chr( 219 ) + ;\n Chr( 219 ) + Chr( 219 ) + Chr( 219 ) + Chr( 219 ) )\n\n#define HB_B_THIN_UNI hb_UTF8ToStrBox( \"█▀███▄██\" )\n#define HB_B_FAT_UNI hb_UTF8ToStrBox( \"████████\" )\n\n\n#xcommand TEXT INTO [] [] => ;\n #pragma __text | += iif( <.trm.>, LTrim( %s ), %s ) +;\n iif( <.wrp.>, hb_eol(), \"\" ); := \"\"\n#xcommand TEXT INTO WRAP [] [] => ;\n #pragma __text | += iif( <.trm.>, LTrim( %s ), %s ) +;\n iif( <.EOL.>, , hb_eol() ); := \"\"\n\n#endif\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: TODBCField, TODBC. Harbour contribution module 'hbodbc' (ODBC database connectivity): contrib/hbodbc/todbc.prg. Defines classes: TODBCField, TODBC. This file handles database operations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"sql.ch\"\n\n\nCREATE CLASS TODBCField\n\n VAR FieldID INIT -1\n VAR FieldName INIT \"\"\n VAR DataType INIT -1\n VAR DataSize INIT -1\n VAR DataDecs INIT -1\n VAR AllowNull INIT .F.\n VAR Value INIT NIL\n\n METHOD New()\n\nENDCLASS\n\nMETHOD New() CLASS TODBCField\n RETURN Self\n\n\nCREATE CLASS TODBC\n\n VAR hEnv\n VAR hDbc\n VAR hStmt\n VAR cODBCStr\n VAR cODBCRes\n VAR cSQL\n VAR Active INIT .F.\n VAR Fields INIT {}\n VAR nEof INIT 0\n VAR lBof INIT .F.\n VAR nRetCode\n VAR nRecCount INIT 0 \n VAR nRecNo INIT 0 \n VAR lCacheRS \n VAR aRecordSet INIT {} \n\n VAR lAutoCommit AS LOGICAL INIT .T. \n\n METHOD New( cODBCStr, cUserName, cPassword, lCache )\n METHOD Destroy()\n\n METHOD SetSQL( cSQL )\n METHOD Open()\n METHOD ExecSQL()\n METHOD Close()\n\n METHOD LoadData( nPos )\n METHOD ClearData() INLINE AEval( ::Fields, {| oField | oField:Value := NIL } )\n METHOD FieldByName( cField )\n\n METHOD Fetch( nFetchType, nOffSet )\n\n METHOD Next()\n METHOD Prior()\n METHOD First()\n METHOD Last()\n METHOD MoveBy( nSteps )\n METHOD GoTo( nRecNo )\n METHOD Skip()\n METHOD Eof()\n METHOD Bof()\n METHOD RecNo()\n METHOD RecCount()\n METHOD LastRec()\n\n METHOD SQLErrorMessage()\n\n METHOD SetCnnOptions( nType, uBuffer )\n METHOD GetCnnOptions( nType )\n METHOD Commit()\n METHOD RollBack()\n METHOD SetStmtOptions( nType, uBuffer )\n METHOD GetStmtOptions( nType )\n METHOD SetAutoCommit( lEnable )\n\nENDCLASS\n\nMETHOD SQLErrorMessage() CLASS TODBC\n\n LOCAL cErrorClass, nType, cErrorMsg\n\n SQLError( ::hEnv, ::hDbc, ::hStmt, @cErrorClass, @nType, @cErrorMsg )\n\n RETURN \"Error \" + cErrorClass + \" - \" + cErrorMsg\n\nMETHOD New( cODBCStr, cUserName, cPassword, lCache ) CLASS TODBC\n\n LOCAL nRet\n\n hb_default( @lCache, .T. )\n\n ::cODBCStr := cODBCStr\n ::lCacheRS := lCache\n\n \n IF ( nRet := SQLAllocEnv( @::hEnv ) ) != SQL_SUCCESS\n ::nRetCode := nRet\n RETURN NIL\n ENDIF\n\n SQLAllocConnect( ::hEnv, @::hDbc ) \n\n IF HB_ISSTRING( cUserName )\n\n hb_default( @cPassword, \"\" )\n\n IF ! ( ( nRet := SQLConnect( ::hDbc, cODBCStr, cUserName, cPassword ) ) == SQL_SUCCESS .OR. nRet == SQL_SUCCESS_WITH_INFO )\n \n ENDIF\n ELSE\n SQLDriverConnect( ::hDbc, ::cODBCStr, @::cODBCRes ) \n ENDIF\n\n RETURN Self\n\nMETHOD SetAutoCommit( lEnable ) CLASS TODBC\n\n LOCAL lOld := ::lAutoCommit\n\n hb_default( @lEnable, .T. )\n\n IF lEnable != lOld\n ::SetCnnOptions( SQL_AUTOCOMMIT, iif( lEnable, SQL_AUTOCOMMIT_ON, SQL_AUTOCOMMIT_OFF ) )\n ::lAutoCommit := lEnable\n ENDIF\n\n RETURN lOld\n\nMETHOD Destroy() CLASS TODBC\n\n SQLDisconnect( ::hDbc ) \n\n ::hDbc := NIL \n ::hEnv := NIL \n\n RETURN NIL\n\nMETHOD GetCnnOptions( nType ) CLASS TODBC\n\n LOCAL cBuffer := Space( 256 )\n\n ::nRetCode := SQLGetConnectAttr( ::hDbc, nType, @cBuffer )\n\n RETURN cBuffer\n\nMETHOD SetCnnOptions( nType, uBuffer ) CLASS TODBC\n\n RETURN ::nRetCode := SQLSetConnectAttr( ::hDbc, nType, uBuffer )\n\nMETHOD Commit() CLASS TODBC\n\n RETURN ::nRetCode := SQLCommit( ::hEnv, ::hDbc )\n\nMETHOD RollBack() CLASS TODBC\n\n RETURN ::nRetCode := SQLRollback( ::hEnv, ::hDbc )\n\nMETHOD GetStmtOptions( nType ) CLASS TODBC\n\n LOCAL cBuffer := Space( 256 )\n\n ::nRetCode := SQLGetStmtAttr( ::hStmt, nType, @cBuffer )\n\n RETURN cBuffer\n\nMETHOD SetStmtOptions( nType, uBuffer ) CLASS TODBC\n\n RETURN ::nRetCode := SQLSetStmtAttr( ::hStmt, nType, uBuffer )\n\nMETHOD SetSQL( cSQL ) CLASS TODBC\n\n \n IF ::Active\n ::Close()\n ENDIF\n\n ::cSQL := cSQL\n\n RETURN NIL\n\nMETHOD Open() CLASS TODBC\n\n LOCAL nRet\n LOCAL nCols\n LOCAL nRows\n LOCAL i\n LOCAL cColName\n LOCAL nNameLen\n LOCAL nDataType\n LOCAL nColSize\n LOCAL nDecimals\n LOCAL nNul\n LOCAL nResult\n LOCAL aCurRow\n LOCAL oField\n\n DO WHILE .T.\n\n \n IF ::Active\n\n \n nRet := -1\n EXIT\n ENDIF\n\n \n IF Empty( ::cSQL )\n\n \n nRet := -1\n EXIT\n ENDIF\n\n \n SQLAllocStmt( ::hDbc, @::hStmt )\n IF ( nRet := SQLExecDirect( ::hStmt, ::cSQL ) ) != SQL_SUCCESS\n EXIT\n ENDIF\n\n \n SQLNumResultCols( ::hStmt, @nCols )\n\n \n nResult := SQLRowCount( ::hStmt, @nRows )\n IF nResult == SQL_SUCCESS\n ::nRecCount := nRows\n ENDIF\n\n ::Fields := Array( nCols )\n\n FOR i := 1 TO nCols\n\n SQLDescribeCol( ::hStmt, i, @cColName, 255, @nNameLen, @nDataType, ;\n @nColSize, @nDecimals, @nNul )\n\n ::Fields[ i ] := oField := TODBCField():New()\n oField:FieldID := i\n oField:FieldName := cColName\n oField:DataSize := nColsize\n oField:DataType := nDataType\n oField:DataDecs := nDecimals\n oField:AllowNull := ( nNul != 0 )\n\n NEXT\n\n \n IF ::lCacheRS\n ::aRecordSet := {}\n DO WHILE ::Fetch( SQL_FETCH_NEXT, 1 ) == SQL_SUCCESS\n\n aCurRow := Array( nCols )\n FOR i := 1 TO nCols\n aCurRow[ i ] := ::Fields[ i ]:value\n NEXT\n AAdd( ::aRecordSet, aCurRow )\n ENDDO\n\n ::nRecCount := Len( ::aRecordSet )\n ELSE\n IF ::First() == SQL_SUCCESS\n ::nRecCount := 1\n ELSE\n ::nRecCount := 0\n ENDIF\n ENDIF\n\n ::nRecNo := 1 \n ::Active := .T. \n\n EXIT\n\n ENDDO\n\n RETURN nRet == SQL_SUCCESS\n\n\nMETHOD ExecSQL() CLASS TODBC\n\n LOCAL nRet\n\n \n IF Empty( ::cSQL )\n nRet := SQL_ERROR\n ELSE\n \n SQLAllocStmt( ::hDbc, @::hStmt )\n nRet := SQLExecDirect( ::hStmt, ::cSQL )\n\n ::Close()\n ENDIF\n\n RETURN nRet\n\n\nMETHOD Close() CLASS TODBC\n\n \n ::hStmt := NIL\n ::Active := .F.\n\n \n IF ::lCacheRS\n ::aRecordSet := {}\n ENDIF\n ::nRecCount := 0\n ::nRecNo := 0\n ::lBof := .T.\n\n RETURN NIL\n\n\nMETHOD FieldByName( cField ) CLASS TODBC\n\n LOCAL nRet\n LOCAL xRet := NIL\n\n IF HB_ISSTRING( cField )\n nRet := AScan( ::Fields, {| x | Upper( x:FieldName ) == Upper( cField ) } )\n\n IF nRet != 0\n xRet := ::Fields[ nRet ]\n ELSE\n \n \n ENDIF\n ENDIF\n\n RETURN xRet\n\n\nMETHOD Fetch( nFetchType, nOffset ) CLASS TODBC\n\n LOCAL nResult\n LOCAL nPos := NIL\n\n \n ::ClearData()\n\n \n IF ::lCacheRS .AND. ::Active \n\n \n SWITCH nFetchType\n CASE SQL_FETCH_NEXT\n\n IF ::nRecNo == ::nRecCount\n nResult := SQL_NO_DATA_FOUND\n ELSE\n nResult := SQL_SUCCESS\n nPos := ::nRecNo + 1\n ENDIF\n EXIT\n\n CASE SQL_FETCH_PRIOR\n IF ::nRecNo == 1\n nResult := SQL_NO_DATA_FOUND\n ELSE\n nResult := SQL_SUCCESS\n nPos := ::nRecNo - 1\n ENDIF\n EXIT\n\n CASE SQL_FETCH_FIRST\n nResult := SQL_SUCCESS\n nPos := 1\n EXIT\n\n CASE SQL_FETCH_LAST\n nResult := SQL_SUCCESS\n nPos := ::nRecCount\n EXIT\n\n CASE SQL_FETCH_RELATIVE\n IF ( ::nRecNo + nOffset ) > ::nRecCount .OR. ( ::nRecNo + nOffset ) < 1 \n nResult := SQL_ERROR\n ELSE\n nResult := SQL_SUCCESS\n nPos := ::nRecNo + nOffset\n ENDIF\n EXIT\n\n CASE SQL_FETCH_ABSOLUTE\n IF nOffset > ::nRecCount .OR. nOffset < 1 \n nResult := SQL_ERROR\n ELSE\n nResult := SQL_SUCCESS\n nPos := nOffset\n ENDIF\n EXIT\n\n OTHERWISE\n nResult := SQL_ERROR\n ENDSWITCH\n\n ELSE\n nResult := SQLFetchScroll( ::hStmt, nFetchType, nOffSet )\n ENDIF\n\n IF nResult == SQL_SUCCESS .OR. nResult == SQL_SUCCESS_WITH_INFO\n nResult := SQL_SUCCESS\n\n ::LoadData( nPos )\n ::lBof := .F.\n ELSE\n \n ENDIF\n\n RETURN nResult\n\n\nMETHOD Next() CLASS TODBC\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour test program: tests/mouse.prg. Provides functions: MUPDATE, MINRECT. Contains 4 procedures. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n\nPROCEDURE Main()\n\n LOCAL nR := 5, nC := 38\n\n SET CURSOR OFF\n CLS\n IF ! MPresent()\n ? \" No mouse present !\"\n QUIT\n ENDIF\n\n @ 0, 0 TO MaxRow(), MaxCol() DOUBLE\n @ MaxRow() - 2, 0 TO MaxRow(), 18 DOUBLE\n @ MaxRow() - 1, 2 SAY \"Y:\"\n @ MaxRow() - 1, 10 SAY \"X:\"\n\n @ nR, 2 SAY \"Mouse Type :\"\n\n @ nR, 18 SAY \"Mouse System\"\n\n @ MaxRow() - 2, 68 TO MaxRow(), MaxCol() DOUBLE\n @ MaxRow() - 1, 70 SAY \"Exit\"\n\n @ 10, 2 SAY \" -- Checkings --\"\n @ 11, 2 SAY \"Window Boundaries :\"\n @ 12, 2 SAY \"Press/Release But.:\"\n @ 13, 2 SAY \"Double Click Left :\"\n @ 14, 2 SAY \"Double Click Right:\"\n\n TEST1()\n\n TEST2( nR, nC )\n\n SetPos( MaxRow(), 0 )\n\n SET CURSOR ON\n ?\n\n RETURN\n\nSTATIC FUNCTION MUPDATE()\n\n @ MaxRow() - 1, 4 SAY MRow() PICTURE \"9999\"\n @ MaxRow() - 1, 12 SAY MCol() PICTURE \"9999\"\n\n RETURN 0\n\nSTATIC FUNCTION MINRECT( nTop, nLeft, nBott, nRight )\n\n LOCAL lInside := .F.\n\n IF MRow() >= nTop .AND. MRow() <= nBott\n IF MCol() >= nLeft .AND. MCol() <= nRight\n lInside := .T.\n ENDIF\n ENDIF\n\n RETURN lInside\n\n\nSTATIC PROCEDURE TEST1()\n\n LOCAL nKey\n\n @ MaxRow() - 3, 25 SAY \"Move the cursor until the UPPER side \"\n MUPDATE()\n\n DO WHILE ( nKey := Inkey( 0, INKEY_ALL ) ) != K_TAB\n MUPDATE()\n IF nKey == K_MOUSEMOVE\n IF MRow() < 1\n EXIT\n ENDIF\n CHECKEXIT()\n ENDIF\n ENDDO\n\n @ MaxRow() - 3, 25 SAY \"Move the cursor until the BOTTOM side \"\n\n DO WHILE ( nKey := Inkey( 0, INKEY_ALL ) ) != K_TAB\n MUPDATE()\n IF nKey == K_MOUSEMOVE\n IF MRow() > MaxRow() - 1\n EXIT\n ENDIF\n CHECKEXIT()\n ENDIF\n ENDDO\n\n @ MaxRow() - 3, 25 SAY \"Move the cursor until the LEFT side \"\n\n DO WHILE ( nKey := Inkey( 0, INKEY_ALL ) ) != K_TAB\n MUPDATE()\n IF nKey == K_MOUSEMOVE\n IF MCol() < 1\n EXIT\n ENDIF\n CHECKEXIT()\n ENDIF\n ENDDO\n\n @ MaxRow() - 3, 25 SAY \"Move the cursor until the RIGHT side \"\n\n DO WHILE ( nKey := Inkey( 0, INKEY_ALL ) ) != K_TAB\n MUPDATE()\n IF nKey == K_MOUSEMOVE\n IF MCol() > MaxCol() - 1\n EXIT\n ENDIF\n CHECKEXIT()\n ENDIF\n ENDDO\n\n @ MaxRow() - 3, 20 SAY Space( 50 )\n @ 11, 22 SAY \"Pass\"\n\n RETURN\n\n\nSTATIC PROCEDURE TEST2( nR, nC )\n\n LOCAL cSkip := \"\", nKey, nPress := 0\n\n @ nR + 0, nC SAY \"+---------|---------+\"\n @ nR + 1, nC SAY \"| +===+ +===+ +===+ |\"\n @ nR + 2, nC SAY \"| | | | | | | |\"\n @ nR + 3, nC SAY \"| | | | | | | |\"\n @ nR + 4, nC SAY \"| +===+ +===+ +===+ |\"\n @ nR + 5, nC SAY \"| |\"\n @ nR + 6, nC SAY \"| Up Up Up |\"\n @ nR + 7, nC SAY \"| |\"\n @ nR + 8, nC SAY \"| |\"\n @ nR + 9, nC SAY \"| Harbour |\"\n @ nR + 10, nC SAY \"| mouse |\"\n @ nR + 11, nC SAY \"+-------------------+\"\n\n Set( _SET_EVENTMASK, INKEY_ALL )\n\n IF ! Empty( cSkip )\n IF Upper( cSkip ) == \"BREAK\"\n SetCancel( .T. )\n ELSE\n SetCancel( .F. )\n ENDIF\n ENDIF\n\n MUPDATE()\n\n WHILE ( nKey := Inkey( 0, INKEY_ALL ) ) != K_TAB\n\n DO CASE\n CASE nKey == K_MOUSEMOVE\n \n IF MINRECT( 19, 40, 22, 60 )\n MHide()\n ELSE\n MShow()\n ENDIF\n CHECKEXIT()\n MUPDATE()\n\n CASE nKey == K_LBUTTONDOWN\n \n @ nR + 2, nC + 3 SAY \"XXX\"\n @ nR + 3, nC + 3 SAY \"XXX\"\n @ nR + 6, nC + 3 SAY \"Down\"\n nPress ++\n\n CASE nKey == K_LBUTTONUP\n \n @ nR + 2, nC + 3 SAY \" \"\n @ nR + 3, nC + 3 SAY \" \"\n @ nR + 6, nC + 3 SAY \"Up \"\n\n CASE nKey == K_MBUTTONDOWN\n \n @ nR + 2, nC + 10 SAY \"XXX\"\n @ nR + 3, nC + 10 SAY \"XXX\"\n @ nR + 6, nC + 10 SAY \"Down\"\n nPress ++\n\n CASE nKey == K_MBUTTONUP\n \n @ nR + 6, nC + 10 SAY \"Up \"\n\n CASE nKey == K_RBUTTONDOWN\n \n @ nR + 2, nC + 15 SAY \"XXX\"\n @ nR + 3, nC + 15 SAY \"XXX\"\n @ nR + 6, nC + 15 SAY \"Down\"\n nPress ++\n\n CASE nKey == K_RBUTTONUP\n \n @ nR + 2, nC + 15 SAY \" \"\n @ nR + 3, nC + 15 SAY \" \"\n @ nR + 6, nC + 15 SAY \"Up \"\n\n CASE nKey == K_LDBLCLK\n \n @ 13, 22 SAY \"Pass\"\n\n CASE nKey == K_RDBLCLK\n \n @ 14, 22 SAY \"Pass\"\n\n OTHERWISE\n @ MaxRow(), 20 SAY \"A keyboard key was pressed:\"\n @ MaxRow(), 48 SAY nKey\n#ifdef __HARBOUR__\n @ MaxRow(), 58 SAY hb_keyChar( nKey )\n#else\n @ MaxRow(), 58 SAY iif( nKey >= 32 .AND. nKey <= 255, Chr( nKey ), \"\" )\n#endif\n ENDCASE\n\n IF nPress > 6\n EXIT\n ENDIF\n\n ENDDO\n\n @ MaxRow() - 3, 20 SAY Space( 50 )\n @ 12, 22 SAY \"Pass\"\n\n SET CURSOR ON\n\n @ 20, 1 SAY \"MOUSE TEST FINISH!\"\n ?\n\n RETURN\n\nSTATIC PROCEDURE CHECKEXIT()\n\n IF ! MINRECT( MaxRow() - 2, MaxCol() - 11, MaxRow(), MaxCol() )\n RETURN\n ENDIF\n SET CURSOR ON\n CLS\n ? \"MOUSE TEST FINISH!\"\n ?\n QUIT"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour header file: include/blob.ch. Defines constants: HB_BLOB_CH_. Declares 5 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_BLOB_CH_\n#define HB_BLOB_CH_\n\n#ifndef HB_DBINFO_CH_\n #include \"dbinfo.ch\"\n#endif\n\n#xtranslate BLOBRootLock() => dbInfo( DBI_BLOB_ROOT_LOCK )\n#xtranslate BLOBRootUnlock() => dbInfo( DBI_BLOB_ROOT_UNLOCK )\n#xtranslate BLOBRootGet() => dbInfo( DBI_BLOB_ROOT_GET )\n#xtranslate BLOBRootPut( ) => dbInfo( DBI_BLOB_ROOT_PUT, )\n#xtranslate BLOBRootDelete() => BLOBRootPut( \"\" )\n\n#xtranslate BLOBDirectExport( , [, ] ) => ;\n dbInfo( DBI_BLOB_DIRECT_EXPORT, { , , ;\n iif( <.kMode.>, , BLOB_EXPORT_OVERWRITE ) } )\n#xtranslate BLOBDirectGet( [, [, ]] ) => ;\n dbInfo( DBI_BLOB_DIRECT_GET, { , , } )\n#xtranslate BLOBDirectImport( , ) => ;\n dbInfo( DBI_BLOB_DIRECT_IMPORT, { , } )\n#xtranslate BLOBDirectPut( [], ) => ;\n dbInfo( DBI_BLOB_DIRECT_PUT, { , } )\n#xtranslate BLOBGet( [, [, ]] ) => ;\n dbFieldInfo( DBS_BLOB_GET, , { , } )\n#xtranslate BLOBExport( , , ) => ;\n dbFileGet( , , )\n#xtranslate BLOBImport( , ) => ;\n dbFilePut( , )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/valpos.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of ValPos()\"\n ?\n\n ? ' ValPos( \"1234x56789\" ) == 9 ? --> ' + Str( ValPos( \"1234x56789\" ) )\n ? ' ValPos( \"1234x56789\", 1 ) == 1 ? --> ' + Str( ValPos( \"1234x56789\", 1 ) )\n ? ' ValPos( \"1234x56789\", 11 ) == 0 ? --> ' + Str( ValPos( \"1234x56789\", 11 ) )\n ? ' ValPos( \"1234x56789\", 5 ) == 0 ? --> ' + Str( ValPos( \"1234x56789\", 5 ) )\n\n ?\n ? \"End test of ValPos()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbhttpd' (Multithreaded HTTP/HTTPS server framework): contrib/hbhttpd/tests/eshop.prg. Provides 6 functions including: proc_login, proc_logout, proc_main, proc_shopping, proc_cart. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbssl\"\n#require \"hbhttpd\"\n\nREQUEST __HBEXTERN__HBSSL__\n\nREQUEST DBFCDX\n\nMEMVAR server, get, post, cookie, session\n\nPROCEDURE Main()\n\n LOCAL oServer\n\n LOCAL oLogAccess\n LOCAL oLogError\n\n LOCAL nPort\n\n IF hb_argCheck( \"help\" )\n ? \"Usage: app [options]\"\n ? \"Options:\"\n ? \" \n ? \" \n RETURN\n ENDIF\n\n IF hb_argCheck( \"stop\" )\n hb_MemoWrit( \".uhttpd.stop\", \"\" )\n RETURN\n ELSE\n FErase( \".uhttpd.stop\" )\n ENDIF\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n rddSetDefault( \"DBFCDX\" )\n\n IF ! hb_dbExists( \"users.dbf\" )\n hb_dbDrop( \"users.cdx\" )\n dbCreate( \"users\", { { \"USER\", \"C\", 16, 0 }, { \"PASSWORD\", \"C\", 16, 0 }, { \"NAME\", \"C\", 50, 0 } }, , .T., \"user\" )\n dbAppend()\n FIELD->USER := \"demo\"\n FIELD->PASSWORD := \"demo\"\n FIELD->NAME := \"Demo\"\n ordCreate( \"users\", \"user\", \"USER\" )\n dbCloseArea()\n ELSEIF ! hb_dbExists( \"users.cdx\" )\n dbUseArea( .T., , \"users\", , .F., .F. )\n ordCreate( \"users\", \"user\", \"USER\" )\n dbCloseArea()\n ENDIF\n\n IF ! hb_dbExists( \"carts.dbf\" )\n hb_dbDrop( \"carts.cdx\" )\n dbCreate( \"carts\", { { \"USER\", \"C\", 16, 0 }, { \"CODE\", \"C\", 16, 0 }, { \"AMOUNT\", \"N\", 6, 0 }, { \"TOTAL\", \"N\", 9, 2 } }, , .T., \"cart\" )\n ordCreate( \"carts\", \"user\", \"USER+CODE\" )\n dbCloseArea()\n ELSEIF ! hb_dbExists( \"carts.cdx\" )\n dbUseArea( .T., , \"carts\", , .F., .F. )\n ordCreate( \"carts\", \"user\", \"USER+CODE\" )\n dbCloseArea()\n ENDIF\n\n IF ! hb_dbExists( \"items.dbf\" )\n hb_dbDrop( \"items.cdx\" )\n dbCreate( \"items\", { { \"CODE\", \"C\", 16, 0 }, { \"TITLE\", \"C\", 80, 0 }, { \"PRICE\", \"N\", 9, 2 } }, , .T., \"items\" )\n ordCreate( \"items\", \"code\", \"CODE\" )\n dbCloseArea()\n ELSEIF ! hb_dbExists( \"item.cdx\" )\n dbUseArea( .T., , \"items\", , .F., .F. )\n ordCreate( \"items\", \"code\", \"CODE\" )\n dbCloseArea()\n ENDIF\n\n oLogAccess := UHttpdLog():New( \"eshop_access.log\" )\n\n IF ! oLogAccess:Add( \"\" )\n oLogAccess:Close()\n ? \"Access log file open error \" + hb_ntos( FError() )\n RETURN\n ENDIF\n\n oLogError := UHttpdLog():New( \"eshop_error.log\" )\n\n IF ! oLogError:Add( \"\" )\n oLogError:Close()\n oLogAccess:Close()\n ? \"Error log file open error \" + hb_ntos( FError() )\n RETURN\n ENDIF\n\n ? \"Listening on port:\", nPort := 8002\n\n oServer := UHttpdNew()\n\n IF ! oServer:Run( { ;\n \"FirewallFilter\" => \"\", ;\n \"LogAccess\" => {| m | oLogAccess:Add( m + hb_eol() ) }, ;\n \"LogError\" => {| m | oLogError:Add( m + hb_eol() ) }, ;\n \"Trace\" => {| ... | QOut( ... ) }, ;\n \"Port\" => nPort, ;\n \"Idle\" => {| o | iif( hb_FileExists( \".uhttpd.stop\" ), ( FErase( \".uhttpd.stop\" ), o:Stop() ), NIL ) }, ;\n \"PrivateKeyFilename\" => \"private.key\", ;\n \"CertificateFilename\" => \"certificate.crt\", ;\n \"SSL\" => .T., ;\n \"Mount\" => { ;\n \"/hello\" => {|| UWrite( \"Hello!\" ) }, ;\n \"/info\" => {|| UProcInfo() }, ;\n \"/files/*\" => {| x | QOut( hb_DirBase() + \"/files/\" + X ), UProcFiles( hb_DirBase() + \"/files/\" + X, .F. ) }, ;\n \"/app/login\" => @proc_login(), ;\n \"/app/logout\" => @proc_logout(), ;\n \"/app/account\" => @proc_account(), ;\n \"/app/account/edit\" => @proc_account_edit(), ;\n \"/app/register\" => @proc_register(), ;\n \"/app/main\" => @proc_main(), ;\n \"/app/shopping\" => @proc_shopping(), ;\n \"/app/cart\" => @proc_cart(), ;\n \"/\" => {|| URedirect( \"/app/login\" ) } } } )\n oLogError:Close()\n oLogAccess:Close()\n ? \"Server error:\", oServer:cError\n ErrorLevel( 1 )\n RETURN\n ENDIF\n\n oLogError:Close()\n oLogAccess:Close()\n\n RETURN\n\nSTATIC FUNCTION proc_login()\n\n LOCAL cUser\n\n IF server[ \"REQUEST_METHOD\" ] == \"POST\"\n dbUseArea( .T., , \"users\", \"users\", .T., .T. )\n ordSetFocus( \"user\" )\n cUser := PadR( hb_HGetDef( post, \"user\", \"\" ), 16 )\n USessionStart()\n IF ! Empty( cUser ) .AND. dbSeek( cUser, .F. ) .AND. ! Deleted() .AND. ;\n PadR( hb_HGetDef( post, \"password\", \"\" ), 16 ) == FIELD->PASSWORD\n session[ \"user\" ] := cUser\n URedirect( \"main\" )\n ELSE\n URedirect( \"login?err\" )\n USessionDestroy()\n ENDIF\n dbCloseArea()\n ELSE\n IF hb_HHasKey( get, \"err\" )\n RETURN { \"errtext\" => \"Invalid user name or password!\" }\n ENDIF\n RETURN { => }\n ENDIF\n\n RETURN NIL\n\nSTATIC FUNCTION proc_logout()\n\n USessionStart()\n USessionDestroy()\n\n RETURN { => }\n\nSTATIC FUNCTION proc_main()\n\n USessionStart()\n IF ! hb_HHasKey( session, \"user\" )\n URedirect( \"/app/login\" )\n RETURN NIL\n ENDIF\n\n RETURN { => }\n\nSTATIC FUNCTION proc_shopping()\n\n LOCAL oW, nT, cCode\n\n USessionStart()\n IF ! hb_HHasKey( session, \"user\" )\n URedirect( \"/app/login\" )\n RETURN NIL\n ENDIF\n\n dbUseArea( .T., , \"carts\", \"carts\", .T., .F. )\n ordSetFocus( \"user\" )\n dbUseArea( .T., , \"items\", \"items\", .T., .T. )\n ordSetFocus( \"code\" )\n\n IF hb_HHasKey( get, \"add\" )\n cCode := PadR( get[ \"add\" ], 16 )\n IF items->( dbSeek( cCode ) ) .AND. carts->( FLock() )\n IF ! carts->( dbSeek( session[ \"user\" ] + cCode ) )\n carts->( dbAppend() )\n carts->USER := session[ \"user\" ]\n carts->CODE := cCode\n ENDIF\n carts->AMOUNT += 1\n carts->TOTAL += items->PRICE\n carts->( dbUnlock() )\n ENDIF\n URedirect( \"shopping\" )\n RETURN NIL\n ENDIF\n\n dbSelectArea( \"carts\" )\n ordScope( 0, session[ \"user\" ] )\n ordScope( 1, session[ \"user\" ] )\n nT := 0\n carts->( dbEval( {|| nT += FIELD->TOTAL } ) )\n dbSelectArea( \"items\" )\n oW := UWBrowseNew( \"br_item\" )\n oW:AddColumn( 101, \"Item No.\", \"CODE\" )\n oW:AddColumn( 102, \"Title\", \"TITLE\" )\n oW:AddColumn( 103, \"Price\", \"PRICE\" )\n oW:AddColumn( 104, \"\", {|| ULink( \"Add to cart\", \"?add=\" + RTrim( FIELD->CODE ) ) }, .T. )\n oW:nPageSize := 10\n IF hb_HHasKey( get, \"_pos\" )\n oW:nPos := Val( get[ \"_pos\" ] )\n ENDIF\n\n RETURN { \"browse\" => oW:Output(), \"cartsum\" => nT }\n\nSTATIC FUNCTION proc_cart()\n\n LOCAL oW, nT, cCode\n\n USessionStart()\n IF ! hb_HHasKey( session, \"user\" )\n URedirect( \"/app/login\" )\n RETURN NIL\n ENDIF\n\n dbUseArea( .T., , \"items\", \"items\", .T., .T. )\n ordSetFocus( \"code\" )\n dbUseArea( .T., , \"carts\", \"carts\", .T., .F. )\n ordSetFocus( \"user\" )\n\n IF hb_HHasKey( get, \"del\" )\n cCode := PadR( get[ \"del\" ], 16 )\n IF items->( dbSeek( cCode ) ) .AND. carts->( FLock() )\n IF carts->( dbSeek( session[ \"user\" ] + cCode ) )\n carts->( dbDelete() )\n carts->USER := \"\"\n carts->CODE := cCode\n ENDIF\n carts->( dbUnlock() )\n ENDIF\n URedirect( \"cart\" )\n RETURN NIL\n ENDIF\n\n ordScope( 0, session[ \"user\" ] )\n ordScope( 1, session[ \"user\" ] )\n nT := 0\n carts->( dbEval( {|| nT += FIELD->TOTAL } ) )\n\n oW := UWBrowseNew( \"br_cart\" )\n oW:AddColumn( 101, \"Item No.\", \"CODE\" )\n oW:AddColumn( 102, \"Title\", {|| items->( dbSeek( carts->CODE, .F. ), FIELD->TITLE ) } )\n oW:AddColumn( 103, \"Amount\", \"AMOUNT\" )\n oW:AddColumn( 104, \"Total\", \"TOTAL\" )\n oW:AddColumn( 104, \"\", {|| ULink( \"Delete\", \"?del=\" + RTrim( FIELD->CODE ) ) }, .T. )\n oW:nPageSize := 10\n IF hb_HHasKey( get, \"_pos\" )\n oW:nPos := Val( get[ \"_pos\" ] )\n ENDIF\n\n RETURN { \"browse\" => oW:Output(), \"cartsum\" => nT }\n\nSTATIC FUNCTION proc_account()\n\n USessionStart()\n IF ! hb_HHasKey( session, \"user\" )\n URedirect( \"/app/login\" )\n RETURN NIL\n ENDIF\n dbUseArea( .T., , \"users\", \"users\", .T., .F. )\n ordSetFocus( \"user\" )\n dbSeek( session[ \"user\" ], .F. )\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charnlst.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CharNoList()\"\n ?\n\n ? \"Simple tests:\"\n\n ? ' CharNoList( CharNoList( \"Hello World !\" ) ) == \" !HWdelor\" ? -> \"' + CharNoList( CharNoList( \"Hello World !\" ) ) + '\"'\n ? ' CharNoList( CharNoList( NIL ) ) == \"\" ? -> \"' + CharNoList( CharNoList( NIL ) ) + '\"'\n\n ? \"End test of CharNoList()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: xBrowse1, DbSkipBlock, TBNext. Harbour contribution module 'gtwvw' (): contrib/gtwvw/tests/prog0.prg. Provides 11 functions including: xBrowse1, DbSkipBlock, TBNext, TBPrev, VouBlockField. Contains procedures: Main, xGet1. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"gtwvw\"\n\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\nSTATIC s_zwin := {}\nSTATIC s_cStdColor := \"N/W,N/GR*,,,N/W*\"\n\nPROCEDURE Main()\n\n LOCAL i, j\n\n#if defined( __HBSCRIPT__HBSHELL ) .AND. defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVW\" )\n#endif\n\n SET SCOREBOARD OFF\n SetColor( s_cStdColor )\n SetCursor( SC_NONE )\n CLS\n @ 0, 0 SAY PadC( \"This is the Main Window\", MaxCol() + 1 )\n\n \n DispBegin()\n FOR i := 1 TO MaxRow() - 1\n FOR j := 0 TO MaxCol()\n hb_DispOutAtBox( i, j, hb_UTF8ToStrBox( \"▒\" ) )\n NEXT\n NEXT\n DispEnd()\n\n lboxmessage( \"Welcome to our test program.\" + hb_eol() + ;\n \"This program will show typical GET and BROWSE dialogs \" + ;\n \"with brief help on the bottom of the screen.\" )\n xGet1()\n xBrowse1()\n lboxmessage( \"That's all folks\" )\n\n \n SetCursor( SC_NORMAL )\n\n RETURN \n\nPROCEDURE xGet1()\n\n LOCAL cName := PadR( \"Name\", 20 )\n LOCAL cAddr := PadR( \"Address\", 25 )\n LOCAL cPhone := PadR( \"Phone\", 15 )\n LOCAL cFax := PadR( \"Fax\", 15 )\n LOCAL lDone := .F.\n LOCAL getlist := {}\n LOCAL oldCurs := SetCursor( SC_NORMAL )\n\n znewwindow( hb_UTF8ToStrBox( \"┌─┐│┘─└│\" ), 10, 20, 22, 59, \"Some Window\" )\n\n\n DO WHILE ! lDone\n @ 12, 22 SAY \"Name : \" GET cName PICT \"@!K\" WHEN lMessage( \"Please enter your name\" )\n @ 14, 22 SAY \"Address : \" GET cAddr PICT \"@!K\" WHEN lMessage( \"Please enter your address\" )\n @ 16, 22 SAY \"Phone : \" GET cPhone PICT \"@K\" WHEN lMessage( \"Please enter your phone number\" )\n @ 18, 22 SAY \"Fax : \" GET cFax PICT \"@K\" WHEN lMessage( \"Please enter your fax number\" )\n READ\n\n lMessage( \"\" )\n lDone := lyesno( \"Done?\" )\n ENDDO\n\n zrevwindow()\n\n SetCursor( oldCurs )\n\n RETURN \n\n\nFUNCTION xBrowse1()\n\n LOCAL nKey, bBlock, oBrowse, i\n LOCAL lEnd := .F.\n LOCAL info_\n LOCAL nTop := 6\n LOCAL nLeft := 3\n LOCAL nBottom := MaxRow() - 2\n LOCAL nRight := MaxCol() - 3\n LOCAL nCursor := SetCursor( SC_NONE )\n\n USE \"..\\..\\..\\tests\\test\" NEW\n IF NetErr()\n RETURN NIL\n ENDIF\n info_ := dbStruct()\n\n SetColor( \"N/W*,N/GR*,,,N/W* \" )\n oBrowse := TBrowseNew( nTop + 1, nLeft + 1, nBottom - 1, nRight - 1 )\n\n oBrowse:ColSep := hb_UTF8ToStrBox( \"│\" )\n oBrowse:HeadSep := hb_UTF8ToStrBox( \"─\" )\n oBrowse:GoTopBlock := {|| dbGoTop() }\n oBrowse:GoBottomBlock := {|| dbGoBottom() }\n oBrowse:SkipBlock := {| nSkip | dbSkipBlock( nSkip, oBrowse ) }\n\n FOR i := 1 TO Len( info_ )\n bBlock := VouBlockField( i )\n oBrowse:AddColumn( TBColumnNew( info_[ i, 1 ], bBlock ) )\n NEXT\n\n oBrowse:configure()\n\n znewwindow( hb_UTF8ToStrBox( \"┌─┐│┘─└│\" ), nTop, nLeft, nBottom, nRight, \"test.dbf\" )\n\n WHILE ! lEnd\n oBrowse:ForceStable()\n\n lMessage( \"Record #\" + hb_ntos( RecNo() ) )\n\n nKey := Inkey( 0 )\n\n DO CASE\n CASE nKey == K_ESC .OR. nKey == K_ENTER\n lEnd := lYesNo( \"Done?\" )\n CASE nKey == K_DOWN\n oBrowse:Down()\n CASE nKey == K_UP\n oBrowse:Up()\n CASE nKey == K_LEFT\n oBrowse:Left()\n CASE nKey == K_RIGHT\n oBrowse:Right()\n CASE nKey == K_PGDN\n oBrowse:pageDown()\n CASE nKey == K_PGUP\n oBrowse:pageUp()\n CASE nKey == K_CTRL_PGUP\n oBrowse:goTop()\n CASE nKey == K_CTRL_PGDN\n oBrowse:goBottom()\n CASE nKey == K_HOME\n oBrowse:home()\n CASE nKey == K_END\n oBrowse:end()\n CASE nKey == K_CTRL_LEFT\n oBrowse:panLeft()\n CASE nKey == K_CTRL_RIGHT\n oBrowse:panRight()\n CASE nKey == K_CTRL_HOME\n oBrowse:panHome()\n CASE nKey == K_CTRL_END\n oBrowse:panEnd()\n ENDCASE\n ENDDO\n\n lMessage( \"\" )\n\n zrevwindow()\n\n \n SetCursor( nCursor )\n\n dbCloseArea()\n\n RETURN NIL\n\n\nSTATIC FUNCTION DbSkipBlock( n, oTbr )\n\n LOCAL nSkipped := 0\n\n HB_SYMBOL_UNUSED( oTbr )\n\n IF n == 0\n dbSkip( 0 )\n ELSEIF n > 0\n DO WHILE nSkipped != n .AND. TBNext( oTbr )\n nSkipped++\n ENDDO\n ELSE\n DO WHILE nSkipped != n .AND. TBPrev( oTbr )\n nSkipped--\n ENDDO\n ENDIF\n\n RETURN nSkipped\n\n\nSTATIC FUNCTION TBNext( oTbr )\n\n LOCAL nSaveRecNum := RecNo()\n LOCAL lMoved := .T.\n\n HB_SYMBOL_UNUSED( oTbr )\n\n IF Eof()\n lMoved := .F.\n ELSE\n dbSkip( 1 )\n IF Eof()\n lMoved := .F.\n dbGoto( nSaveRecNum )\n ENDIF\n ENDIF\n\n RETURN lMoved\n\n\nSTATIC FUNCTION TBPrev( oTbr )\n\n LOCAL nSaveRecNum := RecNo()\n LOCAL lMoved := .T.\n\n HB_SYMBOL_UNUSED( oTbr )\n\n dbSkip( -1 )\n IF Bof()\n dbGoto( nSaveRecNum )\n lMoved := .F.\n ENDIF\n\n RETURN lMoved\n\n\nSTATIC FUNCTION VouBlockField( i )\n\n RETURN {|| FieldGet( i ) }\n\n\nFUNCTION lMessage( cMsg )\n\n LOCAL cOldColor := SetColor( s_cStdColor )\n\n @ MaxRow(), 0 SAY PadC( cMsg, MaxCol() + 1 )\n SetColor( cOldColor )\n\n RETURN .T.\n\n\nFUNCTION lYesNo( cMsg )\n\n LOCAL nTopLine, ;\n nLeft := 5, ;\n nBotLine := MaxRow() - 2, ;\n nRight := MaxCol() - 5\n LOCAL nChoice, nWidth\n LOCAL oldCurs := SetCursor( SC_NONE )\n LOCAL oldColor := SetColor( s_cStdColor )\n\n hb_default( @cMsg, \"Please Confirm\" )\n\n cmsg := \" \" + AllTrim( cmsg ) + \" \"\n nWidth := Max( Len( cmsg ), Len( \"Yes\" ) )\n nTopLine := nBotLine - 2 - 1\n\n nLeft := Max( nLeft, ( ( nRight + nLeft )\n znewwindow( hb_UTF8ToStrBox( \"┌─┐│┘─└│\" ), nTopLine, nLeft, nBotLine, nRight, cMsg )\n\n @ nTopLine + 1, nLeft + 1 PROMPT PadR( \"Yes\", nWidth )\n @ nTopLine + 2, nLeft + 1 PROMPT PadR( \"No\", nWidth )\n MENU TO nChoice\n\n \n zrevwindow()\n\n SetCursor( oldCurs )\n SetColor( oldColor )\n\n RETURN nChoice == 1\n\nFUNCTION lBoxMessage( cMsg, cTitle )\n\n LOCAL nTopLine, ;\n nLeft := 5, ;\n nBotLine := MaxRow() - 2, ;\n nRight := MaxCol() - 5\n LOCAL nwidth, nmaxwidth, i, nNumLines, cAline\n LOCAL oldCurs := SetCursor( SC_NONE )\n LOCAL oldColor := SetColor( s_cStdColor )\n\n hb_default( @cTitle, \"Info\" )\n\n cmsg := AllTrim( cmsg )\n nNumLines := MLCount( cmsg, ( nright - nleft ) - 1 )\n nWidth := iif( nNumLines < 2, Len( cmsg ), nRight - nLeft - 1 )\n nTopLine := nBotLine - nNumLines - 1\n IF nTopLine < 0 \n nNumLines += nTopLine\n nTopLine := 0\n ENDIF\n\n nMaxWidth := 0\n FOR i := 1 TO nNumLines\n nMaxWidth := Max( nMaxWidth, Len( RTrim( MemoLine( cmsg, nwidth, i ) ) ) )\n NEXT\n\n nLeft := Max( nLeft, Int( ( ( nRight + nLeft ) / 2 ) - ( nMaxWidth / 2 ) - 1 ) )\n nRight := nLeft + nMaxWidth + 1\n\n \n znewwindow( hb_UTF8ToStrBox( \"┌─┐│┘─└│\" ), nTopLine, nLeft, nBotLine, nRight, cTitle )\n DispBegin()\n FOR i := 1 TO nNumLines\n cAline := MemoLine( cMsg, nWidth, i )\n hb_DispOutAt( nTopLine + i, nLeft + 1, PadC( AllTrim( cAline ), nMaxWidth ) )\n NEXT\n DispEnd()\n\n Inkey( 0 )\n\n \n zrevwindow()\n\n SetCursor( oldCurs )\n SetColor( oldColor )\n\n RETURN .T.\n\n\nFUNCTION ZNEWWINDOW( wtype, r1, c1, r2, c2, ctitle, ccolor )\n\n LOCAL i := Len( s_zwin )\n LOCAL cScreen := SaveScreen( r1, c1, r2, c2 )\n LOCAL cOldColor := SetColor()\n LOCAL nrow := Row(), ncol := Col()\n\n hb_default( @ctitle, \"\" )\n hb_default( @ccolor, s_cStdColor )\n SetColor( ccolor )\n\n AAdd( s_zwin, { i + 1, r1, c1, r2, c2, cScreen, ctitle, nrow, ncol, coldcolor } )\n\n SetColor( ccolor )\n\n hb_Scroll( r1, c1, r2, c2 )\n\n \n hb_DispBox( r1, c1, r2, c2, wtype )\n IF ! Empty( ctitle )\n cTitle := \" \" + AllTrim( ctitle ) + \" \"\n hb_DispOutAt( r1, nCeiling( ( c2 + c1 - Len( cTitle ) ) / 2 ), cTitle )\n ENDIF\n\n SetColor( cOldColor )\n\n RETURN i + 1\n\n\nFUNCTION ZREVWINDOW()\n\n LOCAL i := Len( s_zwin )\n\n IF i == 0\n \n RETURN NIL\n ENDIF\n\n \n RestScreen( s_zwin[ i ][ 2 ], s_zwin[ i ][ 3 ], s_zwin[ i ][ 4 ], s_zwin[ i ][ 5 ], s_zwin[ i ][ 6 ] )\n SetPos( s_zwin[ i ][ 8 ], s_zwin[ i ][ 9 ] )\n SetColor( s_zwin[ i ][ 10 ] )\n\n \n hb_ADel( s_zwin, i, .T. )\n\n RETURN NIL\n\nFUNCTION nCeiling( nNumber )\n\n LOCAL nTemp\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/inline_c.prg. Provides functions: EndDumpTest. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n ? C_FUNC()\n\n ? EndDumpTest()\n\n RETURN\n\n#pragma begindump\n\n#include \"hbapi.h\"\n\nHB_FUNC( C_FUNC )\n{\n hb_retc( \"returned from C_FUNC()\\n\" );\n}\n\n#pragma enddump\n\nFUNCTION EndDumpTest()\n RETURN \"End Dump Test\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour header file: include/dbinfo.ch. Defines 10 constants including: HB_DBINFO_CH_, RDDI_ISDBF, RDDI_CANPUTREC, RDDI_DELIMITER, RDDI_SEPARATOR. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_DBINFO_CH_\n#define HB_DBINFO_CH_\n\n\n#define RDDI_ISDBF 1 \n#define RDDI_CANPUTREC 2 \n#define RDDI_DELIMITER 3 \n#define RDDI_SEPARATOR 4 \n\n#define RDDI_TABLEEXT 5 \n#define RDDI_MEMOEXT 6 \n#define RDDI_ORDBAGEXT 7 \n#define RDDI_ORDEREXT 8 \n#define RDDI_ORDSTRUCTEXT 9 \n\n#define RDDI_LOCAL 10 \n#define RDDI_REMOTE 11 \n#define RDDI_CONNECTION 12 \n#define RDDI_TABLETYPE 13 \n#define RDDI_MEMOTYPE 14 \n#define RDDI_LARGEFILE 15 \n#define RDDI_LOCKSCHEME 16 \n#define RDDI_RECORDMAP 17 \n#define RDDI_ENCRYPTION 18 \n#define RDDI_TRIGGER 19 \n#define RDDI_AUTOLOCK 20 \n\n\n#define RDDI_STRUCTORD 21 \n#define RDDI_STRICTREAD 22 \n#define RDDI_STRICTSTRUCT 23 \n#define RDDI_OPTIMIZE 24 \n#define RDDI_FORCEOPT 25 \n#define RDDI_AUTOOPEN 26 \n#define RDDI_AUTOORDER 27 \n#define RDDI_AUTOSHARE 28 \n#define RDDI_MULTITAG 29 \n#define RDDI_SORTRECNO 30 \n#define RDDI_MULTIKEY 31 \n\n\n#define RDDI_MEMOBLOCKSIZE 32 \n#define RDDI_MEMOVERSION 33 \n#define RDDI_MEMOGCTYPE 34 \n#define RDDI_MEMOREADLOCK 35 \n#define RDDI_MEMOREUSE 36 \n#define RDDI_BLOB_SUPPORT 37 \n\n\n#define RDDI_PENDINGTRIGGER 40 \n#define RDDI_PENDINGPASSWORD 41 \n#define RDDI_PASSWORD 42 \n#define RDDI_LOCKRETRY 43 \n#define RDDI_DIRTYREAD 44 \n#define RDDI_INDEXPAGESIZE 45 \n#define RDDI_DECIMALS 46 \n#define RDDI_SETHEADER 47 \n\n\n#define RDDI_CONNECT 61 \n#define RDDI_DISCONNECT 62 \n#define RDDI_EXECUTE 63 \n#define RDDI_ERROR 64 \n#define RDDI_ERRORNO 65 \n#define RDDI_INSERTID 66 \n#define RDDI_AFFECTEDROWS 67 \n#define RDDI_QUERY 68 \n\n\n#define DBOI_CONDITION 1 \n#define DBOI_EXPRESSION 2 \n#define DBOI_POSITION 3 \n#define DBOI_RECNO 4 \n#define DBOI_NAME 5 \n#define DBOI_NUMBER 6 \n#define DBOI_BAGNAME 7 \n#define DBOI_BAGEXT 8 \n#define DBOI_INDEXEXT DBOI_BAGEXT\n#define DBOI_INDEXNAME DBOI_BAGNAME\n#define DBOI_ORDERCOUNT 9 \n#define DBOI_FILEHANDLE 10 \n#define DBOI_ISCOND 11 \n#define DBOI_ISDESC 12 \n#define DBOI_UNIQUE 13 \n\n\n#define DBOI_FULLPATH 20 \n#define DBOI_KEYTYPE 24 \n#define DBOI_KEYSIZE 25 \n#define DBOI_KEYCOUNT 26 \n#define DBOI_SETCODEBLOCK 27 \n#define DBOI_KEYDEC 28 \n#define DBOI_HPLOCKING 29 \n#define DBOI_LOCKOFFSET 35 \n\n#define DBOI_KEYADD 36 \n#define DBOI_KEYDELETE 37 \n#define DBOI_KEYVAL 38 \n#define DBOI_SCOPETOP 39 \n#define DBOI_SCOPEBOTTOM 40 \n#define DBOI_SCOPETOPCLEAR 41 \n#define DBOI_SCOPEBOTTOMCLEAR 42 \n#define DBOI_CUSTOM 45 \n#define DBOI_SKIPUNIQUE 46 \n\n#define DBOI_KEYSINCLUDED 50 \n\n#define DBOI_KEYGOTO DBOI_POSITION\n#define DBOI_KEYGOTORAW DBOI_KEYNORAW\n#define DBOI_KEYNO DBOI_POSITION\n#define DBOI_KEYNORAW 51 \n#define DBOI_KEYCOUNTRAW 52 \n\n\n#define DBOI_OPTLEVEL 53 \n\n\n#define DBOI_STRICTREAD 60 \n#define DBOI_OPTIMIZE 61 \n#define DBOI_AUTOOPEN 62 \n#define DBOI_AUTOORDER 63 \n#define DBOI_AUTOSHARE 64 \n\n\n#define DBOI_SKIPEVAL 100 \n#define DBOI_SKIPEVALBACK 101 \n#define DBOI_SKIPREGEX 102 \n#define DBOI_SKIPREGEXBACK 103 \n#define DBOI_SKIPWILD 104 \n#define DBOI_SKIPWILDBACK 105 \n#define DBOI_SCOPEEVAL 106 \n#define DBOI_FINDREC 107 \n#define DBOI_FINDRECCONT 108 \n#define DBOI_SCOPESET 109 \n#define DBOI_SCOPECLEAR 110 \n\n#define DBOI_BAGCOUNT 111 \n#define DBOI_BAGNUMBER 112 \n#define DBOI_BAGORDER 113 \n\n#define DBOI_ISMULTITAG 114 \n#define DBOI_ISSORTRECNO 115 \n#define DBOI_LARGEFILE 116 \n#define DBOI_TEMPLATE 117 \n#define DBOI_MULTIKEY 118 \n#define DBOI_CHGONLY 119 \n#define DBOI_PARTIAL 120 \n#define DBOI_SHARED 121 \n#define DBOI_ISREADONLY 122 \n#define DBOI_READLOCK 123 \n#define DBOI_WRITELOCK 124 \n#define DBOI_UPDATECOUNTER 125 \n\n#define DBOI_EVALSTEP 126 \n#define DBOI_ISREINDEX 127 \n#define DBOI_I_BAGNAME 128 \n#define DBOI_I_TAGNAME 129 \n\n#define DBOI_RELKEYPOS 130 \n#define DBOI_USECURRENT 131 \n#define DBOI_INDEXTYPE 132 \n#define DBOI_RESETPOS 133 \n#define DBOI_INDEXPAGESIZE 134 \n\n\n#define DBOI_OPTIMIZED_NONE 0\n#define DBOI_OPTIMIZED_PART 1\n#define DBOI_OPTIMIZED_FULL 2\n\n\n#define DBOI_TYPE_UNDEF -1\n#define DBOI_TYPE_NONE 0\n#define DBOI_TYPE_NONCOMPACT 1\n#define DBOI_TYPE_COMPACT 2\n#define DBOI_TYPE_COMPOUND 3\n\n\n#define DBRMI_FUNCTION 1\n#define DBRMI_PARAM 2\n#define DBRMI_LOVAL 3\n#define DBRMI_HIVAL 4\n#define DBRMI_RESULT 5\n#define DBRMI_SIZE 5\n\n\n#define DBRI_DELETED 1\n#define DBRI_LOCKED 2\n#define DBRI_RECSIZE 3\n#define DBRI_RECNO 4\n#define DBRI_UPDATED 5\n#define DBRI_ENCRYPTED 6 \n#define DBRI_RAWRECORD 7 \n#define DBRI_RAWMEMOS 8 \n#define DBRI_RAWDATA 9 \n\n\n#define DBI_ISDBF 1 \n#define DBI_CANPUTREC 2 \n#define DBI_GETHEADERSIZE 3 \n#define DBI_LASTUPDATE 4 \n#define DBI_GETDELIMITER 5 \n#define DBI_SETDELIMITER 6 \n#define DBI_GETRECSIZE 7 \n#define DBI_GETLOCKARRAY 8 \n#define DBI_TABLEEXT 9 \n#define DBI_FULLPATH 10 \n\n#define DBI_ISFLOCK 20 \n#define DBI_CHILDCOUNT 22 \n#define DBI_FILEHANDLE 23 \n#define DBI_BOF 26 \n#define DBI_EOF 27 \n#define DBI_DBFILTER 28 \n#define DBI_FOUND 29 \n#define DBI_FCOUNT 30 \n#define DBI_LOCKCOUNT 31 \n#define DBI_VALIDBUFFER 32 \n#define DBI_ALIAS 33 \n#define DBI_GETSCOPE 34 \n#define DBI_LOCKOFFSET 35 \n#define DBI_SHARED 36 \n#define DBI_MEMOEXT 37 \n#define DBI_MEMOHANDLE 38 \n#define DBI_MEMOBLOCKSIZE 39 \n\n#define DBI_DB_VERSION 101 \n#define DBI_RDD_VERSION 102 \n\n\n#define DBI_LOCKSCHEME 128 \n#define DBI_ISREADONLY 129 \n#define DBI_ROLLBACK 130 \n#define DBI_PASSWORD 131 \n#define DBI_ISENCRYPTED 132 \n#define DBI_MEMOTYPE 133 \n#define DBI_SEPARATOR 134 \n#define DBI_MEMOVERSION 135 \n#define DBI_TABLETYPE 136 \n#define DBI_SCOPEDRELATION 137 \n#define DBI_TRIGGER 138 \n#define DBI_OPENINFO 139 \n#define DBI_ENCRYPT 140 \n#define DBI_DECRYPT 141 \n#define DBI_MEMOPACK 142 \n#define DBI_DIRTYREAD 143 \n#define DBI_POSITIONED 144 \n#define DBI_ISTEMPORARY 145 \n#define DBI_LOCKTEST 146 \n#define DBI_CODEPAGE 147 \n#define DBI_TRANSREC 148 \n#define DBI_SETHEADER 149 \n\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour header file: include/hbiousr.ch. Defines 10 constants including: _HBIOUSR_CH, IOUSR_ACCEPT, IOUSR_EXISTS, IOUSR_DELETE, IOUSR_RENAME. Defines communication constants"}, {"role": "assistant", "content": "#ifndef _HBIOUSR_CH\n#define _HBIOUSR_CH\n\n\n#define IOUSR_ACCEPT 1\n#define IOUSR_EXISTS 2\n#define IOUSR_DELETE 3\n#define IOUSR_RENAME 4\n#define IOUSR_COPY 5\n\n#define IOUSR_DIREXISTS 6\n#define IOUSR_DIRMAKE 7\n#define IOUSR_DIRREMOVE 8\n#define IOUSR_DIRSPACE 9\n#define IOUSR_DIRECTORY 10\n\n#define IOUSR_TIMEGET 11\n#define IOUSR_TIMESET 12\n#define IOUSR_ATTRGET 13\n#define IOUSR_ATTRSET 14\n\n#define IOUSR_LINK 15\n#define IOUSR_LINKSYM 16\n#define IOUSR_LINKREAD 17\n\n#define IOUSR_OPEN 18\n#define IOUSR_CLOSE 19\n#define IOUSR_LOCK 20\n#define IOUSR_LOCKTEST 21\n#define IOUSR_READ 22\n#define IOUSR_WRITE 23\n#define IOUSR_READAT 24\n#define IOUSR_WRITEAT 25\n#define IOUSR_TRUNCAT 26\n#define IOUSR_SEEK 27\n#define IOUSR_SIZE 28\n#define IOUSR_EOF 29\n#define IOUSR_FLUSH 30\n#define IOUSR_COMMIT 31\n#define IOUSR_CONFIGURE 32\n#define IOUSR_HANDLE 33\n\n#define IOUSR_METHODCOUNT 33\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/smtpcli.prg. Defines classes: TIPClientSMTP. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"tip.ch\"\n\nCREATE CLASS TIPClientSMTP INHERIT TIPClient\n\n VAR lAuthLOGIN INIT .F.\n VAR lAuthPLAIN INIT .F.\n VAR lTLS INIT .F.\n\n METHOD New( oUrl, xTrace, oCredentials, cClientHost )\n METHOD Open( cUrl, lSSL )\n METHOD Close()\n METHOD Write( cData, nLen, bCommit )\n METHOD Mail( cFrom )\n METHOD Rcpt( cTo )\n METHOD Data( cData )\n METHOD Commit()\n METHOD Quit()\n METHOD GetOK()\n METHOD SendMail( oTIpMail )\n\n \n METHOD OpenSecure( cUrl, lSSL )\n METHOD Auth( cUser, cPass ) \n METHOD AuthPlain( cUser, cPass ) \n METHOD ServerSuportSecure( lAuthPlain, lAuthLogin )\n METHOD StartTLS()\n METHOD DetectSecurity()\n\n HIDDEN:\n\n VAR isAuth INIT .F.\n VAR cClientHost\n\nENDCLASS\n\nMETHOD New( oUrl, xTrace, oCredentials, cClientHost ) CLASS TIPClientSMTP\n\n ::super:new( oUrl, iif( hb_defaultValue( xTrace, .F. ), \"smtp\", xTrace ), oCredentials )\n\n ::nDefaultPort := iif( ::oUrl:cProto == \"smtps\", 465, 25 )\n ::nConnTimeout := 50000\n ::nAccessMode := TIP_WO \n ::cClientHost := cClientHost\n\n RETURN Self\n\nMETHOD Open( cUrl, lSSL ) CLASS TIPClientSMTP\n\n LOCAL lOk\n\n IF ! ::super:Open( cUrl )\n RETURN .F.\n ENDIF\n\n IF ! ::GetOk()\n RETURN .F.\n ENDIF\n\n IF hb_defaultValue( lSSL, .F. )\n ::EnableSSL( .T. )\n ::lAuthLogin := .T.\n ::lAuthPlain := .T.\n ENDIF\n\n ::inetSendAll( ::SocketCon, \"HELO \" + iif( Empty( ::cClientHost ), \"TIPClientSMTP\", ::cClientHost ) + ::cCRLF )\n\n DO WHILE .T.\n IF !( lOk := ::GetOk() ) .OR. ::cReply == NIL .OR. ;\n hb_LeftEq( ::cReply, \"250 \" )\n EXIT\n ENDIF\n ENDDO\n\n RETURN lOk\n\nMETHOD OpenSecure( cUrl, lSSL ) CLASS TIPClientSMTP\n\n LOCAL lOk\n\n IF ! ::super:Open( cUrl )\n RETURN .F.\n ENDIF\n\n IF ! ::GetOk()\n RETURN .F.\n ENDIF\n\n hb_default( @lSSL, .F. )\n\n IF lSSL\n ::EnableSSL( .T. )\n ::lAuthLogin := .T.\n ::lAuthPlain := .T.\n ENDIF\n\n ::inetSendAll( ::SocketCon, \"EHLO \" + iif( Empty( ::cClientHost ), \"TIPClientSMTP\", ::cClientHost ) + ::cCRLF )\n\n lOk := ::DetectSecurity()\n\n IF lOk .AND. ! lSSL .AND. ::lTLS\n lOk := ::StartTLS()\n ENDIF\n\n RETURN lOk\n\nMETHOD GetOk() CLASS TIPClientSMTP\n\n ::cReply := ::inetRecvLine( ::SocketCon,, 512 )\n IF ::inetErrorCode( ::SocketCon ) != 0 .OR. ! HB_ISSTRING( ::cReply ) .OR. hb_LeftEq( ::cReply, \"5\" )\n RETURN .F.\n ENDIF\n\n RETURN .T.\n\nMETHOD StartTLS() CLASS TIPClientSMTP\n\n ::inetSendAll( ::SocketCon, \"STARTTLS\" + ::cCRLF )\n\n IF ::GetOk() .AND. ::lHasSSL\n ::EnableSSL( .T. )\n __tip_SSLConnectFD( ::ssl, ::SocketCon )\n ::inetSendAll( ::SocketCon, \"EHLO \" + iif( Empty( ::cClientHost ), \"TIPClientSMTP\", ::cClientHost ) + ::cCRLF )\n RETURN ::DetectSecurity()\n ENDIF\n\n RETURN .F.\n\nMETHOD DetectSecurity() CLASS TIPClientSMTP\n\n LOCAL lOk\n\n DO WHILE .T.\n IF !( lOk := ::GetOk() ) .OR. ;\n ::cReply == NIL\n EXIT\n ENDIF\n IF \"LOGIN\" $ ::cReply\n ::lAuthLogin := .T.\n ENDIF\n IF \"PLAIN\" $ ::cReply\n ::lAuthPlain := .T.\n ENDIF\n IF ::HasSSL() .AND. \"STARTTLS\" $ ::cReply\n ::lTLS := .T.\n ::lAuthLogin := .T.\n ::lAuthPlain := .T.\n ENDIF\n\n IF hb_LeftEq( ::cReply, \"250 \" )\n EXIT\n ENDIF\n ENDDO\n\n RETURN lOk\n\nMETHOD Close() CLASS TIPClientSMTP\n\n ::InetTimeOut( ::SocketCon )\n ::Quit()\n\n RETURN ::super:Close()\n\nMETHOD Commit() CLASS TIPClientSMTP\n\n ::inetSendAll( ::SocketCon, ::cCRLF + \".\" + ::cCRLF )\n\n RETURN ::GetOk()\n\nMETHOD Quit() CLASS TIPClientSMTP\n\n ::inetSendAll( ::SocketCon, \"QUIT\" + ::cCRLF )\n ::isAuth := .F.\n\n RETURN ::GetOk()\n\nMETHOD Mail( cFrom ) CLASS TIPClientSMTP\n\n ::inetSendAll( ::SocketCon, \"MAIL FROM: <\" + cFrom + \">\" + ::cCRLF )\n\n RETURN ::GetOk()\n\nMETHOD Rcpt( cTo ) CLASS TIPClientSMTP\n\n ::inetSendAll( ::SocketCon, \"RCPT TO: <\" + cTo + \">\" + ::cCRLF )\n\n RETURN ::GetOk()\n\nMETHOD Data( cData ) CLASS TIPClientSMTP\n\n ::inetSendAll( ::SocketCon, \"DATA\" + ::cCRLF )\n IF ! ::GetOk()\n RETURN .F.\n ENDIF\n ::inetSendAll( ::SocketCon, cData + ::cCRLF + \".\" + ::cCRLF )\n\n RETURN ::GetOk()\n\nMETHOD Auth( cUser, cPass ) CLASS TIPClientSMTP\n\n ::inetSendAll( ::SocketCon, \"AUTH LOGIN\" + ::cCRLF )\n IF ::GetOk()\n ::inetSendAll( ::SocketCon, hb_base64Encode( StrTran( cUser, \"&at;\", \"@\" ) ) + ::cCRLF )\n IF ::GetOk()\n ::inetSendAll( ::SocketCon, hb_base64Encode( cPass ) + ::cCRLF )\n IF ::GetOk()\n RETURN ::isAuth := .T.\n ENDIF\n ENDIF\n ENDIF\n\n RETURN ::isAuth := .F.\n\nMETHOD AuthPlain( cUser, cPass ) CLASS TIPClientSMTP\n\n ::inetSendAll( ::SocketCon, \"AUTH PLAIN \" + hb_base64Encode( hb_BChar( 0 ) + cUser + hb_BChar( 0 ) + cPass ) + ::cCRLF )\n\n RETURN ::isAuth := ::GetOk()\n\nMETHOD Write( cData, nLen, bCommit ) CLASS TIPClientSMTP\n\n LOCAL cRcpt\n\n IF ! ::bInitialized\n\n IF Empty( ::oUrl:cFile ) \n RETURN -1\n ENDIF\n\n IF ! ::Mail( ::oUrl:cUserid )\n RETURN -1\n ENDIF\n\n FOR EACH cRcpt IN hb_regexSplit( \",\", ::oUrl:cFile )\n IF ! ::Rcpt( cRcpt )\n RETURN -1\n ENDIF\n NEXT\n\n ::inetSendAll( ::SocketCon, \"DATA\" + ::cCRLF )\n IF ! ::GetOk()\n RETURN -1\n ENDIF\n ::bInitialized := .T.\n ENDIF\n\n RETURN ::super:Write( cData, nLen, bCommit )\n\nMETHOD ServerSuportSecure( lAuthPlain, lAuthLogin ) CLASS TIPClientSMTP\n\n IF ::OpenSecure()\n lAuthLogin := ::lAuthLogin\n lAuthPlain := ::lAuthPlain\n ::Close()\n ELSE\n lAuthLogin := .F.\n lAuthPlain := .F.\n ENDIF\n\n RETURN lAuthLogin .OR. lAuthPlain\n\nMETHOD SendMail( oTIpMail ) CLASS TIPClientSmtp\n\n LOCAL cTo\n\n IF ! ::isOpen\n RETURN .F.\n ENDIF\n\n IF ! ::isAuth\n ::Auth( ::oUrl:cUserId, ::oUrl:cPassword )\n IF ! ::isAuth\n RETURN .F.\n ENDIF\n ENDIF\n\n ::mail( oTIpMail:getFieldPart( \"From\" ) )\n\n FOR EACH cTo IN hb_regexSplit( \",\", hb_StrReplace( oTIpMail:getFieldPart( \"To\" ), ;\n { tip_CRLF(), Chr( 9 ), \" \" } ) )\n ::rcpt( cTo )\n NEXT\n\n RETURN ::data( oTIpMail:toString() )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHeader file for contribution module 'hbblat' (Blat email sending utility): contrib/hbblat/hbblat.ch. Defines 10 constants including: _HBBLAT_CH, BLAT_ERR_UNKNONW, BLAT_SUCCESS, BLAT_ERR_MESSAGE_NOT_ACCEPTED, BLAT_ERR_MISSING_FROM. Defines file I/O constants"}, {"role": "assistant", "content": "#ifndef _HBBLAT_CH\n#define _HBBLAT_CH\n\n\n#define BLAT_ERR_UNKNONW -1\n\n#define BLAT_SUCCESS 0\n#define BLAT_ERR_MESSAGE_NOT_ACCEPTED 1\n\n#define BLAT_ERR_MISSING_FROM 1000\n#define BLAT_ERR_MISSING_TO 1001\n#define BLAT_ERR_MISSING_TOFILE 1002\n#define BLAT_ERR_MISSING_BODY 1003\n#define BLAT_ERR_MISSING_BODYFILE 1004\n#define BLAT_ERR_MISSING_SERVERSMTP 1005\n#define BLAT_ERR_MISSING_SUBJECTFILE 1006\n#define BLAT_ERR_MISSING_CCFILE 1007\n#define BLAT_ERR_MISSING_BCCFILE 1008\n#define BLAT_ERR_MISSING_PSFILE 1009\n#define BLAT_ERR_MISSING_ATTACHLISTBINFILE 1010\n#define BLAT_ERR_MISSING_ATTACHLISTTEXTFILE 1011\n#define BLAT_ERR_MISSING_ATTACHLISTEMBEDDEDFILE 1012\n#define BLAT_ERR_MISSING_ALTERNATETEXTFILE 1013\n#define BLAT_ERR_MISSING_SIGNATUREFILE 1014\n#define BLAT_ERR_MISSING_TAGFILE 1015\n#define BLAT_ERR_WRONG_DSN 1016\n\n#define BLAT_ERR_LOGICAL_EXPECTED 2000\n#define BLAT_ERR_STRING_EXPECTED 2001\n\n\n#define BLAT_TEXT_ERROR \"Blat Error\"\n\n#define BLAT_TEXT_ERR_UNKNOWN \"Unknown error\"\n\n#define BLAT_TEXT_SUCCESS \"Ok\"\n#define BLAT_TEXT_ERR_MESSAGE_NOT_ACCEPTED \"Message not accepted by server\"\n\n#define BLAT_TEXT_ERR_MISSING_FROM \"Missing From: parameter\"\n#define BLAT_TEXT_ERR_MISSING_TO \"Missing To: parameter\"\n#define BLAT_TEXT_ERR_MISSING_TOFILE \"ToFile file not found\"\n#define BLAT_TEXT_ERR_MISSING_BODY \"Missing message body\"\n#define BLAT_TEXT_ERR_MISSING_BODYFILE \"Message body file not found\"\n#define BLAT_TEXT_ERR_MISSING_SERVERSMTP \"Missing SMTP server\"\n#define BLAT_TEXT_ERR_MISSING_SUBJECTFILE \"Subject file not found\"\n#define BLAT_TEXT_ERR_MISSING_CCFILE \"CC file not found\"\n#define BLAT_TEXT_ERR_MISSING_BCCFILE \"BCC file not found\"\n#define BLAT_TEXT_ERR_MISSING_PSFILE \"PS file not found\"\n#define BLAT_TEXT_ERR_MISSING_ATTACHLISTBINFILE \"Attach List Bin file not found\"\n#define BLAT_TEXT_ERR_MISSING_ATTACHLISTTEXTFILE \"Attach List Text file not found\"\n#define BLAT_TEXT_ERR_MISSING_ATTACHLISTEMBEDDEDFILE \"Attach List Embedded file not found\"\n#define BLAT_TEXT_ERR_MISSING_ALTERNATETEXTFILE \"Alternate Text file not found\"\n#define BLAT_TEXT_ERR_MISSING_SIGNATUREFILE \"Signature file not found\"\n#define BLAT_TEXT_ERR_MISSING_TAGFILE \"Tag file not found\"\n#define BLAT_TEXT_ERR_WRONG_DSN \"Wrong DSN values (admitted: n, s, f, d)\"\n\n#define BLAT_TEXT_ERR_LOGICAL_EXPECTED \"Logical var expected\"\n#define BLAT_TEXT_ERR_STRING_EXPECTED \"String var expected\"\n\n\n#define BLAT_ERR_CANT_MALLOC 4001 \n#define BLAT_ERR_SENDING_DATA 4002 \n#define BLAT_ERR_INITIALIZING 4003 \n#define BLAT_ERR_VER_NOT_SUPPORTED 4004 \n#define BLAT_ERR_EINVAL 4005 \n#define BLAT_ERR_SYS_NOT_READY 4006 \n#define BLAT_ERR_CANT_RESOLVE_HOSTNAME 4007 \n#define BLAT_ERR_CANT_GET_SOCKET 4008 \n#define BLAT_ERR_READING_SOCKET 4009 \n#define BLAT_ERR_NOT_A_SOCKET 4010 \n#define BLAT_ERR_BUSY 4011 \n#define BLAT_ERR_CLOSING 4012 \n#define BLAT_WAIT_A_BIT 4013 \n#define BLAT_ERR_CANT_RESOLVE_SERVICE 4014 \n#define BLAT_ERR_CANT_CONNECT 4015 \n#define BLAT_ERR_NOT_CONNECTED 4016 \n#define BLAT_ERR_CONNECTION_REFUSED 4017 \n\n#define BLAT_ERR_NO_ERROR_CODE -5000 \n#define BLAT_TRY_INFINITE_KEY -1\n#define BLAT_TRY_INFINITE_VALUE \"INFINITE\"\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour header file: include/hbmacro.ch. Defines 8 constants including: HB_MACRO_CH_, HB_SM_HARBOUR, HB_SM_XBASE, HB_SM_SHORTCUTS, HB_SM_ARRSTR. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_MACRO_CH_\n#define HB_MACRO_CH_\n\n\n#define HB_SM_HARBOUR 1 \n#define HB_SM_XBASE 2 \n#define HB_SM_SHORTCUTS 8 \n#define HB_SM_ARRSTR 16 \n#define HB_SM_EXTOPT 32 \n#define HB_SM_RT_MACRO 64 \n#define HB_SM_PARSER 128 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour Runtime Library file: src/debug/dbgtmitm.prg. Defines classes: HBDbMenuItem. This file provides utility functions"}, {"role": "assistant", "content": "#pragma -b-\n\n#define HB_CLS_NOTOBJECT \n#include \"hbclass.ch\"\n\nCREATE CLASS HBDbMenuItem\n\n VAR nRow\n VAR nCol\n VAR cPrompt\n VAR bAction\n VAR lChecked\n VAR Ident\n\n ACCESS Checked() INLINE ::lChecked\n ASSIGN Checked( lChecked ) INLINE ::lChecked := lChecked\n\n METHOD New( cPrompt, bAction, lChecked, xIdent )\n METHOD Display( cClrText, cClrHotKey )\n METHOD Toggle() INLINE ::lChecked := ! ::lChecked\n\nENDCLASS\n\nMETHOD New( cPrompt, bAction, lChecked, xIdent ) CLASS HBDbMenuItem\n\n ::cPrompt := cPrompt\n ::bAction := bAction\n ::lChecked := hb_defaultValue( lChecked, .F. )\n ::Ident := xIdent\n\n RETURN Self\n\nMETHOD Display( cClrText, cClrHotKey ) CLASS HBDbMenuItem\n\n LOCAL nAt\n\n hb_DispOutAt( ::nRow, ::nCol, StrTran( ::cPrompt, \"~\" ), cClrText )\n\n hb_DispOutAt( ::nRow, ::nCol + ;\n ( nAt := At( \"~\", ::cPrompt ) ) - 1, ;\n SubStr( ::cPrompt, nAt + 1, 1 ), cClrHotKey )\n\n IF ::lChecked\n hb_DispOutAtBox( ::nRow, ::nCol, hb_UTF8ToStrBox( \"√\" ), cClrText )\n ENDIF\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/persist.prg. Defines classes: Test, Test2. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nPROCEDURE Main()\n\n LOCAL oTest := Test():New()\n LOCAL oTest2 := Test2():New()\n\n oTest:One := \"hello\"\n oTest:Two := 123\n oTest:Three := \"this value is not persistent\"\n oTest:Four := oTest2 \n\n oTest2:Five := \"some more text\"\n\n ? oTest:SaveToText() \n\n oTest:SaveToFile( \"test.txt\" ) \n\n RETURN\n\nCREATE CLASS Test FROM HBPersistent\n\n VAR One PROPERTY\n VAR Two PROPERTY\n VAR Three\n VAR Four PROPERTY\n\n METHOD Another() INLINE { 1, { \"One\", \"Two\" }, Date() } PROPERTY\n METHOD More() VIRTUAL\n\nENDCLASS\n\nCREATE CLASS Test2 FROM HBPersistent\n\n VAR Five PROPERTY\n\nENDCLASS"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/achoice2.prg. Provides functions: cUF, cUF2. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n#include \"achoice.ch\"\n\nMEMVAR p_lHiLiTest\n\n#ifndef __HARBOUR__\n#include \"clipper.ch\"\n#endif\n\nPROCEDURE Main()\n\n \n LOCAL aMenu1 := { \" --Wisky--\", \"\", \"not handled\" }\n LOCAL aMenu2 := { \" --Vodka--\", \" --Water--\", NIL, \"not handled\" }\n LOCAL aMenu3 := { \" --Grapa--\", 33, \"not handled\" }\n \n LOCAL aMenu4 := { \"\", \"not handled\" }\n LOCAL aMenu5 := { \" --Absnt--\", \"disabled1\", \"disabled2\" }\n LOCAL aEnab5 := { .F., .F., .F. }\n\n LOCAL lExit := .F.\n LOCAL nCounter := 1\n LOCAL nKeyPressed\n\n \n PUBLIC p_lHiLiTest := .F.\n\n SetColor( \"W+/N, BG+/B, , , W/N\" )\n CLS\n @ 2, 1 SAY aMenu1[ 1 ]\n @ 2, 13 SAY aMenu2[ 1 ]\n @ 2, 25 SAY aMenu3[ 1 ]\n @ 2, 37 SAY aMenu4[ 1 ]\n @ 2, 49 SAY aMenu5[ 1 ]\n @ 3, 13 SAY aMenu2[ 2 ]\n DO WHILE ! lExit\n\n DO CASE\n CASE nCounter == 1\n AChoice( 2, 1, 3, 11, aMenu1 )\n CASE nCounter == 2\n AChoice( 2, 13, 3, 23, aMenu2, .T., \"cUF\" )\n CASE nCounter == 3\n AChoice( 2, 25, 3, 35, aMenu3, .T. )\n CASE nCounter == 4\n \n \n AChoice( 2, 37, 3, 47, aMenu4, .T., \"cUF2\" )\n CASE nCounter == 5\n AChoice( 2, 49, 4, 59, aMenu5, aEnab5, \"cUF2\" )\n ENDCASE\n\n nKeyPressed := LastKey()\n IF nKeyPressed == K_ESC\n lExit := .T.\n ELSEIF nKeyPressed == K_RIGHT\n nCounter := iif( nCounter == 5, 1, nCounter + 1 )\n ELSEIF nKeyPressed == K_LEFT\n nCounter := iif( nCounter == 1, 5, nCounter - 1 )\n ENDIF\n\n ENDDO\n\n RETURN\n\n\nFUNCTION cUF( nMode, nCurElement, nRowPos )\n\n LOCAL nRetVal := AC_CONT\n LOCAL nKey := LastKey()\n\n HB_SYMBOL_UNUSED( nCurElement )\n HB_SYMBOL_UNUSED( nRowPos )\n\n IF p_lHiLiTest\n DispBox( 0, 0, MaxRow(), MaxCol(), Replicate( \"#\", 9 ), \"GR+/G\" )\n ENDIF\n\n IF nMode == AC_NOITEM\n nRetVal := AC_ABORT\n ELSEIF nMode == AC_EXCEPT\n DO CASE\n CASE nKey == K_ENTER\n nRetVal := AC_SELECT\n OTHERWISE\n nRetVal := AC_ABORT\n ENDCASE\n ENDIF\n\n RETURN nRetVal\n\n\nFUNCTION cUF2( nMode, nCurElement, nRowPos )\n\n LOCAL nRetVal := AC_CONT\n LOCAL nKey := LastKey()\n\n HB_SYMBOL_UNUSED( nCurElement )\n HB_SYMBOL_UNUSED( nRowPos )\n\n DispBox( 0, 0, MaxRow(), MaxCol(), Replicate( \"!\", 9 ), \"GR+/G\" )\n\n IF nMode == AC_NOITEM\n nRetVal := AC_ABORT\n ELSEIF nMode == AC_EXCEPT\n DO CASE\n CASE nKey == K_ENTER\n nRetVal := AC_SELECT\n OTHERWISE\n nRetVal := AC_ABORT\n ENDCASE\n ENDIF\n\n RETURN nRetVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'gtwvg' (): contrib/gtwvg/crt.prg. Defines classes: WvgCrt. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nCREATE CLASS WvgCrt INHERIT WvgWindow, WvgPartHandler\n\n VAR oMenu\n\n \n VAR alwaysOnTop INIT .F. \n VAR border INIT 0 \n VAR clipChildren INIT .F.\n VAR closable INIT .T.\n VAR fontHeight INIT 16\n VAR fontWidth INIT 10\n VAR fontName INIT \"Courier New\"\n VAR gridMove INIT .F.\n VAR icon INIT 0\n VAR minMax INIT .T.\n VAR sysMenu INIT .T.\n VAR taskList INIT .T.\n VAR title INIT \" \"\n VAR titleBar INIT .T.\n VAR visible INIT .T.\n\n VAR autoFocus INIT .T.\n VAR autoMark INIT .T.\n VAR dropFont INIT .T.\n VAR dropZone INIT .F.\n VAR helpLink\n VAR maxCol INIT 79\n VAR maxRow INIT 24\n VAR mouseMode INIT 1 \n VAR modalResult \n VAR aSyncFlush INIT .F. \n VAR tooltipText INIT \"\"\n VAR useShortCuts INIT .F. \n VAR xSize INIT 640 READONLY\n VAR ySize INIT 400 READONLY\n\n \n VAR animate INIT .F.\n VAR clipParent INIT .F.\n VAR clipSiblings INIT .T.\n VAR group INIT 0 \n VAR sizeRedraw INIT .F.\n VAR tabStop INIT .F.\n\n \n VAR sl_enter\n VAR sl_leave\n VAR sl_lbClick\n VAR sl_lbDblClick\n VAR sl_lbDown\n VAR sl_lbUp\n VAR sl_mbClick\n VAR sl_mbDblClick\n VAR sl_mbDown\n VAR sl_mbUp\n VAR sl_motion\n VAR sl_rbClick\n VAR sl_rbDblClick\n VAR sl_rbDown\n VAR sl_rbUp\n VAR sl_wheel\n\n VAR sl_close\n VAR sl_helpRequest\n VAR sl_keyboard\n VAR sl_killDisplayFocus \n VAR sl_killInputFocus\n VAR sl_move\n VAR sl_paint \n VAR sl_quit\n VAR sl_resize\n VAR sl_setDisplayFocus \n VAR sl_setInputFocus\n VAR sl_dragEnter\n VAR sl_dragMotion\n VAR sl_dragLeave\n VAR sl_dragDrop\n\n \n VAR resizable INIT .T.\n VAR resizeMode INIT HB_GTI_RESIZEMODE_FONT\n VAR style INIT ( WS_OVERLAPPED + WS_CAPTION + WS_SYSMENU + WS_SIZEBOX + WS_MINIMIZEBOX + WS_MAXIMIZEBOX )\n VAR exStyle INIT 0\n VAR lModal INIT .F.\n VAR pGTp\n VAR pGT\n VAR objType INIT objTypeCrt\n VAR ClassName INIT \"WVGCRT\"\n VAR drawingArea\n VAR hWnd\n VAR aPos INIT { 0, 0 }\n VAR aSize INIT { 24, 79 }\n VAR aPresParams INIT {}\n VAR lHasInputFocus INIT .F.\n VAR nFrameState INIT 0 \n\n VAR isGT INIT .F.\n\n METHOD setTitle( cTitle ) INLINE ::title := cTitle, hb_gtInfo( HB_GTI_WINTITLE, cTitle )\n METHOD getTitle() INLINE hb_gtInfo( HB_GTI_WINTITLE )\n METHOD showWindow() INLINE ::show()\n METHOD refresh() INLINE ::invalidateRect()\n METHOD refreshEx()\n\n \n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD destroy()\n\n \n METHOD currentPos()\n METHOD currentSize()\n METHOD captureMouse()\n METHOD disable()\n METHOD enable()\n METHOD getFrameState()\n METHOD getHWND()\n METHOD getModalState()\n METHOD hasInputFocus()\n METHOD hide()\n METHOD invalidateRect( nTop, nLeft, nBottom, nRight )\n METHOD isEnabled()\n METHOD isVisible()\n METHOD lockPS()\n METHOD lockUpdate()\n METHOD menuBar()\n METHOD setColorBG()\n METHOD setColorFG()\n METHOD setFont()\n METHOD setFontCompoundName()\n METHOD setFrameState( nState )\n METHOD setPresParam()\n METHOD setModalState()\n METHOD setPointer()\n METHOD setTrackPointer()\n METHOD setPos()\n METHOD setPosAndSize()\n METHOD setSize( aSize, lPaint )\n METHOD showModal()\n METHOD show()\n METHOD toBack()\n METHOD toFront()\n METHOD unlockPS()\n METHOD winDevice()\n\n \n METHOD enter( xParam ) SETGET\n METHOD leave( xParam ) SETGET\n METHOD lbClick( xParam ) SETGET\n METHOD lbDblClick( xParam ) SETGET\n METHOD lbDown( xParam ) SETGET\n METHOD lbUp( xParam ) SETGET\n METHOD mbClick( xParam ) SETGET\n METHOD mbDblClick( xParam ) SETGET\n METHOD mbDown( xParam ) SETGET\n METHOD mbUp( xParam ) SETGET\n METHOD motion( xParam ) SETGET\n METHOD rbClick( xParam ) SETGET\n METHOD rbDblClick( xParam ) SETGET\n METHOD rbDown( xParam ) SETGET\n METHOD rbUp( xParam ) SETGET\n METHOD wheel( xParam ) SETGET\n METHOD close( xParam ) SETGET\n METHOD helpRequest( xParam ) SETGET\n METHOD keyboard( xParam ) SETGET\n METHOD killDisplayFocus( xParam ) SETGET\n METHOD killInputFocus( xParam ) SETGET\n METHOD move( xParam ) SETGET\n METHOD paint( xParam ) SETGET\n METHOD quit( xParam, xParam1 ) SETGET\n METHOD resize( xParam ) SETGET\n METHOD setDisplayFocus( xParam ) SETGET\n METHOD setInputFocus( xParam ) SETGET\n METHOD dragEnter( xParam, xParam1 ) SETGET\n METHOD dragMotion( xParam ) SETGET\n METHOD dragLeave( xParam ) SETGET\n METHOD dragDrop( xParam, xParam1 ) SETGET\n\nENDCLASS\n\nMETHOD WvgCrt:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::WvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n IF HB_ISARRAY( aPos )\n ::aPos := aPos\n ENDIF\n IF HB_ISARRAY( aSize )\n ::aSize := aSize\n ENDIF\n IF HB_ISARRAY( aPresParams )\n ::aPresParams := aPresParams\n ENDIF\n IF HB_ISLOGICAL( lVisible )\n ::visible := lVisible\n ENDIF\n\n \n ::drawingArea := Self\n\n RETURN Self\n\nMETHOD WvgCrt:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n LOCAL lRowCol := .T.\n\n __defaultNIL( @oParent , ::oParent )\n __defaultNIL( @oOwner , ::oOwner )\n __defaultNIL( @aPos , ::aPos )\n __defaultNIL( @aSize , ::aSize )\n __defaultNIL( @aPresParams, ::aPresParams )\n __defaultNIL( @lVisible , ::visible )\n\n ::oParent := oParent\n ::oOwner := oOwner\n ::aPos := aPos"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/dbi.prg. Provides functions: xToStr. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n #xtranslate hb_eol() => ( Chr( 13 ) + Chr( 10 ) )\n#endif\n\nPROCEDURE Main()\n\n LOCAL i\n LOCAL cStr\n\n USE test NEW\n\n cStr := \"\"\n FOR i := 1 TO 100\n cStr += Str( i ) + \" \" + xToStr( dbInfo( i ) ) + hb_eol()\n NEXT\n cStr += Str( 101 ) + \" \" + xToStr( dbInfo( 101 ) ) + hb_eol()\n cStr += Str( 101 ) + \" \" + xToStr( dbInfo( 101, 1 ) ) + hb_eol()\n cStr += Str( 101 ) + \" \" + xToStr( dbInfo( 101, 2 ) ) + hb_eol()\n cStr += Str( 102 ) + \" \" + xToStr( dbInfo( 102 ) ) + hb_eol()\n cStr += Str( 101 ) + \" \" + xToStr( dbInfo( 102, 1 ) ) + hb_eol()\n cStr += Str( 101 ) + \" \" + xToStr( dbInfo( 102, 2 ) ) + hb_eol()\n cStr += Str( 999 ) + \" \" + xToStr( dbInfo( 999 ) ) + hb_eol()\n cStr += Str( 1000 ) + \" \" + xToStr( dbInfo( 1000 ) ) + hb_eol()\n\n#ifdef __HARBOUR__\n MemoWrit( \"dbi_hb.txt\", cStr )\n#else\n MemoWrit( \"dbi_cl.txt\", cStr )\n#endif\n\n ? dbRecordInfo( 1 )\n ? dbRecordInfo( 2 )\n ? dbRecordInfo( 3 )\n ? dbRecordInfo( 4 )\n ? dbRecordInfo( 5 )\n\n ? dbFieldInfo( 1, 1 )\n ? dbFieldInfo( 2, 1 )\n ? dbFieldInfo( 3, 1 )\n ? dbFieldInfo( 4, 1 )\n\n RETURN\n\nFUNCTION xToStr( xValue )\n\n LOCAL cType := ValType( xValue )\n\n DO CASE\n CASE cType == \"C\" .OR. cType == \"M\"\n RETURN xValue\n CASE cType == \"N\"\n RETURN hb_ntos( xValue )\n CASE cType == \"D\"\n RETURN DToC( xValue )\n CASE cType == \"L\"\n RETURN iif( xValue, \".T.\", \".F.\" )\n CASE cType == \"U\"\n RETURN \"NIL\"\n CASE cType == \"A\"\n RETURN \"{.}\"\n CASE cType == \"B\"\n RETURN \"{|| }\"\n CASE cType == \"O\"\n RETURN \"[O]\"\n ENDCASE\n\n RETURN xValue"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbamf' (): contrib/hbamf/tests/test.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbamf\"\n#require \"hbtest\"\n\nREQUEST HB_CODEPAGE_UTF8EX\n\nPROCEDURE Main()\n\n hb_cdpSelect( \"UTF8EX\" )\n\n HBTEST amf3_Encode( {} ) IS e\"\\011\\001\\001\"\n HBTEST amf3_Encode( \"a\" ) IS e\"\\006\\003a\"\n HBTEST amf3_Encode( \"ą\" ) IS e\"\\006\\005\\304\\205\"\n HBTEST amf3_Encode( 1 ) IS e\"\\004\\001\"\n HBTEST amf3_Encode( 1000 ) IS e\"\\004\\207h\"\n HBTEST amf3_Encode( 1000000 ) IS e\"\\004\\275\\204@\"\n HBTEST amf3_Encode( 268435455 ) IS e\"\\004\\277\\377\\377\\377\"\n HBTEST amf3_Encode( 268435456 ) IS e\"\\005A\\260\\0\\0\\0\\0\\0\\0\"\n HBTEST amf3_Encode( 268435456000 ) IS e\"\\005BO@\\0\\0\\0\\0\\0\"\n HBTEST amf3_Encode( -1 ) IS e\"\\004\\377\\377\\377\\377\"\n HBTEST amf3_Encode( 9007199254740990 ) IS e\"\\005C?\\377\\377\\377\\377\\377\\376\"\n HBTEST amf3_Encode( amf3_Decode( amf3_Encode( 9007199254740990 ) ) ) IS e\"\\005C?\\377\\377\\377\\377\\377\\376\"\n HBTEST amf3_Encode( 9007199254740991 ) IS e\"\\005C?\\377\\377\\377\\377\\377\\377\"\n HBTEST amf3_Encode( amf3_Decode( amf3_Encode( 9007199254740991 ) ) ) IS e\"\\005C?\\377\\377\\377\\377\\377\\377\"\n HBTEST amf3_Encode( 9007199254740991.00 ) IS e\"\\005C?\\377\\377\\377\\377\\377\\377\"\n HBTEST amf3_Encode( 6969.69 ) IS e\"\\005@\\2739\\260\\243\\327\\012=\"\n HBTEST amf3_Encode( NIL ) IS e\"\\001\"\n HBTEST amf3_Encode( .T. ) IS e\"\\003\"\n HBTEST amf3_Encode( .F. ) IS e\"\\002\"\n HBTEST amf3_Encode( { 1, -1 } ) IS e\"\\011\\005\\001\\004\\001\\004\\377\\377\\377\\377\"\n HBTEST amf3_Encode( { \"ONE\" => 0xCAFE, \"TWO\" => 0xBABE } ) IS e\"\\011\\001\\007ONE\\004\\203\\225~\\007TWO\\004\\202\\365>\\001\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: Initialise, StaticText, WindowBounce. Harbour test program: tests/video.prg. Provides functions: Initialise, StaticText, WindowBounce, ColourBoxes, Summary. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"box.ch\"\n#ifdef __HARBOUR__\n #include \"hbgtinfo.ch\"\n#endif\n\n#ifdef __CLIP__\n #xtranslate hb_SecondsCPU( [] ) => SecondsCPU( [] )\n#endif\n#ifdef FlagShip\n #xtranslate hb_SecondsCPU( [] ) => SecondsCPU( [] )\n#endif\n#ifdef __XHARBOUR__\n #xtranslate hb_SecondsCPU( [] ) => SecondsCPU( [] )\n #undef __HARBOUR__\n#else\n #ifndef __HARBOUR__\n #xtranslate hb_SecondsCPU( [] ) => Seconds( [] )\n #endif\n#endif\n\n#ifndef __HARBOUR__\n #xtranslate hb_eol() => ( Chr( 13 ) + Chr( 10 ) )\n#endif\n\n#command ? => OutStd( hb_eol() ); OutErr( hb_eol() )\n#command ? => OutStd( , hb_eol() ); OutErr( , hb_eol() )\n\n#ifdef FlagShip\n\nSTATIC s_nDispCount := 0\n\n#xtranslate DispBegin() => iif( ( ++s_nDispCount ) == 1, DispBegin( NIL ), )\n#xtranslate DispEnd() => iif( s_nDispCount > 0 .AND. ( --s_nDispCount ) == 0, DispEnd( NIL ), )\n\n#endif\n\nPROCEDURE Main( xUtf, xCompatBuf )\n\n LOCAL aResult := {}\n\n#ifdef __HARBOUR__\n hb_cdpSelect( iif( !Empty( xUtf ), \"UTF8\", \"EN\" ) )\n hb_gtInfo( HB_GTI_BOXCP, hb_cdpSelect() )\n hb_gtInfo( HB_GTI_COMPATBUFFER, !Empty( xCompatBuf ) )\n ? \"codepage:\", hb_cdpSelect(), \"box CP:\", hb_gtInfo( HB_GTI_BOXCP ), ;\n \"compat buffer:\", hb_gtInfo( HB_GTI_COMPATBUFFER )\n#endif\n\n Initialise() \n\n \n AAdd( aResult, StaticText() )\n AAdd( aResult, WindowBounce() )\n AAdd( aResult, ColourBoxes() )\n\n \n Summary( aResult )\n\n RETURN\n\n\nSTATIC FUNCTION Initialise()\n\n SET COLOUR TO \"W+/BG\"\n#ifdef __HARBOUR__\n DispBox( 0, 0, MaxRow(), MaxCol(), Replicate( hb_UTF8ToStrBox( \"░\" ), 9 ), \"BG/B\" )\n#else\n DispBox( 0, 0, MaxRow(), MaxCol(), Replicate( Chr( 176 ), 9 ), \"BG/B\" )\n#endif\n\n RETURN NIL\n\n\nSTATIC FUNCTION StaticText()\n\n LOCAL cResult\n LOCAL r := MaxRow() / 2\n LOCAL str := Version()\n LOCAL c\n LOCAL i\n LOCAL nEnd\n LOCAL nStart := hb_SecondsCPU()\n\n str := \"Hello World - From \" + Left( str, At( \" \", str ) - 1 )\n c := ( MaxCol() - Len( str ) ) / 2\n\n FOR i := 1 TO 5000\n @ r, c SAY str\n NEXT\n\n nEnd := hb_SecondsCPU()\n\n cResult := \"StaticText: Iterations=5000, Time=\" + hb_ntos( nEnd - nStart ) + ;\n \"secs, Average FPS = \" + hb_ntos( Round( 5000 / ( nEnd - nStart ), 0 ) ) + \" FPS\"\n\n RETURN cResult\n\n\nSTATIC FUNCTION WindowBounce()\n\n LOCAL cResult\n LOCAL nBoxes := Min( MaxRow(), MaxCol() - 7 ) - 6 \n LOCAL x := Array( NBOXES )\n LOCAL y := Array( NBOXES )\n LOCAL dx := Array( NBOXES )\n LOCAL dy := Array( NBOXES )\n LOCAL clr := Array( NBOXES )\n LOCAL scr := Array( NBOXES )\n LOCAL nFrames := 0\n LOCAL nStart\n LOCAL nEnd\n LOCAL i\n LOCAL aCol := { ;\n \"N\", \"B\", \"G\", \"BG\", \"R\", \"RB\", \"GR\", \"W\", ;\n \"N*\", \"B*\", \"G*\", \"BG*\", \"R*\", \"RB*\", \"GR*\", \"W*\" }\n\n \n FOR i := 1 TO nBoxes\n x[ i ] := i\n y[ i ] := i - 1\n dx[ i ] := -1\n dy[ i ] := 1\n clr[ i ] := \"W+/\" + aCol[ ( i - 1 ) % 16 + 1 ]\n NEXT\n\n nStart := hb_SecondsCPU()\n DispBegin()\n\n DO WHILE nFrames < 5000\n\n FOR i := 1 TO nBoxes\n scr[ i ] := SaveScreen( x[ i ], y[ i ], x[ i ] + 6, y[ i ] + 12 )\n#ifdef HB_B_SINGLE_UNI\n @ x[ i ], y[ i ], x[ i ] + 6, y[ i ] + 12 BOX HB_B_SINGLE_UNI + \" \" COLOR clr[ i ]\n#else\n @ x[ i ], y[ i ], x[ i ] + 6, y[ i ] + 12 BOX B_SINGLE + \" \" COLOR clr[ i ]\n#endif\n NEXT\n\n DispEnd()\n DispBegin()\n\n FOR i := nBoxes TO 1 STEP -1\n \n RestScreen( x[ i ], y[ i ], x[ i ] + 6, y[ i ] + 12, scr[ i ] )\n\n \n x[ i ] += dx[ i ]\n y[ i ] += dy[ i ]\n IF x[ i ] <= 0 .OR. x[ i ] + 6 >= MaxRow()\n dx[ i ] := -dx[ i ]\n ENDIF\n IF y[ i ] <= 0 .OR. y[ i ] + 12 >= MaxCol()\n dy[ i ] := -dy[ i ]\n ENDIF\n NEXT\n\n ++nFrames\n ENDDO\n\n DispEnd()\n nEnd := hb_SecondsCPU()\n\n cResult := \"WindowBounce:Iterations=\" + hb_ntos( nFrames ) + \", Time=\" + hb_ntos( nEnd - nStart ) + ;\n \"secs, Average FPS = \" + hb_ntos( Round( nFrames / ( nEnd - nStart ), 0 ) ) + \" FPS\"\n\n RETURN cResult\n\n\nSTATIC FUNCTION ColourBoxes()\n\n LOCAL cResult\n LOCAL nFrames := 0\n LOCAL nStart\n LOCAL nEnd\n LOCAL i\n LOCAL nDir := 1\n LOCAL nDepth := 0\n LOCAL aCol := { ;\n \"N\", \"B\", \"G\", \"BG\", \"R\", \"RB\", \"GR\", \"W\", ;\n \"N*\", \"B*\", \"G*\", \"BG*\", \"R*\", \"RB*\", \"GR*\", \"W*\" }\n\n nStart := hb_SecondsCPU()\n \n\n DO WHILE nFrames < 5000\n IF nDir == 1\n DispBegin()\n ELSE\n DispEnd()\n ENDIF\n\n nDepth += nDir\n\n IF nDepth > 4 .OR. nDepth < 1\n nDir := -nDir\n ENDIF\n i := nFrames % 16 + 1\n DispBox( 5, 10, MaxRow() - 5, MaxCol() - 10, ;\n Replicate( Chr( i + 64 ), 9 ), ;\n \"W+/\" + aCol[ i ] )\n ++nFrames\n ENDDO\n\n \n DO WHILE nDepth > 0\n DispEnd()\n nDepth--\n ENDDO\n\n nEnd := hb_SecondsCPU()\n\n cResult := \"ColourBoxes: Iterations=\" + hb_ntos( nFrames ) + \", Time=\" + hb_ntos( nEnd - nStart ) + ;\n \"secs, Average FPS = \" + hb_ntos( Round( nFrames / ( nEnd - nStart ), 0 ) ) + \" FPS\"\n\n RETURN cResult\n\n\nSTATIC FUNCTION Summary( aResult )\n\n LOCAL i\n\n CLS\n ? \"Resolution: \" + hb_ntos( MaxRow() + 1 ) + \" x \" + hb_ntos( MaxCol() + 1 ) + \" \" + Version()\n FOR i := 1 TO Len( aResult )\n ? aResult[ i ]\n NEXT\n ?\n ? \"press any key to continue\"\n Inkey( 0 )\n\n RETURN aResult"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/gtkeys.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n#ifdef __HARBOUR__\n#include \"hbgtinfo.ch\"\n\nREQUEST HB_CODEPAGE_PLMAZ\nREQUEST HB_CODEPAGE_PLISO\nREQUEST HB_CODEPAGE_PL852\nREQUEST HB_CODEPAGE_PLWIN\nREQUEST HB_CODEPAGE_UTF8EX\n#else\n#xtranslate hb_keyStd( ) => ( )\n#xtranslate hb_keyCode( ) => Asc( )\n#xtranslate hb_keyChar( ) => iif( >= 32 .AND. <= 255 .AND. != 127, Chr( ), \"\" )\n#xtranslate hb_ntos( ) => LTrim( Str( ) )\n#endif\n#ifndef HB_K_RESIZE\n#define HB_K_RESIZE 1101\n#endif\n\nPROCEDURE Main( cTermCP, cHostCP, lBoxChar, lRawKey )\n\n LOCAL k, kX, i, s\n LOCAL aKeys := { ;\n { \"K_UP\", 5, \"Up arrow, Ctrl-E\" }, ;\n { \"K_DOWN\", 24, \"Down arrow, Ctrl-X\" }, ;\n { \"K_LEFT\", 19, \"Left arrow, Ctrl-S\" }, ;\n { \"K_RIGHT\", 4, \"Right arrow, Ctrl-D\" }, ;\n { \"K_HOME\", 1, \"Home, Ctrl-A\" }, ;\n { \"K_END\", 6, \"End, Ctrl-F\" }, ;\n { \"K_PGUP\", 18, \"PgUp, Ctrl-R\" }, ;\n { \"K_PGDN\", 3, \"PgDn, Ctrl-C\" }, ;\n { \"K_CTRL_UP\", 397, \"Ctrl-Up arrow\" }, ;\n { \"K_CTRL_DOWN\", 401, \"Ctrl-Down arrow\" }, ;\n { \"K_CTRL_LEFT\", 26, \"Ctrl-Left arrow, Ctrl-Z\" }, ;\n { \"K_CTRL_RIGHT\", 2, \"Ctrl-Right arrow, Ctrl-B\" }, ;\n { \"K_CTRL_HOME\", 29, \"Ctrl-Home, Ctrl-]\" }, ;\n { \"K_CTRL_END\", 23, \"Ctrl-End, Ctrl-W\" }, ;\n { \"K_CTRL_PGUP\", 31, \"Ctrl-PgUp, Ctrl-Hyphen\" }, ;\n { \"K_CTRL_PGDN\", 30, \"Ctrl-PgDn, Ctrl-^\" }, ;\n { \"K_ALT_UP\", 408, \"Alt-Up arrow\" }, ;\n { \"K_ALT_DOWN\", 416, \"Alt-Down arrow\" }, ;\n { \"K_ALT_LEFT\", 411, \"Alt-Left arrow\" }, ;\n { \"K_ALT_RIGHT\", 413, \"Alt-Right arrow\" }, ;\n { \"K_ALT_HOME\", 407, \"Alt-Home\" }, ;\n { \"K_ALT_END\", 415, \"Alt-End\" }, ;\n { \"K_ALT_PGUP\", 409, \"Alt-PgUp\" }, ;\n { \"K_ALT_PGDN\", 417, \"Alt-PgDn\" }, ;\n { \"K_ENTER\", 13, \"Enter, Ctrl-M\" }, ;\n { \"K_RETURN\", 13, \"Return, Ctrl-M\" }, ;\n { \"K_SPACE\", 32, \"Space bar\" }, ;\n { \"K_ESC\", 27, \"Esc, Ctrl-[\" }, ;\n { \"K_CTRL_ENTER\", 10, \"Ctrl-Enter, Ctrl-J\" }, ;\n { \"K_CTRL_RETURN\", 10, \"Ctrl-Return, Ctrl-J\" }, ;\n { \"K_CTRL_RET\", 10, \"Ctrl-Return (Compat.)\" }, ;\n { \"K_CTRL_PRTSCR\", 379, \"Ctrl-Print Screen, Alt-4\" }, ;\n { \"K_ALT_COMMA\", 307, \"Alt-,\" }, ;\n { \"K_ALT_PERIOD\", 308, \"Alt-.\" }, ;\n { \"K_CTRL_QUESTION\", 309, \"Ctrl-?, Alt-Slash\" }, ;\n { \"K_ALT_SLASH\", 309, \"Alt-Slash\" }, ;\n { \"K_ALT_BACKSLASH\", 299, \"Alt-Backslash\" }, ;\n { \"K_ALT_ENTER\", 284, \"Alt-Enter\" }, ;\n { \"K_ALT_RETURN\", 284, \"Alt-Return\" }, ;\n { \"K_ALT_MINUS\", 386, \"Alt-Minus\" }, ;\n { \"K_ALT_EQUALS\", 387, \"Alt-Equals\" }, ;\n { \"K_ALT_ESC\", 257, \"Alt-Esc\" }, ;\n { \"K_ALT_BACKQUOTE\", 297, \"Alt-backquote\" }, ;\n { \"K_ALT_OSB\", 282, \"Alt-[\" }, ;\n { \"K_ALT_CSB\", 283, \"Alt-]\" }, ;\n { \"K_ALT_SC\", 295, \"Alt-;\" }, ;\n { \"K_ALT_QUOTE\", 296, \"Alt-'\" }, ;\n { \"KP_CENTER\", 332, \"Keypad CENTER (5)\" }, ;\n { \"KP_ALT_ENTER\", 422, \"Keypad Alt-Enter\" }, ;\n { \"KP_CTRL_5\", 399, \"Keypad Ctrl-5\" }, ;\n { \"KP_CTRL_SLASH\", 405, \"Keypad Ctrl-/\" }, ;\n { \"KP_CTRL_ASTERISK\", 406, \"Keypad Ctrl-*\" }, ;\n { \"KP_CTRL_MINUS\", 398, \"Keypad Ctrl--\" }, ;\n { \"KP_CTRL_PLUS\", 400, \"Keypad Ctrl-+\" }, ;\n { \"KP_ALT_5\", 5, \"Keypad Alt-5\" }, ;\n { \"KP_ALT_SLASH\", 420, \"Keypad Alt-/\" }, ;\n { \"KP_ALT_ASTERISK\", 311, \"Keypad Alt-*\" }, ;\n { \"KP_ALT_MINUS\", 330, \"Keypad Alt--\" }, ;\n { \"KP_ALT_PLUS\", 334, \"Keypad Alt-+\" }, ;\n { \"K_INS\", 22, \"Ins, Ctrl-V\" }, ;\n { \"K_DEL\", 7, \"Del, Ctrl-G\" }, ;\n { \"K_BS\", 8, \"Backspace, Ctrl-H\" }, ;\n { \"K_SH_BS\", 423, \"Shift-Backspace, Ctrl-Shift-Tab\" }, ;\n { \"K_CTRL_SH_TAB\", 423, \"Ctrl-Shift-Tab\" }, ;\n { \"K_TAB\", 9, \"Tab, Ctrl-I\" }, ;\n { \"K_SH_TAB\", 271, \"Shift-Tab\" }, ;\n { \"K_CTRL_INS\", 402, \"Ctrl-Ins\" }, ;\n { \"K_CTRL_DEL\", 403, \"Ctrl-Del\" }, ;\n { \"K_CTRL_BS\", 127, \"Ctrl-Backspace\" }, ;\n { \"K_CTRL_TAB\", 404, \"Ctrl-Tab\" }, ;\n { \"K_ALT_INS\", 418, \"Alt-Ins\" }, ;\n { \"K_ALT_DEL\", 419, \"Alt-Del\" }, ;\n { \"K_ALT_BS\", 270, \"Alt-Backspace\" }, ;\n { \"K_ALT_TAB\", 421, \"Alt-Tab\" } }\n\n AAdd( aKeys, { \"K_CTRL_A\", 1, \"Ctrl-A, Home\" } )\n AAdd( aKeys, { \"K_CTRL_B\", 2, \"Ctrl-B, Ctrl-Right arrow\" } )\n AAdd( aKeys, { \"K_CTRL_C\", 3, \"Ctrl-C, PgDn, Ctrl-ScrollLock\" } )\n AAdd( aKeys, { \"K_CTRL_D\", 4, \"Ctrl-D, Right arrow\" } )\n AAdd( aKeys, { \"K_CTRL_E\", 5, \"Ctrl-E, Up arrow\" } )\n AAdd( aKeys, { \"K_CTRL_F\", 6, \"Ctrl-F, End\" } )\n AAdd( aKeys, { \"K_CTRL_G\", 7, \"Ctrl-G, Del\" } )\n AAdd( aKeys, { \"K_CTRL_H\", 8, \"Ctrl-H, Backspace\" } )\n AAdd( aKeys, { \"K_CTRL_I\", 9, \"Ctrl-I, Tab\" } )\n AAdd( aKeys, { \"K_CTRL_J\", 10, \"Ctrl-J\" } )\n AAdd( aKeys, { \"K_CTRL_K\", 11, \"Ctrl-K\" } )\n AAdd( aKeys, { \"K_CTRL_L\", 12, \"Ctrl-L\" } )\n AAdd( aKeys, { \"K_CTRL_M\", 13, \"Ctrl-M, Return\" } )\n AAdd( aKeys, { \"K_CTRL_N\", 14, \"Ctrl-N\" } )\n AAdd( aKeys, { \"K_CTRL_O\", 15, \"Ctrl-O\" } )\n AAdd( aKeys, { \"K_CTRL_P\", 16, \"Ctrl-P\" } )\n AAdd( aKeys, { \"K_CTRL_Q\", 17, \"Ctrl-Q\" } )\n AAdd( aKeys, { \"K_CTRL_R\", 18, \"Ctrl-R, PgUp\" } )\n AAdd( aKeys, { \"K_CTRL_S\", 19, \"Ctrl-S, Left arrow\" } )\n AAdd( aKeys, { \"K_CTRL_T\", 20, \"Ctrl-T\" } )\n AAdd( aKeys, { \"K_CTRL_U\", 21, \"Ctrl-U\" } )\n AAdd( aKeys, { \"K_CTRL_V\", 22, \"Ctrl-V, Ins\" } )\n AAdd( aKeys, { \"K_CTRL_W\", 23, \"Ctrl-W, Ctrl-End\" } )\n AAdd( aKeys, { \"K_CTRL_X\", 24, \"Ctrl-X, Down arrow\" } )\n AAdd( aKeys, { \"K_CTRL_Y\", 25, \"Ctrl-Y\" } )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/beforatn.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\n#include \"ct.ch\"\n\nPROCEDURE Main()\n\n LOCAL cStr := \"...This...is...a...test!\"\n\n ctinit()\n\n ? \"Begin test of BeforAtNum()\"\n ?\n ? \" Value of cStr is: \" + '\"' + cStr + '\"'\n ?\n\n ? \" Simple tests:\"\n ? ' BeforAtNum( \"..\", cStr ) should be \"...This...is...a.\",'\n ? ' and is \"' + BeforAtNum( \"..\", cStr ) + '\"'\n ? ' BeforAtNum( \"..\", cStr, 2 ) should be \"...This\",'\n ? ' and is \"' + BeforAtNum( \"..\", cStr, 2 ) + '\"'\n ? ' BeforAtNum( \"..\", cStr, 2, 2 ) should be \"...This...is\",'\n ? ' and is \"' + BeforAtNum( \"..\", cStr, 2, 2 ) + '\"'\n ?\n\n ? \" Multi-Pass tests\"\n ? \" Setting CSetAtMupa() to .T.\"\n CSetAtMupa( .T. )\n ? ' BeforAtNum( \"..\", cStr ) should be \"...This...is...a.\",'\n ? ' and is \"' + BeforAtNum( \"..\", cStr ) + '\"'\n ? ' BeforAtNum( \"..\", cStr, 2 ) should be \".\",'\n ? ' and is \"' + BeforAtNum( \"..\", cStr, 2 ) + '\"'\n ? ' BeforAtNum( \"..\", cStr, 2, 2 ) should be \"...This.\",'\n ? ' and is \"' + BeforAtNum( \"..\", cStr, 2, 2 ) + '\"'\n ? \" Setting CSetAtMupa() to .F.\"\n CSetAtMupa( .F. )\n ?\n\n ? \" SetAtLike tests\"\n ? ' Setting SetAtLike( CT_SETATLIKE_WILDCARD, \".\" )'\n SetAtLike( CT_SETATLIKE_WILDCARD, \".\" )\n ? ' BeforAtNum( \"..\", cStr ) should be \"...This...is...a...tes\",'\n ? ' and is \"' + BeforAtNum( \"..\", cStr ) + '\"'\n ? ' BeforAtNum( \"..\", cStr, 2, 2 ) should be \"...T\",'\n ? ' and is \"' + BeforAtNum( \"..\", cStr, 2, 2 ) + '\"'\n ? ' BeforAtNum( \"..\", cStr, 2, 10 ) should be \"...This...is\",'\n ? ' and is \"' + BeforAtNum( \"..\", cStr, 2, 10 ) + '\"'\n ?\n\n ? \"End test of BeforAtNum()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/tests/barcode.prg. Contains procedures: Main. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbgd\"\n\n#define IMAGES_OUT \"imgs_out\" + hb_ps()\n\nPROCEDURE Main()\n\n LOCAL bar\n\n \n LOCAL black := { 0, 0, 0 }\n LOCAL white := { 255, 255, 255 }\n\n\n LOCAL ccode13 := \"789136043666\"\n LOCAL ccode8 := \"0421000\"\n \n LOCAL ccode128 := \"Code 128\"\n\n \n bar := GDBarCode():New( 13 )\n\n \n bar:Configure( 70, black, white, 2, 1 )\n\n \n bar:CreateBar( 205, 105, IMAGES_OUT + \"bar13.jpg\", white )\n\n \n bar:Draw13( ccode13 )\n\n \n bar:Finish( 2 )\n\n \n bar := GDBarCode():New( 8 )\n\n bar:Configure( 70, black, white, 2, 1 )\n\n bar:CreateBar( 154, 100, IMAGES_OUT + \"bar8.gif\", white )\n\n bar:Draw8( ccode8 )\n\n bar:Finish( 8 )\n\n bar:ResizeImage()\n\n \n bar := GDBarCode():New( 128 )\n\n bar:Configure( 50, black, white, 2, 1 )\n\n bar:CreateBar( 300, 400, IMAGES_OUT + \"bar128.gif\", white )\n\n \n bar:Draw128( cCode128, \"B\" )\n\n bar:Finish( 2 )\n\n \n bar := GDBarCode():New( 25 )\n\n bar:Configure( 25, black, white, 1, 1,, .T. )\n\n bar:CreateBar( 560, 60, IMAGES_OUT + \"febraban.gif\", white )\n bar:DrawI25( \"104995628545723070285700000008218000\" )\n bar:Finish( 8 )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/numtoken.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL cStr := \".,.This.,.is.,.a.,.test!\"\n\n ctinit()\n\n ? \"Begin test of NumToken()\"\n ?\n\n ? \" Simple tests:\"\n ? ' NumToken( \"Hello, World!\" ) == 2 ? --------------------------------> ' + Str( NumToken( \"Hello, World!\" ), 2 )\n ? ' NumToken( \"This is good. See you! How do you do?\", \".!?\" ) == 3 ? --> ' + Str( NumToken( \"This is good. See you! How do you do?\", \".!?\" ), 2 )\n ? ' NumToken( \"one,,three,four,,six\", \",\", 1 ) == 6 ? -----------------> ' + Str( NumToken( \"one,,three,four,,six\", \",\", 1 ), 2 )\n ?\n\n ? ' # of tokens in the string \"' + cStr + '\"'\n ? ' separator list = \".,!\" and skip width = 1: ' + Str( NumToken( cStr, \".,!\", 1 ) )\n ? ' skip width = 3: ' + Str( NumToken( cStr, \".,!\", 3 ) )\n ? ' separator list = \",!\" and skip width = 1: ' + Str( NumToken( cStr, \",!\", 1 ) )\n ? ' skip width = 3: ' + Str( NumToken( cStr, \",!\", 3 ) )\n ? ' separator list = \"!\" and skip width = 1: ' + Str( NumToken( cStr, \"!\", 1 ) )\n ? ' skip width = 3: ' + Str( NumToken( cStr, \"!\", 3 ) )\n\n ?\n ? \"End test of NumToken()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'gtwvg' (): contrib/gtwvg/static.prg. Defines classes: WvgStatic. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nCREATE CLASS WvgStatic INHERIT WvgWindow\n\n VAR autoSize INIT .F.\n VAR caption INIT \"\"\n VAR clipParent INIT .T.\n VAR clipSiblings INIT .F.\n VAR options INIT -1 \n VAR TYPE INIT -1 \n\n VAR hBitmap\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD destroy()\n METHOD handleEvent( nMessage, aNM )\n\n METHOD setCaption( xCaption, cDll )\n\nENDCLASS\n\nMETHOD WvgStatic:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n \n ::style := WS_CHILD + WS_CLIPCHILDREN\n ::className := \"STATIC\"\n ::objType := objTypeStatic\n\n RETURN Self\n\nMETHOD WvgStatic:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n\n SWITCH ::type\n CASE WVGSTATIC_TYPE_TEXT\n IF hb_bitAnd( ::options, WVGSTATIC_TEXT_LEFT ) == WVGSTATIC_TEXT_LEFT\n ::style += SS_LEFT \n ENDIF\n IF hb_bitAnd( ::options, WVGSTATIC_TEXT_RIGHT ) == WVGSTATIC_TEXT_RIGHT\n ::style += SS_RIGHT\n ENDIF\n IF hb_bitAnd( ::options, WVGSTATIC_TEXT_CENTER ) == WVGSTATIC_TEXT_CENTER\n ::style += SS_CENTER\n ENDIF\n IF hb_bitAnd( ::options, WVGSTATIC_TEXT_WORDBREAK ) == WVGSTATIC_TEXT_WORDBREAK\n ::style -= SS_LEFTNOWORDWRAP\n ENDIF\n EXIT\n\n CASE WVGSTATIC_TYPE_GROUPBOX\n EXIT\n CASE WVGSTATIC_TYPE_ICON\n ::style += SS_ICON\n EXIT\n CASE WVGSTATIC_TYPE_SYSICON\n EXIT\n CASE WVGSTATIC_TYPE_BITMAP\n ::style += SS_BITMAP\n DO CASE\n CASE ::options == WVGSTATIC_BITMAP_TILED\n ::style += SS_CENTERIMAGE\n CASE ::options == WVGSTATIC_BITMAP_SCALED\n\n OTHERWISE\n\n ENDCASE\n EXIT\n\n CASE WVGSTATIC_TYPE_FGNDRECT\n ::style += SS_WHITERECT\n EXIT\n CASE WVGSTATIC_TYPE_BGNDRECT\n ::style += SS_BLACKRECT\n EXIT\n CASE WVGSTATIC_TYPE_HALFTONERECT\n ::style += SS_GRAYRECT\n EXIT\n CASE WVGSTATIC_TYPE_FGNDFRAME\n ::style += SS_WHITEFRAME\n EXIT\n CASE WVGSTATIC_TYPE_BGNDFRAME\n ::style += SS_BLACKFRAME\n EXIT\n CASE WVGSTATIC_TYPE_HALFTONEFRAME\n ::style += SS_GRAYFRAME\n EXIT\n CASE WVGSTATIC_TYPE_RAISEDBOX\n ::style += SS_ETCHEDFRAME\n EXIT\n\n CASE WVGSTATIC_TYPE_RECESSEDBOX\n EXIT\n CASE WVGSTATIC_TYPE_RAISEDRECT\n EXIT\n CASE WVGSTATIC_TYPE_RECESSEDRECT\n EXIT\n CASE WVGSTATIC_TYPE_RAISEDLINE\n EXIT\n CASE WVGSTATIC_TYPE_RECESSEDLINE\n EXIT\n ENDSWITCH \n\n#if 1\n \n IF AScan( { WVGSTATIC_TYPE_FGNDFRAME, WVGSTATIC_TYPE_BGNDFRAME, WVGSTATIC_TYPE_HALFTONEFRAME }, ::type ) > 0\n DO CASE\n CASE hb_bitAnd( ::options, WVGSTATIC_FRAMETHIN ) == WVGSTATIC_FRAMETHIN\n ::style += WS_BORDER\n CASE hb_bitAnd( ::options, WVGSTATIC_FRAMETHICK ) == WVGSTATIC_FRAMETHICK\n ::style += WS_DLGFRAME\n ENDCASE\n ENDIF\n#endif\n\n ::oParent:addChild( Self )\n\n ::createControl()\n\n ::SetWindowProcCallback() \n\n IF ::visible\n ::show()\n ENDIF\n ::setPosAndSize()\n\n ::setCaption( ::caption )\n\n RETURN Self\n\nMETHOD WvgStatic:handleEvent( nMessage, aNM )\n\n DO CASE\n\n CASE nMessage == HB_GTE_RESIZED\n IF ::isParentCrt()\n ::rePosition()\n ENDIF\n IF HB_ISBLOCK( ::sl_resize )\n Eval( ::sl_resize, , , Self )\n ENDIF\n AEval( ::aChildren, {| o | o:handleEvent( HB_GTE_RESIZED, { 0, 0, 0, 0, 0 } ) } )\n RETURN EVENT_HANDELLED\n\n CASE nMessage == HB_GTE_CTLCOLOR\n IF HB_ISNUMERIC( ::clr_FG )\n wvg_SetTextColor( aNM[ 1 ], ::clr_FG )\n ENDIF\n IF HB_ISNUMERIC( ::hBrushBG )\n wvg_SetBkMode( aNM[ 1 ], 1 )\n RETURN ::hBrushBG\n ELSE\n RETURN wvg_GetCurrentBrush( aNM[ 1 ] )\n ENDIF\n\n CASE nMessage == HB_GTE_ANY\n IF ::isParentCrt()\n\n ENDIF\n\n ENDCASE\n\n RETURN EVENT_UNHANDELLED\n\nMETHOD PROCEDURE WvgStatic:destroy()\n\n IF ::hBitmap != NIL\n wvg_DeleteObject( ::hBitmap )\n ENDIF\n ::wvgWindow:destroy()\n\n RETURN\n\nMETHOD WvgStatic:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n RETURN Self\n\nMETHOD WvgStatic:setCaption( xCaption, cDll )\n\n HB_SYMBOL_UNUSED( cDll )\n\n __defaultNIL( @xCaption, ::caption )\n ::caption := xCaption\n\n DO CASE\n CASE ::type == WVGSTATIC_TYPE_TEXT\n wvg_SendMessageText( ::hWnd, WM_SETTEXT, 0, ::caption )\n\n CASE ::type == WVGSTATIC_TYPE_BITMAP\n IF ::hBitmap != nil\n wvg_DeleteObject( ::hBitmap )\n ENDIF\n\n ::hBitmap := wvg_LoadImage( ::caption, iif( HB_ISNUMERIC( ::caption ), 1, 2 ) )\n\n wvg_SendMessage( ::hWnd, STM_SETIMAGE, IMAGE_BITMAP, ::hBitmap )\n\n ENDCASE\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'gtwvg' (): contrib/gtwvg/genrc.prg. Provides functions: WvgSetAppWindow. Contains procedures: KillGTChildren. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nTHREAD STATIC t_oCrt\n\nEXIT PROCEDURE KillGTChildren()\n\n IF HB_ISOBJECT( t_oCrt ) .AND. __objGetClsName( t_oCrt ) == \"WVGCRT\" .AND. t_oCrt:isGT\n t_oCrt:destroy()\n t_oCrt := NIL\n ENDIF\n\n RETURN\n\nFUNCTION WvgSetAppWindow( oCrt )\n\n LOCAL ooCrt := t_oCrt\n\n IF Empty( oCrt )\n IF Empty( t_oCrt )\n t_oCrt := WvgCrt():new()\n t_oCrt:hWnd := wvt_GetWindowHandle()\n t_oCrt:pWnd := win_N2P( t_oCrt:hWnd )\n hb_gtInfo( HB_GTI_NOTIFIERBLOCKGUI, {| nEvent, ... | t_oCrt:notifier( nEvent, ... ) } )\n t_oCrt:isGT := .T.\n RETURN t_oCrt\n ENDIF\n ELSE\n t_oCrt := oCrt\n ENDIF\n\n RETURN ooCrt"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/xhbinkey.ch. Defines 10 constants including: XHB_INKEY_CH_, XHB_K_CTRL_A, XHB_K_CTRL_B, XHB_K_CTRL_C, XHB_K_CTRL_D. Defines keyboard input constants"}, {"role": "assistant", "content": "#ifndef XHB_INKEY_CH_\n#define XHB_INKEY_CH_\n\n\n#define XHB_K_CTRL_A 513 \n#define XHB_K_CTRL_B 514 \n#define XHB_K_CTRL_C 515 \n#define XHB_K_CTRL_D 516 \n#define XHB_K_CTRL_E 517 \n#define XHB_K_CTRL_F 518 \n#define XHB_K_CTRL_G 519 \n#define XHB_K_CTRL_H 520 \n#define XHB_K_CTRL_I 521 \n#define XHB_K_CTRL_J 522 \n#define XHB_K_CTRL_K 523 \n#define XHB_K_CTRL_L 524 \n#define XHB_K_CTRL_M 525 \n#define XHB_K_CTRL_N 526 \n#define XHB_K_CTRL_O 527 \n#define XHB_K_CTRL_P 528 \n#define XHB_K_CTRL_Q 529 \n#define XHB_K_CTRL_R 530 \n#define XHB_K_CTRL_S 531 \n#define XHB_K_CTRL_T 532 \n#define XHB_K_CTRL_U 533 \n#define XHB_K_CTRL_V 534 \n#define XHB_K_CTRL_W 535 \n#define XHB_K_CTRL_X 536 \n#define XHB_K_CTRL_Y 537 \n#define XHB_K_CTRL_Z 538 \n\n\n#define XHB_K_SH_LEFT 424 \n#define XHB_K_SH_UP 425 \n#define XHB_K_SH_RIGHT 426 \n#define XHB_K_SH_DOWN 427 \n\n#define XHB_K_SH_INS 428 \n#define XHB_K_SH_DEL 429 \n#define XHB_K_SH_HOME 430 \n#define XHB_K_SH_END 431 \n#define XHB_K_SH_PGUP 432 \n#define XHB_K_SH_PGDN 433 \n\n#define XHB_K_SH_RETURN 434 \n#define XHB_K_SH_ENTER 434 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: __SetFunction. Harbour Runtime Library file: src/rtl/setfunc.prg. Contains procedures: __SetFunction. This file provides utility functions"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n\nPROCEDURE __SetFunction( nFunctionKey, xKeySeq )\n\n \n DO CASE\n CASE nFunctionKey == 1 ; nFunctionKey := K_F1\n#ifndef HB_CLP_STRICT\n CASE nFunctionKey == 11 ; nFunctionKey := K_F11\n CASE nFunctionKey == 12 ; nFunctionKey := K_F12\n#endif\n OTHERWISE ; nFunctionKey := -nFunctionKey + 1\n ENDCASE\n\n IF HB_ISSTRING( xKeySeq )\n SetKey( nFunctionKey, {|| __Keyboard(), hb_keyPut( xKeySeq ) } )\n ELSE\n SetKey( nFunctionKey, NIL )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/flock.prg. Contains procedures: Main, ShowStatus. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n#include \"inkey.ch\"\n\n#define FLX_EXCLUSIVE 0x0000 \n#define FLX_SHARED 0x0100 \n#define FLX_NO_WAIT 0x0000 \n#define FLX_WAIT 0x0200 \n\n#define hb_keyCode( x ) Asc( x )\n\nSTATIC s_lLocked\nSTATIC s_lExclusive\nSTATIC s_lBlocking\n\nPROCEDURE Main()\n\n LOCAL hLockFile\n LOCAL lSuccess\n LOCAL nExclusivity\n LOCAL nBlocking\n LOCAL nKeyHit\n LOCAL nLockType\n\n CLS\n\n IF ! hb_FileExists( \"emphasis.6lo\" )\n hb_MemoWrit( \"emphasis.6lo\", \"\" )\n ENDIF\n\n ? \"Opening lock file\"\n IF ( hLockFile := FOpen( \"emphasis.6lo\", FO_READWRITE ) ) == F_ERROR\n ? \"ERROR: Cannot open Lock File\"\n RETURN\n ENDIF\n ? \"Lock file opened - handle is\", hb_ntos( hLockFile )\n ?\n s_lLocked := .F.\n s_lExclusive := .T.\n s_lBlocking := .F.\n nExclusivity := FLX_EXCLUSIVE\n nBlocking := FLX_NO_WAIT\n ShowStatus()\n ? \"[+] to get a lock, [-] to release it, [Esc] to exit, [E] for exclusive, [S] for shared, [B] for blocking, [N] for non-blocking\"\n DO WHILE .T.\n nKeyHit := Inkey( 0 )\n SWITCH nKeyHit\n CASE hb_keyCode( \"+\" )\n IF s_lLocked\n ? \"Already locked\"\n ELSE\n nLockType := nExclusivity + nBlocking\n ? \"Requesting Lock\"\n lSuccess := hb_FLock( hLockFile, 0, 1, nLockType )\n IF lSuccess\n ? \"Lock has been obtained\"\n s_lLocked := .T.\n ELSE\n ? \"Lock Request Failed - Error Code:\", FError()\n ENDIF\n ENDIF\n EXIT\n CASE hb_keyCode( \"-\" )\n IF ! s_lLocked\n ? \"Lock not currently held\"\n ELSE\n lSuccess := hb_FUnlock( hLockFile, 0, 1 )\n IF lSuccess\n ? \"Lock has been released\"\n s_lLocked := .F.\n ELSE\n ? \"Unlock Request Failed - Error Code:\", FError()\n ENDIF\n ENDIF\n EXIT\n CASE hb_keyCode( \"E\" )\n CASE hb_keyCode( \"e\" )\n IF s_lLocked\n ? \"Release Lock before changing lock type\"\n ELSE\n s_lExclusive := .T.\n nExclusivity := FLX_EXCLUSIVE\n ShowStatus()\n ENDIF\n EXIT\n CASE hb_keyCode( \"S\" )\n CASE hb_keyCode( \"s\" )\n IF s_lLocked\n ? \"Release Lock before changing lock type\"\n ELSE\n s_lExclusive := .F.\n nExclusivity := FLX_SHARED\n ShowStatus()\n ENDIF\n EXIT\n CASE hb_keyCode( \"B\" )\n CASE hb_keyCode( \"b\" )\n IF s_lLocked\n ? \"Release Lock before changing function mode\"\n ELSE\n s_lBlocking := .T.\n nExclusivity := FLX_WAIT\n ShowStatus()\n ENDIF\n EXIT\n CASE hb_keyCode( \"N\" )\n CASE hb_keyCode( \"n\" )\n IF s_lLocked\n ? \"Release Lock before changing function mode\"\n ELSE\n s_lBlocking := .F.\n nExclusivity := FLX_NO_WAIT\n ShowStatus()\n ENDIF\n EXIT\n CASE K_ESC\n ?\n FClose( hLockFile )\n ? \"Exiting\"\n RETURN\n OTHERWISE\n ? \"Key not supported\", nKeyHit\n ENDSWITCH\n ENDDO\n\n RETURN\n\nPROCEDURE ShowStatus()\n\n ? \"Lock: \" + iif( s_lLocked, \"Held\", \"Released\" ) +;\n \" Type: \" + iif( s_lExclusive, \"Exclusive\", \"Shared\" ) +;\n \" Request is: \" + iif( s_lBlocking, \"Blocking\", \"Non-Blocking\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour extra library: extras/httpsrv/modules/showcounter.prg. Provides functions: HRBMAIN, CreateCounter. This file implements server functionality"}, {"role": "assistant", "content": "#if defined( HBMK_HAS_HBGD )\n\nMEMVAR _SERVER \nMEMVAR _REQUEST \n\n#define IMAGES_IN \"..\" + hb_ps() + \"..\" + hb_ps() + \"..\" + hb_ps() + \"contrib\" + hb_ps() + \"hbgd\" + hb_ps() + \"tests\" + hb_ps() + \"digits\" + hb_ps()\n#define IMAGES_OUT ( _SERVER[ \"DOCUMENT_ROOT\" ] + hb_ps() + \"counter\" + hb_ps() )\n\n#define DISPLAY_NUM 10\n\nFUNCTION HRBMAIN()\n\n LOCAL cHtml\n\n IF hb_HHasKey( _REQUEST, \"w\" )\n\n cHtml := CreateCounter( hb_ntos( Val( _REQUEST[ \"w\" ] ) ) )\n IF ! Empty( cHtml )\n uhttpd_SetHeader( \"Content-Type\", \"image/gif\" )\n uhttpd_SetHeader( \"Pragma\", \"no-cache\" )\n uhttpd_SetHeader( \"Content-Disposition\", \"inline; filename=counter\" + hb_ntos( hb_RandomInt( 100 ) ) + \".gif\" )\n uhttpd_Write( cHtml )\n ELSE\n uhttpd_SetHeader( \"Content-Type\", \"text/html\" )\n uhttpd_Write( \"

Error: No image created

\" )\n ENDIF\n ELSE\n uhttpd_SetHeader( \"Content-Type\", \"text/html\" )\n uhttpd_Write( \"

Error: no parameters passed

\" )\n ENDIF\n\n RETURN .T.\n\nSTATIC FUNCTION CreateCounter( cValue, cBaseImage )\n\n LOCAL oI, oIDigits, nWidth, nHeight, nDigits, nNumWidth, oTemp\n\n LOCAL aNumberImages := {}\n LOCAL n, nValue\n\n \n hb_default( @cValue, Str( hb_RandomInt( 1, 10 ^ DISPLAY_NUM ), DISPLAY_NUM ) )\n hb_default( @cBaseImage, \"57chevy.gif\" )\n\n IF ! hb_FileExists( IMAGES_IN + cBaseImage )\n RETURN NIL\n ENDIF\n\n nValue := Val( cValue )\n\n \n IF nValue > 10 ^ DISPLAY_NUM\n nValue := 10 ^ DISPLAY_NUM\n ENDIF\n\n cValue := StrZero( nValue, DISPLAY_NUM )\n\n\n oIDigits := GDImage():LoadFromGif( IMAGES_IN + cBaseImage )\n\n \n nWidth := oIDigits:Width()\n nHeight := oIDigits:Height()\n\n \n DO CASE\n CASE nWidth % 10 == 0 \n nDigits := 10\n CASE nWidth % 11 == 0 \n nDigits := 11\n CASE nWidth % 13 == 0 \n nDigits := 13\n OTHERWISE\n uhttpd_Write( \"Error on digits image\" )\n ENDCASE\n nNumWidth := nWidth / nDigits\n\n\n FOR n := 1 TO nDigits\n oTemp := oIDigits:Copy( ( n - 1 )\n ? \"Image dimensions: \", oI:Width(), oI:Height()\n\n \n white := oI:SetColor( 255, 255, 255 )\n\n \n black := oI:SetColor( 0, 0, 0 )\n blue := oI:SetColor( 0, 0, 255 )\n red := oI:SetColor( 255, 0, 0 )\n green := oI:SetColor( 0, 255, 0 )\n cyan := oI:SetColor( 0, 255, 255 )\n\n \n oI:Rectangle( 0, 0, 200, 30,, blue )\n#endif\n\n \n FOR n := 1 TO Len( cValue )\n \n oTemp := aNumberImages[ Val( SubStr( cValue, n, 1 ) ) + 1 ]:Clone()\n \n \n oI:SetTile( oTemp )\n \n oI:Rectangle( ( n - 1 )\n oI:SaveGif( IMAGES_OUT + \"counter\" + StrZero( hb_RandomInt( 1, 99 ), 2 ) + \".gif\" )\n\n ?\n ? \"Look at \" + IMAGES_OUT + \" folder for output images\"\n ?\n#endif\n\n RETURN oI:ToStringGif()\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/serial2.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\nPROCEDURE Main( cPortName )\n\n LOCAL oWinPort\n LOCAL cString := Space( 32 )\n LOCAL lCTS, lDSR, lRing, lDCD\n LOCAL lCTSHold, lDSRHold, lDCDHold, lXoffHold, lXoffSent, nInQueue, nOutQueue\n LOCAL nResult\n\n IF Empty( cPortName )\n ? \"Usage : winport portname\"\n RETURN\n ENDIF\n\n ? \"Attach a scanner now ...\"\n ?\n Inkey( 0 )\n\n oWinPort := win_com():Init( cPortName, WIN_CBR_9600, WIN_ODDPARITY, 7, WIN_ONESTOPBIT )\n IF ! oWinPort:Open()\n ? \"Open() failed\"\n ELSE\n ? \"Open() succeeded\"\n ?\n IF oWinPort:Status( @lCTS, @lDSR, @lRing, @lDCD )\n ? \"Status() succeeded : CTS \", lCTS, \", DSR \", lDSR, \", Ring \", lRing, \", DCD \", lDCD\n ELSE\n ? \"Status() failed :\", oWinPort:ErrorText()\n ENDIF\n ?\n ? \"Testing DTR, configure a scanner to require DTR\"\n ? \"Scan something... and press enter (shouldn't scan)\"\n Inkey( 0 )\n ? \"Read() \", oWinPort:Read( @cString, 32 ), Len( cString ), cString\n ?\n IF oWinPort:SetDTR( .T. )\n ? \"SetDTR( .T. ) succeeded\"\n ELSE\n ? \"SetDTR( .T. ) failed :\", oWinPort:ErrorText()\n ENDIF\n ? \"Scan something... and press enter (read should work)\"\n Inkey( 0 )\n ?\n IF oWinPort:QueueStatus( @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )\n ? \"QueueStatus() : CTSHold\", lCtsHold, \", DSRHold\", lDsrHold, \", DCDHold\", lDCDHold, \", XoffHold\", lXoffHold, ;\n \", Xoff Sent \", lXoffSent, \", InQueue \", nInQueue, \", nOutQueue \", nOutQueue\n ELSE\n ? \"QueueStatus() failed :\", oWinPort:ErrorText()\n ENDIF\n ?\n ? \"Read() \", oWinPort:Read( @cString, 32 ), Len( cString ), cString\n ?\n IF oWinPort:QueueStatus( @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )\n ? \"QueueStatus() : CTSHold\", lCtsHold, \", DSRHold\", lDsrHold, \", DCDHold\", lDCDHold, \", XoffHold\", lXoffHold, ;\n \", Xoff Sent \", lXoffSent, \", InQueue \", nInQueue, \", nOutQueue \", nOutQueue\n ELSE\n ? \"QueueStatus() failed :\", oWinPort:ErrorText()\n ENDIF\n ?\n IF oWinPort:RTSFlow( WIN_RTS_CONTROL_HANDSHAKE )\n ? \"RTSFlow( WIN_RTS_CONTROL_HANDSHAKE ) succeeded\"\n ELSE\n ? \"RTSFlow( WIN_RTS_CONTROL_HANDSHAKE ) failed :\", oWinPort:ErrorText()\n ENDIF\n ? oWinPort:DebugDCB( HB_WIN_COM_DBGFLOW )\n IF oWinPort:SetRTS( .F. )\n ? \"SetRTS( .F. ) succeeded (it shouldn't according to docs!)\"\n ELSE\n ? \"SetRTS( .F. ) failed (it should) :\", oWinPort:ErrorText()\n ENDIF\n ?\n IF oWinPort:RTSFlow( WIN_RTS_CONTROL_DISABLE )\n ? \"RTSFlow( WIN_RTS_CONTROL_DISABLE ) succeeded\"\n ELSE\n ? \"RTSFlow( WIN_RTS_CONTROL_DISABLE ) failed :\", oWinPort:ErrorText()\n ENDIF\n ? oWinPort:DebugDCB( HB_WIN_COM_DBGFLOW )\n IF oWinPort:SetRTS( .F. )\n ? \"SetRTS( .F. ) succeeded (it should)\"\n ELSE\n ? \"SetRTS( .F. ) failed :\", oWinPort:ErrorText()\n ENDIF\n ?\n ? \"Scan something... we'll not read it but purge it, press enter\"\n Inkey( 0 )\n IF oWinPort:QueueStatus( @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )\n ? \"QueueStatus() : CTSHold\", lCtsHold, \", DSRHold\", lDsrHold, \", DCDHold\", lDCDHold, \", XoffHold\", lXoffHold, ;\n \", Xoff Sent \", lXoffSent, \", InQueue \", nInQueue, \", nOutQueue \", nOutQueue\n ELSE\n ? \"QueueStatus() failed :\", oWinPort:ErrorText()\n ENDIF\n IF oWinPort:Purge( .T., .T. )\n ? \"Purge() succeeded\"\n ELSE\n ? \"Purge() failed :\", oWinPort:ErrorText()\n ENDIF\n ? \"InQueue should be zero\"\n IF oWinPort:QueueStatus( @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )\n ? \"QueueStatus() : CTSHold\", lCtsHold, \", DSRHold\", lDsrHold, \", DCDHold\", lDCDHold, \", XoffHold\", lXoffHold, ;\n \", Xoff Sent \", lXoffSent, \", InQueue \", nInQueue, \", nOutQueue \", nOutQueue\n ELSE\n ? \"QueueStatus() failed :\", oWinPort:ErrorText()\n ENDIF\n ?\n ? \"Read \", oWinPort:Read( @cString, 32 ), Len( cString ), cString\n ?\n ? \"Close\", oWinPort:Close()\n ENDIF\n\n ?\n ? \"This is going to fail, so no device needed\"\n Inkey( 0 )\n\n oWinPort := win_com():Init( cPortName, WIN_CBR_9600, WIN_NOPARITY, 99, WIN_ONESTOPBIT )\n IF ! oWinPort:Open\n ? \"Open() failed :\", oWinPort:ErrorText()\n ELSE\n ? \"Open succeeded\"\n ? \"Close\", oWinPort:Close()\n ENDIF\n\n ? \"Attach a printer now ...\"\n ?\n Inkey( 0 )\n\n oWinPort := win_com():Init( cPortName, WIN_CBR_9600, WIN_NOPARITY, 8, WIN_ONESTOPBIT )\n IF ! oWinPort:Open\n ? \"Open() failed :\", oWinPort:ErrorText()\n ELSE\n ? \"Open succeeded\"\n ?\n ? oWinPort:DebugDCB( HB_WIN_COM_DBGFLOW )\n ? \"Printers will probably have CTS, DSR and DCD high, IF they are off they'll all be low\"\n IF oWinPort:Status( @lCTS, @lDSR, @lRing, @lDCD )\n ? \"Status() succeeded : CTS \", lCTS, \", DSR \", lDSR, \", Ring \", lRing, \", DCD \", lDCD\n ELSE\n ? \"Status() failed :\", oWinPort:ErrorText()\n ENDIF\n ?\n\n ? \"With no flow control the write should succeed whether printer is on or off\"\n cString := \"this is a test string \" + Replicate( \"012356789\", 30 ) + Chr( 13 ) + Chr( 10 )\n IF ( nResult := oWinPort:Write( cString ) ) == Len( cString )\n ? \"Write() succeeded\"\n ELSE\n ? \"Write() failed, returned \", nResult, \" expected \", Len( cString )\n ENDIF\n IF oWinPort:QueueStatus( @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )\n ? \"QueueStatus() : CTSHold\", lCtsHold, \", DSRHold\", lDsrHold, \", DCDHold\", lDCDHold, \", XoffHold\", lXoffHold, ;\n \", Xoff Sent \", lXoffSent, \", InQueue \", nInQueue, \", nOutQueue \", nOutQueue\n ELSE\n ? \"QueueStatus() failed :\", oWinPort:ErrorText()\n ENDIF\n\n ?\n ? \"Switch all handshaking on (normally only hardware and RTS)\"\n IF oWinPort:RTSFlow( WIN_DTR_CONTROL_HANDSHAKE )\n ? \"RTSFlow( WIN_RTS_CONTROL_HANDSHAKE ) succeeded\"\n ELSE\n ? \"RTSFlow( WIN_RTS_CONTROL_HANDSHAKE ) failed :\", oWinPort:ErrorText()\n ENDIF\n IF oWinPort:DTRFlow( WIN_DTR_CONTROL_HANDSHAKE )\n ? \"DTRFlow( WIN_DTR_CONTROL_HANDSHAKE ) succeeded\"\n ELSE\n ? \"DTRFlow( WIN_DTR_CONTROL_HANDSHAKE ) failed :\", oWinPort:ErrorText()\n ENDIF\n IF oWinPort:XonXoffFlow( .T. )\n ? \"XonXoffFlow( .T. ) \", oWinPort:XonXoffFlow( .T. )\n ELSE\n ? \"XonXoffFlow( .T. ) failed :\", oWinPort:ErrorText()\n ENDIF\n ?\n ? oWinPort:DebugDCB( HB_WIN_COM_DBGFLOW )\n\n ? \"If it's on then no Hold status should be on, IF off then probably CTS and DSR\"\n IF oWinPort:QueueStatus( @lCTSHold, @lDSRHold, @lDCDHold, @lXoffHold, @lXoffSent, @nInQueue, @nOutQueue )\n ? \"QueueStatus() : CTSHold\", lCtsHold, \", DSRHold\", lDsrHold, \", DCDHold\", lDCDHold, \", XoffHold\", lXoffHold, ;\n \", Xoff Sent \", lXoffSent, \", InQueue \", nInQueue, \", nOutQueue \", nOutQueue\n ELSE\n ? \"QueueStatus() failed :\", oWinPort:ErrorText()\n ENDIF\n ?\n ? Seconds()\n IF ( nResult := oWinPort:Write( cString ) ) == Len( cString )\n ? \"Write() succeeded\"\n ELSE\n ? \"Write() failed, returned \", nResult, \" expected \", Len( cString )\n ENDIF\n ? Seconds()\n ? \"Close\", oWinPort:Close()\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour test program: tests/gtwin.prg. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "#include \"box.ch\"\n\n#ifdef __PLATFORM__WINDOWS\n #if ! defined( __HBSCRIPT__HBSHELL )\n REQUEST HB_GT_WVT_DEFAULT\n #endif\n #define THREAD_GT \"WVT\"\n#else\n REQUEST HB_GT_STD_DEFAULT\n #define THREAD_GT \"XWC\"\n#endif\n\nproc main()\n local pGT, pGT1, pGT2\n\n#if defined( __HBSCRIPT__HBSHELL )\n #if defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVT\" )\n #elif defined( __PLATFORM__UNIX )\n hbshell_gtSelect( \"GTXWC\" )\n #endif\n#endif\n\n ? \"This is small test for using more then one console window.\"\n ? \"It needs GT which supports such functionality i.e. GTWVT in\"\n ? \"MS-Windows or GTXWC in XWindow\"\n wait\n\n ? \"Create two new GTs:\"\n pGT1 := hb_gtCreate( THREAD_GT )\n ? \"1 =>\", pGT1\n pGT2 := hb_gtCreate( THREAD_GT )\n ? \"2 =>\", pGT1\n\n pGT := hb_gtSelect( pGT1 )\n SetColor( \"W+/R\" )\n DispBox( 10, 10, 20, 50, HB_B_DOUBLE_UNI + \" \" )\n ?? \"This test is shown in 1-st GT window\"\n\n hb_gtSelect( pGT2 )\n SetColor( \"W+/B\" )\n DispBox( 15, 30, 20, 70, HB_B_DOUBLE_UNI + \" \" )\n ?? \"This test is shown in 2-nd GT window\"\n\n hb_gtSelect( pGT )\n ? \"New console window should be visible now\"\n wait\n\n ? \"Destroy 1-st window...\"\n pGT1 := NIL\n ?? \"done\"\n wait\n\n ? \"Destroy 2-nd window...\"\n pGT2 := NIL\n ?? \"done\"\n\n wait \"Press any key to exit\"\n\nreturn"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: __eInstVar52. Harbour Runtime Library file: src/rtl/einstv52.prg. Provides functions: __eInstVar52. This file provides utility functions"}, {"role": "assistant", "content": "#include \"error.ch\"\n\n\nFUNCTION __eInstVar52( oVar, cMethod, xValue, cType, nSubCode, xMin, xMax )\n\n LOCAL oError\n LOCAL lError\n\n IF ValType( xValue ) == cType\n lError := .F.\n IF xMin != NIL\n lError := ! xValue >= xMin\n ENDIF\n \n IF xMax != NIL\n lError := ! xValue <= xMax\n ENDIF\n ELSE\n lError := .T.\n ENDIF\n\n IF lError\n oError := ErrorNew()\n oError:description := hb_langErrMsg( EG_ARG )\n oError:gencode := EG_ARG\n oError:severity := ES_ERROR\n oError:cansubstitute := .T.\n oError:subsystem := oVar:className\n#ifdef HB_CLP_STRICT\n HB_SYMBOL_UNUSED( cMethod )\n#else\n oError:operation := cMethod\n#endif\n oError:subcode := nSubCode\n oError:args := { xValue }\n xValue := Eval( ErrorBlock(), oError )\n IF ! ValType( xValue ) == cType\n __errInHandler()\n ENDIF\n ENDIF\n\n RETURN xValue"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/rangerem.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of RangeRem()\"\n ?\n\n ? ' RangeRem( \"0\", \"9\", \"year2002.dbf\" ) == \"year.dbf\" ? --> \"' + ;\n RangeRem( \"0\", \"9\", \"year2002.dbf\" ) + '\"'\n ? ' RangeRem( \"9\", \"0\", \"year2002.dbf\" ) == \"22\" ? --> \"' + ;\n RangeRem( \"9\", \"0\", \"year2002.dbf\" ) + '\"'\n ? ' RangeRem( \"0\", \"9\", \"yearcurr.dbf\" ) == \"yearcurr.dbf\" ? --> \"' + ;\n RangeRem( \"0\", \"9\", \"yearcurr.dbf\" ) + '\"'\n\n ?\n ? \"End test of RangeRem()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHeader file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hblog.ch. Defines 8 constants including: HB_LOG_CH, HB_LOG_ALL, HB_LOG_ST_DATE, HB_LOG_ST_TIME, HB_LOG_ST_SECS. Declares 5 preprocessor commands. Declares 5 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_LOG_CH\n#define HB_LOG_CH\n\n#include \"hblogdef.ch\"\n\n\n#define HB_LOG_ALL 9999\n\n#define HB_LOG_ST_DATE 0x0001\n#define HB_LOG_ST_TIME 0x0002\n#define HB_LOG_ST_SECS 0x0004\n#define HB_LOG_ST_LEVEL 0x0008\n#define HB_LOG_ST_ISODATE 0x0010\n#define HB_LOG_ST_NAME 0x0020\n\n#xcommand INIT LOG [ON] ;\n [ ([ [,[,[,]]]])] ;\n [ ([])] ;\n [ ([[,]])] ;\n [ ([[,]])] ;\n [ ([ [,[,[,[,[,]]]]]])] ;\n [ ( [ [,]] )] ;\n [NAME ] => ;\n hb_InitStandardLog() ;;\n IF <.con.> ;;\n hb_StandardLogAdd( HB_LogConsole():New( ));;\n END ;;\n IF <.fil.> ;;\n hb_StandardLogAdd( HB_LogFile():New( , , , ));;\n END ;;\n IF <.mon.> ;;\n hb_StandardLogAdd( HB_LogInetPort():New( , ));;\n END ;;\n IF <.sys.> ;;\n hb_StandardLogAdd( HB_LogSysLog():New( , ));;\n END ;;\n IF <.ema.> ;;\n hb_StandardLogAdd( HB_LogEmail():New( ,,,,,));;\n END ;;\n IF <.dbg.> ;;\n hb_StandardLogAdd( HB_LogDebug():New( , ) ) ;;\n END ;;\n hb_StandardLogName( );;\n hb_OpenStandardLog()\n\n\n#xcommand SET LOG STYLE => hb_SetStandardLogStyle( )\n\n#xcommand LOG [PRIORITY ] => ;\n hb_StandardLog( hb_BldLogMsg( ), )\n#xcommand LOG [PRIO ] => ;\n hb_StandardLog( hb_BldLogMsg( ), )\n\n#xcommand CLOSE LOG => hb_CloseStandardLog()\n\n#xtranslate PRIO[RITY] DEFAULT => PRIO HB_LOG_DEFAULT\n#xtranslate PRIO[RITY] CRITICAL => PRIO HB_LOG_CRITICAL\n#xtranslate PRIO[RITY] ERROR => PRIO HB_LOG_ERROR\n#xtranslate PRIO[RITY] WARNING => PRIO HB_LOG_WARNING\n#xtranslate PRIO[RITY] WARN => PRIO HB_LOG_WARN\n#xtranslate PRIO[RITY] INFO => PRIO HB_LOG_INFO\n#xtranslate PRIO[RITY] DEBUG => PRIO HB_LOG_DEBUG\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/delim.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL nCount := 0\n\n USE test NEW\n \n COPY TO test1 DELIMITED\n\n \n COPY FIELD first, last, street, city, state, zip TO test2 DELIMITED FOR _field->salary > 50000\n\n \n COPY RECORD 3 TO test3 DELIMITED\n\n \n COPY NEXT 4 TO test4 DELIMITED\n\n \n GO BOTTOM\n SKIP -4\n COPY WHILE ncount++ < 9 TO test4a DELIMITED\n\n \n GO BOTTOM\n SKIP -9\n COPY REST TO test5 DELIMITED\n\n \n GO BOTTOM\n SKIP -9\n COPY TO test6 DELIMITED WHILE ! Eof()\n\n \n GO BOTTOM\n SKIP -9\n COPY REST TO test7 DELIMITED FOR _field->married\n\n \n DELETE FILE test8.txt\n APPEND FROM test8 DELIMITED\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/service.prg. Contains procedures: Main, SrvMain, Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#if ! defined( __HBSCRIPT__HBSHELL )\n\n#define _SERVICE_NAME \"Harbour_Test_Service\"\n\nPROCEDURE Main( cMode )\n\n LOCAL nError\n LOCAL cMsg\n\n hb_default( @cMode, \"S\" ) \n\n SWITCH Upper( cMode )\n CASE \"I\"\n\n IF win_serviceInstall( _SERVICE_NAME, \"Harbour Windows Test Service\" )\n ? \"Service has been successfully installed\"\n ELSE\n nError := wapi_GetLastError()\n cMsg := Space( 128 )\n wapi_FormatMessage( ,,,, @cMsg )\n ? \"Error installing service: \" + hb_ntos( nError ) + \" \" + cMsg\n ENDIF\n EXIT\n\n CASE \"U\"\n\n IF win_serviceDelete( _SERVICE_NAME )\n ? \"Service has been deleted\"\n ELSE\n nError := wapi_GetLastError()\n cMsg := Space( 128 )\n wapi_FormatMessage( ,,,, @cMsg )\n ? \"Error deleting service: \" + hb_ntos( nError ) + \" \" + cMsg\n ENDIF\n EXIT\n\n CASE \"S\"\n\n \n IF win_serviceStart( _SERVICE_NAME, @SrvMain() )\n ? \"Service has started OK\"\n ELSE\n nError := wapi_GetLastError()\n cMsg := Space( 128 )\n wapi_FormatMessage( ,,,, @cMsg )\n ? \"Service has had some problems: \" + hb_ntos( nError ) + \" \" + cMsg\n ENDIF\n EXIT\n\n ENDSWITCH\n\n RETURN\n\n#include \"fileio.ch\"\n\nPROCEDURE SrvMain( cParam1, cParam2 )\n\n LOCAL n := 0\n LOCAL fhnd := hb_FCreate( hb_FNameExtSet( hb_ProgName(), \".out\" ), FC_NORMAL, FO_DENYNONE + FO_WRITE )\n LOCAL cParam\n\n hb_default( @cParam1, \"\" )\n hb_default( @cParam2, \"\" )\n\n FWrite( fhnd, \"Startup\" + hb_eol() )\n FWrite( fhnd, \"|\" + hb_CmdLine() + \"|\" + hb_eol() )\n FWrite( fhnd, \"|\" + cParam1 + \"|\" + cParam2 + \"|\" + hb_eol() )\n\n FOR EACH cParam IN hb_AParams()\n FWrite( fhnd, \"Parameter \" + hb_ntos( cParam:__enumIndex() ) + \" >\" + cParam + \"<\" + hb_eol() )\n NEXT\n\n DO WHILE win_serviceGetStatus() == WIN_SERVICE_RUNNING\n FWrite( fhnd, \"Work in progress \" + hb_ntos( ++n ) + hb_eol() )\n hb_idleSleep( 0.5 )\n ENDDO\n\n FWrite( fhnd, \"Exiting...\" + hb_eol() )\n FClose( fhnd )\n\n win_serviceSetExitCode( 0 )\n win_serviceStop()\n\n RETURN\n\n#else\n\nPROCEDURE Main()\n\n ? \"Cannot be used in script mode.\"\n\n RETURN\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/tempfile.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#include \"fileio.ch\"\n\nPROCEDURE Main( cPath, cHide )\n\n LOCAL cFile, nHandle\n\n cFile := ft_TempFil( cPath, cHide == \"Y\" )\n\n IF ! Empty( cFile )\n ? cFile\n nHandle := FOpen( cFile, FO_WRITE )\n FWrite( nHandle, \"This is a test!\" )\n FClose( nHandle )\n ELSE\n ? \"An error occurred\"\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'hbmagic': contrib/hbmagic/hbmagic.ch. Defines 10 constants including: HBMAGIC_CH_, MAGIC_NONE, MAGIC_DEBUG, MAGIC_SYMLINK, MAGIC_COMPRESS. Defines keyboard input constants"}, {"role": "assistant", "content": "#ifndef HBMAGIC_CH_\n#define HBMAGIC_CH_\n\n#define MAGIC_NONE 0x000000 \n#define MAGIC_DEBUG 0x000001 \n#define MAGIC_SYMLINK 0x000002 \n#define MAGIC_COMPRESS 0x000004 \n#define MAGIC_DEVICES 0x000008 \n#define MAGIC_MIME_TYPE 0x000010 \n#define MAGIC_CONTINUE 0x000020 \n#define MAGIC_CHECK 0x000040 \n#define MAGIC_PRESERVE_ATIME 0x000080 \n#define MAGIC_RAW 0x000100 \n#define MAGIC_ERROR 0x000200 \n#define MAGIC_MIME_ENCODING 0x000400 \n#define MAGIC_MIME hb_bitOr( MAGIC_MIME_TYPE, MAGIC_MIME_ENCODING )\n#define MAGIC_APPLE 0x000800 \n#define MAGIC_NO_CHECK_COMPRESS 0x001000 \n#define MAGIC_NO_CHECK_TAR 0x002000 \n#define MAGIC_NO_CHECK_SOFT 0x004000 \n#define MAGIC_NO_CHECK_APPTYPE 0x008000 \n#define MAGIC_NO_CHECK_ELF 0x010000 \n#define MAGIC_NO_CHECK_TEXT 0x020000 \n#define MAGIC_NO_CHECK_CDF 0x040000 \n#define MAGIC_NO_CHECK_TOKENS 0x100000 \n#define MAGIC_NO_CHECK_ENCODING 0x200000 \n\n\n#define MAGIC_NO_CHECK_ASCII MAGIC_NO_CHECK_TEXT\n\n\n#define MAGIC_NO_CHECK_FORTRAN 0x000000 \n#define MAGIC_NO_CHECK_TROFF 0x000000 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbcomm' (Serial communication library): contrib/hbcomm/comm.prg. Provides 8 functions including: INIT_PORT, OUTBUFCLR, ISWORKING, INCHR, OUTCHR. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbcom.ch\"\n\nSTATIC s_hPort := { => }\nSTATIC s_hbcomm_mutex := hb_mutexCreate()\n\nFUNCTION INIT_PORT( cPort, nBaud, nData, nParity, nStop, nBufferSize )\n\n LOCAL nPort\n LOCAL cOldPortName\n LOCAL cParity\n\n hb_mutexLock( s_hbcomm_mutex )\n\n \n nPort := Len( s_hPort ) + 1\n\n IF HB_ISSTRING( cPort )\n cOldPortName := hb_comGetDevice( nPort )\n hb_comSetDevice( nPort, cPort )\n ENDIF\n\n hb_comClose( nPort )\n\n IF hb_comOpen( nPort )\n\n hb_default( @nBaud, 9600 )\n\n cParity := \"N\"\n IF HB_ISNUMERIC( nParity )\n SWITCH nParity\n CASE 0 ; cParity := \"N\" ; EXIT\n CASE 1 ; cParity := \"O\" ; EXIT\n CASE 2 ; cParity := \"M\" ; EXIT\n CASE 3 ; cParity := \"E\" ; EXIT\n ENDSWITCH\n ENDIF\n\n hb_default( @nStop, 1 )\n\n HB_SYMBOL_UNUSED( nBufferSize )\n\n IF hb_comInit( nPort, nBaud, cParity, nData, nStop )\n s_hPort[ nPort ] := cOldPortName\n hb_mutexUnlock( s_hbcomm_mutex )\n RETURN nPort\n ELSE\n hb_comClose( nPort )\n ENDIF\n ENDIF\n\n IF cOldPortName != NIL\n hb_comSetDevice( nPort, cOldPortName )\n ENDIF\n\n hb_mutexUnlock( s_hbcomm_mutex )\n\n RETURN 0\n\n\nFUNCTION OUTBUFCLR( nPort )\n RETURN hb_comFlush( nPort, HB_COM_OFLUSH )\n\n\nFUNCTION ISWORKING( nPort )\n RETURN nPort $ s_hPort\n\n\nFUNCTION INCHR( nPort, nCount, cData )\n\n cData := iif( HB_ISNUMERIC( nCount ), Space( nCount ), \"\" )\n\n RETURN hb_comRecv( nPort, @cData, nCount )\n\n\nFUNCTION OUTCHR( nPort, cData )\n\n LOCAL nLen\n\n DO WHILE hb_BLen( cData ) > 0\n\n \n nLen := hb_comSend( nPort, cData,, 1000 )\n\n IF nLen <= 0\n RETURN .F.\n ENDIF\n\n cData := hb_BSubStr( cData, nLen + 1 )\n ENDDO\n\n RETURN .T.\n\n\nFUNCTION INBUFSIZE( nPort )\n RETURN hb_comInputCount( nPort )\n\n\nFUNCTION OUTBUFSIZE( nPort )\n RETURN hb_comOutputCount( nPort )\n\n\nFUNCTION UNINT_PORT( nPort )\n\n LOCAL lRetVal := .F.\n\n hb_mutexLock( s_hbcomm_mutex )\n\n IF nPort $ s_hPort\n IF hb_comClose( nPort )\n \n IF s_hPort[ nPort ] != NIL\n hb_comSetDevice( nPort, s_hPort[ nPort ] )\n ENDIF\n hb_HDel( s_hPort, nPort )\n lRetVal := .T.\n ENDIF\n ENDIF\n\n hb_mutexUnlock( s_hbcomm_mutex )\n\n RETURN lRetVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/rddtest/ntxcl52.prg. Provides functions: test_main. This test file tests specific function APIs"}, {"role": "assistant", "content": "REQUEST dbfntx\n#define _TESTRDD \"dbfntx\"\n#include \"rddtst.prg\"\n\nFUNCTION test_main()\n\nRDDTESTC {0,.t.,.t.,.f.}, LOCAL n\nRDDTESTF \"DBFNTX\", {0,.t.,.t.,.f.}, RDDSETDEFAULT()\nRDDTESTC {1,.t.,.t.,.f.}, USE \"_tst\" SHARED\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE OFF\nRDDTESTC {1,.t.,.t.,.f.}, INDEX on FNUM to TG_N\nRDDTESTC {1,.t.,.t.,.f.}, INDEX on FSTR to TG_C\nRDDTESTF \"TG_C\", {1,.t.,.t.,.f.}, ORDSETFOCUS()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .F.,.F.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .F.,.T.)\nRDDTESTC {1,.t.,.t.,.f.}, SET DELETE OFF\nRDDTESTC {15,.f.,.f.,.f.}, for n:=1 to 15 ; dbappend() ; replace FNUM with int((n+2)/3) ; replace FSTR with chr(FNUM+48) ; next\nRDDTESTF NIL, {15,.f.,.f.,.f.}, dbcommit()\nRDDTESTF NIL, {15,.f.,.f.,.f.}, dbunlock()\nRDDTESTF \"TG_C\", {15,.f.,.f.,.f.}, ORDSETFOCUS(1)\nRDDTESTF \"TG_C\", {15,.f.,.f.,.f.}, ORDSETFOCUS()\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0,.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0.5,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0.5,.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(1.0,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(1.0,.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(2.0,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(2.0,.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(2.5,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(2.5,.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(5.0,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(5.0,.T.,.T.)\nRDDTESTF \"TG_C\", {16,.f.,.t.,.f.}, ORDSETFOCUS(2)\nRDDTESTF \"TG_C\", {16,.f.,.t.,.f.}, ORDSETFOCUS()\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTC {13,.f.,.f.,.f.}, INDEX on FSTR to TG_C DESCEND\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTC {1,.f.,.f.,.f.}, INDEX on FSTR to TG_C\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {2,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {10,.f.,.f.,.f.}, DBSKIP(-5)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(10)\nRDDTESTF NIL, {11,.f.,.f.,.f.}, DBSKIP(-5)\nRDDTESTF NIL, {16,.t.,.t.,.f.}, DBGOTO(16)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {2,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {4,.f.,.f.,.f.}, DBGOTO(4)\nRDDTESTF NIL, {5,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {4,.f.,.f.,.f.}, DBGOTO(4)\nRDDTESTF NIL, {3,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBGOTO(6)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBGOTO(6)\nRDDTESTF NIL, {5,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBGOTO(7)\nRDDTESTF NIL, {8,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBGOTO(7)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBGOTO(12)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBGOTO(12)\nRDDTESTF NIL, {11,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBGOTO(13)\nRDDTESTF NIL, {14,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBGOTO(13)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {14,.f.,.f.,.f.}, DBGOTO(14)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {16,.t.,.t.,.f.}, DBGOTO(16)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF \"TG_C\", {15,.f.,.f.,.f.}, ORDSETFOCUS(0)"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/mail.prg. Defines classes: TIPMail. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"fileio.ch\"\n\nCREATE CLASS TIPMail\n\n VAR hHeaders\n \n VAR aReceived INIT {}\n\n METHOD New( cBody, xEncoder ) CONSTRUCTOR\n METHOD SetBody( cBody )\n METHOD GetBody()\n METHOD GetRawBody() INLINE ::cBody\n METHOD SetEncoder( xEncoder )\n\n METHOD FromString( cMail, cBoundary, nPos )\n METHOD HeadersToString()\n METHOD ToString()\n\n METHOD GetFieldPart( cPart )\n METHOD GetFieldOption( cPart, cOption )\n METHOD SetFieldPart( cPart, cValue )\n METHOD SetFieldOption( cPart, cOption, cValue )\n METHOD SetCharset( cCharset ) INLINE ::cCharset := hb_defaultValue( cCharset, \"UTF-8\" )\n\n METHOD GetContentType() INLINE ::GetFieldPart( \"Content-Type\" )\n METHOD GetCharEncoding() INLINE ::GetFieldOption( \"Content-Type\", \"encoding\" )\n\n METHOD Attach( oSubPart )\n METHOD NextAttachment()\n METHOD CountAttachments() INLINE Len( ::aAttachments )\n METHOD GetAttachment()\n METHOD ResetAttachment() INLINE ::nAttachPos := 1\n\n METHOD MakeBoundary()\n\n METHOD isMultiPart()\n METHOD getMultiParts( aParts )\n\n METHOD setHeader( cSubject, cFrom, xTo, xCC )\n METHOD attachFile( cFileName )\n METHOD detachFile( cPath )\n METHOD getFileName()\n\n HIDDEN:\n\n VAR cBody\n VAR lBodyEncoded INIT .F.\n VAR oEncoder\n VAR aAttachments\n VAR nAttachPos INIT 1\n VAR cCharset\n\nENDCLASS\n\nMETHOD New( cBody, xEncoder ) CLASS TIPMail\n\n ::hHeaders := { => }\n hb_HCaseMatch( ::hHeaders, .F. )\n ::aAttachments := {}\n\n ::setEncoder( xEncoder )\n ::setBody( cBody )\n ::SetCharset()\n\n RETURN Self\n\nMETHOD SetEncoder( xEncoder ) CLASS TIPMail\n\n ::oEncoder := iif( HB_ISSTRING( xEncoder ), tip_GetEncoder( xEncoder ), xEncoder )\n\n IF HB_ISOBJECT( ::oEncoder )\n ::hHeaders[ \"Content-Transfer-Encoding\" ] := ::oEncoder:cName\n RETURN .T.\n ENDIF\n\n RETURN .F.\n\nMETHOD SetBody( cBody ) CLASS TIPMail\n\n IF HB_ISOBJECT( ::oEncoder )\n ::cBody := ::oEncoder:Encode( cBody )\n ::hHeaders[ \"Content-Transfer-Encoding\" ] := ::oEncoder:cName\n ::lBodyEncoded := .T. \n ELSEIF HB_ISSTRING( cBody ) .OR. cBody == NIL\n ::cBody := cBody\n ENDIF\n\n RETURN .T.\n\nMETHOD GetBody() CLASS TIPMail\n RETURN iif( HB_ISOBJECT( ::oEncoder ), ::oEncoder:Decode( ::cBody ), ::cBody )\n\nMETHOD GetFieldPart( cPart ) CLASS TIPMail\n\n LOCAL nPos\n LOCAL cEnc\n\n IF hb_HGetRef( ::hHeaders, cPart, @cEnc )\n IF ( nPos := At( \";\", cEnc ) ) > 0\n cEnc := Left( cEnc, nPos - 1 )\n ENDIF\n RETURN cEnc\n ENDIF\n\n RETURN \"\"\n\nMETHOD GetFieldOption( cPart, cOption ) CLASS TIPMail\n\n LOCAL aMatch\n LOCAL cEnc\n\n IF hb_HGetRef( ::hHeaders, cPart, @cEnc ) .AND. ;\n ! Empty( aMatch := hb_regex( \";\\s*\" + cOption + \"\\s*=\\s*([^;]*)\", cEnc, .F. ) )\n RETURN aMatch[ 2 ]\n ENDIF\n\n RETURN \"\"\n\nMETHOD SetFieldPart( cPart, cValue ) CLASS TIPMail\n\n LOCAL nPos\n LOCAL cEnc\n\n IF HB_ISSTRING( cValue ) .AND. ! Empty( cValue )\n IF hb_HGetRef( ::hHeaders, cPart, @cEnc ) .AND. ;\n ( nPos := At( \";\", cEnc ) ) > 0\n ::hHeaders[ cPart ] := cValue + SubStr( cEnc, nPos )\n ELSE\n ::hHeaders[ cPart ] := cValue\n ENDIF\n ENDIF\n\n RETURN .T.\n\nMETHOD SetFieldOption( cPart, cOption, cValue ) CLASS TIPMail\n\n LOCAL aMatch\n\n IF HB_ISSTRING( cPart ) .AND. cPart $ ::hHeaders .AND. ;\n HB_ISSTRING( cOption ) .AND. ! Empty( cOption )\n\n aMatch := hb_regex( \"(.*?;\\s*)\" + cOption + \"\\s*=[^;]*(.*)?\", ::hHeaders[ cPart ], .F. )\n\n IF Empty( aMatch )\n ::hHeaders[ cPart ] += \"; \" + cOption + \"=\" + '\"' + cValue + '\"'\n ELSE\n ::hHeaders[ cPart ] := aMatch[ 2 ] + cOption + \"=\" + '\"' + cValue + '\"' + aMatch[ 3 ]\n ENDIF\n\n RETURN .T.\n ENDIF\n\n RETURN .F.\n\nMETHOD Attach( oSubPart ) CLASS TIPMail\n\n IF HB_ISOBJECT( oSubPart ) .AND. oSubPart:ClassName() == \"TIPMAIL\"\n \n IF ! ::isMultiPart()\n ::hHeaders[ \"Content-Type\" ] := \"multipart/mixed\"\n ENDIF\n\n AAdd( ::aAttachments, oSubPart )\n RETURN .T.\n ENDIF\n\n RETURN .F.\n\nMETHOD NextAttachment() CLASS TIPMail\n\n IF ::nAttachPos > Len( ::aAttachments )\n RETURN NIL\n ENDIF\n\n RETURN ::aAttachments[ ::nAttachPos++ ]\n\nMETHOD GetAttachment() CLASS TIPMail\n\n IF ::nAttachPos > Len( ::aAttachments )\n RETURN NIL\n ENDIF\n\n RETURN ::aAttachments[ ::nAttachPos ]\n\nMETHOD HeadersToString() CLASS TIPMail\n\n LOCAL cRet := \"\"\n LOCAL cElem, i\n\n \n FOR EACH cElem IN { \"Return-Path\", \"Delivered-To\" }\n IF cElem $ ::hHeaders\n cRet += cElem + \": \" + ::hHeaders[ cElem ] + e\"\\r\\n\"\n ENDIF\n NEXT\n\n FOR EACH cElem IN ::aReceived\n cRet += \"Received: \" + cElem + e\"\\r\\n\"\n NEXT\n\n FOR EACH cElem IN { \"Date\", \"From\", \"To\", \"Subject\" }\n IF cElem $ ::hHeaders\n cRet += cElem + \": \" + ::hHeaders[ cElem ] + e\"\\r\\n\"\n ENDIF\n NEXT\n\n IF ! Empty( ::aAttachments )\n cRet += \"Mime-Version: \" + ::hHeaders[ \"Mime-Version\" ] + e\"\\r\\n\"\n ENDIF\n\n FOR EACH i IN ::hHeaders\n SWITCH Lower( cElem := i:__enumKey() )\n CASE \"return-path\"\n CASE \"delivered-to\"\n CASE \"date\"\n CASE \"from\"\n CASE \"to\"\n CASE \"subject\"\n CASE \"mime-version\"\n EXIT\n OTHERWISE\n cRet += cElem + \": \" + i + e\"\\r\\n\"\n ENDSWITCH\n NEXT\n\n RETURN cRet\n\nMETHOD ToString() CLASS TIPMail\n\n LOCAL cBoundary, i\n LOCAL cRet\n\n \n IF ! Empty( ::aAttachments )\n ::hHeaders[ \"Mime-Version\" ] := \"1.0\"\n\n \n IF ! ::isMultiPart()\n ::hHeaders[ \"Content-Type\" ] := \"multipart/mixed\"\n ENDIF\n\n \n cBoundary := ::GetFieldOption( \"Content-Type\", \"Boundary\" )\n IF Empty( cBoundary )\n cBoundary := ::MakeBoundary()\n IF ! ::SetFieldOption( \"Content-Type\", \"Boundary\", cBoundary )\n ::hHeaders[ \"Content-Type\" ] := \"multipart/mixed; boundary=\" + '\"' + cBoundary + '\"'\n ENDIF\n ENDIF\n ENDIF\n\n \n cRet := ::HeadersToString() + e\"\\r\\n\"\n\n \n IF ::cBody != NIL .AND. ! ::cBody == \"\"\n IF Empty( ::aAttachments )\n cRet += ::cBody + iif( ::lBodyEncoded, \"\", e\"\\r\\n\" )\n ELSE\n \n cRet += ;\n \"--\" + cBoundary + e\"\\r\\n\" + ;\n \"Content-Disposition: inline\" + e\"\\r\\n\" + ;\n \"Content-Type: text/plain; charset=\" + ::cCharset + \"; format=flowed\" + e\"\\r\\n\" + ;\n \"Content-Transfer-Encoding: 7bit\" + e\"\\r\\n\" + ;\n e\"\\r\\n\" + ;\n ::cBody + ;\n e\"\\r\\n\"\n ENDIF\n ENDIF\n\n IF ! Empty( ::aAttachments )\n \n FOR EACH i IN ::aAttachments\n cRet += \"--\" + cBoundary + e\"\\r\\n\" + i:ToString() + e\"\\r\\n\"\n NEXT\n cRet += \"--\" + cBoundary + \"--\" + e\"\\r\\n\"\n ENDIF\n\n RETURN cRet\n\nMETHOD FromString( cMail, cBoundary, nPos ) CLASS TIPMail\n\n LOCAL oSubSection, cSubBoundary\n LOCAL nLinePos, nSplitPos, nBodyPos\n LOCAL cValue, cLastField\n\n IF ! HB_ISSTRING( cMail )\n RETURN 0\n ENDIF\n\n IF Len( ::aAttachments ) > 0\n ::aAttachments := {}\n ENDIF\n\n IF Len( ::hHeaders ) > 0\n ::hHeaders := { => }\n hb_HCaseMatch( ::hHeaders, .F. )\n ENDIF\n\n IF Len( ::aReceived ) > 0\n ::aReceived := {}\n ENDIF\n\n \n hb_default( @nPos, 1 )\n\n DO WHILE ( nLinePos := hb_At( e\"\\r\\n\", cMail, nPos ) ) > nPos\n \n IF ( SubStr( cMail, nPos, 1 ) == \" \" .OR. SubStr( cMail, nPos, 1 ) == e\"\\t\" ) .AND. ;\n cLastField != NIL\n\n cValue := LTrim( SubStr( cMail, nPos, nLinePos - nPos ) )\n IF Lower( cLastField ) == \"received\"\n ::aReceived[ Len( ::aReceived ) ] += \" \" + cValue\n ELSE\n ::hHeaders[ cLastField ] += \" \" + cValue\n ENDIF\n ELSE\n nSplitPos := hb_At( \":\", cMail, nPos )\n cLastField := SubStr( cMail, nPos, nSplitPos - nPos )\n cValue := LTrim( SubStr( cMail, nSplitPos + 1, nLinePos - nSplitPos - 1 ) )\n IF Lower( cLastField ) == \"received\"\n AAdd( ::aReceived, cValue )\n ELSE\n ::hHeaders[ cLastField ] := cValue\n ENDIF"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour test program: tests/rddtest/cdxcl52.prg. Provides functions: test_main. This test file tests specific function APIs"}, {"role": "assistant", "content": "REQUEST dbfcdx\n#define _TESTRDD \"dbfcdx\"\n#include \"rddtst.prg\"\n\nFUNCTION test_main()\n\nRDDTESTC {0,.t.,.t.,.f.}, LOCAL n\nRDDTESTF \"DBFCDX\", {0,.t.,.t.,.f.}, RDDSETDEFAULT()\nRDDTESTC {1,.t.,.t.,.f.}, USE \"_tst\" SHARED\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE OFF\nRDDTESTC {1,.t.,.t.,.f.}, INDEX on FNUM tag TG_N to \"_tst\"\nRDDTESTC {1,.t.,.t.,.f.}, INDEX on FSTR tag TG_C to \"_tst\"\nRDDTESTF \"TG_C\", {1,.t.,.t.,.f.}, ORDSETFOCUS()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .F.,.F.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .F.,.T.)\nRDDTESTC {1,.t.,.t.,.f.}, SET DELETE OFF\nRDDTESTC {15,.f.,.f.,.f.}, for n:=1 to 15 ; dbappend() ; replace FNUM with int((n+2)/3) ; replace FSTR with chr(FNUM+48) ; next\nRDDTESTF NIL, {15,.f.,.f.,.f.}, dbcommit()\nRDDTESTF NIL, {15,.f.,.f.,.f.}, dbunlock()\nRDDTESTF \"TG_C\", {15,.f.,.f.,.f.}, ORDSETFOCUS(1)\nRDDTESTF \"TG_N\", {15,.f.,.f.,.f.}, ORDSETFOCUS()\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0,.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0.5,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0.5,.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(1.0,.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(1.0,.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(2.0,.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(2.0,.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(2.5,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(2.5,.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(5.0,.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(5.0,.T.,.T.)\nRDDTESTF \"TG_N\", {13,.f.,.f.,.t.}, ORDSETFOCUS(2)\nRDDTESTF \"TG_C\", {13,.f.,.f.,.t.}, ORDSETFOCUS()\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTC {15,.f.,.f.,.f.}, INDEX on FSTR tag TG_C to \"_tst\" DESCEND\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {3,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {3,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTC {1,.f.,.f.,.f.}, INDEX on FSTR tag TG_C to \"_tst\"\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {2,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {10,.f.,.f.,.f.}, DBSKIP(-5)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(10)\nRDDTESTF NIL, {11,.f.,.f.,.f.}, DBSKIP(-5)\nRDDTESTF NIL, {16,.t.,.t.,.f.}, DBGOTO(16)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {2,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {4,.f.,.f.,.f.}, DBGOTO(4)\nRDDTESTF NIL, {5,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {4,.f.,.f.,.f.}, DBGOTO(4)\nRDDTESTF NIL, {3,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBGOTO(6)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBGOTO(6)\nRDDTESTF NIL, {5,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBGOTO(7)\nRDDTESTF NIL, {8,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBGOTO(7)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBGOTO(12)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBGOTO(12)\nRDDTESTF NIL, {11,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBGOTO(13)\nRDDTESTF NIL, {14,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBGOTO(13)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {14,.f.,.f.,.f.}, DBGOTO(14)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {16,.t.,.t.,.f.}, DBGOTO(16)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour Runtime Library file: src/rtl/tgetlist.prg. Defines classes: HBGetList. This file implements object-oriented classes using Harbour's class system"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"button.ch\"\n#include \"getexit.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n#include \"tbrowse.ch\"\n\n#define SCORE_ROW 0\n#define SCORE_COL 60\n\n#define _GET_INSERT_ON 7\n#define _GET_INSERT_OFF 8\n#define _GET_INVD_DATE 9\n\n#define K_UNDO K_CTRL_U\n\n#define MSGFLAG 1\n#define MSGROW 2\n#define MSGLEFT 3\n#define MSGRIGHT 4\n#define MSGCOLOR 5\n\nCREATE CLASS HBGetList\n\n EXPORTED:\n\n VAR HasFocus AS LOGICAL INIT .F.\n\n#ifdef HB_COMPAT_C53\n METHOD ReadModal( nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )\n#else\n METHOD ReadModal()\n#endif\n METHOD Settle( nPos, lInit )\n METHOD Reader( oMenu, aMsg )\n METHOD GetApplyKey( nKey, oGet, oMenu, aMsg )\n METHOD GetPreValidate( oGet, aMsg )\n METHOD GetPostValidate( oGet, aMsg )\n METHOD GetDoSetKey( bKeyBlock, oGet )\n METHOD PostActiveGet()\n METHOD GetReadVar()\n METHOD SetFormat( bFormat )\n METHOD KillRead( lKill )\n METHOD GetActive( oGet )\n METHOD DateMsg()\n METHOD ShowScoreBoard()\n METHOD ReadUpdated( lUpdated )\n METHOD ReadVar( cNewVarName )\n METHOD SetFocus()\n METHOD Updated() \n METHOD Get() \n\n#ifdef HB_COMPAT_C53\n METHOD GUIReader( oGet, oMenu, aMsg )\n METHOD GUIApplyKey( oGet, oGUI, nKey, oMenu, aMsg )\n METHOD GUIPreValidate( oGet, oGUI, aMsg )\n METHOD GUIPostValidate( oGet, oGUI, aMsg )\n METHOD TBApplyKey( oGet, oTB, nKey, oMenu, aMsg )\n METHOD TBReader( oGet, oMenu, aMsg )\n METHOD Accelerator( nKey, aMsg )\n METHOD hitTest( nMRow, nMCol, aMsg )\n#endif\n METHOD ReadStats( nElement, xNewValue )\n METHOD ShowGetMsg( oGet, aMsg )\n METHOD EraseGetMsg( aMsg )\n\n METHOD Init( GetList )\n\n PROTECTED:\n\n VAR oGet\n VAR aGetList\n\n VAR lUpdated AS LOGICAL INIT .F.\n VAR bFormat\n VAR lKillRead AS LOGICAL INIT .F.\n VAR lBumpTop AS LOGICAL INIT .F.\n VAR lBumpBot AS LOGICAL INIT .F.\n VAR nLastExitState INIT 0\n VAR nLastPos AS NUMERIC INIT 0\n VAR oActiveGet\n VAR xReadVar\n VAR cVarName\n VAR cReadProcName AS CHARACTER INIT \"\"\n VAR nReadProcLine INIT 0\n VAR nNextGet INIT 0\n VAR nHitCode AS NUMERIC INIT 0\n VAR nPos AS NUMERIC INIT 1\n VAR cMsgSaveS\n VAR nMenuID\n VAR nSaveCursor\n\nENDCLASS\n\n\n#ifdef HB_COMPAT_C53\nMETHOD ReadModal( nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor ) CLASS HBGetList\n#else\nMETHOD ReadModal() CLASS HBGetList\n#endif\n\n#ifdef HB_COMPAT_C53\n LOCAL lMsgFlag\n LOCAL aMsg\n#endif\n\n#ifdef HB_COMPAT_C53\n ::nSaveCursor := SetCursor( SC_NONE )\n#endif\n ::cReadProcName := ProcName( 2 )\n ::nReadProcLine := ProcLine( 2 )\n\n#ifdef HB_COMPAT_C53\n ::nPos := ::Settle( hb_defaultValue( nPos, 0 ), .T. )\n\n IF ( lMsgFlag := HB_ISNUMERIC( nMsgRow ) .AND. ;\n HB_ISNUMERIC( nMsgLeft ) .AND. ;\n HB_ISNUMERIC( nMsgRight ) )\n\n IF ! HB_ISSTRING( cMsgColor )\n cMsgColor := GetClrPair( SetColor(), 1 )\n ENDIF\n\n Scroll( nMsgRow, nMsgLeft, nMsgRow, nMsgRight )\n\n ::cMsgSaveS := SaveScreen( nMsgRow, nMsgLeft, nMsgRow, nMsgRight )\n ENDIF\n\n ::nNextGet := 0\n ::nHitCode := 0\n ::nMenuID := 0\n\n aMsg := { lMsgFlag, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, , , , , }\n#else\n ::nPos := ::Settle( 0 )\n#endif\n\n DO WHILE ::nPos != 0\n\n ::oGet := ::aGetList[ ::nPos ]\n ::PostActiveGet()\n\n#ifdef HB_COMPAT_C53\n IF HB_ISEVALITEM( ::oGet:reader )\n Eval( ::oGet:reader, ::oGet, Self, oMenu, aMsg )\n ELSE\n ::Reader( oMenu, aMsg )\n ENDIF\n#else\n IF HB_ISEVALITEM( ::oGet:reader )\n Eval( ::oGet:reader, ::oGet )\n ELSE\n ::Reader()\n ENDIF\n#endif\n\n ::nPos := ::Settle( ::nPos )\n\n ENDDO\n\n#ifdef HB_COMPAT_C53\n IF lMsgFlag\n RestScreen( nMsgRow, nMsgLeft, nMsgRow, nMsgRight, ::cMsgSaveS )\n ENDIF\n\n SetCursor( ::nSaveCursor )\n#endif\n\n RETURN Self\n\nMETHOD Updated() CLASS HBGetList\n RETURN ::lUpdated\n\nMETHOD Get() CLASS HBGetList\n RETURN ::oGet\n\nMETHOD SetFocus() CLASS HBGetList\n\n __GetListSetActive( Self )\n __GetListLast( Self )\n ::aGetList[ ::nPos ]:setFocus()\n\n RETURN Self\n\nMETHOD Reader( oMenu, aMsg ) CLASS HBGetList\n\n LOCAL oGet := ::oGet\n LOCAL nRow\n LOCAL nCol\n#ifdef HB_COMPAT_C53\n LOCAL nOldCursor\n LOCAL nKey\n#endif\n\n#ifdef HB_COMPAT_C53\n IF ::nLastExitState == GE_SHORTCUT .OR.;\n ::nLastExitState == GE_MOUSEHIT .OR.;\n ::GetPreValidate( oGet, aMsg )\n#else\n IF ::GetPreValidate( oGet, aMsg )\n#endif\n\n ::ShowGetMsg( oGet, aMsg )\n\n ::nHitCode := 0\n ::nLastExitState := 0\n oGet:setFocus()\n\n DO WHILE oGet:exitState == GE_NOEXIT .AND. ! ::lKillRead\n IF oGet:typeOut\n oGet:exitState := GE_ENTER\n ENDIF\n\n\n DO WHILE oGet:exitState == GE_NOEXIT .AND. ! ::lKillRead\n#ifdef HB_COMPAT_C53\n SetCursor( iif( ::nSaveCursor == SC_NONE, SC_NORMAL, ::nSaveCursor ) )\n nKey := Inkey( 0 )\n SetCursor( SC_NONE )\n ::GetApplyKey( nKey, oGet, oMenu, aMsg )\n#else\n ::GetApplyKey( Inkey( 0 ), oGet, oMenu, aMsg )\n#endif\n nRow := Row()\n nCol := Col()\n ::ShowGetMsg( oGet, aMsg )\n SetPos( nRow, nCol )\n ENDDO\n\n#ifdef HB_COMPAT_C53\n IF ! ::nLastExitState == GE_SHORTCUT .AND. ;\n ! ::nLastExitState == GE_MOUSEHIT .AND. ;\n ! ::GetPostValidate( oGet, aMsg )\n#else\n IF ! ::GetPostValidate( oGet, aMsg )\n#endif\n oGet:exitState := GE_NOEXIT\n ENDIF\n ENDDO\n\n#ifdef HB_COMPAT_C53\n nRow := Row()\n nCol := Col()\n nOldCursor := SetCursor()\n#endif\n oGet:killFocus()\n#ifdef HB_COMPAT_C53\n SetCursor( nOldCursor )\n SetPos( nRow, nCol )\n#endif\n\n ::EraseGetMsg( aMsg )\n ENDIF\n\n RETURN Self\n\nMETHOD GetApplyKey( nKey, oGet, oMenu, aMsg ) CLASS HBGetList\n\n LOCAL cKey\n LOCAL bKeyBlock\n\n#ifdef HB_COMPAT_C53\n LOCAL nMRow\n LOCAL nMCol\n LOCAL nButton\n LOCAL nHotItem\n#endif\n\n hb_default( @oGet, ::oGet )\n\n IF ( bKeyBlock := SetKey( nKey ) ) != NIL\n IF ::GetDoSetKey( bKeyBlock, oGet )\n RETURN Self\n ENDIF\n ENDIF\n\n#ifdef HB_COMPAT_C53\n IF ::aGetList != NIL .AND. ( nHotItem := ::Accelerator( nKey, aMsg ) ) != 0\n\n oGet:exitState := GE_SHORTCUT\n ::nNextGet := nHotItem\n ::nLastExitState := GE_SHORTCUT\n ELSEIF ! HB_ISOBJECT( oMenu )\n ELSEIF ( nHotItem := oMenu:getAccel( nKey ) ) != 0\n ::nMenuID := MenuModal( oMenu, nHotItem, aMsg[ MSGROW ], aMsg[ MSGLEFT ], aMsg[ MSGRIGHT ], aMsg[ MSGCOLOR ] )\n nKey := 0\n ELSEIF IsShortcut( oMenu, nKey )\n nKey := 0\n ENDIF\n#else\n HB_SYMBOL_UNUSED( oMenu )\n HB_SYMBOL_UNUSED( aMsg )\n#endif\n\n SWITCH nKey\n CASE K_UP\n oGet:exitState := GE_UP\n EXIT\n\n CASE K_SH_TAB\n oGet:exitState := GE_UP\n EXIT\n\n CASE K_DOWN\n oGet:exitState := GE_DOWN\n EXIT\n\n CASE K_TAB\n oGet:exitState := GE_DOWN\n EXIT\n\n CASE K_ENTER\n oGet:exitState := GE_ENTER\n EXIT\n\n CASE K_ESC\n IF Set( _SET_ESCAPE )\n oGet:undo()\n oGet:exitState := GE_ESCAPE\n ENDIF\n EXIT\n\n CASE K_PGUP\n oGet:exitState := GE_WRITE\n EXIT\n\n CASE K_PGDN\n oGet:exitState := GE_WRITE\n EXIT\n\n CASE K_CTRL_HOME\n oGet:exitState := GE_TOP\n EXIT\n\n#ifdef CTRL_END_SPECIAL\n CASE K_CTRL_END\n oGet:exitState := GE_BOTTOM\n EXIT\n#else\n CASE K_CTRL_W\n oGet:exitState := GE_WRITE\n EXIT\n#endif\n\n#ifdef HB_COMPAT_C53\n CASE K_LBUTTONDOWN\n CASE K_LDBLCLK\n\n nMRow := MRow()\n nMCol := MCol()\n\n IF ! HB_ISOBJECT( oMenu )\n nButton := 0\n ELSEIF ! oMenu:ClassName() == \"TOPBARMENU\"\n nButton := 0\n ELSEIF ( nButton := oMenu:hitTest( nMRow, nMCol ) ) != 0"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour Runtime Library file: src/rtl/adir.prg. Provides functions: ADir. This file provides file I/O operations"}, {"role": "assistant", "content": "#include \"directry.ch\"\n\nFUNCTION ADir( cFileMask, aName, aSize, aDate, aTime, aAttr )\n\n LOCAL aDir\n LOCAL nDirLen\n LOCAL nDirPos\n\n LOCAL nNameLen, nSizeLen, nDateLen, nTimeLen, nAttrLen\n\n LOCAL aFileInfo\n\n LOCAL cDir\n LOCAL cName\n LOCAL cExt\n\n \n IF ! HB_ISSTRING( cFileMask )\n RETURN 0\n ENDIF\n\n \n hb_FNameSplit( cFileMask, @cDir, @cName, @cExt )\n\n IF Empty( cDir )\n cFileMask := hb_FNameMerge( __DefPath(), cName, cExt )\n ENDIF\n\n \n IF HB_ISARRAY( aName )\n nNameLen := Len( aName )\n ENDIF\n IF HB_ISARRAY( aSize )\n nSizeLen := Len( aSize )\n ENDIF\n IF HB_ISARRAY( aDate )\n nDateLen := Len( aDate )\n ENDIF\n IF HB_ISARRAY( aTime )\n nTimeLen := Len( aTime )\n ENDIF\n IF HB_ISARRAY( aAttr )\n nAttrLen := Len( aAttr )\n ENDIF\n\n \n aDir := Directory( cFileMask, iif( HB_ISARRAY( aAttr ), \"HSD\", ) )\n nDirLen := Len( aDir )\n\n FOR nDirPos := 1 TO nDirLen\n\n aFileInfo := aDir[ nDirPos ]\n\n IF nNameLen != NIL .AND. nNameLen >= nDirPos\n aName[ nDirPos ] := aFileInfo[ F_NAME ]\n ENDIF\n IF nSizeLen != NIL .AND. nSizeLen >= nDirPos\n aSize[ nDirPos ] := aFileInfo[ F_SIZE ]\n ENDIF\n IF nDateLen != NIL .AND. nDateLen >= nDirPos\n aDate[ nDirPos ] := aFileInfo[ F_DATE ]\n ENDIF\n IF nTimeLen != NIL .AND. nTimeLen >= nDirPos\n aTime[ nDirPos ] := aFileInfo[ F_TIME ]\n ENDIF\n IF nAttrLen != NIL .AND. nAttrLen >= nDirPos\n aAttr[ nDirPos ] := aFileInfo[ F_ATTR ]\n ENDIF\n\n NEXT\n\n RETURN nDirLen"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/cstruct.ch. Defines constants: __HBCSTRUCT_CH_, __PACK. Declares 5 preprocessor commands. Declares 5 preprocessor translations. Defines color and display constants"}, {"role": "assistant", "content": "#include \"hbctypes.ch\"\n\n#ifndef __HBCSTRUCT_CH_\n #define __HBCSTRUCT_CH_\n\n \n #ifdef _SET_CH\n #xtranslate __ClsSetModule( ) => Empty( )\n #xcommand C STRUCTURE [ALIGN ] => ;\n INIT PROCEDURE __INIT_; ;\n __ActiveStructure( #, ) ; ;\n #xtranslate IS \\[ \\ { \\ } ] => := hb_CStructure( # ):Init( {\\} ); ;\n #xtranslate IS FROM \\ => := hb_CStructure( # ):Buffer( \\ )\n\n \n #xcommand MEMBER IS => hb_Member( #, )\n\n \n #xcommand MEMBER := hb_CStructure( ):Init( {} ) => ;\n hb_Member( #, hb_CStructureId( , .T. ) )\n\n #xcommand MEMBER IS ( ) => hb_Member( #, hb_CTypeArrayId( , ) )\n\n #xcommand MEMBER AS => ;\n hb_Member( #, hb_CStructureId( #, .F. ) )\n\n #xcommand END C STRUCTURE [] => ; ;\n __ClsSetModule( __ActiveStructure() ); ;\n RETURN\n\n #xcommand IMPORT C STRUCTURE => ;\n #xtranslate IS \\[ \\ { \\ } ] => := hb_CStructure( # ):Init( {\\} ); ;\n #xtranslate IS FROM \\ => := hb_CStructure( # ):Buffer( \\ )\n\n \n #define __PACK 8\n\n #xcommand typedef struct [] { [[struct] ] } [, <*synon*>] => ;\n INIT PROCEDURE __INIT_; ;\n hb_CStructureCSyntax( #, {[#,]}, <(tag)>, <\"synon\">, __PACK ); ;\n __ClsSetModule( __ActiveStructure() ); ;\n RETURN; ;\n #xtranslate IS \\[ \\ { \\ } ] => := hb_CStructure( # ):Init( {\\} ); ;\n #xtranslate IS FROM \\ => := hb_CStructure( # ):Buffer( \\ )\n\n #xcommand pragma pack( ) => #undef __PACK; #define __PACK \n #xcommand pragma pack() => #undef __PACK; #define __PACK 8\n\n #xtranslate ( struct ) [] => hb_CStructure( # ):Buffer( )\n #xtranslate ( struct * ) => hb_CStructure( # ):Pointer( )\n #endif\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/prngdi.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\n#include \"simpleio.ch\"\n\nPROCEDURE Main()\n\n LOCAL cPrinterName := \"Microsoft XPS Document Writer\"\n\n LOCAL hDC\n LOCAL pDEVMODE\n LOCAL hRECT\n LOCAL aRECT\n LOCAL hOBJECT\n\n pDEVMODE := __wapi_DEVMODE_New( cPrinterName )\n __wapi_DEVMODE_Set( pDEVMODE, { \"dmPaperSize\" => WIN_DMPAPER_A3 } )\n ? hDC := wapi_CreateDC( NIL, cPrinterName, NIL, pDEVMODE )\n\n ? wapi_StartDoc( hDC, { \"lpszDocName\" => \"test job\" } )\n ? wapi_StartPage( hDC )\n ? hOBJECT := wapi_CreateFont( ,,,,,,,,,,,,, \"Arial\" )\n ? wapi_SelectObject( hDC, hOBJECT )\n\n ? \"in ARR\"\n aRECT := { 100, 150, 450, 250 }\n ? wapi_DrawText( hDC, \"0TEST\", aRECT )\n\n ? \"inout ARR\"\n aRECT := { 100, 150, 450, 250 }\n ? wapi_DrawText( hDC, \"1TEST\", aRECT, WIN_DT_CALCRECT )\n ? aRECT[ 1 ], aRECT[ 2 ], aRECT[ 3 ], aRECT[ 4 ]\n\n ? \"out HASH\"\n hRECT := { => }\n ? wapi_DrawText( hDC, \"2TEST\", hRECT, WIN_DT_CALCRECT )\n ? hRECT[ \"left\" ], hRECT[ \"top\" ], hRECT[ \"bottom\" ], hRECT[ \"right\" ]\n\n ? \"inout HASH\"\n hRECT := { => }\n hRECT[ \"left\" ] := 300\n hRECT[ \"top\" ] := 350\n ? wapi_DrawText( hDC, \"3TEST\", hRECT, WIN_DT_CALCRECT )\n ? hRECT[ \"left\" ], hRECT[ \"top\" ], hRECT[ \"bottom\" ], hRECT[ \"right\" ]\n\n ? \"in HASH\"\n hRECT := { => }\n hRECT[ \"left\" ] := 300\n hRECT[ \"top\" ] := 350\n hRECT[ \"right\" ] := 650\n hRECT[ \"bottom\" ] := 450\n ? wapi_DrawText( hDC, \"4TEST\", hRECT )\n\n ? wapi_EndPage( hDC )\n ? wapi_EndDoc( hDC )\n\n hDC := NIL\n hOBJECT := NIL\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/omacro.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL obj := ErrorNew()\n\n MEMVAR m_send1\n MEMVAR m_send2\n\n PRIVATE m_send1 := \"_description\"\n PRIVATE m_send2 := \"_tries\"\n\n obj:tries := 1\n obj:&m_send1 := \"test\"\n\n obj:tries += 1\n obj:tries++\n ++obj:tries\n\n WITH OBJECT obj\n :tries += 1\n :tries++\n ++:tries\n\n\n :&m_send2 += 1\n :&m_send2++\n ++:&m_send2\n ++:&( m_send2 )\n\n :&( m_send2 ) := :&( SubStr( m_send2, 2 ) ) + 1\n\n :&m_send1 += \" description\"\n :&( m_send1 ) += \" of \"\n ENDWITH\n\n obj:&( \"_\" + SubStr( m_send1, 2 ) ) += \"Error object\"\n ? m_send1, \"=\", obj:&( SubStr( m_send1, 2 ) )\n ? m_send2, \"=\", obj:tries\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/adir.prg. Provides functions: TestIt. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n#include \"clipper.ch\"\n#endif\n\nPROCEDURE Main()\n\n TestIt( hb_osFileMask() )\n TestIt( hb_ps() )\n TestIt( \"..\" + hb_ps() )\n TestIt( \"..\" + hb_ps() + hb_osFileMask() )\n\n RETURN\n\nSTATIC FUNCTION TestIt( cSpec )\n\n LOCAL a\n LOCAL a1\n LOCAL a2\n LOCAL a3\n LOCAL a4\n LOCAL a5\n\n \n a := ADir( cSpec, , , , , {} )\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n a1 := Array( a )\n a2 := Array( a )\n a3 := Array( iif( a >= 1, a - 1, a ) )\n a4 := Array( a )\n a5 := Array( a + 1 )\n\n OutStd( \"--------------------------------------------------------\" )\n OutStd( hb_eol() )\n\n ADir( cSpec, a1, a2, a3, a4, a5 )\n\n AEval( a1, {| tmp | OutStd( tmp ), OutStd( hb_eol() ) } )\n AEval( a2, {| tmp | OutStd( tmp ), OutStd( hb_eol() ) } )\n AEval( a3, {| tmp | OutStd( tmp ), OutStd( hb_eol() ) } )\n AEval( a4, {| tmp | OutStd( tmp ), OutStd( hb_eol() ) } )\n AEval( a5, {| tmp | OutStd( tmp ), OutStd( hb_eol() ) } )\n\n ADir( cSpec, 10, \"A\", NIL, NIL, NIL )\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/classex.ch. Declares 5 preprocessor commands. Declares 5 preprocessor translations. Defines communication constants"}, {"role": "assistant", "content": "#xcommand PROPERTY [TYPE ] [AS ] [INDEX ] READ WRITE [DEFAULT ];\n [] ;\n => ;\n DATA T_ AS STRING INIT <(type)> PROTECTED ;;\n #xtranslate __FNAME() => F ;;\n DATA __FNAME() [AS ] PROTECTED [INIT ] ;;\n ACCESS INLINE ::( [ ] ) ;;\n ASSIGN (v) INLINE ::( [ , ] v)\n\n#xcommand PROPERTY [AS ] [INDEX ] READ WRITE [DEFAULT ];\n [] ;\n => ;\n #xtranslate __FNAME() => F ;;\n DATA __FNAME() [AS ] PROTECTED [INIT ] ;;\n ACCESS INLINE ::( [ ] ) ;;\n ASSIGN (v) INLINE ::( [ , ] v)\n\n\n#xcommand PROPERTY [TYPE ] [AS ] [INDEX ] WRITE [DEFAULT ];\n [] ;\n => ;\n DATA T_ AS STRING INIT <(type)> PROTECTED ;;\n #xtranslate __FNAME() => F ;;\n DATA __FNAME() [AS ] PROTECTED [INIT ] ;;\n ASSIGN (v) INLINE ::( [ , ] v)\n\n#xcommand PROPERTY [AS ] [INDEX ] WRITE [DEFAULT ];\n [] ;\n => ;\n #xtranslate __FNAME() => F ;;\n DATA __FNAME() [AS ] PROTECTED [INIT ] ;;\n ASSIGN (v) INLINE ::( [ , ] v)\n\n#xcommand PROPERTY [TYPE ] [AS ] [INDEX ] READ [DEFAULT ];\n [] ;\n => ;\n DATA T_ AS STRING INIT <(type)> PROTECTED ;;\n #xtranslate __FNAME() => F ;;\n DATA __FNAME() [AS ] PROTECTED [INIT ] ;;\n ACCESS INLINE ::( [ ] )\n\n#xcommand PROPERTY [AS ] [INDEX ] READ [DEFAULT ];\n [] ;\n => ;\n #xtranslate __FNAME() => F ;;\n DATA __FNAME() [AS ] PROTECTED [INIT ] ;;\n ACCESS INLINE ::( [ ] )\n\n\n#xcommand PROPERTY [TYPE ] [AS ] [DEFAULT ];\n [] ;\n => ;\n DATA T_ AS STRING INIT <(type)> PROTECTED ;;\n #xtranslate __FNAME() => F ;;\n DATA __FNAME() [AS ] EXPORTED [INIT ]\n\n#xcommand PROPERTY [AS ] [DEFAULT ];\n [] ;\n => ;\n #xtranslate __FNAME() => F ;;\n DATA __FNAME() [AS ] EXPORTED [INIT ]\n\n#xtranslate __FNAME() => F"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/statfun.prg. Provides functions: SecondOne. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n ? \"From Main()\"\n\n SecondOne()\n\n ? \"From Main() again\"\n\n RETURN\n\nSTATIC FUNCTION SecondOne()\n\n ? \"From Second()\"\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/gfx.prg. Provides functions: PutFrame. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbgtinfo.ch\"\n#include \"hbgfx.ch\"\n\nPROCEDURE Main()\n\n LOCAL nFontHeight, nFontWidth\n LOCAL nTop, nLeft, nHeight, nWidth, nColor, nSec := Seconds()\n LOCAL cWelcome\n\n#if defined( __HBSCRIPT__HBSHELL )\n# if defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVT\" )\n# elif defined( __PLATFORM__UNIX )\n hbshell_gtSelect( \"GTXWC\" )\n# endif\n#endif\n\n IF ! hb_gtInfo( HB_GTI_ISGRAPHIC )\n ? \"You are using a non graphics capable gt:\"\n ? \"GT\" + hb_gtVersion()\n QUIT\n ENDIF\n\n IF hb_gtInfo( HB_GTI_DESKTOPWIDTH ) > 1000\n hb_gtInfo( HB_GTI_FONTWIDTH, 12 )\n hb_gtInfo( HB_GTI_FONTSIZE, 24 )\n ENDIF\n\n nFontHeight := hb_gtInfo( HB_GTI_FONTSIZE )\n nFontWidth := hb_gtInfo( HB_GTI_FONTWIDTH )\n\n cWelcome := \"Welcome to the World of Harbour multiplatform Graphics!\" + \" (GT\" + hb_gtVersion() + \")\"\n\n SetColor( \"n/w\" )\n @ 0, 0 SAY Space( MaxCol() + 1 )\n @ 1, 0 SAY PadC( cWelcome, MaxCol() + 1 )\n @ 2, 0 SAY Space( MaxCol() + 1 )\n\n hb_gtInfo( HB_GTI_WINTITLE, \"Cross-GT, multiplatform graphics demo\" )\n\n PutFrame( ;\n nFontHeight / 2, ;\n MaxCol() / 2\n hb_gfxText( nTop, nLeft, \"Hello\", nColor, nHeight )\n EXIT\n ENDSWITCH\n IF Seconds() - nSec > 3\n hb_gfxFloodFill( 0, 0, nColor )\n nSec := Seconds()\n ENDIF\n ENDDO\n\n RETURN\n\nFUNCTION PutFrame( nTop, nLeft, nBottom, nRight, nColor1, nColor2 )\n\n hb_gfxRect( nTop, nLeft, nBottom, nRight, nColor1 )\n hb_gfxRect( nTop + 1, nLeft + 1, nBottom - 1, nRight - 1, nColor2 )\n hb_gfxLine( nTop + 1, nLeft + 1, nTop + 1, nRight - 1, nColor2 )\n hb_gfxLine( nTop + 2, nLeft + 1, nBottom - 1, nLeft + 1, nColor2 )\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour source file: src/rdd/dbdelim.prg. Provides functions: __dbDelim. This file implements core Record Driver Driver functionality"}, {"role": "assistant", "content": "REQUEST Delim\n\nFUNCTION __dbDelim( lExport, cFile, cDelimArg, aFields, bFor, bWhile, nNext, nRecord, lRest, cCodePage )\n\n#ifdef HB_CLP_STRICT\n\n LOCAL nSrcArea\n LOCAL nDstArea\n LOCAL aStruct\n LOCAL cRDD := \"DELIM\"\n\n IF lExport\n nSrcArea := Select()\n ELSE\n nDstArea := Select()\n ENDIF\n\n IF Empty( aStruct := __dbStructFilter( dbStruct(), aFields ) )\n RETURN .F.\n ENDIF\n\n IF lExport\n dbCreate( cFile, aStruct, cRDD, .T., \"\", cDelimArg )\n nDstArea := Select()\n IF nDstArea == nSrcArea\n nDstArea := NIL\n ENDIF\n dbSelectArea( nSrcArea )\n ELSE\n IF ! __dbOpenSDF( cFile, aStruct, cRDD, .T., \"\", cDelimArg )\n RETURN .F.\n ENDIF\n nSrcArea := Select()\n ENDIF\n\n IF nDstArea != NIL\n __dbTrans( nDstArea, aStruct, bFor, bWhile, nNext, nRecord, lRest )\n ENDIF\n\n IF lExport\n IF nDstArea != NIL\n dbSelectArea( nDstArea )\n dbCloseArea()\n ENDIF\n dbSelectArea( nSrcArea )\n ELSE\n dbSelectArea( nSrcArea )\n dbCloseArea()\n dbSelectArea( nDstArea )\n ENDIF\n\n RETURN .T.\n\n#else\n\n RETURN iif( lExport, ;\n __dbCopy( cFile, aFields, bFor, bWhile, nNext, nRecord, lRest, \"DELIM\",, cCodePage, cDelimArg ), ;\n __dbApp( cFile, aFields, bFor, bWhile, nNext, nRecord, lRest, \"DELIM\",, cCodePage, cDelimArg ) )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'gtwvg' (): contrib/gtwvg/tests/demowvg.prg. Contains 6 procedures. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"gtwvg\"\n\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n#include \"hbver.ch\"\n#include \"wvgparts.ch\"\n\nREQUEST DBFCDX\nREQUEST DBFNTX\n\n#define IMAGE_VOUCH hb_DirBase() + \"vouch1.bmp\"\n#define IMAGE_BROWSE hb_DirBase() + \"v_browse.ico\"\n#define IMAGE_VR hb_DirBase() + \"vr_1.ico\"\n#define IMAGE_NOTES hb_DirBase() + \"v_notes.ico\"\n#define IMAGE_TOOLS hb_DirBase() + \"v_tools.ico\"\n#define IMAGE_HELP hb_DirBase() + \"v_notes.ico\"\n\n#define OBJ_TYPE_BUTTON 1\n\n#ifndef __SQL__\n ANNOUNCE Hb_NoStartUpWindow\n#endif\n\nMEMVAR cCdxExp, First, Last, City\n\nTHREAD STATIC t_wvtScreen := {}\n\n#ifdef __XCC__\nSTATIC s_paint_ := { { \"\", {} } }\n#endif\n\nEXIT PROCEDURE CleanHandles()\n\n LOCAL obj\n\n FOR EACH obj IN SetFonts()\n wvg_DeleteObject( obj )\n obj := NIL\n NEXT\n FOR EACH obj IN SetIcons()\n wvg_DeleteObject( obj )\n obj := NIL\n NEXT\n\n RETURN\n\nPROCEDURE Main()\n\n LOCAL aLastPaint, clr, scr, pGT\n LOCAL hPopup\n LOCAL dDate := hb_SToD()\n LOCAL cName := PadR( \"Pritpal Bedi\", 35 )\n LOCAL cAdd1 := PadR( \"60, New Professor Colony\", 35 )\n LOCAL cAdd2 := PadR( \"Ludhiana, INDIA\", 35 )\n LOCAL cAdd3 := PadR( hb_Version( HB_VERSION_URL_BASE ), 35 )\n LOCAL nSlry := 20000\n LOCAL aBlocks := {}\n LOCAL nColGet := 8\n LOCAL GetList := {}\n LOCAL nTop := 4\n LOCAL nLft := 4\n LOCAL nBtm := 20\n LOCAL nRgt := 75\n LOCAL cLabel := \"Harbour simulated GUI.\"\n LOCAL aObjects := WvtSetObjects( {} )\n LOCAL oLastMenu\n LOCAL oError := ErrorBlock( {| o | MyError( o ) } )\n\n#if defined( __HBSCRIPT__HBSHELL ) .AND. defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVG\" )\n#endif\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n Set( _SET_EVENTMASK, INKEY_ALL + HB_INKEY_GTEVENT )\n\n wvt_SetGUI( .T. )\n WvtSetKeys( .T. )\n Popups( 1 )\n wvt_SetMouseMove( .T. )\n wvt_SetFont( \"Courier New\", 18, 0, 0 )\n\n CLS\n wvt_ShowWindow( SW_RESTORE )\n\n \n oLastMenu := BuildMainMenu()\n oLastMenu:disableItem( 11 )\n oLastMenu:checkItem( 1 )\n oLastMenu:insItem( 11, { \"I am inserted later !\", ;\n {|| wvg_MessageBox( , \"Hi \" + iif( oLastMenu:isItemChecked( 1 ), \"Yes\", \"No\" ) + ;\n iif( oLastMenu:isItemEnabled( 12 ), \" Yes\", \" No\" ) ) } } )\n\n oLastMenu:setItem( 14, { \"This is Set Against Prev Menu\", {|| wvg_MessageBox( , \"Hi\" ) } } )\n\n SetMode( MaxRow() + 1, MaxCol() + 1 ) \n\n SetKey( K_F12 , {|| hb_gtInfo( HB_GTI_ACTIVATESELECTCOPY ) } )\n SetKey( K_CTRL_V , {|| __Keyboard( hb_gtInfo( HB_GTI_CLIPBOARDDATA ) ) } )\n SetKey( K_RBUTTONDOWN, {|| __Keyboard( hb_gtInfo( HB_GTI_CLIPBOARDDATA ) ) } )\n\n hPopup := wvt_SetPopupMenu()\n\n pGT := SetGT( 1, hb_gtSelect() )\n\n \n wvt_SetMousePos( 2, 40 )\n\n AAdd( aBlocks, {|| wvt_SetIcon( GetResource( \"vr_1.ico\" ) ) } )\n AAdd( aBlocks, {|| Wvt_SetTitle( \"Vouch\" ) } )\n AAdd( aBlocks, {|| wvt_DrawLabel( 1, 40, cLabel, 6,, RGB( 255, 255, 255 ), RGB( 198, 198, 198 ), \"Arial\", 26, , , , , .T., .T. ) } )\n AAdd( aBlocks, {|| wvt_DrawBoxRaised( nTop, nLft, nBtm, nRgt ) } )\n AAdd( aBlocks, {|| wvt_DrawBoxRecessed( 7, 61, 13, 70 ) } )\n AAdd( aBlocks, {|| wvt_DrawBoxGroup( 15, 59, 18, 72 ) } )\n AAdd( aBlocks, {|| wvt_DrawBoxGroup( 5, 6, 19, 44 ) } )\n AAdd( aBlocks, {|| wvt_DrawImage( 8, 62, 12, 69, IMAGE_VOUCH, , .T. ) } )\n AAdd( aBlocks, {|| wvt_DrawBoxRecessed( 7, 48, 13, 55 ) } )\n AAdd( aBlocks, {|| wvt_DrawLine( MaxRow() - 2, 0, MaxRow() - 2, MaxCol(), WVT_LINE_HORZ, WVT_LINE_RECESSED, WVT_LINE_BOTTOM ) } )\n AAdd( aBlocks, {|| wvt_DrawLine( MaxRow() - 1, 41, MaxRow(), 41, WVT_LINE_VERT, WVT_LINE_RECESSED, WVT_LINE_CENTER ) } )\n AAdd( aBlocks, {|| AEval( GetList, {| oGet | wvt_DrawBoxGet( oGet:Row, oGet:Col, Len( Transform( oGet:VarGet(), oGet:Picture ) ) ) } ) } )\n\n AAdd( aBlocks, {|| wvt_Mouse( -1000001 ) } )\n\n aLastPaint := WvtSetBlocks( aBlocks )\n\n \n BuildButtons()\n\n scr := SaveScreen( 0, 0, MaxRow(), MaxCol() )\n clr := SetColor( \"N/W\" )\n CLS\n SetColor( \"N/W,N/GR*,,,N/W*\" )\n\n @ 6, nColGet SAY \"< Date >\"\n @ 9, nColGet SAY \"<\" + PadC( \"Name\", 33 ) + \">\"\n @ 12, nColGet SAY \"<\" + PadC( \"Address\", 33 ) + \">\"\n @ 16, 61 SAY \"< Salary >\"\n\n dDate := hb_SToD( \"20040401\" )\n\n @ 7, nColGet GET dDate WHEN DispStatusMsg( \"Date must be valid\" ) VALID ClearStatusMsg()\n @ 10, nColGet GET cName WHEN DispStatusMsg( \"Must be one of the list!\" ) VALID VouChoice() < 7 .AND. ClearStatusMsg()\n @ 13, nColGet GET cAdd1\n @ 15, nColGet GET cAdd2\n @ 17, nColGet GET cAdd3\n @ 17, 61 GET nSlry PICTURE \"@Z 9999999.99\"\n\n WvgSetAppWindow():refresh()\n\n READ\n\n \n WvtSetBlocks( aLastPaint )\n WvtSetObjects( aObjects )\n SetColor( clr )\n RestScreen( 0, 0, MaxRow(), MaxCol(), scr )\n WvtSetKeys( .F. )\n wvt_SetPopupMenu( hPopup )\n\n Popups( 1, .T. )\n SetGT( 1, pGT )\n\n ErrorBlock( oError )\n\n RETURN\n\nSTATIC PROCEDURE WvtConsoleGets( nMode )\n\n hb_default( @nMode, 0 )\n\n IF hb_mtvm()\n hb_threadStart( {| oCrt | hb_gtReload( \"WVT\" ), ;\n oCrt := hb_gtSelect(), ;\n iif( nMode == 0, WvtNextGetsConsole(), OnlineMap() ), ;\n oCrt := NIL } )\n ENDIF\n\n RETURN\n\nPROCEDURE WvtNextGetsConsole()\n\n LOCAL dDate := hb_SToD()\n LOCAL cName := Space( 35 )\n LOCAL cAdd1 := Space( 35 )\n LOCAL cAdd2 := Space( 35 )\n LOCAL cAdd3 := Space( 35 )\n LOCAL nSlry := 0\n LOCAL nColGet := 8\n LOCAL GetList := {}\n\n SetMode( 20, 51 )\n SetColor( \"N/W,N/GR*,,,N/W*\" )\n CLS\n hb_gtInfo( HB_GTI_WINTITLE, \"WVT Console in WVG Application\" )\n\n @ MaxRow(), 0 SAY PadC( \"GTWVT in GTWVG Console Gets\", MaxCol() + 1 ) COLOR \"W+/B*\"\n\n @ 2, nColGet SAY \"< Date >\"\n @ 5, nColGet SAY \"<\" + PadC( \"Name\", 33 ) + \">\"\n @ 8, nColGet SAY \"<\" + PadC( \"Address\", 33 ) + \">\"\n @ 15, nColGet SAY \"< Salary >\"\n\n @ 3, nColGet GET dDate\n @ 6, nColGet GET cName\n @ 9, nColGet GET cAdd1\n @ 11, nColGet GET cAdd2\n @ 13, nColGet GET cAdd3\n @ 16, nColGet GET nSlry PICTURE \"@Z 9999999.99\"\n\n READ\n\n RETURN\n\nPROCEDURE WvtNextGets() \n\n IF hb_mtvm()\n hb_threadStart( {|| hb_gtReload( \"WVG\" ), wvt_SetFont( \"Terminal\", 20 ), ;\n hb_clear(), wvt_ShowWindow( SW_RESTORE ), WvtNextGets_X() } )\n ELSE\n WvtNextGets_X()\n ENDIF\n\n RETURN\n\nPROCEDURE WvtNextGets_X()\n\n LOCAL aLastPaint, clr\n LOCAL dDate := hb_SToD()\n LOCAL cName := Space( 35 )\n LOCAL cAdd1 := Space( 35 )\n LOCAL cAdd2 := Space( 35 )\n LOCAL cAdd3 := Space( 35 )\n LOCAL nSlry := 0\n LOCAL aBlocks := {}\n LOCAL nColGet := 8\n LOCAL GetList := {}\n LOCAL aPalette := Wvt_GetPalette()\n LOCAL aNewPalette := AClone( aPalette )\n LOCAL aObjects := WvtSetObjects( {} )\n LOCAL nRow := Row()\n LOCAL nCol := Col()\n LOCAL scr := SaveScreen( 0, 0, MaxRow(), MaxCol() )\n LOCAL wvtScr := wvt_SaveScreen( 0, 0, MaxRow(), MaxCol() )\n\n STATIC s_nPalletMultiplier := 0\n\n \n aNewPalette[ 8 ] := aNewPalette[ 8 ] + ( 100000\n AAdd( aBlocks, {|| Wvt_SetTitle( \"Wvt Gets 2nd Window with Different Palette\" ) } )\n AAdd( aBlocks, {|| wvt_DrawLine( MaxRow() - 1, 0, MaxRow() - 1, MaxCol() ) } )\n AAdd( aBlocks, {|| wvt_SetBrush( 0, RGB( 32, 255, 100 ) ) } )\n AAdd( aBlocks, {|| wvt_DrawEllipse( 6, 50, 10, 58 ) } )\n AAdd( aBlocks, {|| wvt_SetBrush( 2, RGB( 255, 255, 100 ), 1 ) } )\n AAdd( aBlocks, {|| wvt_DrawRectangle( 11, 50, 13, 58 ) } )\n AAdd( aBlocks, {|| wvt_DrawBoxGroupRaised( 5, 6, 19, 72 ) } )\n AAdd( aBlocks, {|| AEval( GetList, {| oGet | wvt_DrawBoxGet( oGet:Row, oGet:Col, Len( Transform( oGet:VarGet(), oGet:Picture ) ) ) } ) } )\n\n AAdd( aBlocks, {|| wvt_DrawButton( 21, 6, 22, 9, \"New\", \"vouch1.bmp\" ) } )\n AAdd( aBlocks, {|| wvt_DrawButton( 21, 11, 22, 14, \"Browse\", \"vouch1.bmp\", 1, RGB( 255, 255, 255 ) ) } )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/menuto.prg. Contains procedures: Main, RECURSE. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n#define hb_ntos( n ) LTrim( Str( n ) )\n#endif\n\n#include \"inkey.ch\"\n\nPROCEDURE Main()\n\n MEMVAR m_testvar\n\n LOCAL testvar\n\n#ifdef _SET_EVENTMASK\n Set( _SET_EVENTMASK, INKEY_ALL )\n MSetCursor( .T. )\n#endif\n\n SET KEY K_F8 TO RECURSE()\n\n CLS\n\n @ 1, 10 PROMPT \"Menu Item 1\" MESSAGE \"Menu Message 1\"\n __AtPrompt( 2, 10, \"Menu Item 2\", \"Menu Message 2\", \"R+/GR, GR+/N\" )\n @ 3, 10 PROMPT \"Menu Item 3\" MESSAGE \"Menu Message 3\"\n @ 4, 10 PROMPT \"Menu Item 4\" MESSAGE \"Menu Message 4\"\n\n @ 6, 10 SAY \"Testing with LOCAL parameter\"\n @ 7, 10 SAY \"Press F8 to recurse into MENU TO\"\n\n MENU TO testvar\n\n @ 9, 10 SAY \"Your Choice = \" + hb_ntos( testvar )\n\n Inkey( 0 )\n\n SET KEY K_F8 TO RECURSE()\n\n CLS\n\n @ 1, 10 PROMPT \"Menu Item 1\" MESSAGE \"Menu Message 1\"\n @ 2, 10 PROMPT \"Menu Item 2\" MESSAGE \"Menu Message 2\"\n @ 3, 10 PROMPT \"Menu Item 3\" MESSAGE \"Menu Message 3\"\n @ 4, 10 PROMPT \"Menu Item 4\" MESSAGE \"Menu Message 4\"\n\n @ 6, 10 SAY \"Testing with MEMVAR parameter\"\n @ 7, 10 SAY \"Press F8 to recurse into MENU TO\"\n\n MENU TO m_testvar\n\n @ 9, 10 SAY \"Your Choice = \" + hb_ntos( m_testvar )\n\n RETURN\n\nPROCEDURE RECURSE()\n\n LOCAL testvar\n\n SET KEY K_F8 TO\n\n @ 6, 10 SAY Space( Len( \"Press F8 to recurse into MENU TO\" ) )\n\n @ 1, 50 PROMPT \"Menu Item 1\" MESSAGE \"Menu Message 1\"\n @ 2, 50 PROMPT \"Menu Item 2\" MESSAGE \"Menu Message 2\"\n @ 3, 50 PROMPT \"Menu Item 3\" MESSAGE \"Menu Message 3\"\n @ 4, 50 PROMPT \"Menu Item 4\" MESSAGE \"Menu Message 4\"\n\n MENU TO testvar\n\n @ 7, 10 SAY \"Press F8 to recurse into MENU TO\"\n\n @ 9, 50 SAY \"Your Choice = \" + hb_ntos( testvar )\n\n SET KEY K_F8 TO RECURSE()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/serial1.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\nPROCEDURE Main( cPortName )\n\n LOCAL oWinPort := win_com():Init( cPortName, WIN_CBR_9600, WIN_NOPARITY, 8, WIN_ONESTOPBIT )\n LOCAL cString := \"ATE0\" + Chr( 13 ) + \"ATI3\" + Chr( 13 )\n LOCAL nResult\n\n IF ! oWinPort:Open()\n ? \"Open() failed\"\n ELSE\n ? \"Open() succeeded\"\n ?\n IF oWinPort:SetDTR( .T. )\n ? \"SetDTR( .T. ) succeeded\"\n ELSE\n ? \"SetDTR( .T. ) failed :\", oWinPort:ErrorText()\n ENDIF\n IF ( nResult := oWinPort:Write( cString ) ) == Len( cString )\n ? \"Write() succeeded\"\n ELSE\n ? \"Write() failed, returned \", nResult, \" expected \", Len( cString )\n ENDIF\n ? \"Scan something... we'll not read it but purge it, press enter\"\n Inkey( 0 )\n ? \"Read() \", oWinPort:Read( @cString, 32 ), Len( cString ), cString\n ? oWinPort:ErrorText()\n ? \"Close\", oWinPort:Close()\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour source file: src/rdd/dbupdat.prg. Provides functions: __dbUpdate. This file implements core Record Driver Driver functionality"}, {"role": "assistant", "content": "FUNCTION __dbUpdate( cAlias, bKey, lRandom, bAssign )\n\n LOCAL nOldArea := Select()\n LOCAL xKey\n\n LOCAL oError\n LOCAL lError := .F.\n\n __defaultNIL( @lRandom, .F. )\n\n dbGoTop()\n\n BEGIN SEQUENCE\n\n dbSelectArea( cAlias )\n dbGoTop()\n DO WHILE ! Eof()\n\n xKey := Eval( bKey )\n\n dbSelectArea( nOldArea )\n IF lRandom\n IF dbSeek( xKey )\n Eval( bAssign )\n ENDIF\n ELSE\n DO WHILE Eval( bKey ) < xKey .AND. ! Eof()\n dbSkip()\n ENDDO\n\n IF Eval( bKey ) == xKey .AND. ! Eof()\n Eval( bAssign )\n ENDIF\n ENDIF\n\n dbSelectArea( cAlias )\n dbSkip()\n ENDDO\n\n RECOVER USING oError\n lError := .T.\n END SEQUENCE\n\n dbSelectArea( nOldArea )\n\n IF lError\n Break( oError )\n ENDIF\n\n RETURN .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbmysql' (MySQL database client library): contrib/hbmysql/tsqlbrw.prg. Defines classes: TBColumnSQL, TBrowseSQL. Provides functions: Skipper. This file handles database operations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"inkey.ch\"\n#include \"dbstruct.ch\"\n\n#include \"mysql.ch\"\n\n\nCREATE CLASS TBColumnSQL FROM TBColumn\n\n VAR oBrw \n \n\n VAR nFieldNum \n\n MESSAGE Block METHOD Block() \n \n \n METHOD New( cHeading, bBlock, oBrw ) \n\nENDCLASS\n\n\nMETHOD New( cHeading, bBlock, oBrw ) CLASS TBColumnSQL\n\n ::super:New( cHeading, bBlock )\n ::oBrw := oBrw\n\n RETURN Self\n\n\nMETHOD Block() CLASS TBColumnSQL\n\n LOCAL xValue := ::oBrw:oCurRow:FieldGet( ::nFieldNum )\n LOCAL xType := ::oBrw:oCurRow:FieldType( ::nFieldNum )\n\n DO CASE\n CASE xType == \"N\"\n xValue := \"'\" + Str( xValue, ::oBrw:oCurRow:FieldLen( ::nFieldNum ), ::oBrw:oCurRow:FieldDec( ::nFieldNum ) ) + \"'\"\n\n CASE xType == \"D\"\n xValue := \"'\" + DToC( xValue ) + \"'\"\n\n CASE xType == \"L\"\n xValue := iif( xValue, \".T.\", \".F.\" )\n\n CASE xType == \"C\"\n \n \n xValue := '\"' + StrTran( xValue, '\"', e\"\\\" + '\\\"' + \\\"\" ) + '\"'\n\n CASE xType == \"M\"\n xValue := \"' '\"\n\n OTHERWISE\n xValue := \"'\" + xValue + \"'\"\n ENDCASE\n\n RETURN hb_macroBlock( xValue )\n\n\nCREATE CLASS TBrowseSQL FROM TBrowse\n\n VAR oCurRow \n VAR oQuery \n\n METHOD New( nTop, nLeft, nBottom, nRight, oServer, oQuery, cTable )\n\n METHOD EditField() \n \n\n METHOD BrowseTable( lCanEdit, aExitKeys ) \n \n \n METHOD KeyboardHook( nKey ) \n\nENDCLASS\n\n\nMETHOD New( nTop, nLeft, nBottom, nRight, oServer, oQuery, cTable ) CLASS TBrowseSQL\n\n LOCAL i, oCol\n\n HB_SYMBOL_UNUSED( oServer )\n HB_SYMBOL_UNUSED( cTable )\n\n ::super:New( nTop, nLeft, nBottom, nRight )\n\n ::oQuery := oQuery\n\n \n ::oCurRow := ::oQuery:GetRow( 1 )\n\n \n ::SkipBlock := {| n | ::oCurRow := Skipper( @n, ::oQuery ), n }\n ::GoBottomBlock := {|| ::oCurRow := ::oQuery:GetRow( ::oQuery:LastRec() ), 1 }\n ::GoTopBlock := {|| ::oCurRow := ::oQuery:GetRow( 1 ), 1 }\n\n \n FOR i := 1 TO ::oQuery:FCount()\n\n \n oCol := TBColumnSQL():New( ::oCurRow:FieldName( i ),, Self )\n\n IF !( ::oCurRow:FieldType( i ) == \"M\" )\n oCol:Width := Max( ::oCurRow:FieldLen( i ), Len( oCol:Heading ) )\n ELSE\n oCol:Width := 10\n ENDIF\n\n \n oCol:nFieldNum := i\n\n \n DO CASE\n CASE ::oCurRow:FieldType( i ) == \"N\"\n oCol:picture := Replicate( \"9\", oCol:Width )\n\n CASE ::oCurRow:FieldType( i ) $ \"CM\"\n oCol:picture := Replicate( \"!\", oCol:Width )\n ENDCASE\n\n ::AddColumn( oCol )\n NEXT\n\n RETURN Self\n\nSTATIC FUNCTION Skipper( nSkip, oQuery )\n\n LOCAL i := 0\n\n DO CASE\n CASE nSkip == 0 .OR. oQuery:LastRec() == 0\n oQuery:Skip( 0 )\n\n CASE nSkip > 0\n DO WHILE i < nSkip \n\n IF oQuery:recno() == oQuery:lastrec()\n EXIT\n ENDIF\n oQuery:Skip( 1 )\n i++\n\n ENDDO\n\n CASE nSkip < 0\n DO WHILE i > nSkip \n\n IF oQuery:recno() == 1\n EXIT\n ENDIF\n\n oQuery:Skip( -1 )\n i--\n\n ENDDO\n ENDCASE\n\n nSkip := i\n\n RETURN oQuery:GetRow( oQuery:RecNo() )\n\n\nMETHOD EditField() CLASS TBrowseSQL\n\n LOCAL oCol\n LOCAL aGetList\n LOCAL nKey\n LOCAL cMemoBuff, cMemo\n\n \n oCol := ::getColumn( ::colPos )\n\n \n IF ::oCurRow:FieldType( oCol:nFieldNum ) == \"M\"\n\n \n cMemoBuff := SaveScreen( 10, 10, 22, 69 )\n\n hb_Scroll( 10, 10, 22, 69, 0 )\n hb_DispBox( 10, 10, 22, 69 )\n\n \n cMemo := MemoEdit( ::oCurRow:FieldGet( oCol:nFieldNum ), 11, 11, 21, 68, .T. )\n\n IF LastKey() == K_CTRL_END\n ::oCurRow:FieldPut( oCol:nFieldNum, cMemo )\n\n \n IF ! ::oQuery:Update( ::oCurRow )\n Alert( Left( ::oQuery:Error(), 60 ) )\n ENDIF\n ENDIF\n\n RestScreen( 10, 10, 22, 69, cMemoBuff )\n\n ELSE\n \n \n aGetList := { GetNew( Row(), Col(),;\n {| xValue | iif( xValue == NIL, Eval( oCol:Block ), ::oCurRow:FieldPut( oCol:nFieldNum, xValue ) ) },;\n oCol:heading,;\n oCol:picture,;\n ::colorSpec ) }\n\n \n ReadModal( aGetList )\n \n\n IF ! ::oQuery:Update( ::oCurRow )\n Alert( Left( ::oQuery:Error(), 60 ) )\n ENDIF\n\n endif\n\n IF ! ::oQuery:Refresh()\n Alert( ::oQuery:Error() )\n ENDIF\n\n ::RefreshAll()\n\n \n nKey := LastKey()\n IF nKey == K_UP .OR. nKey == K_DOWN .OR. ;\n nKey == K_PGUP .OR. nKey == K_PGDN\n\n \n hb_keyIns( nKey )\n\n ENDIF\n\n RETURN Self\n\n\nMETHOD BrowseTable( lCanEdit, aExitKeys ) CLASS TBrowseSQL\n\n LOCAL nKey\n LOCAL lKeepGoing := .T.\n\n IF ! HB_ISNUMERIC( nKey )\n nKey := NIL\n ENDIF\n hb_default( @lCanEdit, .F. )\n hb_default( @aExitKeys, { K_ESC } )\n\n DO WHILE lKeepGoing\n\n DO WHILE .T.\n nKey := Inkey()\n IF ::Stabilize() .AND. nKey != 0\n EXIT\n ENDIF\n ENDDO\n\n IF nKey == 0\n nKey := Inkey( 0 )\n ENDIF\n\n IF AScan( aExitKeys, nKey ) > 0\n lKeepGoing := .F.\n LOOP\n ENDIF\n\n DO CASE\n CASE nKey == K_DOWN\n ::down()\n\n CASE nKey == K_PGDN\n ::pageDown()\n\n CASE nKey == K_CTRL_PGDN\n ::goBottom()\n\n CASE nKey == K_UP\n ::up()\n\n CASE nKey == K_PGUP\n ::pageUp()\n\n CASE nKey == K_CTRL_PGUP\n ::goTop()\n\n CASE nKey == K_RIGHT\n ::right()\n\n CASE nKey == K_LEFT\n ::left()\n\n CASE nKey == K_HOME\n ::home()\n\n CASE nKey == K_END\n ::end()\n\n CASE nKey == K_CTRL_LEFT\n ::panLeft()\n\n CASE nKey == K_CTRL_RIGHT\n ::panRight()\n\n CASE nKey == K_CTRL_HOME\n ::panHome()\n\n CASE nKey == K_CTRL_END\n ::panEnd()\n\n CASE nKey == K_ENTER .AND. lCanEdit\n ::EditField()\n\n\n OTHERWISE\n ::KeyboardHook( nKey )\n ENDCASE\n ENDDO\n\n RETURN Self\n\n\nMETHOD KeyboardHook( nKey ) CLASS TBrowseSQL\n\n HB_SYMBOL_UNUSED( nKey )\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/pdfcreat.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\nPROCEDURE Main()\n\n LOCAL oPC, nTime, cDefaultPrinter, cFilename, oPrinter, nEvent := 0\n\n IF Empty( oPC := win_oleCreateObject( \"PDFCreator.clsPDFCreator\" ) )\n ? \"Unable to create PDFCreator COM object\"\n RETURN\n ENDIF\n\n cFilename := hb_ProgName()\n\n \n oPC:__hSink := __axRegisterHandler( oPC:__hObj, {| X | nEvent := X } )\n\n oPC:cStart( \"/NoProcessingAtStartup\" )\n oPC:_cOption( \"UseAutosave\", 1 )\n oPC:_cOption( \"UseAutosaveDirectory\", 1 )\n oPC:_cOption( \"AutosaveDirectory\", Left( cFileName, RAt( hb_ps(), cFilename ) - 1 ) )\n oPC:_cOption( \"AutosaveFilename\", \"pdfcreat.pdf\" )\n oPC:_cOption( \"AutosaveFormat\", 0 )\n\n cDefaultPrinter := oPC:cDefaultPrinter\n oPC:cDefaultPrinter := \"PDFCreator\"\n oPC:cClearCache()\n\n \n#if 1\n oPrinter := win_Prn():New( \"PDFCreator\" )\n oPrinter:Create()\n oPrinter:startDoc( \"Harbour print job via PDFCreator\" )\n oPrinter:NewLine()\n oPrinter:NewLine()\n oPrinter:TextOut( \"Hello, PDFCreator! This is Harbour :)\" )\n oPrinter:EndDoc()\n oPrinter:Destroy()\n#else\n oPrinter := NIL\n ? \"Do some printing to PDFCreator printer and press any key...\"\n Inkey( 0 )\n#endif\n\n oPC:cPrinterStop := .F.\n\n nTime := hb_MilliSeconds()\n DO WHILE nEvent == 0 .AND. hb_MilliSeconds() - nTime < 10000\n hb_idleSleep( 0.5 )\n \n oPC:cOption( \"UseAutosave\" )\n ENDDO\n\n IF nEvent == 0\n ? \"Print timeout\"\n ELSEIF nEvent == 1\n ? \"Printed successfully\"\n ELSEIF nEvent == 2\n ? \"Error:\", oPC:cError():Description\n ELSE\n ? \"Unknown event\"\n ENDIF\n\n oPC:cDefaultPrinter := cDefaultPrinter\n oPC:cClose()\n oPC := NIL\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/csetarge.prg. Provides functions: myerrhandler. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#else\n#define hb_ntos( n ) LTrim( Str( n ) )\n#endif\n\n#include \"ct.ch\"\n\nPROCEDURE Main()\n\n LOCAL cRet, olderr\n\n ctinit()\n\n ? \"Begin test of CSetArgErr()\"\n ?\n\n ?\n ? \"Local error handler: \"\n\n olderr := ErrorBlock( {| oerr | myerrhandler( oerr ) } )\n\n \n ?\n ? \"Standard behaviour\"\n ? \" Call to AddAscii( 5789676, 1, 2, .T. ):\"\n cRet := AddAscii( 5789676, 1, 2, .T. )\n ? \" return value was\", cRet\n ?\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n \n ?\n ? \"CT_ARGERR_WHOCARES behaviour\"\n CSetArgErr( CT_ARGERR_WHOCARES )\n ? \" Call to AddAscii( 5789676, 1, 2, .T. ):\"\n cRet := AddAscii( 5789676, 1, 2, .T. )\n ? \" return value was\", cRet\n ?\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n \n ?\n ? \"CT_ARGERR_WARNING behaviour\"\n CSetArgErr( CT_ARGERR_WARNING )\n ? \" Call to AddAscii( 5789676, 1, 2, .T. ):\"\n cRet := AddAscii( 5789676, 1, 2, .T. )\n ? \" return value was\", cRet\n ?\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n \n ?\n ? \"CT_ARGERR_ERROR behaviour\"\n CSetArgErr( CT_ARGERR_ERROR )\n ? \" Call to AddAscii( 5789676, 1, 2, .T. ):\"\n cRet := AddAscii( 5789676, 1, 2, .T. )\n ? \" return value was\", cRet\n ?\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n \n ?\n ? \"CT_ARGERR_CATASTROPHIC behaviour\"\n CSetArgErr( CT_ARGERR_CATASTROPHIC )\n ? \" Call to AddAscii( 5789676, 1, 2, .T. ):\"\n cRet := AddAscii( 5789676, 1, 2, .T. )\n ? \" return value was\", cRet\n ?\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n ?\n ? \"Standard error handler: \"\n ErrorBlock( olderr )\n\n \n ?\n ? \"Standard behaviour\"\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n \n ?\n ? \"CT_ARGERR_WHOCARES behaviour\"\n CSetArgErr( CT_ARGERR_WHOCARES )\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n \n ?\n ? \"CT_ARGERR_WARNING behaviour\"\n CSetArgErr( CT_ARGERR_WARNING )\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n \n ?\n ? \"CT_ARGERR_ERROR behaviour\"\n CSetArgErr( CT_ARGERR_ERROR )\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n \n ?\n ? \"CT_ARGERR_CATASTROPHIC behaviour\"\n CSetArgErr( CT_ARGERR_CATASTROPHIC )\n ? \" Call to CharAdd( 'AA', .F. ):\"\n cRet := CharAdd( \"AA\", .F. )\n ? \" return value was\", cRet, \"\"\n ?\n Inkey( 0 )\n\n ? \"End test of CSetArgErr()\"\n\n ctexit()\n\n RETURN\n\nFUNCTION myerrhandler( oerr )\n\n LOCAL ni, nDigit\n\n LOCAL cInput\n\n ? \" Error handler called:\"\n ? \" err:severity.....:\", oerr:severity\n ? \" err:subSystem....:\", oerr:subSystem\n ? \" err:operation....:\", oerr:operation\n ? \" Len(err:args)....:\", Len( oerr:args )\n FOR ni := 1 TO Len( oerr:args )\n ? \" err:args[\" + hb_ntos( ni ) + \"]..:\", oerr:args[ ni ]\n NEXT\n ? \" err:genCode......:\", oerr:genCode\n ? \" err:subCode......:\", oerr:subCode\n ? \" err:osCode.......:\", oerr:osCode\n ? \" err:filename.....:\", oerr:filename\n ? \" err:tries........:\", oerr:tries\n ? \" err:cargo........:\", oerr:cargo\n ? \" err:canDefault...:\", oerr:canDefault\n ? \" err:canRetry.....:\", oerr:canRetry\n ? \" err:canSubstitute:\", oerr:canSubstitute\n ?\n\n IF oerr:canSubstitute\n\n ? \" Error handler can substitute return value, so please\"\n ACCEPT \" type in return value : \" TO cInput\n\n IF Empty( cInput )\n ? \" You have chosen the default return value. Ok, this should \"\n ? \" be now problem, since the last digit of err:subCode indicates\"\n ? \" the type of the return value:\"\n ? \" 0 is NIL, 1 is String, 2 is Integer,\"\n ? \" 3 is Float, 4 is Boolean, 5 is Date\"\n ? \" 6 is Block, 7 is Array, 8 is Object\"\n ? \" 9 is unknown\"\n nDigit := Int( oerr:subCode % 10 )\n ? \" Here it's a \" + hb_ntos( nDigit ) + \", so I return a \"\n DO CASE\n CASE nDigit == 0\n ?? \"NIL.\"\n cInput := NIL\n\n CASE nDigit == 1\n ?? \"String.\"\n cInput := \"\"\n\n CASE nDigit == 2\n ?? \"Integer.\"\n cInput := 0\n\n CASE nDigit == 3\n ?? \"Float.\"\n cInput := 0.0\n\n CASE nDigit == 4\n ?? \"Boolean.\"\n cInput := .F.\n\n CASE nDigit == 5\n ?? \"Date.\"\n cInput := CToD( \"\" ) \n\n CASE nDigit == 6\n ?? \"Block.\"\n cInput := {|| NIL }\n\n CASE nDigit == 7\n ?? \"Array.\"\n cInput := {}\n\n CASE nDigit == 8\n ?? \"Object.\"\n cInput := GetNew()\n\n CASE nDigit == 9\n ?? \" \"' + CharMix( \"ABC\", \"123\" ) + '\"'\n ? ' CharMix( \"ABCDE\", \"12\" ) == \"A1B2C1D2E1\" ? --> \"' + CharMix( \"ABCDE\", \"12\" ) + '\"'\n ? ' CharMix( \"AB\", \"12345\" ) == \"A1B2\" ? --> \"' + CharMix( \"AB\", \"12345\" ) + '\"'\n ? ' CharMix( \"HELLO\", \" \" ) == \"H E L L O \" ? --> \"' + CharMix( \"HELLO\", \" \" ) + '\"'\n ? ' CharMix( \"HELLO\", \"\" ) == \"HELLO\" ? --> \"' + CharMix( \"HELLO\", \"\" ) + '\"'\n ?\n\n ? \"End test of CharMix()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/encoder.prg. Defines classes: TIPEncoder. Provides functions: tip_GetEncoder. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"fileio.ch\"\n\nCREATE CLASS TIPEncoder\n\n VAR cName\n\n METHOD New( cMode )\n METHOD Encode( cData )\n METHOD Decode( cData )\n\nENDCLASS\n\n#define MODE_PASSTHROUGH \"as-is\"\n\nMETHOD New( cMode ) CLASS TIPEncoder\n\n ::cName := Lower( hb_defaultValue( cMode, MODE_PASSTHROUGH ) )\n\n RETURN Self\n\nMETHOD Encode( cData ) CLASS TIPEncoder\n RETURN iif( ::cName == MODE_PASSTHROUGH, cData, tip_GetEncoder( ::cName ):Encode( cData ) )\n\nMETHOD Decode( cData ) CLASS TIPEncoder\n RETURN iif( ::cName == MODE_PASSTHROUGH, cData, tip_GetEncoder( ::cName ):Decode( cData ) )\n\nFUNCTION tip_GetEncoder( cMode )\n\n SWITCH Lower( hb_defaultValue( cMode, MODE_PASSTHROUGH ) )\n CASE \"base64\" ; RETURN TIPEncoderBase64():New()\n CASE \"quoted-printable\" ; RETURN TIPEncoderQP():New()\n CASE \"url\"\n CASE \"urlencoded\" ; RETURN TIPEncoderUrl():New()\n ENDSWITCH\n\n RETURN TIPEncoder():New()"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbpgsql' (PostgreSQL database client library): contrib/hbpgsql/tests/dbf2pg.prg. Contains procedures: Main, Help. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbpgsql\"\n\n#include \"fileio.ch\"\n#include \"inkey.ch\"\n\n#include \"hbextcdp.ch\"\n\nPROCEDURE Main()\n\n LOCAL cHostName\n LOCAL cUser\n LOCAL cPassword\n LOCAL cDatabase := \"postgres\", cTable, cFile\n LOCAL i\n LOCAL lCreateTable := .F.\n LOCAL oServer, oTable, oRecord\n LOCAL cField\n LOCAL cTypeDB\n LOCAL cTypePG\n LOCAL cValue\n LOCAL nCommit := 100\n LOCAL hFile\n LOCAL nCount := 0\n LOCAL nRecno := 0\n LOCAL lTruncate := .F.\n LOCAL lUseTrans := .F.\n LOCAL cPath := \"public\"\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n Set( _SET_DELETED, .T. )\n\n \n FOR i := 1 TO PCount()\n\n SWITCH hb_PValue( i )\n CASE \"-h\" ; cHostName := hb_PValue( ++i ) ; EXIT\n CASE \"-d\" ; cDatabase := hb_PValue( ++i ) ; EXIT\n CASE \"-t\" ; cTable := AllTrim( hb_PValue( ++i ) ) ; EXIT\n CASE \"-f\" ; cFile := hb_PValue( ++i ) ; EXIT\n CASE \"-u\" ; cUser := hb_PValue( ++i ) ; EXIT\n CASE \"-p\" ; cPassword := hb_PValue( ++i ) ; EXIT\n CASE \"-c\" ; lCreateTable := .T. ; EXIT\n CASE \"-x\" ; lTruncate := .T. ; EXIT\n CASE \"-s\" ; lUseTrans := .T. ; EXIT\n CASE \"-m\" ; nCommit := Val( hb_PValue( ++i ) ) ; EXIT\n CASE \"-r\" ; nRecno := Val( hb_PValue( ++i ) ) ; EXIT\n CASE \"-e\" ; cPath := hb_PValue( ++i ) ; EXIT\n CASE \"-cp\" ; Set( _SET_DBCODEPAGE, hb_PValue( ++i ) ) ; EXIT\n OTHERWISE\n help()\n RETURN\n ENDSWITCH\n NEXT\n\n IF Empty( cTable ) .OR. cFile == \"\"\n help()\n RETURN\n ENDIF\n\n \n IF ( hFile := hb_vfOpen( cTable + \".log\", FO_CREAT + FO_TRUNC + FO_WRITE ) ) == NIL\n ? \"Cannot create log file\"\n RETURN\n ENDIF\n\n USE ( cFile ) SHARED READONLY\n\n oServer := TPQServer():New( cHostName, cDatabase, cUser, cPassword, , cPath )\n IF oServer:NetErr()\n ? oServer:ErrorMsg()\n RETURN\n ENDIF\n\n oServer:lallCols := .F.\n\n IF lCreateTable\n IF oServer:TableExists( cTable )\n oServer:DeleteTable( cTable )\n IF oServer:NetErr()\n ? oServer:ErrorMsg()\n hb_vfWrite( hFile, \"Error: \" + oServer:ErrorMsg() + hb_eol() )\n hb_vfClose( hFile )\n RETURN\n ENDIF\n ENDIF\n\n oServer:CreateTable( cTable, dbStruct() )\n IF oServer:NetErr()\n ? oServer:ErrorMsg()\n hb_vfWrite( hFile, \"Error: \" + oServer:ErrorMsg() + hb_eol() )\n hb_vfClose( hFile )\n RETURN\n ENDIF\n ENDIF\n\n IF lTruncate\n oServer:Execute( \"truncate table \" + cTable )\n IF oServer:NetErr()\n ? oServer:ErrorMsg()\n hb_vfWrite( hFile, \"Error: \" + oServer:ErrorMsg() + hb_eol() )\n hb_vfClose( hFile )\n RETURN\n ENDIF\n ENDIF\n\n oTable := oServer:Query( \"SELECT * FROM \" + cTable + \" LIMIT 1\" )\n IF oTable:NetErr()\n ? oTable:ErrorMsg()\n hb_vfWrite( hFile, \"Error: \" + oTable:ErrorMsg() + hb_eol() )\n hb_vfClose( hFile )\n RETURN\n ENDIF\n\n IF lUseTrans\n oServer:StartTransaction()\n ENDIF\n\n hb_vfWrite( hFile, \"Start: \" + Time() + hb_eol() )\n\n ? \"Start:\", Time()\n ?\n\n IF nRecno != 0\n dbGoto( nRecno )\n ENDIF\n\n DO WHILE ! Eof() .AND. hb_keyStd( Inkey() ) != K_ESC .AND. ( nRecno == 0 .OR. nRecno == RecNo() )\n oRecord := oTable:GetBlankRow()\n\n FOR i := 1 TO oTable:FCount()\n cField := Lower( oTable:FieldName( i ) )\n cTypeDB := Left( hb_FieldType( FieldPos( cField ) ), 1 )\n cTypePG := oRecord:FieldType( i )\n cValue := FieldGet( FieldPos( cField ) )\n\n IF cValue != NIL\n IF cTypePG != cTypeDB\n DO CASE\n CASE cTypePG == \"C\" .AND. cTypeDB $ \"NIYF8BZ24\" ; cValue := hb_ntos( cValue )\n CASE cTypePG == \"C\" .AND. cTypeDB == \"D\" ; cValue := DToC( cValue )\n CASE cTypePG == \"C\" .AND. cTypeDB $ \"T@\" ; cValue := hb_TToC( cValue )\n CASE cTypePG == \"C\" .AND. cTypeDB == \"L\" ; cValue := iif( cValue, \"S\", \"N\" )\n CASE cTypePG == \"N\" .AND. cTypeDB $ \"CQ\" ; cValue := Val( cValue )\n CASE cTypePG == \"N\" .AND. cTypeDB == \"D\" ; cValue := Val( DToS( cValue ) )\n CASE cTypePG == \"N\" .AND. cTypeDB == \"L\" ; cValue := iif( cValue, 1, 0 )\n CASE cTypePG == \"D\" .AND. cTypeDB $ \"CQ\" ; cValue := CToD( cValue )\n CASE cTypePG == \"D\" .AND. cTypeDB $ \"NIYF8BZ24\" ; cValue := hb_SToD( hb_ntos( cValue ) )\n CASE cTypePG == \"L\" .AND. cTypeDB $ \"NIYF8BZ24\" ; cValue := ! Empty( cValue )\n CASE cTypePG == \"L\" .AND. cTypeDB $ \"CQ\" ; cValue := AllTrim( cValue ) $ \"YySs1\"\n ENDCASE\n ENDIF\n\n IF cValue != NIL\n IF oRecord:FieldType( i ) == \"C\" .OR. oRecord:FieldType( i ) == \"M\"\n oRecord:FieldPut( i, hb_StrToUTF8( cValue ) )\n ELSE\n oRecord:FieldPut( i, cValue )\n ENDIF\n ENDIF\n ENDIF\n NEXT\n\n oTable:Append( oRecord )\n\n IF oTable:NetErr()\n ?\n ? \"Error Record:\", RecNo(), Left( oTable:ErrorMsg(), 70 )\n ?\n hb_vfWrite( hFile, \"Error at record: \" + hb_ntos( RecNo() ) + \" Description: \" + oTable:ErrorMsg() + hb_eol() )\n ELSE\n nCount++\n ENDIF\n\n dbSkip()\n\n IF nCount % nCommit == 0\n DevPos( Row(), 1 )\n DevOut( \"imported recs:\", hb_ntos( nCount ) )\n\n IF lUseTrans\n oServer:commit()\n oServer:StartTransaction()\n ENDIF\n ENDIF\n ENDDO\n\n IF nCount % nCommit != 0 .AND. lUseTrans\n oServer:commit()\n ENDIF\n\n hb_vfWrite( hFile, \"End: \" + Time() + \", records in dbf: \" + hb_ntos( RecNo() ) + \", imported recs: \" + hb_ntos( nCount ) + hb_eol() )\n\n ? \"End:\", Time()\n\n hb_vfClose( hFile )\n\n dbCloseAll()\n\n oTable:Destroy()\n oServer:Destroy()\n\n RETURN\n\nSTATIC PROCEDURE Help()\n\n ? \"dbf2pg - dbf file to PostgreSQL table conversion utility\"\n ? \"-h hostname\"\n ? \"-u user\"\n ? \"-p password\"\n ? \"-d name of database to use (default: postgres)\"\n ? \"-t name of table to add records to (required)\"\n ? \"-c delete existing table and create a new one\"\n ? \"-f name of .dbf file to import (required)\"\n ? \"-x truncate table before append records\"\n ? \"-s use transaction\"\n ? \"-m commit interval\"\n ? \"-r insert only record number\"\n ? \"-e search path\"\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/ftp_ul.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbtip\"\n\n#include \"directry.ch\"\n\nPROCEDURE Main( cURL, cMask )\n\n LOCAL lRetVal := .T.\n\n LOCAL aFiles, aFile\n LOCAL oFTP, oURL\n\n \n IF ! Empty( aFiles := hb_vfDirectory( hb_defaultValue( cMask, hb_osFileMask() ) ) )\n\n hb_default( @cURL, \"ftp:\n\n oURL := TUrl():New( cURL )\n\n oFTP := TIPClientFTP():New( oURL, .T. )\n oFTP:nConnTimeout := 20000\n oFTP:bUsePasv := .T.\n\n IF oFTP:Open( cURL )\n FOR EACH aFile IN aFiles\n ? \"Filename:\", aFile[ F_NAME ]\n IF ! oFtp:UploadFile( aFile[ F_NAME ] )\n lRetVal := .F.\n EXIT\n ENDIF\n NEXT\n oFTP:Close()\n ELSE\n ? \"Could not connect to FTP server\", oURL:cServer\n IF oFTP:SocketCon == NIL\n ? \"Connection not initialized\"\n ELSEIF hb_inetErrorCode( oFTP:SocketCon ) == 0\n ? \"Server response:\", oFTP:cReply\n ELSE\n ? \"Error in connection:\", hb_inetErrorDesc( oFTP:SocketCon )\n ENDIF\n lRetVal := .F.\n ENDIF\n ENDIF\n\n ErrorLevel( iif( lRetVal, 0, 1 ) )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/metaph.prg. Provides functions: ft_Metaph, _ftMakeAlpha, _ftConvVowel. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_Metaph( cName, nSize ) \n\n LOCAL cMeta\n\n __defaultNIL( @cName, \"\" ) \n __defaultNIL( @nSize, 4 ) \n\n \n cMeta := \" \" + _ftMakeAlpha( Upper( AllTrim( cName ) ) ) + \" \"\n\n \n IF \" KN\" $ cMeta ; cMeta := StrTran( cMeta, \" KN\" , \" N\" ) ; ENDIF\n IF \" GN\" $ cMeta ; cMeta := StrTran( cMeta, \" GN\" , \" N\" ) ; ENDIF\n IF \" PN\" $ cMeta ; cMeta := StrTran( cMeta, \" PN\" , \" N\" ) ; ENDIF\n IF \" AE\" $ cMeta ; cMeta := StrTran( cMeta, \" AE\" , \" E\" ) ; ENDIF\n IF \" X\" $ cMeta ; cMeta := StrTran( cMeta, \" X\" , \" S\" ) ; ENDIF\n IF \" WR\" $ cMeta ; cMeta := StrTran( cMeta, \" WR\" , \" R\" ) ; ENDIF\n IF \" WHO\" $ cMeta ; cMeta := StrTran( cMeta, \" WHO\" , \" H\" ) ; ENDIF\n IF \" WH\" $ cMeta ; cMeta := StrTran( cMeta, \" WH\" , \" W\" ) ; ENDIF\n IF \" MCG\" $ cMeta ; cMeta := StrTran( cMeta, \" MCG\" , \" MK\" ) ; ENDIF\n IF \" MC\" $ cMeta ; cMeta := StrTran( cMeta, \" MC\" , \" MK\" ) ; ENDIF\n IF \" MACG\" $ cMeta ; cMeta := StrTran( cMeta, \" MACG\", \" MK\" ) ; ENDIF\n IF \" MAC\" $ cMeta ; cMeta := StrTran( cMeta, \" MAC\" , \" MK\" ) ; ENDIF\n IF \" GI\" $ cMeta ; cMeta := StrTran( cMeta, \" GI\" , \" K\" ) ; ENDIF\n\n \n IF \"MB \" $ cMeta ; cMeta := StrTran( cMeta, \"MB \", \"M \" ) ; ENDIF\n IF \"NG \" $ cMeta ; cMeta := StrTran( cMeta, \"NG \", \"N \" ) ; ENDIF\n\n \n IF \" \" $ SubStr( cMeta, 2, Len( cMeta ) - 2 )\n cMeta := \" \" + StrTran( cMeta, \" \" ) + \" \"\n ENDIF\n\n \n IF \"BB\" $ cMeta ; cMeta := StrTran( cMeta, \"BB\", \"B\" ) ; ENDIF\n IF \"CC\" $ cMeta ; cMeta := StrTran( cMeta, \"CC\", \"CH\" ) ; ENDIF\n IF \"DD\" $ cMeta ; cMeta := StrTran( cMeta, \"DD\", \"T\" ) ; ENDIF\n IF \"FF\" $ cMeta ; cMeta := StrTran( cMeta, \"FF\", \"F\" ) ; ENDIF\n IF \"GG\" $ cMeta ; cMeta := StrTran( cMeta, \"GG\", \"K\" ) ; ENDIF\n IF \"KK\" $ cMeta ; cMeta := StrTran( cMeta, \"KK\", \"K\" ) ; ENDIF\n IF \"LL\" $ cMeta ; cMeta := StrTran( cMeta, \"LL\", \"L\" ) ; ENDIF\n IF \"MM\" $ cMeta ; cMeta := StrTran( cMeta, \"MM\", \"M\" ) ; ENDIF\n IF \"NN\" $ cMeta ; cMeta := StrTran( cMeta, \"NN\", \"N\" ) ; ENDIF\n IF \"PP\" $ cMeta ; cMeta := StrTran( cMeta, \"PP\", \"P\" ) ; ENDIF\n IF \"RR\" $ cMeta ; cMeta := StrTran( cMeta, \"RR\", \"R\" ) ; ENDIF\n IF \"SS\" $ cMeta ; cMeta := StrTran( cMeta, \"SS\", \"S\" ) ; ENDIF\n IF \"TT\" $ cMeta ; cMeta := StrTran( cMeta, \"TT\", \"T\" ) ; ENDIF\n IF \"XX\" $ cMeta ; cMeta := StrTran( cMeta, \"XX\", \"KS\" ) ; ENDIF\n IF \"ZZ\" $ cMeta ; cMeta := StrTran( cMeta, \"ZZ\", \"S\" ) ; ENDIF\n\n \n IF \"DGE\" $ cMeta ; cMeta := StrTran( cMeta, \"DGE\", \"J\" ) ; ENDIF\n IF \"DGY\" $ cMeta ; cMeta := StrTran( cMeta, \"DGY\", \"J\" ) ; ENDIF\n IF \"DGI\" $ cMeta ; cMeta := StrTran( cMeta, \"DGI\", \"J\" ) ; ENDIF\n IF \"GI\" $ cMeta ; cMeta := StrTran( cMeta, \"GI\" , \"J\" ) ; ENDIF\n IF \"GE\" $ cMeta ; cMeta := StrTran( cMeta, \"GE\" , \"J\" ) ; ENDIF\n IF \"GY\" $ cMeta ; cMeta := StrTran( cMeta, \"GY\" , \"J\" ) ; ENDIF\n\n \n IF \"X\" $ cMeta ; cMeta := StrTran( cMeta, \"X\", \"KS\" ) ; ENDIF\n\n \n IF \"ISCH\" $ cMeta; cMeta := StrTran( cMeta, \"ISCH\", \"IX\" ) ; ENDIF\n IF \"SCH\" $ cMeta; cMeta := StrTran( cMeta, \"SCH\" , \"SK\" ) ; ENDIF\n\n \n IF \"CIA\" $ cMeta ; cMeta := StrTran( cMeta, \"CIA\", \"X\" ) ; ENDIF\n IF \"SIO\" $ cMeta ; cMeta := StrTran( cMeta, \"SIO\", \"X\" ) ; ENDIF\n IF \"C\" $ cMeta ; cMeta := StrTran( cMeta, \"SIA\", \"X\" ) ; ENDIF\n IF \"SH\" $ cMeta ; cMeta := StrTran( cMeta, \"SH\" , \"X\" ) ; ENDIF\n IF \"TIA\" $ cMeta ; cMeta := StrTran( cMeta, \"TIA\", \"X\" ) ; ENDIF\n IF \"TIO\" $ cMeta ; cMeta := StrTran( cMeta, \"TIO\", \"X\" ) ; ENDIF\n IF \"TCH\" $ cMeta ; cMeta := StrTran( cMeta, \"TCH\", \"X\" ) ; ENDIF\n IF \"CH\" $ cMeta ; cMeta := StrTran( cMeta, \"CH\" , \"X\" ) ; ENDIF\n\n \n IF \"SCI\" $ cMeta ; cMeta := StrTran( cMeta, \"SCI\", \"S\" ) ; ENDIF\n IF \"SCE\" $ cMeta ; cMeta := StrTran( cMeta, \"SCE\", \"S\" ) ; ENDIF\n IF \"SCY\" $ cMeta ; cMeta := StrTran( cMeta, \"SCY\", \"S\" ) ; ENDIF\n IF \"CI\" $ cMeta ; cMeta := StrTran( cMeta, \"CI\" , \"S\" ) ; ENDIF\n IF \"CE\" $ cMeta ; cMeta := StrTran( cMeta, \"CE\" , \"S\" ) ; ENDIF\n IF \"CY\" $ cMeta ; cMeta := StrTran( cMeta, \"CY\" , \"S\" ) ; ENDIF\n IF \"Z\" $ cMeta ; cMeta := StrTran( cMeta, \"Z\" , \"S\" ) ; ENDIF\n\n \n IF \"TH\" $ cMeta ; cMeta := StrTran( cMeta, \"TH\" , \"0\" ) ; ENDIF\n\n \n cMeta := Left( cMeta, 2 ) + _ftConvVowel( SubStr( cMeta, 3 ) )\n\n \n IF \"Y\" $ cMeta\n cMeta := StrTran( cMeta, \"Yv\", \"#\" ) \n cMeta := StrTran( cMeta, \"Y\" , \"\" ) \n cMeta := StrTran( cMeta, \"#\" , \"Yv\" ) \n ENDIF\n\n \n IF \"GHv\" $ cMeta ; cMeta := StrTran( cMeta, \"GHv\" , \"G\" ) ; ENDIF\n IF \"vGHT\" $ cMeta ; cMeta := StrTran( cMeta, \"vGHT\", \"T\" ) ; ENDIF\n IF \"vGH\" $ cMeta ; cMeta := StrTran( cMeta, \"vGH\" , \"W\" ) ; ENDIF\n IF \"GN\" $ cMeta ; cMeta := StrTran( cMeta, \"GN\" , \"N\" ) ; ENDIF\n IF \"G\" $ cMeta ; cMeta := StrTran( cMeta, \"G\" , \"K\" ) ; ENDIF\n\n \n IF \"vHv\" $ cMeta ; cMeta := StrTran( cMeta, \"vHv\" , \"H\" ) ; ENDIF\n IF \"vH\" $ cMeta ; cMeta := StrTran( cMeta, \"vH\" , \"\" ) ; ENDIF\n\n \n IF \"PH\" $ cMeta ; cMeta := StrTran( cMeta, \"PH\" , \"F\" ) ; ENDIF\n IF \"V\" $ cMeta ; cMeta := StrTran( cMeta, \"V\" , \"F\" ) ; ENDIF\n\n \n IF \"D\" $ cMeta ; cMeta := StrTran( cMeta, \"D\" , \"T\" ) ; ENDIF\n\n \n IF \"CK\" $ cMeta ; cMeta := StrTran( cMeta, \"CK\" , \"K\" ) ; ENDIF\n IF \"Q\" $ cMeta ; cMeta := StrTran( cMeta, \"Q\" , \"K\" ) ; ENDIF\n IF \"C\" $ cMeta ; cMeta := StrTran( cMeta, \"C\" , \"K\" ) ; ENDIF\n\n \n cMeta := StrTran( cMeta, \"v\" )\n\n RETURN PadR( AllTrim( cMeta ), nSize )\n\nSTATIC FUNCTION _ftMakeAlpha( cStr ) \n\n LOCAL x, cAlpha := \"\"\n\n FOR x := 1 TO Len( cStr )\n IF SubStr( cStr, x, 1 ) == \" \" .OR. IsAlpha( SubStr( cStr, x, 1 ) )\n cAlpha += SubStr( cStr, x, 1 )\n ENDIF\n NEXT\n\n RETURN cAlpha\n\nSTATIC FUNCTION _ftConvVowel( cStr ) \n\n LOCAL x, cConverted := \"\"\n\n FOR x := 1 TO Len( cStr )\n IF SubStr( cStr, x, 1 ) $ \"AEIOU\"\n cConverted += \"v\"\n ELSE\n cConverted += SubStr( cStr, x, 1 )\n ENDIF\n NEXT\n\n RETURN cConverted"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/ascpos.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of AscPos()\"\n ?\n\n ? ' AscPos( \"0123456789\" ) == 57 ? --> ' + Str( AscPos( \"0123456789\" ) )\n ? ' AscPos( \"0123456789\", 1 ) == 48 ? --> ' + Str( AscPos( \"0123456789\", 1 ) )\n ? ' AscPos( \"0123456789\", 11 ) == 0 ? --> ' + Str( AscPos( \"0123456789\", 11 ) )\n\n ?\n ? \"End test of AscPos()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/oleauto.prg. Defines classes: win_oleAuto. Provides functions: win_oleGetActiveObject, win_oleCreateObject. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#define HB_CLS_NOTOBJECT \n#include \"hbclass.ch\"\n\n\nCREATE CLASS win_oleAuto\n\n VAR __hObj\n VAR __hObjEnum\n VAR __hSink\n VAR __cargo\n\n METHOD __enumStart( enum, lDescend )\n METHOD __enumSkip( enum, lDescend )\n METHOD __enumStop()\n\n METHOD __OpIndex( xIndex, xValue ) OPERATOR \"[]\"\n\n ERROR HANDLER __OnError()\n\nENDCLASS\n\n\nMETHOD __enumStart( enum, lDescend ) CLASS win_oleAuto\n\n LOCAL hObjEnum\n\n IF ! Empty( hObjEnum := __oleEnumCreate( ::__hObj, lDescend ) )\n IF ! Empty( ::__hObjEnum )\n \n Self := __objClone( Self )\n ENDIF\n ::__hObjEnum := hObjEnum\n \n ( @enum ):__enumBase( Self )\n RETURN ::__enumSkip( @enum, lDescend )\n ENDIF\n\n RETURN .F.\n\n\nMETHOD __enumSkip( enum, lDescend ) CLASS win_oleAuto\n\n LOCAL lContinue, xValue\n\n HB_SYMBOL_UNUSED( lDescend )\n\n xValue := __oleEnumNext( ::__hObjEnum, @lContinue, ::classH )\n \n ( @enum ):__enumValue( xValue )\n\n RETURN lContinue\n\n\nMETHOD PROCEDURE __enumStop() CLASS win_oleAuto\n\n ::__hObjEnum := NIL \n\n RETURN\n\n\nFUNCTION win_oleGetActiveObject( ... )\n\n LOCAL oOle, hOle\n\n IF ! Empty( hOle := __oleGetActiveObject( ... ) )\n oOle := win_oleAuto()\n oOle:__hObj := hOle\n ENDIF\n\n RETURN oOle\n\n\nFUNCTION win_oleCreateObject( ... )\n\n LOCAL oOle, hOle\n\n IF ! Empty( hOle := __oleCreateObject( ... ) )\n oOle := win_oleAuto()\n oOle:__hObj := hOle\n ENDIF\n\n RETURN oOle"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: HotChoice. Harbour test program: tests/achoice3.prg. Provides functions: HotChoice. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n#include \"clipper.ch\"\n#endif\n\n#include \"achoice.ch\"\n#include \"inkey.ch\"\n\n\nMEMVAR m_aItems\n\nPROCEDURE Main()\n\n LOCAL nResult\n\n PRIVATE m_aItems := { ;\n \"Apple\", ;\n \"Blueberry\", ;\n \"Cashew\", ;\n \"Grape\", ;\n \"Hazelnut\", ;\n \"Jackfruit\", ;\n \"Kumquat\", ;\n \"Mulberry\" }\n\n CLS\n @ 7, 25 TO 8 + Len( m_aItems ), 57\n nResult := AChoice( 8, 26, 8 + Len( m_aItems ), 55, m_aItems,, \"HotChoice\" )\n IF nResult > 0\n Alert( m_aItems[ nResult ] + \" selected\" )\n ENDIF\n\n RETURN\n\nFUNCTION HotChoice( nStatus, nCurrent, window_pos )\n\n LOCAL nKey, cKey\n\n HB_SYMBOL_UNUSED( nCurrent )\n HB_SYMBOL_UNUSED( window_pos )\n\n DO CASE\n CASE nStatus == AC_EXCEPT\n nKey := LastKey()\n cKey := Upper( hb_keyChar( nKey ) )\n DO CASE\n CASE AScan( m_aItems, {| c | Left( c, 1 ) == cKey } ) > 0\n hb_keyPut( K_ENTER )\n RETURN AC_GOTO\n CASE nKey == K_ENTER\n RETURN AC_SELECT\n CASE nKey == K_ESC\n RETURN AC_ABORT\n OTHERWISE\n ?? Chr( 7 )\n ENDCASE\n CASE nStatus == AC_NOITEM\n RETURN AC_ABORT\n ENDCASE\n\n RETURN AC_CONT"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/objarr.prg. Provides functions: TNumber, New, Get. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL o := TNumber():New()\n\n ? \"Direct reference : \", hb_ValToStr( o:x )\n\n o:x[ 1 ] := \"I am a data\"\n o:Get()[ 2 ] := \"I am a method\"\n ? \"Assign text : \", hb_ValToStr( o:x )\n\n o:x[ 1 ] := 4\n o:Get()[ 2 ] := 4\n ? \"Assign 4 : \", hb_ValToStr( o:x )\n\n ? \"Post increment : \", o:x[ 1 ]++ , o:Get()[ 2 ]++\n ? \"After : \", o:x[ 1 ] , o:Get()[ 2 ]\n ? \"Pre decrement : \", --o:x[ 1 ] , --o:Get()[ 2 ]\n ? \"After : \", o:x[ 1 ] , o:Get()[ 2 ]\n\n o:x[ 1 ] += 2\n o:Get()[ 2 ] += 2\n ? \"Plus 2 : \", hb_ValToStr( o:x )\n\n o:x[ 1 ] -= 3\n o:Get()[ 2 ] -= 3\n ? \"Minus 3 : \", hb_ValToStr( o:x )\n\n o:x[ 1 ]\n ? \"Times 3 : \", hb_ValToStr( o:x )\n\n o:x[ 1 ] /= 1.5\n o:Get()[ 2 ] /= 1.5\n ? \"Divide by 1.5 : \", hb_ValToStr( o:x )\n\n o:x[ 1 ] %= 4\n o:Get()[ 2 ] %= 4\n ? \"Modulus 4 : \", hb_ValToStr( o:x )\n\n o:x[ 1 ] ^= 3\n o:Get()[ 2 ] ^= 3\n ? \"To the power 3 : \", hb_ValToStr( o:x )\n\n ? \"Global stack\"\n ? hb_ValToExp( __dbgVMStkGList() )\n ? \"Statics\"\n ? hb_ValToExp( __dbgVMVarSList() )\n\n RETURN\n\nFUNCTION TNumber() \n\n STATIC oNumber\n\n IF oNumber == NIL\n oNumber := HBClass():New( \"TNumber\" )\n\n oNumber:AddData ( \"x\" )\n oNumber:AddMethod( \"Get\", @Get() )\n oNumber:AddMethod( \"New\", @New() )\n oNumber:Create()\n ENDIF\n\n RETURN oNumber:Instance()\n\nSTATIC FUNCTION New()\n\n LOCAL self := QSelf()\n\n ::x := { 1, 1 }\n\n RETURN Self\n\nSTATIC FUNCTION Get()\n\n LOCAL self := QSelf()\n\n RETURN ::x"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/thfuncx.prg. Provides functions: ThreadID, ThreadObject, ThreadWait, ThreadWaitAll. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ThreadID()\n RETURN hb_threadID()\n\nFUNCTION ThreadObject( oThread )\n\n THREAD STATIC t_oThread\n\n IF PCount() > 0\n t_oThread := oThread\n ENDIF\n\n RETURN t_oThread\n\nFUNCTION ThreadWait( aThreads, nTimeOut )\n\n LOCAL xResult, nPos, apThIDs, th\n\n apThIDs := {}\n FOR EACH th IN aThreads\n IF HB_ISOBJECT( th )\n AAdd( apThIDs, th:threadSelf )\n ELSE\n AAdd( apThIDs, th )\n ENDIF\n NEXT\n\n nPos := hb_threadWait( apThIDs, iif( HB_ISNUMERIC( nTimeOut ) .AND. nTimeOut != 0, ;\n nTimeOut / 100, ) )\n IF nPos != 0\n xResult := aThreads[ nPos ]\n ENDIF\n\n RETURN xResult\n\n\nFUNCTION ThreadWaitAll( aThreads, nTimeOut )\n\n LOCAL apThIDs, th\n\n apThIDs := {}\n FOR EACH th IN aThreads\n IF HB_ISOBJECT( th )\n AAdd( apThIDs, th:threadSelf )\n ELSE\n AAdd( apThIDs, th )\n ENDIF\n NEXT\n\n RETURN hb_threadWait( apThIDs, iif( HB_ISNUMERIC( nTimeOut ) .AND. nTimeOut != 0, ;\n nTimeOut / 100, ), .T. ) == Len( apThIDs )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbssl' (OpenSSL wrapper for SSL/TLS encryption): contrib/hbssl/tests/inetssl.prg. Provides functions: Client, Server, LoadCertificates, DispCertInfo. Contains procedures: Main. This file implements security and encryption functions"}, {"role": "assistant", "content": "#require \"hbssl\"\n\n#define N_PORT 4001\n#define EOL e\"\\r\\n\"\n#define PEM_CERT_FILE \"inetssl.pem\"\n\nSTATIC s_lReady := .F.\nSTATIC s_lStop := .F.\n\nSTATIC s_lDelaySrv := .F.\nSTATIC s_lDelayCli := .F.\n\nREQUEST HB_MT\n\nPROCEDURE Main( delay )\n LOCAL thrd\n\n IF ! Empty( delay )\n s_lDelayCli := \"C\" $ Upper( delay )\n s_lDelaySrv := \"S\" $ Upper( delay )\n ENDIF\n\n \n SSL_init()\n RAND_seed( Time() + hb_TSToStr( hb_DateTime() ) + hb_DirBase() + NetName() )\n\n \n thrd := hb_threadStart( @Server() )\n IF Empty( thrd )\n ? \"Cannot start thread.\"\n RETURN\n ENDIF\n\n \n DO WHILE ! s_lReady\n hb_idleSleep( 0.01 )\n IF hb_threadWait( thrd, 0 ) != 0\n hb_threadJoin( thrd )\n QUIT\n ENDIF\n ENDDO\n\n \n Client()\n\n \n s_lStop := .T.\n hb_threadJoin( thrd )\n ?\n\n RETURN\n\n\nSTATIC FUNCTION Client()\n LOCAL sock, ssl_ctx, ssl, nResult, nErr, cLine\n\n ssl_ctx := SSL_CTX_new()\n ssl := SSL_new( ssl_ctx )\n\n sock := hb_inetCreate()\n hb_inetTimeout( sock, 5000 )\n\n ? \"CLIENT: connecting...\"\n IF Empty( hb_inetConnectIP( \"127.0.0.1\", N_PORT, sock ) )\n ? \"CLIENT: cannot connect to server.\"\n ELSE\n ? \"CLIENT: connected to the server.\"\n hb_inetTimeout( sock, 3000 )\n\n IF s_lDelayCli\n ? \"CLIENT: waiting...\"\n hb_idleSleep( 1 )\n ENDIF\n\n ? \"CLIENT: SSL CONNECT...\"\n nResult := hb_inetSSL_CONNECT( sock, ssl )\n nErr := ERR_get_error()\n ?? hb_StrFormat( e\"\\nCLIENT: hb_inetSSL_CONNECT()=>%d (%d), '%s'\\n\", ;\n nResult, nErr, ;\n ERR_error_string( nErr ) )\n IF nResult == 1\n ? \"CLIENT: connected with\", SSL_get_cipher( ssl ), \"encryption.\"\n DispCertInfo( ssl, \"CLIENT: \" )\n\n hb_inetSendAll( sock, hb_TSToStr( hb_DateTime() ) + EOL )\n DO WHILE ! Empty( cLine := hb_inetRecvLine( sock ) )\n ? \"CLIENT: RECV:\", hb_ValToExp( cLine )\n ENDDO\n ENDIF\n ENDIF\n hb_inetClose( sock )\n\n RETURN NIL\n\n\nSTATIC FUNCTION Server()\n LOCAL sockSrv, sockConn, ssl_ctx, ssl, nResult, nErr, cLine\n\n ? \"SERVER: loading certificates...\"\n ssl_ctx := SSL_CTX_new()\n LoadCertificates( ssl_ctx, PEM_CERT_FILE, PEM_CERT_FILE )\n ssl := SSL_new( ssl_ctx )\n\n ? \"SERVER: create listen socket...\"\n IF Empty( sockSrv := hb_inetServer( N_PORT ) )\n ? \"SERVER: cannot create listen socket.\"\n ELSE\n\n ? \"SERVER: waiting for connections...\"\n hb_inetTimeout( sockSrv, 100 )\n s_lReady := .T.\n DO WHILE ! s_lStop\n IF ! Empty( sockConn := hb_inetAccept( sockSrv ) )\n ? \"SERVER: accepted new connection.\"\n hb_inetTimeout( sockConn, 3000 )\n\n IF s_lDelaySrv\n ? \"SERVER: waiting...\"\n hb_idleSleep( 1 )\n ENDIF\n\n ? \"SERVER: SSL ACCEPT...\"\n nResult := hb_inetSSL_ACCEPT( sockConn, ssl )\n nErr := ERR_get_error()\n ?? hb_StrFormat( e\"\\nSERVER: hb_inetSSL_ACCEPT()=>%d (%d), '%s'\\n\", ;\n nResult, nErr, ;\n ERR_error_string( nErr ) )\n\n IF nResult == 1\n cLine := hb_inetRecvLine( sockConn )\n ? \"SERVER: RECV:\", hb_ValToExp( cLine )\n hb_inetSendAll( sockConn, ;\n \"ECHO[ \" + cLine + \" ]\" + EOL + ;\n hb_TSToStr( hb_DateTime() ) + EOL + ;\n OS() + EOL + ;\n Version() + EOL + ;\n EOL )\n ENDIF\n\n hb_inetClose( sockConn )\n sockConn := nil\n ENDIF\n ENDDO\n\n s_lReady := .F.\n ENDIF\n\n RETURN NIL\n\n\nSTATIC FUNCTION LoadCertificates( ssl_ctx, cCertFile, cKeyFile )\n\n \n IF ! hb_FileExists( cCertFile ) .AND. ! hb_FileExists( cKeyFile )\n ? \"SERVER: generating certificates...\"\n hb_run( \"openssl req -x509 -nodes -days 365 -newkey rsa:2048 \" + ;\n \"-out \" + cCertFile + \" -keyout \" + cKeyFile )\n ENDIF\n\n \n IF SSL_CTX_use_certificate_file( ssl_ctx, cCertFile, HB_SSL_FILETYPE_PEM ) <= 0\n OutErr( hb_StrFormat( e\"SERVER: SSL_CTX_use_certificate_file()=> '%s'\\n\", ;\n ERR_error_string( ERR_get_error() ) ) )\n QUIT\n ENDIF\n\n \n IF SSL_CTX_use_PrivateKey_file( ssl_ctx, cKeyFile, HB_SSL_FILETYPE_PEM ) <= 0\n OutErr( hb_StrFormat( e\"SERVER: SSL_CTX_use_PrivateKey_file()=> '%s'\\n\", ;\n ERR_error_string( ERR_get_error() ) ) )\n QUIT\n ENDIF\n\n \n IF ! SSL_CTX_check_private_key( ssl_ctx ) == 1\n OutErr( e\"SERVER: Private key does not match the public certificate\\n\" )\n QUIT\n ENDIF\n\n RETURN NIL\n\n\nSTATIC FUNCTION DispCertInfo( ssl, cWho )\n LOCAL cert\n\n IF ! Empty( cert := SSL_get_peer_certificate( ssl ) )\n ? cWho + \"Server certificates:\"\n ? cWho + \"Subject:\", X509_name_oneline( X509_get_subject_name( cert ), 0, 0 )\n ? cWho + \"Issuer:\", X509_name_oneline( X509_get_issuer_name( cert ), 0, 0 )\n ELSE\n ? cWho + \"No certificates.\"\n ENDIF\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour test program: tests/dates3.prg. Provides functions: LastMonday. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL dDate, i\n\n Set( _SET_DATEFORMAT, \"dd/mm/yyyy\" )\n dDate := hb_SToD( \"19990525\" )\n\n ? dDate, DoW( dDate )\n\n ? LastMonday( dDate )\n\n dDate += 3\n ? dDate, DoW( dDate )\n\n dDate += 4\n ? dDate, DoW( dDate )\n\n Set( _SET_DATEFORMAT, \"mm/dd/yyyy\" )\n dDate := hb_SToD( \"19990525\" )\n\n ? dDate, DoW( dDate )\n\n ? LastMonday( dDate )\n\n dDate += 3\n ? dDate, DoW( dDate )\n\n dDate += 4\n ? dDate, DoW( dDate )\n\n ?\n dDate := Date()\n FOR i := 1 TO 7\n ? dDate, DoW( dDate )\n dDate++\n NEXT\n ? hb_SToD(), DoW( hb_SToD() )\n\n RETURN\n\n\nSTATIC FUNCTION LastMonday( dDate )\n RETURN dDate - DoW( dDate ) + 2"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour test program: tests/ipsvr.prg. Contains procedures: Main, process. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n\n#include \"hbsocket.ch\"\n\n#define ADDRESS \"0.0.0.0\"\n#define PORT 10000\n#define EOT hb_BChar( 4 )\n#define TIMEOUT 3000 \n\nPROCEDURE Main()\n\n LOCAL hListen\n LOCAL hSocket\n\n IF ! hb_mtvm()\n ? \"multithread support required\"\n RETURN\n ENDIF\n\n ? \"create listening socket\"\n IF Empty( hListen := hb_socketOpen() )\n ? \"socket create error \" + hb_ntos( hb_socketGetError() )\n ENDIF\n IF ! hb_socketBind( hListen, { HB_SOCKET_AF_INET, ADDRESS, PORT } )\n ? \"bind error \" + hb_ntos( hb_socketGetError() )\n ENDIF\n IF ! hb_socketListen( hListen )\n ? \"listen error \" + hb_ntos( hb_socketGetError() )\n ENDIF\n DO WHILE .T.\n IF Empty( hSocket := hb_socketAccept( hListen, , TIMEOUT ) )\n IF hb_socketGetError() == HB_SOCKET_ERR_TIMEOUT\n ? \"loop\"\n ELSE\n ? \"accept error \" + hb_ntos( hb_socketGetError() )\n ENDIF\n ELSE\n ? \"accept socket request\"\n hb_threadDetach( hb_threadStart( @process(), hSocket ) )\n ENDIF\n IF Inkey() == K_ESC\n ? \"quitting - esc pressed\"\n EXIT\n ENDIF\n ENDDO\n\n ? \"close listening socket\"\n\n hb_socketShutdown( hListen )\n hb_socketClose( hListen )\n\n RETURN\n\nPROCEDURE process( hSocket )\n\n LOCAL cRequest\n LOCAL nLen\n LOCAL cBuf\n\n DO WHILE .T.\n cRequest := \"\"\n nLen := 1\n DO WHILE hb_BAt( EOT, cRequest ) == 0 .AND. nLen > 0\n cBuf := Space( 4096 )\n IF ( nLen := hb_socketRecv( hSocket, @cBuf,,, 10000 ) ) > 0 \n cRequest += hb_BLeft( cBuf, nLen )\n ELSE\n IF nLen == -1 .AND. hb_socketGetError() == HB_SOCKET_ERR_TIMEOUT\n nLen := 0\n ENDIF\n ENDIF\n ENDDO\n\n IF nLen == -1\n ? \"recv() error:\", hb_socketGetError()\n ELSEIF nLen == 0\n ? \"connection closed\"\n EXIT\n ELSE\n ? cRequest\n IF \"quit\" $ cRequest\n ? \"exit\"\n EXIT\n ENDIF\n ENDIF\n ENDDO\n\n ? \"close socket\"\n\n hb_socketShutdown( hSocket )\n hb_socketClose( hSocket )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/simwce.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\n#include \"hbsim.ch\"\n\nPROCEDURE Main()\n\n#if defined( __PLATFORM__WINCE )\n\n LOCAL o := wce_Sim():New()\n LOCAL a\n\n IF o:lInitialize()\n Alert( \"Api Sim initialized!!\" + Str( o:nLastError ) )\n ELSE\n Alert( \"Api Sim NOT initialized!!. Error \" + Str( o:nLastError ) )\n ENDIF\n\n\n IF ! o:lGetSimPhoneEntry( 1, SIM_PBSTORAGE_SIM, @a )\n Alert( \"Pos 1 error\" )\n ELSE\n Alert( \"VALTYPE-> \" + ValType( a ) + \" LEN -> \" + Str( Len( a ) ), a[ 1 ][ 1 ] )\n AEval( a, {| n | Alert( \"Phone: \" + n[ 1 ] + hb_eol() + \"Name: \" + n[ 2 ] + hb_eol() + \"Adr. Type: \" + Str( n[ 3 ] ) + hb_eol() + \"Plan Type: \" + Str( n[ 4 ] ), \"pos 1\" ) } )\n ENDIF\n\n IF ! o:lGetSimPhoneEntry( 110, SIM_PBSTORAGE_SIM, @a )\n Alert( \"Pos 123 error\" )\n ELSE\n AEval( a, {| n | Alert( \"Phone: \" + n[ 1 ] + hb_eol() + \"Name: \" + n[ 2 ] + hb_eol() + \"Adr. Type: \" + Str( n[ 3 ] ) + hb_eol() + \"Plan Type: \" + Str( n[ 4 ] ), \"pos 110\" ) } )\n ENDIF\n\n IF ! o:lSetSimPhoneEntry( 80, SIM_PBSTORAGE_SIM, \"660099696\", \"pepeluis\", SIM_NUMPLAN_UNKNOWN, SIM_ADDRTYPE_NATIONAL )\n Alert( \"Error writing pos 80 Errpr=>\" + Str( o:nLastError ) )\n ENDIF\n IF ! o:lDelSimPhoneEntry( 80, SIM_PBSTORAGE_SIM )\n Alert( \"Error deletein pos 80 Errpr=>\" + Str( o:nLastError ) )\n ENDIF\n\n IF ! o:lDeInitialize()\n Alert( \"Not De-Initialized SIM api. Error :\" + Str( o:nLastError ) )\n ELSE\n Alert( \"Api Sim Deinitialized!!!\" )\n ENDIF\n\n o:End()\n\n#else\n\n ? \"This test requires WinCE to run.\"\n\n#endif\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: ft_Byt2Bit. Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/byt2bit.prg. Provides functions: ft_Byt2Bit. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_Byt2Bit( cByte )\n\n LOCAL nCounter, cBitstring\n\n IF HB_ISSTRING( cByte )\n cByte := hb_BCode( cByte )\n cBitString := \"\"\n FOR nCounter := 7 TO 0 STEP -1\n cBitString += iif( hb_bitTest( cByte, nCounter ), \"1\", \"0\" )\n NEXT\n RETURN cBitString\n ENDIF\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour source file: src/rdd/dbtotal.prg. Provides functions: __dbTotal, __GetField, __dbTransRec. This file implements core Record Driver Driver functionality"}, {"role": "assistant", "content": "#include \"dbstruct.ch\"\n#include \"error.ch\"\n\n\nFUNCTION __dbTotal( cFile, xKey, aFields, ;\n xFor, xWhile, nNext, nRec, lRest, ;\n cRDD, nConnection, cCodePage )\n\n LOCAL nOldArea\n LOCAL nNewArea\n\n LOCAL aNewDbStruct\n LOCAL aGetField\n LOCAL aFieldsSum\n LOCAL lDbTransRecord\n LOCAL xCurKey\n\n LOCAL bWhileBlock\n LOCAL bForBlock\n LOCAL bKeyBlock\n\n LOCAL oError\n LOCAL lError := .F.\n\n DO CASE\n CASE HB_ISEVALITEM( xWhile )\n bWhileBlock := xWhile\n lRest := .T.\n CASE HB_ISSTRING( xWhile ) .AND. ! Empty( xWhile )\n bWhileBlock := hb_macroBlock( xWhile )\n lRest := .T.\n OTHERWISE\n bWhileBlock := {|| .T. }\n ENDCASE\n\n DO CASE\n CASE HB_ISEVALITEM( xFor )\n bForBlock := xFor\n CASE HB_ISSTRING( xFor ) .AND. ! Empty( xFor )\n bForBlock := hb_macroBlock( xFor )\n OTHERWISE\n bForBlock := {|| .T. }\n ENDCASE\n\n __defaultNIL( @lRest, .F. )\n\n IF nRec != NIL\n dbGoto( nRec )\n nNext := 1\n ELSEIF nNext == NIL\n nNext := -1\n IF ! lRest\n dbGoTop()\n ENDIF\n ELSE\n lRest := .T.\n ENDIF\n\n nOldArea := Select()\n\n aNewDbStruct := {}\n AEval( dbStruct(), {| aField | iif( aField[ DBS_TYPE ] == \"M\", NIL, AAdd( aNewDbStruct, aField ) ) } )\n IF Empty( aNewDbStruct )\n RETURN .F.\n ENDIF\n\n BEGIN SEQUENCE\n\n IF HB_ISEVALITEM( xKey )\n bKeyBlock := xKey\n ELSE\n IF Empty( xKey )\n xKey := ordKey()\n ENDIF\n IF HB_ISSTRING( xKey ) .AND. ! Empty( xKey )\n bKeyBlock := hb_macroBlock( xKey )\n ELSE\n bKeyBlock := {|| NIL }\n ENDIF\n ENDIF\n\n aGetField := {}\n AEval( aFields, {| cField | AAdd( aGetField, __GetField( cField ) ) } )\n aFieldsSum := Array( Len( aGetField ) )\n\n \n dbCreate( cFile, aNewDbStruct, cRDD, .T., \"\", , cCodePage, nConnection )\n nNewArea := Select()\n\n dbSelectArea( nOldArea )\n DO WHILE ! Eof() .AND. nNext != 0 .AND. Eval( bWhileBlock )\n\n lDbTransRecord := .F.\n\n AFill( aFieldsSum, 0 )\n\n xCurKey := Eval( bKeyBlock )\n\n DO WHILE ! Eof() .AND. nNext-- != 0 .AND. Eval( bWhileBlock ) .AND. ;\n xCurKey == Eval( bKeyBlock )\n\n IF Eval( bForBlock )\n IF ! lDbTransRecord\n __dbTransRec( nNewArea, aNewDbStruct )\n dbSelectArea( nOldArea )\n lDbTransRecord := .T.\n ENDIF\n AEval( aGetField, {| bFieldBlock, nFieldPos | aFieldsSum[ nFieldPos ] += Eval( bFieldBlock ) } )\n ENDIF\n\n dbSkip()\n ENDDO\n\n IF lDbTransRecord\n dbSelectArea( nNewArea )\n AEval( aGetField, {| bFieldBlock, nFieldPos | Eval( bFieldBlock, aFieldsSum[ nFieldPos ] ) } )\n dbSelectArea( nOldArea )\n ENDIF\n\n ENDDO\n\n RECOVER USING oError\n lError := .T.\n END SEQUENCE\n\n IF nNewArea != NIL\n dbSelectArea( nNewArea )\n dbCloseArea()\n ENDIF\n\n dbSelectArea( nOldArea )\n\n IF lError\n Break( oError )\n ENDIF\n\n RETURN .T.\n\nSTATIC FUNCTION __GetField( cField )\n\n LOCAL nCurrArea := Select()\n LOCAL nPos\n LOCAL oError\n\n \n IF ( nPos := At( \"->\", cField ) ) > 0\n\n IF Select( Left( cField, nPos - 1 ) ) != nCurrArea\n\n oError := ErrorNew()\n oError:severity := ES_ERROR\n oError:genCode := EG_SYNTAX\n oError:subSystem := \"DBCMD\"\n oError:canDefault := .T.\n oError:operation := cField\n oError:subCode := 1101\n\n IF hb_defaultValue( Eval( ErrorBlock(), oError ), .T. )\n __errInHandler()\n ENDIF\n\n Break( oError )\n ENDIF\n\n cField := SubStr( cField, nPos + 2 )\n ENDIF\n\n RETURN FieldBlock( cField )\n\nFUNCTION __dbTransRec( nDstArea, aFieldsStru )\n RETURN __dbTrans( nDstArea, aFieldsStru, , , 1 )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/dynobj.prg. Provides functions: TForm, New, Smile, BigSmile, Pause. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL oForm := TForm():New()\n\n ? \"What methods are in the class :\"\n ? hb_ValToExp( __objGetMethodList( oForm ) )\n\n \n ? \"Let's add inline 'CalcArea' at run-time to an already instanced class\"\n\n __objAddInline( oForm, \"CalcArea\", ;\n {| Self | ( ::nRight - ::nLeft )\n ? \"What methods are in the class :\"\n ? hb_ValToExp( __objGetMethodList( oForm ) )\n\n ? \"What is the Form area ?\"\n ? oForm:CalcArea()\n\n ? \"Let's add method 'Smile' at run-time to an already instanced class\"\n\n __objAddMethod( oForm, \"Smile\", @Smile() )\n\n ? \"What methods are in the class :\"\n ? hb_ValToExp( __objGetMethodList( oForm ) )\n\n ? \"Smile please \"\n oForm:Smile()\n\n Pause()\n\n ? \"Data items before\"\n ? hb_ValToExp( oForm )\n\n ? \"Let's add an additional data item\"\n\n __objAddData( oForm, \"cHelp\" )\n\n oForm:cHelp := \"This is a real tricky test\"\n\n ? \"Data items after\"\n ? hb_ValToExp( oForm )\n\n Pause()\n\n ? \"Let's attach a bigger smile\"\n\n __objModMethod( oForm, \"Smile\", @BigSmile() )\n\n ? \"Let's smile\"\n oForm:Smile()\n\n ? \"And CalcArea() will now give a result in square inches\"\n\n __objModInline( oForm, \"CalcArea\", ;\n {| Self | ( ::nRight - ::nLeft )\n ? \"What is the Form area ?\"\n ? oForm:CalcArea()\n\n ? \"What methods are in the class :\"\n ? hb_ValToExp( __objGetMethodList( oForm ) )\n\n ? \"Delete CalcArea\"\n __objDelInline( oForm, \"CalcArea\" )\n\n ? \"What methods are in the class :\"\n ? hb_ValToExp( __objGetMethodList( oForm ) )\n\n ? \"Delete Smile\"\n __objDelMethod( oForm, \"Smile\" )\n\n ? \"What methods are in the class :\"\n ? hb_ValToExp( __objGetMethodList( oForm ) )\n\n Pause()\n\n ? \"Data items before\"\n ? hb_ValToExp( oForm )\n\n ? \"Let's delete cHelp\"\n\n __objDelData( oForm, \"cHelp\" )\n\n ? \"Data items after\"\n ? hb_ValToExp( oForm )\n\n\n RETURN\n\nFUNCTION TForm()\n\n STATIC s_oClass\n\n IF s_oClass == NIL\n s_oClass := HBClass():New( \"TFORM\" ) \n\n s_oClass:AddData( \"cText\" ) \n s_oClass:AddData( \"nTop\" )\n s_oClass:AddData( \"nLeft\" )\n s_oClass:AddData( \"nBottom\" )\n s_oClass:AddData( \"nRight\" )\n\n s_oClass:AddMethod( \"New\", @New() ) \n s_oClass:AddInline( \"Show\", {| self | ::cText } )\n\n s_oClass:Create() \n ENDIF\n\n RETURN s_oClass:Instance() \n\nSTATIC FUNCTION New()\n\n LOCAL Self := QSelf()\n\n ::nTop := 10\n ::nLeft := 10\n ::nBottom := 20\n ::nRight := 40\n\n RETURN Self\n\nSTATIC FUNCTION Smile()\n\n LOCAL self := QSelf()\n\n IF ::CalcArea() == 300\n ? \":-)\"\n ELSE\n ? \":-(\"\n ENDIF\n\n RETURN self\n\nSTATIC FUNCTION BigSmile()\n\n LOCAL self := QSelf()\n\n ? \":-)))\"\n\n RETURN self\n\nFUNCTION Pause()\n\n WAIT \"Pause:\"\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbssl' (OpenSSL wrapper for SSL/TLS encryption): contrib/hbssl/tests/test.prg. Contains procedures: Main. This file implements security and encryption functions"}, {"role": "assistant", "content": "#require \"hbssl\"\n\n#define CRLF Chr( 13 ) + Chr( 10 )\n\nPROCEDURE Main()\n\n LOCAL ssl_ctx\n LOCAL ssl\n LOCAL cipher\n\n LOCAL socket\n LOCAL buffer\n\n LOCAL bits\n LOCAL tmp\n\n \n hb_inetInit()\n\n ? \"-------\"\n\n socket := hb_inetCreate()\n ? \"INETTIMEOUT\", hb_inetTimeout( socket, 500 )\n ? \"INETCONN\", hb_inetConnect( \"www.fortify.net\", 80, socket )\n ? \"INETERR\", hb_inetErrorCode( socket )\n ? \"INETFD\", hb_inetFD( socket )\n ? \"INETSEND\", hb_inetSend( socket, \"GET / http/1.1\" + CRLF + \"Host: \" + \"www.fortify.net\" + CRLF + CRLF )\n ? \"INETERR\", hb_inetErrorCode( socket )\n buffer := Space( 1024 )\n ? \"INETRECVALL\", hb_inetRecvAll( socket, @buffer, Len( buffer ) )\n ? \"BUFFER\", \">\" + AllTrim( buffer ) + \"<\"\n ? \"INETCLOSE\", hb_inetClose( socket )\n\n ? \"-------\"\n\n socket := hb_inetCreate()\n ? hb_inetTimeout( socket, 2500 )\n ? hb_inetConnect( \"www.fortify.net\", 443, socket )\n ? hb_inetErrorCode( socket )\n\n \n SSL_init()\n\n ? SSLeay_version()\n ? SSLeay_version( HB_SSLEAY_VERSION )\n ? SSLeay_version( HB_SSLEAY_CFLAGS )\n ? SSLeay_version( HB_SSLEAY_BUILT_ON )\n ? SSLeay_version( HB_SSLEAY_PLATFORM )\n ? SSLeay_version( HB_SSLEAY_DIR )\n\n ? \"RAND_SEED\", RAND_seed( \"some entropy\" )\n\n ? \"SSL_CTX_NEW\", ssl_ctx := SSL_CTX_new()\n\n ? \"SSL_NEW\", ssl := SSL_new( ssl_ctx )\n\n ? \"SSL_VERSION\", SSL_version( ssl )\n ? \"SSL_GET_VERSION\", SSL_get_version( ssl )\n\n ? \"INET FD\", hb_inetFD( socket )\n\n ? \"SSL_SET_FD\", SSL_set_fd( ssl, hb_inetFD( socket ) )\n ? \"SSL_CONNECT\", tmp := SSL_connect( ssl )\n ? \"SSL_GET_ERROR\", SSL_get_error( ssl, tmp )\n\n tmp := SSL_get_ciphers( ssl )\n FOR EACH cipher IN tmp\n ? \"SSL_CIPHER_GET_NAME\", SSL_CIPHER_get_name( cipher )\n ? \"SSL_CIPHER_GET_VERSION\", SSL_CIPHER_get_version( cipher )\n ? \"SSL_CIPHER_GET_BITS\", SSL_CIPHER_get_bits( cipher, @bits ), bits\n ? \"SSL_CIPHER_DESCRIPTION\", \">\" + SSL_CIPHER_description( cipher ) + \"<\"\n ? \"- - - - - - - - - - - - - - -\"\n NEXT\n\n ? \"SSL_GET_CIPHER_BITS\", SSL_get_cipher_bits( ssl, @bits ), bits\n ? \"SSL_GET_CIPHER_LIST\", SSL_get_cipher_list( ssl )\n ? \"SSL_GET_CIPHER_NAME\", SSL_get_cipher_name( ssl )\n ? \"SSL_GET_CIPHER_VERSION\", SSL_get_cipher_version( ssl )\n\n ? \"SSL_GET_CURRENT_CIPHER\", cipher := SSL_get_current_cipher( ssl )\n ? \"SSL_CIPHER_GET_NAME\", SSL_CIPHER_get_name( cipher )\n ? \"SSL_CIPHER_GET_VERSION\", SSL_CIPHER_get_version( cipher )\n ? \"SSL_CIPHER_GET_BITS\", SSL_CIPHER_get_bits( cipher, @bits ), bits\n ? \"SSL_CIPHER_DESCRIPTION\", SSL_CIPHER_description( cipher )\n\n ? \"SSL_WRITE\", tmp := SSL_write( ssl, \"GET / http/1.1\" + CRLF + \"Host: \" + \"www.fortify.net\" + CRLF + CRLF )\n ? \"SSL_GET_ERROR\", SSL_get_error( ssl, tmp )\n buffer := Space( 1024 )\n ? \"SSL_READ\", tmp := SSL_read( ssl, @buffer )\n ? \"SSL_GET_ERROR\", SSL_get_error( ssl, tmp )\n ? buffer\n\n ? hb_inetClose( socket )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charand.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#else\n#define hb_BChar( n ) Chr( n )\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CharAnd()\"\n ?\n\n ? \"Simple tests:\"\n\n ? ' CharAnd( \"012345678\", hb_BChar( 254 ) ) == \"002244668\" ? --> \"' + CharAnd( \"012345678\", hb_BChar( 254 ) ) + '\"'\n ? ' CharAnd( \"012345678\", hb_BChar( 254 ) + hb_BChar( 252 ) ) == \"002044648\" ? --> \"' + CharAnd( \"012345678\", hb_BChar( 254 ) + hb_BChar( 252 ) ) + '\"'\n\n ? \"End test of CharAnd()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour Runtime Library file: src/rtl/wait.prg. Provides functions: __Wait. This file provides utility functions"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n\nFUNCTION __Wait( xPrompt )\n\n LOCAL nKey\n LOCAL cKey\n LOCAL bBlock\n\n \n QOut( iif( xPrompt == NIL, \"Press any key to continue...\", xPrompt ) )\n\n DO WHILE .T.\n\n nKey := Inkey( 0 )\n\n IF ( bBlock := SetKey( nKey ) ) != NIL\n Eval( bBlock, ProcName( 1 ), ProcLine( 1 ), \"\" )\n ELSE\n cKey := hb_keyChar( nKey )\n IF Len( cKey ) > 0\n QQOut( cKey )\n ELSE\n cKey := Chr( 0 )\n ENDIF\n\n EXIT\n ENDIF\n\n ENDDO\n\n RETURN cKey"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charrem.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CharRem()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharRem( \" \", \" 1 2 \" ) == \"12\" ? ---> \"' + CharRem( \" \", \" 1 2 \" ) + '\"'\n ? ' CharRem( \"3y\", \"xyz123\" ) == \"xz12\" ? ---> \"' + CharRem( \"3y\", \"xyz123\" ) + '\"'\n ?\n\n ? \"End test of CharRem()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/rddtest/adscl52.prg. Provides functions: test_main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#define _TEST_ADS_\nREQUEST dbfcdx\n#define _TESTRDD \"dbfcdx\"\n#include \"rddtst.prg\"\n\nFUNCTION test_main()\n\nRDDTESTC {0,.t.,.t.,.f.}, LOCAL n\nRDDTESTF \"DBFCDX\", {0,.t.,.t.,.f.}, RDDSETDEFAULT()\nRDDTESTC {1,.t.,.t.,.f.}, USE \"_tst\" SHARED\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE OFF\nRDDTESTC {1,.t.,.t.,.f.}, INDEX on FNUM tag TG_N to \"_tst\"\nRDDTESTC {1,.t.,.t.,.f.}, INDEX on FSTR tag TG_C to \"_tst\"\nRDDTESTF \"TG_C\", {1,.t.,.t.,.f.}, ORDSETFOCUS()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTC {1,.t.,.f.,.f.}, SET DELETE ON\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF NIL, {1,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.t.,.f.}, DBGOTO(0)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .F.,.F.)\nRDDTESTF .f., {1,.t.,.t.,.f.}, DBSEEK(\"\", .F.,.T.)\nRDDTESTC {1,.t.,.t.,.f.}, SET DELETE OFF\nRDDTESTC {15,.f.,.f.,.f.}, for n:=1 to 15 ; dbappend() ; replace FNUM with int((n+2)/3) ; replace FSTR with chr(FNUM+48) ; next\nRDDTESTF NIL, {15,.f.,.f.,.f.}, dbcommit()\nRDDTESTF NIL, {15,.f.,.f.,.f.}, dbunlock()\nRDDTESTF \"TG_C\", {15,.f.,.f.,.f.}, ORDSETFOCUS(1)\nRDDTESTF \"TG_N\", {15,.f.,.f.,.f.}, ORDSETFOCUS()\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0,.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0.5,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0.5,.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(1.0,.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(1.0,.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(2.0,.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(2.0,.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(2.5,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(2.5,.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(5.0,.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(5.0,.T.,.T.)\nRDDTESTF \"TG_N\", {13,.f.,.f.,.t.}, ORDSETFOCUS(2)\nRDDTESTF \"TG_C\", {13,.f.,.f.,.t.}, ORDSETFOCUS()\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTC {15,.f.,.f.,.f.}, INDEX on FSTR tag TG_C to \"_tst\" DESCEND\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .t., {3,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .t., {3,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK(\"5\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTC {1,.f.,.f.,.f.}, INDEX on FSTR tag TG_C to \"_tst\"\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTOP()\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBGOBOTTOM()\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(0)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {2,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(5)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {10,.f.,.f.,.f.}, DBSKIP(-5)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBSKIP(10)\nRDDTESTF NIL, {11,.f.,.f.,.f.}, DBSKIP(-5)\nRDDTESTF NIL, {16,.t.,.t.,.f.}, DBGOTO(16)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {2,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {1,.f.,.f.,.f.}, DBGOTO(1)\nRDDTESTF NIL, {1,.t.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {4,.f.,.f.,.f.}, DBGOTO(4)\nRDDTESTF NIL, {5,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {4,.f.,.f.,.f.}, DBGOTO(4)\nRDDTESTF NIL, {3,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBGOTO(6)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBGOTO(6)\nRDDTESTF NIL, {5,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBGOTO(7)\nRDDTESTF NIL, {8,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {7,.f.,.f.,.f.}, DBGOTO(7)\nRDDTESTF NIL, {6,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBGOTO(12)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBGOTO(12)\nRDDTESTF NIL, {11,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBGOTO(13)\nRDDTESTF NIL, {14,.f.,.f.,.f.}, DBSKIP(1)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBGOTO(13)\nRDDTESTF NIL, {12,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {14,.f.,.f.,.f.}, DBGOTO(14)\nRDDTESTF NIL, {13,.f.,.f.,.f.}, DBSKIP(-1)\nRDDTESTF NIL, {16,.t.,.t.,.f.}, DBGOTO(16)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, DBSKIP(-1)"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour Runtime Library file: src/rtl/profiler.prg. Defines classes: HBProfileEntity, HBProfileFunction, HBProfileMethod, HBProfileOPCode, HBProfile. This file provides file I/O operations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"fileio.ch\"\n\n\nCREATE CLASS HBProfileEntity\n\n EXPORTED:\n\n VAR cName READONLY\n VAR nCalls READONLY\n VAR nTicks READONLY\n\n ACCESS nSeconds\n ACCESS nMeanTicks\n ACCESS nMeanSeconds\n\n METHOD init( cName, aInfo )\n METHOD describe()\n\nENDCLASS\n\n\nMETHOD init( cName, aInfo ) CLASS HBProfileEntity\n\n ::cName := cName\n ::nCalls := aInfo[ 1 ]\n ::nTicks := aInfo[ 2 ]\n\n RETURN Self\n\nACCESS nSeconds CLASS HBProfileEntity\n RETURN hb_Clocks2Secs( ::nTicks )\n\nACCESS nMeanTicks CLASS HBProfileEntity\n RETURN iif( ::nCalls == 0, 0, ::nTicks / ::nCalls )\n\nACCESS nMeanSeconds CLASS HBProfileEntity\n RETURN iif( ::nCalls == 0, 0, ::nSeconds / ::nCalls )\n\nMETHOD describe() CLASS HBProfileEntity\n RETURN \"Base Entity\"\n\n\nCREATE CLASS HBProfileFunction INHERIT HBProfileEntity\n\n EXPORTED:\n\n METHOD describe()\n\nENDCLASS\n\n\nMETHOD describe() CLASS HBProfileFunction\n RETURN \"Function\"\n\n\nCREATE CLASS HBProfileMethod INHERIT HBProfileEntity\n\n EXPORTED:\n\n METHOD describe()\n\nENDCLASS\n\n\nMETHOD describe() CLASS HBProfileMethod\n RETURN \"Method\"\n\n\nCREATE CLASS HBProfileOPCode INHERIT HBProfileEntity\n\n EXPORTED:\n\n METHOD describe()\n\nENDCLASS\n\n\nMETHOD describe() CLASS HBProfileOPCode\n RETURN \"OPCode\"\n\n\nCREATE CLASS HBProfile\n\n EXPORTED:\n\n VAR aProfile\n\n METHOD init()\n METHOD gather()\n METHOD forEach( b )\n METHOD sort( b )\n METHOD nameSort()\n METHOD callSort()\n METHOD timeSort()\n METHOD totalCalls()\n METHOD totalTicks()\n METHOD totalSeconds()\n\n PROTECTED:\n\n METHOD gatherFunctions()\n METHOD gatherMethods()\n METHOD reset()\n METHOD ignoreSymbol( cSymbol )\n\nENDCLASS\n\n\nMETHOD init() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n ::reset()\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD reset() CLASS HBProfile\n\n ::aProfile := {}\n\n RETURN Self\n\nMETHOD ignoreSymbol( cSymbol ) CLASS HBProfile\n RETURN hb_LeftEq( cSymbol, \"HBPROFILE\" ) .OR. cSymbol == \"__SETPROFILER\"\n\nMETHOD gatherFunctions() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n LOCAL nSymCount := __dynsCount()\n LOCAL cName\n LOCAL n\n\n \n FOR n := 1 TO nSymCount\n\n \n IF __dynsIsFun( n )\n\n \n IF ! ::ignoreSymbol( cName := __dynsGetName( n ) )\n \n AAdd( ::aProfile, HBProfileFunction():new( cName, __dynsGetPrf( n ) ) )\n ENDIF\n ENDIF\n NEXT\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD gatherMethods() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n LOCAL n := 1\n LOCAL cClass\n LOCAL nMembers\n LOCAL aMembers\n LOCAL nMember\n\n \n DO WHILE ! Empty( cClass := __className( n ) )\n\n \n IF ! ::ignoreSymbol( cClass )\n\n \n nMembers := Len( aMembers := __classSel( n ) )\n\n FOR nMember := 1 TO nMembers\n\n \n IF ! Empty( aMembers[ nMember ] )\n \n AAdd( ::aProfile, HBProfileMethod():new( cClass + \":\" + aMembers[ nMember ], __GetMsgPrf( n, aMembers[ nMember ] ) ) )\n ENDIF\n NEXT\n ENDIF\n\n ++n\n ENDDO\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD gather() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n ::reset() \n ::gatherFunctions() \n ::gatherMethods() \n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD forEach( b ) CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n AEval( ::aProfile, b )\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD sort( b ) CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n ASort( ::aProfile, , , b )\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD nameSort() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n ::sort( {| oX, oY | oX:cName < oY:cName } )\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD callSort() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n ::sort( {| oX, oY | oX:nCalls > oY:nCalls } )\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD timeSort() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n ::sort( {| oX, oY | oX:nTicks > oY:nTicks } )\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD totalCalls() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n LOCAL nCalls := 0\n\n ::forEach( {| o | nCalls += o:nCalls } )\n\n __SetProfiler( lProfile )\n\n RETURN nCalls\n\nMETHOD totalTicks() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n LOCAL nTicks := 0\n\n ::forEach( {| o | nTicks += o:nTicks } )\n\n __SetProfiler( lProfile )\n\n RETURN nTicks\n\nMETHOD totalSeconds() CLASS HBProfile\n\n LOCAL lProfile := __SetProfiler( .F. )\n LOCAL nSeconds := 0\n\n ::forEach( {| o | nSeconds += o:nSeconds } )\n\n __SetProfiler( lProfile )\n\n RETURN nSeconds\n\n\nCREATE CLASS HBProfileLowLevel INHERIT HBProfile\n\n EXPORTED:\n\n METHOD gather()\n\n PROTECTED:\n\n METHOD gatherOPCodes()\n\nENDCLASS\n\n\nMETHOD gather() CLASS HBProfileLowLevel\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n \n ::super:gather()\n\n \n ::gatherOPCodes()\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD gatherOPCodes() CLASS HBProfileLowLevel\n\n LOCAL nMax := __opCount()\n LOCAL cName\n LOCAL nOP\n\n \n FOR nOP := 0 TO nMax - 1\n \n IF ! ::ignoreSymbol( cName := \"OPCODE( \" + Str( nOP, 3 ) + \" )\" )\n \n AAdd( ::aProfile, HBProfileOpcode():new( cName, __opGetPrf( nOP ) ) )\n ENDIF\n NEXT\n\n RETURN Self\n\n\nCREATE CLASS HBProfileReport\n\n PROTECTED:\n\n VAR oProfile\n\n METHOD writeLines( aLines )\n METHOD header()\n METHOD emitHeader()\n METHOD line( oEntity )\n METHOD emitLine( oEntity )\n\n EXPORTED:\n\n METHOD init( oProfile )\n METHOD generate( bFilter )\n\nENDCLASS\n\n\nMETHOD init( oProfile ) CLASS HBProfileReport\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n ::oProfile := oProfile\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\nMETHOD writeLines( aLines ) CLASS HBProfileReport\n\n AEval( aLines, {| c | QOut( c ) } )\n\n RETURN Self\n\nMETHOD header() CLASS HBProfileReport\n RETURN { ;\n \"Name Type Calls Ticks Seconds\", ;\n \"=================================== ========== ======== =========== ===========\" }\n\nMETHOD emitHeader() CLASS HBProfileReport\n\n ::writeLines( ::Header() )\n\n RETURN Self\n\nMETHOD line( oEntity ) CLASS HBProfileReport\n RETURN { ;\n PadR( oEntity:cName, 35 ) + \" \" + ;\n PadR( oEntity:describe(), 8 ) + \" \" + ;\n Str( oEntity:nCalls, 10 ) + \" \" + ;\n Str( oEntity:nTicks, 11 ) + \" \" + ;\n Str( oEntity:nSeconds, 11, 2 ) }\n\nMETHOD emitLine( oEntity ) CLASS HBProfileReport\n\n ::writeLines( ::line( oEntity ) )\n\n RETURN Self\n\nMETHOD generate( bFilter ) CLASS HBProfileReport\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n hb_default( @bFilter, {|| .T. } )\n\n ::emitHeader():oProfile:forEach( {| o | iif( Eval( bFilter, o ), ::emitLine( o ), NIL ) } )\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\n\nCREATE CLASS HBProfileReportToFile INHERIT HBProfileReport\n\n PROTECTED:\n\n VAR hFile\n\n METHOD writeLines( aLines )\n\n EXPORTED:\n\n METHOD generate( bFilter, cFile )\n\nENDCLASS\n\n\nMETHOD writeLines( aLines ) CLASS HBProfileReportToFile\n\n IF ::hFile != F_ERROR\n AEval( aLines, {| c | FWrite( ::hFile, c + hb_eol() ) } )\n ENDIF\n\n RETURN Self\n\nMETHOD generate( bFilter, cFile ) CLASS HBProfileReportToFile\n\n LOCAL lProfile := __SetProfiler( .F. )\n\n IF ( ::hFile := FCreate( hb_defaultValue( cFile, \"hbprof.txt\" ) ) ) != F_ERROR\n ::super:generate( bFilter )\n FClose( ::hFile )\n ELSE\n \n ENDIF\n\n __SetProfiler( lProfile )\n\n RETURN Self\n\n\nCREATE CLASS HBProfileReportToArray INHERIT HBProfileReport\n\n PROTECTED:\n\n VAR aReport\n\n METHOD writeLines( aLines )\n\n EXPORTED:\n\n METHOD generate( bFilter )\n\nENDCLASS\n\n\nMETHOD writeLines( aLines ) CLASS HBProfileReportToArray\n\n AEval( aLines, {| c | AAdd( ::aReport, c ) } )\n\n RETURN Self\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour header file: include/hbhrb.ch. Defines 10 constants including: HB_HRB_CH_, HB_HRB_BIND_DEFAULT, HB_HRB_BIND_LOCAL, HB_HRB_BIND_OVERLOAD, HB_HRB_BIND_FORCELOCAL. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_HRB_CH_\n#define HB_HRB_CH_\n\n#define HB_HRB_BIND_DEFAULT 0x0 \n\n#define HB_HRB_BIND_LOCAL 0x1 \n\n#define HB_HRB_BIND_OVERLOAD 0x2 \n\n#define HB_HRB_BIND_FORCELOCAL 0x3 \n\n#define HB_HRB_BIND_MODEMASK 0x3 \n\n#define HB_HRB_BIND_LAZY 0x4 \n\n#define HB_HRB_ARG_PRGNAME 0x10 \n\n#define HB_HRB_FUNC_PUBLIC 0x1 \n#define HB_HRB_FUNC_STATIC 0x2 \n#define HB_HRB_FUNC_LOCAL 0x3 \n#define HB_HRB_FUNC_EXTERN 0x4 \n\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: CallDll32, hb_DynaCall1, StrPtr. Harbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/calldll.prg. Provides functions: CallDll32, hb_DynaCall1, StrPtr, PtrStr. Contains procedures: UnloadAllDll. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbdyn.ch\"\n\nSTATIC s_hDLL := { => }\nSTATIC s_mutex := hb_mutexCreate()\n\nPROCEDURE UnloadAllDll()\n\n hb_mutexLock( s_mutex )\n s_hDLL := { => }\n hb_mutexUnlock( s_mutex )\n\n RETURN\n\nFUNCTION CallDll32( cFunction, cLibrary, ... )\n RETURN hb_DynaCall1( cFunction, cLibrary, NIL, ... )\n\n#if define( __PLATFORM__WINDOWS )\n \n #define _DEF_CALLCONV_ HB_DYN_CALLCONV_STDCALL\n#else\n #define _DEF_CALLCONV_ HB_DYN_CALLCONV_CDECL\n#endif\n\nFUNCTION hb_DynaCall1( cFunction, cLibrary, nCount, ... )\n\n LOCAL aParams\n LOCAL hHandle\n\n IF HB_ISSTRING( cFunction ) .AND. ;\n HB_ISSTRING( cLibrary )\n\n hb_mutexLock( s_mutex )\n\n IF ! cLibrary $ s_hDLL\n s_hDLL[ cLibrary ] := hb_libLoad( cLibrary )\n ENDIF\n\n hHandle := s_hDLL[ cLibrary ]\n\n hb_mutexUnlock( s_mutex )\n\n IF HB_ISNUMERIC( nCount ) .AND. nCount >= 0 .AND. nCount < PCount() - 3\n aParams := ASize( hb_AParams(), nCount )\n RETURN hb_DynCall( { cFunction, hHandle, _DEF_CALLCONV_ }, hb_ArrayToParams( aParams ) )\n ELSE\n RETURN hb_DynCall( { cFunction, hHandle, _DEF_CALLCONV_ }, ... )\n ENDIF\n ENDIF\n\n RETURN NIL\n\nFUNCTION StrPtr( x )\n RETURN x\n\nFUNCTION PtrStr( x )\n RETURN x"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: _dbExport, xpp_dbUseArea. Harbour contribution module 'hbxpp' (xBase++ compatibility functions): contrib/hbxpp/dbfuncsx.prg. Provides functions: _dbExport, xpp_dbUseArea. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION _dbExport( cFile, aFields, bFor, bWhile, nNext, nRecord, lRest, cXPP_Driver, cDelimiter )\n\n SWITCH hb_defaultValue( cXPP_Driver, \"\" )\n CASE \"SDFDBE\"\n RETURN __dbCopy( cFile, aFields, bFor, bWhile, nNext, nRecord, lRest, \"SDF\" )\n CASE \"DELDBE\"\n RETURN __dbCopy( cFile, aFields, bFor, bWhile, nNext, nRecord, lRest, \"DELIM\", , , cDelimiter )\n ENDSWITCH\n\n RETURN __dbCopy( cFile, aFields, bFor, bWhile, nNext, nRecord, lRest, cXPP_Driver )\n\nFUNCTION xpp_dbUseArea( lNewArea, cDriver, cName, xcAlias, lShared, lReadonly )\n\n LOCAL nOldArea\n LOCAL nArea\n\n IF HB_ISLOGICAL( lNewArea ) .AND. lNewArea\n\n hb_default( @xcAlias, \"\" )\n\n IF Empty( xcAlias )\n xcAlias := cName\n ENDIF\n\n IF HB_ISSTRING( xcAlias )\n nOldArea := Select()\n IF ( nArea := Select( xcAlias ) ) > 0\n xcAlias += \"_\" + hb_ntos( nArea )\n ENDIF\n dbSelectArea( nOldArea )\n ENDIF\n ENDIF\n\n RETURN dbUseArea( lNewArea, cDriver, cName, xcAlias, lShared, lReadonly )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour header file: include/hbthread.ch. Defines constants: HB_THREAD_CH_, HB_THREAD_INHERIT_PUBLIC, HB_THREAD_INHERIT_PRIVATE, HB_THREAD_INHERIT_MEMVARS, HB_THREAD_MEMVARS_COPY. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_THREAD_CH_\n#define HB_THREAD_CH_\n\n#define HB_THREAD_INHERIT_PUBLIC 1\n#define HB_THREAD_INHERIT_PRIVATE 2\n#define HB_THREAD_INHERIT_MEMVARS 3\n#define HB_THREAD_MEMVARS_COPY 4\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHeader file for contribution module 'hblzf' (LZF compression library): contrib/hblzf/hblzf.ch. Defines 6 constants including: HBLZF_CH_, HB_LZF_OK, HB_LZF_BUF_ERROR, HB_LZF_MEM_ERROR, HB_LZF_DATA_CORRUPTED. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HBLZF_CH_\n#define HBLZF_CH_\n\n#define HB_LZF_OK 0\n#define HB_LZF_BUF_ERROR 1\n#define HB_LZF_MEM_ERROR 2\n#define HB_LZF_DATA_CORRUPTED 22\n\n#define HB_LZF_DEFAULT_BUFFSIZE 1024\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/hbdoc.prg. Provides functions: DirGetName. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"directry.ch\"\n#include \"simpleio.ch\"\n\nPROCEDURE Main( cRoot )\n\n LOCAL aEntry\n LOCAL cName\n\n LOCAL aDir\n LOCAL cDir\n\n LOCAL aFile\n\n LOCAL tModified\n LOCAL aErrMsg\n LOCAL tmp\n\n IF ! HB_ISSTRING( cRoot )\n \n cRoot := \".\" + hb_ps()\n DO WHILE hb_DirExists( cRoot + \"..\" )\n IF hb_FileExists( cRoot + \"README.md\" ) .AND. ;\n hb_FileExists( cRoot + \"COPYING.txt\" ) .AND. ;\n hb_DirExists( cRoot + \"config\" )\n EXIT\n ENDIF\n cRoot += \"..\" + hb_ps()\n ENDDO\n ELSE\n cDir := hb_DirSepAdd( cDir )\n ENDIF\n\n ? \"Root: \" + cRoot\n\n aDir := { cRoot }\n\n FOR EACH aFile IN Directory( cRoot + \"contrib\" + hb_ps() + hb_osFileMask(), \"D\" )\n IF \"D\" $ aFile[ F_ATTR ] .AND. ;\n !( aFile[ F_NAME ] == \".\" ) .AND. ;\n !( aFile[ F_NAME ] == \"..\" )\n AAdd( aDir, cRoot + \"contrib\" + hb_ps() + aFile[ F_NAME ] )\n ENDIF\n NEXT\n\n FOR EACH cDir IN aDir\n\n IF ! Empty( tModified := __hbdoc_DirLastModified( cDir ) )\n\n cName := DirGetName( cDir )\n IF Empty( cName )\n cName := \"harbour\"\n ENDIF\n\n aErrMsg := {}\n\n aEntry := __hbdoc_LoadDir( cDir, cName, aErrMsg )\n\n \n FOR EACH tmp IN aErrMsg\n ? tmp\n NEXT\n\n IF ! Empty( aEntry )\n ? __hbdoc_SaveHBD( cName, aEntry ), cName, Len( aEntry ), tModified\n ENDIF\n ENDIF\n NEXT\n\n RETURN\n\nSTATIC FUNCTION DirGetName( cDir )\n\n LOCAL cName\n\n cDir := hb_DirSepDel( cDir )\n\n hb_FNameSplit( cDir,, @cName )\n\n IF Empty( cName ) .OR. cName == \".\" .OR. cName == \"..\"\n RETURN \"\"\n ENDIF\n\n RETURN cName"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/set.prg. Contains procedures: Main, testline. This test file tests specific function APIs"}, {"role": "assistant", "content": "REQUEST DBFNTX\n\nPROCEDURE Main()\n\n \n @ Row(), Col() SAY \"\"\n\n TestLine( \"_SET_EXACT\", 1 )\n TestLine( \"_SET_FIXED\", 2 )\n TestLine( \"_SET_DECIMALS\", 3 )\n TestLine( \"_SET_DATEFORMAT\", 4 )\n TestLine( \"_SET_EPOCH\", 5 )\n TestLine( \"_SET_PATH\", 6 )\n TestLine( \"_SET_DEFAULT\", 7 )\n\n TestLine( \"_SET_EXCLUSIVE\", 8 )\n TestLine( \"_SET_SOFTSEEK\", 9 )\n TestLine( \"_SET_UNIQUE\", 10 )\n TestLine( \"_SET_DELETED\", 11 )\n\n TestLine( \"_SET_CANCEL\", 12 )\n TestLine( \"_SET_DEBUG\", 13 )\n TestLine( \"_SET_TYPEAHEAD\", 14 )\n\n TestLine( \"_SET_COLOR\", 15 )\n TestLine( \"_SET_CURSOR\", 16 )\n TestLine( \"_SET_CONSOLE\", 17 )\n TestLine( \"_SET_ALTERNATE\", 18 )\n TestLine( \"_SET_ALTFILE\", 19 )\n TestLine( \"_SET_DEVICE\", 20 )\n TestLine( \"_SET_EXTRA\", 21 )\n TestLine( \"_SET_EXTRAFILE\", 22 )\n TestLine( \"_SET_PRINTER\", 23 )\n TestLine( \"_SET_PRINTFILE\", 24 )\n TestLine( \"_SET_MARGIN\", 25 )\n\n TestLine( \"_SET_BELL\", 26 )\n TestLine( \"_SET_CONFIRM\", 27 )\n TestLine( \"_SET_ESCAPE\", 28 )\n TestLine( \"_SET_INSERT\", 29 )\n TestLine( \"_SET_EXIT\", 30 )\n TestLine( \"_SET_INTENSITY\", 31 )\n TestLine( \"_SET_SCOREBOARD\", 32 )\n TestLine( \"_SET_DELIMITERS\", 33 )\n TestLine( \"_SET_DELIMCHARS\", 34 )\n\n TestLine( \"_SET_WRAP\", 35 )\n TestLine( \"_SET_MESSAGE\", 36 )\n TestLine( \"_SET_MCENTER\", 37 )\n TestLine( \"_SET_SCROLLBREAK\", 38 )\n\n#ifdef _SET_EVENTMASK\n TestLine( \"_SET_EVENTMASK\", 39 )\n\n TestLine( \"_SET_VIDEOMODE\", 40 )\n\n TestLine( \"_SET_MBLOCKSIZE\", 41 )\n TestLine( \"_SET_MFILEEXT\", 42 )\n\n TestLine( \"_SET_STRICTREAD\", 43 )\n TestLine( \"_SET_OPTIMIZE\", 44 )\n TestLine( \"_SET_AUTOPEN\", 45 )\n TestLine( \"_SET_AUTORDER\", 46 )\n TestLine( \"_SET_AUTOSHARE\", 47 )\n#endif\n\n#ifdef _SET_LANGUAGE\n TestLine( \"_SET_LANGUAGE\", 100 )\n TestLine( \"_SET_IDLEREPEAT\", 101 )\n TestLine( \"_SET_FILECASE\", 102 )\n TestLine( \"_SET_DIRCASE\", 103 )\n TestLine( \"_SET_DIRSEPARATOR\", 104 )\n Set( _SET_DIRSEPARATOR, \"/\" )\n TestLine( \"_SET_DIRSEPARATOR\", 104 )\n#endif\n\n RETURN\n\nPROCEDURE testline( c, n )\n\n ? ;\n Str( n, 3 ),;\n PadR( c, 20 ),;\n Set( n )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/http_adv.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbssl\"\n#require \"hbtip\"\n\n#if ! defined( __HBSCRIPT__HBSHELL )\nREQUEST __HBEXTERN__HBSSL__\n#endif\n\nPROCEDURE Main( cURL )\n\n LOCAL oHTTP, oURL, i\n\n IF Empty( oURL := TUrl():New( cURL ) )\n ? \"Invalid URL\", cURL\n RETURN\n ENDIF\n\n IF ! oURL:cProto == \"http\" .AND. ;\n ! oURL:cProto == \"https\"\n ? \"This is a header test for http/https.\"\n ? \"Use an http/https address.\"\n RETURN\n ENDIF\n\n IF oURL:cProto == \"https\" .AND. ! tip_SSL()\n ? \"Error: Requires SSL support\"\n RETURN\n ENDIF\n\n oHTTP := TIPClientHTTP():New( oURL )\n oHTTP:nConnTimeout := 20000\n ? \"Connecting with\", oURL:cServer\n IF oHTTP:Open( cURL )\n ? \"Connection eshtablished\"\n ? \"Retrieving\", oURL:cPath, oURL:cFile, oURL:cQuery\n\n IF oHTTP:Get( oURL:cPath )\n ? \"Get Successful\"\n FOR EACH i IN oHTTP:hHeaders\n ? i:__enumKey() + \":\", i\n NEXT\n ELSE\n ? \"Get failure (server reply:\", oHTTP:cReply, \")\"\n ENDIF\n\n oHTTP:Close()\n ELSE\n ? \"Could not connect with\", oURL:cServer\n IF oHTTP:SocketCon == NIL\n ? \"Connection not initiated\"\n ELSEIF hb_inetErrorCode( oHTTP:SocketCon ) == 0\n ? \"Server replied:\", oHTTP:cReply\n ELSE\n ? \"Error in connection:\", hb_inetErrorDesc( oHTTP:SocketCon )\n ENDIF\n ENDIF\n\n ? \"Done\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbsqlit3' (SQLite3 database client library): contrib/hbsqlit3/tests/hooks.prg. Provides 6 functions including: CallBack, HookCommitY, HookCommitN, HookRollback, cErrorMsg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbsqlit3\"\n\nPROCEDURE Main()\n\n LOCAL cSQLTEXT, cFile := \":memory:\"\n LOCAL pDb, cb := @CallBack()\n\n IF Empty( pDb := PrepareDB( cFile ) )\n ErrorLevel( 1 )\n RETURN\n ENDIF\n\n sqlite3_commit_hook( pDb, \"HookCommitY\" )\n\n ? cSQLTEXT := \"SELECT * FROM person WHERE name == 'Andy'\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT, cb ) )\n\n ? cSQLTEXT := \"BEGIN EXCLUSIVE TRANSACTION\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT ) )\n\n ? cSQLTEXT := \"DELETE FROM person WHERE name == 'Andy'\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT ) )\n\n ? cSQLTEXT := \"END TRANSACTION\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT ) )\n\n ? cSQLTEXT := \"SELECT * FROM person WHERE name == 'Andy'\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT, cb ) )\n\n ? Replicate( \"-\", Len( cSQLTEXT ) )\n\n sqlite3_sleep( 10000 )\n\n sqlite3_commit_hook( pDb, @HookCommitN() )\n sqlite3_rollback_hook( pDb, @HookRollback() )\n\n ? cSQLTEXT := \"SELECT * FROM person WHERE name == 'Ivet'\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT, cb ) )\n\n ? cSQLTEXT := \"BEGIN EXCLUSIVE TRANSACTION\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT ) )\n\n ? cSQLTEXT := \"DELETE FROM person WHERE name == 'Ivet'\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT ) )\n\n ? cSQLTEXT := \"END TRANSACTION\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT ) )\n\n ? cSQLTEXT := \"SELECT * FROM person WHERE name == 'Ivet'\"\n ? \"return value: \", cErrorMsg( sqlite3_exec( pDb, cSQLTEXT, cb ) )\n\n pDb := NIL\n\n sqlite3_sleep( 10000 )\n\n RETURN\n\n\nFUNCTION CallBack( nColCount, aValue, aColName )\n\n LOCAL nI\n LOCAL oldColor := SetColor( \"G/N\" )\n\n FOR nI := 1 TO nColCount\n ? PadR( aColName[ nI ], 5 ), \" == \", aValue[ nI ]\n NEXT\n\n SetColor( oldColor )\n\n RETURN 0\n\n\nFUNCTION HookCommitY()\n\n LOCAL oldColor := SetColor( \"R+/N\" )\n\n ? \"!! COMMIT\"\n\n SetColor( oldColor )\n\n RETURN 0\n\nFUNCTION HookCommitN()\n\n LOCAL oldColor := SetColor( \"B+/N\" )\n\n ? \"?? COMMIT or ROLLBACK\"\n\n SetColor( oldColor )\n\n RETURN 1 \n\nFUNCTION HookRollback()\n\n LOCAL oldColor := SetColor( \"R+/N\" )\n\n ? \"!! ROLLBACK\"\n\n SetColor( oldColor )\n\n RETURN 1\n\n\nSTATIC FUNCTION cErrorMsg( nError, lShortMsg )\n\n hb_default( @lShortMsg, .T. )\n\n RETURN iif( lShortMsg, hb_sqlite3_errstr_short( nError ), sqlite3_errstr( nError ) )\n\n\nSTATIC FUNCTION PrepareDB( cFile )\n\n LOCAL cSQLTEXT, cMsg\n LOCAL pDb, pStmt\n LOCAL hPerson := { ;\n \"Bob\" => 52, ;\n \"Fred\" => 32, ;\n \"Sasha\" => 17, ;\n \"Andy\" => 20, ;\n \"Ivet\" => 28 ;\n }, enum\n\n pDb := sqlite3_open( cFile, .T. )\n IF Empty( pDb )\n ? \"Can't open/create database : \", cFile\n\n RETURN NIL\n ENDIF\n\n ? cSQLTEXT := \"CREATE TABLE person( name TEXT, age INTEGER )\"\n cMsg := cErrorMsg( sqlite3_exec( pDb, cSQLTEXT ) )\n\n IF !( cMsg == \"SQLITE_OK\" )\n ? \"Can't create table : person\"\n pDb := NIL \n\n RETURN NIL\n ENDIF\n\n cSQLTEXT := \"INSERT INTO person( name, age ) VALUES( :name, :age )\"\n pStmt := sqlite3_prepare( pDb, cSQLTEXT )\n IF Empty( pStmt )\n ? \"Can't prepare statement : \", cSQLTEXT\n pDb := NIL\n\n RETURN NIL\n ENDIF\n\n ? sqlite3_sql( pStmt )\n ? Replicate( \"-\", Len( cSQLTEXT ) )\n\n FOR EACH enum IN hPerson\n sqlite3_reset( pStmt )\n sqlite3_bind_text( pStmt, 1, enum:__enumKey() )\n sqlite3_bind_int( pStmt, 2, enum:__enumValue() )\n sqlite3_step( pStmt )\n NEXT\n\n sqlite3_clear_bindings( pStmt )\n sqlite3_finalize( pStmt )\n\n RETURN pDb"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Header file for contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tip.ch. Defines constants: TIP_CH, TIP_RO, TIP_WO, TIP_RW"}, {"role": "assistant", "content": "#ifndef TIP_CH\n#define TIP_CH\n\n#define TIP_RO 0 \n#define TIP_WO 1 \n#define TIP_RW 2 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbhpdf' (PDF generation library (libharu)): contrib/hbhpdf/errstr.prg. Provides functions: hb_HPDF_GetErrorString. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#include \"harupdf.ch\"\n\n\nFUNCTION hb_HPDF_GetErrorString( nStatus )\n\n IF ! HB_ISNUMERIC( nStatus )\n RETURN \"HB_HPDF_INVALID\"\n ENDIF\n\n SWITCH nStatus\n CASE HB_HPDF_BADPARAM ; RETURN \"HB_HPDF_BADPARAM\"\n CASE HPDF_OK ; RETURN \"HPDF_OK\"\n CASE HPDF_ARRAY_COUNT_ERR ; RETURN \"HPDF_ARRAY_COUNT_ERR\"\n CASE HPDF_ARRAY_ITEM_NOT_FOUND ; RETURN \"HPDF_ARRAY_ITEM_NOT_FOUND\"\n CASE HPDF_ARRAY_ITEM_UNEXPECTED_TYPE ; RETURN \"HPDF_ARRAY_ITEM_UNEXPECTED_TYPE\"\n CASE HPDF_BINARY_LENGTH_ERR ; RETURN \"HPDF_BINARY_LENGTH_ERR\"\n CASE HPDF_CANNOT_GET_PALLET ; RETURN \"HPDF_CANNOT_GET_PALLET\"\n CASE HPDF_DICT_COUNT_ERR ; RETURN \"HPDF_DICT_COUNT_ERR\"\n CASE HPDF_DICT_ITEM_NOT_FOUND ; RETURN \"HPDF_DICT_ITEM_NOT_FOUND\"\n CASE HPDF_DICT_ITEM_UNEXPECTED_TYPE ; RETURN \"HPDF_DICT_ITEM_UNEXPECTED_TYPE\"\n CASE HPDF_DICT_STREAM_LENGTH_NOT_FOUND ; RETURN \"HPDF_DICT_STREAM_LENGTH_NOT_FOUND\"\n CASE HPDF_DOC_ENCRYPTDICT_NOT_FOUND ; RETURN \"HPDF_DOC_ENCRYPTDICT_NOT_FOUND\"\n CASE HPDF_DOC_INVALID_OBJECT ; RETURN \"HPDF_DOC_INVALID_OBJECT\"\n CASE HPDF_DUPLICATE_REGISTRATION ; RETURN \"HPDF_DUPLICATE_REGISTRATION\"\n CASE HPDF_EXCEED_JWW_CODE_NUM_LIMIT ; RETURN \"HPDF_EXCEED_JWW_CODE_NUM_LIMIT\"\n CASE HPDF_ENCRYPT_INVALID_PASSWORD ; RETURN \"HPDF_ENCRYPT_INVALID_PASSWORD\"\n CASE HPDF_ERR_UNKNOWN_CLASS ; RETURN \"HPDF_ERR_UNKNOWN_CLASS\"\n CASE HPDF_EXCEED_GSTATE_LIMIT ; RETURN \"HPDF_EXCEED_GSTATE_LIMIT\"\n CASE HPDF_FAILD_TO_ALLOC_MEM ; RETURN \"HPDF_FAILD_TO_ALLOC_MEM\"\n CASE HPDF_FILE_IO_ERROR ; RETURN \"HPDF_FILE_IO_ERROR\"\n CASE HPDF_FILE_OPEN_ERROR ; RETURN \"HPDF_FILE_OPEN_ERROR\"\n CASE HPDF_FONT_EXISTS ; RETURN \"HPDF_FONT_EXISTS\"\n CASE HPDF_FONT_INVALID_WIDTHS_TABLE ; RETURN \"HPDF_FONT_INVALID_WIDTHS_TABLE\"\n CASE HPDF_INVALID_AFM_HEADER ; RETURN \"HPDF_INVALID_AFM_HEADER\"\n CASE HPDF_INVALID_ANNOTATION ; RETURN \"HPDF_INVALID_ANNOTATION\"\n CASE HPDF_INVALID_BIT_PER_COMPONENT ; RETURN \"HPDF_INVALID_BIT_PER_COMPONENT\"\n CASE HPDF_INVALID_CHAR_MATRICS_DATA ; RETURN \"HPDF_INVALID_CHAR_MATRICS_DATA\"\n CASE HPDF_INVALID_COLOR_SPACE ; RETURN \"HPDF_INVALID_COLOR_SPACE\"\n CASE HPDF_INVALID_COMPRESSION_MODE ; RETURN \"HPDF_INVALID_COMPRESSION_MODE\"\n CASE HPDF_INVALID_DATE_TIME ; RETURN \"HPDF_INVALID_DATE_TIME\"\n CASE HPDF_INVALID_DESTINATION ; RETURN \"HPDF_INVALID_DESTINATION\"\n CASE HPDF_INVALID_DOCUMENT ; RETURN \"HPDF_INVALID_DOCUMENT\"\n CASE HPDF_INVALID_DOCUMENT_STATE ; RETURN \"HPDF_INVALID_DOCUMENT_STATE\"\n CASE HPDF_INVALID_ENCODER ; RETURN \"HPDF_INVALID_ENCODER\"\n CASE HPDF_INVALID_ENCODER_TYPE ; RETURN \"HPDF_INVALID_ENCODER_TYPE\"\n CASE HPDF_INVALID_ENCODING_NAME ; RETURN \"HPDF_INVALID_ENCODING_NAME\"\n CASE HPDF_INVALID_ENCRYPT_KEY_LEN ; RETURN \"HPDF_INVALID_ENCRYPT_KEY_LEN\"\n CASE HPDF_INVALID_FONTDEF_DATA ; RETURN \"HPDF_INVALID_FONTDEF_DATA\"\n CASE HPDF_INVALID_FONTDEF_TYPE ; RETURN \"HPDF_INVALID_FONTDEF_TYPE\"\n CASE HPDF_INVALID_FONT_NAME ; RETURN \"HPDF_INVALID_FONT_NAME\"\n CASE HPDF_INVALID_IMAGE ; RETURN \"HPDF_INVALID_IMAGE\"\n CASE HPDF_INVALID_JPEG_DATA ; RETURN \"HPDF_INVALID_JPEG_DATA\"\n CASE HPDF_INVALID_N_DATA ; RETURN \"HPDF_INVALID_N_DATA\"\n CASE HPDF_INVALID_OBJECT ; RETURN \"HPDF_INVALID_OBJECT\"\n CASE HPDF_INVALID_OBJ_ID ; RETURN \"HPDF_INVALID_OBJ_ID\"\n CASE HPDF_INVALID_OPERATION ; RETURN \"HPDF_INVALID_OPERATION\"\n CASE HPDF_INVALID_OUTLINE ; RETURN \"HPDF_INVALID_OUTLINE\"\n CASE HPDF_INVALID_PAGE ; RETURN \"HPDF_INVALID_PAGE\"\n CASE HPDF_INVALID_PAGES ; RETURN \"HPDF_INVALID_PAGES\"\n CASE HPDF_INVALID_PARAMETER ; RETURN \"HPDF_INVALID_PARAMETER\"\n CASE HPDF_INVALID_PNG_IMAGE ; RETURN \"HPDF_INVALID_PNG_IMAGE\"\n CASE HPDF_INVALID_STREAM ; RETURN \"HPDF_INVALID_STREAM\"\n CASE HPDF_MISSING_FILE_NAME_ENTRY ; RETURN \"HPDF_MISSING_FILE_NAME_ENTRY\"\n CASE HPDF_INVALID_TTC_FILE ; RETURN \"HPDF_INVALID_TTC_FILE\"\n CASE HPDF_INVALID_TTC_INDEX ; RETURN \"HPDF_INVALID_TTC_INDEX\"\n CASE HPDF_INVALID_WX_DATA ; RETURN \"HPDF_INVALID_WX_DATA\"\n CASE HPDF_ITEM_NOT_FOUND ; RETURN \"HPDF_ITEM_NOT_FOUND\"\n CASE HPDF_LIBPNG_ERROR ; RETURN \"HPDF_LIBPNG_ERROR\"\n CASE HPDF_NAME_INVALID_VALUE ; RETURN \"HPDF_NAME_INVALID_VALUE\"\n CASE HPDF_NAME_OUT_OF_RANGE ; RETURN \"HPDF_NAME_OUT_OF_RANGE\"\n CASE HPDF_PAGE_INVALID_PARAM_COUNT ; RETURN \"HPDF_PAGE_INVALID_PARAM_COUNT\"\n CASE HPDF_PAGES_MISSING_KIDS_ENTRY ; RETURN \"HPDF_PAGES_MISSING_KIDS_ENTRY\"\n CASE HPDF_PAGE_CANNOT_FIND_OBJECT ; RETURN \"HPDF_PAGE_CANNOT_FIND_OBJECT\"\n CASE HPDF_PAGE_CANNOT_GET_ROOT_PAGES ; RETURN \"HPDF_PAGE_CANNOT_GET_ROOT_PAGES\"\n CASE HPDF_PAGE_CANNOT_RESTORE_GSTATE ; RETURN \"HPDF_PAGE_CANNOT_RESTORE_GSTATE\"\n CASE HPDF_PAGE_CANNOT_SET_PARENT ; RETURN \"HPDF_PAGE_CANNOT_SET_PARENT\"\n CASE HPDF_PAGE_FONT_NOT_FOUND ; RETURN \"HPDF_PAGE_FONT_NOT_FOUND\"\n CASE HPDF_PAGE_INVALID_FONT ; RETURN \"HPDF_PAGE_INVALID_FONT\"\n CASE HPDF_PAGE_INVALID_FONT_SIZE ; RETURN \"HPDF_PAGE_INVALID_FONT_SIZE\"\n CASE HPDF_PAGE_INVALID_GMODE ; RETURN \"HPDF_PAGE_INVALID_GMODE\"\n CASE HPDF_PAGE_INVALID_INDEX ; RETURN \"HPDF_PAGE_INVALID_INDEX\"\n CASE HPDF_PAGE_INVALID_ROTATE_VALUE ; RETURN \"HPDF_PAGE_INVALID_ROTATE_VALUE\"\n CASE HPDF_PAGE_INVALID_SIZE ; RETURN \"HPDF_PAGE_INVALID_SIZE\"\n CASE HPDF_PAGE_INVALID_XOBJECT ; RETURN \"HPDF_PAGE_INVALID_XOBJECT\"\n CASE HPDF_PAGE_OUT_OF_RANGE ; RETURN \"HPDF_PAGE_OUT_OF_RANGE\"\n CASE HPDF_REAL_OUT_OF_RANGE ; RETURN \"HPDF_REAL_OUT_OF_RANGE\"\n CASE HPDF_STREAM_EOF ; RETURN \"HPDF_STREAM_EOF\"\n CASE HPDF_STREAM_READLN_CONTINUE ; RETURN \"HPDF_STREAM_READLN_CONTINUE\"\n CASE HPDF_STRING_OUT_OF_RANGE ; RETURN \"HPDF_STRING_OUT_OF_RANGE\"\n CASE HPDF_THIS_FUNC_WAS_SKIPPED ; RETURN \"HPDF_THIS_FUNC_WAS_SKIPPED\"\n CASE HPDF_TTF_CANNOT_EMBEDDING_FONT ; RETURN \"HPDF_TTF_CANNOT_EMBEDDING_FONT\"\n CASE HPDF_TTF_INVALID_CMAP ; RETURN \"HPDF_TTF_INVALID_CMAP\"\n CASE HPDF_TTF_INVALID_FOMAT ; RETURN \"HPDF_TTF_INVALID_FOMAT\"\n CASE HPDF_TTF_MISSING_TABLE ; RETURN \"HPDF_TTF_MISSING_TABLE\"\n CASE HPDF_UNSUPPORTED_FONT_TYPE ; RETURN \"HPDF_UNSUPPORTED_FONT_TYPE\"\n CASE HPDF_UNSUPPORTED_FUNC ; RETURN \"HPDF_UNSUPPORTED_FUNC\"\n CASE HPDF_UNSUPPORTED_JPEG_FORMAT ; RETURN \"HPDF_UNSUPPORTED_JPEG_FORMAT\"\n CASE HPDF_UNSUPPORTED_TYPE1_FONT ; RETURN \"HPDF_UNSUPPORTED_TYPE1_FONT\"\n CASE HPDF_XREF_COUNT_ERR ; RETURN \"HPDF_XREF_COUNT_ERR\"\n CASE HPDF_ZLIB_ERROR ; RETURN \"HPDF_ZLIB_ERROR\"\n CASE HPDF_INVALID_PAGE_INDEX ; RETURN \"HPDF_INVALID_PAGE_INDEX\"\n CASE HPDF_INVALID_URI ; RETURN \"HPDF_INVALID_URI\"\n CASE HPDF_PAGE_LAYOUT_OUT_OF_RANGE ; RETURN \"HPDF_PAGE_LAYOUT_OUT_OF_RANGE\"\n CASE HPDF_PAGE_MODE_OUT_OF_RANGE ; RETURN \"HPDF_PAGE_MODE_OUT_OF_RANGE\"\n CASE HPDF_PAGE_NUM_STYLE_OUT_OF_RANGE ; RETURN \"HPDF_PAGE_NUM_STYLE_OUT_OF_RANGE\"\n CASE HPDF_ANNOT_INVALID_ICON ; RETURN \"HPDF_ANNOT_INVALID_ICON\"\n CASE HPDF_ANNOT_INVALID_BORDER_STYLE ; RETURN \"HPDF_ANNOT_INVALID_BORDER_STYLE\"\n CASE HPDF_PAGE_INVALID_DIRECTION ; RETURN \"HPDF_PAGE_INVALID_DIRECTION\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour test program: tests/asort.prg. Provides functions: aDump, xToStr. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n #define hb_ntos( n ) LTrim( Str( n ) )\n#endif\n\nPROCEDURE Main()\n\n LOCAL oError := ErrorNew()\n\n LOCAL a := { 3, 2, 1 }\n LOCAL b := { 10 }\n LOCAL c := { 2, .T., \"B\", NIL, { 1 }, {|| b }, oError, Date(), 1, .F., \"A\", NIL, Date() - 1, { 0 }, {|| a }, oError }\n\n ? \"Original...:\", aDump( a )\n ? \"ASort......:\", aDump( ASort( AClone( a ) ) )\n ? \"ASort.block:\", aDump( ASort( AClone( a ), , , {| x, y | x < y } ) )\n ?\n ? \"Original...:\", aDump( b )\n ? \"ASort......:\", aDump( ASort( AClone( b ) ) )\n ? \"ASort.block:\", aDump( ASort( AClone( b ), , , {| x, y | x < y } ) )\n ?\n ? \"Original...:\", aDump( c )\n ? \"ASort......:\", aDump( ASort( AClone( c ) ) )\n ? \"ASort.block:\", aDump( ASort( AClone( c ), , , {| x, y | xToStr( x ) < xToStr( y ) } ) )\n ?\n\n RETURN\n\nFUNCTION aDump( a )\n\n LOCAL cStr := \"\"\n LOCAL n := Len( a )\n LOCAL i\n\n FOR i := 1 TO n\n cStr += AllTrim( xToStr( a[ i ] ) ) + \" \"\n NEXT\n\n RETURN cStr\n\nFUNCTION xToStr( xValue )\n\n LOCAL cType := ValType( xValue )\n\n DO CASE\n CASE cType == \"C\" .OR. cType == \"M\"\n RETURN xValue\n CASE cType == \"N\"\n RETURN hb_ntos( xValue )\n CASE cType == \"D\"\n RETURN DToC( xValue )\n CASE cType == \"L\"\n RETURN iif( xValue, \".T.\", \".F.\" )\n CASE cType == \"U\"\n RETURN \"NIL\"\n CASE cType == \"A\"\n RETURN \"{.}\"\n CASE cType == \"B\"\n RETURN \"{|| }\"\n CASE cType == \"O\"\n RETURN \"[O]\"\n ENDCASE\n\n RETURN xValue"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/kxlat.prg. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n\n#include \"hbgtinfo.ch\"\n#include \"hbinkey.ch\"\n\n#include \"ctscan.ch\"\n\n\n#define hb_keyCode( x ) Asc( x )\n\nSTATIC s_hTrs := { => }\nSTATIC s_hMutex := hb_mutexCreate()\n\nSTATIC sc_hCnv := { ;\n KS_DISABLE => 0 , ;\n KS_A => hb_keyCode( \"A\" ) , ;\n KS_B => hb_keyCode( \"B\" ) , ;\n KS_C => hb_keyCode( \"C\" ) , ;\n KS_D => hb_keyCode( \"D\" ) , ;\n KS_E => hb_keyCode( \"E\" ) , ;\n KS_F => hb_keyCode( \"F\" ) , ;\n KS_G => hb_keyCode( \"G\" ) , ;\n KS_H => hb_keyCode( \"H\" ) , ;\n KS_I => hb_keyCode( \"I\" ) , ;\n KS_J => hb_keyCode( \"J\" ) , ;\n KS_K => hb_keyCode( \"K\" ) , ;\n KS_L => hb_keyCode( \"L\" ) , ;\n KS_M => hb_keyCode( \"M\" ) , ;\n KS_N => hb_keyCode( \"N\" ) , ;\n KS_O => hb_keyCode( \"O\" ) , ;\n KS_P => hb_keyCode( \"P\" ) , ;\n KS_Q => hb_keyCode( \"Q\" ) , ;\n KS_R => hb_keyCode( \"R\" ) , ;\n KS_S => hb_keyCode( \"S\" ) , ;\n KS_T => hb_keyCode( \"T\" ) , ;\n KS_U => hb_keyCode( \"U\" ) , ;\n KS_V => hb_keyCode( \"V\" ) , ;\n KS_W => hb_keyCode( \"W\" ) , ;\n KS_X => hb_keyCode( \"X\" ) , ;\n KS_Y => hb_keyCode( \"Y\" ) , ;\n KS_Z => hb_keyCode( \"Z\" ) , ;\n KS_a => hb_keyCode( \"a\" ) , ;\n KS_b => hb_keyCode( \"b\" ) , ;\n KS_c => hb_keyCode( \"c\" ) , ;\n KS_d => hb_keyCode( \"d\" ) , ;\n KS_e => hb_keyCode( \"e\" ) , ;\n KS_f => hb_keyCode( \"f\" ) , ;\n KS_g => hb_keyCode( \"g\" ) , ;\n KS_h => hb_keyCode( \"h\" ) , ;\n KS_i => hb_keyCode( \"i\" ) , ;\n KS_j => hb_keyCode( \"j\" ) , ;\n KS_k => hb_keyCode( \"k\" ) , ;\n KS_l => hb_keyCode( \"l\" ) , ;\n KS_m => hb_keyCode( \"m\" ) , ;\n KS_n => hb_keyCode( \"n\" ) , ;\n KS_o => hb_keyCode( \"o\" ) , ;\n KS_p => hb_keyCode( \"p\" ) , ;\n KS_q => hb_keyCode( \"q\" ) , ;\n KS_r => hb_keyCode( \"r\" ) , ;\n KS_s => hb_keyCode( \"s\" ) , ;\n KS_t => hb_keyCode( \"t\" ) , ;\n KS_u => hb_keyCode( \"u\" ) , ;\n KS_v => hb_keyCode( \"v\" ) , ;\n KS_w => hb_keyCode( \"w\" ) , ;\n KS_x => hb_keyCode( \"x\" ) , ;\n KS_y => hb_keyCode( \"y\" ) , ;\n KS_z => hb_keyCode( \"z\" ) , ;\n KS_1 => hb_keyCode( \"1\" ) , ;\n KS_2 => hb_keyCode( \"2\" ) , ;\n KS_3 => hb_keyCode( \"3\" ) , ;\n KS_4 => hb_keyCode( \"4\" ) , ;\n KS_5 => hb_keyCode( \"5\" ) , ;\n KS_6 => hb_keyCode( \"6\" ) , ;\n KS_7 => hb_keyCode( \"7\" ) , ;\n KS_8 => hb_keyCode( \"8\" ) , ;\n KS_9 => hb_keyCode( \"9\" ) , ;\n KS_0 => hb_keyCode( \"0\" ) , ;\n KS_DOT => hb_keyCode( \".\" ) , ;\n KS_COMMA => hb_keyCode( \",\" ) , ;\n KS_CTRL_A => K_CTRL_A , ;\n KS_CTRL_B => K_CTRL_B , ;\n KS_CTRL_C => K_CTRL_C , ;\n KS_CTRL_D => K_CTRL_D , ;\n KS_CTRL_E => K_CTRL_E , ;\n KS_CTRL_F => K_CTRL_F , ;\n KS_CTRL_G => K_CTRL_G , ;\n KS_CTRL_H => K_CTRL_H , ;\n KS_CTRL_I => K_CTRL_I , ;\n KS_CTRL_M => K_CTRL_M , ;\n KS_CTRL_N => K_CTRL_N , ;\n KS_CTRL_R => K_CTRL_R , ;\n KS_CTRL_S => K_CTRL_S , ;\n KS_CTRL_T => K_CTRL_T , ;\n KS_CTRL_U => K_CTRL_U , ;\n KS_CTRL_V => K_CTRL_V , ;\n KS_CTRL_W => K_CTRL_W , ;\n KS_CTRL_X => K_CTRL_X , ;\n KS_CTRL_Y => K_CTRL_Y , ;\n KS_CTRL_Z => K_CTRL_Z , ;\n KS_ALT_A => K_ALT_A , ;\n KS_ALT_B => K_ALT_B , ;\n KS_ALT_C => K_ALT_C , ;\n KS_ALT_D => K_ALT_D , ;\n KS_ALT_E => K_ALT_E , ;\n KS_ALT_F => K_ALT_F , ;\n KS_ALT_G => K_ALT_G , ;\n KS_ALT_H => K_ALT_H , ;\n KS_ALT_I => K_ALT_I , ;\n KS_ALT_J => K_ALT_J , ;\n KS_ALT_K => K_ALT_K , ;\n KS_ALT_L => K_ALT_L , ;\n KS_ALT_M => K_ALT_M , ;\n KS_ALT_N => K_ALT_N , ;\n KS_ALT_O => K_ALT_O , ;\n KS_ALT_P => K_ALT_P , ;\n KS_ALT_Q => K_ALT_Q , ;\n KS_ALT_R => K_ALT_R , ;\n KS_ALT_S => K_ALT_S , ;\n KS_ALT_T => K_ALT_T , ;\n KS_ALT_U => K_ALT_U , ;\n KS_ALT_V => K_ALT_V , ;\n KS_ALT_W => K_ALT_W , ;\n KS_ALT_X => K_ALT_X , ;\n KS_ALT_Y => K_ALT_Y , ;\n KS_ALT_Z => K_ALT_Z , ;\n KS_ALT_1 => K_ALT_1 , ;\n KS_ALT_2 => K_ALT_2 , ;\n KS_ALT_3 => K_ALT_3 , ;\n KS_ALT_4 => K_ALT_4 , ;\n KS_ALT_5 => K_ALT_5 , ;\n KS_ALT_6 => K_ALT_6 , ;\n KS_ALT_7 => K_ALT_7 , ;\n KS_ALT_8 => K_ALT_8 , ;\n KS_ALT_9 => K_ALT_9 , ;\n KS_ALT_0 => K_ALT_0 , ;\n KS_F1 => K_F1 , ;\n KS_F2 => K_F2 , ;\n KS_F3 => K_F3 , ;\n KS_F4 => K_F4 , ;\n KS_F5 => K_F5 , ;\n KS_F6 => K_F6 , ;\n KS_F7 => K_F7 , ;\n KS_F8 => K_F8 , ;\n KS_F9 => K_F9 , ;\n KS_F10 => K_F10 , ;\n KS_F11 => K_F11 , ;\n KS_F12 => K_F12 , ;\n KS_SH_F1 => K_SH_F1 , ;\n KS_SH_F2 => K_SH_F2 , ;\n KS_SH_F3 => K_SH_F3 , ;\n KS_SH_F4 => K_SH_F4 , ;\n KS_SH_F5 => K_SH_F5 , ;\n KS_SH_F6 => K_SH_F6 , ;\n KS_SH_F7 => K_SH_F7 , ;\n KS_SH_F8 => K_SH_F8 , ;\n KS_SH_F9 => K_SH_F9 , ;\n KS_SH_F10 => K_SH_F10 , ;\n KS_SH_F11 => K_SH_F11 , ;\n KS_SH_F12 => K_SH_F12 , ;\n KS_CTRL_F1 => K_CTRL_F1 , ;\n KS_CTRL_F2 => K_CTRL_F2 , ;\n KS_CTRL_F3 => K_CTRL_F3 , ;\n KS_CTRL_F4 => K_CTRL_F4 , ;\n KS_CTRL_F5 => K_CTRL_F5 , ;\n KS_CTRL_F6 => K_CTRL_F6 , ;\n KS_CTRL_F7 => K_CTRL_F7 , ;\n KS_CTRL_F8 => K_CTRL_F8 , ;\n KS_CTRL_F9 => K_CTRL_F9 , ;\n KS_CTRL_F10 => K_CTRL_F10 , ;\n KS_CTRL_F11 => K_CTRL_F11 , ;\n KS_CTRL_F12 => K_CTRL_F12 , ;\n KS_ALT_F1 => K_ALT_F1 , ;\n KS_ALT_F2 => K_ALT_F2 , ;\n KS_ALT_F3 => K_ALT_F3 , ;\n KS_ALT_F4 => K_ALT_F4 , ;\n KS_ALT_F5 => K_ALT_F5 , ;\n KS_ALT_F6 => K_ALT_F6 , ;\n KS_ALT_F7 => K_ALT_F7 , ;\n KS_ALT_F8 => K_ALT_F8 , ;\n KS_ALT_F9 => K_ALT_F9 , ;\n KS_ALT_F10 => K_ALT_F10 , ;\n KS_ALT_F11 => K_ALT_F11 , ;\n KS_ALT_F12 => K_ALT_F12 , ;"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour Runtime Library file: src/rtl/menuto.prg. Provides functions: __AtPrompt, __MenuTo, HitTest. This file provides utility functions"}, {"role": "assistant", "content": "#include \"color.ch\"\n#include \"inkey.ch\"\n#include \"hbmemvar.ch\"\n#include \"setcurs.ch\"\n\n#define _ITM_ROW 1\n#define _ITM_COL 2\n#define _ITM_PROMPT 3\n#define _ITM_MSG 4\n#define _ITM_COLOR 5\n\nTHREAD STATIC t_aLevel := {}\nTHREAD STATIC t_nPointer := 1\n\n\nFUNCTION __AtPrompt( nRow, nCol, cPrompt, cMsg, cColor )\n\n IF t_nPointer < 1\n t_nPointer := 1\n ENDIF\n\n \n DO WHILE Len( t_aLevel ) < t_nPointer\n AAdd( t_aLevel, {} )\n ENDDO\n\n \n AAdd( t_aLevel[ t_nPointer ], { ;\n nRow, ; \n nCol, ; \n cPrompt, ; \n cMsg, ; \n cColor } ) \n\n \n DispOutAt( nRow, nCol, cPrompt, cColor )\n\n RETURN .F.\n\nFUNCTION __MenuTo( bBlock, cVariable )\n\n LOCAL nKey\n LOCAL cKey\n LOCAL y\n LOCAL q\n LOCAL n\n LOCAL lExit\n LOCAL nArrLen\n LOCAL xMsg\n LOCAL nMsgCol\n LOCAL nMsgRow\n LOCAL lMsgCenter\n LOCAL nSaveCursor\n LOCAL cSaveReadVar\n\n LOCAL lDeclared\n LOCAL bAction\n#ifdef HB_COMPAT_C53\n LOCAL nMouseClik\n#endif\n\n LOCAL nPointer\n LOCAL cColor\n LOCAL cColorSelect\n LOCAL cColorNormal\n#ifndef HB_CLP_STRICT\n LOCAL nHiLited\n#endif\n\n \n lDeclared := ! __mvExist( cVariable )\n\n IF lDeclared\n __mvPublic( cVariable )\n ENDIF\n\n n := Eval( bBlock )\n\n \n IF t_nPointer < 1 .OR. t_nPointer > Len( t_aLevel )\n\n n := 0\n\n ELSE\n\n t_nPointer++\n nPointer := t_nPointer\n\n nArrLen := Len( t_aLevel[ nPointer - 1 ] )\n\n \n IF ! HB_ISNUMERIC( n ) .OR. n < 1\n n := 1\n ENDIF\n\n IF n > nArrLen\n n := nArrLen\n ENDIF\n\n \n#ifndef HB_CLP_STRICT\n nHiLited := 0\n#endif\n\n nSaveCursor := SetCursor( iif( Set( _SET_INTENSITY ), SC_NONE, NIL ) )\n cSaveReadVar := ReadVar( hb_asciiUpper( cVariable ) )\n xMsg := \"\"\n nMsgCol := 0\n nMsgRow := Set( _SET_MESSAGE )\n lMsgCenter := Set( _SET_MCENTER )\n lExit := .F.\n\n DO WHILE n != 0\n\n \n IF nMsgRow > 0\n\n IF ! Empty( xMsg )\n DispOutAt( nMsgRow, nMsgCol, Space( Len( xMsg ) ) )\n ENDIF\n\n xMsg := t_aLevel[ nPointer - 1 ][ n ][ _ITM_MSG ]\n\n \n IF HB_ISEVALITEM( xMsg )\n xMsg := Eval( xMsg )\n ENDIF\n\n hb_default( @xMsg, \"\" )\n\n IF lMsgCenter\n nMsgCol := Int( ( MaxCol() - Len( xMsg ) ) / 2 )\n ENDIF\n\n DispOutAt( nMsgRow, nMsgCol, xMsg )\n\n ENDIF\n\n \n q := n\n\n cColor := t_aLevel[ t_nPointer - 1 ][ n ][ _ITM_COLOR ]\n cColorNormal := hb_ColorIndex( iif( Empty( hb_ColorIndex( cColor, CLR_STANDARD ) ), SetColor(), cColor ), CLR_STANDARD )\n IF Set( _SET_INTENSITY )\n cColorSelect := hb_ColorIndex( iif( Empty( hb_ColorIndex( cColor, CLR_ENHANCED ) ), SetColor(), cColor ), CLR_ENHANCED )\n ELSE\n cColorSelect := cColorNormal\n ENDIF\n\n#ifndef HB_CLP_STRICT\n \n IF nHiLited != n\n nHiLited := n\n#endif\n \n DispOutAt( ;\n t_aLevel[ nPointer - 1 ][ n ][ _ITM_ROW ], ;\n t_aLevel[ nPointer - 1 ][ n ][ _ITM_COL ], ;\n t_aLevel[ nPointer - 1 ][ n ][ _ITM_PROMPT ], ;\n cColorSelect )\n#ifndef HB_CLP_STRICT\n ENDIF\n#endif\n\n IF lExit\n EXIT\n ENDIF\n\n nKey := 0\n DO WHILE nKey == 0\n\n \n nKey := Inkey( 0 )\n\n IF ( bAction := SetKey( nKey ) ) != NIL\n\n Eval( bBlock, n )\n Eval( bAction, ProcName( 1 ), ProcLine( 1 ), hb_asciiUpper( cVariable ) )\n n := Eval( bBlock )\n\n IF n < 1\n n := 1\n ELSEIF n > nArrLen\n n := nArrLen\n ENDIF\n\n nKey := 0\n\n ENDIF\n ENDDO\n\n \n SWITCH nKey\n#ifdef HB_COMPAT_C53\n CASE K_MOUSEMOVE\n EXIT\n CASE K_LBUTTONDOWN\n CASE K_LDBLCLK\n IF ( nMouseClik := HitTest( t_aLevel[ nPointer - 1 ], ;\n MRow(), MCol() ) ) > 0\n n := nMouseClik\n ENDIF\n \n IF nKey == K_LDBLCLK\n lExit := .T.\n ENDIF\n EXIT\n#endif\n CASE K_DOWN\n CASE K_RIGHT\n IF ++n > nArrLen\n n := iif( Set( _SET_WRAP ), 1, nArrLen )\n ENDIF\n EXIT\n CASE K_UP\n CASE K_LEFT\n IF --n < 1\n n := iif( Set( _SET_WRAP ), nArrLen, 1 )\n ENDIF\n EXIT\n CASE K_HOME\n n := 1\n EXIT\n CASE K_END\n n := nArrLen\n EXIT\n CASE K_ENTER\n CASE K_PGUP\n CASE K_PGDN\n lExit := .T.\n EXIT\n CASE K_ESC\n n := 0\n EXIT\n OTHERWISE\n \n IF Len( cKey := Upper( hb_keyChar( nKey ) ) ) > 0\n FOR y := 1 TO nArrLen\n IF hb_LeftEqI( LTrim( t_aLevel[ nPointer - 1 ][ y ][ _ITM_PROMPT ] ), cKey )\n n := y\n lExit := .T.\n EXIT\n ENDIF\n NEXT\n ENDIF\n ENDSWITCH\n\n IF n != 0\n#ifndef HB_CLP_STRICT\n \n IF nHiLited != n\n nHiLited := 0\n#endif\n DispOutAt( ;\n t_aLevel[ nPointer - 1 ][ q ][ _ITM_ROW ], ;\n t_aLevel[ nPointer - 1 ][ q ][ _ITM_COL ], ;\n t_aLevel[ nPointer - 1 ][ q ][ _ITM_PROMPT ], ;\n cColorNormal )\n#ifndef HB_CLP_STRICT\n ENDIF\n#endif\n ENDIF\n\n ENDDO\n\n ReadVar( cSaveReadVar )\n SetCursor( nSaveCursor )\n\n t_nPointer := nPointer\n t_nPointer--\n ASize( t_aLevel, t_nPointer - 1 )\n\n ENDIF\n\n Eval( bBlock, n )\n\n IF lDeclared\n __mvXRelease( cVariable )\n ENDIF\n\n SetPos( MaxRow() - 1, 0 )\n\n RETURN n\n\n#ifdef HB_COMPAT_C53\n\nSTATIC FUNCTION HitTest( aMenu, nMRow, nMCol )\n\n LOCAL aMenuItem\n\n FOR EACH aMenuItem IN aMenu\n IF nMRow == aMenuItem[ _ITM_ROW ] .AND. ;\n nMCol >= aMenuItem[ _ITM_COL ] .AND. ;\n nMCol < aMenuItem[ _ITM_COL ] + Len( aMenuItem[ _ITM_PROMPT ] )\n\n RETURN aMenuItem:__enumIndex()\n ENDIF\n NEXT\n\n RETURN 0\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbzebra' (Barcode generation library): contrib/hbzebra/tests/pclqr.prg. Contains procedures: Main, DrawBarcodePCL, PclWriteBitmap. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbzebra\"\n\n#define WIDTH 10\n\nREQUEST HB_GT_CGI_DEFAULT\n\n\nPROCEDURE Main( nDpi, nX, nY, cCode, cLabel, cFile, ... ) \n LOCAL n\n\n IF HB_ISSTRING( nDpi )\n nDpi := Val( nDpi )\n ELSE\n nDpi := 300\n ENDIF\n\n IF HB_ISSTRING( nX )\n nX := Val( nX )\n ENDIF\n\n IF HB_ISSTRING( nY )\n nY := Val( nY )\n ENDIF\n\n IF PCount() > 6\n FOR n := 7 TO PCount()\n cFile += \" \" + hb_PValue( n )\n NEXT\n ENDIF\n\n IF Empty( cCode )\n cCode := \"https:\n ENDIF\n\n DrawBarcodePCL( WIDTH, \"QRCODE\",, nDpi, nX, nY, cCode, cLabel, cFile )\n\n RETURN\n\nSTATIC PROCEDURE DrawBarcodePCL( nLineWidth, cType, nFlags, nDpi, nX, nY, cCode, cLabel, cFile )\n\n LOCAL hZebra, cBitMap, nXPad, nYPad, ;\n nLineHeight, nWidth, nHeight\n\n \n SWITCH cType\n\n CASE \"QRCODE\" ; hZebra := hb_zebra_create_qrcode( cCode, nFlags ); nLineHeight := nLineWidth ; EXIT\n ENDSWITCH\n\n IF hZebra != NIL\n IF hb_zebra_geterror( hZebra ) == 0\n\n IF nLineHeight == NIL\n nLineHeight := nLineWidth\n ? \"Type\", cType, \"Code\", cCode, \"Error\", hb_zebra_geterror( hZebra )\n ENDIF\n hb_zebra_destroy( hZebra )\n ELSE\n ? \"Invalid barcode type\", cType\n ENDIF\n\n RETURN\n\n\nPROCEDURE PclWriteBitmap( cBitMap, nWidth, nHeight, nDpi, nX, nY, cLabel, cFile )\n\n LOCAL hFile, cContents, lPrepend := .T.\n LOCAL nRow, nBytesPerRow, nPos, cRow\n\n IF Empty( cFile )\n cFile := \"output.pcl\"\n lPrepend := .F.\n ENDIF\n\n IF ! Empty( lPrepend ) .AND. File( cFile )\n cContents := hb_MemoRead( cFile )\n ENDIF\n\n hFile := FCreate( cFile )\n IF hFile < 0\n ? \"Cannot create file:\", cFile\n RETURN\n ENDIF\n\n nBytesPerRow := Int( ( nWidth + 7 ) / 8 )\n\n \n FWrite( hFile, Chr( 27 ) + \"*t\" + hb_ntos( nDpi ) + \"R\" ) \n\n \n IF ! Empty( nX )\n FWrite( hFile, Chr( 27 ) + \"*p\" + hb_ntos( Int( nDpi * nX ) ) + \"X\" ) \n ENDIF\n\n IF ! Empty( nY )\n FWrite( hFile, Chr( 27 ) + \"*p\" + hb_ntos( Int( nDpi * nY ) ) + \"Y\" ) \n ENDIF\n\n FWrite( hFile, Chr( 27 ) + \"*r1U\" ) \n FWrite( hFile, Chr( 27 ) + \"*r0F\" ) \n\n \n IF Empty( nX )\n FWrite( hFile, Chr( 27 ) + \"*r0A\" ) \n ELSE\n FWrite( hFile, Chr( 27 ) + \"*r1A\" ) \n ENDIF\n\n FWrite( hFile, Chr( 27 ) + \"*r\" + hb_ntos( nHeight ) + \"T\" ) \n\n \n nPos := 1\n FOR nRow := 1 TO nHeight\n cRow := hb_BSubStr( cBitMap, nPos, nBytesPerRow )\n\n nPos += nBytesPerRow\n\n \n FWrite( hFile, Chr( 27 ) + \"*b\" + hb_ntos( nBytesPerRow ) + \"W\" )\n FWrite( hFile, cRow )\n NEXT\n\n \n FWrite( hFile, Chr( 27 ) + \"*rC\" )\n\n IF ! Empty( cLabel ) .AND. ! cLabel == \".\"\n cLabel := StrTran( cLabel, \"~\", \" \" )\n FWrite( hFile, Chr( 10 ) )\n IF ! Empty( nX )\n FWrite( hFile, Chr( 27 ) + \"*p\" + hb_ntos( Int( nDpi * nX ) ) + \"X\" ) \n ENDIF\n FWrite( hFile, cLabel )\n ENDIF\n\n FWrite( hFile, Chr( 27 ) + \"*p0X\" ) \n FWrite( hFile, Chr( 27 ) + \"*p0Y\" ) \n\n \n IF ! Empty( cContents )\n FWrite( hFile, cContents )\n ENDIF\n\n FClose( hFile )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/tipmail.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbtip\"\n\nPROCEDURE Main( cFileName )\n\n LOCAL oMail, cData, i\n\n IF ! HB_ISSTRING( cFileName ) .OR. ;\n ( cData := hb_MemoRead( cFileName ) ) == \"\"\n\n ? \"Cannot open\", cFileName\n RETURN\n ENDIF\n\n oMail := TIPMail():New()\n IF oMail:FromString( cData ) == 0\n ? \"Malformed mail. Dumping up to where parsed\"\n ENDIF\n\n ? PadC( \" HEADERS \", 60, \"-\" )\n FOR EACH i IN oMail:hHeaders\n ? i:__enumKey(), \":\", i\n NEXT\n ?\n\n ? PadC( \" RECEIVED \", 60, \"-\" )\n FOR EACH cData IN oMail:aReceived\n ? cData\n NEXT\n ?\n\n ? PadC( \" BODY \", 60, \"-\" )\n ? oMail:GetBody()\n ?\n\n DO WHILE oMail:GetAttachment() != NIL\n ? PadC( \" ATTACHMENT \", 60, \"-\" )\n ? oMail:NextAttachment():GetBody()\n ?\n ENDDO\n\n ? \"DONE\"\n ?\n \n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbsms' (SMS sending via modem): contrib/hbsms/tests/send.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbsms\"\n\nPROCEDURE Main( cPort )\n\n#if defined( __PLATFORM__WINDOWS )\n hb_default( @cPort, \"\\\\.\\COM22\" )\n#elif defined( __PLATFORM__LINUX )\n hb_default( @cPort, \"/dev/ttyS1\" )\n#elif defined( __PLATFORM__DARWIN )\n hb_default( @cPort, \"/dev/cu.myport-COM1-1\" )\n#endif\n\n ? \"start\"\n ? sms_Send( cPort, \"555555555\", \"test msg\", .T. )\n ? \"end\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/osshell.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL cShell\n\n#if defined( __PLATFORM__UNIX )\n cShell := GetEnv( \"SHELL\" )\n#else\n cShell := GetEnv( \"COMSPEC\" )\n#endif\n\n ? \"About to shell to OS..\"\n ! ( cShell )\n ? \"Hey, I am back !\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/say.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n CLS\n SET CENTURY ON\n @ 2, 39 TO 7, 39 DOUBLE\n @ 0, 0 SAY \"Testing @ SAY with and without PICTURE clauses\"\n @ 0, 60 SAY Date()\n SET CENTURY OFF\n @ 2, 1 SAY -1.25\n @ 2, 41 SAY -1.25 PICTURE \"@( 99,999.99\"\n @ 3, 1 SAY 1.25 PICTURE \"@( 9,999.99\"\n @ 3, 41 SAY 1.25 PICTURE \"@( $9,999.99\"\n @ 5, 1 SAY Date()\n @ 5, 41 SAY Date() PICTURE \"@E\"\n @ 7, 1 SAY \"Hello\"\n @ 7, 41 SAY \"Hello\" PICTURE \"@!\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/acctmnth.prg. Provides functions: ft_AcctMonth. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_AcctMonth( dGivenDate, nMonthNum )\n\n LOCAL nYTemp, nMTemp, aRetVal\n\n IF HB_ISNUMERIC( dGivenDate )\n nMonthNum := dGivenDate\n dGivenDate := Date()\n ELSEIF ! HB_ISDATE( dGivenDate )\n dGivenDate := Date()\n ENDIF\n\n aRetVal := ft_Month( dGivenDate )\n nYTemp := Val( SubStr( aRetVal[ 1 ], 1, 4 ) )\n nMTemp := Val( SubStr( aRetVal[ 1 ], 5, 2 ) )\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n\n IF dGivenDate < aRetVal[ 2 ]\n\n dGivenDate := ft_MAdd( dGivenDate, -1 )\n aRetVal := ft_Month( dGivenDate )\n nMTemp -= 1\n IF nMTemp == 0\n nYTemp -= 1\n nMTemp := 12\n ENDIF\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n\n ELSEIF dGivenDate > aRetVal[ 3 ]\n\n dGivenDate := ft_MAdd( dGivenDate, 1 )\n aRetVal := ft_Month( dGivenDate )\n nMTemp += 1\n IF nMTemp == 13\n nYTemp += 1\n nMTemp := 1\n ENDIF\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n\n ENDIF\n\n IF HB_ISNUMERIC( nMonthNum )\n IF nMonthNum < 1 .OR. nMonthNum > 12\n nMonthNum := 12\n ENDIF\n aRetVal := ft_Month( dGivenDate, nMonthNum )\n nYTemp := Val( SubStr( aRetVal[ 1 ], 1, 4 ) )\n nMTemp := Val( SubStr( aRetVal[ 1 ], 5, 2 ) )\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n ENDIF\n\n aRetVal[ 1 ] := Str( nYTemp, 4 ) + StrZero( nMTemp, 2 )\n\n RETURN aRetVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/atadjust.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\n#include \"ct.ch\"\n\nPROCEDURE Main()\n\n LOCAL aStr := { ;\n \"Introduction: 1\", ;\n \"Theory: 5\", ;\n \"Material and Methods: 13\", ;\n \"Results: 19\", ;\n \"Discussion: 21\" }\n LOCAL ni\n\n ctinit()\n\n ? \"Begin test of AtAdjust()\"\n ?\n\n ? \" Original strings:\"\n FOR ni := 1 TO Len( aStr )\n ? Space( 4 ) + aStr[ ni ]\n NEXT\n ?\n\n ? ' AtAdjust( \":\", aStr[ ni ], 21, 1,, \".\" ) yields'\n FOR ni := 1 TO Len( aStr )\n ? Space( 4 ) + AtAdjust( \":\", aStr[ ni ], 21, 1,, \".\" )\n NEXT\n ?\n\n ? ' AtAdjust( \":\", aStr[ ni ], 10, 1,, \".\" ) yields'\n FOR ni := 1 TO Len( aStr )\n ? Space( 4 ) + AtAdjust( \":\", aStr[ ni ], 10, 1,, \".\" )\n NEXT\n ?\n\n ? ' SetAtLike( CT_SETATLIKE_WILDCARD, \":\" )'\n ? ' AtAdjust( \":\", aStr[ ni ], 10, 1,, \".\" ) yields now'\n SetAtLike( CT_SETATLIKE_WILDCARD, \":\" )\n FOR ni := 1 TO Len( aStr )\n ? Space( 4 ) + AtAdjust( \":\", aStr[ ni ], 10, 1,, \".\" )\n NEXT\n ?\n\n ? \"End test of AtAdjust()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/prn2.prg. Contains procedures: Main, PrnTest. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\nPROCEDURE Main()\n\n LOCAL nPrn := 1\n LOCAL cFileName := Space( 40 )\n LOCAL GetList := {}\n\n LOCAL aPrn := win_printerList()\n\n CLS\n\n IF Empty( aPrn )\n Alert( \"No printers installed - Cannot continue\" )\n ELSE\n DO WHILE nPrn != 0\n CLS\n @ 0, 0 SAY \"win_PrintFileRaw() test program. Choose a printer to test\"\n @ 1, 0 SAY \"File name:\" GET cFileName PICT \"@!K\"\n READ\n @ 2, 0 TO MaxRow(), MaxCol()\n nPrn := AChoice( 3, 1, MaxRow() - 1, MaxCol() - 1, aPrn, .T.,, nPrn )\n IF nPrn != 0\n PrnTest( aPrn[ nPrn ], cFileName )\n ENDIF\n ENDDO\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE PrnTest( cPrinter, cFileName )\n\n LOCAL lDelete\n\n IF Empty( cFileName )\n hb_MemoWrit( cFileName := hb_FNameExtSet( __FILE__, \".prn\" ), \"Hello World!\" + Chr( 12 ) )\n lDelete := .T.\n ELSE\n lDelete := .F.\n ENDIF\n\n Alert( \"win_PrintFileRaw() returned: \" + hb_ntos( win_PrintFileRaw( cPrinter, cFileName, \"testing raw printing\" ) ) )\n\n IF lDelete\n FErase( cFileName )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbunix' (Unix-specific functions): contrib/hbunix/tests/daemon.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbunix\"\n\nREQUEST HB_GT_CGI_DEFAULT\n\nPROCEDURE Main()\n\n LOCAL cLogFile, cLogText\n\n cLogFile := hb_ps() + CurDir() + hb_ps() + hb_FNameExtSet( __FILE__, \".txt\" )\n\n ? hb_StrFormat( \"Parent(%d) launching child... \", posix_getpid() )\n\n IF unix_daemon( 0, 0 ) == -1\n ? hb_StrFormat( \"failed with errno=%d\", posix_errno() )\n ErrorLevel( 1 )\n ELSE\n IF hb_FileExists( cLogFile )\n FErase( cLogFile )\n ENDIF\n\n ? \"***\" + hb_eol() + \"* If you see this, something is b0rked\" + hb_eol() + \"***\"\n\n cLogText := hb_StrFormat( \"Hello, this is the daemon child(%d) writing.\", posix_getpid() ) + hb_eol()\n cLogText += hb_StrFormat( \"I am currenty residing in %s and \", hb_ps() + CurDir() ) + hb_eol()\n cLogText += hb_StrFormat( \"am writing this message to %s\", cLogFile ) + hb_eol()\n cLogText += \"Good bye now.\" + hb_eol()\n\n hb_MemoWrit( cLogFile, cLogText )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/nooccur.prg. Provides functions: ft_NoOccur. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_NoOccur( cCheckFor, cCheckIn, lIgnoreCase )\n\n \n IF ! HB_ISLOGICAL( lIgnoreCase ) .OR. lIgnoreCase\n cCheckFor := Upper( cCheckFor )\n cCheckIn := Upper( cCheckIn )\n ENDIF\n\n RETURN iif( Len( cCheckFor ) == 0 .OR. Len( cCheckIn ) == 0, ;\n 0, ;\n Int( ( Len( cCheckIn ) - Len( StrTran( cCheckIn, cCheckFor ) ) ) / ;\n Len( cCheckFor ) ) )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/pchr.prg. Provides functions: ft_PChr. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#define LEFTEQUAL( l, r ) ( Left( l, Len( r ) ) == r )\n\nFUNCTION ft_PChr( c_nums )\n\n LOCAL c_ret := \"\", c_st := 0, c_part, c_st2, c_hex := \"0123456789ABCDEF\"\n LOCAL c_upper, c_t1, c_t2\n\n IF Left( c_nums, 1 ) == \",\" .OR. RTrim( c_nums ) == \"\"\n RETURN \"\"\n ENDIF\n\n c_nums := RTrim( c_nums ) + \",~,\"\n c_part := SubStr( c_nums, c_st + 1, At( \",\", SubStr( c_nums, c_st + 2 ) ) )\n\n DO WHILE ! ( c_part == \"~\" .OR. c_part == \"\" )\n\n IF Left( c_part, 1 ) == '\"'\n\n c_st2 := At( '\"', SubStr( c_part, 2 ) ) + 1\n c_ret := c_ret + SubStr( c_part, 2, c_st2 - 2 )\n\n ELSEIF Left( c_part, 1 ) == \"&\"\n\n c_upper := Upper( c_part )\n c_t1 := At( SubStr( c_upper, 2, 1 ), c_hex ) - 1\n IF c_t1 > -1\n c_t2 := At( SubStr( c_upper, 3, 1 ), c_hex ) - 1\n IF c_t2 > -1\n c_t1 := c_t1\n ELSEIF ( Val( c_part ) > 0 .AND. Val( c_part ) < 256 ) .OR. c_part == \"0\"\n\n c_ret := c_ret + Chr( Val( c_part ) )\n\n ELSE\n\n IF Left( c_part, 1 ) == \"/\"\n\n c_upper := Upper( c_part )\n\n DO CASE\n CASE LEFTEQUAL( c_upper, \"/GRAPHIC\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 116 ) + hb_BChar( 1 )\n CASE LEFTEQUAL( c_upper, \"/ITALIC\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 116 ) + hb_BChar( 0 )\n CASE LEFTEQUAL( c_upper, \"/PICTURE\" )\n c_ret += ;\n hb_BChar( 27 ) + hb_BChar( 116 ) + hb_BChar( 1 ) + ;\n hb_BChar( 27 ) + hb_BChar( 120 ) + hb_BChar( 1 ) + ;\n hb_BChar( 27 ) + hb_BChar( 107 ) + hb_BChar( 1 ) + ;\n hb_BChar( 27 ) + hb_BChar( 77 ) + hb_BChar( 27 ) + \"U\"\n CASE LEFTEQUAL( c_upper, \"/COND\" ) .OR. LEFTEQUAL( c_upper, \"/SI\" )\n c_ret += hb_BChar( 15 )\n CASE LEFTEQUAL( c_upper, \"/ROMAN\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 107 ) + hb_BChar( 0 )\n CASE LEFTEQUAL( c_upper, \"/SANS\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 107 ) + hb_BChar( 1 )\n CASE LEFTEQUAL( c_upper, \"/NLQ\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 120 ) + hb_BChar( 1 )\n CASE LEFTEQUAL( c_upper, \"/DRAFT\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 120 ) + hb_BChar( 0 )\n CASE LEFTEQUAL( c_upper, \"/ELITE\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 77 )\n CASE LEFTEQUAL( c_upper, \"/PICA\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 80 )\n CASE LEFTEQUAL( c_upper, \"/EMPHOFF\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 70 )\n CASE LEFTEQUAL( c_upper, \"/EMPH\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 69 )\n CASE LEFTEQUAL( c_upper, \"/1/6\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 50 )\n CASE LEFTEQUAL( c_upper, \"/1/8\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 48 )\n CASE LEFTEQUAL( c_upper, \"/SKIPOFF\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 79 )\n CASE LEFTEQUAL( c_upper, \"/SKIP\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 78 )\n CASE LEFTEQUAL( c_upper, \"/FF\" ) .OR. LEFTEQUAL( c_upper, \"/EJECT\" )\n c_ret += hb_BChar( 12 )\n CASE LEFTEQUAL( c_upper, \"/INIT\" ) .OR. LEFTEQUAL( c_upper, \"/RESET\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 64 )\n CASE LEFTEQUAL( c_upper, \"/SPANISH\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 82 ) + hb_BChar( 12 )\n CASE LEFTEQUAL( c_upper, \"/USA\" )\n c_ret += hb_BChar( 27 ) + hb_BChar( 82 ) + hb_BChar( 0 )\n CASE LEFTEQUAL( c_upper, \"/ONE\" )\n c_ret += hb_BChar( 27 ) + \"U\" + hb_BChar( 1 )\n CASE LEFTEQUAL( c_upper, \"/TWO\" )\n c_ret += hb_BChar( 27 ) + \"U\" + hb_BChar( 0 )\n CASE LEFTEQUAL( c_upper, \"/FAST\" )\n c_ret += hb_BChar( 27 ) + \"s\" + hb_BChar( 0 )\n CASE LEFTEQUAL( c_upper, \"/SLOW\" )\n c_ret += hb_BChar( 27 ) + \"s\" + hb_BChar( 1 )\n CASE LEFTEQUAL( c_upper, \"/OFF\" )\n c_ret += hb_BChar( 19 )\n CASE LEFTEQUAL( c_upper, \"/ON\" )\n c_ret += hb_BChar( 17 )\n CASE LEFTEQUAL( c_upper, \"/BEEP\" ) .OR. LEFTEQUAL( c_upper, \"/BELL\" )\n c_ret += hb_BChar( 7 )\n CASE LEFTEQUAL( c_upper, \"/CAN\" )\n c_ret += hb_BChar( 24 )\n ENDCASE\n\n ENDIF\n\n ENDIF\n\n c_st := At( \",\", SubStr( c_nums, c_st + 1 ) ) + c_st\n c_part := SubStr( c_nums, c_st + 1, At( \",\", SubStr( c_nums, c_st + 2 ) ) )\n\n ENDDO\n\n RETURN c_ret"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/tests/fontdpi.prg. Contains procedures: Main. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbgd\"\n\n#define IMAGES_IN \"imgs_in\" + hb_ps()\n#define IMAGES_OUT \"imgs_out\" + hb_ps()\n\nPROCEDURE Main()\n\n LOCAL oI := GDImage():Create( 600, 300 )\n\n LOCAL black := oI:SetColor( 50, 0, 0 )\n\n oI:SetColor( black )\n oI:SetFontName( \"Arial\" ) \n oI:SetFontPitch( 10 )\n\n \n oI:SayFreeType( 10, 100, \"GD_RESOLUTION: 96 dpi\" )\n\n \n oI:SayFreeType( 10, 150, \"GD_RESOLUTION: 150 dpi\",,,,,,,, 150 )\n\n \n oI:SayFreeType( 10, 200, \"GD_RESOLUTION: 300 dpi\",,,,,,,, 300 )\n\n oI:SavePng( IMAGES_OUT + \"testdpi.png\" )\n oI:SaveJpeg( IMAGES_OUT + \"testdpi.jpg\" )\n oI:SaveGif( IMAGES_OUT + \"testdpi.gif\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbmemio' (Memory file I/O operations): contrib/hbmemio/tests/test.prg. Contains procedures: Main. This file handles data format parsing and generation"}, {"role": "assistant", "content": "#require \"hbmemio\"\n\nREQUEST HB_MEMIO\n\nPROCEDURE Main()\n\n LOCAL tmp\n\n dbCreate( \"mem:test\", { { \"F1\", \"N\", 9, 0 } }, , .T., \"memarea\" )\n FOR tmp := 1 TO 1000\n dbAppend()\n FIELD->F1 := hb_Random()\n dbDrop( \"mem:test\" ) \n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour test program: tests/sha2.prg. Provides functions: StrToHex. Contains procedures: Main, Test_SHA2, Test_SHA2_HMAC. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n ? \"SHA-2 FIPS 180-2 Validation tests\"\n Test_SHA2()\n\n ? \"HMAC-SHA-2 IETF Validation tests\"\n Test_SHA2_HMAC()\n\n RETURN\n\nSTATIC PROCEDURE Test_SHA2()\n\n LOCAL cMsg1 := \"abc\"\n LOCAL cMsg2a := \"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\n LOCAL cMsg2b := \"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu\"\n LOCAL cMsg3 := Replicate( \"a\", 1000000 )\n\n LOCAL results := {;\n {; \n \"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7\" ,;\n \"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525\" ,;\n \"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67\" },;\n {; \n \"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad\" ,;\n \"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1\" ,;\n \"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0\" },;\n {; \n \"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7\" ,;\n \"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039\" ,;\n \"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985\" },;\n {; \n \"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f\" ,;\n \"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909\" ,;\n \"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b\" } }\n\n ? StrToHex( hb_SHA224( cMsg1 ) ) == results[ 1 ][ 1 ]\n ? StrToHex( hb_SHA224( cMsg2a ) ) == results[ 1 ][ 2 ]\n ? StrToHex( hb_SHA224( cMsg3 ) ) == results[ 1 ][ 3 ]\n\n ? StrToHex( hb_SHA256( cMsg1 ) ) == results[ 2 ][ 1 ]\n ? StrToHex( hb_SHA256( cMsg2a ) ) == results[ 2 ][ 2 ]\n ? StrToHex( hb_SHA256( cMsg3 ) ) == results[ 2 ][ 3 ]\n\n ? StrToHex( hb_SHA384( cMsg1 ) ) == results[ 3 ][ 1 ]\n ? StrToHex( hb_SHA384( cMsg2b ) ) == results[ 3 ][ 2 ]\n ? StrToHex( hb_SHA384( cMsg3 ) ) == results[ 3 ][ 3 ]\n\n ? StrToHex( hb_SHA512( cMsg1 ) ) == results[ 4 ][ 1 ]\n ? StrToHex( hb_SHA512( cMsg2b ) ) == results[ 4 ][ 2 ]\n ? StrToHex( hb_SHA512( cMsg3 ) ) == results[ 4 ][ 3 ]\n\n RETURN\n\nSTATIC PROCEDURE Test_SHA2_HMAC()\n LOCAL aMsg := {;\n \"Hi There\",;\n \"what do ya want for nothing?\",;\n Replicate( hb_BChar( 0xdd ), 50 ),;\n Replicate( hb_BChar( 0xcd ), 50 ),;\n \"Test With Truncation\",;\n \"Test Using Larger Than Block-Size Key - Hash Key First\",;\n \"This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.\" }\n\n LOCAL results := {;\n \"896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22\",; \n \"a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44\",;\n \"7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea\",;\n \"6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a\",;\n \"0e2aea68a90c8d37c988bcdb9fca6fa8\",;\n \"95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e\",;\n \"3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1\",;\n \"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7\",; \n \"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843\",;\n \"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe\",;\n \"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b\",;\n \"a3b6167473100ee06e0c796c2955552b\",;\n \"60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54\",;\n \"9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2\",;\n \"afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6\",; \n \"af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649\",;\n \"88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27\",;\n \"3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb\",;\n \"3abf34c3503b2a23a46efc619baef897\",;\n \"4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952\",;\n \"6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e\",;\n \"87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854\",; \n \"164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737\",;\n \"fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb\",;\n \"b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd\",;\n \"415fad6271580a531d4179bc891d87a6\",;\n \"80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598\",;\n \"e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58\"}\n\n LOCAL keys := {;\n Replicate( hb_BChar( 0x0b ), 20 ),;\n \"Jefe\",;\n Replicate( hb_BChar( 0xaa ), 20 ),;\n \"\",;\n Replicate( hb_BChar( 0x0c ), 20 ),;\n Replicate( hb_BChar( 0xaa ), 131 ),;\n Replicate( hb_BChar( 0xaa ), 131 ) }\n\n LOCAL tmp\n\n FOR tmp := 1 TO 25\n keys[ 4 ] += hb_BChar( tmp )\n NEXT\n\n FOR tmp := 1 TO 7\n IF tmp != 5\n ? StrToHex( hb_HMAC_SHA224( aMsg[ tmp ], keys[ tmp ] ) ) == results[ tmp ]\n ? StrToHex( hb_HMAC_SHA256( aMsg[ tmp ], keys[ tmp ] ) ) == results[ tmp + 7 ]\n ? StrToHex( hb_HMAC_SHA384( aMsg[ tmp ], keys[ tmp ] ) ) == results[ tmp + 14 ]\n ? StrToHex( hb_HMAC_SHA512( aMsg[ tmp ], keys[ tmp ] ) ) == results[ tmp + 21 ]\n\n\n ENDIF\n NEXT\n\n RETURN\n\nSTATIC FUNCTION StrToHex( cString )\n RETURN Lower( cString )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour Runtime Library file: src/debug/dbgbrwsr.prg. Defines classes: HBDbBrowser, HBDbColumn. Provides functions: HBDbColumnNew. This file provides utility functions"}, {"role": "assistant", "content": "#pragma -b-\n\n#define HB_CLS_NOTOBJECT \n#include \"hbclass.ch\"\n\n\nCREATE CLASS HBDbBrowser\n\n VAR Window\n VAR cargo\n\n VAR nTop\n VAR nLeft\n VAR nBottom\n VAR nRight\n VAR cColorSpec\n VAR autoLite INIT .T.\n\n VAR goTopBlock\n VAR goBottomBlock\n VAR skipBlock\n\n VAR stable INIT .F.\n VAR rowCount INIT 0\n VAR rowPos INIT 1\n VAR colCount INIT 0\n VAR colPos INIT 1\n VAR hitBottom INIT .F.\n VAR freeze INIT 0\n\n VAR aColumns INIT {}\n VAR aRowState INIT {}\n VAR aColorSpec INIT {}\n VAR nFirstVisible INIT 1\n VAR lConfigured INIT .F.\n\n METHOD New( nTop, nLeft, nBottom, nRight, oParentWindow )\n METHOD AddColumn( oCol ) INLINE AAdd( ::aColumns, oCol ), ::colCount++, Self\n METHOD Resize( nTop, nLeft, nBottom, nRight )\n ACCESS ColorSpec INLINE ::cColorSpec\n ASSIGN ColorSpec( cColors ) METHOD SetColorSpec( cColors )\n METHOD Configure()\n METHOD DeHiLite() INLINE ::DispRow( ::rowPos, .F. )\n METHOD HiLite() INLINE ::DispRow( ::rowPos, .T. )\n METHOD DispRow( nRow, lHiLite )\n METHOD MoveCursor( nSkip )\n METHOD GoTo( nRow )\n METHOD GoTop() INLINE ::GoTo( 1 ), ::rowPos := 1, ::nFirstVisible := 1, ::RefreshAll()\n METHOD GoBottom()\n METHOD Down() INLINE ::MoveCursor( 1 )\n METHOD Up() INLINE ::MoveCursor( -1 )\n METHOD PageDown() INLINE ::MoveCursor( ::rowCount )\n METHOD PageUp() INLINE ::MoveCursor( -::rowCount )\n METHOD GetColumn( nColumn ) INLINE ::aColumns[ nColumn ]\n METHOD RefreshAll() INLINE AFill( ::aRowState, .F. ), Self\n METHOD RefreshCurrent() INLINE iif( ::rowCount >= 1 .AND. ::rowPos <= Len( ::aRowState ), ::aRowState[ ::rowPos ] := .F., ), Self\n METHOD Invalidate() INLINE ::RefreshAll()\n METHOD Stabilize() INLINE ::ForceStable()\n METHOD ForceStable()\n\nENDCLASS\n\nMETHOD New( nTop, nLeft, nBottom, nRight, oParentWindow ) CLASS HBDbBrowser\n\n ::Window := oParentWindow\n ::nTop := nTop\n ::nLeft := nLeft\n ::nBottom := nBottom\n ::nRight := nRight\n\n RETURN Self\n\nMETHOD Configure() CLASS HBDbBrowser\n\n ::rowCount := ::nBottom - ::nTop + 1\n IF ::rowPos > ::rowCount\n ::nFirstVisible += ::rowPos - ::rowCount\n ::rowPos := ::rowCount\n ENDIF\n AFill( ASize( ::aRowState, ::rowCount ), .F. )\n ::lConfigured := .T.\n\n RETURN Self\n\nMETHOD SetColorSpec( cColors ) CLASS HBDbBrowser\n\n IF HB_ISSTRING( cColors )\n ::cColorSpec := cColors\n ::aColorSpec := hb_ATokens( ::cColorSpec, \",\" )\n ENDIF\n\n RETURN ::cColorSpec\n\nMETHOD MoveCursor( nSkip ) CLASS HBDbBrowser\n\n LOCAL nSkipped\n\n nSkipped := ::GoTo( ::rowPos + ::nFirstVisible - 1 + nSkip )\n IF ! ::hitBottom .OR. nSkipped != 0\n IF iif( nSkipped > 0, ::rowPos + nSkipped <= ::rowCount, ::rowPos + nSkipped >= 1 )\n ::RefreshCurrent()\n ::rowPos += nSkipped\n ::RefreshCurrent()\n ELSE\n ::nFirstVisible := Max( 1, nSkipped + ::nFirstVisible )\n ::RefreshAll()\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD DispRow( nRow, lHiLite ) CLASS HBDbBrowser\n\n LOCAL nColX, nWid, aClr, nClr\n LOCAL xData\n LOCAL oCol\n\n ::GoTo( ::nFirstVisible + nRow - 1 )\n IF ::hitBottom\n hb_Scroll( ::nTop + nRow - 1, ::nLeft, ::nTop + nRow - 1, ::nRight,,, ::aColorSpec[ 1 ] )\n ELSE\n DispBegin()\n nColX := ::nLeft\n FOR EACH oCol IN ::aColumns\n IF nColX <= ::nRight\n xData := Eval( oCol:block )\n nClr := iif( lHiLite, 2, 1 )\n aClr := Eval( oCol:colorBlock, xData )\n IF HB_ISARRAY( aClr )\n nClr := aClr[ nClr ]\n ELSE\n nClr := oCol:defColor[ nClr ]\n ENDIF\n nWid := oCol:width\n IF nWid == NIL\n nWid := Len( xData )\n ENDIF\n hb_DispOutAt( ::nTop + nRow - 1, nColX, ;\n Left( PadR( xData, nWid ) + iif( oCol:__enumIsLast(), \"\", \" \" ), ;\n ::nRight - nColX + 1 ), ::aColorSpec[ nClr ] )\n nColX += nWid + 1\n ENDIF\n NEXT\n DispEnd()\n ENDIF\n\n RETURN Self\n\nMETHOD ForceStable() CLASS HBDbBrowser\n\n LOCAL nRow\n\n IF ! ::lConfigured\n ::Configure()\n ENDIF\n DispBegin()\n FOR nRow := 1 TO ::rowCount\n IF ! ::aRowState[ nRow ]\n ::DispRow( nRow, nRow == ::rowPos )\n ::aRowState[ nRow ] := .T.\n ENDIF\n NEXT\n ::GoTo( ::nFirstVisible + ::rowPos - 1 )\n SetPos( ::nTop + ::rowPos - 1, ::nLeft )\n DispEnd()\n\n RETURN Self\n\nMETHOD GoTo( nRow ) CLASS HBDbBrowser\n\n LOCAL nOldRow := ::nFirstVisible + ::rowPos - 1\n LOCAL nSkipped := 0\n\n Eval( ::goTopBlock )\n IF nRow == 1\n ::hitBottom := .F.\n ELSE\n nSkipped := Eval( ::skipBlock, nRow - 1 )\n ::hitBottom := ( nSkipped != nRow - 1 )\n ENDIF\n\n RETURN nSkipped - nOldRow + 1\n\nMETHOD GoBottom() CLASS HBDbBrowser\n\n LOCAL nScroll\n\n DO WHILE ! ::hitBottom\n ::PageDown()\n ENDDO\n IF ::rowPos < ::rowCount .AND. ::nFirstVisible > 1\n nScroll := Min( ::nFirstVisible - 1, ::rowCount - ::rowPos )\n ::nFirstVisible -= nScroll\n ::rowPos += nScroll\n ENDIF\n\n RETURN Self\n\nMETHOD Resize( nTop, nLeft, nBottom, nRight ) CLASS HBDbBrowser\n\n LOCAL lResize := .F.\n\n IF HB_ISNUMERIC( nTop ) .AND. nTop != ::nTop\n ::nTop := nTop\n lResize := .T.\n ENDIF\n IF HB_ISNUMERIC( nLeft ) .AND. nLeft != ::nLeft\n ::nLeft := nLeft\n lResize := .T.\n ENDIF\n IF HB_ISNUMERIC( nBottom ) .AND. nBottom != ::nBottom\n ::nBottom := nBottom\n lResize := .T.\n ENDIF\n IF HB_ISNUMERIC( nRight ) .AND. nRight != ::nRight\n ::nRight := nRight\n lResize := .T.\n ENDIF\n\n IF lResize\n ::Configure():ForceStable()\n ENDIF\n\n RETURN Self\n\nCREATE CLASS HBDbColumn\n\n EXPORTED:\n\n VAR block AS CODEBLOCK \n VAR colorBlock AS CODEBLOCK INIT {|| NIL } \n VAR defColor AS ARRAY INIT { 1, 2 } \n VAR width AS USUAL \n\n METHOD New( cHeading, bBlock )\n\nENDCLASS\n\nMETHOD New( cHeading, bBlock ) CLASS HBDbColumn\n\n HB_SYMBOL_UNUSED( cHeading )\n ::block := bBlock\n\n RETURN Self\n\nFUNCTION HBDbColumnNew( cHeading, bBlock )\n RETURN HBDbColumn():New( cHeading, bBlock )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbfbird' (Firebird database client): contrib/hbfbird/tests/stress.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbfbird\"\n\nPROCEDURE Main()\n\n LOCAL oServer, oQuery, oRow, i, x\n\n LOCAL cServer := \"localhost:\"\n LOCAL cDatabase\n LOCAL cUser := \"SYSDBA\"\n LOCAL cPass := \"masterkey\"\n LOCAL nPageSize := 1024\n LOCAL cCharSet := \"UTF8\"\n LOCAL nDialect := 1\n LOCAL cQuery, cName\n\n CLS\n\n hb_FNameSplit( hb_argv( 0 ), NIL, @cName, NIL )\n cDatabase := hb_DirTemp() + cName + \".fdb\"\n\n IF ! hb_FileExists( cDatabase )\n ? FBCreateDB( cServer + cDatabase, cUser, cPass, nPageSize, cCharSet, nDialect )\n ENDIF\n\n ? \"Connecting...\"\n\n oServer := TFBServer():New( cServer + cDatabase, cUser, cPass, nDialect )\n\n IF oServer:NetErr()\n ? oServer:Error()\n QUIT\n ENDIF\n\n IF oServer:TableExists( \"test\" )\n ? oServer:Execute( \"DROP TABLE Test\" )\n ? oServer:Execute( \"DROP DOMAIN boolean_field\" )\n ENDIF\n\n ? \"Creating domain for boolean fields...\"\n\n ? oServer:Execute( \"create domain boolean_field as smallint default 0 not null check (value in (0,1))\" )\n\n ? \"Creating test table...\"\n cQuery := \"CREATE TABLE test(\"\n cQuery += \" Code SmallInt not null primary key, \"\n cQuery += \" dept Integer, \"\n cQuery += \" Name Varchar(40), \"\n cQuery += \" Sales boolean_field, \"\n cQuery += \" Tax Float, \"\n cQuery += \" Salary Double Precision, \"\n cQuery += \" Budget Numeric(12,2), \"\n cQuery += \" Discount Decimal(5,2), \"\n cQuery += \" Creation Date, \"\n cQuery += \" Description blob sub_type 1 segment size 40 ) \"\n\n ? \"CREATE TABLE:\", oServer:Execute( cQuery )\n\n oQuery := oServer:Query( \"SELECT code, dept, name, sales, salary, creation FROM test\" )\n\n oServer:StartTransaction()\n\n FOR i := 1 TO 10000\n @ 15, 0 SAY \"Inserting values....\" + hb_ntos( i )\n\n oRow := oQuery:Blank()\n\n oRow:FieldPut( 1, i )\n oRow:FieldPut( 2, i + 1 )\n oRow:FieldPut( 3, \"DEPARTMENT NAME \" + StrZero( i ) )\n oRow:FieldPut( 4, ( i % 10 ) == 0 )\n oRow:FieldPut( 5, 3000 + i )\n oRow:FieldPut( 6, Date() )\n\n oServer:Append( oRow )\n\n IF i % 100 == 0\n oServer:Commit()\n oServer:StartTransaction()\n ENDIF\n NEXT\n\n FOR i := 5000 TO 7000\n @ 16, 0 SAY \"Deleting values....\" + Str( i )\n\n oRow := oQuery:Blank()\n oServer:Delete( oRow, \"code = \" + Str( i ) )\n\n IF i % 100 == 0\n oServer:Commit()\n oServer:StartTransaction()\n ENDIF\n NEXT\n\n FOR i := 2000 TO 3000\n @ 17, 0 SAY \"Updating values....\" + Str( i )\n\n oRow := oQuery:Blank()\n oRow:FieldPut( 5, 4000 + i )\n oServer:update( oRow, \"code = \" + Str( i ) )\n\n IF i % 100 == 0\n oServer:Commit()\n oServer:StartTransaction()\n ENDIF\n NEXT\n\n oQuery := oServer:Query( \"SELECT sum(salary) sum_salary FROM test WHERE code between 1 and 4000\" )\n\n IF ! oQuery:NetErr()\n oQuery:Fetch()\n @ 18, 0 SAY \"Sum values....\" + Str( oQuery:FieldGet( 1 ) )\n oQuery:Destroy()\n ENDIF\n\n x := 0\n FOR i := 1 TO 4000\n oQuery := oServer:Query( \"SELECT * FROM test WHERE code = \" + Str( i ) )\n\n IF ! oQuery:NetErr()\n oQuery:Fetch()\n oRow := oQuery:getrow()\n\n oQuery:destroy()\n x += oRow:FieldGet( oRow:FieldPos( \"salary\" ) )\n\n @ 19, 0 SAY \"Sum values....\" + Str( x )\n ENDIF\n NEXT\n\n oServer:Destroy()\n\n ? \"Closing...\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbfoxpro' (FoxPro file format support): contrib/hbfoxpro/occurs.prg. Provides functions: Occurs, fox_At. This file handles data format parsing and generation"}, {"role": "assistant", "content": "FUNCTION Occurs( cSub, cStr )\n\n LOCAL nCount := 0, nPos\n\n IF HB_ISSTRING( cSub ) .AND. HB_ISSTRING( cStr )\n nPos := 0\n DO WHILE ( nPos := hb_At( cSub, cStr, nPos + 1 ) ) > 0\n ++nCount\n ENDDO\n ENDIF\n\n RETURN nCount\n\nFUNCTION fox_At( cSub, cStr, nOccurrence )\n\n LOCAL nPos := 0\n\n IF HB_ISSTRING( cSub ) .AND. HB_ISSTRING( cStr )\n hb_default( @nOccurrence, 1 )\n DO WHILE --nOccurrence >= 0 .AND. ( nPos := hb_At( cSub, cStr, nPos + 1 ) ) != 0\n ENDDO\n ENDIF\n\n RETURN nPos"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbsqlit3' (SQLite3 database client library): contrib/hbsqlit3/tests/demo.prg. Contains procedures: Main, t1, t2. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbsqlit3\"\n\n#include \"fileio.ch\"\n\n#define TRACE\n#define TABLE_SQL \"CREATE TABLE t1( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER )\"\n\nPROCEDURE Main()\n\n ? sqlite3_libversion()\n sqlite3_sleep( 3000 )\n\n IF sqlite3_libversion_number() < 3005001\n RETURN\n ENDIF\n\n t1()\n t2()\n\n RETURN\n\n\nPROCEDURE t1()\n\n LOCAL lCreateIfNotExist := .F.\n LOCAL db := sqlite3_open( \"new.s3db\", lCreateIfNotExist )\n\n IF ! Empty( db )\n sqlite3_exec( db, \"DROP TABLE t1\" )\n ENDIF\n\n RETURN\n\n\nPROCEDURE t2()\n\n LOCAL lCreateIfNotExist := .T.\n LOCAL db := sqlite3_open( \"new.s3db\", lCreateIfNotExist )\n LOCAL stmt\n LOCAL nCCount, nCType, nI, nJ\n LOCAL aCType := { \"SQLITE_INTEGER\", \"SQLITE_FLOAT\", \"SQLITE_TEXT\", \"SQLITE_BLOB\", \"SQLITE_NULL\" }\n LOCAL aTable\n#ifdef TRACE\n LOCAL hTraceFile, hProfileFile\n#endif\n\n IF ! Empty( db )\n\n#ifdef TRACE\n IF sqlite3_libversion_number() < 3014000\n sqlite3_profile( db, .T. )\n sqlite3_trace( db, .T. )\n ELSE\n hTraceFile := FOpen( \"hbsq3_tr.log\", FO_READWRITE + HB_FO_CREAT )\n FSeek( hTraceFile, 0, FS_END )\n hProfileFile := FOpen( \"hbsq3_pr.log\", FO_READWRITE + HB_FO_CREAT )\n FSeek( hProfileFile, 0, FS_END )\n sqlite3_trace_v2( db, SQLITE_TRACE_STMT + SQLITE_TRACE_PROFILE, {| nMask, pStmt, x |\n IF nMask == SQLITE_TRACE_STMT\n IF hb_LeftEq( x, \"--\" )\n FWrite( hTraceFile, x + hb_eol() )\n ELSE\n FWrite( hTraceFile, sqlite3_expanded_sql( pStmt ) + hb_eol() )\n ENDIF\n ELSEIF nMask == SQLITE_TRACE_PROFILE\n FWrite( hProfileFile, sqlite3_expanded_sql( pStmt ) + \" - \" + hb_NToS( x ) + hb_eol() )\n ENDIF\n RETURN 0\n } )\n ENDIF\n#endif\n sqlite3_exec( db, \"PRAGMA auto_vacuum=0\" )\n sqlite3_exec( db, \"PRAGMA page_size=4096\" )\n\n IF sqlite3_exec( db, TABLE_SQL ) == SQLITE_OK\n ? \"CREATE TABLE t1 - Ok\"\n ENDIF\n\n sqlite3_exec( db, ;\n \"BEGIN TRANSACTION;\" + ;\n \"INSERT INTO t1( name, age ) VALUES( 'Bob', 52 );\" + ;\n \"INSERT INTO t1( name, age ) VALUES( 'Fred', 40 );\" + ;\n \"INSERT INTO t1( name, age ) VALUES( 'Sasha', 25 );\" + ;\n \"INSERT INTO t1( name, age ) VALUES( 'Ivet', 28 );\" + ;\n \"COMMIT;\" )\n\n ? \"BEGIN TRANSACTION\"\n ? \"INSERT INTO t1( name, age ) VALUES( 'Bob', 52 )\"\n ? \"INSERT INTO t1( name, age ) VALUES( 'Fred', 40 )\"\n ? \"INSERT INTO t1( name, age ) VALUES( 'Sasha', 25 )\"\n ? \"INSERT INTO t1( name, age ) VALUES( 'Ivet', 28 )\"\n ? \"COMMIT\"\n\n ? \"The number of database rows that were changed: \" + hb_ntos( sqlite3_changes( db ) )\n ? \"Total changes: \" + hb_ntos( sqlite3_total_changes( db ) )\n\n sqlite3_sleep( 3000 )\n\n stmt := sqlite3_prepare( db, \"INSERT INTO t1( name, age ) VALUES( :name, :age )\" )\n IF ! Empty( stmt )\n IF sqlite3_bind_text( stmt, 1, \"Andy\" ) == SQLITE_OK .AND. ;\n sqlite3_bind_int( stmt, 2, 17 ) == SQLITE_OK\n IF sqlite3_step( stmt ) == SQLITE_DONE\n ? \"INSERT INTO t1( name, age ) VALUES( 'Andy', 17 ) - Done\"\n ENDIF\n ENDIF\n sqlite3_reset( stmt )\n\n IF sqlite3_bind_text( stmt, 1, \"Mary\" ) == SQLITE_OK .AND. ;\n sqlite3_bind_int( stmt, 2, 19 ) == SQLITE_OK\n IF sqlite3_step( stmt ) == SQLITE_DONE\n ? \"INSERT INTO t1( name, age ) VALUES( 'Mary', 19 ) - Done\"\n ENDIF\n ENDIF\n sqlite3_clear_bindings( stmt )\n sqlite3_finalize( stmt )\n ENDIF\n\n ? \"The number of database rows that were changed: \" + hb_ntos( sqlite3_changes( db ) )\n ? \"Total changes: \" + hb_ntos( sqlite3_total_changes( db ) )\n ? \"Last _ROWID_: \" + Str( sqlite3_last_insert_rowid( db ) )\n ? \"\"\n\n stmt := sqlite3_prepare( db, \"SELECT * FROM t1 WHERE name == :name \" )\n sqlite3_bind_text( stmt, 1, \"Andy\" )\n\n ?\n ? \"SELECT * FROM t1 WHERE name == 'Andy'\"\n nJ := 0\n\n DO WHILE sqlite3_step( stmt ) == SQLITE_ROW\n nCCount := sqlite3_column_count( stmt )\n ++nJ\n ? \"Record # \" + Str( nJ )\n\n IF nCCount > 0\n FOR nI := 0 TO nCCount - 1\n nCType := sqlite3_column_type( stmt, nI )\n ? \"Column name : \" + sqlite3_column_name( stmt, nI )\n ? \"Column type : \" + aCType[ nCType ]\n ? \"Column value: \"\n\n SWITCH nCType\n CASE SQLITE_BLOB\n ?? \"BLOB\" \n EXIT\n\n CASE SQLITE_INTEGER\n ?? Str( sqlite3_column_int( stmt, nI ) )\n EXIT\n\n CASE SQLITE_NULL\n ?? \"NULL\"\n EXIT\n\n CASE SQLITE_TEXT\n ?? sqlite3_column_text( stmt, nI )\n EXIT\n ENDSWITCH\n\n NEXT\n ENDIF\n ENDDO\n ? \"Total records - \" + Str( nJ )\n\n sqlite3_clear_bindings( stmt )\n sqlite3_finalize( stmt )\n\n sqlite3_sleep( 3000 )\n\n stmt := sqlite3_prepare( db, \"SELECT * FROM t1 WHERE age >= ?5\" )\n sqlite3_bind_int( stmt, 5, 40 )\n\n ?\n ? \"SELECT * FROM t1 WHERE age >= 40 \"\n nJ := 0\n DO WHILE sqlite3_step( stmt ) == SQLITE_ROW\n nCCount := sqlite3_column_count( stmt )\n ++nJ\n ? \"Record # \" + Str( nJ )\n\n IF nCCount > 0\n FOR nI := 1 TO nCCount\n nCType := sqlite3_column_type( stmt, nI )\n ? \"Column name : \" + sqlite3_column_name( stmt, nI )\n ? \"Column type : \" + aCType[ nCType ]\n ? \"Column value: \"\n\n SWITCH nCType\n CASE SQLITE_BLOB\n ?? \"BLOB\" \n EXIT\n\n CASE SQLITE_INTEGER\n ?? Str( sqlite3_column_int( stmt, nI ) )\n EXIT\n\n CASE SQLITE_NULL\n ?? \"NULL\"\n EXIT\n\n CASE SQLITE_TEXT\n ?? sqlite3_column_text( stmt, nI )\n EXIT\n ENDSWITCH\n\n NEXT\n ENDIF\n ENDDO\n ? \"Total records - \" + Str( nJ )\n sqlite3_clear_bindings( stmt )\n sqlite3_finalize( stmt )\n\n sqlite3_sleep( 3000 )\n\n ?\n ? \"SELECT id, name, age + 5 FROM t1\"\n stmt := sqlite3_prepare( db, \"SELECT id, name, age + 5 FROM t1\" )\n\n ? sqlite3_column_name( stmt, 1 )\n ? sqlite3_column_name( stmt, 2 )\n ? sqlite3_column_name( stmt, 3 )\n\n ? aCType[ sqlite3_column_type( stmt, 1 ) ]\n ? aCType[ sqlite3_column_type( stmt, 2 ) ]\n ? aCType[ sqlite3_column_type( stmt, 3 ) ]\n\n ? sqlite3_column_decltype( stmt, 1 )\n ? sqlite3_column_decltype( stmt, 2 )\n ? sqlite3_column_decltype( stmt, 3 )\n\n sqlite3_finalize( stmt )\n\n sqlite3_sleep( 3000 )\n\n ?\n ? \"sqlite3_get_table\"\n ?\n aTable := sqlite3_get_table( db, \"SELECT name, age FROM t1 WHERE age BETWEEN 10 AND 20\" )\n FOR nI := 1 TO Len( aTable )\n FOR nJ := 1 TO Len( aTable[ nI ] )\n ?? aTable[ nI ][ nJ ], \" \"\n NEXT\n ?\n NEXT\n\n sqlite3_sleep( 3000 )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/test.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#include \"inkey.ch\"\n\nPROCEDURE Main()\n\n LOCAL nver, nmar, ntype, nir, ppp\n\n nmar := ft_MVersion( @nver, @ntype, @nir )\n ppp := nmar + nver\n ? Str( nmar, 2, 0 ), \".\", Str( nver, 2, 0 )\n ? ppp / 100\n Inkey( 0 )\n ? \"is mouse on\", ft_MReset()\n Inkey( 0 )\n ? ft_MShowCrs()\n Inkey( 0 )\n ? ft_MXLimit( 0, 8\n ? \"mouse row is\", ft_MGetX()\n ? \"mouse col is\", ft_MGetY()\n IF LastKey() == K_ESC\n EXIT\n ENDIF\n ENDDO\n ft_MHideCrs()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/multifnc/t1.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "proc main2()\n? \"main2\", procfile(\"main2\"), procfile(@main2())\n? \"alert\", procfile(\"alert\"), procfile(@alert()), alert()\n? \"p0\", procfile(\"p0\"), procfile(@p0()), (@p0()):exec(), p0(), t(\"p0\",@p0(),p0(),\"t0.prg\")\n? \"p1\", procfile(\"p1\"), procfile(@p1()), (@p1()):exec(), p1(), t(\"p1\",@p1(),p1(),\"t0.prg\")\n? \"p2\", procfile(\"p2\"), procfile(@p2()), (@p2()):exec(), p2(), t(\"p2\",@p2(),p2(),\"t1.prg\")\n? \"p3\", procfile(\"p3\"), procfile(@p3()), (@p3()):exec(), p3(), t(\"p3\",@p3(),p3(),\"t0.prg\")\n? \"p4\", procfile(\"p4\"), procfile(@p4()), (@p4()):exec(), p4(), t(\"p4\",@p4(),p4(),\"t1.prg\")\n? \"p5\", procfile(\"p5\"), procfile(@p5()), (@p5()):exec(), p5(), t(\"p5\",@p5(),p5(),\"t2.prg\")\n? \"p6\", procfile(\"p6\"), procfile(@p6()), (@p6()):exec(), p6(), t(\"p6\",@p6(),p6(),\"t0.prg\")\n? \"p7\", procfile(\"p7\"), procfile(@p7()), (@p7()):exec(), p7(), t(\"p7\",@p7(),p7(),\"t1.prg\")\n? \"===\"\nmain3()\nreturn\n\nfunc p1(); return \"P1:t1.prg\"\nfunc p2(); return \"P2:t1.prg\"\nfunc p3(); return \"P3:t1.prg\"\nfunc p4(); return \"P4:t1.prg\"\n\nfunc alert()\nreturn \"[ALERT]\"\n\n#pragma begindump\n#include \"hbapi.h\"\n\nHB_FUNC( P7 )\n{\n hb_retc( \"P7:t1.prg\" );\n}\n#pragma enddump"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour source file: src/rdd/dblist.prg. Contains procedures: __dbList. This file implements core Record Driver Driver functionality"}, {"role": "assistant", "content": "PROCEDURE __dbList( lOff, abEval, lAll, bFor, bWhile, nNext, nRecord, lRest, lToPrint, cToFileName )\n\n LOCAL lOldPrinter\n LOCAL lOldExtra\n LOCAL cOldExtraFile\n\n LOCAL oError\n LOCAL lError := .F.\n\n LOCAL bOutBlock\n\n \n IF lOff\n bOutBlock := {|| QOut( iif( Deleted(), \"*\", \" \" ) ), ;\n AEval( abEval, {| bEval | QQOut( Eval( bEval ), \"\" ) } ) }\n ELSE\n bOutBlock := {|| QOut( Str( RecNo(), 7 ), iif( Deleted(), \"*\", \" \" ) ), ;\n AEval( abEval, {| bEval | QQOut( Eval( bEval ), \"\" ) } ) }\n ENDIF\n\n \n IF ! Empty( lToPrint ) \n lOldPrinter := Set( _SET_PRINTER, .T. )\n ENDIF\n IF ! Empty( cToFileName )\n lOldExtra := Set( _SET_EXTRA, .T. )\n cOldExtraFile := Set( _SET_EXTRAFILE, ;\n iif( Set( _SET_DEFEXTENSIONS ), ;\n hb_FNameExtSetDef( cToFileName, \".txt\" ), ;\n cToFileName ) )\n ENDIF\n\n \n BEGIN SEQUENCE\n\n IF Empty( lAll ) .AND. ; \n Empty( bFor ) .AND. ;\n Empty( bWhile ) .AND. ;\n Empty( nNext ) .AND. ; \n Empty( nRecord ) .AND. ; \n Empty( lRest ) \n\n Eval( bOutBlock )\n ELSE\n dbEval( bOutBlock, bFor, bWhile, nNext, nRecord, lRest )\n ENDIF\n\n RECOVER USING oError\n lError := .T.\n END SEQUENCE\n\n \n IF ! Empty( lToPrint )\n Set( _SET_PRINTER, lOldPrinter )\n ENDIF\n IF ! Empty( cToFileName )\n Set( _SET_EXTRAFILE, cOldExtraFile )\n Set( _SET_EXTRA, lOldExtra )\n ENDIF\n\n \n IF lError\n Break( oError )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/csetref.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CSetRef()\"\n ? \" Default switch should be .F., is..................................\", CSetRef()\n ? \" Setting switch to .T., return value should be .F., is.............\", CSetRef( .T. )\n ? \" Switch setting should now be .T., is..............................\", CSetRef()\n ? \" Setting switch to .F. again, return value should still be .T., is \", CSetRef( .F. )\n ? \"End test of CSetRef()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/dev.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n#ifdef __HARBOUR__\n SET PRINTER TO dev_hb\n#else\n SET PRINTER TO dev_cl\n#endif\n SET DEVICE TO PRINTER\n DevPos( -2, 76 )\n ? PRow(), PCol()\n DevOut( \"First text written!\" )\n ? PRow(), PCol()\n DevOut( \"Hello\" )\n ? PRow(), PCol()\n DevPos( 6, 74 )\n ? PRow(), PCol()\n DevOut( \"Off to the side!!\" )\n ? PRow(), PCol()\n DevPos( 8, -12 )\n ? PRow(), PCol()\n DevPos( 13, -12 )\n ? PRow(), PCol()\n DevOut( \"More test text!\" )\n ? PRow(), PCol()\n DevOut( \"Yet more text!\" )\n ? PRow(), PCol()\n DevPos( 19, 85 )\n ? PRow(), PCol()\n DevPos( 500, 20 )\n ? PRow(), PCol()\n DevOut( \"!\" )\n ? PRow(), PCol()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/datecnfg.prg. Provides functions: ft_DateCnfg. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_DateCnfg( cFYStart, nDow )\n\n THREAD STATIC t_aDatePar := { hb_SToD( \"19800101\" ), 1 }\n\n LOCAL dCheck\n\n IF HB_ISSTRING( cFYStart )\n dCheck := CToD( cFYStart )\n IF ! Empty( dCheck )\n\n \n IF Month( dCheck ) == 2 .AND. Day( dcheck ) == 29\n dCheck--\n ENDIF\n\n t_aDatePar[ 1 ] := dCheck\n ENDIF\n ENDIF\n\n IF HB_ISNUMERIC( nDow ) .AND. nDow > 0 .AND. nDow < 8\n t_aDatePar[ 2 ] := nDow\n ENDIF\n\n RETURN { hb_DToC( t_aDatePar[ 1 ], \"yyyy.mm.dd\" ), t_aDatePar[ 2 ] }"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: GDBar. Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/gdbar.prg. Defines classes: GDBar. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#include \"gd.ch\"\n#include \"hbclass.ch\"\n\n#define IMG_FORMAT_PNG 1\n#define IMG_FORMAT_JPEG 2\n#define IMG_FORMAT_WBMP 4\n#define IMG_FORMAT_GIF 8\n#define IMG_QUALITY 95\n\n#define THICKNESS_I250 0\n#define THICKNESS_I251 0\n\nCREATE CLASS GDBar INHERIT GDImage\n\n \n VAR positionX AS NUMERIC INIT 4\n VAR positionY AS NUMERIC\n VAR maxHeight AS NUMERIC INIT 25\n VAR maxHDefa AS NUMERIC INIT 25\n VAR lastX AS NUMERIC\n VAR lastY AS NUMERIC\n VAR error AS NUMERIC\n VAR imWidth AS NUMERIC\n\n \n VAR Parity\n VAR LeftHand_Even AS ARRAY\n VAR Right_Hand AS ARRAY\n VAR LeftHand_Odd AS ARRAY\n VAR keys AS ARRAY\n\n VAR book AS LOGICAL INIT .F.\n VAR acode AS ARRAY\n VAR KeysModeA AS CHARACTER\n VAR KeysModeB AS CHARACTER\n VAR KeysModeC AS ARRAY\n\n \n VAR res AS NUMERIC\n VAR textfont AS NUMERIC\n VAR TEXT AS CHARACTER\n VAR filename AS CHARACTER\n VAR color_b AS ARRAY\n VAR color_f AS ARRAY\n VAR FillColor AS NUMERIC\n VAR BackColor AS NUMERIC\n VAR lDrawValue AS LOGICAL INIT .T.\n\n \n METHOD CreateBar( sx, sy, filename, cColor )\n METHOD Configure( nMaxHeight, aFillColor, aBackColor, nRes, nTextFont, lBook, lDrawValue )\n METHOD Allocate()\n METHOD DrawError( ptext )\n METHOD DrawSingleBar( pcode )\n METHOD DrawSingleI25( pcode )\n METHOD DrawText( lIsI25 )\n METHOD nextX( lI25 )\n METHOD Finish( image_style, quality, nFG )\n METHOD SetText( ptext )\n METHOD ResetColor()\n METHOD CheckCode()\n METHOD CheckValInArray( cChar )\n\nENDCLASS\n\nMETHOD CreateBar( sx, sy, filename, cColor ) CLASS GDBar\n\n ::Create( sx, sy )\n\n hb_default( @cColor, { 255, 255, 255 } )\n\n ::SetColor( cColor[ 1 ], cColor[ 2 ], cColor[ 3 ] )\n\n ::error := 0\n ::positionY := 0\n ::imWidth := sx\n\n IF ! Empty( filename )\n ::filename := filename\n ENDIF\n\n ::FillColor := ::SetColor( ::color_f[ 1 ], ::color_f[ 2 ], ::color_f[ 3 ] )\n ::BackColor := ::SetColor( ::color_b[ 1 ], ::color_b[ 2 ], ::color_b[ 3 ] )\n\n ::Setfont( \"Arial\" )\n\n \n IF ::textfont == 1 ; ::SetFontSmall()\n ELSEIF ::textfont == 2 ; ::SetFontLarge()\n ELSEIF ::textfont == 3 ; ::SetFontMediumBold()\n ELSEIF ::textfont == 4 ; ::SetFontGiant()\n ELSEIF ::textfont == 5 ; ::SetFontTiny()\n ENDIF\n\n ::SetFontPitch( ::textfont )\n\n \n ::maxHeight := ::maxHDefa\n\n RETURN Self\n\nMETHOD Configure( nMaxHeight, aFillColor, aBackColor, nRes, nTextFont, lBook, lDrawValue ) CLASS GDBar\n\n hb_default( @lBook , .F. )\n hb_default( @lDrawValue , .T. )\n hb_default( @nMaxHeight , 25 )\n hb_default( @nTextFont , 2 )\n hb_default( @nRes , 2 )\n hb_default( @aBackColor , { 255, 255, 255 } )\n hb_default( @aFillColor , { 0, 0, 0 } )\n\n ::book := lBook\n ::maxHeight := nMaxHeight\n ::res := nRes\n ::textfont := nTextFont\n ::lDrawValue := lDrawValue\n\n ::color_b := AClone( aBackColor )\n ::color_f := AClone( aFillColor )\n\n RETURN NIL\n\nMETHOD SetText( ptext ) CLASS GDBar\n\n ::text := ptext\n\n RETURN NIL\n\nMETHOD ResetColor() CLASS GDBar\n\n ::FillColor := ::SetColor( ::color_f[ 1 ], ::color_f[ 2 ], ::color_f[ 3 ] )\n ::BackColor := ::SetColor( ::color_b[ 1 ], ::color_b[ 2 ], ::color_b[ 3 ] )\n\n RETURN NIL\n\nMETHOD Allocate() CLASS GDBar\n\n LOCAL R := ::color_b[ 1 ]\n LOCAL G := ::color_b[ 2 ]\n LOCAL B := ::color_b[ 3 ]\n\n RETURN ::SetColor( R, G, B )\n\nMETHOD DrawSingleBar( pcode ) CLASS GDBar\n\n LOCAL i\n LOCAL j\n\n FOR j := 1 TO Len( pcode )\n\n FOR i := 1 TO ::res\n ::Line( ::positionX + i, ::positionY, ::positionX + i, ::positionY + ::maxHeight, ;\n iif( SubStr( pcode, j, 1 ) $ \"0\", ::BackColor, ::FillColor ) )\n NEXT\n\n ::NextX()\n NEXT\n\n RETURN NIL\n\nMETHOD DrawSingleI25( pcode ) CLASS GDBar\n\n LOCAL j\n\n LOCAL widthSlimBar := 1\n LOCAL widthFatBar := 3\n\n LOCAL imgBar\n LOCAL imgWid\n LOCAL end_y\n LOCAL qw\n\n ::positionX := 10\n\n FOR j := 1 TO Len( pcode )\n\n imgBar := iif( j % 2 == 0, ::FillColor, ::BackColor )\n imgWid := iif( SubStr( pcode, j, 1 ) == \"0\", widthSlimBar, widthFatBar )\n\n end_y := ::maxHeight\n\n FOR qw := 1 TO imgWid\n ::Line( ::positionX, 1, ::positionX, end_y, imgBar )\n ::nextX( .T. )\n NEXT\n NEXT\n\n RETURN NIL\n\nMETHOD DrawError( ptext ) CLASS GDBar\n\n ::Say( 5, ::error\n ::say( xPosition, ::maxHeight, \"*\" + ::text + \"*\", ::FillColor )\n ::lastY := ::maxHeight + ::GetFontHeight()\n ENDIF\n ELSE\n If ::textfont != 0\n xPosition := ( ::positionX / 2 ) - ( Len( ::text ) / 2 )\n ::DrawError( \"Character \" + SubStr( ::text, i, 1 ) + \" not allowed.\" )\n lRet := .F.\n ENDIF\n NEXT\n\n RETURN lRet\n\nMETHOD CheckValInArray( cChar ) CLASS GDBar\n\n LOCAL nPos := AScan( ::keys, {| x | SubStr( x, 1, 1 ) == cChar } )\n\n RETURN iif( nPos > 0, nPos, NIL )\n\nMETHOD Finish( image_style, quality, nFG ) CLASS GDBar\n\n hb_default( @image_style, IMG_FORMAT_PNG )\n hb_default( @quality , 95 )\n hb_default( @nFG , { 255, 255, 255 } )\n\n IF Empty( ::filename ) .OR. ::filename == NIL\n\n \n IF image_style == IMG_FORMAT_PNG\n ::OutputPng()\n ELSEIF image_style == IMG_FORMAT_JPEG\n ::OutputJpeg( , quality )\n ELSEIF image_style == IMG_FORMAT_WBMP\n ::OutputWBmp( , nFG )\n ELSEIF image_style == IMG_FORMAT_GIF\n ::OutputGif()\n ENDIF\n ELSE\n IF image_style == IMG_FORMAT_PNG\n ::SavePng( ::filename )\n ELSEIF image_style == IMG_FORMAT_JPEG\n ::Savejpeg( ::filename, quality )\n ELSEIF image_style == IMG_FORMAT_WBMP\n ::SaveWBmp( ::filename, nFG )\n ELSEIF image_style == IMG_FORMAT_GIF\n ::SaveGif( ::filename )\n ENDIF\n ENDIF\n\n RETURN .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/activex.prg. Defines classes: HActiveX. Contains procedures: Main, Event. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\n#include \"hbgtinfo.ch\"\n#include \"hbclass.ch\"\n\n#if ! defined( __HBSCRIPT__HBSHELL )\nREQUEST HB_GT_WVT_DEFAULT\n#endif\n\nPROCEDURE Main()\n\n LOCAL oMSCAL\n\n#if ! defined( __HBSCRIPT__HBSHELL ) .AND. defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVT\" )\n#endif\n\n WAIT \"Make sure we are 'Active Window'\"\n oMSCAL := HActiveX():Init( wapi_GetActiveWindow(), \"MSCAL.Calendar\", 0, 0, 300, 300 )\n WAIT \"Press any key to exit\"\n\n HB_SYMBOL_UNUSED( oMSCAL )\n\n RETURN\n\nCREATE CLASS HActiveX\n\n VAR oOLE\n VAR hWnd\n METHOD Init( hWnd, cProgId, nTop, nLeft, nWidth, nHeight, cID )\n METHOD Event( ... )\n ERROR HANDLER OnError()\n DESTRUCTOR Close()\n\nENDCLASS\n\nMETHOD Init( hWnd, cProgId, nTop, nLeft, nWidth, nHeight, cID ) CLASS HActiveX\n\n LOCAL nStyle := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_CLIPCHILDREN\n\n win_axInit()\n ::hWnd := wapi_CreateWindowEx( 0, \"AtlAxWin\", cProgId, nStyle, nLeft, nTop, nWidth, nHeight, hWnd, 0 )\n ::oOLE := win_axGetControl( ::hWnd, {| event, ... | ::Event( event, ... ) }, cID )\n\n RETURN Self\n\nPROCEDURE Event( ... ) CLASS HActiveX\n\n LOCAL cEvents := \"\"\n LOCAL aEvents := { ... }\n\n AEval( aEvents, {| xEvent | cEvents += hb_ValToStr( xEvent ) + \", \" } )\n wapi_OutputDebugString( cEvents )\n\n RETURN\n\nMETHOD OnError() CLASS HActiveX\n RETURN hb_ExecFromArray( ::oOLE, __GetMessage(), hb_AParams() )\n\nMETHOD Close() CLASS HActiveX\n\n wapi_OutputDebugString( \"Close\" )\n wapi_DestroyWindow( ::hWnd )\n ::hWnd := NIL\n ::oOLE := NIL\n wapi_OutputDebugString( \"After Close\" )\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour Runtime Library file: src/rtl/dbedit.prg. Provides functions: dbEdit, CallUser. This file handles database operations"}, {"role": "assistant", "content": "#include \"dbedit.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\n\nFUNCTION dbEdit( nTop, nLeft, nBottom, nRight, ;\n acColumns, xUserFunc, ;\n xColumnSayPictures, xColumnHeaders, ;\n xHeadingSeparators, xColumnSeparators, ;\n xFootingSeparators, xColumnFootings )\n\n LOCAL nOldCUrsor, nKey, lContinue, nPos, nAliasPos, nColCount\n LOCAL lDoIdleCall, lAppend, lFlag\n LOCAL cHeading, cBlock\n LOCAL bBlock\n LOCAL oBrowse\n LOCAL oColumn\n LOCAL aCol\n\n IF ! Used()\n RETURN .F.\n ELSEIF Eof()\n dbGoBottom()\n ENDIF\n\n IF ! HB_ISNUMERIC( nTop ) .OR. nTop < 0\n nTop := 0\n ENDIF\n IF ! HB_ISNUMERIC( nLeft ) .OR. nLeft < 0\n nLeft := 0\n ENDIF\n IF ! HB_ISNUMERIC( nBottom ) .OR. nBottom > MaxRow() .OR. nBottom < nTop\n nBottom := MaxRow()\n ENDIF\n IF ! HB_ISNUMERIC( nRight ) .OR. nRight > MaxCol() .OR. nRight < nLeft\n nRight := MaxCol()\n ENDIF\n\n oBrowse := TBrowseDB( nTop, nLeft, nBottom, nRight )\n oBrowse:headSep := iif( HB_ISSTRING( xHeadingSeparators ), xHeadingSeparators, hb_UTF8ToStrBox( \"═╤═\" ) )\n oBrowse:colSep := iif( HB_ISSTRING( xColumnSeparators ), xColumnSeparators, hb_UTF8ToStrBox( \" │ \" ) )\n oBrowse:footSep := hb_defaultValue( xFootingSeparators, \"\" )\n oBrowse:skipBlock := {| nRecs | Skipped( nRecs, lAppend ) }\n oBrowse:autoLite := .F. \n\n IF HB_ISARRAY( acColumns )\n nColCount := 0\n FOR EACH aCol IN acColumns\n IF HB_ISSTRING( aCol ) .AND. ! Empty( aCol )\n nColCount++\n ELSE\n EXIT\n ENDIF\n NEXT\n ELSE\n nColCount := FCount()\n ENDIF\n\n IF nColCount == 0\n RETURN .F.\n ENDIF\n\n \n FOR nPos := 1 TO nColCount\n\n IF HB_ISARRAY( acColumns )\n cBlock := acColumns[ nPos ]\n IF ( nAliasPos := At( \"->\", cBlock ) ) > 0\n cHeading := Left( cBlock, nAliasPos - 1 ) + \"->;\" + ;\n SubStr( cBlock, nAliasPos + 2 )\n ELSE\n cHeading := cBlock\n ENDIF\n ELSE\n cBlock := FieldName( nPos )\n cHeading := cBlock\n ENDIF\n\n \n bBlock := iif( Type( cBlock ) == \"M\", {|| \" \" }, hb_macroBlock( cBlock ) )\n\n DO CASE\n CASE HB_ISARRAY( xColumnHeaders ) .AND. Len( xColumnHeaders ) >= nPos .AND. HB_ISSTRING( xColumnHeaders[ nPos ] )\n cHeading := xColumnHeaders[ nPos ]\n CASE HB_ISSTRING( xColumnHeaders )\n cHeading := xColumnHeaders\n ENDCASE\n\n oColumn := TBColumnNew( cHeading, bBlock )\n\n DO CASE\n CASE HB_ISARRAY( xColumnSayPictures ) .AND. nPos <= Len( xColumnSayPictures ) .AND. HB_ISSTRING( xColumnSayPictures[ nPos ] ) .AND. ! Empty( xColumnSayPictures[ nPos ] )\n oColumn:picture := xColumnSayPictures[ nPos ]\n CASE HB_ISSTRING( xColumnSayPictures ) .AND. ! Empty( xColumnSayPictures )\n oColumn:picture := xColumnSayPictures\n ENDCASE\n\n DO CASE\n CASE HB_ISARRAY( xColumnFootings ) .AND. nPos <= Len( xColumnFootings ) .AND. HB_ISSTRING( xColumnFootings[ nPos ] )\n oColumn:footing := xColumnFootings[ nPos ]\n CASE HB_ISSTRING( xColumnFootings )\n oColumn:footing := xColumnFootings\n ENDCASE\n\n IF HB_ISARRAY( xHeadingSeparators ) .AND. nPos <= Len( xHeadingSeparators ) .AND. HB_ISSTRING( xHeadingSeparators[ nPos ] )\n oColumn:headSep := xHeadingSeparators[ nPos ]\n ENDIF\n\n IF HB_ISARRAY( xColumnSeparators ) .AND. nPos <= Len( xColumnSeparators ) .AND. HB_ISSTRING( xColumnSeparators[ nPos ] )\n oColumn:colSep := xColumnSeparators[ nPos ]\n ENDIF\n\n IF HB_ISARRAY( xFootingSeparators ) .AND. nPos <= Len( xFootingSeparators ) .AND. HB_ISSTRING( xFootingSeparators[ nPos ] )\n oColumn:footSep := xFootingSeparators[ nPos ]\n ENDIF\n\n oBrowse:addColumn( oColumn )\n NEXT\n\n nOldCUrsor := SetCursor( SC_NONE )\n\n \n lAppend := .F.\n lFlag := .T.\n lDoIdleCall := .T.\n lContinue := .T.\n\n DO WHILE lContinue\n\n DO WHILE .T.\n nKey := Inkey()\n IF oBrowse:stabilize()\n EXIT\n ENDIF\n#ifdef HB_COMPAT_C53\n IF nKey != 0 .AND. nKey != K_MOUSEMOVE\n EXIT\n ENDIF\n#else\n IF nKey != 0\n EXIT\n ENDIF\n#endif\n ENDDO\n\n IF nKey == 0\n IF lDoIdleCall\n lContinue := CallUser( oBrowse, xUserFunc, 0, @lAppend, @lFlag )\n oBrowse:forceStable()\n ENDIF\n IF lContinue .AND. lFlag\n oBrowse:hiLite()\n#ifdef HB_COMPAT_C53\n DO WHILE ( nKey := Inkey( 0 ) ) == K_MOUSEMOVE\n ENDDO\n#else\n nKey := Inkey( 0 )\n#endif\n oBrowse:deHilite()\n IF ( bBlock := SetKey( nKey ) ) != NIL\n Eval( bBlock, ProcName( 1 ), ProcLine( 1 ), \"\" )\n LOOP\n ENDIF\n ELSE\n lFlag := .T.\n ENDIF\n ENDIF\n\n lDoIdleCall := .T.\n\n IF nKey != 0\n#ifdef HB_CLP_UNDOC\n IF lAppend\n SWITCH nKey\n CASE K_DOWN\n CASE K_PGDN\n CASE K_CTRL_PGDN\n oBrowse:hitBottom := .T.\n LOOP\n CASE K_UP\n CASE K_PGUP\n CASE K_CTRL_PGUP\n oBrowse:hitTop := .T.\n LOOP\n ENDSWITCH\n ENDIF\n#endif\n SWITCH nKey\n#ifdef HB_COMPAT_C53\n CASE K_LBUTTONDOWN\n CASE K_LDBLCLK\n TBMouse( oBrowse, MRow(), MCol() )\n EXIT\n#endif\n CASE K_DOWN ; oBrowse:down() ; EXIT\n CASE K_UP ; oBrowse:up() ; EXIT\n CASE K_PGDN ; oBrowse:pageDown() ; EXIT\n CASE K_PGUP ; oBrowse:pageUp() ; EXIT\n CASE K_CTRL_PGUP ; oBrowse:goTop() ; EXIT\n CASE K_CTRL_PGDN ; oBrowse:goBottom() ; EXIT\n CASE K_RIGHT ; oBrowse:right() ; EXIT\n CASE K_LEFT ; oBrowse:left() ; EXIT\n CASE K_HOME ; oBrowse:home() ; EXIT\n CASE K_END ; oBrowse:end() ; EXIT\n CASE K_CTRL_LEFT ; oBrowse:panLeft() ; EXIT\n CASE K_CTRL_RIGHT ; oBrowse:panRight() ; EXIT\n CASE K_CTRL_HOME ; oBrowse:panHome() ; EXIT\n CASE K_CTRL_END ; oBrowse:panEnd() ; EXIT\n OTHERWISE\n lContinue := CallUser( oBrowse, xUserFunc, nKey, @lAppend, @lFlag )\n lDoIdleCall := .F.\n ENDSWITCH\n ENDIF\n ENDDO\n\n SetCursor( nOldCUrsor )\n\n RETURN .T.\n\n\nSTATIC FUNCTION CallUser( oBrowse, xUserFunc, nKey, lAppend, lFlag )\n\n LOCAL nPrevRecNo\n\n LOCAL nAction\n LOCAL nMode := ;\n iif( nKey != 0, DE_EXCEPT, ;\n iif( ! lAppend .AND. IsDbEmpty(), DE_EMPTY, ;\n iif( oBrowse:hitBottom, DE_HITBOTTOM, ;\n iif( oBrowse:hitTop, DE_HITTOP, DE_IDLE ) ) ) )\n\n oBrowse:forceStable()\n\n nPrevRecNo := RecNo()\n\n \n nAction := iif( HB_ISEVALITEM( xUserFunc ), ;\n Eval( xUserFunc, nMode, oBrowse:colPos ), ;\n iif( HB_ISSTRING( xUserFunc ) .AND. ! Empty( xUserFunc ), ;\n &xUserFunc( nMode, oBrowse:colPos ), ; \n iif( nKey == K_ENTER .OR. nKey == K_ESC, DE_ABORT, DE_CONT ) ) )\n\n IF ! lAppend .AND. Eof() .AND. ! IsDbEmpty()\n dbSkip( -1 )\n ENDIF\n\n#ifdef HB_CLP_UNDOC\n IF nAction == DE_APPEND\n\n IF ( lAppend := !( lAppend .AND. Eof() ) )\n dbGoBottom()\n oBrowse:down()\n ELSE\n oBrowse:refreshAll():forceStable()\n ENDIF\n lFlag := .F.\n RETURN .T.\n ENDIF\n#endif\n\n IF nAction == DE_REFRESH .OR. nPrevRecNo != RecNo()\n\n IF nAction != DE_ABORT\n\n lAppend := .F.\n\n IF ( Set( _SET_DELETED ) .AND. Deleted() ) .OR. ;\n ( ! Empty( dbFilter() ) .AND. ! Eval( hb_macroBlock( dbFilter() ) ) )\n dbSkip()\n ENDIF\n IF Eof()\n dbGoBottom()\n ENDIF\n\n nPrevRecNo := RecNo()"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/pegs.prg. Provides functions: ft_Pegs, DrawBox, err_msg, moremoves. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\n#translate DOUBLEBOX( , , , ) => hb_DispBox( , , , , hb_UTF8ToStrBox( \"╔═╗║╝═╚║ \" ) )\n\n\nFUNCTION ft_Pegs()\n\n LOCAL XX, MOVE, MPOS, POSSIBLE_, BUFFER, TOPROW, OLDSCORE, MOVE2\n LOCAL SCANBLOCK, OLDCOLOR := SetColor( \"w/n\" )\n LOCAL oldscrn := SaveScreen( 0, 0, MaxRow(), MaxCol() )\n LOCAL GetList\n\n LOCAL board_ := { ;\n { { 0, 29, 2, 34 }, { 2, 4 }, { 3, 9 }, .T. }, ;\n { { 0, 37, 2, 42 }, { 5 }, { 10 }, .T. }, ;\n { { 0, 45, 2, 50 }, { 2, 6 }, { 1, 11 }, .T. }, ;\n { { 3, 29, 5, 34 }, { 5, 9 }, { 6, 16 }, .T. }, ;\n { { 3, 37, 5, 42 }, { 10 }, { 17 }, .T. }, ;\n { { 3, 45, 5, 50 }, { 5, 11 }, { 4, 18 }, .T. }, ;\n { { 6, 13, 8, 18 }, { 8, 14 }, { 9, 21 }, .T. }, ;\n { { 6, 21, 8, 26 }, { 9, 15 }, { 10, 22 }, .T. }, ;\n { { 6, 29, 8, 34 }, { 4, 8, 10, 16 }, { 1, 7, 11, 23 }, .T. }, ;\n { { 6, 37, 8, 42 }, { 5, 9, 11, 17 }, { 2, 8, 12, 24 }, .T. }, ;\n { { 6, 45, 8, 50 }, { 6, 10, 12, 18 }, { 3, 9, 13, 25 }, .T. }, ;\n { { 6, 53, 8, 58 }, { 11, 19 }, { 10, 26 }, .T. }, ;\n { { 6, 61, 8, 66 }, { 12, 20 }, { 11, 27 }, .T. }, ;\n { { 9, 13, 11, 18 }, { 15 }, { 16 }, .T. }, ;\n { { 9, 21, 11, 26 }, { 16 }, { 17 }, .T. }, ;\n { { 9, 29, 11, 34 }, { 9, 15, 17, 23 }, { 4, 14, 18, 28 }, .T. }, ;\n { { 9, 37, 11, 42 }, { 10, 16, 18, 24 }, { 5, 15, 19, 29 }, .F. }, ;\n { { 9, 45, 11, 50 }, { 11, 17, 19, 25 }, { 6, 16, 20, 30 }, .T. }, ;\n { { 9, 53, 11, 58 }, { 18 }, { 17 }, .T. }, ;\n { { 9, 61, 11, 66 }, { 19 }, { 18 }, .T. }, ;\n { { 12, 13, 14, 18 }, { 14, 22 }, { 7, 23 }, .T. }, ;\n { { 12, 21, 14, 26 }, { 15, 23 }, { 8, 24 }, .T. }, ;\n { { 12, 29, 14, 34 }, { 16, 22, 24, 28 }, { 9, 21, 25, 31 }, .T. }, ;\n { { 12, 37, 14, 42 }, { 17, 23, 25, 29 }, { 10, 22, 26, 32 }, .T. }, ;\n { { 12, 45, 14, 50 }, { 18, 24, 26, 30 }, { 11, 23, 27, 33 }, .T. }, ;\n { { 12, 53, 14, 58 }, { 19, 25 }, { 12, 24 }, .T. }, ;\n { { 12, 61, 14, 66 }, { 20, 26 }, { 13, 25 }, .T. }, ;\n { { 15, 29, 17, 34 }, { 23, 29 }, { 16, 30 }, .T. }, ;\n { { 15, 37, 17, 42 }, { 24 }, { 17 }, .T. }, ;\n { { 15, 45, 17, 50 }, { 25, 29 }, { 18, 28 }, .T. }, ;\n { { 18, 29, 20, 34 }, { 28, 32 }, { 23, 33 }, .T. }, ;\n { { 18, 37, 20, 42 }, { 29 }, { 24 }, .T. }, ;\n { { 18, 45, 20, 50 }, { 30, 32 }, { 25, 31 }, .T. } }\n\n \n scanblock := {| a | a[ 2 ] == move2 }\n hb_Scroll()\n SetColor( \"w/r\" )\n hb_DispBox( 22, 31, 24, 48, hb_UTF8ToStrBox( \"┌─┐│┘─└│ \" ) )\n hb_DispOutAt( 23, 33, \"Your move:\" )\n AEval( board_, {| a, x | HB_SYMBOL_UNUSED( a ), drawbox( board_, x ) } )\n DO WHILE LastKey() != K_ESC .AND. moremoves( board_ )\n move := 1\n\n SetColor( \"w/n\" )\n GetList := { Get():New( 23, 44, {| v | iif( PCount() == 0, move, move := v ) }, \"move\", \"##\" ) }\n ATail( GetList ):postBlock := {| oGet | RangeCheck( oGet,, 1, 33 ) }\n ATail( GetList ):display()\n READ\n\n IF move > 0\n DO CASE\n CASE ! board_[ move ][ 4 ]\n err_msg( \"No piece there!\" )\n OTHERWISE\n possible_ := {}\n FOR xx := 1 TO Len( board_[ move ][ 2 ] )\n IF board_[ board_[ move ][ 2, xx ] ][ 4 ] .AND. ;\n ! board_[ board_[ move ][ 3, xx ] ][ 4 ]\n AAdd( possible_, { board_[ move ][ 2, xx ], board_[ move ][ 3, xx ] } )\n ENDIF\n NEXT\n \n DO CASE\n CASE Len( possible_ ) == 1\n \n board_[ move ][ 4 ] := board_[ possible_[ 1, 1 ] ][ 4 ] := .F.\n board_[ possible_[ 1, 2 ] ][ 4 ] := .T.\n drawbox( board_, move )\n drawbox( board_, possible_[ 1, 1 ] )\n drawbox( board_, possible_[ 1, 2 ] )\n CASE Len( possible_ ) == 0\n err_msg( \"Illegal move!\" )\n OTHERWISE\n move2 := possible_[ 1, 2 ]\n toprow := 21 - Len( possible_ )\n SetColor( \"+w/b\" )\n buffer := SaveScreen( toprow, 55, 22, 74 )\n DOUBLEBOX( toprow, 55, 22, 74 )\n hb_DispOutAt( toprow, 58, \"Possible Moves\" )\n SetPos( toprow, 65 )\n AEval( possible_, {| a | hb_DispOutAt( Row() + 1, 65, Transform( a[ 2 ], \"##\" ) ) } )\n oldscore := Set( _SET_SCOREBOARD, .F. )\n\n GetList := { Get():New( 23, 44, {| v | iif( PCount() == 0, move2, move2 := v ) }, \"move2\", \"##\" ) }\n ATail( GetList ):postBlock := {|| AScan( possible_, scanblock ) > 0 }\n ATail( GetList ):display()\n READ\n\n RestScreen( toprow, 55, 22, 74, buffer )\n Set( _SET_SCOREBOARD, oldscore )\n mpos := AScan( possible_, {| a | move2 == a[ 2 ] } )\n \n board_[ move ][ 4 ] := board_[ possible_[ mpos, 1 ] ][ 4 ] := .F.\n board_[ move2 ][ 4 ] := .T.\n drawbox( board_, move )\n drawbox( board_, possible_[ mpos, 1 ] )\n drawbox( board_, move2 )\n\n ENDCASE\n ENDCASE\n move := 1\n ENDIF\n ENDDO\n SetColor( oldcolor )\n RestScreen( 0, 0, MaxRow(), MaxCol(), oldscrn )\n\n RETURN NIL\n\nSTATIC FUNCTION DrawBox( board_, nelement )\n\n SetColor( iif( board_[ nelement ][ 4 ], \"+w/rb\", \"w/n\" ) )\n\n hb_DispBox( ;\n board_[ nelement ][ 1, 1 ], ;\n board_[ nelement ][ 1, 2 ], ;\n board_[ nelement ][ 1, 3 ], ;\n board_[ nelement ][ 1, 4 ], hb_UTF8ToStrBox( \"┌─┐│┘─└│ \" ) )\n\n hb_DispOutAt( ;\n board_[ nelement ][ 1, 1 ] + 1, ;\n board_[ nelement ][ 1, 2 ] + 2, hb_ntos( nelement ) )\n\n RETURN NIL\n\nSTATIC FUNCTION err_msg( msg )\n\n LOCAL buffer := SaveScreen( 23, 33, 23, 47 )\n\n SetCursor( SC_NONE )\n SetColor( \"+w/r\" )\n hb_DispOutAt( 23, 33, msg )\n Inkey( 2 )\n SetCursor( SC_NORMAL )\n RestScreen( 23, 33, 23, 47, buffer )\n\n RETURN NIL\n\nSTATIC FUNCTION moremoves( board_ )\n\n LOCAL xx, yy, canmove := .F., piecesleft := 0, buffer\n\n FOR xx := 1 TO 33\n FOR yy := 1 TO Len( board_[ xx ][ 2 ] )\n IF board_[ xx ][ 4 ] .AND. ; \n board_[ board_[ xx ][ 2, yy ] ][ 4 ] .AND. ; \n ! board_[ board_[ xx ][ 3, yy ] ][ 4 ] \n canmove := .T.\n EXIT\n ENDIF\n NEXT\n \n IF board_[ xx ][ 4 ]\n piecesleft++\n ENDIF\n NEXT\n IF ! canmove\n SetColor( \"+w/b\" )\n buffer := SaveScreen( 18, 55, 21, 74 )\n DOUBLEBOX( 18, 55, 21, 74 )\n hb_DispOutAt( 19, 58, \"No more moves!\" )\n hb_DispOutAt( 20, 58, hb_ntos( piecesleft ) + \" pieces left\" )\n Inkey( 0 )\n RestScreen( 18, 55, 21, 74, buffer )\n ENDIF\n\n RETURN canmove"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHeader file for contribution module 'hbtest' (Test framework utilities): contrib/hbtest/hbtest.ch. Defines constants: HB_TEST_CH_. Declares 1 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_TEST_CH_\n#define HB_TEST_CH_\n\n#xtranslate HBTEST IS => hbtest_Call( #, {|| }, )\n\n#pragma linenumber=on\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/xhbtedit.prg. Defines classes: XHBEditor. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"error.ch\"\n#include \"fileio.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n#include \"color.ch\"\n#include \"hbgtinfo.ch\"\n\nCREATE CLASS XHBEditor\n\n VAR cFile INIT \"\" \n\n VAR aText INIT {} \n\n VAR nTop \n VAR nLeft\n VAR nBottom\n VAR nRight\n\n VAR nFirstCol INIT 1 \n VAR nFirstRow INIT 1\n VAR nRow INIT 1 \n VAR nCol INIT 1\n\n VAR nPhysRow INIT 0 \n VAR nPhysCol INIT 0 \n \n\n VAR nTextRow INIT 0 \n VAR nTextCol INIT 0 \n VAR nWndRow INIT 0 \n VAR nWndCol INIT 0 \n\n VAR nNumCols INIT 1 \n VAR nNumRows INIT 1\n\n VAR nTabWidth INIT 5 \n VAR lEditAllow INIT .T. \n VAR lSaved INIT .F. \n VAR lWordWrap INIT .T. \n VAR nWordWrapCol INIT 0 \n VAR lChanged INIT .F. \n VAR lExitEdit INIT .F. \n\n VAR cColorSpec INIT SetColor() \n\n VAR lRightScroll INIT .T. \n VAR nMarkPos \n VAR nMarkLen\n VAR nOrigCursor INIT SetCursor() \n\n VAR ProcName INIT \"\"\n VAR ProcLine INIT 0\n\n VAR nCurrentCursor INIT SetCursor()\n\n VAR lSelActive INIT .F.\n VAR nRowSelStart INIT 0 \n VAR nRowSelEnd INIT 0 \n VAR nColSelRow INIT 0 \n VAR nColSelStart INIT 0 \n VAR nColSelEnd INIT 0 \n\n \n METHOD lInsert() BLOCK {|| Set( _SET_INSERT ) }\n METHOD _lInsert( lInsert ) BLOCK {| Self, lInsert | HB_SYMBOL_UNUSED( Self ), iif( HB_ISLOGICAL( lInsert ), Set( _SET_INSERT, lInsert ), Set( _SET_INSERT ) ) }\n\n METHOD New( cString, nTop, nLeft, nBottom, ; \n nRight, lEditMode, nLineLength, nTabSize, nTextRow, nTextCol, nWndRow, nWndCol )\n METHOD LoadFile( cFileName ) \n METHOD LoadText( cString ) \n METHOD SaveFile() \n\n METHOD AddLine( cLine, lSoftCR ) \n METHOD InsertLine( cLine, lSoftCR, nRow ) \n METHOD RemoveLine( nRow ) \n METHOD GetLine( nRow ) \n METHOD LineLen( nRow ) INLINE iif( nRow == NIL, nRow := ::nRow, ), iif( nRow <= ::LastRow(), Len( ::aText[ nRow ]:cText ), 0 ) \n METHOD SplitLine( nRow ) \n METHOD GotoLine( nRow ) \n METHOD GotoCol( nCol ) \n METHOD GotoPos( nRow, nCol, lRefresh )\n METHOD GetText( lSoftCR ) \n METHOD DelText() \n METHOD AddText( cString, lAtPos ) \n METHOD GetTextIndex() \n\n METHOD SetTextSelection( cAction, nCount ) \n METHOD GetTextSelection( lSoftCr ) \n METHOD DelTextSelection() \n METHOD ClrTextSelection() \n\n METHOD RefreshWindow() \n METHOD RefreshLine( lRefreshColSel ) \n METHOD RefreshColumn() \n\n METHOD LineColor( nRow ) \n METHOD ColColor() \n\n METHOD MoveCursor( nKey ) \n METHOD InsertState( lInsState ) \n METHOD Edit( nPassedKey ) \n\n METHOD KeyboardHook() \n METHOD IdleHook() \n\n METHOD Resize( nTop, nLeft, nBottom, nRight ) \n METHOD SetColor( cColorString ) \n METHOD Hilite() \n METHOD DeHilite() \n\n METHOD SetPos( nRow, nCol ) \n METHOD Row() INLINE ::nPhysRow \n METHOD Col() INLINE ::nPhysCol \n\n METHOD Down()\n METHOD PageDown()\n METHOD Bottom()\n METHOD GoBottom()\n METHOD Up()\n METHOD PageUp()\n METHOD Top()\n METHOD GoTop()\n METHOD Right()\n METHOD WordRight()\n METHOD End()\n METHOD Left()\n METHOD WordLeft()\n METHOD Home()\n\n METHOD K_Ascii( nKey )\n METHOD K_Return()\n METHOD K_Del()\n METHOD K_Bs()\n METHOD K_Tab()\n METHOD K_Mouse( nKey )\n METHOD K_Esc()\n\n \n VAR cInsLabel \n VAR lVerticalScroll INIT .T. \n VAR bKeyBlock \n\n METHOD DisplayInsert( lInsert ) \n METHOD LastRow() INLINE Len( ::aText ) \n METHOD DelTextRight( nRow ) \n METHOD DelWordRight() \n METHOD ReformParagraph() \n\n \n PROTECTED:\n\n METHOD BrowseText( nPassedKey, lHandleOneKey )\n\n \n METHOD GetCol( nRow, nCol ) INLINE iif( nRow > 0 .AND. nRow <= ::LastRow(), iif( nCol > 0 .AND. nCol <= Min( ::nWordWrapCol + 1, ::LineLen( nRow ) ), SubStr( ::aText[ nRow ]:cText, nCol, 1 ), \"\" ), \"\" )\n METHOD IsEmptyLine( nRow ) INLINE iif( nRow > 0 .AND. nRow <= ::LastRow(), Empty( ::aText[ nRow ]:cText ), .T. )\n\nENDCLASS\n\n\nMETHOD New( cString, nTop, nLeft, nBottom, nRight, lEditMode, nLineLength, nTabSize, nTextRow, nTextCol, nWndRow, nWndCol ) CLASS XHBEditor\n\n __defaultNIL( @cString, \"\" )\n __defaultNIL( @nTop, 0 )\n __defaultNIL( @nLeft, 0 )\n __defaultNIL( @nBottom, MaxRow() )\n __defaultNIL( @nRight, MaxCol() )\n __defaultNIL( @lEditMode, .T. )\n __defaultNIL( @nLineLength, NIL )\n __defaultNIL( @nTabSize, NIL )\n __defaultNIL( @nTextRow, 1 )\n __defaultNIL( @nTextCol, 0 )\n __defaultNIL( @nWndRow, 0 )\n __defaultNIL( @nWndCol, 0 )\n\n \n IF nTop > nBottom .OR. nLeft > nRight\n Throw( xhb_ErrorNew( \"BASE\", 0, 1127, \"Argument error: \", ProcName() ) )\n ENDIF\n\n\n ::cColorSpec := SetColor()\n\n \n ::nOrigCursor := SetCursor()\n\n\n ::nTop := Min( Max( 0, nTop ), MaxRow() )\n ::nLeft := Min( Max( 0, nLeft ), MaxCol() )\n ::nBottom := Max( 0, Min( MaxRow(), nBottom ) )\n ::nRight := Max( 0, Min( MaxCol(), nRight ) )\n\n\n ::nNumCols := ::nRight - ::nLeft + 1\n ::nNumRows := ::nBottom - ::nTop + 1\n\n \n IF ! HB_ISNUMERIC( nLineLength )\n nLineLength := ::nNumCols\n ELSE\n IF nLineLength < 0\n nLineLength := 255\n ::lWordWrap := .F.\n ELSE\n nLineLength := Max( 6, nLineLength )\n ENDIF\n ENDIF\n\n ::nWordWrapCol := nLineLength - 1 \n\n\n IF lEditMode != NIL\n ::lEditAllow := lEditMode\n ENDIF\n\n \n IF ::lEditAllow\n \n ::InsertState( ! Set( _SET_INSERT ) )\n ::InsertState( ! Set( _SET_INSERT ) )\n ENDIF\n\n \n ::lChanged := .F.\n\n \n IF nTabSize != NIL\n ::nTabWidth := nTabSize\n ENDIF\n\n ::nTextRow := Max( 1, nTextRow )\n ::nTextCol := Max( 0, nTextCol )\n ::nWndRow := Max( 0, nWndRow )\n ::nWndCol := Max( 0, nWndCol )\n\n ::nFirstRow := Max( 1, ::nTextRow - ::nWndRow )\n ::nFirstCol := Max( 1, ::nTextCol - ::nWndCol )\n\n\n ::aText := Text2Array( cString, nLineLength )\n\n IF ::LastRow() == 0\n AAdd( ::aText, HBTextLine():New() )\n ENDIF\n\n \n ::nRow := Max( 1, Min( ::nTextRow, Len( ::aText ) ) )\n ::nCol := Max( 1, Min( Len( ::aText[ ::nRow ]:cText ), ::nTextCol + 1 ) )\n\n \n IF ::nFirstRow > ::LastRow()\n ::nFirstRow := ::LastRow()\n ENDIF\n\n IF ::nFirstCol > ::LineLen( ::nRow ) + 1\n ::nFirstCol := ::LineLen( ::nRow ) + 1\n ENDIF\n\n\n ::SetPos( ::nTop + ::nWndRow, ::nLeft + ::nWndCol )\n\n ::RefreshWindow()\n\n RETURN Self\n\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/fib.prg. Provides functions: FibR, FibI. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL n\n\n FOR n := 1 TO 20\n ? FibR( n )\n ? FibI( n )\n NEXT\n\n RETURN\n\nFUNCTION FibR( n )\n\n LOCAL nFib\n\n IF n < 2\n nFib := n\n ELSE\n nFib := FibR( n - 2 ) + FibR( n - 1 )\n ENDIF\n\n RETURN nFib\n\nFUNCTION FibI( n )\n\n LOCAL nFibMin1 := 1\n LOCAL nFibMinN1 := 0\n LOCAL i := 1\n LOCAL nFib\n\n IF n < 2\n nFib := n\n ELSE\n DO WHILE i < n\n nFib := nFibMin1 + nFibMinN1\n nFibMinN1 := nFibMin1\n nFibMin1 := nFib\n ++i\n ENDDO\n ENDIF\n\n RETURN nFib"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour header file: extras/hbusb/hbusb.ch. Defines constants: HBUSB_CH, LIBUSB_UNREF_DEVICES, LIBUSB_KERNEL_HAS_INTERFACE, LIBUSB_ENDPOINT_IN, LIBUSB_ENDPOINT_OUT. Defines file I/O constants"}, {"role": "assistant", "content": "#ifndef HBUSB_CH\n#define HBUSB_CH\n\n#define LIBUSB_UNREF_DEVICES 1\n\n#define LIBUSB_KERNEL_HAS_INTERFACE 1\n\n#define LIBUSB_ENDPOINT_IN 129 \n#define LIBUSB_ENDPOINT_OUT 0\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/sortbug.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n dbCreate( \"testsort\", { { \"ITEM\", \"N\", 10, 2 } } )\n\n USE testsort\n dbAppend() ; FIELD->ITEM := 5.00\n dbAppend() ; FIELD->ITEM := -5.12\n dbAppend() ; FIELD->ITEM := 6.00\n dbAppend() ; FIELD->ITEM := 7.00\n dbAppend() ; FIELD->ITEM := -5.00\n\n SORT TO tempsort ON FIELD->ITEM /D\n\n USE tempsort\n dbEval( {|| QOut( FIELD->ITEM ) } )\n\n \n dbCloseArea()\n hb_dbDrop( \"testsort\" )\n hb_dbDrop( \"tempsort\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hblzf' (LZF compression library): contrib/hblzf/tests/test.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hblzf\"\n\n#define TEST_STRING \"This is test of LZF extension\"\n#define _NREPL_ 128\n\nPROCEDURE Main()\n\n LOCAL cStr, str_compressed, str_decompressed\n LOCAL b64_expected_result := \"BFRoaXMgIAIUdGVzdCBvZiBMWkYgZXh0ZW5zaW9u\"\n LOCAL nLen, nResult := 0\n\n ? \"LZF API version is\", ;\n hb_ntos( hb_lzf_version() ) + \" (0x\" + hb_NumToHex( hb_lzf_version() ) + \")\"\n ? \"LibLZF optimized for\", iif( hb_lzf_optimized_for_speed(), \"speed.\", \"compression.\" )\n\n ? \"--- test 1 ---\"\n \n cStr := TEST_STRING\n str_compressed := hb_lzf_compress( cStr, 15, @nResult )\n\n IF nResult == HB_LZF_OK\n ? \"Lenght of a string is\", hb_ntos( Len( cStr ) )\n ? \"Lenght of a compressed string is\", hb_ntos( Len( str_compressed ) )\n ELSE\n ? \"hb_lzf_compress() returns\", iif( nResult == HB_LZF_BUF_ERROR, \"LZF_BUF_ERROR\", \"LZF_MEM_ERROR\" )\n ENDIF\n\n ? \"--- test 2 ---\"\n cStr := TEST_STRING\n str_compressed := Space( 15 )\n str_compressed := hb_lzf_compress( cStr, @str_compressed, @nResult )\n\n IF nResult == HB_LZF_OK\n ? \"Lenght of a string is\", hb_ntos( Len( cStr ) )\n ? \"Lenght of a compressed string is\", hb_ntos( Len( str_compressed ) )\n ELSE\n ? \"hb_lzf_compress() returns\", iif( nResult == HB_LZF_BUF_ERROR, \"LZF_BUF_ERROR\", \"LZF_MEM_ERROR\" )\n ENDIF\n\n ? \"--- test 3 ---\"\n nLen := hb_lzf_compressbound( cStr )\n\n cStr := TEST_STRING\n str_compressed := hb_lzf_compress( cStr, nLen, @nResult )\n\n IF nResult == HB_LZF_OK\n ? \"Lenght of a string is\", hb_ntos( Len( cStr ) )\n ? \"Lenght of a compressed string is\", hb_ntos( Len( str_compressed ) )\n\n ? iif( hb_base64Encode( str_compressed ) == b64_expected_result, \"OK!\", \"not OK!\" )\n ELSE\n ? \"hb_lzf_compress() returns\", iif( nResult == HB_LZF_BUF_ERROR, \"LZF_BUF_ERROR\", \"LZF_MEM_ERROR\" )\n ENDIF\n\n ? \"--- test 4 ---\"\n nLen := hb_lzf_compressbound( cStr )\n str_compressed := Space( nLen )\n\n cStr := TEST_STRING\n str_compressed := hb_lzf_compress( cStr, @str_compressed, @nResult )\n\n IF nResult == HB_LZF_OK\n ? \"Lenght of a string is\", hb_ntos( Len( cStr ) )\n ? \"Lenght of a compressed string is\", hb_ntos( Len( str_compressed ) )\n\n ? iif( hb_base64Encode( str_compressed ) == b64_expected_result, \"OK!\", \"not OK!\" )\n ELSE\n ? \"hb_lzf_compress() returns\", iif( nResult == HB_LZF_BUF_ERROR, \"LZF_BUF_ERROR\", \"LZF_MEM_ERROR\" )\n ENDIF\n\n ? \"--- test 5 ---\"\n cStr := Replicate( TEST_STRING, _NREPL_ )\n str_compressed := hb_lzf_compress( cStr, NIL, @nResult )\n\n IF nResult == HB_LZF_OK\n ? \"Lenght of a string is\", hb_ntos( Len( cStr ) )\n ? \"Lenght of a compressed string is\", hb_ntos( Len( str_compressed ) )\n ELSE\n ? \"hb_lzf_compress() returns\", iif( nResult == HB_LZF_BUF_ERROR, \"LZF_BUF_ERROR\", \"LZF_MEM_ERROR\" )\n ENDIF\n\n ? \"--- test 6 ---\"\n str_decompressed := hb_lzf_decompress( str_compressed, NIL, @nResult )\n\n IF nResult == HB_LZF_DATA_CORRUPTED\n ? \"LZF decompression failed, compressed data corrupted\"\n ELSE\n ? iif( cStr == str_decompressed, \"OK!\", \"not OK!\" )\n ENDIF\n\n ? \"--- test 7 ---\"\n cStr := Replicate( TEST_STRING, _NREPL_ )\n str_compressed := hb_ZCompress( cStr, NIL, @nResult )\n\n str_decompressed := hb_lzf_decompress( str_compressed, NIL, @nResult )\n\n IF nResult == HB_LZF_DATA_CORRUPTED\n ? \"LZF decompression failed, compressed data corrupted!\"\n ELSE\n ? iif( cStr == str_decompressed, \"OK!\", \"not OK!\" )\n ENDIF\n\n ? \"--- test 8 ---\"\n cStr := Replicate( TEST_STRING, _NREPL_ )\n str_compressed := hb_lzf_compress( cStr, NIL, @nResult )\n\n str_decompressed := Space( 4096 )\n str_decompressed := hb_lzf_decompress( str_compressed, @str_decompressed, @nResult )\n\n IF nResult == HB_LZF_DATA_CORRUPTED\n ? \"LZF decompression failed, compressed data corrupted!\"\n ELSE\n ? iif( cStr == str_decompressed, \"OK!\", \"not OK!\" )\n ENDIF\n\n ? \"--- test 9 ---\"\n cStr := Replicate( TEST_STRING, _NREPL_ )\n str_compressed := hb_lzf_compress( cStr, NIL, @nResult )\n\n str_decompressed := \"\"\n str_decompressed := hb_lzf_decompress( str_compressed, @str_decompressed, @nResult )\n\n IF nResult != HB_LZF_OK\n ? \"hb_lzf_decompress() returns\", ;\n iif( nResult == HB_LZF_MEM_ERROR, \"HB_LZF_MEM_ERROR\", hb_ntos( nResult ) )\n ELSE\n ? iif( cStr == str_decompressed, \"OK!\", \"not OK!\" )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour header file: include/box.ch. Defines 9 constants including: _BOX_CH, B_SINGLE, B_DOUBLE, B_SINGLE_DOUBLE, B_DOUBLE_SINGLE. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef _BOX_CH\n#define _BOX_CH\n\n\n#define B_SINGLE ( Chr( 218 ) + Chr( 196 ) + Chr( 191 ) + Chr( 179 ) + ; \n Chr( 217 ) + Chr( 196 ) + Chr( 192 ) + Chr( 179 ) )\n\n\n#define B_DOUBLE ( Chr( 201 ) + Chr( 205 ) + Chr( 187 ) + Chr( 186 ) + ; \n Chr( 188 ) + Chr( 205 ) + Chr( 200 ) + Chr( 186 ) )\n\n\n#define B_SINGLE_DOUBLE ( Chr( 214 ) + Chr( 196 ) + Chr( 183 ) + Chr( 186 ) + ; \n Chr( 189 ) + Chr( 196 ) + Chr( 211 ) + Chr( 186 ) )\n\n\n#define B_DOUBLE_SINGLE ( Chr( 213 ) + Chr( 205 ) + Chr( 184 ) + Chr( 179 ) + ; \n Chr( 190 ) + Chr( 205 ) + Chr( 212 ) + Chr( 179 ) )\n\n#define HB_B_SINGLE_UNI hb_UTF8ToStrBox( \"┌─┐│┘─└│\" )\n#define HB_B_DOUBLE_UNI hb_UTF8ToStrBox( \"╔═╗║╝═╚║\" )\n#define HB_B_SINGLE_DOUBLE_UNI hb_UTF8ToStrBox( \"╓─╖║╜─╙║\" )\n#define HB_B_DOUBLE_SINGLE_UNI hb_UTF8ToStrBox( \"╒═╕│╛═╘│\" )\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/usrrdd/exfcm.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "REQUEST FCOMMA\n\nPROCEDURE Main()\n\n USE test.csv VIA \"FCOMMA\"\n ? \"ALIAS\", Alias(), \"RECNO\", RecNo(), ;\n \"BOF\", Bof(), \"EOF\", Eof(), \"LASTREC\", LastRec()\n ? RecNo(), '\"' + FIELD->LINE + '\"'\n dbGoBottom()\n ? RecNo(), '\"' + FIELD->LINE + '\"'\n dbGoTop()\n ? RecNo(), '\"' + FIELD->LINE + '\"'\n WAIT\n DO WHILE ! Eof()\n ? RecNo(), '\"' + FIELD->LINE + '\"'\n IF RecNo() == 20\n Inkey( 0 )\n ENDIF\n dbSkip()\n ENDDO\n ? \"ALIAS\", Alias(), \"RECNO\", RecNo(), ;\n \"BOF\", Bof(), \"EOF\", Eof(), \"LASTREC\", LastRec()\n WAIT\n dbGoBottom()\n ? \"ALIAS\", Alias(), \"RECNO\", RecNo(), ;\n \"BOF\", Bof(), \"EOF\", Eof(), \"LASTREC\", LastRec()\n WAIT\n DO WHILE ! Bof()\n ? RecNo(), '[' + FIELD->LINE + ']'\n IF RecNo() == LastRec() - 20\n Inkey( 0 )\n ENDIF\n dbSkip( -1 )\n ENDDO\n ? \"ALIAS\", Alias(), \"RECNO\", RecNo(), ;\n \"BOF\", Bof(), \"EOF\", Eof(), \"LASTREC\", LastRec()\n WAIT\n Browse()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/scregion.prg. Provides functions: ft_SavRgn, ft_RstRgn, ft_RgnStack. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "THREAD STATIC t_aRgnStack := {}\n\nFUNCTION ft_SavRgn( nTop, nLeft, nBottom, nRight )\n\n RETURN hb_BChar( nTop ) + hb_BChar( nLeft ) + hb_BChar( nBottom ) + hb_BChar( nRight ) + ;\n SaveScreen( nTop, nLeft, nBottom, nRight )\n\nFUNCTION ft_RstRgn( cScreen, nTop, nLeft )\n\n IF PCount() == 3\n RestScreen( nTop, nLeft, ;\n ( nTop - hb_BCode( hb_BSubStr( cScreen, 1, 1 ) ) ) + hb_BCode( hb_BSubStr( cScreen, 3, 1 ) ), ;\n ( nLeft - hb_BCode( hb_BSubStr( cScreen, 2, 1 ) ) ) + hb_BCode( hb_BSubStr( cScreen, 4, 1 ) ), ;\n hb_BSubStr( cScreen, 5 ) )\n ELSE\n RestScreen( ;\n hb_BCode( hb_BSubStr( cScreen, 1, 1 ) ), ;\n hb_BCode( hb_BSubStr( cScreen, 2, 1 ) ), ;\n hb_BCode( hb_BSubStr( cScreen, 3, 1 ) ), ;\n hb_BCode( hb_BSubStr( cScreen, 4, 1 ) ), ;\n hb_BSubStr( cScreen, 5 ) )\n ENDIF\n\n RETURN NIL\n\n\nFUNCTION ft_RgnStack( cAction, nTop, nLeft, nBottom, nRight )\n\n THREAD STATIC t_nStackPtr := 0\n\n LOCAL nPopTop\n\n IF cAction == \"push\"\n\n ASize( t_aRgnStack, ++t_nStackPtr )[ t_nStackPtr ] := ;\n ft_SavRgn( nTop, nLeft, nBottom, nRight )\n\n ELSEIF cAction == \"pop\" .OR. cAction == \"pop all\"\n\n nPopTop := iif( \"all\" $ cAction, 0, t_nStackPtr - 1 )\n\n DO WHILE t_nStackPtr > nPopTop\n ft_RstRgn( t_aRgnStack[ t_nStackPtr-- ] )\n ENDDO\n\n ASize( t_aRgnStack, t_nStackPtr )\n\n ENDIF\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbodbc' (ODBC database connectivity): contrib/hbodbc/tests/odbccall.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbodbc\"\n\nPROCEDURE Main()\n\n LOCAL dsFunctions := TODBC():New( \"DBQ=\" + hb_FNameMerge( hb_DirBase(), \"test.mdb\" ) + \";Driver={Microsoft Access Driver (*.mdb)}\" )\n\n dsFunctions:SetSQL( \"SELECT * FROM test\" )\n dsFunctions:Open()\n ? dsFunctions:FieldByName( \"First\" ):Value\n ? dsFunctions:Skip()\n ? dsFunctions:FieldByName( \"First\" ):Value\n ? dsFunctions:GoTo( 1 )\n ? dsFunctions:FieldByName( \"First\" ):Value\n ? dsFunctions:Prior()\n ? dsFunctions:FieldByName( \"First\" ):Value\n ? dsFunctions:First()\n ? dsFunctions:FieldByName( \"First\" ):Value\n ? dsFunctions:Last()\n ? dsFunctions:FieldByName( \"First\" ):Value\n ? dsFunctions:Close()\n\n dsFunctions:Destroy()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'gtwvw' (): contrib/gtwvw/tests/_wvwmous.prg. Defines classes: WVWMouseButton. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n#include \"setcurs.ch\"\n#include \"hbclass.ch\"\n\nSTATIC s_amouseobjlist := {}\nSTATIC s_ncurkey := 0\nSTATIC s_nkeyrepeater := NIL\nSTATIC s_nrepeatrate := 0.1\nSTATIC s_nrepeatdelay := 0.5\n\n#define _DEFAULT_CAPTION_FONT \"Tahoma\"\n#define _DEFAULT_CAPTION_HEIGHT 16\n\n\n#define _IDX_BLACK 0\n#define _IDX_BLUE 1\n#define _IDX_GREEN 2\n#define _IDX_CYAN 3\n#define _IDX_RED 4\n#define _IDX_MAGENTA 5\n#define _IDX_BROWN 6\n#define _IDX_WHITE 7\n#define _IDX_LIGHT_GRAY 8\n#define _IDX_BRIGHT_BLUE 9\n#define _IDX_BRIGHT_GREEN 10\n#define _IDX_BRIGHT_CYAN 11\n#define _IDX_BRIGHT_RED 12\n#define _IDX_BRIGHT_MAGENTA 13\n#define _IDX_YELLOW 14\n#define _IDX_BRIGHT_WHITE 15\n\n\n#define _MOBJECT_BUTTON 0 \n#define _MOBJECT_HSCROLL 1 \n#define _MOBJECT_VSCROLL 2 \n\n\n#define _BUTTON_NORMAL 0 \n#define _BUTTON_FLAT 1 \n#define _BUTTON_NONE 2 \n#define _BUTTON_HARD 3 \n\n\nCREATE CLASS WVWMouseButton\n\n VAR nWinId \n VAR lVisible \n VAR lEnable \n VAR lTight \n VAR nType \n VAR nRow1, nCol1, nRow2, nCol2 \n\n VAR bClickBlock \n VAR bPressBlock \n\n VAR lRepeatPress \n\n VAR cCaption\n VAR cCaptionFont \n VAR nCaptionHeight \n VAR cImage \n\n VAR cNormalColor \n VAR cPressedColor \n\n \n VAR lPressed \n VAR lHover \n\n \n METHOD New( cCaption, nRow1, nCol1, nRow2, nCol2, bClickBlock, nType, lDraw, nWinId )\n\n\n METHOD Enable( lEnable )\n\n METHOD SetClickBlock( bBlock )\n METHOD GetClickBlock() INLINE ::bClickBlock\n\n METHOD SetPressBlock( bBlock )\n METHOD GetPressBlock() INLINE ::bPressBlock\n\n METHOD SetRepeatPress( lRepeat )\n METHOD GetRepeatPress() INLINE ::lRepeatPress\n\n METHOD SetCaption( cCaption )\n\n METHOD OnClick()\n METHOD OnPress() \n METHOD OnRelease() \n METHOD OnReleaseOut() \n METHOD OnMouseOut() \n METHOD OnMouseOver() \n\n METHOD Draw( nWinNum )\n\nENDCLASS \n\nMETHOD New( cCaption, nRow1, nCol1, nRow2, nCol2, bClickBlock, nType, lDraw, nWinId ) CLASS WVWMouseButton\n\n hb_default( @cCaption, \"\" ) \n hb_default( @nRow1, 0 )\n hb_default( @nCol1, 0 )\n hb_default( @nRow2, nRow1 )\n hb_default( @nCol2, nCol1 + Max( 10, Len( cCaption ) + 2 ) - 1 )\n hb_default( @nType, _BUTTON_NORMAL ) \n hb_default( @lDraw, .T. )\n hb_default( @nWinId, wvw_nNumWindows() - 1 ) \n\n \n ::nWinId := nWinId \n\n ::nRow1 := nRow1\n ::nCol1 := nCol1\n ::nRow2 := nRow2\n ::nCol2 := nCol2\n\n ::bClickBlock := iif( HB_ISBLOCK( bClickBlock ), bClickBlock, NIL )\n ::bPressBlock := NIL\n\n ::lRepeatPress := .F.\n\n ::lPressed := .F.\n ::lHover := .F. \n ::cCaption := cCaption\n ::cCaptionFont := _DEFAULT_CAPTION_FONT\n ::nCaptionHeight := _DEFAULT_CAPTION_HEIGHT\n\n ::cImage := NIL \n\n \n ::cNormalColor := \"W\"\n ::cPressedColor := \"W\"\n\n ::lVisible := .T.\n ::lEnable := .T.\n ::lTight := .F.\n ::nType := nType\n\n IF lDraw \n ::Draw( ::nWinId )\n ENDIF\n\n RETURN Self \n\nMETHOD Enable( lEnable ) CLASS WVWMouseButton\n\n ::lEnable := lEnable\n ::draw()\n\n RETURN Self\n\nMETHOD SetClickBlock( bBlock ) CLASS WVWMouseButton\n\n ::bClickBlock := bBlock\n\n RETURN Self\n\nMETHOD SetPressBlock( bBlock ) CLASS WVWMouseButton\n\n ::bPressBlock := bBlock\n\n RETURN Self\n\nMETHOD SetRepeatPress( lRepeat ) CLASS WVWMouseButton\n\n ::lRepeatPress := lRepeat\n\n RETURN Self\n\nMETHOD SetCaption( cCaption ) CLASS WVWMouseButton\n\n ::cCaption := cCaption\n\n RETURN Self\n\nMETHOD OnPress() CLASS WVWMouseButton\n\n \n LOCAL lWasPressed\n IF ! ::lEnable \n RETURN Self\n ENDIF\n\n lWasPressed := ::lPressed\n ::lPressed := .T.\n ::Draw()\n\n IF ::lRepeatPress \n IF ! lWasPressed\n xKeyRepeater( .T. ) \n ENDIF\n wvwm_SetKeyRepeater( .T. ) \n ENDIF\n\n IF HB_ISBLOCK( ::bPressBlock )\n Eval( ::bPressBlock )\n ENDIF\n\n RETURN Self\n\nMETHOD OnClick() CLASS WVWMouseButton\n\n \n IF ! ::lEnable \n RETURN Self\n ENDIF\n\n IF HB_ISBLOCK( ::bClickBlock )\n Eval( ::bClickBlock )\n ENDIF\n\n RETURN Self\n\nMETHOD OnRelease() CLASS WVWMouseButton\n\n LOCAL lWasPressed := ::lPressed\n\n IF ! ::lEnable \n RETURN Self\n ENDIF\n\n ::lPressed := .F.\n ::Draw()\n\n IF ::lRepeatPress \n wvwm_SetKeyRepeater( .F. ) \n ENDIF\n\n IF lWasPressed\n ::OnClick()\n ENDIF\n\n RETURN Self\n\nMETHOD OnReleaseOut() CLASS WVWMouseButton\n\n \n IF ! ::lEnable \n RETURN Self\n ENDIF\n\n ::lPressed := .F.\n ::Draw()\n\n \n RETURN Self\n\n\nMETHOD OnMouseOut() CLASS WVWMouseButton\n\n \n IF ! ::lEnable \n RETURN Self\n ENDIF\n\n if ::lRepeatPress .AND. ::lPressed\n wvwm_SetKeyRepeater( .F. ) \n ENDIF\n\n ::lHover := .F.\n ::Draw()\n\n RETURN Self\n\n\nMETHOD OnMouseOver() CLASS WVWMouseButton\n\n \n IF ! ::lEnable \n RETURN Self\n ENDIF\n\n if ::lRepeatPress .AND. ::lPressed\n wvwm_SetKeyRepeater( .T. ) \n ENDIF\n\n ::lHover := .T.\n ::Draw()\n\n RETURN Self\n\nMETHOD DRAW( nWinNum ) CLASS WVWMouseButton\n\n LOCAL nOldCursor := SetCursor( SC_NONE )\n LOCAL lMouseOver := ::lHover \n LOCAL lPressed := ::lPressed .AND. lMouseOver\n LOCAL aFontInfo := iif( ::nCaptionHeight == NIL, wvw_GetFontInfo( nWinNum ), NIL )\n LOCAL nLabelColor := iif( ! lPressed, RGB( 0, 0, 0 ), RGB( 96, 96, 96 ) )\n LOCAL lUseImage := HB_ISSTRING( ::cImage ) \n\n IF ! ::lVisible .OR. ::nType == _BUTTON_NONE\n SetCursor( nOldCursor ) \n RETURN Self\n ENDIF\n\n if ::nrow1 > ::nrow2 .OR. ::ncol1 > ::ncol2\n SetCursor( nOldCursor ) \n RETURN Self\n ENDIF\n\n hb_default( @nWinNum, ::nWinId )\n\n IF lPressed \n IF ::nType != _BUTTON_HARD\n wvw_FillRectangle( nWinNum, ::nrow1, ::nCol1, ::nrow2, ::nCol2, wvw_GetRGBColor( hb_ColorToN( ::cPressedColor ) ), ::lTight )\n wvw_DrawBoxRecessed( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::lTight ) \n ELSE\n wvw_FillRectangle( nWinNum, ::nrow1, ::nCol1, ::nrow2, ::nCol2, wvw_GetRGBColor( hb_ColorToN( ::cNormalColor ) ), ::lTight )\n wvw_DrawBoxRaised( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::lTight )\n ENDIF\n\n IF lUseImage .AND. ::nType != _BUTTON_NONE\n IF ! wvw_DrawImage( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::cImage, ::lTight )\n win_MessageBox( NIL, \"Button Failed wvw_DrawImage(\" + ::cImage + \")\" )\n ENDIF\n ENDIF\n\n IF ! Empty( ::cCaption )\n wvw_DrawLabel( nWinNum, ::nRow1, _nCeiling( ( ::nCol2 + ::nCol1 ) / 2 ), ::cCaption, 6, , nLabelColor, RGB( 198, 198, 198 ), ::cCaptionFont, iif( HB_ISARRAY( afontinfo ), afontinfo[ 2 ], ::nCaptionHeight ), 0, , , , .F., .F. )\n ENDIF\n ELSE\n IF lMouseOver .OR. ::nType == _BUTTON_NORMAL .OR. ::nType == _BUTTON_HARD\n wvw_FillRectangle( nWinNum, ::nrow1, ::nCol1, ::nrow2, ::nCol2, wvw_GetRGBColor( hb_ColorToN( ::cNormalColor ) ), ::lTight )\n wvw_DrawBoxRaised( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::lTight )\n ELSE\n \n wvw_DrawBoxGroup( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2 )\n ENDIF\n\n IF lUseImage .AND. ::nType != _BUTTON_NONE\n IF ! wvw_DrawImage( nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ::cImage, ::lTight )\n win_MessageBox( NIL, \"Button Failed wvw_DrawImage(\" + ::cImage + \")\" )\n ENDIF\n ENDIF\n\n IF ! ::lEnable\n nLabelColor := RGB( 96, 96, 96 )\n ELSEIF lMouseOver\n nLabelColor := RGB( 255, 0, 0 )\n ENDIF\n\n IF ! Empty( ::cCaption )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/memory.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "#include \"hbmemory.ch\"\n\nPROCEDURE Main()\n\n ? \"HB_MEM_CHAR \", Memory( HB_MEM_CHAR )\n ? \"HB_MEM_BLOCK \", Memory( HB_MEM_BLOCK )\n ? \"HB_MEM_RUN \", Memory( HB_MEM_RUN )\n ? \"HB_MEM_VM \", Memory( HB_MEM_VM )\n ? \"HB_MEM_EMS \", Memory( HB_MEM_EMS )\n ? \"HB_MEM_FM \", Memory( HB_MEM_FM )\n ? \"HB_MEM_FMSEGS \", Memory( HB_MEM_FMSEGS )\n ? \"HB_MEM_SWAP \", Memory( HB_MEM_SWAP )\n ? \"HB_MEM_CONV \", Memory( HB_MEM_CONV )\n ? \"HB_MEM_EMSUSED \", Memory( HB_MEM_EMSUSED )\n ? \"HB_MEM_USED \", Memory( HB_MEM_USED )\n ? \"HB_MEM_USEDMAX \", Memory( HB_MEM_USEDMAX )\n ? \"HB_MEM_STACKITEMS\", Memory( HB_MEM_STACKITEMS )\n ? \"HB_MEM_STACK \", Memory( HB_MEM_STACK )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour Runtime Library file: src/rtl/tmenusys.prg. Defines classes: HBMenuSys. This file implements menu system classes"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"getexit.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\n#define IS_IN( str, list ) ( \"|\" + ( str ) + \"|\" $ \"|\" + ( list ) + \"|\" )\n\n\n#ifdef HB_COMPAT_C53\n\n\n#define SNLASTEXIT 6\n#define SNNEXTGET 12\n\n\nCREATE CLASS HBMenuSys\n\n EXPORTED:\n\n METHOD Modal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )\n METHOD Init( oMenu )\n\n PROTECTED:\n\n METHOD PushMenu()\n METHOD PopMenu()\n METHOD PopChild( nNewLevel )\n METHOD PopAll()\n METHOD Execute()\n METHOD MHitTest( oNewMenu, nNewLevel, nNewItem )\n METHOD ShowMsg( lMode )\n METHOD GetMsgArray()\n\n VAR oMenu\n VAR lOldMsgFlag\n VAR cOldMessage\n VAR aMenuList\n VAR nMenuLevel\n VAR nOldRow\n VAR nOldCol\n VAR nOldCursor\n VAR lMsgFlag\n VAR nMsgRow\n VAR nMsgLeft\n VAR nMsgRight\n VAR cMsgColor\n VAR cMsgSaveS\n\nENDCLASS\n\n\nMETHOD Modal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList ) CLASS HBMenuSys\n\n LOCAL oTopMenu := ::oMenu\n\n LOCAL nReturn := 0\n\n LOCAL nKey\n LOCAL nNewItem\n LOCAL lLeftDown\n LOCAL oNewMenu\n LOCAL nNewLevel\n LOCAL oMenuItem\n LOCAL nMenuItem\n LOCAL nTemp\n LOCAL bKeyBlock\n LOCAL lSubMenu\n\n ::nOldRow := Row()\n ::nOldCol := Col()\n ::nOldCursor := SetCursor( SC_NONE )\n\n ::nMsgRow := nMsgRow\n ::nMsgLeft := nMsgLeft\n ::nMsgRight := nMsgRight\n ::cMsgColor := cMsgColor\n\n IF ( ::lMsgFlag := HB_ISNUMERIC( ::nMsgRow ) .AND. ;\n HB_ISNUMERIC( ::nMsgLeft ) .AND. ;\n HB_ISNUMERIC( ::nMsgRight ) )\n\n IF ! HB_ISSTRING( ::cMsgColor )\n ::cMsgColor := GetClrPair( SetColor(), 1 )\n ENDIF\n\n Scroll( ::nMsgRow, ::nMsgLeft, ::nMsgRow, ::nMsgRight )\n\n ::cMsgSaveS := SaveScreen( ::nMsgRow, ::nMsgLeft, ::nMsgRow, ::nMsgRight )\n ENDIF\n\n oTopMenu:select( nSelection )\n\n IF oTopMenu:ClassName() == \"TOPBARMENU\" .OR. oTopMenu:isOpen\n oTopMenu:display()\n ELSE\n oTopMenu:open()\n ENDIF\n\n IF nSelection <= 0\n\n DO WHILE nSelection <= 0\n\n nKey := Inkey( 0, hb_bitOr( INKEY_KEYBOARD, INKEY_LDOWN ) )\n\n IF nKey == K_LBUTTONDOWN .OR. nKey == K_LDBLCLK\n nSelection := oTopMenu:hitTest( MRow(), MCol() )\n\n ELSEIF ( nSelection := oTopMenu:getAccel( nKey ) ) != 0\n\n ELSEIF IsShortcut( oTopMenu, nKey, @nReturn )\n RETURN nReturn\n ELSE\n nSelection := 1\n ENDIF\n ENDDO\n\n oTopMenu:select( nSelection )\n oTopMenu:display()\n ENDIF\n\n IF ! oTopMenu:getItem( nSelection ):enabled\n RETURN 0\n ENDIF\n\n ::aMenuList := Array( 16 )\n ::nMenuLevel := 1\n ::aMenuList[ 1 ] := ::oMenu\n\n lLeftDown := MLeftDown()\n\n ::ShowMsg( .T. )\n\n DO WHILE .T.\n\n nKey := Inkey( 0 )\n\n IF ( bKeyBlock := SetKey( nKey ) ) != NIL\n Eval( bKeyBlock, ProcName( 1 ), ProcLine( 1 ), \"\" )\n LOOP\n ENDIF\n\n DO CASE\n CASE nKey == K_MOUSEMOVE\n\n IF lLeftDown\n\n IF ! ::MHitTest( @oNewMenu, @nNewLevel, @nNewItem ) \n\n ELSEIF nNewLevel != ::nMenuLevel \n\n IF nNewItem != oNewMenu:current .AND. oNewMenu:GetItem( nNewItem ):enabled\n ::oMenu := oNewMenu\n ::PopChild( nNewLevel )\n ::oMenu:select( nNewItem )\n ::oMenu:display()\n ::PushMenu()\n ::ShowMsg( .T. )\n ENDIF\n\n ELSEIF nNewItem != oNewMenu:Current() \n\n ::PopChild( ::nMenuLevel )\n\n IF ::oMenu:getItem( nNewItem ):enabled\n ::oMenu:select( nNewItem )\n ::oMenu:display()\n ::PushMenu()\n ::ShowMsg( .T. )\n ENDIF\n ENDIF\n ENDIF\n\n CASE nKey == K_DOWN\n\n IF ::oMenu:ClassName() == \"TOPBARMENU\"\n IF ::PushMenu()\n ::ShowMsg( .T. )\n ENDIF\n ELSE\n nTemp := ::oMenu:getNext()\n IF nTemp == 0\n nTemp := ::oMenu:getFirst()\n ENDIF\n ::oMenu:select( nTemp )\n ::oMenu:display()\n ::ShowMsg( .T. )\n ENDIF\n\n CASE nKey == K_UP\n\n IF ! ::oMenu:ClassName() == \"TOPBARMENU\"\n nTemp := ::oMenu:getPrev()\n IF nTemp == 0\n nTemp := ::oMenu:getLast()\n ENDIF\n ::oMenu:select( nTemp )\n ::oMenu:display()\n ::ShowMsg( .T. )\n ENDIF\n\n CASE nKey == K_LEFT\n\n IF ( lSubMenu := ( ::nMenuLevel > 1 ) )\n ::PopMenu()\n ENDIF\n\n IF ::oMenu:ClassName() == \"TOPBARMENU\"\n nTemp := ::oMenu:getPrev()\n IF nTemp == 0\n nTemp := ::oMenu:getLast()\n ENDIF\n ::oMenu:select( nTemp )\n ::oMenu:display()\n IF lSubMenu\n ::PushMenu()\n ENDIF\n ENDIF\n ::ShowMsg( .T. )\n\n CASE nKey == K_RIGHT\n\n IF ( lSubMenu := ( ::nMenuLevel > 1 ) )\n ::PopMenu()\n ENDIF\n\n IF ::oMenu:ClassName() == \"TOPBARMENU\"\n nTemp := ::oMenu:getNext()\n IF nTemp == 0\n nTemp := ::oMenu:getFirst()\n ENDIF\n ::oMenu:select( nTemp )\n ::oMenu:display()\n IF lSubMenu\n ::PushMenu()\n ENDIF\n ENDIF\n ::ShowMsg( .T. )\n\n CASE nKey == K_ENTER\n\n IF ::PushMenu()\n ::ShowMsg( .T. )\n ELSE\n ::ShowMsg( .F. )\n nReturn := ::execute()\n IF nReturn != 0\n EXIT\n ENDIF\n ENDIF\n\n CASE nKey == K_ESC \n\n IF ::PopMenu()\n ::oMenu:display()\n ::ShowMsg( .T. )\n ELSE\n IF IS_IN( ::oMenu:ClassName(), \"POPUPMENU|HB_POPUPMENU\" )\n ::oMenu:close()\n ENDIF\n\n nReturn := -1 \n EXIT\n ENDIF\n\n CASE nKey == K_LBUTTONDOWN\n\n IF ! ::MHitTest( @oNewMenu, @nNewLevel, @nNewItem )\n\n IF GetList != NIL .AND. HitTest( GetList, MRow(), MCol(), ::GetMsgArray() ) != 0\n GetActive():ExitState := GE_MOUSEHIT\n ReadStats( SNLASTEXIT, GE_MOUSEHIT ) \n IF IS_IN( ::oMenu:ClassName(), \"POPUPMENU|HB_POPUPMENU\" )\n ::PopMenu()\n ENDIF\n nReturn := -1\n EXIT\n ENDIF\n\n IF IS_IN( ::oMenu:ClassName(), \"POPUPMENU|HB_POPUPMENU\" )\n ::PopMenu()\n ENDIF\n\n ELSEIF nNewLevel == ::nMenuLevel\n ::oMenu:select( nNewItem )\n ::oMenu:display()\n ::PushMenu()\n ::ShowMsg( .T. )\n\n ELSE\n ::nMenuLevel := nNewLevel\n ::oMenu := ::aMenuList[ ::nMenuLevel ]\n\n nMenuItem := ::oMenu:current\n IF ( oMenuItem := ::oMenu:getItem( ::oMenu:Current ) ):isPopUp()\n oMenuItem:data:close()\n ENDIF\n\n IF nMenuItem != nNewItem\n ::oMenu:select( nNewItem )\n ::oMenu:display()\n ::PushMenu()\n ENDIF\n\n ::ShowMsg( .T. )\n ENDIF\n\n lLeftDown := .T.\n\n CASE nKey == K_LBUTTONUP\n\n lLeftDown := .F.\n\n IF ::MHitTest( @oNewMenu, @nNewLevel, @nNewItem ) .AND. ;\n nNewLevel == ::nMenuLevel\n\n IF nNewItem == ::oMenu:current\n ::ShowMsg( .F. )\n nReturn := ::execute()\n IF nReturn != 0\n EXIT\n ENDIF\n ENDIF\n ENDIF\n\n CASE ( nNewItem := ::oMenu:getAccel( nKey ) ) != 0\n\n IF ::oMenu:getItem( nNewItem ):enabled\n ::oMenu:select( nNewItem )\n ::oMenu:display()\n\n IF ! ::PushMenu()\n ::ShowMsg( .F. )\n nReturn := ::execute()\n IF nReturn != 0\n EXIT\n ENDIF"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHeader file for contribution module 'hbxdiff' (File difference/patching): contrib/hbxdiff/hbxdiff.ch. Defines 10 constants including: HBXDIFF_CH_, XDLT_STD_BLKSIZE, XDL_PATCH_NORMAL, XDL_PATCH_REVERSE, XDL_PATCH_MODEMASK. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HBXDIFF_CH_\n#define HBXDIFF_CH_\n\n#define XDLT_STD_BLKSIZE ( 1024\n#define XDL_PATCH_NORMAL Asc( \"-\" )\n#define XDL_PATCH_REVERSE Asc( \"+\" )\n#define XDL_PATCH_MODEMASK ( hb_bitShift( 1, 8 ) - 1 )\n#define XDL_PATCH_IGNOREBSPACE hb_bitShift( 1, 8 )\n\n#define XDL_MMB_READONLY hb_bitShift( 1, 0 )\n\n#define XDL_MMF_ATOMIC hb_bitShift( 1, 0 )\n\n#define XDL_BDOP_INS 1\n#define XDL_BDOP_CPY 2\n#define XDL_BDOP_INSB 3\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/cdx.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n#include \"clipper.ch\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL aStruct := { ;\n { \"CHARACTER\", \"C\", 25, 0 }, ;\n { \"NUMERIC\", \"N\", 8, 0 }, ;\n { \"DOUBLE\", \"N\", 8, 2 }, ;\n { \"DATE\", \"D\", 8, 0 }, ;\n { \"MEMO\", \"M\", 10, 0 }, ;\n { \"LOGICAL\", \"L\", 1, 0 } }\n\n CLS\n dbUseArea( .T., \"DBFCDX\", \"test\", \"TESTDBF\", .T., .F. )\n dbCreate( \"testcdx\", aStruct, \"DBFCDX\", .T., \"TESTCDX\" )\n\n ? \"RddName:\", rddName()\n ? \"Press any key to continue...\"\n Inkey( 0 )\n Select( \"TESTDBF\" )\n SET FILTER TO TESTDBF->SALARY > 140000\n TESTDBF->( dbGoTop() )\n WHILE ! TESTDBF->( Eof() )\n TESTCDX->( dbAppend() )\n TESTCDX->CHARACTER := TESTDBF->FIRST\n TESTCDX->NUMERIC := TESTDBF->SALARY\n TESTCDX->MEMO := TESTDBF->FIRST + hb_eol() + ;\n TESTDBF->LAST + hb_eol() + ;\n TESTDBF->STREET\n TESTDBF->( dbSkip() )\n ENDDO\n\n ? TESTCDX->( RecCount() )\n TESTCDX->( dbGoTop() )\n ? TESTCDX->( Eof() )\n WHILE ! TESTCDX->( Eof() )\n ? TESTCDX->( RecNo() ), TESTCDX->NUMERIC\n ? TESTCDX->MEMO\n TESTCDX->( dbSkip() )\n ? \"Press any key to continue...\"\n Inkey( 0 )\n ENDDO\n\n hb_dbDrop( \"testcdx.cdx\" )\n\n Select( \"TESTCDX\" )\n ordCreate( \"testcdx\", \"Character\", \"FIELD->CHARACTER\", {|| FIELD->CHARACTER }, .F. )\n\n dbCloseAll()\n hb_dbDrop( \"testcdx\",, \"DBFCDX\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbfoxpro' (FoxPro file format support): contrib/hbfoxpro/dll.prg. Provides functions: fox___DynCall. This file handles data format parsing and generation"}, {"role": "assistant", "content": "#include \"hbdyn.ch\"\n\n\nFUNCTION fox___DynCall( cCommand, ... )\n\n LOCAL aParam\n\n LOCAL cFunction\n LOCAL cLibrary\n LOCAL nFuncFlags := hb_bitOr( HB_DYN_CALLCONV_CDECL, HB_DYN_ENC_RAW )\n\n LOCAL aCommand := hb_ATokens( cCommand )\n LOCAL nPos := 1\n\n LOCAL aType := { ;\n \"SHORT\" => HB_DYN_CTYPE_SHORT, ;\n \"INTEGER\" => HB_DYN_CTYPE_INT, ;\n \"SINGLE\" => HB_DYN_CTYPE_FLOAT, ;\n \"DOUBLE\" => HB_DYN_CTYPE_DOUBLE, ;\n \"LONG\" => HB_DYN_CTYPE_LONG, ;\n \"STRING\" => HB_DYN_CTYPE_CHAR_PTR, ;\n \"OBJECT\" => HB_DYN_CTYPE_VOID_PTR }\n\n IF nPos <= Len( aCommand ) .AND. Upper( aCommand[ nPos ] ) == \"DECLARE\"\n ++nPos\n ENDIF\n\n IF nPos <= Len( aCommand ) .AND. Upper( aCommand[ nPos ] ) $ aType\n nFuncFlags := hb_bitOr( nFuncFlags, aType[ Upper( aCommand[ nPos ] ) ] )\n ++nPos\n ELSE\n RETURN NIL\n ENDIF\n\n IF nPos <= Len( aCommand )\n cFunction := aCommand[ nPos ]\n ++nPos\n ELSE\n RETURN NIL\n ENDIF\n\n IF nPos <= Len( aCommand ) .AND. Upper( aCommand[ nPos ] ) == \"IN\"\n ++nPos\n ELSE\n RETURN NIL\n ENDIF\n\n IF nPos <= Len( aCommand )\n cLibrary := aCommand[ nPos ]\n ++nPos\n ELSE\n RETURN NIL\n ENDIF\n\n IF nPos <= Len( aCommand ) .AND. Upper( aCommand[ nPos ] ) == \"AS\"\n nPos += 2\n ENDIF\n\n aParam := { cFunction, cLibrary, nFuncFlags }\n\n DO WHILE nPos <= Len( aCommand )\n IF Upper( Upper( aCommand[ nPos ] ) ) $ aType\n AAdd( aParam, hb_bitOr( HB_DYN_ENC_RAW, aType[ Upper( aCommand[ nPos ] ) ] ) )\n ++nPos\n ENDIF\n IF nPos <= Len( aCommand ) .AND. aCommand[ nPos ] == \"@\"\n ++nPos\n ENDIF\n \n IF nPos <= Len( aCommand )\n ++nPos\n ENDIF\n IF nPos <= Len( aCommand ) .AND. aCommand[ nPos ] == \",\"\n ++nPos\n ENDIF\n ENDDO\n\n RETURN hb_DynCall( aParam, ... )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charswap.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CharSwap()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharSwap( \"0123456789\" ) == \"1032547698\" ? --> \"' + CharSwap( \"0123456789\" ) + '\"'\n ? ' CharSwap( \"ABCDEFGHIJK\" ) == \"BADCFEHGJIK\" ? --> \"' + CharSwap( \"ABCDEFGHIJK\" ) + '\"'\n ?\n\n ? \"End test of CharSwap()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/dates2.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL dDate := hb_SToD( \"19990430\" )\n\n ? Set( _SET_DATEFORMAT ), dDate\n Set( _SET_DATEFORMAT, \"yyy/mm/ddd\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"on\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"off\" )\n ? Set( _SET_DATEFORMAT ), dDate\n Set( _SET_DATEFORMAT, \"yyy/m/d/yyy\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"on\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"off\" )\n ? Set( _SET_DATEFORMAT ), dDate\n Set( _SET_DATEFORMAT, \"m/d/y/m/d\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"on\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"off\" )\n ? Set( _SET_DATEFORMAT ), dDate\n Set( _SET_DATEFORMAT, \"mmmm/ddddd\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"on\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"off\" )\n ? Set( _SET_DATEFORMAT ), dDate\n Set( _SET_DATEFORMAT, \"mmmmm/dd\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"on\" )\n ? Set( _SET_DATEFORMAT ), dDate\n __SetCentury( \"off\" )\n ? Set( _SET_DATEFORMAT ), dDate\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHeader file for contribution module 'hbmysql' (MySQL database client library): contrib/hbmysql/mysql.ch. Defines 10 constants including: HBMYSQL_CH_, MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HBMYSQL_CH_\n#define HBMYSQL_CH_\n\n\n#define MYSQL_TYPE_DECIMAL 0\n#define MYSQL_TYPE_TINY 1 \n#define MYSQL_TYPE_SHORT 2\n#define MYSQL_TYPE_LONG 3\n#define MYSQL_TYPE_FLOAT 4\n#define MYSQL_TYPE_DOUBLE 5\n#define MYSQL_TYPE_NULL 6\n#define MYSQL_TYPE_TIMESTAMP 7\n#define MYSQL_TYPE_LONGLONG 8\n#define MYSQL_TYPE_INT24 9\n#define MYSQL_TYPE_DATE 10\n#define MYSQL_TYPE_TIME 11\n#define MYSQL_TYPE_DATETIME 12\n#define MYSQL_TYPE_YEAR 13\n#define MYSQL_TYPE_NEWDATE 14\n#define MYSQL_TYPE_VARCHAR 15\n#define MYSQL_TYPE_BIT 16\n#define MYSQL_TYPE_NEWDECIMAL 246\n#define MYSQL_TYPE_ENUM 247\n#define MYSQL_TYPE_SET 248\n#define MYSQL_TYPE_TINY_BLOB 249\n#define MYSQL_TYPE_MEDIUM_BLOB 250\n#define MYSQL_TYPE_LONG_BLOB 251\n#define MYSQL_TYPE_BLOB 252\n#define MYSQL_TYPE_VAR_STRING 253\n#define MYSQL_TYPE_STRING 254\n#define MYSQL_TYPE_GEOMETRY 255\n\n\n#define MYSQL_FS_NAME 1 \n#define MYSQL_FS_TABLE 2 \n#define MYSQL_FS_DEF 3 \n#define MYSQL_FS_TYPE 4 \n#define MYSQL_FS_LENGTH 5 \n#define MYSQL_FS_MAXLEN 6 \n#define MYSQL_FS_FLAGS 7 \n#define MYSQL_FS_DECIMALS 8 \n\n\n#define NOT_NULL_FLAG hb_bitShift( 1, 0 ) \n#define PRI_KEY_FLAG hb_bitShift( 1, 1 ) \n#define UNIQUE_KEY_FLAG hb_bitShift( 1, 2 ) \n#define MULTIPLE_KEY_FLAG hb_bitShift( 1, 3 ) \n#define BLOB_FLAG hb_bitShift( 1, 4 ) \n#define UNSIGNED_FLAG hb_bitShift( 1, 5 ) \n#define ZEROFILL_FLAG hb_bitShift( 1, 6 ) \n#define BINARY_FLAG hb_bitShift( 1, 7 )\n\n#define ENUM_FLAG hb_bitShift( 1, 8 ) \n#define AUTO_INCREMENT_FLAG hb_bitShift( 1, 9 ) \n#define TIMESTAMP_FLAG hb_bitShift( 1, 10 ) \n#define PART_KEY_FLAG hb_bitShift( 1, 14 ) \n#define GROUP_FLAG hb_bitShift( 1, 15 ) \n\n\n#define DBS_NOTNULL 5 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'rddmisc' (): contrib/rddmisc/logrdd.prg. Provides 19 functions including: LOGRDD_INIT, LOGRDD_EXIT, LOGRDD_CREATE, LOGRDD_CREATEFIELDS, LOGRDD_OPEN. Contains procedures: _LOGRDD_INIT, OpenLogFile, ToLog. This file handles database operations"}, {"role": "assistant", "content": "#include \"dbinfo.ch\"\n#include \"fileio.ch\"\n#include \"hbusrrdd.ch\"\n#include \"rddsys.ch\"\n\n#define ARRAY_FILENAME 1\n#define ARRAY_FHANDLE 2\n#define ARRAY_TAG 3\n#define ARRAY_ACTIVE 4\n#define ARRAY_RDDNAME 5\n#define ARRAY_MSGLOGBLOCK 6\n#define ARRAY_USERLOGBLOCK 7\n\nANNOUNCE LOGRDD\n\nDYNAMIC hb_LogRddInherit \n\nSTATIC s_nRddID := -1\n\nSTATIC FUNCTION LOGRDD_INIT( nRDD )\n\n \n LOCAL cFileName := \"changes.log\"\n LOCAL lActive := .F.\n LOCAL cTag := NetName() + \"\\\" + hb_UserName()\n LOCAL cRDDName := hb_LogRddInherit()\n\n \n USRRDD_RDDDATA( nRDD, { cFileName, NIL, cTag, lActive, cRDDName, NIL, NIL } )\n\n RETURN HB_SUCCESS\n\nSTATIC FUNCTION LOGRDD_EXIT( nRDD )\n\n LOCAL aRDDData := USRRDD_RDDDATA( nRDD )\n\n \n IF aRDDData[ ARRAY_FHANDLE ] != NIL\n FClose( aRDDData[ ARRAY_FHANDLE ] )\n aRDDData[ ARRAY_FHANDLE ] := NIL\n ENDIF\n\n RETURN HB_SUCCESS\n\n\nSTATIC FUNCTION LOGRDD_CREATE( nWA, aOpenInfo )\n\n LOCAL nResult\n\n IF ( nResult := UR_SUPER_CREATE( nWA, aOpenInfo ) ) == HB_SUCCESS\n ToLog( \"CREATE\", nWA, aOpenInfo )\n ENDIF\n\n RETURN nResult\n\n\nSTATIC FUNCTION LOGRDD_CREATEFIELDS( nWA, aStruct )\n\n LOCAL nResult\n\n IF ( nResult := UR_SUPER_CREATEFIELDS( nWA, aStruct ) ) == HB_SUCCESS\n ToLog( \"CREATEFIELDS\", nWA, aStruct )\n ENDIF\n\n RETURN nResult\n\n\nSTATIC FUNCTION LOGRDD_OPEN( nWA, aOpenInfo )\n\n LOCAL nResult\n\n IF ( nResult := UR_SUPER_OPEN( nWA, aOpenInfo ) ) == HB_SUCCESS\n ToLog( \"OPEN\", nWA, aOpenInfo )\n ENDIF\n\n RETURN nResult\n\n\nSTATIC FUNCTION LOGRDD_CLOSE( nWA )\n\n LOCAL cFile := dbInfo( DBI_FULLPATH )\n LOCAL cAlias := Alias()\n LOCAL nResult\n\n IF ( nResult := UR_SUPER_CLOSE( nWA ) ) == HB_SUCCESS\n ToLog( \"CLOSE\", nWA, cFile, cAlias )\n ENDIF\n\n RETURN nResult\n\nSTATIC FUNCTION LOGRDD_APPEND( nWA, lUnlockAll )\n\n LOCAL nResult\n\n IF ( nResult := UR_SUPER_APPEND( nWA, lUnlockAll ) ) == HB_SUCCESS\n ToLog( \"APPEND\", nWA, lUnlockAll )\n ENDIF\n\n RETURN nResult\n\nSTATIC FUNCTION LOGRDD_DELETE( nWA )\n\n LOCAL nResult\n\n IF ( nResult := UR_SUPER_DELETE( nWA ) ) == HB_SUCCESS\n ToLog( \"DELETE\", nWA )\n ENDIF\n\n RETURN nResult\n\nSTATIC FUNCTION LOGRDD_RECALL( nWA )\n\n LOCAL nResult\n\n IF ( nResult := UR_SUPER_RECALL( nWA ) ) == HB_SUCCESS\n ToLog( \"RECALL\", nWA )\n ENDIF\n\n RETURN nResult\n\nSTATIC FUNCTION LOGRDD_PUTVALUE( nWA, nField, xValue )\n\n LOCAL xOldValue := FieldGet( nField )\n LOCAL nResult := UR_SUPER_PUTVALUE( nWA, nField, xValue )\n\n \n IF ! xOldValue == xValue\n ToLog( \"PUTVALUE\", nWA, nField, xValue, xOldValue )\n ENDIF\n\n RETURN nResult\n\nSTATIC FUNCTION LOGRDD_ZAP( nWA )\n\n LOCAL nResult\n\n IF ( nResult := UR_SUPER_ZAP( nWA ) ) == HB_SUCCESS\n ToLog( \"ZAP\", nWA )\n ENDIF\n\n RETURN nResult\n\n\nREQUEST DBFCDX\n\n\nFUNCTION LOGRDD_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, pSuperRddID )\n\n LOCAL cSuperRDD := hb_LogRddInherit() \n LOCAL aMyFunc[ UR_METHODCOUNT ]\n\n s_nRddID := nRddID\n\n aMyFunc[ UR_INIT ] := @LOGRDD_INIT()\n aMyFunc[ UR_EXIT ] := @LOGRDD_EXIT()\n aMyFunc[ UR_CREATE ] := @LOGRDD_CREATE()\n aMyFunc[ UR_CREATEFIELDS ] := @LOGRDD_CREATEFIELDS()\n aMyFunc[ UR_OPEN ] := @LOGRDD_OPEN()\n aMyFunc[ UR_CLOSE ] := @LOGRDD_CLOSE()\n aMyFunc[ UR_APPEND ] := @LOGRDD_APPEND()\n aMyFunc[ UR_DELETE ] := @LOGRDD_DELETE()\n aMyFunc[ UR_RECALL ] := @LOGRDD_RECALL()\n aMyFunc[ UR_PUTVALUE ] := @LOGRDD_PUTVALUE()\n aMyFunc[ UR_ZAP ] := @LOGRDD_ZAP()\n\n RETURN USRRDD_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, ;\n cSuperRDD, aMyFunc, pSuperRddID )\n\nINIT PROCEDURE _LOGRDD_INIT()\n\n rddRegister( \"LOGRDD\", RDT_FULL )\n\n RETURN\n\n\nFUNCTION hb_LogRddLogFileName( cFileName )\n\n LOCAL aRDDData\n LOCAL cOldFileName\n\n IF s_nRddID >= 0\n\n aRDDData := USRRDD_RDDDATA( s_nRddID )\n\n cOldFileName := aRDDData[ ARRAY_FILENAME ]\n\n IF HB_ISSTRING( cFileName )\n aRDDData[ ARRAY_FILENAME ] := cFileName\n ENDIF\n ENDIF\n\n RETURN cOldFileName\n\nFUNCTION hb_LogRddTag( cTag )\n\n LOCAL aRDDData\n LOCAL cOldTag\n\n IF s_nRddID >= 0\n\n aRDDData := USRRDD_RDDDATA( s_nRddID )\n\n cOldTag := aRDDData[ ARRAY_TAG ]\n\n IF HB_ISSTRING( cTag )\n aRDDData[ ARRAY_TAG ] := cTag\n ENDIF\n ENDIF\n\n RETURN cOldTag\n\nFUNCTION hb_LogRddActive( lActive )\n\n LOCAL aRDDData\n LOCAL lOldActive\n\n IF s_nRddID >= 0\n\n aRDDData := USRRDD_RDDDATA( s_nRddID )\n\n lOldActive := aRDDData[ ARRAY_ACTIVE ]\n\n IF HB_ISLOGICAL( lActive )\n aRDDData[ ARRAY_ACTIVE ] := lActive\n ENDIF\n ENDIF\n\n RETURN lOldActive\n\nFUNCTION hb_LogRddMsgLogBlock( bMsgLogBlock )\n\n LOCAL aRDDData\n LOCAL bOldMsgLogBlock\n\n IF s_nRddID >= 0\n\n aRDDData := USRRDD_RDDDATA( s_nRddID )\n\n bOldMsgLogBlock := aRDDData[ ARRAY_MSGLOGBLOCK ]\n\n IF HB_ISEVALITEM( bMsgLogBlock )\n aRDDData[ ARRAY_MSGLOGBLOCK ] := bMsgLogBlock\n ENDIF\n ENDIF\n\n RETURN bOldMsgLogBlock\n\nFUNCTION hb_LogRddUserLogBlock( bUserLogBlock )\n\n LOCAL aRDDData\n LOCAL bOldUserLogBlock\n\n IF s_nRddID >= 0\n\n aRDDData := USRRDD_RDDDATA( s_nRddID )\n\n bOldUserLogBlock := aRDDData[ ARRAY_MSGLOGBLOCK ]\n\n IF HB_ISEVALITEM( bUserLogBlock )\n aRDDData[ ARRAY_USERLOGBLOCK ] := bUserLogBlock\n ENDIF\n ENDIF\n\n RETURN bOldUserLogBlock\n\nFUNCTION hb_LogRddValueToText( uValue )\n\n LOCAL cType\n LOCAL cText\n\n SWITCH cType := ValType( uValue )\n CASE \"C\" ; cText := hb_StrToExp( uValue ) ; EXIT\n CASE \"N\" ; cText := hb_ntos( uValue ) ; EXIT\n CASE \"D\" ; cText := DToS( uValue ) ; cText := \"0d\" + iif( Empty( cText ), \"00000000\", cText ) ; EXIT\n OTHERWISE ; cText := hb_ValToStr( uValue )\n ENDSWITCH\n\n RETURN \"[\" + cType + \"]>>>\" + cText + \"<<<\"\n\n\nSTATIC PROCEDURE OpenLogFile( nWA )\n\n LOCAL aRDDData := USRRDD_RDDDATA( USRRDD_ID( nWA ) )\n LOCAL cFileName := aRDDData[ ARRAY_FILENAME ]\n LOCAL hFile := aRDDData[ ARRAY_FHANDLE ]\n LOCAL lActive := aRDDData[ ARRAY_ACTIVE ]\n\n\n IF lActive .AND. hFile == NIL\n\n \n IF hb_FileExists( cFileName )\n hFile := FOpen( cFileName, FO_READWRITE + FO_SHARED )\n ELSE\n hFile := FCreate( cFileName )\n \n IF FError() == 0 .AND. hFile != F_ERROR\n FClose( hFile )\n hFile := FOpen( cFileName, FO_READWRITE + FO_SHARED )\n ENDIF\n ENDIF\n IF FError() == 0 .AND. hFile != F_ERROR\n \n FSeek( hFile, 0, FS_END )\n ELSE\n hFile := NIL\n ENDIF\n\n aRDDData[ ARRAY_FHANDLE ] := hFile\n ENDIF\n\n RETURN\n\nSTATIC FUNCTION ToString( cCmd, nWA, xPar1, xPar2, xPar3 )\n\n SWITCH cCmd\n CASE \"CREATE\"\n \n RETURN xPar1[ UR_OI_NAME ]\n CASE \"CREATEFIELDS\"\n \n RETURN hb_ValToExp( xPar1 )\n CASE \"OPEN\"\n \n RETURN 'Table: \"' + xPar1[ UR_OI_NAME ] + '\", Alias: \"' + Alias() + '\", WorkArea: ' + hb_ntos( nWA )\n CASE \"CLOSE\"\n \n RETURN 'Table: \"' + xPar1 + '\", Alias: \"' + xPar2 + '\", WorkArea: ' + hb_ntos( nWA )\n CASE \"APPEND\"\n \n RETURN Alias() + \"->RecNo() == \" + hb_ntos( RecNo() )\n CASE \"DELETE\"\n \n RETURN Alias() + \"->RecNo() == \" + hb_ntos( RecNo() )\n CASE \"RECALL\"\n \n RETURN Alias() + \"->RecNo() == \" + hb_ntos( RecNo() )\n CASE \"PUTVALUE\"\n \n HB_SYMBOL_UNUSED( xPar3 ) \n RETURN Alias() + \"(\" + hb_ntos( RecNo() ) + \")->\" + PadR( FieldName( xPar1 ), 10 ) + \" := \" + hb_LogRddValueToText( xPar2 )\n CASE \"ZAP\"\n \n RETURN 'Alias: \"' + Alias() + ' Table: \"' + dbInfo( DBI_FULLPATH ) + '\"'\n ENDSWITCH\n\n RETURN NIL\n\nSTATIC PROCEDURE ToLog( cCmd, nWA, xPar1, xPar2, xPar3 )\n\n LOCAL aRDDData := USRRDD_RDDDATA( USRRDD_ID( nWA ) )\n LOCAL lActive := aRDDData[ ARRAY_ACTIVE ]\n LOCAL hFile, cTag, cRDDName, bMsgLogBlock, bUserLogBlock, cLog\n\n \n IF lActive\n\n cTag := aRDDData[ ARRAY_TAG ]\n cRDDName := aRDDData[ ARRAY_RDDNAME ]"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: WvgComboBox. Harbour contribution module 'gtwvg' (): contrib/gtwvg/combobox.prg. Defines classes: WvgComboBox. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nCREATE CLASS WvgComboBox INHERIT WvgWindow, WvgDataRef\n\n VAR type INIT WVGCOMBO_DROPDOWN\n VAR drawMode INIT WVG_DRAW_NORMAL\n VAR nCurSelected INIT 0\n\n VAR aInfo INIT NIL\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD destroy()\n METHOD handleEvent( nMessage, aNM )\n\n METHOD sendCBMessage( nMsg, wParam, lParam ) INLINE wvg_SendCBMessage( ::pWnd, nMsg, wParam, lParam )\n METHOD listBoxFocus( lFocus )\n METHOD listBoxSize()\n METHOD sleSize()\n\n METHOD addItem( cItem )\n METHOD clear() INLINE ::sendCBMessage( CB_RESETCONTENT )\n METHOD delItem( nIndex ) INLINE ::sendCBMessage( CB_DELETESTRING, nIndex - 1 )\n METHOD getItem( nIndex ) INLINE ::sendCBMessage( CB_GETLBTEXT, nIndex - 1 )\n METHOD insItem( nIndex, cItem ) INLINE ::sendCBMessage( CB_INSERTSTRING, nIndex - 1, cItem )\n METHOD setItem( nIndex, cItem ) VIRTUAL\n METHOD setIcon( nItem, cIcon )\n\n VAR oSLE\n VAR oListBox\n ACCESS XbpSLE INLINE ::oSLE\n ACCESS XbpListBox INLINE ::oListBox\n\n VAR sl_itemMarked\n VAR sl_itemSelected\n VAR sl_drawItem\n\n METHOD itemMarked( ... ) SETGET\n METHOD itemSelected( ... ) SETGET\n METHOD drawItem( ... ) SETGET\n\nENDCLASS\n\nMETHOD WvgComboBox:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::style := WS_CHILD + WS_TABSTOP + WS_BORDER + WS_VSCROLL + CBS_NOINTEGRALHEIGHT + CBS_AUTOHSCROLL\n\n ::className := \"COMBOBOX\"\n ::objType := objTypeComboBox\n\n RETURN Self\n\nMETHOD WvgComboBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::oParent:AddChild( Self )\n\n DO CASE\n CASE ::type == WVGCOMBO_DROPDOWNLIST\n ::style += CBS_DROPDOWNLIST\n CASE ::type == WVGCOMBO_SIMPLE\n ::style += CBS_SIMPLE\n OTHERWISE\n ::style += CBS_DROPDOWN\n ENDCASE\n\n ::createControl()\n\n\n IF ::visible\n ::show()\n ENDIF\n ::setPosAndSize()\n\n \n IF ! Empty( ::aInfo := ::sendCBMessage( CB_GETCOMBOBOXINFO ) )\n ::oSLE := WvgSLE():new()\n ::oSLE:oParent := Self\n ::oSLE:hWnd := ::aInfo[ 5 ]\n ::oSLE:pWnd := win_N2P( ::aInfo[ 5 ] )\n\n ::oListBox := WvgListBox():new()\n ::oListBox:oParent := Self\n ::oListBox:hWnd := ::aInfo[ 6 ]\n ::oListBox:pWnd := win_N2P( ::aInfo[ 6 ] )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgComboBox:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n RETURN Self\n\nMETHOD PROCEDURE WvgComboBox:destroy()\n\n ::wvgWindow:destroy()\n\n RETURN\n\nMETHOD WvgComboBox:handleEvent( nMessage, aNM )\n\n DO CASE\n\n CASE nMessage == HB_GTE_RESIZED\n IF ::isParentCrt()\n ::rePosition()\n ENDIF\n ::sendMessage( WM_SIZE, 0, 0 )\n\n CASE nMessage == HB_GTE_COMMAND\n DO CASE\n CASE aNM[ 1 ] == CBN_SELCHANGE\n ::nCurSelected := ::editBuffer := wvg_lbGetCurSel( ::hWnd ) + 1\n IF ::isParentCrt()\n ::oParent:setFocus()\n ENDIF\n ::itemMarked()\n IF ::isParentCrt()\n IF ::pointerFocus\n ::setFocus()\n ENDIF\n ENDIF\n\n CASE aNM[ 1 ] == CBN_DBLCLK\n ::editBuffer := ::nCurSelected\n IF ::isParentCrt()\n ::oParent:setFocus()\n ENDIF\n ::itemSelected()\n IF ::isParentCrt()\n IF ::pointerFocus\n ::setFocus()\n ENDIF\n ENDIF\n\n CASE aNM[ 1 ] == CBN_KILLFOCUS\n ::killInputFocus()\n\n CASE aNM[ 1 ] == CBN_SETFOCUS\n ::setInputFocus()\n\n ENDCASE\n\n CASE nMessage == HB_GTE_KEYTOITEM\n IF aNM[ 1 ] == K_ENTER\n IF ::isParentCrt()\n ::oParent:setFocus()\n ENDIF\n ::itemSelected()\n IF ::isParentCrt()\n IF ::pointerFocus\n ::setFocus()\n ENDIF\n ENDIF\n ENDIF\n\n CASE nMessage == HB_GTE_CTLCOLOR\n IF HB_ISNUMERIC( ::clr_FG )\n wvg_SetTextColor( aNM[ 1 ], ::clr_FG )\n ENDIF\n IF HB_ISNUMERIC( ::hBrushBG )\n wvg_SetBkMode( aNM[ 1 ], 1 )\n RETURN ::hBrushBG\n ELSE\n RETURN wvg_GetCurrentBrush( aNM[ 1 ] )\n ENDIF\n\n ENDCASE\n\n RETURN EVENT_UNHANDELLED\n\nMETHOD WvgComboBox:addItem( cItem )\n\n IF HB_ISSTRING( cItem )\n RETURN ::sendCBMessage( CB_ADDSTRING, cItem )\n ENDIF\n\n RETURN -1\n\nMETHOD WvgComboBox:listBoxFocus( lFocus )\n\n LOCAL lOldFocus := ::sendCBMessage( CB_GETDROPPEDSTATE )\n\n IF HB_ISLOGICAL( lFocus )\n ::sendCBMessage( CB_SHOWDROPDOWN, lFocus )\n ENDIF\n\n RETURN lOldFocus\n\nMETHOD WvgComboBox:sleSize()\n\n IF HB_ISOBJECT( ::oSLE )\n RETURN ::oSLE:currentSize()\n ENDIF\n\n RETURN { 0, 0 }\n\nMETHOD WvgComboBox:listBoxSize()\n\n IF HB_ISOBJECT( ::oListBox )\n RETURN ::oListBox:currentSize()\n ENDIF\n\n RETURN { 0, 0 }\n\nMETHOD WvgComboBox:setIcon( nItem, cIcon )\n\n HB_SYMBOL_UNUSED( nItem )\n HB_SYMBOL_UNUSED( cIcon )\n\n RETURN Self\n\nMETHOD WvgComboBox:itemMarked( ... )\n\n LOCAL a_ := hb_AParams()\n\n IF Len( a_ ) == 1 .AND. HB_ISBLOCK( a_[ 1 ] )\n ::sl_itemMarked := a_[ 1 ]\n ELSEIF Len( a_ ) >= 0 .AND. HB_ISBLOCK( ::sl_itemMarked )\n Eval( ::sl_itemMarked, , , Self )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgComboBox:itemSelected( ... )\n\n LOCAL a_ := hb_AParams()\n\n IF Len( a_ ) == 1 .AND. HB_ISBLOCK( a_[ 1 ] )\n ::sl_itemSelected := a_[ 1 ]\n ELSEIF Len( a_ ) >= 0 .AND. HB_ISBLOCK( ::sl_itemSelected )\n Eval( ::sl_itemSelected, , , Self )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgComboBox:drawItem( ... )\n\n LOCAL a_ := hb_AParams()\n\n IF Len( a_ ) == 1 .AND. HB_ISBLOCK( a_[ 1 ] )\n ::sl_xbePDrawItem := a_[ 1 ]\n ELSEIF Len( a_ ) >= 2 .AND. HB_ISBLOCK( ::sl_xbePDrawItem )\n Eval( ::sl_xbePDrawItem, a_[ 1 ], a_[ 2 ], Self )\n ENDIF\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/output.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifndef __HARBOUR__\n#include \"clipper.ch\"\n#endif\n\nPROCEDURE Main()\n\n OutStd( hb_eol(), \"Testing Harbour device management on\", Date() )\n SET ALTERNATE TO output_a ADDITIVE\n Set( _SET_EXTRAFILE, \"output_e.ext\", .F. )\n SET PRINTER TO output_p\n SET MARGIN TO 5\n QOut( \"SCREEN, EXTRA, NOT ALTERNATE, NOT PRINTER\" )\n @ 5, 5 SAY \"SCREEN, NOT EXTRA, NOT ALTERNATE NOT PRINTER\"\n SET ALTERNATE ON\n SET PRINTER ON\n QOut( \"SCREEN, EXTRA, ALTERNATE AND PRINTER\" )\n @ 10, 10 SAY \"SCREEN, NOT EXTRA, NOT ALTERNATE, NOT PRINTER\"\n SET DEVICE TO PRINTER\n Set( _SET_EXTRAFILE, \"\" )\n QOut( \"SCREEN, ALTERNATE AND PRINTER AGAIN, BUT NOT EXTRA\" )\n SET PRINTER OFF\n Set( _SET_EXTRAFILE, \"output_e.ext\", .T. )\n QOut( \"SCREEN, EXTRA, AND ALTERNATE, BUT NOT PRINTER\" )\n @ 15, 15 SAY \"PRINTER, NOT SCREEN, NOT ALTERNATE\"\n EJECT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour Runtime Library file: src/rtl/hbini.prg. Provides 7 functions including: hb_iniNew, hb_iniRead, hb_iniReadStr, hb_iniFileLow, hb_iniStringLow. Contains procedures: hb_iniSetComment. This file provides file I/O operations"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n\nSTATIC s_cLineComment := \";\"\nSTATIC s_cHalfLineComment := \"#\"\n\nPROCEDURE hb_iniSetComment( cLc, cHlc )\n\n IF HB_ISSTRING( cLc )\n s_cLineComment := cLc\n ENDIF\n\n IF HB_ISSTRING( cHlc )\n s_cHalfLineComment := cHlc\n ENDIF\n\n RETURN\n\nFUNCTION hb_iniNew( lAutoMain )\n\n LOCAL hIni := { => }\n\n IF hb_defaultValue( lAutoMain, .T. )\n hIni[ \"MAIN\" ] := { => }\n ENDIF\n\n RETURN hIni\n\nFUNCTION hb_iniRead( cFileSpec, lKeyCaseSens, cSplitters, lAutoMain )\n RETURN hb_iniReadStr( iif( HB_ISSTRING( cFileSpec ), hb_iniFileLow( cFileSpec ), \"\" ), lKeyCaseSens, cSplitters, lAutoMain )\n\nFUNCTION hb_iniReadStr( cData, lKeyCaseSens, cSplitters, lAutoMain )\n\n LOCAL hIni := { => }\n\n \n hb_default( @lKeyCaseSens, .T. )\n hb_default( @lAutoMain, .T. )\n\n hb_HCaseMatch( hIni, lKeyCaseSens )\n\n IF lAutoMain\n hIni[ \"MAIN\" ] := { => }\n ENDIF\n\n RETURN hb_iniStringLow( hIni, hb_defaultValue( cData, \"\" ), lKeyCaseSens, ;\n hb_defaultValue( cSplitters, \"=\" ), lAutoMain )\n\nSTATIC FUNCTION hb_iniFileLow( cFileSpec )\n\n LOCAL cFile, nLen\n LOCAL hFile\n LOCAL cData\n LOCAL aFiles := hb_ATokens( cFileSpec, hb_osPathListSeparator() )\n\n IF Empty( aFiles )\n aFiles := { cFileSpec }\n ENDIF\n\n hFile := F_ERROR\n FOR EACH cFile IN aFiles\n IF ! Empty( cFile ) .AND. hb_FileExists( cFile )\n IF ( hFile := FOpen( cFile ) ) != F_ERROR\n EXIT\n ENDIF\n ENDIF\n NEXT\n\n IF hFile == F_ERROR\n RETURN \"\"\n ENDIF\n\n \n cData := Space( FSeek( hFile, 0, FS_END ) )\n FSeek( hFile, 0, FS_SET )\n nLen := FRead( hFile, @cData, hb_BLen( cData ) )\n cData := hb_BLeft( cData, nLen )\n FClose( hFile )\n\n RETURN cData\n\nSTATIC FUNCTION hb_iniStringLow( hIni, cData, lKeyCaseSens, cSplitters, lAutoMain )\n\n LOCAL aKeyVal, hCurrentSection\n LOCAL cLine\n LOCAL reComment, reInclude, reSection, reSplitters\n\n reComment := hb_regexComp( s_cHalfLineComment + \"|^[ \\t]*\" + s_cLineComment )\n reInclude := hb_regexComp( \"include (.*)\" )\n reSection := hb_regexComp( \"[[](.*)[]]\" )\n reSplitters := hb_regexComp( cSplitters )\n\n \n hCurrentSection := iif( lAutoMain, hIni[ \"MAIN\" ], hIni )\n\n cLine := \"\"\n FOR EACH cData IN hb_ATokens( cData, .T. )\n cLine += AllTrim( cData )\n\n \n IF Right( cLine, 3 ) == \" ||\"\n cLine := hb_StrShrink( cLine, 2 )\n \n IF ! cData:__enumIsLast()\n LOOP\n ENDIF\n ENDIF\n\n \n IF Empty( cLine )\n LOOP\n ENDIF\n\n \n IF ! Empty( aKeyVal := hb_regexSplit( reComment, cLine ) )\n IF Empty( cLine := AllTrim( aKeyVal[ 1 ] ) )\n \n LOOP\n ENDIF\n ENDIF\n\n \n IF ! Empty( aKeyVal := hb_regex( reInclude, cLine ) )\n \n aKeyVal[ 2 ] := AllTrim( aKeyVal[ 2 ] )\n IF Len( aKeyVal[ 2 ] ) == 0\n LOOP\n ENDIF\n hb_iniStringLow( hIni, hb_iniFileLow( aKeyVal[ 2 ] ), lKeyCaseSens, cSplitters, lAutoMain )\n \n ELSEIF ! Empty( aKeyVal := hb_regex( reSection, cLine ) )\n cLine := AllTrim( aKeyVal[ 2 ] )\n IF Len( cLine ) != 0\n hCurrentSection := { => }\n IF ! lKeyCaseSens\n cLine := Upper( cLine )\n ENDIF\n hIni[ cLine ] := hCurrentSection\n ENDIF\n \n ELSEIF Len( aKeyVal := hb_regexSplit( reSplitters, cLine,,, 1 ) ) == 1\n \n ELSE\n \n IF ! lKeyCaseSens\n aKeyVal[ 1 ] := Upper( aKeyVal[ 1 ] )\n ENDIF\n hCurrentSection[ AllTrim( aKeyVal[ 1 ] ) ] := AllTrim( aKeyVal[ 2 ] )\n ENDIF\n\n cLine := \"\"\n NEXT\n\n RETURN hIni\n\nFUNCTION hb_iniWrite( xFileName, hIni, cCommentBegin, cCommentEnd, lAutoMain )\n\n LOCAL hFile\n LOCAL lClose\n LOCAL cBuffer\n\n cBuffer := hb_iniWriteStr( hIni, cCommentBegin, cCommentEnd, lAutoMain )\n\n IF ! HB_ISSTRING( cBuffer )\n RETURN .F.\n ENDIF\n\n IF HB_ISSTRING( xFileName )\n hFile := FCreate( xFileName )\n lClose := .T.\n ELSEIF HB_ISNUMERIC( xFileName )\n hFile := xFileName\n lClose := .F.\n ELSE\n RETURN .F.\n ENDIF\n\n IF hFile == F_ERROR\n RETURN .F.\n ENDIF\n\n IF FWrite( hFile, cBuffer ) != hb_BLen( cBuffer )\n IF lClose\n FClose( hFile )\n ENDIF\n RETURN .F.\n ENDIF\n\n IF lClose\n FClose( hFile )\n ENDIF\n\n RETURN .T.\n\nFUNCTION hb_iniWriteStr( hIni, cCommentBegin, cCommentEnd, lAutoMain )\n\n LOCAL cNewLine := hb_eol()\n LOCAL cSection\n LOCAL cBuffer := \"\"\n\n IF ! HB_ISHASH( hIni )\n RETURN NIL\n ENDIF\n\n IF HB_ISSTRING( cCommentBegin ) .AND. ! Empty( cCommentBegin )\n cBuffer += cCommentBegin + cNewLine\n ENDIF\n\n hb_default( @lAutoMain, .T. )\n\n \n IF lAutoMain .AND. !( \"MAIN\" $ hIni )\n lAutoMain := .F.\n ENDIF\n\n \n IF lAutoMain\n \n hb_HEval( hIni[ \"MAIN\" ], {| cKey, xVal | ;\n cBuffer += hb_CStr( cKey ) + \"=\" + hb_CStr( xVal ) + cNewLine } )\n ELSE\n \n hb_HEval( hIni, {| cKey, xVal | iif( HB_ISHASH( xVal ), , ;\n cBuffer += hb_CStr( cKey ) + \"=\" + hb_CStr( xVal ) + cNewLine ) } )\n ENDIF\n\n FOR EACH cSection IN hIni\n\n \n IF lAutoMain\n \n IF cSection:__enumKey == \"MAIN\"\n LOOP\n ENDIF\n ELSE\n \n IF ! HB_ISHASH( cSection )\n LOOP\n ENDIF\n ENDIF\n\n cBuffer += cNewLine + \"[\" + hb_CStr( cSection:__enumKey ) + \"]\" + cNewLine\n\n hb_HEval( cSection, ;\n {| cKey, xVal | cBuffer += hb_CStr( cKey ) + \"=\" + ;\n hb_CStr( xVal ) + cNewLine } )\n NEXT\n\n IF HB_ISSTRING( cCommentEnd ) .AND. ! Empty( cCommentEnd )\n cBuffer += cCommentEnd + cNewLine\n ENDIF\n\n RETURN iif( Empty( cBuffer ), NIL, cBuffer )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour header file: include/hbsocket.ch. Defines 10 constants including: HB_SOCKET_CH_, HB_SOCKET_ERR_NONE, HB_SOCKET_ERR_PIPE, HB_SOCKET_ERR_TIMEOUT, HB_SOCKET_ERR_WRONGADDR. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_SOCKET_CH_\n#define HB_SOCKET_CH_\n\n\n#define HB_SOCKET_ERR_NONE 0\n#define HB_SOCKET_ERR_PIPE 1\n#define HB_SOCKET_ERR_TIMEOUT 2\n#define HB_SOCKET_ERR_WRONGADDR 3\n#define HB_SOCKET_ERR_AFNOSUPPORT 4\n#define HB_SOCKET_ERR_PFNOSUPPORT 5\n#define HB_SOCKET_ERR_PROTONOSUPPORT 6\n#define HB_SOCKET_ERR_PARAMVALUE 7\n#define HB_SOCKET_ERR_NOSUPPORT 8\n#define HB_SOCKET_ERR_NORESOURCE 9\n#define HB_SOCKET_ERR_ACCESS 10\n#define HB_SOCKET_ERR_ADDRINUSE 11\n#define HB_SOCKET_ERR_INTERRUPT 12\n#define HB_SOCKET_ERR_ALREADYCONNECTED 13\n#define HB_SOCKET_ERR_CONNREFUSED 14\n#define HB_SOCKET_ERR_CONNABORTED 15\n#define HB_SOCKET_ERR_CONNRESET 16\n#define HB_SOCKET_ERR_NETUNREACH 17\n#define HB_SOCKET_ERR_NETDOWN 18\n#define HB_SOCKET_ERR_NETRESET 19\n#define HB_SOCKET_ERR_INPROGRESS 20\n#define HB_SOCKET_ERR_ALREADY 21\n#define HB_SOCKET_ERR_ADDRNOTAVAIL 22\n#define HB_SOCKET_ERR_READONLY 23\n#define HB_SOCKET_ERR_AGAIN 24\n#define HB_SOCKET_ERR_INVALIDHANDLE 25\n#define HB_SOCKET_ERR_INVAL 26\n#define HB_SOCKET_ERR_PROTO 27\n#define HB_SOCKET_ERR_PROTOTYPE 28\n#define HB_SOCKET_ERR_NOFILE 29\n#define HB_SOCKET_ERR_NOBUFS 30\n#define HB_SOCKET_ERR_NOMEM 31\n#define HB_SOCKET_ERR_FAULT 32\n#define HB_SOCKET_ERR_NAMETOOLONG 33\n#define HB_SOCKET_ERR_NOENT 34\n#define HB_SOCKET_ERR_NOTDIR 35\n#define HB_SOCKET_ERR_LOOP 36\n#define HB_SOCKET_ERR_MSGSIZE 37\n#define HB_SOCKET_ERR_DESTADDRREQ 38\n#define HB_SOCKET_ERR_NOPROTOOPT 39\n#define HB_SOCKET_ERR_NOTCONN 40\n#define HB_SOCKET_ERR_SHUTDOWN 41\n#define HB_SOCKET_ERR_TOOMANYREFS 42\n#define HB_SOCKET_ERR_RESTARTSYS 43\n#define HB_SOCKET_ERR_NOSR 44\n#define HB_SOCKET_ERR_HOSTDOWN 45\n#define HB_SOCKET_ERR_HOSTUNREACH 46\n#define HB_SOCKET_ERR_NOTEMPTY 47\n#define HB_SOCKET_ERR_USERS 48\n#define HB_SOCKET_ERR_DQUOT 49\n#define HB_SOCKET_ERR_STALE 50\n#define HB_SOCKET_ERR_REMOTE 51\n#define HB_SOCKET_ERR_PROCLIM 52\n#define HB_SOCKET_ERR_DISCON 53\n#define HB_SOCKET_ERR_NOMORE 54\n#define HB_SOCKET_ERR_CANCELLED 55\n#define HB_SOCKET_ERR_INVALIDPROCTABLE 56\n#define HB_SOCKET_ERR_INVALIDPROVIDER 57\n#define HB_SOCKET_ERR_PROVIDERFAILEDINIT 58\n#define HB_SOCKET_ERR_REFUSED 59\n#define HB_SOCKET_ERR_SYSNOTREADY 60\n#define HB_SOCKET_ERR_VERNOTSUPPORTED 61\n#define HB_SOCKET_ERR_NOTINITIALISED 62\n#define HB_SOCKET_ERR_TRYAGAIN 63\n#define HB_SOCKET_ERR_HOSTNOTFOUND 64\n#define HB_SOCKET_ERR_NORECOVERY 65\n#define HB_SOCKET_ERR_NODATA 66\n#define HB_SOCKET_ERR_SYSCALLFAILURE 67\n#define HB_SOCKET_ERR_SERVICENOTFOUND 68\n#define HB_SOCKET_ERR_TYPENOTFOUND 69\n#define HB_SOCKET_ERR_OTHER 70\n\n\n#define HB_SOCKET_AF_LOCAL 1\n#define HB_SOCKET_AF_INET 2\n#define HB_SOCKET_AF_IPX 4\n#define HB_SOCKET_AF_INET6 10\n#define HB_SOCKET_AF_PACKET 17\n\n\n#define HB_SOCKET_PF_LOCAL HB_SOCKET_AF_LOCAL\n#define HB_SOCKET_PF_INET HB_SOCKET_AF_INET\n#define HB_SOCKET_PF_IPX HB_SOCKET_AF_IPX\n#define HB_SOCKET_PF_INET6 HB_SOCKET_AF_INET6\n#define HB_SOCKET_PF_PACKET HB_SOCKET_AF_PACKET\n\n\n#define HB_SOCKET_PT_STREAM 1\n#define HB_SOCKET_PT_DGRAM 2\n#define HB_SOCKET_PT_RAW 3\n#define HB_SOCKET_PT_RDM 4\n#define HB_SOCKET_PT_SEQPACKET 5\n\n\n#define HB_SOCKET_IPPROTO_IP 0 \n#define HB_SOCKET_IPPROTO_ICMP 1 \n#define HB_SOCKET_IPPROTO_IGMP 2 \n#define HB_SOCKET_IPPROTO_IPIP 4 \n#define HB_SOCKET_IPPROTO_TCP 6 \n#define HB_SOCKET_IPPROTO_EGP 8 \n#define HB_SOCKET_IPPROTO_PUP 12 \n#define HB_SOCKET_IPPROTO_UDP 17 \n#define HB_SOCKET_IPPROTO_IDP 22 \n#define HB_SOCKET_IPPROTO_DCCP 23 \n#define HB_SOCKET_IPPROTO_RDP 29 \n#define HB_SOCKET_IPPROTO_TP 29 \n#define HB_SOCKET_IPPROTO_IPV6 41 \n#define HB_SOCKET_IPPROTO_ROUTING 43 \n#define HB_SOCKET_IPPROTO_FRAGMENT 44 \n#define HB_SOCKET_IPPROTO_RSVP 46 \n#define HB_SOCKET_IPPROTO_GRE 47 \n#define HB_SOCKET_IPPROTO_ESP 50 \n#define HB_SOCKET_IPPROTO_AH 51 \n#define HB_SOCKET_IPPROTO_ICMPV6 58 \n#define HB_SOCKET_IPPROTO_NONE 59 \n#define HB_SOCKET_IPPROTO_DSTOPTS 60 \n#define HB_SOCKET_IPPROTO_ND 77 \n#define HB_SOCKET_IPPROTO_ICLFXBM 78 \n#define HB_SOCKET_IPPROTO_EON 80 \n#define HB_SOCKET_IPPROTO_MTP 92 \n#define HB_SOCKET_IPPROTO_ENCAP 98 \n#define HB_SOCKET_IPPROTO_PIM 103 \n#define HB_SOCKET_IPPROTO_COMP 108 \n#define HB_SOCKET_IPPROTO_PGM 113 \n#define HB_SOCKET_IPPROTO_L2TP 115 \n#define HB_SOCKET_IPPROTO_SCTP 132 \n#define HB_SOCKET_IPPROTO_RAW 255 \n\n\n#define HB_SOCKET_MSG_OOB 0x01 \n#define HB_SOCKET_MSG_PEEK 0x02 \n#define HB_SOCKET_MSG_DONTROUTE 0x04 \n#define HB_SOCKET_MSG_WAITALL 0x08 \n\n\n#define HB_SOCKET_SHUT_RD 0\n#define HB_SOCKET_SHUT_WR 1\n#define HB_SOCKET_SHUT_RDWR 2\n\n\n#define HB_SOCKET_IFF_UP 0x0001 \n#define HB_SOCKET_IFF_BROADCAST 0x0002 \n#define HB_SOCKET_IFF_LOOPBACK 0x0004 \n#define HB_SOCKET_IFF_POINTOPOINT 0x0008 \n#define HB_SOCKET_IFF_MULTICAST 0x0010 \n\n\n#define HB_SOCKET_IFINFO_FAMILY 1 \n#define HB_SOCKET_IFINFO_NAME 2 \n#define HB_SOCKET_IFINFO_FLAGS 3 \n#define HB_SOCKET_IFINFO_ADDR 4 \n#define HB_SOCKET_IFINFO_NETMASK 5 \n#define HB_SOCKET_IFINFO_BROADCAST 6 \n#define HB_SOCKET_IFINFO_P2PADDR 7 \n#define HB_SOCKET_IFINFO_HWADDR 8 \n#define HB_SOCKET_IFINFO_LEN 8\n\n\n#define HB_SOCKET_ADINFO_FAMILY 1\n#define HB_SOCKET_ADINFO_ADDRESS 2 \n#define HB_SOCKET_ADINFO_PATH 2 \n#define HB_SOCKET_ADINFO_PORT 3 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Header file for contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/ctvideo.ch. Defines 8 constants including: _CTVIDEO_CH, VCARD_MONOCHROME, VCARD_CGA, VCARD_HERCULES, VCARD_MCGA"}, {"role": "assistant", "content": "#ifndef _CTVIDEO_CH\n#define _CTVIDEO_CH\n\n#define VCARD_MONOCHROME 1 \n#define VCARD_CGA 2 \n#define VCARD_HERCULES 5 \n#define VCARD_MCGA 10 \n#define VCARD_PGA 19 \n#define VCARD_EGA 55 \n#define VCARD_VGA 127 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/aliasrt.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n USE test\n\n REPLACE Age WITH 1\n ? FIELD->Age\n\n REPLACE 1->Age WITH 2\n ? FIELD->Age\n\n\n REPLACE TEST->Age WITH 4\n ? FIELD->Age\n\n TEST->Age := 5\n ? FIELD->Age\n\n TEST->( FieldPut( FieldPos( \"AGE\" ), 6 ) )\n ? FIELD->Age\n\n dbCloseArea()\n\n SELECT 2\n\n USE test\n\n\n ? ( \"B\" )->FIRST\n ? ( \"2\" )->FIRST\n ? 2->FIRST\n ? B->FIRST\n\n Inkey( 0 )\n\n\n ? Select()\n ? Select( 1 )\n ? Select( 2 )\n\n ? \"0\", Select( \"0\" )\n ? \"1\", Select( \"1\" )\n ? \"2\", Select( \"2\" )\n ? \"A\", Select( \"A\" )\n ? \"B\", Select( \"B\" )\n ? \"C\", Select( \"C\" )\n ? \"D\", Select( \"D\" )\n ? \"E\", Select( \"E\" )\n ? \"F\", Select( \"F\" )\n ? \"G\", Select( \"G\" )\n ? \"H\", Select( \"H\" )\n ? \"I\", Select( \"I\" )\n ? \"J\", Select( \"J\" )\n ? \"K\", Select( \"K\" )\n ? \"L\", Select( \"L\" )\n ? \"M\", Select( \"M\" )\n ? \"N\", Select( \"N\" )\n ? \"O\", Select( \"O\" )\n ? \"P\", Select( \"P\" )\n ? \"Q\", Select( \"Q\" )\n ? \"R\", Select( \"R\" )\n ? \"S\", Select( \"S\" )\n ? \"T\", Select( \"T\" )\n ? \"U\", Select( \"U\" )\n ? \"V\", Select( \"V\" )\n ? \"W\", Select( \"W\" )\n ? \"X\", Select( \"X\" )\n ? \"Y\", Select( \"Y\" )\n ? \"Z\", Select( \"Z\" )\n\n Inkey( 0 )\n\n ? \"\" , dbSelectArea() , Select()\n ? \"\" , dbSelectArea( NIL ), Select()\n\n\n ? \"0\" , dbSelectArea( \"0\" ), Select()\n ? \"1\" , dbSelectArea( \"1\" ), Select()\n ? \"2\" , dbSelectArea( \"2\" ), Select()\n ? \"A\" , dbSelectArea( \"A\" ), Select()\n ? \"B\" , dbSelectArea( \"B\" ), Select()\n ? \"C\" , dbSelectArea( \"C\" ), Select()\n ? \"D\" , dbSelectArea( \"D\" ), Select()\n ? \"E\" , dbSelectArea( \"E\" ), Select()\n ? \"F\" , dbSelectArea( \"F\" ), Select()\n ? \"G\" , dbSelectArea( \"G\" ), Select()\n ? \"H\" , dbSelectArea( \"H\" ), Select()\n ? \"I\" , dbSelectArea( \"I\" ), Select()\n ? \"J\" , dbSelectArea( \"J\" ), Select()\n ? \"K\" , dbSelectArea( \"K\" ), Select()\n\n ? \"M\" , dbSelectArea( \"M\" ), Select()\n\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/ctscan.ch. Defines 10 constants including: KS_DISABLE, KS_A, KS_B, KS_C, KS_D. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#define KS_DISABLE hb_BChar( 255 ) + hb_BChar( 255 )\n\n#define KS_A hb_BChar( 65 ) + hb_BChar( 16 )\n#define KS_B hb_BChar( 66 ) + hb_BChar( 48 )\n#define KS_C hb_BChar( 67 ) + hb_BChar( 46 )\n#define KS_D hb_BChar( 68 ) + hb_BChar( 32 )\n#define KS_E hb_BChar( 69 ) + hb_BChar( 18 )\n#define KS_F hb_BChar( 70 ) + hb_BChar( 33 )\n#define KS_G hb_BChar( 71 ) + hb_BChar( 34 )\n#define KS_H hb_BChar( 72 ) + hb_BChar( 35 )\n#define KS_I hb_BChar( 73 ) + hb_BChar( 23 )\n#define KS_J hb_BChar( 74 ) + hb_BChar( 36 )\n#define KS_K hb_BChar( 75 ) + hb_BChar( 37 )\n#define KS_L hb_BChar( 76 ) + hb_BChar( 38 )\n#define KS_M hb_BChar( 77 ) + hb_BChar( 39 )\n#define KS_N hb_BChar( 78 ) + hb_BChar( 49 )\n#define KS_O hb_BChar( 79 ) + hb_BChar( 24 )\n#define KS_P hb_BChar( 80 ) + hb_BChar( 25 )\n#define KS_Q hb_BChar( 81 ) + hb_BChar( 30 )\n#define KS_R hb_BChar( 82 ) + hb_BChar( 19 )\n#define KS_S hb_BChar( 83 ) + hb_BChar( 31 )\n#define KS_T hb_BChar( 84 ) + hb_BChar( 20 )\n#define KS_U hb_BChar( 85 ) + hb_BChar( 22 )\n#define KS_V hb_BChar( 86 ) + hb_BChar( 47 )\n#define KS_W hb_BChar( 87 ) + hb_BChar( 44 )\n#define KS_X hb_BChar( 88 ) + hb_BChar( 45 )\n#define KS_Y hb_BChar( 89 ) + hb_BChar( 21 )\n#define KS_Z hb_BChar( 90 ) + hb_BChar( 17 )\n\n#define KS_a hb_BChar( 97 ) + hb_BChar( 16 )\n#define KS_b hb_BChar( 98 ) + hb_BChar( 48 )\n#define KS_c hb_BChar( 99 ) + hb_BChar( 46 )\n#define KS_d hb_BChar( 100 ) + hb_BChar( 32 )\n#define KS_e hb_BChar( 101 ) + hb_BChar( 18 )\n#define KS_f hb_BChar( 102 ) + hb_BChar( 33 )\n#define KS_g hb_BChar( 103 ) + hb_BChar( 34 )\n#define KS_h hb_BChar( 104 ) + hb_BChar( 35 )\n#define KS_i hb_BChar( 105 ) + hb_BChar( 23 )\n#define KS_j hb_BChar( 106 ) + hb_BChar( 36 )\n#define KS_k hb_BChar( 107 ) + hb_BChar( 37 )\n#define KS_l hb_BChar( 108 ) + hb_BChar( 38 )\n#define KS_m hb_BChar( 109 ) + hb_BChar( 39 )\n#define KS_n hb_BChar( 110 ) + hb_BChar( 49 )\n#define KS_o hb_BChar( 111 ) + hb_BChar( 24 )\n#define KS_p hb_BChar( 112 ) + hb_BChar( 25 )\n#define KS_q hb_BChar( 113 ) + hb_BChar( 30 )\n#define KS_r hb_BChar( 114 ) + hb_BChar( 19 )\n#define KS_s hb_BChar( 115 ) + hb_BChar( 31 )\n#define KS_t hb_BChar( 116 ) + hb_BChar( 20 )\n#define KS_u hb_BChar( 117 ) + hb_BChar( 22 )\n#define KS_v hb_BChar( 118 ) + hb_BChar( 47 )\n#define KS_w hb_BChar( 119 ) + hb_BChar( 44 )\n#define KS_x hb_BChar( 120 ) + hb_BChar( 45 )\n#define KS_y hb_BChar( 121 ) + hb_BChar( 21 )\n#define KS_z hb_BChar( 122 ) + hb_BChar( 17 )\n\n#define KS_1 hb_BChar( 49 ) + hb_BChar( 2 )\n#define KS_2 hb_BChar( 50 ) + hb_BChar( 3 )\n#define KS_3 hb_BChar( 51 ) + hb_BChar( 4 )\n#define KS_4 hb_BChar( 52 ) + hb_BChar( 5 )\n#define KS_5 hb_BChar( 53 ) + hb_BChar( 6 )\n#define KS_6 hb_BChar( 54 ) + hb_BChar( 7 )\n#define KS_7 hb_BChar( 55 ) + hb_BChar( 8 )\n#define KS_8 hb_BChar( 56 ) + hb_BChar( 9 )\n#define KS_9 hb_BChar( 57 ) + hb_BChar( 10 )\n#define KS_0 hb_BChar( 48 ) + hb_BChar( 11 )\n\n#define KS_DOT hb_BChar( 46 ) + hb_BChar( 52 )\n#define KS_COMMA hb_BChar( 44 ) + hb_BChar( 51 )\n\n#define KS_CTRL_A hb_BChar( 1 ) + hb_BChar( 30 )\n#define KS_CTRL_B hb_BChar( 2 ) + hb_BChar( 48 )\n#define KS_CTRL_C hb_BChar( 3 ) + hb_BChar( 46 )\n#define KS_CTRL_D hb_BChar( 4 ) + hb_BChar( 32 )\n#define KS_CTRL_E hb_BChar( 5 ) + hb_BChar( 18 )\n#define KS_CTRL_F hb_BChar( 6 ) + hb_BChar( 33 )\n#define KS_CTRL_G hb_BChar( 7 ) + hb_BChar( 34 )\n#define KS_CTRL_H hb_BChar( 8 ) + hb_BChar( 35 )\n#define KS_CTRL_I hb_BChar( 9 ) + hb_BChar( 23 )\n#define KS_CTRL_M hb_BChar( 13 ) + hb_BChar( 50 )\n#define KS_CTRL_N hb_BChar( 14 ) + hb_BChar( 49 )\n#define KS_CTRL_R hb_BChar( 18 ) + hb_BChar( 19 )\n#define KS_CTRL_S hb_BChar( 19 ) + hb_BChar( 31 )\n#define KS_CTRL_T hb_BChar( 20 ) + hb_BChar( 20 )\n#define KS_CTRL_U hb_BChar( 21 ) + hb_BChar( 22 )\n#define KS_CTRL_V hb_BChar( 22 ) + hb_BChar( 47 )\n#define KS_CTRL_W hb_BChar( 23 ) + hb_BChar( 17 )\n#define KS_CTRL_X hb_BChar( 24 ) + hb_BChar( 45 )\n#define KS_CTRL_Y hb_BChar( 25 ) + hb_BChar( 21 )\n#define KS_CTRL_Z hb_BChar( 26 ) + hb_BChar( 44 )\n\n#define KS_ALT_A hb_BChar( 0 ) + hb_BChar( 30 )\n#define KS_ALT_B hb_BChar( 0 ) + hb_BChar( 48 )\n#define KS_ALT_C hb_BChar( 0 ) + hb_BChar( 46 )\n#define KS_ALT_D hb_BChar( 0 ) + hb_BChar( 32 )\n#define KS_ALT_E hb_BChar( 0 ) + hb_BChar( 18 )\n#define KS_ALT_F hb_BChar( 0 ) + hb_BChar( 33 )\n#define KS_ALT_G hb_BChar( 0 ) + hb_BChar( 34 )\n#define KS_ALT_H hb_BChar( 0 ) + hb_BChar( 35 )\n#define KS_ALT_I hb_BChar( 0 ) + hb_BChar( 23 )\n#define KS_ALT_J hb_BChar( 0 ) + hb_BChar( 36 )\n#define KS_ALT_K hb_BChar( 0 ) + hb_BChar( 37 )\n#define KS_ALT_L hb_BChar( 0 ) + hb_BChar( 38 )\n#define KS_ALT_M hb_BChar( 0 ) + hb_BChar( 50 )\n#define KS_ALT_N hb_BChar( 0 ) + hb_BChar( 49 )\n#define KS_ALT_O hb_BChar( 0 ) + hb_BChar( 24 )\n#define KS_ALT_P hb_BChar( 0 ) + hb_BChar( 25 )\n#define KS_ALT_Q hb_BChar( 0 ) + hb_BChar( 16 )\n#define KS_ALT_R hb_BChar( 0 ) + hb_BChar( 19 )\n#define KS_ALT_S hb_BChar( 0 ) + hb_BChar( 31 )\n#define KS_ALT_T hb_BChar( 0 ) + hb_BChar( 20 )\n#define KS_ALT_U hb_BChar( 0 ) + hb_BChar( 22 )\n#define KS_ALT_V hb_BChar( 0 ) + hb_BChar( 47 )\n#define KS_ALT_W hb_BChar( 0 ) + hb_BChar( 17 )\n#define KS_ALT_X hb_BChar( 0 ) + hb_BChar( 45 )\n#define KS_ALT_Y hb_BChar( 0 ) + hb_BChar( 21 )\n#define KS_ALT_Z hb_BChar( 0 ) + hb_BChar( 44 )\n\n#define KS_ALT_1 hb_BChar( 0 ) + hb_BChar( 120 )\n#define KS_ALT_2 hb_BChar( 0 ) + hb_BChar( 121 )\n#define KS_ALT_3 hb_BChar( 0 ) + hb_BChar( 122 )\n#define KS_ALT_4 hb_BChar( 0 ) + hb_BChar( 123 )\n#define KS_ALT_5 hb_BChar( 0 ) + hb_BChar( 124 )\n#define KS_ALT_6 hb_BChar( 0 ) + hb_BChar( 125 )\n#define KS_ALT_7 hb_BChar( 0 ) + hb_BChar( 126 )\n#define KS_ALT_8 hb_BChar( 0 ) + hb_BChar( 127 )\n#define KS_ALT_9 hb_BChar( 0 ) + hb_BChar( 128 )\n#define KS_ALT_0 hb_BChar( 0 ) + hb_BChar( 129 )\n\n#define KS_F1 hb_BChar( 0 ) + hb_BChar( 59 )\n#define KS_F2 hb_BChar( 0 ) + hb_BChar( 60 )\n#define KS_F3 hb_BChar( 0 ) + hb_BChar( 61 )\n#define KS_F4 hb_BChar( 0 ) + hb_BChar( 62 )\n#define KS_F5 hb_BChar( 0 ) + hb_BChar( 63 )\n#define KS_F6 hb_BChar( 0 ) + hb_BChar( 64 )\n#define KS_F7 hb_BChar( 0 ) + hb_BChar( 65 )\n#define KS_F8 hb_BChar( 0 ) + hb_BChar( 66 )\n#define KS_F9 hb_BChar( 0 ) + hb_BChar( 67 )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/color.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"color.ch\"\n\nPROCEDURE Main()\n\n LOCAL cColor := \"r+/bg*,rg*/ng+,w/n,b+/w,rg/b,w+/n*\"\n\n ? \"original set \", Set( _SET_COLOR )\n ? \"should match \", SetColor( cColor )\n ? \"input 1 \", cColor\n ? \"return \", SetColor( \"1/7,9/15\" )\n ? \"input 2 \", \"1/7,9/15\"\n ? \"return \", SetColor()\n ? \"final set \", Set( _SET_COLOR )\n\n SetColor( \"BG/N, N/BG\" )\n ? \"Hello1\"\n ColorSelect( CLR_ENHANCED )\n ? \"Hello2\"\n ColorSelect( CLR_STANDARD )\n ? \"Hello3\"\n ColorSelect( CLR_ENHANCED )\n SetColor( \"GR/N, N/GR\" )\n ? \"Hello4\"\n ColorSelect( CLR_ENHANCED )\n ? \"Hello5\"\n ColorSelect( CLR_STANDARD )\n ? \"Hello6\"\n SetColor( \"B/N, N/B\" )\n ? \"Hello7\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'hbodbc' (ODBC database connectivity): contrib/hbodbc/sql.ch. Defines 10 constants including: HBODBC_CH_, SQL_INVALID_HANDLE, SQL_ERROR, SQL_SUCCESS, SQL_SUCCESS_WITH_INFO. Defines keyboard input constants"}, {"role": "assistant", "content": "#ifndef HBODBC_CH_\n#define HBODBC_CH_\n\n\n#define SQL_INVALID_HANDLE -2\n#define SQL_ERROR -1\n#define SQL_SUCCESS 0\n#define SQL_SUCCESS_WITH_INFO 1\n#define SQL_STILL_EXECUTING 2\n#define SQL_NO_DATA 100\n#define SQL_NO_DATA_FOUND SQL_NO_DATA\n#define SQL_NEED_DATA 99\n\n\n#define SQL_SUCCEEDED( rc ) ( hb_bitAnd( rc, hb_bitNot( SQL_SUCCESS_WITH_INFO ) ) == SQL_SUCCESS )\n\n\n#define SQL_CHAR 1\n#define SQL_NUMERIC 2\n#define SQL_DECIMAL 3\n#define SQL_INTEGER 4\n#define SQL_SMALLINT 5\n#define SQL_FLOAT 6\n#define SQL_REAL 7\n#define SQL_DOUBLE 8\n#define SQL_DATE 9\n#define SQL_TIME 10\n#define SQL_TIMESTAMP 11\n#define SQL_VARCHAR 12\n#define SQL_TYPE_DATE 91\n#define SQL_TYPE_TIME 92\n#define SQL_TYPE_TIMESTAMP 93\n#define SQL_LONGVARCHAR -1\n#define SQL_BINARY -2\n#define SQL_VARBINARY -3\n#define SQL_LONGVARBINARY -4\n#define SQL_BIGINT -5\n#define SQL_TINYINT -6\n#define SQL_BIT -7\n#define SQL_WCHAR -8\n#define SQL_WVARCHAR -9\n#define SQL_NVARCHAR SQL_WVARCHAR\n#define SQL_WLONGVARCHAR -10\n\n#define SQL_TYPE_NULL 0\n#define SQL_TYPE_MIN SQL_WLONGVARCHAR\n#define SQL_TYPE_MAX SQL_TYPE_TIMESTAMP\n#define SQL_ALL_TYPES 0\n\n\n#define SQL_NO_NULLS 0\n#define SQL_NULLABLE 1\n#define SQL_NULLABLE_UNKNOWN 2\n\n\n#define SQL_NULL_DATA -1\n#define SQL_DATA_AT_EXEC -2\n#define SQL_NTS -3\n\n\n#define SQL_CLOSE 0\n#define SQL_DROP 1\n#define SQL_UNBIND 2\n#define SQL_RESET_PARAMS 3\n\n\n#define SQL_COLUMN_COUNT 0\n#define SQL_COLUMN_NAME 1\n#define SQL_COLUMN_TYPE 2\n#define SQL_COLUMN_LENGTH 3\n#define SQL_COLUMN_PRECISION 4\n#define SQL_COLUMN_SCALE 5\n#define SQL_COLUMN_DISPLAY_SIZE 6\n#define SQL_COLUMN_NULLABLE 7\n#define SQL_COLUMN_UNSIGNED 8\n#define SQL_COLUMN_MONEY 9\n#define SQL_COLUMN_UPDATABLE 10\n#define SQL_COLUMN_AUTO_INCREMENT 11\n#define SQL_COLUMN_CASE_SENSITIVE 12\n#define SQL_COLUMN_SEARCHABLE 13\n#define SQL_COLUMN_TYPE_NAME 14\n#define SQL_COLUMN_TABLE_NAME 15\n#define SQL_COLUMN_OWNER_NAME 16\n#define SQL_COLUMN_QUALIFIER_NAME 17\n#define SQL_COLUMN_LABEL 18\n#define SQL_COLATT_OPT_MAX SQL_COLUMN_LABEL\n#define SQL_COLUMN_DRIVER_START 1000\n\n#define SQL_COLATT_OPT_MIN SQL_COLUMN_COUNT\n\n\n#define SQL_ATTR_READONLY 0\n#define SQL_ATTR_WRITE 1\n#define SQL_ATTR_READWRITE_UNKNOWN 2\n\n\n#define SQL_UNSEARCHABLE 0\n#define SQL_LIKE_ONLY 1\n#define SQL_ALL_EXCEPT_LIKE 2\n#define SQL_SEARCHABLE 3\n\n\n#define SQL_FETCH_NEXT 1\n#define SQL_FETCH_FIRST 2\n#define SQL_FETCH_LAST 3\n#define SQL_FETCH_PRIOR 4\n#define SQL_FETCH_ABSOLUTE 5\n#define SQL_FETCH_RELATIVE 6\n#define SQL_FETCH_BOOKMARK 8\n\n\n#define SQL_AUTOCOMMIT_OFF 0\n#define SQL_AUTOCOMMIT_ON 1\n#define SQL_AUTOCOMMIT 102\n\n#define SQL_INFO_FIRST 0\n#define SQL_ACTIVE_CONNECTIONS 0\n#define SQL_ACTIVE_STATEMENTS 1\n#define SQL_DATA_SOURCE_NAME 2\n#define SQL_DRIVER_HDBC 3\n#define SQL_DRIVER_HENV 4\n#define SQL_DRIVER_HSTMT 5\n#define SQL_DRIVER_NAME 6\n#define SQL_DRIVER_VER 7\n#define SQL_FETCH_DIRECTION 8\n#define SQL_ODBC_API_CONFORMANCE 9\n#define SQL_ODBC_VER 10\n#define SQL_ROW_UPDATES 11\n#define SQL_ODBC_SAG_CLI_CONFORMANCE 12\n#define SQL_SERVER_NAME 13\n#define SQL_SEARCH_PATTERN_ESCAPE 14\n#define SQL_ODBC_SQL_CONFORMANCE 15\n\n#define SQL_DATABASE_NAME 16\n#define SQL_DBMS_NAME 17\n#define SQL_DBMS_VER 18\n\n#define SQL_ACCESSIBLE_TABLES 19\n#define SQL_ACCESSIBLE_PROCEDURES 20\n#define SQL_PROCEDURES 21\n#define SQL_CONCAT_NULL_BEHAVIOR 22\n#define SQL_CURSOR_COMMIT_BEHAVIOR 23\n#define SQL_CURSOR_ROLLBACK_BEHAVIOR 24\n#define SQL_DATA_SOURCE_READ_ONLY 25\n#define SQL_DEFAULT_TXN_ISOLATION 26\n#define SQL_EXPRESSIONS_IN_ORDERBY 27\n#define SQL_IDENTIFIER_CASE 28\n#define SQL_IDENTIFIER_QUOTE_CHAR 29\n#define SQL_MAX_COLUMN_NAME_LEN 30\n#define SQL_MAX_CURSOR_NAME_LEN 31\n#define SQL_MAX_OWNER_NAME_LEN 32\n#define SQL_MAX_PROCEDURE_NAME_LEN 33\n#define SQL_MAX_QUALIFIER_NAME_LEN 34\n#define SQL_MAX_TABLE_NAME_LEN 35\n#define SQL_MULT_RESULT_SETS 36\n#define SQL_MULTIPLE_ACTIVE_TXN 37\n#define SQL_OUTER_JOINS 38\n#define SQL_OWNER_TERM 39\n#define SQL_PROCEDURE_TERM 40\n#define SQL_QUALIFIER_NAME_SEPARATOR 41\n#define SQL_QUALIFIER_TERM 42\n#define SQL_SCROLL_CONCURRENCY 43\n#define SQL_SCROLL_OPTIONS 44\n#define SQL_TABLE_TERM 45\n#define SQL_TXN_CAPABLE 46\n#define SQL_USER_NAME 47\n\n#define SQL_CONVERT_FUNCTIONS 48\n#define SQL_NUMERIC_FUNCTIONS 49\n#define SQL_STRING_FUNCTIONS 50\n#define SQL_SYSTEM_FUNCTIONS 51\n#define SQL_TIMEDATE_FUNCTIONS 52\n\n#define SQL_CONVERT_BIGINT 53\n#define SQL_CONVERT_BINARY 54\n#define SQL_CONVERT_BIT 55\n#define SQL_CONVERT_CHAR 56\n#define SQL_CONVERT_DATE 57\n#define SQL_CONVERT_DECIMAL 58\n#define SQL_CONVERT_DOUBLE 59\n#define SQL_CONVERT_FLOAT 60\n#define SQL_CONVERT_INTEGER 61\n#define SQL_CONVERT_LONGVARCHAR 62\n#define SQL_CONVERT_NUMERIC 63\n#define SQL_CONVERT_REAL 64\n#define SQL_CONVERT_SMALLINT 65\n#define SQL_CONVERT_TIME 66\n#define SQL_CONVERT_TIMESTAMP 67\n#define SQL_CONVERT_TINYINT 68\n#define SQL_CONVERT_VARBINARY 69\n#define SQL_CONVERT_VARCHAR 70\n#define SQL_CONVERT_LONGVARBINARY 71\n\n#define SQL_TXN_ISOLATION_OPTION 72\n#define SQL_ODBC_SQL_OPT_IEF 73\n\n#define SQL_QUERY_TIMEOUT 0\n#define SQL_MAX_ROWS 1\n#define SQL_NOSCAN 2\n#define SQL_MAX_LENGTH 3\n#define SQL_ASYNC_ENABLE 4\n#define SQL_BIND_TYPE 5\n\n\n#define SQL_HANDLE_ENV 1\n#define SQL_HANDLE_DBC 2\n#define SQL_HANDLE_STMT 3\n#define SQL_HANDLE_DESC 4\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/oletst1.prg. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\n#define NETSERVER \"127.0.0.1\"\n#define NETPORT 2941\n#define NETPASSWD \"topsecret\"\n\nPROCEDURE Main()\n\n LOCAL oObject\n\n oObject := win_oleCreateObject( \"MyOleRPCServer\" )\n\n IF ! Empty( oObject )\n IF oObject:connect( NETSERVER, NETPORT,, NETPASSWD )\n ? \"Connected to the server:\", NETSERVER\n \n ? oObject:Upper( \"hello world !!!\" )\n ? \"SERVER DATE:\", oObject:Date()\n ? \"SERVER TIME:\", oObject:Time()\n ? \"SERVER DATETIME:\", oObject:hb_DateTime()\n ELSE\n ? \"Cannot connect to the server:\", NETSERVER\n ENDIF\n ELSE\n ? \"Can not access 'MyOleRPCServer' OLE server.\"\n ENDIF\n\n WAIT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour contribution module 'gtwvw' (): contrib/gtwvw/tests/prog1.prg. Provides 10 functions including: xBrowse1, DbSkipBlock, TBNext, TBPrev, VouBlockField. Contains procedures: Main, xGet1. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"gtwvw\"\n\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\nSTATIC s_zwin := {}\nSTATIC s_cStdColor := \"N/W,N/GR*,,,N/W*\"\n\nPROCEDURE Main()\n\n LOCAL i, j\n LOCAL lMainCoord\n\n#if defined( __HBSCRIPT__HBSHELL ) .AND. defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVW\" )\n#endif\n\n lMainCoord := wvw_SetMainCoord( .T. )\n\n wvw_SetCodepage( , 255 )\n\n SET SCOREBOARD OFF\n SetColor( s_cStdColor )\n SetCursor( SC_NONE )\n CLS\n @ 0, 0 SAY PadC( \"This is the Main Window\", MaxCol() + 1 )\n\n \n DispBegin()\n FOR i := 1 TO MaxRow() - 1\n FOR j := 0 TO MaxCol()\n hb_DispOutAtBox( i, j, hb_UTF8ToStrBox( \"▒\" ) )\n NEXT\n NEXT\n DispEnd()\n\n lboxmessage( \"Welcome to our test program.\" + hb_eol() + ;\n \"This program will show typical GET and BROWSE dialogs \" + ;\n \"with brief help on the bottom of the screen.\" )\n xGet1()\n xBrowse1()\n lboxmessage( \"That's all folks\" )\n\n \n SetCursor( SC_NORMAL )\n\n RETURN\n\nPROCEDURE xGet1()\n\n LOCAL cName := PadR( \"Name\", 20 )\n LOCAL cAddr := PadR( \"Address\", 25 )\n LOCAL cPhone := PadR( \"Phone\", 15 )\n LOCAL cFax := PadR( \"Fax\", 15 )\n LOCAL lDone := .F.\n LOCAL getlist := {}\n LOCAL oldCurs := SetCursor( SC_NORMAL )\n\n znewwindow( hb_UTF8ToStrBox( \"┌─┐│┘─└│\" ), 10, 20, 22, 59, \"Some Window\" )\n\n\n DO WHILE ! lDone\n @ 12, 22 SAY \"Name : \" GET cName PICT \"@!K\" WHEN lMessage( \"Please enter your name\" )\n @ 14, 22 SAY \"Address : \" GET cAddr PICT \"@!K\" WHEN lMessage( \"Please enter your address\" )\n @ 16, 22 SAY \"Phone : \" GET cPhone PICT \"@K\" WHEN lMessage( \"Please enter your phone number\" )\n @ 18, 22 SAY \"Fax : \" GET cFax PICT \"@K\" WHEN lMessage( \"Please enter your fax number\" )\n READ\n\n lMessage( \"\" )\n lDone := lyesno( \"Done?\" )\n ENDDO\n\n zrevwindow()\n\n SetCursor( oldCurs )\n\n RETURN \n\n\nFUNCTION xBrowse1()\n\n LOCAL nKey, bBlock, oBrowse, i\n LOCAL lEnd := .F.\n LOCAL info_\n LOCAL nTop := 6\n LOCAL nLeft := 3\n LOCAL nBottom := MaxRow() - 2\n LOCAL nRight := MaxCol() - 3\n LOCAL nCursor := SetCursor( SC_NONE )\n\n USE \"..\\..\\..\\tests\\test\" NEW\n IF NetErr()\n RETURN NIL\n ENDIF\n info_ := dbStruct()\n\n SetColor( \"N/W*,N/GR*,,,N/W* \" )\n oBrowse := TBrowseNew( nTop + 1, nLeft + 1, nBottom - 1, nRight - 1 )\n\n oBrowse:ColSep := hb_UTF8ToStrBox( \"│\" )\n oBrowse:HeadSep := hb_UTF8ToStrBox( \"═\" )\n oBrowse:GoTopBlock := {|| dbGoTop() }\n oBrowse:GoBottomBlock := {|| dbGoBottom() }\n oBrowse:SkipBlock := {| nSkip | dbSkipBlock( nSkip, oBrowse ) }\n\n FOR i := 1 TO Len( info_ )\n bBlock := VouBlockField( i )\n oBrowse:AddColumn( TBColumnNew( info_[ i, 1 ], bBlock ) )\n NEXT\n\n oBrowse:configure()\n\n znewwindow( hb_UTF8ToStrBox( \"┌─┐│┘─└│\" ), nTop, nLeft, nBottom, nRight, \"test.dbf\" )\n\n WHILE ! lEnd\n oBrowse:ForceStable()\n\n lMessage( \"Record #\" + hb_ntos( RecNo() ) )\n\n nKey := Inkey( 0 )\n\n DO CASE\n CASE nKey == K_ESC .OR. nKey == K_ENTER\n lEnd := lYesNo( \"Done?\" )\n CASE nKey == K_DOWN\n oBrowse:Down()\n CASE nKey == K_UP\n oBrowse:Up()\n CASE nKey == K_LEFT\n oBrowse:Left()\n CASE nKey == K_RIGHT\n oBrowse:Right()\n CASE nKey == K_PGDN\n oBrowse:pageDown()\n CASE nKey == K_PGUP\n oBrowse:pageUp()\n CASE nKey == K_CTRL_PGUP\n oBrowse:goTop()\n CASE nKey == K_CTRL_PGDN\n oBrowse:goBottom()\n CASE nKey == K_HOME\n oBrowse:home()\n CASE nKey == K_END\n oBrowse:end()\n CASE nKey == K_CTRL_LEFT\n oBrowse:panLeft()\n CASE nKey == K_CTRL_RIGHT\n oBrowse:panRight()\n CASE nKey == K_CTRL_HOME\n oBrowse:panHome()\n CASE nKey == K_CTRL_END\n oBrowse:panEnd()\n ENDCASE\n ENDDO\n\n lMessage( \"\" )\n\n zrevwindow()\n\n \n SetCursor( nCursor )\n\n dbCloseArea()\n\n RETURN NIL\n\n\nSTATIC FUNCTION DbSkipBlock( n, oTbr )\n\n LOCAL nSkipped := 0\n\n HB_SYMBOL_UNUSED( oTbr )\n\n IF n == 0\n dbSkip( 0 )\n ELSEIF n > 0\n DO WHILE nSkipped != n .AND. TBNext( oTbr )\n nSkipped++\n ENDDO\n ELSE\n DO WHILE nSkipped != n .AND. TBPrev( oTbr )\n nSkipped--\n ENDDO\n ENDIF\n\n RETURN nSkipped\n\n\nSTATIC FUNCTION TBNext( oTbr )\n\n LOCAL nSaveRecNum := RecNo()\n LOCAL lMoved := .T.\n\n HB_SYMBOL_UNUSED( oTbr )\n\n IF Eof()\n lMoved := .F.\n ELSE\n dbSkip( 1 )\n IF Eof()\n lMoved := .F.\n dbGoto( nSaveRecNum )\n ENDIF\n ENDIF\n\n RETURN lMoved\n\n\nSTATIC FUNCTION TBPrev( oTbr )\n\n LOCAL nSaveRecNum := RecNo()\n LOCAL lMoved := .T.\n\n HB_SYMBOL_UNUSED( oTbr )\n\n dbSkip( -1 )\n IF Bof()\n dbGoto( nSaveRecNum )\n lMoved := .F.\n ENDIF\n\n RETURN lMoved\n\n\nSTATIC FUNCTION VouBlockField( i )\n\n RETURN {|| FieldGet( i ) }\n\n\nFUNCTION lMessage( cMsg )\n\n \n LOCAL cOldColor := SetColor( s_cStdColor )\n @ MaxRow(), 0 SAY PadC( cMsg, MaxCol() + 1 )\n SetColor( cOldColor )\n\n RETURN .T.\n\nFUNCTION lYesNo( cMsg )\n\n \n LOCAL nTopLine, ;\n nLeft := 5, ;\n nBotLine := MaxRow() - 2, ;\n nRight := MaxCol() - 5\n LOCAL nChoice, nWidth\n LOCAL oldCurs := SetCursor( SC_NONE )\n LOCAL oldColor := SetColor( s_cStdColor )\n\n hb_default( @cMsg, \"Please Confirm\" )\n\n cmsg := \" \" + AllTrim( cmsg ) + \" \"\n nWidth := Max( Len( cmsg ), Len( \"Yes\" ) )\n nTopLine := nBotLine - 2 - 1\n\n nLeft := Max( nLeft, ( ( nRight + nLeft )\n znewwindow( hb_UTF8ToStrBox( \"┌─┐│┘─└│\" ), nTopLine, nLeft, nBotLine, nRight, cMsg )\n\n @ nTopLine + 1, nLeft + 1 PROMPT PadR( \"Yes\", nWidth )\n @ nTopLine + 2, nLeft + 1 PROMPT PadR( \"No\", nWidth )\n MENU TO nChoice\n\n \n zrevwindow()\n\n SetCursor( oldCurs )\n SetColor( oldColor )\n\n RETURN nChoice == 1\n\nFUNCTION lBoxMessage( cMsg, cTitle )\n\n LOCAL nTopLine, ;\n nLeft := 5, ;\n nBotLine := MaxRow() - 2, ;\n nRight := MaxCol() - 5\n LOCAL nwidth, nmaxwidth, i, nNumLines, cAline\n LOCAL oldCurs := SetCursor( SC_NONE )\n LOCAL oldColor := SetColor( s_cStdColor )\n\n hb_default( @cTitle, \"Info\" )\n\n cmsg := AllTrim( cmsg )\n nNumLines := MLCount( cmsg, ( nright - nleft ) - 1 )\n nWidth := iif( nNumLines < 2, Len( cmsg ), nRight - nLeft - 1 )\n nTopLine := nBotLine - nNumLines - 1\n IF nTopLine < 0 \n nNumLines += nTopLine\n nTopLine := 0\n ENDIF\n\n nMaxWidth := 0\n FOR i := 1 TO nNumLines\n nMaxWidth := Max( nMaxWidth, Len( RTrim( MemoLine( cmsg, nwidth, i ) ) ) )\n NEXT\n\n nLeft := Max( nLeft, Int( ( ( nRight + nLeft ) / 2 ) - ( nMaxWidth / 2 ) - 1 ) )\n nRight := nLeft + nMaxWidth + 1\n\n \n znewwindow( hb_UTF8ToStrBox( \"┌─┐│┘─└│\" ), nTopLine, nLeft, nBotLine, nRight, cTitle )\n DispBegin()\n FOR i := 1 TO nNumLines\n cAline := MemoLine( cMsg, nWidth, i )\n hb_DispOutAt( nTopLine + i, nLeft + 1, PadC( AllTrim( cAline ), nMaxWidth ) )\n NEXT\n DispEnd()\n\n Inkey( 0 )\n\n \n zrevwindow()\n\n SetCursor( oldCurs )\n SetColor( oldColor )\n\n RETURN .T.\n\n\nFUNCTION ZNEWWINDOW( wtype, r1, c1, r2, c2, ctitle, ccolor )\n\n LOCAL i := Len( s_zwin )\n LOCAL cScreen := SaveScreen( r1, c1, r2, c2 )\n LOCAL cOldColor := SetColor()\n LOCAL nrow := Row(), ncol := Col()\n\n hb_default( @ctitle, \"\" )\n hb_default( @ccolor, s_cStdColor )\n\n SetColor( ccolor )\n\n wvw_nOpenWindow( ctitle, r1, c1, r2, c2 )\n\n AAdd( s_zwin, { i + 1, r1, c1, r2, c2, cScreen, ctitle, nrow, ncol, coldcolor } )\n\n SetColor( ccolor )\n\n hb_Scroll( r1, c1, r2, c2 )\n\n \n hb_DispBox( r1, c1, r2, c2, wtype )\n IF ! Empty( ctitle )\n cTitle := \" \" + AllTrim( ctitle ) + \" \"\n hb_DispOutAt( r1, nCeiling( ( c2 + c1 - Len( cTitle ) ) / 2 ), cTitle )\n ENDIF\n\n SetColor( cOldColor )\n\n RETURN i + 1\n\n\nFUNCTION ZREVWINDOW()\n\n LOCAL i := Len( s_zwin )\n\n IF i == 0\n \n RETURN NIL\n ENDIF\n\n wvw_lCloseWindow()\n\n \n RestScreen( s_zwin[ i ][ 2 ], s_zwin[ i ][ 3 ], s_zwin[ i ][ 4 ], s_zwin[ i ][ 5 ], s_zwin[ i ][ 6 ] )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour header file: utils/hbtest/rt_main.ch. Defines constants: __CLIPPER__, HB_CLP_STRICT. Declares 1 preprocessor translations. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#translate HBTEST IS => TEST_CALL( #, {|| }, )\n\n#ifndef __HARBOUR__\n #ifndef __XPP__\n #ifndef __CLIP__\n #ifndef FlagShip\n #ifndef __VO__ \n #define __CLIPPER__\n #endif\n #endif\n #endif\n #endif\n#endif\n\n#ifdef __HARBOUR__\n #pragma linenumber=on\n#else\n #define HB_CLP_STRICT\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: ErrorSys. Harbour Runtime Library file: src/rtl/errsys.prg. Provides functions: DefError, ErrorMessage. Contains procedures: ErrorSys. This file implements error handling and reporting"}, {"role": "assistant", "content": "#include \"error.ch\"\n\nPROCEDURE ErrorSys()\n\n ErrorBlock( {| oError | DefError( oError ) } )\n\n RETURN\n\nSTATIC FUNCTION DefError( oError )\n\n LOCAL cMessage\n LOCAL cOSError\n\n LOCAL aOptions\n LOCAL nChoice\n\n LOCAL n\n\n \n IF oError:genCode == EG_ZERODIV .AND. ;\n oError:canSubstitute\n RETURN 0\n ENDIF\n\n \n IF oError:genCode == EG_LOCK .AND. ;\n oError:canRetry\n \n RETURN .T.\n ENDIF\n\n \n IF oError:genCode == EG_OPEN .AND. ;\n oError:osCode == 32 .AND. ;\n oError:canDefault\n NetErr( .T. )\n RETURN .F.\n ENDIF\n\n \n IF oError:genCode == EG_APPENDLOCK .AND. ;\n oError:canDefault\n NetErr( .T. )\n RETURN .F.\n ENDIF\n\n cMessage := ErrorMessage( oError )\n IF ! Empty( oError:osCode )\n cOSError := hb_StrFormat( \"(DOS Error %1$d)\", oError:osCode )\n ENDIF\n\n \n aOptions := {}\n\n AAdd( aOptions, \"Quit\" )\n\n IF oError:canRetry\n AAdd( aOptions, \"Retry\" )\n ENDIF\n\n IF oError:canDefault\n AAdd( aOptions, \"Default\" )\n ENDIF\n\n \n DO WHILE ( nChoice := Alert( cMessage + ;\n iif( cOSError == NIL, \"\", \";\" + cOSError ), aOptions ) ) == 0\n ENDDO\n\n IF ! Empty( nChoice ) \n SWITCH aOptions[ nChoice ]\n CASE \"Break\"\n Break( oError )\n CASE \"Retry\"\n RETURN .T.\n CASE \"Default\"\n RETURN .F.\n ENDSWITCH\n ENDIF\n\n \n IF cOSError != NIL\n cMessage += \" \" + cOSError\n ENDIF\n\n OutErr( hb_eol() )\n OutErr( cMessage )\n\n n := 1\n DO WHILE ! Empty( ProcName( ++n ) )\n OutErr( hb_eol() )\n OutErr( hb_StrFormat( \"Called from %1$s(%2$d) \", ;\n ProcName( n ), ;\n ProcLine( n ) ) )\n ENDDO\n\n ErrorLevel( 1 )\n QUIT\n\n RETURN .F.\n\nSTATIC FUNCTION ErrorMessage( oError )\n\n \n LOCAL cMessage := iif( oError:severity > ES_WARNING, \"Error\", \"Warning\" ) + \" \"\n\n \n IF HB_ISSTRING( oError:subsystem )\n cMessage += oError:subsystem()\n ELSE\n cMessage += \"???\"\n ENDIF\n\n \n IF HB_ISNUMERIC( oError:subCode )\n cMessage += \"/\" + hb_ntos( oError:subCode )\n ELSE\n cMessage += \"/???\"\n ENDIF\n\n \n IF HB_ISSTRING( oError:description )\n cMessage += \" \" + oError:description\n ENDIF\n\n \n DO CASE\n CASE ! Empty( oError:filename )\n cMessage += \": \" + oError:filename\n CASE ! Empty( oError:operation )\n cMessage += \": \" + oError:operation\n ENDCASE\n\n RETURN cMessage"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/flink.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"simpleio.ch\"\n\nPROCEDURE Main()\n\n hb_MemoWrit( \"_hb_h.tmp\", \">h.tmp<\" )\n\n ? hb_FLink()\n ? FError()\n\n ? hb_FLinkRead()\n ? FError()\n\n ? hb_FLinkRead( \"_hb_h.tmp\" )\n ? FError()\n\n ? hb_FLink( \"_hb_h.tmp\", \"_hb_hlnk.tmp\" )\n ? FError()\n\n hb_MemoWrit( \"_hb_s.tmp\", \">s.tmp<\" )\n\n \n ? hb_FLinkSym()\n ? FError()\n\n ? hb_FLinkSym( \"_hb_s.tmp\", \"_hb_slnk.tmp\" )\n ? FError()\n\n ? hb_FLinkRead( \"_hb_slnk.tmp\" )\n ? FError()\n\n hb_DirCreate( \"_hb_d\" )\n\n ? hb_FLinkSym( \"_hb_d\", \"_hb_dlnk\" )\n ? FError()\n\n ? hb_FLinkRead( \"_hb_dlnk\" )\n ? FError()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour extra library: extras/hbxlsxml/tests/example3.prg. Contains procedures: Main. This file provides spreadsheet generation capabilities"}, {"role": "assistant", "content": "#require \"hbxlsxml\"\n\nPROCEDURE Main()\n\n LOCAL xml, sheet1, format4\n\n xml := ExcelWriterXML():New( \"my file.xml\" )\n\n sheet1 := xml:addSheet( \"Plan 1\" )\n\n format4 := xml:addStyle( \"my style\" )\n format4:setFontSize( 20 )\n format4:setFontColor( \"yellow\" )\n format4:bgColor( \"blue\" )\n\n sheet1:columnWidth( 1, 150 )\n sheet1:columnWidth( 2, 150 )\n sheet1:columnWidth( 3, 150 )\n sheet1:writeString( 2, 3, \"celula 2_3\", format4 )\n sheet1:writeString( 2, 2, \"celula 2_2\", format4 )\n sheet1:writeString( 2, 1, \"celula 2_1\", format4 )\n\n sheet1:writeString( 1, 1, \"celula 1_1\", format4 )\n sheet1:writeString( 1, 3, \"celula 1_3\", format4 )\n sheet1:cellMerge( 1, 1, 1, 0 )\n\n xml:writeData( \"example3.xml\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: KeySec. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/keysec.prg. Provides functions: KeySec. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "THREAD STATIC t_hIdle\n\nFUNCTION KeySec( nKey, nTime, nCounter, lMode )\n\n LOCAL nSeconds\n\n IF t_hIdle != NIL\n hb_idleDel( t_hIdle )\n t_hIdle := NIL\n ENDIF\n\n IF HB_ISNUMERIC( nKey )\n\n IF ! HB_ISNUMERIC( nTime )\n nTime := 0\n ELSEIF nTime < 0\n nTime := -nTime / 18.2\n ENDIF\n nTime"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/clasname.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n \n AEval( { NIL, {}, \"\", 0, CToD( \"\" ), .F., {|| NIL }, ErrorNew() }, ;\n {| x | QOut( x:className() ) } )\n\n \n ?\n\n ? NIL:className()\n ? {}:className()\n ? \"\":className()\n ? 0:className()\n ? CToD( \"\" ):className()\n ? .F. :className()\n ? {|| NIL }:className()\n ? ErrorNew():className()\n\n \n ?\n\n ? NIL : className()\n ? {} : className()\n ? \"\" : className()\n ? 0 : className()\n ? CToD( \"\" ) : className()\n ? .F. : className()\n ? {|| NIL } : className()\n ? ErrorNew() : className()\n\n \n ?\n ? ( NIL:className() ):className()\n\n ?\n ? ( ( NIL:className() ):className() ):className()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/idle.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n CLS\n\n ? \"DEFAULT IDLEREPEAT =\", Set( _SET_IDLEREPEAT )\n ?\n ? \"Idle Block should be displayed multiple times until key or 10 seconds elapsed!\"\n ? \"Press any key to begin...\"\n ?\n Inkey( 0 )\n\n hb_idleAdd( {|| QOut( \"Idle Block\" ) } )\n Inkey( 2 )\n\n Set( _SET_IDLEREPEAT, .F. )\n\n hb_idleAdd( {|| QOut( \"Idle Block2\" ) } )\n\n CLS\n ? \"Idle Block & Block-2 should display ONCE! while waitning for key or 10 seconds elapsed!\"\n ?\n Inkey( 2 )\n\n ?\n ? \"Again - Idle Block & Block-2 should display ONCE! while waitning for key or 10 seconds elapsed!\"\n ?\n Inkey( 2 )\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/dates4.prg. Provides functions: CheckDate. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\n\nPROCEDURE Main()\n\n LOCAL i\n LOCAL dDate := Date()\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n FOR i := 7 TO 49 STEP 7\n CheckDate( dDate )\n dDate += i\n NEXT\n\n RETURN\n\nFUNCTION CheckDate( dDate )\n\n ? \"Testing date:\", dDate\n ? \"Days in month..:\", DaysInMonth( dDate )\n ? \"Day of year....:\", DoY( dDate )\n ? \"Begin of month.:\", BoM( dDate )\n ? \"End of month...:\", EoM( dDate )\n ? \"Week of month..:\", WoM( dDate )\n ? \"Begin of year..:\", BoY( dDate )\n ? \"End of year....:\", EoY( dDate )\n ?\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/test.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbct\"\n#require \"hbtest\"\n\nPROCEDURE Main()\n\n LOCAL nTotal\n\n HBTEST AddAscii( \"0000\", 1, 1 ) IS \"1000\"\n HBTEST AddAscii( \"0000\", 1 ) IS \"0001\"\n HBTEST AddAscii( \"AAAA\", -255, 1 ) IS \"BAAA\"\n HBTEST AddAscii( \"AAAA\", -255 ) IS \"AAAB\"\n HBTEST AddAscii( \"AAAA\", 1, 2, .T. ) IS \"ABAA\"\n HBTEST AddAscii( \"AAAA\", 257, 2, .T. ) IS \"BBAA\"\n HBTEST AddAscii( \"AAAA\", 257, 2, .F. ) IS \"ABAA\"\n HBTEST AddAscii( \"AAAA\", 258,, .T. ) IS \"AABC\"\n HBTEST AddAscii( \"ABBA\", -257, 3, .T. ) IS \"AAAA\"\n\n HBTEST AsciiSum( Replicate( \"A\", 10000 ) ) IS 650000\n HBTEST AsciiSum( \"0123456789\" ) IS 525\n HBTEST AsciiSum( NIL ) IS 0\n\n HBTEST AscPos( \"0123456789\" ) IS 57\n HBTEST AscPos( \"0123456789\", 1 ) IS 48\n HBTEST AscPos( \"0123456789\", 11 ) IS 0 \n\n HBTEST ValPos( \"1234x56789\" ) IS 9\n HBTEST ValPos( \"1234x56789\", 1 ) IS 1\n HBTEST ValPos( \"1234x56789\", 11 ) IS 0 \n HBTEST ValPos( \"1234x56789\", 5 ) IS 0 \n\n HBTEST AfterAtNum( \"..\", \"..This..is..a..test!\" ) IS \"test!\"\n HBTEST AfterAtNum( \"..\", \"..This..is..a..test!\", 2 ) IS \"is..a..test!\"\n HBTEST AfterAtNum( \"..\", \"..This..is..a..test!\", 2, 2 ) IS \"a..test!\"\n HBTEST BeforAtNum( \"..\", \"..This..is..a..test!\" ) IS \"..This..is..a\"\n HBTEST BeforAtNum( \"..\", \"..This..is..a..test!\", 2 ) IS \"..This\"\n HBTEST BeforAtNum( \"..\", \"..This..is..a..test!\", 2, 2 ) IS \"..This..is\"\n\n HBTEST AtNum( \"..\", \"..This..is..a..test!\" ) IS 14\n HBTEST AtNum( \"..\", \"..This..is..a..test!\", 2 ) IS 7\n HBTEST AtNum( \"..\", \"..This..is..a..test!\", 2, 2 ) IS 11\n\n HBTEST AtRepl( \"ABC\", \"ABCDABCDABC\", \"xx\" ) IS \"xxDxxDxx\"\n HBTEST AtRepl( \"ABC\", \"ABCDABC\", \"ZYXW\" ) IS \"ZYXWDZYXW\"\n HBTEST AtRepl( \"ABC\", \"ABCDABCDABC\", \"xx\", 2 ) IS \"xxDxxDABC\"\n HBTEST AtRepl( \"ABC\", \"ABCDABCDABC\", \"xx\", 2, .T. ) IS \"ABCDxxDABC\"\n\n HBTEST CharEven( \" 1 2 3 4 5\" ) IS \"12345\"\n HBTEST CharEven( \" 1 2 3 4 \" ) IS \"1234\"\n HBTEST CharEven( \" \" ) IS \"\"\n\n HBTEST CharOdd( \"1A2B3C4D5E\" ) IS \"12345\"\n HBTEST CharOdd( \"1A2B3C4D5\" ) IS \"12345\"\n\n HBTEST CharSList( \"Hello World !\" ) IS \" !HWdelor\"\n HBTEST CharSList( \"Hello World !\" ) IS CharSort( CharList( \"Hello World !\" ) )\n HBTEST CharSList( NIL ) IS \"\"\n\n HBTEST CharHist( \"Hello World !\" )[ 109 ] IS 3\n HBTEST ( nTotal := 0, AEval( CharHist( \"Hello World !\" ), {| x | nTotal += x } ), nTotal ) IS Len( \"Hello World !\" )\n\n HBTEST CharList( \"Hello World !\" ) IS \"Helo Wrd!\"\n HBTEST CharList( NIL ) IS \"\"\n\n HBTEST CharNoList( CharNoList( \"Hello World !\" ) ) IS CharSList( \"Hello World !\" )\n HBTEST CharNoList( CharNoList( NIL ) ) IS \"\"\n\n HBTEST CharMirr( \"racecar\" ) IS \"racecar\"\n HBTEST CharMirr( \"racecar \", .T. ) IS \"racecar \"\n HBTEST CharMirr( \"racecar \", .F. ) IS \" racecar\"\n\n HBTEST CharMix( \"ABC\", \"123\" ) IS \"A1B2C3\"\n HBTEST CharMix( \"ABCDE\", \"12\" ) IS \"A1B2C1D2E1\"\n HBTEST CharMix( \"AB\", \"12345\" ) IS \"A1B2\"\n HBTEST CharMix( \"HELLO\", \" \" ) IS \"H E L L O \"\n HBTEST CharMix( \"HELLO\", \"\" ) IS \"HELLO\"\n\n HBTEST CharOne( \"122333a123\" ) IS \"123a123\"\n HBTEST CharOne( \"A B CCCD\" ) IS \"A B CD\"\n HBTEST CharOne( \" \", \"A B A B\" ) IS \"A B A B\"\n HBTEST CharOne( \"o\", \"122oooB12o\" ) IS \"122oB12o\"\n\n HBTEST WordOne( \"12ABAB12\" ) IS \"12AB12\"\n HBTEST WordOne( \"1AAAA2\" ) IS \"1AAAA2\"\n HBTEST WordOne( \"12\", \"1212ABAB\" ) IS \"12ABAB\"\n\n HBTEST CharOnly( \"0123456789\", \"0211 - 38 99 77\" ) IS \"0211389977\"\n HBTEST CharOnly( \"0123456789\", \"0211/ 389 977\" ) IS \"0211389977\"\n\n HBTEST WordOnly( \"AABBCCDD\", \"XXAAYYBBZZ\" ) IS \"AABB\"\n HBTEST WordOnly( \"AABBCCDD\", \"XAAYYYBBZZ\" ) IS \"BB\"\n\n HBTEST CharRem( \" \", \" 1 2 \" ) IS \"12\"\n HBTEST CharRem( \"3y\", \"xyz123\" ) IS \"xz12\"\n\n HBTEST WordRem( \"abcd\", \"0ab1cd\" ) IS \"0ab1\"\n HBTEST WordRem( \"abcd\", \"ab0cd1\" ) IS \"0cd1\"\n\n HBTEST CharAdd( \"012345678\", hb_BChar( 1 ) ) IS \"123456789\"\n HBTEST CharAdd( \"012345678\", hb_BChar( 1 ) + hb_BChar( 2 ) ) IS \"133557799\"\n HBTEST CharAdd( \"123456789\", hb_BChar( 255 ) ) IS \"012345678\"\n HBTEST CharAdd( \"123456789\", hb_BChar( 255 ) + hb_BChar( 254 ) ) IS \"002244668\"\n HBTEST CharAnd( \"012345678\", hb_BChar( 254 ) ) IS \"002244668\"\n HBTEST CharAnd( \"012345678\", hb_BChar( 254 ) + hb_BChar( 252 ) ) IS \"002044648\"\n\n HBTEST CharNot( hb_BChar( 85 ) + hb_BChar( 128 ) + hb_BChar( 170 ) + hb_BChar( 1 ) ) IS hb_BChar( 170 ) + hb_BChar( 127 ) + hb_BChar( 85 ) + hb_BChar( 254 )\n HBTEST CharNot( CharNot( \"This is a test!\" ) ) IS \"This is a test!\"\n\n HBTEST CharOr( \"012345678\", hb_BChar( 1 ) ) IS \"113355779\"\n HBTEST CharOr( \"012345678\", hb_BChar( 1 ) + hb_BChar( 3 ) ) IS \"133357779\"\n\n HBTEST CharXor( CharXor( \"This is top secret !\", \"My Password\" ), \"My Password\" ) IS \"This is top secret !\"\n\n HBTEST CharSub( \"123456789\", hb_BChar( 1 ) ) IS \"012345678\"\n HBTEST CharSub( \"123456789\", hb_BChar( 1 ) + hb_BChar( 2 ) ) IS \"002244668\"\n HBTEST CharSub( \"012345678\", hb_BChar( 255 ) ) IS \"123456789\"\n HBTEST CharSub( \"012345678\", hb_BChar( 255 ) + hb_BChar( 254 ) ) IS \"133557799\"\n\n HBTEST CharShl( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 ) IS hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ) + hb_BChar( 0 ) + hb_BChar( 0 ) + hb_BChar( 0 )\n HBTEST CharShr( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 ) IS hb_BChar( 0 ) + hb_BChar( 0 ) + hb_BChar( 0 ) + hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 )\n HBTEST CharRll( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 ) IS hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ) + hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 )\n HBTEST CharRlr( hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 ) + hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ), 3 ) IS hb_BChar( 32 ) + hb_BChar( 64 ) + hb_BChar( 128 ) + hb_BChar( 1 ) + hb_BChar( 2 ) + hb_BChar( 4 ) + hb_BChar( 8 ) + hb_BChar( 16 )\n\n HBTEST CharRepl( \"1234\", \"1x2y3z\", \"abcd\" ) IS \"axbycz\"\n HBTEST CharRepl( \"abcdefghij\", \"jhfdb\", \"1234567890\" ) IS \"08642\"\n HBTEST CharRepl( \"abcdefghij\", \"jhfdb\", \"12345\" ) IS \"55542\"\n HBTEST CharRepl( \"1234\", \"1234\", \"234A\" ) IS \"AAAA\"\n HBTEST CharRepl( \"1234\", \"1234\", \"234A\", .T. ) IS \"234A\"\n\n HBTEST CharSort( \"qwert\" ) IS \"eqrtw\"\n HBTEST CharSort( \"qwert\", 2 ) IS \"erqwt\"\n HBTEST CharSort( \"b1a4a3a2a1\", 2, 1 ) IS \"a2a1a3a4b1\"\n HBTEST CharSort( \"XXXqwert\", 1, 1, 3 ) IS \"XXXeqrtw\"\n HBTEST CharSort( \"b1a4a3a2a1\", 2, 1, 0, 1 ) IS \"a1b1a2a3a4\"\n HBTEST CharSort( \"384172852\", 1, 1, 0, 0, 4 ) IS \"134872852\"\n HBTEST CharSort( \"qwert\",,,,,, .T. ) IS \"wtrqe\"\n\n HBTEST CharSwap( \"0123456789\" ) IS \"1032547698\"\n HBTEST CharSwap( \"ABCDEFGHIJK\" ) IS \"BADCFEHGJIK\"\n\n HBTEST WordSwap( \"1234567890\" ) IS \"3412785690\"\n HBTEST WordSwap( \"1234567890\", .T. ) IS \"4321876590\"\n\n HBTEST Floor( 1.1 ) IS 1.0\n HBTEST Floor( -1.1 ) IS -2.0\n HBTEST Ceiling( 1.1 ) IS 2.0\n HBTEST Ceiling( -1.1 ) IS -1.0\n HBTEST Sign( 1.1 ) IS 1\n HBTEST Sign( -1.1 ) IS -1\n HBTEST Sign( 0.0 ) IS 0\n HBTEST Log10( 10.0 ) IS 1.0\n HBTEST Log10( Sqrt( 10.0 ) ) IS 0.5\n HBTEST Fact( 0 ) IS 1\n HBTEST Fact( 1 ) IS 1\n HBTEST Fact( 4 ) IS 24\n HBTEST Round( FV( 1000, 0.00, 10 ), 1 ) IS 10000.0\n HBTEST Round( FV( 1000, 0.05, 10 ), 3 ) IS 12577.893\n HBTEST Round( PV( 100, 0.0, 60 ), 1 ) IS 6000.0"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbfbird' (Firebird database client): contrib/hbfbird/tests/simple.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbfbird\"\n\nPROCEDURE Main()\n\n LOCAL oServer, oQuery, oRow, i, x, aTables, aStruct, aKey\n\n LOCAL cServer := \"localhost:\"\n LOCAL cDatabase\n LOCAL cUser := \"SYSDBA\"\n LOCAL cPass := \"masterkey\"\n LOCAL nPageSize := 1024\n LOCAL cCharSet := \"ASCII\"\n LOCAL nDialect := 1\n LOCAL cQuery, cName\n\n hb_FNameSplit( hb_argv( 0 ), NIL, @cName, NIL )\n cDatabase := hb_DirTemp() + cName + \".fdb\"\n\n IF hb_FileExists( cDatabase )\n FErase( cDatabase )\n ENDIF\n\n ? FBCreateDB( cServer + cDatabase, cUser, cPass, nPageSize, cCharSet, nDialect )\n\n ? \"Connecting...\"\n\n oServer := TFBServer():New( cServer + cDatabase, cUser, cPass, nDialect )\n\n IF oServer:NetErr()\n ? oServer:Error()\n QUIT\n ENDIF\n\n ? \"Tables...\"\n\n FOR x := 1 TO 1\n aTables := oServer:ListTables()\n\n FOR i := 1 TO Len( aTables )\n ? aTables[ i ]\n NEXT\n NEXT\n\n ? \"Using implicit transaction...\"\n\n IF oServer:TableExists( \"TEST\" )\n oServer:Execute( \"DROP TABLE Test\" )\n oServer:Execute( \"DROP DOMAIN boolean_field\" )\n ENDIF\n\n ? \"Creating domain for boolean fields...\"\n oServer:Execute( \"create domain boolean_field as smallint default 0 not null check (value in (0,1))\" )\n\n oServer:StartTransaction()\n ? \"Creating test table...\"\n cQuery := \"CREATE TABLE test(\"\n cQuery += \" Code SmallInt not null primary key, \"\n cQuery += \" dept Integer, \"\n cQuery += \" Name Varchar(40), \"\n cQuery += \" Sales boolean_field, \"\n cQuery += \" Tax Float, \"\n cQuery += \" Salary Double Precision, \"\n cQuery += \" Budget Numeric(12,2), \"\n cQuery += \" Discount Decimal(5,2), \"\n cQuery += \" Creation Date, \"\n cQuery += \" Description blob sub_type 1 segment size 40 ) \"\n\n oServer:Execute( cQuery )\n\n IF oServer:NetErr()\n ? oServer:Error()\n ENDIF\n\n oServer:Commit()\n\n oServer:Query( \"SELECT code, dept, name, sales, salary, creation FROM test\" )\n WAIT\n\n\n ? \"Structure of test table\"\n aStruct := oServer:TableStruct( \"test\" )\n\n FOR i := 1 TO Len( aStruct )\n ?\n FOR x := 1 TO Len( aStruct[ i ] )\n ?? aStruct[ i, x ]\n NEXT\n NEXT\n\n ? \"Inserting, declared transaction control \"\n oServer:StartTransaction()\n\n FOR i := 1 TO 100\n cQuery := \"INSERT INTO test(code, dept, name, sales, tax, salary, budget, Discount, Creation, Description) \"\n cQuery += 'VALUES( ' + Str( i ) + ', 2, \"TEST\", 1, 5, 3000, 1500.2, 7.5, \"12-22-2003\", \"Short Description about what ? \")'\n\n oServer:Execute( cQuery )\n\n IF oServer:NetErr()\n ? oServer:error()\n ENDIF\n NEXT\n\n oServer:Commit()\n\n oQuery := oServer:Query( \"SELECT code, name, description, sales FROM test\" )\n\n aStruct := oQuery:Struct()\n\n FOR i := 1 TO Len( aStruct )\n ? aStruct[ i, 1 ], aStruct[ i, 2 ], aStruct[ i, 3 ], aStruct[ i, 4 ]\n NEXT\n\n aKey := oQuery:GetKeyField()\n\n ? \"Fields: \", oQuery:FCount(), \"Primary Key: \", aKey[ 1 ]\n\n oRow := oQuery:Blank()\n\n ? ;\n oRow:FCount(), ;\n oRow:FieldPos( \"code\" ), ;\n oRow:FieldGet( 1 ), ;\n oRow:FieldName( 1 ), ;\n oRow:FieldType( 1 ), ;\n oRow:FieldDec( 1 ), ;\n oRow:FieldLen( 1 ), ;\n Len( oRow:Getkeyfield() )\n\n oRow:FieldPut( 1, 150 )\n oRow:FieldPut( 2, \"MY TEST\" )\n\n ? oRow:FieldGet( 1 ), oRow:FieldGet( 2 )\n\n ? oServer:Append( oRow )\n\n ? oServer:Delete( oQuery:blank(), \"code = 200\" )\n\n ? oServer:Execute( \"error caused intentionaly\" )\n\n DO WHILE ! oQuery:Eof()\n oQuery:Skip()\n ? ;\n oQuery:FieldGet( oQuery:FieldPos( \"code\" ) ), ;\n oQuery:FieldGet( 4 ), ;\n oQuery:FieldGet( 2 ), ;\n oQuery:FieldName( 1 ), ;\n oQuery:FieldType( 1 ), ;\n oQuery:FieldDec( 1 ), ;\n oQuery:FieldLen( 1 ), ;\n oQuery:FieldGet( 3 )\n\n IF oQuery:RecNo() == 50\n oRow := oQuery:getrow()\n\n oRow:FieldPut( 2, \"My Second test\" )\n ? \"Update: \", oServer:Update( oRow )\n ENDIF\n\n IF oQuery:RecNo() == 60\n oRow := oQuery:getrow()\n ? \"Delete: \", oServer:Delete( oRow )\n ENDIF\n ENDDO\n\n ? \"Delete: \", oServer:Delete( oQuery:Blank(), \"code = 70\" )\n\n oQuery:Refresh()\n\n DO WHILE oQuery:Fetch()\n oRow := oQuery:getrow()\n\n ? ;\n oRow:FieldGet( oRow:FieldPos( \"code\" ) ), ;\n oRow:FieldGet( 4 ), ;\n oRow:FieldGet( 2 ), ;\n oRow:FieldName( 1 ), ;\n oRow:FieldType( 1 ), ;\n oRow:FieldDec( 1 ), ;\n oRow:FieldLen( 1 ), ;\n oRow:FieldGet( 3 )\n ENDDO\n\n oQuery:Destroy()\n\n oServer:Destroy()\n\n ? \"Closing...\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/codebl2.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL i, bBlock[ 3 ]\n\n MEMVAR m_Var1, m_Var2, m_Var3, m_Macro\n PRIVATE m_Var1, m_Var2, m_Var3, m_Macro\n\n m_Var1 := \"m_Var1\"\n m_Var2 := \"m_Var2\"\n m_Var3 := \"m_Var3\"\n\n FOR i := 1 TO 3\n m_Macro := \"m_Var\" + Str( i, 1 )\n bBlock[ i ] := {|| &m_Macro }\n NEXT\n\n ? \"Early (Simple):\"\n\n FOR i := 1 TO 3\n ? Eval( bBlock[ i ] )\n NEXT\n\n FOR i := 1 TO 3\n m_Macro := \"m_Var\" + Str( i, 1 )\n bBlock[ i ] := {|| &m_Macro + \"!\" }\n NEXT\n\n ?\n ? \"Early (Complex):\"\n\n FOR i := 1 TO 3\n ? Eval( bBlock[ i ] )\n NEXT\n\n FOR i := 1 TO 3\n m_Macro := \"m_Var\" + Str( i, 1 )\n bBlock[ i ] := {|| &( m_Macro ) }\n NEXT\n\n ?\n ? \"Late:\"\n\n FOR i := 1 TO 3\n ? Eval( bBlock[ i ] )\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/savesets.prg. Provides functions: ft_SaveSets. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#define FT_EXTRA_SETS 2\n#define FT_SET_CENTURY _SET_COUNT + 1\n#define FT_SET_BLINK _SET_COUNT + 2\n\nFUNCTION ft_SaveSets()\n\n LOCAL aOldSets := Array( _SET_COUNT + FT_EXTRA_SETS )\n\n AEval( aOldSets, ;\n {| xElement, nElementNo | HB_SYMBOL_UNUSED( xElement ), ;\n aOldSets[ nElementNo ] := Set( nElementNo ) } )\n\n aOldSets[ FT_SET_CENTURY ] := ft_SetCentury()\n aOldSets[ FT_SET_BLINK ] := SetBlink()\n\n RETURN aOldSets"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbfbird' (Firebird database client): contrib/hbfbird/tfirebrd.prg. Defines classes: TFbServer. This file handles database operations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#define SQL_TEXT 452\n#define SQL_VARYING 448\n#define SQL_SHORT 500\n#define SQL_LONG 496\n#define SQL_FLOAT 482\n#define SQL_DOUBLE 480\n#define SQL_D_FLOAT 530\n#define SQL_TIMESTAMP 510\n#define SQL_BLOB 520\n#define SQL_ARRAY 540\n#define SQL_QUAD 550\n#define SQL_TYPE_TIME 560\n#define SQL_TYPE_DATE 570\n#define SQL_INT64 580\n#define SQL_DATE SQL_TIMESTAMP\n\nCREATE CLASS TFbServer\n\n VAR db\n VAR trans\n VAR StartedTrans\n VAR nError\n VAR lError\n VAR dialect\n\n METHOD New( cServer, cUser, cPassword, nDialect )\n METHOD Destroy() INLINE FBClose( ::db )\n METHOD Close() INLINE FBClose( ::db )\n\n METHOD TableExists( cTable )\n METHOD ListTables()\n METHOD TableStruct( cTable )\n\n METHOD StartTransaction()\n METHOD Commit()\n METHOD Rollback()\n\n METHOD Execute( cQuery )\n METHOD Query( cQuery )\n\n METHOD Update( oRow, cWhere )\n METHOD Delete( oRow, cWhere )\n METHOD Append( oRow )\n\n METHOD NetErr() INLINE ::lError\n METHOD Error() INLINE FBError( ::nError )\n METHOD ErrorNo() INLINE ::nError\n\nENDCLASS\n\nMETHOD New( cServer, cUser, cPassword, nDialect ) CLASS TFbServer\n\n hb_default( @nDialect, 1 )\n\n ::lError := .F.\n ::nError := 0\n ::StartedTrans := .F.\n ::Dialect := nDialect\n\n ::db := FBConnect( cServer, cUser, cPassword )\n\n IF HB_ISNUMERIC( ::db )\n ::lError := .T.\n ::nError := ::db\n ENDIF\n\n RETURN Self\n\nMETHOD StartTransaction() CLASS TFbServer\n\n LOCAL result := .F.\n\n ::trans := FBStartTransaction( ::db )\n\n IF HB_ISNUMERIC( ::trans )\n ::lError := .T.\n ::nError := ::trans\n ELSE\n result := .T.\n ::lError := .F.\n ::lnError := 0\n ::StartedTrans := .T.\n ENDIF\n\n RETURN result\n\nMETHOD Rollback() CLASS TFbServer\n\n LOCAL result := .F.\n LOCAL n\n\n IF ::StartedTrans\n IF ( n := FBRollback( ::trans ) ) < 0\n ::lError := .T.\n ::nError := n\n ELSE\n ::lError := .F.\n ::nError := 0\n result := .T.\n ::StartedTrans := .F.\n ENDIF\n ENDIF\n\n RETURN result\n\nMETHOD Commit() CLASS TFbServer\n\n LOCAL result := .F.\n LOCAL n\n\n IF ::StartedTrans\n IF ( n := FBCommit( ::trans ) ) < 0\n ::lError := .T.\n ::nError := n\n ELSE\n ::lError := .F.\n ::nError := 0\n result := .T.\n ::StartedTrans := .F.\n ENDIF\n ENDIF\n\n RETURN result\n\nMETHOD Execute( cQuery ) CLASS TFbServer\n\n LOCAL result\n LOCAL n\n\n cQuery := RemoveSpaces( cQuery )\n\n IF ::StartedTrans\n n := FBExecute( ::db, cQuery, ::dialect, ::trans )\n ELSE\n n := FBExecute( ::db, cQuery, ::dialect )\n ENDIF\n\n IF n < 0\n ::lError := .T.\n ::nError := n\n result := .F.\n ELSE\n ::lError := .F.\n ::nError := 0\n result := .T.\n ENDIF\n\n RETURN result\n\nMETHOD Query( cQuery ) CLASS TFbServer\n RETURN TFBQuery():New( ::db, cQuery, ::dialect )\n\nMETHOD TableExists( cTable ) CLASS TFbServer\n\n LOCAL cQuery\n LOCAL result := .F.\n LOCAL qry\n\n cQuery := 'select rdb$relation_name from rdb$relations where rdb$relation_name = \"' + Upper( cTable ) + '\"'\n\n qry := FBQuery( ::db, cQuery, ::dialect )\n\n IF HB_ISARRAY( qry )\n result := ( FBFetch( qry ) == 0 )\n\n FBFree( qry )\n ENDIF\n\n RETURN result\n\nMETHOD ListTables() CLASS TFbServer\n\n LOCAL result := {}\n LOCAL cQuery\n LOCAL qry\n\n cQuery := 'select rdb$relation_name '\n cQuery += ' from rdb$relations '\n cQuery += ' where rdb$relation_name not like \"RDB$%\" '\n cQuery += ' and rdb$view_blr is null '\n cQuery += ' order by 1 '\n\n qry := FBQuery( ::db, RemoveSpaces( cQuery ), ::dialect )\n\n IF HB_ISARRAY( qry )\n DO WHILE FBFetch( qry ) == 0\n AAdd( result, FBGetData( qry, 1 ) )\n ENDDO\n\n FBFree( qry )\n ENDIF\n\n RETURN result\n\nMETHOD TableStruct( cTable ) CLASS TFbServer\n\n LOCAL result := {}\n LOCAL cQuery, cType, nSize, cDomain, cField, nType, nDec\n LOCAL qry\n\n cQuery := 'select '\n cQuery += ' a.rdb$field_name,'\n cQuery += ' b.rdb$field_type,'\n cQuery += ' b.rdb$field_length,'\n cQuery += ' b.rdb$field_scale\n cQuery += ' and a.rdb$relation_name = \"' + Upper( ctable ) + '\" '\n cQuery += 'order by '\n cQuery += ' a.rdb$field_position '\n\n qry := FBQuery( ::db, RemoveSpaces( cQuery ), ::dialect )\n\n IF HB_ISARRAY( qry )\n DO WHILE FBFetch( qry ) == 0\n cField := FBGetData( qry, 1 )\n nType := Val( FBGetData( qry, 2 ) )\n nSize := Val( FBGetData( qry, 3 ) )\n nDec := Val( FBGetData( qry, 4 ) )\n cDomain := FBGetData( qry, 5 )\n\n SWITCH nType\n CASE 7 \n IF \"BOOL\" $ cDomain\n cType := \"L\"\n nSize := 1\n nDec := 0\n ELSE\n cType := \"N\"\n nSize := 5\n ENDIF\n\n EXIT\n\n CASE 8 \n CASE 9\n cType := \"N\"\n nSize := 9\n EXIT\n\n CASE 10 \n CASE 11\n cType := \"N\"\n nSize := 15\n EXIT\n\n CASE 12 \n cType := \"D\"\n nSize := 8\n EXIT\n\n CASE 13 \n cType := \"C\"\n nSize := 10\n EXIT\n\n CASE 14 \n cType := \"C\"\n EXIT\n\n CASE 16 \n cType := \"N\"\n nSize := 9\n EXIT\n\n CASE 27 \n cType := \"N\"\n nSize := 15\n EXIT\n\n CASE 35 \n cType := \"D\"\n nSize := 8\n EXIT\n\n CASE 37 \n CASE 40\n cType := \"C\"\n EXIT\n\n CASE 261 \n cType := \"M\"\n nSize := 10\n EXIT\n\n OTHERWISE\n cType := \"C\"\n nDec := 0\n ENDSWITCH\n\n AAdd( result, { cField, cType, nSize, nDec } )\n\n ENDDO\n\n FBFree( qry )\n ENDIF\n\n RETURN result\n\nMETHOD Delete( oRow, cWhere ) CLASS TFbServer\n\n LOCAL result := .F.\n LOCAL aKeys, i, nField, xField, cQuery, aTables\n\n aTables := oRow:GetTables()\n\n IF ! HB_ISNUMERIC( ::db ) .AND. Len( aTables ) == 1\n \n\n IF cWhere == NIL\n aKeys := oRow:GetKeyField()\n\n cWhere := \"\"\n FOR i := 1 TO Len( aKeys )\n nField := oRow:FieldPos( aKeys[ i ] )\n xField := oRow:FieldGet( nField )\n\n cWhere += aKeys[ i ] + \"=\" + DataToSql( xField )\n\n IF i != Len( aKeys )\n cWhere += \",\"\n ENDIF\n NEXT\n ENDIF\n\n IF !( cWhere == \"\" )\n cQuery := 'DELETE FROM ' + aTables[ 1 ] + ' WHERE ' + cWhere\n\n result := ::Execute( cQuery )\n ENDIF\n ENDIF\n\n RETURN result\n\nMETHOD Append( oRow ) CLASS TFbServer\n\n LOCAL result := .F.\n LOCAL cQuery, i, aTables\n\n aTables := oRow:GetTables()\n\n IF ! HB_ISNUMERIC( ::db ) .AND. Len( aTables ) == 1\n \n\n cQuery := 'INSERT INTO ' + aTables[ 1 ] + '('\n FOR i := 1 TO oRow:FCount()\n IF oRow:Changed( i )\n \n cQuery += oRow:FieldName( i ) + \",\"\n ENDIF\n NEXT\n\n cQuery := Left( cQuery, Len( cQuery ) - 1 ) + \") VALUES (\"\n\n FOR i := 1 TO oRow:FCount()\n IF oRow:Changed( i )\n cQuery += DataToSql( oRow:FieldGet( i ) ) + \",\"\n ENDIF\n NEXT\n\n cQuery := Left( cQuery, Len( cQuery ) - 1 ) + \")\"\n\n result := ::Execute( cQuery )\n ENDIF\n\n RETURN result\n\nMETHOD Update( oRow, cWhere ) CLASS TFbServer\n\n LOCAL result := .F.\n LOCAL aKeys, cQuery, i, nField, xField, aTables\n\n aTables := oRow:GetTables()\n\n IF ! HB_ISNUMERIC( ::db ) .AND. Len( aTables ) == 1\n \n\n IF cWhere == NIL\n aKeys := oRow:GetKeyField()\n\n cWhere := \"\"\n FOR i := 1 TO Len( aKeys )\n nField := oRow:FieldPos( aKeys[ i ] )\n xField := oRow:FieldGet( nField )\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/woy.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\nPROCEDURE Main()\n\n LOCAL dDate\n LOCAL GetList := {}\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n DO WHILE .T.\n\n @ 2, 10 SAY \"Date to Test\"\n\n dDate := hb_SToD()\n @ 2, 24 GET dDate\n READ\n\n IF Empty( dDate )\n EXIT\n ENDIF\n\n @ 4, 10 SAY \"Is Day Number \" + Str( ft_DoY( dDate ), 10 )\n @ 6, 10 SAY \"Is in Week Number \" + Str( ft_WoY( dDate ), 10 )\n @ 7, 0\n\n WAIT\n\n ENDDO\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/encb64.prg. Defines classes: TIPEncoderBase64. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nCREATE CLASS TIPEncoderBase64 INHERIT TIPEncoder\n\n \n VAR bHttpExcept INIT .F.\n\n METHOD New() CONSTRUCTOR\n METHOD Encode( cData )\n METHOD Decode( cData )\n\nENDCLASS\n\nMETHOD New() CLASS TIPEncoderBase64\n\n ::cName := \"base64\"\n\n RETURN Self\n\nMETHOD Encode( cData ) CLASS TIPEncoderBase64\n RETURN hb_base64Encode( cData, iif( ::bHttpExcept, NIL, 76 ) )\n\nMETHOD Decode( cData ) CLASS TIPEncoderBase64\n RETURN hb_base64Decode( cData )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'gtwvg' (): contrib/gtwvg/dialog.prg. Defines classes: WvgDialog. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\nCREATE CLASS WvgDialog INHERIT WvgWindow\n\n VAR oMenu\n VAR aRect\n VAR drawingArea\n VAR tasklist INIT .T.\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD destroy()\n METHOD setFrameState( nState )\n METHOD getFrameState()\n METHOD menuBar()\n\n METHOD showModal() INLINE NIL\n METHOD setTitle( cTitle ) INLINE ::title := cTitle, hb_gtInfo( HB_GTI_WINTITLE, cTitle )\n METHOD getTitle() INLINE hb_gtInfo( HB_GTI_WINTITLE )\n METHOD calcClientRect() INLINE ::aRect := wvg_GetClientRect( ::hWnd ), { 0, 0, ::aRect[ 3 ], ::aRect[ 4 ] }\n METHOD calcFrameRect() INLINE ::aRect := wvg_GetWindowRect( ::hWnd ), { ::aRect[ 1 ], ::aRect[ 2 ], ::aRect[ 3 ] - ::aRect[ 1 ], ::aRect[ 4 ] - ::aRect[ 2 ] }\n\nENDCLASS\n\nMETHOD WvgDialog:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::WvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::className := \"WVGDIALOG\"\n ::resizeMode := 0\n ::mouseMode := 0\n ::objType := objTypeDialog\n\n ::style := WS_THICKFRAME + WS_OVERLAPPED + WS_CAPTION + WS_SYSMENU + WS_MINIMIZEBOX + WS_MAXIMIZEBOX\n\n RETURN Self\n\nMETHOD WvgDialog:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n LOCAL oW\n\n ::WvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n IF ::lModal\n ::pGT := hb_gtCreate( \"WGU\" )\n ::pGTp := hb_gtSelect( ::pGT )\n ELSE\n hb_gtReload( \"WGU\" )\n ::pGT := hb_gtSelect()\n ENDIF\n\n hb_gtInfo( HB_GTI_PRESPARAMS, { ::exStyle, ::style, ::aPos[ 1 ], ::aPos[ 2 ], ;\n ::aSize[ 1 ], ::aSize[ 2 ], ::pGTp, .F., .F., HB_WNDTYPE_DIALOG } )\n\n IF ::visible\n hb_gtInfo( HB_GTI_SPEC, HB_GTS_SHOWWINDOW, SW_NORMAL )\n ELSE\n hb_gtInfo( HB_GTI_SPEC, HB_GTS_SHOWWINDOW, SW_HIDE )\n ENDIF\n\n ::hWnd := hb_gtInfo( HB_GTI_SPEC, HB_GTS_WINDOWHANDLE )\n\n hb_gtInfo( HB_GTI_RESIZABLE, ::resizable )\n hb_gtInfo( HB_GTI_CLOSABLE, ::closable )\n hb_gtInfo( HB_GTI_WINTITLE, ::title )\n\n IF ! Empty( ::icon )\n IF HB_ISNUMERIC( ::icon )\n hb_gtInfo( HB_GTI_ICONRES, ::icon )\n\n ELSEIF HB_ISSTRING( ::icon )\n hb_gtInfo( HB_GTI_ICONFILE, ::icon )\n\n ENDIF\n ENDIF\n\n IF ::lModal\n hb_gtInfo( HB_GTI_DISABLE, ::pGTp )\n ENDIF\n\n IF ::visible\n ::lHasInputFocus := .T.\n ENDIF\n\n oW := WvgDrawingArea():new( Self ):create( , , { 0, 0 }, Self:currentSize(), , .F. )\n IF ! Empty( oW:hWnd )\n ::drawingArea := oW\n ELSE\n ::drawingArea := Self\n ENDIF\n\n hb_gtInfo( HB_GTI_NOTIFIERBLOCK, {| nEvent, ... | ::notifier( nEvent, ... ) } )\n\n RETURN Self\n\nMETHOD WvgDialog:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::WvgWindow:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n RETURN Self\n\nMETHOD WvgDialog:destroy()\n\n IF HB_ISOBJECT( ::oMenu )\n ::oMenu:destroy()\n ENDIF\n\n IF Len( ::aChildren ) > 0\n AEval( ::aChildren, {| o | o:destroy() } )\n ENDIF\n\n IF ! Empty( ::hBrushBG )\n wvg_DeleteObject( ::hBrushBG )\n ENDIF\n\n ::pGT := NIL\n ::pGTp := NIL\n\n RETURN Self\n\nMETHOD WvgDialog:setFrameState( nState )\n\n LOCAL lSuccess := .F.\n\n DO CASE\n\n CASE nState == WVGDLG_FRAMESTAT_MINIMIZED\n RETURN ::sendMessage( WM_SYSCOMMAND, SC_MINIMIZE, 0 ) != 0\n\n CASE nState == WVGDLG_FRAMESTAT_MAXIMIZED\n RETURN ::sendMessage( WM_SYSCOMMAND, SC_MAXIMIZE, 0 ) != 0\n\n CASE nState == WVGDLG_FRAMESTAT_NORMALIZED\n RETURN ::sendMessage( WM_SYSCOMMAND, SC_RESTORE, 0 ) != 0\n\n ENDCASE\n\n RETURN lSuccess\n\nMETHOD WvgDialog:getFrameState()\n\n IF wvg_IsIconic( ::hWnd )\n RETURN WVGDLG_FRAMESTAT_MINIMIZED\n ENDIF\n IF wvg_IsZoomed( ::hWnd )\n RETURN WVGDLG_FRAMESTAT_MAXIMIZED\n ENDIF\n\n RETURN WVGDLG_FRAMESTAT_NORMALIZED\n\nMETHOD WvgDialog:menuBar()\n\n IF ! HB_ISOBJECT( ::oMenu )\n ::oMenu := WvgMenuBar():New( Self ):create()\n ENDIF\n\n RETURN ::oMenu"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charhist.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL nTotal := 0\n\n ctinit()\n\n ? \"Begin test of CharHist()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharHist( \"Hello World !\" )' + \"'109' == 3 ? --> \", CharHist( \"Hello World !\" )' 109 '\n ? ' AEval( CharHist( \"Hello World !\" ), {| x | nTotal += x } ) '\n AEval( CharHist( \"Hello World !\" ), {| x | nTotal += x } )\n ? ' ==> nTotal == Len( \"Hello World !\" ) ? --> ', nTotal == Len( \"Hello World !\" )\n\n ? \"End test of CharHist()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/wintypes.ch. Defines 10 constants including: __WINTYPES_CH, VOID, UINT, HANDLE, HICON. Defines error handling constants and codes"}, {"role": "assistant", "content": "#ifndef __WINTYPES_CH\n#define __WINTYPES_CH\n\n#include \"cstruct.ch\"\n\n#define VOID CTYPE_VOID\n#define UINT CTYPE_UNSIGNED_INT\n#define HANDLE CTYPE_UNSIGNED_LONG\n#define HICON CTYPE_UNSIGNED_LONG\n#define HBITMAP CTYPE_UNSIGNED_LONG\n#define HCURSOR CTYPE_UNSIGNED_LONG\n#define HBRUSH CTYPE_UNSIGNED_LONG\n#define LPCSTR CTYPE_CHAR_PTR\n#define WNDPROC CTYPE_UNSIGNED_LONG\n#define BOOL CTYPE_LONG\n#define LPVOID CTYPE_VOID_PTR\n#define DWORD CTYPE_UNSIGNED_LONG\n#define WORD CTYPE_UNSIGNED_SHORT\n#define LPCTSTR CTYPE_CHAR_PTR\n#define COLORREF CTYPE_UNSIGNED_LONG\n#define BYTE CTYPE_CHAR\n#define TCHAR CTYPE_UNSIGNED_CHAR\n#define HINSTANCE CTYPE_UNSIGNED_LONG\n#define HMENU CTYPE_UNSIGNED_LONG\n#define HTREEITEM CTYPE_UNSIGNED_LONG\n#define INT CTYPE_INT\n#define int CTYPE_INT\n#define HWND CTYPE_UNSIGNED_LONG\n#define LPARAM CTYPE_LONG\n#define HGLOBAL CTYPE_UNSIGNED_LONG\n#define WPARAM CTYPE_INT\n#define HKEY CTYPE_UNSIGNED_LONG\n#define char CTYPE_CHAR\n#define LONG CTYPE_LONG\n#define BCHAR CTYPE_UNSIGNED_CHAR\n#define WCHAR CTYPE_UNSIGNED_SHORT\n#define DOUBLE CTYPE_DOUBLE\n#define LPTSTR CTYPE_CHAR_PTR\n#define LPSTR CTYPE_CHAR_PTR\n#define ULONG CTYPE_UNSIGNED_LONG\n#define UCHAR CTYPE_UNSIGNED_CHAR\n#define SHORT CTYPE_SHORT\n#define USHORT CTYPE_UNSIGNED_SHORT\n#define PVOID CTYPE_VOID_PTR\n#define ULONG_PTR CTYPE_UNSIGNED_LONG_PTR\n\n#define LPOFNHOOKPROC CTYPE_UNSIGNED_LONG\n#define LPCFHOOKPROC CTYPE_UNSIGNED_LONG\n#define LPFRHOOKPROC CTYPE_UNSIGNED_LONG\n#define LPPAGESETUPHOOK CTYPE_UNSIGNED_LONG\n#define LPPAGEPAINTHOOK CTYPE_UNSIGNED_LONG\n#define LPPRINTHOOKPROC CTYPE_UNSIGNED_LONG\n#define LPSETUPHOOKPROC CTYPE_UNSIGNED_LONG\n\n#define BFFCALLBACK CTYPE_UNSIGNED_LONG\n\n#define HDC CTYPE_UNSIGNED_LONG\n#define HIMAGELIST CTYPE_UNSIGNED_LONG\n\n#ytranslate CTYPE_Int( ) => Int( ) \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/regex.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL regex\n LOCAL aMatch\n LOCAL cStr, nRow := 2, nCol\n LOCAL aSource := { ;\n \"First date to match: 2001-3-21\", ;\n \"2002-12/2\", ;\n \"Another can be 1999/5/12, and succeeds\", ;\n \"Could be 1999/534/12, but this will fail\" }\n\n CLS\n\n @ 0, 15 SAY \"Regular expression scan tests\"\n \n regex := hb_regexComp( \"([0-9]{4})[-/]([0-9]{1,2})[-/]([0-9]{1,2})\" )\n\n FOR EACH cStr IN aSource\n @ nRow, 5 SAY \"String is '\" + cStr + \"'\"\n nRow++\n aMatch := hb_regex( regex, cStr )\n IF ! Empty( aMatch )\n @ nRow, 10 SAY \"Matched: \" + aMatch[ 1 ] + \" ( Year: \" + aMatch[ 2 ] + \", Month: \" + ;\n aMatch[ 3 ] + \", Day: \" + aMatch[ 4 ] + \")\"\n ELSE\n @ nRow, 10 SAY \"Match FAILED!\"\n ENDIF\n nRow += 2\n NEXT\n\n cStr := \"searching 'regex' here:\"\n @ nRow, 5 SAY \"A test of a regex compiled on the fly; \" + cStr\n aMatch := hb_regex( \"(.*)regex(.*)\", cStr )\n nRow++\n IF Empty( aMatch )\n @ nRow, 10 SAY \"NOT FOUND!\"\n ELSE\n @ nRow, 10 SAY \"Found (Before: <<\" + aMatch[ 2 ] + \">>, After: <<\" + aMatch[ 3 ] + \">>)\"\n ENDIF\n\n nRow += 2\n\n cStr := \"A str; with: separators :; here \"\n @ nRow, 5 SAY \"Split test; splitting '\" + cStr + \"' by ':|;'\"\n nRow++\n aMatch := hb_regexSplit( \":|;\", cStr )\n IF Empty( aMatch )\n @ nRow++, 10 SAY \"Test failed\"\n ELSE\n nCol := 10\n FOR EACH cStr IN aMatch\n @ nRow, nCol SAY cStr + \"/\"\n nCol += Len( cStr ) + 1\n NEXT\n nRow++\n ENDIF\n\n cStr := \"A string without separators\"\n @ nRow, 5 SAY \"Split test; splitting '\" + cStr + \"' by ':|;'\"\n nRow++\n aMatch := hb_regexSplit( \":|;\", cStr )\n IF Empty( aMatch )\n @ nRow++, 10 SAY \"Test failed\"\n ELSE\n nCol := 10\n FOR EACH cStr IN aMatch\n @ nRow, nCol SAY cStr + \"/\"\n nCol += Len( cStr ) + 1\n NEXT\n nRow++\n ENDIF\n\n cStr := \"Test for RegexAtX()\"\n @ nRow, 5 SAY \"RegexAtX() test; scanning '\" + cStr + \"' by 'Reg(.x)'\"\n nRow++\n aMatch := hb_regexAtX( \"Reg(.x)\", cStr )\n IF Empty( aMatch )\n @ nRow++, 10 SAY \"Test failed\"\n ELSE\n nCol := 15\n FOR EACH cStr in aMatch\n @ nRow, nCol SAY \"FOUND: '\" + cStr[ 1 ] + \"' Start: \" + hb_ntos( cStr[ 2 ] ) + ;\n \" End: \" + hb_ntos( cStr[ 3 ] )\n nRow++\n NEXT\n nRow++\n ENDIF\n\n @ nRow, 1\n @ MaxRow(), 25 SAY \"Press a key to continue\"\n Inkey( 0 )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/fornext.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL n\n\n ? \"Testing Harbour For Next loops. Going up quick\"\n\n FOR n := 1 TO 10 STEP 4\n ? n\n NEXT\n\n ? \"Going down\"\n\n FOR n := 10 TO 1 STEP -1\n ? n\n NEXT\n\n ? \"No step\"\n\n FOR n := 1 TO 10\n ? n\n NEXT\n\n ? \"No production\"\n\n FOR n := 1 TO 10 STEP -1\n ? n\n NEXT\n\n ? \"Ok!\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/fcopy.prg. Provides 6 functions including: FileCopy, FileCOpen, FileCDaTi, FileCCont, FileCCLose. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n\n#define F_BLOCK 512\n\nTHREAD STATIC t_hSrcFile := F_ERROR\nTHREAD STATIC t_lSetDaTi := .T.\nTHREAD STATIC t_fileTime\n\n\nFUNCTION FileCopy( cSource, cDest, lMode )\n\n LOCAL hDstFile\n LOCAL cBuffer := Space( F_BLOCK )\n LOCAL lDone := .F.\n LOCAL nSrcBytes, nDstBytes, nTotBytes := 0\n\n hb_default( @lMode, .F. )\n\n IF t_hSrcFile != F_ERROR\n FClose( t_hSrcFile )\n ENDIF\n t_hSrcFile := FOpen( cSource, FO_READ )\n IF t_hSrcFile != F_ERROR\n hDstFile := FCreate( cDest )\n IF hDstFile != F_ERROR\n DO WHILE .T.\n nSrcBytes := FRead( t_hSrcFile, @cBuffer, F_BLOCK )\n IF nSrcBytes == 0\n lDone := .T.\n EXIT\n ENDIF\n nDstBytes := FWrite( hDstFile, cBuffer, nSrcBytes )\n IF nDstBytes > 0\n nTotBytes += nDstBytes\n ENDIF\n IF nDstBytes < nSrcBytes\n IF lMode\n FSeek( t_hSrcFile, nDstBytes - nSrcBytes, FS_RELATIVE )\n ENDIF\n EXIT\n ENDIF\n ENDDO\n FClose( hDstFile )\n IF lDone .OR. ! lMode\n FClose( t_hSrcFile )\n t_hSrcFile := F_ERROR\n ENDIF\n hb_FGetDateTime( cSource, @t_fileTime )\n IF t_lSetDaTi .and. !Empty( t_fileTime )\n hb_FSetDateTime( cDest, t_fileTime )\n ENDIF\n ELSE\n FClose( t_hSrcFile )\n t_hSrcFile := F_ERROR\n ENDIF\n ENDIF\n\n RETURN nTotBytes\n\nFUNCTION FileCOpen()\n\n RETURN t_hSrcFile != F_ERROR\n\nFUNCTION FileCDaTi( lNewMode )\n\n LOCAL lOldMode := t_lSetDaTi\n\n IF HB_ISLOGICAL( lNewMode )\n t_lSetDaTi := lNewMode\n ENDIF\n\n RETURN lOldMode\n\nFUNCTION FileCCont( cDest )\n\n LOCAL hDstFile\n LOCAL cBuffer := Space( F_BLOCK )\n LOCAL lDone := .F.\n LOCAL nSrcBytes, nDstBytes, nTotBytes := 0\n\n IF t_hSrcFile != F_ERROR\n hDstFile := FCreate( cDest )\n IF hDstFile != F_ERROR\n DO WHILE .T.\n nSrcBytes := FRead( t_hSrcFile, @cBuffer, F_BLOCK )\n IF nSrcBytes == 0\n lDone := .T.\n EXIT\n ENDIF\n nDstBytes := FWrite( hDstFile, cBuffer, nSrcBytes )\n IF nDstBytes > 0\n nTotBytes += nDstBytes\n ENDIF\n IF nDstBytes < nSrcBytes\n EXIT\n ENDIF\n ENDDO\n FClose( hDstFile )\n IF lDone\n FClose( t_hSrcFile )\n t_hSrcFile := F_ERROR\n ENDIF\n IF t_lSetDaTi .and. !Empty( t_fileTime )\n hb_FSetDateTime( cDest, t_fileTime )\n ENDIF\n ENDIF\n ENDIF\n\n RETURN nTotBytes\n\nFUNCTION FileCCLose()\n\n IF t_hSrcFile != F_ERROR\n FClose( t_hSrcFile )\n t_hSrcFile := F_ERROR\n RETURN .T.\n ENDIF\n\n RETURN .F.\n\nFUNCTION FileAppend( cSrc, cDest )\n\n LOCAL cBuffer := Space( F_BLOCK )\n LOCAL hSrcFile, hDstFile\n LOCAL nSrcBytes, nDstBytes, nTotBytes := 0\n\n hSrcFile := FOpen( cSrc, FO_READ )\n IF hSrcFile != F_ERROR\n IF ! hb_FileExists( cDest )\n hDstFile := FCreate( cDest )\n ELSE\n hDstFile := FOpen( cDest, FO_WRITE )\n FSeek( hDstFile, 0, FS_END )\n ENDIF\n\n IF hDstFile != F_ERROR\n DO WHILE .T.\n nSrcBytes := FRead( hSrcFile, @cBuffer, F_BLOCK )\n IF nSrcBytes == 0\n EXIT\n ENDIF\n nDstBytes := FWrite( hDstFile, cBuffer, nSrcBytes )\n IF nDstBytes < nSrcBytes\n EXIT\n ENDIF\n nTotBytes += nDstBytes\n ENDDO\n FClose( hDstFile )\n ENDIF\n FClose( hSrcFile )\n ENDIF\n\n RETURN nTotBytes"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/at2.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\nPROCEDURE Main()\n\n LOCAL cSearch, cTarget, var0\n\n CLS\n ? \"TEST TO DEMONSTRATE EXAMPLES OF FT_AT2\"\n ?\n cSearch := \"t\"\n ? \"Find occurrences of 't' in: \"\n cTarget := \"This is the day that the Lord has made.\"\n ?? cTarget\n ?\n var0 := ft_At2( cSearch, cTarget )\n ? PadR( \"ft_At2( cSearch, cTarget ) -> \", 40 )\n ?? var0\n ?\n var0 := ft_At2( cSearch, cTarget, 2 )\n ? PadR( \"ft_At2( cSearch, cTarget, 2 ) -> \", 40 )\n ??var0\n ?\n var0 := ft_At2( cSearch, cTarget, 2, .F. )\n ? PadR( \"ft_At2( cSearch, cTarget, 2, .F. ) -> \", 40 )\n ??var0\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour Runtime Library file: src/rtl/tpopup.prg. Defines classes: PopupMenu. This file implements menu system classes"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"box.ch\"\n#include \"button.ch\"\n#include \"color.ch\"\n\n\n#ifdef HB_COMPAT_C53\n\nCREATE CLASS PopupMenu FUNCTION HBPopupMenu\n\n EXPORTED:\n\n VAR cargo\n\n METHOD addItem( oItem )\n METHOD close( lCloseChild )\n METHOD delItem( nPos )\n METHOD display()\n METHOD getAccel( xKey )\n METHOD getFirst()\n METHOD getItem( nPos )\n METHOD getLast()\n METHOD getNext()\n METHOD getPrev()\n METHOD getShortCt( nKey )\n METHOD hitTest( nMRow, nMCol )\n METHOD insItem( nPos, oItem )\n METHOD isOpen()\n METHOD open()\n METHOD select( nPos )\n METHOD setItem( nPos, oItem )\n\n METHOD border( cBorder ) SETGET\n METHOD bottom( nBottom ) SETGET\n METHOD colorSpec( cColorSpec ) SETGET\n METHOD current() SETGET\n METHOD itemCount() SETGET\n METHOD left( nLeft ) SETGET\n METHOD right( nRight ) SETGET\n METHOD top( nTop ) SETGET\n METHOD width() SETGET\n\n METHOD Init( nTop, nLeft, nBottom, nRight ) \n\n PROTECTED:\n\n VAR cBorder INIT HB_B_SINGLE_UNI + HB_SEPARATOR_SINGLE_UNI\n VAR nBottom\n VAR cColorSpec\n VAR nCurrent INIT 0\n VAR nItemCount INIT 0\n VAR nLeft\n VAR nRight\n VAR nTop\n VAR nWidth INIT 0\n\n VAR aItems INIT {}\n VAR aSaveScr\n\n VAR lShadowed INIT .F. \n\n METHOD setMetrics()\n\nENDCLASS\n\nMETHOD addItem( oItem ) CLASS PopupMenu\n\n IF HB_ISOBJECT( oItem ) .AND. oItem:ClassName() == \"MENUITEM\"\n\n AAdd( ::aItems, oItem )\n ::nItemCount++\n\n ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )\n\n ENDIF\n\n RETURN Self\n\nMETHOD close( lCloseChild ) CLASS PopupMenu\n\n __defaultNIL( @lCloseChild, .T. )\n\n IF ::isOpen()\n\n ::setMetrics()\n\n IF ::nCurrent > 0 .AND. ;\n ::aItems[ ::nCurrent ]:isPopUp() .AND. ;\n ::aItems[ ::nCurrent ]:data:isOpen()\n\n ::aItems[ ::nCurrent ]:data:Close()\n ENDIF\n\n RestScreen( ::aSaveScr[ 1 ], ::aSaveScr[ 2 ], ::aSaveScr[ 3 ], ::aSaveScr[ 4 ], ::aSaveScr[ 5 ] )\n\n ::aSaveScr := NIL\n ::nCurrent := 0\n ENDIF\n\n RETURN Self\n\nMETHOD delItem( nPos ) CLASS PopupMenu\n\n LOCAL nLen\n LOCAL nWidth\n LOCAL item\n\n IF nPos >= 1 .AND. nPos <= ::nItemCount\n\n nLen := Len( ::aItems[ nPos ]:caption )\n\n hb_ADel( ::aItems, nPos, .T. )\n ::nItemCount--\n\n IF ::nWidth == nLen + 2\n nWidth := 0\n FOR EACH item IN ::aItems\n nWidth := Max( __CapMetrics( item ), nWidth )\n NEXT\n ::nWidth := nWidth\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD display() CLASS PopupMenu\n\n LOCAL nTop\n LOCAL nLeft\n LOCAL nCurrent\n LOCAL item\n LOCAL nWidth\n LOCAL oPopup\n LOCAL nHotKeyPos\n LOCAL cCaption\n LOCAL nCharPos\n\n IF ::isOpen()\n\n ::setMetrics()\n\n nTop := ::nTop\n nLeft := ::nLeft\n nCurrent := ::nCurrent\n nWidth := ::nWidth\n\n DispBegin()\n\n hb_DispBox( nTop, nLeft, ::nBottom, ::nRight, ;\n SubStr( ::cBorder, 1, 8 ) + \" \", ;\n hb_ColorIndex( ::cColorSpec, 5 ) )\n\n IF ::lShadowed\n hb_Shadow( nTop, nLeft, ::nBottom, ::nRight )\n ENDIF\n\n nLeft++\n FOR EACH item IN ::aItems\n\n nTop++\n\n IF item:__issep\n\n hb_DispOutAtBox( nTop, nLeft - 1, SubStr( ::cBorder, 9, 1 ) + Replicate( SubStr( ::cBorder, 10, 1 ), nWidth ) + SubStr( ::cBorder, 11, 1 ), hb_ColorIndex( ::cColorSpec, 5 ) )\n\n ELSE\n cCaption := PadR( item:caption, nWidth - 1 )\n\n IF item:checked\n cCaption := SubStr( item:style, 1, 1 ) + cCaption\n ELSE\n cCaption := \" \" + cCaption\n ENDIF\n\n IF item:isPopup()\n\n oPopup := item:data\n oPopup:top := nTop\n oPopup:left := ::nRight + 1\n oPopup:bottom := NIL\n oPopup:right := NIL\n\n cCaption += SubStr( item:style, 2, 1 )\n ELSE\n cCaption += \" \"\n ENDIF\n\n item:__row := nTop\n item:__col := nLeft\n\n IF ( nHotKeyPos := At( \"&\", cCaption ) ) == 0\n IF ( nCharPos := RAt( SubStr( item:style, 2, 1 ), cCaption ) ) > 0\n cCaption := Stuff( cCaption, nCharPos - 1, 1, \"\" )\n ELSE\n cCaption := hb_StrShrink( cCaption )\n ENDIF\n ELSEIF nHotKeyPos == Len( RTrim( cCaption ) )\n cCaption := hb_StrShrink( cCaption )\n nHotKeyPos := 0\n ELSE\n cCaption := Stuff( cCaption, nHotKeyPos, 1, \"\" )\n ENDIF\n\n hb_DispOutAt( nTop, nLeft, cCaption, hb_ColorIndex( ::cColorSpec, iif( item:__enumIndex() == nCurrent, 1, iif( item:enabled, 0, 4 ) ) ) )\n\n IF item:enabled .AND. nHotKeyPos != 0\n hb_DispOutAt( nTop, nLeft + nHotKeyPos - 1, SubStr( cCaption, nHotKeyPos, 1 ), hb_ColorIndex( ::cColorSpec, iif( item:__enumIndex() == nCurrent, 3, 2 ) ) )\n ENDIF\n ENDIF\n NEXT\n\n DispEnd()\n\n ENDIF\n\n RETURN Self\n\nMETHOD getAccel( xKey ) CLASS PopupMenu\n\n LOCAL cKey\n LOCAL item\n\n DO CASE\n CASE HB_ISSTRING( xKey )\n cKey := xKey\n CASE HB_ISNUMERIC( xKey )\n cKey := hb_keyChar( xKey )\n OTHERWISE\n RETURN 0\n ENDCASE\n\n IF Len( cKey ) > 0\n cKey := \"&\" + cKey\n FOR EACH item in ::aItems\n IF hb_AtI( cKey, item:caption ) > 0\n RETURN item:__enumIndex()\n ENDIF\n NEXT\n ENDIF\n\n RETURN 0\n\nMETHOD getFirst() CLASS PopupMenu\n\n LOCAL item\n\n FOR EACH item IN ::aItems\n IF item:enabled\n RETURN item:__enumIndex()\n ENDIF\n NEXT\n\n RETURN 0\n\nMETHOD getItem( nPos ) CLASS PopupMenu\n RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ], NIL )\n\nMETHOD getLast() CLASS PopupMenu\n\n LOCAL item\n\n FOR EACH item IN ::aItems DESCEND\n IF item:enabled\n RETURN item:__enumIndex()\n ENDIF\n NEXT\n\n RETURN 0\n\nMETHOD getNext() CLASS PopupMenu\n\n LOCAL nPos\n\n FOR nPos := ::nCurrent + 1 TO ::nItemCount\n IF ::aItems[ nPos ]:enabled\n RETURN nPos\n ENDIF\n NEXT\n\n RETURN 0\n\nMETHOD getPrev() CLASS PopupMenu\n\n LOCAL nPos\n\n FOR nPos := ::nCurrent - 1 TO 1 STEP -1\n IF ::aItems[ nPos ]:enabled\n RETURN nPos\n ENDIF\n NEXT\n\n RETURN 0\n\n\nMETHOD getShortCt( nKey ) CLASS PopupMenu\n\n LOCAL item\n\n FOR EACH item IN ::aItems\n IF item:shortcut == nKey\n RETURN item:__enumIndex()\n ENDIF\n NEXT\n\n RETURN 0\n\n\nMETHOD hitTest( nMRow, nMCol ) CLASS PopupMenu\n\n LOCAL nPos\n\n ::setMetrics()\n\n DO CASE\n CASE nMRow == ::nTop\n IF nMCol == ::nLeft\n RETURN HTTOPLEFT\n ELSEIF nMCol == ::nRight\n RETURN HTTOPRIGHT\n ELSEIF nMCol >= ::nLeft .AND. nMCol <= ::nRight\n RETURN HTTOP\n ENDIF\n CASE nMRow == ::nBottom\n IF nMCol == ::nLeft\n RETURN HTBOTTOMLEFT\n ELSEIF nMCol == ::nRight\n RETURN HTBOTTOMRIGHT\n ELSEIF nMCol >= ::nLeft .AND. nMCol <= ::nRight\n RETURN HTBOTTOM\n ENDIF\n CASE nMCol == ::nLeft\n IF nMRow >= ::nTop .AND. nMRow <= ::nBottom\n RETURN HTLEFT\n ELSE\n RETURN HTNOWHERE\n ENDIF\n CASE nMCol == ::nRight\n IF nMRow >= ::nTop .AND. nMRow <= ::nBottom\n RETURN HTRIGHT\n ELSE\n RETURN HTNOWHERE\n ENDIF\n CASE nMRow > ::nTop .AND. ;\n nMRow < ::nBottom .AND. ;\n nMCol > ::nLeft .AND. ;\n nMCol < ::nRight\n\n nPos := nMRow - ::nTop\n DO CASE\n CASE ::aItems[ nPos ]:__issep\n RETURN HTSEPARATOR\n OTHERWISE\n RETURN nPos\n ENDCASE\n ENDCASE\n\n RETURN HTNOWHERE\n\nMETHOD insItem( nPos, oItem ) CLASS PopupMenu\n\n IF nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;\n HB_ISOBJECT( oItem ) .AND. oItem:ClassName() == \"MENUITEM\"\n\n hb_AIns( ::aItems, nPos, oItem, .T. )\n ::nItemCount++\n\n ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )\n ENDIF\n\n RETURN Self\n\nMETHOD isOpen() CLASS PopupMenu\n RETURN ::aSaveScr != NIL\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/dayofyr.prg. Provides functions: ft_DayOfYr. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_DayOfYr( dGivenDate, nDayNum, lIsAcct )\n\n LOCAL nTemp, aRetVal\n\n IF HB_ISNUMERIC( dGivenDate )\n nDayNum := dGivenDate\n dGivenDate := Date()\n ELSEIF HB_ISLOGICAL( dGivenDate )\n lIsAcct := dGivenDate\n dGivenDate := Date()\n ELSEIF ! HB_ISDATE( dGivenDate )\n dGivenDate := Date()\n ENDIF\n\n IF HB_ISLOGICAL( lIsAcct )\n aRetVal := ft_AcctYear( dGivenDate )\n ELSE\n aRetVal := ft_Year( dGivenDate )\n ENDIF\n\n IF HB_ISNUMERIC( nDayNum )\n nTemp := aRetVal[ 3 ] - aRetVal[ 2 ] + 1\n IF nDayNum < 1 .OR. nDayNum > nTemp\n nDayNum := nTemp\n ENDIF\n aRetVal[ 1 ] := aRetVal[ 2 ] + nDayNum - 1\n ELSE\n aRetVal[ 1 ] += StrZero( dGivenDate - aRetVal[ 2 ] + 1, 3 )\n ENDIF\n\n RETURN aRetVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour contribution module 'hbsqlit3' (SQLite3 database client library): contrib/hbsqlit3/tests/blob.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbsqlit3\"\n\n#define TABLE_SQL \"CREATE TABLE image( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT(50), image BLOB )\"\n\nPROCEDURE Main()\n\n LOCAL lCreateIfNotExist := .T.\n LOCAL db := sqlite3_open( \"test.s3db\", lCreateIfNotExist )\n LOCAL stmt\n LOCAL buff, blob\n\n IF ! Empty( db )\n\n sqlite3_exec( db, \"PRAGMA auto_vacuum=0\" )\n sqlite3_exec( db, \"PRAGMA page_size=8192\" )\n\n sqlite3_exec( db, \"DROP TABLE image\" )\n\n sqlite3_exec( db, TABLE_SQL )\n\n stmt := sqlite3_prepare( db, \"INSERT INTO image( title, image ) VALUES( :title, :image )\" )\n IF ! Empty( stmt )\n buff := sqlite3_file_to_buff( \"pngtest.png\" )\n\n IF sqlite3_bind_text( stmt, 1, \"pngtest.png\" ) == SQLITE_OK .AND. ;\n sqlite3_bind_blob( stmt, 2, @buff ) == SQLITE_OK\n IF sqlite3_step( stmt ) == SQLITE_DONE\n ? \"Save pngtest.png into BLOB\"\n ? \"INSERT INTO image( title, image ) VALUES( 'pngtest.png', 'pngtest.png' ) - Done\"\n ENDIF\n ENDIF\n buff := NIL\n sqlite3_clear_bindings( stmt )\n sqlite3_finalize( stmt )\n ENDIF\n\n ? \"\"\n ? \"The number of database rows that were changed: \" + hb_ntos( sqlite3_changes( db ) )\n ? \"Total changes: \" + hb_ntos( sqlite3_total_changes( db ) )\n ? \"\"\n sqlite3_sleep( 3000 )\n\n blob := sqlite3_blob_open( db, NIL, \"image\", \"image\", sqlite3_last_insert_rowid( db ), 0 )\n IF ! Empty( blob )\n ? \"Open BLOB image - Ok\"\n\n buff := sqlite3_blob_read( blob )\n\n \n ? \"The size in bytes of the blob - \", sqlite3_blob_bytes( blob )\n\n IF sqlite3_buff_to_file( \"pngtest1.png\", @buff ) == SQLITE_OK\n ? \"Save BLOB into pngtest1.png - Done\"\n ENDIF\n\n buff := NIL\n\n sqlite3_blob_close( blob )\n ? \"Close BLOB\"\n ENDIF\n sqlite3_sleep( 3000 )\n\n ? \"\"\n ? \"Save BLOB using sqlite3_column_blob()\"\n stmt := sqlite3_prepare( db, \"SELECT image FROM image WHERE id == ?5 \" )\n IF ! Empty( stmt )\n IF sqlite3_bind_int64( stmt, 5, sqlite3_last_insert_rowid( db ) ) == SQLITE_OK\n IF sqlite3_step( stmt ) == SQLITE_ROW\n buff := sqlite3_column_blob( stmt, 1 )\n IF sqlite3_buff_to_file( \"pngtest2.png\", @buff ) == SQLITE_OK\n ? \"Save BLOB into pngtest2.png - Done\"\n ENDIF\n buff := NIL\n ENDIF\n sqlite3_clear_bindings( stmt )\n sqlite3_finalize( stmt )\n ENDIF\n ENDIF\n WAIT\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbhpdf' (PDF generation library (libharu)): contrib/hbhpdf/misc.prg. Provides functions: hb_HPDF_IsVersion. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "FUNCTION hb_HPDF_IsVersion( ma, mi, mu )\n\n LOCAL HPDF_MAJOR_VERSION, HPDF_MINOR_VERSION, HPDF_BUGFIX_VERSION\n\n hb_HPDF_Version( @HPDF_MAJOR_VERSION, @HPDF_MINOR_VERSION, @HPDF_BUGFIX_VERSION )\n\n RETURN ;\n HPDF_MAJOR_VERSION > ma .OR. ;\n ( HPDF_MAJOR_VERSION == ma .AND. ;\n ( HPDF_MINOR_VERSION > mi .OR. ;\n ( HPDF_MINOR_VERSION == mi .AND. HPDF_BUGFIX_VERSION >= mu ) ) )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/datetime.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "#include \"simpleio.ch\"\n\nPROCEDURE Main()\n\n ? hb_DateTime( 1974 )\n\n ? \" ValType( hb_DateTime() ) =>\", ValType( hb_DateTime() )\n ? \" Year( hb_DateTime() ) =>\", Year( hb_DateTime() )\n ? \" Month( hb_DateTime() ) =>\", Month( hb_DateTime() )\n ? \" Day( hb_DateTime() ) =>\", Day( hb_DateTime() )\n ?\n\n ? \" ValType( hb_DateTime( 1974, 5, 31 ) ) =>\", ValType( hb_DateTime( 1974, 5, 31 ) )\n ? \" Year( hb_DateTime( 1974, 5, 31 ) ) =>\", Year( hb_DateTime( 1974, 5, 31 ) )\n ? \" Month( hb_DateTime( 1974, 5, 31 ) ) =>\", Month( hb_DateTime( 1974, 5, 31 ) )\n ? \" Day( hb_DateTime( 1974, 5, 31 ) ) =>\", Day( hb_DateTime( 1974, 5, 31 ) )\n ? \" DToC( hb_DateTime( 1974, 5, 31 ) ) =>\", DToC( hb_DateTime( 1974, 5, 31 ) )\n ?\n\n ? \" ValType( hb_DateTime( 1974, 31, 5, NIL, NIL, NIL ) ) =>\", ValType( hb_DateTime( 1974, 31, 5, NIL, NIL, NIL ) )\n ?\n\n ? \" ValType( hb_DateTime( 2001, 10, 13, 18, 42, 16 ) ) =>\", ValType( hb_DateTime( 2001, 10, 13, 18, 42, 16 ) )\n ?\n\n ? \" ValType( hb_DateTime( NIL, NIL, NIL, 10, 36, 5 ) ) =>\", ValType( hb_DateTime( NIL, NIL, NIL, 10, 36, 5 ) )\n ? \" hb_DateTime( NIL, NIL, NIL, 10, 36, 5 ) =>\", hb_DateTime( NIL, NIL, NIL, 10, 36, 5 )\n ?\n\n ? \" ValType( hb_DateTime( NIL, NIL, NIL, 10, 36, 5, 176 ) ) =>\", ValType( hb_DateTime( NIL, NIL, NIL, 10, 36, 5, 176 ) )\n ? \" hb_DateTime( NIL, NIL, NIL, 10, 36, 5, 176 ) =>\", hb_DateTime( NIL, NIL, NIL, 10, 36, 5, 176 )\n\n ? \" ValType( hb_DateTime( 0, 0, 0, 10, 36, 5, 176 ) ) =>\", ValType( hb_DateTime( 0, 0, 0, 10, 36, 5, 176 ) )\n ? \" hb_DateTime( 0, 0, 0, 10, 36, 5, 176 ) =>\", hb_DateTime( 0, 0, 0, 10, 36, 5, 176 )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main, DrawFlake, KochFlake. Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/tests/tpoly.prg. Contains procedures: Main, DrawFlake, KochFlake. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbgd\"\n\n#command TurnRight( ) => s_nAngle += Pi() / 3\n#define IMAGES_OUT \"imgs_out\" + hb_ps()\n\nSTATIC s_aCoords\nSTATIC s_nAngle, s_nCoordX, s_nCoordY\n\nPROCEDURE Main()\n\n DrawFlake( .T. )\n DrawFlake( .F. )\n\n RETURN\n\nPROCEDURE DrawFlake( lOpenPoly )\n\n LOCAL nOrder, nSide, nSides, nSideLen\n LOCAL gdImage, gdColor\n LOCAL cImageName\n\n nSides := 3\n nSideLen := 1500\n nOrder := 7\n\n cImageName := iif( lOpenPoly, \"flakeo.png\", \"flake.png\" )\n\n gdImage := gdImageCreate( 1900, 2100 )\n gdImageColorAllocate( gdImage, 0, 0, 0 )\n\n \n s_nCoordX := 200\n s_nCoordY := 600\n s_aCoords := { { s_nCoordX, s_nCoordY } }\n s_nAngle := 0\n\n FOR nSide := 1 TO nSides\n KochFlake( nOrder, nSideLen, .F. )\n s_nAngle += Pi()\n ? hb_StrFormat( \"Drawing %d vertices\", Len( s_aCoords ) )\n\n \n gdColor := gdImageColorAllocate( gdImage, 0, 255, 0 )\n\n IF lOpenPoly\n gdImageOpenPolygon( gdImage, s_aCoords, gdColor )\n ELSE\n gdImagePolygon( gdImage, s_aCoords, gdColor )\n ENDIF\n\n \n s_nCoordX := 200\n s_nCoordY := 600\n s_aCoords := { { s_nCoordX, s_nCoordY } }\n s_nAngle := 0\n\n FOR nSide := 1 TO nSides\n KochFlake( nOrder, nSideLen, .T. )\n s_nAngle += Pi()\n ? hb_StrFormat( \"Drawing %d vertices\", Len( s_aCoords ) )\n\n \n gdColor := gdImageColorAllocate( gdImage, 255, 255, 0 )\n\n IF lOpenPoly\n gdImageOpenPolygon( gdImage, s_aCoords, gdColor )\n ELSE\n gdImagePolygon( gdImage, s_aCoords, gdColor )\n ENDIF\n\n gdImagePng( gdImage, IMAGES_OUT + cImageName )\n\n RETURN\n\nPROCEDURE KochFlake( nOrder, nSideLen, lLeftFirst )\n\n IF nOrder == 0\n AAdd( s_aCoords, { ;\n s_nCoordX += Cos( s_nAngle )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/usrrdd/exmemo.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "REQUEST DBTCDX\nREQUEST FPTCDX\nREQUEST SMTCDX\n\nPROCEDURE Main()\n\n dbCreate( \"table1\", { { \"F1\", \"M\", 4, 0 } }, \"DBTCDX\" )\n dbCreate( \"table2\", { { \"F1\", \"M\", 4, 0 } }, \"FPTCDX\" )\n dbCreate( \"table3\", { { \"F1\", \"M\", 4, 0 } }, \"SMTCDX\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/findith.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\nPROCEDURE Main( cCk, cStr, nOcc, xCase )\n\n LOCAL nFind\n\n IF PCount() != 4\n ? \"usage: findith cCk cStr nOcc xCase\"\n ELSE\n xCase := iif( xCase == \"Y\", .T., .F. )\n nOcc := Val( nOcc )\n ? iif( xCase, \"Ignoring \", \"Observing \" ) + \"case:\"\n\n ? cStr\n nFind := ft_FindITh( cCk, cStr, nOcc, xCase )\n ? iif( nFind > 0, Space( nFind - 1 ) + \"^\", \"Not found\" )\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbmxml' (XML generation library): contrib/hbmxml/tests/testmxml.prg. Contains procedures: Main. This file handles data format parsing and generation"}, {"role": "assistant", "content": "#require \"hbmxml\"\n\n#include \"simpleio.ch\"\n\nREQUEST HB_GT_CGI_DEFAULT\n\nSTATIC s_aTypes := { ;\n \"MXML_ELEMENT\", ;\n \"MXML_INTEGER\", ;\n \"MXML_OPAQUE\", ;\n \"MXML_REAL\", ;\n \"MXML_TEXT\" }\n\nSTATIC s_aSAXEventCounts := { 0, 0, 0, 0, 0, 0 }\n\n\nPROCEDURE Main( cFileArg )\n\n LOCAL hTree \n LOCAL hNode \n LOCAL hInd \n LOCAL nNum, cStr\n LOCAL i\n\n \n IF Empty( cFileArg )\n OutErr( hb_StrFormat( \"Usage: %1$s filename.xml\", hb_ProgName() ) + hb_eol() )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n \n hTree := mxmlNewElement( MXML_NO_PARENT, \"element\" )\n IF Empty( hTree )\n OutErr( \"ERROR: No parent node in basic test!\" + hb_eol() )\n QUIT\n ENDIF\n\n nNum := mxmlGetType( hTree )\n IF nNum != MXML_ELEMENT\n IF nNum < MXML_ELEMENT .OR. nNum > MXML_TEXT\n OutErr( hb_StrFormat( \"ERROR: Parent has type %s (%d), expected MXML_ELEMENT!\", ;\n \"UNKNOWN\", nNum ) + hb_eol() )\n ELSE\n OutErr( hb_StrFormat( \"ERROR: Parent has type %s (%d), expected MXML_ELEMENT!\", ;\n s_aTypes[ nNum + 1 ], nNum ) + hb_eol() )\n ENDIF\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n cStr := mxmlGetElement( hTree )\n IF !( cStr == \"element\" )\n OutErr( hb_StrFormat( \"ERROR: Parent value is '%s', expected 'element'\", cStr ) + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n mxmlNewInteger( hTree, 123 )\n mxmlNewOpaque( hTree, \"opaque\" )\n mxmlNewReal( hTree, 123.4 )\n mxmlNewText( hTree, 1, \"text\" )\n\n mxmlLoadString( hTree, \"string string string\", MXML_NO_CALLBACK )\n mxmlLoadString( hTree, \"1 2 3\", MXML_INTEGER_CALLBACK )\n mxmlLoadString( hTree, \"1.0 2.0 3.0\", MXML_REAL_CALLBACK )\n mxmlLoadString( hTree, \"opaque opaque opaque\", MXML_OPAQUE_CALLBACK )\n mxmlLoadString( hTree, \"valuevalue2\", MXML_OPAQUE_CALLBACK )\n\n IF Empty( hNode := mxmlGetFirstChild( hTree ) )\n OutErr( \"ERROR: No first child in basic test!\" + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n nNum := mxmlGetType( hNode )\n IF nNum != MXML_INTEGER\n IF nNum < MXML_ELEMENT .OR. nNum > MXML_TEXT\n OutErr( hb_StrFormat( \"ERROR: First child has type %s (%d), expected MXML_TEXT!\", ;\n \"UNKNOWN\", nNum ) + hb_eol() )\n ELSE\n OutErr( hb_StrFormat( \"ERROR: First child has type %s (%d), expected MXML_TEXT!\", ;\n s_aTypes[ nNum + 1 ], nNum ) + hb_eol() )\n ENDIF\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n nNum := mxmlGetInteger( hNode )\n IF nNum != 123\n OutErr( hb_StrFormat( \"ERROR: First child value is %d, expected 123!\", nNum ) + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n hNode := mxmlGetNextSibling( hNode )\n IF Empty( hNode )\n OutErr( \"ERROR: No second child node in basic test!\" + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n nNum := mxmlGetType( hNode )\n IF nNum != MXML_OPAQUE\n IF nNum < MXML_ELEMENT .OR. nNum > MXML_TEXT\n OutErr( hb_StrFormat( \"ERROR: Second child has type %s (%d), expected MXML_OPAQUE!\", ;\n \"UNKNOWN\", nNum ) + hb_eol() )\n ELSE\n OutErr( hb_StrFormat( \"ERROR: Second child has type %s (%d), expected MXML_OPAQUE!\", ;\n s_aTypes[ nNum + 1 ], nNum ) + hb_eol() )\n ENDIF\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n hNode := mxmlGetNextSibling( hNode )\n IF Empty( hNode )\n OutErr( \"ERROR: No third child node in basic test!\" + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n nNum := mxmlGetType( hNode )\n IF nNum != MXML_REAL\n IF nNum < MXML_ELEMENT .OR. nNum > MXML_TEXT\n OutErr( hb_StrFormat( \"ERROR: Third child has type %s (%d), expected MXML_REAL!\", ;\n \"UNKNOWN\", nNum ) + hb_eol() )\n ELSE\n OutErr( hb_StrFormat( \"ERROR: Third child has type %s (%d), expected MXML_REAL!\", ;\n s_aTypes[ nNum + 1 ], nNum ) + hb_eol() )\n ENDIF\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n nNum := mxmlGetReal( hNode )\n IF nNum != 123.4\n OutErr( hb_StrFormat( \"ERROR: Third child value is %f, expected 123.4!\", nNum ) + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n hNode := mxmlGetNextSibling( hNode )\n IF Empty( hNode )\n OutErr( \"ERROR: No fourth child node in basic test!\" + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n nNum := mxmlGetType( hNode )\n IF nNum != MXML_TEXT\n IF nNum < MXML_ELEMENT .OR. nNum > MXML_TEXT\n OutErr( hb_StrFormat( \"ERROR: Fourth child has type %s (%d), expected MXML_TEXT!\", ;\n \"UNKNOWN\", nNum ) + hb_eol() )\n ELSE\n OutErr( hb_StrFormat( \"ERROR: Fourth child has type %s (%d), expected MXML_TEXT!\", ;\n s_aTypes[ nNum + 1 ], nNum ) + hb_eol() )\n ENDIF\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n cStr := mxmlGetText( hNode, @nNum )\n IF nNum != 1 .OR. Empty( cStr ) .OR. !( cStr == \"text\" )\n OutErr( hb_StrFormat( \"ERROR: Fourth child value is %d, '%s', expected 1, 'text'!\", ;\n nNum, cStr ) + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n FOR i := 0 TO 3\n IF Empty( hNode := mxmlGetNextSibling( hNode ) )\n OutErr( hb_StrFormat( \"ERROR: No group #%d child node in basic test!\", i ) + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n IF ( ( nNum := mxmlGetType( hNode ) ) != MXML_ELEMENT )\n IF nNum < MXML_ELEMENT .OR. nNum > MXML_TEXT\n OutErr( hb_StrFormat( \"ERROR: Group child #%d has type %s (%d), expected MXML_ELEMENT!\", ;\n i + 1, \"UNKNOWN\", nNum ) + hb_eol() )\n ELSE\n OutErr( hb_StrFormat( \"ERROR: Group child #%d has type %s (%d), expected MXML_ELEMENT!\", ;\n s_aTypes[ nNum + 1 ], nNum ) + hb_eol() )\n ENDIF\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n NEXT\n\n \n hNode := mxmlFindPath( hTree, \"*/two\" )\n IF Empty( hNode )\n OutErr( \"ERROR: Unable to find value for '*/two'.\" + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ELSEIF mxmlGetType( hNode ) != MXML_OPAQUE .OR. !( mxmlGetOpaque( hNode ) == \"value\" )\n OutErr( \"ERROR: Bad value for '*/two'.\" + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n hNode := mxmlFindPath( hTree, \"footwo'.\" + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ELSEIF mxmlGetType( hNode ) != MXML_OPAQUE .OR. !( mxmlGetOpaque( hNode ) == \"value\" )\n OutErr( \"ERROR: Bad value for 'foo\n\n hInd := mxmlIndexNew( hTree )\n IF Empty( hInd )\n OutErr( \"ERROR: Unable to create index of all nodes!\" + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n IF ( nNum := mxmlIndexGetCount( hInd ) ) != 10\n OutErr( hb_StrFormat( \"ERROR: Index of all nodes contains %d nodes; expected 10!\", nNum ) + hb_eol() )\n\n mxmlIndexDelete( hInd )\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n mxmlIndexReset( hInd )\n IF Empty( mxmlIndexFind( hInd, \"group\" ) )\n OutErr( \"ERROR: mxmlIndexFind for 'group' failed!\" + hb_eol() )\n\n mxmlIndexDelete( hInd )\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n\n mxmlIndexDelete( hInd )\n\n hInd := mxmlIndexNew( hTree, \"group\" )\n IF Empty( hInd )\n OutErr( \"ERROR: Unable to create index of groups!\" + hb_eol() )\n\n mxmlDelete( hTree )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour Runtime Library file: src/rtl/langcomp.prg. Provides functions: hb_langSelect, __LangStdToLangHb. This file provides utility functions"}, {"role": "assistant", "content": "#ifdef HB_LEGACY_LEVEL4\n\nREQUEST HB_CODEPAGE_CS852\nREQUEST HB_CODEPAGE_DE850\nREQUEST HB_CODEPAGE_EL737\n#endif\n\nFUNCTION hb_langSelect( cLangID, cCP )\n\n LOCAL tmp\n LOCAL cCPDef\n LOCAL cLangIDBase\n\n IF HB_ISSTRING( cLangID )\n\n cCPDef := hb_cdpSelect()\n\n#ifdef HB_LEGACY_LEVEL4\n\n \n SWITCH Upper( cLangID )\n CASE \"BE866\" ; cCPDef := \"BG866\" ; cLangIDBase := \"be\" ; EXIT\n CASE \"BEWIN\" ; cCPDef := \"BGWIN\" ; cLangIDBase := \"be\" ; EXIT\n CASE \"BG866\" ; cCPDef := \"BG866\" ; cLangIDBase := \"bg\" ; EXIT\n CASE \"BGISO\" ; cCPDef := \"BGISO\" ; cLangIDBase := \"bg\" ; EXIT\n CASE \"BGMIK\" ; cCPDef := \"BGMIK\" ; cLangIDBase := \"bg\" ; EXIT\n CASE \"BGWIN\" ; cCPDef := \"BGWIN\" ; cLangIDBase := \"bg\" ; EXIT\n CASE \"CS852\" ; cCPDef := \"CS852\" ; cLangIDBase := \"cs\" ; EXIT\n CASE \"CSISO\" ; cCPDef := \"CSISO\" ; cLangIDBase := \"cs\" ; EXIT\n CASE \"CSKAM\" ; cCPDef := \"CSKAMC\"; cLangIDBase := \"cs\" ; EXIT\n CASE \"CSWIN\" ; cCPDef := \"CSWIN\" ; cLangIDBase := \"cs\" ; EXIT\n CASE \"DEWIN\" ; cCPDef := \"DEWIN\" ; cLangIDBase := \"de\" ; EXIT\n CASE \"ELWIN\" ; cCPDef := \"ELWIN\" ; cLangIDBase := \"el\" ; EXIT\n CASE \"ESWIN\" ; cCPDef := \"ESWIN\" ; cLangIDBase := \"es\" ; EXIT\n CASE \"HE862\" ; cCPDef := \"HE862\" ; cLangIDBase := \"he\" ; EXIT\n CASE \"HEWIN\" ; cCPDef := \"HEWIN\" ; cLangIDBase := \"he\" ; EXIT\n CASE \"HR646\" ; cCPDef := \"HR646\" ; cLangIDBase := \"hr\" ; EXIT\n CASE \"HR852\" ; cCPDef := \"HR852\" ; cLangIDBase := \"hr\" ; EXIT\n CASE \"HRISO\" ; cCPDef := \"HRISO\" ; cLangIDBase := \"hr\" ; EXIT\n CASE \"HRWIN\" ; cCPDef := \"HRWIN\" ; cLangIDBase := \"hr\" ; EXIT\n CASE \"HU852\" ; cCPDef := \"HU852\" ; cLangIDBase := \"hu\" ; EXIT\n CASE \"HUISO\" ; cCPDef := \"HUISO\" ; cLangIDBase := \"hu\" ; EXIT\n CASE \"HUWIN\" ; cCPDef := \"HUWIN\" ; cLangIDBase := \"hu\" ; EXIT\n CASE \"IS850\" ; cCPDef := \"IS850\" ; cLangIDBase := \"is\" ; EXIT\n CASE \"LTWIN\" ; cCPDef := \"LTWIN\" ; cLangIDBase := \"lt\" ; EXIT\n CASE \"PL852\" ; cCPDef := \"PL852\" ; cLangIDBase := \"pl\" ; EXIT\n CASE \"PLISO\" ; cCPDef := \"PLISO\" ; cLangIDBase := \"pl\" ; EXIT\n CASE \"PLMAZ\" ; cCPDef := \"PLMAZ\" ; cLangIDBase := \"pl\" ; EXIT\n CASE \"PLWIN\" ; cCPDef := \"PLWIN\" ; cLangIDBase := \"pl\" ; EXIT\n CASE \"PTISO\" ; cCPDef := \"PTISO\" ; cLangIDBase := \"pt\" ; EXIT\n CASE \"RU866\" ; cCPDef := \"RU866\" ; cLangIDBase := \"ru\" ; EXIT\n CASE \"RUKOI8\" ; cCPDef := \"RUKOI8\"; cLangIDBase := \"ru\" ; EXIT\n CASE \"RUWIN\" ; cCPDef := \"RU1251\"; cLangIDBase := \"ru\" ; EXIT\n CASE \"SK852\" ; cCPDef := \"SK852\" ; cLangIDBase := \"sk\" ; EXIT\n CASE \"SKISO\" ; cCPDef := \"SKISO\" ; cLangIDBase := \"sk\" ; EXIT\n CASE \"SKKAM\" ; cCPDef := \"SKKAMC\"; cLangIDBase := \"sk\" ; EXIT\n CASE \"SKWIN\" ; cCPDef := \"SKWIN\" ; cLangIDBase := \"sk\" ; EXIT\n CASE \"SL646\" ; cCPDef := \"SL646\" ; cLangIDBase := \"sl\" ; EXIT\n CASE \"SL852\" ; cCPDef := \"SL852\" ; cLangIDBase := \"sl\" ; EXIT\n CASE \"SLISO\" ; cCPDef := \"SLISO\" ; cLangIDBase := \"sl\" ; EXIT\n CASE \"SLWIN\" ; cCPDef := \"SLWIN\" ; cLangIDBase := \"sl\" ; EXIT\n CASE \"SR852\" ; cCPDef := \"SL852\" ; cLangIDBase := \"sr_lat\" ; EXIT\n CASE \"SRISO\" ; cCPDef := \"SLISO\" ; cLangIDBase := \"sr_lat\" ; EXIT\n CASE \"SRWIN\" ; cCPDef := \"SRWIN\" ; cLangIDBase := \"sr_cyr\" ; EXIT\n CASE \"SVWIN\" ; cCPDef := \"SVWIN\" ; cLangIDBase := \"sv\" ; EXIT\n CASE \"TR857\" ; cCPDef := \"TR857\" ; cLangIDBase := \"tr\" ; EXIT\n CASE \"TRWIN\" ; cCPDef := \"TRWIN\" ; cLangIDBase := \"tr\" ; EXIT\n CASE \"UA866\" ; cCPDef := \"UA866\" ; cLangIDBase := \"uk\" ; EXIT\n CASE \"UADOS\" ; cCPDef := \"UA1125\"; cLangIDBase := \"uk\" ; EXIT\n CASE \"UAKOI8\" ; cCPDef := \"UAKOI8\"; cLangIDBase := \"uk\" ; EXIT\n CASE \"UAWIN\" ; cCPDef := \"UA1251\"; cLangIDBase := \"uk\" ; EXIT\n CASE \"ZHB5\" ; cCPDef := \"BIG5\" ; cLangIDBase := \"zh\" ; EXIT\n CASE \"ZHGB\" ; cCPDef := \"GBK\" ; cLangIDBase := \"zh_sim\" ; EXIT\n OTHERWISE\n \n SWITCH cLangID\n CASE \"CA\" ; cCPDef := \"DE850\" ; cLangIDBase := \"ca\" ; EXIT\n CASE \"DE\" ; cCPDef := \"DE850\" ; cLangIDBase := \"de\" ; EXIT\n CASE \"EL\" ; cCPDef := \"EL737\" ; cLangIDBase := \"el\" ; EXIT\n CASE \"EO\" ; cCPDef := \"DE850\" ; cLangIDBase := \"eo\" ; EXIT\n CASE \"ES\" ; cCPDef := \"DE850\" ; cLangIDBase := \"es\" ; EXIT\n CASE \"EU\" ; cCPDef := \"DE850\" ; cLangIDBase := \"eu\" ; EXIT\n CASE \"FR\" ; cCPDef := \"DE850\" ; cLangIDBase := \"fr\" ; EXIT\n CASE \"GL\" ; cCPDef := \"DE850\" ; cLangIDBase := \"gl\" ; EXIT\n CASE \"ID\" ; cCPDef := \"EN\" ; cLangIDBase := \"id\" ; EXIT\n CASE \"IT\" ; cCPDef := \"DE850\" ; cLangIDBase := \"it\" ; EXIT\n \n CASE \"NL\" ; cCPDef := \"EN\" ; cLangIDBase := \"nl\" ; EXIT\n CASE \"PT\" ; cCPDef := \"DE850\" ; cLangIDBase := \"pt\" ; EXIT\n CASE \"RO\" ; cCPDef := \"CS852\" ; cLangIDBase := \"ro\" ; EXIT\n CASE \"SV\" ; cCPDef := \"DE850\" ; cLangIDBase := \"sv\" ; EXIT\n ENDSWITCH\n ENDSWITCH\n\n#endif\n\n IF ! HB_ISSTRING( cCP )\n cCP := cCPDef\n ENDIF\n\n#ifdef HB_LEGACY_LEVEL4\n IF Empty( cLangIDBase )\n#endif\n \n IF Empty( tmp := __LangStdToLangHb( cLangID ) )\n \n cLangIDBase := cLangID\n ELSE\n cLangID := cLangIDBase := tmp\n ENDIF\n#ifdef HB_LEGACY_LEVEL4\n ELSE\n \n cLangID := cLangIDBase\n ENDIF\n#endif\n\n IF ! hb_cdpIsUTF8( cCP )\n cLangID += \".\" + cCP\n hb_langNew( cLangID, cCP, cLangIDBase, \"UTF8\" )\n ENDIF\n ENDIF\n\n RETURN __hb_langSelect( cLangID )\n\nSTATIC FUNCTION __LangStdToLangHb( cLangStd )\n\n LOCAL cLangHb := \"\"\n\n IF HB_ISSTRING( cLangStd )\n SWITCH Lower( StrTran( cLangStd, \"_\", \"-\" ) )\n CASE \"be\" ; cLangHb := \"be\" ; EXIT\n CASE \"bg-bg\"\n CASE \"bg\" ; cLangHb := \"bg\" ; EXIT\n CASE \"ca-es\"\n CASE \"ca\" ; cLangHb := \"ca\" ; EXIT\n CASE \"cs-cz\"\n CASE \"cs\" ; cLangHb := \"cs\" ; EXIT\n CASE \"de-at\" ; cLangHb := \"de_at\" ; EXIT\n CASE \"de-ch\"\n CASE \"de-de\"\n CASE \"de-li\"\n CASE \"de-lu\"\n CASE \"de\" ; cLangHb := \"de\" ; EXIT\n CASE \"el-gr\"\n CASE \"el\" ; cLangHb := \"el\" ; EXIT\n CASE \"en-au\"\n CASE \"en-bz\"\n CASE \"en-ca\"\n CASE \"en-cb\"\n CASE \"en-gb\"\n CASE \"en-ie\"\n CASE \"en-jm\"\n CASE \"en-nz\"\n CASE \"en-ph\"\n CASE \"en-tt\"\n CASE \"en-us\"\n CASE \"en-za\"\n CASE \"en-zw\"\n CASE \"en\" ; cLangHb := \"en\" ; EXIT\n CASE \"eo\" ; cLangHb := \"eo\" ; EXIT\n CASE \"es-419\" ; cLangHb := \"es_419\" ; EXIT\n CASE \"es-ar\"\n CASE \"es-bo\"\n CASE \"es-cl\"\n CASE \"es-co\"\n CASE \"es-cr\"\n CASE \"es-do\"\n CASE \"es-ec\"\n CASE \"es-es\"\n CASE \"es-gt\"\n CASE \"es-hn\"\n CASE \"es-mx\"\n CASE \"es-ni\"\n CASE \"es-pa\"\n CASE \"es-pe\"\n CASE \"es-pr\"\n CASE \"es-py\"\n CASE \"es-sv\"\n CASE \"es-uy\"\n CASE \"es-ve\"\n CASE \"es\" ; cLangHb := \"es\" ; EXIT\n CASE \"eu-es\"\n CASE \"eu\" ; cLangHb := \"eu\" ; EXIT\n CASE \"fr-be\"\n CASE \"fr-ca\"\n CASE \"fr-ch\"\n CASE \"fr-fr\"\n CASE \"fr-lu\"\n CASE \"fr-mc\"\n CASE \"fr\" ; cLangHb := \"fr\" ; EXIT\n CASE \"gl-es\"\n CASE \"gl\" ; cLangHb := \"gl\" ; EXIT\n CASE \"he-il\"\n CASE \"he\" ; cLangHb := \"he\" ; EXIT\n CASE \"hr-hr\"\n CASE \"hr\" ; cLangHb := \"hr\" ; EXIT\n CASE \"hu-hu\"\n CASE \"hu\" ; cLangHb := \"hu\" ; EXIT\n CASE \"id-id\"\n CASE \"id\" ; cLangHb := \"id\" ; EXIT\n CASE \"is-is\"\n CASE \"is\" ; cLangHb := \"is\" ; EXIT\n CASE \"it-ch\"\n CASE \"it-it\"\n CASE \"it\" ; cLangHb := \"it\" ; EXIT\n CASE \"ko-kr\"\n CASE \"ko\" ; cLangHb := \"ko\" ; EXIT\n CASE \"lt-lt\"\n CASE \"lt\" ; cLangHb := \"lt\" ; EXIT\n CASE \"nl-be\"\n CASE \"nl-nl\""}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: RadioGroup. Harbour Runtime Library file: src/rtl/radiogrp.prg. Defines classes: RadioGroup. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"box.ch\"\n#include \"button.ch\"\n#include \"color.ch\"\n#include \"setcurs.ch\"\n\n\n#ifdef HB_COMPAT_C53\n\nCREATE CLASS RadioGroup FUNCTION HBRadioGroup\n\n EXPORTED:\n\n VAR cargo\n\n METHOD addItem( oRadioButton )\n METHOD delItem( nPos )\n METHOD display()\n METHOD getAccel( xKey )\n METHOD getItem( nPos )\n METHOD hitTest( nMRow, nMCol )\n METHOD insItem( nPos, oRadioButton )\n METHOD killFocus()\n METHOD nextItem()\n METHOD prevItem()\n METHOD select( xValue )\n METHOD setColor( cColorSpec )\n METHOD setFocus()\n METHOD setStyle( cStyle )\n\n METHOD bottom( nBottom ) SETGET\n METHOD buffer() SETGET\n METHOD capCol( nCapCol ) SETGET\n METHOD capRow( nCapRow ) SETGET\n METHOD caption( cCaption ) SETGET\n METHOD coldBox( cColdBox ) SETGET\n METHOD colorSpec( cColorSpec ) SETGET\n METHOD fBlock( bFBlock ) SETGET\n METHOD hasFocus() SETGET\n METHOD hotBox( cHotBox ) SETGET\n METHOD itemCount() SETGET\n METHOD left( nLeft ) SETGET\n METHOD message( cMessage ) SETGET\n METHOD right( nRight ) SETGET\n METHOD textValue() SETGET \n METHOD top( nTop ) SETGET\n METHOD typeOut() SETGET\n METHOD value() SETGET \n\n METHOD Init( nTop, nLeft, nBottom, nRight ) \n\n PROTECTED:\n\n VAR nBottom\n VAR xBuffer\n VAR nCapCol\n VAR nCapRow\n VAR cCaption INIT \"\"\n VAR cColdBox INIT HB_B_SINGLE_UNI\n VAR cColorSpec\n VAR bFBlock\n VAR lHasFocus INIT .F.\n VAR cHotBox INIT HB_B_DOUBLE_UNI\n VAR nItemCount INIT 0\n VAR nLeft\n VAR cMessage INIT \"\"\n VAR nRight\n VAR cTextValue INIT \"\"\n VAR nTop\n VAR nValue INIT 0\n\n VAR aItems INIT {}\n VAR nCursor INIT 0\n\n METHOD changeButton( nUnselect, nSelect )\n\nENDCLASS\n\nMETHOD addItem( oRadioButton ) CLASS RadioGroup\n\n IF HB_ISOBJECT( oRadioButton ) .AND. oRadioButton:ClassName() == \"RADIOBUTTN\"\n AAdd( ::aItems, oRadioButton )\n ::nItemCount++\n ENDIF\n\n RETURN Self\n\nMETHOD delItem( nPos ) CLASS RadioGroup\n\n IF nPos >= 1 .AND. nPos <= ::nItemCount\n hb_ADel( ::aItems, nPos, .T. )\n ::nItemCount--\n ENDIF\n\n IF ::lHasFocus .AND. ::nItemCount < ::nValue\n ::nValue := ::nItemCount\n ::cTextValue := ::aItems[ ::nValue ]:data\n ::xBuffer := iif( HB_ISNUMERIC( ::xBuffer ), ::nValue, ::cTextValue )\n ENDIF\n\n RETURN Self\n\nMETHOD display() CLASS RadioGroup\n\n LOCAL cSelBox\n LOCAL cUnSelBox\n LOCAL cCaption\n LOCAL nPos\n\n DispBegin()\n\n IF ::lHasFocus\n cSelBox := ::cHotBox\n cUnSelBox := ::cColdbox\n ELSE\n cSelBox := ::cColdbox\n cUnSelBox := ::cHotBox\n ENDIF\n\n DO CASE\n CASE ! Empty( cSelBox )\n hb_DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, cSelBox, hb_ColorIndex( ::cColorSpec, 0 ) )\n CASE ! Empty( cUnSelBox )\n hb_DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, cUnSelBox, hb_ColorIndex( ::cColorSpec, 0 ) )\n ENDCASE\n\n IF ! Empty( cCaption := ::cCaption )\n\n IF ( nPos := At( \"&\", cCaption ) ) > 0\n IF nPos == Len( cCaption )\n nPos := 0\n ELSE\n cCaption := Stuff( cCaption, nPos, 1, \"\" )\n ENDIF\n ENDIF\n\n hb_DispOutAt( ::nCapRow, ::nCapCol, cCaption, hb_ColorIndex( ::cColorSpec, 1 ) )\n\n IF nPos > 0\n hb_DispOutAt( ::nCapRow, ::nCapCol + nPos - 1, SubStr( cCaption, nPos, 1 ), hb_ColorIndex( ::cColorSpec, 2 ) )\n ENDIF\n ENDIF\n\n AEval( ::aItems, {| o | o:display() } )\n\n DispEnd()\n\n RETURN Self\n\nMETHOD getAccel( xKey ) CLASS RadioGroup\n\n LOCAL cKey\n\n DO CASE\n CASE HB_ISSTRING( xKey )\n cKey := xKey\n CASE HB_ISNUMERIC( xKey )\n cKey := hb_keyChar( xKey )\n OTHERWISE\n RETURN 0\n ENDCASE\n\n IF Len( cKey ) > 0\n cKey := Lower( cKey )\n RETURN AScan( ::aItems, {| o | o:isAccel( cKey ) } )\n ENDIF\n\n RETURN 0\n\nMETHOD getItem( nPos ) CLASS RadioGroup\n RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ], NIL )\n\nMETHOD hitTest( nMRow, nMCol ) CLASS RadioGroup\n\n LOCAL nLen\n LOCAL nPos\n LOCAL item\n\n DO CASE\n CASE Empty( ::cColdbox + ::cHotBox )\n CASE nMRow == ::nTop\n DO CASE\n CASE nMCol == ::nLeft\n RETURN HTTOPLEFT\n CASE nMCol == ::nRight\n RETURN HTTOPRIGHT\n CASE nMCol >= ::nLeft .AND. nMCol <= ::nRight\n RETURN HTTOP\n ENDCASE\n CASE nMRow == ::nBottom\n DO CASE\n CASE nMCol == ::nLeft\n RETURN HTBOTTOMLEFT\n CASE nMCol == ::nRight\n RETURN HTBOTTOM\n CASE nMCol >= ::nLeft .AND. nMCol <= ::nRight\n RETURN HTBOTTOMRIGHT\n ENDCASE\n CASE nMCol == ::nLeft\n IF nMRow >= ::nTop .AND. ;\n nMRow <= ::nBottom\n RETURN HTLEFT\n ELSE\n RETURN HTNOWHERE\n ENDIF\n CASE nMCol == ::nRight\n IF nMRow >= ::nTop .AND. ;\n nMRow <= ::nBottom\n RETURN HTRIGHT\n ELSE\n RETURN HTNOWHERE\n ENDIF\n ENDCASE\n\n nLen := Len( ::cCaption )\n\n IF ( nPos := At( \"&\", ::cCaption ) ) > 0 .AND. nPos < nLen\n nLen--\n ENDIF\n\n DO CASE\n CASE Empty( ::cCaption )\n CASE nMRow != ::nCapRow\n CASE nMCol < ::nCapCol\n CASE nMCol < ::nCapCol + nLen\n RETURN HTCAPTION\n ENDCASE\n\n DO CASE\n CASE nMRow < ::nTop\n CASE nMRow > ::nBottom\n CASE nMCol < ::nLeft\n CASE nMCol <= ::nRight\n FOR EACH item IN ::aItems\n IF item:hitTest( nMRow, nMCol ) != HTNOWHERE\n RETURN item:__enumIndex()\n ENDIF\n NEXT\n RETURN HTCLIENT\n ENDCASE\n\n RETURN HTNOWHERE\n\nMETHOD insItem( nPos, oRadioButton ) CLASS RadioGroup\n\n IF HB_ISOBJECT( oRadioButton ) .AND. oRadioButton:ClassName() == \"RADIOBUTTN\" .AND. ;\n nPos < ::nItemCount\n\n hb_AIns( ::aItems, nPos, oRadioButton, .T. )\n ::nItemCount++\n ENDIF\n\n RETURN ::aItems[ nPos ]\n\nMETHOD killFocus() CLASS RadioGroup\n\n LOCAL item\n\n LOCAL nOldMCur\n\n IF ::lHasFocus\n\n ::lHasFocus := .F.\n\n IF HB_ISEVALITEM( ::bFBlock )\n Eval( ::bFBlock )\n ENDIF\n\n nOldMCur := MSetCursor( .F. )\n\n DispBegin()\n\n FOR EACH item IN ::aItems\n item:killFocus()\n NEXT\n\n ::display()\n\n DispEnd()\n\n MSetCursor( nOldMCur )\n SetCursor( ::nCursor )\n ENDIF\n\n RETURN Self\n\nMETHOD setFocus() CLASS RadioGroup\n\n LOCAL item\n\n LOCAL nOldMCur\n\n IF ! ::lHasFocus\n\n ::nCursor := SetCursor( SC_NONE )\n ::lHasFocus := .T.\n\n nOldMCur := MSetCursor( .F. )\n\n DispBegin()\n\n FOR EACH item IN ::aItems\n item:setFocus()\n NEXT\n\n ::display()\n\n DispEnd()\n\n MSetCursor( nOldMCur )\n\n IF HB_ISEVALITEM( ::bFBlock )\n Eval( ::bFBlock )\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD nextItem() CLASS RadioGroup\n\n LOCAL nValue\n\n IF ::lHasFocus .AND. ::nItemCount > 0\n ::changeButton( nValue := ::nValue, iif( nValue == ::nItemCount, 1, nValue + 1 ) )\n ENDIF\n\n RETURN Self\n\nMETHOD prevItem() CLASS RadioGroup\n\n LOCAL nValue\n LOCAL nPos\n\n IF ::lHasFocus .AND. ::nItemCount > 0\n\n nValue := ::nValue\n\n DO CASE\n CASE nValue == 0 ; nPos := 1\n CASE nValue == 1 ; nPos := ::nItemCount\n OTHERWISE ; nPos := nValue - 1\n ENDCASE\n\n ::changeButton( nValue, nPos )\n ENDIF\n\n RETURN Self\n\nMETHOD select( xValue ) CLASS RadioGroup\n\n LOCAL nPos\n LOCAL nLen\n\n SWITCH ValType( xValue )\n CASE \"C\"\n\n nLen := ::nItemCount\n FOR nPos := 1 TO nLen\n IF ::aItems[ nPos ]:data == xValue\n\n IF ::xBuffer == NIL\n ::xBuffer := \"\"\n ENDIF\n\n ::changeButton( ::nValue, nPos )\n\n EXIT\n ENDIF\n NEXT\n\n IF nPos > nLen\n ::xBuffer := xValue\n ENDIF\n EXIT\n\n CASE \"N\"\n\n IF xValue >= 1 .AND. xValue <= ::nItemCount\n IF ::xBuffer == NIL\n ::xBuffer := 0\n ENDIF\n\n ::changeButton( ::nValue, xValue )\n ENDIF\n EXIT\n\n ENDSWITCH\n\n RETURN Self\n\nMETHOD setColor( cColorSpec ) CLASS RadioGroup\n\n LOCAL item\n\n FOR EACH item IN ::aItems"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/dectobin.prg. Provides functions: ft_Dec2Bin. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_Dec2Bin( x )\n\n LOCAL buffer := { \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\", \"0\" }\n LOCAL i\n\n FOR i := 8 TO 1 STEP -1\n IF x >= 2 ^ ( i - 1 )\n x -= 2 ^ ( i - 1 )\n buffer[ 9 - i ] := \"1\"\n ENDIF\n NEXT\n\n RETURN ;\n buffer[ 1 ] + buffer[ 2 ] + buffer[ 3 ] + buffer[ 4 ] + ;\n buffer[ 5 ] + buffer[ 6 ] + buffer[ 7 ] + buffer[ 8 ]"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main, fi_Error. Harbour contribution module 'hbfimage' (FreeImage library wrapper): contrib/hbfimage/tests/test.prg. Contains procedures: Main, fi_Error. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbfimage\"\n\n#include \"fileio.ch\"\n#include \"simpleio.ch\"\n\n#define IMAGES_IN \"\"\n#define IMAGES_OUT \"imgs_out\" + hb_ps()\n\nPROCEDURE Main()\n\n LOCAL im, clone, rotated, rotatedEx, rescale, im2, im3\n LOCAL centerX, centerY, width, height\n\n LOCAL bkcolor\n LOCAL bmpinfo\n LOCAL nH, nLen, cStr\n\n AltD()\n \n IF ! hb_DirExists( IMAGES_OUT )\n hb_DirCreate( IMAGES_OUT )\n ENDIF\n\n ? \"Initialise\"\n fi_Initialise()\n\n \n ? \"Version :\", fi_GetVersion()\n ? \"Copyright :\", fi_GetCopyrightMessage()\n ? \"File type :\", fi_GetFileType( IMAGES_IN + \"sample1.jpg\" )\n\n ? \"Set Error Message (symbol):\", fi_SetOutputMessage( @fi_Error() )\n im := fi_Load( FIF_JPEG, IMAGES_IN + \"nothere.jpg\", JPEG_DEFAULT )\n ? \"Set Error Message (block):\", fi_SetOutputMessage( {| cFormat, cMessage | fi_Error( cFormat, cMessage ) } )\n im := fi_Load( FIF_JPEG, IMAGES_IN + \"nothere.jpg\", JPEG_DEFAULT )\n\n ? \"Load JPEG directly from file\"\n im := fi_Load( FIF_JPEG, IMAGES_IN + \"sample1.jpg\", JPEG_DEFAULT )\n\n ? \"Clone image\"\n clone := fi_Clone( im )\n\n ? \"Pointer :\", hb_ValToExp( im )\n\n ? \"Image Type :\", fi_GetImageType( im )\n ? \"Color Used :\", fi_GetColorsUsed( im )\n ? \"Pixel size :\", fi_GetBPP( im )\n ? \"Width :\", fi_GetWidth( im )\n ? \"Height :\", fi_GetHeight( im )\n ? \"Byte Size :\", fi_GetLine( im )\n ? \"Pitch :\", fi_GetPitch( im )\n ? \"DIB Size :\", fi_GetDIBSize( im )\n ? \"Dots per Meter X :\", fi_GetDotsPerMeterX( im )\n ? \"Dots per Meter Y :\", fi_GetDotsPerMeterY( im )\n ? \"Color Type :\", fi_GetColorType( im )\n ? \"Red Mask :\", fi_GetRedMask( im )\n ? \"Green Mask :\", fi_GetGreenMask( im )\n ? \"Blue Mask :\", fi_GetBlueMask( im )\n ? \"Transp. Count :\", fi_GetTransparencyCount( im )\n ? \"Is Transparent ? :\", fi_IsTransparent( im )\n ?\n ? \"Save BMP ? :\", fi_Save( FIF_BMP , im, IMAGES_OUT + \"sample1.bmp\", BMP_DEFAULT )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im, IMAGES_OUT + \"sample1.jpg\", JPEG_DEFAULT )\n ? \"Save PNG ? :\", fi_Save( FIF_PNG , im, IMAGES_OUT + \"sample1.png\", PNG_DEFAULT )\n\n ? \"Save TIFF ? :\", fi_Save( FIF_TIFF, clone, IMAGES_OUT + \"sample1.tif\", TIFF_DEFAULT )\n ? \"Flip Horizontal ?:\", fi_FlipHorizontal( clone )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, clone, IMAGES_OUT + \"horizont.jpg\", JPEG_DEFAULT )\n ? \"Flip Vertical ? :\", fi_FlipVertical( clone )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, clone, IMAGES_OUT + \"vertical.jpg\", JPEG_DEFAULT )\n\n ? \"Rotate Classic :\", hb_ValToExp( rotated := fi_RotateClassic( clone, 90 ) )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, rotated, IMAGES_OUT + \"rotate.jpg\", JPEG_DEFAULT )\n\n centerx := fi_GetWidth( clone ) / 2\n centery := fi_GetHeight( clone ) / 2\n ? \"Rotate Ex :\", hb_ValToExp( rotatedEx := fi_RotateEx( clone, 15, 0, 0, centerx, centery, .T. ) )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, rotatedEx, IMAGES_OUT + \"rotateex.jpg\", JPEG_DEFAULT )\n\n width := fi_GetWidth( im )\n height := fi_GetHeight( im )\n\n ? \"Rescale :\", hb_ValToExp( rescale := fi_Rescale( im, width / 2, height / 2, FILTER_BICUBIC ) )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, rescale, IMAGES_OUT + \"rescale.jpg\", JPEG_DEFAULT )\n\n im2 := fi_Clone( im )\n ? \"Adjust Gamma ? :\", fi_AdjustGamma( im2, 3.0 )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im2, IMAGES_OUT + \"adjgamma.jpg\", JPEG_DEFAULT )\n\n im2 := fi_Clone( im )\n ? \"Adjust Brightness:\", fi_AdjustBrightness( im2, - 30 )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im2, IMAGES_OUT + \"adjbrigh.jpg\", JPEG_DEFAULT )\n\n im2 := fi_Clone( im )\n ? \"Adjust Contrast ?:\", fi_AdjustContrast( im2, - 30 )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im2, IMAGES_OUT + \"adjcontr.jpg\", JPEG_DEFAULT )\n\n im2 := fi_Clone( im )\n ? \"Invert ? :\", fi_Invert( im2 )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im2, IMAGES_OUT + \"invert.jpg\", JPEG_DEFAULT )\n\n ? \"Red Channel :\", hb_ValToExp( im2 := fi_GetChannel( im, FICC_RED ) )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im2, IMAGES_OUT + \"red.jpg\", JPEG_DEFAULT )\n\n ? \"Green Channel :\", hb_ValToExp( im2 := fi_GetChannel( im, FICC_GREEN ) )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im2, IMAGES_OUT + \"green.jpg\", JPEG_DEFAULT )\n\n ? \"Blue Channel :\", hb_ValToExp( im2 := fi_GetChannel( im, FICC_BLUE ) )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im2, IMAGES_OUT + \"blue.jpg\", JPEG_DEFAULT )\n\n ? \"Copy :\", hb_ValToExp( im2 := fi_Copy( im, 300, 100, 800, 200 ) )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im2, IMAGES_OUT + \"copy.jpg\", JPEG_DEFAULT )\n\n im3 := fi_Clone( im )\n ? \"Paste ? :\", fi_Paste( im3, im2, 10, 10, 70 )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im3, IMAGES_OUT + \"paste.jpg\", JPEG_DEFAULT )\n\n ? \"Allocate Bitmap :\", hb_ValToExp( im3 := fi_AllocateT( FIT_BITMAP, 320, 200, 32 ) )\n ? \"Save JPG ? :\", fi_Save( FIF_JPEG, im3, IMAGES_OUT + \"allocate.jpg\", JPEG_DEFAULT )\n\n ? \"Create ERROR :\"\n ? \"Save GIF ? :\", fi_Save( FIF_GIF, im, IMAGES_OUT + \"wrong.gif\", 0 )\n\n bkcolor := hb_BChar( 0 ) + hb_BChar( 0 ) + hb_BChar( 205 ) + hb_BChar( 0 ) \n ? fi_SetBackgroundColor( im, bkcolor )\n ? fi_GetBackgroundColor( im, @bkcolor )\n ? hb_StrToHex( bkcolor )\n\n\n IF ( nH := FOpen( IMAGES_IN + \"sample1.jpg\" ) ) != F_ERROR\n nLen := FSeek( nH, 0, FS_END )\n FSeek( nH, 0, FS_SET )\n cStr := Space( nLen )\n FRead( nH, @cStr, nLen )\n FClose( nH )\n\n ? \"Load JPEG from memory\"\n im := fi_LoadFromMemory( FIF_JPEG, cStr, JPEG_DEFAULT )\n\n ? \"Pointer :\", hb_ValToExp( im )\n ? \"Image Type :\", fi_GetImageType( im )\n ? \"Save PNG ? :\", fi_Save( FIF_PNG, im, IMAGES_OUT + \"sample2.png\", PNG_DEFAULT )\n ENDIF\n\n \n ? \"DeInitialise\"\n fi_DeInitialise()\n\n ?\n ? \"Look at \" + IMAGES_OUT + \" folder for output images\"\n ?\n\n RETURN\n\nSTATIC PROCEDURE fi_Error( cFormat, cMessage )\n\n ? \"ERROR!..\"\n ? \"Format : \", cFormat\n ? \"Message: \", cMessage\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour extra library: extras/rddado/tests/access1.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"rddado\"\n\n#include \"adordd.ch\"\n\nREQUEST ADORDD\n\nPROCEDURE Main()\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n USE ( hb_DirBase() + \"test.mdb\" ) VIA \"ADORDD\" TABLE \"Table1\"\n\n CLS\n Browse()\n\n USE\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour header file: include/hbusrrdd.ch. Defines 10 constants including: UR_BOF, UR_EOF, UR_FOUND, UR_GOBOTTOM, UR_GOTO. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#define UR_BOF 1\n#define UR_EOF 2\n#define UR_FOUND 3\n#define UR_GOBOTTOM 4\n#define UR_GOTO 5\n#define UR_GOTOID 6\n#define UR_GOTOP 7\n#define UR_SEEK 8\n#define UR_SKIP 9\n#define UR_SKIPFILTER 10\n#define UR_SKIPRAW 11\n\n\n#define UR_ADDFIELD 12\n#define UR_APPEND 13\n#define UR_CREATEFIELDS 14\n#define UR_DELETE 15\n#define UR_DELETED 16\n#define UR_FIELDCOUNT 17\n#define UR_FIELDDISPLAY 18\n#define UR_FIELDINFO 19\n#define UR_FIELDNAME 20\n#define UR_FLUSH 21\n#define UR_GETREC 22\n#define UR_GETVALUE 23\n#define UR_GETVARLEN 24\n#define UR_GOCOLD 25\n#define UR_GOHOT 26\n#define UR_PUTREC 27\n#define UR_PUTVALUE 28\n#define UR_RECALL 29\n#define UR_RECCOUNT 30\n#define UR_RECINFO 31\n#define UR_RECNO 32\n#define UR_RECID 33\n#define UR_SETFIELDEXTENT 34\n\n\n#define UR_ALIAS 35\n#define UR_CLOSE 36\n#define UR_CREATE 37\n#define UR_INFO 38\n#define UR_NEW 39\n#define UR_OPEN 40\n#define UR_RELEASE 41\n#define UR_STRUCTSIZE 42\n#define UR_SYSNAME 43\n#define UR_DBEVAL 44\n#define UR_PACK 45\n#define UR_PACKREC 46\n#define UR_SORT 47\n#define UR_TRANS 48\n#define UR_TRANSREC 49\n#define UR_ZAP 50\n\n\n#define UR_CHILDEND 51\n#define UR_CHILDSTART 52\n#define UR_CHILDSYNC 53\n#define UR_SYNCCHILDREN 54\n#define UR_CLEARREL 55\n#define UR_FORCEREL 56\n#define UR_RELAREA 57\n#define UR_RELEVAL 58\n#define UR_RELTEXT 59\n#define UR_SETREL 60\n\n\n#define UR_ORDLSTADD 61\n#define UR_ORDLSTCLEAR 62\n#define UR_ORDLSTDELETE 63\n#define UR_ORDLSTFOCUS 64\n#define UR_ORDLSTREBUILD 65\n#define UR_ORDSETCOND 66\n#define UR_ORDCREATE 67\n#define UR_ORDDESTROY 68\n#define UR_ORDINFO 69\n\n\n#define UR_CLEARFILTER 70\n#define UR_CLEARLOCATE 71\n#define UR_CLEARSCOPE 72\n#define UR_COUNTSCOPE 73\n#define UR_FILTERTEXT 74\n#define UR_SCOPEINFO 75\n#define UR_SETFILTER 76\n#define UR_SETLOCATE 77\n#define UR_SETSCOPE 78\n#define UR_SKIPSCOPE 79\n#define UR_LOCATE 80\n\n\n#define UR_COMPILE 81\n#define UR_ERROR 82\n#define UR_EVALBLOCK 83\n\n\n#define UR_RAWLOCK 84\n#define UR_LOCK 85\n#define UR_UNLOCK 86\n\n\n#define UR_CLOSEMEMFILE 87\n#define UR_CREATEMEMFILE 88\n#define UR_GETVALUEFILE 89\n#define UR_OPENMEMFILE 90\n#define UR_PUTVALUEFILE 91\n\n\n#define UR_READDBHEADER 92\n#define UR_WRITEDBHEADER 93\n\n\n#define UR_INIT 94\n#define UR_EXIT 95\n#define UR_DROP 96\n#define UR_EXISTS 97\n#define UR_RENAME 98\n#define UR_RDDINFO 99\n\n\n#define UR_WHOCARES 100\n\n#define UR_METHODCOUNT 100\n\n\n#ifndef HB_FT_NONE\n#define HB_FT_NONE 0\n#define HB_FT_STRING 1 \n#define HB_FT_LOGICAL 2 \n#define HB_FT_DATE 3 \n#define HB_FT_LONG 4 \n#define HB_FT_FLOAT 5 \n#define HB_FT_INTEGER 6 \n#define HB_FT_DOUBLE 7 \n#define HB_FT_TIME 8 \n#define HB_FT_TIMESTAMP 9 \n#define HB_FT_MODTIME 10 \n#define HB_FT_ROWVER 11 \n#define HB_FT_AUTOINC 12 \n#define HB_FT_CURRENCY 13 \n#define HB_FT_CURDOUBLE 14 \n#define HB_FT_VARLENGTH 15 \n#define HB_FT_MEMO 16 \n#define HB_FT_ANY 17 \n#define HB_FT_IMAGE 18 \n#define HB_FT_BLOB 19 \n#define HB_FT_OLE 20 \n#endif\n\n\n#define DBTF_MATCH 0x0001\n#define DBTF_PUTREC 0x0002\n#define DBTF_CPYCTR 0x0004\n#define DBTF_RECALL 0x0008\n\n\n#define DBLM_EXCLUSIVE 1\n#define DBLM_MULTIPLE 2\n#define DBLM_FILE 3\n\n\n#define FILE_LOCK 1\n#define FILE_UNLOCK 2\n#define REC_LOCK 3\n#define REC_UNLOCK 4\n#define HEADER_LOCK 5\n#define HEADER_UNLOCK 6\n#define APPEND_LOCK 7\n#define APPEND_UNLOCK 8\n\n\n#define UR_OI_AREA 1\n#define UR_OI_NAME 2\n#define UR_OI_ALIAS 3\n#define UR_OI_SHARED 4\n#define UR_OI_READONLY 5\n#define UR_OI_CDPID 6\n#define UR_OI_CONNECT 7\n#define UR_OI_HEADER 8\n#define UR_OI_SIZE 8\n\n\n#define UR_FI_NAME 1\n#define UR_FI_TYPE 2\n#define UR_FI_TYPEEXT 3\n#define UR_FI_LEN 4\n#define UR_FI_DEC 5\n#define UR_FI_SIZE 5\n\n\n#define UR_LI_RECORD 1\n#define UR_LI_METHOD 2\n#define UR_LI_RESULT 3\n#define UR_LI_SIZE 3\n\n\n#define UR_FRI_BEXPR 1\n#define UR_FRI_CEXPR 2\n#define UR_FRI_ACTIVE 3\n#define UR_FRI_OPTIMIZED 4\n#define UR_FRI_CARGO 5\n#define UR_FRI_SIZE 5\n\n\n#define UR_RI_BEXPR 1\n#define UR_RI_CEXPR 2\n#define UR_RI_SCOPED 3\n#define UR_RI_OPTIMIZED 4\n#define UR_RI_PARENT 5\n#define UR_RI_CHILD 6\n#define UR_RI_NEXT 7\n#define UR_RI_SIZE 7\n\n\n#define UR_SI_BFOR 1\n#define UR_SI_CFOR 2\n#define UR_SI_BWHILE 3\n#define UR_SI_CWHILE 4\n#define UR_SI_NEXT 5\n#define UR_SI_RECORD 6\n#define UR_SI_REST 7\n#define UR_SI_IGNOREFILTER 8\n#define UR_SI_INCLUDEDELETED 9\n#define UR_SI_LAST 10\n#define UR_SI_IGNOREDUPS 11\n#define UR_SI_BACKWARD 12\n#define UR_SI_OPTIMIZED 13\n#define UR_SI_SIZE 13\n\n\n#define UR_EI_BLOCK 1\n#define UR_EI_CEXPR 2\n#define UR_EI_SCOPE 3"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/db_brows.prg. Provides functions: DBFLIST. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n#include \"inkey.ch\"\n\n#define LI_NSTR mslist[ 1 ]\n#define LI_CLR mslist[ 2 ] \n#define LI_CLRV mslist[ 3 ] \n#define LI_BSKIP mslist[ 4 ] \n#define LI_BGTOP mslist[ 5 ] \n#define LI_BGBOT mslist[ 6 ] \n#define LI_BEOF mslist[ 7 ] \n#define LI_BBOF mslist[ 8 ] \n#define LI_B1 mslist[ 9 ]\n#define LI_MSF mslist[ 10 ] \n#define LI_NAMES mslist[ 11 ] \n#define LI_NMCLR mslist[ 12 ] \n#define LI_FREEZE mslist[ 13 ] \n#define LI_RCOU mslist[ 14 ]\n#define LI_MSREC mslist[ 15 ]\n#define LI_PRFLT mslist[ 16 ]\n#define LI_TEKZP mslist[ 17 ]\n#define LI_KOLZ mslist[ 18 ]\n#define LI_VALID mslist[ 19 ] \n#define LI_WHEN mslist[ 20 ] \n#define LI_MSNAME mslist[ 21 ]\n#define LI_MSTYP mslist[ 22 ]\n#define LI_MSLEN mslist[ 23 ]\n#define LI_MSDEC mslist[ 24 ]\n#define LI_EXPFI mslist[ 25 ]\n#define LI_BDESHIN mslist[ 26 ]\n#define LI_BDESHOUT mslist[ 27 ]\n#define LI_RECNO mslist[ 28 ]\n#define LI_BGOTO mslist[ 29 ]\n#define LI_Y1 mslist[ 30 ]\n#define LI_X1 mslist[ 31 ]\n#define LI_Y2 mslist[ 32 ]\n#define LI_X2 mslist[ 33 ]\n#define LI_LSOHR mslist[ 34 ]\n#define LI_LVIEW mslist[ 35 ]\n#define LI_NCOLUMNS mslist[ 36 ]\n#define LI_LEFTVISIBLE mslist[ 37 ]\n#define LI_NLEFT mslist[ 38 ]\n#define LI_COLPOS mslist[ 39 ]\n#define LI_XPOS mslist[ 40 ]\n#define LI_MSED mslist[ 41 ]\n#define LI_COLCOUNT mslist[ 42 ]\n#define LI_LEN 42\n\n\nPROCEDURE Main( filename )\n\n LOCAL vybkey := 1\n\n IF filename == NIL\n ? \"Dbf browse demo\"\n ? \"Syntax:\"\n ? \"\", \"db_brows filename\"\n QUIT\n ENDIF\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n USE ( filename )\n DO WHILE vybkey != 0\n vybkey := DBFLIST( , 3, 1, 76, 20, filename )\n DO CASE\n CASE vybkey == K_ENTER\n \n CASE vybkey == K_F3\n \n CASE vybkey == K_F5\n \n ENDCASE\n ENDDO\n\n RETURN\n\n\nFUNCTION DBFLIST( mslist, x1, y1, x2, y2, title, maskey )\n\n LOCAL rezproc, xkey, rez, fipos, wndbuf, predit, predxx, oldcolors\n LOCAL i\n LOCAL fbar1, fbar2, vartmp, varbuf, razmer\n LOCAL GetList := {}\n\n LOCAL str_barbox := hb_UTF8ToStrBox( \"░\" )\n LOCAL str_bar := Chr( 31 ) + Chr( 30 ) + hb_UTF8ToStr( \"■\" )\n\n IF mslist == NIL\n mslist := InitList()\n ENDIF\n LI_Y1 := y1\n LI_X1 := x1\n LI_Y2 := y2\n LI_X2 := x2\n IF LI_MSF == NIL\n LI_COLCOUNT := FCount()\n LI_MSTYP := Array( LI_COLCOUNT )\n LI_MSLEN := Array( LI_COLCOUNT )\n LI_MSDEC := Array( LI_COLCOUNT )\n AFields( , LI_MSTYP, LI_MSLEN, LI_MSDEC )\n ELSE\n LI_COLCOUNT := Len( LI_MSF )\n IF LI_MSTYP == NIL\n LI_MSTYP := Array( LI_COLCOUNT )\n LI_MSLEN := Array( LI_COLCOUNT )\n LI_MSDEC := Array( LI_COLCOUNT )\n FOR i := 1 TO LI_COLCOUNT\n IF HB_ISBLOCK( LI_MSF[ i ] )\n vartmp := Eval( LI_MSF[ i ], mslist, i )\n LI_MSTYP[ i ] := ValType( vartmp )\n IF LI_MSTYP[ i ] == \"C\"\n LI_MSLEN[ i ] := Len( vartmp )\n ELSEIF LI_MSTYP[ i ] == \"N\"\n vartmp := Str( vartmp )\n LI_MSLEN[ i ] := Len( vartmp )\n LI_MSDEC[ i ] := iif( \".\" $ vartmp, LI_MSLEN[ i ] - At( \".\", vartmp ), 0 )\n ELSEIF LI_MSTYP[ i ] == \"D\"\n LI_MSLEN[ i ] := 8\n ELSEIF LI_MSTYP[ i ] == \"L\"\n LI_MSLEN[ i ] := 1\n ENDIF\n ELSE\n LI_MSTYP[ i ] := ValType( FieldGet( FieldPos( LI_MSF[ i ] ) ) )\n ENDIF\n NEXT\n ENDIF\n ENDIF\n IF HB_ISNUMERIC( LI_MSED )\n predxx := predit := LI_MSED\n ELSE\n predxx := predit := iif( AScan( LI_MSED, 3 ) != 0, 3, iif( AScan( LI_MSED, 2 ) != 0, 2, 1 ) )\n ENDIF\n SET CURSOR ( predit > 1 )\n IF LI_LSOHR\n wndbuf := SaveScreen( LI_Y1, LI_X1, LI_Y2, LI_X2 )\n ENDIF\n oldcolors := SetColor()\n SetColor( LI_CLR )\n hb_DispBox( LI_Y1, LI_X1, LI_Y2, LI_X2, hb_UTF8ToStrBox( \"┌─┐│┘─└│ \" ) )\n IF title != NIL\n hb_DispOutAt( LI_Y1, ( LI_X2 - LI_X1 - 1 - Len( title ) ) / 2 + LI_X1, \" \" + title + \" \" )\n ENDIF\n IF title != NIL .AND. LI_NAMES != NIL\n LI_Y1++\n ENDIF\n razmer := LI_Y2 - LI_Y1 - 1\n IF ! LI_PRFLT\n LI_KOLZ := Eval( LI_RCOU, mslist )\n ENDIF\n LI_COLPOS := 1\n LI_NLEFT := LI_FREEZE + 1\n\n LI_LEFTVISIBLE := LI_NLEFT\n STORE .T. TO rez\n LI_NCOLUMNS := FLDCOUNT( mslist, LI_X1 + 2, LI_X2 - 2, LI_NLEFT )\n VIVNAMES( mslist, LI_NLEFT )\n IF Eval( LI_BEOF, mslist )\n Eval( LI_BGTOP, mslist )\n LI_NSTR := 1\n ELSE\n Eval( LI_BSKIP, mslist, -( LI_NSTR - 1 ) )\n IF Eval( LI_BBOF, mslist )\n Eval( LI_BGTOP, mslist )\n LI_NSTR := 1\n ENDIF\n ENDIF\n WNDVIVOD( mslist )\n Eval( LI_BSKIP, mslist, ( LI_NSTR - 1 ) )\n IF LI_KOLZ == 0 .AND. predit == 3\n LI_NSTR := 0\n hb_keyIns( K_DOWN )\n ENDIF\n DO WHILE rez\n SetColor( LI_CLR )\n Eval( LI_B1, mslist )\n\n\n SetColor( LI_CLRV )\n\n VIVSTR( mslist, LI_NSTR + LI_Y1, iif( predit > 1, LI_COLPOS, 0 ) )\n SetColor( LI_CLR )\n \n DO CASE\n CASE !( Type( \"sx_KeyNo()\" ) == \"U\" )\n fbar1 := \"sx_KeyNo()\"\n fbar2 := \"sx_KeyCount()\"\n CASE !( Type( \"AdsKeyNo()\" ) == \"U\" )\n fbar1 := \"AdsKeyNo()\"\n fbar2 := \"AdsKeyCount()\"\n CASE !( Type( \"Ax_KeyNo()\" ) == \"U\" )\n fbar1 := \"Ax_KeyNo()\"\n fbar2 := \"Ax_KeyCount()\"\n ENDCASE\n IF ! Empty( fbar1 )\n hb_DispBox( LI_Y1 + 2, LI_X2, LI_Y2 - 2, LI_X2, str_barbox )\n hb_DispOutAt( LI_Y1 + 1, LI_X2, SubStr( str_bar, 2, 1 ) )\n hb_DispOutAt( LI_Y2 - 1, LI_X2, SubStr( str_bar, 1, 1 ) )\n hb_DispOutAt( LI_Y1 + 2 + Int( iif( LI_PRFLT, LI_TEKZP, &fbar1 )\n CASE ( xkey == K_ENTER .OR. !( hb_keyChar( xkey ) == \"\" ) ) .AND. predit > 1\n fipos := LI_COLPOS + LI_NLEFT - 1 - LI_FREEZE\n IF LI_WHEN == NIL .OR. Len( LI_WHEN ) < fipos .OR. LI_WHEN[ fipos ] == NIL .OR. Eval( LI_WHEN[ fipos ] )\n IF ! HB_ISNUMERIC( LI_MSED )\n vartmp := iif( Len( LI_MSED ) < fipos, 1, LI_MSED[ fipos ] )\n IF HB_ISNUMERIC( vartmp )\n IF vartmp != 2\n LOOP\n ENDIF\n ELSE\n LOOP\n ENDIF\n ENDIF\n SET CURSOR ON\n SetColor( LI_CLRV + \",\" + LI_CLRV )\n IF xkey != K_ENTER\n DO WHILE NextKey() != 0\n hb_keyPut( Inkey( 0 ) )\n ENDDO\n hb_keyIns( xkey )\n ENDIF\n vartmp := ReadExit( .T. )\n varbuf := FieldGet( fipos )\n @ LI_NSTR + LI_Y1, LI_XPOS GET varbuf PICTURE Defpict( mslist, fipos, LI_X2 - LI_X1 - 3 )\n IF LI_VALID != NIL .AND. Len( LI_VALID ) >= fipos .AND. LI_VALID[ fipos ] != NIL\n Getlist[ 1 ]:postBlock := LI_VALID[ fipos ]\n ENDIF\n READ\n IF LastKey() != K_ESC .AND. Updated()\n IF Eval( LI_BEOF, mslist )\n APPEND BLANK\n LI_KOLZ := Eval( LI_RCOU, mslist )\n ELSE\n IF ! Set( _SET_EXCLUSIVE )\n RLock()\n IF NetErr()\n LOOP\n ENDIF\n ENDIF\n ENDIF\n IF LI_BDESHOUT != NIL .AND. HB_ISSTRING( varbuf )\n varbuf := Eval( LI_BDESHOUT, mslist, varbuf )\n ENDIF\n FieldPut( fipos, varbuf )\n IF ! Set( _SET_EXCLUSIVE )\n UNLOCK\n ENDIF\n ENDIF\n IF ( LastKey() == K_ESC .OR. ! Updated() ) .AND. Eval( LI_BEOF, mslist )\n SetColor( LI_CLR )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour header file: include/button.ch. Defines 10 constants including: HB_BUTTON_CH_, _BUTTON_DEFINED, SCROLL_VERTICAL, SCROLL_HORIZONTAL, MENU_SEPARATOR. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_BUTTON_CH_\n#define HB_BUTTON_CH_\n#define _BUTTON_DEFINED \n\n\n#define SCROLL_VERTICAL 1\n#define SCROLL_HORIZONTAL 2\n\n\n#define MENU_SEPARATOR Chr( 196 ) \n#define SEPARATOR_DOUBLE ( Chr( 204 ) + Chr( 205 ) + Chr( 185 ) ) \n#define SEPARATOR_SINGLE ( Chr( 195 ) + MENU_SEPARATOR + Chr( 180 ) ) \n#define SEPARATOR_DOUBLE_SINGLE ( Chr( 199 ) + MENU_SEPARATOR + Chr( 182 ) ) \n\n#define HB_MENU_SEPARATOR_UNI hb_UTF8ToStrBox( \"─\" )\n#define HB_SEPARATOR_DOUBLE_UNI hb_UTF8ToStrBox( \"╠═╣\" )\n#define HB_SEPARATOR_SINGLE_UNI hb_UTF8ToStrBox( \"├─┤\" )\n#define HB_SEPARATOR_DOUBLE_SINGLE_UNI hb_UTF8ToStrBox( \"╟─╢\" )\n\n\n#define HTNOWHERE 0\n\n#define HTTOPLEFT -1\n#define HTTOP -2\n#define HTTOPRIGHT -3\n#define HTRIGHT -4\n#define HTBOTTOMRIGHT -5\n#define HTBOTTOM -6\n#define HTBOTTOMLEFT -7\n#define HTLEFT -8\n\n#define HTBORDERFIRST -8\n#define HTBORDERLAST -1\n\n#define HTCAPTION -1025\n\n#define HTCLIENT -2049\n\n#define HTSCROLLTHUMBDRAG -3073\n#define HTSCROLLUNITDEC -3074\n#define HTSCROLLUNITINC -3075\n#define HTSCROLLBLOCKDEC -3076\n#define HTSCROLLBLOCKINC -3077\n\n#define HTSCROLLFIRST -3077\n#define HTSCROLLLAST -3073\n\n#define HTDROPBUTTON -4097\n#define HTSEPARATOR -4098\n\n#define HTCELL -5121\n#define HTHEADING -5122\n#define HTFOOTING -5123\n#define HTHEADSEP -5124\n#define HTFOOTSEP -5125\n#define HTCOLSEP -5126\n\n#define HTMENU -6145\n#define HTSIZE -6146\n#define HTMINBUTTON -6147\n#define HTMAXBUTTON -6148\n#define HTGROWBOX HTSIZE\n#define HTREDUCE HTMINBUTTON\n#define HTZOOM HTMAXBUTTON\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/cdow.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n ? CMonth( Date() )\n ? CMonth( Date() + 31 )\n ? CMonth( Date() + 60 )\n ?\n\n ? CDoW( Date() )\n ? CDoW( Date() + 6 )\n ? CDoW( Date() + 7 )\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/attoken.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#else\n#define hb_ntos( n ) LTrim( Str( n ) )\n#endif\n\nPROCEDURE Main()\n\n LOCAL cStr := \"...This...is...a...test!\"\n LOCAL ni, npos\n\n ctinit()\n\n ? \"Begin test of AtToken()\"\n ?\n\n ? \" Simple tests:\"\n ? ' AtToken( \"Hello, World!\" ) == 8 ? ------------> ' + Str( AtToken( \"Hello, World!\" ) )\n ? ' AtToken( \"Hello, World!\",, 2 ) == 8 ? --------> ' + Str( AtToken( \"Hello, World!\",, 2 ) )\n ? ' AtToken( \"Hello, World!\",, 2, 1 ) == 7 ? -----> ' + Str( AtToken( \"Hello, World!\",, 2, 1 ) )\n ? ' AtToken( \"Hello, World!\", \" \", 2, 1 ) == 8 ? -> ' + Str( AtToken( \"Hello, World!\", \" \", 2, 1 ) )\n ?\n\n ? ' Tokenizing a string with skip width == 1 and \".!\" as tokenizer list:'\n ? \" Value of cStr is: \" + '\"' + cStr + '\"'\n ?\n FOR ni := 1 TO NumToken( cStr, \".!\", 1 )\n ? ' Token #' + hb_ntos( ni ) + '(\"' + Token( cStr, \".!\", ni, 1 ) + '\")'\n ? \" starts at pos \" + Str( npos := AtToken( cStr, \".!\", ni, 1 ), 3 ) + ;\n \" and is \" + iif( SubStr( cStr, npos, 1 ) $ \".!\", \"\", \"not \" ) + \"an empty token.\"\n NEXT\n\n ?\n ? \"End test of AtToken()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/base64.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"simpleio.ch\"\n\nPROCEDURE Main()\n\n LOCAL cVector, cStr\n\n LOCAL hTestVectors := { ;\n \"\" => \"\", ;\n \"f\" => \"Zg==\", ;\n \"fo\" => \"Zm8=\", ;\n \"foo\" => \"Zm9v\", ;\n \"foob\" => \"Zm9vYg==\", ;\n \"fooba\" => \"Zm9vYmE=\", ;\n \"foobar\" => \"Zm9vYmFy\" }\n\n FOR EACH cVector IN hTestVectors\n\n cStr := hb_base64Encode( cVector:__enumKey )\n IF !( cStr == cVector )\n ? hb_StrFormat( \"hb_base64Encode(): expected '%s' got '%s' while encoding '%s'\", ;\n cVector:__enumKey(), cStr, cVector )\n ELSE\n ? hb_StrFormat( \"hb_base64Encode(): passed '%s'\", cVector:__enumKey )\n ENDIF\n\n cStr := hb_base64Decode( cVector )\n IF !( cStr == cVector:__enumKey() )\n ? hb_StrFormat( \"hb_base64Decode(): expected '%s' got '%s' while decoding '%s'\", ;\n cVector, cStr, cVector:__enumKey() )\n ELSE\n ? hb_StrFormat( \"hb_base64Decode(): passed '%s'\", cVector )\n ENDIF\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/array16.prg. Provides functions: Test, ReleaseTest. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL a := { 100, 200, \"Third\" }\n LOCAL b := Array( 8832 )\n\n ? ValType( a )\n ? ValType( { \"A\" } )\n\n AAdd( a, \"new element\" )\n ? Len( a )\n\n ? a[ 1 ]\n ? a[ 2 ]\n ? a[ 3 ]\n ? a[ 4 ]\n\n ? ATail( a )\n\n a[ 3 ] := { \"this\", { \"seems\", \"to\", { \"work\", \"so\", \"well\" } } }\n ? a[ 3 ][ 2 ][ 3 ][ 1 ] \n\n a[ 3, 2 ][ 3, 1 ] := \"Harbour power!\" \n ? a[ 3, 2, 3, 1 ]\n\n ? ValType( b )\n ? Len( b )\n\n b[ 8832 ] := \"Harbour\"\n\n ? b[ 8832 ]\n\n ? ATail( b )\n\n ASize( b, 200 )\n ? Len( b )\n\n b[ 100 ] := 10\n Test( b[ 100 ]++ )\n ? b[ 100 ]\n\n b[ 100 ] := 10\n Test( ++b[ 100 ] )\n ? b[ 100 ]\n\n b := { 1, { 2, { 4, 5 } } }\n Test( b[ 2 ][ 2 ][ 1 ]++ )\n ? b[ 2 ][ 2 ][ 1 ]\n\n b[ 2 ][ 2 ][ 1 ] := 2\n Test( ++b[ 2 ][ 2 ][ 1 ] )\n ? b[ 2 ][ 2 ][ 1 ]\n\n ReleaseTest()\n\n RETURN\n\nFUNCTION Test( n )\n\n ? n\n\n RETURN NIL\n\nFUNCTION ReleaseTest()\n\n LOCAL a := { 1, 2, 3 }\n\n HB_SYMBOL_UNUSED( a )\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHeader file for contribution module 'hbzebra' (Barcode generation library): contrib/hbzebra/hbzebra.ch. Defines 10 constants including: HB_ZEBRA_CH_, HB_ZEBRA_TYPE_EAN13, HB_ZEBRA_TYPE_EAN8, HB_ZEBRA_TYPE_UPCA, HB_ZEBRA_TYPE_UPCE. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_ZEBRA_CH_\n#define HB_ZEBRA_CH_\n\n\n#define HB_ZEBRA_TYPE_EAN13 1\n#define HB_ZEBRA_TYPE_EAN8 2\n#define HB_ZEBRA_TYPE_UPCA 3\n#define HB_ZEBRA_TYPE_UPCE 4\n#define HB_ZEBRA_TYPE_CODE128 5\n#define HB_ZEBRA_TYPE_CODE93 6\n#define HB_ZEBRA_TYPE_CODE39 7\n#define HB_ZEBRA_TYPE_CODE11 8\n#define HB_ZEBRA_TYPE_CODABAR 9\n#define HB_ZEBRA_TYPE_ITF 10\n#define HB_ZEBRA_TYPE_MSI 11\n\n#define HB_ZEBRA_TYPE_PDF417 257\n#define HB_ZEBRA_TYPE_DATAMATRIX 258\n#define HB_ZEBRA_TYPE_QRCODE 259\n\n\n#define HB_ZEBRA_ERROR_INVALIDCODE 1\n#define HB_ZEBRA_ERROR_BADCHECKSUM 2\n#define HB_ZEBRA_ERROR_TOOLARGE 3\n#define HB_ZEBRA_ERROR_ARGUMENT 4\n\n\n#define HB_ZEBRA_ERROR_INVALIDZEBRA 101\n\n\n#define HB_ZEBRA_FLAG_CHECKSUM 1\n#define HB_ZEBRA_FLAG_WIDE2 0x00 \n#define HB_ZEBRA_FLAG_WIDE2_5 0x40\n#define HB_ZEBRA_FLAG_WIDE3 0x80\n\n\n#define HB_ZEBRA_FLAG_PDF417_TRUNCATED 0x0100\n#define HB_ZEBRA_FLAG_PDF417_LEVEL_MASK 0xF000\n#define HB_ZEBRA_FLAG_PDF417_LEVEL0 0x1000\n#define HB_ZEBRA_FLAG_PDF417_LEVEL1 0x2000\n#define HB_ZEBRA_FLAG_PDF417_LEVEL2 0x3000\n#define HB_ZEBRA_FLAG_PDF417_LEVEL3 0x4000\n#define HB_ZEBRA_FLAG_PDF417_LEVEL4 0x5000\n#define HB_ZEBRA_FLAG_PDF417_LEVEL5 0x6000\n#define HB_ZEBRA_FLAG_PDF417_LEVEL6 0x7000\n#define HB_ZEBRA_FLAG_PDF417_LEVEL7 0x8000\n#define HB_ZEBRA_FLAG_PDF417_LEVEL8 0x9000\n\n#define HB_ZEBRA_FLAG_DATAMATRIX_SQUARE 0x0100\n#define HB_ZEBRA_FLAG_DATAMATRIX_RECTANGLE 0x0200\n\n#define HB_ZEBRA_FLAG_QR_LEVEL_MASK 0x0700\n#define HB_ZEBRA_FLAG_QR_LEVEL_L 0x0100\n#define HB_ZEBRA_FLAG_QR_LEVEL_M 0x0200\n#define HB_ZEBRA_FLAG_QR_LEVEL_Q 0x0300\n#define HB_ZEBRA_FLAG_QR_LEVEL_H 0x0400\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/menu1.prg. Provides functions: fubar. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#include \"setcurs.ch\"\n\nPROCEDURE Main( cCmdLine )\n\n LOCAL sDosScrn, nDosRow, nDosCol, lColor\n\n \n LOCAL cNormN\n LOCAL cWindN\n LOCAL cErrH\n LOCAL cErrN\n\n \n LOCAL aColors\n LOCAL aBar := { \" ENTER/EDIT \", \" REPORTS \", \" DISPLAY \", \" MAINTENANCE \", \" QUIT \" }\n LOCAL aOptions[ Len( aBar ) ]\n\n LOCAL nMaxRow\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n AEval( aBar, {| x, i | HB_SYMBOL_UNUSED( x ), aOptions[ i ] := { {}, {}, {} } } )\n\n cCmdLine := iif( cCmdLine == NIL, \"\", cCmdLine )\n\n lColor := iif( \"MONO\" $ Upper( cCmdLine ), .F., IsColor() )\n\n \n aColors := iif( lColor, { \"W+/G\", \"N/G\", \"N/G\", \"N/W\", \"N+/G\" }, ;\n { \"W+/N\", \"W+/N\", \"W/N\", \"N/W\", \"W/N\" } )\n\n ft_Fill( aOptions[ 1 ], \"A. Execute A Dummy Procedure\" , {|| fubar() }, .T. )\n ft_Fill( aOptions[ 1 ], \"B. Enter Daily Charge/Credit Slips\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 1 ], \"C. Enter Payments On Accounts\" , {|| .T. }, .F. )\n ft_Fill( aOptions[ 1 ], \"D. Edit Daily Transactions\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 1 ], \"E. Enter/Update Member File\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 1 ], \"F. Update Code File\" , {|| .T. }, .F. )\n ft_Fill( aOptions[ 1 ], \"G. Add/Update Auto Charge File\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 1 ], \"H. Post All Transactions To A/R File\", {|| .T. }, .T. )\n ft_Fill( aOptions[ 1 ], \"I. Increment Next Posting Date\" , {|| .T. }, .T. )\n\n ft_Fill( aOptions[ 2 ], \"A. Print Member List\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"B. Print Active Auto Charges\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"C. Print Edit List\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"D. Print Pro-Usage Report\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"E. Print A/R Transaction Report\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"F. Aging Report Preparation\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"G. Add Interest Charges\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"H. Print Aging Report\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"I. Print Monthly Statements\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"J. Print Mailing Labels\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"K. Print Transaction Totals\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"L. Print Transaction Codes File\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 2 ], \"M. Print No-Activity List\" , {|| .T. }, .T. )\n\n ft_Fill( aOptions[ 3 ], \"A. Transaction Totals Display\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 3 ], \"B. Display Invoice Totals\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 3 ], \"C. Accounts Receivable Display\" , {|| .T. }, .T. )\n\n ft_Fill( aOptions[ 4 ], \"A. Backup Database Files\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 4 ], \"B. Reindex Database Files\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 4 ], \"C. Set System Parameters\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 4 ], \"D. This EXITs Too\" , {|| .F. }, .T. )\n\n ft_Fill( aOptions[ 5 ], \"A. Does Nothing\" , {|| .T. }, .T. )\n ft_Fill( aOptions[ 5 ], \"B. Exit Application\" , {|| .F. }, .T. )\n\n \n SET SCOREBOARD OFF\n\n cNormN := iif( lColor, \"N/G\" , \"W/N\" )\n cWindN := iif( lColor, \"W/B\" , \"W/N\" )\n cErrH := iif( lColor, \"W+/R\", \"W+/N\" )\n cErrN := iif( lColor, \"W/R\" , \"W/N\" )\n\n SAVE SCREEN TO sDosScrn\n nDosRow := Row()\n nDosCol := Col()\n SetColor( \"w/n\" )\n CLS\n NoSnow( \"NOSNOW\" $ Upper( cCmdLine ) )\n IF \"VGA\" $ Upper( cCmdLine )\n SetMode( 50, 80 )\n ENDIF\n nMaxRow := MaxRow()\n SetBlink( .F. )\n SetColor( cWindN + \"*\" )\n CLS\n SetColor( cNormN )\n @ nMaxRow, 0\n @ nMaxRow, 0 SAY hb_UTF8ToStr( \" FT_MENU1 1.0 │ \" )\n @ nMaxRow, 16 SAY \"WRITTEN BY PAUL FERRARA [76702,556] FOR NANFORUM.LIB\"\n @ nMaxRow, 69 SAY hb_UTF8ToStr( \"│ \" ) + DToC( Date() )\n\n SetColor( cErrH )\n @ nMaxRow - 11, 23, nMaxRow - 3, 56 BOX hb_UTF8ToStr( \"┌─┐│┘─└│ \" )\n @ nMaxRow - 9, 23 SAY hb_UTF8ToStr( \"├────────────────────────────────┤\" )\n SetColor( cErrN )\n @ nMaxRow - 10, 33 SAY \"Navigation Keys\"\n @ nMaxRow - 8, 25 SAY \"LeftArrow RightArrow Alt-E\"\n @ nMaxRow - 7, 25 SAY \"Home End Alt-R\"\n @ nMaxRow - 6, 25 SAY \"Tab Shift-Tab Alt-D\"\n @ nMaxRow - 5, 25 SAY \"PgUp PgDn Alt-M\"\n @ nMaxRow - 4, 25 SAY \"Enter ESCape Alt-Q\"\n SetColor( cNormN )\n\n ft_Menu1( aBar, aOptions, aColors )\n\n SetColor( \"W/N\" )\n SetCursor( SC_NORMAL )\n SetBlink( .T. )\n IF \"VGA\" $ Upper( cCmdLine )\n SetMode( 25, 80 )\n ENDIF\n RESTORE SCREEN FROM sDosScrn\n SetPos( nDosRow, nDosCol )\n\n RETURN\n\nFUNCTION fubar()\n\n LOCAL OldColor := SetColor( \"W/N\" )\n\n CLS\n QOut( \"Press Any Key\" )\n Inkey( 0 )\n SetColor( OldColor )\n\n RETURN .T."}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/mt/mttest07.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "#define N_THREADS 5\n#define N_JOBS 10000\n\nstatic s_aCounters\nstatic s_mtxJobs\nstatic s_mtxResults\n\nproc main()\n local aThreads, aResults, i, nDigit, nSum, nExpected\n\n ? Version()\n ? \"Main start\"\n\n s_aCounters := array( N_THREADS )\n aFill( s_aCounters, 0 )\n aThreads := {}\n aResults := {}\n s_mtxJobs := hb_mutexCreate()\n s_mtxResults := hb_mutexCreate()\n\n ? \"Starting threads: \"\n for i := 1 to N_THREADS\n aadd( aThreads, hb_threadStart( @thFunc() ) )\n ?? \"<\" + hb_ntos( i ) + \">\"\n next\n\n ? \"Sending jobs... \"\n nDigit := 10\n for i := 1 to N_JOBS\n hb_mutexNotify( s_mtxJobs, nDigit )\n \n nDigit++\n next\n\n ? \"Sending terminate values...\"\n for i := 1 to N_THREADS\n hb_mutexNotify( s_mtxJobs, NIL )\n ?? \"<\" + hb_ntos( i ) + \">\"\n next\n\n ? \"Collecting results... \"\n for i := 1 to N_JOBS\n hb_mutexSubscribe( s_mtxResults,, @nDigit )\n \n aadd( aResults, nDigit )\n next\n\n ? \"Waiting for threads...\"\n aEval( aThreads, {| x | hb_threadJoin( x ) } )\n ? \"Threads joined\"\n\n nSum := 0\n for each nDigit in aResults\n nSum += nDigit\n next\n\n nSum := round( nSum, 2 )\n nExpected := round( ( 10 + 10 + N_JOBS - 1 ) / 2 / 3\n ? \"OK, final sum:\", hb_ntos( nSum )\n else\n ? \"ERROR, final sum:\", hb_ntos( nSum ), ;\n \"expected:\", hb_ntos( nExpected )\n endif\n ? \"End of main\"\nreturn\n\nproc thFunc()\n local xJob, xResult\n while .T.\n hb_mutexSubscribe( s_mtxJobs,, @xJob )\n if xJob == NIL\n exit\n endif\n xResult := xJob / 3\n hb_mutexNotify( s_mtxResults, xResult )\n enddo\nreturn"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write Harbour functions: FPTCDX_GETFUNCTABLE. Harbour contribution module 'rddmisc' (): contrib/rddmisc/fptcdx.prg. Provides functions: FPTCDX_GETFUNCTABLE. Contains procedures: FPTCDX_INIT. This file handles database operations"}, {"role": "assistant", "content": "#include \"dbinfo.ch\"\n#include \"hbusrrdd.ch\"\n#include \"rddsys.ch\"\n\n\nREQUEST DBFCDX\nREQUEST DBFFPT\n\n\nANNOUNCE FPTCDX\n\nFUNCTION FPTCDX_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, pSuperRddID )\n RETURN USRRDD_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, ;\n \"DBFCDX\", {}, pSuperRddID ) \n\nINIT PROCEDURE FPTCDX_INIT()\n\n rddRegister( \"FPTCDX\", RDT_FULL )\n rddInfo( RDDI_MEMOTYPE, DB_MEMO_FPT, \"FPTCDX\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/tipmmail.prg. Contains procedures: Main, Usage. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbtip\"\n\nPROCEDURE Main( ... )\n\n LOCAL oMail, cData, i, oAttach\n LOCAL cFname\n\n IF PCount() == 0\n Usage()\n RETURN\n ENDIF\n\n oMail := TIPMail():New( \"This is the body of the mail\" )\n oMail:hHeaders[ \"Content-Type\" ] := \"text/plain; charset=utf-8\"\n oMail:hHeaders[ \"Date\" ] := tip_TimeStamp()\n\n FOR i := 1 TO PCount()\n\n SWITCH Lower( cData := hb_PValue( i ) )\n CASE \"-h\"\n Usage()\n RETURN\n CASE \"-f\"\n IF HB_ISSTRING( cData := hb_PValue( ++i ) )\n oMail:hHeaders[ \"From\" ] := hb_StrToUTF8( cData )\n ENDIF\n EXIT\n CASE \"-t\"\n IF HB_ISSTRING( cData := hb_PValue( ++i ) )\n oMail:hHeaders[ \"To\" ] := hb_StrToUTF8( cData )\n ENDIF\n EXIT\n CASE \"-s\"\n IF HB_ISSTRING( cData := hb_PValue( ++i ) )\n oMail:hHeaders[ \"Subject\" ] := hb_StrToUTF8( cData )\n ENDIF\n EXIT\n CASE \"-b\"\n IF HB_ISSTRING( cData := hb_PValue( ++i ) )\n oMail:SetBody( hb_StrToUTF8( cData ) + e\"\\r\\n\" )\n ENDIF\n EXIT\n CASE \"-m\"\n IF HB_ISSTRING( cData := hb_PValue( ++i ) )\n IF ( cData := hb_MemoRead( cData ) ) == \"\"\n ? \"Fatal: Could not read\", hb_PValue( i )\n RETURN\n ENDIF\n oMail:SetBody( cData + e\"\\r\\n\" )\n ENDIF\n EXIT\n OTHERWISE \n IF ( cData := hb_MemoRead( cData ) ) == \"\"\n ? \"Fatal: Could not read attachment or attachment empty\", hb_PValue( i )\n RETURN\n ENDIF\n\n oAttach := TIPMail():New()\n oAttach:SetEncoder( \"base64\" )\n \n cFName := hb_FNameNameExt( hb_PValue( i ) )\n \n oAttach:hHeaders[ \"Content-Type\" ] := ;\n \"application/X-TIP-Attachment; filename=\" + cFName\n \n oAttach:hHeaders[ \"Content-Disposition\" ] := ;\n \"attachment; filename=\" + cFname\n oAttach:SetBody( cData )\n\n oMail:Attach( oAttach )\n ENDSWITCH\n NEXT\n\n \n OutStd( oMail:ToString() )\n\n RETURN\n\nSTATIC PROCEDURE Usage()\n\n ? \"Usage:\"\n ? \" tipmmail [options] attachment1, attachment2...\"\n ? \"Options:\"\n ? \" -h Help\"\n ? ' -f \"from\" Set \"mail from\" field'\n ? ' -t \"to\" Set \"mail to\" field'\n ? ' -s \"subject\" Set mail subject'\n ? ' -b \"body\" Set mail body (or message)'\n ? ' -m \"bodyfile\" Set mail body using a file'\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour OOP classes for the functionality described: Harbour test program: tests/clasinh.prg. Defines classes: TClassBase, TAnyClass. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nPROCEDURE Main()\n\n LOCAL oObject, oBase\n\n oObject := TAnyClass():New()\n oBase := TClassBase():New()\n\n HB_SYMBOL_UNUSED( oObject )\n HB_SYMBOL_UNUSED( oBase )\n\n RETURN\n\nCREATE CLASS TClassBase\n\n METHOD New()\n METHOD Test() INLINE Alert( \"Test\" )\n\nENDCLASS\n\nMETHOD New() CLASS TClassBase\n\n RETURN Self\n\nCREATE CLASS TAnyClass FROM TClassBase\n\n METHOD New()\n\nENDCLASS\n\nMETHOD New() CLASS TAnyClass\n\n ::super:New()\n ::super:Test()\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour extra library: extras/hbxlsxml/tests/example2.prg. Contains procedures: Main. This file provides spreadsheet generation capabilities"}, {"role": "assistant", "content": "#require \"hbxlsxml\"\n\nPROCEDURE Main()\n\n LOCAL xml, format1, format2, format3, format4\n LOCAL sheet1, sheet2, sheet4\n\n xml := ExcelWriterXML():new( \"my file.xml\" )\n\n \n xml:docTitle( \"My Demo Doc\" )\n xml:docAuthor( \"Robert F Greer\" )\n xml:docCompany( \"Greers.Org\" )\n xml:docManager( \"Wife\" )\n\n \n format1 := xml:addStyle( \"left_rotate60_big\" )\n format1:alignRotate( 60 )\n format1:alignHorizontal( \"Left\" )\n format1:setFontSize( \"18\" )\n\n format2 := xml:addStyle( \"verticaltext_left\" )\n format2:alignVerticaltext( 45 )\n format2:alignHorizontal( \"Left\" )\n\n format3 := xml:addStyle( \"wraptext_top\" )\n format3:alignWraptext()\n format3:alignVertical( \"Top\" )\n\n \n sheet1 := xml:addSheet( \"Alignment\" )\n \n sheet1:writeString( 1, 1, \"left_rotate45\", format1 )\n sheet1:writeString( 1, 2, \"vertical left\", \"verticaltext_left\" )\n sheet1:writeString( 1, 3, \"this text has been wrapped and is aligned at the top\", \"wraptext_top\" )\n\n sheet2 := xml:addSheet( \"Formulas\" )\n \n sheet2:columnWidth( 1, 100 )\n sheet2:writeString( 1, 1, \"Number\" )\n sheet2:writeNumber( 1, 2, 50 )\n sheet2:writeString( 2, 1, \"Number\" )\n sheet2:writeNumber( 2, 2, 30 )\n sheet2:writeString( 3, 1, \"Number\" )\n sheet2:writeNumber( 3, 2, 20 )\n sheet2:writeString( 4, 1, \"=SUM(R[-3]C:R[-1]C)\" )\n sheet2:writeFormula( \"Number\", 4, 2, \"=SUM(R[-3]C:R[-1]C)\" )\n sheet2:writeString( 5, 1, \"=SUM(R1C2:R3C2)\" )\n sheet2:writeFormula( \"Number\", 5, 2, \"=SUM(R1C1:R3C2)\" )\n\n sheet4 := xml:addSheet( \"more formatting\" )\n format4 := xml:addStyle( \"my style\" )\n format4:setFontBold()\n format4:setFontItalic()\n format4:setFontUnderline( \"DoubleAccounting\" )\n format4:bgColor( \"Black\" )\n format4:setFontColor( \"White\" )\n format4:setNumberFormatDateTime()\n sheet4:writeDateTime( 1, 1, DToC( Date() ), format4 )\n \n sheet4:rowHeight( 1, \"30\" )\n sheet4:writeString( 2, 1, \"formatted text + cell color + merged + underlined\", format4 )\n \n sheet4:cellMerge( 2, 1, 4, 2 )\n\n \n xml:writeData( \"example2.xml\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'sddodbc' (): contrib/sddodbc/tests/test2.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"rddsql\"\n#require \"sddodbc\"\n\n#include \"simpleio.ch\"\n\nREQUEST SQLMIX, SDDODBC\n\nPROCEDURE Main()\n\n LOCAL nConnection, nI, aI\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n rddSetDefault( \"SQLMIX\" )\n nConnection := rddInfo( RDDI_CONNECT, { \"ODBC\", \"Server=localhost;Driver={MySQL ODBC 5.1 Driver};dsn=;User=test;database=test;\" } )\n IF nConnection == 0\n ? \"Unable connect to server\", rddInfo( RDDI_ERRORNO ), rddInfo( RDDI_ERROR )\n RETURN\n ENDIF\n ? nConnection\n ? rddInfo( RDDI_EXECUTE, \"DROP TABLE country\" )\n ? rddInfo( RDDI_EXECUTE, \"CREATE TABLE country (CODE char(3), NAME char(50), RESIDENTS int(11))\" )\n ? rddInfo( RDDI_EXECUTE, \"INSERT INTO country values ('LTU', 'Lithuania', 3369600),('USA', 'United States of America', 305397000), ('POR', 'Portugal', 10617600), ('POL', 'Poland', 38115967), ('AUS', 'Australia', 21446187), ('FRA', 'France', 64473140), ('RUS', 'Russia', 141900000)\" )\n ? dbUseArea( .T., , \"SELECT * FROM country\", \"country\" )\n ? \"LASTREC:\", LastRec()\n DO WHILE ! Eof()\n aI := Array( FCount() )\n FOR nI := 1 TO FCount()\n aI[nI] := FieldGet( nI )\n NEXT\n ? RecNo(), hb_ValToExp( aI )\n dbSkip()\n ENDDO\n ? \"LASTREC:\", LastRec()\n dbCloseAll()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/mt/mttest11.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "proc main()\n local getList := {}\n local cVar := space( 20 )\n\n CLS\n\n if ! hb_mtvm()\n ? \"No MT support in HVM. Clock will not be shown.\"\n WAIT\n else\n hb_threadStart( @thFunc() )\n endif\n\n @ 10, 10 SAY \"Insert cVar:\" GET cVar\n READ\n SetPos( 12, 0 )\n ? \"Result -> [\" + cVar + \"]\"\n WAIT\n\nreturn\n\nfunc thFunc()\n local cTime\n while .T.\n cTime := dtoc( date() ) + \" \" + time()\n \n hb_dispOutAt( 0, maxcol() - len( cTime ) + 1, cTime, \"GR+/N\" )\n hb_idleSleep( 1 )\n enddo\nreturn nil"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour Runtime Library file: src/rtl/einstvar.prg. Provides functions: __eInstVar53. This file provides utility functions"}, {"role": "assistant", "content": "#include \"error.ch\"\n\n\nFUNCTION __eInstVar53( oVar, cMethod, xValue, cType, nSubCode, bValid )\n\n LOCAL oError\n\n IF ! ValType( xValue ) == cType .OR. ;\n ( bValid != NIL .AND. ! Eval( bValid, oVar, xValue ) )\n oError := ErrorNew()\n oError:description := hb_langErrMsg( EG_ARG )\n oError:gencode := EG_ARG\n oError:severity := ES_ERROR\n oError:cansubstitute := .T.\n oError:subsystem := oVar:className\n#ifdef HB_CLP_STRICT\n HB_SYMBOL_UNUSED( cMethod )\n#else\n oError:operation := cMethod\n#endif\n oError:subcode := nSubCode\n oError:args := { xValue }\n xValue := Eval( ErrorBlock(), oError )\n IF ! ValType( xValue ) == cType\n __errInHandler()\n ENDIF\n ENDIF\n\n RETURN xValue"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main, Two. Harbour test program: tests/returns.prg. Contains procedures: Main, Two. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n ? \"From Main()\"\n\n Two( 1 )\n\n ? \"back to Main()\"\n\n Two( 2 )\n\n ? \"back to Main()\"\n\n RETURN\n\nPROCEDURE Two( n )\n\n DO CASE\n CASE n == 1\n ? \"n == 1\"\n RETURN\n\n CASE n == 2\n ? \"n == 2\"\n RETURN\n ENDCASE\n\n ? \"This message should not been seen\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/asum.prg. Provides functions: ft_ASum. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#define CASE_AT( x, y, z ) z[ At( x, y ) + 1 ]\n#define FORCE_BETWEEN( x, y, z ) ( y := Max( Min( y, z ), x ) )\n\nFUNCTION ft_ASum( aArray, nStartIndex, nEndIndex )\n\n LOCAL nSumTotal := 0 \n\n __defaultNIL( @nStartIndex, 1 )\n __defaultNIL( @nEndIndex, Len( aArray ) )\n\n \n FORCE_BETWEEN( 1, nEndIndex, Len( aArray ) )\n FORCE_BETWEEN( 1, nStartIndex, nEndIndex )\n\n AEval( aArray, ;\n {| xElement | ;\n nSumTotal += ;\n CASE_AT( ValType( xElement ), \"NC\", ;\n { 0, xElement, ;\n iif( HB_ISSTRING( xElement ), Len( xElement ), 0 ) } ) }, ;\n nStartIndex, nEndIndex - nStartIndex + 1 )\n\n RETURN nSumTotal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/month.prg. Provides functions: ft_Month. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_Month( dGivenDate, nMonthNum )\n\n LOCAL nTemp, aRetVal\n\n IF HB_ISNUMERIC( dGivenDate )\n nMonthNum := dGivenDate\n dGivenDate := Date()\n ELSEIF ! HB_ISDATE( dGivenDate )\n dGivenDate := Date()\n ENDIF\n\n aRetVal := ft_Year( dGivenDate )\n\n IF HB_ISNUMERIC( nMonthNum )\n IF nMonthNum < 1 .OR. nMonthNum > 12\n nMonthNum := 12\n ENDIF\n dGivenDate := ft_MAdd( aRetVal[ 2 ], nMonthNum - 1 )\n ENDIF\n\n nTemp := Month( dGivenDate ) - Month( aRetVal[ 2 ] )\n nTemp += iif( nTemp >= 0, 1, 13 )\n\n aRetVal[ 1 ] += StrZero( nTemp, 2 )\n aRetVal[ 2 ] := ft_MAdd( aRetVal[ 2 ], nTemp - 1 )\n aRetVal[ 3 ] := ft_MAdd( aRetVal[ 2 ], 1 ) - 1\n\n RETURN aRetVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'gtwvg' (): contrib/gtwvg/wnd.prg. Defines classes: WvgWindow. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\n\nCREATE CLASS WvgWindow INHERIT WvgPartHandler\n\n \n VAR animate INIT .F.\n VAR clipChildren INIT .F.\n VAR clipParent INIT .F.\n VAR clipSiblings INIT .T.\n VAR group INIT 0 \n VAR sizeRedraw INIT .F.\n VAR tabStop INIT .F.\n VAR visible INIT .T.\n\n VAR pointerFocus INIT .T.\n\n \n VAR dropZone INIT .F.\n VAR helpLink\n VAR s_tooltipText INIT \"\"\n METHOD tooltipText( cText ) SETGET\n\n VAR clr_FG\n VAR clr_BG\n VAR fnt_COMMPOUNDNAME\n VAR fnt_hFont\n\n \n VAR sl_enter\n VAR sl_leave\n VAR sl_lbClick\n VAR sl_lbDblClick\n VAR sl_lbDown\n VAR sl_lbUp\n VAR sl_mbClick\n VAR sl_mbDblClick\n VAR sl_mbDown\n VAR sl_mbUp\n VAR sl_motion\n VAR sl_rbClick\n VAR sl_rbDblClick\n VAR sl_rbDown\n VAR sl_rbUp\n VAR sl_wheel\n\n VAR sl_helpRequest\n VAR sl_keyboard\n VAR sl_killInputFocus\n VAR sl_move\n VAR sl_paint\n VAR sl_quit\n VAR sl_resize\n VAR sl_setInputFocus\n VAR sl_dragEnter\n VAR sl_dragMotion\n VAR sl_dragLeave\n VAR sl_dragDrop\n\n VAR sl_close\n VAR sl_setDisplayFocus\n VAR sl_killDisplayFocus\n\n VAR hBrushBG\n VAR is_hidden INIT .F.\n VAR is_enabled INIT .T.\n VAR title INIT \" \"\n VAR icon INIT 0\n VAR closable INIT .T.\n VAR resizable INIT .T.\n VAR resizeMode INIT 0\n VAR style INIT WIN_WS_OVERLAPPEDWINDOW\n VAR exStyle INIT 0\n VAR lModal INIT .F.\n VAR pGTp\n VAR pGT\n VAR objType INIT objTypeNone\n VAR className INIT \"\"\n\n VAR hWnd\n VAR pWnd\n VAR aPos INIT { 0, 0 }\n VAR aSize INIT { 0, 0 }\n VAR aPresParams INIT {}\n VAR lHasInputFocus INIT .F.\n VAR nFrameState INIT 0 \n\n VAR maxCol INIT 79\n VAR maxRow INIT 24\n VAR mouseMode INIT 1\n\n VAR nID INIT 0\n VAR nControlID INIT 5000\n VAR nOldProc INIT 0\n\n VAR oMenu\n\n VAR nTop\n VAR nLeft\n VAR nBottom\n VAR nRight\n\n VAR hWndTT\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD destroy()\n METHOD SetWindowProcCallback()\n\n METHOD captureMouse()\n METHOD currentPos()\n METHOD currentSize()\n METHOD disable()\n METHOD enable()\n METHOD getHWND()\n METHOD getModalState()\n METHOD hasInputFocus()\n METHOD hide()\n METHOD invalidateRect( aRect )\n METHOD lockPS()\n METHOD lockUpdate()\n METHOD isDerivedFrom( cClassORoObject )\n METHOD setColorBG( nRGB )\n METHOD setModalState()\n METHOD setPointer()\n METHOD setTrackPointer()\n METHOD setPos( aPos, lPaint )\n METHOD setPosAndSize( aPos, aSize, lPaint )\n METHOD setSize( aSize, lPaint )\n METHOD setFont()\n METHOD setFontCompoundName( xFont )\n METHOD setPresParam()\n METHOD show()\n METHOD toBack()\n METHOD toFront()\n METHOD unlockPS()\n METHOD winDevice()\n\n METHOD Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD setFocus()\n METHOD sendMessage( nMessage, nlParam, nwParam )\n METHOD findObjectByHandle( hWnd )\n\n METHOD getControlID() INLINE ++::nControlID\n METHOD HandleEvent() INLINE EVENT_UNHANDELLED\n METHOD isEnabled() INLINE ::is_enabled\n METHOD isVisible() INLINE ! ::is_hidden\n METHOD setColorFG( nRGB ) INLINE ::clr_FG := iif( HB_ISSTRING( nRGB ), wvt_GetRGBColorByString( nRGB, 0 ), nRGB ), ::invalidateRect()\n\n METHOD enter( xParam ) SETGET\n METHOD leave( xParam ) SETGET\n METHOD lbClick( xParam ) SETGET\n METHOD lbDblClick( xParam ) SETGET\n METHOD lbDown( xParam ) SETGET\n METHOD lbUp( xParam ) SETGET\n METHOD mbClick( xParam ) SETGET\n METHOD mbDblClick( xParam ) SETGET\n METHOD mbDown( xParam ) SETGET\n METHOD mbUp( xParam ) SETGET\n METHOD motion( xParam ) SETGET\n METHOD rbClick( xParam ) SETGET\n METHOD rbDblClick( xParam ) SETGET\n METHOD rbDown( xParam ) SETGET\n METHOD rbUp( xParam ) SETGET\n METHOD wheel( xParam ) SETGET\n METHOD close( xParam ) SETGET\n METHOD helpRequest( xParam ) SETGET\n METHOD keyboard( xParam ) SETGET\n METHOD killDisplayFocus( xParam ) SETGET\n METHOD killInputFocus( xParam ) SETGET\n METHOD move( xParam ) SETGET\n METHOD paint( xParam ) SETGET\n METHOD quit( xParam, xParam1 ) SETGET\n METHOD resize( xParam, xParam1 ) SETGET\n METHOD setDisplayFocus( xParam ) SETGET\n METHOD setInputFocus( xParam ) SETGET\n METHOD dragEnter( xParam, xParam1 ) SETGET\n METHOD dragMotion( xParam ) SETGET\n METHOD dragLeave( xParam ) SETGET\n METHOD dragDrop( xParam, xParam1 ) SETGET\n\n PROTECTED:\n\n METHOD getPosAndSize( aPs, aSz )\n METHOD isParentCrt() INLINE ( iif( HB_ISOBJECT( ::oParent ), ::oParent:objType == objTypeCrt, .F. ) )\n METHOD rePosition()\n METHOD createControl()\n\nENDCLASS\n\nMETHOD WvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n __defaultNIL( @oParent , ::oParent )\n __defaultNIL( @oOwner , ::oOwner )\n __defaultNIL( @aPos , ::aPos )\n __defaultNIL( @aSize , ::aSize )\n __defaultNIL( @aPresParams, ::aPresParams )\n __defaultNIL( @lVisible , ::visible )\n\n ::oParent := oParent\n ::oOwner := oOwner\n ::aPos := aPos\n ::aSize := aSize\n ::aPresParams := aPresParams\n ::visible := lVisible\n\n ::WvgPartHandler:new( oParent, oOwner )\n\n RETURN Self\n\nMETHOD WvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n __defaultNIL( @oParent , ::oParent )\n __defaultNIL( @oOwner , ::oOwner )\n __defaultNIL( @aPos , ::aPos )\n __defaultNIL( @aSize , ::aSize )\n __defaultNIL( @aPresParams, ::aPresParams )\n __defaultNIL( @lVisible , ::visible )\n\n ::oParent := oParent\n ::oOwner := oOwner\n ::aPos := aPos\n ::aSize := aSize\n ::aPresParams := aPresParams\n ::visible := lVisible\n\n IF Empty( ::oParent )\n IF ! ::ClassName() $ \"WVGCRT,WVGDIALOG\"\n ::oParent := WvgSetAppWindow()\n ENDIF\n ENDIF\n\n ::WvgPartHandler:create( oParent, oOwner )\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main, draw_table, show_text_right. Harbour contribution module 'hbcairo' (Cairo graphics library wrapper): contrib/hbcairo/tests/table.prg. Contains 4 procedures. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbcairo\"\n\nPROCEDURE Main()\n\n LOCAL hSurface, hCairo\n FIELD CODE, NAME, RESIDENTS\n\n \n dbCreate( \"country\", { { \"CODE\", \"C\", 3, 0 }, { \"NAME\", \"C\", 30, 0 }, { \"RESIDENTS\", \"N\", 10, 0 } },, .T. )\n dbAppend(); CODE := \"LTU\"; NAME := \"Lithuania\"; RESIDENTS := 3369600\n dbAppend(); CODE := \"USA\"; NAME := \"United States of America\"; RESIDENTS := 305397000\n dbAppend(); CODE := \"POR\"; NAME := \"Portugal\"; RESIDENTS := 10617600\n dbAppend(); CODE := \"POL\"; NAME := \"Poland\"; RESIDENTS := 38115967\n dbAppend(); CODE := \"AUS\"; NAME := \"Australia\"; RESIDENTS := 21446187\n dbAppend(); CODE := \"FRA\"; NAME := \"France\"; RESIDENTS := 64473140\n dbAppend(); CODE := \"RUS\"; NAME := \"Russia\"; RESIDENTS := 141900000\n\n \n hSurface := cairo_pdf_surface_create( \"table.pdf\", 566.9, 793.7 ) \n hCairo := cairo_create( hSurface )\n\n cairo_select_font_face( hCairo, \"sans-serif\", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD )\n cairo_set_font_size( hCairo, 16 )\n cairo_set_source_rgb( hCairo, 0, 0, 0 )\n\n cairo_move_to( hCairo, 50, 50 )\n cairo_show_text( hCairo, \"Table of countries\" )\n\n draw_table( hCairo, 50, 75, { { \"Code\", \"CODE\" }, { \"Country\", \"NAME\" }, { \"Residents\", \"RESIDENTS\" } } )\n\n cairo_show_page( hCairo )\n cairo_destroy( hCairo )\n cairo_surface_destroy( hSurface )\n dbCloseAll()\n\n RETURN\n\n\nSTATIC PROCEDURE draw_table( hCairo, nX, nY, aCol )\n\n LOCAL nI, aWidth, nDX, nW, xValue\n\n cairo_save( hCairo )\n cairo_select_font_face( hCairo, \"sans-serif\", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL )\n cairo_set_font_size( hCairo, 10 )\n cairo_set_source_rgb( hCairo, 0, 0, 0 )\n cairo_set_line_width( hCairo, 1 )\n\n dbGoTop()\n aWidth := Array( Len( aCol ) )\n FOR nI := 1 TO Len( aCol )\n aWidth[ nI ] := cairo_text_extents( hCairo, Replicate( \"9\", FieldLen( FieldPos( aCol[ nI, 2 ] ) ) ) )[ 5 ]\n aWidth[ nI ] := Max( aWidth[ nI ], cairo_text_extents( hCairo, aCol[ nI, 1 ] )[ 5 ] ) + 20\n NEXT\n nW := 0\n AEval( aWidth, {| X | nW += X } )\n\n cairo_move_to( hCairo, nX, nY )\n cairo_rel_line_to( hCairo, nW, 0 )\n cairo_stroke( hCairo )\n\n nDX := nX\n FOR nI := 1 TO Len( aCol )\n cairo_move_to( hCairo, nDX + aWidth[ nI ] / 2, nY + 10 )\n show_text_center( hCairo, aCol[ nI, 1 ] )\n nDX += aWidth[ nI ]\n IF nI < Len( aCol )\n cairo_move_to( hCairo, nDX, nY )\n cairo_rel_line_to( hCairo, 0, 13 )\n cairo_stroke( hCairo )\n ENDIF\n NEXT\n nY += 13\n cairo_move_to( hCairo, nX, nY )\n cairo_rel_line_to( hCairo, nW, 0 )\n cairo_stroke( hCairo )\n\n DO WHILE ! Eof()\n nDX := nX\n FOR nI := 1 TO Len( aCol )\n xValue := FieldGet( FieldPos( aCol[ nI, 2 ] ) )\n SWITCH ValType( xValue )\n CASE \"C\"\n cairo_move_to( hCairo, nDX + 10, nY + 10 )\n cairo_show_text( hCairo, xValue )\n EXIT\n CASE \"N\"\n cairo_move_to( hCairo, nDX + aWidth[ nI ] - 10, nY + 10 )\n show_text_right( hCairo, Str( xValue ) )\n EXIT\n CASE \"D\"\n cairo_move_to( hCairo, nDX + 10, nY + 10 )\n show_text_right( hCairo, DToC( xValue ) )\n EXIT\n ENDSWITCH\n nDX += aWidth[ nI ]\n IF nI < Len( aCol )\n cairo_move_to( hCairo, nDX, nY )\n cairo_rel_line_to( hCairo, 0, 13 )\n cairo_stroke( hCairo )\n ENDIF\n NEXT\n dbSkip()\n nY += 13\n ENDDO\n cairo_move_to( hCairo, nX, nY )\n cairo_rel_line_to( hCairo, nW, 0 )\n cairo_stroke( hCairo )\n\n cairo_restore( hCairo )\n\n RETURN\n\n\nSTATIC PROCEDURE show_text_right( hCairo, cText )\n\n cairo_rel_move_to( hCairo, - cairo_text_extents( hCairo, cText )[ 5 ], 0 )\n cairo_show_text( hCairo, cText )\n\n RETURN\n\n\nSTATIC PROCEDURE show_text_center( hCairo, cText )\n\n cairo_rel_move_to( hCairo, -0.5"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Header file for contribution module 'hbcurl' (libcurl wrapper for HTTP/FTP/SMTP operations): contrib/hbcurl/hbcurl.ch. Defines 10 constants including: HBCURL_CH_, HB_CURLOPT_FILE, HB_CURLOPT_URL, HB_CURLOPT_PORT, HB_CURLOPT_PROXY. Defines keyboard input constants"}, {"role": "assistant", "content": "#ifndef HBCURL_CH_\n#define HBCURL_CH_\n\n\n#define HB_CURLOPT_FILE 1\n#define HB_CURLOPT_URL 2\n#define HB_CURLOPT_PORT 3\n#define HB_CURLOPT_PROXY 4\n#define HB_CURLOPT_USERPWD 5\n#define HB_CURLOPT_PROXYUSERPWD 6\n#define HB_CURLOPT_RANGE 7\n#define HB_CURLOPT_INFILE 9\n#define HB_CURLOPT_ERRORBUFFER 10\n#define HB_CURLOPT_WRITEFUNCTION 11\n#define HB_CURLOPT_READFUNCTION 12\n#define HB_CURLOPT_TIMEOUT 13\n#define HB_CURLOPT_INFILESIZE 14\n#define HB_CURLOPT_POSTFIELDS 15\n#define HB_CURLOPT_REFERER 16\n#define HB_CURLOPT_FTPPORT 17\n#define HB_CURLOPT_USERAGENT 18\n#define HB_CURLOPT_LOW_SPEED_LIMIT 19\n#define HB_CURLOPT_LOW_SPEED_TIME 20\n#define HB_CURLOPT_RESUME_FROM 21\n#define HB_CURLOPT_COOKIE 22\n#define HB_CURLOPT_HTTPHEADER 23\n#define HB_CURLOPT_HTTPPOST 24\n#define HB_CURLOPT_SSLCERT 25\n#define HB_CURLOPT_KEYPASSWD 26\n#define HB_CURLOPT_SSLCERTPASSWD HB_CURLOPT_KEYPASSWD\n#define HB_CURLOPT_SSLKEYPASSWD HB_CURLOPT_KEYPASSWD\n#define HB_CURLOPT_CRLF 27\n#define HB_CURLOPT_QUOTE 28\n#define HB_CURLOPT_WRITEHEADER 29\n#define HB_CURLOPT_COOKIEFILE 31\n#define HB_CURLOPT_SSLVERSION 32\n#define HB_CURLOPT_TIMECONDITION 33\n#define HB_CURLOPT_TIMEVALUE 34\n#define HB_CURLOPT_CUSTOMREQUEST 36\n#define HB_CURLOPT_STDERR 37\n#define HB_CURLOPT_POSTQUOTE 39\n#define HB_CURLOPT_WRITEINFO 40\n#define HB_CURLOPT_VERBOSE 41 \n#define HB_CURLOPT_HEADER 42 \n#define HB_CURLOPT_NOPROGRESS 43 \n#define HB_CURLOPT_NOBODY 44 \n#define HB_CURLOPT_FAILONERROR 45 \n#define HB_CURLOPT_UPLOAD 46 \n#define HB_CURLOPT_POST 47 \n#define HB_CURLOPT_DIRLISTONLY 48 \n#define HB_CURLOPT_FTPLISTONLY HB_CURLOPT_DIRLISTONLY\n#define HB_CURLOPT_APPEND 50 \n#define HB_CURLOPT_FTPAPPEND HB_CURLOPT_APPEND\n#define HB_CURLOPT_NETRC 51\n#define HB_CURLOPT_FOLLOWLOCATION 52 \n#define HB_CURLOPT_TRANSFERTEXT 53 \n#define HB_CURLOPT_PUT 54 \n#define HB_CURLOPT_PROGRESSFUNCTION 56\n#define HB_CURLOPT_PROGRESSDATA HB_CURLOPT_XFERINFODATA\n#define HB_CURLOPT_XFERINFODATA 57\n#define HB_CURLOPT_AUTOREFERER 58\n#define HB_CURLOPT_PROXYPORT 59\n#define HB_CURLOPT_POSTFIELDSIZE 60\n#define HB_CURLOPT_HTTPPROXYTUNNEL 61\n#define HB_CURLOPT_INTERFACE 62\n#define HB_CURLOPT_KRBLEVEL 63 \n#define HB_CURLOPT_KRB4LEVEL HB_CURLOPT_KRBLEVEL\n#define HB_CURLOPT_SSL_VERIFYPEER 64\n#define HB_CURLOPT_CAINFO 65\n#define HB_CURLOPT_MAXREDIRS 68\n#define HB_CURLOPT_FILETIME 69\n#define HB_CURLOPT_TELNETOPTIONS 70\n#define HB_CURLOPT_MAXCONNECTS 71\n#define HB_CURLOPT_CLOSEPOLICY 72\n#define HB_CURLOPT_FRESH_CONNECT 74\n#define HB_CURLOPT_FORBID_REUSE 75\n#define HB_CURLOPT_RANDOM_FILE 76 \n#define HB_CURLOPT_EGDSOCKET 77 \n#define HB_CURLOPT_CONNECTTIMEOUT 78\n#define HB_CURLOPT_HEADERFUNCTION 79\n#define HB_CURLOPT_HTTPGET 80\n#define HB_CURLOPT_SSL_VERIFYHOST 81\n#define HB_CURLOPT_COOKIEJAR 82\n#define HB_CURLOPT_SSL_CIPHER_LIST 83\n#define HB_CURLOPT_HTTP_VERSION 84\n#define HB_CURLOPT_FTP_USE_EPSV 85\n#define HB_CURLOPT_SSLCERTTYPE 86\n#define HB_CURLOPT_SSLKEY 87\n#define HB_CURLOPT_SSLKEYTYPE 88\n#define HB_CURLOPT_SSLENGINE 89\n#define HB_CURLOPT_SSLENGINE_DEFAULT 90\n#define HB_CURLOPT_DNS_USE_GLOBAL_CACHE 91 \n#define HB_CURLOPT_DNS_CACHE_TIMEOUT 92\n#define HB_CURLOPT_PREQUOTE 93\n#define HB_CURLOPT_DEBUGFUNCTION 94\n#define HB_CURLOPT_DEBUGDATA 95\n#define HB_CURLOPT_COOKIESESSION 96\n#define HB_CURLOPT_CAPATH 97\n#define HB_CURLOPT_BUFFERSIZE 98\n#define HB_CURLOPT_NOSIGNAL 99\n#define HB_CURLOPT_SHARE 100\n#define HB_CURLOPT_PROXYTYPE 101\n#define HB_CURLOPT_ACCEPT_ENCODING 102\n#define HB_CURLOPT_ENCODING HB_CURLOPT_ACCEPT_ENCODING\n#define HB_CURLOPT_PRIVATE 103\n#define HB_CURLOPT_HTTP200ALIASES 104\n#define HB_CURLOPT_UNRESTRICTED_AUTH 105\n#define HB_CURLOPT_FTP_USE_EPRT 106\n#define HB_CURLOPT_HTTPAUTH 107\n#define HB_CURLOPT_SSL_CTX_FUNCTION 108\n#define HB_CURLOPT_SSL_CTX_DATA 109\n#define HB_CURLOPT_FTP_CREATE_MISSING_DIRS 110\n#define HB_CURLOPT_PROXYAUTH 111\n#define HB_CURLOPT_FTP_RESPONSE_TIMEOUT 112\n#define HB_CURLOPT_IPRESOLVE 113\n#define HB_CURLOPT_MAXFILESIZE 114\n#define HB_CURLOPT_INFILESIZE_LARGE 115\n#define HB_CURLOPT_RESUME_FROM_LARGE 116\n#define HB_CURLOPT_MAXFILESIZE_LARGE 117\n#define HB_CURLOPT_NETRC_FILE 118\n#define HB_CURLOPT_USE_SSL 119\n#define HB_CURLOPT_FTP_SSL HB_CURLOPT_USE_SSL\n#define HB_CURLOPT_POSTFIELDSIZE_LARGE 120\n#define HB_CURLOPT_TCP_NODELAY 121\n#define HB_CURLOPT_SOURCE_USERPWD 123\n#define HB_CURLOPT_SOURCE_PREQUOTE 127\n#define HB_CURLOPT_SOURCE_POSTQUOTE 128\n#define HB_CURLOPT_FTPSSLAUTH 129\n#define HB_CURLOPT_IOCTLFUNCTION 130\n#define HB_CURLOPT_IOCTLDATA 131\n#define HB_CURLOPT_SOURCE_URL 132\n#define HB_CURLOPT_SOURCE_QUOTE 133\n#define HB_CURLOPT_FTP_ACCOUNT 134\n#define HB_CURLOPT_COOKIELIST 135\n#define HB_CURLOPT_IGNORE_CONTENT_LENGTH 136\n#define HB_CURLOPT_FTP_SKIP_PASV_IP 137\n#define HB_CURLOPT_FTP_FILEMETHOD 138\n#define HB_CURLOPT_LOCALPORT 139\n#define HB_CURLOPT_LOCALPORTRANGE 140\n#define HB_CURLOPT_CONNECT_ONLY 141\n#define HB_CURLOPT_CONV_FROM_NETWORK_FUNCTION 142\n#define HB_CURLOPT_CONV_TO_NETWORK_FUNCTION 143\n#define HB_CURLOPT_CONV_FROM_UTF8_FUNCTION 144\n#define HB_CURLOPT_MAX_SEND_SPEED_LARGE 145\n#define HB_CURLOPT_MAX_RECV_SPEED_LARGE 146\n#define HB_CURLOPT_FTP_ALTERNATIVE_TO_USER 147\n#define HB_CURLOPT_SOCKOPTFUNCTION 148\n#define HB_CURLOPT_SOCKOPTDATA 149\n#define HB_CURLOPT_SSL_SESSIONID_CACHE 150\n#define HB_CURLOPT_SSH_AUTH_TYPES 151\n#define HB_CURLOPT_SSH_PUBLIC_KEYFILE 152\n#define HB_CURLOPT_SSH_PRIVATE_KEYFILE 153\n#define HB_CURLOPT_FTP_SSL_CCC 154\n#define HB_CURLOPT_TIMEOUT_MS 155\n#define HB_CURLOPT_CONNECTTIMEOUT_MS 156\n#define HB_CURLOPT_HTTP_TRANSFER_DECODING 157\n#define HB_CURLOPT_HTTP_CONTENT_DECODING 158\n#define HB_CURLOPT_NEW_FILE_PERMS 159\n#define HB_CURLOPT_NEW_DIRECTORY_PERMS 160\n#define HB_CURLOPT_POST301 161\n#define HB_CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 162"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbmxml' (XML generation library): contrib/hbmxml/tests/reminder.prg. Provides functions: simplexml_load_file, asXML, type_cb. Contains procedures: Main, my_mxmlError. This file handles data format parsing and generation"}, {"role": "assistant", "content": "#require \"hbmxml\"\n\nSTATIC s_mxml_error := .F.\nSTATIC s_mxml_error_msg := \"\"\n\nPROCEDURE Main()\n\n LOCAL xml\n\n mxmlSetErrorCallback( @my_mxmlError() )\n\n IF hb_FileExists( \"rem.xml\" )\n xml := simplexml_load_file( \"rem.xml\" )\n ELSE\n RETURN\n ENDIF\n\n IF ! s_mxml_error\n OutStd( asXML( xml ), hb_eol() )\n ENDIF\n\n mxmlDelete( xml )\n\n IF hb_FileExists( \"rem_err.xml\" )\n xml := simplexml_load_file( \"rem_err.xml\" )\n\n IF s_mxml_error\n OutErr( \"hbmxml:\", s_mxml_error_msg, hb_eol() )\n ELSE\n OutStd( asXML( xml ), hb_eol() )\n ENDIF\n ENDIF\n\n RETURN\n\nPROCEDURE my_mxmlError( cErrorMsg )\n\n s_mxml_error_msg := cErrorMsg\n s_mxml_error := .T.\n\n RETURN\n\nSTATIC FUNCTION simplexml_load_file( file )\n\n RETURN mxmlLoadString( NIL, hb_MemoRead( file ), @type_cb() )\n\nSTATIC FUNCTION asXML( xml )\n\n LOCAL cText := \"\", c\n LOCAL wt := 3\n LOCAL node, subnode\n\n node := mxmlFindElement( xml, xml, \"note\", NIL, NIL, MXML_DESCEND )\n IF Empty( node )\n RETURN \"\"\n ENDIF\n\n subnode := mxmlGetFirstChild( node )\n DO WHILE ! Empty( subnode := mxmlGetNextSibling( subnode ) )\n IF mxmlGetType( subnode ) == MXML_ELEMENT\n IF mxmlGetElement( subnode ) == \"body\"\n c := mxmlGetOpaque( subnode )\n ELSE\n c := mxmlGetText( subnode, @wt )\n ENDIF\n cText += ( c + \" \" )\n ENDIF\n ENDDO\n\n RETURN cText\n\nFUNCTION type_cb( node )\n\n LOCAL nResult\n LOCAL cType\n\n \n IF Empty( cType := mxmlElementGetAttr( node, \"type\" ) )\n cType := mxmlGetElement( node )\n ENDIF\n\n SWITCH Lower( cType )\n CASE \"note\"\n CASE \"to\"\n CASE \"from\"\n CASE \"heading\"\n nResult := MXML_TEXT\n EXIT\n\n CASE \"body\"\n CASE \"opaque\"\n nResult := MXML_OPAQUE\n EXIT\n\n OTHERWISE\n nResult := MXML_IGNORE\n EXIT\n ENDSWITCH\n\n RETURN nResult"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbgd' (Graphics drawing library (GD)): contrib/hbgd/tests/cgi.prg. Provides functions: GetVars, GetParams, URLDecode, URLEncode. Contains 5 procedures. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbgd\"\n\n#command WRITE => FWrite( 1, + hb_eol() )\n#command OutHTML => WRITE \n\nPROCEDURE Main( ... )\n\n LOCAL cPar\n LOCAL aParams := hb_AParams()\n LOCAL cQuery := GetEnv( \"QUERY_STRING\" )\n LOCAL hParams := { => }\n\n LOCAL cImg, nPt, nWidth, nHeight, cPhoto\n\n\n IF Empty( aParams )\n IF ! Empty( cQuery )\n hParams := GetVars( cQuery )\n ENDIF\n ELSE\n hParams := GetParams( aParams )\n ENDIF\n\n \n IF ! Empty( hParams )\n FOR EACH cPar IN hParams:Keys\n\n DO CASE\n CASE cPar == \"txt\"\n \n\n CASE cPar == \"img\"\n cImg := hParams[ cPar ]\n\n CASE cPar == \"photo\"\n cPhoto := hParams[ cPar ]\n\n CASE cPar == \"width\"\n nWidth := Val( hParams[ cPar ] )\n\n CASE cPar == \"height\"\n nHeight := Val( hParams[ cPar ] )\n\n CASE cPar == \"pt\"\n nPt := Val( hParams[ cPar ] )\n\n ENDCASE\n NEXT\n ENDIF\n\n \n hb_default( @nPt, 30 )\n\n IF cImg != NIL\n OutPhoto( cImg, nWidth, nHeight )\n\n ELSEIF cPhoto != NIL\n StartHTML()\n OutHTML \"\"\n OutHTML \"\"\n OutHTML \"\"\n OutHTML \"\"\n OutHTML \"
\"\n OutHTML \"\" + \"
\"\n OutHTML \"
\"\n OutHTML \"\" + \"
\"\n OutHTML \"
\"\n OutHTML cPhoto\n OutHTML \"
\"\n OutHTML \"
\"\n EndHTML()\n ELSE\n StartHTML()\n EndHTML()\n ENDIF\n\n RETURN\n\nPROCEDURE StartHTML( cTitle )\n\n hb_default( @cTitle, \"\" )\n\n WRITE \"content-type: text/html\"\n WRITE \"Pragma: no-cache\"\n WRITE hb_eol()\n WRITE \"\"\n WRITE \"\"\n WRITE \"\" + cTitle + \"\"\n WRITE \"\"\n WRITE \"\"\n\n RETURN\n\nPROCEDURE EndHTML()\n\n WRITE \"\"\n WRITE \"\"\n\n RETURN\n\nPROCEDURE OutPhoto( cPhoto, nWidth, nHeight )\n\n LOCAL cType\n\n LOCAL oImage := GDImage():LoadFromFile( cPhoto )\n\n IF nWidth != NIL .AND. nHeight != NIL\n oImage:Resize( nWidth, nHeight )\n ELSEIF nWidth != NIL .AND. nHeight == NIL\n nHeight := oImage:Height()\n WRITE \"content-type: \" + oImage:cMime + hb_eol()\n cType := oImage:cType\n\n DO CASE\n CASE cType == \"jpeg\"\n oImage:OutputJpeg()\n CASE cType == \"gif\"\n oImage:OutputGif()\n CASE cType == \"png\"\n oImage:OutputPng()\n ENDCASE\n\n RETURN\n\nPROCEDURE OutJpg( cText, nPitch )\n\n LOCAL oI\n\n \n LOCAL blue\n LOCAL aSize, nWidth, nHeight, nX, nY\n\n hb_default( @cText, \"Sample TEXT\" )\n hb_default( @nPitch, 30 )\n\n \n oI := GDImage( 400, 100 )\n\n\n oI:SetFontName( \"Verdana\" ) \n oI:SetFontPitch( nPitch )\n#endif\n __OutDebug( oI:GetFTFontHeight() )\n#endif\n aSize := oI:GetFTStringSize( cText )\n nWidth := aSize[ 1 ]\n nHeight := aSize[ 2 ]\n nX := aSize[ 3 ]\n nY := aSize[ 4 ]\n oI:Resize( nWidth, nHeight )\n\n\n blue := oI:SetColor( 0, 0, 200 )\n oI:SetFontName( \"Verdana\" ) \n oI:SetFontPitch( nPitch )\n oI:SayFreeType( 0 - nX, 0 + nHeight - nY, cText, , , 0, blue )\n#endif\n oI:SayFreeType( 0, 0, cText, , , 0, blue )\n\n oI:Resize( nWidth, nHeight )\n __OutDebug( \"prima\", oI:Width(), oI:Height() )\n oI:Resize( 60, 40 )\n __OutDebug( \"dopo\", oI:Width(), oI:Height() )\n\n oI:SetFontLarge()\n oI:SetColor( blue )\n oI:Say( 0, 0, cText )\n#endif\n\n WRITE \"content-type: image/jpeg\" + hb_eol()\n\n oI:OutputJpeg()\n\n RETURN\n\nFUNCTION GetVars( cFields, cSeparator )\n\n LOCAL hHashVars := { => }\n LOCAL aField, cField, aFields\n LOCAL cName, xValue\n\n hb_default( @cSeparator, \"&\" )\n\n aFields := hb_regexSplit( cSeparator, cFields )\n\n FOR EACH cField in aFields\n aField := hb_regexSplit( \"=\", cField, 2 )\n IF Len( aField ) != 2\n LOOP\n ENDIF\n\n cName := LTrim( aField[ 1 ] )\n xValue := UrlDecode( aField[ 2 ] )\n\n \n IF SubStr( cName, Len( cName ) - 1 ) == \"[]\"\n cName := SubStr( cName, 1, Len( cName ) - 2 )\n\n hHashVars[ cName ] := { xValue }\n\n ELSE\n\n hHashVars[ cName ] := xValue\n\n ENDIF\n \n NEXT\n \n\n RETURN hHashVars\n\nFUNCTION GetParams( aParams )\n\n LOCAL hHashVars := { => }\n LOCAL aField, cField, aFields\n LOCAL cName, xValue\n\n aFields := aParams\n\n FOR EACH cField in aFields\n aField := hb_regexSplit( \"=\", cField, 2 )\n IF Len( aField ) != 2\n LOOP\n ENDIF\n\n cName := LTrim( aField[ 1 ] )\n xValue := UrlDecode( aField[ 2 ] )\n\n \n IF SubStr( cName, Len( cName ) - 1 ) == \"[]\"\n cName := SubStr( cName, 1, Len( cName ) - 2 )\n\n hHashVars[ cName ] := { xValue }\n\n ELSE\n\n hHashVars[ cName ] := xValue\n\n ENDIF\n \n NEXT\n \n\n RETURN hHashVars\n\n\nFUNCTION URLDecode( cStr )\n\n LOCAL cRet := \"\", i, cCar\n\n \n FOR i := 1 TO Len( cStr )\n cCar := cStr[ i ]\n\n DO CASE\n CASE cCar == \"+\"\n cRet += \" \"\n\n CASE cCar == \"%\"\n i++\n cRet += Chr( hb_HexToNum( SubStr( cStr, i, 2 ) ) )\n i++\n\n OTHERWISE\n cRet += cCar\n\n ENDCASE\n\n NEXT\n\n\n RETURN cRet\n\nFUNCTION URLEncode( cStr )\n\n LOCAL cRet := \"\", i, nVal, cCar\n\n FOR i := 1 TO Len( cStr )\n cCar := cStr[ i ]\n DO CASE\n CASE cCar == \" \"\n cRet += \"+\"\n\n CASE cCar >= \"A\" .AND. cCar <= \"Z\"\n cRet += cCar\n\n CASE cCar >= \"a\" .AND. cCar <= \"z\"\n cRet += cCar\n\n CASE cCar >= \"0\" .AND. cCar <= \"9\"\n cRet += cCar\n\n OTHERWISE\n nVal := Asc( cCar )\n cRet += \"%\" + hb_NumToHex( nVal )\n ENDCASE\n NEXT\n\n RETURN cRet"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: HBDbWindow. Harbour Runtime Library file: src/debug/dbgtwin.prg. Defines classes: HBDbWindow. This file provides utility functions"}, {"role": "assistant", "content": "#pragma -b-\n\n#define HB_CLS_NOTOBJECT \n#include \"hbclass.ch\"\n\n#include \"hbmemvar.ch\"\n\n#include \"box.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\nCREATE CLASS HBDbWindow \n\n VAR nTop\n VAR nLeft\n VAR nBottom\n VAR nRight\n VAR cCaption\n VAR cBackImage\n VAR cColor\n VAR lFocused INIT .F.\n VAR bGotFocus\n VAR bLostFocus\n VAR bKeyPressed\n VAR bPainted\n VAR bLButtonDown\n VAR bLDblClick\n VAR lShadow INIT .F.\n VAR lVisible INIT .F.\n VAR Cargo\n VAR Browser\n\n METHOD New( nTop, nLeft, nBottom, nRight, cCaption, cColor )\n\n METHOD Hide()\n METHOD IsOver( nRow, nCol )\n METHOD nWidth() INLINE ::nRight - ::nLeft + 1\n METHOD Clear()\n METHOD ScrollUp( nLines )\n METHOD SetCaption( cCaption )\n METHOD ShowCaption()\n METHOD SetFocus( lOnOff )\n METHOD Show( lFocused )\n METHOD ShowModal()\n METHOD LButtonDown( nMRow, nMCol )\n METHOD LDblClick( nMRow, nMCol )\n METHOD LoadColors()\n\n METHOD Move()\n METHOD KeyPressed( nKey )\n METHOD Refresh()\n METHOD Resize( nTop, nLeft, nBottom, nRight )\n\nENDCLASS\n\nMETHOD New( nTop, nLeft, nBottom, nRight, cCaption, cColor ) CLASS HBDbWindow\n\n ::nTop := nTop\n ::nLeft := nLeft\n ::nBottom := nBottom\n ::nRight := nRight\n ::cCaption := cCaption\n ::cColor := hb_defaultValue( cColor, __dbgColors()[ 1 ] )\n\n RETURN Self\n\nMETHOD PROCEDURE Clear() CLASS HBDbWindow\n\n hb_Scroll( ::nTop + 1, ::nLeft + 1, ::nBottom - 1, ::nRight - 1,,, ::cColor )\n\n RETURN\n\nMETHOD PROCEDURE Hide() CLASS HBDbWindow\n\n __dbgRestScreen( ::nTop, ::nLeft, ::nBottom + iif( ::lShadow, 1, 0 ), ;\n ::nRight + iif( ::lShadow, 2, 0 ), ::cBackImage )\n ::cBackImage := NIL\n ::lVisible := .F.\n\n RETURN\n\nMETHOD IsOver( nRow, nCol ) CLASS HBDbWindow\n\n RETURN ;\n nRow >= ::nTop .AND. nRow <= ::nBottom .AND. ;\n nCol >= ::nLeft .AND. nCol <= ::nRight\n\nMETHOD PROCEDURE ScrollUp( nLines ) CLASS HBDbWindow\n\n hb_Scroll( ::nTop + 1, ::nLeft + 1, ::nBottom - 1, ::nRight - 1, hb_defaultValue( nLines, 1 ),, ::cColor )\n\n RETURN\n\nMETHOD PROCEDURE SetCaption( cCaption ) CLASS HBDbWindow\n\n ::cCaption := cCaption\n\n RETURN\n\nMETHOD PROCEDURE ShowCaption() CLASS HBDbWindow\n\n IF ! Empty( ::cCaption )\n hb_DispOutAt( ::nTop, ::nLeft + ( ( ::nRight - ::nLeft ) / 2 ) - ;\n ( ( Len( ::cCaption ) + 2 ) / 2 ), ;\n \" \" + ::cCaption + \" \", ::cColor )\n ENDIF\n\n RETURN\n\nMETHOD PROCEDURE SetFocus( lOnOff ) CLASS HBDbWindow\n\n IF ! lOnOff .AND. HB_ISEVALITEM( ::bLostFocus )\n Eval( ::bLostFocus, Self )\n ENDIF\n\n ::lFocused := lOnOff\n\n IF lOnOff .AND. HB_ISEVALITEM( ::bGotFocus )\n Eval( ::bGotFocus, Self )\n ENDIF\n\n RETURN\n\nMETHOD PROCEDURE Refresh() CLASS HBDbWindow\n\n DispBegin()\n\n hb_DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, iif( ::lFocused, HB_B_DOUBLE_UNI, HB_B_SINGLE_UNI ), ::cColor )\n hb_DispOutAtBox( ::nTop, ::nLeft + 1, hb_UTF8ToStrBox( \"[■]\" ), ::cColor )\n\n ::ShowCaption( ::cCaption )\n\n IF HB_ISEVALITEM( ::bPainted )\n Eval( ::bPainted, Self )\n ENDIF\n\n DispEnd()\n\n RETURN\n\nMETHOD PROCEDURE Show( lFocused ) CLASS HBDbWindow\n\n ::cBackImage := __dbgSaveScreen( ::nTop, ::nLeft, ;\n ::nBottom + iif( ::lShadow, 1, 0 ), ;\n ::nRight + iif( ::lShadow, 2, 0 ) )\n hb_Scroll( ::nTop, ::nLeft, ::nBottom, ::nRight,,, ::cColor )\n ::SetFocus( hb_defaultValue( lFocused, ::lFocused ) )\n\n IF ::lShadow\n hb_Shadow( ::nTop, ::nLeft, ::nBottom, ::nRight )\n ENDIF\n\n ::Refresh()\n ::lVisible := .T.\n\n RETURN\n\nMETHOD PROCEDURE ShowModal() CLASS HBDbWindow\n\n LOCAL lExit := .F.\n LOCAL nKey\n\n ::lShadow := .T.\n ::Show()\n\n DO WHILE ! lExit\n nKey := __dbgInkey()\n\n IF HB_ISEVALITEM( ::bKeyPressed )\n Eval( ::bKeyPressed, nKey )\n ENDIF\n\n SWITCH nKey\n CASE K_ESC\n lExit := .T.\n EXIT\n\n CASE K_LBUTTONDOWN\n IF MRow() == ::nTop .AND. MCol() >= ::nLeft + 1 .AND. ;\n MCol() <= ::nLeft + 3\n lExit := .T.\n ENDIF\n EXIT\n\n ENDSWITCH\n ENDDO\n\n ::Hide()\n\n RETURN\n\nMETHOD PROCEDURE LButtonDown( nMRow, nMCol ) CLASS HBDbWindow\n\n IF HB_ISEVALITEM( ::bLButtonDown )\n Eval( ::bLButtonDown, nMRow, nMCol )\n ENDIF\n\n RETURN\n\nMETHOD PROCEDURE LDblClick( nMRow, nMCol ) CLASS HBDbWindow\n\n IF HB_ISEVALITEM( ::bLDblClick )\n Eval( ::bLDblClick, nMRow, nMCol )\n ENDIF\n\n RETURN\n\nMETHOD PROCEDURE Move() CLASS HBDbWindow\n\n LOCAL nOldTop := ::nTop\n LOCAL nOldLeft := ::nLeft\n LOCAL nOldBottom := ::nbottom\n LOCAL nOldRight := ::nright\n LOCAL nKey\n\n DO WHILE .T.\n __dbgRestScreen( ,,,, ::cBackImage )\n hb_DispBox( ::nTop, ::nLeft, ::nRight, ::nBottom, Replicate( hb_UTF8ToStrBox( \"░\" ), 8 ) + \" \", ::cColor )\n\n SWITCH nKey := __dbgInkey()\n CASE K_UP\n\n IF ::nTop != 0\n ::nTop--\n ::nBottom--\n ENDIF\n EXIT\n\n CASE K_DOWN\n\n IF ::nBottom != MaxRow()\n ::nTop++\n ::nBottom++\n ENDIF\n EXIT\n\n CASE K_LEFT\n\n IF ::nLeft != 0\n ::nLeft--\n ::nRight--\n ENDIF\n EXIT\n\n CASE K_RIGHT\n\n IF ::nBottom != MaxRow()\n ::nLeft++\n ::nRight++\n ENDIF\n EXIT\n\n CASE K_ESC\n\n ::nTop := nOldTop\n ::nLeft := nOldLeft\n ::nBottom := nOldBottom\n ::nRight := nOldRight\n EXIT\n\n ENDSWITCH\n\n IF nKey == K_ESC .OR. nKey == K_ENTER\n EXIT\n ENDIF\n ENDDO\n\n\n RETURN\n\nMETHOD PROCEDURE KeyPressed( nKey ) CLASS HBDbWindow\n\n IF HB_ISEVALITEM( ::bKeyPressed )\n Eval( ::bKeyPressed, nKey, Self )\n ENDIF\n\n RETURN\n\nMETHOD PROCEDURE LoadColors() CLASS HBDbWindow\n\n LOCAL aClr := __dbgColors()\n\n ::cColor := aClr[ 1 ]\n\n IF ::Browser != NIL\n ::Browser:ColorSpec := aClr[ 2 ] + \",\" + aClr[ 5 ] + \",\" + aClr[ 3 ] + \",\" + aClr[ 6 ]\n ENDIF\n\n RETURN\n\nMETHOD Resize( nTop, nLeft, nBottom, nRight ) CLASS HBDbWindow\n\n LOCAL lShow\n\n IF ( ! HB_ISNUMERIC( nTop ) .OR. nTop == ::nTop ) .AND. ;\n ( ! HB_ISNUMERIC( nLeft ) .OR. nLeft == ::nLeft ) .AND. ;\n ( ! HB_ISNUMERIC( nBottom ) .OR. nBottom == ::nBottom ) .AND. ;\n ( ! HB_ISNUMERIC( nRight ) .OR. nRight == ::nRight )\n RETURN Self\n ENDIF\n\n IF ( lShow := ::lVisible )\n ::Hide()\n ENDIF\n\n IF HB_ISNUMERIC( nTop )\n ::nTop := nTop\n ENDIF\n IF HB_ISNUMERIC( nBottom )\n ::nBottom := nBottom\n ENDIF\n IF HB_ISNUMERIC( nLeft )\n ::nLeft := nLeft\n ENDIF\n IF HB_ISNUMERIC( nRight )\n ::nRight := nRight\n ENDIF\n\n IF ::Browser != NIL\n ::Browser:Resize( ::nTop + 1, ::nLeft + 1, ::nBottom - 1, ::nRight - 1 )\n ENDIF\n\n IF lShow\n ::Show( ::lFocused )\n ENDIF\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'gtwvg' (): contrib/gtwvg/tests/demoxbp.prg. Provides functions: ResizeDialogXbp. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"gtwvg\"\n\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\nPROCEDURE Main()\n\n LOCAL oCrt, oTBar, oSBar, oStatic, oCom, oXbp, oTree, oItem1, oItem2\n LOCAL oListBox, oCheck, oRadio, oStatic2, oMLE, oAddr\n LOCAL oPanel, oPanel1, oPanel2, cText, cNavigate, oDA\n LOCAL cVarA := \"Test A\", cVarB := \"Test B\"\n LOCAL aState := { \"not selected\", \"selected\", \"undefined\" }\n LOCAL aParts := {}\n\n#if defined( __HBSCRIPT__HBSHELL ) .AND. defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVG\" )\n#endif\n\n \n oCrt := WvgDialog():new( , , { 30, 30 }, { 900, 600 }, , .T. )\n oCrt:closable := .T.\n oCrt:icon := \"vr_1.ico\"\n oCrt:create()\n\n oCrt:setFontCompoundName( \"12.Courier italic\" )\n\n oDA := oCrt:drawingArea\n\n \n ActiveXBuildMenuXbp( oCrt, @oStatic, @oStatic2 )\n\n \n oTBar := ActiveXBuildToolBarXbp( oDA )\n\n \n oSBar := WvgStatusBar():new( oCrt ):create( , , , , , .T. )\n oSBar:panelClick := {| oPanel | wvg_MessageBox( , oPanel:caption ) }\n oPanel := oSBar:getItem( 1 )\n oPanel:caption := \"My Root Panel\"\n oPanel1 := oSBar:addItem()\n oPanel1:caption := \"Ready\"\n oPanel2 := oSBar:addItem()\n oPanel2:caption := \"Click on any part!\"\n\n \n oStatic := WvgStatic():new( oDA )\n oStatic:type := WVGSTATIC_TYPE_TEXT\n oStatic:options := WVGSTATIC_TEXT_CENTER\n oStatic:caption := Chr( 13 ) + \"Implemented Xbase++ Parts\"\n\n oStatic:create( , , { 0, oTBar:currentSize()[ 2 ] + 3 }, { 120, oCrt:currentSize()[ 2 ] - ;\n oTBar:currentSize()[ 2 ] - oSBar:currentSize()[ 2 ] - 4 }, , .T. )\n oStatic:setColorBG( RGB( 200, 200, 200 ) )\n\n \n oListBox := WvgListBox():new()\n oListBox:create( oStatic, , { 5, 55 }, { 107, 380 } )\n\n oListBox:setColorFG( RGB( 218, 61, 34 ) )\n\n\n AAdd( aParts, \"XbpDialog\" )\n AAdd( aParts, \"XbpMenuBar\" )\n AAdd( aParts, \"XbpToolBar\" )\n AAdd( aParts, \"XbpToolBarButton\" )\n AAdd( aParts, \"XbpStatusBar\" )\n AAdd( aParts, \"XbpStatic\" )\n AAdd( aParts, \"XbpTreeView\" )\n AAdd( aParts, \"XbpTreeViewItem\" )\n AAdd( aParts, \"XbpActiveXControl\" )\n AAdd( aParts, \"XbpListBox\" )\n AAdd( aParts, \"XbpPushButton\" )\n AAdd( aParts, \"XbpCheckBox\" )\n AAdd( aParts, \"XbpRadioButton\" )\n AAdd( aParts, \"Xbp3State\" )\n AAdd( aParts, \"XbpSLE\" )\n AAdd( aParts, \"XbpMLE\" )\n AAdd( aParts, \"XbpHTMLViewer\" )\n AAdd( aParts, \"XbpSysWindow\" )\n AAdd( aParts, \"XbpFontDialog\" )\n AAdd( aParts, \"XbpFont\" )\n AAdd( aParts, \"-------------\" )\n AAdd( aParts, \"DataRef\" )\n\n AEval( aParts, {| e | oListBox:addItem( e ) } )\n oListBox:itemSelected := {|| wvg_MessageBox( , oListBox:getCurItem() ) }\n oListBox:setData( 3 ) \n\n \n oXbp := WvgPushButton():new( oStatic )\n oXbp:caption := \"Hide\"\n oXbp:create( , , { 20, 440 }, { 80, 30 } )\n oXbp:activate := {|| oStatic:hide(), oCrt:sendMessage( WM_SIZE, 0, 0 ) }\n\n \n oTree := WvgTreeView():new( oDA, , { oCrt:currentSize()[ 1 ] - 160, oTBar:currentSize()[ 2 ] + 3 }, ;\n { 160, oCrt:currentSize()[ 2 ] - ;\n oTBar:currentSize()[ 2 ] - oSBar:currentSize()[ 2 ] - 4 }, , .T. )\n oTree:hasLines := .T.\n oTree:hasButtons := .T.\n oTree:alwaysShowSelection := .T.\n oTree:create()\n oTree:setColorBG( RGB( 120, 15, 240 ) )\n oTree:setColorFG( RGB( 15, 240, 120 ) )\n oTree:itemSelected := {| oItem | iif( oItem != NIL, wvg_MessageBox( , oItem:caption ), NIL ) }\n\n oItem1 := oTree:rootItem:addItem( \"First level A\" )\n\n oTree:rootItem:addItem( \"First level B\" )\n\n oItem2 := oItem1:addItem( \"Second level A\" )\n oItem1:addItem( \"Second level B\" )\n\n oItem2:addItem( \"Third level A\" )\n oItem2:addItem( \"Third level B\" )\n oItem2:addItem( \"Third level C\" )\n\n\n oTree:setData( oItem2 )\n\n \n hb_gtInfo( HB_GTI_WINTITLE, \"http:\n oCom:create()\n oCom:Navigate( \"http:\n\n oAddr := WvgSLE():new()\n oAddr:bufferLength := 500\n oAddr:border := .T.\n cNavigate := \"http:\n oAddr:dataLink := {| x | iif( x == NIL, cNavigate, cNavigate := x ) }\n oAddr:setColorFG( RGB( 0, 0, 255 ) )\n oAddr:setColorBG( RGB( 0, 255, 255 ) )\n oAddr:create( oDA, , { 120, oTBar:currentSize()[ 2 ] }, { 500, 20 }, , .T. )\n oAddr:setData()\n oAddr:killInputFocus := {| m1, m2, oS | m1 := m1, m2 := m2, oS:getData(), oCom:navigate( cNavigate ) }\n\n \n oStatic2 := WvgStatic():New( oDA, , { 150, 150 }, { 500, 310 }, , .F. )\n \n oStatic2:exStyle += WS_EX_WINDOWEDGE\n \n oStatic2:create()\n oStatic2:setColorBG( RGB( 175, 175, 175 ) )\n\n oXbp := WvgPushButton():new( oStatic2 )\n oXbp:caption := \"Hide\"\n oXbp:caption := \"Hide\"\n oXbp:create( , , { 430, 275 }, { 60, 25 } )\n oXbp:activate := {|| oStatic2:hide(), oCrt:sendMessage( WM_SIZE, 0, 0 ) }\n\n oRadio := WvgRadioButton():new( oStatic2, , { 10, 10 }, { 100, 15 } )\n oRadio:caption := \"Com 1\"\n oRadio:selection := .T.\n oRadio:selected := {| m1, m2, obj | m1 := m1, m2 := m2, wvg_MessageBox( , obj:caption + iif( obj:selection, \"< S >\", \"< N >\" ) ) }\n oRadio:create()\n\n oRadio := WvgRadioButton():new( oStatic2, , { 10, 35 }, { 100, 15 } )\n oRadio:caption := \"Com 2\"\n oRadio:create()\n\n oCheck := WvgCheckBox():New( oStatic2, , { 10, 70 }, { 100, 15 }, , .T. )\n oCheck:caption := \"Checkbox A\"\n oCheck:create()\n oCheck:selected := {| m1, m2, o | m1 := m1, m2 := m2, wvg_MessageBox( , iif( o:getData(), \"I am selected\", \"I am not selected\" ) ) }\n\n \n oXbp := Wvg3State():new()\n oXbp:caption := \"3 State A\"\n oXbp:create( oStatic2, , { 10, 100 }, { 100, 15 } )\n \n oXbp:selected := {| m1, m2, oBtn | m2 := m2, oBtn := oBtn, oPanel1:caption := \"3State A [\" + aState[ m1 + 1 ] + \"]\" }\n\n \n oXbp := Wvg3State():new( oStatic2, , { 10, 125 }, { 100, 15 } )\n oXbp:caption := \"3 State B\"\n oXbp:create( oStatic2 )\n \n oXbp:selected := {| m1, m2, oBtn | m1 := m1, m2 := m2, wvg_MessageBox( , \"3State B\", aState[ oBtn:getData() + 1 ] ) }\n\n \n oXbp := WvgSLE():new()\n oXbp:autoTab := .T.\n oXbp:bufferLength := 20\n \n oXbp:dataLink := {| x | iif( x == NIL, cVarA, cVarA := x ) }\n oXbp:create( oStatic2, , { 10, 170 }, { 150, 20 } )\n oXbp:setData()\n \n oXbp:killInputFocus := {| x, y, oSLE | x := x, y := y, oSLE:getData(), oPanel:caption := \"cVarA =\" + cVarA }\n\n \n oXbp := WvgSLE():new( , , { 10, 200 }, { 150, 20 } )\n oXbp:tabStop := .T.\n oXbp:bufferLength := 15\n oXbp:dataLink := {| x | iif( x == NIL, cVarB, cVarB := x ) }\n oXbp:create( oStatic2 )\n oXbp:setData()\n oXbp:killInputFocus := {| x, y, oSLE | x := x, y := y, oSLE:getData(), oPanel:caption := \"cVarB =\" + cVarB }\n\n \n cText := MemoRead( \"gtwvg.hbc\" )\n \n \n oMLE := WvgMLE():new()\n oMLE:wordWrap := .F.\n oMLE:border := .T.\n oMLE:dataLink := {| x | iif( x == NIL, cText, cText := x ) }\n oMLE:create( oStatic2, , { 180, 10 }, { 310, 250 } )\n \n oMLE:setData()\n\n \n oTBar:buttonClick := {| oBtn | iif( oBtn:caption == \"Hide\" , oStatic:hide(), NIL ), ;\n iif( oBtn:caption == \"Show\" , oStatic:show(), NIL ), ;\n iif( oBtn:caption == \"Tools\" , oStatic2:show():toFront(), NIL ), ;\n iif( oBtn:caption == \"FontDlg\", ExeFontDialog( oCrt ), NIL ), ;\n iif( oBtn:caption $ \"Hide,Show\", oCrt:sendMessage( WM_SIZE, 0, 0 ), NIL ), ;\n oPanel2:caption := \"Button [ \" + oBtn:caption + \" ] clicked!\" }\n\n oCrt:resize := {|| ResizeDialogXbp( oCrt, oTBar, oSBar, oStatic, oCom, oTree, oAddr ) }\n\n oCrt:sendMessage( WM_SIZE, 0, 0 )\n oCrt:show()\n\n DO WHILE .T.\n IF Inkey() == K_ESC\n EXIT\n ENDIF\n ENDDO\n\n oCrt:Destroy()\n\n RETURN\n\nSTATIC FUNCTION ResizeDialogXbp( oCrt, oTBar, oSBar, oStatic, oCom, oTree, oAddr )\n\n LOCAL aCrt, aTBar, aSBar\n LOCAL nH, nT\n\n aCrt := oCrt:currentSize()\n aTBar := oTBar:currentSize()\n aSBar := oSBar:currentSize()\n\n nT := aTBar[ 2 ]\n nH := aCrt[ 2 ] - aTBar[ 2 ] - aSBar[ 2 ]\n\n IF oStatic:isVisible"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour utility program: utils/hbtest/rt_hvm.prg. Contains procedures: Main_HVM. This file is part of the test framework"}, {"role": "assistant", "content": "#include \"rt_main.ch\"\n\n\n#include \"rt_vars.ch\"\n\nPROCEDURE Main_HVM()\n\n \n HBTEST ValType( scString ) IS \"C\"\n HBTEST ValType( scStringE ) IS \"C\"\n HBTEST ValType( scStringZ ) IS \"C\"\n HBTEST ValType( snIntZ ) IS \"N\"\n HBTEST ValType( snDoubleZ ) IS \"N\"\n HBTEST ValType( snIntP ) IS \"N\"\n HBTEST ValType( snLongP ) IS \"N\"\n HBTEST ValType( snDoubleP ) IS \"N\"\n HBTEST ValType( snIntN ) IS \"N\"\n HBTEST ValType( snLongN ) IS \"N\"\n HBTEST ValType( snDoubleN ) IS \"N\"\n HBTEST ValType( snDoubleI ) IS \"N\"\n HBTEST ValType( sdDateE ) IS \"D\"\n HBTEST ValType( slFalse ) IS \"L\"\n HBTEST ValType( slTrue ) IS \"L\"\n HBTEST ValType( soObject ) IS \"O\"\n HBTEST ValType( suNIL ) IS \"U\"\n HBTEST ValType( sbBlock ) IS \"B\"\n HBTEST ValType( saArray ) IS \"A\"\n HBTEST ValType( { 1, 2, 3 } ) IS \"A\"\n IF TEST_DBFAvail()\n HBTEST ValType( w_TEST->TYPE_C ) IS \"C\"\n HBTEST ValType( w_TEST->TYPE_D ) IS \"D\"\n HBTEST ValType( w_TEST->TYPE_M ) IS \"M\"\n HBTEST ValType( w_TEST->TYPE_N_I ) IS \"N\"\n HBTEST ValType( w_TEST->TYPE_N_D ) IS \"N\"\n HBTEST ValType( w_TEST->TYPE_L ) IS \"L\"\n ENDIF\n#ifdef __HARBOUR__\n HBTEST ValType( @scString ) IS \"C\" \n HBTEST ValType( @scStringE ) IS \"C\" \n HBTEST ValType( @scStringZ ) IS \"C\" \n HBTEST ValType( @snIntZ ) IS \"N\" \n HBTEST ValType( @snDoubleZ ) IS \"N\" \n HBTEST ValType( @snIntP ) IS \"N\" \n HBTEST ValType( @snLongP ) IS \"N\" \n HBTEST ValType( @snDoubleP ) IS \"N\" \n HBTEST ValType( @snIntN ) IS \"N\" \n HBTEST ValType( @snLongN ) IS \"N\" \n HBTEST ValType( @snDoubleN ) IS \"N\" \n HBTEST ValType( @snDoubleI ) IS \"N\" \n HBTEST ValType( @sdDateE ) IS \"D\" \n HBTEST ValType( @slFalse ) IS \"L\" \n HBTEST ValType( @slTrue ) IS \"L\" \n HBTEST ValType( @soObject ) IS \"O\" \n HBTEST ValType( @suNIL ) IS \"U\" \n HBTEST ValType( @sbBlock ) IS \"B\" \n HBTEST ValType( @saArray ) IS \"A\" \n#endif\n HBTEST ValType( mcString ) IS \"C\"\n HBTEST ValType( mcStringE ) IS \"C\"\n HBTEST ValType( mcStringZ ) IS \"C\"\n HBTEST ValType( mnIntZ ) IS \"N\"\n HBTEST ValType( mnDoubleZ ) IS \"N\"\n HBTEST ValType( mnIntP ) IS \"N\"\n HBTEST ValType( mnLongP ) IS \"N\"\n HBTEST ValType( mnDoubleP ) IS \"N\"\n HBTEST ValType( mnIntN ) IS \"N\"\n HBTEST ValType( mnLongN ) IS \"N\"\n HBTEST ValType( mnDoubleN ) IS \"N\"\n HBTEST ValType( mnDoubleI ) IS \"N\"\n HBTEST ValType( mdDateE ) IS \"D\"\n HBTEST ValType( mlFalse ) IS \"L\"\n HBTEST ValType( mlTrue ) IS \"L\"\n HBTEST ValType( moObject ) IS \"O\"\n HBTEST ValType( muNIL ) IS \"U\"\n HBTEST ValType( mbBlock ) IS \"B\"\n HBTEST ValType( maArray ) IS \"A\"\n#ifdef __HARBOUR__\n HBTEST ValType( @mcString ) IS \"C\" \n HBTEST ValType( @mcStringE ) IS \"C\" \n HBTEST ValType( @mcStringZ ) IS \"C\" \n HBTEST ValType( @mnIntZ ) IS \"N\" \n HBTEST ValType( @mnDoubleZ ) IS \"N\" \n HBTEST ValType( @mnIntP ) IS \"N\" \n HBTEST ValType( @mnLongP ) IS \"N\" \n HBTEST ValType( @mnDoubleP ) IS \"N\" \n HBTEST ValType( @mnIntN ) IS \"N\" \n HBTEST ValType( @mnLongN ) IS \"N\" \n HBTEST ValType( @mnDoubleN ) IS \"N\" \n HBTEST ValType( @mnDoubleI ) IS \"N\" \n HBTEST ValType( @mdDateE ) IS \"D\" \n HBTEST ValType( @mlFalse ) IS \"L\" \n HBTEST ValType( @mlTrue ) IS \"L\" \n HBTEST ValType( @moObject ) IS \"O\" \n HBTEST ValType( @muNIL ) IS \"U\" \n HBTEST ValType( @mbBlock ) IS \"B\" \n HBTEST ValType( @maArray ) IS \"A\" \n#endif\n\n \n#ifndef __XPP__\n HBTEST Type( NIL ) IS \"E 1 BASE 1121 Argument error (TYPE) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST Type( 100 ) IS \"E 1 BASE 1121 Argument error (TYPE) OS:0 #:0 A:1:N:100 F:S\"\n HBTEST Type( {} ) IS \"E 1 BASE 1121 Argument error (TYPE) OS:0 #:0 A:1:A:{.[0].} F:S\"\n#endif\n IF TEST_DBFAvail()\n HBTEST Type( \"w_TEST->TYPE_C\" ) IS \"C\"\n HBTEST Type( \"w_TEST->TYPE_D\" ) IS \"D\"\n HBTEST Type( \"w_TEST->TYPE_M\" ) IS \"M\"\n HBTEST Type( \"w_TEST->TYPE_N_I\" ) IS \"N\"\n HBTEST Type( \"w_TEST->TYPE_N_D\" ) IS \"N\"\n HBTEST Type( \"w_TEST->TYPE_L\" ) IS \"L\"\n ENDIF\n HBTEST Type( \"mxNotHere\" ) IS \"U\"\n HBTEST Type( \"mcString\" ) IS \"C\"\n HBTEST Type( \"mcStringE\" ) IS \"C\"\n HBTEST Type( \"mcStringZ\" ) IS \"C\"\n HBTEST Type( \"mnIntZ\" ) IS \"N\"\n HBTEST Type( \"mnDoubleZ\" ) IS \"N\"\n HBTEST Type( \"mnIntP\" ) IS \"N\"\n HBTEST Type( \"mnLongP\" ) IS \"N\"\n HBTEST Type( \"mnDoubleP\" ) IS \"N\"\n HBTEST Type( \"mnIntN\" ) IS \"N\"\n HBTEST Type( \"mnLongN\" ) IS \"N\"\n HBTEST Type( \"mnDoubleN\" ) IS \"N\"\n HBTEST Type( \"mnDoubleI\" ) IS \"N\"\n HBTEST Type( \"mdDateE\" ) IS \"D\"\n HBTEST Type( \"mlFalse\" ) IS \"L\"\n HBTEST Type( \"mlTrue\" ) IS \"L\"\n HBTEST Type( \"moObject\" ) IS \"O\"\n HBTEST Type( \"muNIL\" ) IS \"U\"\n HBTEST Type( \"mbBlock\" ) IS \"B\"\n HBTEST Type( \"maArray\" ) IS \"A\"\n\n \n#ifndef __HARBOUR__\n#ifndef __XPP__\n HBTEST NIL:className() IS \"NIL\"\n#endif\n#endif\n#ifndef __XPP__\n HBTEST \"\":className() IS \"CHARACTER\"\n HBTEST 0:className() IS \"NUMERIC\"\n HBTEST hb_SToD( \"\" ):className() IS \"DATE\"\n HBTEST .F.:className() IS \"LOGICAL\"\n HBTEST {|| NIL }:className() IS \"BLOCK\"\n HBTEST {}:className() IS \"ARRAY\"\n#endif\n HBTEST ErrorNew():className() IS \"ERROR\"\n HBTEST ErrorNew():className IS \"ERROR\"\n\n#ifndef __HARBOUR__\n#ifndef __XPP__\n HBTEST NIL:classH() IS 0\n#endif\n#endif\n#ifndef __XPP__\n HBTEST \"\":classH() IS 0\n HBTEST 0:classH() IS 0\n HBTEST hb_SToD( \"\" ):classH() IS 0\n HBTEST .F.:classH() IS 0\n HBTEST {|| NIL }:classH() IS 0\n HBTEST {}:classH() IS 0\n#endif\n HBTEST ErrorNew():classH() > 0 IS .T.\n HBTEST ErrorNew():classH > 0 IS .T.\n\n\n#ifndef __HARBOUR__\n#ifndef __XPP__\n HBTEST suNIL:className() IS \"NIL\"\n#endif\n#endif\n#ifndef __XPP__\n HBTEST scString:className() IS \"CHARACTER\"\n HBTEST snIntP:className() IS \"NUMERIC\"\n HBTEST sdDateE:className() IS \"DATE\"\n HBTEST slFalse:className() IS \"LOGICAL\"\n HBTEST sbBlock:className() IS \"BLOCK\"\n HBTEST saArray:className() IS \"ARRAY\"\n#endif\n HBTEST soObject:className() IS \"ERROR\"\n HBTEST soObject:className IS \"ERROR\"\n\n#ifndef __HARBOUR__\n#ifndef __XPP__\n HBTEST suNIL:classH() IS 0\n#endif\n#endif\n#ifndef __XPP__\n HBTEST scString:classH() IS 0\n HBTEST snIntP:classH() IS 0\n HBTEST sdDateE:classH() IS 0\n HBTEST slFalse:classH() IS 0\n HBTEST sbBlock:classH() IS 0\n HBTEST saArray:classH() IS 0\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour contribution module 'hbpgsql' (PostgreSQL database client library): contrib/hbpgsql/tests/cache.prg. Provides 9 functions including: SQLApplyUpdates, SQLFetch, SQLOpen, SQLConnect, SQLCurrentServer. Contains 6 procedures. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbpgsql\"\n\n#define DB_ALIAS 1 \n#define DB_QUERY 2 \n#define DB_ROW 3 \n#define DB_FETCH 4 \n\nTHREAD STATIC t_oServer\nTHREAD STATIC t_aTableTemp := {}\n\nPROCEDURE Main( cHost, cDatabase, cUser, cPass )\n\n LOCAL i\n\n IF SQLConnect( cHost, hb_defaultValue( cDatabase, \"postgres\" ), cUser, cPass )\n\n QuickQuery( \"DROP TABLE test\" )\n\n SQLQuery( \"CREATE TABLE test (\" + ;\n \" codigo integer primary key,\" + ;\n \" descri char(50),\" + ;\n \" email varchar(50) )\" )\n\n SQLOpen( \"nomes\", \"SELECT * FROM test\" )\n\n FOR i := 1 TO 50\n dbAppend()\n nomes->codigo := i\n nomes->descri := \"test \" + hb_ntos( i )\n NEXT\n\n SQLApplyUpdates()\n\n SQLOpen( \"nomes\", SQLPrepare( \"SELECT * FROM test WHERE codigo >= :1 ORDER BY codigo\", 1 ) )\n\n DO WHILE ! Eof()\n ? RecNo(), nomes->Codigo, nomes->descri, nomes->email\n\n IF RecNo() == 10\n dbDelete()\n ENDIF\n\n IF RecNo() == 20\n nomes->email := \"teste\"\n ENDIF\n\n SQLFetch()\n ENDDO\n\n SQLApplyUpdates()\n ENDIF\n\n SQLGarbageCollector()\n\n RETURN\n\n\nFUNCTION SQLApplyUpdates()\n\n LOCAL cAlias := Upper( Alias() )\n LOCAL i, x\n LOCAL oQuery\n LOCAL oRow\n LOCAL lUpdate\n LOCAL lError := .F.\n LOCAL cError\n\n IF ( i := AScan( t_aTableTemp, {| aVal | aVal[ DB_ALIAS ] == cAlias } ) ) > 0\n\n oQuery := t_aTableTemp[ i ][ DB_QUERY ]\n\n FOR i := 1 TO LastRec()\n\n dbGoto( i )\n\n IF i > oQuery:LastRec()\n\n \n IF ! Deleted()\n\n oRow := oQuery:GetBlankRow()\n\n FOR x := 1 TO FCount()\n IF oRow:FieldPos( FieldName( x ) ) != 0\n oRow:FieldPut( FieldName( x ), FieldGet( x ) )\n ENDIF\n NEXT\n\n oQuery:Append( oRow )\n cError := oQuery:ErrorMsg()\n lError := oQuery:NetErr()\n ENDIF\n ELSE\n oRow := oQuery:GetRow( i )\n\n IF Deleted()\n oQuery:Delete( oRow )\n cError := oQuery:ErrorMsg()\n lError := oQuery:NetErr()\n ELSE\n \n\n lUpdate := .F.\n FOR x := 1 TO FCount()\n IF oRow:FieldPos( FieldName( x ) ) != 0 .AND. ;\n ! FieldGet( x ) == oRow:FieldGet( FieldName( x ) )\n oRow:FieldPut( FieldName( x ), FieldGet( x ) )\n lUpdate := .T.\n ENDIF\n NEXT\n\n IF lUpdate\n oQuery:Update( oRow )\n cError := oQuery:ErrorMsg()\n lError := oQuery:NetErr()\n ENDIF\n ENDIF\n ENDIF\n\n IF lError\n EXIT\n ENDIF\n NEXT\n ENDIF\n\n IF lError\n ? cError\n ENDIF\n\n RETURN ! lError\n\nPROCEDURE SQLCloseTemp( cAlias )\n\n LOCAL x\n\n IF Select( cAlias ) != 0\n ( cAlias )->( dbCloseArea() )\n ENDIF\n\n IF ( x := AScan( t_aTableTemp, {| aVal | aVal[ DB_ALIAS ] == cAlias } ) ) > 0\n hb_ADel( t_aTableTemp, x, .F. )\n ENDIF\n\n RETURN\n\nPROCEDURE SQLGarbageCollector()\n\n LOCAL item\n LOCAL oQuery\n\n dbCloseAll()\n\n FOR EACH item IN t_aTableTemp\n IF ( oQuery := item[ DB_QUERY ] ) != NIL\n oQuery:Destroy()\n ENDIF\n NEXT\n\n ASize( t_aTableTemp, 0 )\n\n RETURN\n\nFUNCTION SQLFetch( lFetchAll )\n\n LOCAL oQuery\n LOCAL oRow\n LOCAL cAlias := Upper( Alias() )\n LOCAL i, x, y\n LOCAL nPos\n LOCAL lEof := .F.\n\n hb_default( @lFetchAll, .F. )\n\n \n IF ( i := AScan( t_aTableTemp, {| aVal | aVal[ DB_ALIAS ] == cAlias } ) ) > 0\n\n \n oQuery := t_aTableTemp[ i ][ DB_QUERY ]\n nPos := t_aTableTemp[ i ][ DB_ROW ] + 1\n\n IF lFetchAll\n t_aTableTemp[ i ][ DB_FETCH ] := .T.\n ENDIF\n\n IF oQuery:LastRec() >= nPos\n\n y := nPos\n\n DO WHILE nPos <= iif( lFetchAll, oQuery:LastRec(), y )\n oRow := oQuery:GetRow( nPos )\n dbAppend()\n\n FOR x := 1 TO oRow:FCount()\n FieldPut( FieldPos( oRow:FieldName( x ) ), oRow:FieldGet( x ) )\n NEXT\n\n t_aTableTemp[ i ][ DB_ROW ] := nPos\n nPos++\n ENDDO\n\n ELSE\n \n dbSkip()\n ENDIF\n\n lEof := nPos > oQuery:LastRec()\n ENDIF\n\n RETURN lEof\n\nPROCEDURE SQLFetchAll()\n\n SQLFetch( .T. )\n dbGoTop()\n\n RETURN\n\nFUNCTION SQLOpen( cAlias, cQuery, xFetch, cOrder )\n\n LOCAL x\n LOCAL oServer\n LOCAL oQuery\n LOCAL lFetch\n\n oServer := SQLCurrentServer()\n cAlias := Upper( cAlias )\n\n \n IF ( x := AScan( t_aTableTemp, {| aVal | aVal[ DB_ALIAS ] == cAlias } ) ) > 0\n oQuery := t_aTableTemp[ x ][ DB_QUERY ]\n oQuery:Destroy()\n ENDIF\n\n IF cQuery == NIL\n cQuery := \"SELECT * FROM \" + cAlias\n IF ! Empty( cOrder )\n cQuery += \" ORDER BY \" + cOrder\n ENDIF\n ENDIF\n\n oQuery := oServer:Query( cQuery )\n\n IF oQuery:NetErr()\n ? oQuery:ErrorMsg()\n RETURN .F.\n ENDIF\n\n IF Select( cAlias ) == 0\n hb_dbCreateTemp( cAlias, oQuery:Struct() )\n ELSE\n dbSelectArea( cAlias )\n hb_dbZap()\n ENDIF\n\n IF xFetch != NIL\n lFetch := xFetch\n ELSE\n lFetch := .F.\n ENDIF\n\n \n IF x == 0\n AAdd( t_aTableTemp, { ;\n cAlias, ; \n oQuery, ; \n 0, ; \n lFetch } ) \n ELSE\n\n t_aTableTemp[ x ][ DB_QUERY ] := oQuery\n t_aTableTemp[ x ][ DB_ROW ] := 0\n t_aTableTemp[ x ][ DB_FETCH ] := lFetch\n\n ENDIF\n\n \n SQLFetch( lFetch )\n\n IF lFetch\n dbGoTop()\n ENDIF\n\n RETURN .T.\n\nFUNCTION SQLConnect( cHost, cDatabase, cUser, cPassword, cSchema )\n\n LOCAL lRetval := .T.\n\n t_oServer := TPQServer():New( cHost, cDatabase, cUser, cPassword, 5432, cSchema )\n IF t_oServer:NetErr()\n ? t_oServer:ErrorMsg()\n lRetval := .F.\n ENDIF\n t_oServer:lAllCols := .F.\n\n RETURN lRetval\n\nPROCEDURE SQLDestroy()\n\n IF t_oServer != NIL\n t_oServer:Destroy()\n ENDIF\n\n RETURN\n\nFUNCTION SQLCurrentServer\n RETURN t_oServer\n\nFUNCTION SQLQuery( cQuery )\n\n LOCAL oQuery := t_oServer:Query( cQuery )\n\n IF oQuery:NetErr()\n ? cQuery + \":\" + oQuery:ErrorMsg()\n ENDIF\n\n RETURN oQuery\n\nFUNCTION SQLExecQuery( cQuery )\n\n LOCAL oQuery := t_oServer:Query( cQuery )\n\n IF oQuery:NetErr()\n ? \"Cannot execute\", cQuery + \":\" + oQuery:ErrorMsg()\n RETURN .F.\n ENDIF\n\n oQuery:Destroy()\n\n RETURN .T.\n\nFUNCTION SQLPrepare( cQuery, ... )\n\n LOCAL i, x\n\n IF PCount() >= 2\n \n DO WHILE Space( 2 ) $ cQuery\n cQuery := StrTran( cQuery, Space( 2 ), Space( 1 ) )\n ENDDO\n\n \n FOR i := 1 TO PCount() - 1\n IF ( x := At( \":\" + hb_ntos( i ), cQuery ) ) > 0\n cQuery := Stuff( cQuery, x, 0, \"{\" )\n cQuery := Stuff( cQuery, x + Len( hb_ntos( i ) ) + 2, 0, \"}\" )\n ENDIF\n NEXT\n\n \n FOR i := 2 TO PCount()\n x := hb_PValue( i )\n\n DO CASE\n CASE x != NIL .AND. Empty( x )\n x := \"null\"\n\n CASE HB_ISNUMERIC( x )\n x := hb_ntos( x )\n\n CASE HB_ISDATE( x )\n x := \"'\" + hb_DToC( x, \"yyyy-mm-dd\" ) + \"'\"\n\n CASE HB_ISLOGICAL( x )\n x := iif( x, \"'t'\", \"'f'\" )\n\n CASE HB_ISSTRING( x )\n x := SToQ( RTrim( x ) )\n\n OTHERWISE\n x := \"null\"\n ENDCASE\n\n cQuery := StrTran( cQuery, \"{:\" + hb_ntos( i - 1 ) + \"}\", x )\n NEXT\n ENDIF\n\n RETURN hb_StrReplace( cQuery, { ;\n \"==\" => \"=\" , ;\n \"!=\" => \"<>\" , ;\n \".and.\" => \"and\" , ;\n \".or.\" => \"or\" , ;\n \".not.\" => \"not\" } )\n\n\nFUNCTION SQLSequence( Sequence_name )\n RETURN Val( QuickQuery( \"SELECT nextval(\" + SToQ( sequence_name ) + \")\" ) )\n\nPROCEDURE SQLStartTrans()\n\n IF PQtransactionStatus( t_oServer:pDB ) != PQTRANS_INTRANS\n t_oServer:StartTransaction()\n ENDIF\n\n RETURN\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHeader file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hbcomprs.ch. Defines 10 constants including: HB_COMPRESS_CH, HB_Z_OK, HB_Z_STREAM_END, HB_Z_NEED_DICT, HB_Z_ERRNO. Defines error handling constants and codes"}, {"role": "assistant", "content": "#ifndef HB_COMPRESS_CH\n#define HB_COMPRESS_CH\n\n#include \"hbzlib.ch\"\n\n#define HB_Z_OK HB_ZLIB_RES_OK\n#define HB_Z_STREAM_END HB_ZLIB_RES_STREAM_END\n#define HB_Z_NEED_DICT HB_ZLIB_RES_NEED_DICT\n#define HB_Z_ERRNO HB_ZLIB_RES_ERRNO\n#define HB_Z_STREAM_ERROR HB_ZLIB_RES_STREAM_ERROR\n#define HB_Z_DATA_ERROR HB_ZLIB_RES_DATA_ERROR\n#define HB_Z_MEM_ERROR HB_ZLIB_RES_MEM_ERROR\n#define HB_Z_BUF_ERROR HB_ZLIB_RES_BUF_ERROR\n#define HB_Z_VERSION_ERROR HB_ZLIB_RES_VERSION_ERROR\n\n#define HB_Z_NO_COMPRESSION HB_ZLIB_COMPRESSION_NONE\n#define HB_Z_BEST_SPEED HB_ZLIB_COMPRESSION_SPEED\n#define HB_Z_BEST_COMPRESSION HB_ZLIB_COMPRESSION_SIZE\n#define HB_Z_DEFAULT_COMPRESSION HB_ZLIB_COMPRESSION_DEFAULT\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour contribution module 'hbxdiff' (File difference/patching): contrib/hbxdiff/tests/test.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbxdiff\"\n\n#define _SIZE 62\n\nPROCEDURE Main()\n\n LOCAL pMMF\n LOCAL cFileCtx\n LOCAL nSize\n\n pMMF := xdl_init_mmfile( XDLT_STD_BLKSIZE, XDL_MMF_ATOMIC )\n ? xdl_mmfile_size( pMMF )\n ? xdl_mmfile_iscompact( pMMF )\n\n cFileCtx := hb_MemoRead( __FILE__ )\n\n ? xdl_write_mmfile( pMMF, cFileCtx ), Len( cFileCtx )\n ? xdl_mmfile_size( pMMF )\n\n ? xdl_read_mmfile( pMMF, NIL, _SIZE, @nSize )\n ? nSize\n\n xdl_seek_mmfile( pMMF, 0 )\n\n ? xdl_read_mmfile( pMMF, NIL, _SIZE, @nSize )\n ? nSize\n\n ? xdl_read_mmfile( pMMF, NIL, _SIZE, @nSize )\n ? nSize\n\n xdl_seek_mmfile( pMMF, _SIZE )\n\n ? xdl_read_mmfile( pMMF, NIL, _SIZE, @nSize )\n ? nSize\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour header file: include/hbdebug.ch. Defines 10 constants including: HB_DEBUGGER_CH_, HB_DBG_MODULENAME, HB_DBG_LOCALNAME, HB_DBG_STATICNAME, HB_DBG_ENDPROC. Defines color and display constants"}, {"role": "assistant", "content": "#ifndef HB_DEBUGGER_CH_\n#define HB_DEBUGGER_CH_\n\n\n#define HB_DBG_MODULENAME 1 \n#define HB_DBG_LOCALNAME 2 \n#define HB_DBG_STATICNAME 3 \n#define HB_DBG_ENDPROC 4 \n#define HB_DBG_SHOWLINE 5 \n#define HB_DBG_GETENTRY 6 \n#define HB_DBG_ACTIVATE 7 \n#define HB_DBG_VMQUIT 8 \n\n\n#define HB_DBG_CS_MODULE 1 \n#define HB_DBG_CS_FUNCTION 2 \n#define HB_DBG_CS_LINE 3 \n#define HB_DBG_CS_LEVEL 4 \n#define HB_DBG_CS_LOCALS 5 \n#define HB_DBG_CS_STATICS 6 \n#define HB_DBG_CS_LEN 6\n\n\n#define HB_DBG_MOD_NAME 1 \n#define HB_DBG_MOD_STATICS 2 \n#define HB_DBG_MOD_GLOBALS 3 \n#define HB_DBG_MOD_EXTGLOBALS 4 \n#define HB_DBG_MOD_LEN 4\n\n\n#define HB_DBG_VAR_NAME 1 \n#define HB_DBG_VAR_INDEX 2 \n#define HB_DBG_VAR_TYPE 3 \n#define HB_DBG_VAR_FRAME 4 \n#define HB_DBG_VAR_LEN 4\n\n\n#define HB_DBG_WP_EXPR 1 \n#define HB_DBG_WP_ISTRACE 2 \n#define HB_DBG_WP_VALID 3 \n#define HB_DBG_WP_RESULT 4 \n#define HB_DBG_WP_LEN 4\n\n\n#define HB_DBG_BP_LINE 1 \n#define HB_DBG_BP_MODULE 2 \n#define HB_DBG_BP_FUNC 3 \n#define HB_DBG_BP_LEN 3\n\n\n#define HB_DBG_SET_POS 1 \n#define HB_DBG_SET_NAME 2 \n#define HB_DBG_SET_VALUE 3 \n#define HB_DBG_SET_LEN 3\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'gtwvg' (): contrib/gtwvg/htmlview.prg. Defines classes: WvgHTMLViewer. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#include \"hbgtwvg.ch\"\n#include \"wvtwin.ch\"\n#include \"wvgparts.ch\"\n\n#define evBeforeNavigate 100\n#define evNavigateComplete 101\n#define evStatusTextChange 102\n#define evDownloadComplete 104\n#define evCommandStateChange 105\n#define evDownloadBegin 106\n#define evProgressChange 108\n#define evTitleChange 113\n\n#define evPropertyChange 112\n#define evBeforeNavigate2 250\n#define evNavigateComplete2 252\n#define evDocumentComplete 259\n#define evNavigateError 271\n\nCREATE CLASS WvgHTMLViewer INHERIT WvgActiveXControl\n\n METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n METHOD xBeforeNavigate( cURL, Flags, TFName, PData, Headers )\n METHOD xStatusTextChange( cText )\n METHOD xNavigateComplete( cURL )\n METHOD xProgressChange( nProgress, nProgMax )\n METHOD xTitleChange( cTitle )\n METHOD xDocumentComplete( cURI )\n METHOD setHTML( cHTML )\n\n METHOD back() INLINE ::goBack()\n METHOD forward() INLINE ::goForward()\n METHOD home() INLINE ::goHome()\n METHOD search() INLINE ::goSearch()\n METHOD isBusy() INLINE ::busy()\n\n VAR sl_beforeNavigate PROTECTED\n ACCESS beforeNavigate INLINE ::sl_beforeNavigate\n ASSIGN beforeNavigate( bBlock ) INLINE ::sl_beforeNavigate := bBlock\n\n VAR sl_navigateComplete PROTECTED\n ACCESS navigateComplete INLINE ::sl_navigateComplete\n ASSIGN navigateComplete( bBlock ) INLINE ::sl_navigateComplete := bBlock\n\n VAR sl_statusTextChange PROTECTED\n ACCESS statusTextChange INLINE ::sl_statusTextChange\n ASSIGN statusTextChange( bBlock ) INLINE ::sl_statusTextChange := bBlock\n\n VAR sl_progressChange PROTECTED\n ACCESS progressChange INLINE ::sl_progressChange\n ASSIGN progressChange( bBlock ) INLINE ::sl_progressChange := bBlock\n\n VAR sl_titleChange PROTECTED\n ACCESS titleChange INLINE ::sl_titleChange\n ASSIGN titleChange( bBlock ) INLINE ::sl_titleChange := bBlock\n\n VAR sl_documentComplete PROTECTED\n ACCESS documentComplete INLINE ::sl_documentComplete\n ASSIGN documentComplete( bBlock ) INLINE ::sl_documentComplete := bBlock\n\n VAR CLSID PROTECTED INIT \"Shell.Explorer\"\n\nENDCLASS\n\nMETHOD WvgHTMLViewer:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::WvgActiveXControl:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n RETURN Self\n\nMETHOD WvgHTMLViewer:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::mapEvent( evBeforeNavigate, {| cURL, Flags, TFName, PData, Headers | ;\n ::xBeforeNavigate( cURL, Flags, TFName, PData, Headers ) } )\n\n ::mapEvent( evStatusTextChange, {| cText| ::xStatusTextChange( cText ) } )\n\n ::mapEvent( evNavigateComplete, {| cURL | ::xNavigateComplete( cURL ) } )\n\n ::mapEvent( evProgressChange, {| nProgress, nProgMax | ::xProgressChange( nProgress, nProgMax ) } )\n\n ::mapEvent( evTitleChange, {| cTitle | ::xTitleChange( cTitle ) } )\n\n ::mapEvent( evDocumentComplete, {| cURI | ::xDocumentComplete( cURI ) } )\n\n ::WvgActiveXControl:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n RETURN Self\n\nMETHOD WvgHTMLViewer:xBeforeNavigate( cURL, Flags, TFName, PData, Headers )\n\n HB_SYMBOL_UNUSED( Flags )\n HB_SYMBOL_UNUSED( TFName )\n HB_SYMBOL_UNUSED( PData )\n HB_SYMBOL_UNUSED( Headers )\n\n IF PCount() >= 1 .AND. HB_ISBLOCK( ::sl_beforeNavigate )\n Eval( ::sl_beforeNavigate, cURL, , Self )\n RETURN NIL\n ENDIF\n\n RETURN Self\n\nMETHOD WvgHTMLViewer:xStatusTextChange( cText )\n\n IF HB_ISBLOCK( ::sl_statusTextChange )\n Eval( ::sl_statusTextChange, cText, , Self )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgHTMLViewer:xNavigateComplete( cURL )\n\n IF HB_ISBLOCK( ::sl_navigateComplete )\n Eval( ::sl_navigateComplete, cURL, , Self )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgHTMLViewer:xProgressChange( nProgress, nProgMax )\n\n IF HB_ISBLOCK( ::sl_progressChange )\n Eval( ::sl_progressChange, nProgress, nProgMax, Self )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgHTMLViewer:xTitleChange( cTitle )\n\n IF HB_ISBLOCK( ::sl_titleChange )\n Eval( ::sl_titleChange, cTitle, , Self )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgHTMLViewer:xDocumentComplete( cURI )\n\n IF HB_ISBLOCK( ::sl_documentComplete )\n Eval( ::sl_documentComplete, cURI, , Self )\n ENDIF\n\n RETURN Self\n\nMETHOD WvgHTMLViewer:setHTML( cHTML )\n\n ::document:innerHTML := cHTML\n ::refresh()\n\n RETURN Self"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/tests/compress.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"xhb\"\n\n#include \"hbcomprs.ch\"\n\nPROCEDURE Main()\n\n LOCAL cText := \"A text to be compressed \"\n LOCAL cComp\n LOCAL cDecomp\n LOCAL nError, nBufLen\n\n CLS\n @ 1, 15 SAY \"X H A R B O U R - ZLIB based compression test\"\n\n @ 2, 5 SAY \"TEST 1: using on-the-fly Buffer creation\"\n\n nBufLen := hb_CompressBufLen( Len( cText ) )\n \n cComp := hb_Compress( cText )\n cDecomp := hb_Uncompress( nBuflen, cComp )\n\n @ 3, 7 SAY \"Uncompressed: (\" + hb_ntos( Len( cText ) ) + \")\" + cText + \"<<\"\n @ 4, 7 SAY \"Compressed (\" + hb_ntos( Len( cComp ) ) + \")\" + hb_StrToHex( cComp ) + \"<<\"\n @ 5, 7 SAY \"Decompressed: (\" + hb_ntos( Len( cDecomp ) ) + \")\" + cDecomp + \"<<\"\n\n @ 7, 5 SAY \"TEST 2: using preallocated buffers\"\n\n cComp := Space( nBufLen )\n \n \n cDecomp := Space( Int( nBufLen\n @ 8, 7 SAY \"Uncompressed: (\" + hb_ntos( Len( cText ) ) + \")\" + cText + \"<<\"\n @ 9, 7 SAY \"Compressed (\" + hb_ntos( nBuflen ) + \")\" + hb_StrToHex( cComp ) + \"<<\"\n \n \n @ 10, 7 SAY \"Decompressed: (\" + hb_ntos( Len( cDecomp ) ) + \")\" + cDecomp + \"<<\"\n\n @ 12, 5 SAY \"TEST 3: Generating an error\"\n\n nBufLen := hb_CompressBufLen( Len( cText ) )\n cComp := Space( nBufLen )\n cDecomp := Space( Len( cText ) )\n\n \n nBuflen := 3\n nError := hb_Compress( cText, Len( cText ), @cComp, @nBuflen )\n\n IF nError != HB_Z_OK\n @ 13, 7 SAY \"Error generated (\" + hb_ntos( Len( cComp ) ) + \")\" + ;\n hb_CompressErrorDesc( nError )\n ELSE\n @ 13, 7 SAY \"NO Error generated (\" + hb_ntos( Len( cComp ) ) + \")\" + ;\n hb_CompressErrorDesc( nError )\n ENDIF\n\n @ 22, 25 SAY \"Press a key to terminate\"\n\n Inkey( 0 )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/numtxthu.prg. Provides functions: NumToTxtHU, NumToTxtRaw. This file provides utility functions"}, {"role": "assistant", "content": "FUNCTION NumToTxtHU( nValue )\n\n LOCAL aTort := { \"tized\", \"század\", \"ezred\", \"tízezred\", \"százezred\", \"milliomod\", \"milliárdod\" }\n LOCAL cRetVal\n LOCAL tmp, tmp1, tmp2\n\n IF nValue < 0\n nValue := -nValue\n cRetVal := \"mínusz \"\n ELSE\n cRetVal := \"\"\n ENDIF\n\n IF Int( nValue ) == 0\n cRetVal += \"nulla\"\n ENDIF\n\n cRetVal += NumToTxtRaw( tmp := Int( nValue ) )\n\n IF ( tmp := ( nValue - tmp ) ) > 0 .AND. tmp < 1\n\n tmp1 := Len( tmp2 := SubStr( Str( tmp, 8, 6 ), 3 ) )\n\n DO WHILE SubStr( tmp2, tmp1, 1 ) == \"0\" .AND. tmp1 > 0\n tmp1--\n ENDDO\n\n cRetVal += \" egész \" + NumToTxtRaw( tmp * ( 10 ^ tmp1 ) ) + iif( tmp1 >= 1 .AND. tmp1 <= Len( aTort ), \" \" + aTort[ tmp1 ], \"\" )\n ENDIF\n\n RETURN hb_UTF8ToStr( cRetVal )\n\nSTATIC FUNCTION NumToTxtRaw( nValue )\n\n LOCAL aEgesz := { \"\", \"ezer\" , \"millió\", \"milliárd\", \"billió\" , \"trillió\", \"kvadrillió\", \"kvintillió\" } \n LOCAL aEgyes := { \"\", \"egy\" , \"kettő\" , \"három\" , \"négy\" , \"öt\" , \"hat\" , \"hét\" , \"nyolc\" , \"kilenc\" }\n LOCAL aTizes1 := { \"\", \"tíz\" , \"húsz\" , \"harminc\" , \"negyven\", \"ötven\" , \"hatvan\" , \"hetven\" , \"nyolcvan\" , \"kilencven\" }\n LOCAL aTizes2 := { \"\", \"tizen\", \"huszon\", \"harminc\" , \"negyven\", \"ötven\" , \"hatvan\" , \"hetven\" , \"nyolcvan\" , \"kilencven\" }\n\n LOCAL aDigit\n LOCAL nLen\n LOCAL cValue\n LOCAL tmp\n\n cValue := hb_ntos( nValue )\n cValue := PadL( cValue, ( Int( Max( Len( cValue ) - 1, 0 ) / 3 ) + 1 ) * 3, \"0\" )\n\n aDigit := Array( nLen := Len( cValue ) )\n FOR tmp := 1 TO nLen\n aDigit[ tmp ] := Val( SubStr( cValue, tmp, 1 ) )\n NEXT\n\n cValue := \"\"\n FOR tmp := 1 TO nLen - 2 STEP 3\n\n IF aDigit[ tmp ] != 0 .OR. ;\n aDigit[ tmp + 1 ] != 0 .OR. ;\n aDigit[ tmp + 2 ] != 0\n\n cValue += ;\n iif( Empty( cValue ), \"\", \"-\" ) + ;\n iif( aDigit[ tmp ] != 0, aEgyes[ aDigit[ tmp ] + 1 ] + \"száz\", \"\" ) + ;\n iif( aDigit[ tmp + 2 ] == 0, aTizes1[ aDigit[ tmp + 1 ] + 1 ], aTizes2[ aDigit[ tmp + 1 ] + 1 ] ) + ;\n aEgyes[ aDigit[ tmp + 2 ] + 1 ] + ;\n aEgesz[ ( Int( ( nLen - tmp ) / 3 ) ) + 1 ]\n ENDIF\n NEXT\n\n RETURN cValue"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbziparc' (ZIP archive handling): contrib/hbziparc/tests/zipa.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbziparc\"\n\nPROCEDURE Main( cZip, ... )\n\n LOCAL a, b, c\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n ? hb_ZipFile( cZip, hb_AParams() )\n\n a := hb_GetFilesInZip( cZip, .T. )\n\n FOR EACH b IN a\n ?\n FOR EACH c IN b\n ?? c, \"\"\n NEXT\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/ddate.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL dDate\n LOCAL A\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n dDate := 0d20051112\n ? \"Should be '2005-11-12' :\", dDate\n\n dDate := 0d18341112\n ? \"Should be '1834-11-12' :\", dDate\n\n dDate := 0d20040229 + 1\n ? \"Should be '2004-03-01' :\", dDate\n\n dDate := 0d20040229 - 1\n ? \"Should be '2004-02-28' :\", dDate\n\n ? \"Should be '4' :\", 0d20040229 - 0d20040225\n ? \"Should be '0' :\", 0d20040229 - 0d20040229\n\n dDate := 0d20000229\n ? \"Should be '2000-02-29' :\", dDate\n\n a := \"0d20040229+1\"\n ? \"Should be '2004-03-01' :\", &a\n\n a := \"Date() - 0d20051112\"\n ? \"Number of days from 2005-11-12:\", &a\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'rddmisc' (): contrib/rddmisc/dbtcdx.prg. Provides functions: DBTCDX_GETFUNCTABLE. Contains procedures: DBTCDX_INIT. This file handles database operations"}, {"role": "assistant", "content": "#include \"dbinfo.ch\"\n#include \"hbusrrdd.ch\"\n#include \"rddsys.ch\"\n\n\nREQUEST DBFCDX\nREQUEST DBFFPT\n\n\nANNOUNCE DBTCDX\n\nFUNCTION DBTCDX_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, pSuperRddID )\n RETURN USRRDD_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, ;\n \"DBFCDX\", {}, pSuperRddID ) \n\nINIT PROCEDURE DBTCDX_INIT()\n\n rddRegister( \"DBTCDX\", RDT_FULL )\n rddInfo( RDDI_MEMOTYPE, DB_MEMO_DBT, \"DBTCDX\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/prtesc.prg. Provides functions: ft_EscCode. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_EscCode( cInput )\n\n LOCAL cOutput := \"\"\n LOCAL cCurrent\n LOCAL nPointer := 1\n LOCAL nLen := Len( cInput )\n\n DO WHILE nPointer <= nLen\n\n cCurrent := SubStr( cInput, nPointer, 1 )\n\n DO CASE\n\n CASE cCurrent == \"\\\" .AND. ;\n IsDigit( SubStr( cInput, nPointer + 1, 1 ) ) .AND. ;\n IsDigit( SubStr( cInput, nPointer + 2, 1 ) ) .AND. ;\n IsDigit( SubStr( cInput, nPointer + 3, 1 ) )\n cOutput += Chr( Val( SubStr( cInput, nPointer + 1, 3 ) ) )\n nPointer += 4\n\n CASE cCurrent == \"\\\" .AND. ;\n SubStr( cInput, nPointer + 1, 1 ) == \"\\\"\n cOutput += \"\\\"\n nPointer += 2\n\n OTHERWISE\n cOutput += cCurrent\n nPointer++\n\n ENDCASE\n ENDDO\n\n RETURN cOutput"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charor.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n#require \"hbct\"\n#else\n#define hb_BChar( n ) Chr( n )\n#endif\n\nPROCEDURE Main()\n\n ctinit()\n\n ? \"Begin test of CharOr()\"\n ?\n\n ? \"Simple tests:\"\n\n ? ' CharOr( \"012345678\", hb_BChar( 1 ) ) == \"113355779\" ? --> \"' + CharOr( \"012345678\", hb_BChar( 1 ) ) + '\"'\n ? ' CharOr( \"012345678\", hb_BChar( 1 ) + hb_BChar( 3 ) ) == \"133357779\" ? --> \"' + CharOr( \"012345678\", hb_BChar( 1 ) + hb_BChar( 3 ) ) + '\"'\n\n ? \"End test of CharOr()\"\n ?\n\n ctexit()\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour test program: tests/seconds.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main( cParam )\n\n LOCAL n, limit := 10\n\n CLS\n\n IF ! Empty( cParam )\n limit := Val( cParam )\n ENDIF\n ? Seconds()\n FOR n := 1 TO limit\n IF Empty( cParam )\n ? \"Pause:\"\n Inkey( 0 )\n ENDIF\n ? Seconds()\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/arrindex.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL a, b, c\n\n a := { {, } }\n\n a[ 1, 2 ] := [Hello]\n\n c := { 1 }\n\n b := a[ c[ 1 ] ][ Val( [ 2 ] ) ]\n\n ? b\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/wce_sim.prg. Defines classes: wce_Sim. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"hbsim.ch\"\n\nCREATE CLASS wce_Sim\n\n VAR lInitialized INIT .F.\n VAR hSim\n VAR nLastError INIT SIM_E_OK\n\n METHOD New()\n METHOD End()\n\n METHOD lInitialize() \n METHOD lDeInitialize() \n\n METHOD lNumberOfPhoneBookEntries( nType, nTotal, nUsed ) \n METHOD aGetAllPhoneBookEntries( nType ) \n METHOD lGetSimPhoneEntry( nPos, nType, aEntry ) \n METHOD lSetSimPhoneEntry( nPos, nType, cNumber, cName, nPlan, nAddrType ) \n METHOD lDelSimPhoneEntry( nPos, nType ) \n\nENDCLASS\n\nMETHOD New() CLASS wce_Sim\n RETURN Self\n\nMETHOD lInitialize() CLASS wce_Sim\n\n LOCAL nResult := wce_SimInitialize( @::hSim )\n\n ::lInitialized := ( nResult == SIM_E_OK )\n ::nLastError := nResult\n\n RETURN ::lInitialized\n\nMETHOD lDeInitialize() CLASS wce_Sim\n\n LOCAL nResult\n\n IF ! ::lInitialized\n ::nLastError := SIM_E_HB_NOTINITIALIZED\n RETURN .F.\n ENDIF\n\n nResult := wce_SimDeInitialize( ::hSim )\n\n ::lInitialized := !( nResult == SIM_E_OK )\n ::nLastError := nResult\n\n RETURN nResult == SIM_E_OK\n\nMETHOD lNumberOfPhoneBookEntries( nType, nTotal, nUsed ) CLASS wce_Sim\n\n LOCAL nResult\n\n IF ! ::lInitialized\n ::nLastError := SIM_E_HB_NOTINITIALIZED\n RETURN .F.\n ENDIF\n\n hb_default( @nType, SIM_PBSTORAGE_SIM )\n\n nResult := wce_SimPhonebookStatus( ::hSim, nType, @nTotal, @nUsed )\n ::nLastError := nResult\n\n RETURN nResult == SIM_E_OK\n\nMETHOD aGetAllPhoneBookEntries( nType ) CLASS wce_Sim\n\n LOCAL nResult\n LOCAL nTotal\n LOCAL nUsed\n LOCAL aEntry\n LOCAL aEntries\n LOCAL nPos\n\n IF ! ::lInitialized\n ::nLastError := SIM_E_HB_NOTINITIALIZED\n RETURN .F.\n ENDIF\n\n hb_default( @nType, SIM_PBSTORAGE_SIM )\n hb_default( @aEntries, {} )\n\n IF ! ::lNumberOfPhoneBookEntries( nType, @nTotal, @nUsed )\n RETURN {}\n ENDIF\n\n FOR nPos := 1 TO nUsed\n aEntry := {}\n nResult := wce_SimReadPhonebookEntry( ::hSim, nType, nPos, @aEntry )\n IF nResult != SIM_E_OK\n ::nLastError := nResult\n EXIT\n ELSE\n AAdd( aEntries, aEntry )\n ENDIF\n NEXT\n\n ::nLastError := nResult\n\n RETURN aEntries\n\nMETHOD lGetSimPhoneEntry( nPos, nType, aEntry ) CLASS wce_Sim\n\n LOCAL nResult\n LOCAL a\n\n IF ! ::lInitialized\n ::nLastError := SIM_E_HB_NOTINITIALIZED\n RETURN .F.\n ENDIF\n\n hb_default( @nType, SIM_PBSTORAGE_SIM )\n\n nResult := wce_SimReadPhonebookEntry( ::hSim, nType, nPos, @a )\n\n aEntry := { a }\n ::nLastError := nResult\n\n RETURN nResult == SIM_E_OK\n\nMETHOD lSetSimPhoneEntry( nPos, nType, cNumber, cName, nPlan, nAddrType ) CLASS wce_Sim\n\n LOCAL nResult\n\n IF ! ::lInitialized\n ::nLastError := SIM_E_HB_NOTINITIALIZED\n RETURN .F.\n ENDIF\n\n hb_default( @nPos, SIM_PBINDEX_FIRSTAVAILABLE )\n hb_default( @nType, SIM_PBSTORAGE_SIM )\n\n nResult := wce_SimWritePhonebookEntry( ::hSim, nType, nPos, cNumber, cName, nPlan, nAddrType )\n ::nLastError := nResult\n\n RETURN nResult == SIM_E_OK\n\nMETHOD lDelSimPhoneEntry( nPos, nType ) CLASS wce_Sim\n\n LOCAL nResult\n\n IF ! ::lInitialized\n ::nLastError := SIM_E_HB_NOTINITIALIZED\n RETURN .F.\n ENDIF\n\n hb_default( @nType, SIM_PBSTORAGE_SIM )\n\n nResult := wce_SimDeletePhonebookEntry( ::hSim, nType, nPos )\n ::nLastError := nResult\n\n RETURN nResult == SIM_E_OK\n\nMETHOD End() CLASS wce_Sim\n\n IF ::lInitialized\n ::lDeInitialize()\n ENDIF\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/altd.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n CLS\n\n AltD( 1 ) \n\n Alert( \"debugger enabled\",, \"GR+/B\" )\n\n AltD() \n\n Alert( \"debugger invoked\",, \"GR+\" )\n\n Alert( \"finished\",, \"GR+/B,W+/R\" )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/floptst.prg. Provides functions: ft_FlopTst. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n\n#define ERR_WRONG_PARAMETERS -1\n#define ERR_NO_ERROR 0\n#define ERR_DRIVE_NOT_READY 1 \n#define ERR_UNFORMATTED 2 \n#define ERR_WRITE_PROTECTED 3\n\n\nFUNCTION ft_FlopTst( nDriveNum )\n\n LOCAL cFileName\n LOCAL fhnd\n\n IF HB_ISNUMERIC( nDriveNum )\n cFileName := Chr( Asc( \"A\" ) + nDriveNum ) + hb_osDriveSeparator()\n ELSEIF HB_ISSTRING( nDriveNum )\n cFileName := nDriveNum\n ELSE\n RETURN ERR_WRONG_PARAMETERS\n ENDIF\n\n cFileName := hb_DirSepAdd( cFileName ) + \"nf$rwtst.tmp\"\n\n IF hb_FileExists( cFileName )\n IF ( fhnd := FOpen( cFileName, FO_DENYNONE + FO_READWRITE ) ) == F_ERROR\n RETURN ERR_WRITE_PROTECTED\n ENDIF\n FClose( fhnd )\n ELSE\n IF ( fhnd := hb_FCreate( cFileName, FC_NORMAL, FO_DENYNONE + FO_READWRITE ) ) == F_ERROR\n RETURN ERR_WRITE_PROTECTED\n ENDIF\n FClose( fhnd )\n\n FErase( cFileName )\n ENDIF\n\n RETURN ERR_NO_ERROR"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/aeminlen.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\nPROCEDURE Main()\n\n LOCAL var0, myarray1 := Directory()\n\n CLS\n ? \"TEST TO DEMONSTRATE EXAMPLES OF FT_AEMINLEN\"\n ?\n ? \"myarray1 := Directory()\"\n ?\n AEval( myarray1, {| v | QOut( PadR( v[ 1 ], 12 ), v[ 2 ], v[ 3 ], v[ 4 ], v[ 5 ] ) } )\n var0 := ft_AEMinLen( myarray1 )\n ? PadR( \"ft_AEMinLen( myarray1 ) ->\", 30 )\n ?? var0\n ?\n var0 := ft_AEMinLen( myarray1, 2 )\n ? PadR( \"ft_AEMinLen( myarray1, 2 ) ->\", 30 )\n ?? var0\n ?\n ?\n var0 := ft_AEMinLen( myarray1[ 2 ] )\n ? PadR( \"ft_AEMinLen( myarray1[ 2 ] ) ->\", 30 )\n ?? var0\n ?\n ?\n var0 := ft_AEMinLen( myarray1, 3 )\n ? PadR( \"ft_AEMinLen( myarray1, 3 ) ->\", 30 )\n ?? var0\n ?\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour test program: tests/box2.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"box.ch\"\n\nPROCEDURE Main()\n\n LOCAL max_row, max_col, boxColor := \"W+/B,N/BG\", lineColor := \"W+/R, N/BG\"\n\n CLS\n max_row := MaxRow()\n max_col := MaxCol()\n\n \n DispBox( -10, -10, 10, 10, HB_B_SINGLE_UNI + \"X\", boxColor )\n DispBox( -10, max_col - 10, 10, max_col + 10, HB_B_SINGLE_UNI + \"X\", boxColor )\n DispBox( max_row - 10, - 10, max_row + 10, 10, HB_B_SINGLE_UNI + \"X\", boxColor )\n DispBox( max_row - 10, max_col - 10, max_row + 10, max_col + 10, HB_B_SINGLE_UNI + \"X\", boxColor )\n\n \n DispBox( -15, -15, 15, 15, 1, boxColor )\n DispBox( -15, max_col - 15, 15, max_col + 15, 1, boxColor )\n DispBox( max_row - 15, - 15, max_row + 15, 15, 1, boxColor )\n DispBox( max_row - 15, max_col - 15, max_row + 15, max_col + 15, 1, boxColor )\n\n \n DispBox( 20, 20, 25, 60, 2, boxColor )\n DispBox( -10, -10, -1, -1, 2, boxColor )\n DispBox( max_row + 1, max_col + 1, max_row + 10, max_col + 10, 2, boxColor )\n\n \n DispBox( 1, -10, 1, 10, HB_B_SINGLE_UNI, lineColor )\n DispBox( 2, -10, 2, max_col + 10, HB_B_DOUBLE_UNI, lineColor )\n DispBox( 3, max_col - 10, 3, max_col + 10, HB_B_SINGLE_UNI, lineColor )\n\n \n DispBox( -10, 1, 10, 1, HB_B_SINGLE_UNI, lineColor )\n DispBox( -10, 2, max_row + 10, 2, HB_B_DOUBLE_UNI, lineColor )\n DispBox( max_row - 10, 3, max_row + 10, 3, HB_B_SINGLE_UNI, lineColor )\n\n Inkey( 5 )\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHeader file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hbcommon.ch. Defines constants: HB_HBCOMMON_CH_, HB_FILE_VER(, HB_FILE_VER(. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_HBCOMMON_CH_\n#define HB_HBCOMMON_CH_\n\n#include \"hbsetup.ch\"\n\n#ifdef HB_FILE_VER_STATIC\n #define HB_FILE_VER( id ) STATIC s_hb_file_ver := id\n#else\n #define HB_FILE_VER( id )\n#endif\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour header file: include/error.ch. Defines 10 constants including: _ERROR_CH, ES_WHOCARES, ES_WARNING, ES_ERROR, ES_CATASTROPHIC. Defines error handling constants and codes"}, {"role": "assistant", "content": "#ifndef _ERROR_CH\n#define _ERROR_CH\n\n\n#define ES_WHOCARES 0\n#define ES_WARNING 1\n#define ES_ERROR 2\n#define ES_CATASTROPHIC 3\n\n\n#define EG_ARG 1\n#define EG_BOUND 2\n#define EG_STROVERFLOW 3\n#define EG_NUMOVERFLOW 4\n#define EG_ZERODIV 5\n#define EG_NUMERR 6\n#define EG_SYNTAX 7\n#define EG_COMPLEXITY 8\n\n#define EG_MEM 11\n#define EG_NOFUNC 12\n#define EG_NOMETHOD 13\n#define EG_NOVAR 14\n#define EG_NOALIAS 15\n#define EG_NOVARMETHOD 16\n#define EG_BADALIAS 17\n#define EG_DUPALIAS 18\n\n#define EG_CREATE 20\n#define EG_OPEN 21\n#define EG_CLOSE 22\n#define EG_READ 23\n#define EG_WRITE 24\n#define EG_PRINT 25\n\n#define EG_UNSUPPORTED 30\n#define EG_LIMIT 31\n#define EG_CORRUPTION 32\n#define EG_DATATYPE 33\n#define EG_DATAWIDTH 34\n#define EG_NOTABLE 35\n#define EG_NOORDER 36\n#define EG_SHARED 37\n#define EG_UNLOCKED 38\n#define EG_READONLY 39\n\n#define EG_APPENDLOCK 40\n#define EG_LOCK 41\n\n#define EG_DESTRUCTOR 45 \n#define EG_ARRACCESS 46 \n#define EG_ARRASSIGN 47 \n#define EG_ARRDIMENSION 48 \n#define EG_NOTARRAY 49 \n#define EG_CONDITION 50 \n\n\n#define HB_EI_ERRUNRECOV 9000 \n#define HB_EI_ERRRECFAILURE 9001 \n#define HB_EI_ERRNOBLOCK 9002 \n#define HB_EI_ERRTOOMANY 9003 \n#define HB_EI_RDDINVALID 9004 \n#define HB_EI_CLSINVMETHOD 9005 \n#define HB_EI_XGRABALLOC 9006 \n#define HB_EI_XREALLOCNULL 9007 \n#define HB_EI_XREALLOCINV 9008 \n#define HB_EI_XREALLOC 9009 \n#define HB_EI_XFREEINV 9010 \n#define HB_EI_XFREENULL 9011 \n#define HB_EI_VMBADSTARTUP 9012 \n#define HB_EI_VMNOSTARTUP 9013 \n#define HB_EI_VMBADOPCODE 9014 \n#define HB_EI_VMNOTSYMBOL 9015 \n#define HB_EI_VMINVSYMBOL 9016 \n#define HB_EI_VMNOTCBLOCK 9017 \n#define HB_EI_VMPOPINVITEM 9018 \n#define HB_EI_STACKUFLOW 9019 \n#define HB_EI_ITEMBADCOPY 9020 \n#define HB_EI_MVBADSYMBOL 9021 \n#define HB_EI_XMEMOVERFLOW 9022 \n#define HB_EI_XGRABNULLSIZE 9023 \n#define HB_EI_XREALLOCNULLSIZE 9024 \n#define HB_EI_XALLOCNULLSIZE 9025 \n\n#define HB_EI_COMPBADOPCODE 9100 \n#define HB_EI_COMPBADOPSIZE 9101 \n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour Runtime Library file: src/rtl/cdpdet.prg. Provides 6 functions including: hb_cdpTerm, hb_cdpOS, __CPWinToCPStd, __UnixParseLangCP, __CPStdToHb. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbextcdp.ch\"\n\nFUNCTION hb_cdpTerm()\n\n LOCAL cCP\n LOCAL cLang\n\n#if defined( __PLATFORM__WINDOWS )\n LOCAL tmp\n cCP := __CPWinToCPStd( iif( ( tmp := __wapi_GetConsoleOutputCP() ) == 0, __wapi_GetOEMCP(), tmp ) )\n cLang := hb_UserLang()\n#elif defined( __PLATFORM__UNIX )\n LOCAL tmp\n cCP := __UnixParseLangCP( iif( Empty( tmp := GetEnv( \"LANG\" ) ), ;\n GetEnv( \"LC_CTYPE\" ), tmp ), @cLang )\n#elif defined( __PLATFORM__DOS )\n \n cCP := cLang := NIL\n#elif defined( __PLATFORM__OS2 )\n \n cCP := cLang := NIL\n#endif\n\n RETURN __CPStdToHb( cCP, cLang )\n\nFUNCTION hb_cdpOS()\n\n LOCAL cCP\n LOCAL cLang\n\n#if defined( __PLATFORM__WINDOWS )\n cCP := __CPWinToCPStd( __wapi_GetACP() )\n cLang := hb_UserLang()\n#elif defined( __PLATFORM__UNIX )\n LOCAL tmp\n cCP := __UnixParseLangCP( iif( Empty( tmp := GetEnv( \"LANG\" ) ), ;\n GetEnv( \"LC_CTYPE\" ), tmp ), @cLang )\n#elif defined( __PLATFORM__DOS )\n \n cCP := cLang := NIL\n#elif defined( __PLATFORM__OS2 )\n \n cCP := cLang := NIL\n#endif\n\n RETURN __CPStdToHb( cCP, cLang )\n\n#if defined( __PLATFORM__WINDOWS )\nSTATIC FUNCTION __CPWinToCPStd( nCPWin )\n\n SWITCH nCPWin\n CASE 65001 ; RETURN \"utf8\"\n CASE 1200 ; RETURN \"utf16\"\n CASE 437\n CASE 737\n CASE 775\n CASE 850\n CASE 852\n CASE 855\n CASE 856\n CASE 857\n CASE 858\n CASE 860\n CASE 861\n CASE 862\n CASE 863\n CASE 864\n CASE 865\n CASE 866\n CASE 869\n CASE 874\n CASE 1250\n CASE 1251\n CASE 1252\n CASE 1253\n CASE 1254\n CASE 1255\n CASE 1256\n CASE 1257\n CASE 1258 ; RETURN \"cp\" + hb_ntos( nCPWin )\n CASE 28591\n CASE 28592\n CASE 28593\n CASE 28594\n CASE 28595\n CASE 28596\n CASE 28597\n CASE 28598\n CASE 28599\n CASE 28603\n CASE 28605 ; RETURN \"iso8859-\" + hb_ntos( nCPWin - 28590 )\n CASE 20866 ; RETURN \"koi-8\"\n CASE 21866 ; RETURN \"koi-8u\"\n CASE 936 ; RETURN \"GBK\"\n CASE 950 ; RETURN \"CP950\"\n ENDSWITCH\n\n RETURN NIL\n\n#elif defined( __PLATFORM__UNIX )\n\n\nSTATIC FUNCTION __UnixParseLangCP( cString, cLang )\n\n LOCAL tmp\n LOCAL cCP\n\n IF ( tmp := At( \".\", cString ) ) > 0\n cLang := Left( cString, tmp - 1 )\n cCP := SubStr( cString, tmp + 1 )\n IF ( tmp := At( \"@\", cString ) ) > 0\n cCP := Left( cString, tmp - 1 )\n ENDIF\n ELSE\n cLang := cString\n cCP := \"UTF-8\"\n ENDIF\n\n \n cCP := hb_StrReplace( Lower( cCP ), { \"_\" => \"\", \"-\" => \"\", \"ibm\" => \"cp\", \"windows\" => \"cp\" } )\n IF hb_LeftEq( cCP, \"iso8859\" )\n cCP := Stuff( cCP, Len( \"iso8859\" ) + 1, 0, \"-\" )\n ENDIF\n\n \n SWITCH cCP\n CASE \"utf8\"\n CASE \"cp437\"\n CASE \"cp737\"\n CASE \"cp775\"\n CASE \"cp850\"\n CASE \"cp852\"\n CASE \"cp855\"\n CASE \"cp856\"\n CASE \"cp857\"\n CASE \"cp858\"\n CASE \"cp860\"\n CASE \"cp861\"\n CASE \"cp862\"\n CASE \"cp863\"\n CASE \"cp864\"\n CASE \"cp865\"\n CASE \"cp866\"\n CASE \"cp869\"\n CASE \"cp874\"\n CASE \"cp1250\"\n CASE \"cp1251\"\n CASE \"cp1252\"\n CASE \"cp1253\"\n CASE \"cp1254\"\n CASE \"cp1255\"\n CASE \"cp1256\"\n CASE \"cp1257\"\n CASE \"cp1258\"\n CASE \"iso8859-1\"\n CASE \"iso8859-2\"\n CASE \"iso8859-3\"\n CASE \"iso8859-4\"\n CASE \"iso8859-5\"\n CASE \"iso8859-6\"\n CASE \"iso8859-7\"\n CASE \"iso8859-8\"\n CASE \"iso8859-9\"\n CASE \"iso8859-13\"\n CASE \"iso8859-15\" ; RETURN cCP\n CASE \"koi8r\" ; RETURN \"koi-8\"\n CASE \"koi8u\" ; RETURN \"koi-8u\"\n CASE \"gbk\" ; RETURN \"GBK\"\n CASE \"big5\" ; RETURN \"BIG5\"\n ENDSWITCH\n\n RETURN NIL\n\n#endif\n\nSTATIC FUNCTION __CPStdToHb( cCPStd, cCtryStd )\n\n LOCAL cCtryHb\n LOCAL cdp\n LOCAL aCP\n\n IF cCPStd != NIL\n SWITCH cCPStd := Lower( cCPStd )\n CASE \"utf8\"\n RETURN \"UTF8\"\n CASE \"utf16\"\n RETURN \"UTF16LE\"\n OTHERWISE\n aCP := hb_cdpList()\n cCtryHb := __LangStdToCPCtryHb( cCtryStd )\n FOR EACH cdp IN aCP\n IF hb_LeftEq( cdp, cCtryHb ) .AND. cCPStd == hb_cdpUniID( cdp )\n RETURN cdp\n ENDIF\n NEXT\n FOR EACH cdp IN aCP\n IF cCPStd == hb_cdpUniID( cdp )\n RETURN hb_cdpUniID( cdp )\n ENDIF\n NEXT\n ENDSWITCH\n ENDIF\n\n RETURN NIL\n\nSTATIC FUNCTION __LangStdToCPCtryHb( cCtryStd )\n\n SWITCH Lower( cCtryStd )\n CASE \"bg-bg\"\n CASE \"bg\" ; RETURN \"BG\"\n CASE \"cs-cz\"\n CASE \"cs\" ; RETURN \"CS\"\n CASE \"da-dk\"\n CASE \"da\" ; RETURN \"DK\"\n CASE \"de-at\"\n CASE \"de-ch\"\n CASE \"de-de\"\n CASE \"de-li\"\n CASE \"de-lu\"\n CASE \"de\" ; RETURN \"DE\"\n CASE \"el-gr\"\n CASE \"el\" ; RETURN \"EL\"\n CASE \"en-au\"\n CASE \"en-bz\"\n CASE \"en-ca\"\n CASE \"en-cb\"\n CASE \"en-gb\"\n CASE \"en-ie\"\n CASE \"en-jm\"\n CASE \"en-nz\"\n CASE \"en-ph\"\n CASE \"en-tt\"\n CASE \"en-us\"\n CASE \"en-za\"\n CASE \"en-zw\"\n CASE \"en\" ; RETURN \"EN\"\n CASE \"es-419\"\n CASE \"es-ar\"\n CASE \"es-bo\"\n CASE \"es-cl\"\n CASE \"es-co\"\n CASE \"es-cr\"\n CASE \"es-do\"\n CASE \"es-ec\"\n CASE \"es-es\"\n CASE \"es-gt\"\n CASE \"es-hn\"\n CASE \"es-mx\"\n CASE \"es-ni\"\n CASE \"es-pa\"\n CASE \"es-pe\"\n CASE \"es-pr\"\n CASE \"es-py\"\n CASE \"es-sv\"\n CASE \"es-uy\"\n CASE \"es-ve\"\n CASE \"es\" ; RETURN \"ES\"\n CASE \"fi-fi\"\n CASE \"fi\" ; RETURN \"FI\"\n CASE \"fr-be\"\n CASE \"fr-ca\"\n CASE \"fr-ch\"\n CASE \"fr-fr\"\n CASE \"fr-lu\"\n CASE \"fr-mc\"\n CASE \"fr\" ; RETURN \"FR\"\n CASE \"he-il\"\n CASE \"he\" ; RETURN \"HE\"\n CASE \"hr-hr\"\n CASE \"hr\" ; RETURN \"HR\"\n CASE \"hu-hu\"\n CASE \"hu\" ; RETURN \"HU\"\n CASE \"is-is\"\n CASE \"is\" ; RETURN \"IS\"\n CASE \"it-ch\"\n CASE \"it-it\"\n CASE \"it\" ; RETURN \"IT\"\n CASE \"lt-lt\"\n CASE \"lt\" ; RETURN \"LT\"\n CASE \"nl-be\"\n CASE \"nl-nl\"\n CASE \"nl\" ; RETURN \"NL\"\n CASE \"no\" ; RETURN \"NO\"\n CASE \"pl-pl\"\n CASE \"pl\" ; RETURN \"PL\"\n CASE \"pt-br\"\n CASE \"pt-pt\"\n CASE \"pt\" ; RETURN \"PT\"\n CASE \"ro-ro\"\n CASE \"ro\" ; RETURN \"RO\"\n CASE \"ru-ru\"\n CASE \"ru\" ; RETURN \"RU\"\n CASE \"sk-sk\"\n CASE \"sk\" ; RETURN \"SK\"\n CASE \"sl-si\"\n CASE \"sl\" ; RETURN \"SL\"\n CASE \"sr-sp-cyrl\"\n CASE \"sr-sp-latn\" ; RETURN \"SR\"\n CASE \"sv-fi\"\n CASE \"sv-se\"\n CASE \"sv\" ; RETURN \"SV\"\n CASE \"tr-tr\"\n CASE \"tr\" ; RETURN \"TR\"\n CASE \"uk-ua\"\n CASE \"uk\" ; RETURN \"UA\"\n ENDSWITCH\n\n RETURN Left( hb_cdpSelect(), 2 )"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour test program: tests/varparam.prg. Contains 14 procedures. This test file tests specific function APIs"}, {"role": "assistant", "content": "MEMVAR m_iLoop\n\nPROCEDURE Main()\n\n LOCAL l1 := 11, l2 := 22, l3 := 33, l4 := 44, l5 := 55, l6 := 66\n PRIVATE m_iLoop\n\n ? \"passed 0: \"; TEST_0_0()\n ? \"passed 1: \"; TEST_0_0( 1 )\n ? \"passed 2: \"; TEST_0_0( 1, 2 )\n ? \"passed 3: \"; TEST_0_0( 1, 2, 3 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_0_0v()\n ? \"passed 1: \"; TEST_0_0v( 1 )\n ? \"passed 2: \"; TEST_0_0v( 1, 2 )\n ? \"passed 3: \"; TEST_0_0v( 1, 2, 3 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_1_0()\n ? \"passed 1: \"; TEST_1_0( 1 )\n ? \"passed 2: \"; TEST_1_0( 1, 2 )\n ? \"passed 3: \"; TEST_1_0( 1, 2, 3 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_1_0v()\n ? \"passed 1: \"; TEST_1_0v( 1 )\n ? \"passed 2: \"; TEST_1_0v( 1, 2 )\n ? \"passed 3: \"; TEST_1_0v( 1, 2, 3 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_1_1()\n ? \"passed 1: \"; TEST_1_1( 1 )\n ? \"passed 2: \"; TEST_1_1( 1, 2 )\n ? \"passed 3: \"; TEST_1_1( 1, 2, 3 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_1_1v()\n ? \"passed 1: \"; TEST_1_1v( 1 )\n ? \"passed 2: \"; TEST_1_1v( 1, 2 )\n ? \"passed 3: \"; TEST_1_1v( 1, 2, 3 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_1_3()\n ? \"passed 1: \"; TEST_1_3( 1 )\n ? \"passed 2: \"; TEST_1_3( 1, 2 )\n ? \"passed 3: \"; TEST_1_3( 1, 2, 3 )\n ? \"passed 4: \"; TEST_1_3( 1, 2, 3, 4 )\n ? \"passed 5: \"; TEST_1_3( 1, 2, 3, 4, 5 )\n ? \"passed 6: \"; TEST_1_3( 1, 2, 3, 4, 5, 6 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_1_3v()\n ? \"passed 1: \"; TEST_1_3v( 1 )\n ? \"passed 2: \"; TEST_1_3v( 1, 2 )\n ? \"passed 3: \"; TEST_1_3v( 1, 2, 3 )\n ? \"passed 4: \"; TEST_1_3v( 1, 2, 3, 4 )\n ? \"passed 5: \"; TEST_1_3v( 1, 2, 3, 4, 5 )\n ? \"passed 6: \"; TEST_1_3v( 1, 2, 3, 4, 5, 6 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_3_0()\n ? \"passed 1: \"; TEST_3_0( 1 )\n ? \"passed 2: \"; TEST_3_0( 1, 2 )\n ? \"passed 3: \"; TEST_3_0( 1, 2, 3 )\n ? \"passed 4: \"; TEST_3_0( 1, 2, 3, 4 )\n ? \"passed 5: \"; TEST_3_0( 1, 2, 3, 4, 5 )\n ? \"passed 6: \"; TEST_3_0( 1, 2, 3, 4, 5, 6 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_3_0v()\n ? \"passed 1: \"; TEST_3_0v( 1 )\n ? \"passed 2: \"; TEST_3_0v( 1, 2 )\n ? \"passed 3: \"; TEST_3_0v( 1, 2, 3 )\n ? \"passed 4: \"; TEST_3_0v( 1, 2, 3, 4 )\n ? \"passed 5: \"; TEST_3_0v( 1, 2, 3, 4, 5 )\n ? \"passed 6: \"; TEST_3_0v( 1, 2, 3, 4, 5, 6 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_3_3()\n ? \"passed 1: \"; TEST_3_3( 1 )\n ? \"passed 2: \"; TEST_3_3( 1, 2 )\n ? \"passed 3: \"; TEST_3_3( 1, 2, 3 )\n ? \"passed 4: \"; TEST_3_3( 1, 2, 3, 4 )\n ? \"passed 5: \"; TEST_3_3( 1, 2, 3, 4, 5 )\n ? \"passed 6: \"; TEST_3_3( 1, 2, 3, 4, 5, 6 )\n\n ? \"---------------------------------------\"\n ? \"passed 0: \"; TEST_3_3v()\n ? \"passed 1: \"; TEST_3_3v( 1 )\n ? \"passed 2: \"; TEST_3_3v( 1, 2 )\n ? \"passed 3: \"; TEST_3_3v( 1, 2, 3 )\n ? \"passed 4: \"; TEST_3_3v( 1, 2, 3, 4 )\n ? \"passed 5: \"; TEST_3_3v( 1, 2, 3, 4, 5 )\n ? \"passed 6: \"; TEST_3_3v( 1, 2, 3, 4, 5, 6 )\n\n ? \"---------------------------------------\"\n ? \"Passed 6 by ref: \"; TEST_0_0( @l1, @l2, @l3, @l4, @l5, @l6 )\n ? \"Passed 6 by ref: \"; TEST_0_0v( @l1, @l2, @l3, @l4, @l5, @l6 )\n\n ? \"---------------------------------------\"\n ? \"Passed 6 by ref: \"; TEST_1_0( @l1, @l2, @l3, @l4, @l5, @l6 )\n ? \"Passed 6 by ref: \"; TEST_1_0v( @l1, @l2, @l3, @l4, @l5, @l6 )\n\n ? \"---------------------------------------\"\n ? \"Passed 6 by ref: \"; TEST_1_1( @l1, @l2, @l3, @l4, @l5, @l6 )\n ? \"Passed 6 by ref: \"; TEST_1_1v( @l1, @l2, @l3, @l4, @l5, @l6 )\n\n ? \"---------------------------------------\"\n ? \"Passed 6 by ref: \"; TEST_1_3( @l1, @l2, @l3, @l4, @l5, @l6 )\n ? \"Passed 6 by ref: \"; TEST_1_3v( @l1, @l2, @l3, @l4, @l5, @l6 )\n\n ? \"---------------------------------------\"\n ? \"Passed 6 by ref: \"; TEST_3_0( @l1, @l2, @l3, @l4, @l5, @l6 )\n ? \"Passed 6 by ref: \"; TEST_3_0v( @l1, @l2, @l3, @l4, @l5, @l6 )\n\n ? \"---------------------------------------\"\n ? \"Passed 6 by ref: \"; TEST_3_3( @l1, @l2, @l3, @l4, @l5, @l6 )\n ? \"Passed 6 by ref: \"; TEST_3_3v( @l1, @l2, @l3, @l4, @l5, @l6 )\n\n RETURN\n\nPROCEDURE TEST_0_0v( ... )\n\n ?? ProcName( 0 ), \" received: \", PCount()\n FOR m_iLoop := 1 TO PCount()\n ? m_iLoop, \"=\", hb_PValue( m_iLoop )\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_0_0()\n\n ?? ProcName( 0 ), \" received: \", PCount()\n FOR m_iLoop := 1 TO PCount()\n ? m_iLoop, \"=\", hb_PValue( m_iLoop )\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_1_0v( ... )\n\n LOCAL i := \"i\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"i=\", i\n FOR i := 1 TO PCount()\n ? i, \"=\", hb_PValue( i )\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_1_0()\n\n LOCAL i := \"i\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"i=\", i\n FOR i := 1 TO PCount()\n ? i, \"=\", hb_PValue( i )\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_1_3v( a, b, c, ... )\n\n LOCAL i := \"i\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"i=\", i\n ? \"a=\", a\n ? \"b=\", b\n ? \"c=\", c\n FOR i := 1 TO PCount()\n ? i, \"=\", hb_PValue( i )\n NEXT\n\n FOR EACH i IN hb_AParams()\n ? i:__enumindex, \"-\", i\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_1_3( a, b, c )\n\n LOCAL i := \"i\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"i=\", i\n ? \"a=\", a\n ? \"b=\", b\n ? \"c=\", c\n FOR i := 1 TO PCount()\n ? i, \"=\", hb_PValue( i )\n NEXT\n\n FOR EACH i IN hb_AParams()\n ? i:__enumindex, \"-\", i\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_1_1( a )\n\n LOCAL i := \"i\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"i=\", i\n ? \"a=\", a\n FOR i := 1 TO PCount()\n ? i, \"=\", hb_PValue( i )\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_1_1v( a, ... )\n\n LOCAL i := \"i\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"i=\", i\n ? \"a=\", a\n FOR i := 1 TO PCount()\n ? i, \"=\", hb_PValue( i )\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_3_3v( a, b, c, ... )\n\n LOCAL x := \"x\", y := \"y\", z := \"z\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"x=\", x\n ? \"y=\", y\n ? \"z=\", z\n ? \"a=\", a\n ? \"b=\", b\n ? \"c=\", c\n FOR m_iLoop := 1 TO PCount()\n ? m_iLoop, \"=\", hb_PValue( m_iLoop )\n NEXT\n\n test_ref( @a, @b, @c, @x, @y, @z )\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_3_3( a, b, c )\n\n LOCAL x := \"x\", y := \"y\", z := \"z\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"x=\", x\n ? \"y=\", y\n ? \"z=\", z\n ? \"a=\", a\n ? \"b=\", b\n ? \"c=\", c\n FOR m_iLoop := 1 TO PCount()\n ? m_iLoop, \"=\", hb_PValue( m_iLoop )\n NEXT\n\n test_ref( @a, @b, @c, @x, @y, @z )\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_3_0()\n\n LOCAL x := \"x\", y := \"y\", z := \"z\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"x=\", x\n ? \"y=\", y\n ? \"z=\", z\n FOR m_iLoop := 1 TO PCount()\n ? m_iLoop, \"=\", hb_PValue( m_iLoop )\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_3_0v( ... )\n\n LOCAL x := \"x\", y := \"y\", z := \"z\"\n\n ?? ProcName( 0 ), \" received: \", PCount()\n ? \"x=\", x\n ? \"y=\", y\n ? \"z=\", z\n FOR m_iLoop := 1 TO PCount()\n ? m_iLoop, \"=\", hb_PValue( m_iLoop )\n NEXT\n\n Inkey( 0 )\n\n RETURN\n\nPROCEDURE TEST_REF( a, ... )\n\n LOCAL b\n\n ? \"@@@\"\n ? ProcName( 0 ), \" received: \", PCount()\n ? \"a= \", a\n ? \"b= \", b\n FOR EACH b IN hb_AParams( 0 )\n ? b:__enumindex, \"-\", b\n NEXT\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Generate Harbour code for: Harbour Runtime Library file: src/rtl/objfunc.prg. Provides 16 functions including: __objHasData, __objHasMethod, __objGetMsgList, __objGetMethodList, __objGetValueList. This file provides utility functions"}, {"role": "assistant", "content": "#include \"error.ch\"\n#include \"hboo.ch\"\n\nFUNCTION __objHasData( oObject, cSymbol )\n\n IF ! HB_ISOBJECT( oObject ) .OR. ! HB_ISSTRING( cSymbol )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ENDIF\n\n RETURN ;\n __objHasMsg( oObject, cSymbol ) .AND. ;\n __objHasMsg( oObject, \"_\" + cSymbol )\n\nFUNCTION __objHasMethod( oObject, cSymbol )\n\n IF ! HB_ISOBJECT( oObject ) .OR. ! HB_ISSTRING( cSymbol )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ENDIF\n\n RETURN ;\n __objHasMsg( oObject, cSymbol ) .AND. ;\n ! __objHasMsg( oObject, \"_\" + cSymbol )\n\nFUNCTION __objGetMsgList( oObject, lDataMethod, nClassType )\n\n LOCAL aInfo\n LOCAL aData\n LOCAL cName\n LOCAL nFirst\n\n IF ! HB_ISOBJECT( oObject )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ENDIF\n\n hb_default( @lDataMethod, .T. )\n\n aInfo := oObject:ClassSel( hb_defaultValue( nClasstype, HB_MSGLISTALL ) )\n aData := {}\n nFirst := AScan( aInfo, {| n | hb_LeftEq( n, \"_\" ) } )\n\n FOR EACH cName IN aInfo\n\n \n IF ! hb_LeftEq( cName, \"_\" )\n\n \n IF ( AScan( aInfo, {| tmp | tmp == ( \"_\" + cName ) }, nFirst ) > 0 ) == lDataMethod\n AAdd( aData, cName )\n ENDIF\n ENDIF\n NEXT\n\n RETURN aData\n\nFUNCTION __objGetMethodList( oObject )\n\n IF ! HB_ISOBJECT( oObject )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ENDIF\n\n RETURN __objGetMsgList( oObject, .F. )\n\nFUNCTION __objGetValueList( oObject, aExcept )\n\n LOCAL aData\n LOCAL cSymbol\n\n IF ! HB_ISOBJECT( oObject )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ENDIF\n\n hb_default( @aExcept, {} )\n\n aData := {}\n FOR EACH cSymbol IN __objGetMsgList( oObject )\n IF hb_AScan( aExcept, cSymbol,,, .T. ) == 0\n AAdd( aData, { cSymbol, __objSendMsg( oObject, cSymbol ) } )\n ENDIF\n NEXT\n\n RETURN aData\n\nFUNCTION __objSetValueList( oObject, aData )\n\n IF HB_ISOBJECT( oObject )\n AEval( aData, {| aItem | __objSendMsg( oObject, \"_\" + aItem[ HB_OO_DATA_SYMBOL ], aItem[ HB_OO_DATA_VALUE ] ) } )\n ELSE\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ENDIF\n\n RETURN oObject\n\nFUNCTION __objAddMethod( oObject, cSymbol, nFuncPtr )\n\n IF ! HB_ISOBJECT( oObject ) .OR. ! HB_ISSTRING( cSymbol ) .OR. ! HB_ISSYMBOL( nFuncPtr )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ELSEIF ! __objHasMsg( oObject, cSymbol )\n __clsAddMsg( oObject:ClassH, cSymbol, nFuncPtr, HB_OO_MSG_METHOD, , 1 )\n ENDIF\n\n RETURN oObject\n\nFUNCTION __objAddInline( oObject, cSymbol, bInline )\n\n IF ! HB_ISOBJECT( oObject ) .OR. ! HB_ISSTRING( cSymbol )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ELSEIF ! __objHasMsg( oObject, cSymbol )\n __clsAddMsg( oObject:ClassH, cSymbol, bInline, HB_OO_MSG_INLINE, , 1 )\n ENDIF\n\n RETURN oObject\n\nFUNCTION __objAddData( oObject, cSymbol )\n\n LOCAL nSeq, hClass\n\n IF ! HB_ISOBJECT( oObject ) .OR. ! HB_ISSTRING( cSymbol )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ELSEIF ! __objHasMsg( oObject, cSymbol ) .AND. ! __objHasMsg( oObject, \"_\" + cSymbol )\n hClass := oObject:ClassH\n nSeq := __cls_IncData( hClass ) \n __clsAddMsg( hClass, cSymbol, nSeq, HB_OO_MSG_ACCESS, , 1 )\n __clsAddMsg( hClass, \"_\" + cSymbol, nSeq, HB_OO_MSG_ASSIGN, , 1 )\n ENDIF\n\n RETURN oObject\n\nFUNCTION __objModMethod( oObject, cSymbol, nFuncPtr )\n\n IF ! HB_ISOBJECT( oObject ) .OR. ! HB_ISSTRING( cSymbol ) .OR. ! HB_ISSYMBOL( nFuncPtr )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ELSEIF __objHasMethod( oObject, cSymbol )\n __clsModMsg( oObject:ClassH, cSymbol, nFuncPtr )\n ENDIF\n\n RETURN oObject\n\nFUNCTION __objModInline( oObject, cSymbol, bInline )\n\n IF ! HB_ISOBJECT( oObject ) .OR. ! HB_ISSTRING( cSymbol ) .OR. ! HB_ISBLOCK( bInline )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ELSEIF __objHasMethod( oObject, cSymbol )\n __clsModMsg( oObject:ClassH, cSymbol, bInline )\n ENDIF\n\n RETURN oObject\n\nFUNCTION __objDelMethod( oObject, cSymbol )\n\n IF ! HB_ISOBJECT( oObject ) .OR. ! HB_ISSTRING( cSymbol )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ELSEIF __objHasMethod( oObject, cSymbol )\n __clsDelMsg( oObject:ClassH, cSymbol )\n ENDIF\n\n RETURN oObject\n\nFUNCTION __objDelInline( oObject, cSymbol )\n RETURN __objDelMethod( oObject, cSymbol )\n\nFUNCTION __objDelData( oObject, cSymbol )\n\n IF ! HB_ISOBJECT( oObject ) .OR. ! HB_ISSTRING( cSymbol )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ELSEIF __objHasData( oObject, cSymbol )\n __clsDelMsg( oObject:ClassH, cSymbol )\n __clsDelMsg( oObject:ClassH, \"_\" + cSymbol )\n __cls_DecData( oObject:ClassH ) \n ENDIF\n\n RETURN oObject\n\nFUNCTION __objDerivedFrom( oObject, xSuper )\n\n LOCAL cClassName\n\n IF ! HB_ISOBJECT( oObject )\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ENDIF\n\n DO CASE\n CASE HB_ISOBJECT( xSuper )\n cClassName := xSuper:ClassName()\n CASE HB_ISSTRING( xSuper )\n cClassName := hb_asciiUpper( xSuper )\n OTHERWISE\n __errRT_BASE( EG_ARG, 3101, , ProcName( 0 ) )\n ENDCASE\n\n RETURN __clsParent( oObject:ClassH, cClassName )\n\nFUNCTION __objGetProperties( oObject, lAllExported )\n\n LOCAL msg\n LOCAL aMsgList := __clsGetProperties( oObject:classH, lAllExported )\n\n FOR EACH msg IN aMsgList\n msg := { msg, __objSendMsg( oObject, msg ) }\n NEXT\n\n RETURN aMsgList"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement these Harbour functions: Harbour Runtime Library file: src/debug/dbghelp.prg. Provides functions: GetTopics, help_en. Contains 4 procedures. This file provides utility functions"}, {"role": "assistant", "content": "#pragma -b-\n\n\n#include \"box.ch\"\n#include \"inkey.ch\"\n\nPROCEDURE __dbgHelp( cTopic )\n\n LOCAL cColor := iif( __dbg():lMonoDisplay, \"N/W, W/N, W+/W, W+/N\", \"N/W, N/BG, R/W, R/BG\" )\n LOCAL oBrw\n LOCAL nTopic\n LOCAL aTopics := GetTopics()\n\n LOCAL oDlg := HBDbWindow():New( 2, 2, MaxRow() - 2, MaxCol() - 2, \"Help\", cColor )\n\n oBrw := HBDbBrowser():New( oDlg:nTop + 1, oDlg:nLeft + 1, oDlg:nBottom - 1, oDlg:nLeft + 12 )\n oBrw:Cargo := 1\n oBrw:AddColumn( HBDbColumnNew( \"\", {|| aTopics[ oBrw:Cargo ][ 1 ] }, 12 ) )\n oBrw:ColorSpec := StrTran( __dbg():ClrModal(), \", R/W\" )\n oBrw:SkipBlock := {| nSkip, nOld | nOld := oBrw:Cargo, oBrw:Cargo += nSkip, ;\n oBrw:Cargo := Min( Max( oBrw:Cargo, 1 ), Len( aTopics ) ), ;\n oBrw:Cargo - nOld }\n oBrw:GoTopBlock := {|| oBrw:Cargo := 1 }\n oBrw:GoBottomBlock := {|| oBrw:Cargo := Len( aTopics ) }\n\n IF HB_ISSTRING( cTopic ) .AND. ;\n ( nTopic := AScan( aTopics, {| x | hb_LeftEqI( x[ 1 ], cTopic ) } ) ) > 1\n oBrw:nFirstVisible := nTopic\n ENDIF\n\n oDlg:bPainted := {|| PaintWindow( oDlg, oBrw, aTopics ) }\n oDlg:bKeyPressed := {| nKey | ProcessKey( nKey, oDlg, oBrw, aTopics, oDlg:cColor ) }\n\n oDlg:ShowModal()\n\n RETURN\n\nSTATIC PROCEDURE PaintWindow( oDlg, oBrw, aTopics )\n\n hb_DispBox( oDlg:nTop + 1, oDlg:nLeft + 13, oDlg:nBottom - 1, oDlg:nLeft + 13, HB_B_SINGLE_UNI, oDlg:cColor )\n hb_DispOutAtBox( oDlg:nTop, oDlg:nLeft + 13, hb_UTF8ToStrBox( \"┬\" ), oDlg:cColor )\n hb_DispOutAtBox( oDlg:nBottom, oDlg:nLeft + 13, hb_UTF8ToStrBox( \"┴\" ), oDlg:cColor )\n\n oBrw:ForceStable()\n ShowTopic( oDlg, aTopics, oBrw:Cargo, 0 ) \n\n RETURN\n\nSTATIC PROCEDURE ProcessKey( nKey, oDlg, oBrw, aTopics )\n\n LOCAL n\n LOCAL nSkip\n\n SWITCH nKey\n CASE K_UP\n\n IF oBrw:Cargo > 1\n oBrw:Up()\n oBrw:ForceStable()\n ShowTopic( oDlg, aTopics, oBrw:Cargo, 0 ) \n ENDIF\n EXIT\n\n CASE K_DOWN\n\n IF oBrw:Cargo < Len( aTopics )\n oBrw:Down()\n oBrw:ForceStable()\n ShowTopic( oDlg, aTopics, oBrw:Cargo, 0 ) \n ENDIF\n EXIT\n\n CASE K_HOME\n\n IF oBrw:Cargo > 1\n oBrw:GoTop()\n oBrw:ForceStable()\n ShowTopic( oDlg, aTopics, oBrw:Cargo, 0 ) \n ENDIF\n EXIT\n\n CASE K_END\n\n IF oBrw:Cargo < Len( aTopics )\n oBrw:GoBottom()\n oBrw:ForceStable()\n ShowTopic( oDlg, aTopics, oBrw:Cargo, 0 ) \n ENDIF\n EXIT\n\n CASE K_PGUP\n CASE K_CTRL_B\n\n ShowTopic( oDlg, aTopics, oBrw:Cargo, -1 ) \n EXIT\n\n CASE K_PGDN\n CASE K_SPACE\n\n ShowTopic( oDlg, aTopics, oBrw:Cargo, 1 ) \n EXIT\n\n CASE K_LBUTTONDOWN\n\n IF ( nSkip := MRow() - oDlg:nTop - oBrw:RowPos ) != 0\n IF nSkip > 0\n FOR n := 1 TO nSkip\n oBrw:Down()\n oBrw:Stabilize()\n NEXT\n ELSE\n FOR n := 1 TO nSkip + 2 STEP -1\n oBrw:Up()\n oBrw:Stabilize()\n NEXT\n ENDIF\n oBrw:ForceStable()\n ShowTopic( oDlg, aTopics, oBrw:Cargo, 0 ) \n ENDIF\n EXIT\n\n ENDSWITCH\n\n RETURN\n\nSTATIC PROCEDURE ShowTopic( oDlg, aTopics, nTopic, nPageOp )\n\n LOCAL oDebug := __dbg()\n LOCAL nRows := oDlg:nBottom - oDlg:nTop - 1\n LOCAL nPages\n LOCAL nRowsToPaint\n LOCAL n\n\n IF nTopic > Len( aTopics )\n nTopic := 1\n ENDIF\n\n nPages := Int( ( Len( aTopics[ nTopic ][ 2 ] ) + nRows - 1 ) / nRows )\n\n IF nPages <= 1\n IF nPageOp == -1 .OR. nPageOp == 1\n RETURN\n ENDIF\n oDebug:nHelpPage := 1\n ELSE\n SWITCH nPageOp\n CASE 0 \n\n oDebug:nHelpPage := 1\n EXIT\n\n CASE 1 \n\n IF oDebug:nHelpPage < nPages\n oDebug:nHelpPage++\n ELSE\n RETURN\n ENDIF\n EXIT\n\n CASE -1 \n\n IF oDebug:nHelpPage > 1\n oDebug:nHelpPage--\n ELSE\n RETURN\n ENDIF\n EXIT\n\n ENDSWITCH\n ENDIF\n\n hb_Scroll( oDlg:nTop + 1, oDlg:nLeft + 14, oDlg:nBottom - 1, oDlg:nRight - 1,,, oDlg:cColor )\n\n nRowsToPaint := Min( nRows, Len( aTopics[ nTopic ][ 2 ] ) - ( ( oDebug:nHelpPage - 1 )\n hb_DispOutAt( oDlg:nBottom, oDlg:nRight - 16, \" Page \" + Str( oDebug:nHelpPage, 1 ) + \" of \" + Str( nPages, 1 ) + \" \", oDlg:cColor )\n\n RETURN\n\nSTATIC FUNCTION GetTopics()\n\n LOCAL aTopics := {}\n LOCAL cLine\n\n FOR EACH cLine IN hb_ATokens( help_en(), .T. )\n IF hb_LeftEq( cLine, \"--\" )\n AAdd( aTopics, { PadR( SubStr( cLine, Len( \"--\" ) + 1 ), 12 ), {} } )\n ELSEIF ! Empty( aTopics ) .AND. ;\n ( ! Empty( cLine ) .OR. ! cLine:__enumIsLast() ) \n AAdd( ATail( aTopics )[ 2 ], cLine )\n ENDIF\n NEXT\n\n RETURN aTopics\n\nSTATIC FUNCTION help_en()\n #pragma __streaminclude \"en.txt\" | RETURN %s"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/dirrec.prg. Provides functions: DirectoryRecurse. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"directry.ch\"\n\nFUNCTION DirectoryRecurse( cPath, cAttr )\n\n LOCAL aResult\n LOCAL cFilePath, cExt, cMask\n\n hb_FNameSplit( cPath, @cFilePath, @cMask, @cExt )\n cMask += cExt\n hb_default( @cAttr, \"\" )\n \n aResult := hb_DirScan( cFilePath, cMask, ;\n StrTran( Upper( cAttr ), \"D\" ) )\n\n AEval( aResult, {| x | x[ F_NAME ] := cFilePath + x[ F_NAME ] } )\n\n RETURN aResult"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/tests/prn1.prg. Contains procedures: Main, PrnTest, PrintBitmap. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"hbwin\"\n\nPROCEDURE Main( cPar1 )\n\n LOCAL nPrn := 1\n LOCAL cBMPFile := Space( 40 )\n LOCAL GetList := {}\n\n LOCAL aPrn := win_printerList()\n\n IF Empty( aPrn )\n Alert( \"No printers installed - Cannot continue\" )\n ELSE\n DO WHILE nPrn != 0\n CLS\n @ 0, 0 SAY \"win_Prn() Class test program. Choose a printer to test\"\n @ 1, 0 SAY \"Bitmap file name:\" GET cBMPFile PICT \"@K\"\n READ\n @ 2, 0 TO MaxRow(), MaxCol()\n nPrn := AChoice( 3, 1, MaxRow() - 1, MaxCol() - 1, aPrn, .T.,, nPrn )\n IF nPrn != 0\n PrnTest( aPrn[ nPrn ], cBMPFile, iif( HB_ISSTRING( cPar1 ) .AND. Lower( cPar1 ) == \"ask\", .T., NIL ) )\n ENDIF\n ENDDO\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE PrnTest( cPrinter, cBMPFile, lAsk )\n\n LOCAL oPrinter := win_Prn():New( cPrinter )\n LOCAL aFonts\n LOCAL x\n LOCAL nColFixed\n LOCAL nColTTF\n LOCAL nColCharSet\n\n oPrinter:Landscape := .F.\n oPrinter:FormType := WIN_DMPAPER_A4\n oPrinter:Copies := 1\n IF HB_ISLOGICAL( lAsk )\n oPrinter:AskProperties := lAsk\n ENDIF\n\n IF ! oPrinter:Create()\n Alert( \"Cannot Create Printer\" )\n ELSE\n IF ! oPrinter:startDoc( \"win_Prn(Doc name in Printer Properties)\" )\n Alert( \"StartDoc() failed\" )\n ELSE\n oPrinter:SetPen( WIN_PS_SOLID, 1, HB_WIN_RGB_RED )\n oPrinter:Bold( WIN_FW_EXTRABOLD )\n oPrinter:TextOut( oPrinter:PrinterName + \": MaxRow() = \" + hb_ntos( oPrinter:MaxRow() ) + \" MaxCol() = \" + hb_ntos( oPrinter:MaxCol() ) )\n oPrinter:Bold( WIN_FW_DONTCARE )\n oPrinter:NewLine()\n oPrinter:TextOut( \" Partial list of available fonts that are available for OEM_\" )\n oPrinter:NewLine()\n oPrinter:UnderLine( .T. )\n oPrinter:Italic( .T. )\n\n nColFixed := 40\n oPrinter:TextOut( \"FontName\" )\n oPrinter:SetPos( nColFixed )\n oPrinter:TextOut( \"Fixed?\" )\n oPrinter:SetPos( nColTTF )\n oPrinter:TextOut( \"TrueType?\" )\n oPrinter:SetPos( nColCharset )\n oPrinter:TextOut( \"CharSet#\", .T. )\n oPrinter:NewLine()\n oPrinter:Italic( .F. )\n oPrinter:UnderLine( .F. )\n aFonts := oPrinter:GetFonts()\n oPrinter:NewLine()\n FOR x := 1 TO Len( aFonts ) STEP 2\n oPrinter:CharSet( aFonts[ x, 4 ] )\n IF oPrinter:SetFont( aFonts[ x, 1 ] ) \n IF oPrinter:FontName == aFonts[ x, 1 ] \n oPrinter:TextOut( aFonts[ x, 1 ] )\n oPrinter:SetPos( nColFixed )\n oPrinter:TextOut( iif( aFonts[ x, 2 ], \"Yes\", \"No\" ) )\n oPrinter:SetPos( nColTTF )\n oPrinter:TextOut( iif( aFonts[ x, 3 ], \"Yes\", \"No\" ) )\n oPrinter:SetPos( nColCharSet )\n oPrinter:TextOut( hb_ntos( aFonts[ x, 4 ] ) )\n oPrinter:SetPos( oPrinter:LeftMargin, oPrinter:PosY + ( oPrinter:CharHeight\n oPrinter:SetFont( \"Lucida Console\", 8, { 3, -50 } ) \n oPrinter:CharSet( 0 ) \n oPrinter:Bold( WIN_FW_EXTRABOLD )\n oPrinter:NewLine()\n oPrinter:TextOut( \"This is on line\" + hb_ntos( oPrinter:PRow() ) + \", Printed bold, \" )\n oPrinter:TextOut( \" finishing at Column: \" )\n oPrinter:TextOut( hb_ntos( oPrinter:PCol() ) )\n oPrinter:SetPRC( oPrinter:PRow() + 3, 0 )\n oPrinter:Bold( WIN_FW_DONTCARE )\n oPrinter:TextOut( \"Notice: UNDERLINE only prints correctly if there is a blank line after\", .T. )\n oPrinter:TextOut( \" it. This is because of :LineHeight and the next line\", .T. )\n oPrinter:TextOut( \" printing over top of the underline. To avoid this happening\", .T. )\n oPrinter:TextOut( \" you can to alter :LineHeight or use a smaller font, or use :SetBkMode( WIN_TRANSPARENT )\" )\n oPrinter:NewLine()\n oPrinter:NewLine()\n oPrinter:SetFont( \"Lucida Console\", 18, 0 ) \n oPrinter:SetColor( HB_WIN_RGB_GREEN )\n oPrinter:TextOut( \"Finally some larger print\" )\n oPrinter:Box( 0, oPrinter:PosY + 100, 100, oPrinter:PosY + 200 )\n oPrinter:Arc( 200, oPrinter:PosY + 100, 300, oPrinter:PosY + 200 )\n oPrinter:Ellipse( 400, oPrinter:PosY + 100, 500, oPrinter:PosY + 200 )\n oPrinter:FillRect( 600, oPrinter:PosY + 100, 700, oPrinter:PosY + 200, HB_WIN_RGB_RED )\n\n \n PrintBitmap( oPrinter, cBMPFile )\n\n oPrinter:EndDoc()\n ENDIF\n oPrinter:Destroy()\n ENDIF\n\n RETURN\n\nSTATIC PROCEDURE PrintBitmap( oPrn, cBitFile )\n\n LOCAL oBMP\n\n IF ! Empty( cBitFile )\n IF hb_FileExists( cBitFile )\n oBMP := win_BMP():New()\n IF oBmp:loadFile( cBitFile )\n\n oBmp:Draw( oPrn, { 200, 200, 2000, 1500 } )\n ENDIF\n oBMP:Destroy()\n ELSE\n Alert( hb_StrFormat( \"%1$s not found \", cBitFile ) )\n ENDIF\n ENDIF\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/ifelse.prg. Contains procedures: Main, TestValue. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL i\n\n ? \"Testing Harbour IF ELSEIF ELSE ENDIF\"\n FOR i := 1 TO 5\n TestValue( i )\n NEXT\n\n RETURN\n\nPROCEDURE TestValue( x )\n\n IF x == 1\n ? \"x is 1\"\n\n ELSEIF x == 2\n ? \"x is 2\"\n\n ELSEIF x == 3\n ? \"x is 3\"\n\n ELSEIF x == 4\n ? \"x is 4\"\n\n ELSE\n ? \"x is not 1 or 2 or 3 or 4\"\n ENDIF\n\n ? \"Ok!\"\n\n RETURN"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement this Harbour module: Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/linked.prg. Provides functions: ft_Linked. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_Linked( cFuncs )\n\n LOCAL aFuncArray := {}, nSpace, nComma, nFEnd, lRetVal := .F.\n\n IF At( \"(\", cFuncs ) == 0\n \n Alert( \"Warning: Expected function(s) in ft_Linked(), but none were found\" )\n ELSE\n DO WHILE ( nFEnd := At( \"(\", cFuncs ) ) > 0\n \n AAdd( aFuncArray, Left( cFuncs, nFEnd ) + \")\" )\n \n cFuncs := SubStr( cFuncs, nFEnd + 1 )\n nSpace := At( \" \", cFuncs )\n nComma := At( \",\", cFuncs )\n DO WHILE ( nComma > 0 .AND. nComma < nFEnd ) .OR. ;\n ( nSpace > 0 .AND. nSpace < nFEnd )\n \n \n IF nComma > 0\n cFuncs := SubStr( cFuncs, nComma + 1 )\n ELSEIF nSpace > 0\n cFuncs := SubStr( cFuncs, nSpace + 1 )\n ENDIF\n nSpace := At( \" \", cFuncs )\n nComma := At( \",\", cFuncs )\n ENDDO\n ENDDO\n \n \n lRetVal := AScan( aFuncArray, {| element | Type( element ) == \"U\" } ) == 0\n ENDIF\n\n RETURN lRetVal"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour extra library: extras/httpsrv/uhttpd.prg. Contains procedures: Main. This file implements server functionality"}, {"role": "assistant", "content": "#require \"hbnf\"\n#require \"hbwin\"\n#require \"hbgd\"\n\n\n#define FIXED_THREADS \n\n#include \"fileio.ch\"\n#include \"inkey.ch\"\n#include \"error.ch\"\n#include \"hbmemory.ch\"\n#include \"hbgtinfo.ch\"\n\nREQUEST __HB_EXTERN__\n\n#include \"hbsocket.ch\"\n\n#if defined( HBMK_HAS_HBGD )\n\nREQUEST GDChart\nREQUEST GDImage\nREQUEST gdImageChar\n #define APP_GD_SUPPORT \"_GD\"\n #stdout \"Lib GD support enabled\"\n#else\n #define APP_GD_SUPPORT \"\"\n #stdout \"Lib GD support disabled\"\n#endif\n\n#ifdef FIXED_THREADS\n #define APP_DT_SUPPORT \"_FIXED_THREADS\"\n #stdout \"Fixed # of threads\"\n#else\n #define APP_DT_SUPPORT \"\"\n #stdout \"Dynamic # of threads\"\n#endif\n\n#define APP_NAME \"uhttpd\"\n#define APP_VER_NUM \"0.4.4\"\n#define APP_VERSION APP_VER_NUM + APP_GD_SUPPORT + APP_DT_SUPPORT\n\n\n#define START_RUNNING_THREADS 6 \n#define MAX_RUNNING_THREADS 20 \n\n#define START_SERVICE_THREADS 0 \n#define MAX_SERVICE_THREADS 3 \n\n#define LISTEN_PORT 8082 \n\n#define FILE_STOP \".uhttpd.stop\"\n#define FILE_ACCESS_LOG \"logs\" + hb_ps() + \"access.log\"\n#define FILE_ERROR_LOG \"logs\" + hb_ps() + \"error.log\"\n#define DIRECTORYINDEX_ARRAY { \"index.html\", \"index.htm\" }\n\n#define PAGE_STATUS_REFRESH 5\n#define THREAD_MAX_WAIT ( 30 ) \n#define CGI_MAX_EXEC_TIME 30 \n\n\n#define HRB_ACTIVATE_CACHE .F. \n\n#define CR_LF ( Chr( 13 ) + Chr( 10 ) )\n\n#define THREAD_GT hb_gtVersion()\n\nSTATIC s_lQuitRequest := .F.\n\nSTATIC s_hmtxQueue, s_hmtxServiceThreads, s_hmtxRunningThreads, s_hmtxLog, s_hmtxConsole, s_hmtxBusy\nSTATIC s_hmtxHRB\n\nSTATIC s_hfileLogAccess, s_hfileLogError, s_cApplicationRoot, s_cDocumentRoot, s_lIndexes, s_lConsole, s_nPort\nSTATIC s_cSessionPath\nSTATIC s_nThreads, s_nStartThreads, s_nMaxThreads\nSTATIC s_nServiceThreads, s_nStartServiceThreads, s_nMaxServiceThreads\nSTATIC s_nConnections, s_nMaxConnections, s_nTotConnections\nSTATIC s_nServiceConnections, s_nMaxServiceConnections, s_nTotServiceConnections\nSTATIC s_aRunningThreads := {}\nSTATIC s_aServiceThreads := {}\nSTATIC s_hHRBModules := { => }\nSTATIC s_aDirectoryIndex\n\nSTATIC s_hActions := { ;\n ; \n ;\n \"cgi-script\" => @Handler_CgiScript(), ;\n \"hrb-script\" => @Handler_HrbScript(), ;\n ;\n \"server-status\" => @Handler_ServerStatus() }\n\nSTATIC s_hHandlers := { ;\n \"hrb\" => \"hrb-script\", ;\n \"exe\" => \"cgi-script\", ;\n \"/serverstatus\" => \"server-status\" }\n\n\nSTATIC s_hScriptAliases := { => }\nSTATIC s_hAliases := { => }\n\nTHREAD STATIC t_cResult, t_nStatusCode, t_cErrorMsg, t_oSession\n\nMEMVAR _SERVER, _GET, _POST, _COOKIE, _SESSION, _REQUEST, _HTTP_REQUEST, _HTTP_RESPONSE, m_cPost\n\nANNOUNCE ERRORSYS\n\n\nPROCEDURE Main( ... )\n\n LOCAL nPort, hListen, hSocket, aRemote, cI, xVal\n LOCAL aThreads, nStartThreads, nMaxThreads, nStartServiceThreads\n LOCAL i, cPar, lStop\n LOCAL cGT, cApplicationRoot, cDocumentRoot, lIndexes, cConfig\n LOCAL lConsole, lScriptAliasMixedCase, aDirectoryIndex\n LOCAL nProgress := 0\n LOCAL hDefault, cLogAccess, cLogError, cSessionPath\n LOCAL cCmdPort, cCmdApplicationRoot, cCmdDocumentRoot, lCmdIndexes, nCmdStartThreads, nCmdMaxThreads\n LOCAL nConsoleRows, nConsoleCols\n LOCAL nCmdConsoleRows, nCmdConsoleCols\n\n#if defined( __HBSCRIPT__HBSHELL )\n #if defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVT\" )\n #endif\n#endif\n\n IF ! hb_mtvm()\n ? \"I need multhread support. Please, recompile me!\"\n WAIT\n ErrorLevel( 2 )\n RETURN\n ENDIF\n\n \n SysSettings()\n\n ErrorBlock( {| oError | uhttpd_DefError( oError ) } )\n\n \n lStop := .F.\n cConfig := hb_DirBase() + APP_NAME + \".ini\"\n lConsole := .T.\n nStartServiceThreads := START_SERVICE_THREADS\n\n \n cGT := hb_gtVersion()\n IF cGT == \"NUL\"\n lConsole := .F.\n ENDIF\n\n \n i := 1\n DO WHILE i <= PCount()\n\n cPar := hb_PValue( i++ )\n\n DO CASE\n CASE cPar == \"--port\" .OR. cPar == \"-p\"\n cCmdPort := hb_PValue( i++ )\n\n CASE cPar == \"--approot\" .OR. cPar == \"-a\"\n cCmdApplicationRoot := hb_PValue( i++ )\n\n CASE cPar == \"--docroot\" .OR. cPar == \"-d\"\n cCmdDocumentRoot := hb_PValue( i++ )\n\n CASE cPar == \"--indexes\" .OR. cPar == \"-i\"\n lCmdIndexes := .T.\n\n CASE cPar == \"--stop\" .OR. cPar == \"-s\"\n lStop := .T.\n\n CASE cPar == \"--config\" .OR. cPar == \"-c\"\n cConfig := hb_PValue( i++ )\n\n CASE cPar == \"--start-threads\" .OR. cPar == \"-ts\"\n nCmdStartThreads := Val( hb_PValue( i++ ) )\n\n CASE cPar == \"--max-threads\" .OR. cPar == \"-tm\"\n nCmdMaxThreads := Val( hb_PValue( i++ ) )\n\n CASE cPar == \"--console-rows\" .OR. cPar == \"-cr\"\n nCmdConsoleRows := Val( hb_PValue( i++ ) )\n\n CASE cPar == \"--console-cols\" .OR. cPar == \"-cc\"\n nCmdConsoleCols := Val( hb_PValue( i++ ) )\n\n CASE cPar == \"--help\" .OR. Lower( cPar ) == \"-h\" .OR. cPar == \"-?\"\n Help()\n RETURN\n\n OTHERWISE\n Help()\n RETURN\n ENDCASE\n ENDDO\n\n \n IF lStop\n hb_MemoWrit( FILE_STOP, \"\" )\n RETURN\n ELSE\n FErase( FILE_STOP )\n ENDIF\n\n \n hDefault := ParseIni( cConfig )\n\n \n nPort := hDefault[ \"MAIN\" ][ \"PORT\" ]\n cApplicationRoot := hDefault[ \"MAIN\" ][ \"APPLICATION_ROOT\" ]\n cDocumentRoot := hDefault[ \"MAIN\" ][ \"DOCUMENT_ROOT\" ]\n lIndexes := hDefault[ \"MAIN\" ][ \"SHOW_INDEXES\" ]\n lScriptAliasMixedCase := hDefault[ \"MAIN\" ][ \"SCRIPTALIASMIXEDCASE\" ]\n cSessionPath := hDefault[ \"MAIN\" ][ \"SESSIONPATH\" ]\n aDirectoryIndex := hDefault[ \"MAIN\" ][ \"DIRECTORYINDEX\" ]\n nConsoleRows := hDefault[ \"MAIN\" ][ \"CONSOLE-ROWS\" ]\n nConsoleCols := hDefault[ \"MAIN\" ][ \"CONSOLE-COLS\" ]\n\n cLogAccess := hDefault[ \"LOGFILES\" ][ \"ACCESS\" ]\n cLogError := hDefault[ \"LOGFILES\" ][ \"ERROR\" ]\n\n nStartThreads := hDefault[ \"THREADS\" ][ \"START_NUM\" ]\n nMaxThreads := hDefault[ \"THREADS\" ][ \"MAX_NUM\" ]\n\n \n FOR EACH xVal IN hDefault[ \"SCRIPTALIASES\" ]\n IF HB_ISSTRING( xVal )\n s_hScriptAliases[ iif( lScriptAliasMixedCase, xVal:__enumKey(), Upper( xVal:__enumKey() ) ) ] := xVal\n ENDIF\n NEXT\n\n \n FOR EACH xVal IN hDefault[ \"ALIASES\" ]\n IF HB_ISSTRING( xVal )\n s_hAliases[ xVal:__enumKey() ] := xVal\n ENDIF\n NEXT\n\n \n IF cCmdPort != NIL\n nPort := Val( cCmdPort )\n ENDIF\n\n IF cCmdApplicationRoot != NIL\n cApplicationRoot := cCmdApplicationRoot\n ENDIF\n\n IF cCmdDocumentRoot != NIL\n cDocumentRoot := cCmdDocumentRoot\n ENDIF\n\n IF lCmdIndexes != NIL\n lIndexes := lCmdIndexes\n ENDIF\n\n IF nCmdStartThreads != NIL\n nStartThreads := nCmdStartThreads\n ENDIF\n\n IF nCmdMaxThreads != NIL\n nMaxThreads := nCmdMaxThreads\n ENDIF\n\n IF nCmdConsoleRows != NIL\n nConsoleRows := nCmdConsoleRows\n ENDIF\n\n IF nCmdConsoleCols != NIL\n nConsoleCols := nCmdConsoleCols\n ENDIF\n\n \n cDocumentRoot := StrTran( cDocumentRoot, \"$(APP_DIR)\", cApplicationRoot )\n cSessionPath := StrTran( cSessionPath, \"$(APP_DIR)\", cApplicationRoot )\n cLogAccess := StrTran( cLogAccess, \"$(APP_DIR)\", cApplicationRoot )\n cLogError := StrTran( cLogError, \"$(APP_DIR)\", cApplicationRoot )\n\n \n IF nPort <= 0 .OR. nPort > 65535\n ? \"Invalid port number:\", nPort\n WAIT\n ErrorLevel( 1 )\n RETURN\n ENDIF\n\n IF HB_ISSTRING( cApplicationRoot )\n IF Empty( cApplicationRoot )\n cApplicationRoot := \".\" + hb_ps()\n ENDIF\n cI := cApplicationRoot\n IF hb_DirExists( cI )\n IF Right( cI, 1 ) == \"/\" .AND. Len( cI ) > 2 .AND. !( SubStr( cI, Len( cI ) - 2, 1 ) == \":\" )\n s_cApplicationRoot := Left( cI, Len( cI ) - 1 )\n ELSE"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Define Harbour macros and constants: Harbour contribution module 'hbnetio' (Network I/O operations): contrib/hbnetio/tests/netiot03.prg. Provides functions: reg_stream, reg_charstream, rpc_timer, rpc_charstream. Contains procedures: Main, createdb, testdb. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbnetio\"\n\n\n#define DBSERVER \"127.0.0.1\"\n#define DBPORT 2941\n#define DBPASSWD \"topsecret\"\n#define DBDIR \"data\"\n#define DBFILE \"_tst_\"\n\n#define DBNAME \"net:\" + DBSERVER + \":\" + hb_ntos( DBPORT ) + \":\" + ;\n DBPASSWD + \":\" + DBDIR + \"/\" + DBFILE\n\nREQUEST DBFCDX\n\nREQUEST hb_DirExists\nREQUEST hb_DirCreate\nREQUEST hb_DateTime\n\nPROCEDURE Main()\n\n LOCAL pSockSrv, lExists, nStream1, nStream2, nSec, xData\n\n SET EXCLUSIVE OFF\n rddSetDefault( \"DBFCDX\" )\n\n pSockSrv := netio_MTServer( DBPORT,,, .T., DBPASSWD )\n IF Empty( pSockSrv )\n ? \"Cannot start NETIO server !!!\"\n WAIT \"Press any key to exit...\"\n QUIT\n ENDIF\n\n ? \"NETIO server activated.\"\n hb_idleSleep( 0.1 )\n WAIT\n\n ?\n ? \"netio_Connect():\", netio_Connect( DBSERVER, DBPORT, , DBPASSWD )\n ?\n\n netio_ProcExec( \"QOut\", \"PROCEXEC\", \"P2\", \"P3\", \"P4\" )\n netio_FuncExec( \"QOut\", \"FUNCEXEC\", \"P2\", \"P3\", \"P4\" )\n ? \"SERVER TIME:\", netio_FuncExec( \"hb_dateTime\" )\n ?\n WAIT\n\n nStream1 := netio_OpenItemStream( \"reg_stream\" )\n ? \"NETIO_OPENITEMSTREAM:\", nStream1\n nStream2 := netio_OpenDataStream( \"reg_charstream\" )\n ? \"NETIO_OPENDATASTREAM:\", nStream2\n\n hb_idleSleep( 3 )\n ? \"NETIO_GETDATA 1:\", hb_ValToExp( netio_GetData( nStream1 ) )\n ? \"NETIO_GETDATA 2:\", hb_ValToExp( netio_GetData( nStream2 ) )\n nSec := Seconds() + 3\n WHILE Seconds() < nSec\n xData := netio_GetData( nStream1 )\n IF ! Empty( xData )\n ? hb_ValToExp( xData )\n ENDIF\n xData := netio_GetData( nStream2 )\n IF ! Empty( xData )\n ?? \"\", hb_ValToExp( xData )\n ENDIF\n ENDDO\n WAIT\n ? \"NETIO_GETDATA 1:\", hb_ValToExp( netio_GetData( nStream1 ) )\n ? \"NETIO_GETDATA 2:\", hb_ValToExp( netio_GetData( nStream2 ) )\n WAIT\n\n lExists := netio_FuncExec( \"hb_DirExists\", \"./data\" )\n ? \"Directory './data'\", iif( lExists, \"exists\", \"not exists\" )\n IF ! lExists\n ? \"Creating directory './data' ->\", ;\n iif( netio_FuncExec( \"hb_DirCreate\", \"./data\" ) == -1, \"error\", \"OK\" )\n ENDIF\n\n createdb( DBNAME )\n testdb( DBNAME )\n WAIT\n\n ?\n ? \"table exists:\", dbExists( DBNAME )\n WAIT\n\n ?\n ? \"delete table with indexes:\", dbDrop( DBNAME )\n ? \"table exists:\", dbExists( DBNAME )\n WAIT\n\n ? \"NETIO_GETDATA 1:\", hb_ValToExp( netio_GetData( nStream1 ) )\n ? \"NETIO_GETDATA 2:\", hb_ValToExp( netio_GetData( nStream2 ) )\n ? \"netio_Disconnect():\", netio_Disconnect( DBSERVER, DBPORT )\n ? \"NETIO_CLOSESTREAM 1:\", netio_CloseStream( nStream1 )\n ? \"NETIO_CLOSESTREAM 2:\", netio_CloseStream( nStream2 )\n hb_idleSleep( 2 )\n ?\n ? \"stopping the server...\"\n netio_ServerStop( pSockSrv, .T. )\n\n RETURN\n\nPROCEDURE createdb( cName )\n\n LOCAL n\n\n dbCreate( cName, { ;\n { \"F1\", \"C\", 20, 0 }, ;\n { \"F2\", \"M\", 4, 0 }, ;\n { \"F3\", \"N\", 10, 2 }, ;\n { \"F4\", \"T\", 8, 0 } } )\n ? \"create neterr:\", NetErr(), hb_osError()\n USE ( cName )\n ? \"use neterr:\", NetErr(), hb_osError()\n WHILE LastRec() < 100\n dbAppend()\n n := RecNo() - 1\n field->F1 := Chr( n % 26 + Asc( \"A\" ) ) + \" \" + Time()\n field->F2 := field->F1\n field->F3 := n / 100\n field->F4 := hb_DateTime()\n ENDDO\n INDEX ON field->F1 TAG T1\n INDEX ON field->F3 TAG T3\n INDEX ON field->F4 TAG T4\n CLOSE\n ?\n\n RETURN\n\nPROCEDURE testdb( cName )\n\n LOCAL i, j\n\n USE ( cName )\n ? \"used:\", Used()\n ? \"nterr:\", NetErr()\n ? \"alias:\", Alias()\n ? \"lastrec:\", LastRec()\n ? \"ordCount:\", ordCount()\n FOR i := 1 TO ordCount()\n ordSetFocus( i )\n ? i, \"name:\", ordName(), \"key:\", ordKey(), \"keycount:\", ordKeyCount()\n NEXT\n ordSetFocus( 1 )\n dbGoTop()\n WHILE ! Eof()\n IF ! field->F1 == field->F2\n ? \"error at record:\", RecNo()\n ? \" ! '\" + field->F1 + \"' == '\" + field->F2 + \"'\"\n ENDIF\n dbSkip()\n ENDDO\n WAIT\n i := Row()\n j := Col()\n dbGoTop()\n Browse()\n SetPos( i, j )\n CLOSE\n\n RETURN\n\nFUNCTION reg_stream( pConnSock, nStream )\n\n ? ProcName(), nStream\n hb_threadDetach( hb_threadStart( @rpc_timer(), pConnSock, nStream ) )\n\n RETURN nStream\n\nFUNCTION reg_charstream( pConnSock, nStream )\n\n ? ProcName(), nStream\n hb_threadDetach( hb_threadStart( @rpc_charstream(), pConnSock, nStream ) )\n\n RETURN nStream\n\nSTATIC FUNCTION rpc_timer( pConnSock, nStream )\n\n WHILE .T.\n IF ! netio_SrvSendItem( pConnSock, nStream, Time() )\n ? \"CLOSED STREAM:\", nStream\n EXIT\n ENDIF\n hb_idleSleep( 1 )\n ENDDO\n\n RETURN NIL\n\nSTATIC FUNCTION rpc_charstream( pConnSock, nStream )\n\n LOCAL n := 0\n\n WHILE .T.\n IF ! netio_SrvSendData( pConnSock, nStream, Chr( Asc( \"A\" ) + n ) )\n ? \"CLOSED STREAM:\", nStream\n EXIT\n ENDIF\n n := Int( ( n + 1 ) % 26 )\n hb_idleSleep( 0.1 )\n ENDDO\n\n RETURN NIL"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour test program: tests/speedtst.prg. Provides functions: spd_logfile. Contains procedures: spd_out. This test file benchmarks performance characteristics"}, {"role": "assistant", "content": "#define N_TESTS 56\n#define N_LOOPS 1000000\n#define ARR_LEN 16\n\n#ifndef __HARBOUR__\n #ifndef __XPP__\n #ifndef __CLIP__\n #ifndef FlagShip\n #define __CLIPPER__\n #endif\n #endif\n #endif\n#endif\n\n\n#ifdef __CLIPPER__\n \n #ifndef __ST__\n #define __ST__\n #endif\n \n #xtranslate hb_secondsCPU([]) => seconds()\n#endif\n\n#ifdef FlagShip\n #define __NO_OBJ_ARRAY__\n \n #ifndef __ST__\n #define __ST__\n #endif\n #xtranslate hb_secondsCPU([]) => secondsCPU()\n \n #xtranslate seconds() => fs_seconds()\n#endif\n\n#ifdef __XPP__\n #define __NO_OBJ_ARRAY__\n \n #xtranslate hb_secondsCPU([]) => seconds()\n#endif\n\n#ifdef __CLIP__\n #define __NO_OBJ_ARRAY__\n \n #ifndef __ST__\n #define __ST__\n #endif\n #xtranslate hb_secondsCPU([]) => secondsCPU()\n#endif\n\n#ifdef __XHARBOUR__\n \n #ifndef __ST__\n #ifndef __MT__\n #ifndef MT\n #ifndef HB_THREAD_SUPPORT\n #define __ST__\n #endif\n #endif\n #endif\n #endif\n #xtranslate hb_secondsCPU([]) => secondsCPU()\n#endif\n\n\n#ifndef __MT__\n #ifndef __ST__\n #define __MT__\n #endif\n#endif\n\n\n#command ? => spd_out()\n#command ? => spd_out();spd_out()\n#command ?? => spd_out()\n\n#ifdef __HARBOUR__\n #ifdef __XHARBOUR__\n #define EOL hb_osNewLine()\n #else\n #define EOL hb_eol()\n #endif\n#else\n #ifndef EOL\n #define EOL chr(10)\n #endif\n#endif\n\n#xcommand TEST ;\n [ WITH ] ;\n [ STATIC ] ;\n [ FIELD ] ;\n [ MEMVAR ] ;\n [ PRIVATE ] ;\n [ PUBLIC ] ;\n [ INIT ] ;\n [ EXIT ] ;\n [ INFO ] ;\n CODE [ ] => ;\n func ; ;\n local time, i:=nil, x:=nil ; ;\n [ local ; ] ;\n [ static ; ] ;\n [ field ; ] ;\n [ memvar ; ] ;\n [ private ; ] ;\n [ public ; ] ;\n [ ; ] ;\n time := hb_secondsCPU() ; ;\n for i:=1 to N_LOOPS ; ;\n [ ( ) ; ] ;\n next ; ;\n time := hb_secondsCPU() - time ; ;\n [ ; ] ;\n return { procname() + \": \" + iif( <.info.>, <(info)>, # ), time }\n\nSTATIC s_lStdOut := .F.\n\n#ifdef __HARBOUR__\n#ifndef __XHARBOUR__\n#include \"hbver.ch\"\n#endif\n#endif\n\n#ifdef __HARBOUR__\nproc main( ... )\n local aParams := hb_aparams()\n#else\nproc main( _p01, _p02, _p03, _p04, _p05, _p06, _p07, _p08, _p09, _p10, ;\n _p11, _p12, _p13, _p14, _p15, _p16, _p17, _p18, _p19, _p20 )\n local aParams := ;\n asize( { _p01, _p02, _p03, _p04, _p05, _p06, _p07, _p08, _p09, _p10, ;\n _p11, _p12, _p13, _p14, _p15, _p16, _p17, _p18, _p19, _p20 }, ;\n min( pCount(), 20 ) )\n#endif\n local nMT, cExclude, lScale, cParam, cMemTests, lSyntax, i, j\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n lSyntax := lScale := .f.\n cMemTests := \"030 031 023 025 027 041 042 044 053 054 019 022 032 033 055 056 \"\n cExclude := \"\"\n nMT := 0\n for j := 1 to len( aParams )\n cParam := lower( aParams[ j ] )\n if cParam = \"--thread\"\n if substr( cParam, 9, 1 ) == \"=\"\n if isdigit( substr( cParam, 10, 1 ) )\n nMT := val( substr( cParam, 10 ) )\n elseif substr( cParam, 10 ) == \"all\"\n nMT := -1\n else\n lSyntax := .t.\n endif\n elseif empty( substr( cParam, 9 ) )\n nMT := -1\n else\n lSyntax := .t.\n endif\n elseif cParam = \"--exclude=\"\n if substr( cParam, 11 ) == \"mem\"\n cExclude += cMemTests\n else\n cExclude += strtran( strtran( strtran( substr( cParam, 11 ), ;\n \".\", \" \" ), \".\", \" \" ), \"/\", \" \" ) + \" \"\n endif\n elseif cParam = \"--only=\"\n cExclude := \"\"\n if substr( cParam, 8 ) == \"mem\"\n cParam := cMemTests\n endif\n for i := 1 to N_TESTS\n if ! strzero( i, 3 ) $ cParam\n cExclude += strzero( i, 3 ) + \" \"\n endif\n next\n elseif cParam == \"--scale\"\n lScale := .t.\n elseif cParam == \"--stdout\"\n s_lStdOut := .t.\n else\n lSyntax := .t.\n endif\n if lSyntax\n ? \"Unknown option:\", cParam\n ? \"syntax: speedtst [--thread[=]] [--only=] [--exclude=]\"\n ?\n return\n endif\n next\n\n IF ! s_lStdOut\n set alternate to ( spd_logfile() ) additive\n set alternate on\n ENDIF\n \n\n test( nMT, cExclude, lScale )\n\n IF ! s_lStdOut\n set alternate off\n set alternate to\n ENDIF\n\nreturn\n\nSTATIC PROCEDURE spd_out( p1, p2, p3, p4, p5, p6 )\n LOCAL nPCount := PCount()\n\n IF s_lStdOut\n DO CASE\n CASE nPCount == 0 ; OutStd( EOL )\n CASE nPCount == 1 ; OutStd( p1 )\n CASE nPCount == 2 ; OutStd( p1, p2 )\n CASE nPCount == 3 ; OutStd( p1, p2, p3 )\n CASE nPCount == 4 ; OutStd( p1, p2, p3, p4 )\n CASE nPCount == 5 ; OutStd( p1, p2, p3, p4, p5 )\n CASE nPCount == 6 ; OutStd( p1, p2, p3, p4, p5, p6 )\n ENDCASE\n ELSE\n DO CASE\n CASE nPCount == 0 ; QOut()\n CASE nPCount == 1 ; QQOut( p1 )\n CASE nPCount == 2 ; QQOut( p1, p2 )\n CASE nPCount == 3 ; QQOut( p1, p2, p3 )\n CASE nPCount == 4 ; QQOut( p1, p2, p3, p4 )\n CASE nPCount == 5 ; QQOut( p1, p2, p3, p4, p5 )\n CASE nPCount == 6 ; QQOut( p1, p2, p3, p4, p5, p6 )\n ENDCASE\n ENDIF\n RETURN\n\nSTATIC FUNCTION spd_logfile()\n#ifndef __HARBOUR__\n RETURN \"speedtst.txt\"\n#else\n LOCAL cName\n hb_FNameSplit( hb_ArgV( 0 ),, @cName )\n RETURN hb_FNameMerge( , cName, \".txt\" )\n#endif\n\n\nTEST t000 INFO \"empty loop overhead\" CODE\n\nTEST t001 WITH L_C:=dtos(date()) CODE x := L_C\n\nTEST t002 WITH L_N:=112345.67 CODE x := L_N\n\nTEST t003 WITH L_D:=date() CODE x := L_D\n\nTEST t004 STATIC s_once := NIL, S_C ;\n INIT hb_threadOnce( @s_once, {|| S_C := dtos( date() ) } ) ;\n CODE x := S_C\n\nTEST t005 STATIC s_once := NIL, S_N ;\n INIT hb_threadOnce( @s_once, {|| S_N := 112345.67 } ) ;\n CODE x := S_N\n\nTEST t006 STATIC s_once := NIL, S_D ;\n INIT hb_threadOnce( @s_once, {|| S_D := date() } ) ;\n CODE x := S_D\n\nTEST t007 MEMVAR M_C ;\n PRIVATE M_C := dtos( date() ) ;\n CODE x := M->M_C\n\nTEST t008 MEMVAR M_N ;\n PRIVATE M_N := 112345.67 ;\n CODE x := M->M_N\n\nTEST t009 MEMVAR M_D ;\n PRIVATE M_D := date() ;\n CODE x := M->M_D\n\nTEST t010 STATIC s_once := NIL ;\n MEMVAR P_C ;\n PUBLIC P_C ;\n INIT hb_threadOnce( @s_once, {|| M->P_C := dtos( date() ) } ) ;\n CODE x := M->P_C\n\nTEST t011 STATIC s_once := NIL ;\n MEMVAR P_N ;\n PUBLIC P_N ;\n INIT hb_threadOnce( @s_once, {|| M->P_N := 112345.67 } ) ;\n CODE x := M->P_N\n\nTEST t012 STATIC s_once := NIL ;\n MEMVAR P_D ;\n PUBLIC P_D ;\n INIT hb_threadOnce( @s_once, {|| M->P_D := date() } ) ;\n CODE x := M->P_D\n\nTEST t013 FIELD F_C ;\n INIT use_dbsh() EXIT close_db() ;\n CODE x := F_C\n\nTEST t014 FIELD F_N ;\n INIT use_dbsh() EXIT close_db() ;\n CODE x := F_N\n\nTEST t015 FIELD F_D ;\n INIT use_dbsh() EXIT close_db() ;\n CODE x := F_D\n\nTEST t016 WITH o := errorNew() CODE x := o:Args\n\nTEST t017 WITH o := errorArray() CODE x := o[2]\n\nTEST t018 CODE round( i / 1000, 2 )\n\nTEST t019 CODE str( i / 1000 )\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour contribution module 'hbmisc' (Miscellaneous utility functions): contrib/hbmisc/hbedit.prg. Provides 14 functions including: EditorNew, EditorCargo, EditorTitle, EditorMode, EditorSize. Contains 5 procedures. This file provides utility functions"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n#include \"setcurs.ch\"\n#include \"fileio.ch\"\n#include \"box.ch\"\n\n#define EDIT_LOWER 0 \n#define EDIT_UPPER 1 \n#define EDIT_SAME 2 \n\n#define EDIT_HARD 13 \n\n#define EDIT_EDIT .T. \n#define EDIT_VIEW .F. \n\n\n#define E_EDIT 1 \n#define E_TOP 2 \n#define E_LEFT 3\n#define E_BOTTOM 4\n#define E_RIGHT 5\n#define E_TITLE 6 \n#define E_COLOR 7 \n#define E_FRAME 8 \n#define E_LINELEN 9 \n#define E_MODE 10 \n#define E_INSERT 11 \n#define E_CARGO 12 \n#define E_STRUCT_LEN 12\n\nTHREAD STATIC t_nESize := 4096 \n\n\nFUNCTION EditorNew( nTop, nLeft, nBottom, nRight, nLength, ;\n cFrame, cTitle, cColor, nSize, nEscape )\n\n LOCAL pEdit, oEdit\n\n __defaultNIL( @nSize, t_nESize )\n hb_default( @nLength, 80 )\n\n pEdit := ed_New( nLength, 4, nSize, nEscape )\n IF ! Empty( pEdit )\n\n __defaultNIL( @cFrame, HB_B_DOUBLE_UNI )\n __defaultNIL( @cColor, \"W/N,W+/N,W+/R,GR+/N,G+/N\" )\n\n oEdit := Array( E_STRUCT_LEN )\n oEdit[ E_EDIT ] := pEdit\n oEdit[ E_TOP ] := nTop\n oEdit[ E_LEFT ] := nLeft\n oEdit[ E_BOTTOM ] := nBottom\n oEdit[ E_RIGHT ] := nRight\n oEdit[ E_LINELEN ] := nLength\n oEdit[ E_FRAME ] := cFrame\n oEdit[ E_TITLE ] := cTitle\n oEdit[ E_COLOR ] := cColor\n oEdit[ E_MODE ] := EDIT_VIEW\n\n ed_Config( pEdit, nTop, nLeft, nBottom, nRight, 0, 0 )\n ENDIF\n\n RETURN oEdit\n\nPROCEDURE EditorKill( oEdit )\n\n oEdit[ E_EDIT ] := NIL\n\n RETURN\n\nFUNCTION EditorCargo( oEdit, xCargo )\n\n LOCAL _xCargo := oEdit[ E_CARGO ]\n\n IF PCount() >= 2\n oEdit[ E_CARGO ] := xCargo\n ENDIF\n\n RETURN _xCargo\n\nFUNCTION EditorTitle( oEdit, cTitle )\n\n LOCAL _cTitle := oEdit[ E_TITLE ]\n\n IF HB_ISSTRING( cTitle )\n oEdit[ E_TITLE ] := cTitle\n ENDIF\n\n RETURN _cTitle\n\n\nFUNCTION EditorMode( oEdit, lMode )\n\n LOCAL _lMode := oEdit[ E_MODE ]\n\n IF HB_ISLOGICAL( lMode )\n oEdit[ E_MODE ] := lMode\n ENDIF\n\n RETURN _lMode\n\nFUNCTION EditorSize( nSize )\n\n LOCAL _nSize := t_nESize\n\n IF nSize != NIL\n t_nESize := nSize\n ENDIF\n\n RETURN _nSize\n\n\nPROCEDURE EditorAddText( oEdit, cText )\n\n ed_AddText( oEdit[ E_EDIT ], cText )\n\n RETURN\n\n\nPROCEDURE EditorSetText( oEdit, cText )\n\n ed_SetText( oEdit[ E_EDIT ], cText )\n\n RETURN\n\n\nPROCEDURE EditorInsText( oEdit, cText, nLine )\n\n IF nLine == NIL\n nLine := ed_LCount( oEdit[ E_EDIT ] )\n ENDIF\n\n ed_InsText( oEdit[ E_EDIT ], cText, nLine )\n\n RETURN\n\n\nFUNCTION EditorGetText( oEdit, nCarret )\n\n hb_default( @nCarret, EDIT_HARD )\n\n RETURN ed_GetText( oEdit[ E_EDIT ], nCarret )\n\n\nFUNCTION EditorLCount( oEdit )\n RETURN ed_LCount( oEdit[ E_EDIT ] )\n\n\nFUNCTION EditorGetLine( oEdit, nLine )\n RETURN ed_GetLine( oEdit[ E_EDIT ], nLine )\n\n\nFUNCTION EditorNextLine( oEdit )\n RETURN ed_GetNext( oEdit[ E_EDIT ] )\n\n\nFUNCTION EditorFile( xInput, cOutput, nLineLen, ;\n lConv, nEscape, lSave )\n\n LOCAL nHandle, nLen, oEdit, lSaved, lClose := .F.\n LOCAL nSize\n\n hb_default( @lSave, .T. )\n\n IF HB_ISSTRING( xInput )\n nHandle := FOpen( xInput )\n lClose := .T.\n ELSE\n nHandle := xInput\n ENDIF\n\n IF nHandle != F_ERROR\n nLen := Max( FileLength( nHandle ), t_nESize )\n ELSE\n nLen := t_nESize\n ENDIF\n\n nSize := iif( nLen < 8192, nLen\n oEdit := EditorNew( 1, 0, 23, 79, nLineLen, \"--- \", cOutput, , ;\n nSize, nEscape )\n\n IF nHandle != F_ERROR\n ed_ReadText( oEdit[ E_EDIT ], nHandle, 0, nLen, ;\n iif( lConv == NIL, .F., lConv ) )\n IF lClose\n FClose( nHandle )\n ENDIF\n ELSE\n EditorSetText( oEdit, \" \" )\n ENDIF\n\n EditorCargo( oEdit, cOutput )\n\n lSaved := EditorEdit( oEdit, EDIT_EDIT, .F. )\n EditorKill( oEdit )\n\n RETURN lSaved\n\n\nFUNCTION EditorRead( oEditor, nHandle, nOffset, nLen, lConv )\n\n RETURN ed_ReadText( oEditor[ E_EDIT ], nHandle, nOffset, nLen, ;\n iif( lConv == NIL, .T., lConv ) )\n\n\nFUNCTION EditorEdit( oEdit, lEdit, lFrame )\n\n LOCAL nRow, nCol := 0, nKey, bKey, oBox, nCursor, nState\n LOCAL nTop, nLeft, nBottom, nRight\n LOCAL lSaveAllowed, lSaved := .F.\n\n oBox := SaveBox( oEdit[ E_TOP ], oEdit[ E_LEFT ], ;\n oEdit[ E_BOTTOM ], oEdit[ E_RIGHT ], ;\n oEdit[ E_COLOR ], oEdit[ E_FRAME ] )\n\n oEdit[ E_INSERT ] := Set( _SET_INSERT )\n nCursor := SetCursor( iif( oEdit[ E_INSERT ], SC_NORMAL, SC_SPECIAL1 ) )\n IF HB_ISLOGICAL( lEdit )\n oEdit[ E_MODE ] := lEdit\n ENDIF\n lSaveAllowed := ( SetKey( K_F2 ) == NIL )\n\n nTop := oEdit[ E_TOP ] + 1\n nLeft := oEdit[ E_LEFT ] + 1\n nBottom := oEdit[ E_BOTTOM ] - 1\n nRight := oEdit[ E_RIGHT ] - 1\n IF lFrame != NIL .AND. ! lFrame\n nLeft--\n nBottom++\n nRight++\n ENDIF\n nState := oEdit[ E_RIGHT ] - 8\n\n \n ed_Config( oEdit[ E_EDIT ], nTop, nLeft, nBottom, nRight, 0, 0 )\n\n DO WHILE .T.\n nRow := ed_Stabilize( oEdit[ E_EDIT ] ) \n \n\n IF nRow != ed_Row( oEdit[ E_EDIT ] )\n nRow := ed_Row( oEdit[ E_EDIT ] )\n hb_DispOutAt( oEdit[ E_TOP ], nState, StrZero( nRow, 4 ) )\n ENDIF\n IF nCol != ed_Col( oEdit[ E_EDIT ] )\n nCol := ed_Col( oEdit[ E_EDIT ] )\n hb_DispOutAt( oEdit[ E_TOP ], nState + 5, StrZero( nCol, 3 ) )\n ENDIF\n SetPos( nTop + ed_WinRow( oEdit[ E_EDIT ] ), nLeft + ed_WinCol( oEdit[ E_EDIT ] ) )\n\n nKey := Inkey( 0 )\n\n DO CASE\n CASE !( hb_keyChar( nKey ) == \"\" )\n IF oEdit[ E_MODE ]\n ed_PutChar( oEdit[ E_EDIT ], Asc( hb_keyChar( nKey ) ), oEdit[ E_INSERT ] )\n ENDIF\n\n CASE nKey == K_F2 .AND. lSaveAllowed\n lSaved := EditorSave( oEdit ) \n\n CASE EditorMove( oEdit[ E_EDIT ], nKey )\n\n CASE nKey == K_DOWN\n IF ! ed_Down( oEdit[ E_EDIT ] )\n hb_Scroll( nTop, nLeft, nBottom, nRight, 1 )\n ENDIF\n\n CASE nKey == K_UP\n IF ! ed_Up( oEdit[ E_EDIT ] )\n hb_Scroll( nTop, nLeft, nBottom, nRight, -1 )\n ENDIF\n\n CASE nKey == K_ESC\n EXIT\n\n OTHERWISE\n bKey := SetKey( nKey )\n IF HB_ISBLOCK( bKey )\n Eval( bKey, oEdit )\n ELSE\n IF oEdit[ E_MODE ]\n EditorKeys( oEdit, nKey )\n ENDIF\n ENDIF\n ENDCASE\n ENDDO\n\n SetCursor( nCursor )\n RestBox( oBox )\n\n RETURN lSaved\n\n\nSTATIC PROCEDURE EditorKeys( oEdit, nKey )\n\n LOCAL i\n\n DO CASE\n CASE nKey == K_CTRL_Y\n ed_DelLine( oEdit[ E_EDIT ] )\n\n CASE nKey == K_CTRL_T\n ed_DelWord( oEdit[ E_EDIT ] )\n\n CASE nKey == K_DEL\n ed_DelChar( oEdit[ E_EDIT ] )\n\n CASE nKey == K_BS\n ed_BSpace( oEdit[ E_EDIT ], oEdit[ E_INSERT ] )\n\n CASE nKey == K_ENTER\n ed_Return( oEdit[ E_EDIT ], oEdit[ E_INSERT ] )\n\n CASE nKey == K_TAB\n FOR i := 1 TO 4\n ed_PutChar( oEdit[ E_EDIT ], Asc( \" \" ), oEdit[ E_INSERT ] )\n NEXT\n\n CASE nKey == K_INS\n oEdit[ E_INSERT ] := ! oEdit[ E_INSERT ]\n Set( _SET_INSERT, oEdit[ E_INSERT ] )\n SetCursor( iif( oEdit[ E_INSERT ], SC_NORMAL, SC_SPECIAL1 ) )\n\n ENDCASE\n\n RETURN\n\nSTATIC FUNCTION EditorMove( pEdit, nKey )\n\n LOCAL lMoved := .T.\n\n DO CASE\n CASE nKey == K_PGDN ; ed_PgDown( pEdit )\n CASE nKey == K_PGUP ; ed_PgUp( pEdit )\n CASE nKey == K_CTRL_PGUP ; ed_Top( pEdit )\n CASE nKey == K_CTRL_PGDN ; ed_Bottom( pEdit )\n CASE nKey == K_RIGHT ; ed_Right( pEdit )\n CASE nKey == K_LEFT ; ed_Left( pEdit )\n CASE nKey == K_HOME ; ed_Home( pEdit )\n CASE nKey == K_CTRL_HOME ; ed_Home( pEdit )\n CASE nKey == K_END ; ed_End( pEdit )\n CASE nKey == K_CTRL_END ; ed_End( pEdit )\n CASE nKey == K_CTRL_RIGHT \n CASE nKey == K_CTRL_LEFT ; ed_PWord( pEdit )\n OTHERWISE ; lMoved := .F.\n ENDCASE\n\n RETURN lMoved\n\nSTATIC FUNCTION EditorSave( oEdit )\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbtpathy' (Telepath communication library): contrib/hbtpathy/telepath.prg. Provides 17 functions including: tp_baud, tp_inkey, tp_close, tp_reopen, tp_open. Contains procedures: tp_delay, tp_clearin, tp_clrkbd. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"telepath.ch\"\n\n#include \"hbcom.ch\"\n\n#define TPFP_NAME 1 \n#define TPFP_HANDLE 2\n#define TPFP_BAUD 3\n#define TPFP_DBITS 4\n#define TPFP_PARITY 5\n#define TPFP_SBITS 6\n#define TPFP_OC 7 \n#define TPFP_INBUF 8\n#define TPFP_INBUF_SIZE 9 \n\nTHREAD STATIC t_aPorts \nTHREAD STATIC t_nErrorCode := 0 \n\nFUNCTION tp_baud( nPort, nNewBaud )\n\n hb_default( @nNewBaud, 0 )\n\n IF ! isport( nPort ) .OR. Empty( t_aPorts[ nPort, TPFP_NAME ] )\n RETURN TE_NOPORT\n ENDIF\n\n IF ! isopenport( nPort )\n RETURN 0\n ENDIF\n\n IF nNewBaud > 0\n IF hb_comInit( t_aPorts[ nPort, TPFP_HANDLE ], nNewBaud, t_aPorts[ nPort, TPFP_PARITY ], t_aPorts[ nPort, TPFP_DBITS ], t_aPorts[ nPort, TPFP_SBITS ] )\n t_aPorts[ nPort, TPFP_BAUD ] := nNewBaud\n ELSE\n \n ENDIF\n ENDIF\n\n RETURN t_aPorts[ nPort, TPFP_BAUD ]\n\n\nFUNCTION tp_inkey( ... )\n RETURN Inkey( ... )\n\nPROCEDURE tp_delay( nTime )\n\n hb_default( @nTime, 0 )\n\n IF nTime < 0\n RETURN\n ELSEIF nTime > 1800\n nTime := 1800\n ENDIF\n\n hb_idleSleep( nTime )\n\n RETURN\n\nFUNCTION tp_close( nPort, nTimeout )\n\n hb_default( @nTimeout, 0 )\n\n \n IF ! isopenport( nPort )\n RETURN 0\n ENDIF\n\n IF nTimeout > 0\n tp_flush( nPort, nTimeout )\n ENDIF\n\n IF t_aPorts[ nPort, TPFP_HANDLE ] >= 0\n\n hb_comClose( t_aPorts[ nPort, TPFP_HANDLE ] )\n\n \n t_aPorts[ nPort, TPFP_OC ] := .F.\n t_aPorts[ nPort, TPFP_INBUF ] := \"\"\n t_aPorts[ nPort, TPFP_HANDLE ] := -1\n ENDIF\n\n RETURN 0\n\nFUNCTION tp_reopen( nPort, nInSize, nOutSize )\n\n LOCAL nBaud, nData, cParity, nStop, cPortName\n\n IF ! isport( nPort ) .OR. Empty( t_aPorts[ nPort, TPFP_NAME ] )\n RETURN TE_NOPORT\n ENDIF\n\n cPortname := t_aPorts[ nPort, TPFP_NAME ]\n nBaud := t_aPorts[ nPort, TPFP_BAUD ]\n nData := t_aPorts[ nPort, TPFP_DBITS ]\n cParity := t_aPorts[ nPort, TPFP_PARITY ]\n nStop := t_aPorts[ nPort, TPFP_SBITS ]\n\n RETURN tp_open( nPort, nInSize, nOutSize, nBaud, nData, cParity, nStop, cPortName )\n\nFUNCTION tp_open( nPort, nInSize, nOutSize, nBaud, nData, cParity, nStop, cPortname )\n\n IF ! isport( nPort )\n RETURN TE_NOPORT\n ENDIF\n\n hb_default( @nInSize, 1536 )\n hb_default( @nOutSize, 1536 )\n hb_default( @nBaud, 1200 )\n hb_default( @nData, 8 )\n hb_default( @cParity, \"N\" )\n hb_default( @nStop, 1 )\n\n IF HB_ISSTRING( cPortname )\n hb_comSetDevice( nPort, cPortname )\n ENDIF\n\n t_aPorts[ nPort, TPFP_NAME ] := cPortname\n t_aPorts[ nPort, TPFP_BAUD ] := nBaud\n t_aPorts[ nPort, TPFP_DBITS ] := nData\n t_aPorts[ nPort, TPFP_PARITY ] := cParity\n t_aPorts[ nPort, TPFP_SBITS ] := nStop\n t_aPorts[ nPort, TPFP_OC ] := .F.\n t_aPorts[ nPort, TPFP_INBUF ] := \"\"\n t_aPorts[ nPort, TPFP_INBUF_SIZE ] := nInSize\n t_aPorts[ nPort, TPFP_HANDLE ] := -1\n\n IF hb_comOpen( nPort )\n\n t_aPorts[ nPort, TPFP_HANDLE ] := nPort\n\n IF hb_comInit( t_aPorts[ nPort, TPFP_HANDLE ], t_aPorts[ nPort, TPFP_BAUD ], t_aPorts[ nPort, TPFP_PARITY ], t_aPorts[ nPort, TPFP_DBITS ], t_aPorts[ nPort, TPFP_SBITS ] )\n t_aPorts[ nPort, TPFP_OC ] := .T.\n RETURN 0\n ELSE\n tp_close( t_aPorts[ nPort, TPFP_HANDLE ] )\n RETURN TE_PARAM\n ENDIF\n ENDIF\n\n t_aPorts[ nPort, TPFP_NAME ] := \"\"\n t_aPorts[ nPort, TPFP_HANDLE ] := -1\n t_aPorts[ nPort, TPFP_BAUD ] := 1200\n t_aPorts[ nPort, TPFP_DBITS ] := 8\n t_aPorts[ nPort, TPFP_PARITY ] := \"N\"\n t_aPorts[ nPort, TPFP_SBITS ] := 1\n t_aPorts[ nPort, TPFP_OC ] := .F.\n t_aPorts[ nPort, TPFP_INBUF ] := \"\"\n t_aPorts[ nPort, TPFP_INBUF_SIZE ] := 0\n\n RETURN TE_CONFL \n\nFUNCTION tp_recv( nPort, nLength, nTimeout )\n\n LOCAL nDone\n LOCAL cRet\n\n IF ! HB_ISNUMERIC( nLength )\n nLength := t_aPorts[ nPort, TPFP_INBUF_SIZE ]\n ENDIF\n hb_default( @nTimeout, 0 )\n\n FetchChars( nPort )\n\n nDone := Seconds() + iif( nTimeout >= 0, nTimeout, 0 )\n\n DO WHILE Len( t_aPorts[ nPort, TPFP_INBUF ] ) < nLength .AND. ;\n ( nTimeout < 0 .OR. Seconds() < nDone )\n\n IF ! tp_idle()\n FetchChars( nPort )\n ELSE\n EXIT\n ENDIF\n ENDDO\n\n IF nLength > Len( t_aPorts[ nPort, TPFP_INBUF ] )\n cRet := t_aPorts[ nPort, TPFP_INBUF ]\n t_aPorts[ nPort, TPFP_INBUF ] := \"\"\n ELSE\n cRet := SubStr( t_aPorts[ nPort, TPFP_INBUF ], 1, nLength )\n t_aPorts[ nPort, TPFP_INBUF ] := SubStr( t_aPorts[ nPort, TPFP_INBUF ], nLength + 1 )\n ENDIF\n\n RETURN cRet\n\nFUNCTION tp_send( nPort, cString, nTimeout )\n\n hb_default( @cString, \"\" )\n hb_default( @nTimeout, 0 )\n\n IF ! isopenport( nPort )\n RETURN 0\n ENDIF\n IF Len( cString ) == 0\n RETURN 0\n ENDIF\n\n RETURN hb_comSend( t_aPorts[ nPort, TPFP_HANDLE ], cString,, nTimeout )\n\n\nFUNCTION tp_sendsub( nPort, cString, nStart, nLength, nTimeout )\n\n hb_default( @nStart, 1 )\n IF ! HB_ISNUMERIC( nLength )\n nLength := Len( cString )\n ENDIF\n\n RETURN tp_send( nPort, SubStr( cString, nStart, nLength ), nTimeout )\n\n\nFUNCTION tp_recvto( nPort, cDelim, nMaxlen, nTimeout )\n\n LOCAL cChar\n LOCAL nAt\n LOCAL nStartPos := 1, nFirst := 0\n LOCAL nDone, cRet := \"\"\n\n IF ! isopenport( nPort )\n RETURN \"\"\n ENDIF\n\n IF ! HB_ISSTRING( cDelim ) .OR. Len( cDelim ) == 0\n RETURN \"\"\n ENDIF\n\n hb_default( @nMaxLen, 64999 ) \n hb_default( @nTimeout, 0 )\n\n FetchChars( nPort )\n\n \n IF nTimeout == 0 .AND. Len( t_aPorts[ nPort, TPFP_INBUF ] ) == 0\n RETURN \"\"\n ENDIF\n\n nDone := Seconds() + iif( nTimeout >= 0, nTimeout, 0 )\n\n DO WHILE ( nTimeout < 0 .OR. Seconds() < nDone )\n\n IF Len( cDelim ) == 1\n\n nAt := hb_At( cDelim, t_aPorts[ nPort, TPFP_INBUF ], nStartPos )\n\n IF nAt > 0 .AND. iif( nFirst > 0, nAt < nFirst, .T. )\n nFirst := nAt\n ENDIF\n\n ELSE\n\n FOR EACH cChar IN cDelim\n\n nAt := hb_At( cChar, t_aPorts[ nPort, TPFP_INBUF ], nStartPos )\n\n IF nAt > 0 .AND. iif( nFirst > 0, nAt < nFirst, .T. )\n nFirst := nAt\n ENDIF\n\n NEXT\n\n ENDIF\n\n \n IF nFirst > 0\n EXIT\n\n ELSE\n \n \n nStartPos := Max( Len( t_aPorts[ nPort, TPFP_INBUF ] ), 1 )\n\n \n IF nStartPos >= nMaxLen\n EXIT\n ENDIF\n\n IF ! tp_idle()\n FetchChars( nPort )\n ELSE\n EXIT\n ENDIF\n ENDIF\n\n ENDDO\n\n IF nFirst > 0\n cRet := Left( t_aPorts[ nPort, TPFP_INBUF ], nFirst )\n t_aPorts[ nPort, TPFP_INBUF ] := SubStr( t_aPorts[ nPort, TPFP_INBUF ], nFirst + 1 )\n ENDIF\n\n RETURN cRet\n\n\nFUNCTION tp_lookfor( nPort, cLookfor )\n\n IF ! isopenport( nPort )\n RETURN 0\n ENDIF\n\n FetchChars( nPort )\n\n RETURN At( cLookfor, t_aPorts[ nPort, TPFP_INBUF ] )\n\nFUNCTION tp_inchrs( nPort )\n\n IF ! isopenport( nPort )\n RETURN 0\n ENDIF\n\n FetchChars( nPort )\n\n RETURN Len( t_aPorts[ nPort, TPFP_INBUF ] )\n\nFUNCTION tp_infree( nPort )\n\n IF ! isopenport( nPort )\n RETURN 0\n ENDIF\n\n RETURN __tp_infree( t_aPorts[ nPort, TPFP_HANDLE ] )\n\nFUNCTION tp_outfree( nPort )\n\n IF ! isopenport( nPort )\n RETURN 0\n ENDIF\n\n RETURN __tp_outfree( t_aPorts[ nPort, TPFP_HANDLE ] )\n\nPROCEDURE tp_clearin( nPort )\n\n IF isopenport( nPort )\n FetchChars( nPort )\n t_aPorts[ nPort, TPFP_INBUF ] := \"\"\n ENDIF\n\n RETURN\n\nPROCEDURE tp_clrkbd()\n\n CLEAR TYPEAHEAD\n\n RETURN\n\nFUNCTION tp_crc16( cString )\n\n RETURN hb_ByteSwapW( hb_CRCCT( cString ) ) \n\nFUNCTION tp_crc32( cString )\n\n RETURN hb_CRC32( cString )\n\n\nFUNCTION tp_waitfor( ... ) \n\n LOCAL aParam := hb_AParams()\n LOCAL nPort \n\n nPort := aParam[ 1 ]\n \n \n IF ! isopenport( nPort )\n RETURN 0\n ENDIF\n\n \n RETURN 0\n\n\nFUNCTION tp_ctrlcts( nPort, nNewCtrl )\n\n LOCAL nCurValue\n LOCAL nFlag\n\n IF ! isopenport( nPort )\n RETURN 0\n ENDIF\n"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour test program: tests/lnlenli1.prg. Provides functions: LongLine1. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LongLine1()\n\n RETURN\n\nFUNCTION LongLine1()\n RETURN { ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;\n { I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ), {|| I_( \"XXXXXXXXXXXXXXXXXXXXXXXXXXX\" ) }, 99, 9 }, ;"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Create Harbour preprocessor definitions: Harbour header file: include/hbgtinfo.ch. Defines 10 constants including: HB_GTINFO_CH_, HB_GTI_ISGRAPHIC, HB_GTI_SCREENWIDTH, HB_GTI_SCREENHEIGHT, HB_GTI_SCREENDEPTH. Defines keyboard input constants"}, {"role": "assistant", "content": "#ifndef HB_GTINFO_CH_\n#define HB_GTINFO_CH_\n\n#define HB_GTI_ISGRAPHIC 0 \n#define HB_GTI_SCREENWIDTH 1 \n#define HB_GTI_SCREENHEIGHT 2 \n#define HB_GTI_SCREENDEPTH 3 \n#define HB_GTI_FONTSIZE 4 \n#define HB_GTI_FONTWIDTH 5 \n#define HB_GTI_DESKTOPWIDTH 6 \n#define HB_GTI_DESKTOPHEIGHT 7 \n#define HB_GTI_DESKTOPDEPTH 8 \n#define HB_GTI_COMPATBUFFER 9 \n#define HB_GTI_KBDSHIFTS 10 \n#define HB_GTI_KBDSPECIAL 11 \n#define HB_GTI_KBDALT 12 \n#define HB_GTI_ISSCREENPOS 13 \n#define HB_GTI_FULLSCREEN HB_GTI_ISSCREENPOS \n#define HB_GTI_KBDSUPPORT 14 \n#define HB_GTI_CLIPBOARDDATA 15 \n#define HB_GTI_CLIPBOARDPASTE 16 \n#define HB_GTI_CURSORBLINKRATE 19 \n#define HB_GTI_DESKTOPROWS 20 \n#define HB_GTI_DESKTOPCOLS 21 \n#define HB_GTI_FONTWEIGHT 22 \n#define HB_GTI_FONTQUALITY 23 \n#define HB_GTI_FONTNAME 24 \n#define HB_GTI_CODEPAGE 25 \n#define HB_GTI_WINTITLE 26 \n#define HB_GTI_ICONFILE 27 \n#define HB_GTI_ICONRES 28 \n#define HB_GTI_MOUSESTATUS 29 \n\n#define HB_GTI_INPUTFD 30 \n#define HB_GTI_OUTPUTFD 31 \n#define HB_GTI_ERRORFD 32 \n\n#define HB_GTI_ESCDELAY 33 \n\n\n#define HB_GTI_VIEWMAXHEIGHT 34 \n#define HB_GTI_VIEWMAXWIDTH 35 \n\n#define HB_GTI_VIEWPORTHEIGHT 36 \n#define HB_GTI_VIEWPORTWIDTH 37 \n\n#define HB_GTI_STDOUTCON 38 \n#define HB_GTI_STDERRCON 39 \n\n#define HB_GTI_ISCTWIN 40 \n#define HB_GTI_ISMULTIWIN 41 \n#define HB_GTI_GETWIN 42 \n#define HB_GTI_SETWIN 43 \n#define HB_GTI_NEWWIN 44 \n\n#define HB_GTI_ADDKEYMAP 45 \n#define HB_GTI_DELKEYMAP 46 \n\n#define HB_GTI_ISUNICODE 47 \n\n#define HB_GTI_SELECTCOPY 48 \n#define HB_GTI_RESIZABLE 49 \n#define HB_GTI_CLOSABLE 50 \n\n\n#define HB_GTI_NOTIFIERBLOCK 51 \n#define HB_GTI_SCREENSIZE 52 \n#define HB_GTI_PALETTE 53 \n\n#define HB_GTI_RESIZEMODE 54 \n#define HB_GTI_SETPOS_XY 55 \n#define HB_GTI_SETPOS_ROWCOL 56 \n\n#define HB_GTI_BOXCP 57 \n\n#define HB_GTI_CARGO 58 \n#define HB_GTI_FONTSEL 59 \n\n#define HB_GTI_INKEYFILTER 60 \n#define HB_GTI_INKEYREAD 61 \n\n#define HB_GTI_ALTENTER 62 \n#define HB_GTI_ISFULLSCREEN 63 \n#define HB_GTI_ONLINE 64 \n#define HB_GTI_VERSION 65 \n\n#define HB_GTI_MAXIMIZED 66 \n#define HB_GTI_FONTATTRIBUTE 67 \n#define HB_GTI_UNITRANS 68 \n#define HB_GTI_WINHANDLE 69 \n#define HB_GTI_MOUSEPOS_XY 70 \n#define HB_GTI_DISPIMAGE 71 \n#define HB_GTI_REDRAWMAX 72 \n#define HB_GTI_RESIZESTEP 73 \n#define HB_GTI_CLOSEMODE 74 \n#define HB_GTI_MINIMIZED 75 \n#define HB_GTI_QUICKEDIT 76 \n#define HB_GTI_SYSMENUADD 77 \n#define HB_GTI_MSGBOX 78 \n#define HB_GTI_SOUND 79 \n\n\n#define HB_GTI_FONTW_THIN 1\n#define HB_GTI_FONTW_NORMAL 2\n#define HB_GTI_FONTW_BOLD 3\n\n\n#define HB_GTI_FONTQ_DRAFT 1\n#define HB_GTI_FONTQ_NORMAL 2\n#define HB_GTI_FONTQ_HIGH 3\n\n\n#define HB_GTI_FONTA_FIXMETRIC 0x0001\n#define HB_GTI_FONTA_CLRBKG 0x0002\n#define HB_GTI_FONTA_DRAWBOX 0x0004\n#define HB_GTI_FONTA_CTRLCHARS 0x0008\n#define HB_GTI_FONTA_NOSTRETCH 0x0010\n\n\n#define HB_GTI_KBD_SHIFT 0x000001\n#define HB_GTI_KBD_CTRL 0x000002\n#define HB_GTI_KBD_ALT 0x000004\n#define HB_GTI_KBD_KEYPAD 0x000008\n#define HB_GTI_KBD_SCROLOCK 0x000010\n#define HB_GTI_KBD_NUMLOCK 0x000020\n#define HB_GTI_KBD_CAPSLOCK 0x000040\n#define HB_GTI_KBD_INSERT 0x000080\n#define HB_GTI_KBD_LSHIFT 0x000100\n#define HB_GTI_KBD_RSHIFT 0x000200\n#define HB_GTI_KBD_LCTRL 0x000400\n#define HB_GTI_KBD_RCTRL 0x000800\n#define HB_GTI_KBD_LALT 0x001000\n#define HB_GTI_KBD_RALT 0x002000\n#define HB_GTI_KBD_LWIN 0x004000\n#define HB_GTI_KBD_RWIN 0x008000\n#define HB_GTI_KBD_MENU 0x010000\n\n#ifdef HB_LEGACY_LEVEL4\n\n#define HB_GTE_ACTIVATE 1\n#define HB_GTE_SETFOCUS 2\n#define HB_GTE_KILLFOCUS 3\n#define HB_GTE_CLOSE 4\n#define HB_GTE_RESIZED 5\n#endif\n\n\n#define HB_GTI_RESIZEMODE_FONT 0 \n#define HB_GTI_RESIZEMODE_ROWS 1\n\n#endif"}]} {"messages": [{"role": "system", "content": "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)."}, {"role": "user", "content": "Implement the following Harbour classes: THtml. Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/thtm.prg. Defines classes: THtml. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n#include \"cgi.ch\"\n\nTHREAD STATIC t_nHtm := NIL\nTHREAD STATIC t_cForm := 0\nTHREAD STATIC t_oPage := 0\n\n\nCREATE CLASS THtml\n\n VAR nH\n VAR FName, TITLE\n VAR FontFace INIT \"Verdana\"\n VAR FontSize INIT 1\n VAR FontColor INIT \"black\"\n VAR aImages\n VAR lCgi INIT .F.\n VAR cStr Init \"\"\n VAR BaseURL, BaseTarget\n VAR lFont INIT .F.\n\n\n METHOD Newalt( cType )\n METHOD cgiNew( cTitle, cLinkTitle, cCharSet, aScriptSRC, ;\n BGIMAGE, BGCOLOR, txtColor, aJsCode, ;\n onLoad, onUnload, ;\n cLinkClr, cVLinkClr, cALinkClr, ;\n cStyle, aImages, aServerSrc, ;\n cBaseURL, cBaseTarget, ;\n nRefresh, cRefreshURL, cStyleScr, ;\n lNocache, NOF, nMarginTop, nMarginHeight, ;\n nMarginWidth, nMarginLeft, lCgi, cFile )\n METHOD New( cTitle, cLinkTitle, cCharSet, aScriptSRC, ;\n BGIMAGE, BGCOLOR, txtColor, aJsCode, ;\n onLoad, onUnload, ;\n cLinkClr, cVLinkClr, cALinkClr, ;\n cStyle, aImages, aServerSrc, ;\n cBaseURL, cBaseTarget, ;\n nRefresh, cRefreshURL, cStyleScr, ;\n lNocache, NOF, nMarginTop, nMarginHeight, ;\n nMarginWidth, nMarginLeft, lCgi, cFile )\n\n METHOD CGIClose()\n\n METHOD SetPageColor( cColor, lBody ) INLINE hb_default( @lBody, .T. ), ::cStr += iif( lBody, '', ' bgcolor=\"' + cColor + '\" ' )\n\n METHOD SetTextColor( cColor, lBody ) INLINE hb_default( @lBody, .T. ), ::cStr += iif( lBody, '', ' text=\"' + cColor + '\" ' )\n\n METHOD SetBgImage( cImage, lBody ) INLINE hb_default( @lBody, .T. ), ::cStr += iif( lBody, '', ' background=\"' + cImage + '\" ' )\n\n METHOD Close()\n\n METHOD SetCenter( lOn ) INLINE ::cStr += iif( lOn, \"
\", \"
\" )\n\n METHOD SetFont( cFont, lBold, lItalic, lULine, nSize, cColor, lSet )\n\n METHOD StartFont( cFont, lBold, lItalic, lULine, nSize, cColor, lSet, lPut )\n\n METHOD DefineFont( cFont, cType, nSize, cColor, lSet )\n\n METHOD EndFont()\n\n METHOD Say( str, font, size, type, color, style )\n\n METHOD QQOut( c ) INLINE hb_default( @c, \"\" ), ::cStr += c\n\n METHOD QOut( c ) INLINE hb_default( @c, \"\" ), ::cStr += CRLF() + c + \"
\" + CRLF()\n\n METHOD Write( c ) INLINE hb_default( @c, \"\" ), ::cStr += c\n\n METHOD WriteLN( c ) INLINE hb_default( @c, \"\" ), ::cStr += CRLF() + c + \"
\" + CRLF()\n\n METHOD SayColor( t, c ) INLINE hb_default( @t, \"\" ), hb_default( @c, \"black\" ), ;\n ::cStr += '' + t + \"\"\n\n METHOD Space( n ) INLINE hb_default( @n, 1 ), ::cStr += Replicate( \" \", n )\n\n METHOD PutImage( cImage, nBorder, nHeight, cOnclick, cOnMsOver, cOnMsOut, ;\n cName, cAlt, cTarget, nWidth, lBreak, ID, MAP, ALING, HSPACE )\n\n METHOD Text( cText, nCols, lWrap ) INLINE hb_default( @lWrap, .T. ), hb_default( @nCols, 80 ), ;\n ::cStr += \"\", \">\" ) + CRLF() + cText + CRLF() + \"\" + CRLF()\n\n METHOD MultiCol( txt, cols, gutter, width ) INLINE hb_default( @txt, \"\" ), ;\n hb_default( @cols, 2 ), ;\n hb_default( @gutter, 5 ), ;\n hb_default( @width, 100 ), ;\n ::cStr += '', ;\n ::cStr += txt, ;\n ::cStr += \"\"\n\n METHOD PutHeading( cText, nWeight, lCentered )\n\n METHOD HLine( nSize, nWidth, lShade, cColor )\n\n METHOD PutParagraph() INLINE ::cStr += \"

\" + CRLF()\n\n METHOD Paragraph( lStart, cAlign, cStyle )\n\n METHOD PutBreak() INLINE ::cStr += \"
\" + CRLF()\n\n METHOD Marquee( cText, cFont, cFntColor, nFntSize, cAlign, nWidth, nHeight, cbgColor, ;\n cBehavior, cDirection, nScrollAmt, nScrollDelay, LOOP, ;\n onMsOver, onMsOut, onClick, onStart, onFinish )\n\n METHOD StartMarquee( cFont, cFntColor, nFntSize, cAlign, nWidth, nHeight, cbgColor, ;\n cBehavior, cDirection, nScrollAmt, nScrollDelay, LOOP, ;\n onMsOver, onMsOut, onClick, onStart, onFinish )\n METHOD EndMarquee()\n\n METHOD PutTextUrl( cText, cUrl, cOnClick, cOnMsOver, cOnMsout, cTarget, font, clr, size, style, bld, lbreak, cClass )\n\n METHOD PutImageUrl( cImage, nBorder, nHeight, cUrl, ;\n cOnclick, cOnMsOver, cOnMsOut, cName, cAlt, cTarget, nWidth, lbreak, cClass, ;\n Id, hSpace, Aling )\n\n METHOD DefineTable( nCols, nBorder, nWidth, nHeight, ColorFore, ColorBG, ;\n l3d, lRuleCols, lRuleRows, cClrDark, cClrLight, cClrBorder, ;\n nCellPadding, nCellSpacing, cAling, lRules, ;\n bgImage, cStyle, Id, NOF )\n\n METHOD TableHead( cHead, cColor, cAlign, cFont, nSize, cFntColor, nHeight, cBgPic )\n\n METHOD NewTableRow( cColor, vAling, aLing )\n\n METHOD EndTableRow()\n\n METHOD NewTableCell( cAlign, cColor, cFont, nSize, cFntColor, nHeight, ;\n cBgPic, nWidth, lWrap, nColspan, nRowspan, cValign, ;\n clrdrk, clrlt, cBdrClr, cClass, lNoFont )\n\n METHOD EndTableCell()\n\n METHOD EndTable()\n\n METHOD NewList() INLINE ::cStr += \"
    \" + CRLF()\n\n METHOD ListItem() INLINE ::cStr += \"
  • \"\n\n METHOD EndList() INLINE ::cStr += \"
\"\n\n METHOD NewForm( cMethod, cAction, cName )\n\n METHOD FormImage( cText, name, File )\n\n METHOD FormEdit( cType, cName, xValue, nSize )\n\n METHOD FormReset( cText )\n\n METHOD FormSubmit( cText )\n\n METHOD FormQOut( c ) INLINE ::cStr += c + \"
\" + CRLF()\n\n METHOD FormQQOut( c ) INLINE ::cStr += c + CRLF()\n\n METHOD EndForm() INLINE ::cStr += CRLF() + \"\" + CRLF()\n\n METHOD PushButton( cName, cCaption, cCgiApp, cOnClick, cOnFocus, cOnBlur, cOnMsOver, cOnMsOut, style, ID )\n\n METHOD endButton()\n\n METHOD Button( cName, cCaption, cOnClick, cCgiApp, cOnMsOver, cOnMsOut, style, ID )\n\n METHOD iFrame( name, src, border, marginwidth, marginheight, scrolling, align, WIDTH, HEIGHT )\n\n METHOD StartJava() INLINE ::cStr += '