QtQuickWidgets: dead code deletion

QtQuickWidgets: dead code deletion

/*

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

  Copyright (C) 2012-2017 Marcos Antonio Gambeta <marcosgambeta@uol.com.br>

*/

#include "hbclass.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QURL
REQUEST QQMLENGINE
REQUEST QQMLCONTEXT
REQUEST QQUICKITEM
REQUEST QQMLERROR
REQUEST QSIZE
REQUEST QSURFACEFORMAT
#endif

CLASS QQuickWidget INHERIT QWidget

   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   METHOD new1
   METHOD new2
   METHOD new3
   METHOD new
   METHOD delete
   METHOD source
   METHOD setSource
   METHOD engine
   METHOD rootContext
   METHOD rootObject
   METHOD resizeMode
   METHOD setResizeMode
   METHOD status
   METHOD errors
   METHOD sizeHint
   METHOD initialSize
   METHOD setContent
   METHOD format
   METHOD setFormat

   METHOD onStatusChanged
   METHOD onSceneGraphError

   DESTRUCTOR destroyObject

END CLASS

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

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
#include <QQuickWidget>
#endif
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_clsid.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
#include <QQuickWidget>
#endif
#endif

#include <QQmlError>

/*
explicit QQuickWidget(QWidget *parent = 0)
*/
HB_FUNC_STATIC( QQUICKWIDGET_NEW1 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QWidget * par1 = ISNIL(1)? 0 : (QWidget *) _qt5xhb_itemGetPtr(1);
  QQuickWidget * o = new QQuickWidget ( par1 );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

/*
QQuickWidget(QQmlEngine* engine, QWidget *parent)
*/
HB_FUNC_STATIC( QQUICKWIDGET_NEW2 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQmlEngine * par1 = (QQmlEngine *) _qt5xhb_itemGetPtr(1);
  QWidget * par2 = (QWidget *) _qt5xhb_itemGetPtr(2);
  QQuickWidget * o = new QQuickWidget ( par1, par2 );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

/*
QQuickWidget(const QUrl &source, QWidget *parent = 0)
*/
HB_FUNC_STATIC( QQUICKWIDGET_NEW3 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QUrl * par1 = (QUrl *) _qt5xhb_itemGetPtr(1);
  QWidget * par2 = ISNIL(2)? 0 : (QWidget *) _qt5xhb_itemGetPtr(2);
  QQuickWidget * o = new QQuickWidget ( *par1, par2 );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

//[1]explicit QQuickWidget(QWidget *parent = 0)
//[2]QQuickWidget(QQmlEngine* engine, QWidget *parent)
//[3]QQuickWidget(const QUrl &source, QWidget *parent = 0)

HB_FUNC_STATIC( QQUICKWIDGET_NEW )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  if( ISBETWEEN(0,1) && ISOPTQWIDGET(1) )
  {
    HB_FUNC_EXEC( QQUICKWIDGET_NEW1 );
  }
  else if( ISNUMPAR(2) && ISQQMLENGINE(1) && ISQWIDGET(2) )
  {
    HB_FUNC_EXEC( QQUICKWIDGET_NEW2 );
  }
  else if( ISBETWEEN(1,2) && ISQURL(1) && ISOPTQWIDGET(2) )
  {
    HB_FUNC_EXEC( QQUICKWIDGET_NEW3 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
#endif
}

HB_FUNC_STATIC( QQUICKWIDGET_DELETE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QUrl source() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_SOURCE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * ptr = new QUrl( obj->source (  ) );
    _qt5xhb_createReturnClass ( ptr, "QURL", true );
  }
#endif
}

/*
void setSource(const QUrl&)
*/
HB_FUNC_STATIC( QQUICKWIDGET_SETSOURCE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * par1 = (QUrl *) _qt5xhb_itemGetPtr(1);
    obj->setSource ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QQmlEngine* engine() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_ENGINE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QQmlEngine * ptr = obj->engine (  );
    _qt5xhb_createReturnClass ( ptr, "QQMLENGINE" );
  }
#endif
}

/*
QQmlContext* rootContext() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_ROOTCONTEXT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QQmlContext * ptr = obj->rootContext (  );
    _qt5xhb_createReturnClass ( ptr, "QQMLCONTEXT" );
  }
#endif
}

/*
QQuickItem *rootObject() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_ROOTOBJECT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QQuickItem * ptr = obj->rootObject (  );
    _qt5xhb_createReturnClass ( ptr, "QQUICKITEM" );
  }
#endif
}

/*
ResizeMode resizeMode() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_RESIZEMODE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->resizeMode (  ) );
  }
#endif
}

/*
void setResizeMode(ResizeMode)
*/
HB_FUNC_STATIC( QQUICKWIDGET_SETRESIZEMODE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setResizeMode (  (QQuickWidget::ResizeMode) par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
Status status() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_STATUS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->status (  ) );
  }
#endif
}

/*
QList<QQmlError> errors() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_ERRORS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QList<QQmlError> list = obj->errors (  );
    PHB_DYNS pDynSym;
    #ifdef __XHARBOUR__
    pDynSym = hb_dynsymFind( "QQMLERROR" );
    #else
    pDynSym = hb_dynsymFindName( "QQMLERROR" );
    #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, (QQmlError *) new QQmlError ( list[i] ) );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_itemRelease( pItem );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
      }
    }
    hb_itemReturnRelease(pArray);
  }
#endif
}

/*
QSize sizeHint() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_SIZEHINT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSize * ptr = new QSize( obj->sizeHint (  ) );
    _qt5xhb_createReturnClass ( ptr, "QSIZE", true );
  }
#endif
}

/*
QSize initialSize() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_INITIALSIZE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSize * ptr = new QSize( obj->initialSize (  ) );
    _qt5xhb_createReturnClass ( ptr, "QSIZE", true );
  }
#endif
}

/*
void setContent(const QUrl& url, QQmlComponent *component, QObject *item)
*/
HB_FUNC_STATIC( QQUICKWIDGET_SETCONTENT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * par1 = (QUrl *) _qt5xhb_itemGetPtr(1);
    QQmlComponent * par2 = (QQmlComponent *) _qt5xhb_itemGetPtr(2);
    QObject * par3 = (QObject *) _qt5xhb_itemGetPtr(3);
    obj->setContent ( *par1, par2, par3 );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QSurfaceFormat format() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_FORMAT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSurfaceFormat * ptr = new QSurfaceFormat( obj->format (  ) );
    _qt5xhb_createReturnClass ( ptr, "QSURFACEFORMAT" );
  }
#endif
}

/*
void setFormat(const QSurfaceFormat &format)
*/
HB_FUNC_STATIC( QQUICKWIDGET_SETFORMAT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSurfaceFormat * par1 = (QSurfaceFormat *) _qt5xhb_itemGetPtr(1);
    obj->setFormat ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

#pragma ENDDUMP

/*

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

  Copyright (C) 2012-2017 Marcos Antonio Gambeta <marcosgambeta@uol.com.br>

*/

#include "hbclass.ch"
//#include "qt5xhb_clsid.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QURL
REQUEST QQMLENGINE
REQUEST QQMLCONTEXT
REQUEST QQUICKITEM
REQUEST QQMLERROR
REQUEST QSIZE
REQUEST QSURFACEFORMAT
#endif

CLASS QQuickWidget INHERIT QWidget

   //DATA class_id INIT Class_Id_QQuickWidget
   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   METHOD new1
   METHOD new2
   METHOD new3
   METHOD new
   METHOD delete
   METHOD source
   METHOD setSource
   METHOD engine
   METHOD rootContext
   METHOD rootObject
   METHOD resizeMode
   METHOD setResizeMode
   METHOD status
   METHOD errors
   METHOD sizeHint
   METHOD initialSize
   METHOD setContent
   METHOD format
   METHOD setFormat

   METHOD onStatusChanged
   METHOD onSceneGraphError

   DESTRUCTOR destroyObject

END CLASS

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

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
#include <QQuickWidget>
#endif
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_clsid.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
#include <QQuickWidget>
#endif
#endif

#include <QQmlError>

/*
explicit QQuickWidget(QWidget *parent = 0)
*/
HB_FUNC_STATIC( QQUICKWIDGET_NEW1 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QWidget * par1 = ISNIL(1)? 0 : (QWidget *) _qt5xhb_itemGetPtr(1);
  QQuickWidget * o = new QQuickWidget ( par1 );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

/*
QQuickWidget(QQmlEngine* engine, QWidget *parent)
*/
HB_FUNC_STATIC( QQUICKWIDGET_NEW2 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQmlEngine * par1 = (QQmlEngine *) _qt5xhb_itemGetPtr(1);
  QWidget * par2 = (QWidget *) _qt5xhb_itemGetPtr(2);
  QQuickWidget * o = new QQuickWidget ( par1, par2 );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

/*
QQuickWidget(const QUrl &source, QWidget *parent = 0)
*/
HB_FUNC_STATIC( QQUICKWIDGET_NEW3 )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QUrl * par1 = (QUrl *) _qt5xhb_itemGetPtr(1);
  QWidget * par2 = ISNIL(2)? 0 : (QWidget *) _qt5xhb_itemGetPtr(2);
  QQuickWidget * o = new QQuickWidget ( *par1, par2 );
  _qt5xhb_storePointerAndFlag( o, false );
#endif
}

//[1]explicit QQuickWidget(QWidget *parent = 0)
//[2]QQuickWidget(QQmlEngine* engine, QWidget *parent)
//[3]QQuickWidget(const QUrl &source, QWidget *parent = 0)

HB_FUNC_STATIC( QQUICKWIDGET_NEW )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  if( ISBETWEEN(0,1) && ISOPTQWIDGET(1) )
  {
    HB_FUNC_EXEC( QQUICKWIDGET_NEW1 );
  }
  else if( ISNUMPAR(2) && ISQQMLENGINE(1) && ISQWIDGET(2) )
  {
    HB_FUNC_EXEC( QQUICKWIDGET_NEW2 );
  }
  else if( ISBETWEEN(1,2) && ISQURL(1) && ISOPTQWIDGET(2) )
  {
    HB_FUNC_EXEC( QQUICKWIDGET_NEW3 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
#endif
}

HB_FUNC_STATIC( QQUICKWIDGET_DELETE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QUrl source() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_SOURCE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * ptr = new QUrl( obj->source (  ) );
    _qt5xhb_createReturnClass ( ptr, "QURL", true );
  }
#endif
}

/*
void setSource(const QUrl&)
*/
HB_FUNC_STATIC( QQUICKWIDGET_SETSOURCE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * par1 = (QUrl *) _qt5xhb_itemGetPtr(1);
    obj->setSource ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QQmlEngine* engine() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_ENGINE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QQmlEngine * ptr = obj->engine (  );
    _qt5xhb_createReturnClass ( ptr, "QQMLENGINE" );
  }
#endif
}

/*
QQmlContext* rootContext() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_ROOTCONTEXT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QQmlContext * ptr = obj->rootContext (  );
    _qt5xhb_createReturnClass ( ptr, "QQMLCONTEXT" );
  }
#endif
}

/*
QQuickItem *rootObject() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_ROOTOBJECT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QQuickItem * ptr = obj->rootObject (  );
    _qt5xhb_createReturnClass ( ptr, "QQUICKITEM" );
  }
#endif
}

/*
ResizeMode resizeMode() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_RESIZEMODE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->resizeMode (  ) );
  }
#endif
}

/*
void setResizeMode(ResizeMode)
*/
HB_FUNC_STATIC( QQUICKWIDGET_SETRESIZEMODE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setResizeMode (  (QQuickWidget::ResizeMode) par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
Status status() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_STATUS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->status (  ) );
  }
#endif
}

/*
QList<QQmlError> errors() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_ERRORS )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QList<QQmlError> list = obj->errors (  );
    PHB_DYNS pDynSym;
    #ifdef __XHARBOUR__
    pDynSym = hb_dynsymFind( "QQMLERROR" );
    #else
    pDynSym = hb_dynsymFindName( "QQMLERROR" );
    #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, (QQmlError *) new QQmlError ( list[i] ) );
        hb_objSendMsg( pObject, "_POINTER", 1, pItem );
        hb_itemRelease( pItem );
        hb_arrayAddForward( pArray, pObject );
        hb_itemRelease( pObject );
      }
    }
    hb_itemReturnRelease(pArray);
  }
#endif
}

/*
QSize sizeHint() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_SIZEHINT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSize * ptr = new QSize( obj->sizeHint (  ) );
    _qt5xhb_createReturnClass ( ptr, "QSIZE", true );
  }
#endif
}

/*
QSize initialSize() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_INITIALSIZE )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSize * ptr = new QSize( obj->initialSize (  ) );
    _qt5xhb_createReturnClass ( ptr, "QSIZE", true );
  }
#endif
}

/*
void setContent(const QUrl& url, QQmlComponent *component, QObject *item)
*/
HB_FUNC_STATIC( QQUICKWIDGET_SETCONTENT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QUrl * par1 = (QUrl *) _qt5xhb_itemGetPtr(1);
    QQmlComponent * par2 = (QQmlComponent *) _qt5xhb_itemGetPtr(2);
    QObject * par3 = (QObject *) _qt5xhb_itemGetPtr(3);
    obj->setContent ( *par1, par2, par3 );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

/*
QSurfaceFormat format() const
*/
HB_FUNC_STATIC( QQUICKWIDGET_FORMAT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSurfaceFormat * ptr = new QSurfaceFormat( obj->format (  ) );
    _qt5xhb_createReturnClass ( ptr, "QSURFACEFORMAT" );
  }
#endif
}

/*
void setFormat(const QSurfaceFormat &format)
*/
HB_FUNC_STATIC( QQUICKWIDGET_SETFORMAT )
{
#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0))
  QQuickWidget * obj = (QQuickWidget *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QSurfaceFormat * par1 = (QSurfaceFormat *) _qt5xhb_itemGetPtr(1);
    obj->setFormat ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
#endif
}

#pragma ENDDUMP


[Runtime] doc update

[Runtime] doc update

//
// 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.
//
// Most of these settings will Get and Set properties of the Runtime.State class
#include "GetSet.xh"

USING XSharp

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setamext/*" />
FUNCTION SetAMExt() AS STRING
	GETSTATE STRING Set.AmExt

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setamext/*" />
FUNCTION SetAMExt(cAMExt AS STRING) AS STRING
	SETSTATE STRING Set.AmExt cAMExt

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setampm/*" />
FUNCTION SetAmPm() AS LOGIC
	GETSTATE LOGIC Set.AmPm

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setampm/*" />
FUNCTION SetAmPm(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.AmPm lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setansi/*" />
FUNCTION SetAnsi() AS LOGIC
	RETURN RuntimeState.Ansi

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setansi/*" />
FUNCTION SetAnsi(lNewSetting AS LOGIC) AS LOGIC
	LOCAL lOld := RuntimeState.Ansi AS LOGIC
	RuntimeState.Ansi := lNewSetting
    // Keep charset in sync with Ansi
    RuntimeState.SetValue<LONG>(Set.CharSet, IIF (lNewSetting, 0, 1))
	RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setbeep/*" />
FUNCTION SetBeep() AS LOGIC
	GETSTATE LOGIC Set.Bell

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setbeep/*" />
FUNCTION SetBeep(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Bell lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcentury/*" />
FUNCTION SetCentury() AS LOGIC
	RETURN RuntimeState.Century

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcentury/*" />
FUNCTION SetCentury(lNewSetting AS LOGIC) AS LOGIC
	LOCAL lOld AS LOGIC
    lOld := RuntimeState.Century
    IF lOld != lNewSetting
      VAR cFormat := XSharp.RuntimeState.DateFormat

      IF lNewSetting
        IF ! cFormat:Contains("YYYY")
            cFormat := cFormat:Replace( "YY", "YYYY" )
        ENDIF
      ELSE
        IF cFormat:Contains("YYYY")
            cFormat := cFormat:Replace( "YYYY", "YY" )
        ENDIF
      ENDIF

      SetDateFormat( cFormat )

    ENDIF
    RETURN lOld

FUNCTION SetCompatible() AS LOGIC
	RETURN RuntimeState.Compatible

FUNCTION SetCompatible(lNewSetting AS LOGIC) AS LOGIC
	VAR lOld := RuntimeState.Compatible
    RuntimeState.Compatible := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcpu/*" />
FUNCTION SetCpu() AS DWORD
	GETSTATE DWORD Set.Cpu

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcpu/*" />
FUNCTION SetCpu(nNewSetting AS DWORD) AS DWORD
   	SETSTATE DWORD Set.Cpu nNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdatecountry/*" />
FUNCTION SetDateCountry() AS DWORD
	RETURN RuntimeState.DateCountry

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdatecountry/*" />
FUNCTION SetDateCountry(dwNewSetting AS DWORD) AS DWORD
//	setstate DWORD Set.DATECOUNTRY nNewSetting
	LOCAL dwOld := RuntimeState.DateCountry AS DWORD
	RuntimeState.DateCountry := dwNewSetting
	RETURN dwOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/getdateformat/*" />
FUNCTION GetDateFormat() AS STRING
	GETSTATE STRING Set.DateFormat

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdateformat/*" />
FUNCTION SetDateFormat(cNewSetting AS STRING) AS STRING
	LOCAL cOld AS STRING
	// Changing Dateformat also changes DateCountry and Century
	cOld := RuntimeState.DateFormat
	RuntimeState.DateFormat := cNewSetting
	RETURN cOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdecimal/*" />
FUNCTION SetDecimal() AS DWORD
	RETURN RuntimeState.Decimals

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdecimal/*" />
FUNCTION SetDecimal(nNewSetting AS DWORD) AS DWORD
	VAR nOld := RuntimeState.Decimals
    RuntimeState.Decimals := nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdecimalsep/*" />
FUNCTION SetDecimalSep() AS DWORD
    RETURN RuntimeState.DecimalSep

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdecimalsep/*" />
FUNCTION SetDecimalSep(nNewSetting AS DWORD) AS DWORD
	LOCAL oCulture AS System.Globalization.CultureInfo
    VAR nOld := RuntimeState.DecimalSep
	oCulture := (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread:CurrentCulture:Clone()
	oCulture:NumberFormat:NumberDecimalSeparator := ((CHAR)nNewSetting):ToString()
	System.Threading.Thread.CurrentThread:CurrentCulture := oCulture
	RuntimeState.DecimalSep := nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdefault/*" />
FUNCTION SetDefault() AS STRING
	GETSTATE STRING Set.Default

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdefault/*" />
FUNCTION SetDefault(cPathSpec AS STRING) AS STRING
	SetPathArray(NULL)
    IF XSharp.RuntimeState.Dialect == XSharpDialect.FoxPro
        VAR cTemp := cPathSpec:Trim()
        IF cTemp:EndsWith(System.IO.Path.DirectorySeparatorChar:ToString())
            cTemp := cTemp:Substring(0, cTemp:Length-1)
        ENDIF
        IF ! System.IO.Directory.Exists(cTemp)
            var err := Error.VOError(EG_ARG, __FUNCTION__, nameof(cPathSpec),1, <OBJECT>{cPathSpec})
            err:Description := "Directory not found: '"+cPathSpec+"'"
            THROW err
        ENDIF
    ENDIF
	SETSTATE STRING Set.Default  cPathSpec

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdefaultdir/*" />
FUNCTION SetDefaultDir() AS STRING
	GETSTATE STRING Set.DefaultDir

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdefaultdir/*" />
FUNCTION SetDefaultDir(cPathSpec AS STRING) AS STRING
	SetPathArray(NULL)
	SETSTATE STRING Set.DefaultDir  cPathSpec

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdeleted/*" />
FUNCTION SetDeleted() AS LOGIC
	RETURN RuntimeState.Deleted

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdeleted/*" />
FUNCTION SetDeleted(lNewSetting AS LOGIC) AS LOGIC
    VAR lOld :=  RuntimeState.Deleted
    RuntimeState.Deleted := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdigit/*" />
FUNCTION SetDigit() AS DWORD
	RETURN RuntimeState.Digits

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdigit/*" />
FUNCTION SetDigit(nNewSetting AS DWORD) AS DWORD
    VAR nOld :=  RuntimeState.Digits
    RuntimeState.Digits := nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdigitfixed/*" />
FUNCTION SetDigitFixed() AS LOGIC
	RETURN RuntimeState.DigitsFixed

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdigitfixed/*" />
FUNCTION SetDigitFixed(lNewSetting AS LOGIC) AS LOGIC
    VAR lOld :=  RuntimeState.DigitsFixed
    RuntimeState.DigitsFixed := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setepoch/*" />
FUNCTION SetEpoch() AS DWORD
	RETURN RuntimeState.Epoch

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setepoch/*" />
FUNCTION SetEpoch(nNewSetting AS DWORD) AS DWORD
	LOCAL wYear AS DWORD
	LOCAL wCent AS DWORD
    VAR nOld := RuntimeState.Epoch
	wYear := nNewSetting % 100
	wCent := (( nNewSetting / 100) +1) * 100
	XSharp.RuntimeState.SetValue<DWORD> (Set.EpochYear, wYear)
	XSharp.RuntimeState.SetValue<DWORD> (Set.EpochCent, wCent)
	RuntimeState.Epoch := nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/seterrorlog/*" />
FUNCTION SetErrorLog() AS LOGIC
	GETSTATE LOGIC Set.Errorlog

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/seterrorlog/*" />
FUNCTION SetErrorLog(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Errorlog lNewSetting

/// Get the name of the current errorlog file
/// <returns>Current name of the error log file.</returns>
FUNCTION SetErrorLogFile() AS STRING
	GETSTATE STRING Set.ErrorLogFile

/// Set the name of the current errorlog file
/// <param name="cNewSetting">New name of error log file </param>
/// <returns>Previous name of the error log file.</returns>
FUNCTION SetErrorLogFile(cNewSetting AS STRING) AS STRING
	SETSTATE STRING Set.ErrorLogFile cNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setexact/*" />
FUNCTION SetExact() AS LOGIC
	RETURN RuntimeState.Exact

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setexact/*" />
FUNCTION SetExact(lNewSetting AS LOGIC) AS LOGIC
    VAR lOld :=  RuntimeState.Exact
    RuntimeState.Exact := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setexclusive/*" />
FUNCTION SetExclusive() AS LOGIC
	GETSTATE LOGIC Set.Exclusive

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setexclusive/*" />
FUNCTION SetExclusive(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Exclusive lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setfieldstore/*" />
FUNCTION SetFieldStore() AS LOGIC
	GETSTATE LOGIC Set.Fieldstore

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setfieldstore/*" />
FUNCTION SetFieldStore(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Fieldstore lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setfixed/*" />
FUNCTION SetFixed() AS LOGIC
	RETURN RuntimeState.Fixed

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setfixed/*" />
FUNCTION SetFixed(lNewSetting AS LOGIC) AS LOGIC
    VAR lOld :=  RuntimeState.Fixed
    RuntimeState.Fixed := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setmath/*" />
FUNCTION SetMath() AS DWORD
	GETSTATE DWORD Set.Math

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setmath/*" />
FUNCTION SetMath(nNewSetting AS DWORD) AS DWORD
	SETSTATE DWORD Set.Math nNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setnatdll/*" />
/// <remarks>
/// In Visual Objects the nation DLL is an external DLL. For X# there are no separate
/// nation DLL. The nation support code is integrated in XSharp.Core.DLL.
/// For compatibility you can still use the SetNatDLL() function to switch to another
/// nation module.

/// The available nation modules are (just like in Visual Objects):

/// 	"BRAZIL", "CROATIA", "CZECH852", "CZECH895", "DANISH", "DUTCH", "FINNISH",
/// 	"FRENCH", "GENERIC", "GERMAN", "GERMAN2", "HUNG852", "HUNGCWI", "ITALIAN",
///     "NORWEGN", "POL-ISO", "POL-MAZ", "POL852", "PORT850", "PORT860", "ROMANIA",
/// 	"RUSSIAN", "SERBIA", "SL-W-95", "SL-W-AS7", "SL-W-EE", "SLOV852", "SLOV895",
/// 	"SPANISH", "SWEDISH", "TURKISH", "UK"
///
 You may specify a DLL name with full path. The Runtime will strip the path and extension
/// from the file name and will look for one of the names listed above.

/// The nation DLL name is NOT case sensitive.
///</remarks>

FUNCTION SetNatDLL(cNewDLL AS STRING) AS LOGIC
	LOCAL cBase AS STRING
	_SetNatDLL(cNewDLL)
	cBase := System.IO.Path.GetFileNameWithoutExtension(cNewDLL)
	_SetCollation(cBase)
	RETURN String.Compare(Messages.CurrentLanguageName, cBase, TRUE) == 0

/// <exclude/>
FUNCTION _SetCollation(cBase AS STRING) AS LOGIC
	VAR rm := System.Resources.ResourceManager{ "XSharp.Collations", TYPEOF(Functions):Assembly }
	VAR obj := rm:GetObject(cBase:ToUpper())
	IF obj != NULL
		VAR bytes := obj ASTYPE BYTE[]
		IF bytes != NULL
			XSharp.RuntimeState.CollationTable := bytes
			RETURN TRUE
		ENDIF
	ENDIF
	RETURN FALSE
/// <exclude/>
INTERNAL FUNCTION	_SetNatDLL(cNewDLL AS STRING) AS STRING
	LOCAL cBase AS STRING
	cBase := System.IO.Path.GetFileNameWithoutExtension(cNewDLL)
	Messages.SetCurrentLanguage(cBase)
	SETSTATE STRING Set.NatDLL cNewDLL

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setpath/*" />
FUNCTION SetPath() AS STRING
	GETSTATE STRING Set.Path

/// <exclude/>
FUNCTION _SetDict() AS LOGIC
    GETSTATE LOGIC Set.Dict

/// <exclude/>
FUNCTION _SetDict(lNewSetting AS LOGIC) AS LOGIC
    SETSTATE LOGIC Set.Dict lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setpath/*" />
FUNCTION SetPath(cPathList AS STRING) AS STRING
	SetPathArray(NULL)
	SETSTATE STRING Set.Path cPathList

///
/// Return the Path array that is used by the File() function to locate files outside of the current directory.
/// This is a combination of the SetDefault() and SetPath() variables.
/// This may be null if the file function has never been called or never been called for files outside of the current
/// directory.
///
/// <returns>
/// </returns>
FUNCTION SetPathArray() AS STRING[]
	GETSTATE STRING[] Set.Patharray

///
/// Set the Path array that is used by the File() function to locate files outside of the current directory.
/// This is a combination of the SetDefault() and SetPath() variables.
/// This array gets cleared when SetPath() or SetDefault() is called and is initialized the first time File() or a related function
//  is called after the path has been changed.
///
/// <param name="aPath"></param>
/// <returns>
/// </returns>
FUNCTION SetPathArray(aPath AS STRING[]) AS STRING[]
	SETSTATE STRING[] Set.Patharray aPath

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setpmext/*" />
FUNCTION SetPMExt() AS STRING
	GETSTATE STRING Set.PmExt

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setpmext/*" />
FUNCTION SetPMExt(cPMExt AS STRING) AS STRING
	SETSTATE STRING Set.PmExt cPMExt

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setscience/*" />
FUNCTION SetScience() AS LOGIC
	GETSTATE LOGIC Set.Science

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setscience/*" />
FUNCTION SetScience(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Science lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setsoftseek/*" />
FUNCTION SetSoftSeek() AS LOGIC
	RETURN RuntimeState.SoftSeek

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setsoftseek/*" />
FUNCTION SetSoftSeek(lNewSetting AS LOGIC) AS LOGIC
	VAR lOld := RuntimeState.SoftSeek
    RuntimeState.SoftSeek := lNewSetting
    RETURN lOld

FUNCTION SetSafety() AS LOGIC
	RETURN RuntimeState.Safety

FUNCTION SetSafety(lNewSetting AS LOGIC) AS LOGIC
	VAR lOld := RuntimeState.Safety
    RuntimeState.Safety := lNewSetting
    RETURN lOld

///
/// Return the setting that determines whether a space is displayed between fields or expressions when you use the ? or ?? command.
///
/// <returns>
/// </returns>
FUNCTION SetSpace() AS LOGIC
	GETSTATE LOGIC Set.Space

///
/// Change the setting that determines whether a space is displayed between fields or expressions when you use the ? or ?? command.
///
/// <param name="lSet"></param>
/// <returns>
/// </returns>
FUNCTION SetSpace(lSet AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Space lSet

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setthousandsep/*" />
FUNCTION SetThousandSep() AS DWORD
	RETURN RuntimeState.ThousandSep

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setthousandsep/*" />
FUNCTION SetThousandSep(nNewSetting AS DWORD) AS DWORD
	LOCAL oCulture AS System.Globalization.CultureInfo
    VAR nOld := RuntimeState.ThousandSep
	oCulture := (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread:CurrentCulture:Clone()
	oCulture:NumberFormat:NumberGroupSeparator := ((CHAR)nNewSetting):ToString()
	System.Threading.Thread.CurrentThread:CurrentCulture := oCulture
    RuntimeState.ThousandSep :=  nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/settimesep/*" />
FUNCTION SetTimeSep() AS DWORD
	GETSTATE DWORD Set.Timesep

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/settimesep/*" />
FUNCTION SetTimeSep(dwNewSetting AS DWORD) AS DWORD
	SETSTATE DWORD Set.Timesep dwNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setunique/*" />
FUNCTION SetUnique() AS LOGIC
	RETURN RuntimeState.Unique

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setunique/*" />
FUNCTION SetUnique(lNewSetting AS LOGIC) AS LOGIC
	VAR lOld := RuntimeState.Unique
    RuntimeState.Unique := lNewSetting
    RETURN lOld

///
///
/// <returns>
/// </returns>
FUNCTION SetYield() AS LOGIC
	GETSTATE LOGIC Set.Yield

///
///
/// <param name="lSet"></param>
/// <returns>
/// </returns>
FUNCTION SetYield(lSet AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Yield lSet

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/errorlevel/*" />
FUNCTION ErrorLevel(dwNewSetting AS DWORD) AS DWORD
	SETSTATE DWORD Set.ErrorLevel dwNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/errorlevel/*" />
FUNCTION ErrorLevel() AS DWORD
	GETSTATE DWORD Set.ErrorLevel

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setinternational/*" />
FUNCTION SetInternational() AS STRING
	RETURN RuntimeState.International:ToString():ToUpper()

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setinternational/*" />
/// <remarks>
/// SetInternational() allows XSharp apps to operate in different international modes.
/// The "CLIPPER" mode is provided for compatibility with CA-Clipper applications and uses an
/// internationalization routine defined in the nation module.

/// The "Windows" mode uses international services provided by Windows.
/// When you set this mode several settings will be changed
/// <list type="table">
/// <listheader>
/// <term>Setting</term> <description>Initial value in CLIPPER mode</description>
/// </listheader>
///	<item><term>SetAmExt</term> <description>Empty String</description></item>
/// <item><term>SetPmExt</term> <description>Empty String</description></item>
/// <item><term>SetAmPm</term> <description>FALSE (24 hour format)</description></item>
/// <item><term>SetCentury</term> <description>FALSE</description></item>
/// <item><term>SetDateCountry</term> <description>American (1)</description></item>
/// <item><term>SetDateFormat</term> <description>mm/dd/yy</description></item>
/// <item><term>SetDecimal</term> <description>2</description></item>
/// <item><term>SetDecimalSep</term> <description>Period (.)</description></item>
/// <item><term>SetThousandSep</term> <description>Comma (,)</description></item>
/// <item><term>SetTimeSep</term> <description>Colon(:)</description></item>
/// </list>
/// </remarks>
FUNCTION SetInternational(symNewSetting AS STRING) AS STRING
	LOCAL cOld AS STRING
	cOld := RuntimeState.International:ToString():ToUpper()
	SWITCH symNewSetting:ToUpper()
	CASE "CLIPPER"
	CASE "XPP"
		RuntimeState.GetInstance()._SetInternationalClipper()
	CASE "WINDOWS"
	CASE "UNICODE"
	CASE "ORDINAL"
		RuntimeState.GetInstance()._SetInternationalWindows()
	OTHERWISE
		THROW Error.ArgumentError(__ENTITY__, NAMEOF(symNewSetting), "Unsupported international mode: "+ symNewSetting)
	END SWITCH
	RETURN cOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcollation/*" />
/// <remarks>
/// <include file="CoreComments.xml" path="Comments/Collation/*" />
/// </remarks>
FUNCTION SetCollation() AS STRING
	RETURN RuntimeState.CollationMode:ToString():ToUpper()

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcollation/*" />
/// <remarks>
/// <include file="CoreComments.xml" path="Comments/Collation/*" />
/// </remarks>
/// <returns>The current setting, either "Windows" (the default),  "Clipper", "Unicode" or "Ordinal" </returns>
/// <param name="cCollation">The collation mode to use. The available modes are "Windows" (the default),  "Clipper", "Unicode" and "Ordinal". </param>
FUNCTION SetCollation(symNewSetting AS STRING)  AS STRING
	LOCAL cOld AS STRING
	cOld := RuntimeState.CollationMode:ToString():ToUpper()
	SWITCH symNewSetting:ToUpper()
	CASE "CLIPPER"
		RuntimeState.CollationMode := CollationMode.Clipper
	CASE "XPP"
		RuntimeState.CollationMode := CollationMode.Xpp
	CASE "WINDOWS"
		RuntimeState.CollationMode := CollationMode.Windows
	CASE "UNICODE"
		RuntimeState.CollationMode := CollationMode.Unicode
	CASE "ORDINAL"
		RuntimeState.CollationMode := CollationMode.Ordinal
	OTHERWISE
		THROW Error.ArgumentError(__ENTITY__, NAMEOF(symNewSetting), "Unsupported collation mode: "+symNewSetting)
	END SWITCH
	RETURN cOld

FUNCTION SetTimeFormat(timeformat AS STRING) AS VOID
    RuntimeState.GetInstance():_SetTimeFormat(timeformat)

//
// 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.
//
// Most of these settings will Get and Set properties of the Runtime.State class
#include "GetSet.xh"

USING XSharp

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setamext/*" />
FUNCTION SetAMExt() AS STRING
	GETSTATE STRING Set.AmExt

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setamext/*" />
FUNCTION SetAMExt(cAMExt AS STRING) AS STRING
	SETSTATE STRING Set.AmExt cAMExt

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setampm/*" />
FUNCTION SetAmPm() AS LOGIC
	GETSTATE LOGIC Set.AmPm

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setampm/*" />
FUNCTION SetAmPm(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.AmPm lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setansi/*" />
FUNCTION SetAnsi() AS LOGIC
	RETURN RuntimeState.Ansi

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setansi/*" />
FUNCTION SetAnsi(lNewSetting AS LOGIC) AS LOGIC
	LOCAL lOld := RuntimeState.Ansi AS LOGIC
	RuntimeState.Ansi := lNewSetting
    // Keep charset in sync with Ansi
    RuntimeState.SetValue<LONG>(Set.CharSet, IIF (lNewSetting, 0, 1))
	RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setbeep/*" />
FUNCTION SetBeep() AS LOGIC
	GETSTATE LOGIC Set.Bell

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setbeep/*" />
FUNCTION SetBeep(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Bell lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcentury/*" />
FUNCTION SetCentury() AS LOGIC
	RETURN RuntimeState.Century

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcentury/*" />
FUNCTION SetCentury(lNewSetting AS LOGIC) AS LOGIC
	LOCAL lOld AS LOGIC
    lOld := RuntimeState.Century
    IF lOld != lNewSetting
      VAR cFormat := XSharp.RuntimeState.DateFormat

      IF lNewSetting
        IF ! cFormat:Contains("YYYY")
            cFormat := cFormat:Replace( "YY", "YYYY" )
        ENDIF
      ELSE
        IF cFormat:Contains("YYYY")
            cFormat := cFormat:Replace( "YYYY", "YY" )
        ENDIF
      ENDIF

      SetDateFormat( cFormat )

    ENDIF
    RETURN lOld

FUNCTION SetCompatible() AS LOGIC
	RETURN RuntimeState.Compatible

FUNCTION SetCompatible(lNewSetting AS LOGIC) AS LOGIC
	VAR lOld := RuntimeState.Compatible
    RuntimeState.Compatible := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcpu/*" />
FUNCTION SetCpu() AS DWORD
	GETSTATE DWORD Set.Cpu

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcpu/*" />
FUNCTION SetCpu(nNewSetting AS DWORD) AS DWORD
   	SETSTATE DWORD Set.Cpu nNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdatecountry/*" />
FUNCTION SetDateCountry() AS DWORD
	RETURN RuntimeState.DateCountry

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdatecountry/*" />
FUNCTION SetDateCountry(dwNewSetting AS DWORD) AS DWORD
//	setstate DWORD Set.DATECOUNTRY nNewSetting
	LOCAL dwOld := RuntimeState.DateCountry AS DWORD
	RuntimeState.DateCountry := dwNewSetting
	RETURN dwOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/getdateformat/*" />
FUNCTION GetDateFormat() AS STRING
	GETSTATE STRING Set.DateFormat

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdateformat/*" />
FUNCTION SetDateFormat(cNewSetting AS STRING) AS STRING
	LOCAL cOld AS STRING
	// Changing Dateformat also changes DateCountry and Century
	cOld := RuntimeState.DateFormat
	RuntimeState.DateFormat := cNewSetting
	RETURN cOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdecimal/*" />
FUNCTION SetDecimal() AS DWORD
	RETURN RuntimeState.Decimals

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdecimal/*" />
FUNCTION SetDecimal(nNewSetting AS DWORD) AS DWORD
	VAR nOld := RuntimeState.Decimals
    RuntimeState.Decimals := nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdecimalsep/*" />
FUNCTION SetDecimalSep() AS DWORD
    RETURN RuntimeState.DecimalSep

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdecimalsep/*" />
FUNCTION SetDecimalSep(nNewSetting AS DWORD) AS DWORD
	LOCAL oCulture AS System.Globalization.CultureInfo
    VAR nOld := RuntimeState.DecimalSep
	oCulture := (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread:CurrentCulture:Clone()
	oCulture:NumberFormat:NumberDecimalSeparator := ((CHAR)nNewSetting):ToString()
	System.Threading.Thread.CurrentThread:CurrentCulture := oCulture
	RuntimeState.DecimalSep := nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdefault/*" />
FUNCTION SetDefault() AS STRING
	GETSTATE STRING Set.Default

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdefault/*" />
FUNCTION SetDefault(cPathSpec AS STRING) AS STRING
	SetPathArray(NULL)
    IF XSharp.RuntimeState.Dialect == XSharpDialect.FoxPro
        VAR cTemp := cPathSpec:Trim()
        IF cTemp:EndsWith(System.IO.Path.DirectorySeparatorChar:ToString())
            cTemp := cTemp:Substring(0, cTemp:Length-1)
        ENDIF
        IF ! System.IO.Directory.Exists(cTemp)
            var err := Error.VOError(EG_ARG, __FUNCTION__, nameof(cPathSpec),1, <OBJECT>{cPathSpec})
            err:Description := "Directory not found: '"+cPathSpec+"'"
            THROW err
        ENDIF
    ENDIF
	SETSTATE STRING Set.Default  cPathSpec

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdefaultdir/*" />
FUNCTION SetDefaultDir() AS STRING
	GETSTATE STRING Set.DefaultDir

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdefaultdir/*" />
FUNCTION SetDefaultDir(cPathSpec AS STRING) AS STRING
	SetPathArray(NULL)
	SETSTATE STRING Set.DefaultDir  cPathSpec

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdeleted/*" />
FUNCTION SetDeleted() AS LOGIC
	RETURN RuntimeState.Deleted

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdeleted/*" />
FUNCTION SetDeleted(lNewSetting AS LOGIC) AS LOGIC
    VAR lOld :=  RuntimeState.Deleted
    RuntimeState.Deleted := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdigit/*" />
FUNCTION SetDigit() AS DWORD
	RETURN RuntimeState.Digits

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdigit/*" />
FUNCTION SetDigit(nNewSetting AS DWORD) AS DWORD
    VAR nOld :=  RuntimeState.Digits
    RuntimeState.Digits := nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdigitfixed/*" />
FUNCTION SetDigitFixed() AS LOGIC
	RETURN RuntimeState.DigitsFixed

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setdigitfixed/*" />
FUNCTION SetDigitFixed(lNewSetting AS LOGIC) AS LOGIC
    VAR lOld :=  RuntimeState.DigitsFixed
    RuntimeState.DigitsFixed := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setepoch/*" />
FUNCTION SetEpoch() AS DWORD
	RETURN RuntimeState.Epoch

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setepoch/*" />
FUNCTION SetEpoch(nNewSetting AS DWORD) AS DWORD
	LOCAL wYear AS DWORD
	LOCAL wCent AS DWORD
    VAR nOld := RuntimeState.Epoch
	wYear := nNewSetting % 100
	wCent := (( nNewSetting / 100) +1) * 100
	XSharp.RuntimeState.SetValue<DWORD> (Set.EpochYear, wYear)
	XSharp.RuntimeState.SetValue<DWORD> (Set.EpochCent, wCent)
	RuntimeState.Epoch := nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/seterrorlog/*" />
FUNCTION SetErrorLog() AS LOGIC
	GETSTATE LOGIC Set.Errorlog

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/seterrorlog/*" />
FUNCTION SetErrorLog(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Errorlog lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/seterrorlog/*" />
FUNCTION SetErrorLogFile() AS STRING
	GETSTATE STRING Set.ErrorLogFile

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/seterrorlog/*" />
FUNCTION SetErrorLogFile(cNewSetting AS STRING) AS STRING
	SETSTATE STRING Set.ErrorLogFile cNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setexact/*" />
FUNCTION SetExact() AS LOGIC
	RETURN RuntimeState.Exact

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setexact/*" />
FUNCTION SetExact(lNewSetting AS LOGIC) AS LOGIC
    VAR lOld :=  RuntimeState.Exact
    RuntimeState.Exact := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setexclusive/*" />
FUNCTION SetExclusive() AS LOGIC
	GETSTATE LOGIC Set.Exclusive

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setexclusive/*" />
FUNCTION SetExclusive(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Exclusive lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setfieldstore/*" />
FUNCTION SetFieldStore() AS LOGIC
	GETSTATE LOGIC Set.Fieldstore

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setfieldstore/*" />
FUNCTION SetFieldStore(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Fieldstore lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setfixed/*" />
FUNCTION SetFixed() AS LOGIC
	RETURN RuntimeState.Fixed

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setfixed/*" />
FUNCTION SetFixed(lNewSetting AS LOGIC) AS LOGIC
    VAR lOld :=  RuntimeState.Fixed
    RuntimeState.Fixed := lNewSetting
    RETURN lOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setmath/*" />
FUNCTION SetMath() AS DWORD
	GETSTATE DWORD Set.Math

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setmath/*" />
FUNCTION SetMath(nNewSetting AS DWORD) AS DWORD
	SETSTATE DWORD Set.Math nNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setnatdll/*" />
/// <remarks>
/// In Visual Objects the nation DLL is an external DLL. For X# there are no separate
/// nation DLL. The nation support code is integrated in XSharp.Core.DLL.
/// For compatibility you can still use the SetNatDLL() function to switch to another
/// nation module.

/// The available nation modules are (just like in Visual Objects):

/// 	"BRAZIL", "CROATIA", "CZECH852", "CZECH895", "DANISH", "DUTCH", "FINNISH",
/// 	"FRENCH", "GENERIC", "GERMAN", "GERMAN2", "HUNG852", "HUNGCWI", "ITALIAN",
///     "NORWEGN", "POL-ISO", "POL-MAZ", "POL852", "PORT850", "PORT860", "ROMANIA",
/// 	"RUSSIAN", "SERBIA", "SL-W-95", "SL-W-AS7", "SL-W-EE", "SLOV852", "SLOV895",
/// 	"SPANISH", "SWEDISH", "TURKISH", "UK"
///
 You may specify a DLL name with full path. The Runtime will strip the path and extension
/// from the file name and will look for one of the names listed above.

/// The nation DLL name is NOT case sensitive.
///</remarks>

FUNCTION SetNatDLL(cNewDLL AS STRING) AS LOGIC
	LOCAL cBase AS STRING
	_SetNatDLL(cNewDLL)
	cBase := System.IO.Path.GetFileNameWithoutExtension(cNewDLL)
	_SetCollation(cBase)
	RETURN String.Compare(Messages.CurrentLanguageName, cBase, TRUE) == 0

/// <exclude/>
FUNCTION _SetCollation(cBase AS STRING) AS LOGIC
	VAR rm := System.Resources.ResourceManager{ "XSharp.Collations", TYPEOF(Functions):Assembly }
	VAR obj := rm:GetObject(cBase:ToUpper())
	IF obj != NULL
		VAR bytes := obj ASTYPE BYTE[]
		IF bytes != NULL
			XSharp.RuntimeState.CollationTable := bytes
			RETURN TRUE
		ENDIF
	ENDIF
	RETURN FALSE
/// <exclude/>
INTERNAL FUNCTION	_SetNatDLL(cNewDLL AS STRING) AS STRING
	LOCAL cBase AS STRING
	cBase := System.IO.Path.GetFileNameWithoutExtension(cNewDLL)
	Messages.SetCurrentLanguage(cBase)
	SETSTATE STRING Set.NatDLL cNewDLL

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setpath/*" />
FUNCTION SetPath() AS STRING
	GETSTATE STRING Set.Path

/// <exclude/>
FUNCTION _SetDict() AS LOGIC
    GETSTATE LOGIC Set.Dict

/// <exclude/>
FUNCTION _SetDict(lNewSetting AS LOGIC) AS LOGIC
    SETSTATE LOGIC Set.Dict lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setpath/*" />
FUNCTION SetPath(cPathList AS STRING) AS STRING
	SetPathArray(NULL)
	SETSTATE STRING Set.Path cPathList

///
/// Return the Path array that is used by the File() function to locate files outside of the current directory.
/// This is a combination of the SetDefault() and SetPath() variables.
/// This may be null if the file function has never been called or never been called for files outside of the current
/// directory.
///
/// <returns>
/// </returns>
FUNCTION SetPathArray() AS STRING[]
	GETSTATE STRING[] Set.Patharray

///
/// Set the Path array that is used by the File() function to locate files outside of the current directory.
/// This is a combination of the SetDefault() and SetPath() variables.
/// This array gets cleared when SetPath() or SetDefault() is called and is initialized the first time File() or a related function
//  is called after the path has been changed.
///
/// <param name="aPath"></param>
/// <returns>
/// </returns>
FUNCTION SetPathArray(aPath AS STRING[]) AS STRING[]
	SETSTATE STRING[] Set.Patharray aPath

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setpmext/*" />
FUNCTION SetPMExt() AS STRING
	GETSTATE STRING Set.PmExt

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setpmext/*" />
FUNCTION SetPMExt(cPMExt AS STRING) AS STRING
	SETSTATE STRING Set.PmExt cPMExt

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setscience/*" />
FUNCTION SetScience() AS LOGIC
	GETSTATE LOGIC Set.Science

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setscience/*" />
FUNCTION SetScience(lNewSetting AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Science lNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setsoftseek/*" />
FUNCTION SetSoftSeek() AS LOGIC
	RETURN RuntimeState.SoftSeek

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setsoftseek/*" />
FUNCTION SetSoftSeek(lNewSetting AS LOGIC) AS LOGIC
	VAR lOld := RuntimeState.SoftSeek
    RuntimeState.SoftSeek := lNewSetting
    RETURN lOld

FUNCTION SetSafety() AS LOGIC
	RETURN RuntimeState.Safety

FUNCTION SetSafety(lNewSetting AS LOGIC) AS LOGIC
	VAR lOld := RuntimeState.Safety
    RuntimeState.Safety := lNewSetting
    RETURN lOld

///
/// Return the setting that determines whether a space is displayed between fields or expressions when you use the ? or ?? command.
///
/// <returns>
/// </returns>
FUNCTION SetSpace() AS LOGIC
	GETSTATE LOGIC Set.Space

///
/// Change the setting that determines whether a space is displayed between fields or expressions when you use the ? or ?? command.
///
/// <param name="lSet"></param>
/// <returns>
/// </returns>
FUNCTION SetSpace(lSet AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Space lSet

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setthousandsep/*" />
FUNCTION SetThousandSep() AS DWORD
	RETURN RuntimeState.ThousandSep

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setthousandsep/*" />
FUNCTION SetThousandSep(nNewSetting AS DWORD) AS DWORD
	LOCAL oCulture AS System.Globalization.CultureInfo
    VAR nOld := RuntimeState.ThousandSep
	oCulture := (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread:CurrentCulture:Clone()
	oCulture:NumberFormat:NumberGroupSeparator := ((CHAR)nNewSetting):ToString()
	System.Threading.Thread.CurrentThread:CurrentCulture := oCulture
    RuntimeState.ThousandSep :=  nNewSetting
    RETURN nOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/settimesep/*" />
FUNCTION SetTimeSep() AS DWORD
	GETSTATE DWORD Set.Timesep

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/settimesep/*" />
FUNCTION SetTimeSep(dwNewSetting AS DWORD) AS DWORD
	SETSTATE DWORD Set.Timesep dwNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setunique/*" />
FUNCTION SetUnique() AS LOGIC
	RETURN RuntimeState.Unique

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setunique/*" />
FUNCTION SetUnique(lNewSetting AS LOGIC) AS LOGIC
	VAR lOld := RuntimeState.Unique
    RuntimeState.Unique := lNewSetting
    RETURN lOld

///
///
/// <returns>
/// </returns>
FUNCTION SetYield() AS LOGIC
	GETSTATE LOGIC Set.Yield

///
///
/// <param name="lSet"></param>
/// <returns>
/// </returns>
FUNCTION SetYield(lSet AS LOGIC) AS LOGIC
	SETSTATE LOGIC Set.Yield lSet

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/errorlevel/*" />
FUNCTION ErrorLevel(dwNewSetting AS DWORD) AS DWORD
	SETSTATE DWORD Set.ErrorLevel dwNewSetting

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/errorlevel/*" />
FUNCTION ErrorLevel() AS DWORD
	GETSTATE DWORD Set.ErrorLevel

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setinternational/*" />
FUNCTION SetInternational() AS STRING
	RETURN RuntimeState.International:ToString():ToUpper()

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setinternational/*" />
/// <remarks>
/// SetInternational() allows XSharp apps to operate in different international modes.
/// The "CLIPPER" mode is provided for compatibility with CA-Clipper applications and uses an
/// internationalization routine defined in the nation module.

/// The "Windows" mode uses international services provided by Windows.
/// When you set this mode several settings will be changed
/// <list type="table">
/// <listheader>
/// <term>Setting</term> <description>Initial value in CLIPPER mode</description>
/// </listheader>
///	<item><term>SetAmExt</term> <description>Empty String</description></item>
/// <item><term>SetPmExt</term> <description>Empty String</description></item>
/// <item><term>SetAmPm</term> <description>FALSE (24 hour format)</description></item>
/// <item><term>SetCentury</term> <description>FALSE</description></item>
/// <item><term>SetDateCountry</term> <description>American (1)</description></item>
/// <item><term>SetDateFormat</term> <description>mm/dd/yy</description></item>
/// <item><term>SetDecimal</term> <description>2</description></item>
/// <item><term>SetDecimalSep</term> <description>Period (.)</description></item>
/// <item><term>SetThousandSep</term> <description>Comma (,)</description></item>
/// <item><term>SetTimeSep</term> <description>Colon(:)</description></item>
/// </list>
/// </remarks>
FUNCTION SetInternational(symNewSetting AS STRING) AS STRING
	LOCAL cOld AS STRING
	cOld := RuntimeState.International:ToString():ToUpper()
	SWITCH symNewSetting:ToUpper()
	CASE "CLIPPER"
	CASE "XPP"
		RuntimeState.GetInstance()._SetInternationalClipper()
	CASE "WINDOWS"
	CASE "UNICODE"
	CASE "ORDINAL"
		RuntimeState.GetInstance()._SetInternationalWindows()
	OTHERWISE
		THROW Error.ArgumentError(__ENTITY__, NAMEOF(symNewSetting), "Unsupported international mode: "+ symNewSetting)
	END SWITCH
	RETURN cOld

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcollation/*" />
/// <remarks>
/// <include file="CoreComments.xml" path="Comments/Collation/*" />
/// </remarks>
FUNCTION SetCollation() AS STRING
	RETURN RuntimeState.CollationMode:ToString():ToUpper()

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/setcollation/*" />
/// <remarks>
/// <include file="CoreComments.xml" path="Comments/Collation/*" />
/// </remarks>
/// <returns>The current setting, either "Windows" (the default),  "Clipper", "Unicode" or "Ordinal" </returns>
/// <param name="cCollation">The collation mode to use. The available modes are "Windows" (the default),  "Clipper", "Unicode" and "Ordinal". </param>
FUNCTION SetCollation(symNewSetting AS STRING)  AS STRING
	LOCAL cOld AS STRING
	cOld := RuntimeState.CollationMode:ToString():ToUpper()
	SWITCH symNewSetting:ToUpper()
	CASE "CLIPPER"
		RuntimeState.CollationMode := CollationMode.Clipper
	CASE "XPP"
		RuntimeState.CollationMode := CollationMode.Xpp
	CASE "WINDOWS"
		RuntimeState.CollationMode := CollationMode.Windows
	CASE "UNICODE"
		RuntimeState.CollationMode := CollationMode.Unicode
	CASE "ORDINAL"
		RuntimeState.CollationMode := CollationMode.Ordinal
	OTHERWISE
		THROW Error.ArgumentError(__ENTITY__, NAMEOF(symNewSetting), "Unsupported collation mode: "+symNewSetting)
	END SWITCH
	RETURN cOld

FUNCTION SetTimeFormat(timeformat AS STRING) AS VOID
    RuntimeState.GetInstance():_SetTimeFormat(timeformat)


[Runtime] Set default for Scope related functions to SCOPE_BOTH

//
// 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.
//
USING XSharp.Rdd.Support
USING XSharp.Rdd
///
///
/// <returns>
/// </returns>
FUNCTION DBClearOrderCondition()  AS LOGIC

	RETURN OrdCondSet("", NIL, .F., NIL, NIL, 0, 0, 0, 0, .F., .F.)

///
///
/// <returns>
/// </returns>
FUNCTION DbReindex() AS LOGIC
    // Don't call CoreDb because of error handling
	RETURN OrdListRebuild()

/// Move to the record having the specified key value in the controlling order.
///
FUNCTION DbSeek(xValue, lSoft, lLast) AS LOGIC CLIPPER
	LOCAL dbsci     AS DBSCOPEINFO
	LOCAL lRet      AS LOGIC

	DEFAULT(REF lSoft, SetSoftSeek())

	dbsci := DbScopeInfo{}
	IF lLast:IsNil
		lLast := FALSE
	ENDIF
	VoDb.SetScope( dbsci)
	DEFAULT(REF xValue, "")
    IF lRet := _DbThrowErrorOnFailure(__FUNCTION__, VoDb.Seek(xValue, lSoft, lLast))
	    lRet := VoDb.Found()
	    VoDb.SetScope(dbsci)
    ENDIF
	RETURN lRet

///
///
/// <returns>
/// </returns>
FUNCTION DbSetFound(lFnd AS LOGIC) AS LOGIC
	RETURN VoDb.SetFound(lFnd)

///
///
/// <returns>
/// </returns>
FUNCTION DbSetOrderCondition(  cFor, uCobFor, lAll, uCobWhile, uCobEval, nStep, nStart, nNext, nRecno, lRest, lDescending, lAdditive, lCurrent, lCustom, lNoOptimize) AS LOGIC CLIPPER
    // Don't call VoDb because of error handling
	RETURN OrdCondSet( cFor, uCobFor, lAll, uCobWhile, uCobEval, ;
		nStep, nStart, nNext, nRecno, lRest,      ;
		lDescending, lAdditive, lCurrent, lCustom, lNoOptimize)

/// Open an index file and add all its orders to the order list in a work area.
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION DbSetIndex(cIndex, uOrder) AS LOGIC CLIPPER
	// Don't call VoDb because of error handling
	IF cIndex:IsNil
		RETURN OrdListClear()
	ENDIF
	RETURN OrdListAdd(cIndex, uOrder)

/// Set the controlling order for a work area.
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION DbSetOrder(uOrder, cBagName) AS LOGIC CLIPPER
	DEFAULT( REF cBagName, "")
	RETURN VoDb.OrdSetFocus(cBagName, uOrder)

///
///
/// <returns>
/// </returns>
FUNCTION IndexCount() AS DWORD
	LOCAL nRet      AS DWORD
	IF Used()
		nRet := DbOrderInfo(DBOI_ORDERCOUNT)
    ELSE
        nRet := 0
	ENDIF

	RETURN nRet

/// Return the default index file extension for a work area as defined by its RDD.
/// <returns>A string indicating the default index file extension for a work area as defined by its RDD</returns>
FUNCTION IndexExt       () AS STRING STRICT
	RETURN VoDb.OrdBagExt()

/// Return the key expression of a specified order.
/// <returns>The key expression of the specified order.  If there is no corresponding order or if no database file is open, IndexKey() returns a NULL_STRING.</returns>
/// <param name='nPosition'>The position of the order in the order list of the work area.  A value of 0 specifies the controlling order, without regard to its actual position in the list.</param>
FUNCTION IndexKey(nPosition) AS STRING CLIPPER
	LOCAL uRetVal   AS USUAL
	IF nPosition:IsNil
		nPosition := 0
	ENDIF
	uRetVal := DbOrderInfo(DBOI_EXPRESSION, "", nPosition)
	RETURN uRetVal

/// Return the position of the controlling order within the order list.
/// <returns>The position of the controlling order.  A value of 0 indicates either that no database file is open or that there is no
/// controlling order and records are being accessed in natural order.</returns>
FUNCTION IndexOrd() AS INT STRICT
	LOCAL uRetVal := NIL AS USUAL
	uRetVal := DbOrderInfo(DBOI_NUMBER, "", NIL)
	DEFAULT( REF uRetVal, 0)
    RETURN uRetVal

/// Relate a specified work area to the current work area.

FUNCTION OrdSetRelation(cAlias, bKey, cKey) AS USUAL CLIPPER
	DbSetRelation(cAlias, bKey, cKey)
	(cAlias)->(OrdScope(0, bKey))
	(cAlias)->(OrdScope(1, bKey))
	RETURN NIL

/// Set or clear the boundaries for scoping key values in the controlling order.
FUNCTION OrdScope(nScope, xVal) AS USUAL CLIPPER
	LOCAL n     AS DWORD
	nScope := VoDb.OrdScopeNum(nScope)
	n := DBOI_SCOPETOP
	IF PCount() > 1 .AND. xVal:IsNil
		n := DBOI_SCOPETOPCLEAR
	ENDIF
	RETURN DbOrderInfo(n + nScope,,,xVal)

/// Move the record pointer to the next or previous unique key in the controlling order.
FUNCTION OrdSkipUnique(uCount) AS USUAL CLIPPER
	RETURN VoDb.OrderInfo ( DBOI_SKIPUNIQUE, "", NIL, uCount )

/// Return the status of the unique flag for a given order.
FUNCTION OrdIsUnique   (xOrder, cOrderBag) AS USUAL CLIPPER
    LOCAL result := NIL AS USUAL
	VoDb.OrderInfo(DBOI_UNIQUE, cOrderBag, xOrder,REF result)
    RETURN result

///
///
/// <returns>
/// </returns>
FUNCTION OrdBagExt() AS STRING STRICT
	RETURN VoDb.OrdBagExt()

///
///
/// <returns>
/// </returns>
FUNCTION OrdBagName(uOrder) AS STRING CLIPPER
	RETURN DbOrderInfo(DBOI_BAGNAME, "", uOrder)

/// Set the condition and scope for an order.
/// <remarks>OrdCondSet() is like VODBOrdCondSet() but untyped and the various parameters are passed individually.</remarks>
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
/// <seealso cref='M:XSharp.CoreDb.OrdCondSet(XSharp.RDD.Support.DbOrderCondInfo)' />
FUNCTION OrdCondSet(cFor, uCobFor, lAll, uCobWhile, uCobEval, nStep, nStart,     ;
		nNext, nRecno,lRest,lDescending,lAdditive,lCurrent, lCustom, lNoOptimize     ) AS LOGIC CLIPPER

	LOCAL dbOrdCondInfo     AS DbOrderCondInfo

	dbOrdCondInfo := DbOrderCondInfo{}

    dbOrdCondInfo:ForBlock := VoDb.ValidBlock(uCobFor)
    dbOrdCondInfo:WhileBlock := VoDb.ValidBlock(uCobWhile)
	dbOrdCondInfo:EvalBlock := VoDb.ValidBlock(uCobEval)
	IF !cFor:IsNil
        dbOrdCondInfo:ForExpression := cFor
        IF dbOrdCondInfo:ForBlock == NULL
            dbOrdCondInfo:ForBlock := MCompile(dbOrdCondInfo:ForExpression)
        ENDIF
	ENDIF
	IF nStep:IsNumeric
		dbOrdCondInfo:StepSize := nStep
	ENDIF
	IF nStart:IsNumeric
		dbOrdCondInfo:StartRecNo := nStart
	ENDIF
	IF nNext:IsNumeric
		dbOrdCondInfo:NextCount := nNext
	ENDIF
	IF nRecno:IsNumeric
		dbOrdCondInfo:RecNo := nRecno
	ENDIF
	IF lRest:IsLogic
		dbOrdCondInfo:Rest := lRest
	ENDIF
	IF lDescending:IsLogic
		dbOrdCondInfo:Descending := lDescending
	ENDIF
	IF lAll:IsLogic
		dbOrdCondInfo:All := lAll
	ENDIF
	IF lAdditive:IsLogic
		dbOrdCondInfo:Additive := lAdditive
	ENDIF
	IF lCustom:IsLogic
		dbOrdCondInfo:Custom := lCustom
	ENDIF
	IF lCurrent:IsLogic
		dbOrdCondInfo:UseCurrent := lCurrent
	ENDIF
	IF !lNoOptimize:IsNil
		dbOrdCondInfo:NoOptimize := lNoOptimize
	ENDIF
	RETURN _DbThrowErrorOnFailure(__FUNCTION__, VoDb.OrdCondSet( dbOrdCondInfo ))

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdCreate(cName, cOrder, cExpr, cobExpr, lUnique) AS LOGIC CLIPPER
	IF lUnique:IsNil
		lUnique := SetUnique()
	ENDIF

	IF cName:IsNil
		IF cOrder:IsNil
            RddError.PostArgumentError("OrdCreate", EDB_CREATEINDEX, nameof(cName), 1, {cName})
			DoError("OrdCreate")
		ELSE
			cName := ""
		ENDIF
	ENDIF

	IF cExpr:IsNil
		cExpr := ""
		IF cobExpr:IsNil
            RddError.PostArgumentError("OrdCreate", EDB_EXPRESSION, nameof(cExpr), 3, {cExpr})
  			DoError("OrdCreate")
		ENDIF
	ELSE
		IF cobExpr:IsNil
			cobExpr := &( "{||" + cExpr + "}" )
		ENDIF
	ENDIF

    RETURN _DbThrowErrorOnFailure(__FUNCTION__, VoDb.OrdCreate(cName, cOrder, cExpr, cobExpr, lUnique, NULL))

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdDescend(xOrder, cOrdBag, lDescend) AS LOGIC CLIPPER
	LOCAL oResult AS OBJECT
	IF ! lDescend:IsLogic
		lDescend := NIL
	ENDIF
    oResult := lDescend
    VoDb.OrderInfo(DBOI_ISDESC, cOrdBag, xOrder, REF oResult)
    RETURN (LOGIC) oResult

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdDestroy(uOrder, cOrdBag) AS LOGIC CLIPPER
	IF !uOrder:IsString
        RddError.PostArgumentError(__FUNCTION__, EDB_ORDDESTROY, nameof(uOrder), 1, {uOrder})
        RETURN FALSE
    ENDIF
    RETURN _DbThrowErrorOnFailure(__FUNCTION__, VoDb.OrdDestroy(cOrdBag, uOrder))

///
///
/// <returns>
/// </returns>
FUNCTION OrdFor(uOrder, cOrdBag, cFor) AS LOGIC CLIPPER
	IF !cFor:IsString
		cFor := NIL
	ENDIF
	RETURN VoDb.OrderInfo(DBOI_CONDITION, cOrdBag, uOrder, cFor)

///
///
/// <returns>
/// </returns>
FUNCTION OrdKey(uOrder, cOrdBag) AS USUAL CLIPPER
	LOCAL xKey  := NIL    AS USUAL
	IF !VODBOrderInfo(DBOI_EXPRESSION, cOrdBag, uOrder, REF xKey)
		xKey := ""
	ENDIF
	RETURN xKey

/// Add a key to a custom built order.
FUNCTION OrdKeyAdd(xOrder, cOrdBag, xVal) AS USUAL CLIPPER
	RETURN VoDb.OrderInfo(DBOI_KEYADD, cOrdBag, xOrder, xVal)

/// Delete a key from a custom built order.
FUNCTION OrdKeyDel(xOrder, cOrdBag, xVal) AS USUAL CLIPPER
	RETURN VoDb.OrderInfo( DBOI_KEYDELETE, cOrdBag, xOrder, NIL)

/// Move to a record specified by its logical record number in the controlling order.
FUNCTION OrdKeyGoto    (nKeyNo) AS LOGIC CLIPPER
	LOCAL lRetCode  AS LOGIC
	IF nKeyNo:IsNumeric
		DbGotop()
		DBSKIP(nKeyno - 1)
		lRetCode := TRUE
    ELSE
        lRetCode := FALSE
	ENDIF
	RETURN lRetCode

/// Return the number of keys in an order.
FUNCTION OrdKeyCount(xOrder, cOrdBag) AS USUAL CLIPPER
    LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_KEYCOUNT, cOrdBag, xOrder, REF result)
    RETURN result

/// Get the logical record number of the current record.
FUNCTION OrdKeyNo(xOrder, cOrdBag) 	AS USUAL CLIPPER
    LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_POSITION, cOrdBag, xOrder, REF result)
    RETURN result

/// Get the key value of the current record from the controlling order.
FUNCTION OrdKeyVal() AS USUAL STRICT
    LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_KEYVAL, NIL, NIL, REF result)
    RETURN result

/// Determines the number of orders for the current work area.
/// <returns>OrdCount() returns the number of open indexes as a numeric value.
/// When no index is open or when no file is open in the current workarea, the return value is 0. </returns>
FUNCTION OrdCount() AS DWORD
    RETURN IIF (Used(), DBOrderInfo(DBOI_ORDERCOUNT),0)

/// Return a list of all tag names for the current work area.
/// <returns>OrdList() returns a one dimensional array holding strings with the tag names of all open indexes.
/// When no index is open, an empty array is returned. </returns>
FUNCTION OrdList() AS ARRAY STRICT
	LOCAL aResult AS ARRAY
	LOCAL nIndex, nCount AS DWORD
	aResult := {}
	nCount := OrdCount()
	FOR nIndex := 1 UPTO nCount
		AAdd(aResult, DBOrderInfo(DBOI_NAME, ,nIndex) )
	NEXT
	RETURN aResult

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
/// <param name="cOrdBag">A character string containing the file name of the index to open. The file name can be specified without a path or a file extension.</param>
/// <param name="uOrder">The name or the numeric position of the the tag to become the controlling index. If uOrder is missing, then the first one becomes the controlling index. </param>
FUNCTION OrdListAdd(cOrdBag, uOrder) AS LOGIC CLIPPER
	RETURN VoDb.OrdListAdd(cOrdBag, uOrder)

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdListClear(cOrdBag, uOrder)  AS LOGIC CLIPPER
	RETURN VoDb.OrdListClear(cOrdBag, uOrder)

/// <exclude />
FUNCTION __OrdListClear()  AS LOGIC STRICT
	LOCAL lRet      AS LOGIC
	LOCAL lOpen     AS LOGIC
	LOCAL cDBF      AS STRING
	LOCAL cAlias    AS STRING
	LOCAL lShare    AS LOGIC
	LOCAL aRDD      AS ARRAY
	LOCAL rdds      AS _RddList
	LOCAL i         AS DWORD

	IF Used()
		cDBF   := DbInfo(DBI_FULLPATH)
		rdds   := DbInfo(DBI_RDD_LIST)

		aRdd := {}
		FOR i := 1 TO rdds:uiRDDCount
			AAdd(aRdd, rdds:atomRddName[i] )
		NEXT

		lShare := DbInfo(DBI_SHARED)
		cAlias := ALIAS()
		lOpen := RDDINFO(_SET_AUTOOPEN)
		RDDINFO(_SET_AUTOOPEN, .F.)
		DBCLOSEAREA()
		lRet := DBUSEAREA(.F., aRdd, cDBF, cAlias, lShare)
		RDDINFO(_SET_AUTOOPEN, lOpen)
	ELSE
		lRet := .F.
	ENDIF

	RETURN lRet

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdListRebuild ()  AS LOGIC STRICT
    RETURN _DbThrowErrorOnFailure(__FUNCTION__, VoDb.OrdListRebuild())

///
///
/// <returns>
/// </returns>
FUNCTION OrdName(uOrder, cOrdBag) AS USUAL CLIPPER
	LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_NAME, cOrdBag, uOrder, REF result)
	RETURN result

///
///
/// <returns>
/// </returns>
FUNCTION OrdNumber(uOrder, cOrdBag) AS USUAL CLIPPER

	LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_NUMBER, cOrdBag, uOrder,REF result)
	RETURN result

///
///
/// <returns>
/// </returns>
FUNCTION OrdSetFocus(uOrder, cOrdBag) AS USUAL CLIPPER
	LOCAL cOrder := ""   AS   STRING
	DEFAULT( REF cOrdBag, "")
	VoDb.OrdSetFocus(cOrdBag, uOrder, OUT cOrder)
	RETURN cOrder

   /// Checks if a scope is set in a work area.
    /// <param name="uScope">An optional constant that indicates which scope needs to be set.

    /// <include file="RTComments.xml" path="Comments/ScopeParams/*"  />
</param>
    /// <returns><include file="RTComments.xml" path="Comments/ScopeReturn/*"  /></returns>
    /// <seealso cref='M:XSharp.RT.Functions.DbSetScope(System.Int32,XSharp.__Usual)' />
    /// <seealso cref='M:XSharp.RT.Functions.DbClearScope(System.Int32)' />

FUNCTION DbScope(uScope) AS USUAL CLIPPER
    LOCAL nScope AS LONG
    IF IsNil(uScope)
        uScope := OrdScope(TOPSCOPE)
        IF isNil(uScope)
            uScope := OrdScope(BOTTOMSCOPE)
        ENDIF
        RETURN ! IsNil(uScope)
    ENDIF
    EnForceNumeric(uScope)
    nScope := uScope
    SWITCH nScope
    CASE SCOPE_TOP
        uScope := OrdScope(TOPSCOPE)
    CASE SCOPE_BOTTOM
        uScope := OrdScope(BOTTOMSCOPE)
    CASE SCOPE_BOTH
    OTHERWISE
        uScope := {OrdScope(TOPSCOPE),OrdScope(BOTTOMSCOPE)}
        uScope := NIL
    END SWITCH
    RETURN uScope

    /// Sets scope values.
    /// <param name="nScope">A constant that indicates which scope needs to be set.

    /// <include file="RTComments.xml" path="Comments/ScopeParams/*"  /></param>
    /// <param name="uValue">The value that needs to be set.
    /// The type of the value must match the type of the index expression.</param>
    /// <returns>TRUE when the scope was set succesfully, otherwise FALSE.</returns>
    /// <seealso cref='M:XSharp.RT.Functions.DbClearScope(System.Int32)' />
    /// <seealso cref='M:XSharp.RT.Functions.DbScope(XSharp.__Usual)' />

FUNCTION DbSetScope(nScope AS LONG, uValue AS USUAL) AS LOGIC
    LOCAL lResult := TRUE AS LOGIC
    TRY
        SWITCH nScope
        CASE SCOPE_TOP
            OrdScope(TOPSCOPE,uValue)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        CASE SCOPE_BOTTOM
            OrdScope(BOTTOMSCOPE, uValue)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        CASE SCOPE_BOTH
        OTHERWISE
            OrdScope(TOPSCOPE,uValue)
            OrdScope(BOTTOMSCOPE, uValue)
            lResult := XSharp.RuntimeState:LastRDDError == NULL
            lResult := FALSE
        END SWITCH
    CATCH AS Exception
        lResult := FALSE
    END TRY
    RETURN lResult

    /// Clears the top and/or bottom scope.
    /// <param name="nScope">A constant that indicates which scope needs to be set.

    /// <include file="RTComments.xml" path="Comments/ScopeParams/*"  /></param>
    /// <returns>TRUE when the scope was cleared succesfully, otherwise FALSE.</returns>
    /// <seealso cref='M:XSharp.RT.Functions.DbSetScope(System.Int32,XSharp.__Usual)' />
    /// <seealso cref='M:XSharp.RT.Functions.DbScope(XSharp.__Usual)' />

FUNCTION DbClearScope(nScope AS LONG) AS LOGIC
    LOCAL lResult := TRUE AS LOGIC
    TRY
        SWITCH nScope
        CASE SCOPE_TOP
            OrdScope(TOPSCOPE,NIL)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        CASE SCOPE_BOTTOM
            OrdScope(BOTTOMSCOPE, NIL)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        CASE SCOPE_BOTH
        OTHERWISE   // SCOPE_BOTH is default in Xbase++
            OrdScope(TOPSCOPE,NIL)
            OrdScope(BOTTOMSCOPE, NIL)
            lResult := XSharp.RuntimeState:LastRDDError == NULL
        END SWITCH
    CATCH AS Exception
        lResult := FALSE
    END TRY
    RETURN lResult

//
// 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.
//
USING XSharp.Rdd.Support
USING XSharp.Rdd
///
///
/// <returns>
/// </returns>
FUNCTION DBClearOrderCondition()  AS LOGIC

	RETURN OrdCondSet("", NIL, .F., NIL, NIL, 0, 0, 0, 0, .F., .F.)

///
///
/// <returns>
/// </returns>
FUNCTION DbReindex() AS LOGIC
    // Don't call CoreDb because of error handling
	RETURN OrdListRebuild()

/// Move to the record having the specified key value in the controlling order.
///
FUNCTION DbSeek(xValue, lSoft, lLast) AS LOGIC CLIPPER
	LOCAL dbsci     AS DBSCOPEINFO
	LOCAL lRet      AS LOGIC

	DEFAULT(REF lSoft, SetSoftSeek())

	dbsci := DbScopeInfo{}
	IF lLast:IsNil
		lLast := FALSE
	ENDIF
	VoDb.SetScope( dbsci)
	DEFAULT(REF xValue, "")
    IF lRet := _DbThrowErrorOnFailure(__FUNCTION__, VoDb.Seek(xValue, lSoft, lLast))
	    lRet := VoDb.Found()
	    VoDb.SetScope(dbsci)
    ENDIF
	RETURN lRet

///
///
/// <returns>
/// </returns>
FUNCTION DbSetFound(lFnd AS LOGIC) AS LOGIC
	RETURN VoDb.SetFound(lFnd)

///
///
/// <returns>
/// </returns>
FUNCTION DbSetOrderCondition(  cFor, uCobFor, lAll, uCobWhile, uCobEval, nStep, nStart, nNext, nRecno, lRest, lDescending, lAdditive, lCurrent, lCustom, lNoOptimize) AS LOGIC CLIPPER
    // Don't call VoDb because of error handling
	RETURN OrdCondSet( cFor, uCobFor, lAll, uCobWhile, uCobEval, ;
		nStep, nStart, nNext, nRecno, lRest,      ;
		lDescending, lAdditive, lCurrent, lCustom, lNoOptimize)

/// Open an index file and add all its orders to the order list in a work area.
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION DbSetIndex(cIndex, uOrder) AS LOGIC CLIPPER
	// Don't call VoDb because of error handling
	IF cIndex:IsNil
		RETURN OrdListClear()
	ENDIF
	RETURN OrdListAdd(cIndex, uOrder)

/// Set the controlling order for a work area.
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION DbSetOrder(uOrder, cBagName) AS LOGIC CLIPPER
	DEFAULT( REF cBagName, "")
	RETURN VoDb.OrdSetFocus(cBagName, uOrder)

///
///
/// <returns>
/// </returns>
FUNCTION IndexCount() AS DWORD
	LOCAL nRet      AS DWORD
	IF Used()
		nRet := DbOrderInfo(DBOI_ORDERCOUNT)
    ELSE
        nRet := 0
	ENDIF

	RETURN nRet

/// Return the default index file extension for a work area as defined by its RDD.
/// <returns>A string indicating the default index file extension for a work area as defined by its RDD</returns>
FUNCTION IndexExt       () AS STRING STRICT
	RETURN VoDb.OrdBagExt()

/// Return the key expression of a specified order.
/// <returns>The key expression of the specified order.  If there is no corresponding order or if no database file is open, IndexKey() returns a NULL_STRING.</returns>
/// <param name='nPosition'>The position of the order in the order list of the work area.  A value of 0 specifies the controlling order, without regard to its actual position in the list.</param>
FUNCTION IndexKey(nPosition) AS STRING CLIPPER
	LOCAL uRetVal   AS USUAL
	IF nPosition:IsNil
		nPosition := 0
	ENDIF
	uRetVal := DbOrderInfo(DBOI_EXPRESSION, "", nPosition)
	RETURN uRetVal

/// Return the position of the controlling order within the order list.
/// <returns>The position of the controlling order.  A value of 0 indicates either that no database file is open or that there is no
/// controlling order and records are being accessed in natural order.</returns>
FUNCTION IndexOrd() AS INT STRICT
	LOCAL uRetVal := NIL AS USUAL
	uRetVal := DbOrderInfo(DBOI_NUMBER, "", NIL)
	DEFAULT( REF uRetVal, 0)
    RETURN uRetVal

/// Relate a specified work area to the current work area.

FUNCTION OrdSetRelation(cAlias, bKey, cKey) AS USUAL CLIPPER
	DbSetRelation(cAlias, bKey, cKey)
	(cAlias)->(OrdScope(0, bKey))
	(cAlias)->(OrdScope(1, bKey))
	RETURN NIL

/// Set or clear the boundaries for scoping key values in the controlling order.
FUNCTION OrdScope(nScope, xVal) AS USUAL CLIPPER
	LOCAL n     AS DWORD
	nScope := VoDb.OrdScopeNum(nScope)
	n := DBOI_SCOPETOP
	IF PCount() > 1 .AND. xVal:IsNil
		n := DBOI_SCOPETOPCLEAR
	ENDIF
	RETURN DbOrderInfo(n + nScope,,,xVal)

/// Move the record pointer to the next or previous unique key in the controlling order.
FUNCTION OrdSkipUnique(uCount) AS USUAL CLIPPER
	RETURN VoDb.OrderInfo ( DBOI_SKIPUNIQUE, "", NIL, uCount )

/// Return the status of the unique flag for a given order.
FUNCTION OrdIsUnique   (xOrder, cOrderBag) AS USUAL CLIPPER
    LOCAL result := NIL AS USUAL
	VoDb.OrderInfo(DBOI_UNIQUE, cOrderBag, xOrder,REF result)
    RETURN result

///
///
/// <returns>
/// </returns>
FUNCTION OrdBagExt() AS STRING STRICT
	RETURN VoDb.OrdBagExt()

///
///
/// <returns>
/// </returns>
FUNCTION OrdBagName(uOrder) AS STRING CLIPPER
	RETURN DbOrderInfo(DBOI_BAGNAME, "", uOrder)

/// Set the condition and scope for an order.
/// <remarks>OrdCondSet() is like VODBOrdCondSet() but untyped and the various parameters are passed individually.</remarks>
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
/// <seealso cref='M:XSharp.CoreDb.OrdCondSet(XSharp.RDD.Support.DbOrderCondInfo)' />
FUNCTION OrdCondSet(cFor, uCobFor, lAll, uCobWhile, uCobEval, nStep, nStart,     ;
		nNext, nRecno,lRest,lDescending,lAdditive,lCurrent, lCustom, lNoOptimize     ) AS LOGIC CLIPPER

	LOCAL dbOrdCondInfo     AS DbOrderCondInfo

	dbOrdCondInfo := DbOrderCondInfo{}

    dbOrdCondInfo:ForBlock := VoDb.ValidBlock(uCobFor)
    dbOrdCondInfo:WhileBlock := VoDb.ValidBlock(uCobWhile)
	dbOrdCondInfo:EvalBlock := VoDb.ValidBlock(uCobEval)
	IF !cFor:IsNil
        dbOrdCondInfo:ForExpression := cFor
        IF dbOrdCondInfo:ForBlock == NULL
            dbOrdCondInfo:ForBlock := MCompile(dbOrdCondInfo:ForExpression)
        ENDIF
	ENDIF
	IF nStep:IsNumeric
		dbOrdCondInfo:StepSize := nStep
	ENDIF
	IF nStart:IsNumeric
		dbOrdCondInfo:StartRecNo := nStart
	ENDIF
	IF nNext:IsNumeric
		dbOrdCondInfo:NextCount := nNext
	ENDIF
	IF nRecno:IsNumeric
		dbOrdCondInfo:RecNo := nRecno
	ENDIF
	IF lRest:IsLogic
		dbOrdCondInfo:Rest := lRest
	ENDIF
	IF lDescending:IsLogic
		dbOrdCondInfo:Descending := lDescending
	ENDIF
	IF lAll:IsLogic
		dbOrdCondInfo:All := lAll
	ENDIF
	IF lAdditive:IsLogic
		dbOrdCondInfo:Additive := lAdditive
	ENDIF
	IF lCustom:IsLogic
		dbOrdCondInfo:Custom := lCustom
	ENDIF
	IF lCurrent:IsLogic
		dbOrdCondInfo:UseCurrent := lCurrent
	ENDIF
	IF !lNoOptimize:IsNil
		dbOrdCondInfo:NoOptimize := lNoOptimize
	ENDIF
	RETURN _DbThrowErrorOnFailure(__FUNCTION__, VoDb.OrdCondSet( dbOrdCondInfo ))

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdCreate(cName, cOrder, cExpr, cobExpr, lUnique) AS LOGIC CLIPPER
	IF lUnique:IsNil
		lUnique := SetUnique()
	ENDIF

	IF cName:IsNil
		IF cOrder:IsNil
            RddError.PostArgumentError("OrdCreate", EDB_CREATEINDEX, nameof(cName), 1, {cName})
			DoError("OrdCreate")
		ELSE
			cName := ""
		ENDIF
	ENDIF

	IF cExpr:IsNil
		cExpr := ""
		IF cobExpr:IsNil
            RddError.PostArgumentError("OrdCreate", EDB_EXPRESSION, nameof(cExpr), 3, {cExpr})
  			DoError("OrdCreate")
		ENDIF
	ELSE
		IF cobExpr:IsNil
			cobExpr := &( "{||" + cExpr + "}" )
		ENDIF
	ENDIF

    RETURN _DbThrowErrorOnFailure(__FUNCTION__, VoDb.OrdCreate(cName, cOrder, cExpr, cobExpr, lUnique, NULL))

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdDescend(xOrder, cOrdBag, lDescend) AS LOGIC CLIPPER
	LOCAL oResult AS OBJECT
	IF ! lDescend:IsLogic
		lDescend := NIL
	ENDIF
    oResult := lDescend
    VoDb.OrderInfo(DBOI_ISDESC, cOrdBag, xOrder, REF oResult)
    RETURN (LOGIC) oResult

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdDestroy(uOrder, cOrdBag) AS LOGIC CLIPPER
	IF !uOrder:IsString
        RddError.PostArgumentError(__FUNCTION__, EDB_ORDDESTROY, nameof(uOrder), 1, {uOrder})
        RETURN FALSE
    ENDIF
    RETURN _DbThrowErrorOnFailure(__FUNCTION__, VoDb.OrdDestroy(cOrdBag, uOrder))

///
///
/// <returns>
/// </returns>
FUNCTION OrdFor(uOrder, cOrdBag, cFor) AS LOGIC CLIPPER
	IF !cFor:IsString
		cFor := NIL
	ENDIF
	RETURN VoDb.OrderInfo(DBOI_CONDITION, cOrdBag, uOrder, cFor)

///
///
/// <returns>
/// </returns>
FUNCTION OrdKey(uOrder, cOrdBag) AS USUAL CLIPPER
	LOCAL xKey  := NIL    AS USUAL
	IF !VODBOrderInfo(DBOI_EXPRESSION, cOrdBag, uOrder, REF xKey)
		xKey := ""
	ENDIF
	RETURN xKey

/// Add a key to a custom built order.
FUNCTION OrdKeyAdd(xOrder, cOrdBag, xVal) AS USUAL CLIPPER
	RETURN VoDb.OrderInfo(DBOI_KEYADD, cOrdBag, xOrder, xVal)

/// Delete a key from a custom built order.
FUNCTION OrdKeyDel(xOrder, cOrdBag, xVal) AS USUAL CLIPPER
	RETURN VoDb.OrderInfo( DBOI_KEYDELETE, cOrdBag, xOrder, NIL)

/// Move to a record specified by its logical record number in the controlling order.
FUNCTION OrdKeyGoto    (nKeyNo) AS LOGIC CLIPPER
	LOCAL lRetCode  AS LOGIC
	IF nKeyNo:IsNumeric
		DbGotop()
		DBSKIP(nKeyno - 1)
		lRetCode := TRUE
    ELSE
        lRetCode := FALSE
	ENDIF
	RETURN lRetCode

/// Return the number of keys in an order.
FUNCTION OrdKeyCount(xOrder, cOrdBag) AS USUAL CLIPPER
    LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_KEYCOUNT, cOrdBag, xOrder, REF result)
    RETURN result

/// Get the logical record number of the current record.
FUNCTION OrdKeyNo(xOrder, cOrdBag) 	AS USUAL CLIPPER
    LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_POSITION, cOrdBag, xOrder, REF result)
    RETURN result

/// Get the key value of the current record from the controlling order.
FUNCTION OrdKeyVal() AS USUAL STRICT
    LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_KEYVAL, NIL, NIL, REF result)
    RETURN result

/// Determines the number of orders for the current work area.
/// <returns>OrdCount() returns the number of open indexes as a numeric value.
/// When no index is open or when no file is open in the current workarea, the return value is 0. </returns>
FUNCTION OrdCount() AS DWORD
    RETURN IIF (Used(), DBOrderInfo(DBOI_ORDERCOUNT),0)

/// Return a list of all tag names for the current work area.
/// <returns>OrdList() returns a one dimensional array holding strings with the tag names of all open indexes.
/// When no index is open, an empty array is returned. </returns>
FUNCTION OrdList() AS ARRAY STRICT
	LOCAL aResult AS ARRAY
	LOCAL nIndex, nCount AS DWORD
	aResult := {}
	nCount := OrdCount()
	FOR nIndex := 1 UPTO nCount
		AAdd(aResult, DBOrderInfo(DBOI_NAME, ,nIndex) )
	NEXT
	RETURN aResult

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
/// <param name="cOrdBag">A character string containing the file name of the index to open. The file name can be specified without a path or a file extension.</param>
/// <param name="uOrder">The name or the numeric position of the the tag to become the controlling index. If uOrder is missing, then the first one becomes the controlling index. </param>
FUNCTION OrdListAdd(cOrdBag, uOrder) AS LOGIC CLIPPER
	RETURN VoDb.OrdListAdd(cOrdBag, uOrder)

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdListClear(cOrdBag, uOrder)  AS LOGIC CLIPPER
	RETURN VoDb.OrdListClear(cOrdBag, uOrder)

/// <exclude />
FUNCTION __OrdListClear()  AS LOGIC STRICT
	LOCAL lRet      AS LOGIC
	LOCAL lOpen     AS LOGIC
	LOCAL cDBF      AS STRING
	LOCAL cAlias    AS STRING
	LOCAL lShare    AS LOGIC
	LOCAL aRDD      AS ARRAY
	LOCAL rdds      AS _RddList
	LOCAL i         AS DWORD

	IF Used()
		cDBF   := DbInfo(DBI_FULLPATH)
		rdds   := DbInfo(DBI_RDD_LIST)

		aRdd := {}
		FOR i := 1 TO rdds:uiRDDCount
			AAdd(aRdd, rdds:atomRddName[i] )
		NEXT

		lShare := DbInfo(DBI_SHARED)
		cAlias := ALIAS()
		lOpen := RDDINFO(_SET_AUTOOPEN)
		RDDINFO(_SET_AUTOOPEN, .F.)
		DBCLOSEAREA()
		lRet := DBUSEAREA(.F., aRdd, cDBF, cAlias, lShare)
		RDDINFO(_SET_AUTOOPEN, lOpen)
	ELSE
		lRet := .F.
	ENDIF

	RETURN lRet

///
///
/// <returns>TRUE if successful; otherwise, FALSE.</returns>
FUNCTION OrdListRebuild ()  AS LOGIC STRICT
    RETURN _DbThrowErrorOnFailure(__FUNCTION__, VoDb.OrdListRebuild())

///
///
/// <returns>
/// </returns>
FUNCTION OrdName(uOrder, cOrdBag) AS USUAL CLIPPER
	LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_NAME, cOrdBag, uOrder, REF result)
	RETURN result

///
///
/// <returns>
/// </returns>
FUNCTION OrdNumber(uOrder, cOrdBag) AS USUAL CLIPPER

	LOCAL result := NIL AS USUAL
    VoDb.OrderInfo(DBOI_NUMBER, cOrdBag, uOrder,REF result)
	RETURN result

///
///
/// <returns>
/// </returns>
FUNCTION OrdSetFocus(uOrder, cOrdBag) AS USUAL CLIPPER
	LOCAL cOrder := ""   AS   STRING
	DEFAULT( REF cOrdBag, "")
	VoDb.OrdSetFocus(cOrdBag, uOrder, OUT cOrder)
	RETURN cOrder

   /// Checks if a scope is set in a work area.
    /// <param name="uScope">An optional constant that indicates which scope needs to be set.

    /// <include file="RTComments.xml" path="Comments/ScopeParams/*"  />
</param>
    /// <returns><include file="RTComments.xml" path="Comments/ScopeReturn/*"  /></returns>
    /// <seealso cref='M:XSharp.RT.Functions.DbSetScope(System.Int32,XSharp.__Usual)' />
    /// <seealso cref='M:XSharp.RT.Functions.DbClearScope(System.Int32)' />

FUNCTION DbScope(uScope) AS USUAL CLIPPER
    LOCAL nScope AS LONG
    IF IsNil(uScope)
        uScope := OrdScope(TOPSCOPE)
        IF isNil(uScope)
            uScope := OrdScope(BOTTOMSCOPE)
        ENDIF
        RETURN ! IsNil(uScope)
    ENDIF
    EnForceNumeric(uScope)
    nScope := uScope
    SWITCH nScope
    CASE SCOPE_TOP
        uScope := OrdScope(TOPSCOPE)
    CASE SCOPE_BOTTOM
        uScope := OrdScope(BOTTOMSCOPE)
    CASE SCOPE_BOTH
        uScope := {OrdScope(TOPSCOPE),OrdScope(BOTTOMSCOPE)}
    OTHERWISE
        uScope := NIL
    END SWITCH
    RETURN uScope

    /// Sets scope values.
    /// <param name="nScope">A constant that indicates which scope needs to be set.

    /// <include file="RTComments.xml" path="Comments/ScopeParams/*"  /></param>
    /// <param name="uValue">The value that needs to be set.
    /// The type of the value must match the type of the index expression.</param>
    /// <returns>TRUE when the scope was set succesfully, otherwise FALSE.</returns>
    /// <seealso cref='M:XSharp.RT.Functions.DbClearScope(System.Int32)' />
    /// <seealso cref='M:XSharp.RT.Functions.DbScope(XSharp.__Usual)' />

FUNCTION DbSetScope(nScope AS LONG, uValue AS USUAL) AS LOGIC
    LOCAL lResult := TRUE AS LOGIC
    TRY
        SWITCH nScope
        CASE SCOPE_TOP
            OrdScope(TOPSCOPE,uValue)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        CASE SCOPE_BOTTOM
            OrdScope(BOTTOMSCOPE, uValue)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        CASE SCOPE_BOTH
            OrdScope(TOPSCOPE,uValue)
            OrdScope(BOTTOMSCOPE, uValue)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        OTHERWISE
            lResult := FALSE
        END SWITCH
    CATCH AS Exception
        lResult := FALSE
    END TRY
    RETURN lResult

    /// Clears the top and/or bottom scope.
    /// <param name="nScope">A constant that indicates which scope needs to be set.

    /// <include file="RTComments.xml" path="Comments/ScopeParams/*"  /></param>
    /// <returns>TRUE when the scope was cleared succesfully, otherwise FALSE.</returns>
    /// <seealso cref='M:XSharp.RT.Functions.DbSetScope(System.Int32,XSharp.__Usual)' />
    /// <seealso cref='M:XSharp.RT.Functions.DbScope(XSharp.__Usual)' />

FUNCTION DbClearScope(nScope AS LONG) AS LOGIC
    LOCAL lResult := TRUE AS LOGIC
    TRY
        SWITCH nScope
        CASE SCOPE_TOP
            OrdScope(TOPSCOPE,NIL)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        CASE SCOPE_BOTTOM
            OrdScope(BOTTOMSCOPE, NIL)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        CASE SCOPE_BOTH
            OrdScope(TOPSCOPE,NIL)
            OrdScope(BOTTOMSCOPE, NIL)
            lResult := XSharp.RuntimeState:LastRDDError == NULL

        OTHERWISE
            lResult := FALSE
        END SWITCH
    CATCH AS Exception
        lResult := FALSE
    END TRY
    RETURN lResult