Text Generation
PEFT
Safetensors
GGUF
Transformers
English
Spanish
harbour
fivewin
fwh
lora
sft
trl
unsloth
code-generation
xbase
clipper
conversational
Instructions to use fivetech/Harbour with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use fivetech/Harbour with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("/home/fivetech/finetune/models/Qwen3.6-35B-A3B") model = PeftModel.from_pretrained(base_model, "fivetech/Harbour") - Transformers
How to use fivetech/Harbour with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fivetech/Harbour") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("fivetech/Harbour", dtype="auto") - llama-cpp-python
How to use fivetech/Harbour with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="fivetech/Harbour", filename="Qwen3.6-35B-A3B-LoRA-Q4_K_M.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use fivetech/Harbour with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf fivetech/Harbour:Q4_K_M # Run inference directly in the terminal: llama cli -hf fivetech/Harbour:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf fivetech/Harbour:Q4_K_M # Run inference directly in the terminal: llama cli -hf fivetech/Harbour:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf fivetech/Harbour:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf fivetech/Harbour:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf fivetech/Harbour:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf fivetech/Harbour:Q4_K_M
Use Docker
docker model run hf.co/fivetech/Harbour:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use fivetech/Harbour with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fivetech/Harbour" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fivetech/Harbour", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/fivetech/Harbour:Q4_K_M
- SGLang
How to use fivetech/Harbour with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "fivetech/Harbour" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fivetech/Harbour", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "fivetech/Harbour" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fivetech/Harbour", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use fivetech/Harbour with Ollama:
ollama run hf.co/fivetech/Harbour:Q4_K_M
- Unsloth Studio
How to use fivetech/Harbour with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for fivetech/Harbour to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for fivetech/Harbour to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for fivetech/Harbour to start chatting
- Pi
How to use fivetech/Harbour with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf fivetech/Harbour:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "fivetech/Harbour:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use fivetech/Harbour with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf fivetech/Harbour:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default fivetech/Harbour:Q4_K_M
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use fivetech/Harbour with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf fivetech/Harbour:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "fivetech/Harbour:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use fivetech/Harbour with Docker Model Runner:
docker model run hf.co/fivetech/Harbour:Q4_K_M
- Lemonade
How to use fivetech/Harbour with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull fivetech/Harbour:Q4_K_M
Run and chat with the model
lemonade run user.Harbour-Q4_K_M
List all available models
lemonade list
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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 'hbmxml' (XML generation library): contrib/hbmxml/tests/custom.prg. Provides functions: load_c, save_c, whitespace_cb, type_cb. Contains procedures: Main, create_cust, my_mxmlError. This file handles data format parsing and generation"}, {"role": "assistant", "content": "#require \"hbmxml\"\n\n#xtranslate _ENCODE( <xData> ) => ( hb_base64Encode( hb_Serialize( mxmlGetCustom( <xData> ) ) ) )\n\nPROCEDURE Main()\n\n LOCAL tree, node\n LOCAL xData\n\n mxmlSetErrorCallback( @my_mxmlError() )\n mxmlSetCustomHandlers( @load_c(), @save_c() )\n\n IF ! hb_FileExists( \"cust.xml\" )\n create_cust()\n ENDIF\n\n tree := mxmlLoadFile( tree, \"cust.xml\", @type_cb() )\n\n node := mxmlFindElement( tree, tree, \"hash\", NIL, NIL, MXML_DESCEND )\n IF Empty( node )\n OutErr( \"Unable to find <hash> element in XML tree!\" )\n mxmlDelete( tree )\n\n ErrorLevel( -1 )\n RETURN\n ENDIF\n\n IF !( hb_MD5( _ENCODE( node ) ) == mxmlElementGetAttr( node, \"checksum\" ) )\n OutErr( \"Custom data of element <hash> is corrupted!\" )\n mxmlDelete( tree )\n\n ErrorLevel( -1 )\n RETURN\n ENDIF\n\n xData := mxmlGetCustom( node )\n IF HB_ISHASH( xData ) .AND. hb_HHasKey( xData, \"Today\" )\n OutStd( xData[ \"Today\" ], hb_eol() )\n ENDIF\n\n mxmlSetErrorCallback( NIL )\n mxmlSetCustomHandlers( NIL, NIL )\n\n ErrorLevel( 0 )\n\n RETURN\n\nSTATIC PROCEDURE create_cust()\n\n LOCAL tree, group, element, node\n LOCAL hData := { => }\n\n hData[ \"Today\" ] := hb_TSToStr( hb_DateTime() )\n \n\n tree := mxmlNewXML()\n group := mxmlNewElement( tree, \"group\" )\n element := mxmlNewElement( group, \"hash\" )\n node := mxmlNewCustom( element, hData )\n\n mxmlElementSetAttr( element, \"type\", \"custom\" )\n mxmlElementSetAttr( element, \"checksum\", hb_MD5( _ENCODE( node ) ) )\n\n mxmlSaveFile( tree, \"cust.xml\", @whitespace_cb() )\n\n RETURN\n\nPROCEDURE my_mxmlError( cErrorMsg )\n\n OutErr( cErrorMsg, hb_eol() )\n\n RETURN\n\nFUNCTION load_c( node, cString )\n\n mxmlSetCustom( node, hb_Deserialize( hb_base64Decode( cString ) ) )\n\n RETURN 0 \n\nFUNCTION save_c( node )\n\n RETURN _ENCODE( node ) \n\nFUNCTION whitespace_cb( node, where )\n\n LOCAL parent \n LOCAL nLevel := -1 \n LOCAL name \n\n name := mxmlGetElement( node )\n\n IF Left( name, 4 ) == \"?xml\"\n IF where == MXML_WS_AFTER_OPEN\n RETURN hb_eol()\n ELSE\n RETURN NIL\n ENDIF\n\n ELSEIF where == MXML_WS_BEFORE_OPEN .OR. ;\n ( ( name == \"choice\" .OR. name == \"option\" ) .AND. ;\n where == MXML_WS_BEFORE_CLOSE )\n\n parent := mxmlGetParent( node )\n DO WHILE ! Empty( parent )\n nLevel++\n parent := mxmlGetParent( parent )\n ENDDO\n\n IF nLevel > 8\n nLevel := 8\n ELSEIF nLevel < 0\n nLevel := 0\n ENDIF\n\n RETURN Replicate( Chr( 9 ), nLevel )\n\n ELSEIF where == MXML_WS_AFTER_CLOSE .OR. ;\n ( ( name == \"group\" .OR. name == \"option\" .OR. name == \"choice\" ) .AND. ;\n where == MXML_WS_AFTER_OPEN )\n RETURN hb_eol()\n\n ELSEIF where == MXML_WS_AFTER_OPEN .AND. Empty( mxmlGetFirstChild( node ) )\n RETURN hb_eol()\n ENDIF\n\n RETURN NIL \n\nFUNCTION type_cb( node )\n\n LOCAL nResult\n LOCAL cType\n\n IF Empty( cType := mxmlElementGetAttr( node, \"type\" ) )\n cType := mxmlGetElement( node )\n ENDIF\n\n SWITCH Lower( cType )\n CASE \"custom\" \n CASE \"hash\"\n nResult := MXML_CUSTOM\n EXIT\n\n OTHERWISE\n nResult := MXML_TEXT\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": "Write Harbour functions: test_main. Harbour test program: tests/rddtest/adscl53.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,.f.,.t.,.f.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .f., {1,.f.,.t.,.f.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {1,.f.,.t.,.f.}, DBSEEK(\"\", .F.,.F.)\nRDDTESTF .f., {1,.f.,.t.,.f.}, DBSEEK(\"\", .F.,.T.)\nRDDTESTC {1,.f.,.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., {1,.f.,.f.,.f.}, DBSEEK(0,.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(0,.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.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., {3,.f.,.f.,.t.}, DBSEEK(1.0,.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(2.0,.T.,.F.)\nRDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK(2.0,.T.,.T.)\nRDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK(2.5,.T.,.F.)\nRDDTESTF .f., {6,.f.,.f.,.f.}, DBSEEK(2.5,.T.,.T.)\nRDDTESTF .t., {13,.f.,.f.,.t.}, DBSEEK(5.0,.T.,.F.)\nRDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK(5.0,.T.,.T.)\nRDDTESTF \"TG_N\", {15,.f.,.f.,.t.}, ORDSETFOCUS(2)\nRDDTESTF \"TG_C\", {15,.f.,.f.,.t.}, ORDSETFOCUS()\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.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., {3,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.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., {15,.f.,.f.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, ORDSCOPE(0,\"3\")\nRDDTESTF NIL, {15,.f.,.f.,.f.}, ORDSCOPE(1,\"4\")\nRDDTESTF \"3\", {15,.f.,.f.,.f.}, DBORDERINFO(39)\nRDDTESTF \"4\", {15,.f.,.f.,.f.}, DBORDERINFO(40)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK(\"0\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"0\",.T.,.T.)\nRDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .f., {7,.f.,.f.,.f.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"5\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, 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 \"3\", {16,.f.,.t.,.f.}, ORDSCOPE(0,\"3\")\nRDDTESTF \"4\", {16,.f.,.t.,.f.}, ORDSCOPE(1,\"2\")\nRDDTESTF \"3\", {16,.f.,.t.,.f.}, DBORDERINFO(39)\nRDDTESTF \"2\", {16,.f.,.t.,.f.}, DBORDERINFO(40)\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(\"1\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF \"3\", {16,.f.,.t.,.f.}, DBORDERINFO(39)\nRDDTESTF \"2\", {16,.f.,.t.,.f.}, DBORDERINFO(40)\nRDDTESTF .t., {16,.f.,.t.,.f.}, ORDSCOPE(0,NIL)\nRDDTESTF .t., {16,.f.,.t.,.f.}, ORDSCOPE(1,NIL)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBORDERINFO(39)\nRDDTESTF NIL, {16,.f.,.t.,.f.}, DBORDERINFO(40)\nRDDTESTF .t., {1,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.F.)\nRDDTESTF .t., {15,.f.,.f.,.t.}, DBSEEK(\"\", .T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.f.}, DBSEEK(\" \",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\" \",.T.,.T.)\nRDDTESTF .f., {1,.f.,.f.,.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., {3,.f.,.f.,.t.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .t., {4,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .t., {6,.f.,.f.,.t.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .t., {7,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .t., {9,.f.,.f.,.t.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .t., {10,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .t., {12,.f.,.f.,.t.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .t., {13,.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., {15,.f.,.f.,.f.}, DBSEEK(\"6\",.T.,.T.)\nRDDTESTF NIL, {15,.f.,.f.,.f.}, ORDSCOPE(0,\"4\")\nRDDTESTF NIL, {15,.f.,.f.,.f.}, ORDSCOPE(1,\"3\")\nRDDTESTF \"4\", {15,.f.,.f.,.f.}, DBORDERINFO(39)\nRDDTESTF \"3\", {15,.f.,.f.,.f.}, DBORDERINFO(40)\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 .f., {16,.f.,.t.,.f.}, DBSEEK(\"1\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"1\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"2\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"2\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"3\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"3\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"4\",.T.,.F.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"4\",.T.,.T.)\nRDDTESTF .f., {16,.f.,.t.,.f.}, DBSEEK(\"5\",.T.,.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": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/cgi.prg. Defines classes: TIPCgi. Provides functions: HtmlTag. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"fileio.ch\"\n\n#define _CRLF Chr( 13 ) + Chr( 10 )\n\nCREATE CLASS TIPCgi\n\n VAR HTTP_RAW_POST_DATA\n\n VAR cCgiHeader\n VAR cHtmlPage\n VAR hGets INIT { => }\n VAR hPosts INIT { => }\n VAR hCookies INIT { => }\n VAR hSession INIT { => }\n VAR bSavedErrHandler\n VAR cSessionSavePath\n VAR cSID\n VAR cDumpSavePath\n VAR lDumpHtml INIT .F.\n VAR Cargo\n\n METHOD New()\n METHOD Header( cValue )\n METHOD Redirect( cUrl )\n METHOD Write( cString )\n METHOD Flush()\n METHOD ErrHandler( xError )\n\n METHOD StartHtml( hOptions )\n METHOD EndHtml()\n METHOD SaveHtmlPage( cFile )\n\n METHOD StartSession( cSID )\n METHOD DestroySession( cID )\n METHOD CreateSID( cCRCKey ) INLINE ::cSID := tip_GenerateSID( cCrcKey )\n METHOD CheckCrcSID( cSID, cCRCKey ) INLINE tip_CheckSID( cSID, cCRCKey )\n METHOD SessionEncode()\n METHOD SessionDecode( cData )\n\nENDCLASS\n\nMETHOD New() CLASS TIPCgi\n\n LOCAL aVar\n LOCAL nLen\n LOCAL nRead\n LOCAL cTemp\n LOCAL item\n\n ::bSavedErrHandler := ErrorBlock( {| e | ::ErrHandler( e ) } )\n\n ::cCgiHeader := \"\"\n ::cHtmlPage := \"\"\n\n IF \"POST\" $ Upper( GetEnv( \"REQUEST_METHOD\" ) )\n nLen := Val( GetEnv( \"CONTENT_LENGTH\" ) )\n cTemp := Space( nLen )\n IF ( nRead := FRead( hb_GetStdIn(), @cTemp, nLen ) ) != nLen\n ::ErrHandler( \"post error read \" + hb_ntos( nRead ) + \" instead of \" + hb_ntos( nLen ) )\n ELSE\n ::HTTP_RAW_POST_DATA := cTemp\n FOR EACH item IN hb_ATokens( cTemp, \"&\" )\n IF Len( aVar := hb_ATokens( item, \"=\" ) ) == 2\n ::hPosts[ AllTrim( tip_URLDecode( aVar[ 1 ] ) ) ] := tip_URLDecode( aVar[ 2 ] )\n ENDIF\n NEXT\n ENDIF\n ELSEIF ! Empty( cTemp := GetEnv( \"QUERY_STRING\" ) )\n FOR EACH item IN hb_ATokens( cTemp, \"&\" )\n IF Len( aVar := hb_ATokens( item, \"=\" ) ) == 2\n ::hGets[ AllTrim( tip_URLDecode( aVar[ 1 ] ) ) ] := tip_URLDecode( aVar[ 2 ] )\n ENDIF\n NEXT\n ENDIF\n\n IF ! Empty( cTemp := GetEnv( \"HTTP_COOKIE\" ) )\n FOR EACH item IN hb_ATokens( cTemp, \";\" )\n IF Len( aVar := hb_ATokens( item, \"=\" ) ) == 2\n ::hCookies[ AllTrim( tip_URLDecode( aVar[ 1 ] ) ) ] := tip_URLDecode( aVar[ 2 ] )\n ENDIF\n NEXT\n ENDIF\n\n RETURN Self\n\nMETHOD Header( cValue ) CLASS TIPCgi\n\n IF HB_ISSTRING( cValue ) .AND. ! Empty( cValue )\n ::cCgiHeader += cValue + _CRLF\n ELSE\n ::cCgiHeader += \"Content-Type: text/html\" + _CRLF\n ENDIF\n\n RETURN Self\n\nMETHOD Redirect( cUrl ) CLASS TIPCgi\n\n IF HB_ISSTRING( cUrl ) .AND. ! Empty( cUrl )\n ::cCgiHeader += \"Location: \" + cUrl + _CRLF\n ENDIF\n\n RETURN Self\n\nMETHOD Flush() CLASS TIPCgi\n\n LOCAL cStream\n LOCAL lRet\n\n LOCAL hFile\n LOCAL cFile\n\n LOCAL cSession\n\n hb_HEval( ::hCookies, {| k, v | ::cCgiHeader += \"Set-Cookie: \" + k + \"=\" + v + \";\" + _CRLF } )\n\n cStream := ::cCgiHeader + _CRLF + ::cHtmlPage + _CRLF\n\n lRet := ( FWrite( hb_GetStdOut(), cStream ) == hb_BLen( cStream ) )\n\n IF ::lDumpHtml\n IF ::cDumpSavePath == NIL\n ::cDumpSavePath := hb_DirTemp()\n ENDIF\n hb_MemoWrit( hb_DirSepAdd( ::cDumpSavePath ) + \"dump.html\", ::cHtmlPage )\n ENDIF\n\n ::cCgiHeader := \"\"\n ::cHtmlPage := \"\"\n\n IF ! Empty( ::cSID )\n\n cFile := hb_DirSepAdd( ::cSessionSavePath ) + \"SESSIONID_\" + ::cSID\n\n IF ( hFile := hb_vfOpen( cFile, FO_CREAT + FO_TRUNC + FO_WRITE + FO_EXCLUSIVE ) ) != NIL\n cSession := ::SessionEncode()\n IF hb_vfWrite( hFile, cSession ) != hb_BLen( cSession )\n ::Write( \"ERROR: On writing session file: \" + cFile + \", File error: \" + hb_CStr( FError() ) )\n ENDIF\n hb_vfClose( hFile )\n ELSE\n ::Write( \"ERROR: On writing session file: \" + cFile + \", File error: \" + hb_CStr( FError() ) )\n ENDIF\n ENDIF\n\n RETURN lRet\n\nMETHOD SaveHtmlPage( cFile ) CLASS TIPCgi\n RETURN hb_MemoWrit( cFile, ::cHtmlPage + _CRLF )\n\nMETHOD StartSession( cSID ) CLASS TIPCgi\n\n LOCAL hFile\n LOCAL cFile\n LOCAL nFileSize\n LOCAL cBuffer\n\n IF ! HB_ISSTRING( cSID ) .OR. Empty( cSID )\n DO CASE\n CASE hb_HGetRef( ::hGets, \"SESSIONID\", @cSID )\n CASE hb_HGetRef( ::hPosts, \"SESSIONID\", @cSID )\n CASE hb_HGetRef( ::hCookies, \"SESSIONID\", @cSID )\n ENDCASE\n ENDIF\n\n IF ::cSessionSavePath == NIL\n ::cSessionSavePath := hb_DirTemp()\n ENDIF\n\n IF ! Empty( cSID )\n\n ::cSID := cSID\n\n cFile := hb_DirSepAdd( ::cSessionSavePath ) + \"SESSIONID_\" + cSID\n\n IF hb_vfExists( cFile )\n IF ( hFile := hb_vfOpen( cFile, FO_READ ) ) != NIL\n nFileSize := hb_vfSize( hFile )\n hb_vfSeek( hFile, 0, FS_SET )\n cBuffer := Space( nFileSize )\n IF hb_vfRead( hFile, @cBuffer, nFileSize ) != nFileSize\n ::ErrHandler( \"ERROR: On reading session file: \" + cFile + \", File error: \" + hb_CStr( FError() ) )\n ELSE\n ::SessionDecode( cBuffer )\n ENDIF\n hb_vfClose( hFile )\n ENDIF\n ELSE\n ::ErrHandler( \"ERROR: On opening session file: \" + cFile + \", file not exist.\" )\n ENDIF\n ELSE\n ::CreateSID()\n ::hSession := { => }\n ENDIF\n\n ::hCookies[ \"SESSIONID\" ] := ::cSID\n\n RETURN Self\n\nMETHOD SessionEncode() CLASS TIPCgi\n RETURN hb_Serialize( ::hSession )\n\nMETHOD SessionDecode( cData ) CLASS TIPCgi\n RETURN HB_ISHASH( ::hSession := hb_Deserialize( cData ) )\n\nMETHOD DestroySession( cID ) CLASS TIPCgi\n\n LOCAL cFile\n LOCAL cSID\n LOCAL lOk\n\n IF HB_ISSTRING( cID ) .AND. ! Empty( cID )\n cSID := cID\n ELSE\n cSID := ::cSID\n ENDIF\n\n IF ! Empty( cSID )\n\n ::hSession := { => }\n\n cFile := hb_DirSepAdd( ::cSessionSavePath ) + \"SESSIONID_\" + cSID\n\n IF ( lOk := ( hb_vfErase( cFile ) != F_ERROR ) )\n ::hCookies[ \"SESSIONID\" ] := cSID + \"; expires= \" + tip_DateToGMT( hb_DateTime() - 1 )\n ::CreateSID()\n ::hCookies[ \"SESSIONID\" ] := ::cSID\n ELSE\n ::Write( \"ERROR: On deleting session file: \" + cFile + \", File error: \" + hb_CStr( FError() ) )\n ENDIF\n ENDIF\n\n RETURN lOk\n\nMETHOD PROCEDURE ErrHandler( xError ) CLASS TIPCgi\n\n LOCAL nCalls\n\n LOCAL cErrMsg := ;\n '<table border=\"1\">' + ;\n \"<tr><td>SCRIPT NAME:</td><td>\" + GetEnv( \"SCRIPT_NAME\" ) + \"</td></tr>\"\n\n DO CASE\n CASE HB_ISOBJECT( xError )\n cErrMsg += ;\n \"<tr><td>CRITICAL ERROR:</td><td>\" + xError:Description + \"</td></tr>\" + ;\n \"<tr><td>OPERATION:</td><td>\" + xError:Operation + \"</td></tr>\" + ;\n \"<tr><td>OS ERROR:</td><td>\" + hb_ntos( xError:OsCode ) + \" IN \" + xError:SubSystem + \"/\" + hb_ntos( xError:SubCode ) + \"</td></tr>\" + ;\n \"<tr><td>FILENAME:</td><td>\" + Right( xError:FileName, 40 ) + \"</td></tr>\"\n CASE HB_ISSTRING( xError )\n cErrMsg += \"<tr><td>ERROR MESSAGE:</td><td>\" + tip_HtmlSpecialChars( xError ) + \"</td></tr>\"\n ENDCASE\n\n nCalls := 0\n DO WHILE ! Empty( ProcName( ++nCalls ) )\n cErrMsg += \"<tr><td>PROC/LINE:</td><td>\" + ProcName( nCalls ) + \"/\" + hb_ntos( ProcLine( nCalls ) ) + \"</td></tr>\"\n ENDDO\n\n cErrMsg += \"</table>\"\n\n ::Write( cErrMsg )\n\n OutErr( cErrMsg )\n\n ::Flush()\n\n QUIT\n\n RETURN\n\nMETHOD Write( cString ) CLASS TIPCgi\n\n ::cHtmlPage += cString + _CRLF\n\n RETURN Self\n\nMETHOD StartHtml( hOptions ) CLASS TIPCgi\n\n ::cHtmlPage += ;\n \"<!DOCTYPE html>\" + _CRLF + ;\n \"<html>\" + ;\n '<head><meta charset=\"' + HtmlOption( hOptions, \"encoding\" ) + '\" />' + ;\n HtmlTag( hOptions, \"title\", \"title\" ) + ;\n HtmlScript( hOptions ) + ;\n HtmlStyle( hOptions ) + ;\n HtmlLinkRel( hOptions ) + ;\n \"</head>\" + ;\n \"<body \" + HtmlAllOption( hOptions ) + \">\"\n\n RETURN Self\n\nMETHOD EndHtml() CLASS TIPCgi\n\n ::cHtmlPage += \"</body></html>\"\n\n RETURN Self\n\nSTATIC FUNCTION HtmlTag( xVal, cKey, cDefault )\n\n LOCAL cVal\n\n IF HB_ISHASH( xVal ) .AND. ! Empty( cKey ) .AND. cKey $ xVal"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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: xhb_ErrorSys. Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/xhberr.prg. Provides 7 functions including: xhb_ErrorLog, err_ModuleName, err_ProcName, err_ProcLine, xhb_DefError. Contains procedures: xhb_ErrorSys. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"error.ch\"\n#include \"fileio.ch\"\n\nREQUEST Select, Alias, RecNo, DbFilter, DbRelation, IndexOrd, IndexKey\n\nSTATIC s_cErrorLog := \"error.log\"\nSTATIC s_lErrorLogAppend := .F.\n\nFUNCTION xhb_ErrorLog( cErrorLog, lErrorLogAppend )\n\n LOCAL aValueOld := { s_cErrorLog, s_lErrorLogAppend }\n\n IF HB_ISSTRING( cErrorLog )\n s_cErrorLog := cErrorLog\n ENDIF\n IF HB_ISLOGICAL( lErrorLogAppend )\n s_lErrorLogAppend := lErrorLogAppend\n ENDIF\n\n RETURN aValueOld\n\nPROCEDURE xhb_ErrorSys()\n\n ErrorBlock( {| oError | xhb_DefError( oError ) } )\n\n RETURN\n\nSTATIC FUNCTION err_ModuleName( oError, n )\n\n RETURN iif( __objHasMsg( oError, \"MODULENAME\" ), oError:ModuleName, ;\n iif( n != NIL, ProcFile( n ), NIL ) )\n\nSTATIC FUNCTION err_ProcName( oError, n )\n\n RETURN iif( __objHasMsg( oError, \"PROCNAME\" ), oError:ProcName, ;\n iif( n != NIL, ProcName( n ), NIL ) )\n\nSTATIC FUNCTION err_ProcLine( oError, n )\n\n RETURN iif( __objHasMsg( oError, \"PROCLINE\" ), oError:ProcLine, ;\n iif( n != NIL, ProcLine( n ), NIL ) )\n\nSTATIC FUNCTION xhb_DefError( oError )\n\n LOCAL cMessage\n LOCAL cDOSError\n\n LOCAL aOptions\n LOCAL nChoice\n\n LOCAL n\n\n n := 0\n WHILE ! Empty( ProcName( ++n ) )\n IF ProcName( n ) == ProcName()\n n := 3\n TraceLog( \"Error system failure!\", err_ProcName( oError, n ), err_ProcLine( oError, n ), err_ModuleName( oError, n ), oError:description )\n Alert( \"Error system failure!;Please correct error handler:;\" + err_ProcName( oError, n ) + \"(\" + hb_ntos( err_ProcLine( oError, n ) ) + \") in module: \" + err_ModuleName( oError, n ) )\n ErrorLevel( 1 )\n QUIT\n ENDIF\n ENDDO\n\n \n IF oError:genCode == EG_ZERODIV\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 \n DO WHILE DispCount() > 0\n DispEnd()\n ENDDO\n\n cMessage := ErrorMessage( oError )\n IF ! Empty( oError:osCode )\n cDOSError := \"(DOS Error \" + hb_ntos( oError:osCode ) + \")\"\n ENDIF\n\n\n IF HB_ISARRAY( oError:Args )\n cMessage += \" Arguments: (\" + Arguments( oError ) + \")\"\n ENDIF\n\n \n IF MaxCol() > 0\n aOptions := {}\n\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 nChoice := 0\n DO WHILE nChoice == 0\n\n IF Empty( oError:osCode )\n nChoice := Alert( cMessage, aOptions )\n ELSE\n nChoice := Alert( cMessage + \";\" + cDOSError, aOptions )\n ENDIF\n\n ENDDO\n\n IF ! Empty( nChoice )\n DO CASE\n CASE aOptions[ nChoice ] == \"Break\"\n Break( oError )\n CASE aOptions[ nChoice ] == \"Retry\"\n RETURN .T.\n CASE aOptions[ nChoice ] == \"Default\"\n RETURN .F.\n ENDCASE\n ENDIF\n ELSE\n IF Empty( oError:osCode )\n Alert( cMessage + \";\" + err_ProcName( oError, 3 ) + \"(\" + hb_ntos( err_ProcLine( oError, 3 ) ) + \") in module: \" + err_ModuleName( oError, 3 ) )\n ELSE\n Alert( cMessage + \";\" + cDOSError + \";\" + err_ProcName( oError, 3 ) + \"(\" + hb_ntos( err_ProcLine( oError, 3 ) ) + \") in module: \" + err_ModuleName( oError, 3 ) )\n ENDIF\n ENDIF\n\n \n IF ! Empty( oError:osCode )\n cMessage += \" \" + cDOSError\n ENDIF\n\n ? cMessage\n\n ?\n ? \"Error at ...:\", err_ProcName( oError, 3 ) + \"(\" + hb_ntos( err_ProcLine( oError, 3 ) ) + \") in Module:\", err_ModuleName( oError, 3 )\n n := 2\n WHILE ! Empty( ProcName( ++n ) )\n ? \"Called from :\", ProcName( n ) + ;\n \"(\" + hb_ntos( ProcLine( n ) ) + \") in Module:\", ProcFile( n )\n ENDDO\n\n \n LogError( oError )\n\n ErrorLevel( 1 )\n ?\n QUIT\n\n RETURN .F.\n\n\nSTATIC FUNCTION ErrorMessage( oError )\n\n LOCAL cMessage\n\n \n 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\n\nSTATIC FUNCTION LogError( oErr )\n\n LOCAL cScreen\n LOCAL cLogFile := s_cErrorLog \n LOCAL lAppendLog := s_lErrorLogAppend \n LOCAL nCols\n LOCAL nRows\n\n LOCAL nCount\n\n LOCAL nForLoop\n LOCAL cOutString\n\n LOCAL nHandle\n LOCAL nBytes\n\n LOCAL nHandle2 := F_ERROR\n LOCAL cLogFile2 := \"_error.log\"\n LOCAL cBuff := \"\"\n LOCAL nRead\n\n nCols := MaxCol()\n IF nCols > 0\n nRows := MaxRow()\n cScreen := SaveScreen()\n ENDIF\n\n \n IF ! lAppendLog\n nHandle := FCreate( cLogFile, FC_NORMAL )\n ELSE\n IF ! hb_FileExists( cLogFile )\n nHandle := FCreate( cLogFile, FC_NORMAL )\n ELSE\n nHandle := FCreate( cLogFile2, FC_NORMAL )\n nHandle2 := FOpen( cLogFile, FO_READ )\n ENDIF\n ENDIF\n\n\n IF nHandle < 3 .AND. !( Lower( cLogFile ) == \"error.log\" )\n \n \n cLogFile := \"error.log\"\n nHandle := FCreate( cLogFile, FC_NORMAL )\n ENDIF\n\n IF nHandle < 3\n ELSE\n\n FWriteLine( nHandle, PadC( \" xHarbour Error Log \", 79, \"-\" ) )\n FWriteLine( nHandle, \"\" )\n\n FWriteLine( nHandle, \"Date...............: \" + DToC( Date() ) )\n FWriteLine( nHandle, \"Time...............: \" + Time() )\n\n FWriteLine( nHandle, \"\" )\n FWriteLine( nHandle, \"Application name...: \" + hb_CmdArgArgV() )\n FWriteLine( nHandle, \"Workstation name...: \" + NetName() )\n FWriteLine( nHandle, \"Available memory...: \" + strvalue( Memory( 0 ) ) )\n FWriteLine( nHandle, \"Current disk.......: \" + DiskName() )\n FWriteLine( nHandle, \"Current directory..: \" + CurDir() )\n FWriteLine( nHandle, \"Free disk space....: \" + strvalue( DiskSpace() ) )\n FWriteLine( nHandle, \"\" )\n FWriteLine( nHandle, \"Operating system...: \" + OS() )\n FWriteLine( nHandle, \"xHarbour version...: \" + Version() )\n FWriteLine( nHandle, \"xHarbour built on..: \" + hb_BuildDate() )\n FWriteLine( nHandle, \"C/C++ compiler.....: \" + hb_Compiler() )\n\n FWriteLine( nHandle, \"Multi Threading....: \" + iif( hb_mtvm(), \"YES\", \"NO\" ) )\n FWriteLine( nHandle, \"VM Optimization....: \" + strvalue( hb_VMMode() ) )\n\n IF hb_IsFunction( \"Select\" )\n FWriteLine( nHandle, \"\" )\n FWriteLine( nHandle, \"Current Area ......:\" + strvalue( Eval( hb_macroBlock( \"Select()\" ) ) ) )\n ENDIF\n\n FWriteLine( nHandle, \"\" )\n FWriteLine( nHandle, PadC( \" Environmental Information \", 79, \"-\" ) )\n FWriteLine( nHandle, \"\" )\n\n FWriteLine( nHandle, \"SET ALTERNATE......: \" + strvalue( Set( _SET_ALTERNATE ), .T. ) )\n FWriteLine( nHandle, \"SET ALTFILE........: \" + strvalue( Set( _SET_ALTFILE ) ) )\n FWriteLine( nHandle, \"SET AUTOPEN........: \" + strvalue( Set( _SET_AUTOPEN ), .T. ) )\n FWriteLine( nHandle, \"SET AUTORDER.......: \" + strvalue( Set( _SET_AUTORDER ) ) )\n FWriteLine( nHandle, \"SET AUTOSHARE......: \" + strvalue( Set( _SET_AUTOSHARE ) ) )\n\n#ifdef __XHARBOUR__\n FWriteLine( nHandle, \"SET BACKGROUNDTASKS: \" + strvalue( Set( _SET_BACKGROUNDTASKS ), .T. ) )\n FWriteLine( nHandle, \"SET BACKGROUNDTICK.: \" + strvalue( Set( _SET_BACKGROUNDTICK ), .T. ) )\n#endif\n FWriteLine( nHandle, \"SET BELL...........: \" + strvalue( Set( _SET_BELL ), .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": "Write Harbour functions: Something. Harbour test program: tests/parexpr.prg. Provides functions: Something. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#ifdef __HARBOUR__\n #pragma -es0\n#endif\n\nPROCEDURE Main()\n\n LOCAL x\n LOCAL y\n\n \n x := ( 1 )\n ? x\n\n \n x := ( 1, 2 )\n ? x\n\n \n x := ( 1, 2, 3 )\n ? x\n\n \n x := ( ( 1, 2, 3 ) )\n ? x\n\n \n x := ( ( 1, 2, 3 ), ( 1, 2, 3 ) )\n ? x\n\n \n x := ( y := 10, y )\n ? x\n\n x := ( ( y := ( 1, 2, 3 ) ), y\n ? \"Working\"\n ELSE\n ? \"Borken\"\n ENDIF\n\n IF ( x := 10, y := ( x == 10 ) )\n ? \"Working\"\n ELSE\n ? \"Broken\"\n ENDIF\n\n IF ( Something( 1, 2, 3 ), .T. )\n ? \"Working\"\n ELSE\n ? \"Broken\"\n ENDIF\n\n ?\n\n \n ? IF( (.F.,0,.T.), (\"some\", \"text\", \"IF Working\"), (\"some\", \"text\", \"Broken\") )\n ? IF( (.T.,1,.F.), (\"some\", \"text\", \"Broken\"), (\"some\", \"text\", \"IF Working\") )\n\n ? IF( (.T. .OR. .F.), IF( .T., \"Working\", \"Broken\" ), IF( .F., \"Broken\", \"Working\" ) )\n\n \n RETURN\n\nSTATIC FUNCTION Something( x, y, z )\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": "Implement this Harbour module: Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/hbcomprs.prg. Provides functions: hb_Compress, hb_Uncompress, hb_CompressError, hb_CompressErrorDesc, hb_CompressBufLen. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"error.ch\"\n\n#include \"hbzlib.ch\"\n\nTHREAD STATIC t_nLastError := HB_ZLIB_RES_OK\n\n\nFUNCTION hb_Compress( xPar1, xPar2, xPar3, xPar4, xPar5 )\n\n LOCAL nComprFactor\n LOCAL cSource\n LOCAL nSourceLen\n LOCAL nDestLen\n\n LOCAL lReturnByRef\n\n LOCAL oError\n\n IF HB_ISNUMERIC( xPar1 )\n nComprFactor := xPar1\n cSource := xPar2\n nSourceLen := xPar3\n nDestLen := xPar5\n lReturnByRef := PCount() >= 4\n ELSE\n nComprFactor := HB_ZLIB_COMPRESSION_DEFAULT\n cSource := xPar1\n nSourceLen := xPar2\n nDestLen := xPar4\n lReturnByRef := PCount() >= 3\n ENDIF\n\n IF ! HB_ISSTRING( cSource )\n oError := ErrorNew()\n\n oError:severity := ES_ERROR\n oError:genCode := EG_ARG\n oError:subSystem := \"BASE\"\n oError:subCode := 3012\n oError:args := { cSource }\n\n Eval( ErrorBlock(), oError )\n RETURN NIL\n ENDIF\n\n IF ! HB_ISNUMERIC( nDestLen )\n nDestLen := NIL\n ENDIF\n\n IF HB_ISNUMERIC( nSourceLen ) .AND. nSourceLen >= 0 .AND. nSourceLen < Len( cSource )\n cSource := Left( cSource, nSourceLen )\n ENDIF\n\n IF lReturnByRef\n IF HB_ISNUMERIC( xPar1 )\n xPar4 := hb_ZCompress( cSource, nDestLen, @t_nLastError, nComprFactor )\n hb_default( @xPar4, \"\" )\n xPar5 := Len( xPar4 )\n ELSE\n xPar3 := hb_ZCompress( cSource, nDestLen, @t_nLastError, nComprFactor )\n hb_default( @xPar3, \"\" )\n xPar4 := Len( xPar3 )\n ENDIF\n RETURN t_nLastError\n ENDIF\n\n RETURN hb_ZCompress( cSource, nDestLen, @t_nLastError, nComprFactor )\n\n\nFUNCTION hb_Uncompress( nDestLen, cSource, nSourceLen, cDest )\n\n LOCAL oError\n\n IF ! HB_ISNUMERIC( nDestLen ) .OR. ;\n ! HB_ISSTRING( cSource )\n\n oError := ErrorNew()\n\n oError:severity := ES_ERROR\n oError:genCode := EG_ARG\n oError:subSystem := \"BASE\"\n oError:subCode := 3012\n oError:args := { nDestLen }\n\n Eval( ErrorBlock(), oError )\n RETURN NIL\n ENDIF\n\n IF HB_ISNUMERIC( nSourceLen ) .AND. nSourceLen >= 0 .AND. nSourceLen < Len( cSource )\n cSource := Left( cSource, nSourceLen )\n ENDIF\n\n IF PCount() >= 4\n cDest := hb_ZUncompress( cSource, nDestLen, @t_nLastError )\n RETURN t_nLastError\n ENDIF\n\n RETURN hb_ZUncompress( cSource, nDestLen, @t_nLastError )\n\n\nFUNCTION hb_CompressError()\n RETURN t_nLastError\n\n\nFUNCTION hb_CompressErrorDesc( nError )\n RETURN hb_ZError( nError )\n\n\nFUNCTION hb_CompressBufLen( nSrcLen )\n\n LOCAL nRet\n\n hb_default( @nSrcLen, 0 )\n\n nRet := nSrcLen\n nRet += nRet / 100"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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 'hbssl' (OpenSSL wrapper for SSL/TLS encryption): contrib/hbssl/tests/bio.prg. Contains procedures: Main. This file implements security and encryption functions"}, {"role": "assistant", "content": "#require \"hbssl\"\n\nPROCEDURE Main()\n\n LOCAL bio\n\n SSL_init()\n\n ? bio := BIO_new_fd( 1, HB_BIO_NOCLOSE )\n ? \"BIO_WRITE\", BIO_write( bio, \"Hello world!\" + hb_eol() )\n ? \"BIO_FLUSH\", BIO_flush( bio )\n ? \"BIO_FREE\", BIO_free( bio )\n\n ? bio := BIO_new_file( \"bio_test.txt\", \"a+\" )\n ? \"BIO_WRITE\", BIO_write( bio, \"Hello world!\" + hb_eol() )\n ? \"BIO_FLUSH\", BIO_flush( bio )\n ? \"BIO_FREE\", BIO_free( bio )\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/tests/strdiff.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 StrDiff()\"\n ?\n\n ? \"Simple tests:\"\n\n ? ' StrDiff( \"ABC\", \"ADC\" ) == 3 ? -> ', StrDiff( \"ABC\", \"ADC\" )\n ? ' StrDiff( \"ABC\", \"AEC\" ) == 3 ? -> ', StrDiff( \"ABC\", \"AEC\" )\n ? ' StrDiff( \"CBA\", \"ABC\" ) == 6 ? -> ', StrDiff( \"CBA\", \"ABC\" )\n ? ' StrDiff( \"ABC\", \"AXBC\" ) == 1 ? -> ', StrDiff( \"ABC\", \"AXBC\" )\n ? ' StrDiff( \"AXBC\", \"ABC\" ) == 6 ? -> ', StrDiff( \"AXBC\", \"ABC\" )\n ? ' StrDiff( \"AXBC\", \"ADC\" ) == 9 ? -> ', StrDiff( \"AXBC\", \"ADC\" )\n\n ? \"End test of StrDiff()\"\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 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/acctyear.prg. Provides functions: ft_AcctYear. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION ft_AcctYear( dGivenDate )\n\n LOCAL nYTemp, aRetVal\n\n IF ! HB_ISDATE( dGivenDate )\n dGivenDate := Date()\n ENDIF\n\n aRetVal := ft_Year( dGivenDate )\n nYTemp := Val( aRetVal[ 1 ] )\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n\n IF dGivenDate < aRetVal[ 2 ]\n\n aRetVal := ft_Year( ft_MAdd( dGivenDate, -1 ) )\n nYTemp--\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n\n ELSEIF dGivenDate > aRetVal[ 3 ]\n\n aRetVal := ft_Year( ft_MAdd( dGivenDate, 1 ) )\n nYTemp++\n aRetVal[ 2 ] := ft_AcctAdj( aRetVal[ 2 ] )\n aRetVal[ 3 ] := ft_AcctAdj( aRetVal[ 3 ], .T. )\n\n ENDIF\n\n aRetVal[ 1 ] := Str( nYTemp, 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: Header file for contribution module 'xhb' (Extended Harbour functions): contrib/xhb/xhbver.ch. Defines 10 constants including: HB_VERX_CH_, _HB_VER_MAJOR, _HB_VER_MINOR, _HB_VER_REVISION, _HB_VER_LEX. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_VERX_CH_\n#define HB_VERX_CH_\n\n#define _HB_VER_MAJOR 1 \n#define _HB_VER_MINOR 2 \n#define _HB_VER_REVISION 3 \n#define _HB_VER_LEX 4 \n#define _HB_VER_AS_STRING 5 \n#define _HB_PCODE_VER 6 \n#define _HB_VER_COMPILER 7 \n#define _HB_VER_PLATFORM 8 \n#define _HB_VER_BUILD_DATE 9 \n#define _HB_VER_BUILD_TIME 10 \n#define _HB_VER_LENTRY 11 \n#define _HB_VER_CHLCVS 12 \n#define _HB_VER_C_USR 13 \n#define _HB_VER_L_USR 14 \n#define _HB_VER_PRG_USR 15 \n#define _HB_EXTENSION 16 \n#define _HB_C52_UNDOC 17 \n#define _HB_C52_STRICT 18 \n#define _HB_COMPAT_C53 19 \n#define _HB_COMPAT_XPP 20 \n#define _HB_COMPAT_VO 21 \n#define _HB_COMPAT_FLAGSHIP 22 \n#define _HB_COMPAT_FOXPRO 23 \n#define _HB_COMPAT_DBASE 24 \n#define _HB_HARBOUR_OBJ_GENERATION 25 \n#define _HB_HARBOUR_STRICT_ANSI_C 26 \n#define _HB_CPLUSPLUS 27 \n#define _HB_HARBOUR_YYDEBUG 28 \n#define _HB_SYMBOL_NAME_LEN 29 \n#define _HB_MULTITHREAD 30 \n#define _HB_VM_OPTIMIZATION 31 \n#define _HB_LANG_ID 32 \n#define _HB_ARRAY_MODE 33 \n#define _HB_CREDITS 34 \n#define _HB_VER_LAST 35 \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 'xhb' (Extended Harbour functions): contrib/xhb/hbctypes.ch. Defines 10 constants including: __HBCTYPES_CH_, CTYPE_VOID, CTYPE_CHAR, CTYPE_UNSIGNED_CHAR, CTYPE_CHAR_PTR. Defines error handling constants and codes"}, {"role": "assistant", "content": "#ifndef __HBCTYPES_CH_\n#define __HBCTYPES_CH_\n\n#define CTYPE_VOID 0\n\n#define CTYPE_CHAR 1\n#define CTYPE_UNSIGNED_CHAR -1\n#define CTYPE_CHAR_PTR 10\n#define CTYPE_UNSIGNED_CHAR_PTR -10\n\n#define CTYPE_SHORT 2\n#define CTYPE_UNSIGNED_SHORT -2\n#define CTYPE_SHORT_PTR 20\n#define CTYPE_UNSIGNED_SHORT_PTR -20\n\n#define CTYPE_INT 3\n#define CTYPE_UNSIGNED_INT -3\n#define CTYPE_INT_PTR 30\n#define CTYPE_UNSIGNED_INT_PTR -30\n\n#define CTYPE_LONG 4\n#define CTYPE_UNSIGNED_LONG -4\n#define CTYPE_LONG_PTR 40\n#define CTYPE_UNSIGNED_LONG_PTR -40\n\n#define CTYPE_FLOAT 5\n#define CTYPE_FLOAT_PTR 50\n\n#define CTYPE_DOUBLE 6\n#define CTYPE_DOUBLE_PTR 60\n\n#define CTYPE_VOID_PTR 7\n\n\n#define CTYPE_STRUCTURE 1000\n#define CTYPE_STRUCTURE_PTR 10000\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, test. Harbour test program: tests/str.prg. Contains procedures: Main, test. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n ? \"Running with SET FIXED OFF (the default setting):\"\n ?\n test()\n WAIT \"Pause before running again with SET FIXED ON:\"\n ? \"Running with SET FIXED ON:\"\n ?\n Set( _SET_FIXED, .T. )\n test()\n\n RETURN\n\nPROCEDURE test()\n\n LOCAL a := 15.1\n LOCAL b := 10.0002575\n LOCAL nI, c, d\n\n ?? \"1: \"\n ?? 10\n ?? a\n ?? -a\n ?? b\n ?? -b\n ?\n\n ?? \"2: \"\n ?? a + b\n ?? a - b\n ?? a\n ?? \"3: \"\n ?? a % b\n ?? a ^ b\n ?\n\n c := a\n ?? \"4: \"\n ?? Str( c )\n ?? Str( d )\n ?\n\n ?? \"5: \"\n ?? Str( c + d )\n ?? Str( c - d )\n ?? Str( c\n ?? \"6: \"\n ?? a + b + c\n ?? c - b - a\n ?? b\n ?? Str( 6 + nI ) + \": \"\n ?? 10 ^ nI + ( 1.02\n ?? \"27: \"\n ?? Str( a ), a\n ?\n\n ?? \"28: \"\n ?? Str( b ), b\n ?\n\n ?? \"29: \"\n ?? Str( b, 15 )\n ?\n\n ?? \"30: \"\n ?? Str( b, 20, 5 )\n ?\n\n ?? \"31: \"\n ?? Str( b, 20, 10 )\n ?\n\n ?? \"32: \"\n ?? Str( b, 5, 10 )\n ?\n\n ?? \"33: \"\n ?? Str( b, 20, -10 )\n ?\n\n ?? \"34: \"\n ?? Str( b, -12, 7 )\n ?\n\n ?? \"35: \"\n ?? Str( b, 0 )\n ?\n\n ?\n a := 15.1004\n ?? \"36: \"\n ?? Str( a ), a\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 header file: include/hboo.ch. Defines 10 constants including: HB_OO_CH_, HB_MSGLISTALL, HB_MSGLISTCLASS, HB_MSGLISTPURE, HB_OO_CLSTP_EXPORTED. Defines error handling constants and codes"}, {"role": "assistant", "content": "#ifndef HB_OO_CH_\n#define HB_OO_CH_\n\n\n#define HB_MSGLISTALL 0\n#define HB_MSGLISTCLASS 1\n#define HB_MSGLISTPURE 2\n\n\n#define HB_OO_CLSTP_EXPORTED 1 \n#define HB_OO_CLSTP_PROTECTED 2 \n#define HB_OO_CLSTP_HIDDEN 4 \n#define HB_OO_CLSTP_CTOR 8 \n#define HB_OO_CLSTP_READONLY 16 \n#define HB_OO_CLSTP_SHARED 32 \n#define HB_OO_CLSTP_CLASS 64 \n#define HB_OO_CLSTP_SUPER 128 \n#define HB_OO_CLSTP_PERSIST 256 \n#define HB_OO_CLSTP_NONVIRTUAL 512 \n#define HB_OO_CLSTP_OVERLOADED 1024 \n#define HB_OO_CLSTP_SYNC 2048 \n\n\n#define HB_OO_MSG_METHOD 0\n#define HB_OO_MSG_DATA 1\n#define HB_OO_MSG_CLASSDATA 2\n#define HB_OO_MSG_INLINE 3\n#define HB_OO_MSG_VIRTUAL 4\n#define HB_OO_MSG_SUPER 5\n#define HB_OO_MSG_ONERROR 6\n#define HB_OO_MSG_CLSMTHD 7 \n#define HB_OO_MSG_ASSIGN 8\n#define HB_OO_MSG_ACCESS 9\n#define HB_OO_MSG_CLSASSIGN 10\n#define HB_OO_MSG_CLSACCESS 11\n#define HB_OO_MSG_REALCLASS 12\n#define HB_OO_MSG_DESTRUCTOR 13\n#define HB_OO_MSG_INITIALIZED 14 \n#define HB_OO_MSG_PERFORM 15\n#define HB_OO_MSG_DELEGATE 16\n\n\n#define HB_OO_PROPERTY 32\n#define HB_OO_MSG_PROPERTY HB_OO_PROPERTY + HB_OO_MSG_DATA \n#define HB_OO_MSG_CLASSPROPERTY HB_OO_PROPERTY + HB_OO_MSG_CLASSDATA \n\n\n#define HB_OO_DATA_SYMBOL 1\n#define HB_OO_DATA_VALUE 2\n#define HB_OO_DATA_TYPE 3\n#define HB_OO_DATA_SCOPE 4\n\n\n#define HB_OO_CLSD_SYMBOL 1\n#define HB_OO_CLSD_VALUE 2\n#define HB_OO_CLSD_TYPE 3\n#define HB_OO_CLSD_SCOPE 4\n\n\n#define HB_OO_MTHD_SYMBOL 1\n#define HB_OO_MTHD_PFUNCTION 2\n#define HB_OO_MTHD_SCOPE 3\n\n \n#define HB_OO_CLSM_SYMBOL 1\n#define HB_OO_CLSM_PFUNCTION 2\n#define HB_OO_CLSM_SCOPE 3\n\n\n#define HB_OO_DELEG_SYMBOL 1\n#define HB_OO_DELEG_MESSAGE 2\n#define HB_OO_DELEG_OBJECT 3\n#define HB_OO_DELEG_SCOPE 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": "Write the following Harbour (xBase/Clipper) code:\n\nHeader file for contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/ftint86.ch. Defines 10 constants including: __FTINT86_CH__, INT86_MAX_REGS, AX, BX, CX. Declares 1 preprocessor translations"}, {"role": "assistant", "content": "#ifndef __FTINT86_CH__\n#define __FTINT86_CH__\n\n#define INT86_MAX_REGS 10\n\n#define AX 1\n#define BX 2\n#define CX 3\n#define DX 4\n#define SI 5\n#define DI 6\n#define BP 7\n#define DS 8\n#define ES 9\n#define FLAGS 10\n\n#define FLAG_CARRY 0 \n#define FLAG_PARITY 2 \n#define FLAG_AUX 4 \n#define FLAG_ZERO 6 \n#define FLAG_SIGN 7 \n#define FLAG_TRAP 8 \n#define FLAG_INT 9 \n#define FLAG_DIR 10 \n#define FLAG_OFLOW 11 \n\n#translate MAKEHI( <X> ) => ( ( <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": "Define Harbour macros and constants: Harbour header file: include/directry.ch. Defines 7 constants including: _DIRECTRY_CH, F_NAME, F_SIZE, F_DATE, F_TIME. Defines file I/O constants"}, {"role": "assistant", "content": "#ifndef _DIRECTRY_CH\n#define _DIRECTRY_CH\n\n\n#define F_NAME 1 \n#define F_SIZE 2 \n#define F_DATE 3 \n#define F_TIME 4 \n#define F_ATTR 5 \n\n\n#define F_LEN 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 test program: tests/hsx.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"dbinfo.ch\"\n\n\nPROCEDURE Main()\n\n FIELD FIRST, LAST, STREET, CITY\n LOCAL n, hs\n\n IF AScan( rddList( 1 ), \"RMDBFCDX\" ) != 0\n rddSetDefault( \"RMDBFCDX\" )\n ENDIF\n\n USE test shared\n hs := hs_Index( \"test\", \"FIRST+LAST+STREET+CITY\", 2, 0, , .T., 3 )\n\n \n hs_Set( hs, \"SHERMAN\" )\n WHILE ( n := hs_Next( hs ) ) > 0\n dbGoto( n )\n IF hs_Verify( hs ) > 0\n ? RTrim( FIRST + LAST + STREET + CITY )\n ENDIF\n ENDDO\n WAIT\n\n \n IF dbInfo( DBI_RM_SUPPORTED )\n \n hs_Filter( hs, \"SHERMAN\" )\n dbGoTop()\n Browse()\n ENDIF\n hs_Close( hs )\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/browse.prg. Provides functions: Browse, DoGet, ExitKey, Skipped. Contains procedures: StatLine, FreshOrder. This file provides utility functions"}, {"role": "assistant", "content": "#include \"box.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n\nFUNCTION Browse( nTop, nLeft, nBottom, nRight )\n\n LOCAL oBrw\n LOCAL lContinue, lAppend, lKeyPressed, lRefresh\n LOCAL n, nOldCursor, nKey\n LOCAL cOldScreen\n LOCAL bAction\n\n IF ! Used()\n RETURN .F.\n ENDIF\n\n lAppend := lKeyPressed := lRefresh := .F.\n\n IF PCount() < 4\n nTop := 1\n nLeft := 0\n nBottom := MaxRow()\n nRight := MaxCol()\n ENDIF\n\n DispBegin()\n\n nOldCursor := SetCursor( SC_NONE )\n cOldScreen := SaveScreen( nTop, nLeft, nBottom, nRight )\n\n hb_DispBox( nTop, nLeft, nBottom, nRight, HB_B_DOUBLE_SINGLE_UNI )\n hb_DispOutAtBox( nTop + 3, nLeft, hb_UTF8ToStrBox( \"╞\" ) )\n hb_DispOutAtBox( nTop + 3, nRight, hb_UTF8ToStrBox( \"╡\" ) )\n hb_DispOutAt( nTop + 1, nLeft + 1, Space( nRight - nLeft - 1 ) )\n\n oBrw := TBrowseDB( nTop + 2, nLeft + 1, nBottom - 1, nRight - 1 )\n oBrw:HeadSep := \" \" + hb_UTF8ToStrBox( \"═\" )\n oBrw:SkipBlock := {| nRecs | Skipped( nRecs, lAppend ) }\n\n FOR n := 1 TO FCount()\n oBrw:AddColumn( TBColumnNew( FieldName( n ), FieldBlock( FieldName( n ) ) ) )\n NEXT\n\n IF Eof()\n dbGoTop()\n ENDIF\n\n oBrw:ForceStable()\n\n DispEnd()\n\n IF LastRec() == 0\n nKey := K_DOWN\n lKeyPressed := .T.\n ENDIF\n\n lContinue := .T.\n\n DO WHILE lContinue\n\n DO WHILE ! lKeyPressed .AND. ! oBrw:Stabilize()\n lKeyPressed := ( nKey := Inkey() ) != 0\n ENDDO\n\n IF lKeyPressed\n lKeyPressed := .F.\n ELSE\n IF oBrw:HitBottom .AND. ( ! lAppend .OR. RecNo() != LastRec() + 1 )\n IF lAppend\n oBrw:RefreshCurrent()\n oBrw:ForceStable()\n dbGoBottom()\n ELSE\n lAppend := .T.\n SetCursor( iif( ReadInsert(), SC_INSERT, SC_NORMAL ) )\n ENDIF\n oBrw:Down()\n oBrw:ForceStable()\n oBrw:ColorRect( { oBrw:RowPos, 1, oBrw:RowPos, oBrw:ColCount }, ;\n { 2, 2 } )\n ENDIF\n\n StatLine( oBrw, lAppend )\n\n oBrw:ForceStable()\n\n nKey := Inkey( 0 )\n IF ( bAction := SetKey( nKey ) ) != NIL\n Eval( bAction, ProcName( 1 ), ProcLine( 1 ), \"\" )\n LOOP\n ENDIF\n ENDIF\n\n SWITCH nKey\n\n#ifdef HB_COMPAT_C53\n CASE K_LBUTTONDOWN\n CASE K_LDBLCLK\n TBMouse( oBrw, MRow(), MCol() )\n EXIT\n#endif\n#ifndef HB_CLP_STRICT\n CASE K_MWFORWARD\n#endif\n CASE K_UP\n IF lAppend\n lRefresh := .T.\n ELSE\n oBrw:Up()\n ENDIF\n EXIT\n\n#ifndef HB_CLP_STRICT\n CASE K_MWBACKWARD\n#endif\n CASE K_DOWN\n IF lAppend\n oBrw:HitBottom := .T.\n ELSE\n oBrw:Down()\n ENDIF\n EXIT\n\n CASE K_PGUP\n IF lAppend\n lRefresh := .T.\n ELSE\n oBrw:PageUp()\n ENDIF\n EXIT\n\n CASE K_PGDN\n IF lAppend\n oBrw:HitBottom := .T.\n ELSE\n oBrw:PageDown()\n ENDIF\n EXIT\n\n CASE K_CTRL_PGUP\n IF lAppend\n lRefresh := .T.\n ELSE\n oBrw:GoTop()\n ENDIF\n EXIT\n\n CASE K_CTRL_PGDN\n IF lAppend\n lRefresh := .T.\n ELSE\n oBrw:GoBottom()\n ENDIF\n EXIT\n\n CASE K_LEFT\n oBrw:Left()\n EXIT\n\n CASE K_RIGHT\n oBrw:Right()\n EXIT\n\n CASE K_HOME\n oBrw:Home()\n EXIT\n\n CASE K_END\n oBrw:End()\n EXIT\n\n CASE K_CTRL_LEFT\n oBrw:panLeft()\n EXIT\n\n CASE K_CTRL_RIGHT\n oBrw:panRight()\n EXIT\n\n CASE K_CTRL_HOME\n oBrw:panHome()\n EXIT\n\n CASE K_CTRL_END\n oBrw:panEnd()\n EXIT\n\n CASE K_INS\n IF lAppend\n SetCursor( iif( ReadInsert( ! ReadInsert() ), ;\n SC_NORMAL, SC_INSERT ) )\n ENDIF\n EXIT\n\n CASE K_DEL\n IF RecNo() != LastRec() + 1\n IF Deleted()\n dbRecall()\n ELSE\n dbDelete()\n ENDIF\n ENDIF\n EXIT\n\n CASE K_ENTER\n IF lAppend .OR. RecNo() != LastRec() + 1\n lKeyPressed := ( nKey := DoGet( oBrw, lAppend ) ) != 0\n ELSE\n nKey := K_DOWN\n lKeyPressed := .T.\n ENDIF\n EXIT\n\n CASE K_ESC\n lContinue := .F.\n EXIT\n\n OTHERWISE\n IF ! hb_keyChar( nKey ) == \"\"\n hb_keyIns( nKey )\n nKey := K_ENTER\n lKeyPressed := .T.\n ENDIF\n ENDSWITCH\n\n IF lRefresh\n lRefresh := lAppend := .F.\n FreshOrder( oBrw )\n SetCursor( SC_NONE )\n ENDIF\n\n ENDDO\n\n RestScreen( nTop, nLeft, nBottom, nRight, cOldScreen )\n SetCursor( nOldCursor )\n\n RETURN .T.\n\nSTATIC PROCEDURE StatLine( oBrw, lAppend )\n\n LOCAL nTop := oBrw:nTop - 1\n LOCAL nRight := oBrw:nRight\n\n LOCAL nRecNo := RecNo()\n LOCAL nLastRec := LastRec()\n\n hb_DispOutAt( nTop, nRight - 27, \"Record \" )\n\n IF nLastRec == 0 .AND. ! lAppend\n hb_DispOutAt( nTop, nRight - 20, \"<none> \" )\n ELSEIF nRecNo == nLastRec + 1\n hb_DispOutAt( nTop, nRight - 40, \" \" )\n hb_DispOutAt( nTop, nRight - 20, \" <new>\" )\n ELSE\n hb_DispOutAt( nTop, nRight - 40, iif( Deleted(), \"<Deleted>\", \" \" ) )\n hb_DispOutAt( nTop, nRight - 20, PadR( hb_ntos( nRecNo ) + \"/\" + ;\n hb_ntos( nLastRec ), 16 ) + ;\n iif( oBrw:HitTop, \"<bof>\", \" \" ) )\n ENDIF\n\n RETURN\n\nSTATIC FUNCTION DoGet( oBrw, lAppend )\n\n LOCAL lScore, lExit, bIns, nCursor\n LOCAL oCol, oGet\n LOCAL cIndexKey, cForExp, xKeyValue\n LOCAL bIndexKey\n LOCAL lSuccess, nKey, xValue\n\n oBrw:HitTop := .F.\n StatLine( oBrw, lAppend )\n oBrw:ForceStable()\n\n lScore := Set( _SET_SCOREBOARD, .F. )\n lExit := Set( _SET_EXIT, .T. )\n bIns := SetKey( K_INS, {|| SetCursor( iif( ReadInsert( ! ReadInsert() ), ;\n SC_NORMAL, SC_INSERT ) ) } )\n nCursor := SetCursor( iif( ReadInsert(), SC_INSERT, SC_NORMAL ) )\n IF ! Empty( cIndexKey := IndexKey( 0 ) )\n xKeyValue := Eval( bIndexKey := hb_macroBlock( cIndexKey ) )\n ENDIF\n\n oCol := oBrw:GetColumn( oBrw:ColPos )\n xValue := Eval( oCol:Block )\n oGet := GetNew( Row(), Col(), ;\n {| xNewVal | iif( PCount() == 0, xValue, xValue := xNewVal ) }, ;\n \"mGetVar\", NIL, oBrw:ColorSpec )\n lSuccess := .F.\n IF ReadModal( { oGet } )\n IF lAppend .AND. RecNo() == LastRec() + 1\n dbAppend()\n ENDIF\n Eval( oCol:Block, xValue )\n\n IF ! lAppend .AND. ! Empty( cForExp := ordFor( IndexOrd() ) ) .AND. ;\n ! Eval( hb_macroBlock( cForExp ) )\n dbGoTop()\n ENDIF\n IF ! lAppend .AND. ! Empty( bIndexKey ) .AND. ! xKeyValue == Eval( bIndexKey )\n lSuccess := .T.\n ENDIF\n ENDIF\n\n IF lSuccess\n FreshOrder( oBrw )\n nKey := 0\n ELSE\n oBrw:RefreshCurrent()\n nKey := ExitKey( lAppend )\n ENDIF\n\n IF lAppend\n oBrw:ColorRect( { oBrw:RowPos, 1, oBrw:RowPos, oBrw:ColCount }, ;\n { 2, 2 } )\n ENDIF\n\n SetCursor( nCursor )\n SetKey( K_INS, bIns )\n Set( _SET_EXIT, lExit )\n Set( _SET_SCOREBOARD, lScore )\n\n RETURN nKey\n\nSTATIC FUNCTION ExitKey( lAppend )\n\n LOCAL nKey\n\n SWITCH nKey := LastKey()\n CASE K_PGDN\n RETURN iif( lAppend, 0, K_DOWN )\n CASE K_PGUP\n RETURN iif( lAppend, 0, K_UP )\n CASE K_DOWN\n CASE K_UP\n RETURN nKey\n ENDSWITCH\n\n RETURN iif( nKey == K_ENTER .OR. !( hb_keyChar( nKey ) == \"\" ), K_RIGHT, 0 )\n\nSTATIC PROCEDURE FreshOrder( oBrw )\n\n LOCAL nRec := RecNo()\n\n oBrw:RefreshAll()\n oBrw:ForceStable()\n\n IF nRec != LastRec() + 1\n DO WHILE RecNo() != nRec .AND. ! Bof()\n oBrw:Up()\n oBrw:ForceStable()\n ENDDO\n ENDIF\n\n RETURN\n\nSTATIC FUNCTION Skipped( nRecs, lAppend )\n\n LOCAL nSkipped := 0\n\n IF LastRec() != 0\n DO CASE"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/tests/udpds.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbmisc\"\n\nPROCEDURE Main( cParam )\n\n LOCAL h\n\n IF ! hb_mtvm()\n ? \"This sample should be compiled using MultiThread\"\n RETURN\n ENDIF\n\n IF cParam == NIL\n ? \"udpdstst {c|s|cs}\"\n ? \"Parameter:\"\n ? \" s - run as a server\"\n ? \" c - run as a client\"\n RETURN\n ENDIF\n\n IF \"S\" $ Upper( cParam )\n IF ! Empty( h := hb_udpds_Start( 39999, \"UDPDSDemo\", NetName() + \" \" + hb_TSToStr( hb_DateTime() ) ) )\n hb_idleSleep( 0.1 )\n ENDIF\n ENDIF\n\n IF \"C\" $ Upper( cParam )\n ? hb_ValToExp( hb_udpds_Find( 39999, \"UDPDSDemo\" ) )\n ENDIF\n\n IF \"S\" $ Upper( cParam )\n ? \"Press any key to stop server\"\n Inkey( 0 )\n hb_udpds_Stop( h )\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/mt/mttest10.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n\n#ifdef __PLATFORM__WINDOWS\n REQUEST HB_GT_WVT_DEFAULT\n #define THREAD_GT hb_gtVersion()\n#else\n REQUEST HB_GT_STD_DEFAULT\n #define THREAD_GT \"XWC\"\n#endif\n\nproc main( cGT )\n local i, aThreads\n\n if ! hb_mtvm()\n ? \"This program needs HVM with MT support\"\n quit\n endif\n\n if empty( cGT )\n cGT := THREAD_GT\n endif\n\n if cGT == \"QTC\" .and. ! cGT == hb_gtVersion()\n \n hb_gtReload( cGT )\n endif\n\n ? \"Starting threads...\"\n aThreads := {}\n for i := 1 to 3\n aadd( aThreads, hb_threadStart( @thFunc(), cGT ) )\n ? i, \"=>\", atail( aThreads )\n next\n\n ? \"Waiting for threads\"\n while inkey() != K_ESC\n if hb_threadWait( aThreads, 0.1, .T. ) == len( aThreads )\n wait\n exit\n endif\n ?? \".\"\n enddo\nreturn\n\nproc thFunc( cGT )\n \n hb_gtReload( cGT )\n if ! dbExists( \"test\" ) .and. dbExists( \"../test\" )\n use ../test shared\n else\n use test shared\n endif\n browse()\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": "Generate Harbour code for: Harbour contribution module 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/charlist.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 CharList()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharList( \"Hello World !\" ) == \"Helo Wrd!\" ? -> \"' + CharList( \"Hello World !\" ) + '\"'\n ? ' CharList( NIL ) == \"\" ? -> \"' + CharList( NIL ) + '\"'\n\n ? \"End test of CharList()\"\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/gfx2.prg. 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 nRed, nGreen, nBlue\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#else\n# if defined( __PLATFORM__WINDOWS )\n REQUEST HB_GT_WVT_DEFAULT\n# elif defined( __PLATFORM__UNIX )\n REQUEST HB_GT_XWC_DEFAULT\n# endif\n#endif\n\n ? \"GT\" + hb_gtVersion()\n IF ! hb_gtInfo( HB_GTI_ISGRAPHIC )\n ? \"You are using a non graphics capable gt\"\n QUIT\n ENDIF\n\n\n nRed := hb_gfxMakeColor( 200, 32, 32 )\n nGreen := hb_gfxMakeColor( 32, 200, 32 )\n nBlue := hb_gfxMakeColor( 32, 32, 200 )\n\n hb_gfxLine( 100, 300, 200, 400, nRed )\n WAIT\n hb_gfxLine( 200, 300, 100, 400, nBlue )\n WAIT\n hb_gfxLine( 100, 420, 200, 320, nGreen )\n WAIT\n hb_gfxLine( 200, 420, 100, 320, nGreen )\n WAIT\n hb_gfxRect( 100, 300, 200, 420, nRed )\n WAIT\n hb_gfxRect( 90, 290, 210, 430, nBlue )\n WAIT\n hb_gfxLine( 100, 450, 100, 550, nRed )\n hb_gfxLine( 100, 550, 200, 550, nRed )\n hb_gfxLine( 200, 550, 200, 450, nRed )\n hb_gfxLine( 200, 450, 100, 450, nRed )\n WAIT\n hb_gfxRect( 100, 450, 200, 550, nGreen )\n WAIT\n\n hb_gfxFilledRect( 220, 300, 320, 400, nRed )\n WAIT\n hb_gfxRect( 219, 449, 321, 551, nRed )\n WAIT\n hb_gfxFilledRect( 320, 550, 220, 450, nGreen )\n WAIT\n hb_gfxRect( 230, 310, 310, 390, nGreen )\n WAIT\n hb_gfxCircle( 270, 350, 40, nBlue )\n WAIT\n hb_gfxFilledCircle( 270, 500, 50, nBlue )\n WAIT\n\n hb_gfxRect( 329, 299, 391, 501, nRed )\n hb_gfxFilledRect( 330, 300, 390, 500, nBlue )\n WAIT\n hb_gfxFilledEllipse( 360, 400, 30, 100, nGreen )\n WAIT\n hb_gfxEllipse( 360, 400, 15, 50, nRed )\n WAIT\n\n hb_gfxRect( 0, 0, hb_gtInfo( HB_GTI_SCREENHEIGHT ) - 1, ;\n hb_gtInfo( HB_GTI_SCREENWIDTH ) - 1, nGreen )\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 test program: tests/tb1.prg. Contains procedures: Main, hb_idleSleep. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n#include \"button.ch\"\n#include \"setcurs.ch\"\n#include \"box.ch\"\n\n#ifdef __HARBOUR__\n #define _DRAW_1 hb_UTF8ToStr( \"├\" )\n #define _DRAW_2 hb_UTF8ToStr( \"┤\" )\n #define _DRAW_3 hb_UTF8ToStrBox( \"┐ ┌─\" )\n #define _DRAW_4 hb_UTF8ToStrBox( \"┘ └─\" )\n #define _DRAW_5 hb_UTF8ToStrBox( \"│ │\" )\n #define _DRAW_6 hb_UTF8ToStrBox( \"┐ ┌─┤HIDE├─\" )\n #define _DRAW_7 hb_UTF8ToStrBox( \"╖ ╓─┤HIDE├─\" )\n #define _DRAW_8 hb_UTF8ToStrBox( \"╜ ╙─\" )\n #define _DRAW_9 hb_UTF8ToStrBox( \"║ ║\" )\n#else\n #define _DRAW_1 Chr( 195 )\n #define _DRAW_2 Chr( 180 )\n #define _DRAW_3 Chr( 191 ) + \" \" + Chr( 218 ) + Chr( 196 )\n #define _DRAW_4 Chr( 217 ) + \" \" + Chr( 192 ) + Chr( 196 )\n #define _DRAW_5 Chr( 179 ) + \" \" + Chr( 179 )\n #define _DRAW_6 Chr( 191 ) + \" \" + Chr( 218 ) + Chr( 196 ) + \"HIDE\" + Chr( 195 ) + Chr( 196 )\n #define _DRAW_7 Chr( 183 ) + \" \" + Chr( 214 ) + Chr( 196 ) + \"HIDE\" + Chr( 195 ) + Chr( 196 )\n #define _DRAW_8 Chr( 189 ) + \" \" + Chr( 211 ) + Chr( 196 )\n #define _DRAW_9 Chr( 186 ) + \" \" + Chr( 186 )\n #define hb_keyCode( n ) Asc( n )\n#endif\n\nPROCEDURE Main()\n\n STATIC s_nCount := 0\n STATIC s_nPos := 1\n STATIC s_nSize := 100\n\n LOCAL nTop, nLeft, nBottom, nRight\n LOCAL cColor\n LOCAL oBrw, oCol1, oCol2, oCol3, oCol4\n LOCAL nKey, nCol\n\n nTop := 2\n nLeft := 10\n nBottom := 20\n nRight := 70\n cColor := \"W+/R,G+/BR,RG+/B,BG+/G,N/GR,GR+/BG,B/GR*\"\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n \n#ifdef _SET_EVENTMASK\n Set( _SET_EVENTMASK, INKEY_ALL )\n MSetCursor( .T. )\n#endif\n\n\n CLS\n#ifdef HB_B_DOUBLE_SINGLE_UNI\n DispBox( nTop, nLeft, nBottom, nRight, HB_B_DOUBLE_SINGLE_UNI, cColor )\n#else\n DispBox( nTop, nLeft, nBottom, nRight, B_DOUBLE_SINGLE, cColor )\n#endif\n oBrw := TBrowseNew( nTop + 1, nLeft + 1, nBottom - 1, nRight - 1 )\n DispOutAt( nTop + 3, nLeft, _DRAW_1, cColor )\n DispOutAt( nTop + 3, nRight, _DRAW_2, cColor )\n DispOutAt( nBottom - 2, nLeft, _DRAW_1, cColor )\n DispOutAt( nBottom - 2, nRight, _DRAW_2, cColor )\n\n oBrw:colorSpec := cColor\n oBrw:headSep := _DRAW_3\n oBrw:footSep := _DRAW_4\n oBrw:colSep := _DRAW_5\n\n oBrw:SkipBlock := {| n | hb_idleSleep( 0.2 ), ;\n n := iif( n < 0, Max( n, 1 - s_nPos ), ;\n Min( s_nSize - s_nPos, n ) ), ;\n s_nPos += n, n }\n oBrw:GoTopBlock := {|| s_nPos := 1 }\n oBrw:GoBottomBlock := {|| s_nPos := s_nSize }\n\n oCol1 := TBColumnNew( \"COL;1;\", {|| s_nPos } )\n oCol1:defColor := { 2, 1, 3, 4 }\n oCol1:footing := \"position\"\n oCol1:colorBlock := {| val | { val % 5 + 1, val % 3 + 2 } }\n\n oCol2 := TBColumnNew( \"COL;2\", {|| s_nCount++ } )\n oCol2:defColor := { 3, 4, 5, 6 }\n oCol2:footing := \"counter\"\n oCol2:headSep := _DRAW_6\n\n oCol3 := TBColumnNew( \"COL 3\", {|| s_nPos % 3 == 0 } )\n oCol3:defColor := { 5, 6, 2, 3 }\n oCol3:footing := \"logical\"\n oCol3:picture := \"@YR [Y]\" \n oCol3:headSep := _DRAW_7\n oCol3:footSep := _DRAW_8\n oCol3:colSep := _DRAW_9\n\n oCol4 := TBColumnNew( \" SHOW; ALL\", {|| Date() - s_nPos } )\n oCol4:defColor := { 6, 3, 4, 2 }\n oCol4:footing := \"date\"\n\n oBrw:addColumn( oCol1 )\n oBrw:addColumn( oCol2 )\n oBrw:addColumn( oCol3 )\n oBrw:addColumn( oCol4 )\n\n \n oBrw:goBottom()\n\n WHILE .T.\n WHILE ! oBrw:stabilize() .AND. NextKey() == 0\n ENDDO\n nKey := Inkey( 0 )\n IF nKey == K_ESC\n EXIT\n ELSEIF nKey == K_INS\n oBrw:colorRect( { oBrw:rowPos, 1, oBrw:rowPos, 4 }, { 7, 6 } )\n ELSEIF nKey == K_DEL\n oBrw:refreshCurrent()\n ELSEIF nKey >= hb_keyCode( \"0\" ) .AND. nKey <= hb_keyCode( \"3\" )\n oBrw:freeze := nKey - hb_keyCode( \"0\" )\n ELSEIF nKey == K_LBUTTONDOWN .AND. ;\n oBrw:HitTest( MRow(), MCol() ) == HTHEADSEP .AND. ;\n ( ( nCol := oBrw:mColPos ) == 2 .OR. nCol == 3 )\n IF nCol == 2\n oCol2:width := 0\n ELSE\n oCol3:width := 0\n ENDIF\n oBrw:configure()\n ELSEIF nKey == K_LBUTTONDOWN .AND. ;\n oBrw:HitTest( MRow(), MCol() ) == HTHEADING .AND. ;\n oBrw:mColPos == 4\n oCol2:width := 10\n oCol3:width := 7\n oBrw:configure()\n ELSE\n oBrw:applyKey( nKey )\n ENDIF\n ENDDO\n\n RETURN\n\n#ifndef __HARBOUR__\n\nPROCEDURE hb_idleSleep( n )\n\n n += Seconds()\n WHILE Seconds() < n\n ENDDO\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 'hblzf' (LZF compression library): contrib/hblzf/tests/test2.prg. Contains procedures: Main, MakeTest. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbbz2\"\n#require \"hblzf\"\n\n#define _NREPL_ 50\n\nPROCEDURE Main()\n\n LOCAL cStr := Replicate( hb_MemoRead( hb_argv( 0 ) ), _NREPL_ )\n LOCAL aCompressedData := { NIL, NIL, NIL, NIL }\n LOCAL hFuncs := { ;\n \"GZIP\" => @hb_gzCompress(), ;\n \"ZLIB\" => @hb_ZCompress(), ;\n \"BZ2 \" => @hb_bz2_Compress(), ;\n \"LZF \" => @hb_lzf_compress();\n }\n LOCAL hFuncs2 := { ;\n \"GZIP\" => @hb_ZUncompress(), ;\n \"ZLIB\" => @hb_ZUncompress(), ;\n \"BZ2 \" => @hb_bz2_Uncompress(), ;\n \"LZF \" => @hb_lzf_decompress();\n }\n\n MakeTest( @hFuncs, @aCompressedData, @cStr )\n MakeTest( @hFuncs2, @aCompressedData )\n\n RETURN\n\nSTATIC PROCEDURE MakeTest( ... )\n\n LOCAL e, e2, cRes, cFmt\n LOCAL nResult := 0\n LOCAL nBegin, nEnd\n LOCAL lCmp := ( PCount() > 2 )\n\n FOR EACH e, e2 IN hb_PValue( 1 ), hb_PValue( 2 )\n nBegin := hb_SecondsCPU()\n cRes := Eval( e:__enumValue(), iif( lCmp, hb_PValue( 3 ), e2 ), NIL, @nResult )\n nEnd := hb_SecondsCPU()\n IF lCmp\n e2 := cRes\n ENDIF\n cFmt := hb_StrFormat( ;\n \"%s: %d -> %d, Ratio %.2f%%, Times %.2f\", ;\n e:__enumKey(), ;\n Len( iif( lCmp, hb_PValue( 3 ), e2 ) ), Len( cRes ), ;\n ( Len( cRes ) / Len( iif( lCmp, hb_PValue( 3 ), e2 ) ) )"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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_TRANS. Harbour utility program: utils/hbtest/rt_trans.prg. Contains procedures: Main_TRANS. 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_TRANS()\n\n LOCAL cOldDate := Set( _SET_DATEFORMAT )\n LOCAL cOldFixed := Set( _SET_FIXED )\n LOCAL cOldDecim := Set( _SET_DECIMALS )\n LOCAL dt, df\n\n \n HBTEST Transform( NIL , NIL ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:U:NIL;U:NIL F:S\"\n HBTEST Transform( NIL , \"\" ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:U:NIL;C: F:S\"\n HBTEST Transform( NIL , \"@\" ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:U:NIL;C:@ F:S\"\n HBTEST Transform( {} , NIL ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:A:{.[0].};U:NIL F:S\"\n HBTEST Transform( {} , \"\" ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:A:{.[0].};C: F:S\"\n HBTEST Transform( {} , \"@\" ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:A:{.[0].};C:@ F:S\"\n HBTEST Transform( ErrorNew(), NIL ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:O:ERROR Object;U:NIL F:S\"\n HBTEST Transform( ErrorNew(), \"\" ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:O:ERROR Object;C: F:S\"\n HBTEST Transform( ErrorNew(), \"@\" ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:O:ERROR Object;C:@ F:S\"\n HBTEST Transform( {|| NIL } , NIL ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:B:{||...};U:NIL F:S\"\n HBTEST Transform( {|| NIL } , \"\" ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:B:{||...};C: F:S\"\n HBTEST Transform( {|| NIL } , \"@\" ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:B:{||...};C:@ F:S\"\n\n HBTEST Transform( \"\", \"\" ) IS \"\"\n HBTEST Transform( \"\", \"@\" ) IS \"\"\n#ifndef __XPP__\n HBTEST Transform( \"\", NIL ) IS \"\"\n#endif\n HBTEST Transform( \"\", 100 ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:C:;N:100 F:S\"\n HBTEST Transform( \"hello\", \"\" ) IS \"hello\"\n HBTEST Transform( \"hello\", \"@\" ) IS \"hello\"\n#ifndef __XPP__\n HBTEST Transform( \"hello\", NIL ) IS \"hello\"\n#endif\n HBTEST Transform( \"hello\", 100 ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:C:hello;N:100 F:S\"\n HBTEST Transform( 100.2, \"\" ) IS \" 100.2\"\n HBTEST Transform( 100.2, \"@\" ) IS \" 100.2\"\n#ifndef __XPP__\n HBTEST Transform( 100.2, NIL ) IS \" 100.2\"\n#endif\n HBTEST Transform( 100.2, 100 ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:N:100.2;N:100 F:S\"\n HBTEST Transform( 100.20, \"\" ) IS \" 100.20\"\n HBTEST Transform( 100.20, \"@\" ) IS \" 100.20\"\n#ifndef __XPP__\n HBTEST Transform( 100.20, NIL ) IS \" 100.20\"\n#endif\n HBTEST Transform( 100.20, 100 ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:N:100.20;N:100 F:S\"\n HBTEST Transform( Val( \"100.2\" ), \"\" ) IS \"100.2\"\n HBTEST Transform( Val( \"100.2\" ), \"@\" ) IS \"100.2\"\n#ifndef __XPP__\n HBTEST Transform( Val( \"100.2\" ), NIL ) IS \"100.2\"\n#endif\n HBTEST Transform( Val( \"100.2\" ), 100 ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:N:100.2;N:100 F:S\"\n HBTEST Transform( Val( \"100.20\" ), \"\" ) IS \"100.20\"\n\n#ifndef __XPP__\n HBTEST Transform( Val( \"100.20\" ), NIL ) IS \"100.20\"\n#endif\n HBTEST Transform( Val( \"100.20\" ), 100 ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:N:100.20;N:100 F:S\"\n HBTEST Transform( sdDate, \"\" ) IS \"1984-03-25\"\n HBTEST Transform( sdDate, \"@\" ) IS \"1984-03-25\"\n#ifndef __XPP__\n HBTEST Transform( sdDate, NIL ) IS \"1984-03-25\"\n#endif\n HBTEST Transform( sdDate, 100 ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:D:0d19840325;N:100 F:S\"\n HBTEST Transform( .T., \"\" ) IS \"T\"\n HBTEST Transform( .T., \"@\" ) IS \"T\"\n#ifndef __XPP__\n HBTEST Transform( .F., NIL ) IS \"F\"\n#endif\n HBTEST Transform( .F., 100 ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:L:.F.;N:100 F:S\"\n\n HBTEST Transform( scStringM, \"!!!!!\" ) IS \"HELLO\"\n HBTEST Transform( scStringM, \"@!\" ) IS \"HELLO\"\n#ifdef __HARBOUR__\n HBTEST Transform( @scStringM, \"!!!!!\" ) IS \"HELLO\" \n HBTEST Transform( @scStringM, \"@!\" ) IS \"HELLO\" \n#endif\n HBTEST Transform( scStringM, \"\" ) IS \"Hello\"\n#ifndef __XPP__\n HBTEST Transform( scStringM, NIL ) IS \"Hello\"\n#endif\n HBTEST Transform( scStringM, 100 ) IS \"E 1 BASE 1122 Argument error (TRANSFORM) OS:0 #:0 A:2:C:Hello;N:100 F:S\"\n\n HBTEST Transform( \"abcdef\", \"@! !lkm!\" ) IS \"ABkmE\"\n HBTEST Transform( \"abcdefghijklmnopqrstuvwxyz\", \"@! 1234567890\" ) IS \"12345678I0\"\n HBTEST Transform( \"abcdefghijklmnopqrstuvwxyzabcdefg\", \"@! abcdefghijklmnopqrstuvwxyzabcdefg\" ) IS \"AbcdefghijkLmNopqrstuvwXYzAbcdefg\"\n HBTEST Transform( \"abcdefghijklmnopqrstuvwxyz\", \"@! `~!@#$% ^&*()_+-={}\\|;':\" ) IS \"`~C@E$% ^&*()_+-={}\\|;':\"\n HBTEST Transform( \"abcdefghijklmnopqrstuvwxyz\", \"@! ,./<>?\" ) IS \",./<>?\"\n HBTEST Transform( \"hello\", \" @!\" ) IS \" @L\"\n\n HBTEST Transform( \"abcdef\", \"@R! !lkm!\" ) IS \"ABkmC\"\n HBTEST Transform( \"abcdefghijklmnopqrstuvwxyz\", \"@R! 1234567890\" ) IS \"12345678A0\"\n HBTEST Transform( \"abcdefghijklmnopqrstuvwxyzabcdefg\", \"@R! abcdefghijklmnopqrstuvwxyzabcdefg\" ) IS \"AbcdefghijkBmCopqrstuvwDNzFbcdefg\"\n HBTEST Transform( \"abcdefghijklmnopqrstuvwxyz\", \"@R! `~!@#$% ^&*()_+-={}\\|;':\" ) IS \"`~A@B$% ^&*()_+-={}\\|;':\"\n HBTEST Transform( \"abcdefghijklmnopqrstuvwxyz\", \"@R! ,./<>?\" ) IS \",./<>?ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n HBTEST Transform( \"hello\", \" @R!\" ) IS \" @RL\"\n\n HBTEST Transform( \"abc\", \"@R !!!!\" ) IS \"ABC \"\n HBTEST Transform( \"abc\", \"@R XXXX\" ) IS \"abc \"\n HBTEST Transform( \"abc\", \"@R !!\" ) IS \"AB\"\n HBTEST Transform( \"abc\", \"@R XX\" ) IS \"ab\"\n HBTEST Transform( \"abc\", \"@!R !!!!\" ) IS \"ABC \"\n HBTEST Transform( \"abc\", \"@!R XXXX\" ) IS \"ABC \"\n HBTEST Transform( \"abc\", \"@!R !!\" ) IS \"AB\"\n HBTEST Transform( \"abc\", \"@!R XX\" ) IS \"AB\"\n\n HBTEST Transform( \"Hallo \", \"!!!!!\" ) IS \"HALLO\"\n HBTEST Transform( \"Hallo \", \"!!A!!\" ) IS \"HAlLO\"\n HBTEST Transform( \"Hallo \", \"!!A9!\" ) IS \"HAllO\"\n HBTEST Transform( \"Hallo \", \"!QA9!\" ) IS \"HQllO\"\n HBTEST Transform( \"Hallo \", \"ZQA9!\" ) IS \"ZQllO\"\n HBTEST Transform( \"Hall\" , \"ZQA9!\" ) IS \"ZQll\"\n HBTEST Transform( \"Hallo \", \"!AAA\" ) IS \"Hall\"\n HBTEST Transform( \"Hallo \", \"@!\" ) IS \"HALLO \"\n HBTEST Transform( \"Hallo \", \"@! AA\" ) IS \"HA\"\n HBTEST Transform( \"Hallo \", \"@R\" ) IS \"Hallo \"\n HBTEST Transform( \"Hallo \", \"@Z\" ) IS \" \"\n HBTEST Transform( \"Hallo \", \"@R !!\" ) IS \"HA\"\n HBTEST Transform( \"Hi\" , \"@R !!!\" ) IS \"HI \"\n HBTEST Transform( \"Hallo \", \"\" ) IS \"Hallo \"\n\n HBTEST Transform( .T. , \"\" ) IS \"T\"\n HBTEST Transform( .F. , \"\" ) IS \"F\"\n HBTEST Transform( .T. , \"L\" ) IS \"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": "Define Harbour macros and constants: Harbour contribution module 'hbsqlit3' (SQLite3 database client library): contrib/hbsqlit3/tests/hdbc.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbsqlit3\"\n\n#define _NUMROWS_ 10\n\nPROCEDURE Main()\n\n LOCAL oConn, oMeta, oStmt, cSql, n, oRs\n\n oConn := hdbcSQLTConnection():New( \"test.db\", .T. )\n\n oMeta := oConn:getMetaData()\n\n ? hb_ValToExp( oMeta:getTables() )\n\n IF AScan( oMeta:getTables(), {| a | \"test\" == a[ 3 ] } ) > 0\n ? \"test table already exist let's drop it\"\n oStmt := oConn:createStatement()\n oStmt:executeUpdate( \"DROP TABLE test\" )\n oStmt:Close()\n ? \"dropped\"\n ENDIF\n\n ? \"Creating test table...\"\n cSql := \"CREATE TABLE test(\"\n cSql += \" Code integer not null primary key, \"\n cSql += \" dept Integer, \"\n cSql += \" Name Varchar (40), \"\n cSql += \" Sales boolean, \"\n cSql += \" Tax Float4, \"\n cSql += \" Salary Double Precision, \"\n cSql += \" Budget Numeric (12,2), \"\n cSql += \" Discount Numeric (5,2), \"\n cSql += \" Creation Date, \"\n cSql += \" Description text ) \"\n\n oStmt := oConn:createStatement()\n oStmt:executeUpdate( cSql )\n oStmt:Close()\n ? \"created\"\n\n ? \"Inserting, declared transaction control \"\n oConn:StartTransaction()\n\n ? \"Inserting using direct statement...\"\n\n ? Time()\n FOR n := 1 TO _NUMROWS_\n cSql := \"INSERT INTO test(code, dept, name, sales, tax, salary, budget, Discount, Creation, Description) \"\n cSql += \"VALUES( \" + Str( n ) + \", 2, 'TEST', '\" + iif( n % 2 != 0, \"y\", \"n\" ) + \"', 5, 3000, 1500.2, 7.5, '12-22-2003', 'Short Description ')\"\n\n oStmt := oConn:createStatement()\n oStmt:executeUpdate( cSql )\n\n oStmt:close()\n NEXT\n ? Time()\n\n\n oConn:Commit()\n\n oStmt := oConn:createStatement()\n\n ? \"Excecuting query\"\n\n oRs := oStmt:executeQuery( \"SELECT code, name, description, sales FROM test\" )\n\n ? \"Showing metadata\"\n\n ? oRs:getMetaData():getColumnCount()\n\n ? \"Showing results\"\n\n ? \"nRows\", oRs:nRows\n ? \"getrow\", oRs:getRow()\n ? \"isbeforefirst\", oRs:isBeforeFirst()\n ? \"next\", oRs:next()\n ? \"isfirst\", oRs:isFirst()\n ? \"getrow\", oRs:getRow()\n ? \"previous\", oRs:previous()\n ? \"getrow\", oRs:getRow()\n ? \"first\", oRs:first()\n ? \"getrow\", oRs:getRow()\n ? \"last\", oRs:last()\n ? \"getrow\", oRs:getRow()\n ? \"isbeforefirst\", oRs:isBeforeFirst()\n oRs:beforeFirst()\n\n ? \"ascending\"\n\n DO WHILE oRs:next()\n ? oRs:getrow(), oRs:getString( \"code\" ), oRs:getString( \"name\" ), oRs:getString( \"description\" ), oRs:getBoolean( \"sales\" )\n ENDDO\n\n ? \"isafterlast\", oRs:isAfterLast()\n\n oRs:AfterLast()\n\n ? \"descending\"\n\n DO WHILE oRs:previous()\n ? oRs:getrow(), oRs:getString( \"code\" ), oRs:getString( \"name\" ), oRs:getString( \"description\" ), oRs:getBoolean( \"sales\" )\n ENDDO\n\n ? \"isbeforefirst\", oRs:isBeforeFirst()\n\n oRs:Close()\n\n oStmt:Close()\n\n ? hb_ValToExp( oConn:getMetaData():getPrimaryKeys( \"\", \"public\", \"test\" ) )\n\n oStmt := oConn:createStatement()\n\n ? \"Excecuting query\"\n\n oRs := oStmt:executeQuery( \"SELECT * FROM test\" )\n\n oRs:setTableName( \"TEST\" )\n oRs:setPrimaryKeys( { { \"code\", \"N\" } } )\n\n oRs:moveToInsertRow()\n oRs:updateNumber( 1, 11 )\n oRs:updateString( \"description\", \"Inserted\" )\n oRs:insertRow()\n\n oRs:first()\n oRs:updateNumber( 8, 99.99 )\n oRs:updateDate( 9, Date() )\n oRs:updateString( \"description\", \"Updated\" )\n oRs:updateRow()\n\n oRs:next()\n oRs:deleteRow()\n oRs:next()\n oRs:deleteRow()\n\n oRs:Close()\n\n oRs := oStmt:executeQuery( \"SELECT * FROM test order by code\" )\n\n DO WHILE oRs:next()\n ? oRs:getrow(), oRs:getString( \"code\" ), oRs:getString( \"name\" ), oRs:getString( \"description\" ), oRs:getBoolean( \"sales\" ), oRs:getString( \"Creation\" )\n ENDDO\n\n oRs:close()\n oStmt:close()\n\n\n oConn:Close()\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 Harbour functions: dbModifyStructure, dbImport, dbMerge. Harbour contribution module 'xhb' (Extended Harbour functions): contrib/xhb/xdbmodst.prg. Provides functions: dbModifyStructure, dbImport, dbMerge. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#include \"dbstruct.ch\"\n\n#include \"dbinfo.ch\"\n#include \"error.ch\"\n\n#ifndef EG_RENAME\n#define EG_RENAME 26\n#endif\n\n#xtranslate Throw( <oErr> ) => ( Eval( ErrorBlock(), <oErr> ), Break( <oErr> ) )\n\nFUNCTION dbModifyStructure( cFile )\n\n LOCAL lRet\n LOCAL cExt\n LOCAL cTable\n LOCAL cBakFile\n LOCAL cStructureFile\n LOCAL cNewFile\n LOCAL oErr\n LOCAL nPresetArea := Select()\n LOCAL nSourceArea\n LOCAL cDateTime := SubStr( DToS( Date() ), 3 ) + \".\" + StrTran( Left( Time(), 5 ), \":\", \".\" )\n\n BEGIN SEQUENCE WITH {| oErr | Break( oErr ) }\n\n \n USE ( cFile ) ALIAS ModifySource EXCLUSIVE NEW\n nSourceArea := Select()\n\n cFile := dbInfo( DBI_FULLPATH )\n cExt := dbInfo( DBI_TABLEEXT )\n\n hb_FNameSplit( cFile, , @cTable )\n\n cBakFile := cTable + \".bak.\" + cDateTime + cExt\n cStructureFile := cTable + \".str.\" + cDateTime + cExt\n cNewFile := cTable + \".new.\" + cDateTime + cExt\n\n COPY STRUCTURE EXTENDED TO ( cStructureFile )\n\n \n USE ( cStructureFile ) ALIAS NewStructure EXCLUSIVE NEW\n\n Browse( 0, 0, Min( 20, MaxRow() - 1 ), Min( MaxCol() - 30, 50 ) )\n\n PACK\n CLOSE\n\n CREATE ( cNewFile ) FROM ( cStructureFile ) ALIAS NEW_MODIFIED NEW\n\n\n lRet := dbImport( nSourceArea )\n CLOSE\n\n SELECT ( nSourceArea )\n CLOSE\n\n SELECT ( nPresetArea )\n\n \n IF lRet\n IF FRename( cFile, cBakFile ) == -1\n BREAK\n ENDIF\n\n IF FRename( cNewFile, cFile ) == -1\n \n IF FRename( cBakFile, cFile ) == -1\n \n oErr := ErrorNew()\n oErr:severity := ES_ERROR\n oErr:genCode := EG_RENAME\n oErr:subSystem := \"DBCMD\"\n oErr:canDefault := .F.\n oErr:canRetry := .F.\n oErr:canSubtitute := .F.\n oErr:operation := cFile\n oErr:subCode := 1101\n oErr:args := { cNewFile, cBakFile }\n\n BREAK oErr\n ENDIF\n ENDIF\n ENDIF\n\n RECOVER USING oErr\n IF oErr:className() == \"ERROR\"\n IF oErr:genCode == EG_RENAME\n \n lRet := Throw( oErr )\n ELSE\n lRet := .F.\n ENDIF\n ELSE\n lRet := .F.\n ENDIF\n END SEQUENCE\n\n SELECT ( nPresetArea )\n\n RETURN lRet\n\nFUNCTION dbImport( xSource )\n\n RETURN dbMerge( xSource )\n\nFUNCTION dbMerge( xSource, lAppend )\n\n LOCAL nArea, nSource, nRecNo\n LOCAL aFields\n LOCAL cField, xField\n LOCAL nSourcePos, aTranslate := {}, aTranslation\n\n LOCAL cTargetType\n\n \n IF LastRec() > 0\n IF ! lAppend\n RETURN .F.\n ENDIF\n ENDIF\n\n \n IF HB_ISSTRING( xSource )\n nArea := Select()\n\n USE ( xSource ) ALIAS MergeSource EXCLUSIVE NEW\n nSource := Select()\n\n SELECT ( nArea )\n ELSEIF HB_ISNUMERIC( xSource )\n nSource := xSource\n ELSE\n RETURN .F.\n ENDIF\n\n \n IF LastRec() == 0\n APPEND BLANK\n ENDIF\n\n \n aFields := Array( FCount() )\n AFields( aFields )\n\n FOR EACH cField IN aFields\n nSourcePos := ( nSource )->( FieldPos( cField ) )\n\n IF nSourcePos > 0\n BEGIN SEQUENCE WITH {| oErr | Break( oErr ) }\n \n xField := FieldGet( cField:__EnumIndex() )\n\n \n FieldPut( cField:__EnumIndex(), ( nSource )->( FieldGet( nSourcePos ) ) )\n\n \n FieldPut( cField:__EnumIndex(), xField )\n\n \n AAdd( aTranslate, { cField:__EnumIndex(), nSourcePos, {| xSource | xSource } } )\n RECOVER\n cTargetType := ValType( FieldGet( cField:__EnumIndex() ) )\n\n BEGIN SEQUENCE WITH {| oErr | Break( oErr ) }\n \n FieldPut( cField:__EnumIndex(), ValToType( ( nSource )->( FieldGet( nSourcePos ) ), cTargetType ) )\n\n \n FieldPut( cField:__EnumIndex(), xField )\n\n \n AAdd( aTranslate, { cField:__EnumIndex(), nSourcePos, {| xSource | ValToType( xSource, cTargetType ) } } )\n RECOVER\n \n END SEQUENCE\n END SEQUENCE\n ENDIF\n NEXT\n\n \n IF LastRec() == 1 .AND. ! lAppend\n DELETE\n ZAP\n ENDIF\n\n \n nRecNo := ( nSource )->( RecNo() )\n ( nSource )->( dbGoTop() )\n\n WHILE ! ( nSource )->( Eof() )\n APPEND BLANK\n\n FOR EACH aTranslation IN aTranslate\n FieldPut( aTranslation[ 1 ], Eval( aTranslation[ 3 ], ( nSource )->( FieldGet( aTranslation[ 2 ] ) ) ) )\n NEXT\n\n ( nSource )->( dbSkip() )\n ENDDO\n\n ( nSource )->( dbGoto( nRecNo ) )\n\n \n IF ! Empty( nArea )\n SELECT ( nSource )\n CLOSE\n SELECT ( nArea )\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": "Define Harbour macros and constants: Harbour header file: include/hbver.ch. Defines 10 constants including: HB_VER_CH_, HB_VERSION_HARBOUR, HB_VERSION_COMPILER, HB_VERSION_MAJOR, HB_VERSION_MINOR. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_VER_CH_\n#define HB_VER_CH_\n\n\n#define HB_VERSION_HARBOUR 0 \n#define HB_VERSION_COMPILER 1\n#define HB_VERSION_MAJOR 2\n#define HB_VERSION_MINOR 3\n#define HB_VERSION_RELEASE 4\n#define HB_VERSION_STATUS 5\n#define HB_VERSION_REVISION 6\n#define HB_VERSION_COMMIT_INFO 7\n#define HB_VERSION_ID 8\n#define HB_VERSION_PCODE_VER 9\n#define HB_VERSION_PCODE_VER_STR 10\n#define HB_VERSION_BUILD_DATE_STR 11\n#define HB_VERSION_BUILD_DATE 12\n#define HB_VERSION_BUILD_TIME 13\n#define HB_VERSION_BUILD_TIMESTAMP_UTC 30 \n#define HB_VERSION_BUILD_PLAT 22\n#define HB_VERSION_BUILD_COMP 23\n#define HB_VERSION_FLAG_PRG 14\n#define HB_VERSION_FLAG_C 15\n#define HB_VERSION_FLAG_LINKER 16\n#define HB_VERSION_BITWIDTH 17\n#define HB_VERSION_ENDIANNESS 18\n#define HB_VERSION_MT 19\n#define HB_VERSION_SHARED 26\n#define HB_VERSION_UNIX_COMPAT 20\n#define HB_VERSION_PLATFORM 21\n#define HB_VERSION_CPU 24\n#define HB_VERSION_COMPILER_CPP 25\n#define HB_VERSION_URL_BASE 27\n#define HB_VERSION_URL_SOURCE 28\n#define HB_VERSION_OPTIONS 29\n#define HB_VERSION_MAX_ 30\n\n\n#define HB_VERSION_CHANGELOG_LAST HB_VERSION_COMMIT_INFO\n#define HB_VERSION_CHANGELOG_ID HB_VERSION_ID\n\n\n#define HB_VERSION_ENDIAN_LITTLE 1\n#define HB_VERSION_ENDIAN_BIG 2\n#define HB_VERSION_ENDIAN_PDP 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": "Generate Harbour code for: Harbour header file: include/tbrowse.ch. Defines 10 constants including: _TBROWSE_CH, TBR_EXIT, TBR_CONTINUE, TBR_EXCEPTION, TBR_APPEND"}, {"role": "assistant", "content": "#ifndef _TBROWSE_CH\n#define _TBROWSE_CH\n\n\n#define TBR_EXIT -1\n#define TBR_CONTINUE 0\n#define TBR_EXCEPTION 1\n\n\n#define TBR_APPEND 1\n#define TBR_APPENDING 2\n#define TBR_MODIFY 3\n#define TBR_MOVE 4\n#define TBR_SIZE 5\n#define TBR_CUSTOM 6\n\n\n#define TBC_READWRITE 1\n#define TBC_MOVE 2\n#define TBC_SIZE 3\n#define TBC_CUSTOM 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/num1.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 SET DECIMAL TO 14\n\n ?? \"Test of Numeric functions - part 1\"\n\n ? \"Celsius( 33.8 ) = 1 \n ? Space( 10 ), Celsius( 33.8 ), \" <-- CT for Harbour \"\n ?\n\n ? \"Celsius( 338.0 ) = 170 \n ? Space( 11 ), Celsius( 338.0 ), \" <-- CT for Harbour \"\n ?\n\n ? \"Celsius( 3380.0 ) = 1860 \n ? Space( 12 ), Celsius( 3380.0 ), \" <-- CT for Harbour \"\n ?\n\n ? \"Celsius( -33.8 ) = -36.5555.. \n ? Space( 10 ), Celsius( -33.8 ), \" <-- CT for Harbour \"\n ?\n\n ? \"Fahrenheit( 12.5 ) = 54.5 \n ? Space( 12 ), Fahrenheit( 12.5 ), \" <-- CT for Harbour \"\n ?\n\n ? \"Fahrenheit( 125 ) = 257 \n ? Space( 12 ), Fahrenheit( 125 ), \" <-- CT for Harbour \"\n ?\n\n ? \"Fahrenheit( 1250 ) = 2282 \n ? Space( 14 ), Fahrenheit( 1250 ), \" <-- CT for Harbour \"\n ?\n ? \"Fahrenheit( -155 ) = -247 \n ? Space( 14 ), Fahrenheit( -155 ), \" <-- CT for Harbour \"\n ?\n\n ? \"Infinity() \n ? Space( 8 ), Str( Infinity(), 30, 15 ), \" <-- CT for Harbour\"\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 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/finan.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 SET DECIMAL TO 3\n CLS\n ?? \"Testing Financial functions....\"\n ?\n ? \"Calculate how loan summs if you make deposits for $175.00 for 24 months,\"\n ? \"if the annual rate of the Bank for this mortage is 9.5% fixed\"\n ? \"PV( 175, 0.095 / 12, 24 ) = 3811.433 \n ? Space( 21 ), PV( 175, 0.095 / 12, 24 ), \" <-- CT for Harbour\"\n ?\n ?\n\n ? \"Calculate the amount in your account after 3 years, if you make deposits\"\n ? \"for $150.00 per month, and the annual rate of the Bank for this is 6%\"\n ? \"Capital = FV( 150, 0.06 / 12, 36 ) = 5900.416 \n ? Space( 30 ), FV( 150, 0.06 / 12, 36 ), \" <-- CT for Harbour\"\n ?\n ?\n\n ? \"Calculate the monthly payment for a loan of $2000.00 at an annual rate\"\n ? \"of 10%, within 24 month \"\n ? \"Payment( 2000.00, 0.10 / 12, 24 ) = 92.290 \n ? Space( 28 ), Payment( 2000.00, 0.10 / 12, 24 ), \" <-- CT for Harbour\"\n ?\n ? \" PRESS ANY KEY\"\n\n Inkey( 0 )\n ? \"Continue Testing Financial functions....\"\n ?\n ? \"Calculate how many month do you need to cancel a loan of $4000.00 at\"\n ? \"an annual rate of 9.5% with payments of $200.00 max\"\n ? \"Periods( 4000.00, 200.00, 0.095 / 12 ) = 21.859 \n ? Space( 33 ), Periods( 4000.00, 200.00, 0.095 / 12 ), \" <-- CT for Harbour\"\n ?\n ?\n\n ? \"Calculate which is the effective anual rate of your Bank, for a loan\"\n ? \"of $2500.00 if you pay $86.67 per month for 3 years\"\n ? \"Rate( 2500.00, 86.67, 36 )\n ? Space( 24 ), Rate( 2500.00, 86.67, 36 ) * 12.0, \" <-- CT for Harbour\"\n ?\n ? \" PRESS ANY KEY\"\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": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'sddmy' (): contrib/sddmy/tests/test1.prg. Contains procedures: Main, CreateTable. This file handles database operations"}, {"role": "assistant", "content": "#require \"rddsql\"\n#require \"sddmy\"\n\n#include \"dbinfo.ch\"\n#include \"error.ch\"\n\nREQUEST SDDMY, SQLMIX\n\nANNOUNCE RDDSYS\n\nFIELD RESIDENTS\n\nPROCEDURE Main()\n\n#if defined( __HBSCRIPT__HBSHELL )\n rddRegister( \"SQLBASE\" )\n rddRegister( \"SQLMIX\" )\n hb_SDDMY_Register()\n#endif\n\n rddSetDefault( \"SQLMIX\" )\n\n AEval( rddList(), {| x | QOut( x ) } )\n\n IF rddInfo( RDDI_CONNECT, { \"MYSQL\", \"localhost\", \"test\", , \"test\" } ) == 0\n ? \"Unable connect to the server\"\n RETURN\n ENDIF\n\n CreateTable()\n\n ? \"Let's browse table (press any key)\"\n Inkey( 0 )\n dbUseArea( .T., , \"SELECT * FROM country\", \"country\" )\n Browse()\n\n ? \"Let's browse table ordered by resident count (press any key)\"\n Inkey( 0 )\n INDEX ON RESIDENTS TAG residents TO country\n Browse()\n\n dbCloseAll()\n\n RETURN\n\nSTATIC PROCEDURE CreateTable()\n\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\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/tpopuphb.prg. Defines classes: hb_PopupMenu. This file implements menu system classes"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#ifdef HB_COMPAT_C53\n\nCREATE CLASS hb_PopupMenu INHERIT HBPopupMenu\n\n EXPORTED:\n\n METHOD shadowed( lShadowed ) SETGET\n\n METHOD setCoors( nRow, nCol, lTop )\n METHOD isShortCut( nKey, nID )\n METHOD isQuick( nKey, nID )\n\nENDCLASS\n\nMETHOD shadowed( lShadowed ) CLASS hb_PopupMenu\n\n IF lShadowed != NIL\n ::lShadowed := __eInstVar53( Self, \"SHADOWED\", lShadowed, \"L\", 1001 )\n ENDIF\n\n RETURN ::lShadowed\n\nMETHOD setCoors( nRow, nCol, lTop ) CLASS hb_PopupMenu\n\n LOCAL oItem\n LOCAL nDif\n\n ::setMetrics()\n\n IF ::nTop == -1 .OR. ::nLeft == -1\n ::nTop := nRow\n ::nLeft := nCol\n ::nBottom := ::nTop + ::nItemCount + 1\n ::nRight := ::nLeft + ::nWidth - 1\n\n IF ::nRight > MaxCol()\n nDif := ::nRight - MaxCol()\n ::nRight -= nDif\n ::nLeft -= nDif\n IF ! lTop\n ::nTop++\n ::nBottom++\n ENDIF\n ENDIF\n\n IF ::nLeft < 0\n nDif := ::nLeft\n ::nRight -= nDif\n ::nLeft -= nDif\n ENDIF\n\n IF ::nBottom > MaxRow()\n nDif := ::nBottom - MaxRow()\n ::nBottom -= nDif\n ::nTop -= nDif\n ENDIF\n\n IF ::nTop < 0\n nDif := ::nTop\n ::nBottom -= nDif\n ::nTop -= nDif\n ENDIF\n\n FOR EACH oItem IN ::aItems\n IF oItem:isPopup()\n oItem:data:setCoors( nRow + oItem:__enumIndex(), ::nRight + 1, .F. )\n ENDIF\n NEXT\n ENDIF\n\n RETURN Self\n\nMETHOD isShortCut( nKey, nID ) CLASS hb_PopupMenu\n\n LOCAL nItem\n LOCAL nTotal\n LOCAL nShortCut\n LOCAL oItem\n LOCAL i\n\n DO CASE\n \n \n CASE ( nShortCut := ::getShortCt( nKey ) ) > 0 .AND. ;\n ( oItem := ::getItem( nShortcut ) ):enabled .AND. ;\n ! oItem:isPopUp()\n\n ::select( nShortCut )\n Eval( oItem:data, oItem )\n nID := oItem:id\n\n RETURN .T.\n\n \n CASE nShortCut == 0\n nTotal := ::nItemCount\n nItem := ::nCurrent\n IF nItem == 0\n nItem := 1\n ENDIF\n\n \n FOR i := 1 TO nTotal\n IF ( oItem := ::getItem( nItem ) ):enabled .AND. ;\n oItem:isPopUp() .AND. ;\n oItem:data:isQuick( nKey, @nID )\n RETURN .T.\n ENDIF\n IF ++nItem > nTotal\n nItem := 1\n ENDIF\n NEXT\n\n ENDCASE\n\n RETURN .F.\n\nMETHOD isQuick( nKey, nID ) CLASS hb_PopupMenu\n\n LOCAL nShortCut\n LOCAL oItem\n\n IF ( nShortCut := ::getShortCt( nKey ) ) == 0\n\n FOR EACH oItem IN ::aItems\n IF oItem:Enabled .AND. ;\n oItem:isPopUp() .AND. ;\n oItem:data:isQuick( nKey, @nID )\n RETURN .T.\n ENDIF\n NEXT\n\n ELSEIF !( oItem := ::getItem( nShortCut ) ):IsPopUp()\n\n IF oItem:enabled\n ::select( nShortCut )\n Eval( oItem:data, oItem )\n nID := oItem:id\n RETURN .T.\n ENDIF\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 these Harbour functions: Harbour contribution module 'rddmisc' (): contrib/rddmisc/hscdx.prg. Provides 10 functions including: _HSX_NEW, _HSX_CLOSE, _HSX_GOCOLD, _HSX_GOHOT, _HSX_APPEND. Contains procedures: hsx_Open, hsx_Close, HSCDX_INIT. This file handles database operations"}, {"role": "assistant", "content": "#include \"dbinfo.ch\"\n#include \"fileio.ch\"\n#include \"hbusrrdd.ch\"\n#include \"rddsys.ch\"\n\nANNOUNCE HSCDX\n\n\nSTATIC FUNCTION _HSX_NEW( pWA )\n\n LOCAL aWData := { .F., {}, {} }\n\n \n USRRDD_AREADATA( pWA, aWData )\n\n RETURN HB_SUCCESS\n\nSTATIC FUNCTION _HSX_CLOSE( nWA )\n\n LOCAL aWData := USRRDD_AREADATA( nWA ), nHSX\n\n \n FOR EACH nHSX IN aWData[ 2 ]\n hs_Close( nHSX )\n NEXT\n\n \n ASize( aWData[ 2 ], 0 )\n ASize( aWData[ 3 ], 0 )\n\n \n RETURN UR_SUPER_CLOSE( nWA )\n\nSTATIC FUNCTION _HSX_GOCOLD( nWA )\n\n LOCAL nResult, aWData, nHSX, nRecNo, nKeyNo\n\n IF ( nResult := UR_SUPER_GOCOLD( nWA ) ) == HB_SUCCESS\n aWData := USRRDD_AREADATA( nWA )\n IF aWData[ 1 ]\n IF ! Empty( aWData[ 2 ] )\n nRecNo := RecNo()\n \n FOR EACH nHSX IN aWData[ 2 ]\n nKeyNo := hs_KeyCount( nHSX )\n DO WHILE nKeyNo >= 0 .AND. nKeyNo < nRecNo\n nKeyNo := hs_Add( nHSX, \"\" )\n ENDDO\n IF nKeyNo >= nRecNo\n hs_Replace( nHSX,, nRecNo )\n ENDIF\n NEXT\n ENDIF\n aWData[ 1 ] := .F.\n ENDIF\n ENDIF\n\n RETURN nResult\n\nSTATIC FUNCTION _HSX_GOHOT( nWA )\n\n LOCAL nResult, aWData\n\n IF ( nResult := UR_SUPER_GOHOT( nWA ) ) == HB_SUCCESS\n aWData := USRRDD_AREADATA( nWA )\n aWData[ 1 ] := .T.\n ENDIF\n\n RETURN nResult\n\nSTATIC FUNCTION _HSX_APPEND( nWA, lUnlockAll )\n\n LOCAL nResult, aWData\n\n IF ( nResult := UR_SUPER_APPEND( nWA, lUnlockAll ) ) == HB_SUCCESS\n aWData := USRRDD_AREADATA( nWA )\n aWData[ 1 ] := .T.\n ENDIF\n\n RETURN nResult\n\n\nFUNCTION hsx_Create( cFile, cExpr, nKeySize, nBufSize, lCase, nFiltSet )\n\n LOCAL aWData, nHsx := -1, nOpenMode\n\n IF ! Used()\n ELSEIF ! rddName() == \"HSCDX\"\n ELSE\n aWData := USRRDD_AREADATA( Select() )\n nOpenMode := iif( dbInfo( DBI_SHARED ), 1, 0 ) + ;\n iif( dbInfo( DBI_ISREADONLY ), 2, 0 )\n IF ( nHsx := hs_Index( cFile, cExpr, nKeySize, nOpenMode, nBufSize, lCase, nFiltSet ) ) >= 0\n AAdd( aWData[ 2 ], nHsx )\n AAdd( aWData[ 3 ], cFile )\n ENDIF\n ENDIF\n\n RETURN nHsx\n\nPROCEDURE hsx_Open( cFile, nBufSize )\n\n LOCAL aWData, nHsx, nOpenMode\n\n IF ! Used()\n ELSEIF ! rddName() == \"HSCDX\"\n ELSE\n aWData := USRRDD_AREADATA( Select() )\n nOpenMode := iif( dbInfo( DBI_SHARED ), 1, 0 ) + ;\n iif( dbInfo( DBI_ISREADONLY ), 2, 0 )\n IF ( nHsx := hs_Open( cFile, nBufSize, nOpenMode ) ) >= 0\n AAdd( aWData[ 2 ], nHsx )\n AAdd( aWData[ 3 ], cFile )\n ENDIF\n ENDIF\n\n RETURN\n\nPROCEDURE hsx_Close( xHSX )\n\n LOCAL aWData, nSlot\n\n IF Used() .AND. rddName() == \"HSCDX\"\n aWData := USRRDD_AREADATA( Select() )\n DO CASE\n CASE HB_ISNUMERIC( xHSX )\n nSlot := AScan( aWData[ 2 ], xHSX )\n CASE HB_ISSTRING( xHSX )\n nSlot := AScan( aWData[ 3 ], {| _1 | _1 == xHSX } )\n OTHERWISE\n nSlot := 0\n ENDCASE\n IF nSlot > 0\n hb_ADel( aWData[ 2 ], nSlot, .T. )\n hb_ADel( aWData[ 3 ], nSlot, .T. )\n ENDIF\n ENDIF\n\n RETURN\n\nFUNCTION hsx_Handle( cFile )\n\n LOCAL aWData, nSlot\n\n IF Used() .AND. rddName() == \"HSCDX\"\n aWData := USRRDD_AREADATA( Select() )\n nSlot := AScan( aWData[ 3 ], {| _1 | _1 == cFile } )\n IF nSlot != 0\n RETURN aWData[ 2 ][ nSlot ]\n ENDIF\n ENDIF\n\n RETURN -1\n\nFUNCTION hsx_File( nHsx )\n\n LOCAL aWData, nSlot\n\n IF Used() .AND. rddName() == \"HSCDX\"\n aWData := USRRDD_AREADATA( Select() )\n nSlot := AScan( aWData[ 3 ], nHsx )\n IF nSlot != 0\n RETURN aWData[ 3 ][ nSlot ]\n ENDIF\n ENDIF\n\n RETURN \"\"\n\nFUNCTION hsx_Get( nSlot )\n\n LOCAL aWData\n\n IF Used() .AND. rddName() == \"HSCDX\"\n aWData := USRRDD_AREADATA( Select() )\n IF nSlot > 0 .AND. nSlot <= Len( aWData[ 2 ] )\n RETURN aWData[ 2 ][ nSlot ]\n ENDIF\n ENDIF\n\n RETURN -1\n\n\nREQUEST DBFCDX\n\n\nFUNCTION HSCDX_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, pSuperRddID )\n\n LOCAL cSuperRDD := \"DBFCDX\" \n LOCAL aMyFunc[ UR_METHODCOUNT ]\n\n aMyFunc[ UR_NEW ] := @_HSX_NEW()\n aMyFunc[ UR_CLOSE ] := @_HSX_CLOSE()\n aMyFunc[ UR_GOCOLD ] := @_HSX_GOCOLD()\n aMyFunc[ UR_GOHOT ] := @_HSX_GOHOT()\n aMyFunc[ UR_APPEND ] := @_HSX_APPEND()\n\n RETURN USRRDD_GETFUNCTABLE( pFuncCount, pFuncTable, pSuperTable, nRddID, ;\n cSuperRDD, aMyFunc, pSuperRddID )\n\n\nINIT PROCEDURE HSCDX_INIT()\n\n rddRegister( \"HSCDX\", RDT_FULL )\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: TAny, New, Test. Harbour test program: tests/objects.prg. Provides functions: TAny, New, Test. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hboo.ch\"\n\nPROCEDURE Main()\n\n LOCAL oObject := TAny():New()\n\n ? ValType( oObject )\n ? Len( oObject ) \n ? oObject:ClassH() \n\n ? oObject:ClassName() \n\n oObject:Test() \n \n ? oObject:cName\n\n oObject:DoNothing() \n \n\n RETURN\n\nFUNCTION TAny() \n\n STATIC hClass\n\n IF hClass == NIL\n hClass := __clsNew( \"TANY\", 3 ) \n __clsAddMsg( hClass, \"cName\", 1, HB_OO_MSG_DATA ) \n __clsAddMsg( hClass, \"_cName\", 1, HB_OO_MSG_DATA ) \n __clsAddMsg( hClass, \"New\", @New(), HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"Test\", @Test(), HB_OO_MSG_METHOD )\n __clsAddMsg( hClass, \"DoNothing\", 0, HB_OO_MSG_VIRTUAL )\n ENDIF\n\n \n RETURN __clsInst( hClass ) \n\nSTATIC FUNCTION New()\n\n LOCAL Self := QSelf()\n\n ? ValType( Self )\n ? \"Inside New()\"\n\n ::cName := \"Harbour OOP\"\n\n RETURN Self\n\nSTATIC FUNCTION Test()\n\n LOCAL Self := QSelf() \n\n ? \"Test method invoked!\"\n\n ? ::ClassName() \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 'xhb' (Extended Harbour functions): contrib/xhb/xhbole.prg. Defines classes: TOleAuto. Provides 11 functions including: TOleAuto, CreateObject, GetActiveObject, CreateOleObject, OleDefaultArg. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#ifndef __PLATFORM__WINDOWS\n\nFUNCTION TOleAuto()\n RETURN NIL\n\nFUNCTION CreateObject()\n RETURN NIL\n\nFUNCTION GetActiveObject()\n RETURN NIL\n\nFUNCTION CreateOleObject()\n RETURN NIL\n\nFUNCTION OleDefaultArg()\n RETURN NIL\n\n#else\n\n\n#define HB_CLS_NOTOBJECT \n\n#include \"hbclass.ch\"\n\n#include \"error.ch\"\n\n#include \"hbole.ch\"\n\n#define EG_OLEEXCEPTION 1001\n#define DISPID_VALUE 0\n\nSTATIC s_bBreak := {| oError | Break( oError ) }\n\nSTATIC FUNCTION s_oleOpError( cOperator, ... )\n\n STATIC sc_hErrCode := { ;\n \"==\" => 1070, ;\n \"=\" => 1071, ;\n \"!=\" => 1072, ;\n \"+\" => 1081, ;\n \"-\" => 1082, ;\n \"*\" => 1083, ;\n \"/\" => 1084, ;\n \"%\" => 1085, ;\n \"++\" => 1086, ;\n \"--\" => 1087, ;\n \"^\" => 1088 }\n LOCAL oErr\n\n oErr := ErrorNew()\n oErr:Args := { ... }\n oErr:CanDefault := .F.\n oErr:CanRetry := .F.\n oErr:CanSubstitute := .T.\n oErr:Description := \"argument error\"\n oErr:GenCode := EG_ARG\n oErr:Operation := cOperator\n oErr:Severity := ES_ERROR\n oErr:SubCode := sc_hErrCode[ cOperator ]\n oErr:SubSystem := \"BASE\"\n\n RETURN oErr\n\nSTATIC FUNCTION s_oleError( nGenCode, cDescript )\n\n LOCAL oErr\n\n oErr := ErrorNew()\n oErr:Args := hb_AParams( 1 )\n oErr:CanDefault := .F.\n oErr:CanRetry := .F.\n oErr:CanSubstitute := .T.\n IF PCount() != 0\n oErr:GenCode := nGenCode\n oErr:Description := cDescript\n ELSE\n oErr:GenCode := EG_OLEEXCEPTION\n oErr:Description := win_oleErrorText()\n ENDIF\n oErr:Operation := ProcName( 1 )\n oErr:Severity := ES_ERROR\n oErr:SubCode := -1\n oErr:SubSystem := \"TOleAuto\"\n\n RETURN oErr\n\n\nCREATE CLASS TOleAuto FROM win_oleAuto\n\n VAR cClassName\n\n METHOD hObj( xOle ) SETGET\n METHOD New( xOle, cClass, cLicense )\n METHOD GetActiveObject( cClass )\n\n METHOD Invoke() EXTERN __oleInvokeMethod()\n MESSAGE CallMethod EXTERN __oleInvokeMethod()\n\n METHOD Set() EXTERN __oleInvokePut()\n MESSAGE SetProperty EXTERN __oleInvokePut()\n\n METHOD Get() EXTERN __oleInvokeGet()\n MESSAGE GetProperty EXTERN __oleInvokeGet()\n\n METHOD OleValue()\n METHOD _OleValue( xValue )\n\n METHOD OleValueExactEqual( xArg ) OPERATOR \"==\"\n METHOD OleValueEqual( xArg ) OPERATOR \"=\"\n METHOD OleValueNotEqual( xArg ) OPERATOR \"!=\"\n METHOD OleValuePlus( xArg ) OPERATOR \"+\"\n METHOD OleValueMinus( xArg ) OPERATOR \"-\"\n METHOD OleValueMultiply( xArg ) OPERATOR \"*\"\n METHOD OleValueDivide( xArg ) OPERATOR \"/\"\n METHOD OleValueModulus( xArg ) OPERATOR \"%\"\n METHOD OleValuePower( xArg ) OPERATOR \"^\"\n METHOD OleValueInc() OPERATOR \"++\"\n METHOD OleValueDec() OPERATOR \"--\"\n\nENDCLASS\n\nMETHOD hObj( xOle ) CLASS TOleAuto\n\n IF xOle != NIL\n IF HB_ISNUMERIC( xOle )\n xOle := __olePDisp( xOle )\n ENDIF\n IF __oleIsDisp( xOle )\n ::__hObj := xOle\n ENDIF\n ENDIF\n\n RETURN ::__hObj\n\nMETHOD New( xOle, cClass, cLicense ) CLASS TOleAuto\n\n LOCAL hOle\n\n IF HB_ISSTRING( xOle )\n IF Empty( hOle := __oleCreateObject( xOle,, cLicense ) )\n RETURN Throw( s_oleError() )\n ENDIF\n ::__hObj := hOle\n ::cClassName := xOle\n ELSE\n ::hObj := xOle\n IF ::__hObj == NIL\n RETURN Throw( s_oleError( 0, \"Invalid argument to contructor!\" ) )\n ELSEIF HB_ISSTRING( cClass )\n ::cClassName := cClass\n ELSE\n ::cClassName := hb_ntos( win_P2N( ::__hObj ) )\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD GetActiveObject( cClass ) CLASS TOleAuto\n\n IF HB_ISSTRING( cClass )\n IF Empty( ::__hObj := __oleGetActiveObject( cClass ) )\n RETURN Throw( s_oleError() )\n ENDIF\n ::cClassName := cClass\n ELSE\n wapi_MessageBox( , \"Invalid parameter type to constructor TOleAuto():GetActiveObject()!\", ;\n \"OLE Interface\", )\n ::__hObj := NIL\n ENDIF\n\n RETURN Self\n\nMETHOD OleValue() CLASS TOleAuto\n RETURN __oleInvokeGet( ::__hObj, DISPID_VALUE )\n\nMETHOD _OleValue( xValue ) CLASS TOleAuto\n RETURN __oleInvokePut( ::__hObj, DISPID_VALUE, xValue )\n\n#xcommand OLE OPERATOR <op> METHOD <!mth!> [WITH <!arg!>] IS <exp> => ;\n METHOD <mth>( <arg> ) CLASS TOleAuto ;;\n LOCAL xRet ;;\n BEGIN SEQUENCE WITH s_bBreak ;;\n xRet := ( <exp> ) ;;\n RECOVER ;;\n RETURN Throw( s_oleOpError( <op>, Self [, <arg>] ) ) ;;\n END SEQUENCE ;;\n RETURN xRet\n\nOLE OPERATOR \"==\" METHOD OleValueExactEqual WITH xArg IS ::OleValue == xArg\nOLE OPERATOR \"=\" METHOD OleValueEqual WITH xArg IS ::OleValue = xArg\nOLE OPERATOR \"!=\" METHOD OleValueNotEqual WITH xArg IS ::OleValue != xArg \nOLE OPERATOR \"+\" METHOD OleValuePlus WITH xArg IS ::OleValue + xArg\nOLE OPERATOR \"-\" METHOD OleValueMinus WITH xArg IS ::OleValue - xArg\nOLE OPERATOR \"*\" METHOD OleValueMultiply WITH xArg IS ::OleValue\nOLE OPERATOR \"/\" METHOD OleValueDivide WITH xArg IS ::OleValue / xArg\nOLE OPERATOR \"%\" METHOD OleValueModulus WITH xArg IS ::OleValue % xArg\nOLE OPERATOR \"^\" METHOD OleValuePower WITH xArg IS ::OleValue ^ xArg\nOLE OPERATOR \"++\" METHOD OleValueInc IS ++::OleValue\nOLE OPERATOR \"--\" METHOD OleValueDec IS --::OleValue\n\nFUNCTION CreateObject( xOle, cLicense )\n RETURN TOleAuto():New( xOle,, cLicense )\n\nFUNCTION GetActiveObject( cString )\n RETURN TOleAuto():GetActiveObject( cString )\n\nFUNCTION CreateOleObject( ... )\n RETURN __oleCreateObject( ... )\n\nFUNCTION OleDefaultArg()\n RETURN __oleVariantNew( WIN_VT_ERROR, WIN_DISP_E_PARAMNOTFOUND )\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/cursor.prg. Contains procedures: Main, CursTest. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL x\n\n ? \"This lists the cursor modes, along with the expected shape\"\n ? \"Press a key after each example\"\n ?\n FOR x := 0 TO 4\n CursTest( x )\n NEXT\n ? \"Note: In Windows Console mode, Special2 can not be emulated (it is 2/3 size)\"\n\n SetCursor( 1 )\n\n RETURN\n\nPROCEDURE CursTest( nCurs )\n\n LOCAL aTypes := { \"None\", \"Underline\", \"HalfBlock\", \"FullBlock\", \"Upper Half\" }\n LOCAL aNames := { \"SC_NONE\", \"SC_NORMAL\", \"SC_INSERT\", \"SC_SPECIAL1\", \"SC_SPECIAL2\" }\n\n SetCursor( nCurs )\n ++nCurs\n ? PadR( aNames[ nCurs ], 11 ), PadR( aTypes[ nCurs ], 11 ), Str( SetCursor(), 3 )\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": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/win_tprn.prg. Defines classes: win_Prn. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"hbwin.ch\"\n\n#define MM_TO_INCH 25.4\n\nCREATE CLASS win_Prn\n\n METHOD New( cPrinter )\n METHOD Create() \n \n METHOD Destroy() \n DESTRUCTOR Destruct()\n\n METHOD StartDoc( cDocName ) \n METHOD EndDoc( lAbortDoc ) \n METHOD StartPage()\n METHOD EndPage( lStartNewPage ) \n METHOD NewLine()\n METHOD NewPage( lDelay ) \n METHOD CheckPage()\n METHOD GetDocumentProperties()\n METHOD SetFont( cFontName, nPointSize, xWidth, nBold, lUnderline, lItalic, nCharSet, lManualSize )\n \n \n METHOD SetDefaultFont()\n\n METHOD GetFonts() \n METHOD Bold( nWeight )\n METHOD UnderLine( lUnderline )\n METHOD Italic( lItalic )\n METHOD SetDuplexType( nDuplexType ) \n METHOD SetPrintQuality( nPrintQuality ) \n METHOD CharSet( nCharSet )\n\n\n METHOD SetPos( nPosX, nPosY ) \n METHOD SetColor( nClrText, nClrPane, nAlign )\n METHOD SetBkMode( nMode ) \n\n METHOD TextOut( cString, lNewLine, lUpdatePosX, nAlign ) \n METHOD TextOutAt( nPosX, nPosY, cString, lNewLine, lUpdatePosX, nAlign ) \n\n\n METHOD SetPen( nStyle, nWidth, nColor )\n METHOD Line( nX1, nY1, nX2, nY2 )\n METHOD Box( nX1, nY1, nX2, nY2, nWidth, nHeight )\n METHOD Arc( nX1, nY1, nX2, nY2 )\n METHOD Ellipse( nX1, nY1, nX2, nY2 )\n METHOD FillRect( nX1, nY1, nX2, nY2, nColor )\n METHOD GetCharWidth()\n METHOD GetCharHeight()\n METHOD GetTextWidth( cString )\n METHOD GetTextHeight( cString )\n METHOD DrawBitmap( oBmp )\n\n \n METHOD SetPRC( nRow, nCol ) \n METHOD PRow()\n METHOD PCol()\n METHOD MaxRow() \n METHOD MaxCol() \n\n METHOD MM_TO_POSX( nMm ) \n METHOD MM_TO_POSY( nMm ) \n METHOD INCH_TO_POSX( nInch ) \n METHOD INCH_TO_POSY( nInch ) \n\n METHOD TextAtFont( nPosX, nPosY, cString, cFont, nPointSize, ; \n nWidth, nBold, lUnderLine, lItalic, nCharSet, ; \n lNewLine, lUpdatePosX, nColor, nAlign ) \n \n\n METHOD GetDeviceCaps( nCaps )\n\n VAR PrinterName INIT \"\"\n VAR Printing INIT .F.\n VAR HavePrinted INIT .F.\n VAR PageInit INIT .F.\n VAR PageNumber INIT 0\n VAR hPrinterDc INIT 0\n\n VAR AskProperties INIT .F.\n\n \n VAR FormType INIT 0\n VAR BinNumber INIT 0\n VAR Landscape INIT .F.\n VAR Copies INIT 1\n VAR PaperLength INIT 0 \n VAR PaperWidth INIT 0 \n\n VAR SetFontOk INIT .F.\n VAR hFont INIT 0\n VAR FontName INIT \"\" \n VAR FontPointSize INIT 12 \n VAR FontWidth INIT { 0, 0 } \n \n VAR fBold INIT 0 HIDDEN \n VAR fUnderLine INIT .F. HIDDEN \n VAR fItalic INIT .F. HIDDEN \n VAR fCharSet INIT WIN_DEFAULT_CHARSET HIDDEN\n\n VAR PixelsPerInchY INIT 0\n VAR PixelsPerInchX INIT 0\n VAR PageHeight INIT 0\n VAR PageWidth INIT 0\n VAR TopMargin INIT 0\n VAR BottomMargin INIT 0\n VAR LeftMargin INIT 0\n VAR RightMargin INIT 0\n VAR LineHeight INIT 0\n VAR CharHeight INIT 0\n VAR CharWidth INIT 0\n VAR fCharWidth INIT 0 HIDDEN\n VAR BitmapsOk INIT .F.\n VAR NumColors INIT 1\n VAR fDuplexType INIT 0 HIDDEN\n VAR fPrintQuality INIT 0 HIDDEN\n VAR fNewDuplexType INIT 0 HIDDEN\n VAR fNewPrintQuality INIT 0 HIDDEN\n VAR fOldLandScape INIT .F. HIDDEN\n VAR fOldBinNumber INIT 0 HIDDEN\n VAR fOldFormType INIT 0 HIDDEN\n VAR fOldPaperLength INIT 0 HIDDEN\n VAR fOldPaperWidth INIT 0 HIDDEN\n\n VAR PosX INIT 0\n VAR PosY INIT 0\n\n VAR TextColor\n VAR BkColor\n VAR TextAlign\n\n VAR BkMode\n\n VAR hPen INIT 0\n VAR PenStyle\n VAR PenWidth\n VAR PenColor\n\nENDCLASS\n\nMETHOD New( cPrinter ) CLASS win_Prn\n\n ::PrinterName := iif( Empty( cPrinter ), win_printerGetDefault(), cPrinter )\n \n ::GetDocumentProperties()\n\n RETURN Self\n\nMETHOD Create() CLASS win_Prn\n\n LOCAL lResult := .F.\n\n ::Destroy() \n IF ! Empty( ::hPrinterDC := win_CreateDC( ::PrinterName ) )\n\n \n IF ::AskProperties\n lResult := win_SetDocumentProperties( ::hPrinterDC, ::PrinterName, ;\n @::FormType, @::Landscape, ;\n @::Copies, @::BinNumber, ;\n @::fDuplexType, @::fPrintQuality, ;\n @::PaperLength, @::PaperWidth )\n ELSE\n lResult := win_SetDocumentProperties( ::hPrinterDC, ::PrinterName, ;\n ::FormType, ::Landscape, ;\n ::Copies, ::BinNumber, ;\n ::fDuplexType, ::fPrintQuality, ;\n ::PaperLength, ::PaperWidth )\n ENDIF\n\n IF ! lResult\n ::hPrinterDC := NIL\n ELSE\n IF ::BkMode != NIL\n win_SetBkMode( ::hPrinterDc, ::BkMode )\n ENDIF\n \n win_SetMapMode( ::hPrinterDC, WIN_MM_TEXT )\n\n \n ::PageWidth := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALWIDTH )\n ::PageHeight := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALHEIGHT )\n ::LeftMargin := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALOFFSETX )\n ::RightMargin := ( ::PageWidth - ::LeftMargin ) + 1\n ::PixelsPerInchY := win_GetDeviceCaps( ::hPrinterDC, WIN_LOGPIXELSY )\n ::PixelsPerInchX := win_GetDeviceCaps( ::hPrinterDC, WIN_LOGPIXELSX )\n ::LineHeight := Int( ::PixelsPerInchY / 6 ) \n ::TopMargin := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALOFFSETY )\n ::BottomMargin := ( ::PageHeight - ::TopMargin ) + 1\n\n \n ::BitMapsOk := win_BitmapsOK( ::hPrinterDC )\n\n \n ::NumColors := win_GetDeviceCaps( ::hPrinterDC, WIN_NUMCOLORS )\n\n \n ::SetDefaultFont()\n ::PageNumber := 0\n ::HavePrinted := ::Printing := ::PageInit := .F.\n ::fOldFormType := ::FormType \n ::fOldLandScape := ::LandScape\n ::fOldBinNumber := ::BinNumber\n ::fNewDuplexType := ::fDuplexType\n ::fNewPrintQuality := ::fPrintQuality\n ::fOldPaperLength := ::PaperLength\n ::fOldPaperWidth := ::PaperWidth\n ENDIF\n ENDIF\n\n RETURN lResult\n\nMETHOD Destroy() CLASS win_Prn\n\n IF ! Empty( ::hPrinterDc )\n IF ::Printing\n ::EndDoc()\n ENDIF\n ::hPrinterDC := NIL\n ENDIF\n\n RETURN .T.\n\nMETHOD PROCEDURE Destruct() CLASS win_Prn\n\n ::Destroy()\n\n RETURN\n\nMETHOD StartDoc( cDocName ) CLASS win_Prn\n\n LOCAL lResult\n\n IF ! HB_ISSTRING( cDocName )\n cDocName := hb_argv( 0 ) + \" [\" + DToC( Date() ) + \" - \" + Time() + \"]\"\n ENDIF\n\n IF ( lResult := win_StartDoc( ::hPrinterDc, cDocName ) )\n IF !( lResult := ::StartPage( ::hPrinterDc ) )\n ::EndDoc( .T. )\n ELSE\n ::Printing := .T.\n ENDIF\n ENDIF\n\n RETURN lResult\n\nMETHOD EndDoc( lAbortDoc ) CLASS win_Prn\n\n IF ::HavePrinted\n hb_default( @lAbortDoc, .F. )\n ELSE\n lAbortDoc := .T.\n ENDIF\n IF lAbortDoc\n win_AbortDoc( ::hPrinterDC )\n ELSE\n ::EndPage( .F. )\n win_EndDoc( ::hPrinterDC )\n ENDIF\n ::HavePrinted := ::Printing := ::PageInit := .F.\n ::PageNumber := 0\n\n RETURN .T.\n\nMETHOD StartPage() CLASS win_Prn\n\n LOCAL lLLandScape\n LOCAL nLBinNumber\n LOCAL nLFormType\n LOCAL nLDuplexType\n LOCAL nLPrintQuality\n LOCAL nLPaperLength"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/ntow.prg. Provides functions: ft_NToW, grp_to_words, sol10. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "STATIC sc_ones := { ;\n \"\", \" One\", \" Two\", \" Three\", \" Four\", \" Five\", ;\n \" Six\", \" Seven\", \" Eight\", \" Nine\" ;\n }\n\nSTATIC sc_teens := { ;\n \" Ten\", \" Eleven\", \" Twelve\", ;\n \" Thirteen\", \" Fourteen\", \" Fifteen\", ;\n \" Sixteen\", \" Seventeen\", \" Eighteen\", ;\n \" Nineteen\" ;\n }\n\nSTATIC sc_tens := { ;\n \"\", \"\", \" Twenty\", \" Thirty\", \" Forty\", \" Fifty\", ;\n \" Sixty\", \" Seventy\", \" Eighty\", \" Ninety\" }\n\nSTATIC sc_qualifiers := { \"\", \" Thousand\", \" Million\", \" Billion\", \" Trillion\" }\n\nFUNCTION ft_NToW( nAmount )\n\n LOCAL nTemp, sResult := \" \", nQualNo\n LOCAL nDiv := 10 ^ ( Int( sol10( nAmount ) / 3 )\n sResult += grp_to_words( nTemp, \"\" )\n ENDIF\n\n RETURN LTrim( sResult )\n\nSTATIC FUNCTION grp_to_words( nGrp, sQual )\n\n LOCAL sResult := \"\", nTemp\n\n nTemp := Int( nGrp % 100 )\n nGrp := Int( nGrp / 100 )\n sResult += sc_ones[ nGrp + 1 ] + iif( nGrp > 0, \" Hundred\", \"\" )\n\n DO CASE\n CASE nTemp > 19\n sResult += sc_tens[ Int( nTemp / 10 ) + 1 ]\n sResult += sc_ones[ Int( nTemp % 10 ) + 1 ]\n CASE nTemp < 20 .AND. nTemp > 9\n sResult += sc_teens[ Int( nTemp % 10 ) + 1 ]\n CASE nTemp < 10 .AND. nTemp > 0\n sResult += sc_ones[ Int( nTemp ) + 1 ]\n ENDCASE\n\n RETURN sResult + sQual\n\nSTATIC FUNCTION sol10( nNumber )\n\n RETURN Len( hb_ntos( Int( nNumber ) ) ) - 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 the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/popadder.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 nSickHrs := 0\n LOCAL nPersHrs := 0\n LOCAL nVacaHrs := 0\n LOCAL GetList := {}\n\n SET SCOREBOARD OFF\n CLS\n\n SetKey( K_ALT_A, {|| ft_Adder() } ) \n\n \n @ 12, 5 SAY \"Please enter the total Sick, Personal, and Vacation hours.\"\n @ 15, 22 SAY \"Sick hrs.\"\n @ 15, 40 SAY \"Pers. hrs.\"\n @ 15, 60 SAY \"Vaca. hrs.\"\n @ 23, 20 SAY \"Press <ALT-A> to Pop - Up the Adder.\"\n @ 24, 20 SAY \"Press <ESC> to Quit the adder Demo.\"\n DO WHILE .T. \n @ 16, 24 GET nSickHrs PICTURE \"9999.999\" \n @ 16, 43 GET nPersHrs PICTURE \"9999.999\" \n @ 16, 63 GET nVacaHrs PICTURE \"9999.999\" \n SET CURSOR ON \n CLEAR TYPEAHEAD \n READ\n SET CURSOR OFF\n IF LastKey() == K_ESC \n CLEAR TYPEAHEAD\n EXIT\n ENDIF\n ENDDO\n SET CURSOR ON\n\n SET KEY K_ALT_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": "Implement these Harbour functions: Harbour test program: tests/linecont.prg. Provides functions: TEST1, TEST2. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\nLOCAL a, b\n\n TEST1() ; TEST2()\n Abs( 4 )\n\n TEST3()\n\n TEST4() ; TEST5()\n TEST6()\n\n TEST7 ;\n ()\n\n\n TEST8( ;\n )\n\n\n TEST9( a ;\n)\n\n\n TEST10( a, ;\n)\n\n\n TEST11( a, b ; \n)\n\n a ;\n:=b\n\n a :=;\nb\n\n a ;\n= ;\nb\n\n a ;\n+= ;\nb\n\n TEST12( a := ;\nb ;\n)\n\n a :=b[ 1 ;\n]\n a :=b[ 1 ; ]\n\n a :=b[ ;\n1 , 2 ;\n]\n a :=b[ ; 1, 2 ; ]\n\n a :=TEST13()[ 1 ]\n a :=TEST13()[ ;\n 1 ]\n\n a :=b[ ;\n1;\n,;\n2;\n];\n[ ;\n 3 ]\n\n a :=TEST1(); TEST2()\n\n\n a :=;\n; \n; \n;\n 55\n\nRETURN\n\nFUNCTION TEST1() ; LOCAL n; IF n==5; n =4; END; RETURN n\n\nFUNCTION TEST2(); LOCAL n\n\n WHILE n<5; n++; END\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": "Write the following Harbour (xBase/Clipper) code:\n\nHarbour contribution module 'rddsql' (): contrib/rddsql/tests/arrayrdd.prg. Contains procedures: Main, RDDSYS. This file handles database operations"}, {"role": "assistant", "content": "#require \"rddsql\"\n\nREQUEST SQLMIX\n\nPROCEDURE Main()\n\n CLS\n\n#if defined( __HBSCRIPT__HBSHELL )\n rddRegister( \"SQLBASE\" )\n rddRegister( \"SQLMIX\" )\n#endif\n\n rddSetDefault( \"SQLMIX\" )\n dbCreate( \"persons\", { { \"NAME\", \"C\", 20, 0 }, { \"FAMILYNAME\", \"C\", 20, 0 }, { \"BIRTH\", \"D\", 8, 0 }, { \"AMOUNT\", \"N\", 9, 2 } }, , .T., \"persons\" )\n\n dbAppend(); AEval( { PadR( \"Bil\", 20 ), PadR( \"Gatwick\", 20 ), hb_SToD( \"19650124\" ), 123456.78 }, {| X, Y | FieldPut( Y, X ) } )\n dbAppend(); AEval( { PadR( \"Tom\", 20 ), PadR( \"Heathrow\", 20 ), hb_SToD( \"19870512\" ), 9086.54 }, {| X, Y | FieldPut( Y, X ) } )\n dbAppend(); AEval( { PadR( \"John\", 20 ), PadR( \"Weber\", 20 ), hb_SToD( \"19750306\" ), 2975.45 }, {| X, Y | FieldPut( Y, X ) } )\n dbAppend(); AEval( { PadR( \"Sim\", 20 ), PadR( \"Simsom\", 20 ), hb_SToD( \"19930705\" ), 32975.37 }, {| X, Y | FieldPut( Y, X ) } )\n\n dbGoTop()\n Browse()\n\n INDEX ON FIELD->AMOUNT TO amount\n dbGoTop()\n Browse()\n dbCloseAll()\n\n RETURN\n\nPROCEDURE RDDSYS() ; 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/gui.prg. Provides 8 functions including: _IsGraphic, _SetVideoMode, _GetNumCol, __GUIColor, IsDefColor. This file provides utility functions"}, {"role": "assistant", "content": "#ifdef HB_COMPAT_C53\n\n#define LLG_VIDEO_TXT 3\n\nFUNCTION _IsGraphic()\n RETURN ;\n Set( _SET_VIDEOMODE ) != NIL .AND. ;\n Set( _SET_VIDEOMODE ) != 0 .AND. ;\n Set( _SET_VIDEOMODE ) != LLG_VIDEO_TXT\n\nFUNCTION _SetVideoMode( nMode )\n\n HB_SYMBOL_UNUSED( nMode )\n\n RETURN 0\n\n\nFUNCTION _GetNumCol( cColor )\n\n LOCAL nPos\n\n IF ( nPos := At( \"/\", cColor ) ) > 0\n cColor := Left( cColor, nPos - 1 )\n ENDIF\n IF ( nPos := At( \",\", cColor ) ) > 0\n cColor := Left( cColor, nPos - 1 )\n ENDIF\n\n RETURN hb_AScan( { \"B\", \"G\", \"BG\", \"R\", \"RB\", \"GR\", \"W\", \"N+\", \"B+\", \"G+\", \"BG+\", \"R+\", \"RB+\", \"GR+\", \"W+\" }, cColor,,, .T. )\n\nFUNCTION __GUIColor( cColor, nPos )\n RETURN hb_ColorIndex( cColor, nPos - 1 )\n\nFUNCTION IsDefColor()\n RETURN SetColor() == \"W/N,N/W,N/N,N/N,N/W\" \n\n\nFUNCTION __Caption( cCaption )\n\n LOCAL nPos\n\n RETURN iif( ( nPos := At( \"&\", cCaption ) ) > 0, Stuff( cCaption, nPos, 1, \"\" ), cCaption )\n\nFUNCTION __CapLength( cCaption )\n\n LOCAL nCaptionLen := Len( cCaption )\n LOCAL nPos\n\n RETURN iif( ( nPos := At( \"&\", cCaption ) ) > 0 .AND. nPos < nCaptionLen, nCaptionLen - 1, nCaptionLen )\n\nFUNCTION __CapMetrics( o )\n RETURN __CapLength( o:caption ) + iif( o:isPopup(), 3, 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 'xhb' (Extended Harbour functions): contrib/xhb/tests/decode.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"xhb\"\n\nPROCEDURE Main()\n\n LOCAL aArray\n\n ? \"hb_Decode() FUNCTION TESTS\"\n\n \n ? hb_Decode( 10 )\n \n ? hb_Decode( 3, 1, \"A\", 2, \"B\", 3, \"C\" )\n \n ? hb_Decode( 4, 1, \"A\", 2, \"B\", 3, \"C\", \"X\" )\n \n ? hb_Decode( 2, { 1, \"A\", 2, \"B\", 3, \"C\" } )\n \n ? hb_Decode( 2, { 1, \"A\", 2, \"B\", 3, \"C\", \"X\" } )\n \n ? hb_Decode( 2, { 1 => \"A\", 2 => \"B\", 3 => \"C\" } )\n\n \n ? hb_CStr( hb_Decode( 2, 1, {|| 1 }, 2, {|| 2 }, 3, {|| 3 } ) )\n\n \n aArray := { 1 }\n ? hb_Decode( aArray, aArray, \"A\", { 2 }, \"B\", { 3 }, \"C\" )\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: TIPEncoderUrl. Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/encurl.prg. Defines classes: TIPEncoderUrl. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nCREATE CLASS TIPEncoderUrl INHERIT TIPEncoder\n\n METHOD New() CONSTRUCTOR\n METHOD Encode( cData )\n METHOD Decode( cData )\n\nENDCLASS\n\nMETHOD New() CLASS TIPEncoderUrl\n\n ::cName := \"urlencoded\"\n\n RETURN Self\n\nMETHOD Encode( cData ) CLASS TIPEncoderUrl\n RETURN tip_URLEncode( cData )\n\nMETHOD Decode( cData ) CLASS TIPEncoderUrl\n RETURN tip_URLDecode( 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": "Define Harbour macros and constants: Harbour header file: include/hbmemory.ch. Defines 10 constants including: HB_MEMORY_CH_, HB_MEM_CHAR, HB_MEM_BLOCK, HB_MEM_RUN, HB_MEM_VM. Defines keyboard input constants"}, {"role": "assistant", "content": "#ifndef HB_MEMORY_CH_\n#define HB_MEMORY_CH_\n\n\n#define HB_MEM_CHAR 0 \n#define HB_MEM_BLOCK 1 \n#define HB_MEM_RUN 2 \n\n\n#define HB_MEM_VM 3 \n#define HB_MEM_EMS 4 \n#define HB_MEM_FM 101 \n#define HB_MEM_FMSEGS 102 \n#define HB_MEM_SWAP 103 \n#define HB_MEM_CONV 104 \n#define HB_MEM_EMSUSED 105 \n\n\n#define HB_MEM_USED 1001 \n#define HB_MEM_USEDMAX 1002 \n#define HB_MEM_STACKITEMS 1003 \n#define HB_MEM_STACK 1004 \n#define HB_MEM_STACK_TOP 1005 \n#define HB_MEM_BLOCKS 1007 \n#define HB_MEM_STATISTICS 1008 \n#define HB_MEM_CANLIMIT 1009 \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: netio_MTServer, NETIO_SRVLOOP. Harbour contribution module 'hbnetio' (Network I/O operations): contrib/hbnetio/netiomt.prg. Provides functions: netio_MTServer, NETIO_SRVLOOP. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"error.ch\"\n\nFUNCTION netio_MTServer( nPort, cIfAddr, cRootDir, xRPC, ;\n cPasswd, nCompressLevel, nStrategy, ;\n sSrvFunc )\n\n LOCAL pListenSocket, lRPC\n LOCAL oError\n\n IF sSrvFunc == NIL\n sSrvFunc := @netio_Server()\n ENDIF\n\n IF hb_mtvm()\n\n SWITCH ValType( xRPC )\n CASE \"S\"\n CASE \"H\"\n lRPC := .T.\n EXIT\n CASE \"L\"\n lRPC := xRPC\n EXIT\n OTHERWISE\n xRPC := NIL\n ENDSWITCH\n\n pListenSocket := netio_Listen( nPort, cIfAddr, cRootDir, lRPC )\n IF ! Empty( pListenSocket )\n hb_threadDetach( hb_threadStart( @netio_srvloop(), pListenSocket, ;\n xRPC, sSrvFunc, ;\n cPasswd, nCompressLevel, nStrategy ) )\n ENDIF\n ELSE\n oError := ErrorNew()\n\n oError:severity := ES_ERROR\n oError:genCode := EG_UNSUPPORTED\n oError:subSystem := \"HBNETIO\"\n oError:subCode := 0\n oError:description := hb_langErrMsg( EG_UNSUPPORTED )\n oError:canRetry := .F.\n oError:canDefault := .F.\n oError:fileName := \"\"\n oError:osCode := 0\n\n Eval( ErrorBlock(), oError )\n ENDIF\n\n RETURN pListenSocket\n\n\nSTATIC FUNCTION NETIO_SRVLOOP( pListenSocket, xRPC, sSrvFunc, ... )\n\n LOCAL pConnectionSocket\n\n DO WHILE .T.\n pConnectionSocket := netio_Accept( pListenSocket,, ... )\n IF Empty( pConnectionSocket )\n EXIT\n ENDIF\n IF xRPC != NIL\n netio_RPCFilter( pConnectionSocket, xRPC )\n ENDIF\n hb_threadDetach( hb_threadStart( sSrvFunc, pConnectionSocket ) )\n pConnectionSocket := NIL\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/calling.prg. Provides functions: SecondOne, Third, Fourth. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n SecondOne()\n\n DO Fourth WITH \"from Fourth() function\" \n\n ? \"Ok, back to Main()\"\n\n RETURN\n\nFUNCTION SecondOne()\n\n ? \"Ok, this is from Second() function call\"\n\n Third()\n\n RETURN NIL\n\nFUNCTION Third()\n\n ? \"Ok, this is from Third() function call\"\n\n RETURN NIL\n\nFUNCTION Fourth( cText )\n\n ? cText\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 'xhb' (Extended Harbour functions): contrib/xhb/sprintf.prg. Provides functions: sprintf. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION sprintf( ... )\n\n LOCAL aPar, cReturn, nPar, nPos, cTok\n LOCAL nLen := 0, lUnsigned, l0 := .F., lSign := .F., nDec, xVal\n LOCAL cString\n\n aPar := hb_AParams()\n cReturn := \"\"\n cString := aPar[ 1 ]\n nPar := 2\n\n DO WHILE ! Empty( cString )\n\n nPos := Len( cString ) + 1\n cTok := NIL\n\n IF \"%\" $ cString\n nPos := At( \"%\", cString )\n cTok := \"%\"\n ENDIF\n IF \"\\\" $ cString .AND. At( \"\\\", cString ) < nPos\n nPos := At( \"\\\", cString )\n cTok := \"\\\"\n ENDIF\n\n cReturn += Left( cString, nPos - 1 )\n\n DO CASE\n CASE cTok == NIL\n EXIT\n\n CASE cTok == \"\\\"\n\n SWITCH SubStr( cString, ++nPos, 1 )\n CASE \"t\"\n cReturn += \" \"\n EXIT\n\n CASE \"n\"\n cReturn += Chr( 13 )\n EXIT\n\n CASE \"r\"\n cReturn += Chr( 10 )\n EXIT\n\n OTHERWISE\n cReturn += SubStr( cString, nPos, 1 )\n EXIT\n ENDSWITCH\n\n CASE cTok == \"%\"\n lUnsigned := .F.\n\n SWITCH SubStr( cString, ++nPos, 1 )\n CASE \"%\"\n cReturn += \"%\"\n EXIT\n\n CASE \"+\"\n cString := Left( cString, nPos - 1 ) + SubStr( cString, nPos + 1 )\n nPos := At( \"%\", cString ) - 1\n lSign := .T.\n EXIT\n\n CASE \"0\"\n cString := Left( cString, nPos - 1 ) + SubStr( cString, nPos + 1 )\n nPos := At( \"%\", cString ) - 1\n l0 := .T.\n EXIT\n\n CASE \"1\"\n CASE \"2\"\n CASE \"3\"\n CASE \"4\"\n CASE \"5\"\n CASE \"6\"\n CASE \"7\"\n CASE \"8\"\n CASE \"9\"\n nLen := Val( SubStr( cString, nPos ) )\n cTok := Left( cString, nPos - 1 )\n DO WHILE SubStr( cString, nPos, 1 ) $ \"1234567890.\"\n nPos++\n ENDDO\n cString := cTok + SubStr( cString, nPos )\n nPos := At( \"%\", cString ) - 1\n EXIT\n\n CASE \"u\"\n lUnsigned := .T.\n nPos++\n\n CASE \"d\"\n CASE \"l\"\n CASE \"f\"\n CASE \"i\"\n xVal := aPar[ nPar++ ]\n hb_default( @xVal, 0 )\n IF nLen != 0\n IF nLen - Int( nLen ) > 0.0\n nDec := Str( nLen )\n DO WHILE Right( nDec, 1 ) == \"0\"\n nDec := Left( nDec, Len( nDec ) - 1 )\n ENDDO\n nDec := Val( SubStr( nDec, At( \".\", nDec ) + 1 ) )\n ELSE\n nDec := 0\n ENDIF\n cTok := Str( iif( lUnsigned, Abs( xVal ), xVal ), nLen, nDec )\n ELSE\n cTok := hb_ntos( iif( lUnsigned, Abs( xVal ), xVal ) )\n ENDIF\n IF l0\n IF \"-\" $ cTok .AND. !( Left( cTok, 1 ) == \"-\" )\n cTok := StrTran( cTok, \"-\", \" \" )\n cTok := \"-\" + SubStr( cTok, 2 )\n ENDIF\n cTok := StrTran( cTok, \" \", \"0\" )\n l0 := .F.\n ENDIF\n IF lSign .AND. !( Left( cTok, 1 ) == \"-\" )\n IF nLen == 0\n cTok := \"+\" + cTok\n ELSE\n cTok := \"+\" + SubStr( cTok, 2 )\n ENDIF\n lSign := .F.\n ENDIF\n nLen := 0\n cReturn += cTok\n EXIT\n\n CASE \"c\"\n CASE \"s\"\n IF nLen == 0\n nLen := Len( hb_CStr( aPar[ nPar ] ) )\n ENDIF\n cReturn += PadL( hb_CStr( aPar[ nPar++ ] ), nLen )\n nLen := 0\n l0 := .F.\n lSign := .F.\n EXIT\n\n ENDSWITCH\n ENDCASE\n\n cString := SubStr( cString, nPos + 1 )\n ENDDO\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/box3.prg. Contains procedures: Main, MESSAGE. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n CLS\n\n @ 0, 0, 15, MaxCol() BOX \" \" COLOR \"W+/B\"\n MESSAGE( '@ 0, 0, 15, MaxCol() BOX \" \" COLOR \"W+/B\"' )\n\n __Box( 1, 1, 5, 7 )\n MESSAGE( \"__Box( 1, 1, 5, 7 )\" )\n\n __Box( 1, 1, 5, 7, \"X\" )\n MESSAGE( '__Box( 1, 1, 5, 7, \"X\" )' )\n\n __BoxD( 2, 2, 6, 8 )\n MESSAGE( \"__BoxD( 2, 2, 6, 8 )\" )\n\n __BoxS( 3, 3, 7, 9 )\n MESSAGE( \"__BoxS( 3, 3, 7, 9 )\" )\n\n RETURN\n\nPROCEDURE MESSAGE( cText )\n\n @ 16, 0 CLEAR TO 16, MaxCol()\n @ 16, 0 SAY cText\n OutStd( Chr( 7 ) )\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": "Create Harbour preprocessor definitions: Header file for contribution module 'hbbmp' (BMP image handling): contrib/hbbmp/hbbmp.ch. Defines 10 constants including: _HBBMP_CH_, HB_BMP_ERROR_SIZE, HB_BMP_ERROR_DEPTH, HB_BMP_ERROR_COLORVALUE, HB_BMP_ERROR_PALETTEFULL. Defines color and display constants"}, {"role": "assistant", "content": "#ifndef _HBBMP_CH_\n#define _HBBMP_CH_\n\n#define HB_BMP_ERROR_SIZE 1\n#define HB_BMP_ERROR_DEPTH 2\n#define HB_BMP_ERROR_COLORVALUE 3\n#define HB_BMP_ERROR_PALETTEFULL 4\n#define HB_BMP_ERROR_COLORINDEX 5\n#define HB_BMP_ERROR_RANGE 6\n#define HB_BMP_ERROR_CORRUPT 7\n#define HB_BMP_ERROR_UNSUPPORTED 8\n#define HB_BMP_ERROR_FILEREAD 9\n#define HB_BMP_ERROR_FILEWRITE 10\n#define HB_BMP_ERROR_PARAM 11\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 extra library: extras/httpsrv/modules/testajax.prg. Provides functions: HRBMAIN. This file implements server functionality"}, {"role": "assistant", "content": "MEMVAR _REQUEST\n\nFUNCTION HRBMAIN()\n\n LOCAL cW\n LOCAL cHtml := \"\"\n\n IF hb_HHasKey( _REQUEST, \"w\" )\n IF ! Empty( cW := _REQUEST[ \"w\" ] )\n cHtml += \"This is a reply from testajax : \" + cW\n ENDIF\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 contribution module 'hbxdiff' (File difference/patching): contrib/hbxdiff/tests/test2.prg. Contains procedures: Main. This file provides utility functions"}, {"role": "assistant", "content": "#require \"hbxdiff\"\n\n#include \"fileio.ch\"\n\nPROCEDURE Main()\n\n LOCAL pMMFOld, pMMFNew, pDiff\n LOCAL cFileCtx\n LOCAL hDif, hNew, hErr, hOld\n LOCAL cDiffName\n\n pMMFOld := xdl_init_mmfile( XDLT_STD_BLKSIZE )\n pMMFNew := xdl_init_mmfile( XDLT_STD_BLKSIZE, XDL_MMF_ATOMIC )\n\n cFileCtx := hb_MemoRead( __FILE__ )\n\n xdl_write_mmfile( pMMFOld, @cFileCtx )\n xdl_write_mmfile( pMMFNew, cFileCtx + hb_eol() + Space( 3 ) + \"RETURN NIL\" + hb_eol() )\n\n ? xdl_mmfile_cmp( pMMFOld, pMMFNew )\n\n hb_FNameSplit( __FILE__, NIL, @cDiffName, NIL )\n cDiffName := hb_FNameMerge( NIL, cDiffName, \".dif\" )\n\n hDif := FCreate( cDiffName, FC_NORMAL )\n IF FError() == 0\n FWrite( hDif, \"diff ---\" + hb_eol() )\n xdl_diff( pMMFOld, pMMFNew, 0, 3, hDif )\n\n FClose( hDif )\n ENDIF\n\n pDiff := xdl_init_mmfile( XDLT_STD_BLKSIZE, XDL_MMF_ATOMIC )\n cFileCtx := hb_MemoRead( cDiffName )\n xdl_write_mmfile( pDiff, cFileCtx )\n\n hNew := FCreate( hb_FNameMerge( NIL, cDiffName, \".new\" ), FC_NORMAL )\n hErr := FCreate( hb_FNameMerge( NIL, cDiffName, \".err\" ), FC_NORMAL )\n hOld := FCreate( hb_FNameMerge( NIL, cDiffName, \".old\" ), FC_NORMAL )\n IF FError() == 0\n ? xdl_patch( pMMFOld, pDiff, XDL_PATCH_NORMAL, hNew, hErr )\n ? xdl_patch( pMMFNew, pDiff, XDL_PATCH_REVERSE, hOld, hErr )\n\n FClose( hNew )\n FClose( hErr )\n FClose( hOld )\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/usrrdd/exrlx.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "REQUEST RLCDX\n\nPROCEDURE Main()\n\n dbCreate( \"_tst\", { { \"F1\", \"C\", 10, 0 } }, \"RLCDX\" )\n USE _tst VIA \"RLCDX\" SHARED\n ? \"Table: \", Alias(), \" open VIA: \", rddName()\n ? \"APPEND\"\n dbAppend()\n ? \"Current record locks:\"\n AEval( dbRLockList(), {| nRecNo | QQOut( nRecNo ) } )\n ? \"APPEND\"\n dbAppend()\n ? \"Current record locks:\"\n AEval( dbRLockList(), {| nRecNo | QQOut( nRecNo ) } )\n ? \"UNLOCK\"\n dbUnlock()\n ? \"Current record locks:\"\n AEval( dbRLockList(), {| nRecNo | QQOut( nRecNo ) } )\n\n ? \"Locking record 1\", dbRLock( 1 )\n ? \"Locking record 1\", dbRLock( 1 )\n ? \"Locking record 1\", dbRLock( 1 )\n ? \"Locking record 2\", dbRLock( 2 )\n ? \"Current record locks:\"\n AEval( dbRLockList(), {| nRecNo | QQOut( nRecNo ) } )\n ? \"UnLocking record 1...\"\n dbRUnlock( 1 )\n ? \"Current record locks:\"\n AEval( dbRLockList(), {| nRecNo | QQOut( nRecNo ) } )\n ? \"UnLocking record 2...\"\n dbRUnlock( 2 )\n ? \"Current record locks:\"\n AEval( dbRLockList(), {| nRecNo | QQOut( nRecNo ) } )\n ? \"UnLocking record 1...\"\n dbRUnlock( 1 )\n ? \"Current record locks:\"\n AEval( dbRLockList(), {| nRecNo | QQOut( nRecNo ) } )\n ? \"UnLocking record 1...\"\n dbRUnlock( 1 )\n ? \"Current record locks:\"\n AEval( dbRLockList(), {| nRecNo | QQOut( nRecNo ) } )\n\n CLOSE\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/and_or.prg. Provides functions: DispAndReturnNIL, AndOr. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n ? \"Testing logical shortcuts\"\n\n IF .F. .AND. DispAndReturnNIL() \n ENDIF\n\n ? \"Testing .T. .T.\"\n AndOr( .T., .T. )\n\n ? \"Testing .T. .F.\"\n AndOr( .T., .F. )\n\n ? \"Testing .F. .F.\"\n AndOr( .F., .F. )\n\n ? \"Testing errors...\"\n AndOr( 1, .T. )\n\n RETURN\n\nFUNCTION DispAndReturnNIL()\n\n ? \"this should not show!\"\n\n RETURN NIL\n\nFUNCTION AndOr( lValue1, lValue2 )\n\n IF lValue1 .AND. lValue2\n ? \"They are both true\"\n ELSE\n ? \"They are not both true\"\n ENDIF\n\n IF lValue1 .OR. lValue2\n ? \"At least one of them is true\"\n ELSE\n ? \"None of them are true\"\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: Header file for contribution module 'gtwvw': contrib/gtwvw/wvt2wvw.ch. Declares 5 preprocessor translations. Defines color and display constants"}, {"role": "assistant", "content": "#xtranslate Wvt_CreateMenu ( [<vlist,...>] ) => wvw_CreateMenu ( [<vlist>] )\n#xtranslate Wvt_CreatePopupMenu ( [<vlist,...>] ) => wvw_CreatePopupMenu ( [<vlist>] )\n#xtranslate Wvt_AppendMenu ( [<vlist,...>] ) => wvw_AppendMenu ( [<vlist>] )\n#xtranslate Wvt_DeleteMenu ( [<vlist,...>] ) => wvw_DeleteMenu ( [<vlist>] )\n#xtranslate Wvt_DestroyMenu ( [<vlist,...>] ) => wvw_DestroyMenu ( [<vlist>] )\n#xtranslate Wvt_EnableMenuItem ( [<vlist,...>] ) => wvw_EnableMenuItem ( [<vlist>] )\n#xtranslate Wvt_GetScreenWidth ( [<vlist,...>] ) => wvw_GetScreenWidth ( [<vlist>] )\n#xtranslate Wvt_GetScreenHeight ( [<vlist,...>] ) => wvw_GetScreenHeight ( [<vlist>] )\n#xtranslate Wvt_SetAltF4Close ( [<vlist,...>] ) => wvw_SetAltF4Close ( [<vlist>] )\n#xtranslate Wvt_GetRGBColor ( [<vlist,...>] ) => wvw_GetRGBColor ( [<vlist>] )\n#xtranslate Wvt_GetClipboard ( [<vlist,...>] ) => wvw_GetClipboard ( [<vlist>] )\n#xtranslate Wvt_SetClipboard ( [<vlist,...>] ) => wvw_SetClipboard ( [<vlist>] )\n#xtranslate Wvt_PasteFromClipboard ( [<vlist,...>] ) => wvw_PasteFromClipboard ( [<vlist>] )\n#xtranslate Wvt_Keyboard ( [<vlist,...>] ) => wvw_Keyboard ( [<vlist>] )\n#xtranslate Wvt_IsLButtonPressed ( [<vlist,...>] ) => wvw_IsLButtonPressed ( [<vlist>] )\n#xtranslate Wvt_GetPalette ( [<vlist,...>] ) => wvw_GetPalette ( [<vlist>] )\n#xtranslate Wvt_SetPalette ( [<vlist,...>] ) => wvw_SetPalette ( [<vlist>] )\n#xtranslate Wvt_CreateFont ( [<vlist,...>] ) => wvw_CreateFont ( [<vlist>] )\n#xtranslate Wvt_GetCursorPos ( [<vlist,...>] ) => wvw_GetCursorPos ( [<vlist>] )\n#xtranslate Wvt_ChooseFont ( [<vlist,...>] ) => wvw_ChooseFont ( [<vlist>] )\n#xtranslate Wvt_ChooseColor ( [<vlist,...>] ) => wvw_ChooseColor ( [<vlist>] )\n#xtranslate Wvt_LoadPicture ( [<vlist,...>] ) => wvw_LoadPicture ( [<vlist>] )\n#xtranslate Wvt_LoadFont ( [<vlist,...>] ) => wvw_LoadFont ( [<vlist>] )\n#xtranslate Wvt_LoadPen ( [<vlist,...>] ) => wvw_LoadPen ( [<vlist>] )\n#xtranslate Wvt_SetPen ( [<vlist,...>] ) => wvw_SetPen ( [<vlist>] )\n#xtranslate Wvt_SetBrush ( [<vlist,...>] ) => wvw_SetBrush ( [<vlist>] )\n\n#xtranslate Wvt_CreateDialogDynamic( [<vlist,...>] ) => wvw_CreateDialogDynamic( [<vlist>] )\n#xtranslate Wvt_CreateDialogModal ( [<vlist,...>] ) => wvw_CreateDialogModal ( [<vlist>] )\n#xtranslate Wvt__MakeDlgTemplate ( [<vlist,...>] ) => wvw__MakeDlgTemplate ( [<vlist>] )\n#xtranslate Wvt_LBAddString ( [<vlist,...>] ) => wvw_LBAddString ( [<vlist>] )\n#xtranslate Wvt_LBSetCurSel ( [<vlist,...>] ) => wvw_LBSetCurSel ( [<vlist>] )\n#xtranslate Wvt_CBAddString ( [<vlist,...>] ) => wvw_cbAddString ( [<vlist>] )\n#xtranslate Wvt_CBSetCurSel ( [<vlist,...>] ) => wvw_CBSetCurSel ( [<vlist>] )\n#xtranslate Wvt_DlgSetIcon ( [<vlist,...>] ) => wvw_DlgSetIcon ( [<vlist>] )\n\n\n#xtranslate Wvt_SetMenu ( [<vlist,...>] ) => wvw_SetMenu ( NIL [, <vlist>] )\n#xtranslate Wvt_SetPopupMenu ( [<vlist,...>] ) => wvw_SetPopupMenu ( NIL [, <vlist>] )\n#xtranslate Wvt_GetLastMenuEvent ( [<vlist,...>] ) => wvw_GetLastMenuEvent ( NIL [, <vlist>] )\n#xtranslate Wvt_SetMenuKeyEvent ( [<vlist,...>] ) => wvw_SetMenuKeyEvent ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawMenuBar ( [<vlist,...>] ) => wvw_DrawMenuBar ( NIL [, <vlist>] )\n#xtranslate WVT_SETWINDOWCENTRE ( [<vlist,...>] ) => wvw_SetWindowCentre ( NIL [, <vlist>] )\n#xtranslate Wvt_ProcessMessages ( [<vlist,...>] ) => wvw_ProcessMessages ( NIL [, <vlist>] )\n#xtranslate Wvt_GetTitle ( [<vlist,...>] ) => wvw_GetTitle ( NIL [, <vlist>] )\n#xtranslate Wvt_InvalidateRect ( [<vlist,...>] ) => wvw_InvalidateRect ( NIL [, <vlist>] )\n#xtranslate Wvt_ClientToScreen ( [<vlist,...>] ) => wvw_ClientToScreen ( NIL [, <vlist>] )\n#xtranslate Wvt_SetFont ( [<vlist,...>] ) => wvw_SetFont ( NIL [, <vlist>] )\n#xtranslate Wvt_SetIcon ( [<vlist,...>] ) => wvw_SetIcon ( NIL [, <vlist>] )\n#xtranslate Wvt_SetTitle ( [<vlist,...>] ) => wvw_SetTitle ( NIL [, <vlist>] )\n#xtranslate Wvt_SetWindowPos ( [<vlist,...>] ) => wvw_SetWindowPos ( NIL [, <vlist>] )\n#xtranslate Wvt_GetWindowHandle ( [<vlist,...>] ) => wvw_GetWindowHandle ( NIL [, <vlist>] )\n#xtranslate Wvt_SetCodepage ( [<vlist,...>] ) => wvw_SetCodepage ( NIL [, <vlist>] )\n#xtranslate Wvt_CenterWindow ( [<vlist,...>] ) => wvw_CenterWindow ( NIL [, <vlist>] )\n#xtranslate Wvt_SetMouseMove ( [<vlist,...>] ) => wvw_SetMouseMove ( NIL [, <vlist>] )\n#xtranslate Wvt_GetXYFromRowCol ( [<vlist,...>] ) => wvw_GetXYFromRowCol ( NIL [, <vlist>] )\n#xtranslate Wvt_GetFontInfo ( [<vlist,...>] ) => wvw_GetFontInfo ( NIL [, <vlist>] )\n#xtranslate Wvt_Minimize ( [<vlist,...>] ) => wvw_Minimize ( NIL [, <vlist>] )\n#xtranslate Wvt_Maximize ( [<vlist,...>] ) => wvw_Maximize ( NIL [, <vlist>] )\n#xtranslate Wvt_SetOnTop ( [<vlist,...>] ) => wvw_SetOnTop ( NIL [, <vlist>] )\n#xtranslate Wvt_SetAsNormal ( [<vlist,...>] ) => wvw_SetAsNormal ( NIL [, <vlist>] )\n#xtranslate Wvt_SaveScreen ( [<vlist,...>] ) => wvw_SaveScreen ( NIL [, <vlist>] )\n#xtranslate Wvt_RestScreen ( [<vlist,...>] ) => wvw_RestScreen ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawLabelObj ( [<vlist,...>] ) => wvw_DrawLabelObj ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawToolButtonState ( [<vlist,...>] ) => wvw_DrawToolButtonState ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawScrollButton ( [<vlist,...>] ) => wvw_DrawScrollButton ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawScrollThumbVert ( [<vlist,...>] ) => wvw_DrawScrollThumbVert ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawScrollThumbHorz ( [<vlist,...>] ) => wvw_DrawScrollThumbHorz ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawShadedRect ( [<vlist,...>] ) => wvw_DrawShadedRect ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawTextBox ( [<vlist,...>] ) => wvw_DrawTextBox ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawProgressBar ( [<vlist,...>] ) => wvw_DrawProgressBar ( NIL [, <vlist>] )\n#xtranslate Wvt_TrackPopupMenu ( [<vlist,...>] ) => wvw_TrackPopupMenu ( NIL [, <vlist>] )\n#xtranslate Wvt_GetMenu ( [<vlist,...>] ) => wvw_GetMenu ( NIL [, <vlist>] )\n#xtranslate Wvt_ShowWindow ( [<vlist,...>] ) => wvw_ShowWindow ( NIL [, <vlist>] )\n#xtranslate Wvt_UpdateWINDOW ( [<vlist,...>] ) => wvw_UpdateWindow ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawBoxGet ( [<vlist,...>] ) => wvw_DrawBoxGet ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawBoxRaised ( [<vlist,...>] ) => wvw_DrawBoxRaised ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawBoxRecessed ( [<vlist,...>] ) => wvw_DrawBoxRecessed ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawBoxGroup ( [<vlist,...>] ) => wvw_DrawBoxGroup ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawBoxGroupRaised ( [<vlist,...>] ) => wvw_DrawBoxGroupRaised ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawImage ( [<vlist,...>] ) => wvw_DrawImage ( NIL [, <vlist>] )\n#xtranslate Wvt_DrawLabel ( [<vlist,...>] ) => wvw_DrawLabel ( NIL [, <vlist>] )"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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 'hbamf' (): contrib/hbamf/hbamfobj.prg. Defines classes: amf_Obj, amf_Raw. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nCREATE CLASS amf_Obj\n\n METHOD New( hCachedData ) CONSTRUCTOR\n ERROR HANDLER noMessage( ... )\n METHOD msgNotFound( cMessage, ... )\n\n PROTECTED:\n\n VAR nVersion INIT 0\n VAR cRealClass\n VAR hCachedData\n VAR nRpcOid\n VAR pConnection\n VAR nID\n\n EXPORTED:\n\n ACCESS RealClass INLINE ::cRealClass\n ACCESS RpcOid INLINE ::nRpcOid\n\nENDCLASS\n\nMETHOD New( hCachedData ) CLASS amf_Obj\n\n ::hCachedData := hCachedData\n\n RETURN Self\n\nMETHOD noMessage( ... ) CLASS amf_Obj\n RETURN ::msgNotFound( __GetMessage(), ... )\n\nMETHOD msgNotFound( cMessage, ... ) CLASS amf_Obj\n\n IF PCount() == 1 .AND. !( hb_BLeft( cMessage, 1 ) == \"_\" )\n IF ! Empty( ::hCachedData ) .AND. hb_HHasKey( ::hCachedData, cMessage )\n RETURN ::hCachedData[ cMessage ]\n ENDIF\n ELSEIF PCount() > 1 .AND. hb_BLeft( cMessage, 1 ) == \"_\"\n IF Empty( ::hCachedData )\n ::hCachedData := { => }\n ENDIF\n RETURN ::hCachedData[ hb_BSubStr( cMessage, 2 ) ] := hb_PValue( 2 )\n ENDIF\n\n RETURN NIL\n\nCREATE CLASS amf_Raw\n\n METHOD New( cData ) CONSTRUCTOR\n METHOD GetData INLINE ::cData\n\n PROTECTED:\n VAR cData\n\nENDCLASS\n\nMETHOD New( cData ) CLASS amf_Raw\n\n ::cData := cData\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: Header file for contribution module 'hbexpat' (XML parsing library (Expat)): contrib/hbexpat/hbexpat.ch. Defines 10 constants including: HBEXPAT_CH_, HB_XML_STATUS_ERROR, HB_XML_STATUS_OK, HB_XML_ERROR_NOT_IMPLEMENTED_, HB_XML_ERROR_NONE. Defines error handling constants and codes"}, {"role": "assistant", "content": "#ifndef HBEXPAT_CH_\n#define HBEXPAT_CH_\n\n#define HB_XML_STATUS_ERROR 0\n#define HB_XML_STATUS_OK 1\n\n#define HB_XML_ERROR_NOT_IMPLEMENTED_ ( -1 ) \n#define HB_XML_ERROR_NONE 0\n#define HB_XML_ERROR_NO_MEMORY 1\n#define HB_XML_ERROR_SYNTAX 2\n#define HB_XML_ERROR_NO_ELEMENTS 3\n#define HB_XML_ERROR_INVALID_TOKEN 4\n#define HB_XML_ERROR_UNCLOSED_TOKEN 5\n#define HB_XML_ERROR_PARTIAL_CHAR 6\n#define HB_XML_ERROR_TAG_MISMATCH 7\n#define HB_XML_ERROR_DUPLICATE_ATTRIBUTE 8\n#define HB_XML_ERROR_JUNK_AFTER_DOC_ELEMENT 9\n#define HB_XML_ERROR_PARAM_ENTITY_REF 10\n#define HB_XML_ERROR_UNDEFINED_ENTITY 11\n#define HB_XML_ERROR_RECURSIVE_ENTITY_REF 12\n#define HB_XML_ERROR_ASYNC_ENTITY 13\n#define HB_XML_ERROR_BAD_CHAR_REF 14\n#define HB_XML_ERROR_BINARY_ENTITY_REF 15\n#define HB_XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF 16\n#define HB_XML_ERROR_MISPLACED_XML_PI 17\n#define HB_XML_ERROR_UNKNOWN_ENCODING 18\n#define HB_XML_ERROR_INCORRECT_ENCODING 19\n#define HB_XML_ERROR_UNCLOSED_CDATA_SECTION 20\n#define HB_XML_ERROR_EXTERNAL_ENTITY_HANDLING 21\n#define HB_XML_ERROR_NOT_STANDALONE 22\n#define HB_XML_ERROR_UNEXPECTED_STATE 23\n#define HB_XML_ERROR_ENTITY_DECLARED_IN_PE 24\n#define HB_XML_ERROR_FEATURE_REQUIRES_XML_DTD 25\n#define HB_XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING 26\n#define HB_XML_ERROR_UNBOUND_PREFIX 27\n#define HB_XML_ERROR_UNDECLARING_PREFIX 28\n#define HB_XML_ERROR_INCOMPLETE_PE 29\n#define HB_XML_ERROR_XML_DECL 30\n#define HB_XML_ERROR_TEXT_DECL 31\n#define HB_XML_ERROR_PUBLICID 32\n#define HB_XML_ERROR_SUSPENDED 33\n#define HB_XML_ERROR_NOT_SUSPENDED 34\n#define HB_XML_ERROR_ABORTED 35\n#define HB_XML_ERROR_FINISHED 36\n#define HB_XML_ERROR_SUSPEND_PE 37\n#define HB_XML_ERROR_RESERVED_PREFIX_XML 38\n#define HB_XML_ERROR_RESERVED_PREFIX_XMLNS 39\n#define HB_XML_ERROR_RESERVED_NAMESPACE_URI 40\n#define HB_XML_ERROR_INVALID_ARGUMENT 41\n\n#define HB_XML_INITIALIZED 0\n#define HB_XML_PARSING 1\n#define HB_XML_FINISHED 2\n#define HB_XML_SUSPENDED 3\n\n#define HB_XML_PARAM_ENTITY_PARSING_NEVER 0\n#define HB_XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE 1\n#define HB_XML_PARAM_ENTITY_PARSING_ALWAYS 2\n\n#define HB_XML_ATTR_cName 1\n#define HB_XML_ATTR_cValue 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 'hbodbc' (ODBC database connectivity): contrib/hbodbc/tests/odbc.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbodbc\"\n\nPROCEDURE Main()\n\n LOCAL hEnv\n LOCAL hDbc\n LOCAL hStmt\n LOCAL cConnStr\n LOCAL cConstrout := Space( 1024 )\n LOCAL nRows := 0\n LOCAL cCode, cFunc, cState, cComm\n LOCAL cError1, nError, cError2\n\n ? \"Version: \" + hb_NumToHex( hb_odbcVer() )\n\n cConnStr := \"DBQ=\" + hb_FNameMerge( hb_DirBase(), \"test.mdb\" ) + \";Driver={Microsoft Access Driver (*.mdb)}\"\n\n ? PadC( \"*** ODBC ACCESS TEST ***\", 80 )\n ?\n ? \"Allocating environment... \"\n SQLAllocEnv( @hEnv )\n ? \"Allocating connection... \"\n SQLAllocConnect( hEnv, @hDbc )\n ? \"-- 1st\"\n ? \"Connecting to driver \" + cConnStr + \"... \"\n ? SQLDriverConnect( hDbc, cConnStr, @cConstrout )\n ? cConstrout\n ? \"-- 2nd (test)\"\n cConnStr := \"DBQ=\" + hb_FNameMerge( hb_DirBase(), \"test_nothere.mdb\" ) + \";Driver={Not here (*.non)}\"\n ? \"Connecting to driver \" + cConnStr + \"... \"\n ? SQLDriverConnect( hDbc, cConnStr, @cConstrout )\n ? cConstrout\n ? SQLError( , hDbc,, @cError1, @nError, @cError2 )\n ? \"SQLError\", cError1, nError, cError2\n ? \"--\"\n ? \"Allocating statement... \"\n SQLAllocStmt( hDbc, @hStmt )\n\n ? SQLError( hEnv,,, @cError1, @nError, @cError2 )\n ? \"SQLError\", cError1, nError, cError2\n ? SQLGetDiagRec( SQL_HANDLE_ENV, hEnv, 1, @cError1, @nError, @cError2 )\n ? \"SQLGetDiagRec\", cError1, nError, cError2\n\n ? \"SQL: SELECT FROM test\"\n ? SQLExecDirect( hStmt, \"SELECT FROM test\" )\n\n ? SQLError( ,, hStmt, @cError1, @nError, @cError2 )\n ? \"SQLError\", cError1, nError, cError2\n ? SQLGetDiagRec( SQL_HANDLE_STMT, hStmt, 1, @cError1, @nError, @cError2 )\n ? \"SQLGetDiagRec\", cError1, nError, cError2\n\n ?\n ? \"SQL: SELECT * FROM test\"\n SQLExecDirect( hStmt, \"SELECT * FROM test\" )\n\n ?\n\n DO WHILE SQLFetch( hStmt ) == 0\n SQLGetData( hStmt, 1, SQL_CHAR, 128, @cCode )\n SQLGetData( hStmt, 2, SQL_CHAR, 128, @cFunc )\n SQLGetData( hStmt, 3, SQL_CHAR, 128, @cState )\n SQLGetData( hStmt, 4, SQL_CHAR, 128, @cComm )\n ? cCode, PadR( cFunc, 20 ), cState, cComm\n nRows++\n ENDDO\n\n ? \"------------------------------------------------------------------------------\"\n ? Str( nRows, 4 ), \" Row(s) affected.\"\n\n SQLDisconnect( hDbc )\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/diskspac.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"fileio.ch\"\n\nPROCEDURE Main( cDisk )\n\n IF Empty( cDisk )\n cDisk := hb_DirBase() + hb_ps()\n ENDIF\n\n ? \"Bytes available on disk: \" + Transform( hb_DiskSpace( cDisk, HB_DISK_FREE ), \"999,999,999,999\" )\n ? \"Bytes available for use: \" + Transform( hb_DiskSpace( cDisk, HB_DISK_AVAIL ), \"999,999,999,999\" )\n ? \" Bytes used: \" + Transform( hb_DiskSpace( cDisk, HB_DISK_USED ), \"999,999,999,999\" )\n ? \" Total bytes at \" + cDisk + \": \" + Transform( hb_DiskSpace( cDisk, HB_DISK_TOTAL ), \"999,999,999,999\" )\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 'hbpipeio' (Process pipe I/O operations): contrib/hbpipeio/tests/test.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbpipeio\"\n\n#include \"fileio.ch\"\n\nPROCEDURE Main()\n LOCAL pFile, cData, cBuffer, cResult, nLen, nDone\n\n IF Empty( pFile := hb_vfOpenProcess( \"gzip\", FO_READWRITE, 1000 ) )\n ? \"Cannot open file.\"\n ELSE\n\n ? \"writting...\"\n cData := hb_tsToStr( hb_dateTime() ) + hb_eol() + ;\n Version() + hb_eol() + ;\n OS() + hb_eol() + ;\n Replicate( \"0123456789\" + hb_eol(), 1000 ) + ;\n \"END\" + hb_eol()\n nDone := 0\n WHILE nDone < hb_BLen( cData ) .AND. ;\n ( nLen := hb_vfWrite( pFile, hb_BSubStr( cData, nDone + 1 ) ) ) > 0\n nDone += nLen\n ? \"written: \" + hb_ntos( nLen )\n ENDDO\n ? \"total bytes written: \" + hb_ntos( nDone ) + ;\n \", error: \" + hb_ntos( FError() )\n \n hb_vfConfig( pFile, HB_VF_SHUTDOWN, FO_WRITE )\n ?\n\n cResult := \"\"\n ? \"reading...\"\n cBuffer := Space( 1000 )\n WHILE ( nLen := hb_vfRead( pFile, @cBuffer ) ) > 0\n cResult += hb_BLeft( cBuffer, nLen )\n ? \"read: \" + hb_ntos( nLen )\n ENDDO\n ? \"total bytes read: \" + hb_ntos( hb_BLen( cResult ) ) + ;\n \", error: \" + hb_ntos( FError() )\n\n \n ? \"closing...\"\n hb_vfClose( pFile )\n ? \"DONE\"\n ?\n\n hb_vfErase( \"data.gz\" )\n ? \"write data.gz \" + hb_ntos( hb_BLen( cResult ) ) + \" -> \" + ;\n iif( hb_BLen( cResult ) > 0 .AND. hb_memoWrit( \"data.gz\", cResult ), ;\n \"OK\", \"ERROR\" )\n \n IF hb_ZUncompress( cResult ) == cData\n ? \"OK, GZIP output decompressed correctly and muches the source\"\n ELSE\n ? \"ERROR, decompressed GZIP output does not much the source\"\n ENDIF\n ENDIF\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 a Harbour program with procedures: Main, ShowAdsError. Harbour contribution module 'rddads' (): contrib/rddads/tests/datad.prg. Contains procedures: Main, ShowAdsError. This file handles database operations"}, {"role": "assistant", "content": "#require \"rddads\"\n\nREQUEST ADS\n\n#if defined( __HBDYNLOAD__RDDADS__ )\n#include \"rddads.hbx\"\n#endif\n\nPROCEDURE Main()\n\n LOCAL n\n LOCAL cErr, cStr\n LOCAL aStru := { { \"ID\", \"A\", 1, 0 }, { \"Name\", \"C\", 50, 0 }, { \"address\", \"C\", 50, 0 }, { \"city\", \"C\", 30, 0 }, { \"Age\", \"n\", 3, 0 } }\n LOCAL hConnection1\n\n#if defined( __HBDYNLOAD__RDDADS__ )\n LOCAL l := hb_libLoad( hb_libName( \"rddads\" + hb_libPostfix() ) )\n\n hb_rddADSRegister()\n\n HB_SYMBOL_UNUSED( l )\n#elif defined( __HBSCRIPT__HBSHELL )\n hb_rddADSRegister()\n#endif\n\n CLS\n\n rddSetDefault( \"ADSADT\" )\n AdsSetServerType( 7 )\n SET FILETYPE TO ADT\n\n ? \"Default connection is 0:\", AdsConnection()\n\n FErase( \"harbour.add\" )\n FErase( \"harbour.ai\" )\n FErase( \"harbour.am\" )\n FErase( \"Table1.adt\" )\n FErase( \"Table1.adi\" )\n FErase( \"Table2.adt\" )\n FErase( \"Table2.adi\" )\n\n \n IF ! hb_FileExists( \"harbour.add\" )\n\n AdsDDCreate( \"harbour.add\", , \"Harbour ADS demo for data dictionary\" )\n \n ? \"Default connection is now this admin handle:\", AdsConnection()\n AdsDisconnect() \n \n \n ? \"Default connection is now this handle (zero):\", AdsConnection()\n\n \n dbCreate( \"Table1\", aStru )\n dbCreate( \"Table2\", aStru )\n \n USE table1 NEW\n INDEX ON FIELD->id TAG codigo\n USE\n\n USE table2 NEW\n INDEX ON FIELD->id TAG codigo\n USE\n ENDIF\n\n \n IF AdsConnect60( \"harbour.add\", 7; \n , \"ADSSYS\", \"\", , @hConnection1 )\n \n \n ? \"Default connection is now this handle:\", AdsConnection()\n ? \" Is it a Data Dict connection? (ADS_DATABASE_CONNECTION=6, \"\n ? \" ADS_SYS_ADMIN_CONNECTION=7):\", AdsGetHandleType()\n\n \n AdsDDCreateUser( , \"Luiz\", \"papael\", \"This is user Luiz\" )\n\n\n IF AdsDDGetUserProperty( \"Luiz\", ADS_DD_COMMENT, @cStr, hConnection1 )\n ? \"User comment:\", cStr\n ELSE\n ? \"Error retrieving User comment\"\n ENDIF\n\n\n ? \"Add the tables\"\n AdsDDAddTable( \"Table1\", \"table1.adt\", \"table1.adi\" )\n ?\n IF ! AdsDDAddTable( \"Customer Data\", \"table2.adt\", \"table2.adi\" )\n \n ? \"Error adding table:\", AdsGetLastError( @cErr ), cErr\n ENDIF\n ? \"Set new admin pword on default connection:\", AdsDDSetDatabaseProperty( ADS_DD_ADMIN_PASSWORD, \"newPWord\" )\n ? \"Set new admin pword on explicit connection:\", AdsDDSetDatabaseProperty( ADS_DD_ADMIN_PASSWORD, \"newPWord\", hConnection1 )\n ? \"Clear admin pword:\", AdsDDSetDatabaseProperty( ADS_DD_ADMIN_PASSWORD, \"\" )\n\n ELSE\n ? \"Error connecting to harbour.add!\"\n ENDIF\n AdsDisconnect( hConnection1 )\n hConnection1 := NIL \n\n ? \"Default connection is back to 0:\", AdsConnection()\n ? \"Is a Data Dict connection? (AE_INVALID_HANDLE = 5018):\", AdsGetHandleType()\n\n \n IF AdsConnect60( \"harbour.add\", 7; \n , \"Luiz\", \"papael\", , @hConnection1 )\n ? \"Default connection is now this handle:\", AdsConnection()\n ? \"Connection type?\", AdsGetHandleType()\n\n FOR n := 1 TO 100\n IF AdsCreateSQLStatement( \"Data2\", 3 )\n IF ! AdsExecuteSQLDirect( \" insert into Table1( name,address,city,age) VALUES( '\" + StrZero( n ) + \"','\" + StrZero( n ) + \"','\" + StrZero( n ) + \"',\" + Str( n ) + \")\" )\n ShowAdsError()\n ENDIF\n USE\n ENDIF\n NEXT\n\n FOR n := 1 TO 100\n IF AdsCreateSQLStatement( \"Data1\", 3 )\n IF ! AdsExecuteSQLDirect( \" insert into \" + '\"Customer Data\"' + \"( name,address,city,age) VALUES( '\" + StrZero( n ) + \"','\" + StrZero( n ) + \"','\" + StrZero( n ) + \"',\" + Str( n ) + \")\" )\n ShowAdsError()\n ENDIF\n USE\n ENDIF\n NEXT\n\n\n dbUseArea( .T., , \"Customer Data\", \"custom\", .T., .F. )\n ? \"Press a key to browse\", Alias()\n Inkey( 0 )\n Browse()\n USE\n USE table1 NEW\n Browse()\n USE\n ENDIF\n\n AdsDisconnect( hConnection1 )\n\n RETURN\n\nPROCEDURE ShowAdsError()\n\n LOCAL cMsg\n\n AdsGetLastError( @cMsg )\n\n Alert( cMsg )\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/iotcp.prg. Provides 7 functions including: IOTCP_Open, IOTCP_Close, IOTCP_Read, IOTCP_Write, IOTCP_Eof. Contains procedures: CLIPINIT, Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbiousr.ch\"\n#include \"hbsocket.ch\"\n#include \"fileio.ch\"\n#include \"error.ch\"\n\nANNOUNCE HB_IOTCP\n\n#define IOTCP_SOCKET 1\n#define IOTCP_EOF 2\n#define IOTCP_TIMEOUT 3\n\n#define IOTCP_ERRORBASE 10000\n\n#define IOTCP_NEW( sd, tout ) { sd, .F., tout }\n\n\nSTATIC FUNCTION IOTCP_Open( cFile, cDefExt, nFlags, cPaths, oError )\n LOCAL nTimeout := 10000, nError, hSock := NIL, aFile := NIL\n LOCAL cAddr, cRest, nPort := 0, aAddr\n LOCAL nAt\n\n HB_SYMBOL_UNUSED( cDefExt )\n HB_SYMBOL_UNUSED( cPaths )\n\n \n cAddr := substr( cFile, 5 )\n\n \n IF ( nAt := At( \":\", cAddr ) ) > 1\n cRest := SubStr( cAddr, nAt + 1 )\n cAddr := Left( cAddr, nAt - 1 )\n IF ( nPort := Val( cRest ) ) > 0\n WHILE IsDigit( cRest )\n cRest := SubStr( cRest, 2 )\n ENDDO\n IF cRest = \":\"\n cRest := SubStr( cRest, 2 )\n IF IsDigit( cRest ) .AND. ( nTimeout := Val( cRest ) ) > 0\n WHILE IsDigit( cRest )\n cRest := SubStr( cRest, 2 )\n ENDDO\n IF cRest = \":\"\n cRest := \"\"\n ENDIF\n ENDIF\n ENDIF\n IF ! cRest == \"\"\n nPort := 0\n ENDIF\n ENDIF\n ENDIF\n\n IF nPort != 0\n IF !Empty( aAddr := hb_socketResolveInetAddr( cAddr, nPort ) ) .AND. ;\n !Empty( hSock := hb_socketOpen() )\n hb_socketSetKeepAlive( hSock, .T. )\n IF hb_socketConnect( hSock, aAddr, nTimeout )\n IF !Empty( hSock )\n SWITCH hb_bitAnd( nFlags, hb_bitOr( FO_READ, FO_WRITE, FO_READWRITE ) )\n CASE FO_READ\n hb_socketShutdown( hSock, HB_SOCKET_SHUT_WR )\n EXIT\n CASE FO_WRITE\n hb_socketShutdown( hSock, HB_SOCKET_SHUT_RD )\n EXIT\n ENDSWITCH\n aFile := IOTCP_NEW( hSock, nTimeout )\n ENDIF\n ENDIF\n IF aFile == NIL\n nError := hb_socketGetError()\n hb_socketClose( hSock )\n ENDIF\n ENDIF\n IF nError == 0 .AND. aFile == NIL\n nError := hb_socketGetError()\n ENDIF\n ELSE\n nError := HB_SOCKET_ERR_WRONGADDR\n ENDIF\n\n IOUSR_SetError( nError, IOTCP_ERRORBASE )\n\n IF oError != NIL\n oError:filename := cFile\n IF aFile == NIL\n oError:osCode := nError\n oError:genCode := EG_OPEN\n ENDIF\n ENDIF\n\nRETURN aFile \n\n\nSTATIC FUNCTION IOTCP_Close( aFile )\n hb_socketClose( aFile[ IOTCP_SOCKET ] )\n IOUSR_SetError( hb_socketGetError(), IOTCP_ERRORBASE )\nRETURN NIL\n\n\nSTATIC FUNCTION IOTCP_Read( aFile, cData, nLen, nTimeout )\n LOCAL nRead := 0, nError\n\n IF !aFile[ IOTCP_EOF ]\n IF nTimeout == -1\n nTimeout := aFile[ IOTCP_TIMEOUT ]\n ENDIF\n nRead := hb_socketRecv( aFile[ IOTCP_SOCKET ], @cData, nLen, 0, nTimeout )\n nError := hb_socketGetError()\n IF nRead <= 0\n SWITCH nError\n CASE HB_SOCKET_ERR_TIMEOUT\n CASE HB_SOCKET_ERR_AGAIN\n CASE HB_SOCKET_ERR_TRYAGAIN\n EXIT\n OTHERWISE\n aFile[ IOTCP_EOF ] := .F.\n ENDSWITCH\n nRead := 0\n ENDIF\n IOUSR_SetError( nError, IOTCP_ERRORBASE )\n ENDIF\nRETURN nRead\n\n\nSTATIC FUNCTION IOTCP_Write( aFile, cData, nLen, nTimeout )\n IF nTimeout == -1\n nTimeout := aFile[ IOTCP_TIMEOUT ]\n ENDIF\n nLen := hb_socketSend( aFile[ IOTCP_SOCKET ], cData, nLen, 0, nTimeout )\n IOUSR_SetError( hb_socketGetError(), IOTCP_ERRORBASE )\nRETURN iif( nLen < 0, 0, nLen )\n\n\nSTATIC FUNCTION IOTCP_Eof( aFile )\nRETURN aFile[ IOTCP_EOF ]\n\n\nSTATIC FUNCTION IOTCP_Configure( aFile, nIndex, xValue )\n HB_SYMBOL_UNUSED( aFile )\n HB_SYMBOL_UNUSED( nIndex )\n HB_SYMBOL_UNUSED( xValue )\nRETURN .F.\n\n\nSTATIC FUNCTION IOTCP_Handle( aFile )\n IOUSR_SetError( 0, IOTCP_ERRORBASE )\nRETURN hb_socketGetFD( aFile[ IOTCP_SOCKET ] )\n\n\nINIT PROCEDURE CLIPINIT\n LOCAL aMethods[ IOUSR_METHODCOUNT ]\n\n aMethods[ IOUSR_OPEN ] := @IOTCP_Open()\n aMethods[ IOUSR_CLOSE ] := @IOTCP_Close()\n aMethods[ IOUSR_READ ] := @IOTCP_Read()\n aMethods[ IOUSR_WRITE ] := @IOTCP_Write()\n aMethods[ IOUSR_EOF ] := @IOTCP_Eof()\n aMethods[ IOUSR_CONFIGURE ] := @IOTCP_Configure()\n aMethods[ IOUSR_HANDLE ] := @IOTCP_Handle()\n\n IOUSR_Register( aMethods, \"tcp:\" )\nRETURN\n\n\nREQUEST HB_IOTCP\n\nPROCEDURE Main( cAddr )\n LOCAL hFile, cData, cSend, cEOL, nLen\n\n IF Empty( cAddr )\n cAddr := \"tcp:smtp.gmail.com:25:10000\"\n ENDIF\n\n ? \"open:\", cAddr\n hFile := hb_vfOpen( cAddr, FO_READWRITE )\n IF Empty( hFile )\n ? \"Open error:\", FError()\n ELSE\n cData := Space( 1024 )\n cEOL := e\"\\r\\n\"\n IF ( nLen := hb_vfRead( hFile, @cData,, 10000 ) ) > 0\n ? \"<< \" + StrTran( HB_BLeft( cData, nLen ), cEOL, cEOL + \"<< \" )\n ENDIF\n cSend := \"EHLO\" + cEOL\n nLen := hb_vfWrite( hFile, cSend,, 1000 )\n ? \">> \" + StrTran( HB_BLeft( cSend, nLen ), cEOL, cEOL + \">> \" )\n IF nLen != hb_BLen( cSend )\n ? \"WRITE ERROR:\", FError()\n ENDIF\n IF ( nLen := hb_vfRead( hFile, @cData,, 10000 ) ) > 0\n ? \"<< \" + StrTran( HB_BLeft( cData, nLen ), cEOL, cEOL + \"<< \" )\n ENDIF\n cSend := \"QUIT\" + cEOL\n nLen := hb_vfWrite( hFile, cSend,, 1000 )\n ? \">> \" + StrTran( HB_BLeft( cSend, nLen ), cEOL, cEOL + \">> \" )\n IF nLen != hb_BLen( cSend )\n ? \"WRITE ERROR:\", FError()\n ENDIF\n IF ( nLen := hb_vfRead( hFile, @cData,, 10000 ) ) > 0\n ? \"<< \" + StrTran( HB_BLeft( cData, nLen ), cEOL, cEOL + \"<< \" )\n ENDIF\n hb_vfClose( hFile )\n ? \"closed, error:\", FError()\n ENDIF\n ?\n WAIT\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": "Here is a Harbour (xBase/Clipper) implementation:\n\nHarbour header file: include/hbcom.ch. Defines 10 constants including: HB_COM_CH_, HB_COM_IFLUSH, HB_COM_OFLUSH, HB_COM_IOFLUSH, HB_COM_MCR_DTR. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HB_COM_CH_\n#define HB_COM_CH_\n\n\n#define HB_COM_IFLUSH 1\n#define HB_COM_OFLUSH 2\n#define HB_COM_IOFLUSH 3\n\n\n#define HB_COM_MCR_DTR 0x01 \n#define HB_COM_MCR_RTS 0x02 \n#define HB_COM_MCR_OUT1 0x04 \n#define HB_COM_MCR_OUT2 0x08 \n#define HB_COM_MCR_LOOP 0x10 \n\n\n#define HB_COM_MSR_DELTA_CTS 0x01 \n#define HB_COM_MSR_DELTA_DSR 0x02 \n#define HB_COM_MSR_TERI 0x04 \n#define HB_COM_MSR_DELTA_DCD 0x08 \n#define HB_COM_MSR_CTS 0x10 \n#define HB_COM_MSR_DSR 0x20 \n#define HB_COM_MSR_RI 0x40 \n#define HB_COM_MSR_DCD 0x80 \n\n\n#define HB_COM_LSR_DATA_READY 0x01 \n#define HB_COM_LSR_OVERRUN_ERR 0x02 \n#define HB_COM_LSR_PARITY_ERR 0x04 \n#define HB_COM_LSR_FRAMING_ERR 0x08 \n#define HB_COM_LSR_BREAK 0x10 \n#define HB_COM_LSR_TRANS_HOLD_EMPTY 0x20 \n#define HB_COM_LSR_TRANS_EMPTY 0x40 \n\n\n#define HB_COM_FLOW_IRTSCTS 0x01 \n#define HB_COM_FLOW_ORTSCTS 0x02 \n#define HB_COM_FLOW_IDTRDSR 0x04 \n#define HB_COM_FLOW_ODTRDSR 0x08 \n#define HB_COM_FLOW_DCD 0x10 \n#define HB_COM_FLOW_XOFF 0x20 \n#define HB_COM_FLOW_XON 0x40 \n\n\n#define HB_COM_FL_OOFF 0x01\n#define HB_COM_FL_OON 0x02\n#define HB_COM_FL_IOFF 0x04\n#define HB_COM_FL_ION 0x08\n#define HB_COM_FL_SOFT 0x10\n#define HB_COM_FL_RTSCTS 0x20\n#define HB_COM_FL_DTRDSR 0x40\n#define HB_COM_FL_DCD 0x80\n\n\n#define HB_COM_TX_CTS 0x01\n#define HB_COM_TX_DSR 0x02\n#define HB_COM_TX_DCD 0x04\n#define HB_COM_TX_XOFF 0x08\n#define HB_COM_TX_EMPTY 0x10\n#define HB_COM_TX_RFLUSH 0x20\n\n\n#define HB_COM_RX_XOFF 0x01\n\n\n#define HB_COM_ERR_WRONGPORT 1\n#define HB_COM_ERR_CLOSED 2\n#define HB_COM_ERR_TIMEOUT 3\n#define HB_COM_ERR_NOSUPPORT 4\n#define HB_COM_ERR_PARAMVALUE 5\n#define HB_COM_ERR_BUSY 6\n#define HB_COM_ERR_OTHER 7\n#define HB_COM_ERR_ALREADYOPEN 8\n#define HB_COM_ERR_IO 9\n#define HB_COM_ERR_PIPE 10\n#define HB_COM_ERR_ACCESS 11\n#define HB_COM_ERR_NOCOM 12\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 'hbmysql' (MySQL database client library): contrib/hbmysql/tests/test.prg. Contains procedures: Main. This file handles database operations"}, {"role": "assistant", "content": "#require \"hbmysql\"\n\n#include \"dbstruct.ch\"\n\nPROCEDURE Main( cArg )\n\n LOCAL oServer, oQuery2, oRow, aStru\n LOCAL oQuery\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n oServer := TMySQLServer():New( \"localhost\", \"root\", \"\" )\n IF oServer:NetErr()\n Alert( oServer:Error() )\n ENDIF\n\n oServer:SelectDB( \"ims\" )\n\n dbUseArea( .T.,, cArg, \"wn\", .F. )\n\n IF ! oServer:DeleteTable( \"test\" )\n Alert( oServer:Error() )\n ENDIF\n\n aStru := dbStruct()\n IF oServer:CreateTable( \"test\", aStru )\n Alert( \"test created successfully\" )\n ELSE\n Alert( oServer:Error() )\n ENDIF\n\n oQuery := oServer:Query( \"SELECT C111, C116, C134 from maga limit 10\" )\n\n oServer:Destroy()\n\n DO WHILE ! wn->( Eof() )\n\n oQuery2 := oServer:Query( \"SELECT * from test where CODF='\" + wn->CODF + \"' and CODP='\" + wn->CODP + \"'\" )\n\n IF oQuery2:LastRec() > 0\n\n ? \"found \"\n\n oRow := oQuery2:GetRow()\n\n oRow:FieldPut( oRow:FieldPos( \"GIACENZA\" ), oRow:FieldGet( oRow:FieldPos( \"GIACENZA\" ) ) + wn->GIACENZA )\n oRow:FieldPut( oRow:FieldPos( \"ACQGR\" ), oRow:FieldGet( oRow:FieldPos( \"ACQGR\" ) ) + wn->ACQGR )\n oRow:FieldPut( oRow:FieldPos( \"ACQDI\" ), oRow:FieldGet( oRow:FieldPos( \"ACQDI\" ) ) + wn->ACQDI )\n\n IF ! oQuery2:Update( oRow )\n Alert( oQuery2:Error() )\n ENDIF\n ELSE\n ? wn->CODF + \" \" + wn->CODP\n\n oRow := oQuery:GetBlankRow()\n\n oRow:FieldPut( oRow:FieldPos( \"CODF\" ), wn->CODF )\n oRow:FieldPut( oRow:FieldPos( \"CODP\" ), wn->CODP )\n oRow:FieldPut( oRow:FieldPos( \"GIACENZA\" ), wn->GIACENZA )\n oRow:FieldPut( oRow:FieldPos( \"DATA\" ), wn->DATA + 365\n oRow:FieldPut( oRow:FieldPos( \"ACQGR\" ), wn->ACQGR )\n oRow:FieldPut( oRow:FieldPos( \"ACQDI\" ), wn->ACQDI )\n\n IF ! oQuery:Append( oRow )\n Alert( oQuery:Error() )\n ENDIF\n ENDIF\n\n wn->( dbSkip() )\n\n ENDDO\n\n wn->( 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 Runtime Library file: src/rtl/alert.prg. Provides functions: Alert, hb_Alert. Contains procedures: __NoNoAlert. This file implements error handling and reporting"}, {"role": "assistant", "content": "#include \"box.ch\"\n#include \"color.ch\"\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n#include \"hbgtinfo.ch\"\n\n\n#ifdef HB_CLP_UNDOC\nSTATIC s_lNoAlert\n#endif\n\nFUNCTION Alert( cMessage, aOptions, cColorNorm )\n\n LOCAL cColorHigh\n LOCAL aOptionsOK\n LOCAL cOption\n LOCAL nPos\n\n#ifdef HB_CLP_UNDOC\n\n IF s_lNoAlert == NIL\n s_lNoAlert := hb_argCheck( \"NOALERT\" )\n ENDIF\n\n IF s_lNoAlert\n RETURN NIL\n ENDIF\n\n#endif\n\n IF ! HB_ISSTRING( cMessage )\n RETURN NIL\n ENDIF\n\n cMessage := StrTran( cMessage, \";\", Chr( 10 ) )\n\n IF ! HB_ISSTRING( cColorNorm ) .OR. Empty( cColorNorm )\n cColorNorm := \"W+/R\" \n cColorHigh := \"W+/B\" \n ELSE\n cColorNorm := hb_ColorIndex( cColorNorm, CLR_STANDARD )\n cColorHigh := hb_StrReplace( ;\n iif( ( nPos := At( \"/\", cColorNorm ) ) > 0, ;\n SubStr( cColorNorm, nPos + 1 ) + \"/\" + Left( cColorNorm, nPos - 1 ), ;\n \"N/\" + cColorNorm ), \"+*\" )\n ENDIF\n\n aOptionsOK := {}\n FOR EACH cOption IN hb_defaultValue( aOptions, {} )\n IF HB_ISSTRING( cOption ) .AND. ! Empty( cOption )\n AAdd( aOptionsOK, cOption )\n ENDIF\n NEXT\n\n DO CASE\n CASE Len( aOptionsOK ) == 0\n aOptionsOK := { \"Ok\" }\n#ifdef HB_CLP_STRICT\n CASE Len( aOptionsOK ) > 4 \n ASize( aOptionsOK, 4 )\n#endif\n ENDCASE\n\n RETURN hb_gtAlert( cMessage, aOptionsOK, cColorNorm, cColorHigh )\n\n\nFUNCTION hb_Alert( xMessage, aOptions, cColorNorm, nDelay )\n\n LOCAL cMessage\n LOCAL cColorHigh\n LOCAL aOptionsOK\n LOCAL cString\n LOCAL nPos\n\n#ifdef HB_CLP_UNDOC\n\n IF s_lNoAlert == NIL\n s_lNoAlert := hb_argCheck( \"NOALERT\" )\n ENDIF\n\n IF s_lNoAlert\n RETURN NIL\n ENDIF\n\n#endif\n\n IF PCount() == 0\n RETURN NIL\n ENDIF\n\n DO CASE\n CASE HB_ISARRAY( xMessage )\n cMessage := \"\"\n FOR EACH cString IN xMessage\n cMessage += iif( cString:__enumIsFirst(), \"\", Chr( 10 ) ) + hb_CStr( cString )\n NEXT\n CASE HB_ISSTRING( xMessage )\n cMessage := StrTran( xMessage, \";\", Chr( 10 ) )\n CASE HB_ISHASH( xMessage ) .AND. \"TXT\" $ xMessage\n cMessage := xMessage\n if ! HB_ISARRAY( aOptions ) .OR. Empty( aOptions )\n aOptions := hb_HGetDef( xMessage, \"BTN\" )\n ENDIF\n OTHERWISE\n cMessage := hb_CStr( xMessage )\n ENDCASE\n\n IF ! HB_ISSTRING( cColorNorm ) .OR. Empty( cColorNorm )\n cColorNorm := \"W+/R\" \n cColorHigh := \"W+/B\" \n ELSE\n cColorNorm := hb_ColorIndex( cColorNorm, CLR_STANDARD )\n cColorHigh := hb_StrReplace( ;\n iif( ( nPos := At( \"/\", cColorNorm ) ) > 0, ;\n SubStr( cColorNorm, nPos + 1 ) + \"/\" + Left( cColorNorm, nPos - 1 ), ;\n \"N/\" + cColorNorm ), \"+*\" )\n ENDIF\n\n aOptionsOK := {}\n FOR EACH cString IN hb_defaultValue( aOptions, {} )\n IF HB_ISSTRING( cString ) .AND. ! Empty( cString )\n AAdd( aOptionsOK, cString )\n ENDIF\n NEXT\n\n DO CASE\n CASE Len( aOptionsOK ) == 0\n aOptionsOK := { \"Ok\" }\n#ifdef HB_CLP_STRICT\n CASE Len( aOptionsOK ) > 4 \n ASize( aOptionsOK, 4 )\n#endif\n ENDCASE\n\n RETURN hb_gtAlert( cMessage, aOptionsOK, cColorNorm, cColorHigh, nDelay )\n\n#ifdef HB_CLP_UNDOC\n\nPROCEDURE __NoNoAlert()\n\n s_lNoAlert := .F.\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": "Write a Harbour program with procedures: Main. Harbour contribution module 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/url.prg. Contains procedures: Main. This file provides network protocol implementations"}, {"role": "assistant", "content": "#require \"hbtip\"\n\n#include \"simpleio.ch\"\n\nPROCEDURE Main( cURL )\n\n LOCAL oURL := TURL():New( hb_defaultValue( cURL, \"https:\n\n ? \"cAddress\" , oURL:cAddress\n ? \"cProto\" , oURL:cProto\n ? \"cUserid\" , oURL:cUserid\n ? \"cPassword\" , oURL:cPassword\n ? \"cServer\" , oURL:cServer\n ? \"cPath\" , oURL:cPath\n ? \"cQuery\" , oURL:cQuery\n ? \"cFile\" , oURL:cFile\n ? \"nPort\" , oURL: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": "Generate Harbour code for: Harbour contribution module 'hbblat' (Blat email sending utility): contrib/hbblat/blatcls.prg. Defines classes: HBBlat. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbblat.ch\"\n#include \"hbclass.ch\"\n\nCREATE CLASS HBBlat\n\n PROTECTED:\n VAR nBlatError AS NUMERIC INIT BLAT_SUCCESS \n VAR cBlatError AS STRING INIT \"\" \n VAR nError AS NUMERIC INIT BLAT_SUCCESS\n VAR cError AS STRING INIT \"\"\n VAR aErrors AS ARRAY INIT {}\n VAR cCommand AS STRING INIT \"\"\n VAR cVersion AS STRING INIT \"0.2\"\n VAR cBlatVersion AS STRING INIT \"2.7.6\"\n VAR lChecked AS LOGICAL INIT .F.\n\n EXPORTED:\n \n VAR lSaveSettings AS LOGICAL INIT .F.\n\n \n METHOD SaveSettings( ... ) INLINE ::Install( \"SMTP\", ... )\n \n METHOD Install( cService, cServerAddress, cSenderEmailAddress, nTries, nPort, cProfile, cUsername, cPassword ) VIRTUAL \n\n \n VAR cOptionFile AS STRING\n VAR cTO AS STRING \n VAR cTOFile AS STRING \n VAR cCC AS STRING \n VAR cCCFile AS STRING \n VAR cBCC AS STRING \n VAR cBCCFile AS STRING \n VAR nMaxNames AS NUMERIC INIT 0 \n VAR lToUndiscloseRecipients AS LOGICAL INIT .F. \n VAR cSubject AS STRING \n VAR lSuppressSubject AS LOGICAL INIT .F. \n VAR cSubjectFile AS STRING \n VAR cBody AS STRING \n VAR cBodyFile AS STRING \n VAR cSignatureFile AS STRING \n VAR cTagFile AS STRING \n VAR cPostScriptumFile AS STRING \n\n \n VAR cProfile AS STRING \n VAR lShowProfiles AS LOGICAL INIT .F. \n VAR cServerSMTP AS STRING \n VAR cServerNNTP AS STRING \n VAR cServerPOP3 AS STRING \n VAR cServerIMAP AS STRING \n VAR cMailFrom AS STRING\n VAR cFrom AS STRING\n VAR cReplyTo AS STRING\n VAR cReturnPath AS STRING\n VAR cSender AS STRING\n VAR nPortSMTP AS NUMERIC \n VAR nPortNNTP AS NUMERIC \n VAR nPortPOP3 AS NUMERIC \n VAR nPortIMAP AS NUMERIC \n VAR cUserAUTH AS STRING\n VAR cPasswordAUTH AS STRING\n VAR cUserPOP3 AS STRING\n VAR cPasswordPOP3 AS STRING\n VAR cUserIMAP AS STRING\n VAR cPasswordIMAP AS STRING\n VAR lNoMD5 AS LOGICAL INIT .F. \n\n \n VAR cOrganization AS STRING\n VAR cUserAgent AS STRING\n VAR cXHeader AS STRING\n VAR lNoBlatHomePage AS LOGICAL INIT .T.\n VAR lNoBlatXHeader AS LOGICAL INIT .T.\n VAR lRequestDisposition AS LOGICAL INIT .F.\n VAR lRequestReturnReceipt AS LOGICAL INIT .F.\n VAR cCharSet AS STRING\n VAR cUserHeader1 AS STRING\n VAR cUserHeader2 AS STRING\n VAR cDSN AS STRING \n VAR lEHBase64 AS LOGICAL INIT .F. \n VAR lEHQuoted AS LOGICAL INIT .F. \n VAR lLowPriority AS LOGICAL INIT .F.\n VAR lHighPriority AS LOGICAL INIT .F.\n VAR nSensitivity AS NUMERIC INIT -1 \n\n \n VAR aAttachBinFiles AS ARRAY\n VAR cAttachBinFiles AS STRING\n\n VAR aAttachTextFiles AS ARRAY\n VAR cAttachTextFiles AS STRING\n\n VAR aAttachInlineFiles AS ARRAY\n VAR cAttachInlineFiles AS STRING\n\n VAR aHtmlEmbeddedFiles AS ARRAY\n VAR cHtmlEmbeddedFiles AS STRING \n\n VAR cAttachListBinFile AS STRING\n VAR cAttachListTextFile AS STRING\n VAR cAttachListEmbeddedFile AS STRING\n\n VAR lSendBinaryBase64 AS LOGICAL INIT .F.\n VAR lSendBinaryUUEncoded AS LOGICAL INIT .F.\n VAR lSendEnrichedText AS LOGICAL INIT .F.\n VAR lUnicode AS LOGICAL INIT .F.\n VAR lHtml AS LOGICAL INIT .F.\n VAR cAlternateText AS STRING\n VAR cAlternateTextFile AS STRING\n VAR lMime AS LOGICAL INIT .F. \n VAR lAskFor8BitMime AS LOGICAL INIT .F. \n VAR nMultipartSize AS NUMERIC \n VAR lNoMultipartMessage AS LOGICAL INIT .F. \n VAR cContentType AS STRING \n\n \n VAR cGroups AS STRING \n\n \n VAR lXtndXmit AS LOGICAL INIT .F. \n VAR lHelp AS LOGICAL INIT .F. \n VAR lQuiet AS LOGICAL INIT .T. \n VAR lDebug AS LOGICAL INIT .F. \n VAR cLogFile AS STRING \n VAR lLogTimestamp AS LOGICAL INIT .F. \n VAR lLogOverwrite AS LOGICAL INIT .F. \n VAR nTimeout AS NUMERIC INIT 60 \n VAR nTry AS NUMERIC INIT 1 \n VAR lBinary AS LOGICAL INIT .F. \n VAR cHostname AS STRING \n VAR lRaw AS LOGICAL INIT .F. \n VAR nDelay AS NUMERIC INIT 1 \n VAR cCommentChar AS STRING \n VAR lSuperDebug AS LOGICAL INIT .F. \n VAR lSuperDebugText AS LOGICAL INIT .F. \n\n \n VAR lIgnoreErrors AS LOGICAL INIT .F.\n\n\n METHOD Send()\n METHOD Command( cCommand ) VIRTUAL\n METHOD Error()\n METHOD ErrorString()\n METHOD GetErrors()\n METHOD Check()\n METHOD BlatError()\n METHOD BlatErrorString()\n METHOD TranslateBlatError( nErr )\n METHOD GetCommand()\n METHOD GetVersion() INLINE ::cVersion\n METHOD GetBlatVersion() INLINE ::cBlatVersion\n\nENDCLASS\n\nMETHOD Send() CLASS HBBlat\n\n ::Check()\n\n IF ::nError == BLAT_SUCCESS\n ::nBlatError := hb_blatSend( ::cCommand )\n IF ::nBlatError != 0\n ::nError := ::nBlatError\n ::cError := BLAT_TEXT_ERROR\n ELSE\n ::cError := BLAT_TEXT_SUCCESS\n ENDIF\n ::cBlatError := ::TranslateBlatError( ::nBlatError )\n ENDIF\n\n RETURN ::nError\n\nMETHOD PROCEDURE Check() CLASS HBBlat\n\n \n IF ! ::lChecked\n\n ::cCommand := \"\"\n\n \n IF ! HB_ISSTRING( ::cTO ) .AND. ! HB_ISSTRING( ::cTOFile ) .AND. ! ::lToUndiscloseRecipients\n ::nError := BLAT_ERR_MISSING_TO\n ::cError := ::TranslateBlatError( BLAT_ERR_MISSING_TO )\n AAdd( ::aErrors, { ::nError, ::cError } )\n IF ! ::lIgnoreErrors\n RETURN\n ENDIF\n ELSE\n IF HB_ISSTRING( ::cTO )\n ::cCommand += \" -to \" + ::cTo\n ENDIF\n ENDIF\n\n \n IF HB_ISSTRING( ::cTOFile )\n IF ! hb_FileExists( ::cTOFile )\n ::nError := BLAT_ERR_MISSING_TOFILE\n ::cError := ::TranslateBlatError( BLAT_ERR_MISSING_TOFILE ) + \": \" + ::cToFile\n AAdd( ::aErrors, { ::nError, ::cError } )\n IF ! ::lIgnoreErrors\n RETURN\n ENDIF\n ELSE\n ::cCommand += \" -tf \" + ::cToFile\n ENDIF\n ENDIF\n\n \n IF HB_ISSTRING( ::cCC )\n ::cCommand += \" -cc \" + ::cCC\n ENDIF\n\n \n IF HB_ISSTRING( ::cCCFile )\n IF ! hb_FileExists( ::cCCFile )\n ::nError := BLAT_ERR_MISSING_CCFILE"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/mt/mttest05.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\nthread static t_var := N_INIT\n\nproc main()\n local aThreads := {}, i, nSum\n ? Version()\n t_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\nfunc thFunc()\n local i\n for i := 1 to N_COUNT\n ++t_var\n next\nreturn t_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": "Create Harbour preprocessor definitions: Harbour contribution module 'hbdoc' (Documentation generation utilities): contrib/hbdoc/_base.prg. Defines classes: TPLGenerate. This file provides utility functions"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#define DOCUMENT_ 1\n#define INDEX_ 2\n\nCREATE CLASS TPLGenerate\n\n METHOD NewIndex( cDir, cFilename, cTitle, cExtension, cLang )\n METHOD NewDocument( cDir, cFilename, cTitle, cExtension, cLang )\n METHOD AddEntry( oEntry ) INLINE HB_SYMBOL_UNUSED( oEntry ), NIL\n METHOD AddReference( oEntry ) INLINE HB_SYMBOL_UNUSED( oEntry ), NIL\n METHOD BeginSection( cSection, cFilename ) INLINE HB_SYMBOL_UNUSED( cSection ), HB_SYMBOL_UNUSED( cFilename ), ::Depth++\n METHOD EndSection( cSection, cFilename ) INLINE HB_SYMBOL_UNUSED( cSection ), HB_SYMBOL_UNUSED( cFilename ), ::Depth--\n METHOD Generate()\n METHOD IsIndex() INLINE ::nType == INDEX_\n\n VAR cFilename AS STRING\n\n HIDDEN:\n\n METHOD New( cDir, cFilename, cTitle, cExtension, cLang, nType )\n\n PROTECTED:\n\n VAR nType AS INTEGER\n VAR Depth AS INTEGER INIT 0\n\n VAR cFile AS STRING INIT \"\"\n VAR cDir AS STRING\n VAR cTitle AS STRING\n VAR cExtension AS STRING\n VAR cLang AS STRING\n VAR cOutFileName AS STRING\n\nENDCLASS\n\nMETHOD NewIndex( cDir, cFilename, cTitle, cExtension, cLang ) CLASS TPLGenerate\n\n ::New( cDir, cFilename, cTitle, cExtension, cLang, INDEX_ )\n\n RETURN Self\n\nMETHOD NewDocument( cDir, cFilename, cTitle, cExtension, cLang ) CLASS TPLGenerate\n\n ::New( cDir, cFilename, cTitle, cExtension, cLang, DOCUMENT_ )\n\n RETURN Self\n\nMETHOD New( cDir, cFilename, cTitle, cExtension, cLang, nType ) CLASS TPLGenerate\n\n ::cDir := cDir\n ::cFilename := cFilename\n ::cTitle := cTitle\n ::cExtension := cExtension\n ::cLang := hb_defaultValue( cLang, \"en\" )\n ::nType := nType\n\n ::cOutFileName := ;\n ::cDir + hb_ps() + ;\n ::cFilename + ;\n iif( Lower( ::cLang ) == \"en\", \"\", \".\" + ::cLang ) + ;\n ::cExtension\n\n RETURN Self\n\nMETHOD Generate() CLASS TPLGenerate\n\n LOCAL cDir := hb_FNameDir( ::cOutFileName )\n\n IF ! hb_vfDirExists( cDir )\n OutStd( hb_eol() + \"Creating directory\", \"'\" + cDir + \"'\" )\n hb_vfDirMake( cDir )\n ENDIF\n\n hb_MemoWrit( ::cOutFileName, ::cFile )\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\nHeader file for contribution module 'hbwin' (Windows API wrapper functions): contrib/hbwin/hbsim.ch. Defines 10 constants including: HBSIM_CH_, SIM_E_OK, SIM_E_HB_MISC, SIM_E_HB_NOTINITIALIZED, SIM_E_SIMFAILURE. Defines Harbour internal constants and macros"}, {"role": "assistant", "content": "#ifndef HBSIM_CH_\n#define HBSIM_CH_\n\n\n#define SIM_E_OK 0 \n#define SIM_E_HB_MISC -1 \n#define SIM_E_HB_NOTINITIALIZED -10 \n#define SIM_E_SIMFAILURE -100 \n#define SIM_E_SIMBUSY -200 \n#define SIM_E_SIMWRONG -300 \n#define SIM_E_NOSIMMSGSTORAGE -400 \n#define SIM_E_SIMTOOLKITBUSY -500 \n#define SIM_E_SIMDOWNLOADERROR -600 \n#define SIM_E_SIMNOTINSERTED -700 \n#define SIM_E_PHSIMPINREQUIRED -800 \n#define SIM_E_PHFSIMPINREQUIRED -900 \n#define SIM_E_PHFSIMPUKREQUIRED -1000 \n#define SIM_E_SIMPINREQUIRED -1100 \n#define SIM_E_SIMPUKREQUIRED -1200 \n#define SIM_E_INCORRECTPASSWORD -1300 \n#define SIM_E_SIMPIN2REQUIRED -1400 \n#define SIM_E_SIMPUK2REQUIRED -1500 \n#define SIM_E_NETWKPINREQUIRED -1600 \n#define SIM_E_NETWKPUKREQUIRED -1700 \n#define SIM_E_SUBSETPINREQUIRED -1800 \n#define SIM_E_SUBSETPUKREQUIRED -1900 \n#define SIM_E_SVCPINREQUIRED -2000 \n#define SIM_E_SVCPUKREQUIRED -2100 \n#define SIM_E_CORPPINREQUIRED -2200 \n#define SIM_E_CORPPUKREQUIRED -2300 \n#define SIM_E_MEMORYFULL -2400 \n#define SIM_E_INVALIDINDEX -2500 \n#define SIM_E_NOTFOUND -2600 \n#define SIM_E_MEMORYFAILURE -2700 \n#define SIM_E_SIMMSGSTORAGEFULL -2800 \n#define SIM_E_EMPTYINDEX -2900 \n#define SIM_E_NOTREADY -3100 \n#define SIM_E_SECURITYFAILURE -3200 \n#define SIM_E_BUFFERTOOSMALL -3300 \n#define SIM_E_NOTTEXTMESSAGE -3400 \n#define SIM_E_NOSIM -3500 \n#define SIM_E_NETWORKERROR -3600 \n#define SIM_E_MOBILEERROR -3700 \n#define SIM_E_UNSUPPORTED -3800 \n#define SIM_E_BADPARAM -3900 \n#define SIM_E_UNDETERMINED -4000 \n#define SIM_E_RADIONOTPRESENT -4100 \n#define SIM_E_RADIOOFF -4200 \n\n\n#define SIM_PBSTORAGE_EMERGENCY 0x00000001 \n#define SIM_PBSTORAGE_FIXEDDIALING 0x00000002 \n#define SIM_PBSTORAGE_LASTDIALING 0x00000004 \n#define SIM_PBSTORAGE_OWNNUMBERS 0x00000008 \n#define SIM_PBSTORAGE_SIM 0x00000010 \n#define SIM_NUMPBSTORAGES 5 \n\n\n#define SIM_PBINDEX_FIRSTAVAILABLE 0xFFFFFFFF \n\n\n#define SIM_NUMPLAN_UNKNOWN 0x00000000 \n#define SIM_NUMPLAN_TELEPHONE 0x00000001 \n#define SIM_NUMPLAN_DATA 0x00000002 \n#define SIM_NUMPLAN_TELEX 0x00000003 \n#define SIM_NUMPLAN_NATIONAL 0x00000004 \n#define SIM_NUMPLAN_PRIVATE 0x00000005 \n#define SIM_NUMPLAN_ERMES 0x00000006 \n\n\n#define SIM_ADDRTYPE_UNKNOWN 0x00000000 \n#define SIM_ADDRTYPE_INTERNATIONAL 0x00000001 \n#define SIM_ADDRTYPE_NATIONAL 0x00000002 \n#define SIM_ADDRTYPE_NETWKSPECIFIC 0x00000003 \n#define SIM_ADDRTYPE_SUBSCRIBER 0x00000004 \n#define SIM_ADDRTYPE_ALPHANUM 0x00000005 \n#define SIM_ADDRTYPE_ABBREV 0x00000006 \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 'hbzebra' (Barcode generation library): contrib/hbzebra/tests/wingdi.prg. Provides functions: hb_zebra_draw_wapi. Contains procedures: Main, DrawBarcode. This file provides graphics and image processing capabilities"}, {"role": "assistant", "content": "#require \"hbzebra\"\n#require \"hbwin\"\n\nPROCEDURE Main()\n\n LOCAL hDC\n LOCAL pDEVMODE := __wapi_DEVMODE_New( \"Microsoft XPS Document Writer\" )\n LOCAL hOBJECT\n\n __wapi_DEVMODE_Set( pDEVMODE, { ;\n \"dmPaperSize\" => WIN_DMPAPER_A4, ;\n \"dmOrientation\" => WIN_DMORIENT_PORTRAIT } )\n\n hDC := wapi_CreateDC( NIL, \"Microsoft XPS Document Writer\", NIL, pDEVMODE )\n IF ! Empty( hDC )\n\n wapi_SetMapMode( hDC, WIN_MM_TEXT )\n\n IF wapi_StartDoc( hDC, { \"lpszDocName\" => \"(barcode test)\" } ) > 0\n\n wapi_SetBkMode( hDC, WIN_TRANSPARENT )\n\n IF wapi_StartPage( hDC ) > 0\n\n hOBJECT := wapi_CreateFont( ;\n 96, ;\n 42, ;\n NIL, ;\n NIL, ;\n WIN_FW_NORMAL, ;\n .F., ;\n .F., ;\n NIL, ;\n WIN_ANSI_CHARSET, ;\n NIL, ;\n NIL, ;\n NIL, ;\n NIL, ;\n \"Arial\" )\n\n wapi_SelectObject( hDC, hOBJECT )\n\n DrawBarcode( hDC, 20, 1, \"EAN13\", \"477012345678\" )\n DrawBarcode( hDC, 40, 1, \"EAN8\", \"1234567\" )\n DrawBarcode( hDC, 60, 1, \"UPCA\", \"01234567891\" )\n DrawBarcode( hDC, 80, 1, \"UPCE\", \"123456\" )\n DrawBarcode( hDC, 100, 1, \"CODE39\", \"ABC123\" )\n DrawBarcode( hDC, 120, 1, \"CODE39\", \"ABC123\", HB_ZEBRA_FLAG_CHECKSUM )\n DrawBarcode( hDC, 140, 0.5, \"CODE39\", \"ABC123\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE2_5 )\n DrawBarcode( hDC, 160, 1, \"CODE39\", \"ABC123\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( hDC, 180, 1, \"ITF\", \"1234\", HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( hDC, 200, 1, \"ITF\", \"12345678901\", HB_ZEBRA_FLAG_CHECKSUM )\n DrawBarcode( hDC, 220, 1, \"MSI\", \"1234\" )\n DrawBarcode( hDC, 240, 1, \"MSI\", \"1234\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( hDC, 260, 1, \"MSI\", \"1234567\", HB_ZEBRA_FLAG_CHECKSUM )\n DrawBarcode( hDC, 280, 1, \"CODABAR\", \"40156\", HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( hDC, 300, 1, \"CODABAR\", \"-1234\", HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( hDC, 320, 1, \"CODE93\", \"ABC-123\" )\n DrawBarcode( hDC, 340, 1, \"CODE93\", \"TEST93\" )\n DrawBarcode( hDC, 360, 1, \"CODE11\", \"12\", HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( hDC, 380, 1, \"CODE11\", \"1234567890\", HB_ZEBRA_FLAG_CHECKSUM + HB_ZEBRA_FLAG_WIDE3 )\n DrawBarcode( hDC, 400, 1, \"CODE128\", \"Code 128\" )\n DrawBarcode( hDC, 420, 1, \"CODE128\", \"1234567890\" )\n DrawBarcode( hDC, 440, 1, \"CODE128\", \"Wikipedia\" )\n DrawBarcode( hDC, 460, 1, \"PDF417\", \"Hello, World of Harbour!!! It's 2D barcode PDF417 :)\" )\n DrawBarcode( hDC, 540, 1, \"DATAMATRIX\", \"Hello, World of Harbour!!! It's 2D barcode DataMatrix :)\" )\n DrawBarcode( hDC, 580, 1, \"QRCODE\", \"http:\n\n wapi_EndPage( hDC )\n ENDIF\n wapi_EndDoc( hDC )\n ENDIF\n ENDIF\n\n RETURN\n\n#define _SCALE_ 7.2\n\nPROCEDURE DrawBarcode( hDC, nY, nLineWidth, cType, cCode, nFlags )\n\n LOCAL hZebra, nLineHeight, cTxt\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 ? \"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_wapi( hZebra, hDC, hBrush, ... )\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 | wapi_FillRect( hDC, { Int( x + .5 ), Int( y + .5 ), Int( x + .5 ) + Int( w ), Int( y + .5 ) + Int( h ) + 1 }, hBrush ) }, ... )"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/charonly.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 CharOnly()\"\n ?\n\n ? \"Simple tests:\"\n ? ' CharOnly( \"0123456789\", \"0211 - 38 99 77\" ) == \"0211389977\" ? --> \"' + CharOnly( \"0123456789\", \"0211 - 38 99 77\" ) + '\"'\n ? ' CharOnly( \"0123456789\", \"0211/ 389 977\" ) == \"0211389977\" ? --> \"' + CharOnly( \"0123456789\", \"0211/ 389 977\" ) + '\"'\n ?\n\n ? \"End test of CharOnly()\"\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: DynWinDialog, DynDlgProc. Harbour contribution module 'gtwvg' (): contrib/gtwvg/tests/_dyndlgs.prg. Provides functions: DynWinDialog, DynDlgProc. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#include \"inkey.ch\"\n#include \"hbgtinfo.ch\"\n\n#define ID_BTN_OK 1\n#define ID_MLE 10\n#define ID_CHK_SATIS 11\n#define ID_EDT_TIME 51\n#define ID_LST_LIST 13\n#define ID_CMB_COMBO 31\n#define ID_RDO_XH 21\n#define ID_RDO_CLIP 22\n#define ID_RDO_XBASE 23\n#define ID_EDT_TEXT 14\n#define ID_EDT_NUMB 15\n#define ID_STA_TEXT 71\n#define ID_STA_IMAGE 72\n#define ID_ICO_VOUCH 81\n\n#define ID_GRP_COMP 113\n\n#define ID_MNU_FILE 201\n#define ID_MNU_CONTROL 202\n\nTHREAD STATIC t_aSlides := {}\n\nFUNCTION DynWinDialog( nInfo )\n\n LOCAL hDlg, aDlg, nStyle, cDlgIcon, cDlgProc, lOnTop, hMenu\n\n\n nStyle := DS_SETFONT + WS_VISIBLE + WS_POPUP + WS_CAPTION + WS_SYSMENU + WS_THICKFRAME + WS_MINIMIZEBOX\n\n aDlg := wvt_MakeDlgTemplate( 1, 4, 21, 60, { 0, 0, 0, 0 }, ;\n \"Dialog First [ \" + hb_ntos( nInfo ) + \" ] \" + ;\n iif( nInfo % 2 == 0, \"Modeless\", \"Modal\" ), \" Dialog !\", nStyle )\n\n \n nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + ES_AUTOVSCROLL + ES_MULTILINE + ;\n ES_WANTRETURN + WS_BORDER + WS_VSCROLL\n aDlg := wvt_AddDlgItem( aDlg, 1, 2, 15, 35, {}, ID_MLE , \"EDIT\" , nStyle, )\n\n \n nStyle := WS_CHILD + WS_VISIBLE + SS_ETCHEDVERT\n aDlg := wvt_AddDlgItem( aDlg, 1, 39, 16, 1, {}, 111 , \"STATIC\" , nStyle )\n nStyle := WS_CHILD + WS_VISIBLE + SS_ETCHEDHORZ\n aDlg := wvt_AddDlgItem( aDlg, 17, 2, 1, 56, {}, 112 , \"STATIC\" , nStyle )\n\n \n nStyle := WS_CHILD + WS_VISIBLE + SS_ICON \n aDlg := wvt_AddDlgItem( aDlg, 18, 2, 2, 6, {}, ID_ICO_VOUCH , \"STATIC\" , nStyle, \"\" )\n\n nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + BS_AUTOCHECKBOX\n aDlg := wvt_AddDlgItem( aDlg, 18, 15, 1, 10, {}, ID_CHK_SATIS , \"BUTTON\" , nStyle, \"Satisfied?\" )\n\n nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + ES_RIGHT + ES_READONLY\n aDlg := wvt_AddDlgItem( aDlg, 18, 30, 1, 7, { 3 }, ID_EDT_TIME , \"EDIT\" , nStyle, \"\" )\n\n nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + LBS_NOTIFY + WS_VSCROLL + WS_BORDER\n aDlg := wvt_AddDlgItem( aDlg, 1, 41, 4, 17, {}, ID_LST_LIST , \"LISTBOX\", nStyle, \"ListBox\" )\n\n nStyle := WS_CHILD + WS_VISIBLE + SS_LEFT\n aDlg := wvt_AddDlgItem( aDlg, 4, 41, 1, 17, { 3, 0, 0, 0 }, -1 , \"STATIC\" , nStyle, \"Degree\" )\n nStyle := WS_VISIBLE + WS_TABSTOP + CBS_DROPDOWNLIST + WS_BORDER + WS_VSCROLL\n aDlg := wvt_AddDlgItem( aDlg, 5, 41, 6, 17, {}, ID_CMB_COMBO , \"COMBOBOX\" , nStyle, \"Combo\" )\n\n nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + BS_GROUPBOX\n aDlg := wvt_AddDlgItem( aDlg, 7, 41, 4, 17, { 0, 0, 4, 0 }, ID_GRP_COMP, \"BUTTON\" , nStyle, \"Compiler\" )\n nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + BS_AUTORADIOBUTTON\n aDlg := wvt_AddDlgItem( aDlg, 8, 43, 1, 14, {}, ID_RDO_XH , \"BUTTON\" , nStyle, \"Harbour\" )\n aDlg := wvt_AddDlgItem( aDlg, 9, 43, 1, 14, {}, ID_RDO_CLIP , \"BUTTON\" , nStyle, \"Clipper\" )\n aDlg := wvt_AddDlgItem( aDlg, 10, 43, 1, 14, {}, ID_RDO_XBASE , \"BUTTON\" , nStyle, \"Xbase++\" )\n\n nStyle := WS_CHILD + WS_VISIBLE + SS_LEFT\n aDlg := wvt_AddDlgItem( aDlg, 12, 41, 1, 17, { 3, 0, 0, 0 }, ID_STA_TEXT, \"STATIC\" , nStyle, \"Scrollable Text\" )\n nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + ES_AUTOHSCROLL + WS_BORDER\n aDlg := wvt_AddDlgItem( aDlg, 13, 41, 1, 17, {}, ID_EDT_TEXT , \"EDIT\" , nStyle, \"This is Text Field\" )\n\n nStyle := WS_CHILD + WS_VISIBLE + SS_LEFT\n aDlg := wvt_AddDlgItem( aDlg, 14, 41, 1, 17, { 3, 0, 0, 0 }, -1, \"STATIC\" , nStyle, \"Right Justified Numerics\" )\n nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + ES_AUTOHSCROLL + ES_NUMBER + ES_RIGHT + WS_BORDER\n aDlg := wvt_AddDlgItem( aDlg, 15, 41, 1, 17, {}, ID_EDT_NUMB , \"EDIT\" , nStyle, \"1234567\" )\n\n nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + BS_PUSHBUTTON\n aDlg := wvt_AddDlgItem( aDlg, 18, 50, 1, 8, { -3, 0, 3, 0 }, ID_BTN_OK, \"BUTTON\" , nStyle, \"OK\" )\n\n hMenu := Wvt_CreateMenu()\n Wvt_AppendMenu( hMenu, MF_STRING + MF_ENABLED, ID_MNU_FILE , \"File\" )\n Wvt_AppendMenu( hMenu, MF_STRING + MF_ENABLED, ID_MNU_CONTROL, \"Controls\" )\n\n lOnTop := .F.\n cDlgProc := \"DynDlgProc\"\n\n cDlgIcon := \"v_notes.ico\"\n\n\n IF nInfo == 2\n \n \n hDlg := wvt_DialogBox( aDlg, cDlgProc, Wvt_GetWindowHandle() )\n ELSE\n \n hDlg := wvt_CreateDialog( aDlg, lOnTop, cDlgProc, cDlgIcon, , hMenu )\n\n \n ENDIF\n\n RETURN hDlg\n\nFUNCTION DynDlgProc( hDlg, nMsg, wParam, lParam )\n\n LOCAL lClicked, cPrompt, nIndex, hFont, aHFonts\n\n SWITCH nMsg\n\n CASE WM_TIMER\n wvg_SetDlgItemText( hDlg, ID_EDT_TIME, Time() )\n EXIT\n\n CASE WM_COMMAND\n DO CASE\n\n CASE wParam == ID_CHK_SATIS\n lClicked := ( wvg_IsDlgButtonChecked( hDlg, ID_CHK_SATIS ) == 1 )\n wvg_MessageBox( hDlg, iif( lClicked, \"Satisfied\", \"UnSatisfied\" ), \"CheckBoxStatus\" )\n\n CASE wParam == ID_RDO_XH\n wvg_MessageBox( hDlg, \"Harbour\", \"Compiler\" )\n\n CASE wParam == ID_RDO_CLIP\n wvg_MessageBox( hDlg, \"Clipper\", \"Compiler\" )\n\n CASE wParam == ID_RDO_XBASE\n wvg_MessageBox( hDlg, \"Xbase++\", \"Compiler\" )\n\n CASE wParam == ID_MNU_FILE\n wvg_MessageBox( hDlg, \"Execute Menu Action!\", \"File\" )\n\n CASE wParam == ID_MNU_CONTROL\n wvg_MessageBox( hDlg, \"Controls are from Windows!\", \"Controls\" )\n\n CASE wvg_LOWORD( wParam ) == ID_LST_LIST\n IF wvg_HIWORD( wParam ) == LBN_SELCHANGE\n nIndex := wvg_SendMessage( wvg_GetDlgItem( hDlg, ID_LST_LIST ), LB_GETCURSEL, 0, 0 )\n cPrompt := Space( 20 )\n wvg_SendMessage( wvg_GetDlgItem( hDlg, ID_LST_LIST ), LB_GETTEXT, nIndex, @cPrompt )\n wvg_MessageBox( hDlg, cPrompt, \"ListBox\" )\n ENDIF\n\n CASE wvg_LOWORD( wParam ) == ID_CMB_COMBO\n IF wvg_HIWORD( wParam ) == CBN_SELCHANGE\n nIndex := wvg_SendMessage( wvg_GetDlgItem( hDlg, ID_CMB_COMBO ), CB_GETCURSEL, 0, 0 )\n cPrompt := Space( 20 )\n wvg_SendMessage( wvg_GetDlgItem( hDlg, ID_CMB_COMBO ), CB_GETLBTEXT, nIndex, @cPrompt )\n wvg_MessageBox( hDlg, cPrompt, \"Combo Box\" )\n ENDIF\n\n ENDCASE\n EXIT\n\n CASE WM_CTLCOLOREDIT\n IF wvg_GetDlgItem( hDlg, ID_MLE ) == lParam\n wvg_SetTextColor( wParam, RGB( 0, 0, 255 ) )\n wvg_SetBkColor( wParam, RGB( 255, 255, 200 ) )\n RETURN 1\n ELSEIF wvg_GetDlgItem( hDlg, ID_EDT_TEXT ) == lParam\n wvg_SetTextColor( wParam, RGB( 255, 255, 255 ) )\n wvg_SetBkColor( wParam, RGB( 10, 200, 45 ) )\n RETURN 1\n ENDIF\n EXIT\n\n CASE WM_CTLCOLORSTATIC\n IF wvg_GetDlgItem( hDlg, ID_STA_TEXT ) == lParam\n wvg_SetTextColor( wParam, RGB( 255, 255, 255 ) )\n RETURN 1\n ENDIF\n EXIT\n\n CASE WM_INITDIALOG\n wvg_SetTimer( hDlg, 5001, 1000 ) \n\n IF Empty( aHFonts := SetFonts() )\n IF ( hFont := wvt_CreateFont( \"Times New Roman\", 18 ) ) != 0\n SetFonts( hFont )\n ENDIF\n ENDIF\n\n IF Len( aHFonts ) > 0\n wvg_SendMessage( wvg_GetDlgItem( hDlg, ID_MLE ), WM_SETFONT, ahFonts[ 1 ], 0 )\n ENDIF\n\n IF Empty( SetIcons() )\n SetIcons( wvg_LoadIcon( \"vr_1.ico\" ) )\n ENDIF\n IF ! Empty( SetIcons() )\n wvg_SendMessage( wvg_GetDlgItem( hDlg, ID_ICO_VOUCH ), STM_SETIMAGE, IMAGE_ICON, SetIcons()[ 1 ] )\n ENDIF\n\n \n wvg_SetDlgItemText( hDlg, ID_MLE, GetEditText() )\n wvg_CheckDlgButton( hDlg, ID_CHK_SATIS, .T. )\n\n wvg_CheckRadioButton( hDlg, ID_RDO_XH, ID_RDO_XBASE, ID_RDO_XH )\n\n wvt_LBAddString( hDlg, ID_LST_LIST, \"Harbour\" )\n wvt_LBAddString( hDlg, ID_LST_LIST, \"Gtwvt\" )\n wvt_LBAddString( hDlg, ID_LST_LIST, \"Wvtgui\" )\n wvt_LBAddString( hDlg, ID_LST_LIST, \"Modeless\" )"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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_stra.prg. Contains procedures: Main_STRA. 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_STRA()\n\n \n HBTEST Str( NIL ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST Str( \"A\", 10, 2 ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:3:C:A;N:10;N:2 F:S\"\n HBTEST Str( 100, 10, \"A\" ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:3:N:100;N:10;C:A F:S\"\n HBTEST Str( 100, 10, NIL ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:3:N:100;N:10;U:NIL F:S\"\n HBTEST Str( 100, NIL, NIL ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:3:N:100;U:NIL;U:NIL F:S\"\n IF TEST_DBFAvail()\n HBTEST Str( w_TEST->TYPE_N_I ) IS \" 100\"\n HBTEST Str( w_TEST->TYPE_N_IE ) IS \" 0\"\n HBTEST Str( w_TEST->TYPE_N_D ) IS \" 101.127\"\n HBTEST Str( w_TEST->TYPE_N_DE ) IS \" 0.000\"\n ENDIF\n HBTEST Str( 5000000000.0 ) IS \"5000000000.0\"\n HBTEST Str( 50000000 ) IS \" 50000000\"\n HBTEST Str( 500000000 ) IS \" 500000000\"\n HBTEST Str( 5000000000 ) IS \" 5000000000\"\n HBTEST Str( 50000000000 ) IS \" 50000000000\"\n HBTEST Str( -5000000000.0 ) IS \" -5000000000.0\"\n HBTEST Str( -5000000000 ) IS \" -5000000000\"\n HBTEST Str( 2.0000000000000001 ) IS \" 2.0000000000000000\"\n HBTEST Str( 2.0000000000000009 ) IS \" 2.0000000000000010\"\n HBTEST Str( 2.000000000000001 ) IS \" 2.000000000000001\"\n HBTEST Str( 2.000000000000009 ) IS \" 2.000000000000009\"\n HBTEST Str( 2.00000000000001 ) IS \" 2.00000000000001\"\n HBTEST Str( 2.00000000000009 ) IS \" 2.00000000000009\"\n HBTEST Str( 2.000000000001 ) IS \" 2.000000000001\"\n HBTEST Str( 2.00000000001 ) IS \" 2.00000000001\"\n HBTEST Str( 10 ) IS \" 10\"\n HBTEST Str( 10.0 ) IS \" 10.0\"\n HBTEST Str( 10.00 ) IS \" 10.00\"\n HBTEST Str( 10.50 ) IS \" 10.50\"\n HBTEST Str( 100000 ) IS \" 100000\"\n HBTEST Str( -10 ) IS \" -10\"\n HBTEST Str( -10.0 ) IS \" -10.0\"\n HBTEST Str( -10.00 ) IS \" -10.00\"\n HBTEST Str( -10.50 ) IS \" -10.50\"\n HBTEST Str( -100000 ) IS \" -100000\"\n HBTEST Str( 10, 5 ) IS \" 10\"\n HBTEST Str( 10.0, 5 ) IS \" 10\"\n HBTEST Str( 10.00, 5 ) IS \" 10\"\n HBTEST Str( 10.50, 5 ) IS \" 11\"\n HBTEST Str( 100000, 5 ) IS \"*****\"\n HBTEST Str( 100000, 8 ) IS \" 100000\"\n HBTEST Str( -10, 5 ) IS \" -10\"\n HBTEST Str( -10.0, 5 ) IS \" -10\"\n HBTEST Str( -10.00, 5 ) IS \" -10\"\n HBTEST Str( -10.50, 5 ) IS \" -11\"\n HBTEST Str( -100000, 5 ) IS \"*****\"\n HBTEST Str( -100000, 6 ) IS \"******\"\n HBTEST Str( -100000, 8 ) IS \" -100000\"\n#ifndef __XPP__ \n HBTEST Str( 10, -5 ) IS \" 10\"\n HBTEST Str( 10.0, -5 ) IS \" 10\"\n HBTEST Str( 10.00, -5 ) IS \" 10\"\n HBTEST Str( 10.50, -5 ) IS \" 11\"\n HBTEST Str( 100000, -5 ) IS \" 100000\"\n HBTEST Str( 100000, -8 ) IS \" 100000\"\n HBTEST Str( -10, -5 ) IS \" -10\"\n HBTEST Str( -10.0, -5 ) IS \" -10\"\n HBTEST Str( -10.00, -5 ) IS \" -10\"\n HBTEST Str( -10.50, -5 ) IS \" -11\"\n HBTEST Str( -100000, -5 ) IS \" -100000\"\n HBTEST Str( -100000, -6 ) IS \" -100000\"\n HBTEST Str( -100000, -8 ) IS \" -100000\"\n#endif\n HBTEST Str( 10, 5, 0 ) IS \" 10\"\n HBTEST Str( 10.0, 5, 0 ) IS \" 10\"\n HBTEST Str( 10.00, 5, 0 ) IS \" 10\"\n HBTEST Str( 10.50, 5, 0 ) IS \" 11\"\n HBTEST Str( 100000, 5, 0 ) IS \"*****\"\n HBTEST Str( -10, 5, 0 ) IS \" -10\"\n HBTEST Str( -10.0, 5, 0 ) IS \" -10\"\n HBTEST Str( -10.00, 5, 0 ) IS \" -10\"\n HBTEST Str( -10.50, 5, 0 ) IS \" -11\"\n HBTEST Str( -100000, 5, 0 ) IS \"*****\"\n HBTEST Str( -100000, 6, 0 ) IS \"******\"\n HBTEST Str( -100000, 8, 0 ) IS \" -100000\"\n HBTEST Str( 10, 5, 1 ) IS \" 10.0\"\n HBTEST Str( 10.0, 5, 1 ) IS \" 10.0\"\n HBTEST Str( 10.00, 5, 1 ) IS \" 10.0\"\n HBTEST Str( 10.50, 5, 1 ) IS \" 10.5\"\n HBTEST Str( 100000, 5, 1 ) IS \"*****\"\n HBTEST Str( -10, 5, 1 ) IS \"-10.0\"\n HBTEST Str( -10.0, 5, 1 ) IS \"-10.0\"\n HBTEST Str( -10.00, 5, 1 ) IS \"-10.0\"\n HBTEST Str( -10.50, 5, 1 ) IS \"-10.5\"\n HBTEST Str( -100000, 5, 1 ) IS \"*****\"\n HBTEST Str( -100000, 6, 1 ) IS \"******\"\n HBTEST Str( -100000, 8, 1 ) IS \"********\"\n#ifndef __XPP__ \n HBTEST Str( 10, 5, -1 ) IS \" 10\"\n HBTEST Str( 10.0, 5, -1 ) IS \" 10\"\n HBTEST Str( 10.00, 5, -1 ) IS \" 10\"\n HBTEST Str( 10.50, 5, -1 ) IS \" 11\"\n HBTEST Str( 100000, 5, -1 ) IS \"*****\"\n HBTEST Str( -10, 5, -1 ) IS \" -10\"\n HBTEST Str( -10.0, 5, -1 ) IS \" -10\"\n HBTEST Str( -10.00, 5, -1 ) IS \" -10\"\n HBTEST Str( -10.50, 5, -1 ) IS \" -11\"\n HBTEST Str( -100000, 5, -1 ) IS \"*****\"\n HBTEST Str( -100000, 6, -1 ) IS \"******\"\n HBTEST Str( -100000, 8, -1 ) IS \" -100000\"\n#endif\n\n \n#ifdef HB_CLP_STRICT\n HBTEST StrZero( NIL ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST StrZero( \"A\", 10, 2 ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:3:C:A;N:10;N:2 F:S\"\n HBTEST StrZero( 100, 10, \"A\" ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:3:N:100;N:10;C:A F:S\"\n HBTEST StrZero( 100, 10, NIL ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:3:N:100;N:10;U:NIL F:S\"\n HBTEST StrZero( 100, NIL, NIL ) IS \"E 1 BASE 1099 Argument error (STR) OS:0 #:0 A:3:N:100;U:NIL;U:NIL F:S\"\n#else\n HBTEST StrZero( NIL ) IS \"E 1 BASE 6003 Argument error (STRZERO) OS:0 #:0 A:1:U:NIL F:S\"\n HBTEST StrZero( \"A\", 10, 2 ) IS \"E 1 BASE 6003 Argument error (STRZERO) OS:0 #:0 A:3:C:A;N:10;N:2 F:S\"\n HBTEST StrZero( 100, 10, \"A\" ) IS \"E 1 BASE 6003 Argument error (STRZERO) OS:0 #:0 A:3:N:100;N:10;C:A F:S\"\n HBTEST StrZero( 100, 10, NIL ) IS \"E 1 BASE 6003 Argument error (STRZERO) OS:0 #:0 A:3:N:100;N:10;U:NIL F:S\"\n HBTEST StrZero( 100, NIL, NIL ) IS \"E 1 BASE 6003 Argument error (STRZERO) OS:0 #:0 A:3:N:100;U:NIL;U:NIL F:S\"\n#endif\n HBTEST StrZero( 10 ) IS \"0000000010\"\n HBTEST StrZero( 10.0 ) IS \"0000000010.0\"\n HBTEST StrZero( 10.00 ) IS \"0000000010.00\"\n HBTEST StrZero( 10.50 ) IS \"0000000010.50\"\n HBTEST StrZero( 100000 ) IS \"0000100000\"\n HBTEST StrZero( -10 ) IS \"-000000010\"\n HBTEST StrZero( -10.0 ) IS \"-000000010.0\"\n HBTEST StrZero( -10.00 ) IS \"-000000010.00\"\n HBTEST StrZero( -10.50 ) IS \"-000000010.50\"\n HBTEST StrZero( -100000 ) IS \"-000100000\"\n HBTEST StrZero( 10, 5 ) IS \"00010\"\n HBTEST StrZero( 10.0, 5 ) IS \"00010\"\n HBTEST StrZero( 10.00, 5 ) IS \"00010\"\n HBTEST StrZero( 10.50, 5 ) IS \"00011\"\n HBTEST StrZero( 100000, 5 ) IS \"*****\"\n HBTEST StrZero( 100000, 8 ) IS \"00100000\"\n HBTEST StrZero( -10, 5 ) IS \"-0010\""}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/runshell.prg. Provides functions: RunShell. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION RunShell( cCommand, cProgram, lAsync, lBackground )\n\n \n HB_SYMBOL_UNUSED( lBackground )\n\n IF ! HB_ISSTRING( cProgram )\n#if defined( __PLATFORM__UNIX )\n cProgram := GetEnv( \"SHELL\" )\n#elif defined( __PLATFORM__OS2 )\n cProgram := GetEnv( \"OS2_SHELL\" )\n#else\n cProgram := GetEnv( \"COMSPEC\" )\n#endif\n IF Empty( cProgram )\n#if defined( __PLATFORM__WINDOWS )\n IF hb_osIsWinNT()\n cProgram := \"cmd.exe\"\n ELSE\n cProgram := \"command.com\"\n ENDIF\n#elif defined( __PLATFORM__DOS )\n cProgram := \"command.com\"\n#elif defined( __PLATFORM__OS2 )\n cProgram := \"cmd.exe\"\n#else\n cProgram := \"\"\n#endif\n ENDIF\n ENDIF\n\n IF HB_ISSTRING( cCommand )\n#if defined( __PLATFORM__UNIX )\n cProgram += \" -c \" + \"'\" + StrTran( cCommand, \"'\", \"'\\''\" ) + \"'\"\n#else\n cProgram += \" /c \" + cCommand\n#endif\n ENDIF\n\n RETURN hb_processRun( LTrim( cProgram ),,,, lAsync )"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/com.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbcom.ch\"\n\nPROCEDURE Main( cPortName )\n\n LOCAL cString := \"ATE0\" + Chr( 13 ) + \"ATI3\" + Chr( 13 )\n LOCAL nTimeOut := 3000 \n LOCAL nResult\n LOCAL nPort := 1\n\n IF ! Empty( cPortName )\n hb_comSetDevice( nPort, cPortName )\n ENDIF\n IF ! hb_comOpen( nPort )\n ? \"Cannot open port:\", nPort, hb_comGetDevice( nPort ), ;\n \"error: \" + hb_ntos( hb_comGetError( nPort ) )\n ELSE\n ? \"port:\", hb_comGetDevice( nPort ), \"opened\"\n IF ! hb_comInit( nPort, 9600, \"N\", 8, 1 )\n ? \"Cannot initialize port to: 9600:N:8:1\", ;\n \"error: \" + hb_ntos( hb_comGetError( nPort ) )\n ELSE\n nResult := hb_comSend( nPort, cString, hb_BLen( cString ), nTimeOut )\n IF nResult != hb_BLen( cString )\n ? \"SEND() failed,\", nResult, \"bytes sent in\", nTimeOut / 1000, ;\n \"sec., expected:\", hb_BLen( cString ), \"bytes.\"\n ? \"error: \" + hb_ntos( hb_comGetError( nPort ) )\n ELSE\n ? \"SEND() succeeded.\"\n ENDIF\n\n WAIT \"Press any key to begin reading...\"\n cString := Space( 32 )\n nTimeOut := 500 \n nResult := hb_comRecv( nPort, @cString, hb_BLen( cString ), nTimeOut )\n IF nResult == -1\n ? \"RECV() failed,\", ;\n \"error: \" + hb_ntos( hb_comGetError( nPort ) )\n ELSE\n ? nResult, \"bytes read in\", nTimeOut / 1000, \"sec.\"\n ENDIF\n ENDIF\n ? \"CLOSE:\", hb_comClose( nPort )\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 'hbnetio' (Network I/O operations): contrib/hbnetio/utils/hbnetio/_winsvc.prg. Contains procedures: WinMain, hbnetio_WinServiceEntry. This file provides network protocol implementations"}, {"role": "assistant", "content": "#include \"hbwin.ch\"\n\n#define _SERVICE_NAME \"Harbour_NetIO_Service\"\n\nPROCEDURE WinMain( ... )\n\n LOCAL cMode := hb_PValue( 1 )\n\n LOCAL cMsg, nError\n\n IF cMode == NIL\n cMode := \"\"\n ENDIF\n\n SWITCH Lower( cMode )\n CASE \"-i\"\n CASE \"-install\"\n\n IF win_serviceInstall( _SERVICE_NAME, \"Harbour NetIO Service\", '\"' + hb_ProgName() + '\"' + \" -service\", WIN_SERVICE_AUTO_START )\n OutStd( \"Service has been successfully installed\" + hb_eol() )\n ELSE\n nError := wapi_GetLastError()\n cMsg := Space( 128 )\n wapi_FormatMessage( ,,,, @cMsg )\n OutStd( hb_StrFormat( \"Error installing service: %1$d %2$s\", nError, cMsg ) + hb_eol() )\n ENDIF\n EXIT\n\n CASE \"-u\"\n CASE \"-uninstall\"\n\n IF win_serviceDelete( _SERVICE_NAME )\n OutStd( \"Service has been deleted\" + hb_eol() )\n ELSE\n nError := wapi_GetLastError()\n cMsg := Space( 128 )\n wapi_FormatMessage( ,,,, @cMsg )\n OutStd( hb_StrFormat( \"Error uninstalling service: %1$d %2$s\", nError, cMsg ) + hb_eol() )\n ENDIF\n EXIT\n\n CASE \"-s\"\n CASE \"-service\"\n\n IF win_serviceStart( _SERVICE_NAME, @hbnetio_WinServiceEntry() )\n OutStd( \"Service has started OK\" + hb_eol() )\n ELSE\n OutStd( hb_StrFormat( \"Service has had some problems: %1$d\", wapi_GetLastError() ) + hb_eol() )\n ENDIF\n EXIT\n\n OTHERWISE\n\n netiosrv_Main( .T., ... ) \n EXIT\n\n ENDSWITCH\n\n RETURN\n\nSTATIC PROCEDURE hbnetio_WinServiceEntry( ... )\n\n\n netiosrv_Main( .F., ... ) \n\n win_serviceSetExitCode( 0 )\n win_serviceStop()\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/ontick.prg. Contains procedures: __ft_OnTick, ft_OnTick. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "THREAD STATIC t_bOnTick\nTHREAD STATIC t_nTickInterval := 0\nTHREAD STATIC t_nLastCheck := 0\nTHREAD STATIC t_hIdle\n\nSTATIC PROCEDURE __ft_OnTick()\n\n IF hb_MilliSeconds() >= ( t_nLastCheck + t_nTickInterval )\n t_nLastCheck := hb_MilliSeconds()\n Eval( t_bOnTick )\n ENDIF\n\n RETURN\n\nPROCEDURE ft_OnTick( bOnTick, nTickInterval )\n\n \n IF HB_ISEVALITEM( bOnTick )\n t_bOnTick := bOnTick\n IF HB_ISNUMERIC( nTickInterval )\n t_nTickInterval := ( 1 / 18.20648 )"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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: __Dir, PutDBF, PutNormal. Harbour Runtime Library file: src/rtl/dircmd.prg. Contains procedures: __Dir, PutDBF, PutNormal. This file provides file I/O operations"}, {"role": "assistant", "content": "#include \"directry.ch\"\n#include \"fileio.ch\"\n\n#define _DIR_HEADER 1\n\nPROCEDURE __Dir( cFileMask )\n\n LOCAL cPath\n LOCAL cName\n LOCAL cExt\n\n IF Empty( cFileMask )\n\n \n#ifdef HB_CLP_STRICT\n QOut( \"Database Files # Records Last Update Size\" )\n#else\n QOut( __natMsg( _DIR_HEADER ) )\n#endif\n\n AEval( Directory( hb_FNameMerge( Set( _SET_DEFAULT ), \"*\", \".dbf\" ) ), ;\n {| aDirEntry | PutDbf( aDirEntry ) } )\n ELSE\n\n hb_FNameSplit( iif( Set( _SET_TRIMFILENAME ), AllTrim( cFileMask ), cFileMask ), ;\n @cPath, @cName, @cExt )\n IF Empty( cPath )\n cPath := Set( _SET_DEFAULT )\n ENDIF\n\n AEval( Directory( hb_FNameMerge( cPath, cName, cExt ) ), ;\n {| aDirEntry | PutNormal( aDirEntry ) } )\n ENDIF\n\n QOut()\n\n RETURN\n\n#define _DBF_HEAD_MARK hb_BChar( 0x03 ) + hb_BChar( 0x06 ) + ;\n hb_BChar( 0x30 ) + hb_BChar( 0x31 ) + ;\n hb_BChar( 0x83 ) + hb_BChar( 0x86 ) + ;\n hb_BChar( 0xE5 ) + hb_BChar( 0xE6 ) + ;\n hb_BChar( 0xF5 ) + hb_BChar( 0xF6 )\n\nSTATIC PROCEDURE PutDBF( aDirEntry )\n\n LOCAL fhnd\n LOCAL buffer\n LOCAL nRecCount := 0\n LOCAL dLastUpdate := hb_SToD()\n\n IF ( fhnd := FOpen( aDirEntry[ F_NAME ] ) ) != F_ERROR\n\n buffer := hb_FReadLen( fhnd, 8 )\n\n IF hb_BLen( buffer ) == 8 .AND. hb_BAt( hb_BLeft( buffer, 1 ), _DBF_HEAD_MARK ) > 0\n nRecCount := Bin2L( hb_BSubStr( buffer, 5, 4 ) )\n dLastUpdate := hb_Date( hb_BPeek( buffer, 2 ) + 1900, ;\n hb_BPeek( buffer, 3 ), ;\n hb_BPeek( buffer, 4 ) )\n ENDIF\n\n FClose( fhnd )\n\n ENDIF\n\n QOut( ;\n PadR( aDirEntry[ F_NAME ], 15 ) + ;\n Str( nRecCount, 12 ) + \" \" + ;\n DToC( dLastUpdate ) + ;\n Str( aDirEntry[ F_SIZE ], 12 ) )\n\n RETURN\n\nSTATIC PROCEDURE PutNormal( aDirEntry )\n\n LOCAL cName, cExt\n\n hb_FNameSplit( aDirEntry[ F_NAME ],, @cName, @cExt )\n\n \n QOut( ;\n PadR( cName, 8 ), ;\n PadR( SubStr( cExt, 2 ), 3 ), ;\n Str( aDirEntry[ F_SIZE ], 8 ), \"\", ;\n aDirEntry[ F_DATE ] )\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/multifnc/t0.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "proc main()\n? OS(), VERSION(), DATE(), TIME()\n? HB_COMPILER()\n__NONOALERT()\n? \"main\", procfile(\"main\"), procfile(@main())\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? \"===\"\nmain2()\n\nfunc t(cFunc,sFunc,cResult,cModule)\nif &(cFunc+\"()\")==cResult .and. sFunc:exec()==cResult .and. ;\n upper(cModule)==upper(right(cResult,len(cModule)))\n return \"OK\"\nendif\nreturn \"ERR\"\n\nfunc p0(); return \"P0:t0.prg\"\nfunc p1(); return \"P1:t0.prg\"\nfunc p3(); return \"P3:t0.prg\"\nfunc p6(); return \"P6:t0.prg\""}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/exit.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL x := 0\n\n DO WHILE x < 10\n ++x\n IF x == 5\n EXIT\n ENDIF\n ENDDO\n\n ? \"do exit test\", iif( x == 5, \"passed\", \"fail\" )\n\n FOR x := 1 TO 10\n IF x == 5\n EXIT\n ENDIF\n NEXT\n\n ? \"for exit test\", iif( x == 5, \"passed\", \"fail\" )\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/overload.prg. Defines classes: TString. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\nPROCEDURE Main()\n\n LOCAL oString := TString():New( \"Hello\" )\n\n ? \"Testing TString with Operator Overloading\"\n ? oString:cValue\n ? \"---\"\n\n ? ValType( oString )\n\n ? \"Equal........:\", oString = \"Hello\"\n ? \"Exactly Equal:\", oString == \"Hello\"\n ? \"Not Equal != :\", oString != \"Hello\"\n ? \"Not Equal <> :\", oString <> \"Hello\"\n ? \"Not Equal # :\", oString # \"Hello\"\n ? \"Substring $ :\", oString $ \"Hello\"\n ? \"Less than :\", oString < \"Hello\"\n ? \"Less than or Equal:\", oString <= \"Hello\"\n ? \"Greater than :\", oString > \"Hello\"\n ? \"Greater than or Equal:\", oString >= \"Hello\"\n ? \"Concatenation + :\", oString + \"Hello\"\n ? \"Concatenation - :\", oString - \"Hello\"\n ? \"Array index[2] :\", oString[ 2 ]\n ? \"Array index[3] := 'X' :\", oString[ 3 ] := 'X'\n ? oString:cValue\n\n RETURN\n\nCREATE CLASS TString\n\n VAR cValue\n\n METHOD New( cText ) INLINE ::cValue := cText, Self\n\n OPERATOR \"=\" ARG cArg INLINE ::cValue = cArg\n OPERATOR \"==\" ARG cArg INLINE ::cValue == cArg\n OPERATOR \"!=\" ARG cArg INLINE ::cValue != cArg\n OPERATOR \"<\" ARG cArg INLINE ::cValue < cArg\n OPERATOR \"<=\" ARG cArg INLINE ::cValue <= cArg\n OPERATOR \">\" ARG cArg INLINE ::cValue > cArg\n OPERATOR \">=\" ARG cArg INLINE ::cValue >= cArg\n OPERATOR \"+\" ARG cArg INLINE ::cValue + cArg\n OPERATOR \"-\" ARG cArg INLINE ::cValue - cArg\n OPERATOR \"$\" ARG cArg INLINE ::cValue $ cArg\n OPERATOR \"[]\" ARG nIndex INLINE iif( PCount() > 2, ;\n ::cValue := Stuff( ::cValue, nIndex, 1, hb_PValue( 3 ) ), ;\n SubStr( ::cValue, nIndex, 1 ) )\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 test program: tests/getblock.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL GetList := {}, aStr\n MEMVAR idx, fld, als\n PRIVATE idx, fld, als\n\n aStr := { { \"F1\", \"C\", 10, 0 }, ;\n { \"F2\", \"C\", 10, 0 } }\n\n dbCreate( \"_tst1\", aStr )\n USE _tst1 NEW\n dbAppend()\n field->F1 := \"FIRST\"\n field->F2 := \"SECOND\"\n\n dbCreate( \"_tst2\", aStr )\n USE _tst2 NEW\n dbAppend()\n field->F1 := \"first\"\n field->F2 := \"second\"\n Select( 1 )\n\n CLS\n\n idx := \"1\"\n fld := \"F\" + idx\n als := \"_tst\" + idx\n\n @ 1, 0 GET f&idx\n @ 2, 0 GET field->f&idx\n @ 3, 0 GET _tst1->f&idx\n @ 4, 0 GET &als->f&idx\n @ 5, 0 GET _tst&idx->f&idx\n\n @ 7, 0 GET &fld\n @ 8, 0 GET field->&fld\n @ 9, 0 GET _tst1->&fld\n @ 10, 0 GET &als->&fld\n @ 11, 0 GET _tst&idx->&fld\n\n @ 13, 0 GET &als->F1\n @ 14, 0 GET _tst&idx->F1\n\n InKey( 0 )\n\n idx := \"2\"\n fld := \"F\" + idx\n als := \"_tst\" + idx\n\n READ\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": "Create Harbour OOP classes for the functionality described: Harbour contribution module 'gtwvg' (): contrib/gtwvg/pushbut.prg. Defines classes: WvgPushButton. 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 WvgPushButton INHERIT WvgWindow\n\n VAR autosize INIT .F.\n VAR border INIT .T.\n VAR caption INIT NIL\n VAR pointerFocus INIT .T.\n VAR preSelect INIT .F.\n VAR drawMode INIT WVG_DRAW_NORMAL\n VAR default INIT .F.\n VAR cancel 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, cDll )\n METHOD activate( xParam ) SETGET\n METHOD draw( xParam ) SETGET\n\n METHOD setColorFG() INLINE NIL\n METHOD setColorBG() INLINE NIL\n\nENDCLASS\n\nMETHOD WvgPushButton: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_NOTIFY \n ::className := \"BUTTON\"\n ::objType := objTypePushButton\n\n RETURN Self\n\nMETHOD WvgPushButton:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::wvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n IF HB_ISNUMERIC( ::caption )\n ::style += BS_BITMAP\n ELSEIF HB_ISSTRING( ::caption )\n IF \".ICO\" == Upper( Right( ::caption, 4 ) )\n ::style += BS_ICON\n ELSEIF \".BMP\" == Upper( Right( ::caption, 4 ) )\n ::style += BS_BITMAP\n ENDIF\n ELSEIF HB_ISARRAY( ::caption )\n ASize( ::caption, 3 )\n IF HB_ISNUMERIC( ::caption[ 2 ] )\n IF ::caption[ 2 ] == WVG_IMAGE_ICONFILE .OR. ::caption[ 2 ] == WVG_IMAGE_ICONRESOURCE\n ::style += BS_ICON\n ELSEIF ::caption[ 2 ] == WVG_IMAGE_BITMAPFILE .OR. ::caption[ 2 ] == WVG_IMAGE_BITMAPRESOURCE\n ::style += BS_BITMAP\n ENDIF\n ENDIF\n ENDIF\n\n IF ! ::border\n ::style += BS_FLAT\n ENDIF\n\n ::oParent:AddChild( Self )\n\n ::createControl()\n\n IF ::visible\n ::show()\n ENDIF\n ::setPosAndSize()\n\n ::setCaption( ::caption )\n\n RETURN Self\n\nMETHOD WvgPushButton:handleEvent( nMessage, aNM )\n\n DO CASE\n CASE nMessage == HB_GTE_RESIZED\n IF ::isParentCrt()\n ::rePosition()\n ENDIF\n ::sendMessage( WM_SIZE, 0, 0 )\n IF HB_ISBLOCK( ::sl_resize )\n Eval( ::sl_resize, , , Self )\n ENDIF\n\n CASE nMessage == HB_GTE_COMMAND\n IF aNM[ 1 ] == BN_CLICKED\n IF HB_ISBLOCK( ::sl_lbClick )\n IF ::isParentCrt()\n ::oParent:setFocus()\n ENDIF\n Eval( ::sl_lbClick, , , Self )\n IF ::pointerFocus\n ::setFocus()\n ENDIF\n ENDIF\n RETURN EVENT_HANDELLED\n ENDIF\n\n CASE nMessage == HB_GTE_NOTIFY\n \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 ENDIF\n\n ENDCASE\n\n RETURN EVENT_UNHANDELLED\n\nMETHOD PROCEDURE WvgPushButton:destroy()\n\n ::wvgWindow:destroy()\n\n RETURN\n\nMETHOD WvgPushButton:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )\n\n RETURN Self\n\nMETHOD WvgPushButton:setCaption( xCaption, cDll )\n\n LOCAL nLoadFromResByIdNumber := 0\n LOCAL nLoadFromResByIdName := 1\n LOCAL nLoadFromDiskFile := 2\n\n __defaultNIL( @xCaption, ::caption )\n HB_SYMBOL_UNUSED( cDll )\n\n ::caption := xCaption\n\n IF HB_ISSTRING( xCaption )\n IF \".ICO\" == Upper( Right( ::caption, 4 ) )\n wvg_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_ICON, wvg_LoadImage( ::caption, nLoadFromDiskFile, IMAGE_ICON ) )\n ELSEIF \".BMP\" == Upper( Right( ::caption, 4 ) )\n wvg_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_BITMAP, wvg_LoadImage( ::caption, nLoadFromDiskFile, IMAGE_BITMAP ) )\n ELSE\n wvg_SendMessageText( ::hWnd, WM_SETTEXT, 0, ::caption )\n ENDIF\n\n ELSEIF HB_ISNUMERIC( xCaption ) \n wvg_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_BITMAP, ::caption )\n\n ELSEIF HB_ISARRAY( xCaption )\n ASize( xCaption, 4 )\n IF HB_ISCHAR( xCaption[ 1 ] )\n wvg_SendMessageText( ::hWnd, WM_SETTEXT, 0, xCaption[ 1 ] )\n ENDIF\n IF ! Empty( xCaption[ 2 ] )\n SWITCH xCaption[ 2 ]\n CASE WVG_IMAGE_ICONFILE\n wvg_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_ICON, wvg_LoadImage( xCaption[ 3 ], nLoadFromDiskFile, IMAGE_ICON ) )\n EXIT\n CASE WVG_IMAGE_ICONRESOURCE\n IF HB_ISSTRING( xCaption[ 3 ] )\n wvg_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_ICON, wvg_LoadImage( xCaption[ 3 ], nLoadFromResByIdName, IMAGE_ICON ) )\n ELSE\n wvg_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_ICON, wvg_LoadImage( xCaption[ 3 ], nLoadFromResByIdNumber, IMAGE_ICON ) )\n ENDIF\n EXIT\n CASE WVG_IMAGE_BITMAPFILE\n wvg_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_BITMAP, wvg_LoadImage( xCaption[ 3 ], nLoadFromDiskFile, IMAGE_BITMAP ) )\n EXIT\n CASE WVG_IMAGE_BITMAPRESOURCE\n IF HB_ISSTRING( xCaption[ 3 ] )\n wvg_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_BITMAP, wvg_LoadImage( xCaption[ 3 ], nLoadFromResByIdName, IMAGE_BITMAP ) )\n ELSE\n wvg_SendMessage( ::hWnd, BM_SETIMAGE, IMAGE_BITMAP, wvg_LoadImage( xCaption[ 3 ], nLoadFromResByIdNumber, IMAGE_BITMAP ) )\n ENDIF\n EXIT\n ENDSWITCH\n ENDIF\n ENDIF\n\n RETURN Self\n\nMETHOD WvgPushButton:activate( xParam )\n\n IF HB_ISBLOCK( xParam ) .OR. xParam == NIL\n ::sl_lbClick := xParam\n ENDIF\n\n RETURN Self\n\nMETHOD WvgPushButton:draw( xParam )\n\n IF HB_ISBLOCK( xParam ) .OR. xParam == NIL\n ::sl_paint := xParam\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 'hbtip' (Internet protocol utilities (FTP, HTTP, SMTP, POP3)): contrib/hbtip/tests/email.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\n#include \"simpleio.ch\"\n\nPROCEDURE Main( cFrom, cPassword, cTo, cHost )\n\n LOCAL nPort\n LOCAL lSTARTTLS := .F.\n\n IF ! tip_SSL()\n ? \"Error: Requires SSL support\"\n RETURN\n ENDIF\n\n hb_default( @cFrom , \"<from@example.net>\" )\n hb_default( @cPassword, \"password\" )\n hb_default( @cTo , \"to@example.com\" )\n hb_default( @cHost , \"localhost\" )\n\n cHost := Lower( cHost )\n\n \n DO CASE\n CASE cHost == \"apple\" .OR. \"@icloud.com\" $ cFrom .OR. \"@mac.com\" $ cFrom .OR. \"@me.com\" $ cFrom\n cHost := \"smtp.mail.me.com\"; lSTARTTLS := .T.\n CASE cHost == \"fastmail\" .OR. \"@fastmail.com\" $ cFrom .OR. \"@fastmail.fm\" $ cFrom\n cHost := \"smtp.fastmail.com\"\n CASE cHost == \"gmx.net\" .OR. \"@gmx.net\" $ cFrom .OR. \"@gmx.ch\" $ cFrom .OR. \"@gmx.de\" $ cFrom\n cHost := \"mail.gmx.net\"; lSTARTTLS := .T.\n CASE cHost == \"google\" .OR. \"@gmail.com\" $ cFrom .OR. \"@googlemail.com\" $ cFrom\n cHost := \"smtp.gmail.com\"\n CASE cHost == \"mail.ru\" .OR. \"@mail.ru\" $ cFrom\n cHost := \"smtp.mail.ru\"\n CASE cHost == \"netease\" .OR. \"@163.com\" $ cFrom\n cHost := \"smtp.163.com\"\n CASE cHost == \"office365\"\n cHost := \"smtp.office365.com\"; lSTARTTLS := .T.\n CASE cHost == \"outlook\" .OR. \"@outlook.com\" $ cFrom .OR. \"@hotmail.com\" $ cFrom\n cHost := \"smtp-mail.outlook.com\"; lSTARTTLS := .T.\n CASE cHost == \"sina\" .OR. \"@sina.com\" $ cFrom\n cHost := \"smtp.vip.sina.com\"\n CASE cHost == \"uol\" .OR. \"@uol.com.br\" $ cFrom\n cHost := \"smtps.uol.com.br\"\n CASE cHost == \"yahoo\" .OR. \"@yahoo.com\" $ cFrom\n cHost := \"smtp.mail.yahoo.com\"\n CASE \":\" $ cHost\n IF TUrl():New( cHost ):nPort != -1\n nPort := TUrl():New( cHost ):nPort\n ENDIF\n lSTARTTLS := ( nPort == 587 )\n cHost := TUrl():New( cHost ):cServer\n ENDCASE\n\n hb_default( @nPort, iif( lSTARTTLS, 587, 465 ) )\n\n ? \"Host:\", cHost, hb_ntos( nPort ), iif( lSTARTTLS, \"(STARTTLS)\", \"\" )\n\n ? tip_MailSend( ;\n cHost, ;\n nPort, ;\n cFrom, ;\n cTo, ;\n NIL , ;\n {} , ;\n \"test: body\", ;\n \"test: subject\", ;\n NIL , ;\n cFrom, ;\n cPassword, ;\n \"\", ;\n NIL , ;\n NIL , ;\n .T. , ;\n .F., ;\n NIL , ;\n NIL , ;\n NIL , ;\n nPort == 465 )\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/statics1.prg. Contains procedures: Main. This test file exercises basic Harbour language features"}, {"role": "assistant", "content": "STATIC uOne, uTwo\n\nPROCEDURE Main()\n\n ? \"Statics overlapped!\"\n ? \"===================\"\n ?\n ? \"INSIDE statics1.prg\"\n ? \" static uOne, uTwo\"\n ?\n ? \" uOne, uTwo =>\", uOne, \",\", uTwo\n uOne := 1\n uTwo := 2\n ? \" uOne := 1\"\n ? \" uOne := 2\"\n ? \" uOne, uTwo =>\", uOne, \",\", uTwo\n ?\n Test()\n ? \"INSIDE statics1.prg\"\n ? \" uOne, uTwo =>\", uOne, \",\", uTwo\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 'hbfship' (Fships library functions): contrib/hbfship/fldarr.prg. Provides functions: FieldGetArr, FieldPutArr. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "FUNCTION FieldGetArr( xRecNo )\n\n LOCAL xPrevRec\n LOCAL aFields\n LOCAL nFields, n\n\n IF xRecNo != NIL\n xPrevRec := RecNo()\n dbGoto( xRecNo )\n ENDIF\n\n nFields := FCount()\n aFields := Array( nFields )\n FOR n := 1 TO nFields\n aFields[ n ] := FieldGet( n )\n NEXT\n\n IF xPrevRec != NIL\n dbGoto( xPrevRec )\n ENDIF\n\n RETURN aFields\n\nFUNCTION FieldPutArr( aFields, xRecNo )\n\n LOCAL xPrevRec\n LOCAL nFields, n\n\n IF xRecNo != NIL\n xPrevRec := RecNo()\n dbGoto( xRecNo )\n ENDIF\n\n nFields := FCount()\n IF nFields > Len( aFields )\n nFields := Len( aFields )\n ENDIF\n FOR n := 1 TO nFields\n IF aFields[ n ] != NIL\n FieldPut( n, aFields[ n ] )\n ENDIF\n NEXT\n\n IF xPrevRec != NIL\n dbGoto( xPrevRec )\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": "Define Harbour macros and constants: Harbour header file: include/std.ch. Defines constants: HB_STD_CH_, HB_SYMBOL_UNUSED(, _DFSET(. Declares 5 preprocessor commands. Defines color and display constants"}, {"role": "assistant", "content": "#ifndef HB_STD_CH_\n#define HB_STD_CH_\n\n#include \"set.ch\"\n\n\n#define HB_SYMBOL_UNUSED( symbol ) ( ( symbol ) )\n\n#ifdef HB_CLP_STRICT\n #command END SEQUENCE => end\n #command ENDSEQUENCE => end\n#else\n #command END SEQUENCE => endsequence\n#endif\n\n#command END SWITCH => endswitch\n#command END WITH => endwith\n#command END OBJECT => endwith\n\n#command DO WHILE <exp> => while <exp>\n#command END <x> => end\n#command ENDDO <*x*> => enddo\n#command ENDIF <*x*> => endif\n#command ENDCASE <*x*> => endcase\n#command ENDFOR [<*x*>] => next\n#command NEXT <v> [TO <x>] [STEP <s>] => next\n\n#command DO <proc>.prg [WITH <p,...>] => do <proc> [ WITH <p>]\n#command CALL <proc>() [WITH <p,...>] => call <proc> [ WITH <p>]\n#command STORE <v> TO <v1> [,<vN>] => <v1> := [ <vN> :=] <v>\n\n#command SET ECHO <*x*> =>\n#command SET HEADING <*x*> =>\n#command SET MENU <*x*> =>\n#command SET STATUS <*x*> =>\n#command SET STEP <*x*> =>\n#command SET SAFETY <*x*> =>\n#command SET TALK <*x*> =>\n#command SET PROCEDURE TO =>\n#command SET PROCEDURE TO <f> => _ProcReq_( <(f)> )\n#command SET FORMAT TO <id> => ;\n _ProcReq_( <(id)> + \".fmt\" ) ; __SetFormat( {|| <id>() } )\n#command SET FORMAT TO <id>.<ext> => ;\n _ProcReq_( <(id)> + \".\" + <(ext)> ) ; __SetFormat( {|| <id>() } )\n#command SET FORMAT TO <id:&> => ;\n if ( Empty( <(id)> ) ) ; SET FORMAT TO ; else ;;\n __SetFormat( &( \"{||\" + <(id)> + \"()}\" ) ) ; end\n#command SET FORMAT TO => __SetFormat()\n\n#define _DFSET( x, y ) Set( _SET_DATEFORMAT, iif( __SetCentury(), x, y ) )\n#command SET DATE [TO] AMERICAN => _DFSET( \"mm/dd/yyyy\", \"mm/dd/yy\" )\n#command SET DATE [TO] ANSI => _DFSET( \"yyyy.mm.dd\", \"yy.mm.dd\" )\n#command SET DATE [TO] BRITISH => _DFSET( \"dd/mm/yyyy\", \"dd/mm/yy\" )\n#command SET DATE [TO] FRENCH => _DFSET( \"dd/mm/yyyy\", \"dd/mm/yy\" )\n#command SET DATE [TO] GERMAN => _DFSET( \"dd.mm.yyyy\", \"dd.mm.yy\" )\n#command SET DATE [TO] ITALIAN => _DFSET( \"dd-mm-yyyy\", \"dd-mm-yy\" )\n#command SET DATE [TO] JAPANESE => _DFSET( \"yyyy/mm/dd\", \"yy/mm/dd\" )\n#command SET DATE [TO] USA => _DFSET( \"mm-dd-yyyy\", \"mm-dd-yy\" )\n\n#command SET CENTURY <x:ON,OFF,&> => __SetCentury( <(x)> )\n#command SET CENTURY (<x>) => __SetCentury( <x> )\n#command SET DATE FORMAT [TO] <f> => Set( _SET_DATEFORMAT, <f> )\n#command SET TIME FORMAT [TO] <f> => Set( _SET_TIMEFORMAT, <f> )\n#command SET EPOCH TO <y> => Set( _SET_EPOCH, <y> )\n\n#command SET DECIMALS TO <x> => Set( _SET_DECIMALS, <x> )\n#command SET DECIMALS TO => Set( _SET_DECIMALS, 0 )\n#command SET DEFAULT TO <(path)> => Set( _SET_DEFAULT, <(path)> )\n#command SET DEFAULT TO => Set( _SET_DEFAULT, \"\" )\n#command SET PATH TO <*pth*> => Set( _SET_PATH, <(pth)> )\n#command SET PATH TO => Set( _SET_PATH, \"\" )\n\n#command SET EXACT <x:ON,OFF,&> => Set( _SET_EXACT, <(x)> )\n#command SET EXACT (<x>) => Set( _SET_EXACT, <x> )\n#command SET FIXED <x:ON,OFF,&> => Set( _SET_FIXED, <(x)> )\n#command SET FIXED (<x>) => Set( _SET_FIXED, <x> )\n#command SET EXCLUSIVE <x:ON,OFF,&> => Set( _SET_EXCLUSIVE, <(x)> )\n#command SET EXCLUSIVE (<x>) => Set( _SET_EXCLUSIVE, <x> )\n#command SET SOFTSEEK <x:ON,OFF,&> => Set( _SET_SOFTSEEK, <(x)> )\n#command SET SOFTSEEK (<x>) => Set( _SET_SOFTSEEK, <x> )\n#command SET UNIQUE <x:ON,OFF,&> => Set( _SET_UNIQUE, <(x)> )\n#command SET UNIQUE (<x>) => Set( _SET_UNIQUE, <x> )\n#command SET DELETED <x:ON,OFF,&> => Set( _SET_DELETED, <(x)> )\n#command SET DELETED (<x>) => Set( _SET_DELETED, <x> )\n#command SET CONSOLE <x:ON,OFF,&> => Set( _SET_CONSOLE, <(x)> )\n#command SET CONSOLE (<x>) => Set( _SET_CONSOLE, <x> )\n#command SET BELL <x:ON,OFF,&> => Set( _SET_BELL, <(x)> )\n#command SET BELL (<x>) => Set( _SET_BELL, <x> )\n#command SET CONFIRM <x:ON,OFF,&> => Set( _SET_CONFIRM, <(x)> )\n#command SET CONFIRM (<x>) => Set( _SET_CONFIRM, <x> )\n#command SET ESCAPE <x:ON,OFF,&> => Set( _SET_ESCAPE, <(x)> )\n#command SET ESCAPE (<x>) => Set( _SET_ESCAPE, <x> )\n#command SET INTENSITY <x:ON,OFF,&> => Set( _SET_INTENSITY, <(x)> )\n#command SET INTENSITY (<x>) => Set( _SET_INTENSITY, <x> )\n#command SET SCOREBOARD <x:ON,OFF,&> => Set( _SET_SCOREBOARD, <(x)> )\n#command SET SCOREBOARD (<x>) => Set( _SET_SCOREBOARD, <x> )\n#command SET WRAP <x:ON,OFF,&> => Set( _SET_WRAP, <(x)> )\n#command SET WRAP (<x>) => Set( _SET_WRAP, <x> )\n#command SET DELIMITERS <x:ON,OFF,&> => Set( _SET_DELIMITERS, <(x)> )\n#command SET DELIMITERS (<x>) => Set( _SET_DELIMITERS, <x> )\n#command SET DELIMITERS TO <c> => Set( _SET_DELIMCHARS, <c> )\n#command SET DELIMITERS TO [DEFAULT] => Set( _SET_DELIMCHARS, \"::\" )\n#command SET ALTERNATE <x:ON,OFF,&> => Set( _SET_ALTERNATE, <(x)> )\n#command SET ALTERNATE (<x>) => Set( _SET_ALTERNATE, <x> )\n#command SET ALTERNATE TO => Set( _SET_ALTFILE, \"\" )\n#command SET ALTERNATE TO <(file)> [<add: ADDITIVE>] => ;\n Set( _SET_ALTFILE, <(file)>, <.add.> )\n#command SET PRINTER <x:ON,OFF,&> => Set( _SET_PRINTER, <(x)> )\n#command SET PRINTER (<x>) => Set( _SET_PRINTER, <x> )\n#command SET PRINTER TO => Set( _SET_PRINTFILE, \"\" )\n#command SET PRINTER TO <(file)> [<add: ADDITIVE>] => ;\n Set( _SET_PRINTFILE, <(file)>, <.add.> )\n#command SET CURSOR <x:ON,OFF,&> => ;\n SetCursor( iif( Upper( <(x)> ) == \"ON\", 1, 0 ) )\n#command SET CURSOR (<x>) => SetCursor( iif( <x>, 1, 0 ) )\n#command SET MARGIN TO <x> => Set( _SET_MARGIN, <x> )\n#command SET MARGIN TO => Set( _SET_MARGIN, 0 )\n#command SET DEVICE TO SCREEN => Set( _SET_DEVICE, \"SCREEN\" )\n#command SET DEVICE TO PRINTER => Set( _SET_DEVICE, \"PRINTER\" )\n#command SET COLOR TO [<*c*>] => SetColor( #<c> )\n#command SET COLOR TO ( <c> ) => SetColor( <c> )\n#command SET COLOUR TO [<*c*>] => SET COLOR TO [<c>]\n#command SET ORDER TO <tg> [IN <(bg)>] => ordSetFocus( <tg> [, <(bg)>] )\n#command SET ORDER TO TAG <(tg)> [IN <(bg)>] => ordSetFocus( <(tg)> [, <(bg)>] )\n#command SET INDEX TO [<(i1)> [,<(iN)>]] [<add: ADDITIVE>] => ;\n if ! <.add.> ; ordListClear() ; end ;\n [ ; ordListAdd( <(i1)> )] [ ; ordListAdd( <(iN)> )]\n#command SET MESSAGE TO <n> [<cent: CENTER, CENTRE>] => ;\n Set( _SET_MESSAGE, <n> ) ; Set( _SET_MCENTER, <.cent.> )\n#command SET MESSAGE TO => Set( _SET_MESSAGE, 0 ) ;;\n Set( _SET_MCENTER, .f. )\n#command SET TYPEAHEAD TO <x> => Set( _SET_TYPEAHEAD, <x> )\n#command SET KEY <n> TO <f> => SetKey( <n>, {| p, l, v | <f>( p, l, v ) } )\n#command SET KEY <n> TO <f>([<p,...>]) => SET KEY <n> TO <f>\n#command SET KEY <n> TO <f:&> => ;\n if ( Empty( <(f)> ) ) ; SetKey( <n>, NIL ) ; else ;;\n SetKey( <n>, {| p, l, v | <f>( p, l, v ) } ) ; end\n#command SET KEY <n> [TO] => SetKey( <n>, NIL )\n#command SET FUNCTION <n> [TO] [<f>] => __SetFunction( <n>, <f> )\n\n#ifdef HB_COMPAT_C53\n #command SET EVENTMASK TO <x> => Set( _SET_EVENTMASK, <x> )\n #command SET VIDEOMODE TO <x> => Set( _SET_VIDEOMODE, <x> )\n #command SET SCOPETOP TO => ordScope( 0, nil )\n #command SET SCOPETOP TO <x> => ordScope( 0, <x> )\n #command SET SCOPEBOTTOM TO => ordScope( 1, nil )\n #command SET SCOPEBOTTOM TO <x> => ordScope( 1, <x> )\n #command SET SCOPE TO => ordScope( 0, nil ) ; ordScope( 1, 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 a Harbour program with procedures: Main. Harbour contribution module 'hbnf' (NanForum Toolkit - legacy Clipper compatibility functions): contrib/hbnf/tests/getenvrn.prg. 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 a\n LOCAL c\n\n LOCAL tmp\n\n a := Array( ft_GetE() )\n ft_GetE( @a )\n FOR tmp := 1 TO Len( a )\n ? a[ tmp ]\n NEXT\n\n ? \"-------------------------------------\"\n\n c := \"\"\n ft_GetE( @c )\n ? c\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 'gtwvw' (): contrib/gtwvw/tests/drawimg.prg. Defines classes: wGUIObj, wPaintObj. Provides functions: wg_ResetWPaintObj, wg_AddWPaintObj, wg_DelWPaintObj. Contains procedures: Main. This file provides platform-specific functionality"}, {"role": "assistant", "content": "#require \"gtwvw\"\n\n#include \"inkey.ch\"\n#include \"setcurs.ch\"\n#include \"hbclass.ch\"\n\n\n#define WPAINTOBJ_LABEL 1\n#define WPAINTOBJ_SHADEDRECT 2\n#define WPAINTOBJ_TEXTBOX 3\n#define WPAINTOBJ_PROGRESSBAR 4\n#define WPAINTOBJ_BOXGET 5\n#define WPAINTOBJ_BOXRAISED 6\n#define WPAINTOBJ_BOXRECESSED 7\n#define WPAINTOBJ_BOXGROUP 8\n#define WPAINTOBJ_BOXGROUPRAISED 9\n#define WPAINTOBJ_IMAGE 10\n#define WPAINTOBJ_OUTLINE 11\n#define WPAINTOBJ_LINE 12\n#define WPAINTOBJ_ELLIPSE 13\n#define WPAINTOBJ_RECTANGLE 14\n#define WPAINTOBJ_FILLRECTANGLE 15\n#define WPAINTOBJ_ROUNDRECT 16\n#define WPAINTOBJ_FOCUSRECT 17\n#define WPAINTOBJ_GRIDHORZ 18\n#define WPAINTOBJ_GRIDVERT 19\n#define WPAINTOBJ_PICTURE 20\n#define WPAINTOBJ_LABELEX 21\n#define WPAINTOBJ_LINEEX 22\n#define WPAINTOBJ_OUTLINEEX 23\n\n\n#define WCTRLOBJ_PUSHBUTTON 1001\n#define WCTRLOBJ_VSCROLLBAR 1002\n#define WCTRLOBJ_HSCROLLBAR 1003\n#define WCTRLOBJ_COMBOBOX 1004\n\n\n#define WOBJ_ADD_OVERWRITE 1 \n#define WOBJ_ADD_APPEND 2 \n#define WOBJ_ADD_NEWONLY 3 \n\nSTATIC s_aPObjList := {}\n\nPROCEDURE Main()\n\n LOCAL ntop := 7, ;\n nleft := 3, ;\n nbot := MaxRow() - 2, ;\n nrig := MaxCol() - 2, ;\n nmidver := Int( ( ntop + nbot ) / 2 ), ;\n nmidhor := Int( ( nleft + nrig ) / 2 )\n LOCAL cpict := \"vouch1.gif\"\n LOCAL ltransp := .F.\n LOCAL nMaxCache\n LOCAL i, j, oWPaint\n LOCAL getlist := {}\n\n#if defined( __HBSCRIPT__HBSHELL ) .AND. defined( __PLATFORM__WINDOWS )\n hbshell_gtSelect( \"GTWVW\" )\n#endif\n\n nMaxCache := wvw_SetMaxBMCache()\n\n SetColor( \"N/W,N/GR*,,,N/W*\" )\n wvw_SetCodepage( , 255 )\n wg_ResetWPaintObj( 0 )\n DO WHILE .T.\n CLS\n SetCursor( SC_NORMAL )\n cpict := PadR( cpict, 40 )\n @ 0, 0 SAY \"FileName :\" GET cpict PICT \"@K\" VALID hb_FileExists( AllTrim( cpict ) )\n @ 1, 0 SAY \"Transpar? :\" GET ltransp PICT \"Y\"\n @ 2, 0 SAY \"Max Cache :\" GET nMaxCache PICT \"999\"\n @ 3, 0 SAY \"NumOfCache=\" + Transform( wvw_NumBMCache(), \"999\" ) + ;\n \", Max NumOfCache=\" + Transform( wvw_SetMaxBMCache(), \"999\" )\n READ\n IF LastKey() == K_ESC\n EXIT\n ENDIF\n wvw_SetMaxBMCache( nMaxCache )\n @ 3, 0 SAY \"NumOfCache=\" + Transform( wvw_NumBMCache(), \"999\" ) + ;\n \", Max NumOfCache=\" + Transform( wvw_SetMaxBMCache(), \"999\" )\n\n @ 5, 0 SAY \"TOPLEFT: stretched image TOPRIGHT: fit vertically (proportional)\"\n @ 6, 0 SAY \"BOTLEFT: fit horizontally (proportional) BOTRIGHT: actual image size\"\n\n cpict := AllTrim( cpict )\n\n \n SetCursor( SC_NONE )\n DispBegin()\n FOR i := ntop TO nbot\n FOR j := nleft TO nrig\n @ i, j SAY \"X\"\n NEXT\n NEXT\n @ ntop, nmidhor TO nbot, nmidhor\n @ nmidver, nleft TO nmidver, nrig\n @ ntop, nleft TO nbot, nrig\n DispEnd()\n\n \n oWPaint := wPaintObj():New( 0, WPAINTOBJ_IMAGE, \"TOPLEFT\", ntop + 1, nleft + 1, nmidver - 1, nmidhor - 1, NIL, ltransp )\n oWPaint:cImage := cpict\n wg_AddWPaintObj( 0, oWPaint )\n\n \n oWPaint := wPaintObj():New( 0, WPAINTOBJ_IMAGE, \"TOPRIGHT\", ntop + 1, nmidhor + 1, nmidver - 1, NIL, NIL, ltransp )\n oWPaint:cImage := cpict\n wg_AddWPaintObj( 0, oWPaint )\n\n \n oWPaint := wPaintObj():New( 0, WPAINTOBJ_IMAGE, \"BOTLEFT\", nmidver + 1, nleft + 1, NIL, nmidhor - 1, NIL, ltransp )\n oWPaint:cImage := cpict\n wg_AddWPaintObj( 0, oWPaint )\n\n \n oWPaint := wPaintObj():New( 0, WPAINTOBJ_IMAGE, \"BOTRIGHT\", nmidver + 1, nmidhor + 1, NIL, NIL, NIL, ltransp )\n oWPaint:cImage := cpict\n wg_AddWPaintObj( 0, oWPaint )\n\n Inkey( 0 )\n\n \n wg_DelWPaintObj( 0, WPAINTOBJ_IMAGE, NIL )\n ENDDO \n SetCursor( SC_NORMAL )\n\n RETURN\n\n\nCREATE CLASS wGUIObj\n\n VAR nWinNum \n VAR lVisible \n VAR nType \n VAR cId \n VAR nRow1, nCol1, nRow2, nCol2 \n VAR aOffTLBR \n\nENDCLASS\n\n\nCREATE CLASS wPaintObj FROM wGUIObj\n\n \n VAR cImage\n VAR lTransp\n\n METHOD New( nWinNum, nType, cId, nRow1, nCol1, nRow2, nCol2, aOffTLBR, lTransp )\n METHOD Draw()\n METHOD Undraw()\n METHOD Hide()\n METHOD Show()\n\nENDCLASS\n\nMETHOD New( nWinNum, nType, cId, nRow1, nCol1, nRow2, nCol2, aOffTLBR, lTransp ) CLASS wPaintObj\n\n hb_default( @aOffTLBR, { 0, 0, 0, 0 } )\n hb_default( @lTransp, .F. )\n\n ::nWinNum := nWinNum\n ::lVisible := .T.\n\n ::nType := nType\n ::cId := cId\n ::nRow1 := nRow1\n ::nCol1 := nCol1\n ::nRow2 := nRow2\n ::nCol2 := nCol2\n\n ::aOffTLBR := AClone( aOffTLBR )\n\n ::lTransp := lTransp\n\n RETURN Self\n\nMETHOD Draw() CLASS wPaintObj\n\n IF ! ::lVisible\n RETURN NIL\n ENDIF\n\n DO CASE\n case ::nType == WPAINTOBJ_IMAGE\n IF ! Empty( ::cImage )\n wvw_DrawImage( ::nWinNum, ::nRow1, ::nCol1, ::nRow2, ::nCol2, ;\n ::cImage, ::aOffTLBR, ::lTransp )\n ENDIF\n\n OTHERWISE\n \n ENDCASE\n\n RETURN NIL \n\n\nMETHOD Undraw() CLASS wPaintObj\n\n LOCAL cScreen\n LOCAL nRow1, nCol1, nRow2, nCol2, nMaxRow, nMaxCol\n\n \n nMaxRow := MaxRow()\n nMaxCol := MaxCol()\n\n DO CASE\n case ::nType == WPAINTOBJ_LABEL\n nRow1 := ::nRow1\n nCol1 := ::nCol1\n nRow2 := ::nRow2\n nCol2 := ::nCol2\n OTHERWISE\n nRow1 := Max( ::nRow1 - 1, 0 )\n nCol1 := Max( ::nCol1 - 1, 0 )\n nRow2 := Min( ::nRow2 + 1, nMaxRow )\n nCol2 := Min( ::nCol2 + 1, nMaxCol )\n ENDCASE\n\n cScreen := SaveScreen( nRow1, nCol1, nRow2, nCol2 )\n DispBegin()\n RestScreen( nRow1, nCol1, nRow2, nCol2, cScreen )\n DispEnd()\n\n RETURN NIL \n\nMETHOD Hide() CLASS wPaintObj\n\n \n ::lVisible := .F.\n ::Undraw()\n\n RETURN NIL\n\nMETHOD Show() CLASS wPaintObj\n\n \n ::lVisible := .T.\n ::draw()\n\n RETURN NIL\n\n\nFUNCTION wg_ResetWPaintObj( nWinNum, nObjNum, lStrict )\n\n hb_default( @nObjNum, 0 )\n hb_default( @lStrict, .F. )\n\n DO WHILE Len( s_aPObjList ) < nWinNum + 1\n AAdd( s_aPObjList, {} )\n ENDDO\n\n ASize( s_aPObjList[ nWinNum + 1 ], nObjNum )\n\n RETURN .T.\n\n\nFUNCTION wg_AddWPaintObj( nWinNum, oWPaint, lStrict, nOperation )\n\n LOCAL i\n\n hb_default( @lStrict, .F. )\n hb_default( @nOperation, WOBJ_ADD_OVERWRITE )\n\n \n nOperation := WOBJ_ADD_OVERWRITE\n\n \n i := AScan( s_aPObjList[ nWinNum + 1 ], {| x | x:nType == oWPaint:nType .AND. x:cId == oWPaint:cId } )\n\n IF i > 0\n \n \n IF lStrict\n s_aPObjList[ nWinNum + 1 ][ i ]:Hide()\n ELSE\n s_aPObjList[ nWinNum + 1 ][ i ]:lVisible := .F.\n ENDIF\n s_aPObjList[ nWinNum + 1 ][ i ] := oWPaint\n\n ELSE\n AAdd( s_aPObjList[ nWinNum + 1 ], oWPaint )\n ENDIF\n\n \n IF oWPaint:lVisible\n oWPaint:draw()\n ENDIF\n\n RETURN oWPaint:cId \n\n\nFUNCTION wg_DelWPaintObj( nWinNum, nType, cId, lStrict )\n\n LOCAL i\n LOCAL lDelAll := ( cId == NIL )\n LOCAL nDeleted := 0\n LOCAL nLen\n\n hb_default( @lStrict, .F. )\n\n \n IF nType < 1\n RETURN nDeleted\n ENDIF\n\n \n i := 1\n nLen := Len( s_aPObjList[ nWinNum + 1 ] )\n DO WHILE i <= nLen\n IF s_aPObjList[ nWinNum + 1 ][ i ]:nType == nType .AND. ;\n ( lDelAll .OR. s_aPObjList[ nWinNum + 1 ][ i ]:cId == cId )\n IF lStrict\n s_aPObjList[ nWinNum + 1 ][ i ]:Hide()\n ELSE\n s_aPObjList[ nWinNum + 1 ][ i ]:lVisible := .F.\n ENDIF\n ADel( s_aPObjList[ nWinNum + 1 ], i )\n ASize( s_aPObjList[ nWinNum + 1 ], --nLen )\n nDeleted++\n ELSE\n i++\n ENDIF\n ENDDO\n\n RETURN nDeleted"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/utf8at.prg. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"simpleio.ch\"\n\nREQUEST HB_CODEPAGE_FR850\nREQUEST HB_CODEPAGE_FRISO\n\nPROCEDURE Main()\n\n #define _UTF8_E_ACUTE hb_BChar( 0xC3 ) + hb_BChar( 0xA9 )\n #define _UTF8_E_CIRCUMFLEX hb_BChar( 0xC3 ) + hb_BChar( 0xAA )\n\n LOCAL u := \"Une r\" + _UTF8_E_CIRCUMFLEX + \"ve est la moiti\" + _UTF8_E_ACUTE + \" d'une r\" + _UTF8_E_ACUTE + \"alit\" + _UTF8_E_ACUTE + \".\"\n LOCAL i := hb_Translate( u, \"UTF8\", \"FRISO\" )\n LOCAL d := hb_Translate( u, \"UTF8\", \"FR850\" )\n\n LOCAL uu := _UTF8_E_ACUTE\n LOCAL ii := hb_Translate( uu, \"UTF8\", \"FRISO\" )\n LOCAL dd := hb_Translate( uu, \"UTF8\", \"FR850\" )\n\n LOCAL l := Len( uu ) + 2\n\n ? \"ISO-8859-1 -\", PadR( ii, l ), \"=>\", i\n ?\n ? \"CP850 -\", PadR( dd, l ), \"=>\", d\n ?\n ? \"UTF-8 -\", PadR( uu, l ), \"=>\", u\n ?\n ? At( ii, i ), RAt( ii, i ), \"- ISO-8859-1 at/rat\"\n ? hb_At( ii, i ), hb_RAt( ii, i ), \"- ISO-8859-1 hb_at/rat\"\n ? hb_utf8At( ii, i ), hb_utf8RAt( ii, i ), \"- ISO-8859-1 hb_utf8at/rat\"\n ? At( dd, d ), RAt( dd, d ), \"- CP850 at/rat\"\n ? hb_At( dd, d ), hb_RAt( dd, d ), \"- CP850 hb_at/rat\"\n ? hb_utf8At( dd, d ), hb_utf8RAt( dd, d ), \"- CP850 hb_utf8at/rat\"\n ? At( uu, u ), RAt( uu, u ), \"- UTF-8 at/rat\"\n ? hb_At( uu, u ), hb_RAt( uu, u ), \"- UTF-8 hb_at/rat\"\n ? hb_utf8At( uu, u ), hb_utf8RAt( uu, u ), \"- UTF-8 hb_utf8at/rat\"\n ?\n ? hb_At( ii, i, 33 ), hb_RAt( ii, i, 33 ), hb_At( ii, i, , 33 ), hb_RAt( ii, i, , 33 ), \"- ISO-8859-1 hb_at/rat\"\n ? hb_utf8At( ii, i, 33 ), hb_utf8RAt( ii, i, 33 ), hb_utf8At( ii, i, , 33 ), hb_utf8RAt( ii, i, , 33 ), \"- ISO-8859-1 hb_utf8at/rat\"\n ? hb_At( dd, d, 33 ), hb_RAt( dd, d, 33 ), hb_At( dd, d, , 33 ), hb_RAt( dd, d, , 33 ), \"- CP850 hb_at/rat\"\n ? hb_utf8At( dd, d, 33 ), hb_utf8RAt( dd, d, 33 ), hb_utf8At( dd, d, , 33 ), hb_utf8RAt( dd, d, , 33 ), \"- CP850 hb_utf8at/rat\"\n ? hb_At( uu, u, 33 ), hb_RAt( uu, u, 33 ), hb_At( uu, u, , 33 ), hb_RAt( uu, u, , 33 ), \"- UTF-8 hb_at/rat\"\n ? hb_utf8At( uu, u, 33 ), hb_utf8RAt( uu, u, 33 ), hb_utf8At( uu, u, , 33 ), hb_utf8RAt( uu, u, , 33 ), \"- UTF-8 hb_utf8at/rat\"\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/amedian.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\n#include \"directry.ch\"\n\nPROCEDURE Main()\n\n LOCAL var0, myarray0 := Directory(), myarray1 := {}\n\n CLS\n ? \"TEST TO DEMONSTRATE EXAMPLES OF FT_AMEDIAN\"\n ?\n AEval( myarray0, {| x | AAdd( myarray1, x[ F_SIZE ] ) } )\n var0 := ft_AMedian( myarray1 )\n ? PadR( \"ft_AMedian( myarray1 ) ->\", 35 )\n ?? var0\n ?\n var0 := ft_AMedian( myarray1, 2 )\n ? PadR( \"ft_AMedian( myarray1, 2 ) ->\", 35 )\n ?? var0\n ?\n var0 := ft_AMedian( myarray1, , 9 )\n ? PadR( \"ft_AMedian( myarray1, , 9 ) ->\", 35 )\n ?? var0\n ?\n var0 := ft_AMedian( myarray1, 8, 40 )\n ? PadR( \"ft_AMedian( myarray1, 8, 40 ) ->\", 35 )\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": "Generate Harbour code for: Harbour test program: tests/rto_tb.prg. Contains procedures: Main, TBRAssign. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"error.ch\"\n#include \"fileio.ch\"\n\n#ifndef __HARBOUR__\n #define hb_eol() ( Chr( 13 ) + Chr( 10 ) )\n #define hb_ntos( n ) LTrim( Str( n ) )\n#endif\n\n#ifdef __XHARBOUR__\n #ifndef HB_COMPAT_C53\n \n \n #endif\n#endif\n\n#xtranslate TEST_L_TBR( <x> ) => TEST_C_TBR( o, #<x>, {|| <x> } )\n#xtranslate TEST_L_TBC( <x> ) => TEST_C_TBC( o, #<x>, {|| <x> } )\n\nSTATIC s_cTest := \"\"\nSTATIC s_xVar := NIL\nSTATIC s_fhnd\nSTATIC s_lCallBackStack\nSTATIC s_lRTEDetails\nSTATIC s_lIgnoreErrOp\nSTATIC s_lObjectDump\nSTATIC s_lCatchErr\nSTATIC s_lCheckResult\n\nPROCEDURE Main( cArg01, cArg02, cArg03, cArg04 )\n\n LOCAL o\n\n LOCAL cCommandLine\n\n IF cArg01 == NIL\n cArg01 := \"\"\n ENDIF\n IF cArg02 == NIL\n cArg02 := \"\"\n ENDIF\n IF cArg03 == NIL\n cArg03 := \"\"\n ENDIF\n IF cArg04 == NIL\n cArg04 := \"\"\n ENDIF\n\n Set( _SET_DATEFORMAT, \"yyyy-mm-dd\" )\n\n \n cCommandLine := cArg01 + \" \" + cArg02 + \" \" + cArg03 + \" \" + cArg04\n\n s_lCallBackStack := \"CALLBACKSTACK\" $ Upper( cCommandLine )\n s_lRTEDetails := \"RTEDETAILS\" $ Upper( cCommandLine )\n s_lIgnoreErrOp := \"IGNERROP\" $ Upper( cCommandLine )\n s_lObjectDump := !( \"NODUMP\" $ Upper( cCommandLine ) )\n s_lCatchErr := .T.\n s_lCheckResult := .F.\n\n s_lRTEDetails := .T.\n\n\n #ifdef __HARBOUR__\n s_fhnd := FCreate( \"tb_hb.txt\", FC_NORMAL )\n #else\n s_fhnd := FCreate( \"tb_cl5.txt\", FC_NORMAL )\n #endif\n\n IF s_fhnd == F_ERROR\n RETURN\n ENDIF\n\n \n o := TBColumnNew( \"test00\", {|| \"test00\" } )\n TEST_L_TBC( OBJ_CREATE() )\n TEST_L_TBC( o:defColor := {} )\n TEST_L_TBC( o:defColor := { 1 } )\n TEST_L_TBC( o:defColor := NIL )\n TEST_L_TBC( o:defColor := { 1, 2 } )\n TEST_L_TBC( o:defColor := { 1, 2, 3 } )\n TEST_L_TBC( o:defColor := { 1, 2, 3, 4 } )\n TEST_L_TBC( o:defColor := { 1, 2, 3, 4, 5 } )\n TEST_L_TBC( o:defColor := { \"1\" } )\n TEST_L_TBC( o:defColor := { \"1\", \"2\" } )\n TEST_L_TBC( o:defColor := { \"1\", \"2\", \"3\" } )\n TEST_L_TBC( o:defColor := { \"1\", \"2\", \"3\", \"4\" } )\n TEST_L_TBC( o:defColor := { \"1\", \"2\", \"3\", \"4\", \"5\" } )\n TEST_L_TBC( o:defColor := { \"1\", 2, \"3\" } )\n\n \n s_lCheckResult := .T.\n\n TEST_L_TBC( TBColumnNew( NIL , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( -1 , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( 0 , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( 1 , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( 3 , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( 25 , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( \"\" , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( \"az\" , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( hb_SToD( \"20070425\" ), {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( .F. , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( .T. , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( {|| NIL } , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( {} , {|| \"test00\" } ) )\n TEST_L_TBC( TBColumnNew( { \"\" } , {|| \"test00\" } ) )\n\n TEST_L_TBC( TBColumnNew( \"test00\", NIL ) )\n TEST_L_TBC( TBColumnNew( \"test00\", -1 ) )\n TEST_L_TBC( TBColumnNew( \"test00\", 0 ) )\n TEST_L_TBC( TBColumnNew( \"test00\", 1 ) )\n TEST_L_TBC( TBColumnNew( \"test00\", 3 ) )\n TEST_L_TBC( TBColumnNew( \"test00\", 25 ) )\n TEST_L_TBC( TBColumnNew( \"test00\", \"\" ) )\n TEST_L_TBC( TBColumnNew( \"test00\", \"az\" ) )\n TEST_L_TBC( TBColumnNew( \"test00\", hb_SToD( \"20070425\" ) ) )\n TEST_L_TBC( TBColumnNew( \"test00\", .F. ) )\n TEST_L_TBC( TBColumnNew( \"test00\", .T. ) )\n TEST_L_TBC( TBColumnNew( \"test00\", {|| NIL } ) )\n TEST_L_TBC( TBColumnNew( \"test00\", {} ) )\n TEST_L_TBC( TBColumnNew( \"test00\", { \"\" } ) )\n\n s_lCheckResult := .F.\n\n \n TBRAssign( NIL )\n TBRAssign( -1 )\n TBRAssign( 0 )\n TBRAssign( 1 )\n TBRAssign( 3 )\n TBRAssign( 3.3 )\n TBRAssign( 3.7 )\n TBRAssign( 25 )\n TBRAssign( 25.3 )\n TBRAssign( 25.7 )\n TBRAssign( \"\" )\n TBRAssign( \"az\" )\n TBRAssign( hb_SToD( \"20070425\" ) )\n TBRAssign( .F. )\n TBRAssign( .T. )\n TBRAssign( {|| NIL } )\n TBRAssign( {} )\n TBRAssign( { \"\" } )\n\n \n TBCAssign( NIL )\n TBCAssign( -1 )\n TBCAssign( 0 )\n TBCAssign( 1 )\n TBCAssign( 3 )\n TBCAssign( 3.3 )\n TBCAssign( 3.7 )\n TBCAssign( 25 )\n TBCAssign( 25.3 )\n TBCAssign( 25.7 )\n TBCAssign( \"\" )\n TBCAssign( \"az\" )\n TBCAssign( hb_SToD( \"20070425\" ) )\n TBCAssign( .F. )\n TBCAssign( .T. )\n TBCAssign( {|| NIL } )\n TBCAssign( {} )\n TBCAssign( { \"\" } )\n\n \n s_cTest := \"\"\n\n \n s_lCatchErr := .F.\n\n o := TBrowseNew( 10, 10, 20, 50 )\n TEST_L_TBR( OBJ_CREATE() )\n TEST_L_TBR( o:AddColumn( TBColumnNew( \"test01h\", {|| \"test01d\" } ) ) )\n TEST_L_TBR( o:DelColumn( 1 ) )\n TEST_L_TBR( o:Left() )\n TEST_L_TBR( o:Right() )\n\n \n#ifdef HB_COMPAT_C53\n\n o := TBColumnNew( \"test01h\", {|| \"test01d\" } )\n TEST_L_TBC( OBJ_CREATE() )\n TEST_L_TBC( o:SetStyle( 1 ) )\n TEST_L_TBC( o:SetStyle( 2 ) )\n TEST_L_TBC( o:SetStyle( 3 ) )\n TEST_L_TBC( o:SetStyle( 4, .T. ) )\n TEST_L_TBC( o:SetStyle( 4 ) )\n TEST_L_TBC( o:SetStyle( 4, NIL ) )\n TEST_L_TBC( o:SetStyle( 4 ) )\n TEST_L_TBC( o:SetStyle( 5 ) )\n TEST_L_TBC( o:SetStyle( 5, .T. ) )\n TEST_L_TBC( o:SetStyle( 5, .F. ) )\n\n o := TBrowseNew( 10, 10, 20, 50 )\n TEST_L_TBR( OBJ_CREATE() )\n TEST_L_TBR( o:SetStyle( 1 ) )\n TEST_L_TBR( o:SetStyle( 2 ) )\n TEST_L_TBR( o:SetStyle( 3 ) )\n TEST_L_TBR( o:SetStyle( 4 ) )\n TEST_L_TBR( o:SetStyle( 5 ) )\n TEST_L_TBR( o:SetStyle( 4, .T. ) )\n TEST_L_TBR( o:SetStyle( 4 ) )\n TEST_L_TBR( o:SetStyle( 4, NIL ) )\n TEST_L_TBR( o:SetStyle( 4 ) )\n TEST_L_TBR( o:SetStyle( 6 ) )\n TEST_L_TBR( o:SetStyle( 6, .T. ) )\n TEST_L_TBR( o:SetStyle( 6, .F. ) )\n\n#endif\n\n \n FClose( s_fhnd )\n\n RETURN\n\nPROCEDURE TBRAssign( xVar )\n LOCAL o\n\n s_xVar := xVar\n\n s_cTest := \"TBrowse (empty) assigning: \" + XToStr( xVar )\n\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:AutoLite := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:Cargo := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:ColCount := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:ColorSpec := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:ColPos := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:ColSep := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:FootSep := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:Freeze := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:GoBottomBlock := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:GoTopBlock := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:HeadSep := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:HitBottom := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:HitTop := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:LeftVisible := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:nBottom := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:nLeft := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:nRight := xVar )\n \n IF ValType( xVar ) == \"N\" .AND. xVar < o:nBottom\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:nTop := xVar )\n ENDIF\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:RightVisible := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:RowCount := xVar )\n o := TBrowseNew( 10, 10, 20, 50 ) ; TEST_L_TBR( o:RowPos := xVar )"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/mttest08.prg. This test file tests specific function APIs"}, {"role": "assistant", "content": "#include \"hbthread.ch\"\n\nmemvar pub1, pub2\nmemvar prv1, prv2\n\nproc main()\n\n ? Version()\n ? \"Main start\"\n\n public pub1, pub2\n private prv1, prv2\n\n ?\n ? \"Do not inherit memvars.\"\n initVars()\n ? \"main thread:\"\n testAllVars()\n hb_threadJoin( hb_threadStart( @thFunc() ) )\n ? \"main thread:\"\n testAllVars()\n wait\n\n ?\n ? \"Inherit copy of publics.\"\n initVars()\n ? \"main thread:\"\n testAllVars()\n hb_threadJoin( hb_threadStart( HB_BITOR( HB_THREAD_INHERIT_PUBLIC, ;\n HB_THREAD_MEMVARS_COPY ), ;\n @thFunc() ) )\n ? \"main thread:\"\n testAllVars()\n wait\n\n ?\n ? \"Inherit copy of privates.\"\n initVars()\n ? \"main thread:\"\n testAllVars()\n hb_threadJoin( hb_threadStart( HB_BITOR( HB_THREAD_INHERIT_PRIVATE, ;\n HB_THREAD_MEMVARS_COPY ), ;\n @thFunc() ) )\n ? \"main thread:\"\n testAllVars()\n wait\n\n ?\n ? \"Inherit copy of publics and privates.\"\n initVars()\n ? \"main thread:\"\n testAllVars()\n hb_threadJoin( hb_threadStart( HB_BITOR( HB_THREAD_INHERIT_MEMVARS, ;\n HB_THREAD_MEMVARS_COPY ), ;\n @thFunc() ) )\n ? \"main thread:\"\n testAllVars()\n wait\n\n ?\n ? \"Share publics with child threads.\"\n initVars()\n ? \"main thread:\"\n testAllVars()\n hb_threadJoin( hb_threadStart( HB_THREAD_INHERIT_PUBLIC, @thFunc() ) )\n ? \"main thread:\"\n testAllVars()\n wait\n\n ?\n ? \"Share privates with child threads.\"\n initVars()\n ? \"main thread:\"\n testAllVars()\n hb_threadJoin( hb_threadStart( HB_THREAD_INHERIT_PRIVATE, @thFunc() ) )\n ? \"main thread:\"\n testAllVars()\n wait\n\n ?\n ? \"Share publics and privates with child threads.\"\n initVars()\n ? \"main thread:\"\n testAllVars()\n hb_threadJoin( hb_threadStart( HB_THREAD_INHERIT_MEMVARS, @thFunc() ) )\n ? \"main thread:\"\n testAllVars()\n wait\n\nreturn\n\nstatic proc initVars()\n pub1 := \"main:public1\"\n pub2 := \"main:public2\"\n prv1 := \"main:private1\"\n prv2 := \"main:private2\"\nreturn\n\nstatic proc testAllVars()\n test_var( \"PUB1\" )\n test_var( \"PUB2\" )\n test_var( \"PRV1\" )\n test_var( \"PRV2\" )\nreturn\n\nstatic proc test_var( cVarName )\n ? \" \" + cVarName + \":\", type( cVarName )\n if ! type( cVarName ) == \"U\"\n ?? \" ->\", &cVarName\n endif\nreturn\n\nstatic proc thFunc()\n ? \"child thread:\"\n testAllVars()\n ? \"assign...\"\n pub1 := \"thread:public1\"\n pub2 := \"thread:public2\"\n prv1 := \"thread:private1\"\n prv2 := \"thread:private2\"\n ? \"child thread:\"\n testAllVars()\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 this Harbour module: Harbour Runtime Library file: src/rtl/ttopbar.prg. Defines classes: TopBarMenu. This file implements menu system classes"}, {"role": "assistant", "content": "#include \"hbclass.ch\"\n\n#include \"button.ch\"\n#include \"color.ch\"\n#include \"inkey.ch\"\n\n\n#ifdef HB_COMPAT_C53\n\nCREATE CLASS TopBarMenu FUNCTION HBTopBarMenu\n\n EXPORTED:\n\n VAR cargo\n\n METHOD addItem( oItem )\n METHOD delItem( nPos )\n METHOD display()\n METHOD getFirst()\n METHOD getItem( nPos )\n METHOD getLast()\n METHOD getNext()\n METHOD getPrev()\n METHOD getAccel( nKey )\n METHOD getShortCt( nKey ) \n METHOD hitTest( nMRow, nMCol )\n METHOD insItem( nPos, oItem )\n METHOD select( nPos )\n METHOD setItem( nPos, oItem )\n\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 row( nRow ) SETGET\n\n METHOD Init( nRow, nLeft, nRight ) \n\n PROTECTED:\n\n VAR cColorSpec\n VAR nCurrent INIT 0\n VAR nItemCount INIT 0\n VAR nLeft\n VAR nRight\n VAR nRow\n\n VAR aItems INIT {}\n VAR nWidth INIT 0\n\nENDCLASS\n\nMETHOD addItem( oItem ) CLASS TopBarMenu\n\n IF HB_ISOBJECT( oItem ) .AND. oItem:ClassName() == \"MENUITEM\"\n\n ::nItemCount++\n AAdd( ::aItems, oItem )\n\n ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )\n ENDIF\n\n RETURN Self\n\nMETHOD delItem( nPos ) CLASS TopBarMenu\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 TopBarMenu\n\n LOCAL nRow := ::nRow\n LOCAL nLeft := ::nLeft\n LOCAL nRight := ::nRight\n LOCAL nCurrent := ::nCurrent\n LOCAL item\n\n LOCAL cColor1 := hb_ColorIndex( ::cColorSpec, 0 )\n LOCAL cColor2 := hb_ColorIndex( ::cColorSpec, 1 )\n\n LOCAL oPopUp\n LOCAL cCaption\n LOCAL nCaptionLen\n LOCAL nPos\n\n DispBegin()\n\n hb_DispOutAt( nRow, nLeft, Space( nRight - nLeft + 1 ), cColor1 )\n\n FOR EACH item IN ::aItems\n\n cCaption := \" \" + RTrim( item:caption ) + \" \"\n nCaptionLen := Len( cCaption )\n\n IF nCaptionLen == 0\n LOOP\n ENDIF\n\n IF nLeft > nRight - nCaptionLen\n nLeft := nRight - nCaptionLen\n ENDIF\n\n item:__row := nRow\n item:__col := nLeft\n\n IF item:isPopUp()\n oPopUp := item:data\n oPopUp:top := nRow + 1\n oPopUp:left := nLeft\n oPopUp:bottom := NIL\n oPopUp:right := NIL\n ENDIF\n\n IF ( nPos := At( \"&\", cCaption ) ) > 0\n IF nPos == Len( cCaption )\n nPos := 0\n ELSE\n cCaption := Stuff( cCaption, nPos, 1, \"\" )\n nCaptionLen--\n ENDIF\n ENDIF\n\n hb_DispOutAt( nRow, nLeft, cCaption, ;\n iif( item:__enumIndex() == nCurrent, cColor2, ;\n iif( item:enabled, cColor1, hb_ColorIndex( ::cColorSpec, 4 ) ) ) )\n\n IF item:enabled .AND. nPos > 0\n hb_DispOutAt( nRow, nLeft + nPos - 1, SubStr( cCaption, nPos, 1 ), ;\n iif( item:__enumIndex() == nCurrent, hb_ColorIndex( ::cColorSpec, 3 ), hb_ColorIndex( ::cColorSpec, 2 ) ) )\n ENDIF\n\n nLeft += nCaptionLen\n NEXT\n\n IF nCurrent != 0 .AND. ;\n ::aItems[ nCurrent ]:isPopUp() .AND. ;\n ::aItems[ nCurrent ]:data:isOpen\n\n ::aItems[ nCurrent ]:data:display()\n ENDIF\n\n DispEnd()\n\n RETURN Self\n\nMETHOD getFirst() CLASS TopBarMenu\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 TopBarMenu\n RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ], NIL )\n\nMETHOD getLast() CLASS TopBarMenu\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 TopBarMenu\n\n LOCAL n\n\n FOR n := ::nCurrent + 1 TO ::nItemCount\n IF ::aItems[ n ]:enabled\n RETURN n\n ENDIF\n NEXT\n\n RETURN 0\n\nMETHOD getPrev() CLASS TopBarMenu\n\n LOCAL n\n\n FOR n := ::nCurrent - 1 TO 1 STEP -1\n IF ::aItems[ n ]:enabled\n RETURN n\n ENDIF\n NEXT\n\n RETURN 0\n\n\nMETHOD getAccel( nKey ) CLASS TopBarMenu\n\n LOCAL nIndex := AScan( { ;\n K_ALT_A, K_ALT_B, K_ALT_C, K_ALT_D, K_ALT_E, K_ALT_F, ;\n K_ALT_G, K_ALT_H, K_ALT_I, K_ALT_J, K_ALT_K, K_ALT_L, ;\n K_ALT_M, K_ALT_N, K_ALT_O, K_ALT_P, K_ALT_Q, K_ALT_R, ;\n K_ALT_S, K_ALT_T, K_ALT_U, K_ALT_V, K_ALT_W, K_ALT_X, ;\n K_ALT_Y, K_ALT_Z, K_ALT_1, K_ALT_2, K_ALT_3, K_ALT_4, ;\n K_ALT_5, K_ALT_6, K_ALT_7, K_ALT_8, K_ALT_9, K_ALT_0 }, nKey )\n\n LOCAL cKey\n LOCAL item\n\n IF nIndex > 0\n cKey := \"&\" + SubStr( \"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\", nIndex, 1 )\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 getShortCt( nKey ) CLASS TopBarMenu\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 TopBarMenu\n\n LOCAL nColumn\n LOCAL item\n\n IF nMRow == ::nRow\n\n FOR EACH item IN ::aItems\n\n nColumn := item:__col\n\n IF nMCol >= nColumn .AND. nMCol <= nColumn + Len( item:caption )\n RETURN item:__enumIndex()\n ENDIF\n NEXT\n ENDIF\n\n RETURN HTNOWHERE\n\nMETHOD insItem( nPos, oItem ) CLASS TopBarMenu\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 select( nPos ) CLASS TopBarMenu\n\n IF ( nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;\n ::nCurrent != nPos .AND. ;\n ::aItems[ nPos ]:enabled ) .OR. nPos == 0\n\n\n ::nCurrent := nPos\n ENDIF\n\n RETURN Self\n\nMETHOD setItem( nPos, oItem ) CLASS TopBarMenu\n\n IF nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;\n HB_ISOBJECT( oItem ) .AND. oItem:ClassName() == \"MENUITEM\"\n\n ::aItems[ nPos ] := oItem\n\n ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )\n ENDIF\n\n RETURN Self\n\nMETHOD colorSpec( cColorSpec ) CLASS TopBarMenu\n\n IF cColorSpec != NIL\n ::cColorSpec := __eInstVar53( Self, \"COLORSPEC\", cColorSpec, \"C\", 1001, ;\n {|| ! Empty( hb_ColorIndex( cColorSpec, 5 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 6 ) ) } )\n ENDIF\n\n RETURN ::cColorSpec\n\nMETHOD current() CLASS TopBarMenu\n RETURN ::nCurrent\n\nMETHOD itemCount() CLASS TopBarMenu\n RETURN ::nItemCount\n\nMETHOD left( nLeft ) CLASS TopBarMenu\n\n IF nLeft != NIL\n ::nLeft := __eInstVar53( Self, \"LEFT\", nLeft, \"N\", 1001 )\n ENDIF\n\n RETURN ::nLeft\n\nMETHOD right( nRight ) CLASS TopBarMenu\n\n IF nRight != NIL\n ::nRight := __eInstVar53( Self, \"RIGHT\", nRight, \"N\", 1001 )\n ENDIF\n\n RETURN ::nRight\n\nMETHOD row( nRow ) CLASS TopBarMenu\n\n IF nRow != NIL\n \n ::nRow := __eInstVar53( Self, \"ROW\", nRow, \"N\", 1001 )\n ENDIF\n\n RETURN ::nRow\n\n\nMETHOD Init( nRow, nLeft, nRight ) CLASS TopBarMenu\n\n LOCAL cColor\n\n IF ! HB_ISNUMERIC( nRow ) .OR. ;\n ! HB_ISNUMERIC( nLeft ) .OR. ;\n ! HB_ISNUMERIC( nRight )\n RETURN NIL\n ENDIF\n\n ::nLeft := nLeft\n ::nRight := nRight\n ::nRow := nRow\n\n IF IsDefColor()\n ::cColorSpec := \"N/W,W/N,W+/W,W+/N,N+/W,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_BACKGROUND ) + \",\" + ;\n hb_ColorIndex( cColor, CLR_ENHANCED ) + \",\" + ;\n hb_ColorIndex( cColor, CLR_STANDARD ) + \",\" + ;"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/perfuncs.prg. Provides functions: hb_SetObject, hb_EndObject. This file provides utility functions"}, {"role": "assistant", "content": "THREAD STATIC t_aObjects\n\nFUNCTION hb_SetObject( oSelf, bConstructor )\n\n IF t_aObjects == NIL\n t_aObjects := {}\n AAdd( t_aObjects, oSelf )\n ELSE\n AAdd( t_aObjects, oSelf := Eval( bConstructor ) )\n ENDIF\n\n RETURN oSelf\n\nFUNCTION hb_EndObject()\n\n LOCAL oSelf\n\n IF Len( t_aObjects ) > 1\n ASize( t_aObjects, Len( t_aObjects ) - 1 )\n oSelf := ATail( t_aObjects )\n ELSE\n oSelf := t_aObjects[ 1 ]\n t_aObjects := NIL\n ENDIF\n\n RETURN oSelf"}]} | |
| {"messages": [{"role": "system", "content": "You are an expert Harbour (xBase/Clipper) programmer. Write clean, efficient code following 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/floptst.prg. Contains procedures: Main. This file provides legacy compatibility functions"}, {"role": "assistant", "content": "#require \"hbnf\"\n\nPROCEDURE Main( cArg1 )\n\n LOCAL nErrCode\n\n IF HB_ISSTRING( cArg1 )\n nErrCode := ft_FlopTst( Asc( Upper( cArg1 ) ) - Asc( \"A\" ) )\n ? \"Return Code is \" + hb_ntos( nErrCode )\n ELSE\n ? \"Usage: floptst cDrive\" + hb_eol() + \" where cDrive is 'A' or 'B' etc...\"\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 test program: tests/clsicast.prg. Defines classes: myclass1, myclass2, myclass3, myclass4. This test file tests specific function APIs"}, {"role": "assistant", "content": "#xtranslate QQOUT([<x,...>]) => [OUTSTD(<x>)]\n#xtranslate QOUT([<x,...>]) => OUTSTD(hb_eol())[;OUTSTD(<x>)]\n\n#include \"hbclass.ch\"\n\nproc main()\nlocal o:=myclass4():new(), i, cbErr\n\n? DATE(), TIME(), VERSION(), OS()\n?\n\n\n? \"instance variables [\"+ltrim(str(len(o)))+\"]:\"; ?\nfor i:=1 to len(o); ?? \"\",o[i]; next\n? \" => shoule be [12]:\"\n? \" (x1) (y1) (z1) (x2) (y2) (z2) (x3) (y3) (z3) (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? \"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? \"instance variables [\"+ltrim(str(len(o)))+\"]:\"; ?\nfor i:=1 to len(o); ?? \"\",o[i]; next\n? \" => shoule be [12]:\"\n? \" X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 X4 Y4 Z4\"\n?\n\n? \"Setting MYCLASS1 instance variables...\"\no:myclass1:x1:=\"[X1]\"\no:myclass1:y1:=\"[Y1]\"\no:myclass1:z1:=\"[Z1]\"\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 instance variables...\"\no:myclass2:x2:=\"[X2]\"\no:myclass2:y2:=\"[Y2]\"\no:myclass2:z2:=\"[Z2]\"\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 instance variables...\"\no:myclass3:x3:=\"[X3]\"\no:myclass3:y3:=\"[Y3]\"\no:myclass3:z3:=\"[Z3]\"\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\ncbErr := errorBlock( {| oErr | break( oErr ) } )\nbegin sequence\n ? \"Setting MYCLASS4 instance variables...\"\n o:myclass4:x4:=\"[X4]\"\n o:myclass4:y4:=\"[Y4]\"\n o:myclass4:z4:=\"[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:MYCLASS1 instance variables...\"\no:myclass3:myclass1:x1:=\"<X1>\"\no:myclass3:myclass1:y1:=\"<Y1>\"\no:myclass3:myclass1:z1:=\"<Z1>\"\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:MYCLASS2 instance variables...\"\no:myclass3:myclass2:x2:=\"<X2>\"\no:myclass3:myclass2:y2:=\"<Y2>\"\no:myclass3:myclass2:z2:=\"<Z2>\"\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 SUPER instance variables...\"\no:super:x1:=\"{X1}\"\no:super:y1:=\"{Y1}\"\no:super:z1:=\"{Z1}\"\no:super:x2:=\"{X2}\"\no:super:y2:=\"{Y2}\"\no:super:z2:=\"{Z2}\"\no:super:x3:=\"{X3}\"\no:super:y3:=\"{Y3}\"\no:super:z3:=\"{Z3}\"\n\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? \"instance variables [\"+ltrim(str(len(o)))+\"]:\"; ?\nfor i:=1 to len(o); ?? \"\",o[i]; next\n? \" => shoule be [12]:\"\n? \" {X1} {Y1} {Z1} {X2} {Y2} {Z2} {X3} {Y3} {Z3} [X4] [Y4] [Z4]\"\n?\n\nreturn\n\n\ncreate class myclass1\nexport:\n var x1 init \"(x1)\"\n var y1 init \"(y1)\"\n var z1 init \"(z1)\"\nendclass\n\ncreate class myclass2 from myclass1\nexport:\n var x2 init \"(x2)\"\n var y2 init \"(y2)\"\n var z2 init \"(z2)\"\nendclass\n\ncreate class myclass3 from myclass1, myclass2\nexport:\n var x3 init \"(x3)\"\n var y3 init \"(y3)\"\n var z3 init \"(z3)\"\nendclass\n\ncreate class myclass4 from myclass3, myclass2\nexport:\n var x4 init \"(x4)\"\n var y4 init \"(y4)\"\n var z4 init \"(z4)\"\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 this Harbour module: Harbour test program: tests/passref.prg. Provides functions: testfun. Contains procedures: Main. This test file tests specific function APIs"}, {"role": "assistant", "content": "PROCEDURE Main()\n\n LOCAL a := 10\n LOCAL b := \"X\"\n\n ? 'a := 10', a\n ? 'b := \"X\"', b\n\n testfun( @a, @b )\n ? 'return of \"a\" should = 20', a, iif( a == 20, \"worked\", \"failed\" )\n ? 'return of \"b\" should = A', b, iif( b == \"A\", \"worked\", \"failed\" )\n\n RETURN\n\nFUNCTION testfun( b, c )\n\n b := b + 10\n c := \"A\"\n ? 'a pointer + 10 =', b\n ? 'b pointer := \"A\" =', c\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 'hbct' (CA-Tools compatibility library): contrib/hbct/tests/tokenlow.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 TokenLower()\"\n ?\n\n ? \" Simple tests:\"\n ? ' TokenLower( \"Hello, World, here I am!\" ) == \"hello, world, here i am!\" ?'\n ? ' -> \"' + TokenLower( \"Hello, World, here I am!\" ) + '\"'\n ? ' TokenLower( \"Hello, World, here I am!\",, 3 ) == \"hello, world, here I am!\" ?'\n ? ' -> \"' + TokenLower( \"Hello, World, here I am!\",, 3 ) + '\"'\n ? ' TokenLower( \"Hello, World, here I am!\", \",\", 3 ) == \"hello, World, here I am!\" ?'\n ? ' -> \"' + TokenLower( \"Hello, World, here I am!\", \",\", 3 ) + '\"'\n ? ' TokenLower( \"Hello, World, here I am!\", \" W\" ) == \"hello, World, here i am!\" ?'\n ? ' -> \"' + TokenLower( \"Hello, World, here I am!\", \" W\" ) + '\"'\n ?\n\n ? ' Lowercase the tokens in the string \"' + cStr + '\"'\n ? ' with CSetRef( .T. ) and \"@\"'\n CSetRef( .T. )\n ?\n ? ' --> return value of TokenLower( @cStr ): ', TokenLower( @cStr )\n ? ' --> cStr is now: \"' + cStr + '\"'\n\n ?\n ? \"End test of TokenLower()\"\n ?\n\n ctexit()\n\n RETURN"}]} | |