Wednesday, June 11, 2025

Examples compiled with Harbour + HBUtil

hb32\contrib\hbutil. To compile:

hbmk2 test1.prg hbutil.hbc

1 - Variable declaration and automatic initialization

LOCAL | STATIC | PUBLIC | PRIVATE <var, ...> AS <TYPE>

// Extended commands (override) 

// Declare and initialize variables
LOCAL nPos(1), nSize AS INTEGER
LOCAL nPrice, nTotal(3) AS MONEY // nPrice:=0.00, nTotal:=0.000
LOCAL tDat1, tToday(), tDat3 AS TIMESTAMP
LOCAL dDat1, dToday(), dDat3 AS DATE // dDat1:=CTOD(''), dToday:=DATE()
LOCAL lStart, lEnd AS LOGICAL
LOCAL hItem AS HASH
LOCAL aTypes[3], aItems AS ARRAY
// Harbour native (just declare variables)
LOCAL oBrw AS CLASS TBROWSE
LOCAL oCol, oGet, oPrn AS OBJECT
LOCAL bInit, bAction AS BLOCK

CLS

? '    LOGICAL', lStart, lEnd    // .F. .F. 
? 'INTEGER (N)', nPos, nSize     // 0          0
? '  MONEY (N)', nPrice, nTotal  //          0.00          0.000
? '  TIMESTAMP', tDat1           //   /  /   00:00:00.000
? '           ', tToday          // 06/18/25 14:38:09.398
? '           ', tDat3           //   /  /   00:00:00.000
? '       DATE', dDat1, dDat3    //   /  /     /  /  
? '           ', dToday          // 06/18/25
? oBrw, oCol, bInit              // NIL NIL NIL

// HBUtil: Extended commands 
PRIVATE dVar1, dVar2() AS DATE
? 'PRIVATE', dVar1, dVar2        //   /  /   06/18/25

2 - VALIDATE PARAMETERS: FUNCTION | METHOD

Tuesday, June 10, 2025

new and extended commands for Harbour

5 implementation suggestions

(I implemented the first 4)

1 - Declaration & initialization. Syntax:  

LOCAL | STATIC | PUBLIC | PRIVATE <var, ...> AS <TYPE>

// <TYPE> = ARRAY, CHARACTER, DATE, HASH, LOGICAL, MEMO, NUMERIC, TIMESTAMP
// artificial: CHAR, INTEGER, DECIMAL, MONEY

features:

  • declare and initialize variables with empty value
    • DATE/TIMESTAMP allow to initialize with current date/datetime
  • some types accept arguments in variable
    • for types derived from NUMERIC, it will format the value, but is not useful at runtime
  • CHAR, INTEGER, DECIMAL, MONEY are artificial types for types C, N, N, N
  • Other AS <TYPE> are not overridden by HBUtil:
    • AS OBJECT
    • AS BLOCK
    • AS POINTER
    • AS CLASS <TName> ...

 2 - Runtime parameter validation (functions and methods) . Syntax:

DBU for Windows 32/64 bits (+small features) and other alternatives

Em Windows você tem múltiplas opções para gerenciar arquivos DBF: