[Runtime] Added more possible type combinations for Max()

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

///
/// Determine if a value is between two other values.
///
/// <param name="x">Value which should be compared.</param>
/// <param name="y">Lower value to compare against.</param>
/// <param name="z">Upper value to compare against.</param>
/// <returns>
/// True if x is >= y and <= z otherwise false.
/// </returns>
FUNCTION Between(val AS USUAL,min AS USUAL,max AS USUAL) AS LOGIC
	RETURN val >=min .AND.  val<=max

///
/// Indicate whether the first expression in a series is repeated later in the series.
///
/// <param name="u"></param>
/// <returns>
/// </returns>
FUNCTION InList(u AS USUAL, args PARAMS USUAL[]) AS LOGIC
	RETURN _InListWorker(u, args, FALSE)
///
/// Indicate whether the first expression in a series is repeated in the exact same form later in the series.
///
/// <param name="u"></param>
/// <returns>
/// </returns>
FUNCTION InListExact(u AS USUAL, args PARAMS USUAL[]) AS LOGIC
	RETURN _InListWorker(u, args, TRUE)

INTERNAL FUNCTION _InListWorker( u AS USUAL, args AS CONST USUAL[], lExact AS LOGIC) AS LOGIC
	LOCAL i, nLen AS INT
	nLen := args:Length
	IF lExact
		FOR i := 1 TO nLen
			IF args[i] == u
				RETURN TRUE
			ENDIF
		NEXT
	ELSE
		FOR i := 1 TO nLen
			IF u = args[i]
				RETURN TRUE
			ENDIF
		NEXT
	ENDIF
	RETURN FALSE

///
/// Return the larger of 2 values.
///
/// <param name="u1"></param>
/// <param name="u2"></param>
/// <returns>
/// </returns>
FUNCTION Max(u1 AS USUAL,u2 AS USUAL) AS USUAL

	IF u1:IsNumeric .AND. u2:IsNumeric

		IF u1:IsFloat .OR. u2:IsFloat
			RETURN (USUAL) Math.Max( (REAL8) u1, (REAL8) u2)

		ELSEIF u1:IsDecimal .OR. u2:IsDecimal
			RETURN (USUAL) Math.Max( (Decimal) u1, (Decimal) u2)

		ELSEIF u1:IsInt64 .OR. u2:IsInt64
			RETURN (USUAL) Math.Max( (INT64) u1, (INT64) u2)
		ENDIF
		RETURN (USUAL) Math.Max( (LONG) u1, (LONG) u2)

	ELSEIF u1:IsDate .AND. u2:IsDate
		RETURN IIF ((DATE) u1 > (DATE) u2, u1, u2)

	ELSEIF u1:IsDateTime .AND. u2:IsDateTime
		RETURN IIF ((DateTime) u1 > (DateTime) u2, u1, u2)

	ELSEIF (u1:IsDateTime .or. u1:IsDate) .AND. (u2:IsDateTime .or. u2:IsDate)
		RETURN IIF ((DateTime) u1 > (DateTime) u2, u1, u2)

	ELSEIF u1:IsString .AND. u2:IsString
		RETURN IIF ((STRING) u1 > (STRING) u2, u1, u2)

	ELSEIF u1:IsSymbol .AND. u2:IsSymbol
		RETURN IIF ((SYMBOL) u1 > (SYMBOL) u2, u1, u2)

	ELSE
        THROW Error.ArgumentError( __FUNCTION__, NAMEOF(u2) , "Incompatible types")
	ENDIF

///
/// Return the smaller of 2 values.
///
/// <param name="u1"></param>
/// <param name="u2"></param>
/// <returns>
/// </returns>
FUNCTION Min(u1 AS USUAL,u2 AS USUAL) AS USUAL
	IF u1:IsNumeric .AND. u2:IsNumeric

		IF u1:IsFloat .OR. u2:IsFloat

			RETURN (USUAL) Math.Min((REAL8) u1, (REAL8) u2)

		ELSEIF u1:IsDecimal .OR. u2:IsDecimal
			RETURN (USUAL) Math.Min( (Decimal) u1, (Decimal) u2)

		ELSEIF u1:IsInt64 .OR. u2:IsInt64
			RETURN (USUAL) Math.Min( (INT64) u1, (INT64) u2)
		ENDIF
		RETURN (USUAL) Math.Min( (LONG) u1, (LONG) u2)

	ELSEIF u1:IsDate .AND. u2:IsDate
		RETURN IIF ((DATE) u1 <(DATE) u2, u1, u2)

	ELSEIF u1:IsString .AND. u2:IsString
		RETURN IIF ((STRING) u1 <(STRING) u2, u1, u2)
	ELSE
        THROW Error.ArgumentError( __FUNCTION__, NAMEOF(u2) , "Incompatible types")
	ENDIF

/// This function is not implemented yet
//
// Get a particular color from a user-defined palette.
//
/// <param name="bR"></param>
/// <param name="bG"></param>
/// <param name="bB"></param>
/// <returns>
/// </returns>
FUNCTION PaletteRGB(bR AS USUAL,bG AS USUAL,bB AS BYTE) AS INT
	THROW NotImplementedException{}

/// This function is not implemented yet
//
// Display a system modal dialog box to pause the current application.
//
/// <returns>
/// </returns>
FUNCTION Pause() AS DWORD
	THROW NotImplementedException{}

///
/// Install a system-wide object that receives all messages being sent to other data types.
///
/// <param name="o"></param>
/// <returns>
/// </returns>
[Obsolete];
FUNCTION SysObject(o AS USUAL) AS OBJECT
	RETURN NULL_OBJECT

///
/// Sound a speaker tone for a specified frequency and duration.
///
/// <param name="dwFreq"></param>
/// <param name="dwDur"></param>
/// <returns>
/// </returns>
FUNCTION Tone(dwFreq AS DWORD,dwDur AS DWORD) AS USUAL
	Console.Beep( (INT)dwFreq, (INT)dwDur * 1000 / 18 )
RETURN	 NIL

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

///
/// Determine if a value is between two other values.
///
/// <param name="x">Value which should be compared.</param>
/// <param name="y">Lower value to compare against.</param>
/// <param name="z">Upper value to compare against.</param>
/// <returns>
/// True if x is >= y and <= z otherwise false.
/// </returns>
FUNCTION Between(val AS USUAL,min AS USUAL,max AS USUAL) AS LOGIC
	RETURN val >=min .AND.  val<=max

///
/// Indicate whether the first expression in a series is repeated later in the series.
///
/// <param name="u"></param>
/// <returns>
/// </returns>
FUNCTION InList(u AS USUAL, args PARAMS USUAL[]) AS LOGIC
	RETURN _InListWorker(u, args, FALSE)
///
/// Indicate whether the first expression in a series is repeated in the exact same form later in the series.
///
/// <param name="u"></param>
/// <returns>
/// </returns>
FUNCTION InListExact(u AS USUAL, args PARAMS USUAL[]) AS LOGIC
	RETURN _InListWorker(u, args, TRUE)

INTERNAL FUNCTION _InListWorker( u AS USUAL, args AS CONST USUAL[], lExact AS LOGIC) AS LOGIC
	LOCAL i, nLen AS INT
	nLen := args:Length
	IF lExact
		FOR i := 1 TO nLen
			IF args[i] == u
				RETURN TRUE
			ENDIF
		NEXT
	ELSE
		FOR i := 1 TO nLen
			IF u = args[i]
				RETURN TRUE
			ENDIF
		NEXT
	ENDIF
	RETURN FALSE

///
/// Return the larger of 2 values.
///
/// <param name="u1"></param>
/// <param name="u2"></param>
/// <returns>
/// </returns>
FUNCTION Max(u1 AS USUAL,u2 AS USUAL) AS USUAL

	IF u1:IsNumeric .AND. u2:IsNumeric

		IF u1:IsFloat .OR. u2:IsFloat
			RETURN (USUAL) Math.Max( (REAL8) u1, (REAL8) u2)

		ELSEIF u1:IsDecimal .OR. u2:IsDecimal
			RETURN (USUAL) Math.Max( (Decimal) u1, (Decimal) u2)

		ELSEIF u1:IsInt64 .OR. u2:IsInt64
			RETURN (USUAL) Math.Max( (INT64) u1, (INT64) u2)
		ENDIF
		RETURN (USUAL) Math.Max( (LONG) u1, (LONG) u2)

	ELSEIF u1:IsDate .AND. u2:IsDate
		RETURN IIF ((DATE) u1 > (DATE) u2, u1, u2)

	ELSEIF u1:IsString .AND. u2:IsString
		RETURN IIF ((STRING) u1 > (STRING) u2, u1, u2)

	ELSE
        THROW Error.ArgumentError( __FUNCTION__, NAMEOF(u2) , "Incompatible types")
	ENDIF

///
/// Return the smaller of 2 values.
///
/// <param name="u1"></param>
/// <param name="u2"></param>
/// <returns>
/// </returns>
FUNCTION Min(u1 AS USUAL,u2 AS USUAL) AS USUAL
	IF u1:IsNumeric .AND. u2:IsNumeric

		IF u1:IsFloat .OR. u2:IsFloat

			RETURN (USUAL) Math.Min((REAL8) u1, (REAL8) u2)

		ELSEIF u1:IsDecimal .OR. u2:IsDecimal
			RETURN (USUAL) Math.Min( (Decimal) u1, (Decimal) u2)

		ELSEIF u1:IsInt64 .OR. u2:IsInt64
			RETURN (USUAL) Math.Min( (INT64) u1, (INT64) u2)
		ENDIF
		RETURN (USUAL) Math.Min( (LONG) u1, (LONG) u2)

	ELSEIF u1:IsDate .AND. u2:IsDate
		RETURN IIF ((DATE) u1 <(DATE) u2, u1, u2)

	ELSEIF u1:IsString .AND. u2:IsString
		RETURN IIF ((STRING) u1 <(STRING) u2, u1, u2)
	ELSE
        THROW Error.ArgumentError( __FUNCTION__, NAMEOF(u2) , "Incompatible types")
	ENDIF

/// This function is not implemented yet
//
// Get a particular color from a user-defined palette.
//
/// <param name="bR"></param>
/// <param name="bG"></param>
/// <param name="bB"></param>
/// <returns>
/// </returns>
FUNCTION PaletteRGB(bR AS USUAL,bG AS USUAL,bB AS BYTE) AS INT
	THROW NotImplementedException{}

/// This function is not implemented yet
//
// Display a system modal dialog box to pause the current application.
//
/// <returns>
/// </returns>
FUNCTION Pause() AS DWORD
	THROW NotImplementedException{}

///
/// Install a system-wide object that receives all messages being sent to other data types.
///
/// <param name="o"></param>
/// <returns>
/// </returns>
[Obsolete];
FUNCTION SysObject(o AS USUAL) AS OBJECT
	RETURN NULL_OBJECT

///
/// Sound a speaker tone for a specified frequency and duration.
///
/// <param name="dwFreq"></param>
/// <param name="dwDur"></param>
/// <returns>
/// </returns>
FUNCTION Tone(dwFreq AS DWORD,dwDur AS DWORD) AS USUAL
	Console.Beep( (INT)dwFreq, (INT)dwDur * 1000 / 18 )
RETURN	 NIL


QtWebKitWidgets: module updated (xHarbour compatibility)

Modified:
source/QtWebKitWidgets/QWebFrame.prg

/*

  Qt5xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 5

  Copyright (C) 2017 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

#include "hbclass.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QURL
REQUEST QSIZE
REQUEST QWEBELEMENT
REQUEST QWEBELEMENTCOLLECTION
REQUEST QRECT
REQUEST QWEBHITTESTRESULT
REQUEST QICON
REQUEST QWEBPAGE
REQUEST QPOINT
REQUEST QWEBSECURITYORIGIN
REQUEST QVARIANT
#endif

CLASS QWebFrame INHERIT QObject

   METHOD addToJavaScriptWindowObject
   METHOD baseUrl
   METHOD childFrames
   METHOD contentsSize
   METHOD documentElement
   METHOD findAllElements
   METHOD findFirstElement
   METHOD frameName
   METHOD geometry
   METHOD hasFocus
   METHOD hitTestContent
   METHOD icon
   METHOD load1
   METHOD load2
   METHOD load
   METHOD page
   METHOD parentFrame
   METHOD pos
   METHOD render1
   METHOD render2
   METHOD render3
   METHOD render
   METHOD requestedUrl
   METHOD scroll
   METHOD scrollBarGeometry
   METHOD scrollBarMaximum
   METHOD scrollBarMinimum
   METHOD scrollBarPolicy
   METHOD scrollBarValue
   METHOD scrollPosition
   METHOD scrollToAnchor
   METHOD securityOrigin
   METHOD setContent
   METHOD setFocus
   METHOD setHtml
   METHOD setScrollBarPolicy
   METHOD setScrollBarValue
   METHOD setScrollPosition
   METHOD setTextSizeMultiplier
   METHOD setUrl
   METHOD setZoomFactor
   METHOD textSizeMultiplier
   METHOD title
   METHOD toHtml
   METHOD toPlainText
   METHOD url
   METHOD zoomFactor
   METHOD evaluateJavaScript
   METHOD print

   METHOD onContentsSizeChanged
   METHOD onIconChanged
   METHOD onInitialLayoutCompleted
   METHOD onJavaScriptWindowObjectCleared
   METHOD onLoadFinished
   METHOD onLoadStarted
   METHOD onPageChanged
   METHOD onTitleChanged
   METHOD onUrlChanged

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QWebFrame
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#include <QWebFrame>
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_macros.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#include <QWebFrame>
#endif

#include <QWebElement>
#include <QWebSecurityOrigin>

//[1]void addToJavaScriptWindowObject ( const QString & name, QObject * object )
//[2]void addToJavaScriptWindowObject ( const QString & name, QObject * object, QScriptEngine::ValueOwnership own )

// TODO: implementar

HB_FUNC_STATIC( QWEBFRAME_ADDTOJAVASCRIPTWINDOWOBJECT )
{
//   if( ISNUMPAR(2) && ISCHAR(1) && ISOBJECT(2) )
//   {
//     HB_FUNC_EXEC( QWEBFRAME_ADDTOJAVASCRIPTWINDOWOBJECT1 );
//   }
//   else if( ISNUMPAR(3) && ISCHAR(1) && ISOBJECT(2) && ISNUM(3) )
//   {
//     HB_FUNC_EXEC( QWEBFRAME_ADDTOJAVASCRIPTWINDOWOBJECT2 );
//   }
}

/*
QUrl baseUrl () const
*/
HB_FUNC_STATIC( QWEBFRAME_BASEURL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * ptr = new QUrl( obj->baseUrl () );
    _qt5xhb_createReturnClass ( ptr, "QURL", true );
  }
}

/*
QList<QWebFrame *> childFrames () const
*/
HB_FUNC_STATIC( QWEBFRAME_CHILDFRAMES )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QList<QWebFrame *> list = obj->childFrames ();
    PHB_DYNS pDynSym;
    pDynSym = hb_dynsymFindName( "QWEBFRAME" );
    PHB_ITEM pArray;
    pArray = hb_itemArrayNew(0);
    int i;
    for(i=0;i<list.count();i++)
    {
      if( pDynSym )
      {
        #ifdef __XHARBOUR__
        hb_vmPushSymbol( pDynSym->pSymbol );
        #else
        hb_vmPushDynSym( pDynSym );
        #endif
        hb_vmPushNil();
        hb_vmDo( 0 );
        PHB_ITEM pObject = hb_itemNew( NULL );
        hb_itemCopy( pObject, hb_stackReturnItem() );
        PHB_ITEM pItem = hb_itemNew( NULL );
        hb_itemPutPtr( pItem, (QWebFrame *) list[i] );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
        hb_itemRelease( pItem );
      }
    }
    hb_itemReturnRelease(pArray);
  }
}

/*
QSize contentsSize () const
*/
HB_FUNC_STATIC( QWEBFRAME_CONTENTSSIZE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSize * ptr = new QSize( obj->contentsSize () );
    _qt5xhb_createReturnClass ( ptr, "QSIZE", true );
  }
}

/*
QWebElement documentElement () const
*/
HB_FUNC_STATIC( QWEBFRAME_DOCUMENTELEMENT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebElement * ptr = new QWebElement( obj->documentElement () );
    _qt5xhb_createReturnClass ( ptr, "QWEBELEMENT", true );
  }
}

/*
QWebElementCollection findAllElements ( const QString & selectorQuery ) const
*/
HB_FUNC_STATIC( QWEBFRAME_FINDALLELEMENTS )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebElementCollection * ptr = new QWebElementCollection( obj->findAllElements ( PQSTRING(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QWEBELEMENTCOLLECTION", true );
  }
}

/*
QWebElement findFirstElement ( const QString & selectorQuery ) const
*/
HB_FUNC_STATIC( QWEBFRAME_FINDFIRSTELEMENT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebElement * ptr = new QWebElement( obj->findFirstElement ( PQSTRING(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QWEBELEMENT", true );
  }
}

/*
QString frameName () const
*/
HB_FUNC_STATIC( QWEBFRAME_FRAMENAME )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->frameName () );
  }
}

/*
QRect geometry () const
*/
HB_FUNC_STATIC( QWEBFRAME_GEOMETRY )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QRect * ptr = new QRect( obj->geometry () );
    _qt5xhb_createReturnClass ( ptr, "QRECT", true );
  }
}

/*
bool hasFocus () const
*/
HB_FUNC_STATIC( QWEBFRAME_HASFOCUS )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->hasFocus () );
  }
}

/*
QWebHitTestResult hitTestContent ( const QPoint & pos ) const
*/
HB_FUNC_STATIC( QWEBFRAME_HITTESTCONTENT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebHitTestResult * ptr = new QWebHitTestResult( obj->hitTestContent ( *PQPOINT(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QWEBHITTESTRESULT", true );
  }
}

/*
QIcon icon () const
*/
HB_FUNC_STATIC( QWEBFRAME_ICON )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QIcon * ptr = new QIcon( obj->icon () );
    _qt5xhb_createReturnClass ( ptr, "QICON", true );
  }
}

/*
void load ( const QUrl & url )
*/
HB_FUNC_STATIC( QWEBFRAME_LOAD1 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->load ( *PQURL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void load ( const QNetworkRequest & req, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray & body = QByteArray() )
*/
HB_FUNC_STATIC( QWEBFRAME_LOAD2 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par2 = ISNIL(2)? (int) QNetworkAccessManager::GetOperation : hb_parni(2);
    QByteArray par3 = ISNIL(3)? QByteArray() : *(QByteArray *) _qt5xhb_itemGetPtr(3);
    obj->load ( *PQNETWORKREQUEST(1), (QNetworkAccessManager::Operation) par2, par3 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void load ( const QUrl & url )
//[2]void load ( const QNetworkRequest & req, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray & body = QByteArray() )

HB_FUNC_STATIC( QWEBFRAME_LOAD )
{
  if( ISNUMPAR(1) && ISQURL(1) )
  {
    HB_FUNC_EXEC( QWEBFRAME_LOAD1 );
  }
  else if( ISBETWEEN(1,3) && ISQNETWORKREQUEST(1) && ISOPTNUM(2) && ISOPTQBYTEARRAY(3) )
  {
    HB_FUNC_EXEC( QWEBFRAME_LOAD2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
QWebPage * page () const
*/
HB_FUNC_STATIC( QWEBFRAME_PAGE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebPage * ptr = obj->page ();
    _qt5xhb_createReturnClass ( ptr, "QWEBPAGE" );
  }
}

/*
QWebFrame * parentFrame () const
*/
HB_FUNC_STATIC( QWEBFRAME_PARENTFRAME )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebFrame * ptr = obj->parentFrame ();
    _qt5xhb_createReturnClass ( ptr, "QWEBFRAME" );
  }
}

/*
QPoint pos () const
*/
HB_FUNC_STATIC( QWEBFRAME_POS )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QPoint * ptr = new QPoint( obj->pos () );
    _qt5xhb_createReturnClass ( ptr, "QPOINT", true );
  }
}

/*
void render ( QPainter * painter )
*/
HB_FUNC_STATIC( QWEBFRAME_RENDER1 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->render ( PQPAINTER(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void render ( QPainter * painter, const QRegion & clip )
*/
HB_FUNC_STATIC( QWEBFRAME_RENDER2 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->render ( PQPAINTER(1), *PQREGION(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void render ( QPainter * painter, RenderLayer layer, const QRegion & clip = QRegion() )
*/
HB_FUNC_STATIC( QWEBFRAME_RENDER3 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QRegion par3 = ISNIL(3)? QRegion() : *(QRegion *) _qt5xhb_itemGetPtr(3);
    obj->render ( PQPAINTER(1), (QWebFrame::RenderLayer) hb_parni(2), par3 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void render ( QPainter * painter )
//[2]void render ( QPainter * painter, const QRegion & clip )
//[3]void render ( QPainter * painter, RenderLayer layer, const QRegion & clip = QRegion() )

HB_FUNC_STATIC( QWEBFRAME_RENDER )
{
  if( ISNUMPAR(1) && ISQPAINTER(1) )
  {
    HB_FUNC_EXEC( QWEBFRAME_RENDER1 );
  }
  else if( ISNUMPAR(2) && ISQPAINTER(1) && ISQREGION(2) )
  {
    HB_FUNC_EXEC( QWEBFRAME_RENDER2 );
  }
  else if( ISBETWEEN(2,3) && ISQPAINTER(1) && ISNUM(2) && (ISQREGION(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QWEBFRAME_RENDER3 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
QUrl requestedUrl () const
*/
HB_FUNC_STATIC( QWEBFRAME_REQUESTEDURL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * ptr = new QUrl( obj->requestedUrl () );
    _qt5xhb_createReturnClass ( ptr, "QURL", true );
  }
}

/*
void scroll ( int dx, int dy )
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->scroll ( PINT(1), PINT(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QRect scrollBarGeometry ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARGEOMETRY )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QRect * ptr = new QRect( obj->scrollBarGeometry ( (Qt::Orientation) hb_parni(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QRECT", true );
  }
}

/*
int scrollBarMaximum ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARMAXIMUM )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RINT( obj->scrollBarMaximum ( (Qt::Orientation) hb_parni(1) ) );
  }
}

/*
int scrollBarMinimum ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARMINIMUM )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RINT( obj->scrollBarMinimum ( (Qt::Orientation) hb_parni(1) ) );
  }
}

/*
Qt::ScrollBarPolicy scrollBarPolicy ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARPOLICY )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->scrollBarPolicy ( (Qt::Orientation) hb_parni(1) ) );
  }
}

/*
int scrollBarValue ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARVALUE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RINT( obj->scrollBarValue ( (Qt::Orientation) hb_parni(1) ) );
  }
}

/*
QPoint scrollPosition () const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLPOSITION )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QPoint * ptr = new QPoint( obj->scrollPosition () );
    _qt5xhb_createReturnClass ( ptr, "QPOINT", true );
  }
}

/*
void scrollToAnchor ( const QString & anchor )
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLTOANCHOR )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->scrollToAnchor ( PQSTRING(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QWebSecurityOrigin securityOrigin () const
*/
HB_FUNC_STATIC( QWEBFRAME_SECURITYORIGIN )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebSecurityOrigin * ptr = new QWebSecurityOrigin( obj->securityOrigin () );
    _qt5xhb_createReturnClass ( ptr, "QWEBSECURITYORIGIN", true );
  }
}

/*
void setContent ( const QByteArray & data, const QString & mimeType = QString(), const QUrl & baseUrl = QUrl() )
*/
HB_FUNC_STATIC( QWEBFRAME_SETCONTENT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl par3 = ISNIL(3)? QUrl() : *(QUrl *) _qt5xhb_itemGetPtr(3);
    obj->setContent ( *PQBYTEARRAY(1), OPQSTRING(2,QString()), par3 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setFocus ()
*/
HB_FUNC_STATIC( QWEBFRAME_SETFOCUS )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setFocus ();
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setHtml ( const QString & html, const QUrl & baseUrl = QUrl() )
*/
HB_FUNC_STATIC( QWEBFRAME_SETHTML )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl par2 = ISNIL(2)? QUrl() : *(QUrl *) _qt5xhb_itemGetPtr(2);
    obj->setHtml ( PQSTRING(1), par2 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setScrollBarPolicy ( Qt::Orientation orientation, Qt::ScrollBarPolicy policy )
*/
HB_FUNC_STATIC( QWEBFRAME_SETSCROLLBARPOLICY )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setScrollBarPolicy ( (Qt::Orientation) hb_parni(1), (Qt::ScrollBarPolicy) hb_parni(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setScrollBarValue ( Qt::Orientation orientation, int value )
*/
HB_FUNC_STATIC( QWEBFRAME_SETSCROLLBARVALUE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setScrollBarValue ( (Qt::Orientation) hb_parni(1), PINT(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setScrollPosition ( const QPoint & pos )
*/
HB_FUNC_STATIC( QWEBFRAME_SETSCROLLPOSITION )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setScrollPosition ( *PQPOINT(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setTextSizeMultiplier ( qreal factor )
*/
HB_FUNC_STATIC( QWEBFRAME_SETTEXTSIZEMULTIPLIER )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setTextSizeMultiplier ( PQREAL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setUrl ( const QUrl & url )
*/
HB_FUNC_STATIC( QWEBFRAME_SETURL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setUrl ( *PQURL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setZoomFactor ( qreal factor )
*/
HB_FUNC_STATIC( QWEBFRAME_SETZOOMFACTOR )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setZoomFactor ( PQREAL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
qreal textSizeMultiplier () const
*/
HB_FUNC_STATIC( QWEBFRAME_TEXTSIZEMULTIPLIER )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQREAL( obj->textSizeMultiplier () );
  }
}

/*
QString title () const
*/
HB_FUNC_STATIC( QWEBFRAME_TITLE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->title () );
  }
}

/*
QString toHtml () const
*/
HB_FUNC_STATIC( QWEBFRAME_TOHTML )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->toHtml () );
  }
}

/*
QString toPlainText () const
*/
HB_FUNC_STATIC( QWEBFRAME_TOPLAINTEXT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->toPlainText () );
  }
}

/*
QUrl url () const
*/
HB_FUNC_STATIC( QWEBFRAME_URL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * ptr = new QUrl( obj->url () );
    _qt5xhb_createReturnClass ( ptr, "QURL", true );
  }
}

/*
qreal zoomFactor () const
*/
HB_FUNC_STATIC( QWEBFRAME_ZOOMFACTOR )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQREAL( obj->zoomFactor () );
  }
}

/*
QVariant evaluateJavaScript ( const QString & scriptSource )
*/
HB_FUNC_STATIC( QWEBFRAME_EVALUATEJAVASCRIPT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QVariant * ptr = new QVariant( obj->evaluateJavaScript ( PQSTRING(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QVARIANT", true );
  }
}

/*
void print ( QPrinter * printer ) const
*/
HB_FUNC_STATIC( QWEBFRAME_PRINT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->print ( PQPRINTER(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

#pragma ENDDUMP

/*

  Qt5xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 5

  Copyright (C) 2017 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

#include "hbclass.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QURL
REQUEST QSIZE
REQUEST QWEBELEMENT
REQUEST QWEBELEMENTCOLLECTION
REQUEST QRECT
REQUEST QWEBHITTESTRESULT
REQUEST QICON
REQUEST QWEBPAGE
REQUEST QPOINT
REQUEST QWEBSECURITYORIGIN
REQUEST QVARIANT
#endif

CLASS QWebFrame INHERIT QObject

   METHOD addToJavaScriptWindowObject
   METHOD baseUrl
   METHOD childFrames
   METHOD contentsSize
   METHOD documentElement
   METHOD findAllElements
   METHOD findFirstElement
   METHOD frameName
   METHOD geometry
   METHOD hasFocus
   METHOD hitTestContent
   METHOD icon
   METHOD load1
   METHOD load2
   METHOD load
   METHOD page
   METHOD parentFrame
   METHOD pos
   METHOD render1
   METHOD render2
   METHOD render3
   METHOD render
   METHOD requestedUrl
   METHOD scroll
   METHOD scrollBarGeometry
   METHOD scrollBarMaximum
   METHOD scrollBarMinimum
   METHOD scrollBarPolicy
   METHOD scrollBarValue
   METHOD scrollPosition
   METHOD scrollToAnchor
   METHOD securityOrigin
   METHOD setContent
   METHOD setFocus
   METHOD setHtml
   METHOD setScrollBarPolicy
   METHOD setScrollBarValue
   METHOD setScrollPosition
   METHOD setTextSizeMultiplier
   METHOD setUrl
   METHOD setZoomFactor
   METHOD textSizeMultiplier
   METHOD title
   METHOD toHtml
   METHOD toPlainText
   METHOD url
   METHOD zoomFactor
   METHOD evaluateJavaScript
   METHOD print

   METHOD onContentsSizeChanged
   METHOD onIconChanged
   METHOD onInitialLayoutCompleted
   METHOD onJavaScriptWindowObjectCleared
   METHOD onLoadFinished
   METHOD onLoadStarted
   METHOD onPageChanged
   METHOD onTitleChanged
   METHOD onUrlChanged

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QWebFrame
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#include <QWebFrame>
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_macros.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#include <QWebFrame>
#endif

#include <QWebElement>
#include <QWebSecurityOrigin>

//[1]void addToJavaScriptWindowObject ( const QString & name, QObject * object )
//[2]void addToJavaScriptWindowObject ( const QString & name, QObject * object, QScriptEngine::ValueOwnership own )

// TODO: implementar

HB_FUNC_STATIC( QWEBFRAME_ADDTOJAVASCRIPTWINDOWOBJECT )
{
//   if( ISNUMPAR(2) && ISCHAR(1) && ISOBJECT(2) )
//   {
//     HB_FUNC_EXEC( QWEBFRAME_ADDTOJAVASCRIPTWINDOWOBJECT1 );
//   }
//   else if( ISNUMPAR(3) && ISCHAR(1) && ISOBJECT(2) && ISNUM(3) )
//   {
//     HB_FUNC_EXEC( QWEBFRAME_ADDTOJAVASCRIPTWINDOWOBJECT2 );
//   }
}

/*
QUrl baseUrl () const
*/
HB_FUNC_STATIC( QWEBFRAME_BASEURL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * ptr = new QUrl( obj->baseUrl () );
    _qt5xhb_createReturnClass ( ptr, "QURL", true );
  }
}

/*
QList<QWebFrame *> childFrames () const
*/
HB_FUNC_STATIC( QWEBFRAME_CHILDFRAMES )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QList<QWebFrame *> list = obj->childFrames ();
    PHB_DYNS pDynSym;
    #ifdef __XHARBOUR__
    pDynSym = hb_dynsymFind( "QWEBFRAME" );
    #else
    pDynSym = hb_dynsymFindName( "QWEBFRAME" );
    #endif
    PHB_ITEM pArray;
    pArray = hb_itemArrayNew(0);
    int i;
    for(i=0;i<list.count();i++)
    {
      if( pDynSym )
      {
        #ifdef __XHARBOUR__
        hb_vmPushSymbol( pDynSym->pSymbol );
        #else
        hb_vmPushDynSym( pDynSym );
        #endif
        hb_vmPushNil();
        hb_vmDo( 0 );
        PHB_ITEM pObject = hb_itemNew( NULL );
        hb_itemCopy( pObject, hb_stackReturnItem() );
        PHB_ITEM pItem = hb_itemNew( NULL );
        hb_itemPutPtr( pItem, (QWebFrame *) list[i] );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
        hb_itemRelease( pItem );
      }
    }
    hb_itemReturnRelease(pArray);
  }
}

/*
QSize contentsSize () const
*/
HB_FUNC_STATIC( QWEBFRAME_CONTENTSSIZE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSize * ptr = new QSize( obj->contentsSize () );
    _qt5xhb_createReturnClass ( ptr, "QSIZE", true );
  }
}

/*
QWebElement documentElement () const
*/
HB_FUNC_STATIC( QWEBFRAME_DOCUMENTELEMENT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebElement * ptr = new QWebElement( obj->documentElement () );
    _qt5xhb_createReturnClass ( ptr, "QWEBELEMENT", true );
  }
}

/*
QWebElementCollection findAllElements ( const QString & selectorQuery ) const
*/
HB_FUNC_STATIC( QWEBFRAME_FINDALLELEMENTS )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebElementCollection * ptr = new QWebElementCollection( obj->findAllElements ( PQSTRING(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QWEBELEMENTCOLLECTION", true );
  }
}

/*
QWebElement findFirstElement ( const QString & selectorQuery ) const
*/
HB_FUNC_STATIC( QWEBFRAME_FINDFIRSTELEMENT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebElement * ptr = new QWebElement( obj->findFirstElement ( PQSTRING(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QWEBELEMENT", true );
  }
}

/*
QString frameName () const
*/
HB_FUNC_STATIC( QWEBFRAME_FRAMENAME )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->frameName () );
  }
}

/*
QRect geometry () const
*/
HB_FUNC_STATIC( QWEBFRAME_GEOMETRY )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QRect * ptr = new QRect( obj->geometry () );
    _qt5xhb_createReturnClass ( ptr, "QRECT", true );
  }
}

/*
bool hasFocus () const
*/
HB_FUNC_STATIC( QWEBFRAME_HASFOCUS )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RBOOL( obj->hasFocus () );
  }
}

/*
QWebHitTestResult hitTestContent ( const QPoint & pos ) const
*/
HB_FUNC_STATIC( QWEBFRAME_HITTESTCONTENT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebHitTestResult * ptr = new QWebHitTestResult( obj->hitTestContent ( *PQPOINT(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QWEBHITTESTRESULT", true );
  }
}

/*
QIcon icon () const
*/
HB_FUNC_STATIC( QWEBFRAME_ICON )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QIcon * ptr = new QIcon( obj->icon () );
    _qt5xhb_createReturnClass ( ptr, "QICON", true );
  }
}

/*
void load ( const QUrl & url )
*/
HB_FUNC_STATIC( QWEBFRAME_LOAD1 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->load ( *PQURL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void load ( const QNetworkRequest & req, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray & body = QByteArray() )
*/
HB_FUNC_STATIC( QWEBFRAME_LOAD2 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par2 = ISNIL(2)? (int) QNetworkAccessManager::GetOperation : hb_parni(2);
    QByteArray par3 = ISNIL(3)? QByteArray() : *(QByteArray *) _qt5xhb_itemGetPtr(3);
    obj->load ( *PQNETWORKREQUEST(1), (QNetworkAccessManager::Operation) par2, par3 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void load ( const QUrl & url )
//[2]void load ( const QNetworkRequest & req, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray & body = QByteArray() )

HB_FUNC_STATIC( QWEBFRAME_LOAD )
{
  if( ISNUMPAR(1) && ISQURL(1) )
  {
    HB_FUNC_EXEC( QWEBFRAME_LOAD1 );
  }
  else if( ISBETWEEN(1,3) && ISQNETWORKREQUEST(1) && ISOPTNUM(2) && ISOPTQBYTEARRAY(3) )
  {
    HB_FUNC_EXEC( QWEBFRAME_LOAD2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
QWebPage * page () const
*/
HB_FUNC_STATIC( QWEBFRAME_PAGE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebPage * ptr = obj->page ();
    _qt5xhb_createReturnClass ( ptr, "QWEBPAGE" );
  }
}

/*
QWebFrame * parentFrame () const
*/
HB_FUNC_STATIC( QWEBFRAME_PARENTFRAME )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebFrame * ptr = obj->parentFrame ();
    _qt5xhb_createReturnClass ( ptr, "QWEBFRAME" );
  }
}

/*
QPoint pos () const
*/
HB_FUNC_STATIC( QWEBFRAME_POS )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QPoint * ptr = new QPoint( obj->pos () );
    _qt5xhb_createReturnClass ( ptr, "QPOINT", true );
  }
}

/*
void render ( QPainter * painter )
*/
HB_FUNC_STATIC( QWEBFRAME_RENDER1 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->render ( PQPAINTER(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void render ( QPainter * painter, const QRegion & clip )
*/
HB_FUNC_STATIC( QWEBFRAME_RENDER2 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->render ( PQPAINTER(1), *PQREGION(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void render ( QPainter * painter, RenderLayer layer, const QRegion & clip = QRegion() )
*/
HB_FUNC_STATIC( QWEBFRAME_RENDER3 )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QRegion par3 = ISNIL(3)? QRegion() : *(QRegion *) _qt5xhb_itemGetPtr(3);
    obj->render ( PQPAINTER(1), (QWebFrame::RenderLayer) hb_parni(2), par3 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void render ( QPainter * painter )
//[2]void render ( QPainter * painter, const QRegion & clip )
//[3]void render ( QPainter * painter, RenderLayer layer, const QRegion & clip = QRegion() )

HB_FUNC_STATIC( QWEBFRAME_RENDER )
{
  if( ISNUMPAR(1) && ISQPAINTER(1) )
  {
    HB_FUNC_EXEC( QWEBFRAME_RENDER1 );
  }
  else if( ISNUMPAR(2) && ISQPAINTER(1) && ISQREGION(2) )
  {
    HB_FUNC_EXEC( QWEBFRAME_RENDER2 );
  }
  else if( ISBETWEEN(2,3) && ISQPAINTER(1) && ISNUM(2) && (ISQREGION(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QWEBFRAME_RENDER3 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
QUrl requestedUrl () const
*/
HB_FUNC_STATIC( QWEBFRAME_REQUESTEDURL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * ptr = new QUrl( obj->requestedUrl () );
    _qt5xhb_createReturnClass ( ptr, "QURL", true );
  }
}

/*
void scroll ( int dx, int dy )
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->scroll ( PINT(1), PINT(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QRect scrollBarGeometry ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARGEOMETRY )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QRect * ptr = new QRect( obj->scrollBarGeometry ( (Qt::Orientation) hb_parni(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QRECT", true );
  }
}

/*
int scrollBarMaximum ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARMAXIMUM )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RINT( obj->scrollBarMaximum ( (Qt::Orientation) hb_parni(1) ) );
  }
}

/*
int scrollBarMinimum ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARMINIMUM )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RINT( obj->scrollBarMinimum ( (Qt::Orientation) hb_parni(1) ) );
  }
}

/*
Qt::ScrollBarPolicy scrollBarPolicy ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARPOLICY )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->scrollBarPolicy ( (Qt::Orientation) hb_parni(1) ) );
  }
}

/*
int scrollBarValue ( Qt::Orientation orientation ) const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLBARVALUE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RINT( obj->scrollBarValue ( (Qt::Orientation) hb_parni(1) ) );
  }
}

/*
QPoint scrollPosition () const
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLPOSITION )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QPoint * ptr = new QPoint( obj->scrollPosition () );
    _qt5xhb_createReturnClass ( ptr, "QPOINT", true );
  }
}

/*
void scrollToAnchor ( const QString & anchor )
*/
HB_FUNC_STATIC( QWEBFRAME_SCROLLTOANCHOR )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->scrollToAnchor ( PQSTRING(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QWebSecurityOrigin securityOrigin () const
*/
HB_FUNC_STATIC( QWEBFRAME_SECURITYORIGIN )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QWebSecurityOrigin * ptr = new QWebSecurityOrigin( obj->securityOrigin () );
    _qt5xhb_createReturnClass ( ptr, "QWEBSECURITYORIGIN", true );
  }
}

/*
void setContent ( const QByteArray & data, const QString & mimeType = QString(), const QUrl & baseUrl = QUrl() )
*/
HB_FUNC_STATIC( QWEBFRAME_SETCONTENT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl par3 = ISNIL(3)? QUrl() : *(QUrl *) _qt5xhb_itemGetPtr(3);
    obj->setContent ( *PQBYTEARRAY(1), OPQSTRING(2,QString()), par3 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setFocus ()
*/
HB_FUNC_STATIC( QWEBFRAME_SETFOCUS )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setFocus ();
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setHtml ( const QString & html, const QUrl & baseUrl = QUrl() )
*/
HB_FUNC_STATIC( QWEBFRAME_SETHTML )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl par2 = ISNIL(2)? QUrl() : *(QUrl *) _qt5xhb_itemGetPtr(2);
    obj->setHtml ( PQSTRING(1), par2 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setScrollBarPolicy ( Qt::Orientation orientation, Qt::ScrollBarPolicy policy )
*/
HB_FUNC_STATIC( QWEBFRAME_SETSCROLLBARPOLICY )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setScrollBarPolicy ( (Qt::Orientation) hb_parni(1), (Qt::ScrollBarPolicy) hb_parni(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setScrollBarValue ( Qt::Orientation orientation, int value )
*/
HB_FUNC_STATIC( QWEBFRAME_SETSCROLLBARVALUE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setScrollBarValue ( (Qt::Orientation) hb_parni(1), PINT(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setScrollPosition ( const QPoint & pos )
*/
HB_FUNC_STATIC( QWEBFRAME_SETSCROLLPOSITION )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setScrollPosition ( *PQPOINT(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setTextSizeMultiplier ( qreal factor )
*/
HB_FUNC_STATIC( QWEBFRAME_SETTEXTSIZEMULTIPLIER )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setTextSizeMultiplier ( PQREAL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setUrl ( const QUrl & url )
*/
HB_FUNC_STATIC( QWEBFRAME_SETURL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setUrl ( *PQURL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setZoomFactor ( qreal factor )
*/
HB_FUNC_STATIC( QWEBFRAME_SETZOOMFACTOR )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->setZoomFactor ( PQREAL(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
qreal textSizeMultiplier () const
*/
HB_FUNC_STATIC( QWEBFRAME_TEXTSIZEMULTIPLIER )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQREAL( obj->textSizeMultiplier () );
  }
}

/*
QString title () const
*/
HB_FUNC_STATIC( QWEBFRAME_TITLE )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->title () );
  }
}

/*
QString toHtml () const
*/
HB_FUNC_STATIC( QWEBFRAME_TOHTML )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->toHtml () );
  }
}

/*
QString toPlainText () const
*/
HB_FUNC_STATIC( QWEBFRAME_TOPLAINTEXT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQSTRING( obj->toPlainText () );
  }
}

/*
QUrl url () const
*/
HB_FUNC_STATIC( QWEBFRAME_URL )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * ptr = new QUrl( obj->url () );
    _qt5xhb_createReturnClass ( ptr, "QURL", true );
  }
}

/*
qreal zoomFactor () const
*/
HB_FUNC_STATIC( QWEBFRAME_ZOOMFACTOR )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    RQREAL( obj->zoomFactor () );
  }
}

/*
QVariant evaluateJavaScript ( const QString & scriptSource )
*/
HB_FUNC_STATIC( QWEBFRAME_EVALUATEJAVASCRIPT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QVariant * ptr = new QVariant( obj->evaluateJavaScript ( PQSTRING(1) ) );
    _qt5xhb_createReturnClass ( ptr, "QVARIANT", true );
  }
}

/*
void print ( QPrinter * printer ) const
*/
HB_FUNC_STATIC( QWEBFRAME_PRINT )
{
  QWebFrame * obj = (QWebFrame *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->print ( PQPRINTER(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

#pragma ENDDUMP


[Typed SDK] Added a default so a DbServer call without params will compile (and throw an error)

#pragma warnings(165, off)

PARTIAL CLASS DbServer INHERIT DataServer
	PROTECT lShared AS LOGIC
	PROTECT lReadOnly AS LOGIC
	PROTECT symAlias AS SYMBOL
	PROTECT wWorkArea AS DWORD
	PROTECT cRDDName AS STRING
	PROTECT oFileSpec AS FileSpec
	PROTECT aOriginalBuffer AS ARRAY
	//PROTECT aRLockVerifyBuffer AS ARRAY
	PROTECT siSuspendNotification AS SHORTINT
	PROTECT lRelationsActive AS LOGIC
	PROTECT lCDXSelectionActive AS LOGIC
	PROTECT aRelationChildren AS ARRAY
	PROTECT lSelectionActive AS LOGIC
	PROTECT oDBSelectionParent AS OBJECT
	PROTECT wSelectionWorkArea AS DWORD
	PROTECT cbSelectionParentExpression AS USUAL
	PROTECT uSelectionValue AS USUAL
	PROTECT cbSelectionIndexingExpression AS USUAL
	PROTECT siSelectionStatus AS SHORTINT
	PROTECT lActiveScope AS LOGIC
	PROTECT cbStoredForBlock AS USUAL
	PROTECT cbStoredWhileBlock AS USUAL
	PROTECT uStoredScope AS USUAL
	PROTECT nStoredNextCount AS LONGINT
	PROTECT lStoredAllRecords AS USUAL
	PROTECT lStoredRestOfFile AS LOGIC
	PROTECT wLastSelectionRec AS LONGINT
	PROTECT oErrorInfo AS Error
	PROTECT lErrorFlag AS LOGIC
	PROTECT nEffectiveCCMode AS DWORD
	PROTECT aCurrentBuffer AS ARRAY
	PROTECT lCCOptimisticRecChg AS LOGIC
	PROTECT aStruct AS ARRAY
	PROTECT aRdds AS ARRAY
	PROTECT nRetries AS DWORD
	PROTECT oRDD AS XSharp.RDD.IRdd

METHOD __AcceptSelectiveRelation( oDBParent AS DbServer, wParentWorkArea AS DWORD, cbSelection AS USUAL) AS VOID STRICT

	LOCAL cIndexExt AS STRING
	LOCAL dwCurrentWorkArea AS DWORD

	oDBSelectionParent := oDBParent
	wSelectionWorkArea := wParentWorkArea

	cbSelectionParentExpression := cbSelection

	VoDbSelect( wWorkArea, OUT dwCurrentWorkArea )

	cIndexExt := IndexExt( )

	IF Instr( "MDX", cIndexExt )
		lSelectionActive := TRUE
		siSelectionStatus := DBSELECTIONNULL
		cbSelectionIndexingExpression := DBSelectionIndex{ SELF, __DBSDbOrderInfo( DBOI_EXPRESSION, "", 0 ), wWorkArea }
	ELSE
		lCDXSelectionActive := TRUE
	ENDIF

   __DBSSetSelect( dwCurrentWorkArea  )

	RETURN

METHOD __BuildDataField( a AS ARRAY ) AS DataField STRICT
	LOCAL oRet := NULL AS DataField

	IF IsArray( a )
		oRet := DataField{ a[ DBS_NAME ], FieldSpec{ a[ DBS_NAME ], a[ DBS_TYPE ],  ;
			a[ DBS_LEN ], a[ DBS_DEC ] } }
	ENDIF
	RETURN oRet

METHOD __ClearChildRelation( oChild AS DbServer ) AS VOID STRICT
	LOCAL w AS DWORD
	LOCAL wLen AS DWORD

	IF ! ( ( w := AScan( aRelationChildren, oChild ) ) == 0 )
		IF ALen( aRelationChildren ) == 1
			lRelationsActive := FALSE
			aRelationChildren := { }
		ELSE
			wLen := ALen( aRelationChildren )
			aRelationChildren[w] := aRelationChildren[wLen]
			ASize( aRelationChildren, wLen - 1 )
		ENDIF
	ENDIF

	RETURN

METHOD __ClearLocks( )  AS VOID STRICT
	LOCAL uVOVal AS USUAL

	DO CASE
	CASE nEffectiveCCMode == ccOptimistic
		SELF:__OptimisticFlush( )

	CASE nEffectiveCCMode == ccStable
		IF ! VoDbInfo( DBI_ISFLOCK, REF uVOVal )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF
		IF ! uVOVal
			SELF:UnLock( nLastLock )
		ENDIF

	CASE nEffectiveCCMode == ccRepeatable
		IF ! VoDbInfo( DBI_ISFLOCK, REF uVOVal )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF
		IF ! uVOVal
			SELF:UnLock( )
		ENDIF

	CASE nEffectiveCCMode == ccFile
		SELF:UnLock( )
	ENDCASE

	RETURN

METHOD __DbServerEval( uBlock AS USUAL, uCobFor AS USUAL, uCobWhile AS USUAL, ;
	nNext AS USUAL, nRecno AS USUAL, lRest AS LOGIC, lCC AS LOGIC, lCCUpdate AS LOGIC ) AS LOGIC STRICT
	LOCAL lRetCode := TRUE AS LOGIC
	LOCAL lLimit AS LOGIC
	LOCAL lBlock AS LOGIC
	LOCAL lFor AS LOGIC
	LOCAL lWhile AS LOGIC
	LOCAL lInternalError AS LOGIC
	LOCAL iRecno AS INT
	LOCAL dwCurrentWorkArea AS DWORD
	LOCAL uRC AS USUAL
	LOCAL oError AS USUAL
	LOCAL nCurrRec AS DWORD
	LOCAL uFLock AS USUAL
   LOCAL lRestore	AS LOGIC

   // Make sure we restore the workarea
   // The codeblocks may select another workarea
	lRestore	:= DbSetRestoreWorkarea(TRUE)

	VoDbSelect( wWorkArea, OUT dwCurrentWorkArea )

	lErrorFlag := FALSE
	BEGIN SEQUENCE

		IF ! IsNil( nNext ) .AND. nNext != 0
			lLimit := TRUE
			iRecno := nNext
			IF iRecno < 1
				oHLStatus := HyperLabel{ #BadNext, __CavoStr( __CAVOSTR_DBFCLASS_BADNEXT_CAPTION ),  ;
					__CavoStr( __CAVOSTR_DBFCLASS_BADNEXT ) }
				lInternalError := TRUE
				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
			ENDIF
		ELSE
			lLimit := FALSE
			IF IsNil( uCobWhile ) .AND. ! lRest .AND. ! SELF:GoTop( )
				oHLStatus := HyperLabel{ #NoGoTop, __CavoStr( __CAVOSTR_DBFCLASS_NOGOTOP_CAPTION ),  ;
					__CavoStr( __CAVOSTR_DBFCLASS_NOGOTOP ) }
				lInternalError := TRUE
				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
			ENDIF
		ENDIF

		lBlock 	:= ! IsNil( uBlock )
		lFor 		:= ! IsNil( uCobFor )
		lWhile 	:= ! IsNil( uCobWhile )

		IF ! VoDbInfo( DBI_ISFLOCK, REF uFLock )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF
		DO WHILE ! VoDbEof( )
			IF lWhile .AND. ! Eval( uCobWhile )
				EXIT
			ENDIF
			IF ( ! lFor .OR. Eval( uCobFor ) ) .AND. lBlock
				IF lCC
					IF nEffectiveCCMode = ccOptimistic
						IF lCCUpdate .AND. ! uFLock
							nCurrRec := VoDbRecno( )
							VoDbRlock( nCurrRec )
						ENDIF
					ELSE
						IF nEffectiveCCMode = ccStable .AND. lCCUpdate .AND. ! uFLock
							IF nLastLock != 0
								VoDbUnlock( nLastLock )
							ENDIF
							nLastLock := VoDbRecno( )
							IF ! VoDbEof( )
								lRetCode := VoDbRlock( nLastLock )
							ELSE
								nLastLock := 0
							ENDIF
						ELSEIF nEffectiveCCMode = ccRepeatable
							IF ! VoDbEof( )
								lRetCode := VoDbRlock( VoDbRecno( ) )
							ENDIF
						ENDIF
					ENDIF
				ENDIF

				uRC := Eval( uBlock )
				IF lCC .AND. nEffectiveCCMode = ccOptimistic .AND. lCCUpdate .AND. ! uFLock
					VoDbUnlock( nCurrRec )
				ENDIF

				IF IsLogic( uRC )
					lRetCode := lRetCode .AND. uRC
					IF ! lRetCode
						EXIT
					ENDIF
				ENDIF
			ENDIF

			IF lLimit .AND. ( --iRecno = 0 )
				EXIT
			ENDIF

			IF ! VoDbSkip( 1 )
				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
			ENDIF
		ENDDO
	RECOVER USING oError
		oErrorInfo := oError
		IF ! lInternalError
			__DBSSetSelect(dwCurrentWorkArea  )
			SELF:Error( oErrorInfo, #__DbServerEval )
		ENDIF
		lRetCode := FALSE
	END SEQUENCE

	__DBSSetSelect( dwCurrentWorkArea )

   DbSetRestoreWorkarea(lRestore)
	RETURN lRetCode

METHOD __GenerateStatusHL( oError AS  Error) AS HyperLabel STRICT
	LOCAL oRet AS HyperLabel
	LOCAL cDesc AS STRING
    IF oError == NULL_OBJECT
        oError := Error{}
    ENDIF

	lErrorFlag := TRUE

	cDesc := Symbol2String( ClassName(SELF) ) + ": "
	IF Len( oError:Description ) > 0
		cDesc += oError:Description
	ELSE
		cDesc += ErrString( oError:Gencode )
	ENDIF
	IF  SLen(oError:SubCodeText) > 0
		cDesc += " ("+oError:SubCodeText+")"
	ENDIF

	IF oError:OSCode != 0
		cDesc += ":" + DosErrString( oError:OSCode )
	ENDIF

	oRet := HyperLabel{ oError:FuncSym, AsString( oError:Gencode ), cDesc }

	RETURN oRet

METHOD __InitRecordBuf( ) AS VOID STRICT
	LOCAL i AS DWORD
	LOCAL x AS USUAL

	FOR i := 1 TO SELF:wFieldCount
		IF VoDbFieldGet( i, REF x )
			//Mark as BLOB when fieldtype = 'M' and not string
			aOriginalBuffer[BUFFER_VALUE, i] 			:= x
			IF ! IsString(x) .AND. SELF:aStruct[i,DBS_TYPE] == "M"
				aOriginalBuffer[BUFFER_IS_BLOB, i] 		:= TRUE
			ELSE
				aOriginalBuffer[BUFFER_IS_BLOB, i] 	:= FALSE
			ENDIF
		ELSE
			// If VoDbFieldGet() fails this may be a BLOB field > 64 Kb
			aOriginalBuffer[BUFFER_VALUE, i] 			:= NIL
			aOriginalBuffer[BUFFER_IS_BLOB, i] 		:= TRUE
		ENDIF
		aCurrentBuffer[BUFFER_IS_CHANGED, i] := FALSE
	NEXT  // i

	RETURN

METHOD __Notify( kNotification, uDescription )
   LOCAL uRetValue AS USUAL
   LOCAL oError AS USUAL

	BEGIN SEQUENCE
		uRetValue := SELF:Notify( kNotification, uDescription )
	RECOVER USING oError
		oErrorInfo := oError
		oHLStatus := SELF:__GenerateStatusHL( oError )
	END SEQUENCE

   RETURN uRetValue

METHOD __NotifyBufferFlush( ) AS VOID STRICT
	LOCAL dwCurrentWorkArea  AS DWORD

	ASend( aRelationChildren, #__NotifyBufferFlush )
	VoDbSelect( wWorkArea, OUT dwCurrentWorkArea )
	SELF:__OptimisticFlush( )
	__DBSSetSelect( dwCurrentWorkArea  )

	RETURN

METHOD __OptimisticFlush() AS VOID STRICT
	LOCAL w AS DWORD
	LOCAL uFLock AS USUAL
	LOCAL uValue AS USUAL
	LOCAL nCurRec AS DWORD
	LOCAL uIsRLock AS USUAL
	LOCAL nOrgBuffLen AS DWORD
	LOCAL cFieldType	AS STRING

	IF nEffectiveCCMode == ccOptimistic .AND. lCCOptimisticRecChg
		nCurRec := VoDbRecno( )

		IF ! VoDbRecordInfo( DBRI_LOCKED, 0, REF uIsRLock )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF

		IF ! uIsRLock
			IF SELF:__RLockVerify( )
				IF ! VoDbInfo( DBI_ISFLOCK, REF uFLock )
					BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
				ENDIF
				FOR w := 1 UPTO wFieldCount
					cFieldType := SELF:aStruct[w, DBS_TYPE]
					IF aCurrentBuffer[BUFFER_IS_CHANGED, w] .AND. ! aOriginalBuffer[BUFFER_IS_BLOB, w]
						uValue := aCurrentBuffer[BUFFER_VALUE, w]
						IF ! VoDbFieldPut( w, uValue )
							BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
						ENDIF
						IF ! uFLock
							// Memo Fields must NOT be padded !
							IF cFieldType != "M" .AND. IsString( aOriginalBuffer[BUFFER_VALUE, w] )
								nOrgBuffLen := SLen( aOriginalBuffer[BUFFER_VALUE, w] )
								aOriginalBuffer[BUFFER_VALUE, w] := PadR( uValue, nOrgBuffLen )
							ELSE
								aOriginalBuffer[BUFFER_VALUE, w] := uValue
							ENDIF
						ENDIF
						aCurrentBuffer[BUFFER_VALUE, w]   := NIL
						aCurrentBuffer[BUFFER_IS_CHANGED, w] := FALSE
					ENDIF
				NEXT

				lCCOptimisticRecChg := FALSE

				IF ! uFLock
					VoDbUnlock( nCurRec )
				ENDIF
			ELSE
				IF oErrorInfo = NULL_OBJECT
					BREAK DbError{ SELF, #Optimistic_Buffer_flush, EG_LOCK,  ;
						         __CavoStr( __CAVOSTR_DBFCLASS_RECORDCHANGED ) }
				ELSE
					BREAK oErrorInfo
				ENDIF
			ENDIF
		ENDIF
	ENDIF

	RETURN

METHOD __OptimisticFlushNoLock( ) AS VOID STRICT
	LOCAL w AS DWORD
	LOCAL uValue AS USUAL
	IF nEffectiveCCMode == ccOptimistic .AND. lCCOptimisticRecChg
		FOR w := 1 UPTO wFieldCount
			IF aCurrentBuffer[BUFFER_IS_CHANGED, w] .AND. ! aOriginalBuffer[BUFFER_IS_BLOB, w]
				uValue := aCurrentBuffer[BUFFER_VALUE, w]
				IF ! VoDbFieldPut( w, uValue )
					BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
				ENDIF
				aCurrentBuffer[BUFFER_VALUE, w]		:= NIL
				aCurrentBuffer[BUFFER_IS_CHANGED, w]	:= FALSE
			ENDIF
		NEXT
		lCCOptimisticRecChg := FALSE
	ENDIF

	RETURN

METHOD __ProcessConcurrency( lBreak AS LOGIC) AS LOGIC STRICT
	LOCAL uVOVal AS USUAL
	LOCAL lError AS LOGIC
	LOCAL lRetCode AS LOGIC

	lError := FALSE
	IF SELF:nEffectiveCCMode = ccStable
		IF VoDbInfo( DBI_ISFLOCK, REF uVOVal )
			IF ! uVOVal
				IF nLastLock != 0
					VoDbUnlock( SELF:nLastLock )
				ENDIF
				nLastLock := VoDbRecno( )
				IF ! VoDbEof( )
					lRetCode := VoDbRlock( SELF:nLastLock )
				ELSE
					SELF:nLastLock := 0
				ENDIF
			ELSE
				SELF:nLastLock := 0
			ENDIF
		ELSE
			lError := TRUE
		ENDIF

	ELSEIF SELF:nEffectiveCCMode = ccRepeatable
		IF ! VoDbEof( )
			IF VoDbInfo( DBI_ISFLOCK, REF uVOVal )
				IF ! uVOVal
					lRetCode := VoDbRlock( VoDbRecno( ) )
				ENDIF
			ELSE
				lError := TRUE
			ENDIF
		ENDIF
	ELSE
		lRetCode := TRUE
	ENDIF

	IF lBreak .AND. (lError .OR. ! lRetCode) .AND. CanBreak()
		BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
	ENDIF

	RETURN lRetCode

METHOD __RLockVerify( ) AS LOGIC STRICT
	LOCAL w AS DWORD
	LOCAL siCurrentRec AS LONGINT
	LOCAL uWasLocked AS USUAL
	LOCAL uVOVal AS USUAL
	LOCAL lRetCode AS LOGIC
   LOCAL nDiff	AS FLOAT
	LOCAL uValue	AS USUAL
	LOCAL aRLockVerifyBuffer AS ARRAY

	lRetCode := TRUE
	siCurrentRec := VoDbRecno( )
	IF ! VoDbInfo( DBI_ISFLOCK, REF uVOVal )
		BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
	ENDIF
	IF ! VoDbRecordInfo( DBRI_LOCKED, 0, REF uWasLocked )
		BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
	ENDIF
	uWasLocked := uWasLocked .OR. uVOVal
	IF ! uWasLocked
		lRetCode := VoDbRlock( siCurrentRec )
	ENDIF
	IF ! lRetCode
		BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
	ELSE
		// Store our 'current record'
 		aRLockVerifyBuffer := ArrayNew( wFieldCount )
 		FOR w := 1 UPTO wFieldCount
 			aRLockVerifyBuffer[w] := __DBSFieldGet(w)
 		NEXT
		// Get the current record buffer from disk and compare the fields
		// in the current buffer with our values.
		VoDbBuffRefresh( )
		FOR w := 1 UPTO wFieldCount
			uValue := __DBSFieldGet( w )
			//
			IF aOriginalBuffer[BUFFER_IS_BLOB, w]
				// Field was a blob. Compare field types
				IF UsualType(aOriginalBuffer[BUFFER_VALUE, w]) != UsualType(uValue)
					lRetCode := FALSE
				ENDIF
			ELSEIF ! ( aOriginalBuffer[BUFFER_VALUE, w] == uValue )
				// Field has changed.
				// Test for float fields with non-relevant differences
				IF IsFloat(uValue)
				   nDiff := 10 ^ -(aStruct[w, DBS_DEC])
				   IF Abs(aOriginalBuffer[BUFFER_VALUE, w] - uValue) > nDiff
					   lRetCode := FALSE
				   ENDIF
				ELSE
				   lRetCode := FALSE
				ENDIF
			//ELSE
				// The field has not changed
			ENDIF
			IF ! lRetCode
				oHLStatus := HyperLabel{ #RECORDCHANGED,  ;
					__CavoStr( __CAVOSTR_DBFCLASS_RECORDCHANGED_CAPTION ),  ;
					__CavoStr( __CAVOSTR_DBFCLASS_RECORDCHANGED ), NIL }
				oErrorInfo := NULL_OBJECT
				lErrorFlag := TRUE
				EXIT
			ENDIF
		NEXT
      // restore the 'current record' in the buffer
 		FOR w := 1 UPTO wFieldCount
 			IF ! VoDbFieldPut( w, aRLockVerifyBuffer[w] )
 				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
 			ENDIF
 		NEXT

		IF ! lRetCode .AND. ! uWasLocked
			VoDbUnlock( siCurrentRec )
		ENDIF
	ENDIF

	RETURN lRetCode

METHOD __SetAlias( cName AS STRING, aField AS ARRAY, nField AS DWORD) AS VOID STRICT
	LOCAL cAlias AS STRING
	LOCAL oFSpec AS FieldSpec

	cAlias := "_" + cName
	oFSpec := FieldSpec{ cAlias, aField[DBS_TYPE], aField[DBS_LEN], aField[DBS_DEC] }
	SELF:aDataFields[nField] := DataField{ cName, oFSpec }

	RETURN

METHOD __SetStatusHL( uFuncSym AS USUAL, uGenCode AS USUAL, uMessage AS USUAL ) AS VOID STRICT

	lErrorFlag := TRUE
	oErrorInfo := NULL_OBJECT
	IF ! IsString( uGenCode )
		uGenCode := AsString( uGenCode )
	ENDIF
	oHLStatus := HyperLabel{ uFuncSym, uGenCode, uMessage, NIL }

	RETURN

METHOD __SetupLocks( )  AS VOID STRICT
	LOCAL w AS DWORD
	LOCAL uFlock AS USUAL

	nLastLock := 0
	DO CASE
	CASE nEffectiveCCMode == ccNone
		//nothing to do

	CASE nEffectiveCCMode == ccOptimistic
		FOR w := 1 UPTO wFieldCount
			aCurrentBuffer[BUFFER_VALUE, w]   := NIL
			aCurrentBuffer[BUFFER_IS_CHANGED, w] := FALSE
		NEXT
		lCCOptimisticRecChg := FALSE
		SELF:__InitRecordBuf()

	CASE nEffectiveCCMode == ccStable .OR. nEffectiveCCMode == ccRepeatable
		IF ! VoDbInfo( DBI_ISFLOCK, REF uFlock )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF
		IF ! uFlock
			nLastLock := SELF:RecNo
			IF ! SELF:RLock( nLastLock )
				nLastLock := 0
				oHLStatus := SELF:Status
			ENDIF
		ENDIF

	CASE nEffectiveCCMode == ccFile
		IF ! SELF:FLock( )
			oHLStatus := SELF:Status
		ENDIF

	OTHERWISE
		oErrorInfo := DbError{ SELF, #ConcurrencyControl, EG_ARG,  ;
			__CavoStr( __CAVOSTR_DBFCLASS_BADCONCURRENCYASSIGN ), nCCMode, "nCCMode" }
		SELF:Error( oErrorInfo, #ConcurrencyControl )
	ENDCASE

	RETURN
CONSTRUCTOR( cFile AS STRING, lShareMode := FALSE AS OBJECT, lReadOnlyMode := FALSE AS OBJECT, xDriver:= "" AS STRING, aRdd := NULL_ARRAY AS ARRAY)
    SELF(FileSpec{cFile}, lShareMode, lReadOnlyMode , xDriver, aRdd )

CONSTRUCTOR( oFS := NULL AS FileSpec, lShareMode := FALSE AS OBJECT, lReadOnlyMode := FALSE AS OBJECT, xDriver:= "" AS STRING, aRdd := NULL_ARRAY AS ARRAY)
	LOCAL dwCurrentWorkArea := 0 AS DWORD
	LOCAL cFileName AS STRING
	LOCAL w AS DWORD
	LOCAL n AS DWORD
	LOCAL oError AS USUAL
	LOCAL symTemp AS SYMBOL
	LOCAL cTemp AS STRING
	LOCAL rddList AS _RddList
	LOCAL uTemp AS USUAL
	LOCAL aField AS ARRAY
	LOCAL uProps AS USUAL
	LOCAL wProps AS DWORD
	LOCAL lRetCode AS LOGIC

	SUPER( )

	aRelationChildren := { }

	lErrorFlag := FALSE
	BEGIN SEQUENCE
		siSuspendNotification := 0
		dwCurrentWorkArea := VoDbGetSelect( )
        IF oFs == NULL
		    BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_NOFILENAME ),  ;
			    NIL, "oFs" }
        ENDIF

		IF Empty( oFS:Extension )
			oFS:Extension := ".DBF"
		ENDIF
		oFileSpec := oFS

		cFileName := oFileSpec:FileName

		symAlias := SELF:ConstructUniqueAlias( cFileName )

		IF lShareMode  == NULL
			SELF:lShared := ! SetExclusive( )
		ELSEIF lShareMode  IS LOGIC
			SELF:lShared := (LOGIC) lShareMode
		ELSEIF lShareMode IS SYMBOL VAR symShareMode
			IF symShareMode = #Shared
				SELF:lShared := TRUE
			ELSEIF symShareMode = #Exclusive
				SELF:lShared := FALSE
			ELSE
				BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADSHAREMODE ),  ;
					lShareMode, "lShareMode" }
			ENDIF

		ELSEIF lShareMode IS STRING VAR strShareMode
			symTemp := String2Symbol( strShareMode )
			IF symTemp = #Shared
				SELF:lShared := TRUE
			ELSEIF symTemp = #Exclusive
				SELF:lShared := FALSE
			ELSE
				BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADSHAREMODE ),  ;
					lShareMode, "lShareMode" }
			ENDIF
		ELSE
			BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADSHAREMODE ),  ;
				lShareMode, "lShareMode" }
		ENDIF

		IF lReadOnlyMode == NULL
			lReadOnly := FALSE
		ELSEIF lReadOnlyMode IS LOGIC
			lReadOnly := (LOGIC) lReadOnlyMode
		ELSEIF lReadOnlyMode  IS SYMBOL VAR symReadOnlyMode
			IF symReadOnlyMode = #ReadOnly
				lReadOnly := TRUE
			ELSEIF symReadOnlyMode = #ReadWrite
				lReadOnly := FALSE
			ELSE
				BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADREADONLYMODE ),  ;
					lReadOnlyMode, "lReadOnlyMode" }
			ENDIF
		ELSEIF lReadOnlyMode IS STRING VAR strReadOnlyMode
			symTemp := String2Symbol( strReadOnlyMode)
			IF symTemp = #ReadOnly
				lReadOnly := TRUE
			ELSEIF symTemp = #ReadWrite
				lReadOnly := FALSE
			ELSE
				BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADREADONLYMODE ),  ;
					lReadOnlyMode, "lReadOnlyMode" }
			ENDIF
		ELSE
			BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADREADONLYMODE ),  ;
				lReadOnlyMode, "lReadOnlyMode" }
		ENDIF

		cTemp := Symbol2String( ClassName( SELF ) )
		oHyperLabel := HyperLabel{ cFileName, cFileName,  ;
			cTemp + ": " + cFileName + " " +  ;
			VO_Sprintf( __CAVOSTR_DBFCLASS_ALIAS, Symbol2String( symAlias ) ),  ;
			cTemp + "_" + cFileName }

		oHLStatus := NIL

		SELF:wWorkArea := VoDbSetSelect( -1 )

		IF ! ( IsArray( xDriver ) .OR. IsString( xDriver ) )
			xDriver := RddName( )
		ENDIF

		SELF:aRdds := __RDDList( xDriver, aRdd )
		rddList := __AllocRddList( aRdds )

		lRetCode := VoDbUseArea( FALSE, rddList, oFileSpec:FullPath, Symbol2String( symAlias ),  ;
			lShared, lReadOnly )

		IF ! lRetCode
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF

		SELF:cRDDName := RddName( )
        SELF:oRDD     := (XSharp.RDD.IRdd) DbInfo(DBI_RDD_OBJECT)

        SELF:nCCMode := SELF:nEffectiveCCMode := DbGetDefaultLockMode()
		IF lReadOnly .OR. ! lShared
			SELF:nEffectiveCCMode := ccNone
		ENDIF

		wFieldCount := FCount( )

		aStruct := ArrayCreate( wFieldCount )

		FOR w := 1 UPTO wFieldCount
			uProps := NIL
			IF ! VoDbFieldInfo( DBS_PROPERTIES, w, REF uProps )
				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
			ENDIF
			wProps := uProps
			aField := ArrayCreate( wProps )
			FOR n := 1 UPTO wProps
				VoDbFieldInfo( n, w, REF uTemp )
				aField[n] := uTemp
			NEXT
			aStruct[w] := aField
		NEXT

		aDataFields := ArrayNew( wFieldCount )

		aOriginalBuffer := ArrayNew( 2, wFieldCount )
		aCurrentBuffer  := ArrayNew( 2, wFieldCount )
		SELF:__InitRecordBuf( )

		__DBSSetSelect(dwCurrentWorkArea)

	RECOVER USING oError
		oErrorInfo := oError
		IF Used( )
			VoDbCloseArea( )
		ENDIF
		wWorkArea := 0
		__DBSSetSelect(dwCurrentWorkArea)
		oHLStatus := HyperLabel{ #NoTable, __CavoStr( __CAVOSTR_DBFCLASS_NOTABLE_CAPTION ),  ;
			__CavoStr( __CAVOSTR_DBFCLASS_NOTABLE ) }
		SELF:Error( oErrorInfo, #Init )
	END SEQUENCE

	SELF:nRetries := LockTries( )

	RETURN

END CLASS

#pragma warnings(165, off)

PARTIAL CLASS DbServer INHERIT DataServer
	PROTECT lShared AS LOGIC
	PROTECT lReadOnly AS LOGIC
	PROTECT symAlias AS SYMBOL
	PROTECT wWorkArea AS DWORD
	PROTECT cRDDName AS STRING
	PROTECT oFileSpec AS FileSpec
	PROTECT aOriginalBuffer AS ARRAY
	//PROTECT aRLockVerifyBuffer AS ARRAY
	PROTECT siSuspendNotification AS SHORTINT
	PROTECT lRelationsActive AS LOGIC
	PROTECT lCDXSelectionActive AS LOGIC
	PROTECT aRelationChildren AS ARRAY
	PROTECT lSelectionActive AS LOGIC
	PROTECT oDBSelectionParent AS OBJECT
	PROTECT wSelectionWorkArea AS DWORD
	PROTECT cbSelectionParentExpression AS USUAL
	PROTECT uSelectionValue AS USUAL
	PROTECT cbSelectionIndexingExpression AS USUAL
	PROTECT siSelectionStatus AS SHORTINT
	PROTECT lActiveScope AS LOGIC
	PROTECT cbStoredForBlock AS USUAL
	PROTECT cbStoredWhileBlock AS USUAL
	PROTECT uStoredScope AS USUAL
	PROTECT nStoredNextCount AS LONGINT
	PROTECT lStoredAllRecords AS USUAL
	PROTECT lStoredRestOfFile AS LOGIC
	PROTECT wLastSelectionRec AS LONGINT
	PROTECT oErrorInfo AS Error
	PROTECT lErrorFlag AS LOGIC
	PROTECT nEffectiveCCMode AS DWORD
	PROTECT aCurrentBuffer AS ARRAY
	PROTECT lCCOptimisticRecChg AS LOGIC
	PROTECT aStruct AS ARRAY
	PROTECT aRdds AS ARRAY
	PROTECT nRetries AS DWORD
	PROTECT oRDD AS XSharp.RDD.IRdd

METHOD __AcceptSelectiveRelation( oDBParent AS DbServer, wParentWorkArea AS DWORD, cbSelection AS USUAL) AS VOID STRICT

	LOCAL cIndexExt AS STRING
	LOCAL dwCurrentWorkArea AS DWORD

	oDBSelectionParent := oDBParent
	wSelectionWorkArea := wParentWorkArea

	cbSelectionParentExpression := cbSelection

	VoDbSelect( wWorkArea, OUT dwCurrentWorkArea )

	cIndexExt := IndexExt( )

	IF Instr( "MDX", cIndexExt )
		lSelectionActive := TRUE
		siSelectionStatus := DBSELECTIONNULL
		cbSelectionIndexingExpression := DBSelectionIndex{ SELF, __DBSDbOrderInfo( DBOI_EXPRESSION, "", 0 ), wWorkArea }
	ELSE
		lCDXSelectionActive := TRUE
	ENDIF

   __DBSSetSelect( dwCurrentWorkArea  )

	RETURN

METHOD __BuildDataField( a AS ARRAY ) AS DataField STRICT
	LOCAL oRet := NULL AS DataField

	IF IsArray( a )
		oRet := DataField{ a[ DBS_NAME ], FieldSpec{ a[ DBS_NAME ], a[ DBS_TYPE ],  ;
			a[ DBS_LEN ], a[ DBS_DEC ] } }
	ENDIF
	RETURN oRet

METHOD __ClearChildRelation( oChild AS DbServer ) AS VOID STRICT
	LOCAL w AS DWORD
	LOCAL wLen AS DWORD

	IF ! ( ( w := AScan( aRelationChildren, oChild ) ) == 0 )
		IF ALen( aRelationChildren ) == 1
			lRelationsActive := FALSE
			aRelationChildren := { }
		ELSE
			wLen := ALen( aRelationChildren )
			aRelationChildren[w] := aRelationChildren[wLen]
			ASize( aRelationChildren, wLen - 1 )
		ENDIF
	ENDIF

	RETURN

METHOD __ClearLocks( )  AS VOID STRICT
	LOCAL uVOVal AS USUAL

	DO CASE
	CASE nEffectiveCCMode == ccOptimistic
		SELF:__OptimisticFlush( )

	CASE nEffectiveCCMode == ccStable
		IF ! VoDbInfo( DBI_ISFLOCK, REF uVOVal )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF
		IF ! uVOVal
			SELF:UnLock( nLastLock )
		ENDIF

	CASE nEffectiveCCMode == ccRepeatable
		IF ! VoDbInfo( DBI_ISFLOCK, REF uVOVal )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF
		IF ! uVOVal
			SELF:UnLock( )
		ENDIF

	CASE nEffectiveCCMode == ccFile
		SELF:UnLock( )
	ENDCASE

	RETURN

METHOD __DbServerEval( uBlock AS USUAL, uCobFor AS USUAL, uCobWhile AS USUAL, ;
	nNext AS USUAL, nRecno AS USUAL, lRest AS LOGIC, lCC AS LOGIC, lCCUpdate AS LOGIC ) AS LOGIC STRICT
	LOCAL lRetCode := TRUE AS LOGIC
	LOCAL lLimit AS LOGIC
	LOCAL lBlock AS LOGIC
	LOCAL lFor AS LOGIC
	LOCAL lWhile AS LOGIC
	LOCAL lInternalError AS LOGIC
	LOCAL iRecno AS INT
	LOCAL dwCurrentWorkArea AS DWORD
	LOCAL uRC AS USUAL
	LOCAL oError AS USUAL
	LOCAL nCurrRec AS DWORD
	LOCAL uFLock AS USUAL
   LOCAL lRestore	AS LOGIC

   // Make sure we restore the workarea
   // The codeblocks may select another workarea
	lRestore	:= DbSetRestoreWorkarea(TRUE)

	VoDbSelect( wWorkArea, OUT dwCurrentWorkArea )

	lErrorFlag := FALSE
	BEGIN SEQUENCE

		IF ! IsNil( nNext ) .AND. nNext != 0
			lLimit := TRUE
			iRecno := nNext
			IF iRecno < 1
				oHLStatus := HyperLabel{ #BadNext, __CavoStr( __CAVOSTR_DBFCLASS_BADNEXT_CAPTION ),  ;
					__CavoStr( __CAVOSTR_DBFCLASS_BADNEXT ) }
				lInternalError := TRUE
				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
			ENDIF
		ELSE
			lLimit := FALSE
			IF IsNil( uCobWhile ) .AND. ! lRest .AND. ! SELF:GoTop( )
				oHLStatus := HyperLabel{ #NoGoTop, __CavoStr( __CAVOSTR_DBFCLASS_NOGOTOP_CAPTION ),  ;
					__CavoStr( __CAVOSTR_DBFCLASS_NOGOTOP ) }
				lInternalError := TRUE
				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
			ENDIF
		ENDIF

		lBlock 	:= ! IsNil( uBlock )
		lFor 		:= ! IsNil( uCobFor )
		lWhile 	:= ! IsNil( uCobWhile )

		IF ! VoDbInfo( DBI_ISFLOCK, REF uFLock )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF
		DO WHILE ! VoDbEof( )
			IF lWhile .AND. ! Eval( uCobWhile )
				EXIT
			ENDIF
			IF ( ! lFor .OR. Eval( uCobFor ) ) .AND. lBlock
				IF lCC
					IF nEffectiveCCMode = ccOptimistic
						IF lCCUpdate .AND. ! uFLock
							nCurrRec := VoDbRecno( )
							VoDbRlock( nCurrRec )
						ENDIF
					ELSE
						IF nEffectiveCCMode = ccStable .AND. lCCUpdate .AND. ! uFLock
							IF nLastLock != 0
								VoDbUnlock( nLastLock )
							ENDIF
							nLastLock := VoDbRecno( )
							IF ! VoDbEof( )
								lRetCode := VoDbRlock( nLastLock )
							ELSE
								nLastLock := 0
							ENDIF
						ELSEIF nEffectiveCCMode = ccRepeatable
							IF ! VoDbEof( )
								lRetCode := VoDbRlock( VoDbRecno( ) )
							ENDIF
						ENDIF
					ENDIF
				ENDIF

				uRC := Eval( uBlock )
				IF lCC .AND. nEffectiveCCMode = ccOptimistic .AND. lCCUpdate .AND. ! uFLock
					VoDbUnlock( nCurrRec )
				ENDIF

				IF IsLogic( uRC )
					lRetCode := lRetCode .AND. uRC
					IF ! lRetCode
						EXIT
					ENDIF
				ENDIF
			ENDIF

			IF lLimit .AND. ( --iRecno = 0 )
				EXIT
			ENDIF

			IF ! VoDbSkip( 1 )
				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
			ENDIF
		ENDDO
	RECOVER USING oError
		oErrorInfo := oError
		IF ! lInternalError
			__DBSSetSelect(dwCurrentWorkArea  )
			SELF:Error( oErrorInfo, #__DbServerEval )
		ENDIF
		lRetCode := FALSE
	END SEQUENCE

	__DBSSetSelect( dwCurrentWorkArea )

   DbSetRestoreWorkarea(lRestore)
	RETURN lRetCode

METHOD __GenerateStatusHL( oError AS  Error) AS HyperLabel STRICT
	LOCAL oRet AS HyperLabel
	LOCAL cDesc AS STRING
    IF oError == NULL_OBJECT
        oError := Error{}
    ENDIF

	lErrorFlag := TRUE

	cDesc := Symbol2String( ClassName(SELF) ) + ": "
	IF Len( oError:Description ) > 0
		cDesc += oError:Description
	ELSE
		cDesc += ErrString( oError:Gencode )
	ENDIF
	IF  SLen(oError:SubCodeText) > 0
		cDesc += " ("+oError:SubCodeText+")"
	ENDIF

	IF oError:OSCode != 0
		cDesc += ":" + DosErrString( oError:OSCode )
	ENDIF

	oRet := HyperLabel{ oError:FuncSym, AsString( oError:Gencode ), cDesc }

	RETURN oRet

METHOD __InitRecordBuf( ) AS VOID STRICT
	LOCAL i AS DWORD
	LOCAL x AS USUAL

	FOR i := 1 TO SELF:wFieldCount
		IF VoDbFieldGet( i, REF x )
			//Mark as BLOB when fieldtype = 'M' and not string
			aOriginalBuffer[BUFFER_VALUE, i] 			:= x
			IF ! IsString(x) .AND. SELF:aStruct[i,DBS_TYPE] == "M"
				aOriginalBuffer[BUFFER_IS_BLOB, i] 		:= TRUE
			ELSE
				aOriginalBuffer[BUFFER_IS_BLOB, i] 	:= FALSE
			ENDIF
		ELSE
			// If VoDbFieldGet() fails this may be a BLOB field > 64 Kb
			aOriginalBuffer[BUFFER_VALUE, i] 			:= NIL
			aOriginalBuffer[BUFFER_IS_BLOB, i] 		:= TRUE
		ENDIF
		aCurrentBuffer[BUFFER_IS_CHANGED, i] := FALSE
	NEXT  // i

	RETURN

METHOD __Notify( kNotification, uDescription )
   LOCAL uRetValue AS USUAL
   LOCAL oError AS USUAL

	BEGIN SEQUENCE
		uRetValue := SELF:Notify( kNotification, uDescription )
	RECOVER USING oError
		oErrorInfo := oError
		oHLStatus := SELF:__GenerateStatusHL( oError )
	END SEQUENCE

   RETURN uRetValue

METHOD __NotifyBufferFlush( ) AS VOID STRICT
	LOCAL dwCurrentWorkArea  AS DWORD

	ASend( aRelationChildren, #__NotifyBufferFlush )
	VoDbSelect( wWorkArea, OUT dwCurrentWorkArea )
	SELF:__OptimisticFlush( )
	__DBSSetSelect( dwCurrentWorkArea  )

	RETURN

METHOD __OptimisticFlush() AS VOID STRICT
	LOCAL w AS DWORD
	LOCAL uFLock AS USUAL
	LOCAL uValue AS USUAL
	LOCAL nCurRec AS DWORD
	LOCAL uIsRLock AS USUAL
	LOCAL nOrgBuffLen AS DWORD
	LOCAL cFieldType	AS STRING

	IF nEffectiveCCMode == ccOptimistic .AND. lCCOptimisticRecChg
		nCurRec := VoDbRecno( )

		IF ! VoDbRecordInfo( DBRI_LOCKED, 0, REF uIsRLock )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF

		IF ! uIsRLock
			IF SELF:__RLockVerify( )
				IF ! VoDbInfo( DBI_ISFLOCK, REF uFLock )
					BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
				ENDIF
				FOR w := 1 UPTO wFieldCount
					cFieldType := SELF:aStruct[w, DBS_TYPE]
					IF aCurrentBuffer[BUFFER_IS_CHANGED, w] .AND. ! aOriginalBuffer[BUFFER_IS_BLOB, w]
						uValue := aCurrentBuffer[BUFFER_VALUE, w]
						IF ! VoDbFieldPut( w, uValue )
							BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
						ENDIF
						IF ! uFLock
							// Memo Fields must NOT be padded !
							IF cFieldType != "M" .AND. IsString( aOriginalBuffer[BUFFER_VALUE, w] )
								nOrgBuffLen := SLen( aOriginalBuffer[BUFFER_VALUE, w] )
								aOriginalBuffer[BUFFER_VALUE, w] := PadR( uValue, nOrgBuffLen )
							ELSE
								aOriginalBuffer[BUFFER_VALUE, w] := uValue
							ENDIF
						ENDIF
						aCurrentBuffer[BUFFER_VALUE, w]   := NIL
						aCurrentBuffer[BUFFER_IS_CHANGED, w] := FALSE
					ENDIF
				NEXT

				lCCOptimisticRecChg := FALSE

				IF ! uFLock
					VoDbUnlock( nCurRec )
				ENDIF
			ELSE
				IF oErrorInfo = NULL_OBJECT
					BREAK DbError{ SELF, #Optimistic_Buffer_flush, EG_LOCK,  ;
						         __CavoStr( __CAVOSTR_DBFCLASS_RECORDCHANGED ) }
				ELSE
					BREAK oErrorInfo
				ENDIF
			ENDIF
		ENDIF
	ENDIF

	RETURN

METHOD __OptimisticFlushNoLock( ) AS VOID STRICT
	LOCAL w AS DWORD
	LOCAL uValue AS USUAL
	IF nEffectiveCCMode == ccOptimistic .AND. lCCOptimisticRecChg
		FOR w := 1 UPTO wFieldCount
			IF aCurrentBuffer[BUFFER_IS_CHANGED, w] .AND. ! aOriginalBuffer[BUFFER_IS_BLOB, w]
				uValue := aCurrentBuffer[BUFFER_VALUE, w]
				IF ! VoDbFieldPut( w, uValue )
					BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
				ENDIF
				aCurrentBuffer[BUFFER_VALUE, w]		:= NIL
				aCurrentBuffer[BUFFER_IS_CHANGED, w]	:= FALSE
			ENDIF
		NEXT
		lCCOptimisticRecChg := FALSE
	ENDIF

	RETURN

METHOD __ProcessConcurrency( lBreak AS LOGIC) AS LOGIC STRICT
	LOCAL uVOVal AS USUAL
	LOCAL lError AS LOGIC
	LOCAL lRetCode AS LOGIC

	lError := FALSE
	IF SELF:nEffectiveCCMode = ccStable
		IF VoDbInfo( DBI_ISFLOCK, REF uVOVal )
			IF ! uVOVal
				IF nLastLock != 0
					VoDbUnlock( SELF:nLastLock )
				ENDIF
				nLastLock := VoDbRecno( )
				IF ! VoDbEof( )
					lRetCode := VoDbRlock( SELF:nLastLock )
				ELSE
					SELF:nLastLock := 0
				ENDIF
			ELSE
				SELF:nLastLock := 0
			ENDIF
		ELSE
			lError := TRUE
		ENDIF

	ELSEIF SELF:nEffectiveCCMode = ccRepeatable
		IF ! VoDbEof( )
			IF VoDbInfo( DBI_ISFLOCK, REF uVOVal )
				IF ! uVOVal
					lRetCode := VoDbRlock( VoDbRecno( ) )
				ENDIF
			ELSE
				lError := TRUE
			ENDIF
		ENDIF
	ELSE
		lRetCode := TRUE
	ENDIF

	IF lBreak .AND. (lError .OR. ! lRetCode) .AND. CanBreak()
		BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
	ENDIF

	RETURN lRetCode

METHOD __RLockVerify( ) AS LOGIC STRICT
	LOCAL w AS DWORD
	LOCAL siCurrentRec AS LONGINT
	LOCAL uWasLocked AS USUAL
	LOCAL uVOVal AS USUAL
	LOCAL lRetCode AS LOGIC
   LOCAL nDiff	AS FLOAT
	LOCAL uValue	AS USUAL
	LOCAL aRLockVerifyBuffer AS ARRAY

	lRetCode := TRUE
	siCurrentRec := VoDbRecno( )
	IF ! VoDbInfo( DBI_ISFLOCK, REF uVOVal )
		BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
	ENDIF
	IF ! VoDbRecordInfo( DBRI_LOCKED, 0, REF uWasLocked )
		BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
	ENDIF
	uWasLocked := uWasLocked .OR. uVOVal
	IF ! uWasLocked
		lRetCode := VoDbRlock( siCurrentRec )
	ENDIF
	IF ! lRetCode
		BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
	ELSE
		// Store our 'current record'
 		aRLockVerifyBuffer := ArrayNew( wFieldCount )
 		FOR w := 1 UPTO wFieldCount
 			aRLockVerifyBuffer[w] := __DBSFieldGet(w)
 		NEXT
		// Get the current record buffer from disk and compare the fields
		// in the current buffer with our values.
		VoDbBuffRefresh( )
		FOR w := 1 UPTO wFieldCount
			uValue := __DBSFieldGet( w )
			//
			IF aOriginalBuffer[BUFFER_IS_BLOB, w]
				// Field was a blob. Compare field types
				IF UsualType(aOriginalBuffer[BUFFER_VALUE, w]) != UsualType(uValue)
					lRetCode := FALSE
				ENDIF
			ELSEIF ! ( aOriginalBuffer[BUFFER_VALUE, w] == uValue )
				// Field has changed.
				// Test for float fields with non-relevant differences
				IF IsFloat(uValue)
				   nDiff := 10 ^ -(aStruct[w, DBS_DEC])
				   IF Abs(aOriginalBuffer[BUFFER_VALUE, w] - uValue) > nDiff
					   lRetCode := FALSE
				   ENDIF
				ELSE
				   lRetCode := FALSE
				ENDIF
			//ELSE
				// The field has not changed
			ENDIF
			IF ! lRetCode
				oHLStatus := HyperLabel{ #RECORDCHANGED,  ;
					__CavoStr( __CAVOSTR_DBFCLASS_RECORDCHANGED_CAPTION ),  ;
					__CavoStr( __CAVOSTR_DBFCLASS_RECORDCHANGED ), NIL }
				oErrorInfo := NULL_OBJECT
				lErrorFlag := TRUE
				EXIT
			ENDIF
		NEXT
      // restore the 'current record' in the buffer
 		FOR w := 1 UPTO wFieldCount
 			IF ! VoDbFieldPut( w, aRLockVerifyBuffer[w] )
 				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
 			ENDIF
 		NEXT

		IF ! lRetCode .AND. ! uWasLocked
			VoDbUnlock( siCurrentRec )
		ENDIF
	ENDIF

	RETURN lRetCode

METHOD __SetAlias( cName AS STRING, aField AS ARRAY, nField AS DWORD) AS VOID STRICT
	LOCAL cAlias AS STRING
	LOCAL oFSpec AS FieldSpec

	cAlias := "_" + cName
	oFSpec := FieldSpec{ cAlias, aField[DBS_TYPE], aField[DBS_LEN], aField[DBS_DEC] }
	SELF:aDataFields[nField] := DataField{ cName, oFSpec }

	RETURN

METHOD __SetStatusHL( uFuncSym AS USUAL, uGenCode AS USUAL, uMessage AS USUAL ) AS VOID STRICT

	lErrorFlag := TRUE
	oErrorInfo := NULL_OBJECT
	IF ! IsString( uGenCode )
		uGenCode := AsString( uGenCode )
	ENDIF
	oHLStatus := HyperLabel{ uFuncSym, uGenCode, uMessage, NIL }

	RETURN

METHOD __SetupLocks( )  AS VOID STRICT
	LOCAL w AS DWORD
	LOCAL uFlock AS USUAL

	nLastLock := 0
	DO CASE
	CASE nEffectiveCCMode == ccNone
		//nothing to do

	CASE nEffectiveCCMode == ccOptimistic
		FOR w := 1 UPTO wFieldCount
			aCurrentBuffer[BUFFER_VALUE, w]   := NIL
			aCurrentBuffer[BUFFER_IS_CHANGED, w] := FALSE
		NEXT
		lCCOptimisticRecChg := FALSE
		SELF:__InitRecordBuf()

	CASE nEffectiveCCMode == ccStable .OR. nEffectiveCCMode == ccRepeatable
		IF ! VoDbInfo( DBI_ISFLOCK, REF uFlock )
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF
		IF ! uFlock
			nLastLock := SELF:RecNo
			IF ! SELF:RLock( nLastLock )
				nLastLock := 0
				oHLStatus := SELF:Status
			ENDIF
		ENDIF

	CASE nEffectiveCCMode == ccFile
		IF ! SELF:FLock( )
			oHLStatus := SELF:Status
		ENDIF

	OTHERWISE
		oErrorInfo := DbError{ SELF, #ConcurrencyControl, EG_ARG,  ;
			__CavoStr( __CAVOSTR_DBFCLASS_BADCONCURRENCYASSIGN ), nCCMode, "nCCMode" }
		SELF:Error( oErrorInfo, #ConcurrencyControl )
	ENDCASE

	RETURN
CONSTRUCTOR( cFile AS STRING, lShareMode := FALSE AS OBJECT, lReadOnlyMode := FALSE AS OBJECT, xDriver:= "" AS STRING, aRdd := NULL_ARRAY AS ARRAY)
    SELF(FileSpec{cFile}, lShareMode, lReadOnlyMode , xDriver, aRdd )

CONSTRUCTOR( oFS AS FileSpec, lShareMode := FALSE AS OBJECT, lReadOnlyMode := FALSE AS OBJECT, xDriver:= "" AS STRING, aRdd := NULL_ARRAY AS ARRAY)
	LOCAL dwCurrentWorkArea := 0 AS DWORD
	LOCAL cFileName AS STRING
	LOCAL w AS DWORD
	LOCAL n AS DWORD
	LOCAL oError AS USUAL
	LOCAL symTemp AS SYMBOL
	LOCAL cTemp AS STRING
	LOCAL rddList AS _RddList
	LOCAL uTemp AS USUAL
	LOCAL aField AS ARRAY
	LOCAL uProps AS USUAL
	LOCAL wProps AS DWORD
	LOCAL lRetCode AS LOGIC

	SUPER( )

	aRelationChildren := { }

	lErrorFlag := FALSE
	BEGIN SEQUENCE
		siSuspendNotification := 0
		dwCurrentWorkArea := VoDbGetSelect( )

		IF Empty( oFS:Extension )
			oFS:Extension := ".DBF"
		ENDIF
		oFileSpec := oFS

		cFileName := oFileSpec:FileName

		symAlias := SELF:ConstructUniqueAlias( cFileName )

		IF lShareMode  == NULL
			SELF:lShared := ! SetExclusive( )
		ELSEIF lShareMode  IS LOGIC
			SELF:lShared := (LOGIC) lShareMode
		ELSEIF lShareMode IS SYMBOL VAR symShareMode
			IF symShareMode = #Shared
				SELF:lShared := TRUE
			ELSEIF symShareMode = #Exclusive
				SELF:lShared := FALSE
			ELSE
				BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADSHAREMODE ),  ;
					lShareMode, "lShareMode" }
			ENDIF

		ELSEIF lShareMode IS STRING VAR strShareMode
			symTemp := String2Symbol( strShareMode )
			IF symTemp = #Shared
				SELF:lShared := TRUE
			ELSEIF symTemp = #Exclusive
				SELF:lShared := FALSE
			ELSE
				BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADSHAREMODE ),  ;
					lShareMode, "lShareMode" }
			ENDIF
		ELSE
			BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADSHAREMODE ),  ;
				lShareMode, "lShareMode" }
		ENDIF

		IF lReadOnlyMode == NULL
			lReadOnly := FALSE
		ELSEIF lReadOnlyMode IS LOGIC
			lReadOnly := (LOGIC) lReadOnlyMode
		ELSEIF lReadOnlyMode  IS SYMBOL VAR symReadOnlyMode
			IF symReadOnlyMode = #ReadOnly
				lReadOnly := TRUE
			ELSEIF symReadOnlyMode = #ReadWrite
				lReadOnly := FALSE
			ELSE
				BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADREADONLYMODE ),  ;
					lReadOnlyMode, "lReadOnlyMode" }
			ENDIF
		ELSEIF lReadOnlyMode IS STRING VAR strReadOnlyMode
			symTemp := String2Symbol( strReadOnlyMode)
			IF symTemp = #ReadOnly
				lReadOnly := TRUE
			ELSEIF symTemp = #ReadWrite
				lReadOnly := FALSE
			ELSE
				BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADREADONLYMODE ),  ;
					lReadOnlyMode, "lReadOnlyMode" }
			ENDIF
		ELSE
			BREAK DbError{ SELF, #Init, EG_ARG, __CavoStr( __CAVOSTR_DBFCLASS_BADREADONLYMODE ),  ;
				lReadOnlyMode, "lReadOnlyMode" }
		ENDIF

		cTemp := Symbol2String( ClassName( SELF ) )
		oHyperLabel := HyperLabel{ cFileName, cFileName,  ;
			cTemp + ": " + cFileName + " " +  ;
			VO_Sprintf( __CAVOSTR_DBFCLASS_ALIAS, Symbol2String( symAlias ) ),  ;
			cTemp + "_" + cFileName }

		oHLStatus := NIL

		SELF:wWorkArea := VoDbSetSelect( -1 )

		IF ! ( IsArray( xDriver ) .OR. IsString( xDriver ) )
			xDriver := RddName( )
		ENDIF

		SELF:aRdds := __RDDList( xDriver, aRdd )
		rddList := __AllocRddList( aRdds )

		lRetCode := VoDbUseArea( FALSE, rddList, oFileSpec:FullPath, Symbol2String( symAlias ),  ;
			lShared, lReadOnly )

		IF ! lRetCode
			BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
		ENDIF

		SELF:cRDDName := RddName( )
        SELF:oRDD     := (XSharp.RDD.IRdd) DbInfo(DBI_RDD_OBJECT)

        SELF:nCCMode := SELF:nEffectiveCCMode := DbGetDefaultLockMode()
		IF lReadOnly .OR. ! lShared
			SELF:nEffectiveCCMode := ccNone
		ENDIF

		wFieldCount := FCount( )

		aStruct := ArrayCreate( wFieldCount )

		FOR w := 1 UPTO wFieldCount
			uProps := NIL
			IF ! VoDbFieldInfo( DBS_PROPERTIES, w, REF uProps )
				BREAK ErrorBuild( _VoDbErrInfoPtr( ) )
			ENDIF
			wProps := uProps
			aField := ArrayCreate( wProps )
			FOR n := 1 UPTO wProps
				VoDbFieldInfo( n, w, REF uTemp )
				aField[n] := uTemp
			NEXT
			aStruct[w] := aField
		NEXT

		aDataFields := ArrayNew( wFieldCount )

		aOriginalBuffer := ArrayNew( 2, wFieldCount )
		aCurrentBuffer  := ArrayNew( 2, wFieldCount )
		SELF:__InitRecordBuf( )

		__DBSSetSelect(dwCurrentWorkArea)

	RECOVER USING oError
		oErrorInfo := oError
		IF Used( )
			VoDbCloseArea( )
		ENDIF
		wWorkArea := 0
		__DBSSetSelect(dwCurrentWorkArea)
		oHLStatus := HyperLabel{ #NoTable, __CavoStr( __CAVOSTR_DBFCLASS_NOTABLE_CAPTION ),  ;
			__CavoStr( __CAVOSTR_DBFCLASS_NOTABLE ) }
		SELF:Error( oErrorInfo, #Init )
	END SEQUENCE

	SELF:nRetries := LockTries( )

	RETURN

END CLASS