rtl

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  
c:\harbour\source\rtl
abs.c
TypeFunctionSourceLine
HB_FUNCABS(void)
HB_FUNC( ABS )
{
   PHB_ITEM pNumber = hb_param( 1, HB_IT_NUMERIC );

   if( pNumber )
   {
      int iWidth;
      int iDec;

      hb_itemGetNLen( pNumber, &iWidth, &iDec );

      if( HB_IS_INTEGER( pNumber ) )
      {
         int iNumber = hb_itemGetNI( pNumber );

         if( iNumber >= 0 )
            hb_retnilen( iNumber, iWidth );
#if -HB_INT_MAX > HB_INT_MIN
         else if( iNumber < -HB_INT_MAX )
#if HB_LONG_MAX > HB_INT_MAX
            hb_retnint( - ( HB_LONG ) iNumber );
#else
            hb_retndlen( - ( double ) iNumber, 0, iDec );
#endif
#endif
         else
            hb_retni( -iNumber );
      }
      else if( HB_IS_LONG( pNumber ) )
      {
         HB_LONG lNumber = hb_itemGetNInt( pNumber );

         if( lNumber >= 0 )
            hb_retnintlen( lNumber, iWidth );
#if -HB_LONG_MAX > HB_LONG_MIN
         else if( lNumber < -HB_LONG_MAX )
            hb_retndlen( - ( double ) lNumber, 0, iDec );
#endif
         else
            hb_retnint( -lNumber );
      }
      else
      {
         double dNumber = hb_itemGetND( pNumber );

         hb_retndlen( dNumber >= 0.0 ? dNumber : -dNumber, 0, iDec );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1089, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
abs.c57
accept.c
TypeFunctionSourceLine
STATIC CHAR *hb_acceptBuffer( void )
static char * hb_acceptBuffer( void )
{
   return ( char * ) hb_stackGetTSD( &s_szAcceptResult );
}
accept.c78
HB_FUNC__ACCEPTSTR(void)
HB_FUNC( __ACCEPTSTR )
{
   hb_retc( hb_acceptBuffer() );
}
accept.c83
HB_FUNC__ACCEPT(void)
HB_FUNC( __ACCEPT )
{
   char szAcceptResult[ ACCEPT_BUFFER_LEN ];
   ULONG ulLen = 0;
   int input = 0;

   /* cPrompt(s) passed ? */
   if( hb_pcount() >= 1 )
      HB_FUNC_EXEC( QOUT );

   szAcceptResult[ 0 ] = '\0';

   while( input != K_ENTER && hb_vmRequestQuery() == 0 )
   {
      /* Wait forever, for keyboard events only */
      input = hb_inkey( TRUE, 0.0, INKEY_KEYBOARD );
      switch( input )
      {
         case K_BS:
         case K_LEFT:
            if( ulLen > 0 )
            {
               hb_conOutAlt( "\x8", sizeof( char ) ); /* Erase it from the screen. */
               ulLen--; /* Adjust input count to get rid of last character */
            }
            break;

         default:
            if( ulLen < ( ACCEPT_BUFFER_LEN - 1 ) && input >= 32 && input <= 255 )
            {
               szAcceptResult[ ulLen ] = ( char ) input; /* Accept the input */
               hb_conOutAlt( &szAcceptResult[ ulLen ], sizeof( char ) ); /* Then display it */
               ulLen++; /* Then adjust the input count */
            }
      }
   }

   szAcceptResult[ ulLen ] = '\0';

#ifdef HB_C52_UNDOC
   hb_strncpy( hb_acceptBuffer(), szAcceptResult, ACCEPT_BUFFER_LEN - 1 );
#endif

   hb_retc( szAcceptResult );
}
accept.c90
ampm.c
TypeFunctionSourceLine
HB_FUNCAMPM(void)
HB_FUNC( AMPM )
{
   ULONG  ulTimeLen = hb_parclen( 1 );
   char * pszResult = ( char * ) hb_xgrab( HB_MAX( ulTimeLen, 2 ) + 3 + 1 );
   USHORT uiHour = 0;
   BOOL   bAM;

   if( ulTimeLen )
   {
      char * pszTime = hb_parc( 1 );
      memcpy( pszResult, pszTime, ulTimeLen );
      uiHour = ( USHORT ) hb_strVal( pszTime, ulTimeLen );
   }

   if( uiHour == 0 || uiHour == 24 )
   {
      if( ulTimeLen < 2 )
         ulTimeLen = 2;

      pszResult[ 0 ] = '1';
      pszResult[ 1 ] = '2';
      bAM = TRUE;
   }
   else if( uiHour > 12 )
   {
      if( ulTimeLen < 2 )
         ulTimeLen = 2;

      uiHour -= 12;
      pszResult[ 0 ] = ( char ) ( uiHour / 10 ) + '0';
      pszResult[ 1 ] = ( char ) ( uiHour % 10 ) + '0';

      if( pszResult[ 0 ] == '0' )
         pszResult[ 0 ] = ' ';

      bAM = FALSE;
   }
   else
      bAM = ( uiHour != 12 );

   memcpy( pszResult + ulTimeLen, bAM ? " am" : " pm", 4 );

   hb_retclen_buffer( pszResult, ulTimeLen + 3 );
}
ampm.c55
at.c
TypeFunctionSourceLine
HB_FUNCHB_AT(void)
HB_FUNC( HB_AT )
{
   PHB_ITEM pSub = hb_param( 1, HB_IT_STRING );
   PHB_ITEM pText = hb_param( 2, HB_IT_STRING );

   if( pText && pSub )
   {
      ULONG ulTextLength = hb_itemGetCLen( pText );
      ULONG ulStart = ISNUM( 3 ) ? hb_parnl( 3 ) : 1;
      ULONG ulEnd = ISNUM( 4 ) ? ( ULONG ) hb_parnl( 4 ) : ulTextLength;
      ULONG ulPos;

      if( ulStart > ulTextLength || ulEnd < ulStart )
         hb_retnl( 0 );
      else
      {
         if( ulEnd > ulTextLength )
            ulEnd = ulTextLength;

         ulPos = hb_strAt( hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
                           hb_itemGetCPtr( pText ) + ulStart - 1, ulEnd - ulStart + 1 );

         if( ulPos > 0)
            ulPos += ( ulStart - 1 );

         hb_retnl( ulPos );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1108, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
at.c59
HB_FUNCAT(void)
HB_FUNC( AT )
{
   HB_FUNC_EXEC( HB_AT );
}
at.c93
HB_FUNCAT(void)
HB_FUNC( AT )
{
   PHB_ITEM pSub = hb_param( 1, HB_IT_STRING );
   PHB_ITEM pText = hb_param( 2, HB_IT_STRING );

   if( pText && pSub )
   {
      hb_retnl( hb_strAt( hb_itemGetCPtr( pSub ), hb_itemGetCLen( pSub ),
                          hb_itemGetCPtr( pText ), hb_itemGetCLen( pText ) ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1108, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
at.c100
binnum.c
TypeFunctionSourceLine
HB_FUNCBIN2W(void)
HB_FUNC( BIN2W )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );

   if( pItem )
   {
      char * pszString = hb_itemGetCPtr( pItem );
      ULONG ulLen = hb_itemGetCLen( pItem );

      hb_retnl( HB_MKUSHORT( ( ulLen >= 1 ) ? ( BYTE ) pszString[ 0 ] : 0,
                             ( ulLen >= 2 ) ? ( BYTE ) pszString[ 1 ] : 0 ) );
   }
   else
      hb_retni( 0 );
}
binnum.c39
HB_FUNCBIN2I(void)
HB_FUNC( BIN2I )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );

   if( pItem )
   {
      char * pszString = hb_itemGetCPtr( pItem );
      ULONG ulLen = hb_itemGetCLen( pItem );

      hb_retni( HB_MKSHORT( ( ulLen >= 1 ) ? ( BYTE ) pszString[ 0 ] : 0,
                            ( ulLen >= 2 ) ? ( BYTE ) pszString[ 1 ] : 0 ) );
   }
   else
      hb_retni( 0 );
}
binnum.c55
HB_FUNCBIN2L(void)
HB_FUNC( BIN2L )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );

   if( pItem )
   {
      char * pszString = hb_itemGetCPtr( pItem );
      ULONG ulLen = hb_itemGetCLen( pItem );

      hb_retnl( HB_MKLONG( ( ulLen >= 1 ) ? ( BYTE ) pszString[ 0 ] : 0,
                           ( ulLen >= 2 ) ? ( BYTE ) pszString[ 1 ] : 0,
                           ( ulLen >= 3 ) ? ( BYTE ) pszString[ 2 ] : 0,
                           ( ulLen >= 4 ) ? ( BYTE ) pszString[ 3 ] : 0 ) );
   }
   else
      hb_retnl( 0 );
}
binnum.c71
HB_FUNCI2BIN(void)
HB_FUNC( I2BIN )
{
   char szString[ 2 ];

   if( ISNUM( 1 ) )
   {
      SHORT iValue = ( SHORT ) hb_parni( 1 );

      HB_PUT_LE_UINT16( szString, iValue );
   }
   else
   {
      szString[ 0 ] =
      szString[ 1 ] = '\0';
   }

   hb_retclen( szString, 2 );
}
binnum.c89
HB_FUNCL2BIN(void)
HB_FUNC( L2BIN )
{
   char szString[ 4 ];

   if( ISNUM( 1 ) )
   {
      long lValue = hb_parnl( 1 );

      HB_PUT_LE_UINT32( szString, lValue );
   }
   else
   {
      szString[ 0 ] =
      szString[ 1 ] =
      szString[ 2 ] =
      szString[ 3 ] = '\0';
   }

   hb_retclen( szString, 4 );
}
binnum.c108
binnumx.c
TypeFunctionSourceLine
HB_FUNCBIN2U(void)
HB_FUNC( BIN2U )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );

   if( pItem )
   {
      char * pszString = hb_itemGetCPtr( pItem );
      ULONG ulLen = hb_itemGetCLen( pItem );

      hb_retnint( HB_MKULONG( ( ulLen >= 1 ) ? ( BYTE ) pszString[ 0 ] : 0,
                              ( ulLen >= 2 ) ? ( BYTE ) pszString[ 1 ] : 0,
                              ( ulLen >= 3 ) ? ( BYTE ) pszString[ 2 ] : 0,
                              ( ulLen >= 4 ) ? ( BYTE ) pszString[ 3 ] : 0 ) );
   }
   else
      hb_retnl( 0 );
}
binnumx.c60
HB_FUNCW2BIN(void)
HB_FUNC( W2BIN )
{
   char szString[ 2 ];

   if( ISNUM( 1 ) )
   {
      USHORT uiValue = ( USHORT ) hb_parni( 1 );

      szString[ 0 ] = ( uiValue & 0x00FF );
      szString[ 1 ] = ( uiValue & 0xFF00 ) >> 8;
   }
   else
   {
      szString[ 0 ] =
      szString[ 1 ] = '\0';
   }

   hb_retclen( szString, 2 );
}
binnumx.c78
HB_FUNCU2BIN(void)
HB_FUNC( U2BIN )
{
   char szString[ 4 ];

   if( ISNUM( 1 ) )
   {
      ULONG ulValue = ( ULONG ) hb_parnl( 1 );

      szString[ 0 ] = ( char ) ( ulValue & 0x000000FF );
      szString[ 1 ] = ( char ) ( ( ulValue & 0x0000FF00 ) >> 8 );
      szString[ 2 ] = ( char ) ( ( ulValue & 0x00FF0000 ) >> 16 );
      szString[ 3 ] = ( char ) ( ( ulValue & 0xFF000000 ) >> 24 );
   }
   else
   {
      szString[ 0 ] =
      szString[ 1 ] =
      szString[ 2 ] =
      szString[ 3 ] = '\0';
   }

   hb_retclen( szString, 4 );
}
binnumx.c98
box.c
TypeFunctionSourceLine
HB_FUNCDISPBOX(void)
HB_FUNC( DISPBOX )
{
   PHB_ITEM pTop    = hb_param( 1, HB_IT_NUMERIC );
   PHB_ITEM pLeft   = hb_param( 2, HB_IT_NUMERIC );
   PHB_ITEM pBottom = hb_param( 3, HB_IT_NUMERIC );
   PHB_ITEM pRight  = hb_param( 4, HB_IT_NUMERIC );

   if( pTop && pLeft && pBottom && pRight )
   {
      char * pszColor = hb_parc( 6 );
      char szOldColor[ HB_CLRSTR_LEN ];
      char * pszBox = hb_parc( 5 );

      if( pszColor )
      {
         hb_gtGetColorStr( szOldColor );
         hb_gtSetColorStr( pszColor );
      }

      if( pszBox )
         hb_gtBox( ( SHORT ) hb_itemGetNI( pTop ),
                   ( SHORT ) hb_itemGetNI( pLeft),
                   ( SHORT ) hb_itemGetNI( pBottom ),
                   ( SHORT ) hb_itemGetNI( pRight ),
                   ( BYTE * ) ( *pszBox ? pszBox : "         " ) );

      else if( hb_parni( 5 ) == 2 )
         hb_gtBoxD( ( SHORT ) hb_itemGetNI( pTop ),
                    ( SHORT ) hb_itemGetNI( pLeft),
                    ( SHORT ) hb_itemGetNI( pBottom ),
                    ( SHORT ) hb_itemGetNI( pRight ) );

      else
         hb_gtBoxS( ( SHORT ) hb_itemGetNI( pTop ),
                    ( SHORT ) hb_itemGetNI( pLeft),
                    ( SHORT ) hb_itemGetNI( pBottom ),
                    ( SHORT ) hb_itemGetNI( pRight ) );

      if( pszColor )
         hb_gtSetColorStr( szOldColor );
   }
}
box.c57
cdpapi.c
TypeFunctionSourceLine
STATIC INTutf8Size( USHORT uc )
static int utf8Size( USHORT uc )
{
   if( uc < 0x0080 )
      return 1;

   else if( uc < 0x0800 )
      return 2;

   else                         /* if( uc <= 0xffff ) */
      return 3;
}
cdpapi.c118
STATIC INTu16toutf8( BYTE * szUTF8, USHORT uc )
static int u16toutf8( BYTE * szUTF8, USHORT uc )
{
   int n;

   if( uc < 0x0080 )
   {
      szUTF8[0] = uc & 0xff;
      n = 1;
   }
   else if( uc < 0x0800 )
   {
      szUTF8[0] = 0xc0 | ( ( uc >> 6 ) & 0x1f );
      szUTF8[1] = 0x80 | ( uc & 0x3f );
      n = 2;
   }
   else                         /* if( uc <= 0xffff ) */
   {
      szUTF8[0] = 0xe0 | ( ( uc >> 12 ) & 0x0f );
      szUTF8[1] = 0x80 | ( ( uc >> 6 ) & 0x3f );
      szUTF8[2] = 0x80 | ( uc & 0x3f );
      n = 3;
   }
/*
   else
   {
      n = 0;
   }
*/
   return n;
}
cdpapi.c130
STATIC BOOLutf8tou16nextchar( BYTE byChar, int *n, USHORT * uc )
static BOOL utf8tou16nextchar( BYTE byChar, int *n, USHORT * uc )
{
   if( *n > 0 )
   {
      if( ( byChar & 0xc0 ) != 0x80 )
         return FALSE;
      *uc = ( *uc << 6 ) | ( byChar & 0x3f );
      ( *n )--;
      return TRUE;
   }

   *n = 0;
   *uc = byChar;
   if( byChar >= 0xc0 )
   {
      if( byChar < 0xe0 )
      {
         *uc &= 0x1f;
         *n = 1;
      }
      else if( byChar < 0xf0 )
      {
         *uc &= 0x0f;
         *n = 2;
      }
      else if( byChar < 0xf8 )
      {
         *uc &= 0x07;
         *n = 3;
      }
      else if( byChar < 0xfc )
      {
         *uc &= 0x03;
         *n = 4;
      }
      else if( byChar < 0xfe )
      {
         *uc &= 0x01;
         *n = 5;
      }
   }
   return TRUE;
}
cdpapi.c161
STATIC INTutf8tou16( const BYTE * szUTF8, USHORT * uc )
static int utf8tou16( const BYTE * szUTF8, USHORT * uc )
{
   int n = 1, m = 1;
   UINT32 u32;

   u32 = *szUTF8;
   if( u32 >= 0xc0 )
   {
      if( u32 < 0xe0 )
      {
         u32 &= 0x1f;
         m = 2;
      }
      else if( u32 < 0xf0 )
      {
         u32 &= 0x0f;
         m = 3;
      }
      else if( u32 < 0xf8 )
      {
         u32 &= 0x07;
         m = 4;
      }
      else if( u32 < 0xfc )
      {
         u32 &= 0x03;
         m = 5;
      }
      else if( u32 < 0xfe )
      {
         u32 &= 0x01;
         m = 6;
      }
      while( n < m && ( szUTF8[n] & 0xc0 ) == 0x80 )
      {
         u32 = ( u32 << 6 ) | ( szUTF8[n++] & 0x3f );
      }
      if( n < m )
      {
         u32 <<= 6 * ( m - n );
      }
   }

   *uc = ( USHORT ) u32;
   return n;
}
cdpapi.c206
STATIC ULONGutf8pos( const BYTE * szUTF8, ULONG ulLen, ULONG ulUTF8Pos )
static ULONG utf8pos( const BYTE * szUTF8, ULONG ulLen, ULONG ulUTF8Pos )
{
   if( ulUTF8Pos )
   {
      ULONG ul, ul2;
      USHORT uc;
      int n = 0;

      for( ul = ul2 = 0; ul < ulLen; ++ul )
      {
         if( utf8tou16nextchar( szUTF8[ul], &n, &uc ) )
         {
            if( n == 0 )
            {
               if( --ulUTF8Pos == 0 )
                  return ul2 + 1;
               ul2 = ul + 1;
            }
         }
      }
   }
   return 0;
}
cdpapi.c254
STATIC INThb_cdpFindPos( const char *pszID )
static int hb_cdpFindPos( const char *pszID )
{
   int iPos;

   if( pszID != NULL )
   {
      for( iPos = 0; iPos < HB_CDP_MAX_ && s_cdpList[iPos]; iPos++ )
      {
         if( strcmp( s_cdpList[iPos]->id, pszID ) == 0 )
            return iPos;
      }
   }

   return -1;
}
cdpapi.c278
HB_EXPORT BOOLhb_cdpRegister( PHB_CODEPAGE cdpage )
HB_EXPORT BOOL hb_cdpRegister( PHB_CODEPAGE cdpage )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_cdpRegister(%p)", cdpage ) );

   if( cdpage )
   {
      int iPos = hb_cdpFindPos( cdpage->id );

      if( iPos == -1 )
      {
         for( iPos = 0; iPos < HB_CDP_MAX_; iPos++ )
         {
            if( !s_cdpList[iPos] )
            {
               int i, ia, iu, il, iumax = 0, ilmax = 0;
               char *ptrUpper = ( char * ) cdpage->CharsUpper;
               char *ptrLower = ( char * ) cdpage->CharsLower;
               char *ptr;
               HB_MULTICHAR multi[12];
               int nMulti = 0;

               s_cdpList[iPos] = cdpage;

               cdpage->lSort = cdpage->lAccInterleave || cdpage->lAccEqual;
               cdpage->lChClone = FALSE;
               if( cdpage->nChars )
               {
                  int nAddLower = cdpage->nChars + ( ( cdpage->lLatin ) ? 6 : 0 );

                  cdpage->s_chars = ( BYTE * ) hb_xgrab( 256 );
                  memset( cdpage->s_chars, '\0', 256 );
                  cdpage->s_upper = ( BYTE * ) hb_xgrab( 256 );
                  cdpage->s_lower = ( BYTE * ) hb_xgrab( 256 );
                  if( cdpage->lAccInterleave )
                  {
                     cdpage->s_accent = ( BYTE * ) hb_xgrab( 256 );
                     memset( cdpage->s_accent, '\0', 256 );
                  }
                  else
                     cdpage->s_accent = NULL;

                  for( i = 0; i < 256; i++ )
                  {
                     cdpage->s_upper[i] = ( char ) toupper( ( UCHAR ) i );
                     cdpage->s_lower[i] = ( char ) tolower( ( UCHAR ) i );
                  }
                  if( strpbrk( cdpage->CharsUpper, "~." ) != NULL )
                  {
                     cdpage->CharsUpper = ptrUpper = hb_strdup( cdpage->CharsUpper );
                     cdpage->CharsLower = ptrLower = hb_strdup( cdpage->CharsLower );
                     cdpage->lChClone = TRUE;
                  }
                  for( i = ia = 1; *ptrUpper; i++, ia++, ptrUpper++, ptrLower++ )
                  {
                     if( ( cdpage->lAccEqual || cdpage->lAccInterleave ) &&
                         *ptrUpper == '~' && *ptrLower == '~' )
                     {
                        for( ptr = ptrUpper + 1; *ptr; ptr++ )
                           *( ptr - 1 ) = *ptr;
                        *( ptr - 1 ) = '\0';
                        for( ptr = ptrLower + 1; *ptr; ptr++ )
                           *( ptr - 1 ) = *ptr;
                        *( ptr - 1 ) = '\0';
                        if( cdpage->lAccEqual )
                           i--;
                     }
                     else if( *ptrUpper == '.' && *ptrLower == '.' &&
                              ptrUpper[1] && ptrUpper[2] && ptrUpper[3] == '.' &&
                              ptrLower[1] && ptrLower[2] && ptrLower[3] == '.' )
                     {
                        multi[nMulti].cFirst[0] = *( ptrUpper + 1 );
                        multi[nMulti].cFirst[1] = *( ptrLower + 1 );
                        multi[nMulti].cLast[0] = *( ptrUpper + 2 );
                        multi[nMulti].cLast[1] = *( ptrLower + 2 );
                        multi[nMulti].nCode = i;

                        for( ptr = ptrUpper + 4; *ptr; ptr++ )
                           *( ptr - 4 ) = *ptr;
                        *( ptr - 4 ) = '\0';
                        for( ptr = ptrLower + 4; *ptr; ptr++ )
                           *( ptr - 4 ) = *ptr;
                        *( ptr - 4 ) = '\0';

                        nMulti++;
                        ptrUpper--;
                        ptrLower--;
                        cdpage->lSort = TRUE;
                        continue;
                     }
                     iu = ( UCHAR ) * ptrUpper;
                     il = ( UCHAR ) * ptrLower;
                     if( iu < iumax || il < ilmax )
                        cdpage->lSort = TRUE;
                     iumax = iu;
                     ilmax = il;

                     cdpage->s_chars[iu] = ( char ) i;
                     cdpage->s_chars[il] = ( char ) ( i + nAddLower );
                     if( cdpage->lAccInterleave )
                     {
                        cdpage->s_accent[iu] = ( char ) ia;
                        cdpage->s_accent[il] = ( char ) ( ia + nAddLower );
                     }
                     cdpage->s_upper[il] = *ptrUpper;
                     cdpage->s_lower[iu] = *ptrLower;
                  }
                  if( cdpage->lLatin )
                  {
                     for( i = 91; i <= 96; i++ )
                     {
                        if( !cdpage->s_chars[i] )
                           cdpage->s_chars[i] = ( char ) ( cdpage->nChars + ( i - 90 ) );
                     }
                     for( i = 123; i < 256; i++ )
                     {
                        if( !cdpage->s_chars[i] )
                           cdpage->s_chars[i] = ( char ) ( cdpage->nChars + nAddLower + ( i - 122 ) );
                     }
                  }
                  /*
                     for( i=0; i<32; i++ )
                     printf( "\n %3d %3d %3d %3d %3d %3d %3d %3d",cdpage->s_chars[i*8],
                     cdpage->s_chars[i*8+1],cdpage->s_chars[i*8+2],
                     cdpage->s_chars[i*8+3],cdpage->s_chars[i*8+4],
                     cdpage->s_chars[i*8+5],cdpage->s_chars[i*8+6],
                     cdpage->s_chars[i*8+7] );
                     if( nMulti )
                     {
                     printf( "\n" );
                     for( i=0; imulti = ( PHB_MULTICHAR ) hb_xgrab( sizeof( HB_MULTICHAR ) * nMulti );
                     memcpy( ( BYTE * ) cdpage->multi, ( BYTE * ) multi,
                             sizeof( HB_MULTICHAR ) * nMulti );
                     cdpage->nMulti = nMulti;
                  }
                  else
                     cdpage->multi = NULL;
               }
               return TRUE;
            }
         }
      }
   }

   return FALSE;
}
cdpapi.c294
HB_EXPORT PHB_CODEPAGEhb_cdpFind( const char *pszID )
HB_EXPORT PHB_CODEPAGE hb_cdpFind( const char *pszID )
{
   int iPos;

   HB_TRACE( HB_TR_DEBUG, ( "hb_cdpFind(%s)", pszID ) );

   iPos = hb_cdpFindPos( pszID );

   return ( iPos != -1 ) ? s_cdpList[iPos] : NULL;
}
cdpapi.c447
HB_EXPORT PHB_CODEPAGEhb_cdpSelect( PHB_CODEPAGE cdpage )
HB_EXPORT PHB_CODEPAGE hb_cdpSelect( PHB_CODEPAGE cdpage )
{
   PHB_CODEPAGE cdpOld;

   HB_TRACE( HB_TR_DEBUG, ( "hb_cdpSelect(%p)", cdpage ) );

   cdpOld = hb_vmCDP();
   if( cdpage )
      hb_vmSetCDP( cdpage );

   return cdpOld;
}
cdpapi.c458
HB_EXPORT CHAR *hb_cdpID( void )
HB_EXPORT char * hb_cdpID( void )
{
   PHB_CODEPAGE cdp;

   HB_TRACE( HB_TR_DEBUG, ( "hb_cdpID()" ) );

   cdp = hb_vmCDP();

   return cdp ? ( char * ) cdp->id : NULL;
}
cdpapi.c471
HB_EXPORT CHAR *hb_cdpSelectID( const char *pszID )
HB_EXPORT char * hb_cdpSelectID( const char *pszID )
{
   char *pszIDOld;

   HB_TRACE( HB_TR_DEBUG, ( "hb_cdpSelectID(%s)", pszID ) );

   pszIDOld = hb_cdpID();
   hb_cdpSelect( hb_cdpFind( pszID ) );

   return pszIDOld;
}
cdpapi.c482
HB_EXPORT VOIDhb_cdpTranslate( char *psz, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut )
HB_EXPORT void hb_cdpTranslate( char *psz, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut )
{
   if( cdpIn != cdpOut && cdpIn->nChars == cdpOut->nChars )
   {
      if( cdpIn->lAccEqual )
      {
         for( ; *psz; psz++ )
         {
            char * ptr;

            ptr = strchr( ( char * ) cdpIn->CharsUpper, *psz );
            if( ptr )
               *psz = cdpOut->CharsUpper[ ptr - cdpIn->CharsUpper ];
            else
            {
               ptr = strchr( ( char * ) cdpIn->CharsLower, *psz );
               if( ptr )
                  *psz = cdpOut->CharsLower[ ptr - cdpIn->CharsLower ];
            }
         }
      }
      else
      {
         int nAddLower = ( cdpIn->lLatin ) ? 6 : 0;

         for( ; *psz; psz++ )
         {
            int n = ( int ) cdpIn->s_chars[( UCHAR ) * psz];

            if( n != 0 &&
                ( n <= cdpOut->nChars || ( n > ( cdpOut->nChars + nAddLower ) &&
                                           n <= ( cdpOut->nChars * 2 + nAddLower ) ) ) )
            {
               n--;
               *psz = ( n >= ( cdpOut->nChars + nAddLower ) ) ?
                  cdpOut->CharsLower[n - cdpOut->nChars - nAddLower] : cdpOut->CharsUpper[n];
            }
         }
      }
   }
}
cdpapi.c494
HB_EXPORT VOIDhb_cdpnTranslate( char *psz, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut, ULONG nChars )
HB_EXPORT void hb_cdpnTranslate( char *psz, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut, ULONG nChars )
{
   if( cdpIn != cdpOut && cdpIn->nChars == cdpOut->nChars )
   {
      if( cdpIn->lAccEqual )
      {
         for( ; nChars--; psz++ )
         {
            char * ptr;

            ptr = strchr( ( char * ) cdpIn->CharsUpper, *psz );
            if( ptr )
               *psz = cdpOut->CharsUpper[ ptr - cdpIn->CharsUpper ];
            else
            {
               ptr = strchr( ( char * ) cdpIn->CharsLower, *psz );
               if( ptr )
                  *psz = cdpOut->CharsLower[ ptr - cdpIn->CharsLower ];
            }
         }
      }
      else
      {
         int nAddLower = ( cdpIn->lLatin ) ? 6 : 0;

         for( ; nChars--; psz++ )
         {
            int n = ( int ) cdpIn->s_chars[( UCHAR ) * psz];

            if( n != 0 &&
                ( n <= cdpOut->nChars || ( n > ( cdpOut->nChars + nAddLower ) &&
                                           n <= ( cdpOut->nChars * 2 + nAddLower ) ) ) )
            {
               n--;
               *psz = ( n >= ( cdpOut->nChars + nAddLower ) ) ?
                  cdpOut->CharsLower[n - cdpOut->nChars - nAddLower] : cdpOut->CharsUpper[n];
            }
         }
      }
   }
}
cdpapi.c536
HB_EXPORT USHORThb_cdpGetU16( PHB_CODEPAGE cdp, BOOL fCtrl, BYTE ch )
HB_EXPORT USHORT hb_cdpGetU16( PHB_CODEPAGE cdp, BOOL fCtrl, BYTE ch )
{
   USHORT u;

   if( ( fCtrl || ch >= 32 ) && cdp && cdp->uniTable &&
       cdp->uniTable->uniCodes && ch < cdp->uniTable->nChars )
   {
      u = cdp->uniTable->uniCodes[ch];
   }
   else
   {
      u = ch;
   }
   return u;
}
cdpapi.c578
HB_EXPORT UCHARhb_cdpGetChar( PHB_CODEPAGE cdp, BOOL fCtrl, USHORT uc )
HB_EXPORT UCHAR hb_cdpGetChar( PHB_CODEPAGE cdp, BOOL fCtrl, USHORT uc )
{
   if( ( fCtrl || uc >= 32 ) && cdp && cdp->uniTable && cdp->uniTable->uniCodes )
   {
      int i;

      for( i = fCtrl ? 0 : 32; i < cdp->uniTable->nChars; i++ )
      {
         if( cdp->uniTable->uniCodes[i] == uc )
         {
            uc = ( USHORT ) i;
            break;
         }
      }
   }
   return uc >= 0x100 ? '?' : ( UCHAR ) uc;
}
cdpapi.c594
HB_EXPORT BYTE hb_cdpUTF8StringSubstr( const BYTE * pSrc, ULONG ulLen, ULONG ulFrom, ULONG ulCount, ULONG * pulDest )
HB_EXPORT BYTE *hb_cdpUTF8StringSubstr( const BYTE * pSrc, ULONG ulLen,
                                        ULONG ulFrom, ULONG ulCount, ULONG * pulDest )
{
   ULONG ul, ulCnt, ulDst = 0;
   USHORT uc;
   int n;
   BYTE *pDst = NULL;

   if( ulCount && ulLen )
   {
      n = 0;
      for( ul = 0; ul < ulLen && ulFrom; ++ul )
      {
         if( utf8tou16nextchar( pSrc[ul], &n, &uc ) )
         {
            if( n == 0 )
               --ulFrom;
         }
      }

      if( ul < ulLen )
      {
         ulFrom = ul;
         ulCnt = ulCount;
         n = 0;
         do
         {
            if( utf8tou16nextchar( pSrc[ul], &n, &uc ) )
            {
               if( n == 0 )
                  --ulCnt;
            }
         }
         while( ++ul < ulLen && ulCnt );

         ulDst = ul - ulFrom;
         pDst = ( BYTE * ) hb_xgrab( ulDst + 1 );
         memcpy( pDst, &pSrc[ulFrom], ulDst );
      }
   }

   if( pulDest )
      *pulDest = ulDst;

   return pDst;
}
cdpapi.c612
HB_EXPORT ULONGhb_cdpUTF8StringPeek( const BYTE * pSrc, ULONG ulLen, ULONG ulPos )
HB_EXPORT ULONG hb_cdpUTF8StringPeek( const BYTE * pSrc, ULONG ulLen, ULONG ulPos )
{
   if( ulLen )
   {
      ULONG ul;
      USHORT uc = 0;
      int n = 0;

      for( ul = 0; ul < ulLen && ulPos; ++ul )
      {
         if( utf8tou16nextchar( pSrc[ul], &n, &uc ) )
         {
            if( n == 0 )
               --ulPos;
         }
      }

      if( ul < ulLen )
      {
         n = 0;
         do
         {
            if( utf8tou16nextchar( pSrc[ul], &n, &uc ) )
            {
               if( n == 0 )
                  return uc;
            }
         }
         while( ++ul < ulLen );
      }
   }

   return 0;
}
cdpapi.c659
HB_EXPORT ULONGhb_cdpUTF8StringLength( const BYTE * pSrc, ULONG ulLen )
HB_EXPORT ULONG hb_cdpUTF8StringLength( const BYTE * pSrc, ULONG ulLen )
{
   ULONG ul, ulDst;
   USHORT uc;
   int n = 0;

   for( ul = ulDst = 0; ul < ulLen; ++ul )
   {
      if( utf8tou16nextchar( pSrc[ul], &n, &uc ) )
      {
         if( n == 0 )
            ++ulDst;
      }
   }

   return ulDst;
}
cdpapi.c694
HB_EXPORT ULONGhb_cdpStringInUTF8Length( PHB_CODEPAGE cdp, BOOL fCtrl, const BYTE * pSrc, ULONG ulLen )
HB_EXPORT ULONG hb_cdpStringInUTF8Length( PHB_CODEPAGE cdp, BOOL fCtrl,
                                          const BYTE * pSrc, ULONG ulLen )
{
   ULONG ul, ulDst;

   for( ul = ulDst = 0; ul < ulLen; ++ul )
   {
      ulDst += utf8Size( hb_cdpGetU16( cdp, fCtrl, pSrc[ul] ) );
   }

   return ulDst;
}
cdpapi.c712
HB_EXPORT ULONGhb_cdpUTF8ToStrn( PHB_CODEPAGE cdp, BOOL fCtrl, const BYTE * pSrc, ULONG ulSrc, BYTE * pDst, ULONG ulDst )
HB_EXPORT ULONG hb_cdpUTF8ToStrn( PHB_CODEPAGE cdp, BOOL fCtrl,
                                  const BYTE * pSrc, ULONG ulSrc,
                                  BYTE * pDst, ULONG ulDst )
{
   ULONG ulS, ulD;
   USHORT uc = 0;
   int n = 0;

   for( ulS = ulD = 0; ulS < ulSrc; ++ulS )
   {
      if( utf8tou16nextchar( pSrc[ulS], &n, &uc ) )
      {
         if( n == 0 )
         {
            if( ulD < ulDst )
            {
               if( ( fCtrl || uc >= 32 ) && cdp->uniTable && cdp->uniTable->uniCodes )
               {
                  int i;

                  for( i = fCtrl ? 0 : 32; i < cdp->uniTable->nChars; i++ )
                  {
                     if( cdp->uniTable->uniCodes[i] == uc )
                     {
                        uc = ( USHORT ) i;
                        break;
                     }
                  }
               }
               pDst[ulD] = uc >= 0x100 ? '?' : ( BYTE ) uc;
            }
            ++ulD;
         }
      }
   }

   if( ulD < ulDst )
      pDst[ulD] = '\0';

   return ulD;
}
cdpapi.c725
HB_EXPORT BOOLhb_cdpGetFromUTF8( PHB_CODEPAGE cdp, BOOL fCtrl, BYTE ch, int *n, USHORT * uc )
HB_EXPORT BOOL hb_cdpGetFromUTF8( PHB_CODEPAGE cdp, BOOL fCtrl, BYTE ch,
                                  int *n, USHORT * uc )
{
   if( utf8tou16nextchar( ch, n, uc ) )
   {
      if( *n == 0 && cdp && ( fCtrl || *uc >= 32 ) && cdp->uniTable && cdp->uniTable->uniCodes )
      {
         int i;

         for( i = fCtrl ? 0 : 32; i < cdp->uniTable->nChars; i++ )
         {
            if( cdp->uniTable->uniCodes[i] == *uc )
            {
               *uc = ( USHORT ) i;
               break;
            }
         }
      }
      return TRUE;
   }
   return FALSE;
}
cdpapi.c767
HB_EXPORT ULONGhb_cdpStrnToUTF8( PHB_CODEPAGE cdp, BOOL fCtrl, const BYTE * pSrc, ULONG ulLen, BYTE * pDst )
HB_EXPORT ULONG hb_cdpStrnToUTF8( PHB_CODEPAGE cdp, BOOL fCtrl,
                                  const BYTE * pSrc, ULONG ulLen, BYTE * pDst )
{
   USHORT u, *uniCodes, nChars;
   ULONG i, n;

   if( cdp && cdp->uniTable )
   {
      if( cdp->nMulti || cdp->uniTable->lMulti )
      {
         /*
          * TODO: this translation is bad, please fix me!!!
          */
         for( i = 0, n = 0; i < ulLen; i++ )
         {
            u = hb_cdpGetU16( cdp, fCtrl, pSrc[i] );
            n += u16toutf8( &pDst[n], u );
         }
         return n;
      }
      else
      {
         uniCodes = cdp->uniTable->uniCodes;
         nChars = ( USHORT ) cdp->uniTable->nChars;
      }
   }
   else
   {
      nChars = 0;
      uniCodes = NULL;
   }

   for( i = 0, n = 0; i < ulLen; i++ )
   {
      u = pSrc[i];
      if( uniCodes && u < nChars && ( fCtrl || u >= 32 ) )
         u = uniCodes[u];
      n += u16toutf8( &pDst[n], u );
   }
   pDst[n] = '\0';

   return n;
}
cdpapi.c790
HB_EXPORT ULONGhb_cdpStrnToU16( PHB_CODEPAGE cdp, BOOL fCtrl, const BYTE * pSrc, ULONG ulLen, BYTE * pDst )
HB_EXPORT ULONG hb_cdpStrnToU16( PHB_CODEPAGE cdp, BOOL fCtrl,
                                 const BYTE * pSrc, ULONG ulLen, BYTE * pDst )
{
   USHORT u, *uniCodes, nChars;
   ULONG i;

   if( cdp && cdp->uniTable )
   {
      if( cdp->nMulti || cdp->uniTable->lMulti )
      {
         /*
          * TODO: this translation is bad, please fix me!!!
          */
         for( i = 0; i < ulLen; i++, pDst += 2 )
         {
            u = hb_cdpGetU16( cdp, fCtrl, pSrc[i] );
            HB_PUT_BE_UINT16( pDst, u );
         }
         return i << 1;
      }
      else
      {
         uniCodes = cdp->uniTable->uniCodes;
         nChars = ( USHORT ) cdp->uniTable->nChars;
      }
   }
   else
   {
      nChars = 0;
      uniCodes = NULL;
   }

   for( i = 0; i < ulLen; i++, pDst += 2 )
   {
      u = pSrc[i];
      if( uniCodes && u < nChars && ( fCtrl || u >= 32 ) )
         u = uniCodes[u];
      HB_PUT_BE_UINT16( pDst, u );
   }
   return i << 1;
}
cdpapi.c834
HB_EXPORT INThb_cdpchrcmp( char cFirst, char cSecond, PHB_CODEPAGE cdpage )
HB_EXPORT int hb_cdpchrcmp( char cFirst, char cSecond, PHB_CODEPAGE cdpage )
{
   int n1, n2;

   if( cFirst == cSecond )
      return 0;

   if( ( n1 = ( int ) cdpage->s_chars[( UCHAR ) cFirst] ) != 0 &&
       ( n2 = ( int ) cdpage->s_chars[( UCHAR ) cSecond] ) != 0 )
      return ( n1 < n2 ) ? -1 : 1;

   return ( ( UCHAR ) cFirst < ( UCHAR ) cSecond ) ? -1 : 1;
}
cdpapi.c876
STATIC INThb_cdpMultiWeight( PHB_CODEPAGE cdpage, const char *szChar )
static int hb_cdpMultiWeight( PHB_CODEPAGE cdpage, const char *szChar )
{
   PHB_MULTICHAR pmulti = cdpage->multi;
   int j;

   for( j = 0; j < cdpage->nMulti; ++j, ++pmulti )
   {
      if( ( *szChar == pmulti->cFirst[0] ||
            *szChar == pmulti->cFirst[1] ) &&
          ( *( szChar + 1 ) == pmulti->cLast[0] || *( szChar + 1 ) == pmulti->cLast[1] ) )
      {
         return pmulti->nCode +
            ( ( *szChar == pmulti->cFirst[0] ) ? 0 :
              ( cdpage->nChars + ( cdpage->lLatin ? 6 : 0 ) ) );
      }
   }

   return 0;
}
cdpapi.c890
HB_EXPORT INThb_cdpcmp( const char *szFirst, ULONG ulLenFirst, const char *szSecond, ULONG ulLenSecond, PHB_CODEPAGE cdpage, BOOL fExact )
HB_EXPORT int hb_cdpcmp( const char *szFirst, ULONG ulLenFirst,
                         const char *szSecond, ULONG ulLenSecond,
                         PHB_CODEPAGE cdpage, BOOL fExact )
{
   int iRet = 0, iAcc = 0, n1 = 0, n2 = 0;
   ULONG ul, ulLen;

   ulLen = ulLenFirst < ulLenSecond ? ulLenFirst : ulLenSecond;
   for( ul = 0; ul < ulLen; ++szFirst, ++szSecond, ++ul )
   {
      if( *szFirst != *szSecond )
      {
         if( cdpage->nMulti )
         {
            int nd1, nd2;

            if( ul > 0 )
            {
               nd1 = hb_cdpMultiWeight( cdpage, szFirst - 1 );
               nd2 = hb_cdpMultiWeight( cdpage, szSecond - 1 );
               if( nd1 )
               {
                  if( nd2 )
                  {
                     if( nd1 == nd2 )
                     {
                        nd1 = ( UCHAR ) cdpage->s_chars[( UCHAR ) * szFirst];
                        nd2 = ( UCHAR ) cdpage->s_chars[( UCHAR ) * szSecond];
                        if( nd1 == nd2 || !nd1 || !nd2 )
                        {
                           nd1 = ( UCHAR ) * szFirst;
                           nd2 = ( UCHAR ) * szSecond;
                        }
                     }
                  }
                  else
                     nd2 = n2;
                  iRet = ( nd1 < nd2 ) ? -1 : 1;
                  break;
               }
               else if( nd2 )
               {
                  iRet = ( n1 < nd2 ) ? -1 : 1;
                  break;
               }
            }
            nd1 = ( ul < ulLenFirst - 1 ) ? hb_cdpMultiWeight( cdpage, szFirst ) : 0;
            nd2 = ( ul < ulLenSecond - 1 ) ? hb_cdpMultiWeight( cdpage, szSecond ) : 0;
            if( nd1 )
            {
               if( nd2 )
               {
                  if( nd1 == nd2 )
                  {
                     nd1 = ( UCHAR ) cdpage->s_chars[( UCHAR ) * szFirst];
                     nd2 = ( UCHAR ) cdpage->s_chars[( UCHAR ) * szSecond];
                     if( nd1 == nd2 || !nd1 || !nd2 )
                     {
                        nd1 = ( UCHAR ) * szFirst;
                        nd2 = ( UCHAR ) * szSecond;
                     }
                  }
               }
               else
                  nd2 = ( UCHAR ) cdpage->s_chars[( UCHAR ) * szSecond];
               iRet = ( nd1 < nd2 ) ? -1 : 1;
               break;
            }
            else if( nd2 )
            {
               nd1 = ( UCHAR ) cdpage->s_chars[( UCHAR ) * szFirst];
               iRet = ( nd1 < nd2 ) ? -1 : 1;
               break;
            }
         }

         if( ( n1 = ( UCHAR ) cdpage->s_chars[( UCHAR ) * szFirst] ) == 0 ||
             ( n2 = ( UCHAR ) cdpage->s_chars[( UCHAR ) * szSecond] ) == 0 )
         {
            /* One of characters doesn't belong to the national characters */
            iRet = ( ( UCHAR ) * szFirst < ( UCHAR ) * szSecond ) ? -1 : 1;
            break;
         }
         else if( n1 == n2 )
         {
            if( iAcc == 0 && ( fExact || ( ulLenFirst == ulLenSecond && cdpage->lAccInterleave ) ) )
            {
               if( cdpage->lAccInterleave )
                  iAcc = ( cdpage->s_accent[( UCHAR ) * szFirst] <
                           cdpage->s_accent[( UCHAR ) * szSecond] ) ? -1 : 1;
               else
                  iAcc = ( ( UCHAR ) * szFirst < ( UCHAR ) * szSecond ) ? -1 : 1;
            }
         }
         else
         {
            iRet = ( n1 < n2 ) ? -1 : 1;
            break;
         }
      }
   }

   if( !iRet )
   {
      if( iAcc )
         iRet = iAcc;
      else if( ulLenSecond > ulLenFirst )
         iRet = -1;
      else if( fExact && ulLenSecond < ulLenFirst )
         iRet = 1;
   }

   return iRet;
}
cdpapi.c910
STATIC INThb_cdpMultiWeightI( PHB_CODEPAGE cdpage, const char *szChar )
static int hb_cdpMultiWeightI( PHB_CODEPAGE cdpage, const char *szChar )
{
   PHB_MULTICHAR pmulti = cdpage->multi;
   int j;

   for( j = 0; j < cdpage->nMulti; ++j, ++pmulti )
   {
      if( ( *szChar == pmulti->cFirst[0] ||
            *szChar == pmulti->cFirst[1] ) &&
          ( *( szChar + 1 ) == pmulti->cLast[0] || *( szChar + 1 ) == pmulti->cLast[1] ) )
      {
         return pmulti->nCode;
      }
   }

   return 0;
}
cdpapi.c1025
HB_EXPORT INThb_cdpicmp( const char *szFirst, ULONG ulLenFirst, const char *szSecond, ULONG ulLenSecond, PHB_CODEPAGE cdpage, BOOL fExact )
HB_EXPORT int hb_cdpicmp( const char *szFirst, ULONG ulLenFirst,
                          const char *szSecond, ULONG ulLenSecond,
                          PHB_CODEPAGE cdpage, BOOL fExact )
{
   int iRet = 0, iAcc = 0, n1 = 0, n2 = 0, u1, u2;
   ULONG ul, ulLen;

   ulLen = ulLenFirst < ulLenSecond ? ulLenFirst : ulLenSecond;
   for( ul = 0; ul < ulLen; ++szFirst, ++szSecond, ++ul )
   {
      u1 = ( UCHAR ) cdpage->s_upper[( UCHAR ) * szFirst];
      u2 = ( UCHAR ) cdpage->s_upper[( UCHAR ) * szSecond];
      if( u1 != u2 )
      {
         if( cdpage->nMulti )
         {
            int nd1, nd2;

            if( ul > 0 )
            {
               nd1 = hb_cdpMultiWeightI( cdpage, szFirst - 1 );
               nd2 = hb_cdpMultiWeightI( cdpage, szSecond - 1 );
               if( nd1 )
               {
                  if( nd2 )
                  {
                     if( nd1 == nd2 )
                     {
                        nd1 = ( UCHAR ) cdpage->s_chars[u1];
                        nd2 = ( UCHAR ) cdpage->s_chars[u2];
                        if( nd1 == nd2 || !nd1 || !nd2 )
                        {
                           nd1 = u1;
                           nd2 = u2;
                        }
                     }
                  }
                  else
                     nd2 = n2;
                  iRet = ( nd1 < nd2 ) ? -1 : 1;
                  break;
               }
               else if( nd2 )
               {
                  iRet = ( n1 < nd2 ) ? -1 : 1;
                  break;
               }
            }
            nd1 = ( ul < ulLenFirst - 1 ) ? hb_cdpMultiWeightI( cdpage, szFirst ) : 0;
            nd2 = ( ul < ulLenSecond - 1 ) ? hb_cdpMultiWeightI( cdpage, szSecond ) : 0;
            if( nd1 )
            {
               if( nd2 )
               {
                  if( nd1 == nd2 )
                  {
                     nd1 = ( UCHAR ) cdpage->s_chars[u1];
                     nd2 = ( UCHAR ) cdpage->s_chars[u2];
                     if( nd1 == nd2 || !nd1 || !nd2 )
                     {
                        nd1 = u1;
                        nd2 = u2;
                     }
                  }
               }
               else
                  nd2 = ( UCHAR ) cdpage->s_chars[u2];
               iRet = ( nd1 < nd2 ) ? -1 : 1;
               break;
            }
            else if( nd2 )
            {
               nd1 = ( UCHAR ) cdpage->s_chars[u1];
               iRet = ( nd1 < nd2 ) ? -1 : 1;
               break;
            }
         }

         if( ( n1 = ( UCHAR ) cdpage->s_chars[u1] ) == 0 ||
             ( n2 = ( UCHAR ) cdpage->s_chars[u2] ) == 0 )
         {
            /* One of characters doesn't belong to the national characters */
            iRet = ( u1 < u2 ) ? -1 : 1;
            break;
         }
         else if( n1 == n2 )
         {
            if( iAcc == 0 && ( fExact || ( ulLenFirst == ulLenSecond && cdpage->lAccInterleave ) ) )
            {
               if( cdpage->lAccInterleave )
                  iAcc = ( cdpage->s_accent[u1] < cdpage->s_accent[u2] ) ? -1 : 1;
               else
                  iAcc = ( u1 < u2 ) ? -1 : 1;
            }
         }
         else
         {
            iRet = ( n1 < n2 ) ? -1 : 1;
            break;
         }
      }
   }

   if( !iRet )
   {
      if( iAcc )
         iRet = iAcc;
      else if( ulLenSecond > ulLenFirst )
         iRet = -1;
      else if( fExact && ulLenSecond < ulLenFirst )
         iRet = 1;
   }

   return iRet;
}
cdpapi.c1043
HB_EXPORT VOIDhb_cdpReleaseAll( void )
HB_EXPORT void hb_cdpReleaseAll( void )
{
   int iPos = 0;

   while( iPos < HB_CDP_MAX_ && s_cdpList[iPos] )
   {
      if( s_cdpList[iPos]->s_chars )
         hb_xfree( s_cdpList[iPos]->s_chars );
      if( s_cdpList[iPos]->s_upper )
         hb_xfree( s_cdpList[iPos]->s_upper );
      if( s_cdpList[iPos]->s_lower )
         hb_xfree( s_cdpList[iPos]->s_lower );
      if( s_cdpList[iPos]->s_accent )
         hb_xfree( s_cdpList[iPos]->s_accent );
      if( s_cdpList[iPos]->multi )
         hb_xfree( s_cdpList[iPos]->multi );
      if( s_cdpList[iPos]->lChClone )
      {
         hb_xfree( ( void * ) s_cdpList[iPos]->CharsUpper );
         hb_xfree( ( void * ) s_cdpList[iPos]->CharsLower );
      }
      iPos++;
   }
}
cdpapi.c1159
HB_FUNCHB_SETCODEPAGE(void)
HB_FUNC( HB_SETCODEPAGE )
{
   hb_retc( hb_cdpID() );

   if( ISCHAR( 1 ) )
      hb_cdpSelectID( hb_parc( 1 ) );
}
cdpapi.c1184
HB_FUNCHB_TRANSLATE(void)
HB_FUNC( HB_TRANSLATE )
{
   ULONG ulLen = hb_parclen( 1 );
   char *szIdIn = hb_parc( 2 );
   char *szIdOut = hb_parc( 3 );

   if( ulLen && ( szIdIn || szIdOut ) )
   {
      PHB_CODEPAGE cdpIn = szIdIn ? hb_cdpFind( szIdIn ) : hb_vmCDP();
      PHB_CODEPAGE cdpOut = szIdOut ? hb_cdpFind( szIdOut ) : hb_vmCDP();

      if( cdpIn && cdpOut && cdpIn != cdpOut )
      {
         char *szResult = ( char * ) hb_xgrab( ulLen + 1 );

         memcpy( szResult, hb_parc( 1 ), ulLen + 1 );
         hb_cdpnTranslate( szResult, cdpIn, cdpOut, ulLen );
         hb_retclen_buffer( szResult, ulLen );
      }
      else
         hb_itemReturn( hb_param( 1, HB_IT_STRING ) );
   }
   else
      hb_retc( NULL );
}
cdpapi.c1192
HB_FUNCHB_CDPLIST(void)
HB_FUNC( HB_CDPLIST )
{
   int iCount, iPos;

   for( iCount = 0; iCount < HB_CDP_MAX_; ++iCount )
   {
      if( !s_cdpList[iCount] )
         break;
   }

   hb_reta( iCount );
   for( iPos = 0; iPos < iCount; ++iPos )
   {
      hb_storc( s_cdpList[iPos]->id, -1, iPos + 1 );
   }
}
cdpapi.c1218
HB_FUNCHB_STRTOUTF8(void)
HB_FUNC( HB_STRTOUTF8 )
{
   ULONG ulLen = hb_parclen( 1 ), ulDest = 0;
   char *szString, *szDest = NULL;

   if( ulLen )
   {
      PHB_CODEPAGE cdp = ISCHAR( 2 ) ? hb_cdpFind( hb_parc( 2 ) ) : hb_vmCDP();

      if( cdp )
      {
         szString = hb_parc( 1 );
         ulDest = hb_cdpStringInUTF8Length( cdp, FALSE, ( BYTE * ) szString, ulLen );
         szDest = ( char * ) hb_xgrab( ulDest + 1 );
         hb_cdpStrnToUTF8( cdp, FALSE, ( BYTE * ) szString, ulLen, ( BYTE * ) szDest );
      }
   }
   if( szDest )
      hb_retclen_buffer( szDest, ulDest );
   else
      hb_retc( NULL );
}
cdpapi.c1235
HB_FUNCHB_UTF8CHR(void)
HB_FUNC( HB_UTF8CHR )
{
   if( ISNUM( 1 ) )
   {
      char utf8Char[ HB_MAX_UTF8 ];
      int iLen;

      iLen = u16toutf8( ( BYTE * ) utf8Char, ( USHORT ) hb_parni( 1 ) );
      hb_retclen( utf8Char, iLen );
   }
   else
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}
cdpapi.c1258
HB_FUNCHB_UTF8TOSTR(void)
HB_FUNC( HB_UTF8TOSTR )
{
   char *szString = hb_parc( 1 );

   if( szString )
   {
      ULONG ulLen = hb_parclen( 1 ), ulDest = 0;
      char *szDest = NULL;

      if( ulLen )
      {
         PHB_CODEPAGE cdp = ISCHAR( 2 ) ? hb_cdpFind( hb_parc( 2 ) ) : hb_vmCDP();

         if( cdp )
         {
            szString = hb_parc( 1 );
            ulDest = hb_cdpUTF8StringLength( ( BYTE * ) szString, ulLen );
            szDest = ( char * ) hb_xgrab( ulDest + 1 );
            hb_cdpUTF8ToStrn( cdp, FALSE, ( BYTE * ) szString, ulLen, ( BYTE * ) szDest, ulDest );
         }
      }

      if( szDest )
         hb_retclen_buffer( szDest, ulDest );
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
cdpapi.c1274
HB_FUNCHB_UTF8SUBSTR(void)
HB_FUNC( HB_UTF8SUBSTR )
{
   char *szString = hb_parc( 1 );
   int iPCount = hb_pcount();

   if( szString && ( iPCount < 2 || ( ISNUM( 2 ) && ( iPCount < 3 || ISNUM( 3 ) ) ) ) )
   {
      char *szDest = NULL;
      ULONG ulLen = hb_parclen( 1 ), ulDest = 0;
      LONG lFrom = hb_parnl( 2 );
      LONG lCount = iPCount < 3 ? ( LONG ) ulLen : hb_parnl( 3 );

      if( lFrom < 0 )
      {
         lFrom += hb_cdpUTF8StringLength( ( BYTE * ) szString, ulLen );
         if( lFrom < 0 )
            lFrom = 0;
      }
      else if( lFrom )
         --lFrom;

      if( ulLen && lCount > 0 )
         szDest = ( char * ) hb_cdpUTF8StringSubstr( ( BYTE * ) szString,
                                                     ulLen, lFrom, lCount, &ulDest );
      if( szDest )
         hb_retclen_buffer( szDest, ulDest );
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
cdpapi.c1305
HB_FUNCHB_UTF8LEFT(void)
HB_FUNC( HB_UTF8LEFT )
{
   char *szString = hb_parc( 1 );

   if( szString && ISNUM( 2 ) )
   {
      LONG lLen = hb_parnl( 2 );
      ULONG ulDest = 0;
      char *szDest = NULL;

      if( lLen > 0 )
         szDest = ( char * ) hb_cdpUTF8StringSubstr( ( BYTE * ) szString,
                                                     hb_parclen( 1 ), 0, lLen, &ulDest );

      if( szDest )
         hb_retclen_buffer( szDest, ulDest );
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
cdpapi.c1338
HB_FUNCHB_UTF8RIGHT(void)
HB_FUNC( HB_UTF8RIGHT )
{
   char *szString = hb_parc( 1 );

   if( szString && ISNUM( 2 ) )
   {
      LONG lLen = hb_parnl( 2 ), lFrom;
      ULONG ulLen = hb_parclen( 1 ), ulDest = 0;
      char *szDest = NULL;

      if( ulLen && lLen > 0 )
      {
         lFrom = hb_cdpUTF8StringLength( ( BYTE * ) szString, ulLen ) - lLen;
         if( lFrom < 0 )
            lFrom = 0;
         szDest = ( char * ) hb_cdpUTF8StringSubstr( ( BYTE * ) szString,
                                                     ulLen, lFrom, lLen, &ulDest );
      }

      if( szDest )
         hb_retclen_buffer( szDest, ulDest );
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
cdpapi.c1361
HB_FUNCHB_UTF8PEEK(void)
HB_FUNC( HB_UTF8PEEK )
{
   char *szString = hb_parc( 1 );

   if( szString && ISNUM( 2 ) )
   {
      ULONG ulPos = hb_parnl( 2 );
      ULONG ulLen = hb_parclen( 1 );

      if( ulPos > 0 && ulPos <= ulLen )
         hb_retnint( hb_cdpUTF8StringPeek( ( BYTE * ) szString, ulLen, ulPos - 1 ) );
      else
         hb_retni( 0 );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
cdpapi.c1389
HB_FUNCHB_UTF8POKE(void)
HB_FUNC( HB_UTF8POKE )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText && ISNUM( 2 ) && ISNUM( 3 ) )
   {
      char *szString = hb_itemGetCPtr( pText );
      ULONG ulLen = hb_parclen( 1 ), ulPos;

      ulPos = utf8pos( ( BYTE * ) szString, ulLen, hb_parnl( 2 ) );
      if( ulPos )
      {
         USHORT uc, uc2;
         int n, n2;

         --ulPos;
         uc = ( USHORT ) hb_parni( 3 );
         n = utf8Size( uc );
         n2 = 0;
         utf8tou16nextchar( ( BYTE ) szString[ulPos], &n2, &uc2 );
         ++n2;
         if( n == n2 )
         {
            pText = hb_itemUnShareString( pText );
            u16toutf8( ( BYTE * ) & hb_itemGetCPtr( pText )[ulPos], uc );
            hb_itemReturn( pText );
         }
         else
         {
            char *szResult = ( char * ) hb_xgrab( ulLen - n2 + n + 1 );

            memcpy( szResult, szString, ulPos );
            u16toutf8( ( BYTE * ) & szResult[ulPos], uc );
            memcpy( szResult + ulPos + n, szString + ulPos + n2, ulLen - ulPos - n2 );
            if( ISBYREF( 1 ) )
               hb_storclen( szResult, ulLen - n2 + n, 1 );
            hb_retclen_buffer( szResult, ulLen - n2 + n );
         }
      }
      else
         hb_itemReturn( pText );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
cdpapi.c1407
HB_FUNCHB_UTF8STUFF(void)
HB_FUNC( HB_UTF8STUFF )
{
   char *szString = hb_parc( 1 );

   if( szString && ISNUM( 2 ) && ISNUM( 3 ) && ISCHAR( 4 ) )
   {
      ULONG ulLen = hb_parclen( 1 );
      ULONG ulPos = hb_parnl( 2 );
      ULONG ulDel = hb_parnl( 3 );
      ULONG ulIns = hb_parclen( 4 );
      ULONG ulTot;

      if( ulPos )
      {
         ulPos = utf8pos( ( BYTE * ) szString, ulLen, ulPos );
         if( ulPos == 0 )
            ulPos = ulLen;
         else
            ulPos--;
      }
      if( ulDel )
      {
         if( ulPos < ulLen )
         {
            ulDel = utf8pos( ( BYTE * ) szString + ulPos, ulLen - ulPos, ulDel + 1 );
            if( ulDel == 0 )
               ulDel = ulLen - ulPos;
            else
               ulDel--;
         }
         else
            ulDel = 0;
      }

      if( ( ulTot = ulLen + ulIns - ulDel ) > 0 )
      {
         char *szResult = ( char * ) hb_xgrab( ulTot + 1 );

         hb_xmemcpy( szResult, szString, ulPos );
         hb_xmemcpy( szResult + ulPos, hb_parc( 4 ), ulIns );
         hb_xmemcpy( szResult + ulPos + ulIns, szString + ulPos + ulDel,
                     ulLen - ( ulPos + ulDel ) );
         hb_retclen_buffer( szResult, ulTot );
      }
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
cdpapi.c1453
HB_FUNCHB_UTF8LEN(void)
HB_FUNC( HB_UTF8LEN )
{
   char *szString = hb_parc( 1 );

   if( szString )
      hb_retnint( hb_cdpUTF8StringLength( ( BYTE * ) szString, hb_parclen( 1 ) ) );
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}

/* non of numeric parameters in STRTRAN() (4-th and 5-th) refers to
 * character position in string so we do not need to create new
 * HB_UTF8STRTRAN() but we can safely use normal STRTRAN() function
 */
HB_FUNC_EXTERN( STRTRAN );
cdpapi.c1504
HB_FUNCHB_UTF8STRTRAN(void)
HB_FUNC( HB_UTF8STRTRAN )
{
   HB_FUNC_EXEC( STRTRAN )
}
cdpapi.c1520
chrasc.c
TypeFunctionSourceLine
HB_FUNCCHR(void)
HB_FUNC( CHR )
{
   if( ISNUM( 1 ) )
   {
      /* NOTE: CA-Cl*pper's compiler optimizer will be wrong for those
               CHR() cases where the passed parameter is a constant which
               can be divided by 256 but it's not zero, in this case it
               will return an empty string instead of a Chr(0). [vszakats] */

      /* Believe it or not, clipper does this! */
#ifdef HB_C52_STRICT
      char szChar[ 2 ];
      szChar[ 0 ] = hb_parnl( 1 ) % 256;
      szChar[ 1 ] = '\0';
      hb_retclen( szChar, 1 );
#else
      hb_retclen( hb_szAscii[ hb_parni( 1 ) & 0xff ], 1 );
#endif
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1104, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
chrasc.c59
HB_FUNCASC(void)
HB_FUNC( ASC )
{
   char * szValue = hb_parc( 1 );

   if( szValue )
      hb_retni( ( UCHAR ) szValue[ 0 ] );
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1107, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
chrasc.c83
colorind.c
TypeFunctionSourceLine
HB_FUNCHB_COLORINDEX(void)
HB_FUNC( HB_COLORINDEX )
{
   if( ISCHAR( 1 ) && ISNUM( 2 ) )
   {
      char * pszColor = hb_parc( 1 );
      ULONG ulColorPos;
      ULONG ulColorLen;
      USHORT uiColorIndex = ( USHORT ) hb_parni( 2 );

      /* Skip the given number of commas */
      for( ulColorPos = 0; pszColor[ ulColorPos ] != '\0' && uiColorIndex > 0; ulColorPos++ )
      {
         if( pszColor[ ulColorPos ] == ',' )
            uiColorIndex--;
      }

      /* if found, continue */
      if( uiColorIndex == 0 )
      {
         /* Skip the spaces after the comma */
         while( pszColor[ ulColorPos ] == ' ' )
            ulColorPos++;

         /* Search for next comma or end of string */
         ulColorLen = 0;
         while( pszColor[ ulColorPos + ulColorLen ] != '\0' &&
                pszColor[ ulColorPos + ulColorLen ] != ',' )
            ulColorLen++;

         /* Skip the trailing spaces */
         while( ulColorLen > 0 &&
                pszColor[ ulColorPos + ulColorLen - 1 ] == ' ' )
            ulColorLen--;

         /* Return the string */
         hb_retclen( pszColor + ulColorPos, ulColorLen );
      }
      else
         hb_retc( NULL );
   }
   else
      hb_retc( NULL );
}
colorind.c55
console.c
TypeFunctionSourceLine
STATIC PHB_PRNPOShb_prnPos( void )
static PHB_PRNPOS hb_prnPos( void )
{
   return ( PHB_PRNPOS ) hb_stackGetTSD( &s_prnPos );
}
console.c113
VOIDhb_conInit( void )
void hb_conInit( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_conInit()"));

#if !defined( HB_WIN32_IO )
   /* when HB_WIN32_IO is set file handles with numbers 0, 1, 2 are
      transalted inside filesys to:
      GetStdHandle( STD_INPUT_HANDLE ), GetStdHandle( STD_OUTPUT_HANDLE ),
      GetStdHandle( STD_ERROR_HANDLE ) */

   s_hFilenoStdin  = fileno( stdin );
   s_hFilenoStdout = fileno( stdout );
   s_hFilenoStderr = fileno( stderr );

#endif

#ifdef HB_C52_UNDOC
   {
      /* Undocumented CA-Cl*pper switch //STDERR:x */
      int iStderr = hb_cmdargNum( "STDERR" );

      if( iStderr == 0 || iStderr == 1 )  /* //STDERR with no parameter or 0 */
         s_hFilenoStderr = s_hFilenoStdout;
      /* disabled in default builds. It's not multiplatform and very
       * dangerous because it can redirect error messages to data files
       * [druzus]
       */
#ifdef HB_C52_STRICT
      else if( iStderr > 0 ) /* //STDERR:x */
         s_hFilenoStderr = ( HB_FHANDLE ) iStderr;
#endif
   }
#endif

   /*
    * Some compilers open stdout and stderr in text mode, but
    * Harbour needs them to be open in binary mode.
    */
   hb_fsSetDevMode( s_hFilenoStdout, FD_BINARY );
   hb_fsSetDevMode( s_hFilenoStderr, FD_BINARY );

   hb_gtInit( s_hFilenoStdin, s_hFilenoStdout, s_hFilenoStderr );
}
console.c118
VOIDhb_conRelease( void )
void hb_conRelease( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_conRelease()"));

   /*
    * Clipper does not restore screen size on exit so I removed the code with:
    *    hb_gtSetMode( s_originalMaxRow + 1, s_originalMaxCol + 1 );
    * If the low level GT drive change some video adapter parameters which
    * have to be restored on exit then it should does it in its Exit()
    * method. Here we cannot force any actions because it may cause bad
    * results in some GTs, f.e. when the screen size is controlled by remote
    * user and not Harbour application (some terminal modes), [Druzus]
    */

   hb_gtExit();

   hb_fsSetDevMode( s_hFilenoStdout, FD_TEXT );
   hb_fsSetDevMode( s_hFilenoStderr, FD_TEXT );
}
console.c162
CHAR *hb_conNewLine( void )
char * hb_conNewLine( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_conNewLine()"));

   return ( char * ) s_szCrLf;
}
console.c182
HB_FUNCHB_OSNEWLINE(void)
HB_FUNC( HB_OSNEWLINE )
{
   hb_retc( s_szCrLf );
}
console.c189
VOIDhb_conOutStd( const char * pStr, ULONG ulLen )
void hb_conOutStd( const char * pStr, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_conOutStd(%s, %lu)", pStr, ulLen));

   if( ulLen == 0 )
      ulLen = strlen( pStr );

   if( ulLen > 0 )
      hb_gtOutStd( ( BYTE * ) pStr, ulLen );
}
console.c194
VOIDhb_conOutErr( const char * pStr, ULONG ulLen )
void hb_conOutErr( const char * pStr, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_conOutErr(%s, %lu)", pStr, ulLen));

   if( ulLen == 0 )
      ulLen = strlen( pStr );

   if( ulLen > 0 )
      hb_gtOutErr( ( BYTE * ) pStr, ulLen );
}
console.c206
VOIDhb_conOutAlt( const char * pStr, ULONG ulLen )
void hb_conOutAlt( const char * pStr, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_conOutAlt(%s, %lu)", pStr, ulLen));

   if( hb_setGetConsole() )
      hb_gtWriteCon( ( BYTE * ) pStr, ulLen );

   if( hb_setGetAlternate() && hb_setGetAltHan() != FS_ERROR )
   {
      /* Print to alternate file if SET ALTERNATE ON and valid alternate file */
      hb_fsWriteLarge( hb_setGetAltHan(), ( BYTE * ) pStr, ulLen );
   }

   if( hb_setGetExtraHan() != FS_ERROR )
   {
      /* Print to extra file if valid alternate file */
      hb_fsWriteLarge( hb_setGetExtraHan(), ( BYTE * ) pStr, ulLen );
   }

   if( hb_setGetPrinter() && hb_setGetPrintHan() != FS_ERROR )
   {
      /* Print to printer if SET PRINTER ON and valid printer file */
      hb_fsWriteLarge( hb_setGetPrintHan(), ( BYTE * ) pStr, ulLen );
      hb_prnPos()->col += ( USHORT ) ulLen;
   }
}
console.c218
STATIC VOIDhb_conOutDev( const char * pStr, ULONG ulLen )
static void hb_conOutDev( const char * pStr, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_conOutDev(%s, %lu)", pStr, ulLen));

   if( hb_setGetPrintHan() != FS_ERROR &&
       hb_stricmp( hb_setGetDevice(), "PRINTER" ) == 0 )
   {
      /* Display to printer if SET DEVICE TO PRINTER and valid printer file */
      hb_fsWriteLarge( hb_setGetPrintHan(), ( BYTE * ) pStr, ulLen );
      hb_prnPos()->col += ( USHORT ) ulLen;
   }
   else
      /* Otherwise, display to console */
      hb_gtWrite( ( BYTE * ) pStr, ulLen );
}

typedef void hb_out_func_typedef( const char *, ULONG );
console.c246
STATIC CHAR *hb_itemStringCon( PHB_ITEM pItem, ULONG * pulLen, BOOL * pfFreeReq )
static char * hb_itemStringCon( PHB_ITEM pItem, ULONG * pulLen, BOOL * pfFreeReq )
{
   /* logical values in device output (not console, stdout or stderr) are
      shown as single letter */
   if( HB_IS_LOGICAL( pItem ) )
   {
      *pulLen = 1;
      *pfFreeReq = FALSE;
      return ( char * ) ( hb_itemGetL( pItem ) ? "T" : "F" );
   }
   return hb_itemString( pItem, pulLen, pfFreeReq );
}
console.c265
STATIC VOIDhb_conOut( USHORT uiParam, hb_out_func_typedef * pOutFunc )
static void hb_conOut( USHORT uiParam, hb_out_func_typedef * pOutFunc )
{
   char * pszString;
   ULONG ulLen;
   BOOL bFreeReq;
   PHB_ITEM pItem;

   HB_TRACE(HB_TR_DEBUG, ("hb_conOut(%hu, %p)", uiParam, pOutFunc));

   pItem = hb_param( uiParam, HB_IT_ANY );

   if( pOutFunc == hb_conOutDev )
      pszString = hb_itemStringCon( pItem, &ulLen, &bFreeReq );
   else
      pszString = hb_itemString( pItem, &ulLen, &bFreeReq );

   if( ulLen )
      pOutFunc( pszString, ulLen );

   if( bFreeReq )
      hb_xfree( pszString );
}
console.c278
HB_FUNCOUTSTD(void)
HB_FUNC( OUTSTD ) /* writes a list of values to the standard output device */
{
   USHORT uiPCount = ( USHORT ) hb_pcount();
   USHORT uiParam;

   for( uiParam = 1; uiParam <= uiPCount; uiParam++ )
   {
      hb_conOut( uiParam, hb_conOutStd );
      if( uiParam < uiPCount )
         hb_conOutStd( " ", 1 );
   }
}
console.c302
HB_FUNCOUTERR(void)
HB_FUNC( OUTERR ) /* writes a list of values to the standard error device */
{
   USHORT uiPCount = ( USHORT ) hb_pcount();
   USHORT uiParam;

   for( uiParam = 1; uiParam <= uiPCount; uiParam++ )
   {
      hb_conOut( uiParam, hb_conOutErr );
      if( uiParam < uiPCount )
         hb_conOutErr( " ", 1 );
   }
}
console.c315
HB_FUNCQQOUT(void)
HB_FUNC( QQOUT ) /* writes a list of values to the current device (screen or printer) and is affected by SET ALTERNATE */
{
   USHORT uiPCount = ( USHORT ) hb_pcount();
   USHORT uiParam;

   for( uiParam = 1; uiParam <= uiPCount; uiParam++ )
   {
      hb_conOut( uiParam, hb_conOutAlt );
      if( uiParam < uiPCount )
         hb_conOutAlt( " ", 1 );
   }
}
console.c328
HB_FUNCQOUT(void)
HB_FUNC( QOUT )
{
   hb_conOutAlt( s_szCrLf, s_iCrLfLen );

   if( hb_setGetPrinter() && hb_setGetPrintHan() != FS_ERROR )
   {
      BYTE buf[ 256 ];
      PHB_PRNPOS pPrnPos = hb_prnPos();

      pPrnPos->row++;
      pPrnPos->col = ( USHORT ) hb_setGetMargin();

      if( pPrnPos->col )
      {
         if( pPrnPos->col > sizeof( buf ) )
         {
            BYTE * pBuf = ( BYTE * ) hb_xgrab( pPrnPos->col );
            memset( pBuf, ' ', pPrnPos->col );
            hb_fsWrite( hb_setGetPrintHan(), pBuf, pPrnPos->col );
            hb_xfree( pBuf );
         }
         else
         {
            memset( buf, ' ', pPrnPos->col );
            hb_fsWrite( hb_setGetPrintHan(), buf, pPrnPos->col );
         }
      }
   }

   HB_FUNC_EXEC( QQOUT );
}
console.c341
HB_FUNC__EJECT(void)
HB_FUNC( __EJECT ) /* Ejects the current page from the printer */
{
   PHB_PRNPOS pPrnPos;

   if( hb_setGetPrintHan() != FS_ERROR && hb_stricmp( hb_setGetDevice(), "PRINTER" ) == 0 )
   {
      static const BYTE byEop[ 4 ] = { 0x0C, 0x0D, 0x00, 0x00 }; /* Buffer is 4 bytes to make CodeGuard happy */
      hb_fsWrite( hb_setGetPrintHan(), byEop, 2 );
   }

   pPrnPos = hb_prnPos();
   pPrnPos->row = pPrnPos->col = 0;
}
console.c373
HB_FUNCPROW(void)
HB_FUNC( PROW ) /* Returns the current printer row position */
{
   hb_retni( ( int ) hb_prnPos()->row );
}
console.c387
HB_FUNCPCOL(void)
HB_FUNC( PCOL ) /* Returns the current printer row position */
{
   hb_retni( ( int ) hb_prnPos()->col );
}
console.c392
STATIC VOIDhb_conDevPos( SHORT iRow, SHORT iCol )
static void hb_conDevPos( SHORT iRow, SHORT iCol )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_conDevPos(%hd, %hd)", iRow, iCol));

   /* Position printer if SET DEVICE TO PRINTER and valid printer file
      otherwise position console */

   if( hb_setGetPrintHan() != FS_ERROR &&
       hb_stricmp( hb_setGetDevice(), "PRINTER" ) == 0 )
   {
      USHORT uiPRow = ( USHORT ) iRow;
      USHORT uiPCol = ( USHORT ) iCol + ( USHORT ) hb_setGetMargin();
      PHB_PRNPOS pPrnPos = hb_prnPos();

      if( pPrnPos->row != uiPRow || pPrnPos->col != uiPCol )
      {
         BYTE buf[ 256 ];
         int iPtr = 0;

         if( pPrnPos->row != uiPRow )
         {
            if( ++pPrnPos->row > uiPRow )
            {
               memcpy( &buf[ iPtr ], "\x0C\x0D\x00\x00", 2 );  /* Source buffer is 4 bytes to make CodeGuard happy */
               iPtr += 2;
               pPrnPos->row = 0;
            }
            else
            {
               memcpy( &buf[ iPtr ], s_szCrLf, s_iCrLfLen );
               iPtr += s_iCrLfLen;
            }

            while( pPrnPos->row < uiPRow )
            {
               if( iPtr + s_iCrLfLen > ( int ) sizeof( buf ) )
               {
                  hb_fsWrite( hb_setGetPrintHan(), buf, ( USHORT ) iPtr );
                  iPtr = 0;
               }
               memcpy( &buf[ iPtr ], s_szCrLf, s_iCrLfLen );
               iPtr += s_iCrLfLen;
               ++pPrnPos->row;
            }
            pPrnPos->col = 0;
         }
         else if( pPrnPos->col > uiPCol )
         {
            buf[ iPtr++ ] = '\x0D';
            pPrnPos->col = 0;
         }

         while( pPrnPos->col < uiPCol )
         {
            if( iPtr == ( int ) sizeof( buf ) )
            {
               hb_fsWrite( hb_setGetPrintHan(), buf, ( USHORT ) iPtr );
               iPtr = 0;
            }
            buf[ iPtr++ ] = ' ';
            ++pPrnPos->col;
         }

         if( iPtr )
            hb_fsWrite( hb_setGetPrintHan(), buf, ( SHORT ) iPtr );
      }
   }
   else
      hb_gtSetPos( iRow, iCol );
}
console.c397
HB_FUNCDEVPOS(void)
HB_FUNC( DEVPOS ) /* Sets the screen and/or printer position */
{
   if( ISNUM( 1 ) && ISNUM( 2 ) )
      hb_conDevPos( ( SHORT ) hb_parni( 1 ), ( SHORT ) hb_parni( 2 ) );
}
console.c470
HB_FUNCSETPRC(void)
HB_FUNC( SETPRC ) /* Sets the current printer row and column positions */
{
   if( hb_pcount() == 2 && ISNUM( 1 ) && ISNUM( 2 ) )
   {
      PHB_PRNPOS pPrnPos = hb_prnPos();
      pPrnPos->row = ( USHORT ) hb_parni( 1 );
      pPrnPos->col = ( USHORT ) hb_parni( 2 );
   }
}
console.c476
HB_FUNCDEVOUT(void)
HB_FUNC( DEVOUT ) /* writes a single value to the current device (screen or printer), but is not affected by SET ALTERNATE */
{
   if( ISCHAR( 2 ) )
   {
      char szOldColor[ HB_CLRSTR_LEN ];

      hb_gtGetColorStr( szOldColor );
      hb_gtSetColorStr( hb_parc( 2 ) );

      hb_conOut( 1, hb_conOutDev );

      hb_gtSetColorStr( szOldColor );
   }
   else if( hb_pcount() >= 1 )
      hb_conOut( 1, hb_conOutDev );
}
console.c486
HB_FUNCDISPOUT(void)
HB_FUNC( DISPOUT ) /* writes a single value to the screen, but is not affected by SET ALTERNATE */
{
   char * pszString;
   ULONG ulLen;
   BOOL bFreeReq;

   if( ISCHAR( 2 ) )
   {
      char szOldColor[ HB_CLRSTR_LEN ];

      hb_gtGetColorStr( szOldColor );
      hb_gtSetColorStr( hb_parc( 2 ) );

      pszString = hb_itemStringCon( hb_param( 1, HB_IT_ANY ), &ulLen, &bFreeReq );

      hb_gtWrite( ( BYTE * ) pszString, ulLen );

      if( bFreeReq )
         hb_xfree( pszString );

      hb_gtSetColorStr( szOldColor );
   }
   else if( hb_pcount() >= 1 )
   {
      pszString = hb_itemStringCon( hb_param( 1, HB_IT_ANY ), &ulLen, &bFreeReq );

      hb_gtWrite( ( BYTE * ) pszString, ulLen );

      if( bFreeReq )
         hb_xfree( pszString );
   }
}

console.c503
HB_FUNCDISPOUTAT(void)
HB_FUNC( DISPOUTAT ) /* writes a single value to the screen at speficic position, but is not affected by SET ALTERNATE */
{
   char * pszString;
   ULONG ulLen;
   BOOL bFreeReq;

   if( ISCHAR( 4 ) )
   {
      char szOldColor[ HB_CLRSTR_LEN ];

      hb_gtGetColorStr( szOldColor );
      hb_gtSetColorStr( hb_parc( 4 ) );

      pszString = hb_itemStringCon( hb_param( 3, HB_IT_ANY ), &ulLen, &bFreeReq );

      hb_gtWriteAt( ( USHORT ) hb_parni( 1 ), ( USHORT ) hb_parni( 2 ), ( BYTE * ) pszString, ulLen );

      if( bFreeReq )
         hb_xfree( pszString );

      hb_gtSetColorStr( szOldColor );
   }
   else if( hb_pcount() >= 3 )
   {
      pszString = hb_itemStringCon( hb_param( 3, HB_IT_ANY ), &ulLen, &bFreeReq );

      hb_gtWriteAt( ( USHORT ) hb_parni( 1 ), ( USHORT ) hb_parni( 2 ), ( BYTE * ) pszString, ulLen );

      if( bFreeReq )
         hb_xfree( pszString );
   }
}
console.c540
HB_FUNCHB_GETSTDIN(void)
HB_FUNC( HB_GETSTDIN ) /* Return Handel for STDIN */
{
   hb_retnint( ( HB_NHANDLE ) s_hFilenoStdin );
}
console.c574
HB_FUNCHB_GETSTDOUT(void)
HB_FUNC( HB_GETSTDOUT ) /* Return Handel for STDOUT */
{
   hb_retnint( ( HB_NHANDLE ) s_hFilenoStdout );
}
console.c579
HB_FUNCHB_GETSTDERR(void)
HB_FUNC( HB_GETSTDERR ) /* Return Handel for STDERR */
{
   hb_retnint( ( HB_NHANDLE ) s_hFilenoStderr );
}
console.c584
copyfile.c
TypeFunctionSourceLine
STATIC BOOLhb_fsCopy( char * szSource, char * szDest )
static BOOL hb_fsCopy( char * szSource, char * szDest )
{
   BOOL bRetVal = FALSE;
   HB_FHANDLE fhndSource;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsCopy(%s, %s)", szSource, szDest));

   while( ( fhndSource = hb_spOpen( ( BYTE * ) szSource, FO_READ | FO_SHARED | FO_PRIVATE ) ) == FS_ERROR )
   {
      USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 2012, NULL, szSource, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY, 0 );

      if( uiAction != E_RETRY )
         break;
   }

   if( fhndSource != FS_ERROR )
   {
      HB_FHANDLE fhndDest;

      while( ( fhndDest = hb_spCreate( ( BYTE * ) szDest, FC_NORMAL ) ) == FS_ERROR )
      {
         USHORT uiAction = hb_errRT_BASE_Ext1( EG_CREATE, 2012, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY, 0 );

         if( uiAction != E_RETRY )
            break;
      }

      if( fhndDest != FS_ERROR )
      {
#if defined(HB_OS_UNIX_COMPATIBLE)
         struct stat struFileInfo;
         int iSuccess = fstat( fhndSource, &struFileInfo );
#endif
         BYTE * buffer;
         USHORT usRead;

         buffer = ( BYTE * ) hb_xgrab( BUFFER_SIZE );

         bRetVal = TRUE;

         while( ( usRead = hb_fsRead( fhndSource, buffer, BUFFER_SIZE ) ) != 0 )
         {
            while( hb_fsWrite( fhndDest, buffer, usRead ) != usRead )
            {
               USHORT uiAction = hb_errRT_BASE_Ext1( EG_WRITE, 2016, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY, 0 );

               if( uiAction != E_RETRY )
               {
                  bRetVal = FALSE;
                  break;
               }
            }
         }

         hb_xfree( buffer );

#if defined(HB_OS_UNIX_COMPATIBLE)
         if( iSuccess == 0 )
            fchmod( fhndDest, struFileInfo.st_mode );
#endif

         hb_fsClose( fhndDest );
      }

      hb_fsClose( fhndSource );
   }

   return bRetVal;
}
copyfile.c64
HB_FUNC__COPYFILE(void)
HB_FUNC( __COPYFILE )
{
   if( ISCHAR( 1 ) && ISCHAR( 2 ) )
   {
      if( ! hb_fsCopy( hb_parc( 1 ), hb_parc( 2 ) ) )
         hb_retl( FALSE );
   }
   else
      hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); /* NOTE: Undocumented but existing Clipper Run-time error */
}
copyfile.c136
datec.c
TypeFunctionSourceLine
CHAR *hb_dateCMonth( int iMonth )
char * hb_dateCMonth( int iMonth )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dateCMonth(%d)", iMonth));

   return ( iMonth >= 1 && iMonth <= 12 ) ? ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_MONTH + iMonth - 1 ) : ( char * ) "";
}
datec.c59
CHAR *hb_dateCDOW( int iDay )
char * hb_dateCDOW( int iDay )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_dateCDOW(%d)", iDay));

   return ( iDay >= 1 && iDay <= 7 ) ? ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_DAY + iDay - 1 ) : ( char * ) "";
}
datec.c66
HB_FUNCCMONTH(void)
HB_FUNC( CMONTH )
{
   PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );

   if( pDate )
   {
      int iYear, iMonth, iDay;

      hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
      hb_retc( hb_dateCMonth( iMonth ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1116, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
datec.c73
HB_FUNCCDOW(void)
HB_FUNC( CDOW )
{
   PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );

   if( pDate )
   {
      long lDate = hb_itemGetDL( pDate );

      if( lDate )
      {
         int iYear, iMonth, iDay;

         hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
         hb_retc( hb_dateCDOW( hb_dateDOW( iYear, iMonth, iDay ) ) );
      }
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1117, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
datec.c88
dates.c
TypeFunctionSourceLine
HB_EXPORT CHAR *hb_dateFormat( const char * szDate, char * szFormattedDate, const char * szDateFormat )
HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, const char * szDateFormat )
{
   /*
    * NOTE: szFormattedDate must point to a buffer of at least 11 bytes.
    *       szDateFormat must point to a buffer holding the date format to use.
    */
   int format_count, digit_count, size;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateFormat(%s, %p, %s)", szDate, szFormattedDate, szDateFormat));

   /*
    * Determine the maximum size of the formatted date string
    */
   size = strlen( szDateFormat );
   if( size > 10 )
      size = 10;

   if( szDate && szFormattedDate && strlen( szDate ) == 8 ) /* A valid date is always 8 characters */
   {
      const char * szPtr;
      int digit;
      BOOL used_d, used_m, used_y;

      format_count = 0;
      used_d = used_m = used_y = FALSE;
      szPtr = szDateFormat;

      while( format_count < size )
      {
         digit = toupper( ( UCHAR ) *szPtr );
         szPtr++;
         digit_count = 1;
         while( toupper( ( UCHAR ) *szPtr ) == digit && format_count < size )
         {
            szPtr++;
            if( format_count + digit_count < size )
               digit_count++;
         }
         switch( digit )
         {
            case 'D':
               switch( digit_count )
               {
                  case 4:
                     if( ! used_d && format_count < size )
                     {
                        /* szFormattedDate[ format_count++ ] = '0'; */
                        szFormattedDate[ format_count++ ] = szDate[ 6 ];
                        digit_count--;
                     }
                  case 3:
                     if( ! used_d && format_count < size )
                     {
                        /* szFormattedDate[ format_count++ ] = '0'; */
                        szFormattedDate[ format_count++ ] = szDate[ 6 ];
                        digit_count--;
                     }
                  case 2:
                     if( ! used_d && format_count < size )
                     {
                        szFormattedDate[ format_count++ ] = szDate[ 6 ];
                        digit_count--;
                     }
                  default:
                     if( ! used_d && format_count < size )
                     {
                        szFormattedDate[ format_count++ ] = szDate[ 7 ];
                        digit_count--;
                     }
                     while( digit_count-- > 0 && format_count < size )
                        szFormattedDate[ format_count++ ] = ( char ) digit;
               }
               used_d = TRUE;
               break;

            case 'M':
               switch( digit_count )
               {
                  case 4:
                     if( ! used_m && format_count < size )
                     {
                        /* szFormattedDate[ format_count++ ] = '0'; */
                        szFormattedDate[ format_count++ ] = szDate[ 4 ];
                        digit_count--;
                     }
                  case 3:
                     if( ! used_m && format_count < size )
                     {
                        /* szFormattedDate[ format_count++ ] = '0'; */
                        szFormattedDate[ format_count++ ] = szDate[ 4 ];
                        digit_count--;
                     }
                  case 2:
                     if( ! used_m && format_count < size )
                     {
                        szFormattedDate[ format_count++ ] = szDate[ 4 ];
                        digit_count--;
                     }
                  default:
                     if( ! used_m && format_count < size )
                     {
                        szFormattedDate[ format_count++ ] = szDate[ 5 ];
                        digit_count--;
                     }
                     while( digit_count-- > 0 && format_count < size )
                        szFormattedDate[ format_count++ ] = ( char ) digit;
               }
               used_m = TRUE;
               break;

            case 'Y':
               switch( digit_count )
               {
                  case 4:
                     if( ! used_y && format_count < size )
                     {
                        szFormattedDate[ format_count++ ] = szDate[ 0 ];
                        digit_count--;
                     }

                  case 3:
                     if( ! used_y && format_count < size )
                     {
                        szFormattedDate[ format_count++ ] = szDate[ 1 ];
                        digit_count--;
                     }

                  case 2:
                     if( ! used_y && format_count < size )
                     {
                        szFormattedDate[ format_count++ ] = szDate[ 2 ];
                        digit_count--;
                     }

                  default:
                     if( ! used_y && format_count < size )
                     {
                        szFormattedDate[ format_count++ ] = szDate[ 3 ];
                        digit_count--;
                     }
                     while( digit_count-- > 0 && format_count < size )
                        szFormattedDate[ format_count++ ] = ( char ) digit;
               }
               used_y = TRUE;
               break;

            default:
               while( digit_count-- > 0 && format_count < size )
                  szFormattedDate[ format_count++ ] = ( char ) digit;
         }
      }
   }
   else
   {
      /* Not a valid date string, so return a blank date with separators */
      format_count = size; /* size is either 8 or 10 */
      hb_strncpy( szFormattedDate, szDateFormat, size );

      for( digit_count = 0; digit_count < size; digit_count++ )
      {
         switch( szFormattedDate[ digit_count ] )
         {
            case 'D':
            case 'd':
            case 'M':
            case 'm':
            case 'Y':
            case 'y':
               szFormattedDate[ digit_count ] = ' ';
         }
      }
   }

   szFormattedDate[ format_count ] = '\0';

   return szFormattedDate;
}
dates.c59
HB_EXPORT LONGhb_dateUnformat( const char * szDate, const char * szDateFormat )
HB_EXPORT long hb_dateUnformat( const char * szDate, const char * szDateFormat )
{
   int d_value = 0, m_value = 0, y_value = 0;

   if( szDate )
   {
      int d_pos = 0, m_pos = 0, y_pos = 0;
      int count, digit, non_digit, size;

      if( ! szDateFormat )
         szDateFormat = hb_setGetDateFormat();
      size = strlen( szDateFormat );

      for( count = 0; count < size; count++ )
      {
         switch( szDateFormat[ count ] )
         {
            case 'D':
            case 'd':
               if( d_pos == 0 )
               {
                  if( m_pos == 0 && y_pos == 0 )
                     d_pos = 1;
                  else if( m_pos == 0 || y_pos == 0 )
                     d_pos = 2;
                  else
                     d_pos = 3;
               }
               break;
            case 'M':
            case 'm':
               if( m_pos == 0 )
               {
                  if( d_pos == 0 && y_pos == 0 )
                     m_pos = 1;
                  else if( d_pos == 0 || y_pos == 0 )
                     m_pos = 2;
                  else
                     m_pos = 3;
               }
               break;
            case 'Y':
            case 'y':
               if( y_pos == 0 )
               {
                  if( m_pos == 0 && d_pos == 0 )
                     y_pos = 1;
                  else if( m_pos == 0 || d_pos == 0 )
                     y_pos = 2;
                  else
                     y_pos = 3;
               }
         }
      }

      /* If there are non-digits at the start of the date field,
         they are not to be treated as date field separators */
      non_digit = 1;
      size = strlen( szDate );
      for( count = 0; count < size; count++ )
      {
         digit = szDate[ count ];
         if( isdigit( digit ) )
         {
            /* Process the digit for the current date field */
            if( d_pos == 1 )
               d_value = ( d_value * 10 ) + digit - '0';
            else if( m_pos == 1 )
               m_value = ( m_value * 10 ) + digit - '0';
            else if( y_pos == 1 )
               y_value = ( y_value * 10 ) + digit - '0';
            /* Treat the next non-digit as a date field separator */
            non_digit = 0;
         }
         else if( digit != ' ' )
         {
            /* Process the non-digit */
            if( non_digit++ == 0 )
            {
               /* Only move to the next date field on the first
                  consecutive non-digit that is encountered */
               d_pos--;
               m_pos--;
               y_pos--;
            }
         }
      }

      if( y_value >= 0 && y_value < 100 )
      {
         count = hb_setGetEpoch();
         digit = count / 100;
         count %= 100;

         if( y_value >= count )
            y_value += ( digit * 100 );
         else
            y_value += ( ( digit * 100 ) + 100 );
      }
   }

   return hb_dateEncode( y_value, m_value, d_value );
}
dates.c237
dateshb.c
TypeFunctionSourceLine
HB_FUNCCTOD(void)
HB_FUNC( CTOD )
{
   if( ISCHAR( 1 ) )
      hb_retdl( hb_dateUnformat( hb_parc( 1 ), hb_setGetDateFormat() ) );
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1119, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
dateshb.c82
HB_FUNCDTOC(void)
HB_FUNC( DTOC )
{
   if( ISDATE( 1 ) )
   {
      char szDate[ 9 ];
      char szFormatted[ 11 ];

      hb_retc( hb_dateFormat( hb_pardsbuff( szDate, 1 ), szFormatted, hb_setGetDateFormat() ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1118, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
dateshb.c90
HB_FUNCDTOS(void)
HB_FUNC( DTOS )
{
   if( ISDATE( 1 ) )
   {
      char szDate[ 9 ];

      hb_retc( hb_pardsbuff( szDate, 1 ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1120, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
dateshb.c103
HB_FUNCHB_STOD(void)
HB_FUNC( HB_STOD )
{
   PHB_ITEM pDateString = hb_param( 1, HB_IT_STRING );

   hb_retds( hb_itemGetCLen( pDateString ) >= 7 ? hb_itemGetCPtr( pDateString ) : NULL );
}
dateshb.c117
HB_FUNCYEAR(void)
HB_FUNC( YEAR )
{
   PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );

   if( pDate )
   {
      int iYear, iMonth, iDay;

      hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );

      hb_retnilen( iYear, 5 );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1112, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
dateshb.c124
HB_FUNCMONTH(void)
HB_FUNC( MONTH )
{
   PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );

   if( pDate )
   {
      int iYear, iMonth, iDay;

      hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );

      hb_retnilen( iMonth, 3 );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1113, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
dateshb.c140
HB_FUNCDAY(void)
HB_FUNC( DAY )
{
   PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );

   if( pDate )
   {
      int iYear, iMonth, iDay;

      hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );

      hb_retnilen( iDay, 3 );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1114, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
dateshb.c156
HB_FUNCTIME(void)
HB_FUNC( TIME )
{
   char szResult[ 9 ];
   hb_dateTimeStr( szResult );
   hb_retclen( szResult, 8 );
}
dateshb.c172
HB_FUNCDATE(void)
HB_FUNC( DATE )
{
   int iYear, iMonth, iDay;
   hb_dateToday( &iYear, &iMonth, &iDay );
   hb_retd( iYear, iMonth, iDay );
}
dateshb.c179
HB_FUNCDOW(void)
HB_FUNC( DOW )
{
   PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );

   if( pDate )
   {
      hb_retnilen( hb_dateJulianDOW( hb_itemGetDL( pDate ) ), 3 );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1115, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
dateshb.c186
datesx.c
TypeFunctionSourceLine
HB_FUNCSTOD(void)
HB_FUNC( STOD )
{
   PHB_ITEM pDateString = hb_param( 1, HB_IT_STRING );

   hb_retds( hb_itemGetCLen( pDateString ) >= 7 ? hb_itemGetCPtr( pDateString ) : NULL );
}
datesx.c61
defpath.c
TypeFunctionSourceLine
HB_FUNC__DEFPATH(void)
HB_FUNC( __DEFPATH )
{
   char buffer[ _POSIX_PATH_MAX + 2 ];
   char * szDefault;
   int size = 0;

   szDefault = hb_setGetDefault();
   if( szDefault )
   {
      /* Leave enough space to append a path delimiter */
      hb_strncpy( buffer, szDefault, sizeof( buffer ) - 1 );
      size = strlen( buffer );
   }

   HB_TRACE(HB_TR_INFO, ("HB_DEFPATH: buffer is |%s|, size is %d, last char is |%c|", buffer, size, buffer[ size - 1]));
   HB_TRACE(HB_TR_INFO, ("HB_DEFPATH: HB_OS_PATH_DELIM_CHR is |%c| and HB_OS_PATH_LIST_SEP_CHR is |%c|", HB_OS_PATH_DELIM_CHR, HB_OS_PATH_LIST_SEP_CHR));

   /* If the path is not empty and it doesn't end with a drive or path
      delimiter, then add the appropriate separator. Use ':' if the size
      of the path is 1 and the list separator is not ':', otherwise use
      the path delimiter. This allows the use of a drive letter delimiter
      for DOS compatible operating systems while preventing it from being
      with a Unix compatible OS. */
#ifdef HB_OS_HAS_DRIVE_LETTER
   if( size && buffer[ size - 1 ] != HB_OS_PATH_DELIM_CHR &&
               buffer[ size - 1 ] != HB_OS_DRIVE_DELIM_CHR )
   {
      if( size == 1 )
         buffer[ size++ ] = HB_OS_DRIVE_DELIM_CHR;
      else
         buffer[ size++ ] = HB_OS_PATH_DELIM_CHR;
   }
#else
   if( size && buffer[ size - 1 ] != HB_OS_PATH_DELIM_CHR )
      buffer[ size++ ] = HB_OS_PATH_DELIM_CHR;
#endif

   hb_retclen( buffer, size );
}
defpath.c56
defpathu.c
TypeFunctionSourceLine
HB_FUNCDEFPATH(void)
HB_FUNC( DEFPATH )
{
   HB_FUNC_EXEC( __DEFPATH );
}
defpathu.c59
descend.c
TypeFunctionSourceLine
VOIDhb_strDescend( char * szStringTo, const char * szStringFrom, ULONG ulLen )
void hb_strDescend( char * szStringTo, const char * szStringFrom, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_strDescend(%s, %s, %lu)", szStringTo, szStringFrom, ulLen));

   if( ulLen == 1 && szStringFrom[ 0 ] == '\0' )
      szStringTo[ 0 ] = '\0';
   else
   {
      for(; ulLen--; szStringTo++, szStringFrom++ )
         *szStringTo = ( char ) ( 256 - *szStringFrom );
   }
}
descend.c56
HB_FUNCDESCEND(void)
HB_FUNC( DESCEND )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

   if( pItem )
   {
      if( HB_IS_STRING( pItem ) )
      {
         ULONG ulLen = hb_itemGetCLen( pItem );

         if( ulLen > 0 )
         {
            char * szBuffer = ( char * ) hb_xgrab( ulLen + 1 );
            hb_strDescend( szBuffer, hb_itemGetCPtr( pItem ), ulLen );
            hb_retclen_buffer( szBuffer, ulLen  );
         }
         else
            hb_retc( NULL );
      }
      else if( HB_IS_DATE( pItem ) )
         hb_retnl( 5231808 - hb_itemGetDL( pItem ) );
      else if( HB_IS_NUMERIC( pItem ) )
         hb_retnd( -1 * hb_itemGetND( pItem ) );
      else if( HB_IS_LOGICAL( pItem ) )
         hb_retl( ! hb_itemGetL( pItem ) );
   }
}
descend.c69
dirdrive.c
TypeFunctionSourceLine
HB_FUNCDIRCHANGE(void)
HB_FUNC( DIRCHANGE )
{
   if( ISCHAR( 1 ) )
      hb_retni( hb_fsChDir( ( BYTE * ) hb_parc( 1 ) ) ? 0 : hb_fsError() );
   else
      hb_retni( -1 );
}
dirdrive.c62
HB_FUNCMAKEDIR(void)
HB_FUNC( MAKEDIR )
{
   if( ISCHAR( 1 ) )
      hb_retni( hb_fsMkDir( ( BYTE * ) hb_parc( 1 ) ) ? 0 : hb_fsError() );
   else
      hb_retni( -1 );
}
dirdrive.c73
HB_FUNCDIRREMOVE(void)
HB_FUNC( DIRREMOVE )
{
   if( ISCHAR( 1 ) )
      hb_retni( hb_fsRmDir( ( BYTE * ) hb_parc( 1 ) ) ? 0 : hb_fsError() );
   else
      hb_retni( -1 );
}
dirdrive.c81
HB_FUNCISDISK(void)
HB_FUNC( ISDISK )
{
   hb_retl( ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
            hb_fsIsDrv( ( BYTE )( toupper( *hb_parc( 1 ) ) - 'A' ) ) == 0 :
            FALSE );
}
dirdrive.c93
HB_FUNCDISKCHANGE(void)
HB_FUNC( DISKCHANGE )
{
   hb_retl( ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
            hb_fsChDrv( ( BYTE )( toupper( *hb_parc( 1 ) ) - 'A' ) ) == 0 :
            FALSE );
}
dirdrive.c100
HB_FUNCDISKNAME(void)
HB_FUNC( DISKNAME )
{
   char szDrive[ 1 ];

   szDrive[ 0 ] = ( ( char ) hb_fsCurDrv() ) + 'A';
   hb_retclen( szDrive, 1 );
}
dirdrive.c107
direct.c
TypeFunctionSourceLine
HB_FUNCDIRECTORY(void)
HB_FUNC( DIRECTORY )
{
   char *    szDirSpec = hb_parc( 1 );
   char *    szAttributes = hb_parc( 2 );
   BOOL      fFree = FALSE;
   ULONG     ulMask;

   PHB_ITEM  pDir = hb_itemArrayNew( 0 );
   PHB_FFIND ffind;

   /* Get the passed attributes and convert them to Harbour Flags */

   ulMask = HB_FA_ARCHIVE
          | HB_FA_READONLY
          | HB_FA_DEVICE
          | HB_FA_TEMPORARY
          | HB_FA_SPARSE
          | HB_FA_REPARSE
          | HB_FA_COMPRESSED
          | HB_FA_OFFLINE
          | HB_FA_NOTINDEXED
          | HB_FA_ENCRYPTED
          | HB_FA_VOLCOMP;

   if( szAttributes && *szAttributes )
   {
      if( ( ulMask |= hb_fsAttrEncode( szAttributes ) ) & HB_FA_LABEL )
      {
         /* NOTE: This is Clipper Doc compatible. (not operationally) */
         ulMask = HB_FA_LABEL;
      }
   }

   if( szDirSpec && *szDirSpec )
   {
      szDirSpec = ( char * ) hb_fsNameConv( ( BYTE * ) szDirSpec, &fFree );
      if( *szDirSpec )
      {
         /* CA-Cl*pper compatible behavior - add all file mask when
          * last character is directory or drive separator
          */
         int iLen = strlen( szDirSpec ) - 1;
#ifdef HB_OS_HAS_DRIVE_LETTER
         if( szDirSpec[ iLen ] == HB_OS_PATH_DELIM_CHR ||
             szDirSpec[ iLen ] == HB_OS_DRIVE_DELIM_CHR )
#else
         if( szDirSpec[ iLen ] == HB_OS_PATH_DELIM_CHR )
#endif
         {
            if( fFree )
            {
               char * szTemp = hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL );
               hb_xfree( szDirSpec );
               szDirSpec = szTemp;
            }
            else
            {
               szDirSpec = hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL );
               fFree = TRUE;
            }
         }
      }
      else
      {
         if( fFree )
         {
            hb_xfree( szDirSpec );
            fFree = FALSE;
         }
         szDirSpec = ( char * ) HB_OS_ALLFILE_MASK;
      }
   }
   else
      szDirSpec = ( char * ) HB_OS_ALLFILE_MASK;

   /* Get the file list */

   if( ( ffind = hb_fsFindFirst( szDirSpec, ulMask ) ) != NULL )
   {
      PHB_ITEM pSubarray = hb_itemNew( NULL );

      do
      {
         char buffer[ 32 ];

         hb_arrayNew( pSubarray, F_LEN );
         hb_arraySetC   ( pSubarray, F_NAME, ffind->szName );
         hb_arraySetNInt( pSubarray, F_SIZE, ffind->size );
         hb_arraySetDL  ( pSubarray, F_DATE, ffind->lDate );
         hb_arraySetC   ( pSubarray, F_TIME, ffind->szTime );
         hb_arraySetC   ( pSubarray, F_ATTR, hb_fsAttrDecode( ffind->attr, buffer ) );

         /* Don't exit when array limit is reached */
         hb_arrayAddForward( pDir, pSubarray );
      }
      while( hb_fsFindNext( ffind ) );

      hb_itemRelease( pSubarray );

      hb_fsFindClose( ffind );
   }

   if( fFree )
      hb_xfree( szDirSpec );

   hb_itemReturnRelease( pDir );
}
direct.c106
diskspac.c
TypeFunctionSourceLine
HB_FUNCDISKSPACE(void)
HB_FUNC( DISKSPACE )
{
   double dSpace = 0.0;
   BOOL bError;

#if defined(HB_OS_DOS)
   {
      USHORT uiDrive = ISNUM( 1 ) ? hb_parni( 1 ) : 0;
      union REGS regs;

      regs.HB_XREGS.dx = uiDrive;
      regs.h.ah = 0x36;
      HB_DOS_INT86( 0x21, ®s, ®s );

      bError = regs.HB_XREGS.ax == 0xFFFF;
      if( !bError )
         dSpace = ( double ) regs.HB_XREGS.bx *
                  ( double ) regs.HB_XREGS.ax *
                  ( double ) regs.HB_XREGS.cx;
   }
#elif defined(HB_OS_WIN_32)
   {
#if defined(_MSC_VER) || defined(__LCC__) || \
    ( defined(__GNUC__) && !defined(__RSXNT__) )

#  define HB_GET_LARGE_UINT( v )  ( ( double ) (v).LowPart + \
                                    ( double ) (v).HighPart * \
                                    ( ( ( double ) 0xFFFFFFFF ) + 1 ) )

#else
   /* NOTE: Borland doesn't seem to deal with the un-named
            struct that is part of ULARGE_INTEGER
            [pt] */
#  define HB_GET_LARGE_UINT( v )  ( ( double ) (v).u.LowPart + \
                                    ( double ) (v).u.HighPart * \
                                    ( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#endif

      typedef BOOL ( WINAPI * P_GDFSE )( LPCSTR, PULARGE_INTEGER,
                                         PULARGE_INTEGER, PULARGE_INTEGER );
      ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
      USHORT uiParam = ( USHORT ) hb_parni( 1 );
      USHORT uiDrive = uiParam == 0 ? hb_fsCurDrv() + 1 : uiParam;
      UINT uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS );

#if defined(HB_WINCE)
      TCHAR lpPath[ 4 ];

      lpPath[ 0 ] = ( TCHAR ) uiDrive + 'A' - 1;
      lpPath[ 1 ] = ':';
      lpPath[ 2 ] = '\\';
      lpPath[ 3 ] = '\0';

      bError = !GetDiskFreeSpaceEx( lpPath,
                                    ( PULARGE_INTEGER ) &i64FreeBytesToCaller,
                                    ( PULARGE_INTEGER ) &i64TotalBytes,
                                    ( PULARGE_INTEGER ) &i64FreeBytes );
      if( !bError )
         dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
#else
      char szPath[ 4 ];
      P_GDFSE pGetDiskFreeSpaceEx = ( P_GDFSE )
                           GetProcAddress( GetModuleHandleA( "kernel32.dll" ),
                                           "GetDiskFreeSpaceExA" );
      szPath[ 0 ] = ( char ) uiDrive + 'A' - 1;
      szPath[ 1 ] = ':';
      szPath[ 2 ] = '\\';
      szPath[ 3 ] = '\0';

      if( pGetDiskFreeSpaceEx )
      {
         bError = !pGetDiskFreeSpaceEx( szPath,
                                        ( PULARGE_INTEGER ) &i64FreeBytesToCaller,
                                        ( PULARGE_INTEGER ) &i64TotalBytes,
                                        ( PULARGE_INTEGER ) &i64FreeBytes );
         if( !bError )
            dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
      }
      else
      {
         DWORD dwSectorsPerCluster;
         DWORD dwBytesPerSector;
         DWORD dwNumberOfFreeClusters;
         DWORD dwTotalNumberOfClusters;

         bError = !GetDiskFreeSpaceA( szPath,
                                      &dwSectorsPerCluster,
                                      &dwBytesPerSector,
                                      &dwNumberOfFreeClusters,
                                      &dwTotalNumberOfClusters );
         if( !bError )
            dSpace = ( double ) dwNumberOfFreeClusters *
                     ( double ) dwSectorsPerCluster *
                     ( double ) dwBytesPerSector;
      }
#endif
      SetErrorMode( uiErrMode );
   }
#elif defined(HB_OS_OS2)
   {
      USHORT uiDrive = ISNUM( 1 ) ? hb_parni( 1 ) : 0;
      struct _FSALLOCATE fsa;

      /* Query level 1 info from filesystem */
      bError = DosQueryFSInfo( uiDrive, 1, &fsa, sizeof( fsa ) ) != 0;
      if( !bError )
         dSpace = ( double ) fsa.cUnitAvail *
                  ( double ) fsa.cSectorUnit *
                  ( double ) fsa.cbSector;
   }
#elif defined(HB_OS_UNIX)
   {
      char * szName = hb_parc( 1 );
      BOOL fFree = FALSE;

      if( !szName )
         szName = ( char * ) "/";
      else
         szName = ( char * ) hb_fsNameConv( ( BYTE * ) szName, &fFree );

      {
#if defined(__WATCOMC__) || defined(__CEGCC__)
         struct stat st;
         bError = stat( szName, &st) != 0;
         if( !bError )
            dSpace = ( double ) st.st_blocks * ( double ) st.st_blksize;
#else
         struct statvfs st;
         bError = statvfs( szName, &st ) != 0;
         if( !bError )
         {
            if( getuid() == 0 )
               dSpace = ( double ) st.f_bfree * ( double ) st.f_bsize;
            else
               dSpace = ( double ) st.f_bavail * ( double ) st.f_bsize;
         }
#endif
      }

      if( fFree )
         hb_xfree( szName );
   }
#else
   bError = FALSE;
#endif

   if( bError )
      hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );

   hb_retnlen( dSpace, -1, 0 );
}
diskspac.c77
disksphb.c
TypeFunctionSourceLine
HB_FUNCHB_DISKSPACE(void)
HB_FUNC( HB_DISKSPACE )
{
   char szPathBuf[ 4 ];
   char * szPath = hb_parc( 1 );
   USHORT uiType = ISNUM( 2 ) ? ( USHORT ) hb_parni( 2 ) : HB_DISK_AVAIL;
   double dSpace = 0.0;

   if( uiType > HB_DISK_TOTAL )
      uiType = HB_DISK_AVAIL;

   if( !szPath )
   {
#ifdef HB_OS_HAS_DRIVE_LETTER
      if( ISNUM( 1 ) )
      {
         szPathBuf[ 0 ] = ( char ) hb_parni( 1 ) + 'A' - 1;
         szPathBuf[ 1 ] = HB_OS_DRIVE_DELIM_CHR;
         szPathBuf[ 2 ] = HB_OS_PATH_DELIM_CHR;
         szPathBuf[ 3 ] = '\0';
      }
      else
#endif
      {
         szPathBuf[ 0 ] = HB_OS_PATH_DELIM_CHR;
         szPathBuf[ 1 ] = '\0';
      }
      szPath = szPathBuf;
   }

#if defined(HB_OS_DOS)
   {
      USHORT uiDrive = szPath[ 1 ] != HB_OS_DRIVE_DELIM_CHR ? 0 :
                       ( szPath[ 0 ] >= 'A' && szPath[ 0 ] <= 'Z' ?
                         szPath[ 0 ] - 'A' + 1 :
                       ( szPath[ 0 ] >= 'a' && szPath[ 0 ] <= 'z' ?
                         szPath[ 0 ] - 'a' + 1 : 0 ) );
      for( ;; )
      {
         union REGS regs;

         regs.HB_XREGS.dx = uiDrive;
         regs.h.ah = 0x36;
         HB_DOS_INT86( 0x21, ®s, ®s );

         if( regs.HB_XREGS.ax != 0xFFFF )
         {
            USHORT uiClusterTotal  = regs.HB_XREGS.dx;
            USHORT uiClusterFree   = regs.HB_XREGS.bx;
            USHORT uiSecPerCluster = regs.HB_XREGS.ax;
            USHORT uiSectorSize    = regs.HB_XREGS.cx;

            switch( uiType )
            {
               case HB_DISK_AVAIL:
               case HB_DISK_FREE:
                  dSpace = ( double ) uiClusterFree *
                           ( double ) uiSecPerCluster *
                           ( double ) uiSectorSize;
                  break;

               case HB_DISK_USED:
               case HB_DISK_TOTAL:
                  dSpace = ( double ) uiClusterTotal *
                           ( double ) uiSecPerCluster *
                           ( double ) uiSectorSize;

                  if( uiType == HB_DISK_USED )
                     dSpace -= ( double ) uiClusterFree *
                               ( double ) uiSecPerCluster *
                               ( double ) uiSectorSize;
                  break;
            }
         }
         else
         {
            if( hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, ( EF_CANDEFAULT | EF_CANRETRY ), HB_ERR_ARGS_BASEPARAMS ) == E_RETRY )
               continue;
         }
         break;
      }
   }
#elif defined(HB_OS_WIN_32)
   {
#if defined(_MSC_VER) || defined(__LCC__) || \
    ( defined(__GNUC__) && !defined(__RSXNT__) )

#  define HB_GET_LARGE_UINT( v )  ( ( double ) (v).LowPart + \
                                    ( double ) (v).HighPart * \
                                    ( ( ( double ) 0xFFFFFFFF ) + 1 ) )

#else
   /* NOTE: Borland doesn't seem to deal with the un-named
            struct that is part of ULARGE_INTEGER
            [pt] */
#  define HB_GET_LARGE_UINT( v )  ( ( double ) (v).u.LowPart + \
                                    ( double ) (v).u.HighPart * \
                                    ( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#endif

      typedef BOOL ( WINAPI * P_GDFSE )( LPCSTR, PULARGE_INTEGER,
                                         PULARGE_INTEGER, PULARGE_INTEGER );

      for( ;; )
      {
         ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
         UINT uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS );
         BOOL fResult;

#if defined(HB_WINCE)
         LPTSTR lpPath = HB_TCHAR_CONVTO( szPath );

         fResult = GetDiskFreeSpaceEx( lpPath,
                                       ( PULARGE_INTEGER ) &i64FreeBytesToCaller,
                                       ( PULARGE_INTEGER ) &i64TotalBytes,
                                       ( PULARGE_INTEGER ) &i64FreeBytes );
         hb_fsSetIOError( fResult, 0 );
         HB_TCHAR_FREE( lpPath );
         if( fResult )
         {
            switch( uiType )
            {
               case HB_DISK_AVAIL:
                  dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
                  break;

               case HB_DISK_FREE:
                  dSpace = HB_GET_LARGE_UINT( i64FreeBytes );
                  break;

               case HB_DISK_TOTAL:
                  dSpace = HB_GET_LARGE_UINT( i64TotalBytes );
                  break;

               case HB_DISK_USED:
                  dSpace = HB_GET_LARGE_UINT( i64TotalBytes ) -
                           HB_GET_LARGE_UINT( i64FreeBytes );
                  break;
            }
         }
#else
         P_GDFSE pGetDiskFreeSpaceEx = ( P_GDFSE )
                           GetProcAddress( GetModuleHandleA( "kernel32.dll" ),
                                           "GetDiskFreeSpaceExA" );
         if( pGetDiskFreeSpaceEx )
         {
            fResult = pGetDiskFreeSpaceEx( szPath,
                                           ( PULARGE_INTEGER ) &i64FreeBytesToCaller,
                                           ( PULARGE_INTEGER ) &i64TotalBytes,
                                           ( PULARGE_INTEGER ) &i64FreeBytes );
            hb_fsSetIOError( fResult, 0 );
            if( fResult )
            {
               switch( uiType )
               {
                  case HB_DISK_AVAIL:
                     dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
                     break;

                  case HB_DISK_FREE:
                     dSpace = HB_GET_LARGE_UINT( i64FreeBytes );
                     break;

                  case HB_DISK_TOTAL:
                     dSpace = HB_GET_LARGE_UINT( i64TotalBytes );
                     break;

                  case HB_DISK_USED:
                     dSpace = HB_GET_LARGE_UINT( i64TotalBytes ) -
                              HB_GET_LARGE_UINT( i64FreeBytes );
                     break;
               }
            }
         }
         else
         {
            DWORD dwSectorsPerCluster;
            DWORD dwBytesPerSector;
            DWORD dwNumberOfFreeClusters;
            DWORD dwTotalNumberOfClusters;

            fResult = GetDiskFreeSpaceA( szPath,
                                         &dwSectorsPerCluster,
                                         &dwBytesPerSector,
                                         &dwNumberOfFreeClusters,
                                         &dwTotalNumberOfClusters );
            hb_fsSetIOError( fResult, 0 );
            if( fResult )
            {
               switch( uiType )
               {
                  case HB_DISK_AVAIL:
                  case HB_DISK_FREE:
                     dSpace = ( double ) dwNumberOfFreeClusters *
                              ( double ) dwSectorsPerCluster *
                              ( double ) dwBytesPerSector;
                     break;

                  case HB_DISK_USED:
                  case HB_DISK_TOTAL:
                     dSpace  = ( double ) dwTotalNumberOfClusters *
                               ( double ) dwSectorsPerCluster *
                               ( double ) dwBytesPerSector;

                     if( uiType == HB_DISK_USED )
                        dSpace -= ( double ) dwNumberOfFreeClusters *
                                  ( double ) dwSectorsPerCluster *
                                  ( double ) dwBytesPerSector;
                     break;
               }
            }
         }
#endif
         SetErrorMode( uiErrMode );
         break;
      }
   }
#elif defined(HB_OS_OS2)
   {
      struct _FSALLOCATE fsa;
      USHORT rc;
      USHORT uiDrive = szPath[ 1 ] != HB_OS_DRIVE_DELIM_CHR ? 0 :
                       ( szPath[ 0 ] >= 'A' && szPath[ 0 ] <= 'Z' ?
                         szPath[ 0 ] - 'A' + 1 :
                       ( szPath[ 0 ] >= 'a' && szPath[ 0 ] <= 'z' ?
                         szPath[ 0 ] - 'a' + 1 : 0 ) );

      /* Query level 1 info from filesystem */
      while( ( rc = DosQueryFSInfo( uiDrive, 1, &fsa, sizeof( fsa ) ) ) != 0 )
      {
         if( hb_errRT_BASE_Ext1( EG_OPEN, 2018, NULL, NULL, 0, (EF_CANDEFAULT | EF_CANRETRY), HB_ERR_ARGS_BASEPARAMS ) != E_RETRY )
            break;
      }

      if( rc == 0 )
      {
         switch( uiType )
         {
            case HB_DISK_AVAIL:
            case HB_DISK_FREE:
               dSpace = ( double ) fsa.cUnitAvail *
                        ( double ) fsa.cSectorUnit *
                        ( double ) fsa.cbSector;
               break;

            case HB_DISK_USED:
            case HB_DISK_TOTAL:
               dSpace = ( double ) fsa.cUnit *
                        ( double ) fsa.cSectorUnit *
                        ( double ) fsa.cbSector;

               if( uiType == HB_DISK_USED )
                  dSpace -= ( double ) fsa.cUnitAvail *
                            ( double ) fsa.cSectorUnit *
                            ( double ) fsa.cbSector;
               break;
         }
         hb_fsSetIOError( TRUE, 0 );
      }
      else
         hb_fsSetIOError( FALSE, 0 );
   }
#elif defined(HB_OS_UNIX) && !( defined(__WATCOMC__) || defined(__CEGCC__) )
   {
      struct statvfs sf;
      BOOL fFree = FALSE;

      szPath = ( char * ) hb_fsNameConv( ( BYTE * ) szPath, &fFree );

      if( statvfs( szPath, &sf ) == 0 )
      {
         switch( uiType )
         {
            case HB_DISK_AVAIL:
               dSpace = ( double ) sf.f_bavail * ( double ) sf.f_bsize;
               break;

            case HB_DISK_FREE:
               dSpace = ( double ) sf.f_bfree * ( double ) sf.f_bsize;
               break;

            case HB_DISK_USED:
                dSpace = ( double ) ( sf.f_blocks - sf.f_bfree ) *
                         ( double ) sf.f_bsize;
                break;

            case HB_DISK_TOTAL:
               dSpace = ( double ) sf.f_blocks * ( double ) sf.f_bsize;
               break;
         }
         hb_fsSetIOError( TRUE, 0 );
      }
      else
         hb_fsSetIOError( FALSE, 0 );

      if( fFree )
         hb_xfree( szPath );
   }
#else
   {
      HB_SYMBOL_UNUSED( szPath );
      HB_SYMBOL_UNUSED( uiType );
   }
#endif

   hb_retnlen( dSpace, -1, 0 );
}
disksphb.c69
do.c
TypeFunctionSourceLine
HB_FUNCDO(void)
HB_FUNC( DO )
{
   USHORT uiPCount = ( USHORT ) hb_pcount();

   if( uiPCount > 0 )
   {
      PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

      if( HB_IS_STRING( pItem ) )
      {
         PHB_DYNS pDynSym = hb_dynsymFindName( hb_itemGetCPtr( pItem ) );

         if( pDynSym )
         {
            hb_vmPushDynSym( pDynSym );
            hb_vmPushNil();
         }
         else
         {
            hb_errRT_BASE( EG_NOFUNC, 1001, NULL, hb_itemGetCPtr( pItem ), HB_ERR_ARGS_BASEPARAMS );
            return;
         }
      }
      else if( HB_IS_BLOCK( pItem ) )
      {
         hb_vmPushSymbol( &hb_symEval );
         hb_vmPush( pItem );
      }
      else if( HB_IS_SYMBOL( pItem ) )
      {
         hb_vmPush( pItem );
         hb_vmPushNil();
      }
      else
         uiPCount = 0;
   }

   if( uiPCount > 0 )
   {
      USHORT uiParam;
      for( uiParam = 2; uiParam <= uiPCount; ++uiParam )
         hb_vmPush( hb_stackItemFromBase( uiParam ) );
      hb_vmDo( ( USHORT ) ( uiPCount - 1 ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
do.c66
empty.c
TypeFunctionSourceLine
HB_FUNCEMPTY(void)
HB_FUNC( EMPTY )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );
   PHB_SYMB pSym;

   switch( hb_itemType( pItem ) )
   {
      case HB_IT_ARRAY:
         hb_retl( hb_arrayLen( pItem ) == 0 );
         break;

      case HB_IT_HASH:
         hb_retl( hb_hashLen( pItem ) == 0 );
         break;

      case HB_IT_STRING:
      case HB_IT_MEMO:
         hb_retl( hb_strEmpty( hb_itemGetCPtr( pItem ), hb_itemGetCLen( pItem ) ) );
         break;

      case HB_IT_INTEGER:
         hb_retl( hb_itemGetNI( pItem ) == 0 );
         break;

      case HB_IT_LONG:
         hb_retl( hb_itemGetNInt( pItem ) == 0 );
         break;

      case HB_IT_DOUBLE:
         hb_retl( hb_itemGetND( pItem ) == 0.0 );
         break;

      case HB_IT_DATE:
         hb_retl( hb_itemGetDL( pItem ) == 0 );
         break;

      case HB_IT_LOGICAL:
         hb_retl( ! hb_itemGetL( pItem ) );
         break;

      case HB_IT_BLOCK:
         hb_retl( FALSE );
         break;

      case HB_IT_POINTER:
         hb_retl( hb_itemGetPtr( pItem ) == NULL );
         break;

      case HB_IT_SYMBOL:
         pSym = hb_itemGetSymbol( pItem );
         hb_retl( pSym == NULL || pSym->value.pFunPtr == NULL );
         break;

      default:
         hb_retl( TRUE );
         break;
   }
}
empty.c56
errorapi.c
TypeFunctionSourceLine
STATIC VOIDhb_errorDataRelease( void * Cargo )
static void hb_errorDataRelease( void * Cargo )
{
   PHB_ERRDATA pErrData = ( PHB_ERRDATA ) Cargo;

   hb_itemRelease( pErrData->errorBlock );
}

static HB_TSD_NEW( s_errData, sizeof( HB_ERRDATA ), NULL, hb_errorDataRelease );
errorapi.c129
STATIC BOOLhb_errGetNumCode( int * piValue, const char * szOperation )
static BOOL hb_errGetNumCode( int * piValue, const char * szOperation )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_NUMERIC );

   if( pItem )
      *piValue = hb_itemGetNI( pItem );
   else
   {
      pItem = hb_errRT_BASE_Subst( EG_ARG, 0, NULL, szOperation,
                                   HB_ERR_ARGS_BASEPARAMS );
      if( !pItem )
      {
         *piValue = 0;
         return FALSE;
      }

      if( !HB_IS_NUMERIC( pItem ) )
         hb_errInternal( HB_EI_ERRRECFAILURE, NULL, NULL, NULL );

      *piValue = hb_itemGetNI( pItem );
      hb_itemRelease( pItem );
   }

   return TRUE;
}
errorapi.c139
HB_FUNC_STATICCARGO(void)
HB_FUNC_STATIC( CARGO )
{
   hb_itemReturn( hb_errGetCargo( hb_stackSelfItem() ) );
}
errorapi.c166
HB_FUNC_STATIC_CARGO(void)
HB_FUNC_STATIC( _CARGO )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

   if( pItem )
      hb_errPutCargo( hb_stackSelfItem(), pItem );

   hb_itemReturn( pItem );
}
errorapi.c171
HB_FUNC_STATICARGS(void)
HB_FUNC_STATIC( ARGS )
{
   hb_itemReturn( hb_errGetArgs( hb_stackSelfItem() ) );
}
errorapi.c182
HB_FUNC_STATIC_ARGS(void)
HB_FUNC_STATIC( _ARGS )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ARRAY );

   if( pItem )
      hb_errPutArgsArray( hb_stackSelfItem(), pItem );

   hb_itemReturn( pItem );
}
errorapi.c187
HB_FUNC_STATICCANDEFAULT(void)
HB_FUNC_STATIC( CANDEFAULT )
{
   hb_retl( ( hb_errGetFlags( hb_stackSelfItem() ) & EF_CANDEFAULT ) != 0 );
}
errorapi.c198
HB_FUNC_STATIC_CANDEFAULT(void)
HB_FUNC_STATIC( _CANDEFAULT )
{
   if( ISLOG( 1 ) )
   {
      PHB_ITEM pError = hb_stackSelfItem();
      BOOL fCan = hb_parl( 1 );
      
      if( fCan )
         hb_errPutFlags( pError, ( USHORT ) ( hb_errGetFlags( pError ) | EF_CANDEFAULT ) );
      else
         hb_errPutFlags( pError, ( USHORT ) ( hb_errGetFlags( pError ) & ~EF_CANDEFAULT ) );

      hb_retl( fCan );
   }
}
errorapi.c203
HB_FUNC_STATICCANRETRY(void)
HB_FUNC_STATIC( CANRETRY )
{
   hb_retl( ( hb_errGetFlags( hb_stackSelfItem() ) & EF_CANRETRY ) != 0 );
}
errorapi.c220
HB_FUNC_STATIC_CANRETRY(void)
HB_FUNC_STATIC( _CANRETRY )
{
   if( ISLOG( 1 ) )
   {
      PHB_ITEM pError = hb_stackSelfItem();
      BOOL fCan = hb_parl( 1 );
      
      if( fCan )
         hb_errPutFlags( pError, ( USHORT ) ( hb_errGetFlags( pError ) | EF_CANRETRY ) );
      else
         hb_errPutFlags( pError, ( USHORT ) ( hb_errGetFlags( pError ) & ~EF_CANRETRY ) );

      hb_retl( fCan );
   }
}
errorapi.c225
HB_FUNC_STATICCANSUBST(void)
HB_FUNC_STATIC( CANSUBST )
{
   hb_retl( ( hb_errGetFlags( hb_stackSelfItem() ) & EF_CANSUBSTITUTE ) != 0 );
}
errorapi.c242
HB_FUNC_STATIC_CANSUBST(void)
HB_FUNC_STATIC( _CANSUBST )
{
   if( ISLOG( 1 ) )
   {
      PHB_ITEM pError = hb_stackSelfItem();
      BOOL fCan = hb_parl( 1 );
      
      if( fCan )
         hb_errPutFlags( pError, ( USHORT ) ( hb_errGetFlags( pError ) | EF_CANSUBSTITUTE ) );
      else
         hb_errPutFlags( pError, ( USHORT ) ( hb_errGetFlags( pError ) & ~EF_CANSUBSTITUTE ) );

      hb_retl( fCan );
   }
}
errorapi.c247
HB_FUNC_STATICDESCRIPTION(void)
HB_FUNC_STATIC( DESCRIPTION )
{
   hb_retc( hb_errGetDescription( hb_stackSelfItem() ) );
}
errorapi.c264
HB_FUNC_STATIC_DESCRIPTION(void)
HB_FUNC_STATIC( _DESCRIPTION )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

   if( pItem && HB_IS_STRING( pItem ) )
      hb_errPutDescription( hb_stackSelfItem(), hb_itemGetCPtr( pItem ) );

   hb_itemReturn( pItem );
}
errorapi.c269
HB_FUNC_STATICFILENAME(void)
HB_FUNC_STATIC( FILENAME )
{
   hb_retc( hb_errGetFileName( hb_stackSelfItem() ) );
}
errorapi.c280
HB_FUNC_STATIC_FILENAME(void)
HB_FUNC_STATIC( _FILENAME )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

   if( pItem && HB_IS_STRING( pItem ) )
      hb_errPutFileName( hb_stackSelfItem(), hb_itemGetCPtr( pItem ) );

   hb_itemReturn( pItem );
}
errorapi.c285
HB_FUNC_STATICOPERATION(void)
HB_FUNC_STATIC( OPERATION )
{
   hb_retc( hb_errGetOperation( hb_stackSelfItem() ) );
}
errorapi.c296
HB_FUNC_STATIC_OPERATION(void)
HB_FUNC_STATIC( _OPERATION )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

   if( pItem && HB_IS_STRING( pItem ) )
      hb_errPutOperation( hb_stackSelfItem(), hb_itemGetCPtr( pItem ) );

   hb_itemReturn( pItem );
}
errorapi.c301
HB_FUNC_STATICSUBSYSTEM(void)
HB_FUNC_STATIC( SUBSYSTEM )
{
   hb_retc( hb_errGetSubSystem( hb_stackSelfItem() ) );
}
errorapi.c312
HB_FUNC_STATIC_SUBSYSTEM(void)
HB_FUNC_STATIC( _SUBSYSTEM )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

   if( pItem && HB_IS_STRING( pItem ) )
      hb_errPutSubSystem( hb_stackSelfItem(), hb_itemGetCPtr( pItem ) );

   hb_itemReturn( pItem );
}
errorapi.c317
HB_FUNC_STATICGENCODE(void)
HB_FUNC_STATIC( GENCODE )
{
   hb_retni( hb_errGetGenCode( hb_stackSelfItem() ) );
}
errorapi.c328
HB_FUNC_STATIC_GENCODE(void)
HB_FUNC_STATIC( _GENCODE )
{
   int iValue;

   if( hb_errGetNumCode( &iValue, "GENCODE" ) )
   {
      hb_errPutGenCode( hb_stackSelfItem(), ( USHORT ) iValue );
      hb_errPutDescription( hb_stackSelfItem(),
                            hb_langDGetErrorDesc( iValue ) );
   }

   hb_retni( iValue );
}
errorapi.c333
HB_FUNC_STATICOSCODE(void)
HB_FUNC_STATIC( OSCODE )
{
   hb_retni( hb_errGetOsCode( hb_stackSelfItem() ) );
}
errorapi.c348
HB_FUNC_STATIC_OSCODE(void)
HB_FUNC_STATIC( _OSCODE )
{
   int iValue;

   if( hb_errGetNumCode( &iValue, "OSCODE" ) )
      hb_errPutOsCode( hb_stackSelfItem(), ( USHORT ) iValue );

   hb_retni( iValue );
}
errorapi.c353
HB_FUNC_STATICSUBCODE(void)
HB_FUNC_STATIC( SUBCODE )
{
   hb_retni( hb_errGetSubCode( hb_stackSelfItem() ) );
}
errorapi.c364
HB_FUNC_STATIC_SUBCODE(void)
HB_FUNC_STATIC( _SUBCODE )
{
   int iValue;

   if( hb_errGetNumCode( &iValue, "SUBCODE" ) )
      hb_errPutSubCode( hb_stackSelfItem(), ( USHORT ) iValue );

   hb_retni( iValue );
}
errorapi.c369
HB_FUNC_STATICSEVERITY(void)
HB_FUNC_STATIC( SEVERITY )
{
   hb_retni( hb_errGetSeverity( hb_stackSelfItem() ) );
}
errorapi.c380
HB_FUNC_STATIC_SEVERITY(void)
HB_FUNC_STATIC( _SEVERITY )
{
   int iValue;

   if( hb_errGetNumCode( &iValue, "SEVERITY" ) )
      hb_errPutSeverity( hb_stackSelfItem(), ( USHORT ) iValue );

   hb_retni( iValue );
}
errorapi.c385
HB_FUNC_STATICTRIES(void)
HB_FUNC_STATIC( TRIES )
{
   hb_retni( hb_errGetTries( hb_stackSelfItem() ) );
}
errorapi.c396
HB_FUNC_STATIC_TRIES(void)
HB_FUNC_STATIC( _TRIES )
{
   int iValue;

   if( hb_errGetNumCode( &iValue, "TRIES" ) )
      hb_errPutTries( hb_stackSelfItem(), ( USHORT ) iValue );

   hb_retni( iValue );
}
errorapi.c401
STATIC USHORThb_errClassCreate( void )
static USHORT hb_errClassCreate( void )
{
   USHORT usClassH = hb_clsCreate( HB_TERROR_IVARCOUNT, "ERROR" );
                     
   hb_clsAdd( usClassH, "ARGS"          , HB_FUNCNAME( ARGS )         );
   hb_clsAdd( usClassH, "_ARGS"         , HB_FUNCNAME( _ARGS )        );
   hb_clsAdd( usClassH, "CANDEFAULT"    , HB_FUNCNAME( CANDEFAULT )   );
   hb_clsAdd( usClassH, "_CANDEFAULT"   , HB_FUNCNAME( _CANDEFAULT )  );
   hb_clsAdd( usClassH, "CANRETRY"      , HB_FUNCNAME( CANRETRY )     );
   hb_clsAdd( usClassH, "_CANRETRY"     , HB_FUNCNAME( _CANRETRY )    );
   hb_clsAdd( usClassH, "CANSUBSTITUTE" , HB_FUNCNAME( CANSUBST )     );
   hb_clsAdd( usClassH, "_CANSUBSTITUTE", HB_FUNCNAME( _CANSUBST )    );
   hb_clsAdd( usClassH, "CARGO"         , HB_FUNCNAME( CARGO )        );
   hb_clsAdd( usClassH, "_CARGO"        , HB_FUNCNAME( _CARGO )       );
   hb_clsAdd( usClassH, "DESCRIPTION"   , HB_FUNCNAME( DESCRIPTION )  );
   hb_clsAdd( usClassH, "_DESCRIPTION"  , HB_FUNCNAME( _DESCRIPTION ) );
   hb_clsAdd( usClassH, "FILENAME"      , HB_FUNCNAME( FILENAME )     );
   hb_clsAdd( usClassH, "_FILENAME"     , HB_FUNCNAME( _FILENAME )    );
   hb_clsAdd( usClassH, "GENCODE"       , HB_FUNCNAME( GENCODE )      );
   hb_clsAdd( usClassH, "_GENCODE"      , HB_FUNCNAME( _GENCODE )     );
   hb_clsAdd( usClassH, "OPERATION"     , HB_FUNCNAME( OPERATION )    );
   hb_clsAdd( usClassH, "_OPERATION"    , HB_FUNCNAME( _OPERATION )   );
   hb_clsAdd( usClassH, "OSCODE"        , HB_FUNCNAME( OSCODE )       );
   hb_clsAdd( usClassH, "_OSCODE"       , HB_FUNCNAME( _OSCODE )      );
   hb_clsAdd( usClassH, "SEVERITY"      , HB_FUNCNAME( SEVERITY )     );
   hb_clsAdd( usClassH, "_SEVERITY"     , HB_FUNCNAME( _SEVERITY )    );
   hb_clsAdd( usClassH, "SUBCODE"       , HB_FUNCNAME( SUBCODE )      );
   hb_clsAdd( usClassH, "_SUBCODE"      , HB_FUNCNAME( _SUBCODE )     );
   hb_clsAdd( usClassH, "SUBSYSTEM"     , HB_FUNCNAME( SUBSYSTEM )    );
   hb_clsAdd( usClassH, "_SUBSYSTEM"    , HB_FUNCNAME( _SUBSYSTEM )   );
   hb_clsAdd( usClassH, "TRIES"         , HB_FUNCNAME( TRIES )        );
   hb_clsAdd( usClassH, "_TRIES"        , HB_FUNCNAME( _TRIES )       );

   return usClassH;
}
errorapi.c412
HB_FUNCERRORNEW(void)
HB_FUNC( ERRORNEW )
{
   hb_itemReturnRelease( hb_errNew() );
}
errorapi.c448
HB_FUNC__ERRINHANDLER(void)
HB_FUNC( __ERRINHANDLER )
{
   hb_errInternal( HB_EI_ERRRECFAILURE, NULL, NULL, NULL );
}
errorapi.c456
HB_FUNCERRORBLOCK(void)
HB_FUNC( ERRORBLOCK )
{
   PHB_ITEM pNewErrorBlock = hb_param( 1, HB_IT_BLOCK );
   PHB_ITEM pErrorBlock = hb_errorBlock();

   hb_itemReturn( pErrorBlock );
   if( pNewErrorBlock )
   {
      hb_itemCopy( pErrorBlock, pNewErrorBlock );
   }
}
errorapi.c461
PHB_ITEMhb_errorBlock( void )
PHB_ITEM hb_errorBlock( void )
{
   PHB_ERRDATA pErrData = ( PHB_ERRDATA ) hb_stackGetTSD( &s_errData );

   if( !pErrData->errorBlock )
      pErrData->errorBlock = hb_itemNew( NULL );

   return pErrData->errorBlock;
}
errorapi.c473
HB_ERROR_INFO_PTRhb_errorHandler( HB_ERROR_INFO_PTR pNewHandler )
HB_ERROR_INFO_PTR hb_errorHandler( HB_ERROR_INFO_PTR pNewHandler )
{
   PHB_ERRDATA pErrData = ( PHB_ERRDATA ) hb_stackGetTSD( &s_errData );
   HB_ERROR_INFO_PTR pOld = pErrData->errorHandler;

   if( pNewHandler )
      pNewHandler->Previous = pErrData->errorHandler;
   pErrData->errorHandler = pNewHandler;

   return pOld;
}
errorapi.c483
HB_FUNCDOSERROR(void)
HB_FUNC( DOSERROR )
{
   PHB_ERRDATA pErrData = ( PHB_ERRDATA ) hb_stackGetTSD( &s_errData );

   hb_retni( pErrData->uiErrorDOS );

   if( ISNUM( 1 ) )
      pErrData->uiErrorDOS = ( USHORT ) hb_parni( 1 );
}
errorapi.c500
VOIDhb_errInit( void )
void hb_errInit( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errInit()"));

   /* error function */
   hb_dynsymNew( &s_symErrorNew );

   /* Create error class and base object */
   s_pError = hb_itemNew( NULL );
   hb_clsAssociate( hb_errClassCreate() );
   hb_itemMove( s_pError, hb_stackReturnItem() );
}
errorapi.c510
VOIDhb_errExit( void )
void hb_errExit( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errExit()"));

   hb_itemRelease( s_pError );
   s_pError = NULL;
}
errorapi.c523
PHB_ITEMhb_errNew( void )
PHB_ITEM hb_errNew( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errNew()"));

   if( !s_pError || !HB_IS_OBJECT( s_pError ) )
      hb_errInternal( HB_EI_ERRRECFAILURE, NULL, NULL, NULL );

   return hb_arrayClone( s_pError );
}
errorapi.c531
USHORThb_errLaunch( PHB_ITEM pError )
USHORT hb_errLaunch( PHB_ITEM pError )
{
   USHORT uiAction = E_DEFAULT; /* Needed to avoid GCC -O2 warning */

   HB_TRACE(HB_TR_DEBUG, ("hb_errLaunch(%p)", pError));

   if( pError )
   {
      PHB_ERRDATA pErrData = ( PHB_ERRDATA ) hb_stackGetTSD( &s_errData );
      PHB_ITEM pResult;

      /* Check if we have a valid error handler */
      if( !pErrData->errorBlock || hb_itemType( pErrData->errorBlock ) != HB_IT_BLOCK )
         hb_errInternal( HB_EI_ERRNOBLOCK, NULL, NULL, NULL );

      /* Check if the error launcher was called too many times recursively */
      if( pErrData->iLaunchCount == HB_ERROR_LAUNCH_MAX )
         hb_errInternal( HB_EI_ERRTOOMANY, NULL, NULL, NULL );

      /* Launch the error handler: "lResult := EVAL( ErrorBlock(), oError )" */
      pErrData->iLaunchCount++;

      /* set DOSERROR() to last OS error code */
      pErrData->uiErrorDOS = hb_errGetOsCode( pError );

      if( pErrData->errorHandler )
      {
         /* there is a low-level error handler defined - use it instead
          * of normal Harbour-level one
          */
         pErrData->errorHandler->Error = pError;
         pErrData->errorHandler->ErrorBlock = pErrData->errorBlock;
         pResult = ( pErrData->errorHandler->Func )( pErrData->errorHandler );
         pErrData->errorHandler->Error = NULL;
      }
      else
         pResult = hb_itemDo( pErrData->errorBlock, 1, pError );

      pErrData->iLaunchCount--;

      /* Check results */
      if( hb_vmRequestQuery() != 0 )
      {
         if( pResult )
            hb_itemRelease( pResult );
         uiAction = E_BREAK;
      }
      else if( pResult )
      {
         BOOL bFailure = FALSE;
         USHORT uiFlags = hb_errGetFlags( pError );

         /* If the error block didn't return a logical value, */
         /* or the canSubstitute flag has been set, consider it as a failure */
         if( hb_itemType( pResult ) != HB_IT_LOGICAL || ( uiFlags & EF_CANSUBSTITUTE ) )
            bFailure = TRUE;
         else
         {
            uiAction = hb_itemGetL( pResult ) ? E_RETRY : E_DEFAULT;

            if( ( uiAction == E_DEFAULT && !( uiFlags & EF_CANDEFAULT ) ) ||
                ( uiAction == E_RETRY   && !( uiFlags & EF_CANRETRY   ) ) )
               bFailure = TRUE;
         }

         hb_itemRelease( pResult );

         if( bFailure )
            hb_errInternal( HB_EI_ERRRECFAILURE, NULL, NULL, NULL );

         /* Add one try to the counter. */
         if( uiAction == E_RETRY )
            hb_errPutTries( pError, ( USHORT ) ( hb_errGetTries( pError ) + 1 ) );
      }
      else
         hb_errInternal( HB_EI_ERRRECFAILURE, NULL, NULL, NULL );
   }
   else
      uiAction = E_RETRY; /* Clipper does this, undocumented */

   return uiAction;
}

/* This error launcher should be used in those situations, where the error
   handler is expected to return a value to be substituted as the result of
   a failed operation. [vszakats] */

errorapi.c541
PHB_ITEMhb_errLaunchSubst( PHB_ITEM pError )
PHB_ITEM hb_errLaunchSubst( PHB_ITEM pError )
{
   PHB_ITEM pResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_errLaunchSubst(%p)", pError));

   if( pError )
   {
      PHB_ERRDATA pErrData = ( PHB_ERRDATA ) hb_stackGetTSD( &s_errData );

      /* Check if we have a valid error handler */
      if( !pErrData->errorBlock || hb_itemType( pErrData->errorBlock ) != HB_IT_BLOCK )
         hb_errInternal( HB_EI_ERRNOBLOCK, NULL, NULL, NULL );

      /* Check if the error launcher was called too many times recursively */
      if( pErrData->iLaunchCount == HB_ERROR_LAUNCH_MAX )
         hb_errInternal( HB_EI_ERRTOOMANY, NULL, NULL, NULL );

      /* Launch the error handler: "xResult := EVAL( ErrorBlock(), oError )" */
      pErrData->iLaunchCount++;

      /* set DOSERROR() to last OS error code */
      pErrData->uiErrorDOS = hb_errGetOsCode( pError );

      if( pErrData->errorHandler )
      {
         /* there is a low-level error handler defined - use it instead
          * of normal Harbour-level one
          */
         pErrData->errorHandler->Error = pError;
         pErrData->errorHandler->ErrorBlock = pErrData->errorBlock;
         pResult = ( pErrData->errorHandler->Func )( pErrData->errorHandler );
         pErrData->errorHandler->Error = NULL;
      }
      else
         pResult = hb_itemDo( pErrData->errorBlock, 1, pError );

      pErrData->iLaunchCount--;

      /* Check results */
      if( hb_vmRequestQuery() != 0 )
      {
         if( pResult )
            hb_itemRelease( pResult );
         pResult = NULL;
      }
      else
      {
         /* If the canSubstitute flag has not been set,
            consider it as a failure. */
         if( ! ( hb_errGetFlags( pError ) & EF_CANSUBSTITUTE ) )
            hb_errInternal( HB_EI_ERRRECFAILURE, NULL, NULL, NULL );
      }
   }
   else
      pResult = hb_itemNew( NULL );

   return pResult;
}
errorapi.c635
VOIDhb_errRelease( PHB_ITEM pError )
void hb_errRelease( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errRelease(%p)", pError));

   /* NOTE: NULL pointer is checked by hb_itemRelease() [vszakats] */
   hb_itemRelease( pError );
}
errorapi.c695
PHB_ITEMhb_errGetCargo( PHB_ITEM pError )
PHB_ITEM hb_errGetCargo( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetCargo(%p)", pError));

   return hb_arrayGetItemPtr( pError, HB_TERROR_CARGO );
}
errorapi.c703
PHB_ITEMhb_errPutCargo( PHB_ITEM pError, PHB_ITEM pCargo )
PHB_ITEM hb_errPutCargo( PHB_ITEM pError, PHB_ITEM pCargo )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutCargo(%p, %p)", pError, pCargo));

   hb_arraySet( pError, HB_TERROR_CARGO, pCargo );

   return pError;
}
errorapi.c710
PHB_ITEMhb_errGetArgs( PHB_ITEM pError )
PHB_ITEM hb_errGetArgs( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetArgs(%p)", pError));

   return hb_arrayGetItemPtr( pError, HB_TERROR_ARGS );
}
errorapi.c719
PHB_ITEMhb_errPutArgsArray( PHB_ITEM pError, PHB_ITEM pArgs )
PHB_ITEM hb_errPutArgsArray( PHB_ITEM pError, PHB_ITEM pArgs )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutArgsArray(%p, %p)", pError, pArgs));

   hb_arraySet( pError, HB_TERROR_ARGS, pArgs );

   return pError;
}
errorapi.c726
CHAR *hb_errGetDescription( PHB_ITEM pError )
char * hb_errGetDescription( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetDescription(%p)", pError));

   return hb_arrayGetCPtr( pError, HB_TERROR_DESCRIPTION );
}
errorapi.c735
PHB_ITEMhb_errPutDescription( PHB_ITEM pError, const char * szDescription )
PHB_ITEM hb_errPutDescription( PHB_ITEM pError, const char * szDescription )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutDescription(%p, %s)", pError, szDescription));

   hb_arraySetC( pError, HB_TERROR_DESCRIPTION, szDescription );

   return pError;
}
errorapi.c742
CHAR *hb_errGetFileName( PHB_ITEM pError )
char * hb_errGetFileName( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetFileName(%p)", pError));

   return hb_arrayGetCPtr( pError, HB_TERROR_FILENAME );
}
errorapi.c751
PHB_ITEMhb_errPutFileName( PHB_ITEM pError, const char * szFileName )
PHB_ITEM hb_errPutFileName( PHB_ITEM pError, const char * szFileName )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutFileName(%p, %s)", pError, szFileName));

   hb_arraySetC( pError, HB_TERROR_FILENAME, szFileName );

   return pError;
}
errorapi.c758
USHORThb_errGetGenCode( PHB_ITEM pError )
USHORT hb_errGetGenCode( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetGenCode(%p)", pError));

   return ( USHORT ) hb_arrayGetNI( pError, HB_TERROR_GENCODE );
}
errorapi.c767
PHB_ITEMhb_errPutGenCode( PHB_ITEM pError, USHORT uiGenCode )
PHB_ITEM hb_errPutGenCode( PHB_ITEM pError, USHORT uiGenCode )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutGenCode(%p, %hu)", pError, uiGenCode));

   hb_arraySetNI( pError, HB_TERROR_GENCODE, uiGenCode );

   return pError;
}
errorapi.c774
CHAR *hb_errGetOperation( PHB_ITEM pError )
char * hb_errGetOperation( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetOperation(%p)", pError));

   return hb_arrayGetCPtr( pError, HB_TERROR_OPERATION );
}
errorapi.c783
PHB_ITEMhb_errPutOperation( PHB_ITEM pError, const char * szOperation )
PHB_ITEM hb_errPutOperation( PHB_ITEM pError, const char * szOperation )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutOperation(%p, %s)", pError, szOperation));

   if( szOperation == HB_ERR_FUNCNAME )
   {
      PHB_SYMB pSym = hb_itemGetSymbol( hb_stackBaseItem() );
      if( pSym )
         szOperation = pSym->szName;
   }

   hb_arraySetC( pError, HB_TERROR_OPERATION, szOperation );

   return pError;
}
errorapi.c790
USHORThb_errGetOsCode( PHB_ITEM pError )
USHORT hb_errGetOsCode( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetOsCode(%p)", pError));

   return ( USHORT ) hb_arrayGetNI( pError, HB_TERROR_OSCODE );
}
errorapi.c806
PHB_ITEMhb_errPutOsCode( PHB_ITEM pError, USHORT uiOsCode )
PHB_ITEM hb_errPutOsCode( PHB_ITEM pError, USHORT uiOsCode )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutOsCode(%p, %hu)", pError, uiOsCode));

   hb_arraySetNI( pError, HB_TERROR_OSCODE, uiOsCode );

   return pError;
}
errorapi.c813
USHORThb_errGetSeverity( PHB_ITEM pError )
USHORT hb_errGetSeverity( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetSeverity(%p)", pError));

   return ( USHORT ) hb_arrayGetNI( pError, HB_TERROR_SEVERITY );
}
errorapi.c822
PHB_ITEMhb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity )
PHB_ITEM hb_errPutSeverity( PHB_ITEM pError, USHORT uiSeverity )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutSeverity(%p, %hu)", pError, uiSeverity));

   hb_arraySetNI( pError, HB_TERROR_SEVERITY, uiSeverity );

   return pError;
}
errorapi.c829
USHORThb_errGetSubCode( PHB_ITEM pError )
USHORT hb_errGetSubCode( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetSubCode(%p)", pError));

   return ( USHORT ) hb_arrayGetNI( pError, HB_TERROR_SUBCODE );
}
errorapi.c838
PHB_ITEMhb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode )
PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutSubCode(%p, %hu)", pError, uiSubCode));

   hb_arraySetNI( pError, HB_TERROR_SUBCODE, uiSubCode );

   return pError;
}
errorapi.c845
CHAR *hb_errGetSubSystem( PHB_ITEM pError )
char * hb_errGetSubSystem( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetSubSytem(%p)", pError));

   return hb_arrayGetCPtr( pError, HB_TERROR_SUBSYSTEM );
}
errorapi.c854
PHB_ITEMhb_errPutSubSystem( PHB_ITEM pError, const char * szSubSystem )
PHB_ITEM hb_errPutSubSystem( PHB_ITEM pError, const char * szSubSystem )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutSubSytem(%p, %s)", pError, szSubSystem));

   hb_arraySetC( pError, HB_TERROR_SUBSYSTEM, szSubSystem );

   return pError;
}
errorapi.c861
USHORThb_errGetTries( PHB_ITEM pError )
USHORT hb_errGetTries( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetTries(%p)", pError));

   return ( USHORT ) hb_arrayGetNI( pError, HB_TERROR_TRIES );
}
errorapi.c870
PHB_ITEMhb_errPutTries( PHB_ITEM pError, USHORT uiTries )
PHB_ITEM hb_errPutTries( PHB_ITEM pError, USHORT uiTries )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutTries(%p, %hu)", pError, uiTries));

   hb_arraySetNI( pError, HB_TERROR_TRIES, uiTries );

   return pError;
}
errorapi.c877
USHORThb_errGetFlags( PHB_ITEM pError )
USHORT hb_errGetFlags( PHB_ITEM pError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errGetFlags(%p)", pError));

   return ( USHORT ) hb_arrayGetNI( pError, HB_TERROR_FLAGS );
}
errorapi.c886
PHB_ITEMhb_errPutFlags( PHB_ITEM pError, USHORT uiFlags )
PHB_ITEM hb_errPutFlags( PHB_ITEM pError, USHORT uiFlags )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_errPutFlags(%p, %hu)", pError, uiFlags));

   uiFlags &= EF_CANRETRY | EF_CANSUBSTITUTE | EF_CANDEFAULT;
   hb_arraySetNI( pError, HB_TERROR_FLAGS, uiFlags );

   return pError;
}
errorapi.c893
PHB_ITEMhb_errPutArgs( PHB_ITEM pError, ULONG ulArgCount, ... )
PHB_ITEM hb_errPutArgs( PHB_ITEM pError, ULONG ulArgCount, ... )
{
   PHB_ITEM pArray;
   ULONG ulArgPos;
   va_list va;

   HB_TRACE(HB_TR_DEBUG, ("hb_errPutArgs(%p, %hu, ...)", pError, ulArgCount));

   pArray = hb_itemArrayNew( ulArgCount );

   /* Build the array from the passed arguments. */

   va_start( va, ulArgCount );
   for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ )
      hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) );
   va_end( va );

   /* Assign the new array to the object data item. */
   hb_errPutArgsArray( pError, pArray );

   /* Release the Array. */
   hb_itemRelease( pArray );

   return pError;
}
errorapi.c903
PHB_ITEMhb_errRT_New( USHORT uiSeverity, const char * szSubSystem, ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiOsCode, USHORT uiFlags )
PHB_ITEM hb_errRT_New(
   USHORT uiSeverity,
   const char * szSubSystem,
   ULONG  ulGenCode,
   ULONG  ulSubCode,
   const char * szDescription,
   const char * szOperation,
   USHORT uiOsCode,
   USHORT uiFlags )
{
   PHB_ITEM pError = hb_errNew();

   hb_errPutSeverity( pError, uiSeverity );
   hb_errPutSubSystem( pError, szSubSystem ? szSubSystem : HB_ERR_SS_BASE );
   hb_errPutGenCode( pError, ( USHORT ) ulGenCode );
   hb_errPutSubCode( pError, ( USHORT ) ulSubCode );
   hb_errPutDescription( pError, szDescription ? szDescription : ( const char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ERRDESC + ulGenCode ) );
   hb_errPutOperation( pError, szOperation ? szOperation : "" );
   hb_errPutOsCode( pError, uiOsCode );
   hb_errPutFlags( pError, uiFlags );

   return pError;
}
errorapi.c931
PHB_ITEMhb_errRT_New_Subst( USHORT uiSeverity, const char * szSubSystem, ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiOsCode, USHORT uiFlags )
PHB_ITEM hb_errRT_New_Subst(
   USHORT uiSeverity,
   const char * szSubSystem,
   ULONG  ulGenCode,
   ULONG  ulSubCode,
   const char * szDescription,
   const char * szOperation,
   USHORT uiOsCode,
   USHORT uiFlags )
{
   PHB_ITEM pError = hb_errNew();

   hb_errPutSeverity( pError, uiSeverity );
   hb_errPutSubSystem( pError, szSubSystem ? szSubSystem : HB_ERR_SS_BASE );
   hb_errPutGenCode( pError, ( USHORT ) ulGenCode );
   hb_errPutSubCode( pError, ( USHORT ) ulSubCode );
   hb_errPutDescription( pError, szDescription ? szDescription : ( const char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ERRDESC + ulGenCode ) );
   hb_errPutOperation( pError, szOperation ? szOperation : "" );
   hb_errPutOsCode( pError, uiOsCode );
   hb_errPutFlags( pError, ( USHORT ) ( uiFlags | EF_CANSUBSTITUTE ) );

   return pError;
}
errorapi.c955
PHB_ITEMhb_errRT_SubstParams( const char *szSubSystem, ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation )
PHB_ITEM hb_errRT_SubstParams( const char *szSubSystem, ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation )
{
   PHB_ITEM pRetVal;
   PHB_ITEM pError;
   PHB_ITEM pArray;

   HB_TRACE_STEALTH( HB_TR_DEBUG, ( "hb_errRT_SubstParams()") );

   pError = hb_errRT_New_Subst( ES_ERROR, szSubSystem ? szSubSystem : HB_ERR_SS_BASE,
               ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE );

   pArray = hb_arrayBaseParams();

   /* Assign the new array to the object data item. */
   hb_errPutArgsArray( pError, pArray );

   /* Release the Array. */
   hb_itemRelease( pArray );

   /* Ok, launch... */
   pRetVal = hb_errLaunchSubst( pError );

   hb_itemRelease( pError );

   return pRetVal;
}
errorapi.c979
HB_FUNC__ERRRT_BASE(void)
HB_FUNC( __ERRRT_BASE )
{
   hb_errRT_BASE( ( ULONG ) hb_parnl( 1 ),
                  ( ULONG ) hb_parnl( 2 ),
                  hb_parc( 3 ),
                  hb_parc( 4 ),
                  ( USHORT ) ( hb_pcount() > 5 && hb_parni( 5 ) > 0 ? 1 : 0 ),
                  hb_param( 6, HB_IT_ANY ) );
}
errorapi.c1007
HB_FUNC__ERRRT_SBASE(void)
HB_FUNC( __ERRRT_SBASE )
{
   hb_errRT_BASE_SubstR( ( ULONG ) hb_parnl( 1 ),
                         ( ULONG ) hb_parnl( 2 ),
                         hb_parc( 3 ),
                         hb_parc( 4 ),
                         ( USHORT ) ( hb_pcount() > 5 && hb_parni( 5 ) > 0 ? 1 : 0 ),
                         hb_param( 6, HB_IT_ANY ) );
}
errorapi.c1017
USHORThb_errRT_BASE( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, ULONG ulArgCount, ... )
USHORT hb_errRT_BASE( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, ULONG ulArgCount, ... )
{
   USHORT uiAction;
   PHB_ITEM pError;

   PHB_ITEM pArray;
   va_list va;
   ULONG ulArgPos;

   /* I replaced EF_CANRETRY with EF_NONE for Clipper compatibility
    * If it's wrong and I missed sth please fix me, Druzus.
    */
   pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE /* EF_CANRETRY */ );

   /* Build the array from the passed arguments. */
   if( ulArgCount == 0 )
   {
      pArray = NULL;
   }
   else if( ulArgCount == HB_ERR_ARGS_BASEPARAMS )
   {
      if( hb_pcount() == 0 )
         pArray = NULL;
      else
         pArray = hb_arrayBaseParams();
   }
   else if( ulArgCount == HB_ERR_ARGS_SELFPARAMS )
   {
      pArray = hb_arraySelfParams();
   }
   else
   {
      pArray = hb_itemArrayNew( ulArgCount );

      va_start( va, ulArgCount );
      for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ )
      {
         PHB_ITEM pArg = va_arg( va, PHB_ITEM );
         if( pArg )
            hb_itemArrayPut( pArray, ulArgPos, pArg );
      }
      va_end( va );
   }
   if( pArray )
   {
      /* Assign the new array to the object data item. */
      hb_errPutArgsArray( pError, pArray );

      /* Release the Array. */
      hb_itemRelease( pArray );
   }

   /* Ok, launch... */
   uiAction = hb_errLaunch( pError );

   /* Release. */
   hb_errRelease( pError );

   return uiAction;
}
errorapi.c1027
USHORThb_errRT_BASE_Ext1( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiOsCode, USHORT uiFlags, ULONG ulArgCount, ... )
USHORT hb_errRT_BASE_Ext1( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiOsCode, USHORT uiFlags, ULONG ulArgCount, ... )
{
   USHORT uiAction;
   PHB_ITEM pError;

   PHB_ITEM pArray;
   va_list va;
   ULONG ulArgPos;

   pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, uiOsCode, uiFlags );

   /* Build the array from the passed arguments. */
   if( ulArgCount == 0 )
   {
      pArray = NULL;
   }
   else if( ulArgCount == HB_ERR_ARGS_BASEPARAMS )
   {
      if( hb_pcount() == 0 )
         pArray = NULL;
      else
         pArray = hb_arrayBaseParams();
   }
   else if( ulArgCount == HB_ERR_ARGS_SELFPARAMS )
   {
      pArray = hb_arraySelfParams();
   }
   else
   {
      pArray = hb_itemArrayNew( ulArgCount );

      va_start( va, ulArgCount );
      for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ )
      {
         PHB_ITEM pArg = va_arg( va, PHB_ITEM );
         if( pArg )
            hb_itemArrayPut( pArray, ulArgPos, pArg );
      }
      va_end( va );
   }
   if( pArray )
   {
      /* Assign the new array to the object data item. */
      hb_errPutArgsArray( pError, pArray );

      /* Release the Array. */
      hb_itemRelease( pArray );
   }

   /* Ok, launch... */
   uiAction = hb_errLaunch( pError );

   hb_errRelease( pError );

   return uiAction;
}
errorapi.c1088
PHB_ITEMhb_errRT_BASE_Subst( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, ULONG ulArgCount, ... )
PHB_ITEM hb_errRT_BASE_Subst( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, ULONG ulArgCount, ... )
{
   PHB_ITEM pRetVal;
   PHB_ITEM pError;

   PHB_ITEM pArray;
   va_list va;
   ULONG ulArgPos;

   pError = hb_errRT_New_Subst( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE );

   /* Build the array from the passed arguments. */
   if( ulArgCount == 0 )
   {
      pArray = NULL;
   }
   else if( ulArgCount == HB_ERR_ARGS_BASEPARAMS )
   {
      if( hb_pcount() == 0 )
         pArray = NULL;
      else
         pArray = hb_arrayBaseParams();
   }
   else if( ulArgCount == HB_ERR_ARGS_SELFPARAMS )
   {
      pArray = hb_arraySelfParams();
   }
   else
   {
      pArray = hb_itemArrayNew( ulArgCount );

      va_start( va, ulArgCount );
      for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ )
      {
         PHB_ITEM pArg = va_arg( va, PHB_ITEM );
         if( pArg )
            hb_itemArrayPut( pArray, ulArgPos, pArg );
      }
      va_end( va );
   }
   if( pArray )
   {
      /* Assign the new array to the object data item. */
      hb_errPutArgsArray( pError, pArray );

      /* Release the Array. */
      hb_itemRelease( pArray );
   }

   /* Ok, launch... */
   pRetVal = hb_errLaunchSubst( pError );

   hb_errRelease( pError );

   return pRetVal;
}
errorapi.c1145
VOIDhb_errRT_BASE_SubstR( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, ULONG ulArgCount, ... )
void hb_errRT_BASE_SubstR( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, ULONG ulArgCount, ... )
{
   PHB_ITEM pError;

   PHB_ITEM pArray;
   va_list va;
   ULONG ulArgPos;

   pError = hb_errRT_New_Subst( ES_ERROR, HB_ERR_SS_BASE, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE );

   /* Build the array from the passed arguments. */
   if( ulArgCount == 0 )
   {
      pArray = NULL;
   }
   else if( ulArgCount == HB_ERR_ARGS_BASEPARAMS )
   {
      if( hb_pcount() == 0 )
         pArray = NULL;
      else
         pArray = hb_arrayBaseParams();
   }
   else if( ulArgCount == HB_ERR_ARGS_SELFPARAMS )
   {
      pArray = hb_arraySelfParams();
   }
   else
   {
      pArray = hb_itemArrayNew( ulArgCount );

      va_start( va, ulArgCount );
      for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ )
      {
         PHB_ITEM pArg = va_arg( va, PHB_ITEM );
         if( pArg )
            hb_itemArrayPut( pArray, ulArgPos, pArg );
      }
      va_end( va );
   }
   if( pArray )
   {
      /* Assign the new array to the object data item. */
      hb_errPutArgsArray( pError, pArray );

      /* Release the Array. */
      hb_itemRelease( pArray );
   }

   /* Ok, launch... */
   hb_itemReturnRelease( hb_errLaunchSubst( pError ) );
   hb_errRelease( pError );
}
errorapi.c1202
USHORThb_errRT_TERM( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiOSCode, USHORT uiFlags )
USHORT hb_errRT_TERM( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiOSCode, USHORT uiFlags )
{
   USHORT uiAction;
   PHB_ITEM pError =
      hb_errRT_New( ES_ERROR, HB_ERR_SS_TERMINAL, ulGenCode, ulSubCode, szDescription, szOperation, uiOSCode, uiFlags );

   uiAction = hb_errLaunch( pError );

   hb_errRelease( pError );

   return uiAction;
}
errorapi.c1255
USHORThb_errRT_DBCMD( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation )
USHORT hb_errRT_DBCMD( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation )
{
   USHORT uiAction;
   PHB_ITEM pError =
      hb_errRT_New( ES_ERROR, HB_ERR_SS_DBCMD, ulGenCode, ulSubCode, szDescription, szOperation, 0, EF_NONE );

   uiAction = hb_errLaunch( pError );

   hb_errRelease( pError );

   return uiAction;
}
errorapi.c1268
USHORThb_errRT_DBCMD_Ext( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiFlags )
USHORT hb_errRT_DBCMD_Ext( ULONG ulGenCode, ULONG ulSubCode, const char * szDescription, const char * szOperation, USHORT uiFlags )
{
   USHORT uiAction;
   PHB_ITEM pError;

   pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_DBCMD, ulGenCode, ulSubCode, (const char *)szDescription, (const char *)szOperation, 0, uiFlags );

   uiAction = hb_errLaunch( pError );

   hb_itemRelease( pError );

   return uiAction;
}
errorapi.c1281
errorapu.c
TypeFunctionSourceLine
HB_FUNCERRORINHAN(void)
HB_FUNC( ERRORINHAN )
{
   HB_FUNC_EXEC( __ERRINHANDLER )
}
errorapu.c59
HB_FUNCERRORINHANDLER(void)
HB_FUNC( ERRORINHANDLER )
{
   HB_FUNC_EXEC( __ERRINHANDLER )
}
errorapu.c64
errorint.c
TypeFunctionSourceLine
VOIDhb_errInternal( ULONG ulIntCode, const char * szText, const char * szPar1, const char * szPar2 )
void hb_errInternal( ULONG ulIntCode, const char * szText, const char * szPar1, const char * szPar2 )
{
   char buffer[ 8192 ];
   char file[ _POSIX_PATH_MAX + 1 ];
   const char * szFile;
   USHORT uiLine;
   int iLevel;
   FILE * hLog;

   BOOL fLang;

   HB_TRACE(HB_TR_DEBUG, ("hb_errInternal(%lu, %s, %s, %s)", ulIntCode, szText, szPar1, szPar2));

   if( szPar1 == NULL )
      szPar1 = "";

   if( szPar2 == NULL )
      szPar2 = "";

   fLang = ( hb_langID() != NULL );

   szFile = hb_setGetCPtr( HB_SET_HBOUTLOG );
   if( !szFile )
      szFile = "hb_out.log";

   hLog = hb_fopen( szFile, "a+" );
   if( hLog )
   {
      char szTime[ 9 ];
      int iYear, iMonth, iDay;

      hb_dateToday( &iYear, &iMonth, &iDay );
      hb_dateTimeStr( szTime );

      fprintf( hLog, HB_I_("Application Internal Error - %s\n"), hb_cmdargARGV()[0] );
      fprintf( hLog, HB_I_("Terminated at: %04d.%02d.%02d %s\n"), iYear, iMonth, iDay, szTime );
      if( *hb_setGetCPtr( HB_SET_HBOUTLOGINFO ) )
         fprintf( hLog, HB_I_("Info: %s\n"), hb_setGetCPtr( HB_SET_HBOUTLOGINFO ) );
   }

   hb_conOutErr( hb_conNewLine(), 0 );
   if( fLang )
      snprintf( buffer, sizeof( buffer ), ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ERRINTR ), ulIntCode );
   else
      snprintf( buffer, sizeof( buffer ), "Unrecoverable error %lu: ", ulIntCode );

   hb_conOutErr( buffer, 0 );
   if( hLog )
      fwrite( buffer, sizeof( buffer[ 0 ] ), strlen( buffer ), hLog );

   if( szText )
      snprintf( buffer, sizeof( buffer ), szText, szPar1, szPar2 );
   else if( fLang )
      snprintf( buffer, sizeof( buffer ), ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ERRINTR + ulIntCode - 9000 ), szPar1, szPar2 );
   else
      buffer[ 0 ] = '\0';

   hb_conOutErr( buffer, 0 );
   hb_conOutErr( hb_conNewLine(), 0 );
   if( hLog )
      fprintf( hLog, "%s\n", buffer );

   iLevel = 0;
   while( hb_procinfo( iLevel++, buffer, &uiLine, file ) )
   {
      char msg[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 32 ];

      snprintf( msg, sizeof( msg ), HB_I_("Called from %s(%hu)%s%s\n"), buffer, uiLine, *file ? HB_I_(" in ") : "", file );

      hb_conOutErr( msg, 0 );
      if( hLog )
         fwrite( msg, sizeof( msg[ 0 ] ), strlen( msg ), hLog );
   }

   if( hLog )
   {
      fprintf( hLog, "------------------------------------------------------------------------\n");
      fclose( hLog );
   }

   /* release console settings */
   hb_conRelease();

   if( hb_cmdargCheck( "ERRGPF" ) )
   {
       int *pGPF = NULL;
       *pGPF = 0;
       *(--pGPF) = 0;
   }

   exit( EXIT_FAILURE );
}
errorint.c62
file.c
TypeFunctionSourceLine
HB_EXPORT BOOLhb_fsFile( BYTE * pFilename )
HB_EXPORT BOOL hb_fsFile( BYTE * pFilename )
{
   PHB_FFIND ffind;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsFile(%s)", ( char * ) pFilename));

   pFilename = hb_fsNameConv( pFilename, &fFree );

   if( ( ffind = hb_fsFindFirst( ( char * ) pFilename, HB_FA_ALL ) ) != NULL )
   {
      hb_fsFindClose( ffind );
      if( fFree )
         hb_xfree( pFilename );
      return TRUE;
   }

   if( fFree )
      hb_xfree( pFilename );

   return FALSE;
}
file.c56
HB_EXPORT BOOLhb_fsIsDirectory( BYTE * pFilename )
HB_EXPORT BOOL hb_fsIsDirectory( BYTE * pFilename )
{
   BOOL bResult = FALSE, fFree;
   PHB_FFIND ffind;
   int iLen;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsIsDirectory(%s)", ( char * ) pFilename));

   pFilename = hb_fsNameConv( pFilename, &fFree );

   iLen = strlen( ( char * ) pFilename );
   while( iLen && strchr( HB_OS_PATH_DELIM_CHR_LIST, pFilename[ iLen - 1 ] ) )
      --iLen;

   if( pFilename[ iLen ] )
   {
      if( fFree )
         pFilename[ iLen ] = '\0';
      else
      {
         pFilename = ( BYTE * ) hb_strndup( ( char * ) pFilename, iLen );
         fFree = TRUE;
      }
   }

   if( iLen && iLen <= _POSIX_PATH_MAX )
   {
      if( ( ffind = hb_fsFindFirst( ( char * ) pFilename, HB_FA_DIRECTORY ) ) != NULL )
      {
         if( ( ffind->attr & HB_FA_DIRECTORY ) == HB_FA_DIRECTORY )
            bResult = TRUE;
         hb_fsFindClose( ffind );
      }
   }

   if( fFree )
      hb_xfree( pFilename );

   return bResult;
}
file.c79
filebuf.c
TypeFunctionSourceLine
VOIDhb_fileDsp( PHB_FILE pFile, const char * szMsg )
void hb_fileDsp( PHB_FILE pFile, const char * szMsg )
{
   UINT uiPos = 0;
   printf( "\r\n[%s][", szMsg );
   while( uiPos < pFile->uiLocks )
   {
      PHB_FLOCK pLock = &pFile->pLocks[ uiPos ];
      printf( "%lld:%lld ", pLock->start, pLock->len );
      ++uiPos;
   }
   printf( "]" );
   fflush(stdout);
}
filebuf.c99
STATIC PHB_FILEhb_fileFind( ULONG device, ULONG inode )
static PHB_FILE hb_fileFind( ULONG device, ULONG inode )
{
   if( s_openFiles && ( device || inode ) )
   {
      PHB_FILE pFile = s_openFiles;
      do
      {
         if( pFile->device == device && pFile->inode == inode )
            return pFile;
         pFile = pFile->pNext;
      }
      while( s_openFiles != pFile );
   }
   return NULL;
}
filebuf.c113
STATIC PHB_FILEhb_fileNew( HB_FHANDLE hFile, BOOL fShared, ULONG device, ULONG inode, BOOL fBind )
static PHB_FILE hb_fileNew( HB_FHANDLE hFile, BOOL fShared,
                            ULONG device, ULONG inode, BOOL fBind )
{
   PHB_FILE pFile = hb_fileFind( device, inode );

   if( !pFile )
   {
      pFile = ( PHB_FILE ) hb_xgrab( sizeof( HB_FILE ) );
      memset( pFile, 0, sizeof( HB_FILE ) );
      pFile->device = device;
      pFile->inode  = inode;
      pFile->hFile  = hFile;
      pFile->shared = fShared;

      if( fBind )
      {
         if( s_openFiles )
         {
            pFile->pNext = s_openFiles;
            pFile->pPrev = s_openFiles->pPrev;
            pFile->pPrev->pNext = pFile;
            s_openFiles->pPrev = pFile;
         }
         else
            s_openFiles = pFile->pNext = pFile->pPrev = pFile;
      }
   }
   pFile->used++;

   return pFile;
}
filebuf.c129
STATIC UINThb_fileFindOffset( PHB_FILE pFile, HB_FOFFSET ulOffset )
static UINT hb_fileFindOffset( PHB_FILE pFile, HB_FOFFSET ulOffset )
{
   UINT uiFirst, uiLast, uiMiddle;

   uiFirst = 0;
   uiLast = pFile->uiLocks;
   uiMiddle = uiLast >> 1;

   while( uiFirst < uiLast )
   {
      HB_FOFFSET ulEnd = pFile->pLocks[ uiMiddle ].start +
                         pFile->pLocks[ uiMiddle ].len;
      if( ulEnd <= ulOffset )
         uiFirst = uiMiddle + 1;
      else
         uiLast = uiMiddle;
      uiMiddle = ( uiFirst + uiLast ) >> 1;
   }

   return uiMiddle;
}
filebuf.c161
STATIC VOIDhb_fileInsertLock( PHB_FILE pFile, UINT uiPos, HB_FOFFSET ulStart, HB_FOFFSET ulLen )
static void hb_fileInsertLock( PHB_FILE pFile, UINT uiPos,
                               HB_FOFFSET ulStart, HB_FOFFSET ulLen )
{
   if( pFile->uiLocks == pFile->uiSize )
   {
      pFile->uiSize += HB_FLOCK_RESIZE;
      pFile->pLocks = ( PHB_FLOCK ) hb_xrealloc( pFile->pLocks,
                                          sizeof( HB_FLOCK ) * pFile->uiSize );
      memset( &pFile->pLocks[ pFile->uiLocks ], 0,
              sizeof( HB_FLOCK ) * HB_FLOCK_RESIZE );
   }
   pFile->uiLocks++;
   memmove( &pFile->pLocks[ uiPos + 1 ], &pFile->pLocks[ uiPos ],
            ( pFile->uiLocks - uiPos ) * sizeof( HB_FLOCK ) );
   pFile->pLocks[ uiPos ].start = ulStart;
   pFile->pLocks[ uiPos ].len   = ulLen;
}
filebuf.c183
STATIC VOIDhb_fileDeleteLock( PHB_FILE pFile, UINT uiPos )
static void hb_fileDeleteLock( PHB_FILE pFile, UINT uiPos )
{
   pFile->uiLocks--;
   memmove( &pFile->pLocks[ uiPos ], &pFile->pLocks[ uiPos + 1 ],
            ( pFile->uiLocks - uiPos ) * sizeof( HB_FLOCK ) );
   if( pFile->uiSize - pFile->uiLocks >= ( HB_FLOCK_RESIZE << 1 ) )
   {
      pFile->uiSize -= HB_FLOCK_RESIZE;
      pFile->pLocks = ( PHB_FLOCK ) hb_xrealloc( pFile->pLocks,
                                          sizeof( HB_FLOCK ) * pFile->uiSize );
   }
}
filebuf.c201
STATIC BOOLhb_fileSetLock( PHB_FILE pFile, BOOL * pfLockFS, HB_FOFFSET ulStart, HB_FOFFSET ulLen )
static BOOL hb_fileSetLock( PHB_FILE pFile, BOOL * pfLockFS,
                            HB_FOFFSET ulStart, HB_FOFFSET ulLen )
{
   BOOL fLJoin, fRJoin;
   UINT uiPos;

   uiPos = hb_fileFindOffset( pFile, ulStart );
   fLJoin = fRJoin = FALSE;
   if( uiPos < pFile->uiLocks )
   {
      PHB_FLOCK pLock = &pFile->pLocks[ uiPos ];
      if( ulStart + ulLen > pLock->start )
         return FALSE;
      if( ulStart + ulLen == pLock->start )
         fRJoin = TRUE;
   }
   if( uiPos > 0 )
   {
      PHB_FLOCK pLock = &pFile->pLocks[ uiPos - 1 ];
      if( pLock->start + pLock->len == ulStart )
         fLJoin = TRUE;
   }
   if( fLJoin )
   {
      if( fRJoin )
      {
         pFile->pLocks[ uiPos - 1 ].len += ulLen + pFile->pLocks[ uiPos ].len;
         hb_fileDeleteLock( pFile, uiPos );
      }
      else
         pFile->pLocks[ uiPos - 1 ].len += ulLen;
   }
   else if( fRJoin )
   {
      pFile->pLocks[ uiPos ].start -= ulLen;
      pFile->pLocks[ uiPos ].len   += ulLen;
   }
   else
      hb_fileInsertLock( pFile, uiPos, ulStart, ulLen );

   if( pFile->shared )
      * pfLockFS = TRUE;
   return TRUE;
}
filebuf.c214
STATIC BOOLhb_fileUnlock( PHB_FILE pFile, BOOL * pfLockFS, HB_FOFFSET ulStart, HB_FOFFSET ulLen )
static BOOL hb_fileUnlock( PHB_FILE pFile, BOOL * pfLockFS,
                           HB_FOFFSET ulStart, HB_FOFFSET ulLen )
{
   BOOL fResult = FALSE;
   UINT uiPos;

   uiPos = hb_fileFindOffset( pFile, ulStart );
   if( uiPos < pFile->uiLocks )
   {
      PHB_FLOCK pLock = &pFile->pLocks[ uiPos ];
      if( ulStart >= pLock->start &&
          ulStart + ulLen <= pLock->start + pLock->len )
      {
         if( ulStart == pLock->start )
         {
            if( ulLen == pLock->len )
               hb_fileDeleteLock( pFile, uiPos );
            else
            {
               pLock->start += ulLen;
               pLock->len   -= ulLen;
            }
         }
         else if( ulStart + ulLen == pLock->start + pLock->len )
            pLock->len -= ulLen;
         else
         {
            hb_fileInsertLock( pFile, uiPos + 1, ulStart + ulLen,
                               pLock->start + pLock->len - ulStart - ulLen );
            pLock->len = ulStart - pLock->start;
         }
         if( pFile->shared )
            * pfLockFS = TRUE;
         fResult = TRUE;
      }
   }
   return fResult;
}
filebuf.c259
PHB_FILEhb_fileExtOpen( BYTE * pFilename, BYTE * pDefExt, USHORT uiExFlags, BYTE * pPaths, PHB_ITEM pError )
PHB_FILE hb_fileExtOpen( BYTE * pFilename, BYTE * pDefExt,
                         USHORT uiExFlags, BYTE * pPaths,
                         PHB_ITEM pError )
{
   PHB_FILE pFile = NULL;
#if defined( HB_OS_UNIX )
   struct stat statbuf;
   BOOL fResult;
#endif
   BOOL fShared;
   HB_FHANDLE hFile;
   BYTE * pszFile;

   fShared = ( uiExFlags & ( FO_DENYREAD | FO_DENYWRITE | FO_EXCLUSIVE ) ) == 0;
   pszFile = hb_fsExtName( pFilename, pDefExt, uiExFlags, pPaths );

#if defined( HB_OS_UNIX )
   hb_vmUnlock();
   fResult = stat( ( char * ) pszFile, &statbuf ) == 0;
   hb_fsSetIOError( fResult, 0 );
   hb_vmLock();

   if( fResult )
   {

      hb_threadEnterCriticalSection( &s_fileMtx );
      pFile = hb_fileFind( statbuf.st_dev, statbuf.st_ino );
      if( pFile )
      {
         if( !fShared || ! pFile->shared || ( uiExFlags & FXO_TRUNCATE ) != 0 )
            fResult = FALSE;
         else
            pFile->used++;
      }
      hb_threadLeaveCriticalSection( &s_fileMtx );
   }

   if( pFile )
   {
      if( !fResult )
      {
         hb_fsSetError( ( uiExFlags & FXO_TRUNCATE ) ? 5 : 32 );
         pFile = NULL;
      }
      else if( uiExFlags & FXO_COPYNAME )
         hb_strncpy( ( char * ) pFilename, ( char * ) pszFile, _POSIX_PATH_MAX );

      if( pError )
      {
         hb_errPutFileName( pError, ( char * ) pszFile );
         if( !fResult )
         {
            hb_errPutOsCode( pError, hb_fsError() );
            hb_errPutGenCode( pError, ( USHORT ) ( ( uiExFlags & FXO_TRUNCATE ) ? EG_CREATE : EG_OPEN ) );
         }
      }
   }
   else
#endif
   {
      hFile = hb_fsExtOpen( pFilename, pDefExt, uiExFlags, pPaths, pError );
      if( hFile != FS_ERROR )
      {
         ULONG device = 0, inode = 0;
#if defined( HB_OS_UNIX )
         hb_vmUnlock();
         if( fstat( hFile, &statbuf ) == 0 )
         {
            device = ( ULONG ) statbuf.st_dev;
            inode  = ( ULONG ) statbuf.st_ino;
         }
         hb_fsSetIOError( fResult, 0 );
         hb_vmLock();
#endif

         hb_threadEnterCriticalSection( &s_fileMtx );
         pFile = hb_fileNew( hFile, fShared, device, inode, TRUE );
         hb_threadLeaveCriticalSection( &s_fileMtx );

         if( pFile->hFile != hFile )
            hb_fsClose( hFile );
      }
   }
   hb_xfree( pszFile );

   return pFile;
}
filebuf.c302
VOIDhb_fileClose( PHB_FILE pFile )
void hb_fileClose( PHB_FILE pFile )
{
   HB_FHANDLE hFile = FS_ERROR;

   hb_threadEnterCriticalSection( &s_fileMtx );

   if( --pFile->used == 0 )
   {
      if( pFile->pNext )
      {
         pFile->pPrev->pNext = pFile->pNext;
         pFile->pNext->pPrev = pFile->pPrev;
         if( pFile == s_openFiles )
         {
            s_openFiles = pFile->pNext;
            if( pFile == s_openFiles )
               s_openFiles = NULL;
         }
      }

      hFile = pFile->hFile;

      if( pFile->pLocks )
         hb_xfree( pFile->pLocks );

      hb_xfree( pFile );
   }

   hb_threadLeaveCriticalSection( &s_fileMtx );

   if( hFile != FS_ERROR )
      hb_fsClose( hFile );
}
filebuf.c390
BOOLhb_fileLock( PHB_FILE pFile, HB_FOFFSET ulStart, HB_FOFFSET ulLen, int iType )
BOOL hb_fileLock( PHB_FILE pFile, HB_FOFFSET ulStart, HB_FOFFSET ulLen,
                  int iType )
{
   BOOL fResult, fLockFS = FALSE;

   if( ( iType & FL_MASK ) == FL_UNLOCK )
   {
      hb_threadEnterCriticalSection( &s_fileMtx );
      fResult = hb_fileUnlock( pFile, &fLockFS, ulStart, ulLen );
      hb_threadLeaveCriticalSection( &s_fileMtx );
      if( fLockFS )
         hb_fsLockLarge( pFile->hFile, ulStart, ulLen, iType );
   }
   else
   {
      hb_threadEnterCriticalSection( &s_fileMtx );
      fResult = hb_fileSetLock( pFile, &fLockFS, ulStart, ulLen );
      hb_threadLeaveCriticalSection( &s_fileMtx );
      if( fLockFS )
      {
         fResult = hb_fsLockLarge( pFile->hFile, ulStart, ulLen, iType );
         if( !fResult )
         {
            hb_threadEnterCriticalSection( &s_fileMtx );
            hb_fileUnlock( pFile, &fLockFS, ulStart, ulLen );
            hb_threadLeaveCriticalSection( &s_fileMtx );
         }
      }
   }

   return fResult;
}
filebuf.c424
ULONGhb_fileReadAt( PHB_FILE pFile, BYTE * buffer, ULONG ulSize, HB_FOFFSET llOffset )
ULONG hb_fileReadAt( PHB_FILE pFile, BYTE * buffer, ULONG ulSize,
                     HB_FOFFSET llOffset )
{
   return hb_fsReadAt( pFile->hFile, buffer, ulSize, llOffset );
}
filebuf.c457
ULONGhb_fileWriteAt( PHB_FILE pFile, const BYTE * buffer, ULONG ulSize, HB_FOFFSET llOffset )
ULONG hb_fileWriteAt( PHB_FILE pFile, const BYTE * buffer, ULONG ulSize,
                      HB_FOFFSET llOffset )
{
   return hb_fsWriteAt( pFile->hFile, buffer, ulSize, llOffset );
}
filebuf.c463
BOOLhb_fileTruncAt( PHB_FILE pFile, HB_FOFFSET llOffset )
BOOL hb_fileTruncAt( PHB_FILE pFile, HB_FOFFSET llOffset )
{
   return hb_fsTruncAt( pFile->hFile, llOffset );
}
filebuf.c469
HB_FOFFSEThb_fileSize( PHB_FILE pFile )
HB_FOFFSET hb_fileSize( PHB_FILE pFile )
{
   return hb_fsSeekLarge( pFile->hFile, 0, FS_END );
}
filebuf.c474
VOIDhb_fileCommit( PHB_FILE pFile )
void hb_fileCommit( PHB_FILE pFile )
{
   hb_fsCommit( pFile->hFile );
}
filebuf.c479
HB_FHANDLEhb_fileHandle( PHB_FILE pFile )
HB_FHANDLE hb_fileHandle( PHB_FILE pFile )
{
   return pFile ? pFile->hFile : FS_ERROR;
}
filebuf.c484
PHB_FILEhb_fileCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName )
PHB_FILE hb_fileCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix,
                            ULONG ulAttr, BYTE * pszName )
{
   PHB_FILE pFile = NULL;
   HB_FHANDLE hFile;

   hFile = hb_fsCreateTemp( pszDir, pszPrefix, ulAttr, pszName );
   if( hFile != FS_ERROR )
      pFile = hb_fileNew( hFile, FALSE, 0, 0, FALSE );

   return pFile;
}
filebuf.c489
filehb.c
TypeFunctionSourceLine
HB_FUNCFILE(void)
HB_FUNC( FILE )
{
   BYTE * szFile = ( BYTE * ) hb_parc( 1 );

   hb_retl( szFile ? hb_spFile( szFile, NULL ) : FALSE );
}
filehb.c67
filesys.c
TypeFunctionSourceLine
STATIC HANDLEDosToWinHandle( HB_FHANDLE fHandle )
static HANDLE DosToWinHandle( HB_FHANDLE fHandle )
{
   if( fHandle == ( HB_FHANDLE ) 0 )
      return GetStdHandle( STD_INPUT_HANDLE );

   else if( fHandle == ( HB_FHANDLE ) 1 )
      return GetStdHandle( STD_OUTPUT_HANDLE );

   else if( fHandle == ( HB_FHANDLE ) 2 )
      return GetStdHandle( STD_ERROR_HANDLE) ;

   else
      return ( HANDLE ) fHandle;
}
filesys.c311
STATIC VOIDconvert_open_flags( BOOL fCreate, ULONG ulAttr, USHORT uiFlags, DWORD *dwMode, DWORD *dwShare, DWORD *dwCreat, DWORD *dwAttr )
static void convert_open_flags( BOOL fCreate, ULONG ulAttr, USHORT uiFlags,
                                DWORD *dwMode, DWORD *dwShare,
                                DWORD *dwCreat, DWORD *dwAttr )
{
   if( fCreate )
   {
      *dwCreat = CREATE_ALWAYS;
      *dwMode = GENERIC_READ | GENERIC_WRITE;
   }
   else
   {
      if( uiFlags & FO_CREAT )
      {
         if( uiFlags & FO_EXCL )
            *dwCreat = CREATE_NEW;
         else if( uiFlags & FO_TRUNC )
            *dwCreat = CREATE_ALWAYS;
         else
            *dwCreat = OPEN_ALWAYS;
      }
      else if( uiFlags & FO_TRUNC )
      {
         *dwCreat = TRUNCATE_EXISTING;
      }
      else
      {
         *dwCreat = OPEN_EXISTING;
      }

      *dwMode = 0;
      switch( uiFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) )
      {
         case FO_READWRITE:
            *dwMode |= GENERIC_READ | GENERIC_WRITE;
            break;
         case FO_WRITE:
            *dwMode |= GENERIC_WRITE;
            break;
         case FO_READ:
            *dwMode |= GENERIC_READ;
            break;
      }
   }

   /* shared flags */
   switch( uiFlags & ( FO_DENYREAD | FO_DENYWRITE | FO_EXCLUSIVE | FO_DENYNONE ) )
   {
      case FO_DENYREAD:
         *dwShare = FILE_SHARE_WRITE;
         break;
      case FO_DENYWRITE:
         *dwShare = FILE_SHARE_READ;
         break;
      case FO_EXCLUSIVE:
         *dwShare = 0;
         break;
      default:
         *dwShare = FILE_SHARE_WRITE | FILE_SHARE_READ;
         break;
   }

   /* file attributes flags */
   if( ulAttr == FC_NORMAL )
   {
      *dwAttr = FILE_ATTRIBUTE_NORMAL;
   }
   else
   {
      *dwAttr = FILE_ATTRIBUTE_ARCHIVE;
      if( ulAttr & FC_READONLY )
         *dwAttr |= FILE_ATTRIBUTE_READONLY;
      if( ulAttr & FC_HIDDEN )
         *dwAttr |= FILE_ATTRIBUTE_HIDDEN;
      if( ulAttr & FC_SYSTEM )
         *dwAttr |= FILE_ATTRIBUTE_SYSTEM;
   }
}
filesys.c326
STATIC VOIDconvert_open_flags( BOOL fCreate, ULONG ulAttr, USHORT uiFlags, int *flags, unsigned *mode, int *share, int *attr )
static void convert_open_flags( BOOL fCreate, ULONG ulAttr, USHORT uiFlags,
                                int *flags, unsigned *mode,
                                int *share, int *attr )
{
   HB_TRACE(HB_TR_DEBUG, ("convert_open_flags(%d, %lu, %hu, %p, %p, %p, %p)", fCreate, ulAttr, uiFlags, flags, mode, share, attr));

   /* file access mode */
#if defined( HB_OS_UNIX )
   *mode = HB_FA_POSIX_ATTR( ulAttr );
   if( *mode == 0 )
   {
      *mode = ( ulAttr & FC_HIDDEN ) ? S_IRUSR : ( S_IRUSR | S_IRGRP | S_IROTH );
      if( !( ulAttr & FC_READONLY ) )
      {
         if( *mode & S_IRUSR ) *mode |= S_IWUSR;
         if( *mode & S_IRGRP ) *mode |= S_IWGRP;
         if( *mode & S_IROTH ) *mode |= S_IWOTH;
      }
      if( ulAttr & FC_SYSTEM )
      {
         if( *mode & S_IRUSR ) *mode |= S_IXUSR;
         if( *mode & S_IRGRP ) *mode |= S_IXGRP;
         if( *mode & S_IROTH ) *mode |= S_IXOTH;
      }
   }
#else
   *mode = S_IREAD |
           ( ( ulAttr & FC_READONLY ) ? 0 : S_IWRITE ) |
           ( ( ulAttr & FC_SYSTEM ) ? S_IEXEC : 0 );
#endif

   /* dos file attributes */
#if defined( HB_FS_DOSATTR )
   if( ulAttr == FC_NORMAL )
   {
      *attr = _A_NORMAL;
   }
   else
   {
      *attr = _A_ARCH;
      if( ulAttr & FC_READONLY )
         *attr |= _A_READONLY;
      if( ulAttr & FC_HIDDEN )
         *attr |= _A_HIDDEN;
      if( ulAttr & FC_SYSTEM )
         *attr |= _A_SYSTEM;
   }
#else
   *attr = 0;
#endif

   if( fCreate )
   {
      *flags = O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE |
               ( ( uiFlags & FO_EXCL ) ? O_EXCL : 0 );
   }
   else
   {
      *attr = 0;
      *flags = O_BINARY | O_LARGEFILE;
      switch( uiFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) )
      {
         case FO_READ:
            *flags |= O_RDONLY;
            break;
         case FO_WRITE:
            *flags |= O_WRONLY;
            break;
         case FO_READWRITE:
            *flags |= O_RDWR;
            break;
         default:
            /* this should not happen and it's here to force default OS behavior */
            *flags |= ( O_RDONLY | O_WRONLY | O_RDWR );
            break;
      }

      if( uiFlags & FO_CREAT ) *flags |= O_CREAT;
      if( uiFlags & FO_TRUNC ) *flags |= O_TRUNC;
      if( uiFlags & FO_EXCL  ) *flags |= O_EXCL;
   }

   /* shared flags (HB_FS_SOPEN) */
#if defined( _MSC_VER ) || defined( __DMC__ )
   if( ( uiFlags & FO_DENYREAD ) == FO_DENYREAD )
      *share = _SH_DENYRD;
   else if( uiFlags & FO_EXCLUSIVE )
      *share = _SH_DENYRW;
   else if( uiFlags & FO_DENYWRITE )
      *share = _SH_DENYWR;
   else if( uiFlags & FO_DENYNONE )
      *share = _SH_DENYNO;
   else
      *share = _SH_COMPAT;
#elif !defined( HB_OS_UNIX )
   if( ( uiFlags & FO_DENYREAD ) == FO_DENYREAD )
      *share = SH_DENYRD;
   else if( uiFlags & FO_EXCLUSIVE )
      *share = SH_DENYRW;
   else if( uiFlags & FO_DENYWRITE )
      *share = SH_DENYWR;
   else if( uiFlags & FO_DENYNONE )
      *share = SH_DENYNO;
   else
      *share = SH_COMPAT;
#else
   *share = 0;
#endif

   HB_TRACE(HB_TR_INFO, ("convert_open_flags: flags=0x%04x, mode=0x%04x, share=0x%04x, attr=0x%04x", *flags, *mode, *share, *attr));

}
filesys.c406
STATIC USHORTconvert_seek_flags( USHORT uiFlags )
static USHORT convert_seek_flags( USHORT uiFlags )
{
   /* by default FS_SET is set */
   USHORT result_flags = SEEK_SET;

   HB_TRACE(HB_TR_DEBUG, ("convert_seek_flags(%hu)", uiFlags));

   if( uiFlags & FS_RELATIVE )
      result_flags = SEEK_CUR;

   if( uiFlags & FS_END )
      result_flags = SEEK_END;

   return result_flags;
}
filesys.c520
HB_EXPORT HB_FHANDLEhb_fsGetOsHandle( HB_FHANDLE hFileHandle )
HB_EXPORT HB_FHANDLE hb_fsGetOsHandle( HB_FHANDLE hFileHandle )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsGetOsHandle(%p)", hFileHandle));

#if defined(HB_WIN32_IO)
   return ( HB_FHANDLE ) DosToWinHandle( hFileHandle );
#else
   return hFileHandle;
#endif
}
filesys.c543
HB_EXPORT HB_FHANDLEhb_fsPOpen( BYTE * pFilename, BYTE * pMode )
HB_EXPORT HB_FHANDLE hb_fsPOpen( BYTE * pFilename, BYTE * pMode )
{
   HB_FHANDLE hFileHandle = FS_ERROR;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsPOpen(%p, %s)", pFilename, pMode));

#if defined(HB_OS_UNIX_COMPATIBLE) && !defined(__CYGWIN__)
   {
      HB_FHANDLE hPipeHandle[2], hNullHandle;
      pid_t pid;
      BYTE * pbyTmp;
      BOOL bRead;
      ULONG ulLen;
      int iMaxFD;

      ulLen = strlen( ( char * ) pFilename );
      if( pMode && ( *pMode == 'r' || *pMode == 'w' ) )
         bRead = ( *pMode == 'r' );
      else
      {
         if( pFilename[0] == '|' )
            bRead = FALSE;
         else if( pFilename[ ulLen - 1 ] == '|' )
            bRead = TRUE;
         else
            bRead = FALSE;
      }

      if( pFilename[0] == '|' )
      {
          ++pFilename;
          --ulLen;
      }
      if( pFilename[ ulLen - 1 ] == '|' )
      {
          pbyTmp = ( BYTE * ) hb_strdup( ( char * ) pFilename );
          pbyTmp[--ulLen] = 0;
          pFilename = pbyTmp;
      } else
          pbyTmp = NULL;

      hb_vmUnlock();
      if( pipe( hPipeHandle ) == 0 ) {
         if( ( pid = fork() ) != -1 ) {
            if( pid != 0 ) {
               if( bRead ) {
                  close( hPipeHandle[ 1 ] );
                  hFileHandle = hPipeHandle[ 0 ];
               } else {
                  close( hPipeHandle[ 0 ] );
                  hFileHandle = hPipeHandle[ 1 ];
               }
            } else {
               char * argv[4];
               argv[0] = ( char * ) "sh";
               argv[1] = ( char * ) "-c";
               argv[2] = ( char * ) pFilename;
               argv[3] = ( char * ) 0;
               hNullHandle = open( "/dev/null", O_RDWR );
               if( bRead ) {
                  close( hPipeHandle[ 0 ] );
                  dup2( hPipeHandle[ 1 ], 1 );
                  dup2( hNullHandle, 0 );
                  dup2( hNullHandle, 2 );
               } else {
                  close( hPipeHandle[ 1 ] );
                  dup2( hPipeHandle[ 0 ], 0 );
                  dup2( hNullHandle, 1 );
                  dup2( hNullHandle, 2 );
               }
               iMaxFD = sysconf( _SC_OPEN_MAX );
               if( iMaxFD < 3 )
                  iMaxFD = 1024;
               for( hNullHandle = 3; hNullHandle < iMaxFD; ++hNullHandle )
                  close( hNullHandle );
               setuid( getuid() );
               setgid( getgid() );
               execve( "/bin/sh", argv, environ );
               exit(1);
            }
         }
         else
         {
            close( hPipeHandle[0] );
            close( hPipeHandle[1] );
         }
      }
      hb_fsSetIOError( hFileHandle != FS_ERROR, 0 );
      hb_vmLock();

      if( pbyTmp )
         hb_xfree( pbyTmp );
   }
#else

   HB_SYMBOL_UNUSED( pFilename );
   HB_SYMBOL_UNUSED( pMode );

   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return hFileHandle;
}
filesys.c554
HB_EXPORT HB_FHANDLEhb_fsOpen( BYTE * pFilename, USHORT uiFlags )
HB_EXPORT HB_FHANDLE hb_fsOpen( BYTE * pFilename, USHORT uiFlags )
{
   HB_FHANDLE hFileHandle;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsOpen(%p, %hu)", pFilename, uiFlags));

   pFilename = hb_fsNameConv( pFilename, &fFree );

#if defined(HB_WIN32_IO)
   {
      DWORD dwMode, dwShare, dwCreat, dwAttr;
      HANDLE hFile;

      convert_open_flags( FALSE, FC_NORMAL, uiFlags, &dwMode, &dwShare, &dwCreat, &dwAttr );

      hb_vmUnlock();
      hFile = ( HANDLE ) CreateFileA( ( char * ) pFilename, dwMode, dwShare,
                                      NULL, dwCreat, dwAttr, NULL );
      hb_fsSetIOError( hFile != ( HANDLE ) INVALID_HANDLE_VALUE, 0 );
      hb_vmLock();

      hFileHandle = ( HB_FHANDLE ) hFile;
   }
#elif defined(HB_FS_FILE_IO)
   {
      int flags, share, attr;
      unsigned mode;

      convert_open_flags( FALSE, FC_NORMAL, uiFlags, &flags, &mode, &share, &attr );
      hb_vmUnlock();
#if defined(_MSC_VER) || defined(__DMC__)
      if( share )
         hFileHandle = _sopen( ( char * ) pFilename, flags, share, mode );
      else
         hFileHandle = _open( ( char * ) pFilename, flags, mode );
#elif defined(HB_FS_SOPEN)
      if( share )
         hFileHandle = sopen( ( char * ) pFilename, flags, share, mode );
      else
         hFileHandle = open( ( char * ) pFilename, flags, mode );
#else
      hFileHandle = open( ( char * ) pFilename, flags | share, mode );
#endif
      hb_fsSetIOError( hFileHandle != FS_ERROR, 0 );
      hb_vmLock();
   }
#else

   hFileHandle = FS_ERROR;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   if( fFree )
      hb_xfree( pFilename );

   return hFileHandle;
}
filesys.c659
HB_EXPORT HB_FHANDLEhb_fsCreate( BYTE * pFilename, ULONG ulAttr )
HB_EXPORT HB_FHANDLE hb_fsCreate( BYTE * pFilename, ULONG ulAttr )
{
   HB_FHANDLE hFileHandle;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsCreate(%p, %lu)", pFilename, ulAttr));

   pFilename = hb_fsNameConv( pFilename, &fFree );

#if defined(HB_WIN32_IO)
   {
      DWORD dwMode, dwShare, dwCreat, dwAttr;
      HANDLE hFile;

      convert_open_flags( TRUE, ulAttr, FO_EXCLUSIVE, &dwMode, &dwShare, &dwCreat, &dwAttr );

      hb_vmUnlock();
      hFile = ( HANDLE ) CreateFileA( ( char * ) pFilename, dwMode, dwShare,
                                      NULL, dwCreat, dwAttr, NULL );
      hb_fsSetIOError( hFile != ( HANDLE ) INVALID_HANDLE_VALUE, 0 );
      hb_vmLock();

      hFileHandle = ( HB_FHANDLE ) hFile;
   }
#elif defined(HB_FS_FILE_IO)
   {
      int flags, share, attr;
      unsigned mode;
      convert_open_flags( TRUE, ulAttr, FO_EXCLUSIVE, &flags, &mode, &share, &attr );

      hb_vmUnlock();
#if defined(HB_FS_DOSCREAT)
      hFileHandle = _creat( ( char * ) pFilename, attr );
#elif defined(HB_FS_SOPEN)
      hFileHandle = open( ( char * ) pFilename, flags, mode );
#else
      hFileHandle = open( ( char * ) pFilename, flags | share, mode );
#endif
      hb_fsSetIOError( hFileHandle != FS_ERROR, 0 );
      hb_vmLock();
   }
#else

   hFileHandle = FS_ERROR;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   if( fFree )
      hb_xfree( pFilename );

   return hFileHandle;
}
filesys.c719
HB_EXPORT HB_FHANDLEhb_fsCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags )
HB_EXPORT HB_FHANDLE hb_fsCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags )
{
   HB_FHANDLE hFileHandle;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsCreateEx(%p, %lu, %hu)", pFilename, ulAttr, uiFlags));

   pFilename = hb_fsNameConv( pFilename, &fFree );

#if defined( HB_WIN32_IO )
   {
      DWORD dwMode, dwShare, dwCreat, dwAttr;
      HANDLE hFile;

      convert_open_flags( TRUE, ulAttr, uiFlags, &dwMode, &dwShare, &dwCreat, &dwAttr );

      hb_vmUnlock();
      hFile = ( HANDLE ) CreateFileA( ( char * ) pFilename, dwMode, dwShare,
                                      NULL, dwCreat, dwAttr, NULL );
      hb_fsSetIOError( hFile != ( HANDLE ) INVALID_HANDLE_VALUE, 0 );
      hb_vmLock();

      hFileHandle = ( HB_FHANDLE ) hFile;
   }
#elif defined(HB_FS_FILE_IO)
   {
      int flags, share, attr;
      unsigned mode;
      convert_open_flags( TRUE, ulAttr, uiFlags, &flags, &mode, &share, &attr );

      hb_vmUnlock();
#if defined(HB_FS_SOPEN)
      hFileHandle = open( ( char * ) pFilename, flags, mode );
#else
      hFileHandle = open( ( char * ) pFilename, flags | share, mode );
#endif
      hb_fsSetIOError( hFileHandle != FS_ERROR, 0 );
      hb_vmLock();
   }
#else

   hFileHandle = FS_ERROR;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   if( fFree )
      hb_xfree( pFilename );

   return hFileHandle;
}
filesys.c779
HB_EXPORT VOIDhb_fsClose( HB_FHANDLE hFileHandle )
HB_EXPORT void hb_fsClose( HB_FHANDLE hFileHandle )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsClose(%p)", hFileHandle));

#if defined(HB_FS_FILE_IO)

   hb_vmUnlock();
   #if defined(HB_WIN32_IO)
      hb_fsSetIOError( CloseHandle( DosToWinHandle( hFileHandle ) ), 0 );
   #else
      hb_fsSetIOError( close( hFileHandle ) == 0, 0 );
   #endif
   hb_vmLock();

#else

   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif
}
filesys.c831
HB_EXPORT BOOLhb_fsSetDevMode( HB_FHANDLE hFileHandle, USHORT uiDevMode )
HB_EXPORT BOOL hb_fsSetDevMode( HB_FHANDLE hFileHandle, USHORT uiDevMode )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsSetDevMode(%p, %hu)", hFileHandle, uiDevMode));

   /* TODO: HB_WIN32_IO support */

#if defined(__BORLANDC__) || defined(__IBMCPP__) || defined(__DJGPP__) || \
    defined(__CYGWIN__) || defined(__WATCOMC__) || defined(HB_OS_OS2)
{
   int iRet = 0;

#if defined(HB_WIN32_IO)
   if( hFileHandle > 2 )
      iRet = -1;
   else
#endif
   switch( uiDevMode )
   {
      case FD_BINARY:
         iRet = setmode( hFileHandle, O_BINARY );
         break;

      case FD_TEXT:
         iRet = setmode( hFileHandle, O_TEXT );
         break;
   }

   hb_fsSetIOError( iRet != -1, 0 );

   return iRet != -1;
}
#elif ( defined(_MSC_VER) || defined(__MINGW32__) || defined(__DMC__) ) && \
      !defined(HB_WINCE)
{
   int iRet = 0;

#if defined(HB_WIN32_IO)
   if( ( HB_NHANDLE ) hFileHandle > 2 )
      iRet = -1;
   else
#endif
   switch( uiDevMode )
   {
      case FD_BINARY:
         iRet = _setmode( ( HB_NHANDLE ) hFileHandle, _O_BINARY );
         break;

      case FD_TEXT:
         iRet = _setmode( ( HB_NHANDLE ) hFileHandle, _O_TEXT );
         break;
   }

   hb_fsSetIOError( iRet != -1, 0 );

   return iRet != -1;
}
#elif defined( HB_OS_UNIX ) || defined( HB_WINCE )

   HB_SYMBOL_UNUSED( hFileHandle );

   if( uiDevMode == FD_TEXT )
   {
      hb_fsSetError( ( USHORT ) FS_ERROR );
      return FALSE;
   }

   hb_fsSetError( 0 );
   return TRUE;

#else

   hb_fsSetError( ( USHORT ) FS_ERROR );
   return FALSE;

#endif
}
filesys.c852
HB_EXPORT BOOLhb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec )
HB_EXPORT BOOL hb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec )
{
   BOOL fResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsGetFileTime(%s, %p, %p)", pszFileName, plJulian, plMillisec));

   fResult = FALSE;

#if defined( HB_WIN32_IO )
   {
      HB_FHANDLE hFile = hb_fsOpen( pszFileName, FO_READ | FO_SHARED );

      if( hFile != FS_ERROR )
      {
         FILETIME ft, local_ft;
         SYSTEMTIME st;

         hb_vmUnlock();
         if( GetFileTime( DosToWinHandle( hFile ), NULL, NULL, &ft ) &&
             FileTimeToLocalFileTime( &ft, &local_ft ) &&
             FileTimeToSystemTime( &local_ft, &st ) )
         {
            *plJulian = hb_dateEncode( st.wYear, st.wMonth, st.wDay );
            *plMillisec = hb_timeStampEncode( st.wHour, st.wMinute, st.wSecond, st.wMilliseconds );

            fResult = TRUE;
         }
         hb_fsSetIOError( fResult, 0 );
         hb_vmLock();
         hb_fsClose( hFile );
      }
   }
#elif defined( HB_OS_UNIX ) || defined( HB_OS_OS2 ) || defined( HB_OS_DOS ) || defined( __GNUC__ )
   {
      struct stat sStat;
      BOOL fFree;

      pszFileName = hb_fsNameConv( pszFileName, &fFree );

      hb_vmUnlock();
      if( stat( ( char * ) pszFileName, &sStat ) == 0 )
      {
         time_t ftime;
         struct tm * ft;

         ftime = sStat.st_mtime;
         ft = localtime( &ftime );

         *plJulian = hb_dateEncode( ft->tm_year + 1900, ft->tm_mon + 1, ft->tm_mday );
         *plMillisec = hb_timeStampEncode( ft->tm_hour, ft->tm_min, ft->tm_sec, 0 );

         fResult = TRUE;
      }
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();

      if( fFree )
         hb_xfree( pszFileName );
   }
#else
   {
      int TODO; /* TODO: for given platform */

      HB_SYMBOL_UNUSED( pszFileName );
      HB_SYMBOL_UNUSED( plJulian );
      HB_SYMBOL_UNUSED( plMillisec );
   }
#endif

   return fResult;
}
filesys.c929
HB_EXPORT BOOLhb_fsGetAttr( BYTE * pszFileName, ULONG * pulAttr )
HB_EXPORT BOOL hb_fsGetAttr( BYTE * pszFileName, ULONG * pulAttr )
{
   BOOL fResult;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsGetAttr(%s, %p)", pszFileName, pulAttr));

   fResult = FALSE;
   pszFileName = hb_fsNameConv( pszFileName, &fFree );

#if defined( HB_OS_WIN_32 )
   {
      DWORD dwAttr;

      hb_vmUnlock();
      dwAttr = GetFileAttributesA( ( char * ) pszFileName );

      if( dwAttr != INVALID_FILE_ATTRIBUTES )
      {
         *pulAttr = hb_fsAttrFromRaw( dwAttr );
         fResult = TRUE;
      }
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
   }
#elif defined( HB_OS_DOS )
   hb_vmUnlock();
   {
#if defined( __DJGPP__ ) || defined(__BORLANDC__)
      int attr = _chmod( ( char * ) pszFileName, 0, 0 );
      if( attr != -1 )
#else
      unsigned int attr = 0;
      if( _dos_getfileattr( ( char * ) pszFileName, &attr ) == 0 )
#endif
      {
         *pulAttr = hb_fsAttrFromRaw( attr );
         fResult = TRUE;
      }
      hb_fsSetIOError( fResult, 0 );
   }
   hb_vmLock();
#elif defined( HB_OS_OS2 )
   {
      FILESTATUS3 fs3;
      APIRET ulrc;

      hb_vmUnlock();
      ulrc = DosQueryPathInfo( ( PSZ ) pszFileName, FIL_STANDARD, &fs3, sizeof( fs3 ) );
      if( ulrc == NO_ERROR )
      {
         *pulAttr = hb_fsAttrFromRaw( fs3.attrFile );
         fResult = TRUE;
      }
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
   }
#elif defined( HB_OS_UNIX )
   {
      struct stat sStat;

      hb_vmUnlock();
      if( stat( ( char * ) pszFileName, &sStat ) == 0 )
      {
         *pulAttr = hb_fsAttrFromRaw( sStat.st_mode );
         fResult = TRUE;
      }
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
   }
#else
   {
      int TODO; /* TODO: for given platform */

      HB_SYMBOL_UNUSED( pszFileName );
      HB_SYMBOL_UNUSED( pulAttr );
   }
#endif

   if( fFree )
      hb_xfree( pszFileName );

   return fResult;
}
filesys.c1001
HB_EXPORT BOOLhb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec )
HB_EXPORT BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec )
{
   BOOL fResult;
   int iYear, iMonth, iDay;
   int iHour, iMinute, iSecond, iMSec;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsSetFileTime(%s, %ld, %ld)", pszFileName, lJulian, lMillisec));

   hb_dateDecode( lJulian, &iYear, &iMonth, &iDay );
   hb_timeStampDecode( lMillisec, &iHour, &iMinute, &iSecond, &iMSec );

#if defined( HB_OS_WIN_32 ) && !defined( __CYGWIN__ )
   {
      HB_FHANDLE hFile = hb_fsOpen( pszFileName, FO_READWRITE | FO_SHARED );

      fResult = hFile != FS_ERROR;
      if( fResult )
      {
         FILETIME ft, local_ft;
         SYSTEMTIME st;

         hb_vmUnlock();
         if( lJulian <= 0 || lMillisec < 0 )
            GetLocalTime( &st );
         else
            memset( &st, 0, sizeof( st ) );

         if( lJulian > 0 )
         {
            st.wYear = ( WORD ) iYear;
            st.wMonth = ( WORD ) iMonth;
            st.wDay = ( WORD ) iDay;
         }
         if( lMillisec >= 0 )
         {
            st.wHour = ( WORD ) iHour;
            st.wMinute = ( WORD ) iMinute;
            st.wSecond = ( WORD ) iSecond;
            st.wMilliseconds = ( WORD ) iMSec;
         }
         SystemTimeToFileTime( &st, &local_ft );
         LocalFileTimeToFileTime( &local_ft, &ft );
         fResult = SetFileTime( DosToWinHandle( hFile ), NULL, &ft, &ft ) != 0;
         hb_fsSetIOError( fResult, 0 );
         hb_vmLock();
         hb_fsClose( hFile );
      }
   }
#elif defined( HB_OS_OS2 )
   {
      FILESTATUS3 fs3;
      APIRET ulrc;
      BOOL fFree;

      pszFileName = hb_fsNameConv( pszFileName, &fFree );

      hb_vmUnlock();
      ulrc = DosQueryPathInfo( ( PSZ ) pszFileName, FIL_STANDARD, &fs3, sizeof( fs3 ) );
      if( ulrc == NO_ERROR )
      {
         FDATE fdate;
         FTIME ftime;

         if( lJulian <= 0 || lMillisec < 0 )
         {
            DATETIME dt;

            DosGetDateTime( &dt );

            fdate.year = dt.year - 1980;
            fdate.month = dt.month;
            fdate.day = dt.day;
            ftime.hours = dt.hours;
            ftime.minutes = dt.minutes;
            ftime.twosecs = dt.seconds / 2;
         }
         if( lJulian > 0 )
         {
            fdate.year = iYear - 1980;
            fdate.month = iMonth;
            fdate.day = iDay;
         }
         if( lMillisec >= 0 )
         {
            ftime.hours = iHour;
            ftime.minutes = iMinute;
            ftime.twosecs = iSecond / 2;
         }

         fs3.fdateCreation = fs3.fdateLastAccess = fs3.fdateLastWrite = fdate;
         fs3.ftimeCreation = fs3.ftimeLastAccess = fs3.ftimeLastWrite = ftime;
         ulrc = DosSetPathInfo( ( PSZ ) pszFileName, FIL_STANDARD,
                                &fs3, sizeof( fs3 ), DSPI_WRTTHRU );
      }
      fResult = ulrc == NO_ERROR;
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
      if( fFree )
         hb_xfree( pszFileName );
   }
#elif defined( HB_OS_UNIX_COMPATIBLE ) || defined( HB_OS_DOS )
   {
      BOOL fFree;

      pszFileName = hb_fsNameConv( pszFileName, &fFree );

      hb_vmUnlock();
      if( lJulian <= 0 && lMillisec )
      {
         fResult = utime( ( char * ) pszFileName, NULL ) == 0;
      }
      else
      {
         struct utimbuf buf;
         struct tm new_value;
         time_t tim;

         if( lJulian <= 0 || lMillisec < 0 )
         {
            time_t current_time;

            current_time = time( NULL );
#   if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
            new_value = *localtime( ¤t_time );
#   else
            localtime_r( ¤t_time, &new_value );
#   endif
         }
         else
            memset( &new_value, 0, sizeof( new_value ) );

         if( lJulian > 0 )
         {
            new_value.tm_year = iYear - 1900;
            new_value.tm_mon = iMonth - 1;
            new_value.tm_mday = iDay;
         }
         if( lMillisec >= 0 )
         {
            new_value.tm_hour = iHour;
            new_value.tm_min = iMinute;
            new_value.tm_sec = iSecond;
         }
         tim = mktime( &new_value );
#   if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
         new_value = *gmtime( &tim );
#   else
         gmtime_r( &tim, &new_value );
#   endif
         buf.actime = buf.modtime = mktime( &new_value );
         fResult = utime( ( char * ) pszFileName, &buf ) == 0;
      }
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
      if( fFree )
         hb_xfree( pszFileName );
   }
#else
   {
      int TODO; /* To force warning */

      fResult = FALSE;
      hb_fsSetError( ( USHORT ) FS_ERROR );
   }
#endif

   return fResult;
}
filesys.c1086
HB_EXPORT BOOLhb_fsSetAttr( BYTE * pszFileName, ULONG ulAttr )
HB_EXPORT BOOL hb_fsSetAttr( BYTE * pszFileName, ULONG ulAttr )
{
   BOOL fResult;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsSetAttr(%s, %lu)", pszFileName, ulAttr));

   pszFileName = hb_fsNameConv( pszFileName, &fFree );

#if defined( HB_OS_WIN_32 )
   {
      DWORD dwFlags = FILE_ATTRIBUTE_ARCHIVE;

      if( ulAttr & HB_FA_READONLY )
         dwFlags |= FILE_ATTRIBUTE_READONLY;
      if( ulAttr & HB_FA_HIDDEN )
         dwFlags |= FILE_ATTRIBUTE_HIDDEN;
      if( ulAttr & HB_FA_SYSTEM )
         dwFlags |= FILE_ATTRIBUTE_SYSTEM;
      if( ulAttr & HB_FA_NORMAL )
         dwFlags |= FILE_ATTRIBUTE_NORMAL;
      hb_vmUnlock();
      fResult = SetFileAttributesA( ( char * ) pszFileName, dwFlags );
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
   }
#elif defined( HB_OS_OS2 )
   {
      FILESTATUS3 fs3;
      APIRET ulrc;
      ULONG ulOsAttr = FILE_NORMAL;

      if( ulAttr & HB_FA_READONLY )
         ulOsAttr |= FILE_READONLY;
      if( ulAttr & HB_FA_HIDDEN )
         ulOsAttr |= FILE_HIDDEN;
      if( ulAttr & HB_FA_SYSTEM )
         ulOsAttr |= FILE_SYSTEM;
      if( ulAttr & HB_FA_ARCHIVE )
         ulOsAttr |= FILE_ARCHIVED;

      hb_vmUnlock();
      ulrc = DosQueryPathInfo( ( PSZ ) pszFileName, FIL_STANDARD, &fs3, sizeof( fs3 ) );
      if( ulrc == NO_ERROR )
      {
         fs3.attrFile = ulOsAttr;
         ulrc = DosSetPathInfo( ( PSZ ) pszFileName, FIL_STANDARD,
                                &fs3, sizeof( fs3 ), DSPI_WRTTHRU );
      }
      fResult = ulrc == NO_ERROR;
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
   }
#elif defined( HB_OS_DOS )

   ulAttr &= ~( HB_FA_ARCHIVE | HB_FA_HIDDEN | HB_FA_READONLY | HB_FA_SYSTEM );
   hb_vmUnlock();
#  if defined( __DJGPP__ ) || defined( __BORLANDC__ )
   fResult = _chmod( ( char * ) pszFileName, 1, ulAttr ) != -1;
#  else
   fResult = _dos_setfileattr( ( char * ) pszFileName, ulAttr ) != -1;
#  endif
   hb_fsSetIOError( fResult, 0 );
   hb_vmLock();

#elif defined( HB_OS_UNIX_COMPATIBLE )
   {
      int iAttr = HB_FA_POSIX_ATTR( ulAttr );
      if( iAttr == 0 )
      {
         iAttr = ( ulAttr & HB_FA_HIDDEN ) ? S_IRUSR : ( S_IRUSR | S_IRGRP | S_IROTH );
         if( !( ulAttr & HB_FA_READONLY ) )
         {
            if( iAttr & S_IRUSR ) iAttr |= S_IWUSR;
            if( iAttr & S_IRGRP ) iAttr |= S_IWGRP;
            if( iAttr & S_IROTH ) iAttr |= S_IWOTH;
         }
         if( ulAttr & HB_FA_SYSTEM )
         {
            if( iAttr & S_IRUSR ) iAttr |= S_IXUSR;
            if( iAttr & S_IRGRP ) iAttr |= S_IXGRP;
            if( iAttr & S_IROTH ) iAttr |= S_IXOTH;
         }
      }
      hb_vmUnlock();
      fResult = chmod( ( char * ) pszFileName, iAttr ) != -1;
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
   }
#else
   {
      int TODO; /* To force warning */

      fResult = FALSE;
      hb_fsSetError( ( USHORT ) FS_ERROR );
   }
#endif

   if( fFree )
      hb_xfree( pszFileName );

   return fResult;
}
filesys.c1255
HB_EXPORT USHORThb_fsRead( HB_FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount )
HB_EXPORT USHORT hb_fsRead( HB_FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount )
{
   USHORT uiRead;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsRead(%p, %p, %hu)", hFileHandle, pBuff, uiCount));

#if defined(HB_FS_FILE_IO)

   #if defined(HB_WIN32_IO)
      {
         DWORD dwRead ;
         BOOL fResult;

         hb_vmUnlock();
         fResult = ReadFile( DosToWinHandle( hFileHandle ), pBuff, ( DWORD ) uiCount, &dwRead, NULL );
         hb_fsSetIOError( fResult, 0 );
         hb_vmLock();

         uiRead = fResult ? ( USHORT ) dwRead : 0;
      }
   #else
      hb_vmUnlock();
      uiRead = read( hFileHandle, pBuff, uiCount );
      hb_fsSetIOError( uiRead != ( USHORT ) -1, 0 );
      hb_vmLock();
   #endif

   if( uiRead == ( USHORT ) -1 )
      uiRead = 0;

#else

   uiRead = 0;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return uiRead;
}
filesys.c1359
HB_EXPORT USHORThb_fsWrite( HB_FHANDLE hFileHandle, const BYTE * pBuff, USHORT uiCount )
HB_EXPORT USHORT hb_fsWrite( HB_FHANDLE hFileHandle, const BYTE * pBuff, USHORT uiCount )
{
   USHORT uiWritten;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsWrite(%p, %p, %hu)", hFileHandle, pBuff, uiCount));

#if defined(HB_FS_FILE_IO)

   #if defined(HB_WIN32_IO)
      {
         DWORD dwWritten = 0;
         BOOL fResult;

         hb_vmUnlock();
         if( uiCount )
         {
             fResult = WriteFile( DosToWinHandle( hFileHandle ), pBuff, uiCount, &dwWritten, NULL );
         }
         else
         {
             dwWritten = 0;
             fResult = SetEndOfFile( DosToWinHandle( hFileHandle ) );
         }
         hb_fsSetIOError( fResult, 0 );
         hb_vmLock();

         uiWritten = fResult ? ( USHORT ) dwWritten : 0;
      }
   #else
      if( uiCount )
      {
         hb_vmUnlock();
         uiWritten = write( hFileHandle, pBuff, uiCount );
         hb_fsSetIOError( uiWritten != ( USHORT ) -1, 0 );
         if( uiWritten == ( USHORT ) -1 )
            uiWritten = 0;
         hb_vmLock();
      }
      else
      {
         hb_vmUnlock();
#if defined(HB_USE_LARGEFILE64)
         hb_fsSetIOError( ftruncate64( hFileHandle, lseek64( hFileHandle, 0L, SEEK_CUR ) ) != -1, 0 );
#else
         hb_fsSetIOError( ftruncate( hFileHandle, lseek( hFileHandle, 0L, SEEK_CUR ) ) != -1, 0 );
#endif
         uiWritten = 0;
         hb_vmLock();
      }
   #endif
#else

   uiWritten = 0;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return uiWritten;
}
filesys.c1399
HB_EXPORT ULONGhb_fsReadLarge( HB_FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount )
HB_EXPORT ULONG hb_fsReadLarge( HB_FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount )
{
   ULONG ulRead;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsReadLarge(%p, %p, %lu)", hFileHandle, pBuff, ulCount));

#if defined(HB_FS_FILE_IO)

   #if defined(HB_WIN32_IO)
   {
      hb_vmUnlock();
      hb_fsSetIOError( ReadFile( DosToWinHandle( hFileHandle ),
                                 pBuff, ulCount, &ulRead, NULL ), 0 );
      hb_vmLock();
   }
   #elif defined(HB_FS_LARGE_OPTIMIZED)
   {
      hb_vmUnlock();
      ulRead = read( hFileHandle, pBuff, ulCount );
      hb_fsSetIOError( ulRead != (ULONG) -1, 0 );
      if( ulRead == ( ULONG ) -1 )
         ulRead = 0;
      hb_vmLock();
   }
   #else
   {
      ULONG ulLeftToRead = ulCount;
      USHORT uiToRead;
      USHORT uiRead;
      BYTE * pPtr = pBuff;

      ulRead = 0;

      hb_vmUnlock();
      while( ulLeftToRead )
      {
         /* Determine how much to read this time */
         if( ulLeftToRead > ( ULONG ) INT_MAX )
         {
            uiToRead = INT_MAX;
            ulLeftToRead -= ( ULONG ) uiToRead;
         }
         else
         {
            uiToRead = ( USHORT ) ulLeftToRead;
            ulLeftToRead = 0;
         }

         uiRead = read( hFileHandle, pPtr, uiToRead );
         /* -1 on bad hFileHandle
             0 on disk full
          */

         if( uiRead == 0 )
            break;

         if( uiRead == ( USHORT ) -1 )
         {
            uiRead = 0;
            break;
         }

         ulRead += ( ULONG ) uiRead;
         pPtr += uiRead;
      }
      hb_fsSetIOError( ulLeftToRead == 0, 0 );
      hb_vmLock();
   }
   #endif

#else

   ulRead = 0;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return ulRead;
}
filesys.c1459
HB_EXPORT ULONGhb_fsWriteLarge( HB_FHANDLE hFileHandle, const BYTE * pBuff, ULONG ulCount )
HB_EXPORT ULONG hb_fsWriteLarge( HB_FHANDLE hFileHandle, const BYTE * pBuff, ULONG ulCount )
{
   ULONG ulWritten;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsWriteLarge(%p, %p, %lu)", hFileHandle, pBuff, ulCount));

#if defined(HB_FS_FILE_IO)

   #if defined(HB_WIN32_IO)
   {
      ulWritten = 0;
      hb_vmUnlock();
      if( ulCount )
      {
         hb_fsSetIOError( WriteFile( DosToWinHandle( hFileHandle), pBuff, ulCount, &ulWritten, NULL ), 0 );
      }
      else
      {
         hb_fsSetIOError( SetEndOfFile( DosToWinHandle( hFileHandle ) ), 0 );
      }
      hb_vmLock();
   }
   #else
      if( ulCount )
      #if defined(HB_FS_LARGE_OPTIMIZED)
         {
            hb_vmUnlock();
            ulWritten = write( hFileHandle, pBuff, ulCount );
            hb_fsSetIOError( ulWritten != ( ULONG ) -1, 0 );
            if( ulWritten == ( ULONG ) -1 )
               ulWritten = 0;
            hb_vmLock();
         }
      #else
         {
            ULONG ulLeftToWrite = ulCount;
            USHORT uiToWrite;
            USHORT uiWritten;
            BYTE * pPtr = ( BYTE * ) pBuff;

            ulWritten = 0;

            hb_vmUnlock();
            while( ulLeftToWrite )
            {
               /* Determine how much to write this time */
               if( ulLeftToWrite > ( ULONG ) INT_MAX )
               {
                  uiToWrite = INT_MAX;
                  ulLeftToWrite -= ( ULONG ) uiToWrite;
               }
               else
               {
                  uiToWrite = ( USHORT ) ulLeftToWrite;
                  ulLeftToWrite = 0;
               }

               uiWritten = write( hFileHandle, pPtr, uiToWrite );

               /* -1 on bad hFileHandle
                   0 on disk full
                */

               if( uiWritten == 0 )
                  break;

               if( uiWritten == ( USHORT ) -1 )
               {
                  uiWritten = 0;
                  break;
               }

               ulWritten += ( ULONG ) uiWritten;
               pPtr += uiWritten;
            }
            hb_fsSetIOError( ulLeftToWrite == 0, 0 );
            hb_vmLock();
         }
      #endif
      else
      {
         hb_vmUnlock();
#if defined(HB_USE_LARGEFILE64)
         hb_fsSetIOError( ftruncate64( hFileHandle, lseek64( hFileHandle, 0L, SEEK_CUR ) ) != -1, 0 );
#else
         hb_fsSetIOError( ftruncate( hFileHandle, lseek( hFileHandle, 0L, SEEK_CUR ) ) != -1, 0 );
#endif
         ulWritten = 0;
         hb_vmLock();
      }

   #endif

#else

   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return ulWritten;
}
filesys.c1539
HB_EXPORT ULONGhb_fsReadAt( HB_FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount, HB_FOFFSET llOffset )
HB_EXPORT ULONG hb_fsReadAt( HB_FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount, HB_FOFFSET llOffset )
{
   ULONG ulRead;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsReadAt(%p, %p, %lu, " PFHL ")", hFileHandle, pBuff, ulCount, llOffset));

#if defined(HB_FS_FILE_IO)

   #if defined(HB_WIN32_IO)
   {
      OVERLAPPED Overlapped;
      hb_vmUnlock();
      memset( &Overlapped, 0, sizeof( Overlapped ) );
      Overlapped.Offset     = ( DWORD ) ( llOffset & 0xFFFFFFFF ),
      Overlapped.OffsetHigh = ( DWORD ) ( llOffset >> 32 ),
      hb_fsSetIOError( ReadFile( DosToWinHandle( hFileHandle ),
                                 pBuff, ulCount, &ulRead, &Overlapped ), 0 );
      hb_vmLock();
   }
   #elif defined(HB_OS_UNIX)
   {
      hb_vmUnlock();
      #if defined(HB_USE_LARGEFILE64)
         ulRead = pread64( hFileHandle, pBuff, ulCount, llOffset );
      #else
         ulRead = pread( hFileHandle, pBuff, ulCount, llOffset );
      #endif
      hb_fsSetIOError( ulRead != (ULONG) -1, 0 );
      if( ulRead == ( ULONG ) -1 )
         ulRead = 0;
      hb_vmLock();
   }
   #else
   {
      hb_vmUnlock();
      /* TOFIX: this is not atom operation. It has to be fixed for RDD
       *        file access with shared file handles in aliased work areas
       */
      if( hb_fsSeekLarge( hFileHandle, llOffset, FS_SET ) == llOffset )
         ulRead = hb_fsReadLarge( hFileHandle, pBuff, ulCount );
      else
         ulRead = 0;
      hb_vmLock();
   }
   #endif

#else

   ulRead = 0;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return ulRead;
}
filesys.c1641
HB_EXPORT ULONGhb_fsWriteAt( HB_FHANDLE hFileHandle, const BYTE * pBuff, ULONG ulCount, HB_FOFFSET llOffset )
HB_EXPORT ULONG hb_fsWriteAt( HB_FHANDLE hFileHandle, const BYTE * pBuff, ULONG ulCount, HB_FOFFSET llOffset )
{
   ULONG ulWritten;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsWriteAt(%p, %p, %lu, " PFHL ")", hFileHandle, pBuff, ulCount, llOffset));

#if defined(HB_FS_FILE_IO)

   #if defined(HB_WIN32_IO)
   {
      OVERLAPPED Overlapped;
      hb_vmUnlock();
      memset( &Overlapped, 0, sizeof( Overlapped ) );
      Overlapped.Offset     = ( DWORD ) ( llOffset & 0xFFFFFFFF ),
      Overlapped.OffsetHigh = ( DWORD ) ( llOffset >> 32 ),
      hb_fsSetIOError( WriteFile( DosToWinHandle( hFileHandle ),
                                  pBuff, ulCount, &ulWritten, &Overlapped ), 0 );
      hb_vmLock();
   }
   #elif defined(HB_OS_UNIX)
   {
      hb_vmUnlock();
      #if defined(HB_USE_LARGEFILE64)
         ulWritten = pwrite64( hFileHandle, pBuff, ulCount, llOffset );
      #else
         ulWritten = pwrite( hFileHandle, pBuff, ulCount, llOffset );
      #endif
      hb_fsSetIOError( ulWritten != (ULONG) -1, 0 );
      if( ulWritten == ( ULONG ) -1 )
         ulWritten = 0;
      hb_vmLock();
   }
   #else
   {
      hb_vmUnlock();
      /* TOFIX: this is not atom operation. It has to be fixed for RDD
       *        file access with shared file handles in aliased work areas
       */
      if( hb_fsSeekLarge( hFileHandle, llOffset, FS_SET ) == llOffset )
         ulWritten = hb_fsWriteLarge( hFileHandle, pBuff, ulCount );
      else
         ulWritten = 0;
      hb_vmLock();
   }
   #endif

#else

   ulWritten = 0;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return ulWritten;
}
filesys.c1697
HB_EXPORT BOOLhb_fsTruncAt( HB_FHANDLE hFileHandle, HB_FOFFSET llOffset )
HB_EXPORT BOOL hb_fsTruncAt( HB_FHANDLE hFileHandle, HB_FOFFSET llOffset )
{
   BOOL fResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsReadAt(%p," PFHL ")", hFileHandle, llOffset));

#if defined(HB_FS_FILE_IO)

   hb_vmUnlock();
   #if defined(HB_WIN32_IO)
   {
      ULONG ulOffsetLow  = ( ULONG ) ( llOffset & ULONG_MAX ),
            ulOffsetHigh = ( ULONG ) ( llOffset >> 32 );

      /* This is not atom operation anyhow if someone want to truncate
       * file then he has to made necessary synchronizations in upper level
       * code. We have such situation in our RDD drivers and for us such
       * version is enough. [druzus]
       */
      ulOffsetLow = SetFilePointer( DosToWinHandle( hFileHandle ),
                                    ulOffsetLow, ( PLONG ) &ulOffsetHigh,
                                    ( DWORD ) SEEK_SET );
      if( ( ( ( HB_FOFFSET ) ulOffsetHigh << 32 ) | ulOffsetLow ) == llOffset )
         fResult = SetEndOfFile( DosToWinHandle( hFileHandle ) );
      else
         fResult = FALSE;
   }
   #elif defined(HB_USE_LARGEFILE64)
      fResult = ftruncate64( hFileHandle, llOffset ) != -1;
   #else
      fResult = ftruncate( hFileHandle, llOffset ) != -1;
   #endif
   hb_fsSetIOError( fResult, 0 );
   hb_vmLock();

#else

   fResult = FALSE;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return fResult;
}
filesys.c1753
HB_EXPORT VOIDhb_fsCommit( HB_FHANDLE hFileHandle )
HB_EXPORT void hb_fsCommit( HB_FHANDLE hFileHandle )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsCommit(%p)", hFileHandle));

#if defined(HB_OS_WIN_32)
   {
      hb_vmUnlock();
      #if defined(HB_WIN32_IO)
         hb_fsSetIOError( FlushFileBuffers( ( HANDLE ) DosToWinHandle( hFileHandle ) ), 0 );
      #else
         #if defined(__WATCOMC__)
            hb_fsSetIOError( fsync( hFileHandle ) == 0, 0 );
         #else
            hb_fsSetIOError( _commit( hFileHandle ) == 0, 0 );
         #endif
      #endif
      hb_vmLock();
   }

#elif defined(HB_OS_OS2)

   {
      hb_vmUnlock();
      hb_fsSetIOError( DosResetBuffer( hFileHandle ) == 0, 0 );
      hb_vmLock();
   }

#elif defined(HB_OS_UNIX)

   /* NOTE: close() functions releases all lock regardles if it is an
    * original or duplicated file handle
   */
   hb_vmUnlock();
   #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO + 0 > 0
      /* faster - flushes data buffers only, without updating directory info
      */
      hb_fsSetIOError( fdatasync( hFileHandle ) == 0, 0 );
   #else
      /* slower - flushes all file data buffers and i-node info
      */
      hb_fsSetIOError( fsync( hFileHandle ) == 0, 0 );
   #endif
   hb_vmLock();

#elif defined(__WATCOMC__)

   hb_vmUnlock();
   hb_fsSetIOError( fsync( hFileHandle ) == 0, 0 );
   hb_vmLock();

#elif defined(HB_FS_FILE_IO) && !defined(HB_OS_OS2) && !defined(HB_OS_UNIX)

   /* This hack is very dangerous. POSIX standard define that if _ANY_
      file handle is closed all locks set by the process on the file
      pointed by this descriptor are removed. It doesn't matter they
      were done using different descriptor. It means that we now clean
      all locks on hFileHandle with the code below if the OS is POSIX
      compilant. I vote to disable it.
    */
   {
      int dup_handle;
      BOOL fResult = FALSE;

      hb_vmUnlock();
      dup_handle = dup( hFileHandle );
      if( dup_handle != -1 )
      {
         close( dup_handle );
         fResult = TRUE;
      }
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
   }

#else

   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif
}
filesys.c1798
HB_EXPORT BOOLhb_fsLock( HB_FHANDLE hFileHandle, ULONG ulStart, ULONG ulLength, USHORT uiMode )
HB_EXPORT BOOL hb_fsLock( HB_FHANDLE hFileHandle, ULONG ulStart,
                          ULONG ulLength, USHORT uiMode )
{
   BOOL bResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsLock(%p, %lu, %lu, %hu)", hFileHandle, ulStart, ulLength, uiMode));

#if defined(HB_WIN32_IO)
   hb_vmUnlock();
   switch( uiMode & FL_MASK )
   {
      case FL_LOCK:
      {
         if( hb_iswinnt() )
         {
            OVERLAPPED sOlap ;
            DWORD dwFlags ;
            memset( &sOlap, 0, sizeof( OVERLAPPED ) ) ;
            sOlap.Offset = ( ULONG ) ulStart ;
            dwFlags = ( uiMode & FLX_SHARED ) ? 0 : LOCKFILE_EXCLUSIVE_LOCK ;
            if( !s_fUseWaitLocks || !( uiMode & FLX_WAIT ) )
            {
               dwFlags |= LOCKFILE_FAIL_IMMEDIATELY ;
            }
            bResult = LockFileEx( DosToWinHandle( hFileHandle ), dwFlags, 0, ulLength, 0, &sOlap );
         }
         else
         {
             bResult = LockFile( DosToWinHandle( hFileHandle ), ulStart, 0, ulLength,0 );
         }
         break;
      }
      case FL_UNLOCK:
      {
         if( hb_iswinnt() )
         {
            OVERLAPPED sOlap ;
            memset( &sOlap, 0, sizeof( OVERLAPPED ) ) ;
            sOlap.Offset = ( ULONG ) ulStart ;
            bResult = UnlockFileEx( DosToWinHandle( hFileHandle ), 0, ulLength,0, &sOlap );
         }
         else
         {
            bResult = UnlockFile( DosToWinHandle( hFileHandle ), ulStart, 0, ulLength,0 );
         }
         break;

      }
      default:
         bResult = FALSE;
   }
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();
#elif defined(HB_OS_OS2)
   {
      struct _FILELOCK fl, ful;

      hb_vmUnlock();
      switch( uiMode & FL_MASK )
      {
         case FL_LOCK:

            fl.lOffset = ulStart;
            fl.lRange = ulLength;
            ful.lOffset = 0;
            ful.lRange = 0;

            /* lock region, 2 seconds timeout, exclusive access - no atomic */
            bResult = ( DosSetFileLocks( hFileHandle, &ful, &fl, 2000L, 0L ) == 0 );
            break;

         case FL_UNLOCK:

            fl.lOffset = 0;
            fl.lRange = 0;
            ful.lOffset = ulStart;
            ful.lRange = ulLength;

            /* unlock region, 2 seconds timeout, exclusive access - no atomic */
            bResult = ( DosSetFileLocks( hFileHandle, &ful, &fl, 2000L, 0L ) == 0 );
            break;

         default:
            bResult = FALSE;
      }
      hb_fsSetIOError( bResult, 0 );
      hb_vmLock();
   }
#elif defined(_MSC_VER) || defined(__DMC__)
   {
      ULONG ulOldPos;

      hb_vmUnlock();
      ulOldPos = lseek( hFileHandle, 0L, SEEK_CUR );
      lseek( hFileHandle, ulStart, SEEK_SET );
      switch( uiMode & FL_MASK )
      {
         case FL_LOCK:
            bResult = ( locking( hFileHandle, _LK_NBLCK, ulLength ) == 0 );
            break;

         case FL_UNLOCK:
            bResult = ( locking( hFileHandle, _LK_UNLCK, ulLength ) == 0 );
            break;

         default:
            bResult = FALSE;
      }
      hb_fsSetIOError( bResult, 0 );
      hb_vmLock();
      lseek( hFileHandle, ulOldPos, SEEK_SET );
   }
#elif defined(__MINGW32__)
   {
      ULONG ulOldPos;

      hb_vmUnlock();
      ulOldPos = lseek( hFileHandle, 0L, SEEK_CUR );
      lseek( hFileHandle, ulStart, SEEK_SET );
      switch( uiMode & FL_MASK )
      {
         case FL_LOCK:
            bResult = ( _locking( hFileHandle, _LK_LOCK, ulLength ) == 0 );
            break;

         case FL_UNLOCK:
            bResult = ( _locking( hFileHandle, _LK_UNLCK, ulLength ) == 0 );
            break;

         default:
            bResult = FALSE;
      }
      hb_fsSetIOError( bResult, 0 );
      hb_vmLock();
      lseek( hFileHandle, ulOldPos, SEEK_SET );
   }
#elif defined(HB_OS_UNIX)
   {
      /* TODO: check for append locks (SEEK_END)
       */
      struct flock lock_info;

      hb_vmUnlock();
      switch( uiMode & FL_MASK )
      {
         case FL_LOCK:

            lock_info.l_type   = (uiMode & FLX_SHARED) ? F_RDLCK : F_WRLCK;
            lock_info.l_start  = ulStart;
            lock_info.l_len    = ulLength;
            lock_info.l_whence = SEEK_SET;   /* start from the beginning of the file */
            lock_info.l_pid    = getpid();

            bResult = ( fcntl( hFileHandle,
                               (uiMode & FLX_WAIT) ? F_SETLKW: F_SETLK,
                               &lock_info ) >= 0 );
            break;

         case FL_UNLOCK:

            lock_info.l_type   = F_UNLCK;   /* unlock */
            lock_info.l_start  = ulStart;
            lock_info.l_len    = ulLength;
            lock_info.l_whence = SEEK_SET;
            lock_info.l_pid    = getpid();

            bResult = ( fcntl( hFileHandle, F_SETLK, &lock_info ) >= 0 );
            break;

         default:
            bResult = FALSE;
      }
      hb_fsSetIOError( bResult, 0 );
      hb_vmLock();
   }
#elif defined(HAVE_POSIX_IO) && !defined(__IBMCPP__) && ( !defined(__GNUC__) || defined(__DJGPP__) )

   hb_vmUnlock();
   switch( uiMode & FL_MASK )
   {
      case FL_LOCK:
         bResult = ( lock( hFileHandle, ulStart, ulLength ) == 0 );
         break;

      case FL_UNLOCK:
         bResult = ( unlock( hFileHandle, ulStart, ulLength ) == 0 );
         break;

      default:
         bResult = FALSE;
   }
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#else

   bResult = FALSE;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return bResult;
}
filesys.c1879
HB_EXPORT BOOLhb_fsLockLarge( HB_FHANDLE hFileHandle, HB_FOFFSET ulStart, HB_FOFFSET ulLength, USHORT uiMode )
HB_EXPORT BOOL hb_fsLockLarge( HB_FHANDLE hFileHandle, HB_FOFFSET ulStart,
                               HB_FOFFSET ulLength, USHORT uiMode )
{
   BOOL bResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsLockLarge(%p, %" PFHL "u, %" PFHL "u, %hu)", hFileHandle, ulStart, ulLength, uiMode));

#if defined(HB_WIN32_IO)
   {
      DWORD dwOffsetLo = ( DWORD ) ( ulStart & 0xFFFFFFFF ),
            dwOffsetHi = ( DWORD ) ( ulStart >> 32 ),
            dwLengthLo = ( DWORD ) ( ulLength & 0xFFFFFFFF ),
            dwLengthHi = ( DWORD ) ( ulLength >> 32 );

      hb_vmUnlock();
      switch( uiMode & FL_MASK )
      {
         case FL_LOCK:
            if( hb_iswinnt() )
            {
               OVERLAPPED sOlap ;
               DWORD dwFlags ;

               dwFlags = ( ( uiMode & FLX_SHARED ) ? 0 : LOCKFILE_EXCLUSIVE_LOCK );
               if( !s_fUseWaitLocks || !( uiMode & FLX_WAIT ) )
               {
                  dwFlags |= LOCKFILE_FAIL_IMMEDIATELY ;
               }

               memset( &sOlap, 0, sizeof( OVERLAPPED ) );
               sOlap.Offset = dwOffsetLo;
               sOlap.OffsetHigh = dwOffsetHi;

               bResult = LockFileEx( DosToWinHandle( hFileHandle ), dwFlags, 0,
                                     dwLengthLo, dwLengthHi, &sOlap );
            }
            else
            {
               bResult = LockFile( DosToWinHandle( hFileHandle ),
                                   dwOffsetLo, dwOffsetHi,
                                   dwLengthLo, dwLengthHi );
            }
            break;

         case FL_UNLOCK:
            if( hb_iswinnt() )
            {
               OVERLAPPED sOlap ;

               memset( &sOlap, 0, sizeof( OVERLAPPED ) );
               sOlap.Offset = dwOffsetLo;
               sOlap.OffsetHigh = dwOffsetHi;

               bResult = UnlockFileEx( DosToWinHandle( hFileHandle ), 0,
                                       dwLengthLo, dwLengthHi, &sOlap );
            }
            else
            {
               bResult = UnlockFile( DosToWinHandle( hFileHandle ),
                                     dwOffsetLo, dwOffsetHi,
                                     dwLengthLo, dwLengthHi );
            }
            break;

         default:
            bResult = FALSE;
      }
      hb_fsSetIOError( bResult, 0 );
      hb_vmLock();
   }
#elif defined(HB_USE_LARGEFILE64)
   {
      struct flock64 lock_info;

      hb_vmUnlock();
      switch( uiMode & FL_MASK )
      {
         case FL_LOCK:

            lock_info.l_type   = (uiMode & FLX_SHARED) ? F_RDLCK : F_WRLCK;
            lock_info.l_start  = ulStart;
            lock_info.l_len    = ulLength;
            lock_info.l_whence = SEEK_SET;   /* start from the beginning of the file */
            lock_info.l_pid    = getpid();

            bResult = ( fcntl( hFileHandle,
                               (uiMode & FLX_WAIT) ? F_SETLKW64: F_SETLK64,
                               &lock_info ) != -1 );
            break;

         case FL_UNLOCK:

            lock_info.l_type   = F_UNLCK;   /* unlock */
            lock_info.l_start  = ulStart;
            lock_info.l_len    = ulLength;
            lock_info.l_whence = SEEK_SET;
            lock_info.l_pid    = getpid();

            bResult = ( fcntl( hFileHandle, F_SETLK64, &lock_info ) != -1 );
            break;

         default:
            bResult = FALSE;
      }
      hb_fsSetIOError( bResult, 0 );
      hb_vmLock();
   }
#else
   bResult = hb_fsLock( hFileHandle, (ULONG) ulStart, (ULONG) ulLength, uiMode );
#endif

   return bResult;
}
filesys.c2083
HB_EXPORT ULONGhb_fsSeek( HB_FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags )
HB_EXPORT ULONG hb_fsSeek( HB_FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags )
{
   ULONG ulPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsSeek(%p, %ld, %hu)", hFileHandle, lOffset, uiFlags));

#if defined(HB_FS_FILE_IO)
{
   USHORT Flags = convert_seek_flags( uiFlags );

   hb_vmUnlock();
   #if defined(HB_OS_OS2)
   {
      APIRET ret;

      /* This DOS hack creates 2GB file size limit, Druzus */
      if( lOffset < 0 && Flags == SEEK_SET )
      {
         ret = 1;
         hb_fsSetError( 25 ); /* 'Seek Error' */
      }
      else
      {
         ret = DosSetFilePtr( hFileHandle, lOffset, Flags, &ulPos );
         /* TODO: what we should do with this error code? Is it DOS compatible? */
         hb_fsSetError( ( USHORT ) ret );
      }
      if( ret != 0 )
      {
         /* FIXME: it should work if DosSetFilePtr is lseek compatible
            but maybe OS2 has DosGetFilePtr too, if not then remove this
            comment, Druzus */
         if( DosSetFilePtr( hFileHandle, 0, SEEK_CUR, &ulPos ) != 0 )
         {
            ulPos = 0;
         }
      }
   }
   #elif defined(HB_WIN32_IO)
      /* This DOS hack creates 2GB file size limit, Druzus */
      if( lOffset < 0 && Flags == SEEK_SET )
      {
         ulPos = (ULONG) INVALID_SET_FILE_POINTER;
         hb_fsSetError( 25 ); /* 'Seek Error' */
      }
      else
      {
         ulPos = (DWORD) SetFilePointer( DosToWinHandle( hFileHandle ), lOffset, NULL, ( DWORD ) Flags );
         hb_fsSetIOError( (DWORD) ulPos != INVALID_SET_FILE_POINTER, 0 );
      }

      if( (DWORD) ulPos == INVALID_SET_FILE_POINTER )
      {
         ulPos = (DWORD) SetFilePointer( DosToWinHandle( hFileHandle ), 0, NULL, SEEK_CUR );
      }
   #else
      /* This DOS hack creates 2GB file size limit, Druzus */
      if( lOffset < 0 && Flags == SEEK_SET )
      {
         ulPos = (ULONG) -1;
         hb_fsSetError( 25 ); /* 'Seek Error' */
      }
      else
      {
         ulPos = lseek( hFileHandle, lOffset, Flags );
         hb_fsSetIOError( ulPos != (ULONG) -1, 0 );
      }
      if( ulPos == (ULONG) -1 )
      {
         ulPos = lseek( hFileHandle, 0L, SEEK_CUR );
         if( ulPos == (ULONG) -1 )
         {
            ulPos = 0;
         }
      }
   #endif
   hb_vmLock();
}
#else
   hb_fsSetError( 25 );
   ulPos = 0;
#endif

   return ulPos;
}
filesys.c2197
HB_EXPORT HB_FOFFSEThb_fsSeekLarge( HB_FHANDLE hFileHandle, HB_FOFFSET llOffset, USHORT uiFlags )
HB_EXPORT HB_FOFFSET hb_fsSeekLarge( HB_FHANDLE hFileHandle, HB_FOFFSET llOffset, USHORT uiFlags )
{
   HB_FOFFSET llPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsSeekLarge(%p, %" PFHL "u, %hu)", hFileHandle, llOffset, uiFlags));

#if defined(HB_WIN32_IO)
   {
      USHORT Flags = convert_seek_flags( uiFlags );

      ULONG ulOffsetLow  = ( ULONG ) ( llOffset & ULONG_MAX ),
            ulOffsetHigh = ( ULONG ) ( llOffset >> 32 );

      hb_vmUnlock();
      if( llOffset < 0 && Flags == SEEK_SET )
      {
         llPos = ( HB_FOFFSET ) INVALID_SET_FILE_POINTER;
         hb_fsSetError( 25 ); /* 'Seek Error' */
      }
      else
      {
         ulOffsetLow = SetFilePointer( DosToWinHandle( hFileHandle ),
                                       ulOffsetLow, (PLONG) &ulOffsetHigh,
                                       ( DWORD ) Flags );
         llPos = ( ( HB_FOFFSET ) ulOffsetHigh << 32 ) | ulOffsetLow;
         hb_fsSetIOError( llPos != ( HB_FOFFSET ) INVALID_SET_FILE_POINTER, 0 );
      }

      if( llPos == ( HB_FOFFSET ) INVALID_SET_FILE_POINTER )
      {
         ulOffsetHigh = 0;
         ulOffsetLow = SetFilePointer( DosToWinHandle( hFileHandle ),
                                       0, (PLONG) &ulOffsetHigh, SEEK_CUR );
         llPos = ( ( HB_FOFFSET ) ulOffsetHigh << 32 ) | ulOffsetLow;
      }
      hb_vmLock();
   }
#elif defined(HB_USE_LARGEFILE64)
   {
      USHORT Flags = convert_seek_flags( uiFlags );

      hb_vmUnlock();
      if( llOffset < 0 && Flags == SEEK_SET )
      {
         llPos = (HB_FOFFSET) -1;
         hb_fsSetError( 25 ); /* 'Seek Error' */
      }
      else
      {
         llPos = lseek64( hFileHandle, llOffset, Flags );
         hb_fsSetIOError( llPos != (HB_FOFFSET) -1, 0 );
      }

      if( llPos == (HB_FOFFSET) -1 )
      {
         llPos = lseek64( hFileHandle, 0L, SEEK_CUR );
      }
      hb_vmLock();
   }
#else
   llPos = (HB_FOFFSET) hb_fsSeek( hFileHandle, (LONG) llOffset, uiFlags );
#endif

   return llPos;
}
filesys.c2283
HB_EXPORT ULONGhb_fsTell( HB_FHANDLE hFileHandle )
HB_EXPORT ULONG hb_fsTell( HB_FHANDLE hFileHandle )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsTell(%p)", hFileHandle));

   return hb_fsSeek( hFileHandle, 0, FS_RELATIVE );
}
filesys.c2349
HB_EXPORT BOOLhb_fsDelete( BYTE * pFilename )
HB_EXPORT BOOL hb_fsDelete( BYTE * pFilename )
{
   BOOL bResult;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsDelete(%s)", (char*) pFilename));

   pFilename = hb_fsNameConv( pFilename, &fFree );

#if defined(HB_OS_WIN_32)

   hb_vmUnlock();
   bResult = DeleteFileA( ( char * ) pFilename );
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#elif defined(HB_FS_FILE_IO)

   hb_vmUnlock();
   bResult = ( remove( ( char * ) pFilename ) == 0 );
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#else

   bResult = FALSE;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   if( fFree )
      hb_xfree( pFilename );

   return bResult;
}
filesys.c2356
HB_EXPORT BOOLhb_fsRename( BYTE * pOldName, BYTE * pNewName )
HB_EXPORT BOOL hb_fsRename( BYTE * pOldName, BYTE * pNewName )
{
   BOOL bResult;
   BOOL fFreeOld, fFreeNew;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsRename(%s, %s)", (char*) pOldName, (char*) pNewName));

   pOldName = hb_fsNameConv( pOldName, &fFreeOld );
   pNewName = hb_fsNameConv( pNewName, &fFreeNew );

#if defined(HB_OS_WIN_32)

   hb_vmUnlock();
   bResult = MoveFileA( ( char * ) pOldName, ( char * ) pNewName );
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#elif defined(HB_FS_FILE_IO)

   hb_vmUnlock();
   bResult = ( rename( ( char * ) pOldName, ( char * ) pNewName ) == 0 );
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#else

   bResult = FALSE;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   if( fFreeOld )
      hb_xfree( pOldName );
   if( fFreeNew )
      hb_xfree( pNewName );

   return bResult;
}
filesys.c2392
HB_EXPORT BOOLhb_fsMkDir( BYTE * pDirname )
HB_EXPORT BOOL hb_fsMkDir( BYTE * pDirname )
{
   BOOL bResult;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsMkDir(%s)", (char*) pDirname));

   pDirname = hb_fsNameConv( pDirname, &fFree );

   HB_TRACE(HB_TR_DEBUG, ("hb_fsMkDir(%s)", (char*) pDirname));

#if defined(HB_OS_WIN_32)

   hb_vmUnlock();
   bResult = CreateDirectoryA( ( char * ) pDirname, NULL );
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#elif defined(HAVE_POSIX_IO) || defined(__MINGW32__)

   hb_vmUnlock();
#  if ! defined(HB_OS_UNIX) && \
      ( defined(__WATCOMC__) || defined(__BORLANDC__) || \
        defined(__IBMCPP__) || defined(__MINGW32__) )
      bResult = ( mkdir( ( char * ) pDirname ) == 0 );
#  else
      bResult = ( mkdir( ( char * ) pDirname, S_IRWXU | S_IRWXG | S_IRWXO ) == 0 );
#  endif
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#else

   bResult = FALSE;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   if( fFree )
      hb_xfree( pDirname );

   return bResult;
}
filesys.c2431
HB_EXPORT BOOLhb_fsChDir( BYTE * pDirname )
HB_EXPORT BOOL hb_fsChDir( BYTE * pDirname )
{
   BOOL bResult;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsChDir(%s)", (char*) pDirname));

   pDirname = hb_fsNameConv( pDirname, &fFree );

#if defined(HB_OS_WIN_32)

   hb_vmUnlock();
   bResult = SetCurrentDirectoryA( ( char * ) pDirname );
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#elif defined(HAVE_POSIX_IO) || defined(__MINGW32__)

   hb_vmUnlock();
   bResult = ( chdir( ( char * ) pDirname ) == 0 );
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#else

   bResult = FALSE;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   if( fFree )
      hb_xfree( pDirname );

   return bResult;
}
filesys.c2475
HB_EXPORT BOOLhb_fsRmDir( BYTE * pDirname )
HB_EXPORT BOOL hb_fsRmDir( BYTE * pDirname )
{
   BOOL bResult;
   BOOL fFree;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsRmDir(%s)", (char*) pDirname));

   pDirname = hb_fsNameConv( pDirname, &fFree );

#if defined(HB_OS_WIN_32)

   hb_vmUnlock();
   bResult = RemoveDirectoryA( ( char * ) pDirname );
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#elif defined(HAVE_POSIX_IO) || defined(__MINGW32__)

   hb_vmUnlock();
   bResult = ( rmdir( ( char * ) pDirname ) == 0 );
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#else

   bResult = FALSE;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   if( fFree )
      hb_xfree( pDirname );

   return bResult;
}

filesys.c2511
HB_EXPORT BYTE *hb_fsCurDir( USHORT uiDrive )
HB_EXPORT BYTE * hb_fsCurDir( USHORT uiDrive )
{
   BYTE * pbyDirBuffer;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsCurDir(%hu)", uiDrive));

   pbyDirBuffer = hb_stackDirBuffer();
   hb_fsCurDirBuff( uiDrive, pbyDirBuffer, _POSIX_PATH_MAX + 1 );

   return ( BYTE * ) pbyDirBuffer;
}

filesys.c2550
HB_EXPORT USHORThb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen )
HB_EXPORT USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen )
{
   USHORT uiCurDrv = uiDrive, usError;
   BOOL fResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsCurDirBuff(%hu)", uiDrive));

   pbyBuffer[ 0 ] = '\0';

   /*
    * do not cover this code by HB_OS_HAS_DRIVE_LETTER macro
    * It will allow us to add drive emulation in hb_fsCurDrv()/hb_fsChDrv()
    * and hb_fsNameConv()
    */
#if !defined(HB_OS_OS2) && !defined(__MINGW32__)
   if( uiDrive )
   {
      uiCurDrv = hb_fsCurDrv() + 1;
      if( uiDrive != uiCurDrv )
         hb_fsChDrv( ( BYTE ) ( uiDrive - 1 ) );
   }
#endif

#if defined(HB_OS_WIN_32)

   hb_vmUnlock();
   fResult = GetCurrentDirectoryA( ulLen, ( char * ) pbyBuffer );
   hb_fsSetIOError( fResult, 0 );
   hb_vmLock();

#elif defined(HB_OS_OS2)

   hb_vmUnlock();
   fResult = ( _getcwd1( (char *) pbyBuffer, uiDrive + 'A' - 1 ) == 0 );
   hb_fsSetIOError( fResult, 0 );
   hb_vmLock();

#elif defined(HAVE_POSIX_IO)

   hb_vmUnlock();
   fResult = ( getcwd( ( char * ) pbyBuffer, ulLen ) != NULL );
   hb_fsSetIOError( fResult, 0 );
   hb_vmLock();

#elif defined(__MINGW32__)

   hb_vmUnlock();
   fResult = ( _getdcwd( uiDrive, pbyBuffer, ulLen ) != NULL );
   hb_fsSetIOError( fResult, 0 );
   hb_vmLock();

#else

   fResult = FALSE;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   usError = hb_fsError();

   if( uiDrive != uiCurDrv )
   {
      hb_fsChDrv( ( BYTE ) ( uiCurDrv - 1 ) );
      hb_fsSetError( usError );
   }

   pbyBuffer[ ulLen - 1 ] = '\0';

   if( usError == 0 && pbyBuffer[ 0 ] )
   {
      BYTE * pbyStart = pbyBuffer;

      /* Strip the leading drive spec, and leading backslash if there's one. */
      /* NOTE: A trailing underscore is not returned on this platform,
               so we don't need to strip it. [vszakats] */

      ulLen = strlen( ( char * ) pbyBuffer );

#if defined(HB_OS_HAS_DRIVE_LETTER)
      if( pbyStart[ 1 ] == HB_OS_DRIVE_DELIM_CHR )
      {
         pbyStart += 2;
         ulLen -= 2;
      }
#endif
      if( strchr( HB_OS_PATH_DELIM_CHR_LIST, pbyStart[ 0 ] ) )
      {
         pbyStart++;
         ulLen--;
      }

      /* Strip the trailing (back)slash if there's one */
      if( ulLen && strchr( HB_OS_PATH_DELIM_CHR_LIST, pbyStart[ ulLen - 1 ] ) )
         ulLen--;

      if( ulLen && pbyBuffer != pbyStart )
         memmove( pbyBuffer, pbyStart, ulLen );

      pbyBuffer[ ulLen ] = '\0';
   }

   return usError;
}
filesys.c2565
HB_EXPORT USHORThb_fsChDrv( BYTE nDrive )
HB_EXPORT USHORT hb_fsChDrv( BYTE nDrive )
{
   USHORT uiResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsChDrv(%d)", (int) nDrive));

#if defined(HB_OS_HAS_DRIVE_LETTER)
   {
      /* 'unsigned int' _have to_ be used in Watcom */
      UINT uiSave, uiNewDrive;

      hb_vmUnlock();

      HB_FS_GETDRIVE( uiSave );
      HB_FS_SETDRIVE( nDrive );
      HB_FS_GETDRIVE( uiNewDrive );

      if( ( UINT ) nDrive == uiNewDrive )
      {
         uiResult = 0;
         hb_fsSetError( 0 );
      }
      else
      {
         HB_FS_SETDRIVE( uiSave );

         uiResult = ( USHORT ) FS_ERROR;
         hb_fsSetError( ( USHORT ) FS_ERROR );
      }
      hb_vmLock();
   }
#else

   HB_SYMBOL_UNUSED( nDrive );
   uiResult = ( USHORT ) FS_ERROR;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return uiResult;
}

filesys.c2671
HB_EXPORT USHORThb_fsIsDrv( BYTE nDrive )
HB_EXPORT USHORT hb_fsIsDrv( BYTE nDrive )
{
   USHORT uiResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsIsDrv(%d)", (int) nDrive));

#if defined(HB_OS_WIN_32) && !defined(HB_WINCE)
   {
      char buffer[ 4 ];
      UINT type;

      buffer[ 0 ] = nDrive + 'A';
      buffer[ 1 ] = ':';
      buffer[ 2 ] = '\\';
      buffer[ 3 ] = '\0';

      hb_vmUnlock();
      type = GetDriveTypeA( ( LPCSTR ) buffer );
      hb_vmLock();
      uiResult = ( type == DRIVE_UNKNOWN || type == DRIVE_NO_ROOT_DIR ) ? F_ERROR : 0;
      hb_fsSetError( 0 );
   }
#elif defined(HB_OS_HAS_DRIVE_LETTER)
   {
      /* 'unsigned int' _have to_ be used in Watcom
       */
      UINT uiSave, uiNewDrive;

      hb_vmUnlock();

      HB_FS_GETDRIVE( uiSave );
      HB_FS_SETDRIVE( nDrive );
      HB_FS_GETDRIVE( uiNewDrive );
      if( ( UINT ) nDrive != uiNewDrive )
      {
         uiResult = ( USHORT ) FS_ERROR;
         hb_fsSetError( ( USHORT ) FS_ERROR );
      }
      else
      {
         uiResult = 0;
         hb_fsSetError( 0 );
      }
      HB_FS_SETDRIVE( uiSave );

      hb_vmLock();
   }
#else

   HB_SYMBOL_UNUSED( nDrive );
   uiResult = ( USHORT ) FS_ERROR;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return uiResult;
}
filesys.c2719
HB_EXPORT BOOLhb_fsIsDevice( HB_FHANDLE hFileHandle )
HB_EXPORT BOOL hb_fsIsDevice( HB_FHANDLE hFileHandle )
{
   BOOL bResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsIsDevice(%p)", hFileHandle));

#if defined(HB_OS_WIN_32)

   hb_vmUnlock();
   bResult = GetFileType( DosToWinHandle( hFileHandle ) ) == FILE_TYPE_CHAR;
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#elif defined(HB_FS_FILE_IO)

   hb_vmUnlock();
#if defined( _MSC_VER ) || defined( __MINGW32__ )
   bResult = _isatty( hFileHandle ) != 0;
#else
   bResult = isatty( hFileHandle ) != 0;
#endif
   hb_fsSetIOError( bResult, 0 );
   hb_vmLock();

#else

   bResult = FALSE;
   hb_fsSetError( ( USHORT ) FS_ERROR );
   HB_SYMBOL_UNUSED( hFileHandle );

#endif

   return bResult;
}
filesys.c2777
HB_EXPORT BYTEhb_fsCurDrv( void )
HB_EXPORT BYTE hb_fsCurDrv( void )
{
   UINT uiResult;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsCurDrv()"));

#if defined(HB_OS_HAS_DRIVE_LETTER)

   hb_vmUnlock();
   HB_FS_GETDRIVE( uiResult );
   hb_vmLock();

#else

   uiResult = 0;
   hb_fsSetError( ( USHORT ) FS_ERROR );

#endif

   return ( BYTE ) uiResult; /* Return the drive number, base 0. */
}
filesys.c2814
HB_EXPORT BYTE *hb_fsExtName( BYTE * pFilename, BYTE * pDefExt, USHORT uiExFlags, BYTE * pPaths )
HB_EXPORT BYTE * hb_fsExtName( BYTE * pFilename, BYTE * pDefExt,
                               USHORT uiExFlags, BYTE * pPaths )
{
   HB_PATHNAMES * pNextPath;
   PHB_FNAME pFilepath;
   BOOL fIsFile = FALSE;
   BYTE * szPath;

   szPath = ( BYTE * ) hb_xgrab( _POSIX_PATH_MAX + 1 );

   pFilepath = hb_fsFNameSplit( ( char * ) pFilename );

   if( pDefExt && ( ( uiExFlags & FXO_FORCEEXT ) || !pFilepath->szExtension ) )
   {
      pFilepath->szExtension = ( char * ) pDefExt;
   }

   if( pFilepath->szPath )
   {
      hb_fsFNameMerge( ( char * ) szPath, pFilepath );
   }
   else if( uiExFlags & FXO_DEFAULTS )
   {
      char * szDefault = hb_setGetDefault();
      if( szDefault )
      {
         pFilepath->szPath = szDefault;
         hb_fsFNameMerge( ( char * ) szPath, pFilepath );
         fIsFile = hb_fsFile( szPath );
      }
      if( !fIsFile && hb_setGetPath() )
      {
         pNextPath = hb_setGetFirstSetPath();
         while( !fIsFile && pNextPath )
         {
            pFilepath->szPath = pNextPath->szPath;
            hb_fsFNameMerge( ( char * ) szPath, pFilepath );
            fIsFile = hb_fsFile( szPath );
            pNextPath = pNextPath->pNext;
         }
      }
      if( !fIsFile )
      {
         pFilepath->szPath = szDefault ? szDefault : NULL;
         hb_fsFNameMerge( ( char * ) szPath, pFilepath );
      }
   }
   else if( pPaths && *pPaths )
   {
      HB_PATHNAMES * pSearchPath = NULL;
      hb_fsAddSearchPath( ( char * ) pPaths, &pSearchPath );
      pNextPath = pSearchPath;
      while( !fIsFile && pNextPath )
      {
         pFilepath->szPath = pNextPath->szPath;
         hb_fsFNameMerge( ( char * ) szPath, pFilepath );
         fIsFile = hb_fsFile( szPath );
         pNextPath = pNextPath->pNext;
      }
      hb_fsFreeSearchPath( pSearchPath );
      if( !fIsFile )
      {
         pFilepath->szPath = NULL;
         hb_fsFNameMerge( ( char * ) szPath, pFilepath );
      }
   }
   else
   {
      hb_fsFNameMerge( ( char * ) szPath, pFilepath );
   }
   hb_xfree( pFilepath );

   return szPath;
}
filesys.c2836
HB_EXPORT HB_FHANDLEhb_fsExtOpen( BYTE * pFilename, BYTE * pDefExt, USHORT uiExFlags, BYTE * pPaths, PHB_ITEM pError )
HB_EXPORT HB_FHANDLE hb_fsExtOpen( BYTE * pFilename, BYTE * pDefExt,
                                   USHORT uiExFlags, BYTE * pPaths,
                                   PHB_ITEM pError )
{
   HB_FHANDLE hFile;
   USHORT uiFlags;
   BYTE * szPath;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsExtOpen(%s, %s, %hu, %p, %p)", pFilename, pDefExt, uiExFlags, pPaths, pError));

#if 0
   #define FXO_TRUNCATE  0x0100   /* Create (truncate if exists) */
   #define FXO_APPEND    0x0200   /* Create (append if exists) */
   #define FXO_UNIQUE    0x0400   /* Create unique file FO_EXCL ??? */
   #define FXO_FORCEEXT  0x0800   /* Force default extension */
   #define FXO_DEFAULTS  0x1000   /* Use SET command defaults */
   #define FXO_DEVICERAW 0x2000   /* Open devices in raw mode */
   /* Harbour extension */
   #define FXO_SHARELOCK 0x4000   /* emulate DOS SH_DENY* mode in POSIX OS */
   #define FXO_COPYNAME  0x8000   /* copy final szPath into pFilename */

   hb_errGetFileName( pError );
#endif

   szPath = hb_fsExtName( pFilename, pDefExt, uiExFlags, pPaths );

   uiFlags = uiExFlags & 0xff;
   if( uiExFlags & ( FXO_TRUNCATE | FXO_APPEND | FXO_UNIQUE ) )
   {
      uiFlags |= FO_CREAT;
      if( uiExFlags & FXO_UNIQUE )
         uiFlags |= FO_EXCL;
#if !defined( HB_USE_SHARELOCKS )
      else if( uiExFlags & FXO_TRUNCATE )
         uiFlags |= FO_TRUNC;
#endif
   }

   hFile = hb_fsOpen( szPath, uiFlags );

#if defined( HB_USE_SHARELOCKS )
   if( hFile != FS_ERROR && uiExFlags & FXO_SHARELOCK )
   {
#if defined( HB_USE_BSDLOCKS )
      int iLock;
      if( ( uiFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) ) == FO_READ ||
          ( uiFlags & ( FO_DENYREAD | FO_DENYWRITE | FO_EXCLUSIVE ) ) == 0 )
         iLock = LOCK_SH | LOCK_NB;
      else
         iLock = LOCK_EX | LOCK_NB;
      hb_vmUnlock();
      iLock = flock( hFile, iLock );
      hb_vmLock();
      if( iLock != 0 )
#else
      USHORT uiLock;
      if( ( uiFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) ) == FO_READ ||
          ( uiFlags & ( FO_DENYREAD | FO_DENYWRITE | FO_EXCLUSIVE ) ) == 0 )
         uiLock = FL_LOCK | FLX_SHARED;
      else
         uiLock = FL_LOCK | FLX_EXCLUSIVE;

      if( !hb_fsLockLarge( hFile, HB_SHARELOCK_POS, HB_SHARELOCK_SIZE, uiLock ) )
#endif
      {
         hb_fsClose( hFile );
         hFile = FS_ERROR;
         /*
          * fix for neterr() support and Clipper compatibility,
          * should be revised with a better multi platform solution.
          */
         hb_fsSetError( ( uiExFlags & FXO_TRUNCATE ) ? 5 : 32 );
      }
      else if( uiExFlags & FXO_TRUNCATE )
      {
         /* truncate the file only if properly locked */
         hb_fsSeek( hFile, 0, FS_SET );
         hb_fsWrite( hFile, NULL, 0 );
         if( hb_fsError() != 0 )
         {
            hb_fsClose( hFile );
            hFile = FS_ERROR;
            hb_fsSetError( 5 );
         }
      }
   }
#elif 1
   /*
    * Temporary fix for neterr() support and Clipper compatibility,
    * should be revised with a better solution.
    */
   if( ( uiExFlags & ( FXO_TRUNCATE | FXO_APPEND | FXO_UNIQUE ) ) == 0 &&
       hb_fsError() == 5 )
   {
      hb_fsSetError( 32 );
   }
#endif

   if( pError )
   {
      hb_errPutFileName( pError, ( char * ) szPath );
      if( hFile == FS_ERROR )
      {
         hb_errPutOsCode( pError, hb_fsError() );
         hb_errPutGenCode( pError, ( USHORT ) ( ( uiExFlags & FXO_TRUNCATE ) ? EG_CREATE : EG_OPEN ) );
      }
   }

   if( uiExFlags & FXO_COPYNAME && hFile != FS_ERROR )
      hb_strncpy( ( char * ) pFilename, ( char * ) szPath, _POSIX_PATH_MAX );

   hb_xfree( szPath );
   return hFile;
}
filesys.c2914
HB_EXPORT BOOLhb_fsEof( HB_FHANDLE hFileHandle )
HB_EXPORT BOOL hb_fsEof( HB_FHANDLE hFileHandle )
{
   BOOL fResult;

   hb_vmUnlock();

#if defined(__DJGPP__) || defined(__CYGWIN__) || \
    defined(HB_WIN32_IO) || defined(HB_WINCE) || \
    defined(HB_OS_UNIX_COMPATIBLE)
{
   HB_FOFFSET curPos;
   HB_FOFFSET endPos;
   HB_FOFFSET newPos;

   curPos = hb_fsSeekLarge( hFileHandle, 0L, SEEK_CUR );
   if( curPos != -1 )
   {
      endPos = hb_fsSeekLarge( hFileHandle, 0L, SEEK_END );
      newPos = hb_fsSeekLarge( hFileHandle, curPos, SEEK_SET );
      fResult = ( endPos != -1 && newPos == curPos );
   }
   else
   {
      endPos = -1;
      fResult = FALSE;
   }
   hb_fsSetIOError( fResult, 0 );
   fResult = !fResult || curPos == endPos;
}
#else
   fResult = eof( hFileHandle ) != 0;
   hb_fsSetIOError( fResult, 0 );
#endif

   hb_vmLock();

   return fResult;
}
filesys.c3029
HB_EXPORT BYTE *hb_fsNameConv( BYTE * szFileName, BOOL * pfFree )
HB_EXPORT BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree )
{
   int iFileCase, iDirCase;
   char cDirSep;
   BOOL fTrim;
/*
   Convert file and dir case. The allowed SET options are:
      LOWER - Convert all caracters of file to lower
      UPPER - Convert all caracters of file to upper
      MIXED - Leave as is

   The allowed environment options are:
      FILECASE - define the case of file
      DIRCASE - define the case of path
      DIRSEPARATOR - define separator of path (Ex. "/")
      TRIMFILENAME - strip trailing and leading spaces (also from extension)
*/

   fTrim = hb_setGetTrimFileName();
   cDirSep = hb_setGetDirSeparator();
   iFileCase = hb_setGetFileCase();
   iDirCase = hb_setGetDirCase();

   if( fTrim || cDirSep != HB_OS_PATH_DELIM_CHR ||
       iFileCase != HB_SET_CASE_MIXED || iDirCase != HB_SET_CASE_MIXED )
   {
      PHB_FNAME pFileName;
      ULONG ulLen;

      if( pfFree )
      {
         BYTE * szNew = ( BYTE * ) hb_xgrab( _POSIX_PATH_MAX + 1 );
         hb_strncpy( ( char * ) szNew, ( char * ) szFileName, _POSIX_PATH_MAX );
         szFileName = szNew;
         *pfFree = TRUE;
      }

      if( cDirSep != HB_OS_PATH_DELIM_CHR )
      {
         BYTE *p = szFileName;
         while( *p )
         {
            if( *p == cDirSep )
               *p = HB_OS_PATH_DELIM_CHR;
            p++;
         }
      }

      pFileName = hb_fsFNameSplit( ( char * ) szFileName );

      /* strip trailing and leading spaces */
      if( fTrim )
      {
         if( pFileName->szName )
         {
            ulLen = strlen( pFileName->szName );
            ulLen = hb_strRTrimLen( pFileName->szName, ulLen, FALSE );
            pFileName->szName = hb_strLTrim( pFileName->szName, &ulLen );
            ( ( char * ) pFileName->szName )[ulLen] = '\0';
         }
         if( pFileName->szExtension )
         {
            ulLen = strlen( pFileName->szExtension );
            ulLen = hb_strRTrimLen( pFileName->szExtension, ulLen, FALSE );
            pFileName->szExtension = hb_strLTrim( pFileName->szExtension, &ulLen );
            ( ( char * ) pFileName->szExtension )[ulLen] = '\0';
         }
      }

      /* FILECASE */
      if( iFileCase == HB_SET_CASE_LOWER )
      {
         if( pFileName->szName )
            hb_strLower( ( char * ) pFileName->szName, strlen( pFileName->szName ) );
         if( pFileName->szExtension )
            hb_strLower( ( char * ) pFileName->szExtension, strlen( pFileName->szExtension ) );
      }
      else if( iFileCase == HB_SET_CASE_UPPER )
      {
         if( pFileName->szName )
            hb_strUpper( ( char * ) pFileName->szName, strlen( pFileName->szName ) );
         if( pFileName->szExtension )
            hb_strUpper( ( char * ) pFileName->szExtension, strlen( pFileName->szExtension ) );
      }

      /* DIRCASE */
      if( pFileName->szPath )
      {
         if( iDirCase == HB_SET_CASE_LOWER )
            hb_strLower( ( char * ) pFileName->szPath, strlen( pFileName->szPath ) );
         else if( iDirCase == HB_SET_CASE_UPPER )
            hb_strUpper( ( char * ) pFileName->szPath, strlen( pFileName->szPath ) );
      }

      hb_fsFNameMerge( ( char * ) szFileName, pFileName );
      hb_xfree( pFileName );
   }
   else if( pfFree )
      *pfFree = FALSE;

   return szFileName;
}
filesys.c3068
HB_EXPORT BYTE *hb_fileNameConv( char * szFileName )
HB_EXPORT BYTE * hb_fileNameConv( char * szFileName )
{
   BOOL fFree;
   BYTE * szNew;

   szNew = hb_fsNameConv( ( BYTE * ) szFileName, &fFree );
   if( fFree )
   {
      hb_strncpy( szFileName, ( char * ) szNew, strlen( szFileName ) );
      hb_xfree( szNew );
   }

   return ( BYTE * ) szFileName;
}
filesys.c3173
HB_EXPORT BOOLhb_fsDisableWaitLocks( int iSet )
HB_EXPORT BOOL hb_fsDisableWaitLocks( int iSet )
{
   BOOL fRetVal = s_fUseWaitLocks;

   if( iSet >= 0 )
   {
      s_fUseWaitLocks = ( iSet == 0 );
   }

   return fRetVal;
}
filesys.c3190
HB_FUNCHB_DISABLEWAITLOCKS(void)
HB_FUNC( HB_DISABLEWAITLOCKS )
{
   hb_retl( hb_fsDisableWaitLocks( ISLOG( 1 ) ? ( hb_parl( 1 ) ? 1 : 0 ) : -1 ) );
}
filesys.c3202
fkmax.c
TypeFunctionSourceLine
HB_FUNCFKMAX(void)
HB_FUNC( FKMAX )
{
   hb_retni( 40 ); /* IBM specific */
}
fkmax.c58
HB_FUNCFKLABEL(void)
HB_FUNC( FKLABEL )
{
   PHB_ITEM pPar1 = hb_param( 1, HB_IT_NUMERIC );

   if( pPar1 )
   {
      USHORT uiFKey = ( USHORT ) hb_itemGetNI( pPar1 );

      if( uiFKey > 0 && uiFKey <= 40 )
      {
         char szName[ 4 ];

         snprintf( szName, sizeof( szName ), "F%i", uiFKey );
         hb_retc( szName );
         return;
      }
   }

   hb_retc_null();
}
fkmax.c65
fnsplit.c
TypeFunctionSourceLine
HB_FUNCHB_FNAMESPLIT(void)
HB_FUNC( HB_FNAMESPLIT )
{
   if( ISCHAR( 1 ) )
   {
      PHB_FNAME pFileName = hb_fsFNameSplit( hb_parc( 1 ) );

      hb_storc( pFileName->szPath, 2 );
      hb_storc( pFileName->szName, 3 );
      hb_storc( pFileName->szExtension, 4 );
      hb_storc( pFileName->szDrive, 5 );

      hb_xfree( pFileName );
   }
}
fnsplit.c56
HB_FUNCHB_FNAMEMERGE(void)
HB_FUNC( HB_FNAMEMERGE )
{
   HB_FNAME pFileName;
   char szFileName[ _POSIX_PATH_MAX + 1 ];

   pFileName.szPath = hb_parc( 1 );
   pFileName.szName = hb_parc( 2 );
   pFileName.szExtension = hb_parc( 3 );
   pFileName.szDrive = hb_parc( 4 );

   hb_retc( hb_fsFNameMerge( szFileName, &pFileName ) );
}
fnsplit.c71
fserror.c
TypeFunctionSourceLine
STATIC INThb_errnoToDosError( int ErrCode )
static int hb_errnoToDosError( int ErrCode )
{
   int iResult;

#if defined(__BORLANDC__)
   /* These C compilers use DOS error codes in errno */
   iResult = ErrCode;
#else
   switch( ErrCode )
   {
#if defined( ENMFILE )
      case ENMFILE:
#endif
      case ENOENT:
         iResult = 2;   /* File not found */
         break;
#if defined( ENOTDIR )
      case ENOTDIR:
         iResult = 3;   /* Path not found */
         break;
#endif
#if defined( ENFILE )
      case ENFILE:
#endif
      case EMFILE:
         iResult = 4;   /* Too many open files */
         break;
      case EACCES:
#if defined( ETXTBSY )
      case ETXTBSY:
#endif
         iResult = 5;   /* Access denied */
         break;
      case EBADF:
         iResult = 6;   /* Invalid handle */
         break;
      case ENOMEM:
         iResult = 8;   /* Insufficient memory */
         break;
#if defined( EFAULT )
      case EFAULT:
         iResult = 9;   /* Invalid memory block address */
         break;
#endif
      case EINVAL:
         iResult = 13;  /* Invalid data */
         break;
#if defined( EROFS )
      case EROFS:
         iResult = 19;  /* Attempt to write on write-protected diskette */
         break;
#endif
#if defined( ESPIPE )
      case ESPIPE:
         iResult = 25;  /* Seek error */
         break;
#endif
#if defined( ENOSPC )
      case ENOSPC:
         iResult = 29;  /* Write fault */
         break;
#endif
      case EPIPE:
         iResult = 29;  /* Write fault */
         break;
      case EEXIST:
         iResult = 32;  /* Sharing violation */
         break;
      case EAGAIN:
         iResult = 33;  /* Lock violation */
         break;
      default:
         iResult = ErrCode;
         break;
   }
#endif

   return iResult;
}
fserror.c66
STATIC INThb_WinToDosError( ULONG ulError )
static int hb_WinToDosError( ULONG ulError )
{
   int iResult;

   switch( ulError )
   {
      case ERROR_ALREADY_EXISTS:
         iResult = 5;
         break;
      case ERROR_FILE_NOT_FOUND:
         iResult = 2;
         break;
      case ERROR_PATH_NOT_FOUND:
         iResult = 3;
         break;
      case  ERROR_TOO_MANY_OPEN_FILES:
         iResult = 4;
         break;
      case ERROR_INVALID_HANDLE:
         iResult = 6;
         break;

      default:
         iResult = ( int ) ulError;
         break;
   }

   return iResult;
}
fserror.c148
HB_EXPORT USHORThb_fsGetFError( void )
HB_EXPORT USHORT hb_fsGetFError( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsGetFError()"));

   return hb_stackIOErrors()->uiFError;
}
fserror.c179
HB_EXPORT USHORThb_fsError( void )
HB_EXPORT USHORT hb_fsError( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsError()"));

   return hb_stackIOErrors()->uiErrorLast;
}
fserror.c187
HB_EXPORT USHORThb_fsOsError( void )
HB_EXPORT USHORT hb_fsOsError( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsOsError()"));

   return hb_stackIOErrors()->uiOsErrorLast;
}
fserror.c195
HB_EXPORT VOIDhb_fsSetFError( USHORT uiError )
HB_EXPORT void hb_fsSetFError( USHORT uiError )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_fsSetFError(%hu)", uiError));

   hb_stackIOErrors()->uiFError = uiError;
}
fserror.c203
HB_EXPORT VOIDhb_fsSetError( USHORT uiError )
HB_EXPORT void  hb_fsSetError( USHORT uiError )
{
   PHB_IOERRORS pIOErrors;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsSetError(%hu)", uiError));

   pIOErrors = hb_stackIOErrors();
   /* TODO: untranslate uiError into errno */
   pIOErrors->uiOsErrorLast = pIOErrors->uiErrorLast = uiError;
}
fserror.c211
HB_EXPORT VOIDhb_fsSetIOError( BOOL fResult, USHORT uiOperation )
HB_EXPORT void  hb_fsSetIOError( BOOL fResult, USHORT uiOperation )
{
   USHORT uiOsErrorLast, uiErrorLast;
   PHB_IOERRORS pIOErrors;

   /* TODO: implement it */
   HB_SYMBOL_UNUSED( uiOperation );

   if( fResult )
   {
      uiOsErrorLast = uiErrorLast = 0;
   }
   else
   {
#if defined(HB_WIN32_IO) || defined(HB_OS_WIN_32)
      uiOsErrorLast = ( USHORT ) GetLastError();
      uiErrorLast = ( USHORT ) hb_WinToDosError( uiOsErrorLast );
#elif defined(_MSC_VER) || defined(__DMC__)
      #ifdef __XCC__
         extern unsigned long _doserrno;
         extern void __cdecl _dosmaperr( unsigned long oserrno );
         _dosmaperr( GetLastError() );
      #endif
      if( _doserrno != 0 )
      {
         uiOsErrorLast = uiErrorLast = _doserrno;
      }
      else
      {
         uiOsErrorLast = errno;
         uiErrorLast = hb_errnoToDosError( errno );
      }
#else
      uiOsErrorLast = errno;
      uiErrorLast = hb_errnoToDosError( uiOsErrorLast );
#endif
   }
   pIOErrors = hb_stackIOErrors();
   pIOErrors->uiOsErrorLast = uiOsErrorLast;
   pIOErrors->uiErrorLast = uiErrorLast;
}
fserror.c223
fssize.c
TypeFunctionSourceLine
HB_FOFFSEThb_fsFSize( BYTE * pszFileName, BOOL bUseDirEntry )
HB_FOFFSET hb_fsFSize( BYTE * pszFileName, BOOL bUseDirEntry )
{
   if( bUseDirEntry )
   {
#if defined(HB_WINCE)
      BOOL fFree;
      PHB_FFIND ffind;
      pszFileName = hb_fsNameConv( pszFileName, &fFree );
      ffind = hb_fsFindFirst( ( char * ) pszFileName, HB_FA_ALL );
      if( fFree )
         hb_xfree( pszFileName );
      hb_fsSetIOError( ffind != NULL, 0 );
      if( ffind )
      {
         HB_FOFFSET size = ffind->size;
         hb_fsFindClose( ffind );
         return size;
      }
#elif defined( HB_USE_LARGEFILE64 )
      BOOL fResult, fFree;
      struct stat64 statbuf;
      pszFileName = hb_fsNameConv( pszFileName, &fFree );
      hb_vmUnlock();
      fResult = stat64( ( char * ) pszFileName, &statbuf ) == 0;
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
      if( fFree )
         hb_xfree( pszFileName );
      if( fResult )
         return ( HB_FOFFSET ) statbuf.st_size;
#else
      BOOL fResult, fFree;
      struct stat statbuf;
      pszFileName = hb_fsNameConv( pszFileName, &fFree );
      hb_vmUnlock();
      fResult = stat( ( char * ) pszFileName, &statbuf ) == 0;
      hb_fsSetIOError( fResult, 0 );
      hb_vmLock();
      if( fFree )
         hb_xfree( pszFileName );
      if( fResult )
         return ( HB_FOFFSET ) statbuf.st_size;
#endif
   }
   else
   {
      HB_FHANDLE hFileHandle = hb_fsOpen( pszFileName, 0 );

      if( hFileHandle != FS_ERROR )
      {
         HB_FOFFSET ulPos;

         ulPos = hb_fsSeekLarge( hFileHandle, 0, SEEK_END );
         hb_fsClose( hFileHandle );
         return ulPos;
      }
   }
   return 0;
}
fssize.c81
HB_FUNCHB_FSIZE(void)
HB_FUNC( HB_FSIZE )
{
   hb_retnint( ISCHAR( 1 ) ? hb_fsFSize( ( BYTE * ) hb_parc( 1 ),
                                    ISLOG( 2 ) ? hb_parl( 2 ) : TRUE ) : 0 );
}
fssize.c141
fstemp.c
TypeFunctionSourceLine
STATIC BOOLhb_fsTempName( BYTE * pszBuffer, const BYTE * pszDir, const BYTE * pszPrefix )
static BOOL hb_fsTempName( BYTE * pszBuffer, const BYTE * pszDir, const BYTE * pszPrefix )
{
   BOOL fResult;

   hb_vmUnlock();

#if defined(HB_WIN32_IO)
   {
      char cTempDir[ _POSIX_PATH_MAX + 1 ];

      if( pszDir && pszDir[ 0 ] != '\0' )
         hb_strncpy( ( char * ) cTempDir, ( const char * ) pszDir, sizeof( cTempDir ) - 1 );
      else
      {
         if( ! GetTempPathA( ( DWORD ) _POSIX_PATH_MAX + 1, cTempDir ) )
         {
            hb_fsSetIOError( FALSE, 0 );
            return FALSE;
         }
      }
      cTempDir[ _POSIX_PATH_MAX ] = '\0';

      fResult = GetTempFileNameA( ( LPCSTR ) cTempDir, pszPrefix ? ( LPCSTR ) pszPrefix : ( LPCSTR ) "hb", 0, ( LPSTR ) pszBuffer );
   }
#else

   /* TODO: Implement these: */
   HB_SYMBOL_UNUSED( pszDir );
   HB_SYMBOL_UNUSED( pszPrefix );

   /* TOFIX: The spec says to reserve L_tmpnam number of characters for the
             passed buffer. It will be needed to fix _POSIX_PATH_MAX to be
             at least this large. */

   pszBuffer[ 0 ] = '\0';
   fResult = ( tmpnam( ( char * ) pszBuffer ) != NULL );

#endif

   hb_fsSetIOError( fResult, 0 );
   hb_vmLock();

   return fResult;
}
fstemp.c69
HB_EXPORT HB_FHANDLEhb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName )
HB_EXPORT HB_FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName )
{
   USHORT nAttemptLeft = 999;

   while( --nAttemptLeft )
   {
      if( hb_fsTempName( pszName, pszDir, pszPrefix ) )
      {
          HB_FHANDLE fhnd = hb_fsCreateEx( pszName, ulAttr, FO_EXCLUSIVE | FO_EXCL );

          /* This function may fail, if the generated filename got
             used between generation and the file creation. */

          if( fhnd != FS_ERROR )
             return fhnd;
      }
      else
      {
         /* Don't attempt to retry if the filename generator is
            failing for some reason. */
         break;
      }
   }

   return FS_ERROR;
}
fstemp.c116
STATIC BOOLfsGetTempDirByCase( BYTE *pszName, const char *pszTempDir )
static BOOL fsGetTempDirByCase( BYTE *pszName, const char *pszTempDir )
{
   BOOL fOK = FALSE;

   if( pszTempDir && *pszTempDir != '\0' )
   {
      hb_strncpy( ( char * ) pszName, ( char * ) pszTempDir, _POSIX_PATH_MAX );
      switch( hb_setGetDirCase() )
      {
         case HB_SET_CASE_LOWER:
            hb_strLower( ( char * ) pszName, strlen( ( char * ) pszName ) );
            fOK = strcmp( ( char * ) pszName, pszTempDir ) == 0;
            break;
         case HB_SET_CASE_UPPER:
            hb_strUpper( ( char * ) pszName, strlen( ( char * ) pszName ) );
            fOK = strcmp( ( char * ) pszName, pszTempDir ) == 0;
            break;
         default:
            fOK = TRUE;
            break;
      }
   }

   return fOK;
}
fstemp.c146
HB_EXPORT HB_FHANDLEhb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName )
HB_EXPORT HB_FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName )
{
   /* less attemps */
   int iAttemptLeft = 99, iLen;
   HB_FHANDLE fd;

   do
   {
      pszName[ 0 ] = '\0';

      if( pszDir && pszDir[ 0 ] != '\0' )
      {
         hb_strncpy( ( char * ) pszName, ( char * ) pszDir, _POSIX_PATH_MAX );
      }
      else
      {
         char * pszTmpDir = hb_getenv( "TMPDIR" );

         if( !fsGetTempDirByCase( pszName, pszTmpDir ) )
         {
#ifdef P_tmpdir
            if( !fsGetTempDirByCase( pszName, P_tmpdir ) )
#endif
            {
               pszName[ 0 ] = '.';
               pszName[ 1 ] = '\0';
            }
         }
         if( pszTmpDir )
            hb_xfree( pszTmpDir );
      }

      if( pszName[0] != '\0' )
      {
         int len;
         len = strlen( ( char * ) pszName );
         pszName[ len ] = ( BYTE ) HB_OS_PATH_DELIM_CHR;
         pszName[ len + 1 ] = '\0';
      }

      if( pszPrefix )
         hb_strncat( ( char * ) pszName, ( char * ) pszPrefix, _POSIX_PATH_MAX );

      iLen = ( int ) strlen( ( char * ) pszName );
      if( iLen > _POSIX_PATH_MAX - 6 )
         return FS_ERROR;

#if !defined(__WATCOMC__) && ( defined( HB_OS_LINUX ) || defined( HB_OS_BSD ) )
      if( hb_setGetFileCase() != HB_SET_CASE_LOWER &&
          hb_setGetFileCase() != HB_SET_CASE_UPPER &&
          hb_setGetDirCase() != HB_SET_CASE_LOWER &&
          hb_setGetDirCase() != HB_SET_CASE_UPPER )
      {
         hb_strncat( ( char * ) pszName, "XXXXXX", _POSIX_PATH_MAX );
         hb_vmUnlock();
         fd = ( HB_FHANDLE ) mkstemp( ( char * ) pszName );
         hb_fsSetIOError( fd != ( HB_FHANDLE ) -1, 0 );
         hb_vmLock();
      }
      else
#endif
      {
         int i, n;
         double d = hb_random_num(), x;

         for( i = 0; i < 6; i++ )
         {
            d = d * 36;
            n = ( int ) d;
            d = modf( d, &x );
            pszName[ iLen++ ] = n + ( n > 9 ? 'a' - 10 : '0' );
         }
         hb_fsNameConv( pszName, NULL );
         fd = hb_fsCreateEx( pszName, ulAttr, FO_EXCLUSIVE | FO_EXCL );
      }

      if( fd != ( HB_FHANDLE ) FS_ERROR )
         return fd;
   }
   while( --iAttemptLeft );

   return FS_ERROR;
}
fstemp.c172
HB_FUNCHB_FTEMPCREATE(void)
HB_FUNC( HB_FTEMPCREATE )
{
   BYTE szName[ _POSIX_PATH_MAX + 1 ];

   hb_retnint( ( HB_NHANDLE ) hb_fsCreateTemp( ( BYTE * ) hb_parc( 1 ),
               ( BYTE * ) hb_parc( 2 ),
               ( ULONG ) ( ISNUM( 3 ) ? ( ULONG ) hb_parnl( 3 ) : FC_NORMAL ),
                szName ) );

   hb_storc( ( char *) szName, 4 );
}
fstemp.c258
gete.c
TypeFunctionSourceLine
HB_FUNCGETENV(void)
HB_FUNC( GETENV )
{
   PHB_ITEM pName = hb_param( 1, HB_IT_STRING );

#ifdef HB_EXTENSION
   if( pName )
#else
   if( pName && hb_pcount() == 1 )
#endif
   {
      char * pszName = hb_itemGetC( pName );
      ULONG ulName = strlen( pszName );
      ULONG ulPos;

      /* strip the '=' or else it will clear the variable! */

      for( ulPos = 0; ulPos < ulName; ulPos++ )
      {
         if( pszName[ ulPos ] == '=' )
         {
            pszName[ ulPos ] = '\0';
            break;
         }
      }

      if( pszName[ 0 ] != '\0' )
      {
         char * szValue;

         /* NOTE: Convert the envvar name to uppercase. This is required for
                  DOS and OS/2 systems. [vszakats] */

         #if defined(HB_OS_DOS) || defined(HB_OS_OS2)
            hb_strupr( pszName );
         #endif

         szValue = hb_getenv( pszName );
         if( szValue && szValue[ 0 ] != '\0' )
            hb_retc_buffer( szValue );
         else
         {
            if( szValue )
               hb_xfree( szValue );
#ifdef HB_EXTENSION
            hb_retc( hb_parc( 2 ) );
#else
            hb_retc( NULL );
#endif
         }
      }
      else
         hb_retc( NULL );

      hb_itemFreeC( pszName );
   }
   else
      hb_retc( NULL );
}
gete.c71
HB_FUNCGETE(void)
HB_FUNC( GETE )
{
   HB_FUNC_EXEC( GETENV );
}
gete.c132
HB_FUNCHB_GETENV(void)
HB_FUNC( HB_GETENV )
{
   PHB_ITEM pName = hb_param( 1, HB_IT_STRING );

   if( pName )
   {
      char * pszName = hb_itemGetC( pName );
      ULONG ulName = strlen( pszName );
      ULONG ulPos;

      /* strip the '=' or else it will clear the variable! */

      for( ulPos = 0; ulPos < ulName; ulPos++ )
      {
         if( pszName[ ulPos ] == '=' )
         {
            pszName[ ulPos ] = '\0';
            break;
         }
      }

      if( pszName[ 0 ] != '\0' )
      {
         char * szValue;

         /* NOTE: Convert the envvar name to uppercase. This is required for
                  DOS and OS/2 systems. [vszakats] */

         #if defined(HB_OS_DOS) || defined(HB_OS_OS2)
            hb_strupr( pszName );
         #endif

         szValue = hb_getenv( pszName );
         if( szValue && szValue[ 0 ] != '\0' )
            hb_retc_buffer( szValue );
         else
         {
            if( szValue )
               hb_xfree( szValue );
            hb_retc( hb_parc( 2 ) );
         }
      }
      else
         hb_retc( NULL );

      hb_itemFreeC( pszName );
   }
   else
      hb_retc( NULL );
}
gete.c141
gt.c
TypeFunctionSourceLine
HB_FUNCDISPBEGIN(void)
HB_FUNC( DISPBEGIN )
{
   hb_gtDispBegin();
}
gt.c56
HB_FUNCDISPEND(void)
HB_FUNC( DISPEND )
{
   hb_gtDispEnd();
}
gt.c61
HB_FUNCDISPCOUNT(void)
HB_FUNC( DISPCOUNT )
{
   hb_retni( hb_gtDispCount() );
}
gt.c66
gtapi.c
TypeFunctionSourceLine
HB_EXPORT ERRCODEhb_gtInit( HB_FHANDLE hFilenoStdin, HB_FHANDLE hFilenoStdout, HB_FHANDLE hFilenoStderr )
HB_EXPORT ERRCODE hb_gtInit( HB_FHANDLE hFilenoStdin, HB_FHANDLE hFilenoStdout, HB_FHANDLE hFilenoStderr )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtInit()"));

   hb_gtStartupInit();

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_INIT( pGT, hFilenoStdin, hFilenoStdout, hFilenoStderr );
      HB_GTSELF_SETCOLORSTR( pGT, hb_setGetColor() );
      HB_GTSELF_SETCURSORSTYLE( pGT, SC_NORMAL );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
   }

   if( hb_cmdargCheck( "INFO" ) )
   {
      if( pGT )
         hb_conOutErr( HB_GTSELF_VERSION( pGT, 1 ), 0 );
      hb_conOutErr( hb_conNewLine(), 0 );
   }

   return SUCCESS;
}
gtapi.c89
HB_EXPORT ERRCODEhb_gtExit( void )
HB_EXPORT ERRCODE hb_gtExit( void )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtExit()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      while( HB_GTSELF_DISPCOUNT( pGT ) )
         HB_GTSELF_DISPEND( pGT );

      HB_GTSELF_FLUSH( pGT );
      HB_GTSELF_EXIT( pGT );
      hb_gt_BaseFree( pGT );
   }

   hb_gtUnLoad();

   return SUCCESS;
}
gtapi.c117
HB_EXPORT INThb_gtReadKey( int iEventMask )
HB_EXPORT int hb_gtReadKey( int iEventMask )
{
   int iKey = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtReadKey(%d)", iEventMask));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iKey = HB_GTSELF_READKEY( pGT, iEventMask );
      hb_gt_BaseFree( pGT );
   }
   return iKey;
}
gtapi.c139
HB_EXPORT ERRCODEhb_gtBox( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right, BYTE * pbyFrame )
HB_EXPORT ERRCODE hb_gtBox( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right, BYTE * pbyFrame )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtBox(%hd, %hd, %hd, %hd, %p)", Top, Left, Bottom, Right, pbyFrame));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_BOX( pGT, Top, Left, Bottom, Right, pbyFrame, HB_GTSELF_GETCOLOR( pGT ) );
      HB_GTSELF_SETPOS( pGT, Top + 1, Left + 1 );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c155
HB_EXPORT ERRCODEhb_gtBoxD( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right )
HB_EXPORT ERRCODE hb_gtBoxD( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtBoxD(%hd, %hd, %hd, %hd)", Top, Left, Bottom, Right));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_BOXD( pGT, Top, Left, Bottom, Right, ( BYTE * ) _B_DOUBLE, HB_GTSELF_GETCOLOR( pGT ) );
      HB_GTSELF_SETPOS( pGT, Top + 1, Left + 1 );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c173
HB_EXPORT ERRCODEhb_gtBoxS( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right )
HB_EXPORT ERRCODE hb_gtBoxS( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtBoxS(%hd, %hd, %hd, %hd)", Top, Left, Bottom, Right));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_BOXD( pGT, Top, Left, Bottom, Right, ( BYTE * ) _B_SINGLE, HB_GTSELF_GETCOLOR( pGT ) );
      HB_GTSELF_SETPOS( pGT, Top + 1, Left + 1 );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c191
HB_EXPORT ERRCODEhb_gtColorSelect( USHORT uiColorIndex )
HB_EXPORT ERRCODE hb_gtColorSelect( USHORT uiColorIndex )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtColorSelect(%hu)", uiColorIndex));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_COLORSELECT( pGT, uiColorIndex );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c209
HB_EXPORT ERRCODEhb_gtDispBegin( void )
HB_EXPORT ERRCODE hb_gtDispBegin( void )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtDispBegin()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_DISPBEGIN( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c225
HB_EXPORT USHORThb_gtDispCount( void )
HB_EXPORT USHORT hb_gtDispCount( void )
{
   USHORT uiCount = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtDispCount()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      uiCount = HB_GTSELF_DISPCOUNT( pGT );
      hb_gt_BaseFree( pGT );
   }
   return uiCount;
}
gtapi.c241
HB_EXPORT ERRCODEhb_gtDispEnd( void )
HB_EXPORT ERRCODE hb_gtDispEnd( void )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtDispEnd()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_DISPEND( pGT );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c257
HB_EXPORT ERRCODEhb_gtPreExt( void )
HB_EXPORT ERRCODE hb_gtPreExt( void )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtPreExt()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_PREEXT( pGT ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c274
HB_EXPORT ERRCODEhb_gtPostExt( void )
HB_EXPORT ERRCODE hb_gtPostExt( void )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtPostExt()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_POSTEXT( pGT ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c291
HB_EXPORT ERRCODEhb_gtGetColorStr( char * pszColorString )
HB_EXPORT ERRCODE hb_gtGetColorStr( char * pszColorString )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGetColorStr(%s)", pszColorString));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_GETCOLORSTR( pGT, pszColorString );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   pszColorString[0] = '\0';
   return FAILURE;
}
gtapi.c313
HB_EXPORT INThb_gtColorToN( char * szColorString )
HB_EXPORT int hb_gtColorToN( char * szColorString )
{
   int iColor = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtColorToN(%s)", szColorString));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iColor = HB_GTSELF_COLORNUM( pGT, szColorString );
      hb_gt_BaseFree( pGT );
   }
   return iColor;
}
gtapi.c330
HB_EXPORT ERRCODEhb_gtColorsToString( int * pColors, int iColorCount, char * pszColorString, int iBufSize )
HB_EXPORT ERRCODE hb_gtColorsToString( int * pColors, int iColorCount, char * pszColorString, int iBufSize )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtColorsToString(%p, %d, %p, %d)", pColors, iColorCount, pszColorString, iBufSize));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_COLORSTOSTRING( pGT, pColors, iColorCount, pszColorString, iBufSize );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   pszColorString[0] = '\0';
   return FAILURE;
}
gtapi.c346
HB_EXPORT ERRCODEhb_gtSetColorStr( const char * szColorString )
HB_EXPORT ERRCODE hb_gtSetColorStr( const char * szColorString )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetColorStr(%s)", szColorString));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_SETCOLORSTR( pGT, szColorString );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c363
HB_EXPORT ERRCODEhb_gtGetCursor( USHORT * uipCursorStyle )
HB_EXPORT ERRCODE hb_gtGetCursor( USHORT * uipCursorStyle )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGetCursor(%p)", uipCursorStyle));

   pGT = hb_gt_Base();
   if( pGT )
   {
      *uipCursorStyle = HB_GTSELF_GETCURSORSTYLE( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   *uipCursorStyle = SC_NONE;
   return FAILURE;
}
gtapi.c379
HB_EXPORT ERRCODEhb_gtSetCursor( USHORT uiCursorStyle )
HB_EXPORT ERRCODE hb_gtSetCursor( USHORT uiCursorStyle )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetCursor(%hu)", uiCursorStyle));

   if( uiCursorStyle <= SC_SPECIAL2 )
   {
      PHB_GT pGT = hb_gt_Base();
      if( pGT )
      {
         HB_GTSELF_SETCURSORSTYLE( pGT, uiCursorStyle );
         HB_GTSELF_FLUSH( pGT );
         hb_gt_BaseFree( pGT );
         return SUCCESS;
      }
   }
   return FAILURE;
}
gtapi.c396
HB_EXPORT ERRCODEhb_gtGetPos( SHORT * piRow, SHORT * piCol )
HB_EXPORT ERRCODE hb_gtGetPos( SHORT * piRow, SHORT * piCol )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGetPos(%p, %p)", piRow, piCol));

   pGT = hb_gt_Base();
   if( pGT )
   {
      int iRow, iCol;

      HB_GTSELF_GETPOS( pGT, &iRow, &iCol );
      *piRow = ( SHORT ) iRow;
      *piCol = ( SHORT ) iCol;
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   *piRow = *piCol = 0;
   return FAILURE;
}
gtapi.c414
HB_EXPORT ERRCODEhb_gtSetPos( SHORT iRow, SHORT iCol )
HB_EXPORT ERRCODE hb_gtSetPos( SHORT iRow, SHORT iCol )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetPos(%hd, %hd)", iRow, iCol));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_SETPOS( pGT, iRow, iCol );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c438
HB_EXPORT USHORThb_gtMaxCol( void )
HB_EXPORT USHORT hb_gtMaxCol( void )
{
   USHORT uiMaxCol = 79;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtMaxCol()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      uiMaxCol = HB_GTSELF_MAXCOL( pGT );
      hb_gt_BaseFree( pGT );
   }
   return uiMaxCol;
}
gtapi.c455
HB_EXPORT USHORThb_gtMaxRow( void )
HB_EXPORT USHORT hb_gtMaxRow( void )
{
   USHORT uiMaxRow = 24;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtMaxRow()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      uiMaxRow = HB_GTSELF_MAXROW( pGT );
      hb_gt_BaseFree( pGT );
   }
   return uiMaxRow;
}
gtapi.c471
HB_EXPORT ERRCODEhb_gtScrDim( USHORT * uipHeight, USHORT * uipWidth )
HB_EXPORT ERRCODE hb_gtScrDim( USHORT * uipHeight, USHORT * uipWidth )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtScrDim(%p, %p)", uipHeight, uipWidth));

   pGT = hb_gt_Base();
   if( pGT )
   {
      int iHeight, iWidth;

      HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
      *uipHeight = ( USHORT ) iHeight;
      *uipWidth  = ( USHORT ) iWidth;
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   *uipHeight = *uipWidth = 0;
   return FAILURE;
}
gtapi.c487
HB_EXPORT ERRCODEhb_gtSetSnowFlag( BOOL fNoSnow )
HB_EXPORT ERRCODE hb_gtSetSnowFlag( BOOL fNoSnow )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetSnowFlag(%d)", (int) fNoSnow));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_SETSNOWFLAG( pGT, fNoSnow );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c508
HB_EXPORT ERRCODEhb_gtRectSize( int iTop, int iLeft, int iBottom, int iRight, ULONG * pulBuffSize )
HB_EXPORT ERRCODE hb_gtRectSize( int iTop, int iLeft, int iBottom, int iRight, ULONG * pulBuffSize )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtRectSize(%d, %d, %d, %d, %p)", iTop, iLeft, iBottom, iRight, pulBuffSize));

   pGT = hb_gt_Base();
   if( pGT )
   {
      *pulBuffSize = HB_GTSELF_RECTSIZE( pGT, iTop, iLeft, iBottom, iRight );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   *pulBuffSize = 0;
   return FAILURE;
}
gtapi.c524
HB_EXPORT BOOLhb_gtIsColor( void )
HB_EXPORT BOOL hb_gtIsColor( void )
{
   BOOL fColor = TRUE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtIsColor()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      fColor = HB_GTSELF_ISCOLOR( pGT );
      hb_gt_BaseFree( pGT );
   }
   return fColor;
}
gtapi.c541
HB_EXPORT ERRCODEhb_gtRepChar( USHORT uiRow, USHORT uiCol, BYTE byChar, USHORT uiCount )
HB_EXPORT ERRCODE hb_gtRepChar( USHORT uiRow, USHORT uiCol, BYTE byChar, USHORT uiCount )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtRepChar(%hu, %hu, %d, %hu)", uiRow, uiCol, (int) byChar, uiCount));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_REPLICATE( pGT, uiRow, uiCol, HB_GTSELF_GETCOLOR( pGT ), 0,
                           byChar, uiCount );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c557
HB_EXPORT ERRCODEhb_gtSave( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, void * pScrBuff )
HB_EXPORT ERRCODE hb_gtSave( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, void * pScrBuff )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSave(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pScrBuff));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_SAVE( pGT, uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) pScrBuff );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c575
HB_EXPORT ERRCODEhb_gtRest( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, void * pScrBuff )
HB_EXPORT ERRCODE hb_gtRest( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, void * pScrBuff )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtRest(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pScrBuff));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_REST( pGT, uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) pScrBuff );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c591
HB_EXPORT ERRCODEhb_gtGetChar( USHORT uiRow, USHORT uiCol, BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
HB_EXPORT ERRCODE hb_gtGetChar( USHORT uiRow, USHORT uiCol, BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGetChar(%hu, %hu, %p, %p, %p)", uiRow, uiCol, pbColor, pbAttr, pusChar));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_GETCHAR( pGT, uiRow, uiCol, pbColor, pbAttr, pusChar ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c608
HB_EXPORT ERRCODEhb_gtPutChar( USHORT uiRow, USHORT uiCol, BYTE bColor, BYTE bAttr, USHORT usChar )
HB_EXPORT ERRCODE hb_gtPutChar( USHORT uiRow, USHORT uiCol, BYTE bColor, BYTE bAttr, USHORT usChar )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtPutChar(%hu, %hu, %hu, %hu, %hu)", uiRow, uiCol, bColor, bAttr, usChar));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_PUTCHAR( pGT, uiRow, uiCol, bColor, bAttr, usChar ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c625
HB_EXPORT ERRCODEhb_gtBeginWrite( void )
HB_EXPORT ERRCODE hb_gtBeginWrite( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gtBeginWrite()"));

   /* Do nothing in Harbour */

   return SUCCESS;
}
gtapi.c642
HB_EXPORT ERRCODEhb_gtEndWrite( void )
HB_EXPORT ERRCODE hb_gtEndWrite( void )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtEndWrite()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c651
HB_EXPORT ERRCODEhb_gtGetBlink( BOOL * bpBlink )
HB_EXPORT ERRCODE hb_gtGetBlink( BOOL * bpBlink )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGetBlink(%p)", bpBlink));

   pGT = hb_gt_Base();
   if( pGT )
   {
      *bpBlink = HB_GTSELF_GETBLINK( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   *bpBlink = 0;
   return FAILURE;
}
gtapi.c667
HB_EXPORT ERRCODEhb_gtSetBlink( BOOL fBlink )
HB_EXPORT ERRCODE hb_gtSetBlink( BOOL fBlink )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetBlink(%d)", (int) fBlink));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_SETBLINK( pGT, fBlink );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c684
HB_EXPORT ERRCODEhb_gtSetMode( USHORT uiRows, USHORT uiCols )
HB_EXPORT ERRCODE hb_gtSetMode( USHORT uiRows, USHORT uiCols )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetMode(%hu, %hu)", uiRows, uiCols));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_SETMODE( pGT, uiRows, uiCols ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c700
HB_EXPORT ERRCODEhb_gtWriteAt( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength )
HB_EXPORT ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtWriteAt(%hu, %hu, %p, %lu)", uiRow, uiCol, pStr, ulLength));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_WRITEAT( pGT, uiRow, uiCol, pStr, ulLength );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c717
HB_EXPORT ERRCODEhb_gtWrite( BYTE * pStr, ULONG ulLength )
HB_EXPORT ERRCODE hb_gtWrite( BYTE * pStr, ULONG ulLength )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtWrite(%p, %lu)", pStr, ulLength));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_WRITE( pGT, pStr, ulLength );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c734
HB_EXPORT ERRCODEhb_gtWriteCon( BYTE * pStr, ULONG ulLength )
HB_EXPORT ERRCODE hb_gtWriteCon( BYTE * pStr, ULONG ulLength )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtWriteCon(%p, %lu)", pStr, ulLength));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_WRITECON( pGT, pStr, ulLength );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c751
HB_EXPORT ERRCODEhb_gtScroll( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, SHORT iRows, SHORT iCols )
HB_EXPORT ERRCODE hb_gtScroll( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, SHORT iRows, SHORT iCols )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gtScroll(%hu, %hu, %hu, %hu, %hd, %hd)", uiTop, uiLeft, uiBottom, uiRight, iRows, iCols));

   if( uiTop <= uiBottom && uiLeft <= uiRight )
   {
      PHB_GT pGT = hb_gt_Base();
      if( pGT )
      {
         HB_GTSELF_SCROLL( pGT, uiTop, uiLeft, uiBottom, uiRight,
                           HB_GTSELF_GETCOLOR( pGT ), ' ', iRows, iCols );
         HB_GTSELF_FLUSH( pGT );
         hb_gt_BaseFree( pGT );
         return SUCCESS;
      }
   }
   return FAILURE;
}
gtapi.c768
HB_EXPORT ERRCODEhb_gtScrollUp( USHORT uiRows )
HB_EXPORT ERRCODE hb_gtScrollUp( USHORT uiRows )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gtScrollUp(%hd)", uiRows));

   if( uiRows != 0 )
   {
      PHB_GT pGT = hb_gt_Base();
      if( pGT )
      {
         HB_GTSELF_SCROLLUP( pGT, uiRows, HB_GTSELF_GETCOLOR( pGT ), ' ' );
         HB_GTSELF_FLUSH( pGT );
         hb_gt_BaseFree( pGT );
         return SUCCESS;
      }
   }
   return FAILURE;
}
gtapi.c787
HB_EXPORT ERRCODEhb_gtDrawShadow( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr )
HB_EXPORT ERRCODE hb_gtDrawShadow( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtDrawShadow(%hu, %hu, %hu, %hu, %d)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_DRAWSHADOW( pGT, uiTop, uiLeft, uiBottom, uiRight, byAttr );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c805
HB_EXPORT ERRCODEhb_gtTone( double dFrequency, double dDuration )
HB_EXPORT ERRCODE hb_gtTone( double dFrequency, double dDuration )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtTone(%lf, %lf)", dFrequency, dDuration));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_TONE( pGT, dFrequency, dDuration );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c822
HB_EXPORT CONST CHAR *hb_gtVersion( int iType )
HB_EXPORT const char * hb_gtVersion( int iType )
{
   const char * szVersion = "";
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtVersion(%d)",iType));

   pGT = hb_gt_Base();
   if( pGT )
   {
      szVersion = HB_GTSELF_VERSION( pGT, iType );
      hb_gt_BaseFree( pGT );
   }
   return szVersion;
}
gtapi.c838
HB_EXPORT ERRCODEhb_gtSetAttribute( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr )
HB_EXPORT ERRCODE hb_gtSetAttribute( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetAttribute(%hu, %hu, %hu, %hu, %d)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_SETATTRIBUTE( pGT, uiTop, uiLeft, uiBottom, uiRight, byAttr );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c854
HB_EXPORT ERRCODEhb_gtSuspend( void )
HB_EXPORT ERRCODE hb_gtSuspend( void )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSuspend()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_SUSPEND( pGT ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c871
HB_EXPORT ERRCODEhb_gtResume( void )
HB_EXPORT ERRCODE hb_gtResume( void )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtResume()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_RESUME( pGT ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c889
HB_EXPORT ERRCODEhb_gtOutStd( BYTE * pbyStr, ULONG ulLen )
HB_EXPORT ERRCODE hb_gtOutStd( BYTE * pbyStr, ULONG ulLen )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtOutStd(%p, %lu)", pbyStr, ulLen));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_OUTSTD( pGT, pbyStr, ulLen );
      hb_gt_BaseFree( pGT );
   }
   else
      hb_fsWriteLarge( ( HB_FHANDLE ) HB_STDOUT_HANDLE, pbyStr, ulLen );

   return SUCCESS;
}
gtapi.c906
HB_EXPORT ERRCODEhb_gtOutErr( BYTE * pbyStr, ULONG ulLen )
HB_EXPORT ERRCODE hb_gtOutErr( BYTE * pbyStr, ULONG ulLen )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtOutErr(%p, %lu)", pbyStr, ulLen));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_OUTERR( pGT, pbyStr, ulLen );
      hb_gt_BaseFree( pGT );
   }
   else
      hb_fsWriteLarge( ( HB_FHANDLE ) HB_STDERR_HANDLE, pbyStr, ulLen );

   return SUCCESS;
}
gtapi.c924
HB_EXPORT ERRCODEhb_gtSetDispCP( char * pszTermCDP, char * pszHostCDP, BOOL fBox )
HB_EXPORT ERRCODE hb_gtSetDispCP( char * pszTermCDP, char * pszHostCDP, BOOL fBox )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetDispCP(%s, %s, %d)", pszTermCDP, pszHostCDP, fBox));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c942
HB_EXPORT ERRCODEhb_gtSetKeyCP( char * pszTermCDP, char * pszHostCDP )
HB_EXPORT ERRCODE hb_gtSetKeyCP( char * pszTermCDP, char * pszHostCDP )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetKeyCP(%s, %s)", pszTermCDP, pszHostCDP));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_SETKEYCP( pGT, pszTermCDP, pszHostCDP ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c959
HB_EXPORT ERRCODEhb_gtInfo( int iType, PHB_GT_INFO pInfo )
HB_EXPORT ERRCODE hb_gtInfo( int iType, PHB_GT_INFO pInfo )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtInfo(%d, %p)", iType, pInfo));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_INFO( pGT, iType, pInfo ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c976
HB_EXPORT INThb_gtAlert( PHB_ITEM pMessage, PHB_ITEM pOptions, int iClrNorm, int iClrHigh, double dDelay )
HB_EXPORT int hb_gtAlert( PHB_ITEM pMessage, PHB_ITEM pOptions,
                          int iClrNorm, int iClrHigh, double dDelay )
{
   int iResult = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtAlert(%p, %p, %d, %d, %f)", pMessage, pOptions, iClrNorm, iClrHigh, dDelay));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iResult = HB_GTSELF_ALERT( pGT, pMessage, pOptions, iClrNorm,
                                 iClrHigh, dDelay );
      hb_gt_BaseFree( pGT );
   }
   return iResult;
}
gtapi.c993
HB_EXPORT INThb_gtSetFlag( int iType, int iNewValue )
HB_EXPORT int hb_gtSetFlag( int iType, int iNewValue )
{
   int iFlag = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetFlag(%d, %d)", iType, iNewValue));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iFlag = HB_GTSELF_SETFLAG( pGT, iType, iNewValue );
      hb_gt_BaseFree( pGT );
   }
   return iFlag;
}
gtapi.c1011
HB_EXPORT INThb_gtGetCurrColor( void )
HB_EXPORT int hb_gtGetCurrColor( void )
{
   int iColor = 0x07;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGetCurrColor()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iColor = HB_GTSELF_GETCOLOR( pGT );
      hb_gt_BaseFree( pGT );
   }
   return iColor;
}
gtapi.c1027
HB_EXPORT INThb_gtGetClearColor( void )
HB_EXPORT int hb_gtGetClearColor( void )
{
   int iColor = 0x07;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGetClearColor()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iColor = HB_GTSELF_GETCLEARCOLOR( pGT );
      hb_gt_BaseFree( pGT );
   }
   return iColor;
}
gtapi.c1043
HB_EXPORT ERRCODEhb_gtSetClearColor( int iColor )
HB_EXPORT ERRCODE hb_gtSetClearColor( int iColor )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetClearColor(%d)", iColor));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_SETCLEARCOLOR( pGT, iColor );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c1059
HB_EXPORT INThb_gtGetClearChar( void )
HB_EXPORT int hb_gtGetClearChar( void )
{
   int iChar = ' ';
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGetClearChar()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iChar = HB_GTSELF_GETCLEARCHAR( pGT );
      hb_gt_BaseFree( pGT );
   }
   return iChar;
}
gtapi.c1075
HB_EXPORT ERRCODEhb_gtSetClearChar( int iChar )
HB_EXPORT ERRCODE hb_gtSetClearChar( int iChar )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtSetClearChar(%d)", iChar));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_SETCLEARCHAR( pGT, iChar );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c1091
HB_EXPORT ERRCODEhb_gtGetScrChar( int iRow, int iCol, BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
HB_EXPORT ERRCODE hb_gtGetScrChar( int iRow, int iCol, BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtScrGetChar(%d, %d, %p, %p, %p)", iRow, iCol, pbColor, pbAttr, pusChar));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, pbColor, pbAttr, pusChar ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c1107
HB_EXPORT ERRCODEhb_gtPutScrChar( int iRow, int iCol, BYTE bColor, BYTE bAttr, USHORT usChar )
HB_EXPORT ERRCODE hb_gtPutScrChar( int iRow, int iCol, BYTE bColor, BYTE bAttr, USHORT usChar )
{
   ERRCODE errCode = FAILURE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtPutScrChar(%d, %d, %d, %d, %hu)", iRow, iCol, bColor, bAttr, usChar));

   pGT = hb_gt_Base();
   if( pGT )
   {
      if( HB_GTSELF_PUTSCRCHAR( pGT, iRow, iCol, bColor, bAttr, usChar ) )
         errCode = SUCCESS;
      hb_gt_BaseFree( pGT );
   }
   return errCode;
}
gtapi.c1124
HB_EXPORT ERRCODEhb_gtFlush( void )
HB_EXPORT ERRCODE hb_gtFlush( void )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtFlush()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c1141
HB_EXPORT ERRCODEhb_gtGetPosEx( int * piRow, int * piCol )
HB_EXPORT ERRCODE hb_gtGetPosEx( int * piRow, int * piCol )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGetPosEx(%p, %p)", piRow, piCol));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_GETPOS( pGT, piRow, piCol );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   *piRow = *piCol = 0;
   return FAILURE;
}
gtapi.c1157
HB_EXPORT ERRCODEhb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, BYTE bColor, BYTE bChar, int iRows, int iCols )
HB_EXPORT ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, BYTE bColor, BYTE bChar, int iRows, int iCols )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gtScrollEx(%d, %d, %d, %d, %d, %hd, %d, %d)", iTop, iLeft, iBottom, iRight, bColor, bChar, iRows, iCols));

   if( iTop <= iBottom && iLeft <= iRight )
   {
      PHB_GT pGT = hb_gt_Base();
      if( pGT )
      {
         HB_GTSELF_SCROLL( pGT, iTop, iLeft, iBottom, iRight,
                           bColor, bChar, iRows, iCols );
         HB_GTSELF_FLUSH( pGT );
         hb_gt_BaseFree( pGT );
         return SUCCESS;
      }
   }
   return FAILURE;
}
gtapi.c1174
HB_EXPORT ERRCODEhb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, BYTE bColor )
HB_EXPORT ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, BYTE bColor )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtBoxEx(%d, %d, %d, %d, %p, %d)", iTop, iLeft, iBottom, iRight, pbyFrame, bColor));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_BOX( pGT, iTop, iLeft, iBottom, iRight, pbyFrame, bColor );
      HB_GTSELF_SETPOS( pGT, iTop + 1, iLeft + 1 );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c1193
HB_EXPORT INThb_gtGfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
HB_EXPORT int hb_gtGfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
{
   PHB_GT pGT;
   int iResult = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGfxText(%d, %d, %d, %d, %d, %d)", iType, iTop, iLeft, iBottom, iRight, iColor));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iResult = HB_GTSELF_GFXPRIMITIVE( pGT, iType, iTop, iLeft, iBottom, iRight, iColor );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
   }
   return iResult;
}
gtapi.c1211
HB_EXPORT ERRCODEhb_gtGfxText( int iTop, int iLeft, char * cBuf, int iColor, int iSize, int iWidth )
HB_EXPORT ERRCODE hb_gtGfxText( int iTop, int iLeft, char * cBuf, int iColor, int iSize, int iWidth )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_gtGfxText(%d, %d, %s, %d, %d, %d)", iTop, iLeft, cBuf, iColor, iSize, iWidth));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_GFXTEXT( pGT, iTop, iLeft, cBuf, iColor, iSize, iWidth );
      HB_GTSELF_FLUSH( pGT );
      hb_gt_BaseFree( pGT );
      return SUCCESS;
   }
   return FAILURE;
}
gtapi.c1228
gtapiu.c
TypeFunctionSourceLine
HB_EXPORT VOIDhb_gtWCreate( HB_GT_RECT * rect, HB_GT_WND ** wnd )
HB_EXPORT void hb_gtWCreate( HB_GT_RECT * rect, HB_GT_WND ** wnd )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( rect );
   HB_SYMBOL_UNUSED( wnd );
}
gtapiu.c55
HB_EXPORT VOIDhb_gtWDestroy( HB_GT_WND * wnd )
HB_EXPORT void hb_gtWDestroy( HB_GT_WND * wnd )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( wnd );
}
gtapiu.c63
HB_EXPORT BOOLhb_gtWFlash( void )
HB_EXPORT BOOL hb_gtWFlash( void )
{
   /* TODO: */

   return FALSE;
}
gtapiu.c70
HB_EXPORT VOIDhb_gtWApp( HB_GT_WND ** wnd )
HB_EXPORT void hb_gtWApp( HB_GT_WND ** wnd )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( wnd );
}
gtapiu.c77
HB_EXPORT VOIDhb_gtWCurrent( HB_GT_WND * wnd )
HB_EXPORT void hb_gtWCurrent( HB_GT_WND * wnd )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( wnd );
}
gtapiu.c84
HB_EXPORT VOIDhb_gtWPos( HB_GT_WND * wnd, HB_GT_RECT * rect )
HB_EXPORT void hb_gtWPos( HB_GT_WND * wnd, HB_GT_RECT * rect )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( wnd );
   HB_SYMBOL_UNUSED( rect );
}
gtapiu.c91
HB_EXPORT BOOLhb_gtWVis( HB_GT_WND * wnd, USHORT uiStatus )
HB_EXPORT BOOL hb_gtWVis( HB_GT_WND * wnd, USHORT uiStatus )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( wnd );
   HB_SYMBOL_UNUSED( uiStatus );

   return FALSE;
}
gtapiu.c99
HB_EXPORT USHORThb_gtSLR( HB_GT_SLR * pSLR )
HB_EXPORT USHORT hb_gtSLR( HB_GT_SLR * pSLR ) /* System Level Request */
{
   /* Do nothing in Harbour, since the low-level GT API is
      implemented with a different method than in CA-Cl*pper. */

   HB_SYMBOL_UNUSED( pSLR );

   return 1;
}
gtapiu.c109
HB_EXPORT USHORThb_gtModalRead( void * dummy )
HB_EXPORT USHORT hb_gtModalRead( void * dummy )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( dummy );

   return 1;
}
gtapiu.c119
HB_EXPORT USHORThb_gtFlushCursor( void )
HB_EXPORT USHORT hb_gtFlushCursor( void )
{
   /* TODO: */

   return 1;
}
gtapiu.c128
HB_EXPORT USHORThb_gtSetColor( HB_GT_RGB * color )
HB_EXPORT USHORT hb_gtSetColor( HB_GT_RGB * color )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( color );

   return 1;
}
gtapiu.c135
HB_EXPORT USHORThb_gtGetColor( HB_GT_RGB * color )
HB_EXPORT USHORT hb_gtGetColor( HB_GT_RGB * color )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( color );

   return 1;
}
gtapiu.c144
HB_EXPORT USHORThb_gtSetBorder( HB_GT_RGB * color )
HB_EXPORT USHORT hb_gtSetBorder( HB_GT_RGB * color )
{
   /* TODO: */

   HB_SYMBOL_UNUSED( color );

   return 1;
}
gtapiu.c153
gtchrmap.c
TypeFunctionSourceLine
STATIC VOIDchrmap_init( int *piTransTbl )
static void chrmap_init( int *piTransTbl )
{
   int i;

   for( i = 0; i < 256; ++i )
      piTransTbl[i] = HB_CHRMAP( i < 128 ? 1 : 0, i );

   piTransTbl[155] = HB_CHRMAP( 1, '.' );
}
gtchrmap.c67
STATIC VOIDchrmap_dotctrl( int *piTransTbl )
static void chrmap_dotctrl( int *piTransTbl )
{
   int i;

   for( i = 0; i < 32; ++i )
      piTransTbl[i] = piTransTbl[i+128] = HB_CHRMAP( 1, '.' );
}
gtchrmap.c77
STATIC VOIDchrmap_ascictrl( int *piTransTbl )
static void chrmap_ascictrl( int *piTransTbl )
{
   piTransTbl[04] = HB_CHRMAP( 1, '#' );
   piTransTbl[16] = HB_CHRMAP( 1, '>' );
   piTransTbl[17] = HB_CHRMAP( 1, '<' );
   piTransTbl[30] = HB_CHRMAP( 1, '^' );
   piTransTbl[31] = HB_CHRMAP( 1, 'v' );
   piTransTbl[24] = HB_CHRMAP( 1, '^' );
   piTransTbl[25] = HB_CHRMAP( 1, 'v' );
   piTransTbl[26] = HB_CHRMAP( 1, '>' );
   piTransTbl[27] = HB_CHRMAP( 1, '<' );
}
gtchrmap.c85
STATIC VOIDchrmap_acscbox( int *piTransTbl )
static void chrmap_acscbox( int *piTransTbl )
{
   piTransTbl[ 04] = HB_CHRMAP( 5, '`' ); /* ACS_DIAMOND */
   piTransTbl[ 16] = HB_CHRMAP( 5, '+' ); /* ACS_RARROW */
   piTransTbl[ 17] = HB_CHRMAP( 5, ',' ); /* ACS_LARROW */
   piTransTbl[ 24] = HB_CHRMAP( 5, '-' ); /* ACS_UARROW */
   piTransTbl[ 25] = HB_CHRMAP( 5, '.' ); /* ACS_DARROW */
   piTransTbl[ 26] = HB_CHRMAP( 5, '+' ); /* ACS_RARROW */
   piTransTbl[ 27] = HB_CHRMAP( 5, ',' ); /* ACS_LARROW */
   piTransTbl[ 30] = HB_CHRMAP( 5, '-' ); /* ACS_UARROW */
   piTransTbl[ 31] = HB_CHRMAP( 5, '.' ); /* ACS_DARROW */

   piTransTbl[176] = HB_CHRMAP( 5, 'h' ); /* ACS_BOARD */
   piTransTbl[177] = HB_CHRMAP( 5, 'a' ); /* ACS_CKBOARD */
   piTransTbl[178] = HB_CHRMAP( 5, '0' ); /* ACS_BLOCK */
   piTransTbl[179] = HB_CHRMAP( 5, 'x' ); /* ACS_VLINE */
   piTransTbl[180] = HB_CHRMAP( 5, 'u' ); /* ACS_RTEE */
   piTransTbl[181] = HB_CHRMAP( 5, 'u' ); /* ACS_RTEE */
   piTransTbl[182] = HB_CHRMAP( 5, 'u' ); /* ACS_RTEE */
   piTransTbl[183] = HB_CHRMAP( 5, 'k' ); /* ACS_URCORNER */
   piTransTbl[184] = HB_CHRMAP( 5, 'k' ); /* ACS_URCORNER */
   piTransTbl[185] = HB_CHRMAP( 5, 'u' ); /* ACS_RTEE */
   piTransTbl[186] = HB_CHRMAP( 5, 'x' ); /* ACS_VLINE */
   piTransTbl[187] = HB_CHRMAP( 5, 'k' ); /* ACS_URCORNER */
   piTransTbl[188] = HB_CHRMAP( 5, 'j' ); /* ACS_LRCORNER */
   piTransTbl[189] = HB_CHRMAP( 5, 'j' ); /* ACS_LRCORNER */
   piTransTbl[190] = HB_CHRMAP( 5, 'j' ); /* ACS_LRCORNER */
   piTransTbl[191] = HB_CHRMAP( 5, 'k' ); /* ACS_URCORNER */
   piTransTbl[192] = HB_CHRMAP( 5, 'm' ); /* ACS_LLCORNER */
   piTransTbl[193] = HB_CHRMAP( 5, 'v' ); /* ACS_BTEE */
   piTransTbl[194] = HB_CHRMAP( 5, 'w' ); /* ACS_TTEE */
   piTransTbl[195] = HB_CHRMAP( 5, 't' ); /* ACS_LTEE */
   piTransTbl[196] = HB_CHRMAP( 5, 'q' ); /* ACS_HLINE */
   piTransTbl[197] = HB_CHRMAP( 5, 'n' ); /* ACS_PLUS */
   piTransTbl[198] = HB_CHRMAP( 5, 't' ); /* ACS_LTEE */
   piTransTbl[199] = HB_CHRMAP( 5, 't' ); /* ACS_LTEE */
   piTransTbl[200] = HB_CHRMAP( 5, 'm' ); /* ACS_LLCORNER */
   piTransTbl[201] = HB_CHRMAP( 5, 'l' ); /* ACS_ULCORNER */
   piTransTbl[202] = HB_CHRMAP( 5, 'v' ); /* ACS_BTEE */
   piTransTbl[203] = HB_CHRMAP( 5, 'w' ); /* ACS_TTEE */
   piTransTbl[204] = HB_CHRMAP( 5, 't' ); /* ACS_LTEE */
   piTransTbl[205] = HB_CHRMAP( 5, 'q' ); /* ACS_HLINE */
   piTransTbl[206] = HB_CHRMAP( 5, 'n' ); /* ACS_PLUS */
   piTransTbl[207] = HB_CHRMAP( 5, 'v' ); /* ACS_BTEE */
   piTransTbl[208] = HB_CHRMAP( 5, 'v' ); /* ACS_BTEE */
   piTransTbl[209] = HB_CHRMAP( 5, 'w' ); /* ACS_TTEE */
   piTransTbl[210] = HB_CHRMAP( 5, 'w' ); /* ACS_TTEE */
   piTransTbl[211] = HB_CHRMAP( 5, 'm' ); /* ACS_LLCORNER */
   piTransTbl[212] = HB_CHRMAP( 5, 'm' ); /* ACS_LLCORNER */
   piTransTbl[213] = HB_CHRMAP( 5, 'l' ); /* ACS_ULCORNER */
   piTransTbl[214] = HB_CHRMAP( 5, 'l' ); /* ACS_ULCORNER */
   piTransTbl[215] = HB_CHRMAP( 5, 'n' ); /* ACS_PLUS */
   piTransTbl[216] = HB_CHRMAP( 5, 'n' ); /* ACS_PLUS */
   piTransTbl[217] = HB_CHRMAP( 5, 'j' ); /* ACS_LRCORNER */
   piTransTbl[218] = HB_CHRMAP( 5, 'l' ); /* ACS_ULCORNER */

#if 0
   piTransTbl[219] = HB_CHRMAP( 5, '`' ); /* ACS_DIAMOND */
   piTransTbl[220] = HB_CHRMAP( 5, '`' ); /* ACS_DIAMOND */
   piTransTbl[221] = HB_CHRMAP( 5, '`' ); /* ACS_DIAMOND */
   piTransTbl[222] = HB_CHRMAP( 5, '`' ); /* ACS_DIAMOND */
   piTransTbl[223] = HB_CHRMAP( 5, '`' ); /* ACS_DIAMOND */
#endif
}
gtchrmap.c98
STATIC VOIDskip_blank( char **buf )
static void skip_blank( char **buf )
{
   while( **buf != '\0' && **buf == ' ' )
      ++(*buf);
}
gtchrmap.c163
STATIC INTget_val( char **buf )
static int get_val( char **buf )
{
   int n = -1;
   char c;

   if( (*buf)[0] == '\'' && (*buf)[1] != '\0' && (*buf)[2] == '\'' )
   {
      n = (*buf)[1] & 0xff;
      *buf+=3;
   }
   else if( (*buf)[0] == '0' && ((*buf)[1] == 'x' || (*buf)[1] == 'X') )
   {
      n = 0;
      *buf+=2;
      for(; (**buf >= '0' && **buf <= '9') ||
            (**buf >= 'A' && **buf <= 'F') ||
            (**buf >= 'a' && **buf <= 'f'); (*buf)++ )
      {
         c = **buf | 0x20;
         n = (n << 4) + c - (c > '9' ? ('a' - 10) : '0');
      }
   }
   else if( **buf >= '0' && **buf <= '9' )
   {
      n = 0;
      for(; (**buf >= '0' && **buf <= '9'); (*buf)++ )
         n = n * 10 + (**buf - '0');
   }
   return n > 0xff ? -1 : n;
}
gtchrmap.c169
STATIC INTparse_line( char *buf, int *from, int *to, char *op, int *val, int *mod )
static int parse_line( char *buf, int *from, int *to, char *op, int *val, int *mod )
{
   char *s, *s2;
   int ret = 0, ina = 0;

   s = buf;
   while( *s != '\0' )
   {
      switch( *s )
      {
         case '\t':
            *s = ' ';
            break;
         case '\'':
            ina ^= 1;
            if( ina )
               ++s;
            break;
         case '\n':
         case '\r':
         case '#':
            *s = '\0';
            break;
      }
      if( *s != '\0' )
         ++s;
   }

   s = buf;
   skip_blank( &s );

   if( *s == '@' )
   {
      ++s;
      s2 = buf;
      while( *s != '\0' && *s != ' ' )
         *s2++ = *s++;
      *s2 = '\0';
      ret = strlen( buf ) > 0 ? 2 : -1;
   }
   else if( *s != '\0' )
   {
      ret = *from = *to = *val = *mod = -1;
      *op = '=';

      *from = get_val( &s );
      if( *from >= 0 )
      {
         if( *s == '-' )
         {
            ++s;
            *to = get_val( &s );
         }
         else
            *to = *from;
      }

      if( *to >= 0 && *s == ':' && s[1] == ' ' )
      {
         ++s;
         skip_blank( &s );
         if( *s == '*' && (s[1] == '+' || s[1] == '-' || s[1] == '&' ||
                           s[1] == '|' || s[1] == '^' || s[1] == '=' ||
                           s[1] == ' ') )
         {
            *op = s[1];
            s+=2;
         }
         *val = *op == ' ' ? 0 : get_val( &s );
         if( *val >= 0 )
         {
            skip_blank( &s );
            *mod = get_val( &s );
            skip_blank( &s );
            if( *mod >=0 && *mod <= 5 && *s == '\0' )
               ret = 1;
         }
      }
   }
   return ret;
}
gtchrmap.c200
STATIC INTchrmap_parse( FILE *fp, const char *pszTerm, int *nTransTbl, const char *pszFile )
static int chrmap_parse( FILE *fp, const char *pszTerm, int *nTransTbl, const char *pszFile )
{
   int line = 0, from = 0, to = 0, val = 0, mod = 0, i, n;
   char buf[256], *s, op = 0;
   int isTerm = 0;
   fpos_t pos;

   fgetpos( fp, &pos );
   fseek( fp, 0, SEEK_SET );

   while( !feof( fp ) && isTerm < 2 )
   {
      ++line;
      if( fgets( buf, sizeof( buf ), fp ) != NULL )
      {
         n = 0;
         if( *buf == ':' )
         {
            if( isTerm == 1 )
               isTerm = 2;
            else
            {
               *buf = '|';
               s = buf;
               while( *s != '\0' && *s != ' ' && *s != '\t' &&
                      *s != '\n' && *s != '\r' )
                  ++s;
               *s = '\0';
               s = buf;
               i = strlen( pszTerm );
               while( isTerm == 0 && ( s = strstr( s + 1, pszTerm ) ) != NULL )
               {
                  if( *(s-1) == '|' &&
                      ( s[i] == '|' || s[i] == '\0' ) )
                     isTerm = 1;
               }
            }
         }
         else if( isTerm == 1 )
         {
            n = parse_line( buf, &from, &to, &op, &val, &mod );
         }

         if( n == 2 )
         {
            chrmap_parse( fp, buf, nTransTbl, pszFile );
         }
         else if( n == 1 )
         {
            /* printf("line: %3d\tfrom=%d, to=%d, op='%c', val=%d, mod=%d\n", line, from, to, op, val, mod); */
            for( i = from; i <= to; ++i )
            {
               switch( op )
               {
                  case '|':
                     nTransTbl[i] = ( i | val );
                     break;
                  case '&':
                     nTransTbl[i] = ( i & val );
                     break;
                  case '^':
                     nTransTbl[i] = ( i ^ val );
                     break;
                  case '+':
                     nTransTbl[i] = ( i + val ) & 0xff;
                     break;
                  case '-':
                     nTransTbl[i] = ( i - val ) & 0xff;
                     break;
                  case '=':
                     nTransTbl[i] = val;
                     break;
                  case '*':
                  case ' ':
                  default:
                     nTransTbl[i] = i;
                     break;
               }
               nTransTbl[i] |= mod << 16;
            }
         }
         else if( n == -1 )
         {
            fprintf( stderr, "file: %s, parse error at line: %d\n", pszFile, line );
         }
      }
   }

   fsetpos( fp, &pos );

   return isTerm;
}
gtchrmap.c282
STATIC INThb_gt_chrmapread( const char *pszFile, const char *pszTerm, int *nTransTbl )
static int hb_gt_chrmapread( const char *pszFile, const char *pszTerm, int *nTransTbl )
{
   FILE *fp;
   char buf[256], *ptr, *pTerm;
   int isTerm = -1;

   fp = hb_fopen( pszFile, "r" );

   if( fp != NULL )
   {
      hb_strncpy( buf, pszTerm, sizeof( buf ) - 1 );
      isTerm = 0;
      pTerm = buf;
      while( pTerm )
      {
         if( ( ptr = strchr( pTerm, '/' ) ) != NULL )
            *ptr++ = '\0';

         if( *pTerm )
            if( chrmap_parse( fp, pTerm, nTransTbl, pszFile ) > 0 )
               isTerm = 1;

         pTerm = ptr;
      }
      fclose( fp );
   }
   return isTerm;
}
gtchrmap.c375
INThb_gt_chrmapinit( int *piTransTbl, const char *pszTerm, BOOL fSetACSC )
int hb_gt_chrmapinit( int *piTransTbl, const char *pszTerm, BOOL fSetACSC )
{
   char *pszFree = NULL, *pszFile, szFile[ _POSIX_PATH_MAX + 1 ];
   int nRet = -1;

   chrmap_init( piTransTbl );

   if( pszTerm == NULL || *pszTerm == '\0' )
      pszTerm = pszFree = hb_getenv("HB_TERM");
   if( pszTerm == NULL || *pszTerm == '\0' )
   {
      if( pszFree )
         hb_xfree( pszFree );
      pszTerm = pszFree = hb_getenv("TERM");
   }

   if( pszTerm != NULL && *pszTerm != '\0' )
   {
      pszFile = hb_getenv( "HB_CHARMAP" );
      if( pszFile != NULL && *pszFile != '\0' )
         nRet = hb_gt_chrmapread( pszFile, pszTerm, piTransTbl );
      if( nRet == -1 )
      {
         if( pszFile )
            hb_xfree( pszFile );
         pszFile = hb_getenv( "HB_ROOT" );
         if( pszFile != NULL && sizeof( szFile ) >
                        strlen( pszFile ) + strlen( hb_gt_szCharMapFileDefault ) )
         {
            hb_strncpy( szFile, pszFile, sizeof( szFile ) - 1 );
            hb_strncat( szFile, hb_gt_szCharMapFileDefault, sizeof( szFile ) - 1 );
            nRet = hb_gt_chrmapread( szFile, pszTerm, piTransTbl );
         }
      }
      if( pszFile )
         hb_xfree( pszFile );
      if( nRet == -1 )
         nRet = hb_gt_chrmapread( hb_gt_szCharMapFileDefault, pszTerm, piTransTbl );
   }

   if( pszFree )
      hb_xfree( pszFree );

   if( nRet == -1 )
   {
      chrmap_dotctrl( piTransTbl );
      if( fSetACSC )
         chrmap_acscbox( piTransTbl );
      else
         chrmap_ascictrl( piTransTbl );
   }

   return nRet;
}
gtchrmap.c404
gtclip.c
TypeFunctionSourceLine
BOOLhb_gt_setClipboard( char * szClipData, ULONG ulLen )
BOOL hb_gt_setClipboard( char * szClipData, ULONG ulLen )
{
   hb_threadEnterCriticalSection( &s_clipMtx );

   if( s_ulClipboardLen )
      hb_xfree( s_szClipboardData );
   s_ulClipboardLen = ulLen;
   if( ulLen )
   {
      s_szClipboardData = ( char * ) hb_xgrab( s_ulClipboardLen + 1 );
      memcpy( s_szClipboardData, szClipData, s_ulClipboardLen );
      s_szClipboardData[ s_ulClipboardLen ] = '\0';
   }

   hb_threadLeaveCriticalSection( &s_clipMtx );

   return TRUE;
}
gtclip.c74
BOOLhb_gt_getClipboard( char ** pszClipData, ULONG *pulLen )
BOOL hb_gt_getClipboard( char ** pszClipData, ULONG *pulLen )
{
   hb_threadEnterCriticalSection( &s_clipMtx );

   *pszClipData = NULL;
   *pulLen = s_ulClipboardLen;
   if( s_ulClipboardLen )
   {
      *pszClipData = ( char * ) hb_xgrab( s_ulClipboardLen + 1 );
      memcpy( *pszClipData, s_szClipboardData, s_ulClipboardLen );
      ( *pszClipData )[ s_ulClipboardLen ] = '\0';
   }

   hb_threadLeaveCriticalSection( &s_clipMtx );

   return s_ulClipboardLen != 0;
}
gtclip.c93
BOOLhb_gt_w32_setClipboard( UINT uFormat, char * szClipData, ULONG ulLen )
BOOL hb_gt_w32_setClipboard( UINT uFormat, char * szClipData, ULONG ulLen )
{
   BOOL fResult = FALSE;

   if( OpenClipboard( NULL ) )
   {
      HGLOBAL hglbCopy;

      EmptyClipboard();

      /* Allocate a global memory object for the text. */
      hglbCopy = GlobalAlloc( GMEM_MOVEABLE, uFormat == CF_UNICODETEXT ? ( ulLen + 1 ) * sizeof( wchar_t ) : ulLen + 1 );
      if( hglbCopy )
      {
         /* Lock the handle and copy the text to the buffer. */
         LPTSTR lptstrCopy = ( LPTSTR ) GlobalLock( hglbCopy );
         if( lptstrCopy )
         {
            if( uFormat == CF_UNICODETEXT )
            {
               hb_mbtowcset( ( LPWSTR ) lptstrCopy, szClipData, ulLen );
               * ( ( ( LPWSTR ) lptstrCopy ) + ulLen ) = L'\0';
            }
            else
            {
               memcpy( lptstrCopy, szClipData, ulLen );
               lptstrCopy[ ulLen ] = '\0';
            }
            fResult = TRUE;
         }
         GlobalUnlock( hglbCopy );
         /* Place the handle on the clipboard. */
         SetClipboardData( uFormat, hglbCopy );
      }
      CloseClipboard();
   }
   return fResult;
}
gtclip.c113
BOOLhb_gt_w32_getClipboard( UINT uFormat, char ** pszClipData, ULONG *pulLen )
BOOL hb_gt_w32_getClipboard( UINT uFormat, char ** pszClipData, ULONG *pulLen )
{
   *pulLen = 0;
   *pszClipData = NULL;
   if( IsClipboardFormatAvailable( uFormat ) && OpenClipboard( NULL ) )
   {
      HGLOBAL hglb = GetClipboardData( uFormat );
      if( hglb )
      {
         LPTSTR lptstr = ( LPTSTR ) GlobalLock( hglb );
         if( lptstr )
         {
            switch( uFormat )
            {
               case CF_UNICODETEXT:
                  *pulLen = wcslen( ( LPWSTR ) lptstr );
                  if( *pulLen )
                     *pszClipData = hb_wctomb( ( LPWSTR ) lptstr );
                  break;
               case CF_OEMTEXT:
               case CF_TEXT:
                  *pulLen = strlen( ( char * ) lptstr );
                  if( *pulLen )
                  {
                     *pszClipData = ( char * ) hb_xgrab( *pulLen + 1 );
                     memcpy( *pszClipData, lptstr, *pulLen );
                     ( *pszClipData )[ *pulLen ] = '\0';
                  }
                  break;
               default:
                  *pulLen = GlobalSize( hglb );
                  if( *pulLen )
                  {
                     *pszClipData = ( char * ) hb_xgrab( *pulLen + 1 );
                     memcpy( *pszClipData, lptstr, *pulLen );
                     ( *pszClipData )[ *pulLen ] = '\0';
                  }
                  break;
            }
            GlobalUnlock( hglb );
         }
      }
      CloseClipboard();
   }

   return *pulLen != 0;
}
gtclip.c152
gtfunc.c
TypeFunctionSourceLine
HB_FUNCHB_SETDISPCP(void)
HB_FUNC( HB_SETDISPCP )
{
   if( ISCHAR( 1 ) )
   {
      if( hb_pcount() == 2 && ISLOG( 2 ) )
         hb_gtSetDispCP( hb_parc( 1 ), NULL, hb_parl( 2 ) );
      else
         hb_gtSetDispCP( hb_parc( 1 ), hb_parc( 2 ), hb_parl( 3 ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1089, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
gtfunc.c57
HB_FUNCHB_SETKEYCP(void)
HB_FUNC( HB_SETKEYCP )
{
   if( ISCHAR( 1 ) )
      hb_gtSetKeyCP( hb_parc( 1 ), hb_parc( 2 ) );
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1089, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
gtfunc.c70
HB_FUNCHB_SETTERMCP(void)
HB_FUNC( HB_SETTERMCP )
{
   if( ISCHAR( 1 ) )
   {
      if( hb_pcount() == 2 && ISLOG( 2 ) )
      {
         hb_gtSetDispCP( hb_parc( 1 ), NULL, hb_parl( 2 ) );
         hb_gtSetKeyCP( hb_parc( 1 ), NULL );
      }
      else
      {
         hb_gtSetDispCP( hb_parc( 1 ), hb_parc( 2 ), hb_parl( 3 ) );
         hb_gtSetKeyCP( hb_parc( 1 ), hb_parc( 2 ) );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1089, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
gtfunc.c78
HB_FUNCHB_GTINFO(void)
HB_FUNC( HB_GTINFO )
{
   if( ISNUM( 1 ) )
   {
      HB_GT_INFO gtInfo;

      gtInfo.pNewVal  = hb_param( 2, HB_IT_ANY );
      gtInfo.pNewVal2 = hb_param( 3, HB_IT_ANY );
      gtInfo.pResult  = NULL;

      hb_gtInfo( hb_parni( 1 ), >Info );
      if( gtInfo.pResult )
         hb_itemReturnRelease( gtInfo.pResult );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
gtfunc.c97
HB_FUNCHB_GTVERSION(void)
HB_FUNC( HB_GTVERSION )
{
   hb_retc( hb_gtVersion( hb_parni( 1 ) ) );
}
gtfunc.c115
HB_FUNCHB_GTALERT(void)
HB_FUNC( HB_GTALERT )
{
   hb_retni( hb_gtAlert( hb_param( 1, HB_IT_ANY ),
                         hb_param( 2, HB_IT_ANY ),
                         ISCHAR( 3 ) ? hb_gtColorToN( hb_parc( 3 ) ) : hb_parni( 3 ) /* iClrNorm */,
                         ISCHAR( 4 ) ? hb_gtColorToN( hb_parc( 4 ) ) : hb_parni( 4 ) /* iClrHigh */,
                         hb_parnd( 5 ) ) );
}
gtfunc.c120
HB_FUNCHB_GFXPRIMITIVE(void)
HB_FUNC( HB_GFXPRIMITIVE )
{
   hb_retni( hb_gtGfxPrimitive( hb_parni( 1 ) /* nType   */,
                                hb_parni( 2 ) /* nTop    */,
                                hb_parni( 3 ) /* nLeft   */,
                                hb_parni( 4 ) /* nBottom */,
                                hb_parni( 5 ) /* nRight  */,
                                hb_parni( 6 ) /* nColor  */ ) );
}
gtfunc.c129
HB_FUNCHB_GFXTEXT(void)
HB_FUNC( HB_GFXTEXT )
{
   hb_gtGfxText( hb_parni( 1 ) /* nTop   */,
                 hb_parni( 2 ) /* nLeft  */,
                 hb_parc( 3 )  /* cText  */,
                 hb_parni( 4 ) /* nColor */,
                 hb_parni( 5 ) /* nSize  */,
                 hb_parni( 6 ) /* nWidth */ );
}
gtfunc.c139
gtkbstat.c
TypeFunctionSourceLine
INThb_gt_w32_getKbdState( void )
int hb_gt_w32_getKbdState( void )
{
   BYTE kbState[256];
   int iKbdState = 0;

   GetKeyboardState( kbState );

   if( kbState[VK_SHIFT   ] & 0x80 ) iKbdState |= HB_GTI_KBD_SHIFT;
   if( kbState[VK_CONTROL ] & 0x80 ) iKbdState |= HB_GTI_KBD_CTRL;
   if( kbState[VK_MENU    ] & 0x80 ) iKbdState |= HB_GTI_KBD_ALT;
   if( kbState[VK_LWIN    ] & 0x80 ) iKbdState |= HB_GTI_KBD_LWIN;
   if( kbState[VK_RWIN    ] & 0x80 ) iKbdState |= HB_GTI_KBD_RWIN;
   if( kbState[VK_APPS    ] & 0x80 ) iKbdState |= HB_GTI_KBD_MENU;
   if( kbState[VK_SCROLL  ] & 0x01 ) iKbdState |= HB_GTI_KBD_SCROLOCK;
   if( kbState[VK_NUMLOCK ] & 0x01 ) iKbdState |= HB_GTI_KBD_NUMLOCK;
   if( kbState[VK_CAPITAL ] & 0x01 ) iKbdState |= HB_GTI_KBD_CAPSLOCK;
   if( kbState[VK_INSERT  ] & 0x01 ) iKbdState |= HB_GTI_KBD_INSERT;

   return iKbdState;
}
gtkbstat.c61
VOIDhb_gt_w32_setKbdState( int iKbdState )
void hb_gt_w32_setKbdState( int iKbdState )
{
   BYTE kbState[256];

   GetKeyboardState( kbState );

   kbState[VK_SHIFT  ] = ( iKbdState & HB_GTI_KBD_SHIFT    ) ? 0x80 : 0;
   kbState[VK_CONTROL] = ( iKbdState & HB_GTI_KBD_CTRL     ) ? 0x80 : 0;
   kbState[VK_MENU   ] = ( iKbdState & HB_GTI_KBD_ALT      ) ? 0x80 : 0;
   kbState[VK_LWIN   ] = ( iKbdState & HB_GTI_KBD_LWIN     ) ? 0x80 : 0;
   kbState[VK_RWIN   ] = ( iKbdState & HB_GTI_KBD_RWIN     ) ? 0x80 : 0;
   kbState[VK_APPS   ] = ( iKbdState & HB_GTI_KBD_MENU     ) ? 0x80 : 0;
   kbState[VK_SCROLL ] = ( iKbdState & HB_GTI_KBD_SCROLOCK ) ? 0x01 : 0;
   kbState[VK_NUMLOCK] = ( iKbdState & HB_GTI_KBD_NUMLOCK  ) ? 0x01 : 0;
   kbState[VK_CAPITAL] = ( iKbdState & HB_GTI_KBD_CAPSLOCK ) ? 0x01 : 0;
   kbState[VK_INSERT ] = ( iKbdState & HB_GTI_KBD_INSERT   ) ? 0x01 : 0;

   SetKeyboardState( kbState );
}
gtkbstat.c82
gtkeycod.c
TypeFunctionSourceLine
INThb_gt_dos_keyCodeTranslate( int iKey )
int hb_gt_dos_keyCodeTranslate( int iKey )
{
   /* Perform key translations */
   switch( iKey )
   {
      case -1:  /* No key available */
         iKey = 0;
         break;
      case 328:  /* Up arrow */
         iKey = K_UP;
         break;
      case 336:  /* Down arrow */
         iKey = K_DOWN;
         break;
      case 331:  /* Left arrow */
         iKey = K_LEFT;
         break;
      case 333:  /* Right arrow */
         iKey = K_RIGHT;
         break;
      case 327:  /* Home */
         iKey = K_HOME;
         break;
      case 335:  /* End */
         iKey = K_END;
         break;
      case 329:  /* Page Up */
         iKey = K_PGUP;
         break;
      case 337:  /* Page Down */
         iKey = K_PGDN;
         break;
      case 371:  /*  Ctrl + Left arrow */
         iKey = K_CTRL_LEFT;
         break;
      case 372:  /* Ctrl + Right arrow */
         iKey = K_CTRL_RIGHT;
         break;
      case 375:  /* Ctrl + Home */
         iKey = K_CTRL_HOME;
         break;
      case 373:  /* Ctrl + End */
         iKey = K_CTRL_END;
         break;
      case 388:  /* Ctrl + Page Up */
         iKey = K_CTRL_PGUP;
         break;
      case 374:  /* Ctrl + Page Down */
         iKey = K_CTRL_PGDN;
         break;
      case 338:  /* Insert */
         iKey = K_INS;
         break;
      case 339:  /* Delete */
         iKey = K_DEL;
         break;
      case 315:  /* F1 */
         iKey = K_F1;
         break;
      case 316:  /* F2 */
      case 317:  /* F3 */
      case 318:  /* F4 */
      case 319:  /* F5 */
      case 320:  /* F6 */
      case 321:  /* F7 */
      case 322:  /* F8 */
      case 323:  /* F9 */
      case 324:  /* F10 */
         iKey = 315 - iKey;
         break;
      case 340:  /* Shift + F1 */
      case 341:  /* Shift + F2 */
      case 342:  /* Shift + F3 */
      case 343:  /* Shift + F4 */
      case 344:  /* Shift + F5 */
      case 345:  /* Shift + F6 */
      case 346:  /* Shift + F7 */
      case 347:  /* Shift + F8 */
      case 348:  /* Shift + F9 */
      case 349:  /* Shift + F10 */
      case 350:  /* Ctrl + F1 */
      case 351:  /* Ctrl + F2 */
      case 352:  /* Ctrl + F3 */
      case 353:  /* Ctrl + F4 */
      case 354:  /* Ctrl + F5 */
      case 355:  /* Ctrl + F6 */
      case 356:  /* Ctrl + F7 */
      case 357:  /* Ctrl + F8 */
      case 358:  /* Ctrl + F9 */
      case 359:  /* Ctrl + F10 */
      case 360:  /* Alt + F1 */
      case 361:  /* Alt + F2 */
      case 362:  /* Alt + F3 */
      case 363:  /* Alt + F4 */
      case 364:  /* Alt + F5 */
      case 365:  /* Alt + F6 */
      case 366:  /* Alt + F7 */
      case 367:  /* Alt + F8 */
      case 368:  /* Alt + F9 */
      case 369:  /* Alt + F10 */
         iKey = 330 - iKey;
         break;
      case 389:  /* F11 */
      case 390:  /* F12 */
      case 391:  /* Shift + F11 */
      case 392:  /* Shift + F12 */
      case 393:  /* Ctrl + F11 */
      case 394:  /* Ctrl + F12 */
      case 395:  /* Alt + F11 */
      case 396:  /* Alt + F12 */
         iKey = 349 - iKey;
   }

   return iKey;
}
gtkeycod.c62
gtsys.c
TypeFunctionSourceLine
HB_FUNCHB_GTSYS(void)
HB_FUNC( HB_GTSYS ) {}
gtsys.c78
gttone.c
TypeFunctionSourceLine
STATIC INThb_Inp9x( USHORT usPort )
static int hb_Inp9x( USHORT usPort )
{
   USHORT usVal;

   HB_TRACE(HB_TR_DEBUG, ("hb_Inp9x(%hu)", usPort));

   #if defined( __BORLANDC__ ) || defined(__DMC__)

      _DX = usPort;
      __emit__(0xEC);         /* ASM  IN AL, DX */
      __emit__(0x32,0xE4);    /* ASM XOR AH, AH */
      usVal = _AX;

   #elif ( defined( __XCC__ ) || defined( __POCC__ ) ) && defined( _M_IX86 )

      __asm {
               mov   dx, usPort
               xor   ax, ax
               in    al, dx
               mov   usVal, ax
            }

   #elif defined( __MINGW32__ )
      __asm__ __volatile__ ("inb %w1,%b0":"=a" (usVal):"Nd" (usPort));

   #elif defined( __WATCOMC__ )

      usVal = ( USHORT ) inp( usPort );

   #else

      usVal = ( USHORT ) _inp( usPort );

   #endif

   return usVal;
}
gttone.c77
STATIC INThb_Outp9x( USHORT usPort, USHORT usVal )
static int hb_Outp9x( USHORT usPort, USHORT usVal )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_Outp9x(%hu, %hu)", usPort, usVal));

   #if defined( __BORLANDC__ ) || defined(__DMC__)

      _DX = usPort;
      _AL = usVal;
      __emit__(0xEE);        /* ASM OUT DX, AL */

   #elif ( defined( __XCC__ ) || defined( __POCC__ ) ) && defined( _M_IX86 )

      __asm {
               mov   dx, usPort
               mov   ax, usVal
               out   dx, al
            }

   #elif defined( __MINGW32__ )

      __asm__ __volatile__ ("outb %b0,%w1": :"a" (usVal), "Nd" (usPort));

   #elif defined( __WATCOMC__ )

       outp( usPort, usVal );

   #else

      _outp( usPort, usVal );

   #endif

   return usVal;
}
gttone.c117
STATIC VOIDhb_gt_w9xTone( double dFreq, double dDurat )
static void hb_gt_w9xTone( double dFreq, double dDurat )
{
   INT uLSB,uMSB;
   ULONG lAdjFreq;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_w9xtone(%lf, %lf)", dFreq, dDurat));

   /* sync with internal clock with very small time period */
   hb_idleSleep( 0.01 );

   /* Clipper ignores Tone() requests (but delays anyway) if Frequency is
      less than < 20 hz (and so should we) to maintain compatibility .. */

   if( dFreq >= 20.0 )
   {
      /* Setup Sound Control Port Registers and timer channel 2 */
      hb_Outp9x(67, 182) ;

      lAdjFreq = (ULONG)( 1193180 / dFreq ) ;

      if( (LONG) lAdjFreq < 0 )
         uLSB = lAdjFreq + 65536;
      else
         uLSB = lAdjFreq % 256;

      if( (LONG) lAdjFreq < 0 )
         uMSB = lAdjFreq + 65536;
      else
         uMSB = lAdjFreq / 256;


      /* set the frequency (LSB,MSB) */

      hb_Outp9x(66, ( USHORT ) uLSB);
      hb_Outp9x(66, ( USHORT ) uMSB);

      /* Get current Port setting */
      /* enable Speaker Data & Timer gate bits */
      /* (00000011B is bitmask to enable sound) */
      /* Turn on Speaker - sound Tone for duration.. */

      hb_Outp9x(97, ( USHORT ) hb_Inp9x( 97 ) | 3);

      hb_idleSleep( dDurat );

      /* Read back current Port value for Reset */
      /* disable Speaker Data & Timer gate bits */
      /* (11111100B is bitmask to disable sound) */
      /* Turn off the Speaker ! */

      hb_Outp9x(97, hb_Inp9x( 97 ) & 0xFC);
   }
   else
   {
      hb_idleSleep( dDurat );
   }
}
gttone.c152
STATIC VOIDhb_gt_wNtTone( double dFreq, double dDurat )
static void hb_gt_wNtTone( double dFreq, double dDurat )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_wNtTone(%lf, %lf)", dFreq, dDurat));

   /* Clipper ignores Tone() requests (but delays anyway) if Frequency is
      less than < 20 hz.  Windows NT minimum is 37... */

   if( dFreq >= 37.0 )
   {
      Beep( (ULONG) dFreq, (ULONG) ( dDurat * 1000 ) ); /* Beep wants Milliseconds */
   }
   else
   {
      hb_idleSleep( dDurat );
   }
}
gttone.c213
VOIDhb_gt_w32_tone( double dFrequency, double dDuration )
void hb_gt_w32_tone( double dFrequency, double dDuration )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_w32_tone(%lf, %lf)", dFrequency, dDuration));

   /*
    * According to the Clipper NG, the duration in 'ticks' is truncated to the
    * interger portion  ... Depending on the platform, Harbour allows a finer
    * resolution, but the minimum is 1 tick (for compatibility)
    */
   /* Convert from ticks to seconds */
   dDuration  = ( HB_MIN( HB_MAX( 1.0, dDuration ), ULONG_MAX ) ) / 18.2;

   /* keep the frequency in an acceptable range */
   dFrequency =   HB_MIN( HB_MAX( 0.0, dFrequency ), 32767.0 );

   /* If Windows NT or NT2k, use wNtTone, which provides TONE()
      reset sequence support (new) */
   if( hb_iswinnt() || hb_iswince() )
   {
      hb_gt_wNtTone( dFrequency, dDuration );
   }
   else  /* If Windows 95 or 98, use w9xTone for chosen C compilers */
   {
      #if defined( HB_ARCH_32BIT ) && !defined( _M_ARM ) && \
           ( defined( __BORLANDC__ ) || defined( _MSC_VER ) || \
             defined( __WATCOMC__ )  || defined(__MINGW32__) )
         hb_gt_w9xTone( dFrequency, dDuration );
      #else
         hb_gt_wNtTone( dFrequency, dDuration );
      #endif
   }
}
gttone.c232
gx.c
TypeFunctionSourceLine
HB_FUNCISCOLOR(void)
HB_FUNC( ISCOLOR )
{
   hb_retl( hb_gtIsColor() );
}
gx.c67
HB_FUNCNOSNOW(void)
HB_FUNC( NOSNOW )
{
   if( ISLOG( 1 ) )
      hb_gtSetSnowFlag( hb_parl( 1 ) );
}
gx.c72
HB_FUNCSETMODE(void)
HB_FUNC( SETMODE )
{
   USHORT uiRows, uiCols;

   hb_gtScrDim( &uiRows, &uiCols );
   if( ISNUM( 1 ) )
      uiRows = ( USHORT ) hb_parni( 1 );
   if( ISNUM( 2 ) )
      uiCols = ( USHORT ) hb_parni( 2 );

   hb_retl( hb_gtSetMode( uiRows, uiCols ) == SUCCESS );
}
gx.c78
hardcr.c
TypeFunctionSourceLine
STATIC CHAR *hb_strHardCR( char * pszString, ULONG ulStringLen )
static char * hb_strHardCR( char * pszString, ULONG ulStringLen )
{
   ULONG ulStringPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_strHardCR(%s, %lu)", pszString, ulStringLen));

   for( ulStringPos = 0; ulStringPos < ulStringLen; ulStringPos++ )
   {
      if( pszString[ ulStringPos ]     == HB_CHAR_SOFT1 &&
          pszString[ ulStringPos + 1 ] == HB_CHAR_SOFT2 )
      {
         pszString[ ulStringPos ] = HB_CHAR_HARD1;
      }
   }

   return pszString;
}
hardcr.c56
HB_FUNCHARDCR(void)
HB_FUNC( HARDCR )
{
   PHB_ITEM pString = hb_param( 1, HB_IT_STRING );

   if( pString )
   {
      char * pszBuffer = hb_itemGetC( pString );
      ULONG ulStringLen = hb_itemGetCLen( pString );

      hb_retclen_buffer( hb_strHardCR( pszBuffer, ulStringLen ), ulStringLen );
   }
   else
      hb_retc( NULL );
}
hardcr.c74
hbadler.c
TypeFunctionSourceLine
HB_EXPORT ULONGhb_adler32( ULONG adler, const BYTE *buf, ULONG len )
HB_EXPORT ULONG hb_adler32( ULONG adler, const BYTE *buf, ULONG len )
{
   ULONG s1 = adler & 0xffff;
   ULONG s2 = ( adler >> 16 ) & 0xffff;

   if( buf && len )
   {
      do
      {
         int i = len < NMAX ? len : NMAX;
         len -= i;
         do
         {
            s1 += ( UCHAR ) *buf++;
            s2 += s1;
         }
         while( --i );
         s1 %= BASE;
         s2 %= BASE;
      }
      while( len );
   }

   return ( s2 << 16 ) | s1;
}
hbadler.c62
HB_FUNCHB_ADLER32(void)
HB_FUNC( HB_ADLER32 )
{
   char * szString = hb_parc( 1 );

   if( szString )
      hb_retnint( hb_adler32( ( ULONG ) hb_parnl( 2 ), ( BYTE * ) szString, hb_parclen( 1 ) ) );
   else
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbadler.c88
hbbit.c
TypeFunctionSourceLine
STATIC BOOLhb_numParam( int iParam, HB_LONG * plNum )
static BOOL hb_numParam( int iParam, HB_LONG * plNum )
{
   if( ISNUM( iParam ) )
   {
      *plNum = hb_parnint( iParam );
      return TRUE;
   }
   hb_errRT_BASE_SubstR( EG_ARG, 1089, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   *plNum = 0;
   return FALSE;
}
hbbit.c63
HB_FUNCHB_BITAND(void)
HB_FUNC( HB_BITAND )
{
   HB_LONG lValue;
   if( hb_numParam( 1, &lValue ) )
   {
      int iPCount = hb_pcount() - 1, i = 1;
      do
      {
         HB_LONG lNext;
         if( !hb_numParam( ++i, &lNext ) )
            return;
         lValue &= lNext;
      }
      while( --iPCount > 0 );
      hb_retnint( lValue );
   }
}
hbbit.c75
HB_FUNCHB_BITOR(void)
HB_FUNC( HB_BITOR )
{
   HB_LONG lValue;
   if( hb_numParam( 1, &lValue ) )
   {
      int iPCount = hb_pcount() - 1, i = 1;
      do
      {
         HB_LONG lNext;
         if( !hb_numParam( ++i, &lNext ) )
            return;
         lValue |= lNext;
      }
      while( --iPCount > 0 );
      hb_retnint( lValue );
   }
}
hbbit.c93
HB_FUNCHB_BITXOR(void)
HB_FUNC( HB_BITXOR )
{
   HB_LONG lValue;
   if( hb_numParam( 1, &lValue ) )
   {
      int iPCount = hb_pcount() - 1, i = 1;
      do
      {
         HB_LONG lNext;
         if( !hb_numParam( ++i, &lNext ) )
            return;
         lValue ^= lNext;
      }
      while( --iPCount > 0 );
      hb_retnint( lValue );
   }
}
hbbit.c111
HB_FUNCHB_BITNOT(void)
HB_FUNC( HB_BITNOT )
{
   HB_LONG lValue;
   if( hb_numParam( 1, &lValue ) )
      hb_retnint( ~lValue );
}
hbbit.c129
HB_FUNCHB_BITTEST(void)
HB_FUNC( HB_BITTEST )
{
   HB_LONG lValue, lBit;
   if( hb_numParam( 1, &lValue ) && hb_numParam( 2, &lBit ) )
      hb_retl( ( lValue & ( ( HB_LONG ) 1 << lBit ) ) != 0 );
}
hbbit.c136
HB_FUNCHB_BITSET(void)
HB_FUNC( HB_BITSET )
{
   HB_LONG lValue, lBit;
   if( hb_numParam( 1, &lValue ) && hb_numParam( 2, &lBit ) )
      hb_retnint( lValue | ( ( HB_LONG ) 1 << lBit ) );
}
hbbit.c143
HB_FUNCHB_BITRESET(void)
HB_FUNC( HB_BITRESET )
{
   HB_LONG lValue, lBit;
   if( hb_numParam( 1, &lValue ) && hb_numParam( 2, &lBit ) )
      hb_retnint( lValue & ( ~ ( ( HB_LONG ) 1 << lBit ) ) );
}
hbbit.c150
HB_FUNCHB_BITSHIFT(void)
HB_FUNC( HB_BITSHIFT )
{
   HB_LONG lValue, lBits;
   if( hb_numParam( 1, &lValue ) && hb_numParam( 2, &lBits ) )
   {
      if( lBits < 0 )
         hb_retnint( lValue >> -lBits );
      else
         hb_retnint( lValue << lBits );
   }
}
hbbit.c157
hbcrc.c
TypeFunctionSourceLine
HB_EXPORT ULONGhb_crc32( ULONG crc, const BYTE *buf, ULONG len )
HB_EXPORT ULONG hb_crc32( ULONG crc, const BYTE *buf, ULONG len )
{
   crc ^= 0xffffffffL;
   if( buf && len )
   {
      do
         crc = crc32_tab[ ( crc ^ *buf++ ) & 0xFF ] ^ ( crc >> 8 );
      while( --len );
   }
   return crc ^ 0xffffffffL;
}
hbcrc.c152
HB_EXPORT ULONGhb_crc16( ULONG crc, const BYTE *buf, ULONG len )
HB_EXPORT ULONG hb_crc16( ULONG crc, const BYTE *buf, ULONG len )
{
   crc ^= 0xffff;
   if( buf && len )
   {
      do
         crc = crc16_tab[ ( crc ^ *buf++ ) & 0xFF ] ^ ( crc >> 8 );
      while( --len );
   }
   return crc ^ 0xffff;
}
hbcrc.c164
HB_EXPORT HB_ULONGhb_crc( HB_ULONG crc, const BYTE * buf, ULONG len, HB_ULONG poly )
HB_EXPORT HB_ULONG hb_crc( HB_ULONG crc, const BYTE * buf, ULONG len, HB_ULONG poly )
{
   if( buf && len )
   {
      HB_ULONG mask = 1, revp = 0;

      while( poly > 1 )
      {
         mask <<= 1;
         revp <<= 1;
         if( poly & 1 )
            revp |= 1;
         poly >>= 1;
      }
      crc ^= --mask;
      do
      {
         HB_ULONG b = ( crc ^ ( UCHAR ) * buf++ ) & 0xFF;
         int i = 8;
         do
            b = b & 1 ? revp ^ ( b >> 1 ) : b >> 1;
         while( --i );
         crc = b ^ ( crc >> 8 );
      }
      while( --len );
      crc ^= mask;
   }
   return crc;
}
hbcrc.c176
HB_EXPORT HB_ULONGhb_crcct( HB_ULONG crc, const BYTE * buf, ULONG len, HB_ULONG poly )
HB_EXPORT HB_ULONG hb_crcct( HB_ULONG crc, const BYTE * buf, ULONG len, HB_ULONG poly )
{
   if( buf && len )
   {
      HB_ULONG mask, revp = poly;
      int bits = 0;

      while( revp >>= 1 )
         ++bits;
      mask = ( HB_LONG ) 1 << ( bits - 1 );
      bits -= 8;
      do
      {
         int i = 8;
         crc ^= ( HB_ULONG ) * buf++ << bits;
         do
            crc = crc & mask ? poly ^ ( crc << 1 ) : crc << 1;
         while( --i );
      }
      while( --len );
      crc &= ( mask << 1 ) - 1;
   }
   return crc;
}
hbcrc.c206
HB_FUNCHB_CRC32(void)
HB_FUNC( HB_CRC32 )
{
   char * szString = hb_parc( 1 );

   if( szString )
      hb_retnint( hb_crc32( ( ULONG ) hb_parnl( 2 ), ( BYTE * ) szString, hb_parclen( 1 ) ) );
   else
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbcrc.c231
HB_FUNCHB_CRC16(void)
HB_FUNC( HB_CRC16 )
{
   char * szString = hb_parc( 1 );

   if( szString )
      hb_retnint( hb_crc16( ( ULONG ) hb_parnl( 2 ), ( BYTE * ) szString, hb_parclen( 1 ) ) );
   else
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbcrc.c241
HB_FUNCHB_CRC(void)
HB_FUNC( HB_CRC )
{
   char * szString = hb_parc( 1 );

   if( szString )
   {
      HB_ULONG ulPolynomial = ( HB_ULONG ) hb_parnint( 3 );
      if( ulPolynomial == 0 )
         ulPolynomial = 0x11021;
      hb_retnint( hb_crc( ( HB_ULONG ) hb_parnint( 2 ), ( BYTE * ) szString, hb_parclen( 1 ), ulPolynomial ) );
   }
   else
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbcrc.c251
HB_FUNCHB_CRCCT(void)
HB_FUNC( HB_CRCCT )
{
   char * szString = hb_parc( 1 );

   if( szString )
   {
      HB_ULONG ulPolynomial = ( HB_ULONG ) hb_parnint( 3 );
      if( ulPolynomial == 0 )
         ulPolynomial = 0x11021;
      hb_retnint( hb_crcct( ( HB_ULONG ) hb_parnint( 2 ), ( BYTE * ) szString, hb_parclen( 1 ), ulPolynomial ) );
   }
   else
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbcrc.c266
hbffind.c
TypeFunctionSourceLine
ULONGhb_fsAttrFromRaw( ULONG raw_attr )
ULONG hb_fsAttrFromRaw( ULONG raw_attr )
{
   ULONG ulAttr;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsAttrFromRaw(%lu)", raw_attr));

#if defined(HB_OS_DOS)

   ulAttr = 0;
   if( raw_attr & FA_ARCH )   ulAttr |= HB_FA_ARCHIVE;
   if( raw_attr & FA_DIREC )  ulAttr |= HB_FA_DIRECTORY;
   if( raw_attr & FA_HIDDEN ) ulAttr |= HB_FA_HIDDEN;
   if( raw_attr & FA_RDONLY ) ulAttr |= HB_FA_READONLY;
   if( raw_attr & FA_LABEL )  ulAttr |= HB_FA_LABEL;
   if( raw_attr & FA_SYSTEM ) ulAttr |= HB_FA_SYSTEM;

#elif defined(HB_OS_OS2)

   ulAttr = 0;
   if( raw_attr & FILE_ARCHIVED )  ulAttr |= HB_FA_ARCHIVE;
   if( raw_attr & FILE_DIRECTORY ) ulAttr |= HB_FA_DIRECTORY;
   if( raw_attr & FILE_HIDDEN )    ulAttr |= HB_FA_HIDDEN;
   if( raw_attr & FILE_READONLY )  ulAttr |= HB_FA_READONLY;
   if( raw_attr & FILE_SYSTEM )    ulAttr |= HB_FA_SYSTEM;

#elif defined(HB_OS_WIN_32)

   ulAttr = 0;
   if( raw_attr & FILE_ATTRIBUTE_ARCHIVE )   ulAttr |= HB_FA_ARCHIVE;
   if( raw_attr & FILE_ATTRIBUTE_DIRECTORY ) ulAttr |= HB_FA_DIRECTORY;
   if( raw_attr & FILE_ATTRIBUTE_HIDDEN )    ulAttr |= HB_FA_HIDDEN;
   if( raw_attr & FILE_ATTRIBUTE_READONLY )  ulAttr |= HB_FA_READONLY;
   if( raw_attr & FILE_ATTRIBUTE_SYSTEM )    ulAttr |= HB_FA_SYSTEM;
   if( raw_attr & FILE_ATTRIBUTE_NORMAL )    ulAttr |= HB_FA_NORMAL;

#ifdef HB_EXTENSION
   /* Note that FILE_ATTRIBUTE_NORMAL is not needed
      HB_FA_DEVICE not supported
      HB_FA_VOLCOMP needs to be checked */
   if( raw_attr & FILE_ATTRIBUTE_ENCRYPTED )     ulAttr |= HB_FA_ENCRYPTED;
   if( raw_attr & FILE_ATTRIBUTE_TEMPORARY )     ulAttr |= HB_FA_TEMPORARY;
   if( raw_attr & FILE_ATTRIBUTE_SPARSE_FILE )   ulAttr |= HB_FA_SPARSE;
   if( raw_attr & FILE_ATTRIBUTE_REPARSE_POINT ) ulAttr |= HB_FA_REPARSE;
   if( raw_attr & FILE_ATTRIBUTE_COMPRESSED )    ulAttr |= HB_FA_COMPRESSED;
   if( raw_attr & FILE_ATTRIBUTE_OFFLINE )       ulAttr |= HB_FA_OFFLINE;
   /* FILE_ATTRIBUTE_NOT_CONTENT_INDEXED */
   /* not defined in some older winnt.h  */
   if( raw_attr & 0x00002000 )                   ulAttr |= HB_FA_NOTINDEXED;
   if( raw_attr & 0x00008000 )                   ulAttr |= HB_FA_VOLCOMP;
#endif

#elif defined(HB_OS_UNIX)

   ulAttr = ( ( raw_attr & S_IXOTH ) ? HB_FA_XOTH : 0 ) |
            ( ( raw_attr & S_IWOTH ) ? HB_FA_WOTH : 0 ) |
            ( ( raw_attr & S_IROTH ) ? HB_FA_ROTH : 0 ) |
            ( ( raw_attr & S_IXGRP ) ? HB_FA_XGRP : 0 ) |
            ( ( raw_attr & S_IWGRP ) ? HB_FA_WGRP : 0 ) |
            ( ( raw_attr & S_IRGRP ) ? HB_FA_RGRP : 0 ) |
            ( ( raw_attr & S_IXUSR ) ? HB_FA_XUSR : 0 ) |
            ( ( raw_attr & S_IWUSR ) ? HB_FA_WUSR : 0 ) |
            ( ( raw_attr & S_IRUSR ) ? HB_FA_RUSR : 0 ) |
            ( ( raw_attr & S_ISVTX ) ? HB_FA_SVTX : 0 ) |
            ( ( raw_attr & S_ISGID ) ? HB_FA_SGID : 0 ) |
            ( ( raw_attr & S_ISUID ) ? HB_FA_SUID : 0 );

   if( S_ISREG( raw_attr ) )  ulAttr |= HB_FA_FILE;
   if( S_ISDIR( raw_attr ) )  ulAttr |= HB_FA_DIRECTORY;
   if( S_ISLNK( raw_attr ) )  ulAttr |= HB_FA_LINK;
   if( S_ISCHR( raw_attr ) )  ulAttr |= HB_FA_CHRDEVICE;
   if( S_ISBLK( raw_attr ) )  ulAttr |= HB_FA_BLKDEVICE;
   if( S_ISFIFO( raw_attr ) ) ulAttr |= HB_FA_FIFO;
   if( S_ISSOCK( raw_attr ) ) ulAttr |= HB_FA_SOCKET;

#else

   HB_SYMBOL_UNUSED( raw_attr );
   ulAttr = 0;

#endif

   return ulAttr;
}
hbffind.c180
ULONGhb_fsAttrToRaw( ULONG ulAttr )
ULONG hb_fsAttrToRaw( ULONG ulAttr )
{
   ULONG raw_attr;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsAttrToRaw(%lu)", ulAttr));

#if defined(HB_OS_DOS)

   raw_attr = 0;
   if( ulAttr & HB_FA_ARCHIVE )   raw_attr |= FA_ARCH;
   if( ulAttr & HB_FA_DIRECTORY ) raw_attr |= FA_DIREC;
   if( ulAttr & HB_FA_HIDDEN )    raw_attr |= FA_HIDDEN;
   if( ulAttr & HB_FA_READONLY )  raw_attr |= FA_RDONLY;
   if( ulAttr & HB_FA_LABEL )     raw_attr |= FA_LABEL;
   if( ulAttr & HB_FA_SYSTEM )    raw_attr |= FA_SYSTEM;

#elif defined(HB_OS_OS2)

   raw_attr = 0;
   if( ulAttr & HB_FA_ARCHIVE )   raw_attr |= FILE_ARCHIVED;
   if( ulAttr & HB_FA_DIRECTORY ) raw_attr |= FILE_DIRECTORY;
   if( ulAttr & HB_FA_HIDDEN )    raw_attr |= FILE_HIDDEN;
   if( ulAttr & HB_FA_READONLY )  raw_attr |= FILE_READONLY;
   if( ulAttr & HB_FA_SYSTEM )    raw_attr |= FILE_SYSTEM;

#elif defined(HB_OS_WIN_32)

   raw_attr = 0;

   if( ulAttr & HB_FA_ARCHIVE )   raw_attr |= FILE_ATTRIBUTE_ARCHIVE;
   if( ulAttr & HB_FA_DIRECTORY ) raw_attr |= FILE_ATTRIBUTE_DIRECTORY;
   if( ulAttr & HB_FA_HIDDEN )    raw_attr |= FILE_ATTRIBUTE_HIDDEN;
   if( ulAttr & HB_FA_READONLY )  raw_attr |= FILE_ATTRIBUTE_READONLY;
   if( ulAttr & HB_FA_SYSTEM )    raw_attr |= FILE_ATTRIBUTE_SYSTEM;
   if( ulAttr & HB_FA_NORMAL )    raw_attr |= FILE_ATTRIBUTE_NORMAL;

#ifdef HB_EXTENSION
   /* Note that FILE_ATTRIBUTE_NORMAL is not needed
      HB_FA_DEVICE not supported
      HB_FA_VOLCOMP needs to be checked */
   if( ulAttr & HB_FA_ENCRYPTED )  raw_attr |= FILE_ATTRIBUTE_ENCRYPTED;
   if( ulAttr & HB_FA_TEMPORARY )  raw_attr |= FILE_ATTRIBUTE_TEMPORARY;
   if( ulAttr & HB_FA_SPARSE )     raw_attr |= FILE_ATTRIBUTE_SPARSE_FILE;
   if( ulAttr & HB_FA_REPARSE )    raw_attr |= FILE_ATTRIBUTE_REPARSE_POINT;
   if( ulAttr & HB_FA_COMPRESSED ) raw_attr |= FILE_ATTRIBUTE_COMPRESSED;
   if( ulAttr & HB_FA_OFFLINE )    raw_attr |= FILE_ATTRIBUTE_OFFLINE;
   if( ulAttr & HB_FA_NOTINDEXED ) raw_attr |= 0x00002000; /* FILE_ATTRIBUTE_NOT_CONTENT_INDEXED not defined in some older winnt.h */
   if( ulAttr & HB_FA_VOLCOMP )    raw_attr |= 0x00008000;
#endif

#elif defined(HB_OS_UNIX)

   raw_attr = HB_FA_POSIX_ATTR( ulAttr );

   if( ulAttr & HB_FA_FILE )       raw_attr |= S_IFREG;
   if( ulAttr & HB_FA_DIRECTORY )  raw_attr |= S_IFDIR;
   if( ulAttr & HB_FA_LINK )       raw_attr |= S_IFLNK;
   if( ulAttr & HB_FA_CHRDEVICE )  raw_attr |= S_IFCHR;
   if( ulAttr & HB_FA_BLKDEVICE )  raw_attr |= S_IFBLK;
   if( ulAttr & HB_FA_FIFO )       raw_attr |= S_IFIFO;
   if( ulAttr & HB_FA_SOCKET )     raw_attr |= S_IFSOCK;

#else

   HB_SYMBOL_UNUSED( ulAttr );
   raw_attr = 0;

#endif

   return raw_attr;
}
hbffind.c264
ULONGhb_fsAttrEncode( const char * szAttr )
ULONG hb_fsAttrEncode( const char * szAttr )
{
   const char * pos = szAttr;
   char ch;
   ULONG ulAttr = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsAttrEncode(%p)", szAttr));

   while( ( ch = ( char ) toupper( *pos ) ) != '\0' )
   {
      switch( ch )
      {
         case 'R': ulAttr |= HB_FA_READONLY;   break;
         case 'H': ulAttr |= HB_FA_HIDDEN;     break;
         case 'S': ulAttr |= HB_FA_SYSTEM;     break;
         case 'V': ulAttr |= HB_FA_LABEL;      break;
         case 'D': ulAttr |= HB_FA_DIRECTORY;  break;
         case 'A': ulAttr |= HB_FA_ARCHIVE;    break;
#ifdef HB_EXTENSION
         case 'E': ulAttr |= HB_FA_ENCRYPTED;  break;
         case 'T': ulAttr |= HB_FA_TEMPORARY;  break;
         case 'P': ulAttr |= HB_FA_SPARSE;     break;
         case 'L': ulAttr |= HB_FA_REPARSE;    break;
         case 'C': ulAttr |= HB_FA_COMPRESSED; break;
         case 'O': ulAttr |= HB_FA_OFFLINE;    break;
         case 'X': ulAttr |= HB_FA_NOTINDEXED; break;
         case 'I': ulAttr |= HB_FA_DEVICE;     break;
         case 'M': ulAttr |= HB_FA_VOLCOMP;    break;
#endif
      }

      pos++;
   }

   return ulAttr;
}

hbffind.c339
CHAR *hb_fsAttrDecode( ULONG ulAttr, char * szAttr )
char * hb_fsAttrDecode( ULONG ulAttr, char * szAttr )
{
   char * ptr = szAttr;

   HB_TRACE(HB_TR_DEBUG, ("hb_fsAttrDecode(%lu, %p)", ulAttr, szAttr));

   /* Using the same order as CA-Cl*pper did: RHSVDA. */
   if( ulAttr & HB_FA_READONLY   ) *ptr++ = 'R';
   if( ulAttr & HB_FA_HIDDEN     ) *ptr++ = 'H';
   if( ulAttr & HB_FA_SYSTEM     ) *ptr++ = 'S';
   if( ulAttr & HB_FA_LABEL      ) *ptr++ = 'V';
   if( ulAttr & HB_FA_DIRECTORY  ) *ptr++ = 'D';
   if( ulAttr & HB_FA_ARCHIVE    ) *ptr++ = 'A';
#ifdef HB_EXTENSION
   if( ulAttr & HB_FA_ENCRYPTED  ) *ptr++ = 'E';
   if( ulAttr & HB_FA_TEMPORARY  ) *ptr++ = 'T';
   if( ulAttr & HB_FA_SPARSE     ) *ptr++ = 'P';
   if( ulAttr & HB_FA_REPARSE    ) *ptr++ = 'L';
   if( ulAttr & HB_FA_COMPRESSED ) *ptr++ = 'C';
   if( ulAttr & HB_FA_OFFLINE    ) *ptr++ = 'O';
   if( ulAttr & HB_FA_NOTINDEXED ) *ptr++ = 'X';
   if( ulAttr & HB_FA_DEVICE     ) *ptr++ = 'I';
   if( ulAttr & HB_FA_VOLCOMP    ) *ptr++ = 'M';
#endif

   *ptr = '\0';

   return szAttr;
}
hbffind.c381
STATIC BOOLhb_fsFindNextLow( PHB_FFIND ffind )
static BOOL hb_fsFindNextLow( PHB_FFIND ffind )
{
   BOOL bFound;

   USHORT nYear = 0;
   USHORT nMonth = 0;
   USHORT nDay = 0;

   USHORT nHour = 0;
   USHORT nMin = 0;
   USHORT nSec = 0;

   ULONG raw_attr = 0;

   /* Set the default values in case some platforms don't
      support some of these, or they may fail on them. */

   ffind->szName[ 0 ] = '\0';
   ffind->size = 0;

   /* Do platform dependant first/next search */

   hb_vmUnlock();

#if defined(HB_OS_DOS)

   {
      PHB_FFIND_INFO info = ( PHB_FFIND_INFO ) ffind->info;

      /* Handling HB_FA_LABEL doesn't need any special tricks 
         under the DOS platform. */

      if( ffind->bFirst )
      {
         ffind->bFirst = FALSE;

         tzset();

#if defined(__WATCOMC__)
         bFound = ( _dos_findfirst( ffind->pszFileMask, ( USHORT ) hb_fsAttrToRaw( ffind->attrmask ), &info->entry ) == 0 );
#else
         bFound = ( findfirst( ffind->pszFileMask, &info->entry, ( USHORT ) hb_fsAttrToRaw( ffind->attrmask ) ) == 0 );
#endif
      }
      else
      {
#if defined(__WATCOMC__)
         bFound = ( _dos_findnext( &info->entry ) == 0 );
#else
         bFound = ( findnext( &info->entry ) == 0 );
#endif
      }

      /* Fill Harbour found file info */

      if( bFound )
      {
         hb_strncpy( ffind->szName, info->entry.ff_name, sizeof( ffind->szName ) - 1 );
         ffind->size = info->entry.ff_fsize;

         raw_attr = info->entry.ff_attrib;

         {
            time_t ftime;
            struct tm * ft;
            struct stat sStat;

            stat( info->entry.ff_name, &sStat );

            ftime = sStat.st_mtime;
            ft = localtime( &ftime );

            nYear  = ft->tm_year + 1900;
            nMonth = ft->tm_mon + 1;
            nDay   = ft->tm_mday;

            nHour  = ft->tm_hour;
            nMin   = ft->tm_min;
            nSec   = ft->tm_sec;
         }
      }
      hb_fsSetIOError( bFound, 0 );
   }

#elif defined(HB_OS_OS2)

   {
      PHB_FFIND_INFO info = ( PHB_FFIND_INFO ) ffind->info;

      /* TODO: HB_FA_LABEL handling */

      if( ffind->bFirst )
      {
         ffind->bFirst = FALSE;

         tzset();

         info->hFindFile = HDIR_CREATE;
         info->findCount = 1;

         bFound = DosFindFirst( ffind->pszFileMask,
                                &info->hFindFile,
                                ( LONG ) hb_fsAttrToRaw( ffind->attrmask ),
                                &info->entry,
                                sizeof( info->entry ),
                                &info->findCount,
                                FIL_STANDARD ) == NO_ERROR && info->findCount > 0;
      }
      else
         bFound = DosFindNext( info->hFindFile, 
                               &info->entry, 
                               sizeof( info->entry ), 
                               &info->findCount ) == NO_ERROR && info->findCount > 0;

      /* Fill Harbour found file info */

      if( bFound )
      {
         struct stat sStat;

         stat( info->entry.achName, &sStat );

         hb_strncpy( ffind->szName, info->entry.achName, sizeof( ffind->szName ) - 1 );
         ffind->size = sStat.st_size;

         raw_attr = info->entry.attrFile;

         {
            time_t ftime;
            struct tm * ft;

            ftime = sStat.st_mtime;
            ft = localtime( &ftime );

            nYear  = ft->tm_year + 1900;
            nMonth = ft->tm_mon + 1;
            nDay   = ft->tm_mday;

            nHour  = ft->tm_hour;
            nMin   = ft->tm_min;
            nSec   = ft->tm_sec;
         }
      }
      hb_fsSetIOError( bFound, 0 );
   }

#elif defined(HB_OS_WIN_32)

   {
      PHB_FFIND_INFO info = ( PHB_FFIND_INFO ) ffind->info;

      bFound = FALSE;

      if( ffind->attrmask & HB_FA_LABEL )
      {
         if( ffind->bFirst )
         {
            ffind->bFirst = FALSE;
            ffind->szName[ 0 ] = '\0';

            bFound = GetVolumeInformationA( ffind->pszFileMask, ffind->szName, _POSIX_PATH_MAX, NULL, NULL, NULL, NULL, 0 );
         }
      }
      else
      {
         if( ffind->bFirst )
         {
            ffind->bFirst = FALSE;

            info->hFindFile = FindFirstFileA( ffind->pszFileMask, &info->pFindFileData );
            info->dwAttr    = ( DWORD ) hb_fsAttrToRaw( ffind->attrmask );

            if( ( info->hFindFile != INVALID_HANDLE_VALUE ) && HB_WIN_32_MATCH() )
               bFound = TRUE;
         }

         if( ! bFound && info->hFindFile != INVALID_HANDLE_VALUE )
         {
            while( FindNextFileA( info->hFindFile, &info->pFindFileData ) )
            {
               if( HB_WIN_32_MATCH() )
               {
                  bFound = TRUE;
                  break;
               }
            }
         }

         /* Fill Harbour found file info */

         if( bFound )
         {
            hb_strncpy( ffind->szName, info->pFindFileData.cFileName, sizeof( ffind->szName ) - 1 );

            if( info->pFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
               ffind->size = 0;
            else
            {
#if defined(__XCC__) || __POCC__ >= 500
               /* NOTE: PellesC 5.00.1 will go into an infinite loop if we don't 
                        split this into two operations. [vszakats] */
               ffind->size = ( HB_FOFFSET ) info->pFindFileData.nFileSizeLow;
               ffind->size += ( HB_FOFFSET ) info->pFindFileData.nFileSizeHigh << 32;
#else
               ffind->size = ( HB_FOFFSET ) info->pFindFileData.nFileSizeLow +
                     ( ( HB_FOFFSET ) info->pFindFileData.nFileSizeHigh << 32 );
#endif
            }

            raw_attr = ( ULONG ) info->pFindFileData.dwFileAttributes;

            /* NOTE: One of these may fail when searching on an UNC path, I
                     don't know yet what's the reason. [vszakats] */

            {
               FILETIME ft;
               SYSTEMTIME time;

               if( FileTimeToLocalFileTime( &info->pFindFileData.ftLastWriteTime, &ft ) &&
                   FileTimeToSystemTime( &ft, &time ) )
               {
                  nYear  = time.wYear;
                  nMonth = time.wMonth;
                  nDay   = time.wDay;
                  nHour  = time.wHour;
                  nMin   = time.wMinute;
                  nSec   = time.wSecond;
               }
            }
         }
      }
      hb_fsSetIOError( bFound, 0 );
   }

#elif defined(HB_OS_UNIX)

   {
      PHB_FFIND_INFO info = ( PHB_FFIND_INFO ) ffind->info;

      char dirname[ _POSIX_PATH_MAX + 1 ];
      char string[ _POSIX_PATH_MAX + 1 ];

      bFound = FALSE;

      /* TODO: HB_FA_LABEL handling */

      string[ 0 ] = '\0';
      if( ffind->bFirst )
      {
         char * pos;

         ffind->bFirst = FALSE;

         dirname[ 0 ] = '\0';
         info->pattern[ 0 ] = '\0';

         /* hb_strncpy( string, pszFileName, sizeof( string ) - 1 ); */
         hb_strncpy( string, ffind->pszFileMask, sizeof( string ) - 1 ); 
         pos = strrchr( string, HB_OS_PATH_DELIM_CHR );
         if( pos )
         {
            hb_strncpy( info->pattern, pos + 1, sizeof( info->pattern ) - 1 );
            *( pos + 1 ) = '\0';
            hb_strncpy( dirname, string, sizeof( dirname ) - 1 );
         }
         else
         {
            hb_strncpy( info->pattern, string, sizeof( info->pattern ) - 1 );
            dirname[ 0 ] = '.';
            dirname[ 1 ] = HB_OS_PATH_DELIM_CHR;
            dirname[ 2 ] = '\0';
         }

         tzset();

         info->dir = opendir( dirname );
         hb_strncpy( info->path, dirname, sizeof( info->path ) - 1 );
      }

      if( info->dir && info->pattern[ 0 ] != '\0' )
      {
         while( ( info->entry = readdir( info->dir ) ) != NULL )
         {
            hb_strncpy( string, info->entry->d_name, sizeof( string ) - 1 );
            if( hb_strMatchFile( string, info->pattern ) )
            {
               bFound = TRUE;
               break;
            }
         }
      }

      /* Fill Harbour found file info */
      if( bFound )
      {
         hb_strncpy( dirname, info->path, sizeof( dirname ) - 1 );
         hb_strncat( dirname, info->entry->d_name, sizeof( dirname ) - 1 );
         {
            time_t ftime;
            struct tm * ft;
#if defined( HB_USE_LARGEFILE64 )
            struct stat64 sStat;
            if( stat64( dirname, &sStat ) == 0 )
#else
            struct stat sStat;
            if( stat( dirname, &sStat ) == 0 )
#endif
            {
               hb_strncpy( ffind->szName, info->entry->d_name, sizeof( ffind->szName ) - 1 );
               ffind->size = sStat.st_size;

               raw_attr = sStat.st_mode;

               ftime = sStat.st_mtime;
               ft = localtime( &ftime );

               nYear  = ft->tm_year + 1900;
               nMonth = ft->tm_mon + 1;
               nDay   = ft->tm_mday;

               nHour  = ft->tm_hour;
               nMin   = ft->tm_min;
               nSec   = ft->tm_sec;
            }
            else
               bFound = FALSE;
         }
      }
      hb_fsSetIOError( bFound, 0 );
   }

#else

   {
      int TODO; /* TODO: for given platform */

      /* HB_SYMBOL_UNUSED( ffind ); */

      HB_SYMBOL_UNUSED( nYear );
      HB_SYMBOL_UNUSED( nMonth );
      HB_SYMBOL_UNUSED( nDay );
      HB_SYMBOL_UNUSED( nHour );
      HB_SYMBOL_UNUSED( nMin );
      HB_SYMBOL_UNUSED( nSec );
      HB_SYMBOL_UNUSED( raw_attr );

      bFound = FALSE;

      hb_fsSetError( ( USHORT ) FS_ERROR );
   }

#endif

   /* Fill common Harbour found file info */

   if( bFound )
   {
      /* Do the conversions common for all platforms */
      ffind->szName[ _POSIX_PATH_MAX ] = '\0';

      ffind->attr = hb_fsAttrFromRaw( raw_attr );

      ffind->lDate = hb_dateEncode( nYear, nMonth, nDay );
      hb_dateStrPut( ffind->szDate, nYear, nMonth, nDay );
      ffind->szDate[ 8 ] = '\0';

      snprintf( ffind->szTime, sizeof( ffind->szTime ), "%02d:%02d:%02d", nHour, nMin, nSec );
   }
   hb_vmLock();

   return bFound;
}
hbffind.c415
HB_EXPORT PHB_FFINDhb_fsFindFirst( const char * pszFileMask, ULONG attrmask )
HB_EXPORT PHB_FFIND hb_fsFindFirst( const char * pszFileMask, ULONG attrmask )
{
   PHB_FFIND ffind;

   ffind = ( PHB_FFIND ) hb_xgrab( sizeof( HB_FFIND ) );
   memset( ffind, 0, sizeof( HB_FFIND ) );

   /* Allocate platform dependent file find info storage */
   ffind->info = ( void * ) hb_xgrab( sizeof( HB_FFIND_INFO ) );
   memset( ffind->info, 0, sizeof( HB_FFIND_INFO ) );

   /* Store search parameters */
   ffind->pszFileMask = pszFileMask;
   ffind->attrmask = attrmask;
   ffind->bFirst = TRUE;

   /* Find first/next matching file */

   if( hb_fsFindNext( ffind ) )
      return ffind;

   /* If no file found at all, free stuff allocated so far and return NULL. */

   hb_fsFindClose( ffind );

   return NULL;
}
hbffind.c788
HB_EXPORT BOOLhb_fsFindNext( PHB_FFIND ffind )
HB_EXPORT BOOL hb_fsFindNext( PHB_FFIND ffind )
{
   while( hb_fsFindNextLow( ffind ) )
   {
      /* Filter the result to stay MS-DOS and CA-Cl*pper compatible. */

      if( !( ( ( ffind->attrmask & HB_FA_HIDDEN    ) == 0 && ( ffind->attr & HB_FA_HIDDEN    ) != 0 ) ||
             ( ( ffind->attrmask & HB_FA_SYSTEM    ) == 0 && ( ffind->attr & HB_FA_SYSTEM    ) != 0 ) ||
             ( ( ffind->attrmask & HB_FA_LABEL     ) == 0 && ( ffind->attr & HB_FA_LABEL     ) != 0 ) ||
             ( ( ffind->attrmask & HB_FA_DIRECTORY ) == 0 && ( ffind->attr & HB_FA_DIRECTORY ) != 0 ) ) )
      {
         return TRUE;
      }
   }

   return FALSE;
}
hbffind.c819
HB_EXPORT VOIDhb_fsFindClose( PHB_FFIND ffind )
HB_EXPORT void hb_fsFindClose( PHB_FFIND ffind )
{
   if( ffind )
   {
      /* Do platform dependant cleanup */

      if( ffind->info )
      {
         PHB_FFIND_INFO info = ( PHB_FFIND_INFO ) ffind->info;

         hb_vmUnlock();

#if defined(HB_OS_DOS)

         #if defined(__DJGPP__) || defined(__BORLANDC__)
         {
            HB_SYMBOL_UNUSED( info );
         }
         #else
         {
#if defined(__WATCOMC__)
            _dos_findclose( &info->entry );
#else
            findclose( &info->entry );
#endif
         }
         #endif

#elif defined(HB_OS_OS2)

         {
            DosFindClose( info->hFindFile );
         }

#elif defined(HB_OS_WIN_32)

         if( info->hFindFile != INVALID_HANDLE_VALUE )
         {
            FindClose( info->hFindFile );
         }

#elif defined(HB_OS_UNIX)

         if( info->dir )
         {
            closedir( info->dir );
         }

#else

         {
            /* Intentionally do nothing */
            int TODO; /* TODO: for given platform */

            HB_SYMBOL_UNUSED( info );
         }

#endif

         hb_vmLock();

         hb_xfree( ( void * ) ffind->info );
      }

      hb_xfree( ( void * ) ffind );
   }
}
hbffind.c837
hbfile.c
TypeFunctionSourceLine
HB_FUNCHB_FILEEXISTS(void)
HB_FUNC( HB_FILEEXISTS )
{
   hb_retl( hb_fsFileExists( hb_parc( 1 ) ) );
}
hbfile.c56
HB_FUNCHB_DIREXISTS(void)
HB_FUNC( HB_DIREXISTS )
{
   hb_retl( hb_fsDirExists( hb_parc( 1 ) ) );
}
hbfile.c61
hbgtcore.c
TypeFunctionSourceLine
PHB_GThb_gt_Base( void )
PHB_GT hb_gt_Base( void )
{
   return s_curGT;
}
hbgtcore.c80
VOIDhb_gt_BaseFree( PHB_GT pGT )
void hb_gt_BaseFree( PHB_GT pGT )
{
   HB_SYMBOL_UNUSED( pGT );
}
hbgtcore.c85
STATIC VOIDhb_gt_def_BaseInit( PHB_GT_BASE pGT )
static void hb_gt_def_BaseInit( PHB_GT_BASE pGT )
{
   pGT->fVgaCell     = TRUE;
   pGT->fIsColor     = TRUE;
   pGT->fBlinking    = TRUE;
   pGT->fStdOutCon   = FALSE;
   pGT->fStdErrCon   = FALSE;
   pGT->iCursorShape = SC_NORMAL;
   pGT->uiDispCount  = 0;
   pGT->uiExtCount   = 0;
   pGT->uiClearChar  = ' ';
   pGT->bClearColor  = 0x07;
   pGT->iHeight      = 24;
   pGT->iWidth       = 80;
   pGT->hStdIn       = s_hStdIn;
   pGT->hStdOut      = s_hStdOut;
   pGT->hStdErr      = s_hStdErr;

   pGT->iDoubleClickSpeed = 168; /* In milliseconds */

   pGT->inkeyBuffer     = pGT->defaultKeyBuffer;
   pGT->inkeyBufferSize = HB_DEFAULT_INKEY_BUFSIZE;
}
hbgtcore.c90
STATIC VOID *hb_gt_def_New( PHB_GT pGT )
static void * hb_gt_def_New( PHB_GT pGT )
{
   ULONG ulSize, ulIndex;
   USHORT usChar;
   BYTE bColor, bAttr;
   int i;

   hb_gt_def_BaseInit( pGT );

   HB_GTSELF_GETSIZE( pGT, &pGT->iHeight, &pGT->iWidth );
   ulSize = ( ULONG ) pGT->iHeight * pGT->iWidth;

   pGT->screenBuffer =
            ( PHB_SCREENCELL ) hb_xgrab( sizeof( HB_SCREENCELL ) * ulSize );
   pGT->prevBuffer =
            ( PHB_SCREENCELL ) hb_xgrab( sizeof( HB_SCREENCELL ) * ulSize );
   pGT->pLines = ( BOOL * ) hb_xgrab( sizeof( BOOL ) * pGT->iHeight );

   memset( pGT->prevBuffer, 0, sizeof( HB_SCREENCELL ) * ulSize );
   for( i = 0; i < pGT->iHeight; ++i )
      pGT->pLines[ i ] = TRUE;

   usChar = HB_GTSELF_GETCLEARCHAR( pGT );
   bColor = HB_GTSELF_GETCLEARCOLOR( pGT );
   bAttr  = 0;
   for( ulIndex = 0; ulIndex < ulSize; ++ulIndex )
   {
      pGT->screenBuffer[ ulIndex ].c.usChar = usChar;
      pGT->screenBuffer[ ulIndex ].c.bColor = bColor;
      pGT->screenBuffer[ ulIndex ].c.bAttr = bAttr;
      pGT->prevBuffer[ ulIndex ].c.bAttr = HB_GT_ATTR_REFRESH;
   }

   return pGT;
}
hbgtcore.c115
STATIC VOIDhb_gt_def_Free( PHB_GT pGT )
static void hb_gt_def_Free( PHB_GT pGT )
{
   if( pGT->screenBuffer )
      hb_xfree( pGT->screenBuffer );
   if( pGT->prevBuffer )
      hb_xfree( pGT->prevBuffer );
   if( pGT->pLines )
      hb_xfree( pGT->pLines );
   if( pGT->iColorCount > 0 )
      hb_xfree( pGT->pColor );

   if( pGT->pNotifierBlock )
      hb_itemRelease( pGT->pNotifierBlock );

   if( s_curGT == pGT )
      s_curGT = NULL;

   hb_xfree( pGT );
}
hbgtcore.c151
STATIC VOIDhb_gt_def_Init( PHB_GT pGT, HB_FHANDLE hStdIn, HB_FHANDLE hStdOut, HB_FHANDLE hStdErr )
static void hb_gt_def_Init( PHB_GT pGT, HB_FHANDLE hStdIn, HB_FHANDLE hStdOut, HB_FHANDLE hStdErr )
{
   HB_GTSELF_NEW( pGT );

   pGT->hStdIn  = hStdIn;
   pGT->hStdOut = hStdOut;
   pGT->hStdErr = hStdErr;

   HB_GTSELF_RESIZE( pGT, pGT->iHeight, pGT->iWidth );
   HB_GTSELF_MOUSEINIT( pGT );
   HB_GTSELF_MOUSEGETPOS( pGT, &pGT->iMouseLastRow, &pGT->iMouseLastCol );
}
hbgtcore.c171
STATIC VOIDhb_gt_def_Exit( PHB_GT pGT )
static void hb_gt_def_Exit( PHB_GT pGT )
{
   HB_GTSELF_MOUSEEXIT( pGT );
   HB_GTSELF_INKEYEXIT( pGT );

   HB_GTSELF_FREE( pGT );

   /* clear internal clipboard data */
   hb_gt_setClipboard( NULL, 0 );
}
hbgtcore.c184
STATIC BOOLhb_gt_def_CheckPos( PHB_GT pGT, int iRow, int iCol, long *plIndex )
static BOOL hb_gt_def_CheckPos( PHB_GT pGT, int iRow, int iCol, long *plIndex )
{
   if( iRow >= 0 && iCol >= 0 )
   {
      int iHeight, iWidth;

      HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
      if( iRow < iHeight && iCol < iWidth )
      {
         if( plIndex )
            *plIndex = ( long ) iRow * iWidth + iCol;
         return TRUE;
      }
   }
   return FALSE;
}
hbgtcore.c195
STATIC VOIDhb_gt_def_GetPos( PHB_GT pGT, int * piRow, int * piCol )
static void hb_gt_def_GetPos( PHB_GT pGT, int * piRow, int * piCol )
{
   * piRow = pGT->iRow;
   * piCol = pGT->iCol;
}
hbgtcore.c212
STATIC VOIDhb_gt_def_SetPos( PHB_GT pGT, int iRow, int iCol )
static void hb_gt_def_SetPos( PHB_GT pGT, int iRow, int iCol )
{
   pGT->iRow = iRow;
   pGT->iCol = iCol;
}
hbgtcore.c218
STATIC INThb_gt_def_MaxCol( PHB_GT pGT )
static int hb_gt_def_MaxCol( PHB_GT pGT )
{
   return pGT->iWidth - 1;
}
hbgtcore.c224
STATIC INThb_gt_def_MaxRow( PHB_GT pGT )
static int hb_gt_def_MaxRow( PHB_GT pGT )
{
   return pGT->iHeight - 1;
}
hbgtcore.c229
STATIC BOOLhb_gt_def_IsColor( PHB_GT pGT )
static BOOL hb_gt_def_IsColor( PHB_GT pGT )
{
   return pGT->fIsColor;
}
hbgtcore.c234
STATIC VOIDhb_gt_def_GetColorStr( PHB_GT pGT, char * pszColorString )
static void hb_gt_def_GetColorStr( PHB_GT pGT, char * pszColorString )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_GetColorStr(%p,%s)", pGT, pszColorString));

   HB_GTSELF_COLORSTOSTRING( pGT, pGT->pColor, pGT->iColorCount,
                             pszColorString, HB_CLRSTR_LEN );
}
hbgtcore.c239
STATIC VOIDhb_gt_def_SetColorStr( PHB_GT pGT, const char * szColorString )
static void hb_gt_def_SetColorStr( PHB_GT pGT, const char * szColorString )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_SetColorStr(%p,%s)", pGT, szColorString));

   HB_GTSELF_STRINGTOCOLORS( pGT, szColorString, &pGT->pColor, &pGT->iColorCount );
   pGT->iColorIndex = HB_CLR_STANDARD; /* HB_GTSELF_COLORSELECT( pGT, HB_CLR_STANDARD ); */
}
hbgtcore.c251
STATIC VOIDhb_gt_def_ColorSelect( PHB_GT pGT, int iColorIndex )
static void hb_gt_def_ColorSelect( PHB_GT pGT, int iColorIndex )
{
   if( iColorIndex >= 0 && iColorIndex < pGT->iColorCount )
      pGT->iColorIndex = iColorIndex;
}
hbgtcore.c259
STATIC INThb_gt_def_GetColor( PHB_GT pGT )
static int  hb_gt_def_GetColor( PHB_GT pGT )
{
   if( pGT->iColorCount )
      return pGT->pColor[ pGT->iColorIndex ];
   else
      return HB_GTSELF_GETCLEARCOLOR( pGT );
}
hbgtcore.c265
STATIC VOIDhb_gt_def_GetColorData( PHB_GT pGT, int ** pColorsPtr, int * piColorCount, int * piColorIndex )
static void hb_gt_def_GetColorData( PHB_GT pGT, int ** pColorsPtr, int * piColorCount, int * piColorIndex )
{
   if( pGT->iColorCount )
   {
      *pColorsPtr = ( int * ) hb_xgrab( pGT->iColorCount * sizeof( int ) );
      memcpy( *pColorsPtr, pGT->pColor, pGT->iColorCount * sizeof( int ) );
      *piColorCount = pGT->iColorCount;
      *piColorIndex = pGT->iColorIndex;
   }
   else
   {
      *pColorsPtr = ( int * ) hb_xgrab( sizeof( int ) );
      *pColorsPtr[ 0 ] = 0;
      *piColorCount = 1;
      *piColorIndex = 0;
   }
}
hbgtcore.c273
STATIC INThb_gt_def_GetClearColor( PHB_GT pGT )
static int  hb_gt_def_GetClearColor( PHB_GT pGT )
{
   return pGT->bClearColor;
}
hbgtcore.c291
STATIC VOIDhb_gt_def_SetClearColor( PHB_GT pGT, int iColor )
static void hb_gt_def_SetClearColor( PHB_GT pGT, int iColor )
{
   pGT->bClearColor = iColor;
}
hbgtcore.c296
STATIC INThb_gt_def_GetClearChar( PHB_GT pGT )
static int  hb_gt_def_GetClearChar( PHB_GT pGT )
{
   return pGT->uiClearChar;
}
hbgtcore.c301
STATIC VOIDhb_gt_def_SetClearChar( PHB_GT pGT, int iChar )
static void hb_gt_def_SetClearChar( PHB_GT pGT, int iChar )
{
   pGT->uiClearChar = iChar;
}
hbgtcore.c306
STATIC CONST CHAR *hb_gt_def_ColorDecode( const char * szColorString, int * piColor )
static const char * hb_gt_def_ColorDecode( const char * szColorString, int * piColor )
{
   char c;
   int nColor = 0, iCount = 0;
   BOOL bFore = TRUE;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_ColorDecode(%s,%p)", szColorString, piColor));

   while( ( c = *szColorString++ ) != 0 )
   {
      switch( c )
      {
         case '*':
            nColor |= 0x80;
            break;

         case '+':
            nColor |= 0x08;
            break;

         case '/':
            if( !bFore )
               nColor = ( ( nColor >> 4 ) & 0x0F07 ) | ( nColor & 0x88 );
            else
               bFore = FALSE;
            break;

         case 'b':
         case 'B':
            nColor |= bFore ? 0x01: 0x10;
            break;

         case 'g':
         case 'G':
            nColor |= bFore ? 0x02: 0x20;
            break;

         case 'r':
         case 'R':
            nColor |= bFore ? 0x04: 0x40;
            break;

         case 'w':
         case 'W':
            nColor |= bFore ? 0x07: 0x70;
            break;

         case 'n':
         case 'N':
            nColor &= bFore ? 0xFFF8: 0xFF8F;
            break;

         case 'i':
         case 'I':
            bFore = FALSE;
            nColor &= 0x88;
            nColor |= 0x70;
            break;

         case 'x':
         case 'X':
            nColor &= 0x88;
            break;

         case 'u':
         case 'U':
            if( bFore )
               nColor = ( nColor & 0xF0F8 ) | 0x0801;
            else
               nColor = ( nColor & 0x0F8F ) | 0x8010;
            break;

         case ',':
            * piColor = iCount == 0 ? -1 : nColor;
            return szColorString;

         default:
            if( c >= '0' && c <= '9' )
            {
               int iColor = c - '0';
               while( *szColorString >= '0' && *szColorString <= '9' )
                  iColor = iColor * 10 + ( *szColorString++ - '0' );
               iColor &= 0x0f;
               if( bFore )
                  nColor = ( nColor & 0xF0F8 ) | iColor;
               else
                  nColor = ( nColor & 0x0F8F ) | ( iColor << 4 );
            }
            else
               --iCount;
      }
      ++iCount;
   }

   * piColor = iCount == 0 ? -1 : nColor;
   return NULL;
}
hbgtcore.c311
STATIC INThb_gt_def_ColorNum( PHB_GT pGT, const char * szColorString )
static int  hb_gt_def_ColorNum( PHB_GT pGT, const char * szColorString )
{
   int nColor;

   HB_SYMBOL_UNUSED( pGT );
   hb_gt_def_ColorDecode( szColorString, &nColor );

   return nColor;
}
hbgtcore.c417
STATIC VOIDhb_gt_def_StringToColors( PHB_GT pGT, const char * szColorString, int ** pColorsPtr, int * piColorCount )
static void hb_gt_def_StringToColors( PHB_GT pGT, const char * szColorString, int ** pColorsPtr, int * piColorCount )
{
   int * pColors;
   int nPos = 0;
   int nColor;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_StringToColors(%p,%s,%p,%p)", pGT, szColorString, pColorsPtr, piColorCount));

   HB_SYMBOL_UNUSED( pGT );

   if( *piColorCount == 0 )
   {
      *piColorCount = HB_CLR_MAX_ + 1;
      *pColorsPtr = ( int * ) hb_xgrab( *piColorCount * sizeof( int ) );
      memset( *pColorsPtr, 0, *piColorCount * sizeof( int ) );
   }

   pColors = *pColorsPtr;

   if( !szColorString || !*szColorString )
   {
      pColors[ HB_CLR_STANDARD   ] = 0x07;
      pColors[ HB_CLR_ENHANCED   ] = 0x70;
      pColors[ HB_CLR_BORDER     ] = 0;
      pColors[ HB_CLR_BACKGROUND ] = 0;
      pColors[ HB_CLR_UNSELECTED ] = 0x70;
   }
   else do
   {
      szColorString = hb_gt_def_ColorDecode( szColorString, &nColor );

      if( nPos == *piColorCount )
      {
         ++*piColorCount;
         pColors = *pColorsPtr = ( int * ) hb_xrealloc( pColors, *piColorCount * sizeof( int ) );
         pColors[ nPos ] = 0;
      }
      if( nColor != -1 )
         pColors[ nPos ] = nColor;
      ++nPos;
   }
   while( szColorString );

   if( nPos >= HB_CLR_ENHANCED && nPos < HB_CLR_UNSELECTED &&
       *piColorCount > HB_CLR_UNSELECTED )
      pColors[ HB_CLR_UNSELECTED ] = pColors[ HB_CLR_ENHANCED ];
}
hbgtcore.c427
STATIC VOIDhb_gt_def_ColorsToString( PHB_GT pGT, int * pColors, int iColorCount, char * pszColorString, int iBufSize )
static void hb_gt_def_ColorsToString( PHB_GT pGT, int * pColors, int iColorCount, char * pszColorString, int iBufSize )
{
   int iColorIndex, iPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_ColorsToString(%p,%p,%d,%s,%d)", pGT, pColors, iColorCount, pszColorString, iBufSize));

   HB_SYMBOL_UNUSED( pGT );

   /* Go on if there's space left for the largest color string plus EOF */
   for( iColorIndex = iPos = 0; iColorIndex < iColorCount && iPos < iBufSize - 8; ++iColorIndex )
   {
      int nColor = pColors[ iColorIndex ] & 7;
      int j;

      if( iColorIndex > 0 )
         pszColorString[ iPos++ ] = ',';

      for( j = 0; j <= 1; j++ )
      {
         if( ( pColors[ iColorIndex ] & ( j ? 0x8000 : 0x0800 ) ) == 0 )
         {
            if( nColor == 7 )
               pszColorString[ iPos++ ] = 'W';
            else if( nColor == 0 )
               pszColorString[ iPos++ ] = 'N';
            else
            {
               if( ( nColor & 1 ) != 0 )
                  pszColorString[ iPos++ ] = 'B';

               if( ( nColor & 2 ) != 0 )
                  pszColorString[ iPos++ ] = 'G';

               if( ( nColor & 4 ) != 0 )
                  pszColorString[ iPos++ ] = 'R';
            }
         }
         else
            pszColorString[ iPos++ ] = 'U';

         if( j == 0 )
         {
            /* NOTE: When STRICT is on, Harbour will put both the "*" and "+"
                     chars to the first half of the colorspec (like "W*+/B"),
                     which is quite ugly, otherwise it will put the "+" to the
                     first half and the "*" to the second (like "W+/B*"), which
                     is how it should be done. [vszakats] */
#ifdef HB_C52_STRICT
            if( ( pColors[ iColorIndex ] & 0x80 ) != 0 )
               pszColorString[ iPos++ ] = '*';
#endif

            if( ( pColors[ iColorIndex ] & 0x08 ) != 0 )
               pszColorString[ iPos++ ] = '+';

            pszColorString[ iPos++ ] = '/';
         }
#ifndef HB_C52_STRICT
         else
         {
            if( ( pColors[ iColorIndex ] & 0x80 ) != 0 )
               pszColorString[ iPos++ ] = '*';
         }
#endif
         nColor = ( pColors[ iColorIndex ] >> 4 ) & 7;
      }
   }

   pszColorString[ iPos ] = '\0';
}
hbgtcore.c475
STATIC INThb_gt_def_GetCursorStyle( PHB_GT pGT )
static int  hb_gt_def_GetCursorStyle( PHB_GT pGT )
{
   return pGT->iCursorShape;
}
hbgtcore.c547
STATIC VOIDhb_gt_def_SetCursorStyle( PHB_GT pGT, int iStyle )
static void hb_gt_def_SetCursorStyle( PHB_GT pGT, int iStyle )
{
   switch( iStyle )
   {
      case SC_NONE:
      case SC_NORMAL:
      case SC_INSERT:
      case SC_SPECIAL1:
      case SC_SPECIAL2:
         pGT->iCursorShape = iStyle;
         break;
      default:
         pGT->iCursorShape = SC_NORMAL;
         break;
   }
}
hbgtcore.c552
STATIC VOIDhb_gt_def_GetScrCursor( PHB_GT pGT, int * piRow, int * piCol, int * piStyle )
static void hb_gt_def_GetScrCursor( PHB_GT pGT, int * piRow, int * piCol, int * piStyle )
{
   HB_GTSELF_GETPOS( pGT, piRow, piCol );
   if( *piRow < 0 || *piCol < 0 ||
       *piRow > HB_GTSELF_MAXROW( pGT ) || *piCol > HB_GTSELF_MAXCOL( pGT ) )
      *piStyle = SC_NONE;
   else
      *piStyle = HB_GTSELF_GETCURSORSTYLE( pGT );
}
hbgtcore.c569
STATIC BOOLhb_gt_def_GetBlink( PHB_GT pGT )
static BOOL hb_gt_def_GetBlink( PHB_GT pGT )
{
   return pGT->fBlinking;
}
hbgtcore.c579
STATIC VOIDhb_gt_def_SetBlink( PHB_GT pGT, BOOL fBlink )
static void hb_gt_def_SetBlink( PHB_GT pGT, BOOL fBlink )
{
   pGT->fBlinking = fBlink;
}
hbgtcore.c584
STATIC VOIDhb_gt_def_SetSnowFlag( PHB_GT pGT, BOOL fNoSnow )
static void hb_gt_def_SetSnowFlag( PHB_GT pGT, BOOL fNoSnow )
{
   /*
    * NOTE: This is a compatibility function which have to be implemented
    *       in low level GT driver.
    *       If you're running on a CGA and snow is a problem speak up!
    */

   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( fNoSnow );
}
hbgtcore.c589
STATIC VOIDhb_gt_def_DispBegin( PHB_GT pGT )
static void hb_gt_def_DispBegin( PHB_GT pGT )
{
   pGT->uiDispCount++;
}
hbgtcore.c601
STATIC VOIDhb_gt_def_DispEnd( PHB_GT pGT )
static void hb_gt_def_DispEnd( PHB_GT pGT )
{
   if( pGT->uiDispCount > 0 )
      pGT->uiDispCount--;
}
hbgtcore.c606
STATIC INThb_gt_def_DispCount( PHB_GT pGT )
static int hb_gt_def_DispCount( PHB_GT pGT )
{
   return pGT->uiDispCount;
}
hbgtcore.c612
STATIC BOOLhb_gt_def_PreExt( PHB_GT pGT )
static BOOL hb_gt_def_PreExt( PHB_GT pGT )
{
   if( pGT->uiExtCount == 0 )
      HB_GTSELF_REFRESH( pGT );
   pGT->uiExtCount++;

   return TRUE;
}
hbgtcore.c617
STATIC BOOLhb_gt_def_PostExt( PHB_GT pGT )
static BOOL hb_gt_def_PostExt( PHB_GT pGT )
{
   if( pGT->uiExtCount )
      pGT->uiExtCount--;

   return TRUE;
}
hbgtcore.c626
STATIC BOOLhb_gt_def_Suspend( PHB_GT pGT )
static BOOL hb_gt_def_Suspend( PHB_GT pGT )
{
   return HB_GTSELF_PREEXT( pGT );
}
hbgtcore.c634
STATIC BOOLhb_gt_def_Resume( PHB_GT pGT )
static BOOL hb_gt_def_Resume( PHB_GT pGT )
{
   return HB_GTSELF_POSTEXT( pGT );
}
hbgtcore.c639
STATIC VOIDhb_gt_def_OutStd( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen )
static void hb_gt_def_OutStd( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen )
{
   if( ulLen )
   {
      if( pGT->fStdOutCon )
         HB_GTSELF_WRITECON( pGT, pbyStr, ulLen );
      else
      {
         HB_GTSELF_PREEXT( pGT );
         if( pGT->fDispTrans )
         {
            BYTE * pbyStrBuff = ( BYTE * ) hb_xgrab( ulLen );
            memcpy( pbyStrBuff, pbyStr, ulLen );
            hb_cdpnTranslate( ( char * ) pbyStrBuff,
                              pGT->cdpHost, pGT->cdpTerm, ulLen );
            hb_fsWriteLarge( pGT->hStdOut, pbyStrBuff, ulLen );
            hb_xfree( pbyStrBuff );
         }
         else
            hb_fsWriteLarge( pGT->hStdOut, pbyStr, ulLen );
         HB_GTSELF_POSTEXT( pGT );
      }
   }
}
hbgtcore.c644
STATIC VOIDhb_gt_def_OutErr( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen )
static void hb_gt_def_OutErr( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen )
{
   if( ulLen )
   {
      if( pGT->fStdErrCon )
         HB_GTSELF_WRITECON( pGT, pbyStr, ulLen );
      else
      {
         HB_GTSELF_PREEXT( pGT );
         if( pGT->fDispTrans )
         {
            BYTE * pbyStrBuff = ( BYTE * ) hb_xgrab( ulLen );
            memcpy( pbyStrBuff, pbyStr, ulLen );
            hb_cdpnTranslate( ( char * ) pbyStrBuff,
                              pGT->cdpHost, pGT->cdpTerm, ulLen );
            hb_fsWriteLarge( pGT->hStdErr, pbyStrBuff, ulLen );
            hb_xfree( pbyStrBuff );
         }
         else
            hb_fsWriteLarge( pGT->hStdErr, pbyStr, ulLen );
         HB_GTSELF_POSTEXT( pGT );
      }
   }
}
hbgtcore.c669
STATIC VOIDhb_gt_def_Tone( PHB_GT pGT, double dFrequency, double dDuration )
static void hb_gt_def_Tone( PHB_GT pGT, double dFrequency, double dDuration )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( dFrequency );

   /* convert Clipper (DOS) timer tick units to seconds ( x / 18.2 ) */
   hb_idleSleep( dDuration / 18.2 );
}
hbgtcore.c694
STATIC VOIDhb_gt_def_Bell( PHB_GT pGT )
static void hb_gt_def_Bell( PHB_GT pGT )
{
   HB_GTSELF_TONE( pGT, 700.0, 3.0 );
}
hbgtcore.c703
STATIC CONST CHAR *hb_gt_def_Version( PHB_GT pGT, int iType )
static const char * hb_gt_def_Version( PHB_GT pGT, int iType )
{
   HB_SYMBOL_UNUSED( pGT );

   if( iType == 0 )
      return ( char * ) "NUL";

   return ( char * ) "Harbour Terminal: NULL";
}
hbgtcore.c708
STATIC BOOLhb_gt_def_GetChar( PHB_GT pGT, int iRow, int iCol, BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
static BOOL hb_gt_def_GetChar( PHB_GT pGT, int iRow, int iCol,
                               BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
{
   long lIndex;

   if( HB_GTSELF_CHECKPOS( pGT, iRow, iCol, &lIndex ) )
   {
      *pusChar = pGT->screenBuffer[ lIndex ].c.usChar;
      *pbColor = pGT->screenBuffer[ lIndex ].c.bColor;
      *pbAttr  = pGT->screenBuffer[ lIndex ].c.bAttr;
      return TRUE;
   }
   return FALSE;
}
hbgtcore.c718
STATIC BOOLhb_gt_def_PutChar( PHB_GT pGT, int iRow, int iCol, BYTE bColor, BYTE bAttr, USHORT usChar )
static BOOL hb_gt_def_PutChar( PHB_GT pGT, int iRow, int iCol,
                               BYTE bColor, BYTE bAttr, USHORT usChar )
{
   long lIndex;

   if( HB_GTSELF_CHECKPOS( pGT, iRow, iCol, &lIndex ) )
   {
      pGT->screenBuffer[ lIndex ].c.usChar = usChar;
      pGT->screenBuffer[ lIndex ].c.bColor = bColor;
      pGT->screenBuffer[ lIndex ].c.bAttr  = bAttr;
      pGT->pLines[ iRow ] = TRUE;
      pGT->fRefresh = TRUE;
      return TRUE;
   }
   return FALSE;
}
hbgtcore.c733
STATIC VOIDhb_gt_def_PutText( PHB_GT pGT, int iRow, int iCol, BYTE bColor, BYTE * pText, ULONG ulLen )
static void hb_gt_def_PutText( PHB_GT pGT, int iRow, int iCol, BYTE bColor, BYTE * pText, ULONG ulLen )
{
   while( ulLen-- )
   {
      if( !HB_GTSELF_PUTCHAR( pGT, iRow, iCol, bColor, 0, *pText++ ) )
         break;
      ++iCol;
   }
}
hbgtcore.c750
STATIC VOIDhb_gt_def_Replicate( PHB_GT pGT, int iRow, int iCol, BYTE bColor, BYTE bAttr, USHORT usChar, ULONG ulLen )
static void hb_gt_def_Replicate( PHB_GT pGT, int iRow, int iCol, BYTE bColor,
                                 BYTE bAttr, USHORT usChar, ULONG ulLen )
{
   if( iCol < 0 )
   {
      if( ulLen < ( ULONG ) -iCol )
         ulLen = 0;
      else
         ulLen += iCol;
      iCol = 0;
   }
   while( ulLen-- )
   {
      if( !HB_GTSELF_PUTCHAR( pGT, iRow, iCol, bColor, bAttr, usChar ) )
         break;
      ++iCol;
   }
}
hbgtcore.c760
STATIC VOIDhb_gt_def_WriteAt( PHB_GT pGT, int iRow, int iCol, BYTE * pText, ULONG ulLength )
static void hb_gt_def_WriteAt( PHB_GT pGT, int iRow, int iCol, BYTE * pText, ULONG ulLength )
{
   int iMaxCol = HB_GTSELF_MAXCOL( pGT );

   /* Truncate the text if the cursor will end up off the right edge */
   HB_GTSELF_PUTTEXT( pGT, iRow, iCol, HB_GTSELF_GETCOLOR( pGT ), pText,
                      HB_MIN( ulLength, ( ULONG ) ( iMaxCol - iCol + 1 ) ) );

   /* Finally, save the new cursor position, even if off-screen */
   HB_GTSELF_SETPOS( pGT, iRow, iCol + ( int ) ulLength );
}
hbgtcore.c779
STATIC VOIDhb_gt_def_Write( PHB_GT pGT, BYTE * pText, ULONG ulLength )
static void hb_gt_def_Write( PHB_GT pGT, BYTE * pText, ULONG ulLength )
{
   int iRow, iCol;

   HB_GTSELF_GETPOS( pGT, &iRow, &iCol );
   HB_GTSELF_WRITEAT( pGT, iRow, iCol, pText, ulLength );
}
hbgtcore.c791
STATIC VOIDhb_gt_def_WriteCon( PHB_GT pGT, BYTE * pText, ULONG ulLength )
static void hb_gt_def_WriteCon( PHB_GT pGT, BYTE * pText, ULONG ulLength )
{
   int iLen = 0;
   BOOL bDisp = FALSE;
   BOOL bBell = FALSE;
   BOOL bNewLine = FALSE;
   int iRow, iCol, iMaxRow, iMaxCol;
   BYTE szString[ WRITECON_BUFFER_SIZE ];

   iMaxRow = HB_GTSELF_MAXROW( pGT );
   iMaxCol = HB_GTSELF_MAXCOL( pGT );

   HB_GTSELF_GETPOS( pGT, &iRow, &iCol );

   /* Limit the starting cursor position to maxrow(),maxcol()
      on the high end, but don't limit it on the low end. */

   if( iRow > iMaxRow || iCol > iMaxCol )
   {
      if( iRow > iMaxRow )
         iRow = iMaxRow;
      if( iCol > iMaxCol )
         iCol = iMaxCol;
      HB_GTSELF_SETPOS( pGT, iRow, iCol );
   }

   while( ulLength-- )
   {
      BYTE ch = *pText++;

      switch( ch )
      {
         case HB_CHAR_BEL:
            bDisp = bBell = TRUE;
            break;

         case HB_CHAR_BS:
            if( iCol > 0 )
            {
               --iCol;
               bDisp = TRUE;
            }
            else if( iCol == 0 && iRow > 0 )
            {
               iCol = iMaxCol;
               --iRow;
               bDisp = TRUE;
            }
            if( bDisp )
            {
               if( iLen )
                  szString[ iLen - 1 ] = ' ';
               else
               {
                  HB_GTSELF_SETPOS( pGT, iRow, iCol );
                  szString[ iLen++ ] = ' ';
               }
            }
            break;

         case HB_CHAR_LF:
            iCol = 0;
            if( iRow >= 0 ) ++iRow;
            bDisp = TRUE;
            bNewLine = TRUE;
            break;

         case HB_CHAR_CR:
            iCol = 0;
            if( *pText == HB_CHAR_LF )
            {
               if( iRow >= 0 ) ++iRow;
               bNewLine = TRUE;
               ++pText;
               --ulLength;
            }
            bDisp = TRUE;
            break;

         default:
            ++iCol;
            if( iCol > iMaxCol || iCol <= 0 )
            {
               /* If the cursor position started off the left edge,
                  don't display the first character of the string */
               if( iCol > 0 ) szString[ iLen++ ] = ch;
               /* Always advance to the first column of the next row
                  when the right edge is reached or when the cursor
                  started off the left edge, unless the cursor is off
                  the top edge, in which case only change the column */
               iCol = 0;
               if( iRow >= 0 ) ++iRow;
               bDisp = TRUE;
               bNewLine = TRUE;
            }
            else
               szString[ iLen++ ] = ch;

            /* Special handling for a really wide screen or device */
            if( iLen >= WRITECON_BUFFER_SIZE ) bDisp = TRUE;
      }

      if( bDisp || ulLength == 0 )
      {
         if( iLen )
            HB_GTSELF_WRITE( pGT, szString, iLen );

         iLen = 0;
         if( iRow > iMaxRow )
         {
            /* Normal scroll */
            HB_GTSELF_SCROLL( pGT, 0, 0, iMaxRow, iMaxCol, HB_GTSELF_GETCOLOR( pGT ),
                              HB_GTSELF_GETCLEARCHAR( pGT ), iRow - iMaxRow, 0 );
            iRow = iMaxRow;
            iCol = 0;
         }
         else if( iRow < 0 && bNewLine )
         {
            /* Special case scroll when newline
               and cursor off top edge of display */
            HB_GTSELF_SCROLL( pGT, 0, 0, iMaxRow, iMaxCol, HB_GTSELF_GETCOLOR( pGT ),
                              HB_GTSELF_GETCLEARCHAR( pGT ), 1, 0 );
         }
         HB_GTSELF_SETPOS( pGT, iRow, iCol );
         bDisp = FALSE;
         bNewLine = FALSE;

         /* To emulate scrolling */
         HB_GTSELF_FLUSH( pGT );

         if( bBell )
         {
            HB_GTSELF_BELL( pGT );
            bBell = FALSE;
         }
      }
   }
}
hbgtcore.c801
STATIC LONGhb_gt_def_RectSize( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
static long hb_gt_def_RectSize( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
{
   int iRows, iCols;

   iRows = iBottom - iTop + 1;
   iCols = iRight - iLeft + 1;

   if( iCols <= 0 || iRows <= 0 )
      return 0;
   else
      return ( ( long ) iRows * iCols ) << ( pGT->fVgaCell ? 1 : 2 );
}
hbgtcore.c940
STATIC VOIDhb_gt_def_Save( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BYTE * pBuffer )
static void hb_gt_def_Save( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                            BYTE * pBuffer )
{
   while( iTop <= iBottom )
   {
      BYTE bColor, bAttr;
      USHORT usChar;
      int iCol;

      for( iCol = iLeft; iCol <= iRight; ++iCol )
      {
         if( !HB_GTSELF_GETCHAR( pGT, iTop, iCol, &bColor, &bAttr, &usChar ) )
         {
            usChar = HB_GTSELF_GETCLEARCHAR( pGT );
            bColor = HB_GTSELF_GETCLEARCOLOR( pGT );
            bAttr  = 0x00;
         }
         if( pGT->fVgaCell )
         {
            *pBuffer++ = ( BYTE ) usChar;
            *pBuffer++ = bColor;
         }
         else
         {
            HB_PUT_LE_UINT16( pBuffer, usChar );
            pBuffer += 2;
            *pBuffer++ = bColor;
            *pBuffer++ = bAttr;
         }
      }
      ++iTop;
   }
}
hbgtcore.c953
STATIC VOIDhb_gt_def_Rest( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BYTE * pBuffer )
static void hb_gt_def_Rest( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                            BYTE * pBuffer )
{
   while( iTop <= iBottom )
   {
      BYTE bColor, bAttr;
      USHORT usChar;
      int iCol;

      for( iCol = iLeft; iCol <= iRight; ++iCol )
      {
         if( pGT->fVgaCell )
         {
            usChar = *pBuffer++;
            bColor = *pBuffer++;
            bAttr  = 0;
         }
         else
         {
            usChar = HB_GET_LE_UINT16( pBuffer );
            pBuffer += 2;
            bColor = *pBuffer++;
            bAttr  = *pBuffer++;
         }
         HB_GTSELF_PUTCHAR( pGT, iTop, iCol, bColor, bAttr, usChar );
      }
      ++iTop;
   }
}
hbgtcore.c987
STATIC VOIDhb_gt_def_SetAttribute( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BYTE bColor )
static void hb_gt_def_SetAttribute( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                                    BYTE bColor )
{
   while( iTop <= iBottom )
   {
      BYTE bColorOld, bAttr;
      USHORT usChar;
      int iCol;

      for( iCol = iLeft; iCol <= iRight; ++iCol )
      {
         if( !HB_GTSELF_GETCHAR( pGT, iTop, iCol, &bColorOld, &bAttr, &usChar ) )
            break;
         if( !HB_GTSELF_PUTCHAR( pGT, iTop, iCol, bColor, bAttr, usChar ) )
            break;
      }
      ++iTop;
   }
}
hbgtcore.c1017
STATIC VOIDhb_gt_def_DrawShadow( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BYTE bColor )
static void hb_gt_def_DrawShadow( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                                  BYTE bColor )
{
   int iMaxRow, iMaxCol, i;

   if( iTop > iBottom )
   {
      i = iTop;
      iTop = iBottom;
      iBottom = i;
   }
   if( iLeft > iRight )
   {
      i = iLeft;
      iLeft = iRight;
      iRight = i;
   }

   iLeft += 2;
   ++iBottom;

   iMaxRow = HB_GTSELF_MAXROW( pGT );
   iMaxCol = HB_GTSELF_MAXCOL( pGT );

   /* Draw the bottom edge */
   if( iBottom <= iMaxRow && iLeft <= iMaxCol )
      HB_GTSELF_SETATTRIBUTE( pGT, iBottom, iLeft, iBottom, HB_MIN( iRight, iMaxCol ), bColor );

   ++iRight;
   ++iTop;

   /* Draw the right edge */
   if( iTop <= iMaxRow && iRight <= iMaxCol )
      HB_GTSELF_SETATTRIBUTE( pGT, iTop, iRight, iBottom, HB_MIN( iRight + 1, iMaxCol ), bColor );
}
hbgtcore.c1037
STATIC VOIDhb_gt_def_Scroll( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BYTE bColor, BYTE bChar, int iRows, int iCols )
static void hb_gt_def_Scroll( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                              BYTE bColor, BYTE bChar, int iRows, int iCols )
{
   int iColOld, iColNew, iColSize, iColClear, iClrs, iLength;

   iColSize = iRight - iLeft;
   iLength = iColSize + 1;
   iColOld = iColNew = iLeft;
   if( iCols >= 0 )
   {
      iColOld += iCols;
      iColSize -= iCols;
      iColClear = iColNew + iColSize + 1;
      iClrs = iCols;
   }
   else
   {
      iColNew -= iCols;
      iColSize += iCols;
      iColClear = iColOld;
      iClrs = -iCols;
   }

   if( iLength > 0 && iTop <= iBottom )
   {
      BYTE * pBuffer = NULL;

      if( ( iRows || iCols ) && iColSize >= 0 && ( iBottom - iTop >= iRows ) )
      {
         ULONG ulSize = HB_GTSELF_RECTSIZE( pGT, iTop, iColOld, iTop, iColOld + iColSize );

         if( ulSize )
            pBuffer = ( BYTE * ) hb_xgrab( ulSize );
      }

      while( iTop <= iBottom )
      {
         int iRowPos;

         if( iRows >= 0 )
            iRowPos = iTop++;
         else
            iRowPos = iBottom--;

         if( pBuffer && ( iRows == 0 ||
             ( iRowPos + iRows >= iTop && iRowPos + iRows <= iBottom ) ) )
         {
            HB_GTSELF_SAVE( pGT, iRowPos + iRows, iColOld, iRowPos + iRows, iColOld + iColSize, pBuffer );
            HB_GTSELF_REST( pGT, iRowPos, iColNew, iRowPos, iColNew + iColSize, pBuffer );
            if( iClrs )
               HB_GTSELF_REPLICATE( pGT, iRowPos, iColClear, bColor, 0, bChar, iClrs );
         }
         else
            HB_GTSELF_REPLICATE( pGT, iRowPos, iLeft, bColor, 0, bChar, iLength );
      }

      if( pBuffer )
         hb_xfree( pBuffer );
   }
}
hbgtcore.c1073
STATIC VOIDhb_gt_def_ScrollArea( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BYTE bColor, BYTE bChar, int iRows, int iCols )
static void hb_gt_def_ScrollArea( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                                  BYTE bColor, BYTE bChar, int iRows, int iCols )
{
   if( iRows || iCols )
   {
      int iColNew, iColSize, iColClear, iClrs, iLength, iHeight, iWidth;

      HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
      if( iTop < 0 )
         iTop = 0;
      if( iLeft < 0 )
         iLeft = 0;
      if( iBottom >= iHeight )
         iBottom = iHeight -1;
      if( iRight >= iWidth )
         iRight = iWidth -1;

      iColSize = iRight - iLeft;
      iLength = iColSize + 1;
      iColNew = iLeft;

      if( iCols >= 0 )
      {
         iColSize -= iCols;
         iColClear = iColNew + iColSize + 1;
         iClrs = iCols;
      }
      else
      {
         iColClear = iColNew;
         iColNew -= iCols;
         iColSize += iCols;
         iClrs = -iCols;
      }

      if( iLength > 0 )
      {
         long lIndex, lOffset = ( long ) iRows * iWidth + iCols;
         BOOL fMove = ( iRows || iCols ) && iColSize >= 0 &&
                      ( iBottom - iTop >= iRows );

         while( iTop <= iBottom )
         {
            int iRowPos, i;

            if( iRows >= 0 )
               iRowPos = iTop++;
            else
               iRowPos = iBottom--;

            if( fMove && ( iRows == 0 ||
                ( iRowPos + iRows >= iTop && iRowPos + iRows <= iBottom ) ) )
            {
               lIndex = ( long ) iRowPos * iWidth + iColNew;
               if( lOffset < 0 )
               {
                  for( i = 0; i <= iColSize; ++i, ++lIndex )
                  {
                     pGT->screenBuffer[ lIndex ].uiValue =
                        pGT->screenBuffer[ lIndex + lOffset ].uiValue;
                     pGT->prevBuffer[ lIndex ].uiValue =
                        pGT->prevBuffer[ lIndex + lOffset ].uiValue;
                  }
               }
               else
               {
                  for( i = iColSize, lIndex += iColSize; i >= 0; --i, --lIndex )
                  {
                     pGT->screenBuffer[ lIndex ].uiValue =
                        pGT->screenBuffer[ lIndex + lOffset ].uiValue;
                     pGT->prevBuffer[ lIndex ].uiValue =
                        pGT->prevBuffer[ lIndex + lOffset ].uiValue;
                  }
               }
               if( iClrs )
                  HB_GTSELF_REPLICATE( pGT, iRowPos, iColClear, bColor, 0, bChar, iClrs );
            }
            else
               HB_GTSELF_REPLICATE( pGT, iRowPos, iLeft, bColor, 0, bChar, iLength );
         }
      }
   }
}
hbgtcore.c1134
STATIC VOIDhb_gt_def_ScrollUp( PHB_GT pGT, int iRows, BYTE bColor, BYTE bChar )
static void hb_gt_def_ScrollUp( PHB_GT pGT, int iRows, BYTE bColor, BYTE bChar )
{
   if( iRows > 0 )
   {
      int i, j, iHeight, iWidth;
      long lIndex = 0, lOffset;
      BYTE bAttr = 0;

      HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
      lOffset = ( long ) iRows * iWidth;
      for( i = iRows; i < iHeight; ++i )
      {
         pGT->pLines[ i - iRows ] = pGT->pLines[ i ];
         for( j = 0; j < iWidth; ++j )
         {
            pGT->screenBuffer[ lIndex ].uiValue =
               pGT->screenBuffer[ lIndex + lOffset ].uiValue;
            pGT->prevBuffer[ lIndex ].uiValue =
               pGT->prevBuffer[ lIndex + lOffset ].uiValue;
            ++lIndex;
         }
      }
      for( i = HB_MAX( 0, iHeight - iRows ); i < iHeight; ++i )
      {
         for( j = 0; j < iWidth; ++j )
         {
            pGT->screenBuffer[ lIndex ].c.usChar = bChar;
            pGT->screenBuffer[ lIndex ].c.bColor = bColor;
            pGT->screenBuffer[ lIndex ].c.bAttr  = bAttr;
            ++lIndex;
         }
         pGT->pLines[ i ] = TRUE;
      }
      pGT->fRefresh = TRUE;
   }
}
hbgtcore.c1218
STATIC VOIDhb_gt_def_Box( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, BYTE bColor )
static void hb_gt_def_Box( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                           BYTE * pbyFrame, BYTE bColor )
{
   int iMaxRow, iMaxCol, iRows, iCols, iFirst, i;

   if( iTop > iBottom )
   {
      i = iTop;
      iTop = iBottom;
      iBottom = i;
   }
   if( iLeft > iRight )
   {
      i = iLeft;
      iLeft = iRight;
      iRight = i;
   }
   iMaxRow = HB_GTSELF_MAXROW( pGT ), iMaxCol = HB_GTSELF_MAXCOL( pGT );

   if( iTop <= iMaxRow && iLeft <= iMaxCol && iBottom >= 0 && iRight >= 0 )
   {
      BYTE szBox[ 10 ];
      BYTE bPadCh = HB_GTSELF_GETCLEARCHAR( pGT );

      if( pbyFrame )
      {
         for( i = 0; *pbyFrame && i < 9; ++i )
            bPadCh = szBox[ i ] = *pbyFrame++;
      }
      else
         i = 0;

      while( i < 8 )
         szBox[ i++ ] = bPadCh;
      szBox[ i ] = '\0';

      if( iTop == iBottom )
         HB_GTSELF_HORIZLINE( pGT, iTop, iLeft, iRight, szBox[ 1 ], bColor );
      else if( iLeft == iRight )
         HB_GTSELF_VERTLINE( pGT, iLeft, iTop, iBottom, szBox[ 3 ], bColor );
      else
      {
         BYTE bAttr = HB_GT_ATTR_BOX;
         iRows = ( iBottom > iMaxRow ? iMaxRow + 1 : iBottom ) -
                 ( iTop < 0 ? -1 : iTop ) - 1;
         iCols = ( iRight > iMaxCol ? iMaxCol + 1 : iRight ) -
                 ( iLeft < 0 ? -1 : iLeft ) - 1;
         iFirst = iLeft < 0 ? 0 : iLeft + 1;

         if( iTop >= 0 )
         {
            if( iLeft >= 0 )
               HB_GTSELF_PUTCHAR( pGT, iTop, iLeft, bColor, bAttr, szBox[ 0 ] );
            if( iCols )
               HB_GTSELF_REPLICATE( pGT, iTop, iFirst, bColor, bAttr, szBox[ 1 ], iCols );
            if( iRight <= iMaxCol )
               HB_GTSELF_PUTCHAR( pGT, iTop, iFirst + iCols, bColor, bAttr, szBox[ 2 ] );
            iTop++;
         }
         else
            iTop = 0;
         for( i = 0; i < iRows; ++i )
         {
            if( iLeft >= 0 )
               HB_GTSELF_PUTCHAR( pGT, iTop + i, iLeft, bColor, bAttr, szBox[ 7 ] );
            if( iCols && szBox[ 8 ] )
               HB_GTSELF_REPLICATE( pGT, iTop + i, iFirst, bColor, bAttr, szBox[ 8 ], iCols );
            if( iRight <= iMaxCol )
               HB_GTSELF_PUTCHAR( pGT, iTop + i, iFirst + iCols, bColor, bAttr, szBox[ 3 ] );
         }
         if( iBottom <= iMaxRow )
         {
            if( iLeft >= 0 )
               HB_GTSELF_PUTCHAR( pGT, iBottom, iLeft, bColor, bAttr, szBox[ 6 ] );
            if( iCols )
               HB_GTSELF_REPLICATE( pGT, iBottom, iFirst, bColor, bAttr, szBox[ 5 ], iCols );
            if( iRight <= iMaxCol )
               HB_GTSELF_PUTCHAR( pGT, iBottom, iFirst + iCols, bColor, bAttr, szBox[ 4 ] );
         }
      }
   }
}
hbgtcore.c1255
STATIC VOIDhb_gt_def_BoxS( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, BYTE bColor )
static void hb_gt_def_BoxS( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                            BYTE * pbyFrame, BYTE bColor )
{
   HB_GTSELF_BOX( pGT, iTop, iLeft, iBottom, iRight,
                  pbyFrame ? pbyFrame : ( BYTE * ) _B_SINGLE, bColor );
}
hbgtcore.c1338
STATIC VOIDhb_gt_def_BoxD( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, BYTE bColor )
static void hb_gt_def_BoxD( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                            BYTE * pbyFrame, BYTE bColor )
{
   HB_GTSELF_BOX( pGT, iTop, iLeft, iBottom, iRight,
                  pbyFrame ? pbyFrame : ( BYTE * ) _B_DOUBLE, bColor );
}
hbgtcore.c1345
STATIC VOIDhb_gt_def_HorizLine( PHB_GT pGT, int iRow, int iLeft, int iRight, BYTE bChar, BYTE bColor )
static void hb_gt_def_HorizLine( PHB_GT pGT, int iRow, int iLeft, int iRight,
                                 BYTE bChar, BYTE bColor )
{
   int iLength, iCol;

   if( iLeft <= iRight )
   {
      iLength = iRight - iLeft + 1;
      iCol = iLeft;
   }
   else
   {
      iLength = iLeft - iRight + 1;
      iCol = iRight;
   }

   HB_GTSELF_REPLICATE( pGT, iRow, iCol, bColor, HB_GT_ATTR_BOX, bChar, iLength );
}
hbgtcore.c1352
STATIC VOIDhb_gt_def_VertLine( PHB_GT pGT, int iCol, int iTop, int iBottom, BYTE bChar, BYTE bColor )
static void hb_gt_def_VertLine( PHB_GT pGT, int iCol, int iTop, int iBottom,
                                BYTE bChar, BYTE bColor )
{
   int iLength, iRow;

   if( iTop <= iBottom )
   {
      iLength = iBottom - iTop + 1;
      iRow = iTop;
   }
   else
   {
      iLength = iTop - iBottom + 1;
      iRow = iBottom;
   }

   if( iRow < 0 )
   {
      iLength += iRow;
      iRow = 0;
   }

   while( --iLength >= 0 )
   {
      if( !HB_GTSELF_PUTCHAR( pGT, iRow, iCol, bColor, HB_GT_ATTR_BOX, bChar ) )
         break;
      ++iRow;
   }
}
hbgtcore.c1371
STATIC BOOLhb_gt_def_SetDispCP( PHB_GT pGT, char * pszTermCDP, char * pszHostCDP, BOOL fBox )
static BOOL hb_gt_def_SetDispCP( PHB_GT pGT, char * pszTermCDP, char * pszHostCDP, BOOL fBox )
{
#ifndef HB_CDP_SUPPORT_OFF
   if( !pszHostCDP )
      pszHostCDP = hb_cdpID();
   if( !pszTermCDP )
      pszTermCDP = pszHostCDP;

   if( pszTermCDP && pszHostCDP )
   {
      pGT->cdpTerm = hb_cdpFind( pszTermCDP );
      pGT->cdpHost = hb_cdpFind( pszHostCDP );
      pGT->fDispTrans = pGT->cdpTerm && pGT->cdpHost &&
                        pGT->cdpTerm != pGT->cdpHost;
      return TRUE;
   }
#else
   HB_SYMBOL_UNUSED( pszTermCDP );
   HB_SYMBOL_UNUSED( pszHostCDP );
#endif
   HB_SYMBOL_UNUSED( fBox );

   return FALSE;
}
hbgtcore.c1401
STATIC BOOLhb_gt_def_SetKeyCP( PHB_GT pGT, char * pszTermCDP, char * pszHostCDP )
static BOOL hb_gt_def_SetKeyCP( PHB_GT pGT, char * pszTermCDP, char * pszHostCDP )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( pszTermCDP );
   HB_SYMBOL_UNUSED( pszHostCDP );

   return FALSE;
}
hbgtcore.c1426
STATIC BOOLhb_gt_def_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
static BOOL hb_gt_def_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
{
   switch( iType )
   {
      case HB_GTI_ISGRAPHIC:
      case HB_GTI_FULLSCREEN:
      case HB_GTI_KBDSUPPORT:
      case HB_GTI_ISCTWIN:
      case HB_GTI_ISMULTIWIN:
      case HB_GTI_ISUNICODE:
         pInfo->pResult = hb_itemPutL( pInfo->pResult, FALSE );
         break;

      case HB_GTI_INPUTFD:
         pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( HB_NHANDLE ) pGT->hStdIn );
         break;

      case HB_GTI_OUTPUTFD:
         pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( HB_NHANDLE ) pGT->hStdOut );
         break;

      case HB_GTI_ERRORFD:
         pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( HB_NHANDLE ) pGT->hStdErr );
         break;

      case HB_GTI_COMPATBUFFER:
         pInfo->pResult = hb_itemPutL( pInfo->pResult, pGT->fVgaCell );
         if( hb_itemType( pInfo->pNewVal ) & HB_IT_LOGICAL )
            pGT->fVgaCell = hb_itemGetL( pInfo->pNewVal );
         break;

      case HB_GTI_VIEWMAXWIDTH:
         pInfo->pResult = hb_itemPutNInt( pInfo->pResult, HB_GTSELF_MAXCOL( pGT ) );
         break;

      case HB_GTI_VIEWMAXHEIGHT:
         pInfo->pResult = hb_itemPutNInt( pInfo->pResult, HB_GTSELF_MAXROW( pGT ) );
         break;

      case HB_GTI_NEWWIN:  /* clear screen area, set default cursor shape and position */
      {
         /* Clear screen */
         HB_GTSELF_DISPBEGIN( pGT );
         HB_GTSELF_SCROLL( pGT, 0, 0, HB_GTSELF_MAXROW( pGT ), HB_GTSELF_MAXCOL( pGT ),
                           HB_GTSELF_GETCOLOR( pGT ), HB_GTSELF_GETCLEARCHAR( pGT ), 0, 0 );
         HB_GTSELF_SETPOS( pGT, 0, 0 );
         HB_GTSELF_SETCURSORSTYLE( pGT, SC_NORMAL );
         HB_GTSELF_DISPEND( pGT );
         HB_GTSELF_FLUSH( pGT );
         /* no break; */
      }
      case HB_GTI_GETWIN:  /* save screen buffer, cursor shape and possition */
      {
         int iRow, iCol;
         ULONG ulSize;

         if( !pInfo->pResult )
            pInfo->pResult = hb_itemNew( NULL );
         hb_arrayNew( pInfo->pResult, 8 );
         HB_GTSELF_GETPOS( pGT, &iRow, &iCol );
         hb_arraySetNI( pInfo->pResult, 1, iRow );
         hb_arraySetNI( pInfo->pResult, 2, iCol );
         hb_arraySetNI( pInfo->pResult, 3, HB_GTSELF_GETCURSORSTYLE( pGT ) );
         hb_arraySetC ( pInfo->pResult, 4, hb_conSetColor( NULL ) );

         iRow = HB_GTSELF_MAXROW( pGT );
         iCol = HB_GTSELF_MAXCOL( pGT );
         hb_arraySetNI( pInfo->pResult, 5, iRow );
         hb_arraySetNI( pInfo->pResult, 6, iCol );

         ulSize = HB_GTSELF_RECTSIZE( pGT, 0, 0, iRow, iCol );
         if( ulSize )
         {
            BYTE * pBuffer = ( BYTE * ) hb_xgrab( ulSize + 1 );
            HB_GTSELF_SAVE( pGT, 0, 0, iRow, iCol, pBuffer );
            hb_arraySetCPtr( pInfo->pResult, 7, ( char * ) pBuffer, ulSize );
         }
         break;
      }
      case HB_GTI_SETWIN:  /* restore screen buffer, cursor shape and possition */
         if( hb_arrayLen( pInfo->pNewVal ) == 8 )
         {
            HB_GTSELF_DISPBEGIN( pGT );
            if( hb_arrayGetCLen( pInfo->pNewVal, 7 ) > 0 )
            {
               HB_GTSELF_REST( pGT, 0, 0, hb_arrayGetNI( pInfo->pNewVal, 5 ),
                               hb_arrayGetNI( pInfo->pNewVal, 6 ),
                               ( BYTE * ) hb_arrayGetCPtr( pInfo->pNewVal, 7 ) );
            }
            HB_GTSELF_SETPOS( pGT, hb_arrayGetNI( pInfo->pNewVal, 1 ),
                                   hb_arrayGetNI( pInfo->pNewVal, 2 ) );
            HB_GTSELF_SETCURSORSTYLE( pGT, hb_arrayGetNI( pInfo->pNewVal, 3 ) );
            hb_conSetColor( hb_arrayGetCPtr( pInfo->pNewVal, 4 ) );
            HB_GTSELF_DISPEND( pGT );
            HB_GTSELF_FLUSH( pGT );
         }
         break;

      case HB_GTI_CLIPBOARDDATA:
         if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
         {
            /* set new Clipboard value */
            hb_gt_setClipboard( hb_itemGetCPtr( pInfo->pNewVal ),
                                hb_itemGetCLen( pInfo->pNewVal ) );
         }
         else
         {
            /* get Clipboard value */
            char * pszClipData;
            ULONG ulLen;

            if( hb_gt_getClipboard( &pszClipData, &ulLen ) )
               pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, pszClipData, ulLen );
            else
               pInfo->pResult = hb_itemPutC( pInfo->pResult, NULL );
         }
         break;

      case HB_GTI_NOTIFIERBLOCK:
         if( pGT->pNotifierBlock )
         {
            hb_itemRelease( pGT->pNotifierBlock );
            pGT->pNotifierBlock = NULL;
         }
         if( hb_itemType( pInfo->pNewVal ) & HB_IT_BLOCK )
            pGT->pNotifierBlock = hb_itemNew( pInfo->pNewVal );
         break;

      default:
         return FALSE;
   }

   return TRUE;
}
hbgtcore.c1435
STATIC INThb_gt_def_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, int iClrNorm, int iClrHigh, double dDelay )
static int hb_gt_def_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
                            int iClrNorm, int iClrHigh, double dDelay )
{
   int iOptions = ( int ) hb_arrayLen( pOptions );
   int iRet = 0;

   if( HB_IS_STRING( pMessage ) && iOptions > 0 )
   {
      char * szMessage = hb_itemGetCPtr( pMessage );
      ULONG ulLen = hb_itemGetCLen( pMessage );
      BOOL fScreen = FALSE, fKeyBoard = FALSE;
      int iKey = 0, i, iDspCount, iStyle, iRows, iCols,
          iRow, iCol, iTop, iLeft, iBottom, iRight, iMnuCol, iPos, iClr;
      BYTE * pBuffer = NULL;
      HB_GT_INFO gtInfo;

      gtInfo.pNewVal = gtInfo.pResult = NULL;

      HB_GTSELF_INFO( pGT, HB_GTI_FULLSCREEN, >Info );
      if( gtInfo.pResult )
      {
         fScreen = hb_itemGetL( gtInfo.pResult );
      }
      HB_GTSELF_INFO( pGT, HB_GTI_KBDSUPPORT, >Info );
      if( gtInfo.pResult )
      {
         fKeyBoard = hb_itemGetL( gtInfo.pResult );
         hb_itemRelease( gtInfo.pResult );
      }
      HB_GTSELF_GETSIZE( pGT, &iRows, &iCols );
      if( iCols <= 4 || iRows <= 4 )
         fScreen = FALSE;

      if( fScreen )
      {
         ULONG ulLines = 0, ulWidth = 0, ulCurrWidth = 0, ul = 0, ulDst = 0,
               ulLast = 0, ulSpace1 = 0, ulSpace2 = 0, ulDefWidth, ulMaxWidth;
         char * szMsgDsp;

         ulMaxWidth = iCols - 4;
         ulDefWidth = ( ulMaxWidth * 3 ) >> 2;
         if( ulDefWidth == 0 )
            ulDefWidth = 1;
         szMsgDsp = ( char * ) hb_xgrab( ulLen + ( ulLen / ulDefWidth ) + 1 );

         while( ul < ulLen )
         {
            if( szMessage[ ul ] == '\n' )
            {
               if( ulCurrWidth > ulMaxWidth )
               {
                  ulDst = ulLast;
               }
               else
               {
                  ++ulLines;
                  if( ulCurrWidth > ulWidth )
                     ulWidth = ulCurrWidth;
                  ulCurrWidth = ulSpace1 = ulSpace2 = 0;
                  szMsgDsp[ ulDst++ ] = '\n';
                  ulLast = ulDst;
               }
            }
            else
            {
               if( szMessage[ ul ] == ' ' )
               {
                  if( ulCurrWidth <= ulDefWidth )
                     ulSpace1 = ul;
                  else if( ulCurrWidth <= ulMaxWidth && !ulSpace2 )
                     ulSpace2 = ul;
               }
               szMsgDsp[ ulDst++ ] = szMessage[ ul ];
               ++ulCurrWidth;
               if( ulCurrWidth > ulDefWidth && ulSpace1 )
               {
                  ulCurrWidth -= ul - ulSpace1 + 1;
                  ulDst -= ul - ulSpace1 + 1;
                  ul = ulSpace1;
                  ++ulLines;
                  if( ulCurrWidth > ulWidth )
                     ulWidth = ulCurrWidth;
                  ulCurrWidth = ulSpace1 = ulSpace2 = 0;
                  szMsgDsp[ ulDst++ ] = '\n';
                  ulLast = ulDst;
               }
               else if( ulCurrWidth > ulMaxWidth )
               {
                  if( ulSpace2 )
                  {
                     ulCurrWidth -= ul - ulSpace2 + 1;
                     ulDst -= ul - ulSpace2 + 1;
                     ul = ulSpace2;
                     ++ulLines;
                     if( ulCurrWidth > ulWidth )
                        ulWidth = ulCurrWidth;
                     ulCurrWidth = ulSpace1 = ulSpace2 = 0;
                     szMsgDsp[ ulDst++ ] = '\n';
                     ulLast = ulDst;
                  }
#ifndef HB_C52_STRICT
                  else
                  {
                     ulCurrWidth--;
                     ulDst--;
                     ul--;
                     szMsgDsp[ ulDst++ ] = '\n';
                     ulLast = ulDst;
                     ++ulLines;
                     if( ulCurrWidth > ulWidth )
                        ulWidth = ulCurrWidth;
                     ulCurrWidth = ulSpace1 = ulSpace2 = 0;
                  }
#endif
               }
            }
            ++ul;
         }
         ulLines++;
         if( ulCurrWidth > ulWidth )
            ulWidth = ulCurrWidth;
         if( ulLines == 1 && ulWidth < ulDefWidth )
            ulWidth += HB_MIN( 4, ulDefWidth - ulWidth );

         ulCurrWidth = 0;
         for( i = 1; i <= iOptions; ++i )
         {
            ulCurrWidth += hb_arrayGetCLen( pOptions, i ) + 4;
         }
         if( ulCurrWidth > ulMaxWidth )
            ulCurrWidth = ulMaxWidth;
         if( ulCurrWidth > ulWidth )
            ulWidth = ulCurrWidth;
         if( ( ULONG ) iRows < ulLines + 4 )
            ulLines = iRows - 4;
         iTop = ( iRows - ulLines - 4 ) >> 1;
         iLeft = ( iCols - ulWidth - 4 ) >> 1;
         iBottom = iTop + ulLines + 3;
         iRight = iLeft + ulWidth + 3;

         if( iClrNorm == 0 )
            iClrNorm = 0x4F;
         if( iClrHigh == 0 )
            iClrHigh = 0x1F;
         iDspCount = HB_GTSELF_DISPCOUNT( pGT );
         if( iDspCount == 0 )
            HB_GTSELF_DISPBEGIN( pGT );
         HB_GTSELF_GETPOS( pGT, &iRow, &iCol );
         iStyle = HB_GTSELF_GETCURSORSTYLE( pGT );
         HB_GTSELF_SETCURSORSTYLE( pGT, SC_NONE );
         ulLen = HB_GTSELF_RECTSIZE( pGT, iTop, iLeft, iBottom, iRight );
         if( ulLen )
         {
            pBuffer = ( BYTE * ) hb_xgrab( ulLen );
            HB_GTSELF_SAVE( pGT, iTop, iLeft, iBottom, iRight, pBuffer );
         }
         HB_GTSELF_BOXS( pGT, iTop, iLeft, iBottom, iRight, NULL, iClrNorm );
         HB_GTSELF_BOXS( pGT, iTop + 1, iLeft + 1, iBottom - 1, iRight - 1, ( BYTE * ) "         ", iClrNorm );
         ulLast = 0;
         i = iTop + 1;
         for( ul = 0; ul < ulDst; ++ul )
         {
            if( szMsgDsp[ ul ] == '\n' )
            {
               if( ul > ulLast )
               {
                  ulLen = ul - ulLast;
                  if( ulLen > ulWidth )
                     ulLen = ulWidth;
                  HB_GTSELF_PUTTEXT( pGT, i, iLeft + ( ( ulWidth - ulLen + 1 ) >> 1 ) + 2,
                                     iClrNorm, ( BYTE * ) szMsgDsp + ulLast, ulLen );
               }
               ulLast = ul + 1;
               if( ++i >= iBottom - 1 )
                  break;
            }
         }
         if( ul > ulLast && i < iBottom - 1 )
         {
            ulLen = ul - ulLast;
            if( ulLen > ulWidth )
               ulLen = ulWidth;
            HB_GTSELF_PUTTEXT( pGT, i, iLeft + ( ( ulWidth - ulLen + 1 ) >> 1 ) + 2,
                               iClrNorm, ( BYTE * ) szMsgDsp + ulLast, ulLen );
         }

         iPos = 1;
         while( iRet == 0 )
         {
            HB_GTSELF_DISPBEGIN( pGT );
            iMnuCol = iLeft + ( ( ulWidth - ulCurrWidth ) >> 1 ) + 3;
            for( i = 1; i <= iOptions; ++i )
            {
               iClr = i == iPos ? iClrHigh : iClrNorm;
               ulLen = hb_arrayGetCLen( pOptions, i );
               HB_GTSELF_PUTTEXT( pGT, iBottom - 1, iMnuCol, iClr, ( BYTE * ) " ", 1 );
               HB_GTSELF_PUTTEXT( pGT, iBottom - 1, iMnuCol + 1, iClr,
                                  ( BYTE * ) hb_arrayGetCPtr( pOptions, i ), ulLen );
               HB_GTSELF_PUTTEXT( pGT, iBottom - 1, iMnuCol + 1 + ulLen, iClr, ( BYTE * ) " ", 1 );
               iMnuCol += ulLen + 4;
            }
            while( HB_GTSELF_DISPCOUNT( pGT ) )
               HB_GTSELF_DISPEND( pGT );
            HB_GTSELF_REFRESH( pGT );

            iKey = fKeyBoard ? HB_GTSELF_INKEYGET( pGT, TRUE, dDelay, INKEY_ALL ) : 0;

            if( iKey == K_ESC )
               break;
            else if( iKey == K_ENTER || iKey == K_SPACE || iKey == 0 )
            {
               iRet = iPos;
            }
            else if( iKey == K_LEFT || iKey == K_SH_TAB )
            {
               if( --iPos == 0 )
                  iPos = iOptions;
               dDelay = 0.0;
            }
            else if( iKey == K_RIGHT || iKey == K_TAB )
            {
               if( ++iPos > iOptions )
                  iPos = 1;
               dDelay = 0.0;
            }
#ifdef HB_COMPAT_C53
            else if( iKey == K_LBUTTONDOWN )
            {
               int iMRow, iMCol;
               HB_GTSELF_MOUSEGETPOS( pGT, &iMRow, &iMCol );
               if( iMRow == iBottom - 1 )
               {
                  iMnuCol = iLeft + ( ( ulWidth - ulCurrWidth ) >> 1 ) + 4;
                  for( i = 1; i <= iOptions; ++i )
                  {
                     ulLen = hb_arrayGetCLen( pOptions, i );
                     if( iMCol >= iMnuCol && iMCol < iMnuCol + ( int ) ulLen )
                     {
                        iRet = i;
                        break;
                     }
                     iMnuCol += ulLen + 4;
                  }
               }
            }
#endif
            else if( iKey >= 32 && iKey <= 255 )
            {
               int iUp = hb_charUpper( iKey );
               for( i = 1; i <= iOptions; ++i )
               {
                  char *szValue = hb_arrayGetCPtr( pOptions, i );
                  if( szValue && iUp == hb_charUpper( *szValue ) )
                  {
                     iRet = i;
                     break;
                  }
               }
            }
         }

         hb_xfree( szMsgDsp );
         if( pBuffer )
         {
            HB_GTSELF_REST( pGT, iTop, iLeft, iBottom, iRight, pBuffer );
            hb_xfree( pBuffer );
         }
         HB_GTSELF_SETPOS( pGT, iRow, iCol );
         HB_GTSELF_SETCURSORSTYLE( pGT, iStyle );
         HB_GTSELF_REFRESH( pGT );
         while( HB_GTSELF_DISPCOUNT( pGT ) < iDspCount )
            HB_GTSELF_DISPBEGIN( pGT );
      }
      else
      {
         ULONG ul, ulStart = 0;
         char *szEol = hb_conNewLine();

         for( ul = 0; ul < ulLen; ++ul )
         {
            if( szMessage[ ul ] == '\n' )
            {
               if( ul > ulStart )
                  HB_GTSELF_WRITECON( pGT, ( BYTE * ) szMessage + ulStart, ul - ulStart );
               HB_GTSELF_WRITECON( pGT, ( BYTE * ) szEol, strlen( szEol ) );
               ulStart = ul + 1;
            }
         }
         if( ul > ulStart )
            HB_GTSELF_WRITECON( pGT, ( BYTE * ) szMessage + ulStart, ul - ulStart );
         HB_GTSELF_WRITECON( pGT, ( BYTE * ) " (", 2 );
         for( i = 1; i <= iOptions; ++i )
         {
            if( i > 1 )
               HB_GTSELF_WRITECON( pGT, ( BYTE * ) ", ", 2 );
            HB_GTSELF_WRITECON( pGT, ( BYTE * ) hb_arrayGetCPtr( pOptions, i ),
                                hb_arrayGetCLen( pOptions, i ) );
         }
         HB_GTSELF_WRITECON( pGT, ( BYTE * ) ") ", 2 );
         while( iRet == 0 )
         {
            iKey = fKeyBoard ? HB_GTSELF_INKEYGET( pGT, TRUE, dDelay, INKEY_ALL ) : 0;
            if( iKey == 0 )
               iRet = 1;
            else if( iKey == K_ESC )
               break;
            else if( iKey >= 32 && iKey <= 255 )
            {
               int iUp = hb_charUpper( iKey );
               for( i = 1; i <= iOptions; ++i )
               {
                  char *szValue = hb_arrayGetCPtr( pOptions, i );
                  if( szValue && iUp == hb_charUpper( *szValue ) )
                  {
                     iRet = i;
                     break;
                  }
               }
            }
         }
         if( iKey >= 32 && iKey <= 255 )
         {
            char szVal[2];
            szVal[ 0 ] = ( char ) iKey;
            szVal[ 1 ] = '\0';
            HB_GTSELF_WRITECON( pGT, ( BYTE * ) szVal, 1 );
         }
      }
   }

   return iRet;
}
hbgtcore.c1570
STATIC INThb_gt_def_SetFlag( PHB_GT pGT, int iType, int iNewValue )
static int hb_gt_def_SetFlag( PHB_GT pGT, int iType, int iNewValue )
{
   int iPrevValue = 0;

   switch( iType )
   {
      case HB_GTI_COMPATBUFFER:
         iPrevValue = pGT->fVgaCell;
         pGT->fVgaCell = iNewValue != 0;
         break;

      case HB_GTI_STDOUTCON:
         iPrevValue = pGT->fStdOutCon;
         pGT->fStdOutCon = iNewValue != 0;
         break;

      case HB_GTI_STDERRCON:
         iPrevValue = pGT->fStdErrCon;
         pGT->fStdErrCon = iNewValue != 0;
         break;
   }

   return iPrevValue;
}
hbgtcore.c1903
STATIC BOOLhb_gt_def_SetMode( PHB_GT pGT, int iRows, int iCols )
static BOOL hb_gt_def_SetMode( PHB_GT pGT, int iRows, int iCols )
{
   return HB_GTSELF_RESIZE( pGT, iRows, iCols );
}
hbgtcore.c1928
STATIC BOOLhb_gt_def_Resize( PHB_GT pGT, int iRows, int iCols )
static BOOL hb_gt_def_Resize( PHB_GT pGT, int iRows, int iCols )
{
   if( iRows > 0 && iCols > 0 && pGT->screenBuffer )
   {
      if( pGT->iHeight != iRows || pGT->iWidth != iCols )
      {
         BYTE * pBuffer = NULL;
         ULONG ulLen = ( ULONG ) iRows * iCols, ulIndex;
         ULONG ulSize;
         int i;

         ulSize = HB_GTSELF_RECTSIZE( pGT, 0, 0, iRows - 1, iCols - 1 );
         if( ulSize )
         {
            pBuffer = ( BYTE * ) hb_xgrab( ulSize );
            HB_GTSELF_SAVE( pGT, 0, 0, iRows - 1, iCols - 1, pBuffer );
         }

         pGT->screenBuffer =
               ( PHB_SCREENCELL ) hb_xrealloc( pGT->screenBuffer,
                                             sizeof( HB_SCREENCELL ) * ulLen );
         pGT->prevBuffer =
               ( PHB_SCREENCELL ) hb_xrealloc( pGT->prevBuffer,
                                             sizeof( HB_SCREENCELL ) * ulLen );
         pGT->pLines = ( BOOL * ) hb_xrealloc( pGT->pLines,
                                             sizeof( BOOL ) * iRows );

         memset( pGT->screenBuffer, 0, sizeof( HB_SCREENCELL ) * ulLen );
         memset( pGT->prevBuffer, 0, sizeof( HB_SCREENCELL ) * ulLen );
         for( i = 0; i < iRows; ++i )
            pGT->pLines[ i ] = TRUE;
         for( ulIndex = 0; ulIndex < ulLen; ++ulIndex )
         {
            pGT->screenBuffer[ ulIndex ].c.usChar = HB_GTSELF_GETCLEARCHAR( pGT );
            pGT->screenBuffer[ ulIndex ].c.bColor = HB_GTSELF_GETCLEARCOLOR( pGT );
            pGT->screenBuffer[ ulIndex ].c.bAttr  = 0x00;
            pGT->prevBuffer[ ulIndex ].c.bAttr = HB_GT_ATTR_REFRESH;
         }

         pGT->iHeight = iRows;
         pGT->iWidth = iCols;

         if( pGT->iRow >= pGT->iHeight )
            pGT->iRow = pGT->iHeight - 1;
         if( pGT->iCol >= pGT->iWidth )
            pGT->iCol = pGT->iWidth - 1;

         pGT->fRefresh = TRUE;

         if( ulSize )
         {
            HB_GTSELF_REST( pGT, 0, 0, iRows - 1, iCols - 1, pBuffer );
            hb_xfree( pBuffer );
         }
      }

      return TRUE;
   }

   return FALSE;
}
hbgtcore.c1933
STATIC VOIDhb_gt_def_GetSize( PHB_GT pGT, int * piRows, int * piCols )
static void hb_gt_def_GetSize( PHB_GT pGT, int * piRows, int  * piCols )
{
   *piRows = pGT->iHeight;
   *piCols = pGT->iWidth;
}
hbgtcore.c1995
STATIC VOIDhb_gt_def_SemiCold( PHB_GT pGT )
static void hb_gt_def_SemiCold( PHB_GT pGT )
{
   int i;
   for( i = 0; i < pGT->iHeight; ++i )
      pGT->pLines[ i ]  = FALSE;
   pGT->fRefresh = FALSE;
}
hbgtcore.c2001
STATIC VOIDhb_gt_def_ColdArea( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
static void hb_gt_def_ColdArea( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
{
   long lIndex;
   int i;

   if( iTop > iBottom )
   {
      i = iTop;
      iTop = iBottom;
      iBottom = i;
   }
   if( iLeft > iRight )
   {
      i = iLeft;
      iLeft = iRight;
      iRight = i;
   }
   while( iTop <= iBottom )
   {
      for( i = iLeft; i <= iRight; ++i )
      {
         if( HB_GTSELF_CHECKPOS( pGT, iTop, i, &lIndex ) )
         {
            pGT->screenBuffer[ lIndex ].c.bAttr &= ~HB_GT_ATTR_REFRESH;
            pGT->prevBuffer[ lIndex ].uiValue = pGT->screenBuffer[ lIndex ].uiValue;
         }
      }
      if( iLeft == 0 && iRight == pGT->iWidth - 1 )
         pGT->pLines[ iTop ] = FALSE;
      ++iTop;
   }
}
hbgtcore.c2009
STATIC VOIDhb_gt_def_ExposeArea( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
static void hb_gt_def_ExposeArea( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
{
   long lIndex;
   int i;

   if( iTop > iBottom )
   {
      i = iTop;
      iTop = iBottom;
      iBottom = i;
   }
   if( iLeft > iRight )
   {
      i = iLeft;
      iLeft = iRight;
      iRight = i;
   }
   while( iTop <= iBottom )
   {
      for( i = iLeft; i <= iRight; ++i )
      {
         if( HB_GTSELF_CHECKPOS( pGT, iTop, i, &lIndex ) )
         {
            pGT->prevBuffer[ lIndex ].c.bAttr = HB_GT_ATTR_REFRESH;
            pGT->pLines[ iTop ] = TRUE;
            pGT->fRefresh = TRUE;
         }
      }
      ++iTop;
   }
}
hbgtcore.c2042
STATIC VOIDhb_gt_def_TouchCell( PHB_GT pGT, int iRow, int iCol )
static void hb_gt_def_TouchCell( PHB_GT pGT, int iRow, int iCol )
{
   long lIndex;

   if( HB_GTSELF_CHECKPOS( pGT, iRow, iCol, &lIndex ) )
   {
      pGT->prevBuffer[ lIndex ].c.bAttr = HB_GT_ATTR_REFRESH;
      pGT->pLines[ iRow ] = TRUE;
      pGT->fRefresh = TRUE;
   }
}
hbgtcore.c2074
STATIC VOIDhb_gt_def_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
static void hb_gt_def_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( iRow );
   HB_SYMBOL_UNUSED( iCol );
   HB_SYMBOL_UNUSED( iSize );
}
hbgtcore.c2086
STATIC VOIDhb_gt_def_Refresh( PHB_GT pGT )
static void hb_gt_def_Refresh( PHB_GT pGT )
{
   if( pGT->fRefresh )
   {
      int i, l, r;
      long lIndex;

      for( i = 0; i < pGT->iHeight; ++i )
      {
         if( pGT->pLines[ i ] )
         {
            lIndex = ( long ) i * pGT->iWidth;
            for( l = 0; l < pGT->iWidth; ++l, ++lIndex )
            {
               if( pGT->prevBuffer[ lIndex ].uiValue !=
                   pGT->screenBuffer[ lIndex ].uiValue )
                  break;
            }
            if( l < pGT->iWidth )
            {
               lIndex = ( long ) ( i + 1 ) * pGT->iWidth - 1;
               for( r = pGT->iWidth - 1; r > l; --r, --lIndex )
               {
                  if( pGT->prevBuffer[ lIndex ].uiValue !=
                      pGT->screenBuffer[ lIndex ].uiValue )
                     break;
               }
               HB_GTSELF_REDRAW( pGT, i, l, r - l + 1 );
               lIndex = ( long ) i * pGT->iWidth + l;
               do
               {
                  pGT->prevBuffer[ lIndex ].uiValue =
                     pGT->screenBuffer[ lIndex ].uiValue;
                  ++lIndex;
               }
               while( ++l <= r );
            }
            pGT->pLines[ i ] = FALSE;
         }
      }
      pGT->fRefresh = FALSE;
   }
}
hbgtcore.c2094
STATIC VOIDhb_gt_def_Flush( PHB_GT pGT )
static void hb_gt_def_Flush( PHB_GT pGT )
{
   if( HB_GTSELF_DISPCOUNT( pGT ) == 0 )
      HB_GTSELF_REFRESH( pGT );
}
hbgtcore.c2138
STATIC INThb_gt_def_ReadKey( PHB_GT pGT, int iEventMask )
static int hb_gt_def_ReadKey( PHB_GT pGT, int iEventMask )
{
   return HB_GTSELF_MOUSEREADKEY( pGT, iEventMask );
}
hbgtcore.c2144
STATIC INThb_gt_def_InkeyFilter( PHB_GT pGT, int iKey, int iEventMask )
static int hb_gt_def_InkeyFilter( PHB_GT pGT, int iKey, int iEventMask )
{
   int iMask;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeyFilter(%p,%d,%d)", pGT, iKey, iEventMask));

   HB_SYMBOL_UNUSED( pGT );

   switch( iKey )
   {
      case K_MOUSEMOVE:
      case K_MMLEFTDOWN:
      case K_MMRIGHTDOWN:
      case K_MMMIDDLEDOWN:
      case K_NCMOUSEMOVE:
         iMask = INKEY_MOVE;
         break;
      case K_LBUTTONDOWN:
      case K_LDBLCLK:
         iMask = INKEY_LDOWN;
         break;
      case K_LBUTTONUP:
         iMask = INKEY_LUP;
         break;
      case K_RBUTTONDOWN:
      case K_RDBLCLK:
         iMask = INKEY_RDOWN;
         break;
      case K_RBUTTONUP:
         iMask = INKEY_RUP;
         break;
      case K_MBUTTONDOWN:
      case K_MBUTTONUP:
      case K_MDBLCLK:
         iMask = INKEY_MMIDDLE;
         break;
      case K_MWFORWARD:
      case K_MWBACKWARD:
         iMask = INKEY_MWHEEL;
         break;
      default:
         iMask = INKEY_KEYBOARD;
         break;
   }

   if( ( iMask & iEventMask ) == 0 )
      return 0;

   return iKey;
}
hbgtcore.c2149
STATIC VOIDhb_gt_def_InkeyPop( PHB_GT pGT )
static void hb_gt_def_InkeyPop( PHB_GT pGT )
{
   if( pGT->StrBuffer )
   {
      if( ++pGT->StrBufferPos >= pGT->StrBufferSize )
      {
         hb_xfree( pGT->StrBuffer );
         pGT->StrBuffer = NULL;
      }
   }
   else if( pGT->inkeyHead != pGT->inkeyTail )
   {
      if( ++pGT->inkeyTail >= pGT->inkeyBufferSize )
         pGT->inkeyTail = 0;
   }
}
hbgtcore.c2201
STATIC VOIDhb_gt_def_InkeyPut( PHB_GT pGT, int iKey )
static void hb_gt_def_InkeyPut( PHB_GT pGT, int iKey )
{
   int iHead;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeyPut(%p,%d)", pGT, iKey));

   iHead = pGT->inkeyHead;

   if( iKey == K_MOUSEMOVE )
   {
      /*
       * Clipper does not store in buffer repeated mouse movement
       * IMHO it's good idea to reduce unnecessary inkey buffer
       * overloading so I also implemented it, [druzus]
       */
      if( pGT->iLastPut == iKey && pGT->inkeyHead != pGT->inkeyTail )
         return;
   }

   /*
    * When the buffer is full new event overwrite the last one
    * in the buffer - it's Clipper behavior, [druzus]
    */
   pGT->inkeyBuffer[ iHead++ ] = pGT->iLastPut = iKey;
   if( iHead >= pGT->inkeyBufferSize )
      iHead = 0;

   if( iHead != pGT->inkeyTail )
      pGT->inkeyHead = iHead;
}
hbgtcore.c2219
STATIC VOIDhb_gt_def_InkeyIns( PHB_GT pGT, int iKey )
static void hb_gt_def_InkeyIns( PHB_GT pGT, int iKey )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeyIns(%p,%d)", pGT, iKey));

   if( --pGT->inkeyTail < 0 )
      pGT->inkeyTail = pGT->inkeyBufferSize -1;

   pGT->inkeyBuffer[ pGT->inkeyTail ] = iKey;

   /* When the buffer is full new event overwrite the last one
    * in the buffer. [druzus]
    */
   if( pGT->inkeyHead == pGT->inkeyTail )
   {
      if( --pGT->inkeyHead < 0 )
         pGT->inkeyHead = pGT->inkeyBufferSize -1;
   }
}
hbgtcore.c2251
STATIC BOOLhb_gt_def_InkeyNextCheck( PHB_GT pGT, int iEventMask, int * iKey )
static BOOL hb_gt_def_InkeyNextCheck( PHB_GT pGT, int iEventMask, int * iKey )
{
   HB_TRACE( HB_TR_DEBUG, ("hb_gt_def_InkeyNextCheck(%p,%d)", pGT, iKey) );

   if( pGT->StrBuffer )
   {
      *iKey = pGT->StrBuffer[ pGT->StrBufferPos ];
   }
   else if( pGT->inkeyHead != pGT->inkeyTail )
   {
      *iKey = hb_gt_def_InkeyFilter( pGT, pGT->inkeyBuffer[ pGT->inkeyTail ], iEventMask );
   }
   else
   {
      return FALSE;
   }

   if( *iKey == 0 )
   {
      hb_gt_def_InkeyPop( pGT );
      return FALSE;
   }

   return TRUE;
}
hbgtcore.c2271
STATIC VOIDhb_gt_def_InkeyPollDo( PHB_GT pGT )
static void hb_gt_def_InkeyPollDo( PHB_GT pGT )
{
   int iKey;

   HB_TRACE( HB_TR_DEBUG, ("hb_gt_def_InkeyPollDo(%p)", pGT) );

   iKey = HB_GTSELF_READKEY( pGT, INKEY_ALL );

   if( iKey )
   {
      switch( iKey )
      {
         case HB_BREAK_FLAG:           /* Check for Ctrl+Break */
         case K_ALT_C:                 /* Check for normal Alt+C */
            if( hb_setGetCancel() )
            {
               hb_vmRequestCancel();   /* Request cancellation */
               return;
            }
            break;
         case K_ALT_D:                 /* Check for Alt+D */
            if( hb_setGetDebug() )
            {
               hb_vmRequestDebug();    /* Request the debugger */
               return;
            }
      }
      HB_GTSELF_INKEYPUT( pGT, iKey );
   }
}
hbgtcore.c2298
STATIC VOIDhb_gt_def_InkeyPoll( PHB_GT pGT )
static void hb_gt_def_InkeyPoll( PHB_GT pGT )
{
   HB_TRACE( HB_TR_DEBUG, ("hb_gt_def_InkeyPoll(%p)", pGT) );

   /*
    * Clipper 5.3 always poll events without respecting
    * _SET_TYPEAHEAD when CL5.2 only when it's non zero.
    * IMHO keeping CL5.2 behavior will be more accurate for xharbour
    * because it allow to control it by user what some times could be
    * necessary due to different low level GT behavior on some platforms
    */
   if( hb_setGetTypeAhead() )
   {
      hb_gt_def_InkeyPollDo( pGT );
   }
}
hbgtcore.c2330
STATIC INThb_gt_def_InkeyNext( PHB_GT pGT, int iEventMask )
static int hb_gt_def_InkeyNext( PHB_GT pGT, int iEventMask )
{
   int iKey = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeyNext(%p,%d)", pGT, iEventMask));

   HB_GTSELF_INKEYPOLL( pGT );
   hb_gt_def_InkeyNextCheck( pGT, iEventMask, &iKey );

   return iKey;
}
hbgtcore.c2348
STATIC INThb_gt_def_InkeyGet( PHB_GT pGT, BOOL fWait, double dSeconds, int iEventMask )
static int hb_gt_def_InkeyGet( PHB_GT pGT, BOOL fWait, double dSeconds, int iEventMask )
{
   HB_ULONG end_timer;
   BOOL fPop;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeyGet(%p,%d,%f,%d)", pGT, (int) fWait, dSeconds, iEventMask));

   /* Wait forever ?, Use fixed value 100 for strict Clipper compatibility */
   if( fWait && dSeconds * 100 >= 1 )
      end_timer = hb_dateMilliSeconds() + ( HB_ULONG ) ( dSeconds * 1000 );
   else
      end_timer = 0;

   do
   {
      hb_gt_def_InkeyPollDo( pGT );
      fPop = hb_gt_def_InkeyNextCheck( pGT, iEventMask, &pGT->inkeyLast );

      if( fPop )
         break;

      /* immediately break if a VM request is pending. */
      if( !fWait || hb_vmRequestQuery() != 0 )
         return 0;

      hb_idleState();
   }
   while( end_timer == 0 || end_timer > hb_dateMilliSeconds() );

   hb_idleReset();

   if( fPop )
   {
      hb_gt_def_InkeyPop( pGT );
      return pGT->inkeyLast;
   }

   return 0;
}
hbgtcore.c2361
STATIC INThb_gt_def_InkeyLast( PHB_GT pGT, int iEventMask )
static int hb_gt_def_InkeyLast( PHB_GT pGT, int iEventMask )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeyLast(%p,%d)", pGT, iEventMask));

   HB_GTSELF_INKEYPOLL( pGT );

   return hb_gt_def_InkeyFilter( pGT, pGT->inkeyLast, iEventMask );
}
hbgtcore.c2402
STATIC INThb_gt_def_InkeySetLast( PHB_GT pGT, int iKey )
static int hb_gt_def_InkeySetLast( PHB_GT pGT, int iKey )
{
   int iLast;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeySetLast(%p,%d)", pGT, iKey));

   iLast = pGT->inkeyLast;
   pGT->inkeyLast = iKey;

   return iLast;
}
hbgtcore.c2412
STATIC VOIDhb_gt_def_InkeySetText( PHB_GT pGT, const char * szText, ULONG ulLen )
static void hb_gt_def_InkeySetText( PHB_GT pGT, const char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeySetText(%p,%s,%lu)", pGT, szText, ulLen));

   if( pGT->StrBuffer )
   {
      hb_xfree( pGT->StrBuffer );
      pGT->StrBuffer = NULL;
   }

   if( szText && ulLen )
   {
      pGT->StrBuffer = ( BYTE * ) hb_xgrab( ulLen );
      memcpy( pGT->StrBuffer, szText, ulLen );
      pGT->StrBufferSize = ulLen;
      pGT->StrBufferPos = 0;
   }
}
hbgtcore.c2425
STATIC VOIDhb_gt_def_InkeyReset( PHB_GT pGT )
static void hb_gt_def_InkeyReset( PHB_GT pGT )
{
   int iTypeAhead;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeyReset(%p)", pGT));

   if( pGT->StrBuffer )
   {
      hb_xfree( pGT->StrBuffer );
      pGT->StrBuffer = NULL;
   }

   pGT->inkeyHead = 0;
   pGT->inkeyTail = 0;

   iTypeAhead = hb_setGetTypeAhead();

   if( iTypeAhead != pGT->inkeyBufferSize )
   {
      if( pGT->inkeyBufferSize > HB_DEFAULT_INKEY_BUFSIZE )
         hb_xfree( pGT->inkeyBuffer );

      if( iTypeAhead > HB_DEFAULT_INKEY_BUFSIZE )
      {
         pGT->inkeyBufferSize = iTypeAhead;
         pGT->inkeyBuffer = ( int * ) hb_xgrab( pGT->inkeyBufferSize * sizeof( int ) );
      }
      else
      {
         pGT->inkeyBufferSize = HB_DEFAULT_INKEY_BUFSIZE;
         pGT->inkeyBuffer = pGT->defaultKeyBuffer;
      }
   }
}
hbgtcore.c2445
STATIC VOIDhb_gt_def_InkeyExit( PHB_GT pGT )
static void hb_gt_def_InkeyExit( PHB_GT pGT )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_InkeyExit(%p)", pGT));

   if( pGT->StrBuffer )
   {
      hb_xfree( pGT->StrBuffer );
      pGT->StrBuffer = NULL;
   }
   if( pGT->inkeyBufferSize > HB_DEFAULT_INKEY_BUFSIZE )
   {
      hb_xfree( pGT->inkeyBuffer );
      pGT->inkeyBufferSize = HB_DEFAULT_INKEY_BUFSIZE;
      pGT->inkeyBuffer = pGT->defaultKeyBuffer;
   }
}
hbgtcore.c2481
STATIC VOIDhb_gt_def_MouseInit( PHB_GT pGT )
static void hb_gt_def_MouseInit( PHB_GT pGT )
{
   HB_SYMBOL_UNUSED( pGT );
}
hbgtcore.c2499
STATIC VOIDhb_gt_def_MouseExit( PHB_GT pGT )
static void hb_gt_def_MouseExit( PHB_GT pGT )
{
   HB_SYMBOL_UNUSED( pGT );
}
hbgtcore.c2504
STATIC BOOLhb_gt_def_MouseIsPresent( PHB_GT pGT )
static BOOL hb_gt_def_MouseIsPresent( PHB_GT pGT )
{
   HB_SYMBOL_UNUSED( pGT );
   return FALSE;
}
hbgtcore.c2509
STATIC VOIDhb_gt_def_MouseShow( PHB_GT pGT )
static void hb_gt_def_MouseShow( PHB_GT pGT )
{
   HB_SYMBOL_UNUSED( pGT );
}
hbgtcore.c2515
STATIC VOIDhb_gt_def_MouseHide( PHB_GT pGT )
static void hb_gt_def_MouseHide( PHB_GT pGT )
{
   HB_SYMBOL_UNUSED( pGT );
}
hbgtcore.c2520
STATIC BOOLhb_gt_def_MouseGetCursor( PHB_GT pGT )
static BOOL hb_gt_def_MouseGetCursor( PHB_GT pGT )
{
   return pGT->fMouseVisible;
}
hbgtcore.c2525
STATIC VOIDhb_gt_def_MouseSetCursor( PHB_GT pGT, BOOL fVisible )
static void hb_gt_def_MouseSetCursor( PHB_GT pGT, BOOL fVisible )
{
   if( fVisible )
   {
      HB_GTSELF_MOUSESHOW( pGT );
      pGT->fMouseVisible = TRUE;
   }
   else if( pGT->fMouseVisible )
   {
      /*
       * mouse drivers use hide counters, so repeated calls to
       * HB_GTSELF_MOUSEHIDE( pGT ) will need at least the same number of
       * calls to HB_GTSELF_MOUSESHOW() to make mouse cursor visible. This
       * behavior is not compatible with Clipper so call to
       * HB_GTSELF_MOUSEHIDE( pGT ) is guarded by pGT->fMouseVisible.
       * The counter is not updated when mouse cursor is visible and
       * HB_GTSELF_MOUSESHOW() is called so this behavior is enough.
       * If some platform works in differ way then and this behavior
       * will create problems GT driver should overload
       * HB_GTSELF_MOUSESETCURSOR()/HB_GTSELF_MOUSEGETCURSOR() methods.
       * [druzus]
       */
      HB_GTSELF_MOUSEHIDE( pGT );
      pGT->fMouseVisible = FALSE;
   }
}
hbgtcore.c2530
STATIC INThb_gt_def_MouseRow( PHB_GT pGT )
static int hb_gt_def_MouseRow( PHB_GT pGT )
{
   int iRow, iCol;

   HB_GTSELF_MOUSEGETPOS( pGT, &iRow, &iCol );
   return iRow;
}
hbgtcore.c2557
STATIC INThb_gt_def_MouseCol( PHB_GT pGT )
static int hb_gt_def_MouseCol( PHB_GT pGT )
{
   int iRow, iCol;

   HB_GTSELF_MOUSEGETPOS( pGT, &iRow, &iCol );
   return iCol;
}
hbgtcore.c2565
STATIC VOIDhb_gt_def_MouseGetPos( PHB_GT pGT, int * piRow, int * piCol )
static void hb_gt_def_MouseGetPos( PHB_GT pGT, int * piRow, int * piCol )
{
   HB_SYMBOL_UNUSED( pGT );

   *piRow = *piCol = 0;
}
hbgtcore.c2573
STATIC VOIDhb_gt_def_MouseSetPos( PHB_GT pGT, int iRow, int iCol )
static void hb_gt_def_MouseSetPos( PHB_GT pGT, int iRow, int iCol )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( iRow );
   HB_SYMBOL_UNUSED( iCol );
}
hbgtcore.c2580
STATIC VOIDhb_gt_def_MouseSetBounds( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
static void hb_gt_def_MouseSetBounds( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( iTop );
   HB_SYMBOL_UNUSED( iLeft );
   HB_SYMBOL_UNUSED( iBottom );
   HB_SYMBOL_UNUSED( iRight );
}
hbgtcore.c2587
STATIC VOIDhb_gt_def_MouseGetBounds( PHB_GT pGT, int * piTop, int * piLeft, int * piBottom, int * piRight )
static void hb_gt_def_MouseGetBounds( PHB_GT pGT, int * piTop, int * piLeft, int * piBottom, int * piRight )
{
   HB_SYMBOL_UNUSED( pGT );

   *piTop = *piLeft = 0;
   HB_GTSELF_GETSIZE( pGT, piBottom, piRight );
   --(*piBottom);
   --(*piRight);
}

typedef struct
{
   int   iRow;
   int   iCol;
   int   fVisible;
   int   iTop;
   int   iLeft;
   int   iBottom;
   int   iRight;
} _HB_MOUSE_STORAGE;
hbgtcore.c2596
STATIC INThb_gt_def_mouseStorageSize( PHB_GT pGT )
static int  hb_gt_def_mouseStorageSize( PHB_GT pGT )
{
   HB_SYMBOL_UNUSED( pGT );

   return sizeof( _HB_MOUSE_STORAGE );
}
hbgtcore.c2617
STATIC VOIDhb_gt_def_mouseSaveState( PHB_GT pGT, BYTE * pBuffer )
static void hb_gt_def_mouseSaveState( PHB_GT pGT, BYTE * pBuffer )
{
   _HB_MOUSE_STORAGE * pStore = ( _HB_MOUSE_STORAGE * ) pBuffer;
   int iRow, iCol, iTop, iLeft, iBottom, iRight;

   HB_GTSELF_MOUSEGETPOS( pGT, &iRow, &iCol );
   HB_GTSELF_MOUSEGETBOUNDS( pGT, &iTop, &iLeft, &iBottom, &iRight );

   pStore->iRow      = iRow;
   pStore->iCol      = iCol;
   pStore->fVisible  = HB_GTSELF_MOUSEGETCURSOR( pGT );
   pStore->iTop      = iTop;
   pStore->iLeft     = iLeft;
   pStore->iBottom   = iBottom;
   pStore->iRight    = iRight;
}
hbgtcore.c2624
STATIC VOIDhb_gt_def_mouseRestoreState( PHB_GT pGT, BYTE * pBuffer )
static void hb_gt_def_mouseRestoreState( PHB_GT pGT, BYTE * pBuffer )
{
   _HB_MOUSE_STORAGE * pStore = ( _HB_MOUSE_STORAGE * ) pBuffer;

   HB_GTSELF_MOUSESETBOUNDS( pGT, pStore->iTop, pStore->iLeft, pStore->iBottom, pStore->iRight );
   HB_GTSELF_MOUSESETPOS( pGT, pStore->iRow, pStore->iCol );
   HB_GTSELF_MOUSESETCURSOR( pGT, pStore->fVisible );
}
hbgtcore.c2641
STATIC INThb_gt_def_mouseGetDoubleClickSpeed( PHB_GT pGT )
static int  hb_gt_def_mouseGetDoubleClickSpeed( PHB_GT pGT )
{
   return pGT->iDoubleClickSpeed;
}
hbgtcore.c2650
STATIC VOIDhb_gt_def_mouseSetDoubleClickSpeed( PHB_GT pGT, int iSpeed )
static void hb_gt_def_mouseSetDoubleClickSpeed( PHB_GT pGT, int iSpeed )
{
   if( iSpeed > 0 )
      pGT->iDoubleClickSpeed = iSpeed;
}
hbgtcore.c2655
STATIC INThb_gt_def_MouseCountButton( PHB_GT pGT )
static int hb_gt_def_MouseCountButton( PHB_GT pGT )
{
   HB_SYMBOL_UNUSED( pGT );

   return 0;
}
hbgtcore.c2661
STATIC BOOLhb_gt_def_MouseButtonState( PHB_GT pGT, int iButton )
static BOOL hb_gt_def_MouseButtonState( PHB_GT pGT, int iButton )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( iButton );

   return FALSE;
}
hbgtcore.c2668
STATIC BOOLhb_gt_def_MouseButtonPressed( PHB_GT pGT, int iButton, int * piRow, int * piCol )
static BOOL hb_gt_def_MouseButtonPressed( PHB_GT pGT, int iButton, int * piRow, int * piCol )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( iButton );
   HB_SYMBOL_UNUSED( piRow );
   HB_SYMBOL_UNUSED( piCol );

   return FALSE;
}
hbgtcore.c2676
STATIC BOOLhb_gt_def_MouseButtonReleased( PHB_GT pGT, int iButton, int * piRow, int * piCol )
static BOOL hb_gt_def_MouseButtonReleased( PHB_GT pGT, int iButton, int * piRow, int * piCol )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( iButton );
   HB_SYMBOL_UNUSED( piRow );
   HB_SYMBOL_UNUSED( piCol );

   return FALSE;
}
hbgtcore.c2686
STATIC INThb_gt_def_MouseReadKey( PHB_GT pGT, int iEventMask )
static int hb_gt_def_MouseReadKey( PHB_GT pGT, int iEventMask )
{
   int iKey = 0, iRow, iCol;

   if( HB_GTSELF_MOUSEISPRESENT( pGT ) )
   {
      if( iEventMask & INKEY_LDOWN && HB_GTSELF_MOUSEBUTTONPRESSED( pGT, 0, &iRow, &iCol ) )
      {
         HB_ULONG timer = hb_dateMilliSeconds();
         if( timer - pGT->iMouseLeftTimer <= ( HB_ULONG ) HB_GTSELF_MOUSEGETDOUBLECLICKSPEED( pGT ) )
            iKey = K_LDBLCLK;
         else
            iKey = K_LBUTTONDOWN;
         pGT->iMouseLeftTimer = timer;
      }
      else if( iEventMask & INKEY_LUP && HB_GTSELF_MOUSEBUTTONRELEASED( pGT, 0, &iRow, &iCol ) )
      {
         iKey = K_LBUTTONUP;
      }
      else if( iEventMask & INKEY_RDOWN && HB_GTSELF_MOUSEBUTTONPRESSED( pGT, 1, &iRow, &iCol ) )
      {
         HB_ULONG timer = hb_dateMilliSeconds();
         if( timer - pGT->iMouseRightTimer <= ( HB_ULONG ) HB_GTSELF_MOUSEGETDOUBLECLICKSPEED( pGT ) )
            iKey = K_RDBLCLK;
         else
            iKey = K_RBUTTONDOWN;
         pGT->iMouseRightTimer = timer;
      }
      else if( iEventMask & INKEY_RUP && HB_GTSELF_MOUSEBUTTONRELEASED( pGT, 1, &iRow, &iCol ) )
      {
         iKey = K_RBUTTONUP;
      }
      else if( iEventMask & INKEY_MMIDDLE && HB_GTSELF_MOUSEBUTTONPRESSED( pGT, 2, &iRow, &iCol ) )
      {
         HB_ULONG timer = hb_dateMilliSeconds();
         if( timer - pGT->iMouseMiddleTimer <= ( HB_ULONG ) HB_GTSELF_MOUSEGETDOUBLECLICKSPEED( pGT ) )
            iKey = K_MDBLCLK;
         else
            iKey = K_MBUTTONDOWN;
         pGT->iMouseMiddleTimer = timer;
      }
      else if( iEventMask & INKEY_MMIDDLE && HB_GTSELF_MOUSEBUTTONRELEASED( pGT, 2, &iRow, &iCol ) )
      {
         iKey = K_MBUTTONUP;
      }
      else if( iEventMask & INKEY_MOVE )
      {
         HB_GTSELF_MOUSEGETPOS( pGT, &iRow, &iCol );
         if( iRow != pGT->iMouseLastRow || iCol != pGT->iMouseLastCol )
         {
            pGT->iMouseLastRow = iRow;
            pGT->iMouseLastCol = iCol;
            iKey = K_MOUSEMOVE;
         }
      }
   }
   return iKey;
}
hbgtcore.c2696
STATIC INThb_gt_def_GfxPrimitive( PHB_GT pGT, int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
static int hb_gt_def_GfxPrimitive( PHB_GT pGT, int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( iType );
   HB_SYMBOL_UNUSED( iTop );
   HB_SYMBOL_UNUSED( iLeft );
   HB_SYMBOL_UNUSED( iBottom );
   HB_SYMBOL_UNUSED( iRight );
   HB_SYMBOL_UNUSED( iColor );

   return 0;
}
hbgtcore.c2755
STATIC VOIDhb_gt_def_GfxText( PHB_GT pGT, int iTop, int iLeft, char * szText, int iColor, int iSize, int iWidth )
static void hb_gt_def_GfxText( PHB_GT pGT, int iTop, int iLeft, char * szText, int iColor, int iSize, int iWidth )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( iTop );
   HB_SYMBOL_UNUSED( iLeft );
   HB_SYMBOL_UNUSED( szText );
   HB_SYMBOL_UNUSED( iColor );
   HB_SYMBOL_UNUSED( iSize );
   HB_SYMBOL_UNUSED( iWidth );
}
hbgtcore.c2768
STATIC VOIDhb_gt_def_WhoCares( PHB_GT pGT, void * pCargo )
static void hb_gt_def_WhoCares( PHB_GT pGT, void * pCargo )
{
   HB_SYMBOL_UNUSED( pGT );
   HB_SYMBOL_UNUSED( pCargo );
}

/* ************************************************************************* */

#if defined( __GNUC__ ) && 0
static HB_GT_FUNCS s_gtCoreFunc =
{
   Init                       : hb_gt_def_Init                          ,
   Exit                       : hb_gt_def_Exit                          ,
   New                        : hb_gt_def_New                           ,
   Free                       : hb_gt_def_Free                          ,
   Resize                     : hb_gt_def_Resize                        ,
   SetMode                    : hb_gt_def_SetMode                       ,
   GetSize                    : hb_gt_def_GetSize                       ,
   SemiCold                   : hb_gt_def_SemiCold                      ,
   ColdArea                   : hb_gt_def_ColdArea                      ,
   ExposeArea                 : hb_gt_def_ExposeArea                    ,
   ScrollArea                 : hb_gt_def_ScrollArea                    ,
   TouchCell                  : hb_gt_def_TouchCell                     ,
   Redraw                     : hb_gt_def_Redraw                        ,
   Refresh                    : hb_gt_def_Refresh                       ,
   Flush                      : hb_gt_def_Flush                         ,
   MaxCol                     : hb_gt_def_MaxCol                        ,
   MaxRow                     : hb_gt_def_MaxRow                        ,
   CheckPos                   : hb_gt_def_CheckPos                      ,
   SetPos                     : hb_gt_def_SetPos                        ,
   GetPos                     : hb_gt_def_GetPos                        ,
   IsColor                    : hb_gt_def_IsColor                       ,
   GetColorStr                : hb_gt_def_GetColorStr                   ,
   SetColorStr                : hb_gt_def_SetColorStr                   ,
   ColorSelect                : hb_gt_def_ColorSelect                   ,
   GetColor                   : hb_gt_def_GetColor                      ,
   ColorNum                   : hb_gt_def_ColorNum                      ,
   ColorsToString             : hb_gt_def_ColorsToString                ,
   StringToColors             : hb_gt_def_StringToColors                ,
   GetColorData               : hb_gt_def_GetColorData                  ,
   GetClearColor              : hb_gt_def_GetClearColor                 ,
   SetClearColor              : hb_gt_def_SetClearColor                 ,
   GetClearChar               : hb_gt_def_GetClearChar                  ,
   SetClearChar               : hb_gt_def_SetClearChar                  ,
   GetCursorStyle             : hb_gt_def_GetCursorStyle                ,
   SetCursorStyle             : hb_gt_def_SetCursorStyle                ,
   GetScrCursor               : hb_gt_def_GetScrCursor                  ,
   GetScrChar                 : hb_gt_def_GetChar                       ,
   PutScrChar                 : hb_gt_def_PutChar                       ,
   DispBegin                  : hb_gt_def_DispBegin                     ,
   DispEnd                    : hb_gt_def_DispEnd                       ,
   DispCount                  : hb_gt_def_DispCount                     ,
   GetChar                    : hb_gt_def_GetChar                       ,
   PutChar                    : hb_gt_def_PutChar                       ,
   RectSize                   : hb_gt_def_RectSize                      ,
   Save                       : hb_gt_def_Save                          ,
   Rest                       : hb_gt_def_Rest                          ,
   PutText                    : hb_gt_def_PutText                       ,
   Replicate                  : hb_gt_def_Replicate                     ,
   WriteAt                    : hb_gt_def_WriteAt                       ,
   Write                      : hb_gt_def_Write                         ,
   WriteCon                   : hb_gt_def_WriteCon                      ,
   SetAttribute               : hb_gt_def_SetAttribute                  ,
   DrawShadow                 : hb_gt_def_DrawShadow                    ,
   Scroll                     : hb_gt_def_Scroll                        ,
   ScrollUp                   : hb_gt_def_ScrollUp                      ,
   Box                        : hb_gt_def_Box                           ,
   BoxD                       : hb_gt_def_BoxD                          ,
   BoxS                       : hb_gt_def_BoxS                          ,
   HorizLine                  : hb_gt_def_HorizLine                     ,
   VertLine                   : hb_gt_def_VertLine                      ,
   GetBlink                   : hb_gt_def_GetBlink                      ,
   SetBlink                   : hb_gt_def_SetBlink                      ,
   SetSnowFlag                : hb_gt_def_SetSnowFlag                   ,
   Version                    : hb_gt_def_Version                       ,
   Suspend                    : hb_gt_def_Suspend                       ,
   Resume                     : hb_gt_def_Resume                        ,
   PreExt                     : hb_gt_def_PreExt                        ,
   PostExt                    : hb_gt_def_PostExt                       ,
   OutStd                     : hb_gt_def_OutStd                        ,
   OutErr                     : hb_gt_def_OutErr                        ,
   Tone                       : hb_gt_def_Tone                          ,
   Bell                       : hb_gt_def_Bell                          ,
   Info                       : hb_gt_def_Info                          ,
   Alert                      : hb_gt_def_Alert                         ,
   SetFlag                    : hb_gt_def_SetFlag                       ,
   SetDispCP                  : hb_gt_def_SetDispCP                     ,
   SetKeyCP                   : hb_gt_def_SetKeyCP                      ,
   ReadKey                    : hb_gt_def_ReadKey                       ,
   InkeyGet                   : hb_gt_def_InkeyGet                      ,
   InkeyPut                   : hb_gt_def_InkeyPut                      ,
   InkeyIns                   : hb_gt_def_InkeyIns                      ,
   InkeyLast                  : hb_gt_def_InkeyLast                     ,
   InkeyNext                  : hb_gt_def_InkeyNext                     ,
   InkeyPoll                  : hb_gt_def_InkeyPoll                     ,
   InkeySetText               : hb_gt_def_InkeySetText                  ,
   InkeySetLast               : hb_gt_def_InkeySetLast                  ,
   InkeyReset                 : hb_gt_def_InkeyReset                    ,
   InkeyExit                  : hb_gt_def_InkeyExit                     ,
   MouseInit                  : hb_gt_def_MouseInit                     ,
   MouseExit                  : hb_gt_def_MouseExit                     ,
   MouseIsPresent             : hb_gt_def_MouseIsPresent                ,
   MouseShow                  : hb_gt_def_MouseShow                     ,
   MouseHide                  : hb_gt_def_MouseHide                     ,
   MouseGetCursor             : hb_gt_def_MouseGetCursor                ,
   MouseSetCursor             : hb_gt_def_MouseSetCursor                ,
   MouseCol                   : hb_gt_def_MouseCol                      ,
   MouseRow                   : hb_gt_def_MouseRow                      ,
   MouseGetPos                : hb_gt_def_MouseGetPos                   ,
   MouseSetPos                : hb_gt_def_MouseSetPos                   ,
   MouseSetBounds             : hb_gt_def_MouseSetBounds                ,
   MouseGetBounds             : hb_gt_def_MouseGetBounds                ,
   MouseStorageSize           : hb_gt_def_mouseStorageSize              ,
   MouseSaveState             : hb_gt_def_mouseSaveState                ,
   MouseRestoreState          : hb_gt_def_mouseRestoreState             ,
   MouseGetDoubleClickSpeed   : hb_gt_def_mouseGetDoubleClickSpeed      ,
   MouseSetDoubleClickSpeed   : hb_gt_def_mouseSetDoubleClickSpeed      ,
   MouseCountButton           : hb_gt_def_MouseCountButton              ,
   MouseButtonState           : hb_gt_def_MouseButtonState              ,
   MouseButtonPressed         : hb_gt_def_MouseButtonPressed            ,
   MouseButtonReleased        : hb_gt_def_MouseButtonReleased           ,
   MouseReadKey               : hb_gt_def_MouseReadKey                  ,
   GfxPrimitive               : hb_gt_def_GfxPrimitive                  ,
   GfxText                    : hb_gt_def_GfxText                       ,
   WhoCares                   : hb_gt_def_WhoCares
};
#else
static HB_GT_FUNCS s_gtCoreFunc =
{
   hb_gt_def_Init                         ,
   hb_gt_def_Exit                         ,
   hb_gt_def_New                          ,
   hb_gt_def_Free                         ,
   hb_gt_def_Resize                       ,
   hb_gt_def_SetMode                      ,
   hb_gt_def_GetSize                      ,
   hb_gt_def_SemiCold                     ,
   hb_gt_def_ColdArea                     ,
   hb_gt_def_ExposeArea                   ,
   hb_gt_def_ScrollArea                   ,
   hb_gt_def_TouchCell                    ,
   hb_gt_def_Redraw                       ,
   hb_gt_def_Refresh                      ,
   hb_gt_def_Flush                        ,
   hb_gt_def_MaxCol                       ,
   hb_gt_def_MaxRow                       ,
   hb_gt_def_CheckPos                     ,
   hb_gt_def_SetPos                       ,
   hb_gt_def_GetPos                       ,
   hb_gt_def_IsColor                      ,
   hb_gt_def_GetColorStr                  ,
   hb_gt_def_SetColorStr                  ,
   hb_gt_def_ColorSelect                  ,
   hb_gt_def_GetColor                     ,
   hb_gt_def_ColorNum                     ,
   hb_gt_def_ColorsToString               ,
   hb_gt_def_StringToColors               ,
   hb_gt_def_GetColorData                 ,
   hb_gt_def_GetClearColor                ,
   hb_gt_def_SetClearColor                ,
   hb_gt_def_GetClearChar                 ,
   hb_gt_def_SetClearChar                 ,
   hb_gt_def_GetCursorStyle               ,
   hb_gt_def_SetCursorStyle               ,
   hb_gt_def_GetScrCursor                 ,
   hb_gt_def_GetChar                      , /* intentionally mapped to GetScrChar */
   hb_gt_def_PutChar                      , /* intentionally mapped to PutScrChar */
   hb_gt_def_DispBegin                    ,
   hb_gt_def_DispEnd                      ,
   hb_gt_def_DispCount                    ,
   hb_gt_def_GetChar                      ,
   hb_gt_def_PutChar                      ,
   hb_gt_def_RectSize                     ,
   hb_gt_def_Save                         ,
   hb_gt_def_Rest                         ,
   hb_gt_def_PutText                      ,
   hb_gt_def_Replicate                    ,
   hb_gt_def_WriteAt                      ,
   hb_gt_def_Write                        ,
   hb_gt_def_WriteCon                     ,
   hb_gt_def_SetAttribute                 ,
   hb_gt_def_DrawShadow                   ,
   hb_gt_def_Scroll                       ,
   hb_gt_def_ScrollUp                     ,
   hb_gt_def_Box                          ,
   hb_gt_def_BoxD                         ,
   hb_gt_def_BoxS                         ,
   hb_gt_def_HorizLine                    ,
   hb_gt_def_VertLine                     ,
   hb_gt_def_GetBlink                     ,
   hb_gt_def_SetBlink                     ,
   hb_gt_def_SetSnowFlag                  ,
   hb_gt_def_Version                      ,
   hb_gt_def_Suspend                      ,
   hb_gt_def_Resume                       ,
   hb_gt_def_PreExt                       ,
   hb_gt_def_PostExt                      ,
   hb_gt_def_OutStd                       ,
   hb_gt_def_OutErr                       ,
   hb_gt_def_Tone                         ,
   hb_gt_def_Bell                         ,
   hb_gt_def_Info                         ,
   hb_gt_def_Alert                        ,
   hb_gt_def_SetFlag                      ,
   hb_gt_def_SetDispCP                    ,
   hb_gt_def_SetKeyCP                     ,
   hb_gt_def_ReadKey                      ,
   hb_gt_def_InkeyGet                     ,
   hb_gt_def_InkeyPut                     ,
   hb_gt_def_InkeyIns                     ,
   hb_gt_def_InkeyLast                    ,
   hb_gt_def_InkeyNext                    ,
   hb_gt_def_InkeyPoll                    ,
   hb_gt_def_InkeySetText                 ,
   hb_gt_def_InkeySetLast                 ,
   hb_gt_def_InkeyReset                   ,
   hb_gt_def_InkeyExit                    ,
   hb_gt_def_MouseInit                    ,
   hb_gt_def_MouseExit                    ,
   hb_gt_def_MouseIsPresent               ,
   hb_gt_def_MouseShow                    ,
   hb_gt_def_MouseHide                    ,
   hb_gt_def_MouseGetCursor               ,
   hb_gt_def_MouseSetCursor               ,
   hb_gt_def_MouseCol                     ,
   hb_gt_def_MouseRow                     ,
   hb_gt_def_MouseGetPos                  ,
   hb_gt_def_MouseSetPos                  ,
   hb_gt_def_MouseSetBounds               ,
   hb_gt_def_MouseGetBounds               ,
   hb_gt_def_mouseStorageSize             ,
   hb_gt_def_mouseSaveState               ,
   hb_gt_def_mouseRestoreState            ,
   hb_gt_def_mouseGetDoubleClickSpeed     ,
   hb_gt_def_mouseSetDoubleClickSpeed     ,
   hb_gt_def_MouseCountButton             ,
   hb_gt_def_MouseButtonState             ,
   hb_gt_def_MouseButtonPressed           ,
   hb_gt_def_MouseButtonReleased          ,
   hb_gt_def_MouseReadKey                 ,
   hb_gt_def_GfxPrimitive                 ,
   hb_gt_def_GfxText                      ,
   hb_gt_def_WhoCares
};
#endif

/* ************************************************************************* */

static char s_gtNameBuf[ HB_GT_NAME_MAX_ + 1 ];

#if defined(HB_GT_LIB)
   HB_EXPORT const char * hb_gt_szNameDefault = HB_GT_DRVNAME( HB_GT_LIB );
#elif defined(HB_WINCE)
   HB_EXPORT const char * hb_gt_szNameDefault = "wvt";
#elif defined(HB_OS_WIN_32)
   HB_EXPORT const char * hb_gt_szNameDefault = "win";
#elif defined(HB_OS_DOS)
   HB_EXPORT const char * hb_gt_szNameDefault = "dos";
#elif defined(HB_OS_OS2)
   HB_EXPORT const char * hb_gt_szNameDefault = "os2";
#elif defined(HB_OS_UNIX)
   HB_EXPORT const char * hb_gt_szNameDefault = "trm";
#else
   HB_EXPORT const char * hb_gt_szNameDefault = "std";
#endif

static const HB_GT_INIT * s_gtInit[ HB_GT_MAX_ ];
static int s_gtLinkOrder[ HB_GT_MAX_ ];
static int s_iGtLinkCount = 0;
static int s_iGtCount = 0;

HB_FUNC_EXTERN( HB_GTSYS );
hbgtcore.c2779
STATIC CONST CHAR *hb_gt_FindDefault( void )
static const char * hb_gt_FindDefault( void )
{
   char szFuncName[ 15 + HB_GT_NAME_MAX_ ];
   int iPos;

   for( iPos = 0; iPos < s_iGtCount; iPos++ )
   {
      snprintf( szFuncName, sizeof( szFuncName ),
                "HB_GT_%s_DEFAULT", s_gtInit[ iPos ]->id );
      if( hb_dynsymFind( szFuncName ) )
         return s_gtInit[ iPos ]->id;
   }

   if( hb_dynsymFind( "HB_GT_NUL_DEFAULT" ) )
      return "NUL";
   else
      return NULL;
}
hbgtcore.c3052
STATIC INThb_gt_FindEntry( const char * pszID )
static int hb_gt_FindEntry( const char * pszID )
{
   int iPos;

   for( iPos = 0; iPos < s_iGtCount; iPos++ )
   {
      if( hb_stricmp( s_gtInit[ iPos ]->id, pszID ) == 0 ||
          ( hb_strnicmp( pszID, "gt", 2 ) == 0 &&
            hb_stricmp( s_gtInit[ iPos ]->id, pszID + 2 ) == 0 ) )
         return iPos;
   }

   return -1;
}
hbgtcore.c3071
HB_EXPORT VOIDhb_gtSetDefault( const char * szGtName )
HB_EXPORT void hb_gtSetDefault( const char * szGtName )
{
   hb_strncpy( s_gtNameBuf, szGtName, sizeof( s_gtNameBuf ) - 1 );
   hb_gt_szNameDefault = s_gtNameBuf;
}
hbgtcore.c3086
HB_EXPORT BOOLhb_gtRegister( const HB_GT_INIT * gtInit )
HB_EXPORT BOOL hb_gtRegister( const HB_GT_INIT * gtInit )
{
   if( hb_gt_FindEntry( gtInit->id ) == -1 )
   {
      s_gtInit[ s_iGtCount++ ] = gtInit;
      return TRUE;
   }
   return FALSE;
}
hbgtcore.c3092
HB_EXPORT BOOLhb_gtLoad( const char * szGtName, PHB_GT_FUNCS pFuncTable )
HB_EXPORT BOOL hb_gtLoad( const char * szGtName, PHB_GT_FUNCS pFuncTable )
{
   int iPos;

   if( szGtName )
   {
      if( hb_stricmp( szGtName, "nul" ) == 0 || hb_stricmp( szGtName, "null" ) == 0 )
      {
         if( pFuncTable == NULL )
            pFuncTable = &s_gtCoreFunc;
         if( !s_curGT )
         {
            s_curGT = ( PHB_GT_BASE ) hb_xgrab( sizeof( HB_GT_BASE ) );
            memset( s_curGT, 0, sizeof( HB_GT_BASE ) );
         }
         s_curGT->pFuncTable = pFuncTable;
         return TRUE;
      }

      iPos = hb_gt_FindEntry( szGtName );

      if( iPos != -1 )
      {
         if( pFuncTable == NULL )
            pFuncTable = &s_gtCoreFunc;
         memcpy( s_gtInit[ iPos ]->pSuperTable, pFuncTable, sizeof( HB_GT_FUNCS ) );
         if( !s_gtInit[ iPos ]->init( pFuncTable ) )
         {
            hb_errInternal( 6001, "Screen driver initialization failure", NULL, NULL );
         }
         if( s_gtInit[ iPos ]->pGtId )
            *s_gtInit[ iPos ]->pGtId = s_iGtLinkCount;
         s_gtLinkOrder[ s_iGtLinkCount++ ] = iPos;

         if( !s_curGT )
         {
            s_curGT = ( PHB_GT_BASE ) hb_xgrab( sizeof( HB_GT_BASE ) );
            memset( s_curGT, 0, sizeof( HB_GT_BASE ) );
         }
         s_curGT->pFuncTable = pFuncTable;

         return TRUE;
      }
   }
   return FALSE;
}
hbgtcore.c3102
HB_EXPORT BOOLhb_gtUnLoad( void )
HB_EXPORT BOOL hb_gtUnLoad( void )
{
   while( s_iGtLinkCount > 0 )
   {
      if( --s_iGtLinkCount == 0 )
         memcpy( &s_gtCoreFunc,
                 s_gtInit[ s_gtLinkOrder[ s_iGtLinkCount ] ]->pSuperTable,
                 sizeof( HB_GT_FUNCS ) );
   }

   return TRUE;
}
hbgtcore.c3149
HB_EXPORT VOIDhb_gtStartupInit( void )
HB_EXPORT void hb_gtStartupInit( void )
{
   char * szGtName;
   BOOL fInit;

   szGtName = hb_cmdargString( "GT" );
   if( szGtName )
   {
      fInit = hb_gtLoad( szGtName, &s_gtCoreFunc );
      hb_xfree( szGtName );
      if( fInit )
         return;
   }
   szGtName = hb_getenv( "HB_GT" );
   if( szGtName )
   {
      fInit = hb_gtLoad( szGtName, &s_gtCoreFunc );
      hb_xfree( szGtName );
      if( fInit )
         return;
   }
   if( hb_gtLoad( hb_gt_FindDefault(), &s_gtCoreFunc ) )
      return;
   if( hb_gtLoad( hb_gt_szNameDefault, &s_gtCoreFunc ) )
      return;

   if( hb_dynsymFind( "HB_GT_NUL" ) ) /* GTNUL was explicitly requsted */
   {
      if( hb_gtLoad( "NUL", &s_gtCoreFunc ) )
         return;
   }

   hb_errInternal( 9998, "Screen driver initialization failure", NULL, NULL );

   /* force linking HB_GTSYS() */
   HB_FUNC_EXEC( HB_GTSYS );
}

HB_GT_ANNOUNCE( HB_GT_NAME )
hbgtcore.c3162
hbhex.c
TypeFunctionSourceLine
HB_FUNCHB_HEXTONUM(void)
HB_FUNC( HB_HEXTONUM )
{
   char * szHex = hb_parc( 1 );

   if( szHex )
   {
      HB_ULONG ulNum = 0;

      while( *szHex == ' ' ) szHex++;
      while( *szHex )
      {
         int iDigit;
         char c = *szHex++;
         if( c >= '0' && c <= '9' )
            iDigit = c - '0';
         else if( c >= 'A' && c <= 'F' )
            iDigit = c - ( 'A' - 10 );
         else if( c >= 'a' && c <= 'f' )
            iDigit = c - ( 'a' - 10 );
         else
         {
            ulNum = 0;
            break;
         }
         ulNum = ( ulNum << 4 ) + iDigit;
      }
      hb_retnint( ulNum );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbhex.c57
HB_FUNCHB_NUMTOHEX(void)
HB_FUNC( HB_NUMTOHEX )
{
   HB_ULONG ulNum;
   int      iLen;
   BOOL     fDefaultLen;
   char     ret[ 33 ];

   if( ISNUM( 2 ) )
   {
      iLen = hb_parni( 2 );
      iLen = ( iLen < 1 ) ? 1 : ( ( iLen > 32 ) ? 32 : iLen );
      fDefaultLen = 0;
   }
   else
   {
      iLen = 32;
      fDefaultLen = 1;
   }

   if( ISNUM( 1 ) )
      ulNum = hb_parnint( 1 );
   else if( ISPOINTER( 1 ) )
      ulNum = (HB_PTRDIFF) hb_parptr( 1 );
   else
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   ret[ iLen ] = '\0';
   do
   {
      int iDigit = ( int ) ( ulNum & 0x0F );
      ret[ --iLen ] = ( char ) ( iDigit + ( iDigit < 10 ? '0' : 'A' - 10 ) );
      ulNum >>= 4;
   }
   while( fDefaultLen ? ulNum != 0 : iLen != 0 );

   hb_retc( &ret[ iLen ] );
}
hbhex.c89
HB_FUNCHB_STRTOHEX(void)
HB_FUNC( HB_STRTOHEX )
{
   const char * szStr = hb_parc( 1 ), * szSep = "";
   ULONG ulStr, ulSep = 0;

   if( hb_pcount() > 1 )
   {
      szSep = hb_parc( 2 );
      ulSep = hb_parclen( 2 );
   }

   if( !szStr || !szSep )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   ulStr = hb_parclen( 1 );
   if( ulStr )
   {
      ULONG ulDest = ( ulStr << 1 ) + ( ulStr - 1 ) * ulSep;
      char * szDest, * szPtr;

      szPtr = szDest = ( char * ) hb_xgrab( ulDest + 1 );
      do
      {
         UCHAR uc = ( UCHAR ) *szStr++, ud;
         ud = uc >> 4;
         *szPtr++ = ud + ( ud < 10 ? '0' : 'A' - 10 );
         ud = uc & 0x0F;
         *szPtr++ = ud + ( ud < 10 ? '0' : 'A' - 10 );
         if( --ulStr && ulSep )
         {
            memcpy( szPtr, szSep, ulSep );
            szPtr += ulSep;
         }
      }
      while( ulStr );
      hb_retclen_buffer( szDest, ulDest );
   }
   else
      hb_retc( NULL );
}
hbhex.c130
HB_FUNCHB_HEXTOSTR(void)
HB_FUNC( HB_HEXTOSTR )
{
   char * szStr = hb_parc( 1 );
   ULONG ulStr;

   if( !szStr )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   ulStr = hb_parclen( 1 );
   if( ulStr > 1 )
   {
      ULONG ulDest, ul;
      char * szDest;

      szDest = szStr;
      ul = ulStr;
      ulDest = 0;
      do
      {
         char c = *szDest++;
         if( ( c >= '0' && c <= '9' ) ||
             ( c >= 'A' && c <= 'F' ) ||
             ( c >= 'a' && c <= 'f' ) )
            ++ulDest;
      }
      while( --ul );

      ulDest >>= 1;
      if( ulDest )
      {
         int iVal = 0x10;

         szDest = ( char * ) hb_xgrab( ulDest + 1 );
         /* ul = 0; see above stop condition */
         do
         {
            char c = *szStr++;
            if( c >= '0' && c <= '9' )
               iVal += c - '0';
            else if( c >= 'A' && c <= 'F' )
               iVal += c - ( 'A' - 10 );
            else if( c >= 'a' && c <= 'f' )
               iVal += c - ( 'a' - 10 );
            else
               continue;

            if( iVal & 0x100 )
            {
               szDest[ul++] = ( char ) iVal & 0xff;
               iVal = 0x1;
            }
            iVal <<= 4;
         }
         while( --ulStr );

         hb_retclen_buffer( szDest, ulDest );
         return;
      }
   }

   hb_retc( NULL );
}
hbhex.c174
hbinet.c
TypeFunctionSourceLine
STATIC VOIDhb_inetLinuxSigusrHandle( int sig )
static void hb_inetLinuxSigusrHandle( int sig )
{
   /* nothing to do */
   HB_SYMBOL_UNUSED( sig );
}
#  endif
#endif

/* JC1: we need it volatile to be minimally thread safe. */
static volatile int s_iSessions = 0;
hbinet.c230
STATIC BOOLhb_inetIsOpen( HB_SOCKET_STRUCT *Socket )
static BOOL hb_inetIsOpen( HB_SOCKET_STRUCT *Socket )
{
   if( Socket->com == ( HB_SOCKET_T ) -1 )
   {
      HB_SOCKET_SET_ERROR2( Socket, -4, "Closed socket" );
      return FALSE;
   }
   return TRUE;
}
hbinet.c241
STATIC INThb_selectReadSocket( HB_SOCKET_STRUCT *Socket )
static int hb_selectReadSocket( HB_SOCKET_STRUCT *Socket )
{
   fd_set set;
   struct timeval tv;
   int iResult;

   hb_vmUnlock();

   FD_ZERO( &set );
   FD_SET(Socket->com, &set);

   if( Socket->timeout == -1 )
   {
      iResult = select( Socket->com + 1, &set, NULL, NULL, NULL );
   }
   else
   {
      tv.tv_sec = Socket->timeout/ 1000;
      tv.tv_usec = (Socket->timeout % 1000) * 1000;
      iResult = select( Socket->com + 1, &set, NULL, NULL, &tv );
   }

   hb_vmLock();

   return iResult > 0 ? FD_ISSET( Socket->com, &set ) : 0;
}
hbinet.c253
STATIC INThb_selectWriteSocket( HB_SOCKET_STRUCT *Socket )
static int hb_selectWriteSocket( HB_SOCKET_STRUCT *Socket )
{
   fd_set set;
   struct timeval tv;
   int iResult;

   hb_vmUnlock();

   FD_ZERO( &set );
   FD_SET(Socket->com, &set);

   if( Socket->timeout == -1 )
   {
      iResult = select( Socket->com + 1, NULL, &set, NULL, NULL );
   }
   else
   {
      tv.tv_sec = Socket->timeout/ 1000;
      tv.tv_usec = (Socket->timeout % 1000) * 1000;
      iResult = select( Socket->com + 1, NULL, &set, NULL, &tv );
   }

   hb_vmLock();

   return iResult > 0 ? FD_ISSET( Socket->com, &set ) : 0;
}
hbinet.c280
STATIC INThb_selectWriteExceptSocket( HB_SOCKET_STRUCT *Socket )
static int hb_selectWriteExceptSocket( HB_SOCKET_STRUCT *Socket )
{
   fd_set set, eset;
   struct timeval tv;
   int iResult;

   hb_vmUnlock();

   FD_ZERO( &set );
   FD_SET(Socket->com, &set);
   FD_ZERO( &eset );
   FD_SET(Socket->com, &eset);

   if( Socket->timeout == -1 )
   {
      iResult = select( Socket->com + 1, NULL, &set, &eset, NULL );
   }
   else
   {
      tv.tv_sec = Socket->timeout/ 1000;
      tv.tv_usec = (Socket->timeout % 1000) * 1000;
      iResult = select(Socket->com + 1, NULL, &set, &eset, &tv);
   }

   hb_vmLock();

   if( iResult < 0 || FD_ISSET( Socket->com, &eset) )
      return 2;
   else if( FD_ISSET( Socket->com, &set ) )
      return 1;
   else
      return 0;
}
hbinet.c308
STATIC STRUCT HOSTENT *hb_getHosts( char * name, HB_SOCKET_STRUCT *Socket )
static struct hostent * hb_getHosts( char * name, HB_SOCKET_STRUCT *Socket )
{
   struct hostent *Host = NULL;

   hb_vmUnlock();

   /* TOFIX: make it MT safe */

   /* let's see if name is an IP address; not necessary on Linux */
#if defined(HB_OS_WIN_32) || defined(HB_OS_OS2)
   {
      ULONG ulAddr;

      ulAddr = inet_addr( name );
      if( ulAddr == INADDR_NONE )
      {
         if( strcmp( "255.255.255.255", name ) == 0 )
         {
            Host = gethostbyaddr( (const char*) &ulAddr, sizeof( ulAddr ), AF_INET );
         }
      }
      else
      {
         Host = gethostbyaddr( (const char*)  &ulAddr, sizeof( ulAddr ), AF_INET );
      }
   }
#endif

   if( Host == NULL )
   {
      Host = gethostbyname( name );
   }

   if( Host == NULL && Socket )
   {
#if defined(HB_OS_WIN_32)
      HB_SOCKET_SET_ERROR2( Socket, WSAGetLastError() , "Generic error in gethostbyname()" );
      WSASetLastError( 0 );
#elif defined(HB_OS_OS2) || defined(HB_OS_HPUX) || defined(__WATCOMC__)
      HB_SOCKET_SET_ERROR2( Socket, h_errno, "Generic error in gethostbyname()" );
#else
      HB_SOCKET_SET_ERROR2( Socket, h_errno, (char *) hstrerror( h_errno ) );
#endif
   }

   hb_vmLock();

   return Host;
}
hbinet.c343
STATIC VOIDhb_socketSetNonBlocking( HB_SOCKET_STRUCT *Socket )
static void hb_socketSetNonBlocking( HB_SOCKET_STRUCT *Socket )
{
#ifdef HB_OS_WIN_32
   ULONG mode = 1;
   ioctlsocket( Socket->com, FIONBIO, &mode );

#else
   int flags = fcntl( Socket->com, F_GETFL, 0 );
   if( flags != -1 )
   {
      flags |= O_NONBLOCK;
      fcntl( Socket->com, F_SETFL, (LONG) flags );
   }
#endif
}
hbinet.c397
STATIC VOIDhb_socketSetBlocking( HB_SOCKET_STRUCT *Socket )
static void hb_socketSetBlocking( HB_SOCKET_STRUCT *Socket )
{
#ifdef HB_OS_WIN_32
   ULONG mode = 0;
   ioctlsocket( Socket->com, FIONBIO, &mode );
#else
   int flags = fcntl( Socket->com, F_GETFL, 0 );
   if( flags != -1 )
   {
      flags &= ~O_NONBLOCK;
      fcntl( Socket->com, F_SETFL, ( long ) flags );
   }
#endif
}
hbinet.c416
STATIC INThb_socketConnect( HB_SOCKET_STRUCT *Socket )
static int hb_socketConnect( HB_SOCKET_STRUCT *Socket )
{
   int iErr1;
   #if ! defined(HB_OS_WIN_32)
      int iErrval;
      socklen_t iErrvalLen;
   #endif
   int iOpt = 1;

   hb_vmUnlock();

   setsockopt( Socket->com, SOL_SOCKET, SO_KEEPALIVE, (const char *) &iOpt , sizeof( iOpt ));

   /* we'll be using a nonblocking function */
   hb_socketSetNonBlocking( Socket );

   iErr1 = connect( Socket->com, (struct sockaddr *) &Socket->remote, sizeof(Socket->remote) );
   if( iErr1 != 0 )
   {
#if defined(HB_OS_WIN_32)
      if( WSAGetLastError() != WSAEWOULDBLOCK )
#else
      if( errno != EINPROGRESS )
#endif
      {
         HB_SOCKET_SET_ERROR( Socket );
      }
      else
      {
         /* Now we wait for socket connection or timeout */

#if defined(HB_OS_WIN_32)
         iErr1 = hb_selectWriteExceptSocket( Socket );
         if( iErr1 == 2 )
         {
            HB_SOCKET_SET_ERROR2( Socket, 2, "Connection failed" );
         }
         else if( iErr1 == 1 )
         {
            /* success */
         }
#else
         if( hb_selectWriteSocket( Socket ) )
         {
            /* Connection has been completed with a failure or a success */
            iErrvalLen = sizeof( iErrval );
            iErr1 = getsockopt( Socket->com,
               SOL_SOCKET,
               SO_ERROR,
               (void *) &iErrval,
               &iErrvalLen
            );

            if( iErr1 )
            {
               HB_SOCKET_SET_ERROR1( Socket, iErr1 );
            }
            else if( iErrval )
            {
               HB_SOCKET_SET_ERROR1( Socket, iErrval );
            }
            /* Success! */
         }
#endif
         /* Timed out */
         else
         {
            HB_SOCKET_SET_ERROR2( Socket, -1, "Timeout" );
         }
      }
   }

   hb_socketSetBlocking( Socket );

   hb_vmLock();

   return Socket->errorCode == 0;
}
hbinet.c433
STATIC HB_GARBAGE_FUNC(hb_inetSocketFinalize )
static HB_GARBAGE_FUNC( hb_inetSocketFinalize )
{
   HB_SOCKET_STRUCT *Socket = ( HB_SOCKET_STRUCT *) Cargo;

   if( Socket->com != ( HB_SOCKET_T ) -1 )
   {
      #if defined( HB_OS_WIN_32 )
         shutdown( Socket->com, SD_BOTH );
      #elif defined(HB_OS_OS2)
         shutdown( Socket->com, SO_RCV_SHUTDOWN + SO_SND_SHUTDOWN );
      #elif !defined(__WATCOMC__)
         shutdown( Socket->com, SHUT_RDWR );
      #endif

      HB_INET_CLOSE( Socket->com );
      Socket->com = ( HB_SOCKET_T ) -1;
   }

   if( Socket->caPeriodic )
   {
      hb_itemRelease( Socket->caPeriodic );
      Socket->caPeriodic = NULL;
   }
}
hbinet.c513
HB_FUNCHB_INETINIT(void)
HB_FUNC( HB_INETINIT )
{
   if( s_iSessions )
   {
      s_iSessions++;
   }
   else
   {
      #if defined(HB_OS_WIN_32)
         #define HB_MKWORD( l, h )  ((WORD)(((BYTE)(l)) | (((WORD)((BYTE)(h))) << 8)))
         WSADATA wsadata;
         WSAStartup( HB_MKWORD(1,1), &wsadata );
      #elif defined( HB_INET_LINUX_INTERRUPT )
         signal( HB_INET_LINUX_INTERRUPT, hb_inetLinuxSigusrHandle );
      #endif
      s_iSessions = 1;
   }
}
hbinet.c542
HB_FUNCHB_INETCLEANUP(void)
HB_FUNC( HB_INETCLEANUP )
{
   if( --s_iSessions == 0 )
   {
      #if defined(HB_OS_WIN_32)
         WSACleanup();
      #endif
   }
}
hbinet.c561
HB_FUNCHB_INETCREATE(void)
HB_FUNC( HB_INETCREATE )
{
   PHB_ITEM pSocket = NULL;
   HB_SOCKET_STRUCT *Socket;
   HB_SOCKET_INIT( Socket, pSocket );

   if( ISNUM( 1 ) )
      Socket->timeout = hb_parni(1);
   hb_itemReturnRelease( pSocket );
}
hbinet.c575
HB_FUNCHB_INETCLOSE(void)
HB_FUNC( HB_INETCLOSE )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else if( Socket->com != ( HB_SOCKET_T ) -1 )
   {
      hb_vmUnlock();

      #if defined( HB_OS_WIN_32 )
         shutdown( Socket->com, SD_BOTH );
      #elif defined(HB_OS_OS2)
         shutdown( Socket->com, SO_RCV_SHUTDOWN + SO_SND_SHUTDOWN );
      #elif !defined(__WATCOMC__)
         shutdown( Socket->com, SHUT_RDWR );
      #endif

      hb_retni( HB_INET_CLOSE( Socket->com ) );
      Socket->com = ( HB_SOCKET_T ) -1;

      #ifdef HB_INET_LINUX_INTERRUPT
         kill( 0, HB_INET_LINUX_INTERRUPT );
      #endif

      hb_vmLock();
   }
   else
      hb_retni( -1 );
}
hbinet.c586
HB_FUNCHB_INETFD(void)
HB_FUNC( HB_INETFD )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
   {
      hb_retnint( Socket->com );
      if( ISLOG( 2 ) && hb_parl( 2 ) )
         Socket->com = ( HB_SOCKET_T ) -1;
   }
}
hbinet.c617
HB_FUNCHB_INETSTATUS(void)
HB_FUNC( HB_INETSTATUS )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
      /* TODO: hb_retni( Socket->status ); */
      hb_retni( Socket->com == ( HB_SOCKET_T ) -1 ? -1 : 1 );
}
hbinet.c635
HB_FUNCHB_INETERRORCODE(void)
HB_FUNC( HB_INETERRORCODE )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
      hb_retni( Socket->errorCode );
}
hbinet.c667
HB_FUNCHB_INETERRORDESC(void)
HB_FUNC( HB_INETERRORDESC )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   hb_retc( Socket->errorDesc );
}
hbinet.c677
HB_FUNCHB_INETCLEARERROR(void)
HB_FUNC( HB_INETCLEARERROR )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
      HB_SOCKET_ZERO_ERROR( Socket );
}
hbinet.c690
HB_FUNCHB_INETCOUNT(void)
HB_FUNC( HB_INETCOUNT )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
      hb_retni( Socket->count );
}
hbinet.c701
HB_FUNCHB_INETADDRESS(void)
HB_FUNC( HB_INETADDRESS )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   char *addr;

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
   {
      addr = inet_ntoa( Socket->remote.sin_addr );
      hb_retc( addr );
   }
}
hbinet.c711
HB_FUNCHB_INETPORT(void)
HB_FUNC( HB_INETPORT )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
      hb_retni( ntohs( Socket->remote.sin_port ) );
}
hbinet.c725
HB_FUNCHB_INETTIMEOUT(void)
HB_FUNC( HB_INETTIMEOUT )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket )
   {
      hb_retni( Socket->timeout );
      if( ISNUM( 2 ) )
         Socket->timeout = hb_parni( 2 );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbinet.c736
HB_FUNCHB_INETCLEARTIMEOUT(void)
HB_FUNC( HB_INETCLEARTIMEOUT )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
      Socket->timeout = -1;
}
hbinet.c750
HB_FUNCHB_INETTIMELIMIT(void)
HB_FUNC( HB_INETTIMELIMIT )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
   {
      hb_retnl( Socket->timelimit );
      if( ISNUM( 2 ) )
         Socket->timelimit = hb_parnl(2);
   }
}
hbinet.c760
HB_FUNCHB_INETCLEARTIMELIMIT(void)
HB_FUNC( HB_INETCLEARTIMELIMIT )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
      Socket->timelimit = -1;
}
hbinet.c774
HB_FUNCHB_INETPERIODCALLBACK(void)
HB_FUNC( HB_INETPERIODCALLBACK )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   PHB_ITEM pExec = hb_param( 2, HB_IT_ARRAY | HB_IT_BLOCK | HB_IT_SYMBOL );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
   {
      if( Socket->caPeriodic )
         hb_itemReturn( Socket->caPeriodic );
      if( pExec )
      {
         if( Socket->caPeriodic )
            hb_itemRelease( Socket->caPeriodic );
         Socket->caPeriodic = hb_itemClone( pExec );
      }
   }
}
hbinet.c784
HB_FUNCHB_INETCLEARPERIODCALLBACK(void)
HB_FUNC( HB_INETCLEARPERIODCALLBACK )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else if( Socket->caPeriodic )
   {
      hb_itemRelease( Socket->caPeriodic );
      Socket->caPeriodic = NULL;
   }
}
hbinet.c804
HB_FUNCHB_INETGETSNDBUFSIZE(void)
HB_FUNC( HB_INETGETSNDBUFSIZE )
{
   HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else if( !hb_inetIsOpen( Socket ) )
      hb_retni( -1 );
   else
   {
      int value;
      socklen_t len = sizeof( value );
#if defined( HB_OS_WIN_32 )
      getsockopt( Socket->com, SOL_SOCKET, SO_SNDBUF, ( char * ) &value, &len );
#else
      getsockopt( Socket->com, SOL_SOCKET, SO_SNDBUF, ( void * ) &value, &len );
#endif
      hb_retni( value );
   }
}
hbinet.c817
HB_FUNCHB_INETGETRCVBUFSIZE(void)
HB_FUNC( HB_INETGETRCVBUFSIZE )
{
   HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else if( !hb_inetIsOpen( Socket ) )
      hb_retni( -1 );
   else
   {
      int value;
      socklen_t len = sizeof( value );
#if defined( HB_OS_WIN_32 )
      getsockopt( Socket->com, SOL_SOCKET, SO_RCVBUF, ( char * ) &value, &len );
#else
      getsockopt( Socket->com, SOL_SOCKET, SO_RCVBUF, ( void * ) &value, &len );
#endif
      hb_retni( value );
   }
}
hbinet.c838
HB_FUNCHB_INETSETSNDBUFSIZE(void)
HB_FUNC( HB_INETSETSNDBUFSIZE )
{
   HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else if( !hb_inetIsOpen( Socket ) )
      hb_retni( -1 );
   else
   {
      int value = hb_parni( 2 );
#if defined( HB_OS_WIN_32 )
      setsockopt( Socket->com, SOL_SOCKET, SO_SNDBUF, ( char * ) &value, sizeof( value ) );
#else
      setsockopt( Socket->com, SOL_SOCKET, SO_SNDBUF, ( void * ) &value, sizeof( value ) );
#endif
      hb_retni( value );
   }
}
hbinet.c859
HB_FUNCHB_INETSETRCVBUFSIZE(void)
HB_FUNC( HB_INETSETRCVBUFSIZE )
{
   HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 1 );

   if( Socket == NULL )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else if( !hb_inetIsOpen( Socket ) )
      hb_retni( -1 );
   else
   {
      int value = hb_parni( 2 );
#if defined( HB_OS_WIN_32 )
      setsockopt( Socket->com, SOL_SOCKET, SO_RCVBUF, ( char * ) &value, sizeof( value ) );
#else
      setsockopt( Socket->com, SOL_SOCKET, SO_RCVBUF, ( void * ) &value, sizeof( value ) );
#endif
      hb_retni( value );
   }
}
hbinet.c879
STATIC VOIDs_inetRecvInternal( int iMode )
static void s_inetRecvInternal( int iMode )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING );
   char *buffer;
   int iLen, iMaxLen, iReceived;
   int iTimeElapsed;

   if( Socket == NULL || pBuffer == NULL || !ISBYREF( 2 ) )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }
   else if( !hb_inetIsOpen( Socket ) )
   {
      hb_retni( 0 );
      return;
   }

   pBuffer = hb_itemUnShare( pBuffer );
   buffer = hb_itemGetCPtr( pBuffer );
   iLen = hb_itemGetCLen( pBuffer );

   if( ISNIL( 3 ) )
   {
      iMaxLen = iLen;
   }
   else
   {
      iMaxLen = hb_parni( 3 );
      if( iLen < iMaxLen )
         iMaxLen = iLen;
   }

   hb_vmUnlock();

   iReceived = 0;
   iTimeElapsed = 0;
   HB_SOCKET_ZERO_ERROR( Socket );

   do
   {
      if( hb_selectReadSocket( Socket ) )
      {
         iLen = recv( Socket->com, buffer + iReceived, iMaxLen - iReceived, MSG_NOSIGNAL );
         if( iLen > 0 )
            iReceived += iLen;

         /* Called from InetRecv()? */
         if( iMode == 0 )
            break;
      }
      else
      {
         /* timed out; let's see if we have to run a cb routine */
         iTimeElapsed += Socket->timeout;

         hb_vmLock();

         /* if we have a caPeriodic, timeLimit is our REAL timeout */
         if( Socket->caPeriodic )
         {
            hb_execFromArray( Socket->caPeriodic );

            /* do we continue? */
            if( ! hb_parl( -1 ) || hb_vmRequestQuery() != 0 ||
                ( Socket->timelimit != -1 && iTimeElapsed >= Socket->timelimit ) )
            {
               HB_SOCKET_SET_ERROR2( Socket, -1, "Timeout" );
               hb_retni( iReceived );
               return;
            }

            /* Declare success to continue loop */
            iLen = 1;
         }
         else /* the timeout has gone, and we have no recovery routine */
         {
            HB_SOCKET_SET_ERROR2( Socket, -1, "Timeout" );
            hb_retni( iReceived );
            return;
         }

         hb_vmUnlock();
      }
   }
   while( iReceived < iMaxLen && iLen > 0 );

   Socket->count = iReceived;

   hb_vmLock();

   if( iLen == 0 )
   {
      HB_SOCKET_SET_ERROR2( Socket, -2, "Connection closed" );
      hb_retni( iLen );
   }
   else if( iLen < 0 )
   {
      HB_SOCKET_SET_ERROR( Socket );
      hb_retni( iLen );
   }
   else
      hb_retni( iReceived );
}
hbinet.c905
HB_FUNCHB_INETRECV(void)
HB_FUNC( HB_INETRECV )
{
   s_inetRecvInternal( 0 );
}
hbinet.c1011
HB_FUNCHB_INETRECVALL(void)
HB_FUNC( HB_INETRECVALL )
{
   s_inetRecvInternal( 1 );
}
hbinet.c1017
STATIC VOIDs_inetRecvPattern( const char *szPattern )
static void s_inetRecvPattern( const char *szPattern )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   PHB_ITEM pResult     = hb_param( 2, HB_IT_BYREF );
   PHB_ITEM pMaxSize    = hb_param( 3, HB_IT_NUMERIC );
   PHB_ITEM pBufferSize = hb_param( 4, HB_IT_NUMERIC );

   char cChar = '\0';
   char * Buffer;
   int iAllocated, iBufferSize, iMax;
   int iLen = 0, iPatLen;
   int iPos = 0, iTimeElapsed;

   if( Socket == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }
   else if( !hb_inetIsOpen( Socket ) )
   {
      hb_retni( 0 );
      return;
   }

   if( pBufferSize )
   {
      iBufferSize = hb_itemGetNI( pBufferSize );
   }
   else
   {
      iBufferSize = 80;
   }

   if( pMaxSize )
   {
      iMax = hb_itemGetNI( pMaxSize );
   }
   else
   {
      iMax = 0;
   }

   hb_vmUnlock();

   HB_SOCKET_ZERO_ERROR( Socket );

   Buffer = (char *) hb_xgrab( iBufferSize );
   iAllocated = iBufferSize;
   iTimeElapsed = 0;
   iPatLen = ( int ) strlen( szPattern );

   do
   {
      if( iPos == iAllocated - 1 )
      {
         iAllocated += iBufferSize;
         Buffer = ( char * ) hb_xrealloc( Buffer, iAllocated );
      }

      if( hb_selectReadSocket( Socket ) )
         iLen = recv( Socket->com, &cChar, 1, MSG_NOSIGNAL );
      else
      {
         iTimeElapsed += Socket->timeout;

         if( Socket->caPeriodic )
         {
            BOOL fResult;

            hb_vmLock();
            hb_execFromArray( Socket->caPeriodic );
            fResult = hb_parl( -1 ) && hb_vmRequestQuery() == 0;
            hb_vmUnlock();

            /* do we continue? */
            if( fResult &&
                ( Socket->timelimit == -1 || iTimeElapsed < Socket->timelimit ) )
            {
               continue;
            }
         }

         /* this signals timeout */
         iLen = -2;
      }

      if( iLen > 0 )
      {
         Buffer[ iPos++ ] = cChar;
         /* verify endsequence recognition automata status */
         if( iPos >= iPatLen &&
             memcmp( Buffer + iPos - iPatLen, szPattern, iPatLen ) == 0 )
         {
            break;
         }
      }
      else
      {
         break;
      }
   }
   while( iMax == 0 || iPos < iMax );

   hb_vmLock();

   if( iLen <= 0 )
   {
      if( pResult )
      {
         hb_itemPutNI( pResult, iLen );
      }

      if( iLen == 0 )
      {
         HB_SOCKET_SET_ERROR2( Socket, -2, "Connection closed" );
      }
      else if( iLen == -2 )
      {
         HB_SOCKET_SET_ERROR2( Socket, -1, "Timeout" );
      }
      else
      {
         HB_SOCKET_SET_ERROR( Socket );
      }

      hb_xfree( (void *) Buffer );
   }
   else
   {
      if( iMax == 0 || iPos < iMax )
      {
         iPos -= iPatLen;
         Socket->count = iPos;

         if( pResult )
         {
            hb_itemPutNI( pResult, iPos );
         }

         hb_retclen_buffer( Buffer, iPos );
      }
      else
      {
         HB_SOCKET_SET_ERROR2( Socket, -3, "Buffer overrun" );

         if( pResult )
         {
            hb_itemPutNI( pResult, -2 );
         }

         hb_xfree( (void *) Buffer );
         hb_retc( NULL );
      }
   }
}
hbinet.c1023
HB_FUNCHB_INETRECVLINE(void)
HB_FUNC( HB_INETRECVLINE )
{
   s_inetRecvPattern( "\r\n" );
}
hbinet.c1179
HB_FUNCHB_INETRECVENDBLOCK(void)
HB_FUNC( HB_INETRECVENDBLOCK )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   PHB_ITEM pProto      = hb_param( 2, HB_IT_ARRAY | HB_IT_STRING );
   PHB_ITEM pResult     = hb_param( 3, HB_IT_BYREF );
   PHB_ITEM pMaxSize    = hb_param( 4, HB_IT_NUMERIC );
   PHB_ITEM pBufferSize = hb_param( 5, HB_IT_NUMERIC );

   char cChar = '\0';
   char * Buffer;
   char ** Proto;
   int iAllocated, iBufferSize, iMax;
   int iLen;
   int iPos = 0;
   int iPosProto;
   int iTimeElapsed = 0;
   int iprotos;
   int i;
   int *iprotosize;
   int ifindproto = 0;
   BOOL bProtoFound;


   if( Socket == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }
   else if( !hb_inetIsOpen( Socket ) )
   {
      if( pResult )
         hb_itemPutNI( pResult, -1 );
      hb_retc( NULL );
      return;
   }

   if( pProto )
   {
      if( HB_IS_ARRAY( pProto ) )
      {
         iprotos = (int) hb_arrayLen( pProto );
         if( iprotos <= 0 )
         {
            hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
            return;
         }

         Proto   = (char**) hb_xgrab( sizeof(char*) * iprotos );
         iprotosize = (int *) hb_xgrab( sizeof(int) * iprotos );

         for( i = 0; i < iprotos; i++ )
         {
            Proto[ i ]      = hb_arrayGetCPtr( pProto, i + 1 );
            iprotosize[ i ] = hb_arrayGetCLen( pProto, i + 1 );
         }
      }
      else
      {
         Proto         = (char**) hb_xgrab( sizeof(char*) );
         iprotosize    = (int *) hb_xgrab( sizeof(int) );
         Proto[0]      = hb_itemGetCPtr( pProto );
         iprotosize[0] = hb_itemGetCLen( pProto );
         iprotos       = 1;
      }
   }
   else
   {
      Proto         = (char**) hb_xgrab( sizeof(char*) );
      iprotosize    = (int *) hb_xgrab( sizeof(int) );
      Proto[0]      = (char *) "\r\n";
      iprotos       = 1;
      iprotosize[0] = 2;
   }

   iBufferSize = pBufferSize ? hb_itemGetNI( pBufferSize ) : 80;
   iMax = pMaxSize ? hb_itemGetNI( pMaxSize ) : 0;

   hb_vmUnlock();

   HB_SOCKET_ZERO_ERROR( Socket );

   Buffer = (char *) hb_xgrab( iBufferSize );
   iAllocated = iBufferSize;

   do
   {
      if( iPos == iAllocated - 1 )
      {
         iAllocated += iBufferSize;
         Buffer = ( char * ) hb_xrealloc( Buffer, iAllocated );
      }

      iLen = 0;

      if( hb_selectReadSocket( Socket ) )
      {
         iLen = recv( Socket->com, &cChar, 1, MSG_NOSIGNAL );
      }
      else
      {
         iTimeElapsed += Socket->timeout;
         if( Socket->caPeriodic )
         {
            BOOL fResult;

            hb_vmLock();
            hb_execFromArray( Socket->caPeriodic );
            fResult = hb_parl( -1 ) && hb_vmRequestQuery() == 0;
            hb_vmUnlock();

            if( fResult &&
                ( Socket->timelimit == -1 || iTimeElapsed < Socket->timelimit ) )
            {
               continue;
            }
         }

         iLen = -2;
      }

      if( iLen > 0 )
      {
         int protos;
         bProtoFound = 0;

         for( protos = 0; protos < iprotos; protos++ )
         {
            if( cChar == Proto[protos][iprotosize[protos] - 1] && iprotosize[protos] <= iPos )
            {
               bProtoFound = 1;
               for( iPosProto = 0; iPosProto < ( iprotosize[protos] - 1 ); iPosProto++ )
               {
                  if( Proto[protos][iPosProto] != Buffer[ ( iPos - iprotosize[protos] ) + iPosProto + 1 ] )
                  {
                     bProtoFound = 0;
                     break;
                  }
               }
               if(bProtoFound)
               {
                  ifindproto = protos;
                  break;
               }
            }
         }
         if( bProtoFound )
            break;

         Buffer[ iPos++ ] = cChar;
      }
      else
         break;
   }
   while( iMax == 0 || iPos < iMax );

   hb_vmLock();

   if( iLen <= 0 )
   {
      if( pResult )
      {
         hb_itemPutNI( pResult, iLen );
      }

      if( iLen == 0 )
      {
         HB_SOCKET_SET_ERROR2( Socket, -2, "Connection closed" );
      }
      else if( iLen == -2 )
      {
         HB_SOCKET_SET_ERROR2( Socket, -1, "Timeout" );
      }
      else
      {
         HB_SOCKET_SET_ERROR( Socket );
      }

      hb_xfree( ( void * ) Buffer );
      hb_retc( NULL );
   }
   else
   {
      if( iMax == 0 || iPos < iMax )
      {
         Socket->count = iPos;

         if( pResult )
         {
            hb_itemPutNI( pResult, iPos  - (iprotosize[ifindproto]-1) );
         }

         hb_retclen_buffer( Buffer, iPos  - (iprotosize[ifindproto]-1) );
      }
      else
      {
         HB_SOCKET_SET_ERROR2( Socket, -1, "Buffer overrun" );

         if( pResult )
         {
            hb_itemPutNI( pResult, -2 );
         }

         hb_xfree( (void *) Buffer );
         hb_retc( NULL );
      }
   }

   hb_xfree( Proto );
   hb_xfree( iprotosize );
}
hbinet.c1184
HB_FUNCHB_INETDATAREADY(void)
HB_FUNC( HB_INETDATAREADY )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   int iVal;
   fd_set rfds;
   struct timeval tv = {0,0};

   if( Socket == NULL || ( hb_pcount() > 1 && ! ISNUM( 2 ) ) )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }
   else if( !hb_inetIsOpen( Socket ) )
   {
      hb_retl( FALSE );
      return;
   }

   if( ISNUM( 1 ) )
   {
      iVal = hb_parni( 2 );
      tv.tv_sec = iVal / 1000;
      tv.tv_usec = (iVal % 1000) * 1000;
   }

   hb_vmUnlock();

   HB_SOCKET_ZERO_ERROR( Socket );

   FD_ZERO(&rfds);
   FD_SET(Socket->com, &rfds);

   iVal = select( Socket->com + 1, &rfds, NULL, NULL, &tv );
   /* Don't rely on the value of tv now! */

   if( iVal < 0 )
   {
      HB_SOCKET_SET_ERROR( Socket );
   }

   hb_vmLock();

   hb_retni( iVal );
}
hbinet.c1395
STATIC VOIDs_inetSendInternal( int iMode )
static void s_inetSendInternal( int iMode )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING );
   char *Buffer;
   int iLen, iSent, iSend;

   if( Socket == NULL || pBuffer == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }
   else if( !hb_inetIsOpen( Socket ) )
   {
      hb_retni( 0 );
      return;
   }

   Buffer = hb_itemGetCPtr( pBuffer );
   iSend = ( int ) hb_itemGetCLen( pBuffer );
   if( ISNUM( 3 ) )
   {
      iLen = hb_parni( 3 );
      if( iLen < iSend )
         iSend = iLen;
   }

   hb_vmUnlock();

   HB_SOCKET_ZERO_ERROR( Socket );

   iSent = 0;
   iLen = 0;
   while( iSent < iSend )
   {
      iLen = 0;
      if( hb_selectWriteSocket( Socket ) )
         iLen = send( Socket->com, Buffer + iSent, iSend - iSent, MSG_NOSIGNAL );

      if( iLen > 0 )
      {
         iSent += iLen;
      }
      else if( iLen == 0 )
      {
         HB_SOCKET_SET_ERROR2( Socket, -1 , "Timeout" );
         break;
      }
      else
      {
         HB_SOCKET_SET_ERROR( Socket );
         break;
      }
      if( iMode == 0 )
         break;
   }

   Socket->count = iSent;

   hb_vmLock();

   hb_retni( iLen > 0 ? iSent : -1 );
}
hbinet.c1441
HB_FUNCHB_INETSEND(void)
HB_FUNC( HB_INETSEND )
{
   s_inetSendInternal( 0 );
}
hbinet.c1505
HB_FUNCHB_INETSENDALL(void)
HB_FUNC( HB_INETSENDALL )
{
   s_inetSendInternal( 1 );
}
hbinet.c1510
HB_FUNCHB_INETGETHOSTS(void)
HB_FUNC( HB_INETGETHOSTS )
{
   char * szHost = hb_parc( 1 );
   struct hostent *Host;
   char ** cHosts;
   int iCount = 0;

   if( szHost == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   Host = hb_getHosts( szHost, NULL );
   if( Host )
   {
      cHosts = Host->h_addr_list;
      while( *cHosts )
      {
         iCount++;
         cHosts++;
      }
   }

   if( iCount == 0 )
      hb_reta( 0 );
   else
   {
      PHB_ITEM pHosts = hb_itemArrayNew( iCount );
      iCount = 0;
      cHosts = Host->h_addr_list;
      while( *cHosts )
      {
         hb_arraySetC( pHosts, ++iCount,
                       inet_ntoa( *( ( struct in_addr * ) * cHosts ) ) );
         cHosts++;
      }
      hb_itemReturnRelease( pHosts );
   }
}
hbinet.c1520
HB_FUNCHB_INETGETALIAS(void)
HB_FUNC( HB_INETGETALIAS )
{
   char * szHost = hb_parc( 1 );
   struct hostent *Host;
   char ** cHosts;
   int iCount = 0;

   if( szHost == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   Host = hb_getHosts( szHost, NULL );
   if( Host )
   {
      cHosts = Host->h_aliases;
      while( *cHosts )
      {
         iCount++;
         cHosts++;
      }
   }

   if( iCount == 0 )
      hb_reta( 0 );
   else
   {
      PHB_ITEM pHosts = hb_itemArrayNew( iCount );
      iCount = 0;
      cHosts = Host->h_aliases;
      while( *cHosts )
      {
         hb_arraySetC( pHosts, ++iCount,
                       inet_ntoa( *( ( struct in_addr * ) * cHosts ) ) );
         cHosts++;
      }
      hb_itemReturnRelease( pHosts );
   }
}
hbinet.c1562
HB_FUNCHB_INETSERVER(void)
HB_FUNC( HB_INETSERVER )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 2 );
   PHB_ITEM pSocket = NULL;
   char * szAddress;
   int iPort;
   int iOpt = 1;
   int iListen;

   /* Parameter error checking */
   if( ! ISNUM( 1 ) || ( Socket == NULL && !ISNIL( 2 ) ) )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   if( Socket )
      HB_SOCKET_ZERO_ERROR( Socket );
   else
      HB_SOCKET_INIT( Socket, pSocket );

   /* Creates comm socket */
#if defined(HB_OS_WIN_32)
   Socket->com = socket( AF_INET, SOCK_STREAM, 0 );
#else
   Socket->com = socket( PF_INET, SOCK_STREAM, 0 );
#endif

   if( Socket->com == ( HB_SOCKET_T ) -1 )
   {
      HB_SOCKET_SET_ERROR( Socket );
      if( pSocket )
         hb_itemReturnRelease( pSocket );
      else
         hb_itemReturn( hb_param( 2, HB_IT_ANY ) );
      return;
   }

   /* we'll be using only nonblocking sockets */
   /* hb_socketSetNonBlocking( Socket ); */

   /* Reusable socket; under unix, do not wait it is unused */
   setsockopt( Socket->com, SOL_SOCKET, SO_REUSEADDR, (const char *) &iOpt, sizeof( iOpt ) );

   iPort  = htons( hb_parni( 1 ) );

   Socket->remote.sin_family = AF_INET;
   Socket->remote.sin_port = iPort;

   szAddress = hb_parc( 2 );
   Socket->remote.sin_addr.s_addr = szAddress ? inet_addr( szAddress ) : INADDR_ANY;

   iListen = ISNUM( 3 ) ? hb_parni( 3 ) : 10;

   hb_vmUnlock();

   if( bind( Socket->com, (struct sockaddr *) &Socket->remote, sizeof(Socket->remote) ) )
   {
      HB_SOCKET_SET_ERROR( Socket );
      HB_INET_CLOSE( Socket->com );
      Socket->com = ( HB_SOCKET_T ) -1;
   }
   else if( listen( Socket->com, iListen ) )
   {
      HB_SOCKET_SET_ERROR( Socket );
      HB_INET_CLOSE( Socket->com );
      Socket->com = ( HB_SOCKET_T ) -1;
   }

   hb_vmLock();

   if( pSocket )
      hb_itemReturnRelease( pSocket );
   else
      hb_itemReturn( hb_param( 2, HB_IT_ANY ) );
}
hbinet.c1608
HB_FUNCHB_INETACCEPT(void)
HB_FUNC( HB_INETACCEPT )
{
#if !defined(EAGAIN)
#define EAGAIN -1
#endif
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   HB_SOCKET_STRUCT *NewSocket;
   HB_SOCKET_T incoming = 0;
   int iError = EAGAIN;
   struct sockaddr_in si_remote;
#if defined(_XOPEN_SOURCE_EXTENDED)
   socklen_t Len;
#elif defined(HB_OS_WIN_32)
   int Len;
#else
   unsigned int Len;
#endif

   if( Socket == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }
   else if( !hb_inetIsOpen( Socket ) )
   {
      return;
   }

   hb_vmUnlock();

   Len = sizeof( struct sockaddr_in );

   /*
   * Accept can (and should) be asynchronously stopped by closing the
   * accepting socket. this will make the wait to terminate, and the
   * calling program will be notivfied through the status of the
   * returned socket.
   */

   HB_SOCKET_ZERO_ERROR( Socket );

   /* Connection incoming */
   while( iError == EAGAIN )
   {
      if( hb_selectReadSocket( Socket ) )
      {
         /* On error (e.g. async connection closed) , com will be -1 and
            errno == 22 (invalid argument ) */
         incoming = accept( Socket->com, (struct sockaddr *) &si_remote, &Len );

         if( incoming == ( HB_SOCKET_T ) -1 )
         {
#if defined(HB_OS_WIN_32)
            iError = WSAGetLastError();
#else
            iError = errno;
#endif
         }
         else
            iError = 0;
      }
      /* Timeout expired */
      else
         iError = -1;
   }

   hb_vmLock();

   if( iError == -1 )
   {
      HB_SOCKET_SET_ERROR2( Socket, -1, "Timeout" );
   }
   else if( iError > 0 )
   {
      HB_SOCKET_SET_ERROR1( Socket, iError );
   }
   else
   {
      PHB_ITEM pSocket = NULL;
      /* we'll be using only nonblocking sockets */
      HB_SOCKET_INIT( NewSocket, pSocket );
      memcpy( &NewSocket->remote, &si_remote, Len );
      NewSocket->com = incoming;
      /* hb_socketSetNonBlocking( NewSocket ); */
      hb_itemReturnRelease( pSocket );
   }
}
hbinet.c1685
HB_FUNCHB_INETCONNECT(void)
HB_FUNC( HB_INETCONNECT )
{
   char * szHost = hb_parc( 1 );
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 3 );
   PHB_ITEM pSocket = NULL;
   struct hostent *Host;
   int iPort;

   if( szHost == NULL || !ISNUM( 2 ) || ( Socket == NULL && !ISNIL( 3 ) ) )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   if( Socket )
   {
      if( Socket->com != ( HB_SOCKET_T ) -1 )
      {
         HB_INET_CLOSE( Socket->com );
         Socket->com = ( HB_SOCKET_T ) -1;
      }
      HB_SOCKET_ZERO_ERROR( Socket );
   }
   else
      HB_SOCKET_INIT( Socket, pSocket );

   Host = hb_getHosts( szHost, Socket );

   /* error had been set by get hosts */

   if( Host )
   {
      /* Creates comm socket */
#if defined(HB_OS_WIN_32)
      Socket->com = socket( AF_INET, SOCK_STREAM, 0);
#else
      Socket->com = socket( PF_INET, SOCK_STREAM, 0);
#endif

      if( Socket->com == ( HB_SOCKET_T ) -1 )
      {
         HB_SOCKET_SET_ERROR( Socket );
      }
      else
      {
         iPort = htons( hb_parni( 2 ) );

         Socket->remote.sin_family = AF_INET;
         Socket->remote.sin_port= iPort;
         Socket->remote.sin_addr.s_addr = (*(UINT *)Host->h_addr_list[0]);

         hb_socketConnect( Socket );
      }
   }

   if( pSocket )
      hb_itemReturnRelease( pSocket );
   else
      hb_itemReturn( hb_param( 3, HB_IT_ANY ) );
}
hbinet.c1778
HB_FUNCHB_INETCONNECTIP(void)
HB_FUNC( HB_INETCONNECTIP )
{
   char * szHost = hb_parc( 1 );
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 3 );
   PHB_ITEM pSocket = NULL;
   int iPort = hb_parni( 2 );

   if( szHost == NULL || iPort == 0 || ( Socket == NULL && !ISNIL( 3 ) ) )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   if( Socket )
   {
      if( Socket->com != ( HB_SOCKET_T ) -1 )
      {
         HB_INET_CLOSE( Socket->com );
         Socket->com = ( HB_SOCKET_T ) -1;
      }
      HB_SOCKET_ZERO_ERROR( Socket );
   }
   else
   {
      HB_SOCKET_INIT( Socket, pSocket );
   }

   /* Creates comm socket */
#if defined(HB_OS_WIN_32)
   Socket->com = socket( AF_INET, SOCK_STREAM, 0);
#else
   Socket->com = socket( PF_INET, SOCK_STREAM, 0);
#endif

   if( Socket->com == ( HB_SOCKET_T ) -1 )
   {
      HB_SOCKET_SET_ERROR( Socket );
   }
   else
   {
      iPort = htons( iPort );

      Socket->remote.sin_family = AF_INET;
      Socket->remote.sin_port= iPort;
      Socket->remote.sin_addr.s_addr = inet_addr( szHost );

      hb_socketConnect( Socket );
   }

   if( pSocket )
      hb_itemReturnRelease( pSocket );
   else
      hb_itemReturn( hb_param( 3, HB_IT_ANY ) );
}
hbinet.c1840
HB_FUNCHB_INETDGRAMBIND(void)
HB_FUNC( HB_INETDGRAMBIND )
{
   HB_SOCKET_STRUCT *Socket;
   PHB_ITEM pSocket = NULL;
   int iPort = hb_parni(1);
   int iOpt = 1;
   char * szAddress;

   /* Parameter error checking */
   if( iPort == 0 || ( hb_pcount() > 3 && ! ISCHAR( 4 ) ) )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }

   HB_SOCKET_INIT( Socket, pSocket );

   /* Creates comm socket */
   #if defined(HB_OS_WIN_32)
      Socket->com = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
   #else
      Socket->com = socket( PF_INET, SOCK_DGRAM, 0 );
   #endif

   if( Socket->com == ( HB_SOCKET_T ) -1 )
   {
      HB_SOCKET_SET_ERROR( Socket );
      hb_itemReturnRelease( pSocket );
      return;
   }

   /* Reusable socket; under unix, do not wait it is unused */
   setsockopt( Socket->com, SOL_SOCKET, SO_REUSEADDR, (const char *) &iOpt, sizeof( iOpt ));

   /* Setting broadcast if needed. */
   if( hb_parl( 3 ) )
   {
      iOpt = 1;
      setsockopt( Socket->com, SOL_SOCKET, SO_BROADCAST, (const char *) &iOpt, sizeof( iOpt ));
   }

   /* Binding here */
   iPort = htons( iPort );

   Socket->remote.sin_family = AF_INET;
   Socket->remote.sin_port = iPort;

   szAddress = hb_parc( 2 );
   Socket->remote.sin_addr.s_addr = szAddress ? inet_addr( szAddress ) : INADDR_ANY;

   hb_vmUnlock();

   if( bind( Socket->com, (struct sockaddr *) &Socket->remote, sizeof(Socket->remote) ) )
   {
      HB_SOCKET_SET_ERROR( Socket );
      HB_INET_CLOSE( Socket->com );
      Socket->com = ( HB_SOCKET_T ) -1;
   }
   else if( hb_pcount() > 3 )
   {
      #ifndef IP_ADD_MEMBERSHIP
         #define IP_ADD_MEMBERSHIP  5     /* which header should this be in? */
      #endif

      /* this structure should be define in a header file.  The MS SDK indicates that */
      /* it is in Ws2tcpip.h but I'm not sure I know where it should go in xHb */
      struct ip_mreq
      {
         struct in_addr imr_multiaddr;  /* IP multicast address of group */
         struct in_addr imr_interface;  /* local IP address of interface */
      };

      struct ip_mreq mreq ;

      mreq.imr_multiaddr.s_addr = inet_addr( hb_parc( 4 ) ); /* HELLO_GROUP */
      mreq.imr_interface.s_addr = htonl( INADDR_ANY );

#ifndef IPPROTO_IP
      /*
       * some systems may not have this definitions, it should
       * be 0 what works with TCP/UDP sockets or explicitly set
       * to IPPROTO_TCP/IPPROTO_UDP
       */
#     define IPPROTO_IP 0
#endif

      if( setsockopt( Socket->com, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *) &mreq, sizeof( mreq ) ) < 0 )
      {
         HB_SOCKET_SET_ERROR( Socket );
      }
   }

   hb_vmLock();

   hb_itemReturnRelease( pSocket );
}
hbinet.c1899
HB_FUNCHB_INETDGRAM(void)
HB_FUNC( HB_INETDGRAM )
{
   HB_SOCKET_STRUCT *Socket;
   PHB_ITEM pSocket = NULL;
   int iOpt = 1;

   HB_SOCKET_INIT( Socket, pSocket );

   /* Creates comm socket */
   #if defined(HB_OS_WIN_32)
      Socket->com = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
   #else
      Socket->com = socket( PF_INET, SOCK_DGRAM, 0 );
   #endif

   if( Socket->com == ( HB_SOCKET_T ) -1 )
   {
      HB_SOCKET_SET_ERROR( Socket );
      hb_itemReturnRelease( pSocket );
      return;
   }

   /* Setting broadcast if needed. */
   if( hb_parl( 1 ) )
   {
      iOpt = 1;
      setsockopt( Socket->com, SOL_SOCKET, SO_BROADCAST, (const char *) &iOpt, sizeof( iOpt ));
   }
   /* we'll be using non blocking sockets in all functions */
   /* hb_socketSetNonBlocking( Socket ); */

   hb_itemReturnRelease( pSocket );
}
hbinet.c1996
HB_FUNCHB_INETDGRAMSEND(void)
HB_FUNC( HB_INETDGRAMSEND )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   char * szAddress = hb_parc( 2 );
   int iPort = hb_parni( 3 );
   PHB_ITEM pBuffer = hb_param( 4, HB_IT_STRING );
   int iLen;
   char *szBuffer ;

   if( Socket == NULL ||
       szAddress == NULL || iPort == 0 || pBuffer == NULL )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }
   else if( !hb_inetIsOpen( Socket ) )
   {
      Socket->count = 0;
      hb_retni( 0 );
      return;
   }

   Socket->remote.sin_family = AF_INET;
   Socket->remote.sin_port = htons( iPort );
   Socket->remote.sin_addr.s_addr = inet_addr( szAddress );
   szBuffer = hb_itemGetCPtr( pBuffer );

   iLen = ( int ) hb_itemGetCLen( pBuffer );
   if( ISNUM( 5 ) )
   {
      int iMaxLen = hb_parni( 5 );

      if( iMaxLen < iLen )
         iLen = iMaxLen;
   }

   hb_vmUnlock();

   HB_SOCKET_ZERO_ERROR( Socket );

   Socket->count = 0;
   if( hb_selectWriteSocket( Socket ) )
   {
      Socket->count = sendto( Socket->com, szBuffer, iLen, 0,
            (const struct sockaddr *) &Socket->remote, sizeof( Socket->remote ) );
   }

   hb_vmLock();

   hb_retni( Socket->count );

   if( Socket->count == 0 )
   {
      HB_SOCKET_SET_ERROR2( Socket, -1, "Timeout" );
   }
   else if( Socket->count < 0 )
   {
      Socket->count = 0;
      HB_SOCKET_SET_ERROR( Socket );
   }

}
hbinet.c2030
HB_FUNCHB_INETDGRAMRECV(void)
HB_FUNC( HB_INETDGRAMRECV )
{
   HB_SOCKET_STRUCT *Socket = HB_PARSOCKET( 1 );
   PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING );
   int iTimeElapsed = 0;
   int iLen, iMaxLen;
   char *Buffer;
   BOOL fRepeat;
#if defined(HB_OS_WIN_32)
   int iDtLen = sizeof( struct sockaddr );
#else
   socklen_t iDtLen = (socklen_t) sizeof( struct sockaddr );
#endif

   if( Socket == NULL || pBuffer == NULL || !ISBYREF( 2 ) )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }
   else if( !hb_inetIsOpen( Socket ) )
   {
      Socket->count = 0;
      hb_retni( -1 );
      return;
   }

   pBuffer = hb_itemUnShare( pBuffer );
   Buffer = hb_itemGetCPtr( pBuffer );

   if( ISNUM( 3 ) )
   {
      iMaxLen = hb_parni( 3 );
   }
   else
   {
      iMaxLen = ( int ) hb_itemGetCLen( pBuffer );
   }

   hb_vmUnlock();

   HB_SOCKET_ZERO_ERROR( Socket );

   do
   {
      fRepeat = FALSE;
      iLen = -2;
      if( hb_selectReadSocket( Socket ) )
      {
         iLen = recvfrom( Socket->com, Buffer, iMaxLen, 0,
               (struct sockaddr *) &Socket->remote, &iDtLen );
      }
      iTimeElapsed += Socket->timeout;
      if( Socket->caPeriodic )
      {
         hb_vmLock();
         hb_execFromArray( Socket->caPeriodic );
         /* do we continue? */
         fRepeat = hb_parl( -1 ) && hb_vmRequestQuery() == 0 &&
                   ( Socket->timelimit == -1 || iTimeElapsed < Socket->timelimit );
         hb_vmUnlock();
      }
   }
   while( fRepeat );

   if( iLen == -2 )
   {
      HB_SOCKET_SET_ERROR2( Socket, -1, "Timeout" );
      Socket->count = 0;
      iLen = -1;
   }
   else if( iLen == 0 )
   {
      HB_SOCKET_SET_ERROR2( Socket, -2, "Connection closed" );
      Socket->count = 0;
   }
   else if( iLen < 0 )
   {
      HB_SOCKET_SET_ERROR( Socket );
      Socket->count = 0;
   }
   else
   {
      Socket->count = iLen;
   }

   hb_vmLock();

   hb_retni( iLen );
}
hbinet.c2094
HB_FUNCHB_INETCRLF(void)
HB_FUNC( HB_INETCRLF )
{
   hb_retc( "\r\n" );
}
hbinet.c2189
HB_FUNCHB_INETISSOCKET(void)
HB_FUNC( HB_INETISSOCKET )
{
   hb_retl( HB_PARSOCKET( 1 ) != NULL );
}
hbinet.c2194
hbmd5.c
TypeFunctionSourceLine
STATIC VOIDhb_md5go( MD5_BUF * md5 )
static void hb_md5go( MD5_BUF * md5 )
{
   UINT32 X[ 16 ], A[ 4 ];
   BYTE * ptr;
   int i;

   /* copy accumulators first */
   memcpy( A, md5->accum, sizeof( A ) );

   /* fill buffer */
   for( i = 0, ptr = md5->buf; i < 16; i++, ptr += 4 )
      X[ i ] = HB_GET_LE_UINT32( ptr );

   /* process buffer */
   PF1( 0, 1, 2, 3,  0,  7,  0 );
   PF1( 3, 0, 1, 2,  1, 12,  1 );
   PF1( 2, 3, 0, 1,  2, 17,  2 );
   PF1( 1, 2, 3, 0,  3, 22,  3 );
   PF1( 0, 1, 2, 3,  4,  7,  4 );
   PF1( 3, 0, 1, 2,  5, 12,  5 );
   PF1( 2, 3, 0, 1,  6, 17,  6 );
   PF1( 1, 2, 3, 0,  7, 22,  7 );
   PF1( 0, 1, 2, 3,  8,  7,  8 );
   PF1( 3, 0, 1, 2,  9, 12,  9 );
   PF1( 2, 3, 0, 1, 10, 17, 10 );
   PF1( 1, 2, 3, 0, 11, 22, 11 );
   PF1( 0, 1, 2, 3, 12,  7, 12 );
   PF1( 3, 0, 1, 2, 13, 12, 13 );
   PF1( 2, 3, 0, 1, 14, 17, 14 );
   PF1( 1, 2, 3, 0, 15, 22, 15 );
   PF2( 0, 1, 2, 3,  1,  5, 16 );
   PF2( 3, 0, 1, 2,  6,  9, 17 );
   PF2( 2, 3, 0, 1, 11, 14, 18 );
   PF2( 1, 2, 3, 0,  0, 20, 19 );
   PF2( 0, 1, 2, 3,  5,  5, 20 );
   PF2( 3, 0, 1, 2, 10,  9, 21 );
   PF2( 2, 3, 0, 1, 15, 14, 22 );
   PF2( 1, 2, 3, 0,  4, 20, 23 );
   PF2( 0, 1, 2, 3,  9,  5, 24 );
   PF2( 3, 0, 1, 2, 14,  9, 25 );
   PF2( 2, 3, 0, 1,  3, 14, 26 );
   PF2( 1, 2, 3, 0,  8, 20, 27 );
   PF2( 0, 1, 2, 3, 13,  5, 28 );
   PF2( 3, 0, 1, 2,  2,  9, 29 );
   PF2( 2, 3, 0, 1,  7, 14, 30 );
   PF2( 1, 2, 3, 0, 12, 20, 31 );
   PF3( 0, 1, 2, 3,  5,  4, 32 );
   PF3( 3, 0, 1, 2,  8, 11, 33 );
   PF3( 2, 3, 0, 1, 11, 16, 34 );
   PF3( 1, 2, 3, 0, 14, 23, 35 );
   PF3( 0, 1, 2, 3,  1,  4, 36 );
   PF3( 3, 0, 1, 2,  4, 11, 37 );
   PF3( 2, 3, 0, 1,  7, 16, 38 );
   PF3( 1, 2, 3, 0, 10, 23, 39 );
   PF3( 0, 1, 2, 3, 13,  4, 40 );
   PF3( 3, 0, 1, 2,  0, 11, 41 );
   PF3( 2, 3, 0, 1,  3, 16, 42 );
   PF3( 1, 2, 3, 0,  6, 23, 43 );
   PF3( 0, 1, 2, 3,  9,  4, 44 );
   PF3( 3, 0, 1, 2, 12, 11, 45 );
   PF3( 2, 3, 0, 1, 15, 16, 46 );
   PF3( 1, 2, 3, 0,  2, 23, 47 );
   PF4( 0, 1, 2, 3,  0,  6, 48 );
   PF4( 3, 0, 1, 2,  7, 10, 49 );
   PF4( 2, 3, 0, 1, 14, 15, 50 );
   PF4( 1, 2, 3, 0,  5, 21, 51 );
   PF4( 0, 1, 2, 3, 12,  6, 52 );
   PF4( 3, 0, 1, 2,  3, 10, 53 );
   PF4( 2, 3, 0, 1, 10, 15, 54 );
   PF4( 1, 2, 3, 0,  1, 21, 55 );
   PF4( 0, 1, 2, 3,  8,  6, 56 );
   PF4( 3, 0, 1, 2, 15, 10, 57 );
   PF4( 2, 3, 0, 1,  6, 15, 58 );
   PF4( 1, 2, 3, 0, 13, 21, 59 );
   PF4( 0, 1, 2, 3,  4,  6, 60 );
   PF4( 3, 0, 1, 2, 11, 10, 61 );
   PF4( 2, 3, 0, 1,  2, 15, 62 );
   PF4( 1, 2, 3, 0,  9, 21, 63 );

   /* Update accumulators */
   md5->accum[ 0 ] += A[ 0 ];
   md5->accum[ 1 ] += A[ 1 ];
   md5->accum[ 2 ] += A[ 2 ];
   md5->accum[ 3 ] += A[ 3 ];
}
hbmd5.c158
STATIC VOIDhb_md5accinit( UINT32 accum[] )
static void hb_md5accinit( UINT32 accum[] )
{
   /* fill initial accumulator state */
   accum[ 0 ] = 0x67452301;
   accum[ 1 ] = 0xEFCDAB89;
   accum[ 2 ] = 0x98BADCFE;
   accum[ 3 ] = 0x10325476;
}
hbmd5.c244
STATIC VOIDhb_md5val( UINT32 accum[], BYTE * md5val )
static void hb_md5val( UINT32 accum[], BYTE * md5val )
{
   int i, n;

   for( i = 0; i < 4; i++ )
   {
      for( n = 0; n < 4; n++ )
         *md5val++ = ( BYTE ) ( ( accum[ i ] >> ( n << 3 ) ) & 0xFF );
   }
}
hbmd5.c253
STATIC VOIDhb_md5digest( BYTE * md5val, char * digest )
static void hb_md5digest( BYTE * md5val, char * digest )
{
   int i, b;

   for( i = 0; i < 16; i++ )
   {
      b = ( md5val[ i ] >> 4 ) & 0x0F;
      *digest++ = ( char ) ( b + ( b > 9 ? 'a' - 10 : '0' ) );
      b = md5val[ i ] & 0x0F;
      *digest++ = ( char ) ( b + ( b > 9 ? 'a' - 10 : '0' ) );
   }
}
hbmd5.c264
HB_EXPORT VOIDhb_md5( BYTE * ucData, ULONG ulLen, BYTE * ucDigest )
HB_EXPORT void hb_md5( BYTE * ucData, ULONG ulLen, BYTE * ucDigest )
{
   UCHAR buf[ 128 ];
   MD5_BUF md5;
   int i, n;

   /* perform startup procedures */
   hb_md5accinit( md5.accum );
   /* count full 512bit blocks in data*/
   n = ulLen >> 6;
   /* process full blocks */
   for( i = 0; i < n; i++, ucData += 64 )
   {
      memcpy( md5.buf, ucData, 64 );
      hb_md5go( &md5 );
   }
   /* prepare additional block(s) */
   n = ulLen & 63;
   if( n )
      memcpy( buf, ucData, n );
   memcpy( buf + n, pad, 64 );
   /* count bits length */
   i = 56;
   if( n >= 56 )
   {
      i += 64;
      memcpy( md5.buf, buf, 64 );
      hb_md5go( &md5 );
   }
   buf[ i++ ] = ( UCHAR ) ( ( ulLen << 3 ) & 0xF8 );
   ulLen >>= 5;
   for( n = 7; n; --n )
   {
      buf[ i++ ] = ( UCHAR ) ( ulLen & 0xFF );
      ulLen >>= 8;
   }
   memcpy( md5.buf, buf + i - 64, 64 );
   hb_md5go( &md5 );
   /* write digest */
   hb_md5val( md5.accum, ucDigest );
}
hbmd5.c277
HB_EXPORT VOIDhb_md5file( HB_FHANDLE hFile, BYTE * ucDigest )
HB_EXPORT void hb_md5file( HB_FHANDLE hFile, BYTE * ucDigest )
{
   MD5_BUF md5;
   ULONG n;
   int i;
   HB_FOFFSET flen = 0;
   UCHAR buf[ 128 ], * readbuf = ( UCHAR * ) hb_xgrab( MAX_FBUF );

   hb_md5accinit( md5.accum );
   n = hb_fsReadLarge( hFile, readbuf, MAX_FBUF );
   flen += n;
   while( n == MAX_FBUF )
   {
      for( i = 0; i < ( MAX_FBUF >> 6 ); i++ )
      {
         memcpy( md5.buf, readbuf + ( i << 6 ), 64 );
         hb_md5go( &md5 );
      }
      n = hb_fsReadLarge( hFile, readbuf, MAX_FBUF );
      flen += n;
   }
   hb_fsClose( hFile );
   i = 0;
   while( n > 64 )
   {
      memcpy( md5.buf, readbuf + i, 64 );
      hb_md5go( &md5 );
      i += 64;
      n -= 64;
   }
   if( n )
      memcpy( buf, readbuf + i, n );
   memcpy( buf + n, pad, 64 );
   i = 56;
   if( n >= 56 )
   {
      i += 64;
      memcpy( md5.buf, buf, 64 );
      hb_md5go( &md5 );
   }
   buf[ i++ ] = ( UCHAR ) ( ( flen << 3 ) & 0xF8 );
   flen >>= 5;
   for( n = 7; n; --n )
   {
      buf[ i++ ] = ( UCHAR ) ( flen & 0xFF );
      flen >>= 8;
   }
   memcpy( md5.buf, buf + i - 64, 64 );
   hb_md5go( &md5 );
   hb_md5val( md5.accum, ucDigest );
   hb_xfree( readbuf );
}
hbmd5.c319
HB_FUNCHB_MD5(void)
HB_FUNC( HB_MD5 )
{
   char * pszStr = hb_parc( 1 );

   if( pszStr )
   {
      ULONG ulLen = hb_parclen( 1 );
      BYTE dststr[ 16 ];
      char digest[ 33 ];

      hb_md5( ( BYTE * ) pszStr, ulLen, dststr );
      hb_md5digest( dststr, digest );
      hb_retclen( digest, 32 );
   }
   else
      hb_retc( NULL ); /* return empty string on wrong call */
}
hbmd5.c372
HB_FUNCHB_MD5FILE(void)
HB_FUNC( HB_MD5FILE )
{
   char * pszFile = hb_parc( 1 );

   if( pszFile )
   {
      HB_FHANDLE hFile = hb_fsOpen( ( BYTE * ) pszFile, FO_READ );

      if( hFile != FS_ERROR )
      {
         BYTE dststr[ 16 ];
         char digest[ 33 ];

         hb_md5file( hFile, dststr );
         hb_md5digest( dststr, digest );
         hb_retclen( digest, 32 );
         return;
      }
   }
   hb_retc( NULL ); /* return empty string on wrong call */
}
hbmd5.c390
hbrandom.c
TypeFunctionSourceLine
HB_FUNCHB_RANDOM(void)
HB_FUNC( HB_RANDOM )
{
   double dRnd = hb_random_num();

   if( ! ISNUM( 1 ) )
      hb_retnd( dRnd );
   else if( ! ISNUM( 2 ) )
      hb_retnd( dRnd * hb_parnd( 1 ) );
   else
   {
      double dX = hb_parnd( 2 );
      double dY = hb_parnd( 1 );
      if( dX > dY )
      {
         double dZ = dY;
         dY = dX;
         dX = dZ;
      }
      hb_retnd(  dRnd * ( dY - dX ) + dX );
   }
}
hbrandom.c64
HB_FUNCHB_RANDOMINT(void)
HB_FUNC( HB_RANDOMINT )
{
   double dRnd = hb_random_num();

   if( ! ISNUM( 1 ) )
      hb_retni( dRnd >= 0.5 ? 0 : 1 );
   else if( ! ISNUM( 2 ) )
      hb_retnint( ( HB_LONG ) ( 1 + ( dRnd * hb_parnint( 1 ) ) ) );
   else
   {
      HB_LONG lX = hb_parnint( 1 );
      HB_LONG lY = hb_parnint( 2 );
      if( lX > lY )
      {
         HB_LONG lZ = lY;
         lY = lX;
         lX = lZ;
      }
      hb_retnint( ( HB_LONG ) ( lX + ( dRnd * ( lY - lX + 1 ) ) ) );
   }
}
hbrandom.c93
HB_FUNCHB_RANDOMSEED(void)
HB_FUNC( HB_RANDOMSEED )
{
   srand( ISNUM( 1 ) ? ( unsigned ) hb_parni( 1 ) : ( unsigned ) hb_dateMilliSeconds() );
   s_fInit = TRUE;
}
hbrandom.c123
DOUBLEhb_random_num()
double hb_random_num()
{
   double d1, d2;

   if( !s_fInit )
   {
      srand( ( unsigned ) hb_dateMilliSeconds() );
      s_fInit = TRUE;
   }

   d1 = ( double ) rand();
   d2 = ( double ) RAND_MAX;
#if defined( HB_OS_WIN_32 )
   /* It seems that on win32 platform there some weirdness about EPSILON value so
      that a float division using an epsilon smaller than 1e-10 may be rounded.
      Must dig if it's a borland lib bug or a windows problem.
    */
   d2 += 0.001;
#else
   d2 += DBL_EPSILON;
#endif

   return d1 / d2;
}
hbrandom.c129
hbregex.c
TypeFunctionSourceLine
STATIC VOIDhb_regfree( PHB_REGEX pRegEx )
static void hb_regfree( PHB_REGEX pRegEx )
{
#if defined( HB_PCRE_REGEX )
   ( pcre_free )( pRegEx->re_pcre );
#elif defined( HB_POSIX_REGEX )
   regfree( &pRegEx->reg );
#else
   HB_SYMBOL_UNUSED( pRegEx );
#endif
}
hbregex.c61
STATIC INThb_regcomp( PHB_REGEX pRegEx, const char * szRegEx )
static int hb_regcomp( PHB_REGEX pRegEx, const char * szRegEx )
{
#if defined( HB_PCRE_REGEX )
   const unsigned char * pCharTable = NULL;
   const char *szError = NULL;
   int iErrOffset = 0;
   int iCFlags = ( ( pRegEx->iFlags & HBREG_ICASE   ) ? PCRE_CASELESS  : 0 ) |
                 ( ( pRegEx->iFlags & HBREG_NEWLINE ) ? PCRE_MULTILINE : 0 ) |
                 ( ( pRegEx->iFlags & HBREG_DOTALL  ) ? PCRE_DOTALL    : 0 );

   pRegEx->iEFlags = ( ( pRegEx->iFlags & HBREG_NOTBOL ) ? PCRE_NOTBOL : 0 ) |
                     ( ( pRegEx->iFlags & HBREG_NOTEOL ) ? PCRE_NOTEOL : 0 );

   pRegEx->re_pcre = pcre_compile( szRegEx, iCFlags, &szError,
                                   &iErrOffset, pCharTable );
   return pRegEx->re_pcre ? 0 : -1;
#elif defined( HB_POSIX_REGEX )
   int iCFlags = REG_EXTENDED |
                 ( ( pRegEx->iFlags & HBREG_ICASE   ) ? REG_ICASE   : 0 ) |
                 ( ( pRegEx->iFlags & HBREG_NEWLINE ) ? REG_NEWLINE : 0 ) |
                 ( ( pRegEx->iFlags & HBREG_NOSUB   ) ? REG_NOSUB   : 0 );
   pRegEx->iEFlags = ( ( pRegEx->iFlags & HBREG_NOTBOL ) ? REG_NOTBOL : 0 ) |
                     ( ( pRegEx->iFlags & HBREG_NOTEOL ) ? REG_NOTEOL : 0 );
   return regcomp( &pRegEx->reg, szRegEx, iCFlags );
#else
   HB_SYMBOL_UNUSED( pRegEx );
   HB_SYMBOL_UNUSED( szRegEx );
   return -1;
#endif
}
hbregex.c72
STATIC INThb_regexec( PHB_REGEX pRegEx, const char * szString, ULONG ulLen, int iMatches, HB_REGMATCH * aMatches )
static int hb_regexec( PHB_REGEX pRegEx, const char * szString, ULONG ulLen,
                       int iMatches, HB_REGMATCH * aMatches )
{
#if defined( HB_PCRE_REGEX )
   int iResult, i;

   iResult = pcre_exec( pRegEx->re_pcre, NULL /* pcre_extra */,
                        szString, ulLen, 0 /* startoffset */,
                        pRegEx->iEFlags, aMatches, HB_REGMATCH_SIZE( iMatches ) );
   if( iResult == 0 )
   {
      for( i = 0; i < iMatches; i++ )
      {
         if( HB_REGMATCH_EO( aMatches, i ) != -1 )
            iResult = i + 1;
      }
   }
   return iResult;
#elif defined( HB_POSIX_REGEX )
   char * szBuffer = NULL;
   int iResult, i;

   if( szString[ ulLen ] != 0 )
   {
      szBuffer = hb_strndup( szString, ulLen );
      szString = szBuffer;
   }
   for( i = 0; i < iMatches; i++ )
      HB_REGMATCH_EO( aMatches, i ) = -1;
   iResult = regexec( &pRegEx->reg, szString, iMatches, aMatches, pRegEx->iEFlags );
   if( iResult == 0 )
   {
      for( i = 0; i < iMatches; i++ )
      {
         if( HB_REGMATCH_EO( aMatches, i ) != -1 )
            iResult = i + 1;
      }
   }
   else
      iResult = -1;
   if( szBuffer )
      hb_xfree( szBuffer );
   return iResult;
#else
   HB_SYMBOL_UNUSED( pRegEx );
   HB_SYMBOL_UNUSED( szString );
   HB_SYMBOL_UNUSED( ulLen );
   HB_SYMBOL_UNUSED( iMatches );
   HB_SYMBOL_UNUSED( aMatches );
   return -1;
#endif
}
hbregex.c103
HB_FUNCHB_REGEXCOMP(void)
HB_FUNC( HB_REGEXCOMP )
{
   ULONG ulLen = hb_parclen( 1 );

   if( ulLen == 0 )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, "Wrong parameter count/type", 
                            HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   else
   {
      int iFlags = HBREG_EXTENDED;
      PHB_REGEX pRegEx;

      if( ISLOG( 2 ) && !hb_parl( 2 ) )
         iFlags |= HBREG_ICASE;
      if( hb_parl( 3 ) )
         iFlags |= HBREG_NEWLINE;

      pRegEx = hb_regexCompile( hb_parc( 1 ), ulLen, iFlags );
      if( pRegEx )
      {
         pRegEx->fFree = FALSE;
         hb_retptrGC( pRegEx );
         hb_gcUnlock( pRegEx );
      }
   }
}
hbregex.c157
HB_FUNCHB_ISREGEX(void)
HB_FUNC( HB_ISREGEX )
{
   hb_retl( hb_parptrGC( hb_regexRelease, 1 ) != NULL );
}
hbregex.c184
HB_FUNCHB_ATX(void)
HB_FUNC( HB_ATX )
{
   char * pszString;
   ULONG ulLen, ulStart, ulEnd;
   PHB_REGEX pRegEx;
   PHB_ITEM pString;
   int iPCount = hb_pcount();

   pString = hb_param( 2, HB_IT_STRING );
   if( !pString )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, "Wrong parameters",
                            HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return;
   }
   pszString = hb_itemGetCPtr( pString );
   ulLen     = hb_itemGetCLen( pString );
   pRegEx = hb_regexGet( hb_param( 1, HB_IT_ANY ),
                         ISLOG( 3 ) && !hb_parl( 3 ) ? HBREG_ICASE : 0 );
   if( !pRegEx )
      return;

   ulStart = hb_parnl( 4 );
   ulEnd = hb_parnl( 5 );

   if( ulLen && ulStart <= ulLen && ulStart <= ulEnd )
   {
      HB_REGMATCH aMatches[ HB_REGMATCH_SIZE( 1 ) ];

      if( ulEnd < ulLen )
         ulLen = ulEnd;
      if( ulStart )
      {
         --ulStart;
         ulLen -= ulStart;
      }
      if( hb_regexec( pRegEx, pszString + ulStart, ulLen, 1, aMatches ) > 0 )
      {
         ulStart += HB_REGMATCH_SO( aMatches, 0 ) + 1;
         ulLen = HB_REGMATCH_EO( aMatches, 0 ) - HB_REGMATCH_SO( aMatches, 0 );
         hb_retclen( pszString + ulStart - 1, ulLen );
      }
      else
         ulStart = ulLen = 0;
   }
   else
      ulStart = ulLen = 0;

   hb_regexFree( pRegEx );
   if( iPCount > 3 )
   {
      hb_stornl( ulStart, 4 );
      if( iPCount > 4 )
         hb_stornl( ulLen, 5 );
   }
}
hbregex.c189
STATIC BOOLhb_regex( int iRequest )
static BOOL hb_regex( int iRequest )
{
   HB_REGMATCH aMatches[ HB_REGMATCH_SIZE( REGEX_MAX_GROUPS ) ];
   PHB_ITEM pRetArray, pMatch, pString;
   int i, iMatches, iMaxMatch;
   BOOL fResult = FALSE;
   PHB_REGEX pRegEx;
   char * pszString;
   ULONG ulLen;

   pString = hb_param( 2, HB_IT_STRING );
   if( !pString )
   {
      hb_errRT_BASE_SubstR( EG_ARG, 3012, "Wrong parameters",
                            HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      return FALSE;
   }
   pRegEx = hb_regexGet( hb_param( 1, HB_IT_ANY ),
                         ( ISLOG( 3 ) && !hb_parl( 3 ) ? HBREG_ICASE : 0 ) |
                         ( hb_parl( 4 ) ? HBREG_NEWLINE : 0 ) );
   if( !pRegEx )
      return FALSE;

   pszString = hb_itemGetCPtr( pString );
   ulLen     = hb_itemGetCLen( pString );
   iMaxMatch = iRequest == 0 || iRequest == 4 || iRequest == 5 ?
               REGEX_MAX_GROUPS : 1;
   iMatches = hb_regexec( pRegEx, pszString, ulLen, iMaxMatch, aMatches );
   if( iMatches > 0 )
   {
      switch( iRequest )
      {
         case 0:
            pRetArray = hb_itemArrayNew( iMatches );
            for( i = 0; i < iMatches; i++ )
            {
               if( HB_REGMATCH_EO( aMatches, i ) > -1 )
                  hb_arraySetCL( pRetArray, i + 1,
                                 pszString + HB_REGMATCH_SO( aMatches, i ),
                                 HB_REGMATCH_EO( aMatches, i ) -
                                 HB_REGMATCH_SO( aMatches, i ) );
               else
                  hb_arraySetCL( pRetArray, i + 1, "", 0 );
            }
            hb_itemReturnRelease( pRetArray );
            fResult = TRUE;
            break;

         case 1: /* LIKE */
            fResult = HB_REGMATCH_SO( aMatches, 0 ) == 0 &&
                      ( ULONG ) HB_REGMATCH_EO( aMatches, 0 ) == ulLen;
            break;

         case 2: /* MATCH ( HAS ) */
            fResult = TRUE;
            break;

         case 3: /* SPLIT */
            iMaxMatch = hb_parni( 5 );
            pRetArray = hb_itemArrayNew( 0 );
            pMatch = hb_itemNew( NULL );
            iMatches = 0;
            do
            {
               hb_itemPutCL( pMatch, pszString, HB_REGMATCH_SO( aMatches, 0 ) );
               hb_arrayAddForward( pRetArray, pMatch );
               ulLen -= HB_REGMATCH_EO( aMatches, 0 );
               pszString += HB_REGMATCH_EO( aMatches, 0 );
               iMatches++;
            }
            while( HB_REGMATCH_EO( aMatches, 0 ) > 0 && ulLen &&
                   ( iMaxMatch == 0 || iMatches < iMaxMatch ) &&
                   hb_regexec( pRegEx, pszString, ulLen, 1, aMatches ) > 0 );

            /* last match must be done also in case that pszString is empty;
               this would mean an empty split field at the end of the string */
            /* if( ulLen ) */
            {
               hb_itemPutCL( pMatch, pszString, ulLen );
               hb_arrayAddForward( pRetArray, pMatch );
            }
            hb_itemRelease( pMatch );

            hb_itemReturnRelease( pRetArray );
            fResult = TRUE;
            break;

         case 4: /* results AND positions */
            pRetArray = hb_itemArrayNew( iMatches );

            for( i = 0; i < iMatches; i++ )
            {
               int iSO = HB_REGMATCH_SO( aMatches, i ),
                   iEO = HB_REGMATCH_EO( aMatches, i );
               pMatch = hb_arrayGetItemPtr( pRetArray, i + 1 );
               hb_arrayNew( pMatch, 3 );
               if( iEO != -1 )
               {
                  /* matched string */
                  hb_arraySetCL( pMatch, 1, pszString + iSO, iEO - iSO );
                  /* begin of match */
                  hb_arraySetNI( pMatch, 2, iSO + 1 );
                  /* End of match */
                  hb_arraySetNI( pMatch, 3, iEO );
               }
               else
               {
                  hb_arraySetCL( pMatch, 1, "", 0 );
                  hb_arraySetNI( pMatch, 2, 0 );
                  hb_arraySetNI( pMatch, 3, 0 );
               }
            }
            hb_itemReturnRelease( pRetArray );
            fResult = TRUE;
            break;

         case 5: /* _ALL_ results AND positions */
         {
            PHB_ITEM pAtxArray;
            int   iMax       = hb_parni( 5 );   /* max nuber of matches I want, 0 = unlimited */
            int   iGetMatch  = hb_parni( 6 );   /* Gets if want only one single match or a sub-match */
            BOOL  fOnlyMatch = !ISLOG( 7 ) || hb_parl( 7 ); /* if TRUE returns only matches and sub-matches, not positions */
            ULONG ulOffSet   = 0;
            int   iCount     = 0;
            int   iSO, iEO;

            /* Set new array */
            pRetArray = hb_itemArrayNew( 0 );
            do
            {
               /* If I want all matches */
               if( iGetMatch == 0 || /* Check boundaries */
                   ( iGetMatch < 0 || iGetMatch > iMatches ) )
               {
                  pAtxArray = hb_itemArrayNew( iMatches );
                  for( i = 0; i < iMatches; i++ )
                  {
                     iSO = HB_REGMATCH_SO( aMatches, i );
                     iEO = HB_REGMATCH_EO( aMatches, i );
                     pMatch = hb_arrayGetItemPtr( pAtxArray, i + 1 );
                     if( !fOnlyMatch )
                     {
                        hb_arrayNew( pMatch, 3 );
                        if( iEO != -1 )
                        {
                           /* matched string */
                           hb_arraySetCL( pMatch, 1, pszString + iSO, iEO - iSO );
                           /* begin of match */
                           hb_arraySetNI( pMatch, 2, ulOffSet + iSO + 1 );
                           /* End of match */
                           hb_arraySetNI( pMatch, 3, ulOffSet + iEO );
                        }
                        else
                        {
                           hb_arraySetCL( pMatch, 1, "", 0 );
                           hb_arraySetNI( pMatch, 2, 0 );
                           hb_arraySetNI( pMatch, 3, 0 );
                        }
                     }
                     else
                     {
                        if( iEO != -1 )
                           /* matched string */
                           hb_itemPutCL( pMatch, pszString + iSO, iEO - iSO );
                        else
                           hb_itemPutC( pMatch, NULL );
                     }
                  }
                  hb_arrayAddForward( pRetArray, pAtxArray );
                  hb_itemRelease( pAtxArray );
               }
               else /* Here I get only single matches */
               {
                  i = iGetMatch - 1;
                  iSO = HB_REGMATCH_SO( aMatches, i );
                  iEO = HB_REGMATCH_EO( aMatches, i );
                  pMatch = hb_itemNew( NULL );
                  if( !fOnlyMatch )
                  {
                     hb_arrayNew( pMatch, 3 );
                     if( iEO != -1 )
                     {
                        /* matched string */
                        hb_arraySetCL( pMatch, 1, pszString + iSO, iEO - iSO );
                        /* begin of match */
                        hb_arraySetNI( pMatch, 2, ulOffSet + iSO + 1 );
                        /* End of match */
                        hb_arraySetNI( pMatch, 3, ulOffSet + iEO );
                     }
                     else
                     {
                        hb_arraySetCL( pMatch, 1, "", 0 );
                        hb_arraySetNI( pMatch, 2, 0 );
                        hb_arraySetNI( pMatch, 3, 0 );
                     }
                  }
                  else
                  {
                     if( iEO != -1 )
                        /* matched string */
                        hb_itemPutCL( pMatch, pszString + iSO, iEO - iSO );
                     else
                        hb_itemPutC( pMatch, NULL );
                  }
                  hb_arrayAddForward( pRetArray, pMatch );
                  hb_itemRelease( pMatch );
               }

               iEO = HB_REGMATCH_EO( aMatches, 0 );
               if( iEO == -1 )
                  break;
               ulLen -= iEO;
               pszString += iEO;
               ulOffSet += iEO;
               iCount++;
            }
            while( iEO && ulLen && ( iMax == 0 || iCount < iMax ) &&
                   ( iMatches = hb_regexec( pRegEx, pszString, ulLen, iMaxMatch, aMatches ) ) > 0 );
            hb_itemReturnRelease( pRetArray );
            fResult = TRUE;
            break;
         }
      }
   }
   else if( iRequest == 3 )
   {
      pRetArray = hb_itemArrayNew( 1 );
      hb_arraySet( pRetArray, 1, pString );
      hb_itemReturnRelease( pRetArray );
      fResult = TRUE;
   }

   hb_regexFree( pRegEx );
   return fResult;
}
hbregex.c246
HB_FUNCHB_REGEX(void)
HB_FUNC( HB_REGEX )
{
   hb_regex( 0 );
}
hbregex.c482
HB_FUNCHB_REGEXMATCH(void)
HB_FUNC( HB_REGEXMATCH )
{
   hb_retl( hb_regex( hb_parl( 3 ) ? 1 /* LIKE */ : 2 /* HAS */ ) );
}
hbregex.c488
HB_FUNCHB_REGEXLIKE(void)
HB_FUNC( HB_REGEXLIKE )
{
   hb_retl( hb_regex( 1 ) );
}
hbregex.c494
HB_FUNCHB_REGEXHAS(void)
HB_FUNC( HB_REGEXHAS )
{
   hb_retl( hb_regex( 2 ) );
}
hbregex.c499
HB_FUNCHB_REGEXSPLIT(void)
HB_FUNC( HB_REGEXSPLIT )
{
   hb_regex( 3 );
}
hbregex.c504
HB_FUNCHB_REGEXATX(void)
HB_FUNC( HB_REGEXATX )
{
   hb_regex( 4 );
}
hbregex.c510
HB_FUNCHB_REGEXALL(void)
HB_FUNC( HB_REGEXALL )
{
   hb_regex( 5 );
}
hbregex.c532
STATIC VOID *hb_pcre_grab( size_t size )
static void * hb_pcre_grab( size_t size )
{
   return hb_xgrab( size );
}
#endif

HB_CALL_ON_STARTUP_BEGIN( _hb_regex_init_ )
#if defined( HB_PCRE_REGEX )
   /* Hack to force linking newer PCRE versions not the one included in BCC RTL */
#  if defined( __BORLANDC__ )
   {
      int iUTF8Enabled;
      pcre_config( PCRE_CONFIG_UTF8, &iUTF8Enabled );
   }
#  endif
   pcre_malloc = hb_pcre_grab;
   pcre_free = hb_xfree;
   pcre_stack_malloc = hb_pcre_grab;
   pcre_stack_free = hb_xfree;
#endif
   hb_regexInit( hb_regfree, hb_regcomp, hb_regexec );
HB_CALL_ON_STARTUP_END( _hb_regex_init_ )

#if defined( HB_PRAGMA_STARTUP )
   #pragma startup _hb_regex_init_
#elif defined( HB_MSC_STARTUP )
   #if defined( HB_OS_WIN_64 )
      #pragma section( HB_MSC_START_SEGMENT, long, read )
   #endif
   #pragma data_seg( HB_MSC_START_SEGMENT )
   static HB_$INITSYM hb_vm_auto_regex_init_ = _hb_regex_init_;
hbregex.c538
hbregexc.c
TypeFunctionSourceLine
STATIC VOIDhb_regfree( PHB_REGEX pRegEx )
static void hb_regfree( PHB_REGEX pRegEx )
{
   HB_SYMBOL_UNUSED( pRegEx );
}
hbregexc.c60
STATIC INThb_regcomp( PHB_REGEX pRegEx, const char * szRegEx )
static int hb_regcomp( PHB_REGEX pRegEx, const char * szRegEx )
{
   HB_SYMBOL_UNUSED( pRegEx );
   HB_SYMBOL_UNUSED( szRegEx );
   return -1;
}
hbregexc.c65
STATIC INThb_regexec( PHB_REGEX pRegEx, const char * szString, ULONG ulLen, int iMatches, HB_REGMATCH * aMatches )
static int hb_regexec( PHB_REGEX pRegEx, const char * szString, ULONG ulLen,
                       int iMatches, HB_REGMATCH * aMatches )
{
   HB_SYMBOL_UNUSED( pRegEx );
   HB_SYMBOL_UNUSED( szString );
   HB_SYMBOL_UNUSED( ulLen );
   HB_SYMBOL_UNUSED( iMatches );
   HB_SYMBOL_UNUSED( aMatches );
   return -1;
}

static HB_REG_FREE s_reg_free = hb_regfree;
static HB_REG_COMP s_reg_comp = hb_regcomp;
static HB_REG_EXEC s_reg_exec = hb_regexec;
hbregexc.c72
VOIDhb_regexInit( HB_REG_FREE pFree, HB_REG_COMP pComp, HB_REG_EXEC pExec )
void hb_regexInit( HB_REG_FREE pFree, HB_REG_COMP pComp, HB_REG_EXEC pExec )
{
   s_reg_free = pFree;
   s_reg_comp = pComp;
   s_reg_exec = pExec;
}
hbregexc.c87
HB_GARBAGE_FUNC(hb_regexRelease )
HB_GARBAGE_FUNC( hb_regexRelease )
{
   ( s_reg_free )( ( PHB_REGEX ) Cargo );
}
hbregexc.c94
PHB_REGEXhb_regexCompile( const char *szRegEx, ULONG ulLen, int iFlags )
PHB_REGEX hb_regexCompile( const char *szRegEx, ULONG ulLen, int iFlags )
{
   PHB_REGEX pRegEx;

   HB_SYMBOL_UNUSED( ulLen );

   pRegEx = ( PHB_REGEX ) hb_gcAlloc( sizeof( HB_REGEX ), hb_regexRelease );
   hb_gcLock( pRegEx );
   memset( pRegEx, 0, sizeof( HB_REGEX ) );
   pRegEx->fFree = TRUE;
   pRegEx->iFlags = iFlags;

   if( ( s_reg_comp )( pRegEx, szRegEx ) != 0 )
   {
      hb_gcFree( pRegEx );
      pRegEx = NULL;
   }

   return pRegEx;
}
hbregexc.c100
PHB_REGEXhb_regexGet( PHB_ITEM pRegExItm, int iFlags )
PHB_REGEX hb_regexGet( PHB_ITEM pRegExItm, int iFlags )
{
   PHB_REGEX pRegEx = NULL;

   if( pRegExItm )
   {
      if( HB_IS_POINTER( pRegExItm ) )
      {
         pRegEx = ( PHB_REGEX ) hb_itemGetPtrGC( pRegExItm, hb_regexRelease );
      }
      else if( HB_IS_STRING( pRegExItm ) )
      {
         ULONG ulLen = hb_itemGetCLen( pRegExItm );
         char * szRegEx = hb_itemGetCPtr( pRegExItm );
         if( ulLen > 0 )
            pRegEx = hb_regexCompile( szRegEx, ulLen, iFlags );
      }
   }

   if( !pRegEx )
      hb_errRT_BASE_SubstR( EG_ARG, 3012, "Invalid Regular expression", HB_ERR_FUNCNAME, 1, pRegExItm );

   return pRegEx;
}
hbregexc.c121
VOIDhb_regexFree( PHB_REGEX pRegEx )
void      hb_regexFree( PHB_REGEX pRegEx )
{
   if( pRegEx && pRegEx->fFree )
   {
      ( s_reg_free )( pRegEx );
      hb_gcFree( pRegEx );
   }
}
hbregexc.c146
BOOLhb_regexMatch( PHB_REGEX pRegEx, const char *szString, ULONG ulLen, BOOL fFull )
BOOL      hb_regexMatch( PHB_REGEX pRegEx, const char *szString, ULONG ulLen, BOOL fFull )
{
   HB_REGMATCH aMatches[ HB_REGMATCH_SIZE( 1 ) ];
   BOOL fMatch;

   fMatch = ( s_reg_exec )( pRegEx, szString, ulLen, 1, aMatches ) > 0;
   return fMatch && ( !fFull ||
            ( HB_REGMATCH_SO( aMatches, 0 ) == 0 &&
              HB_REGMATCH_EO( aMatches, 0 ) == ( int ) ulLen ) );
}
hbregexc.c155
hbrunfun.c
TypeFunctionSourceLine
HB_FUNCHB_RUN(void)
HB_FUNC( HB_RUN )
{
   char * szCommand = hb_parc( 1 );

   if( szCommand )
   {
      int iResult = -1;

      if( hb_gtSuspend() == SUCCESS )
      {
         iResult = system( szCommand );
         hb_gtResume();
      }
      hb_retni( iResult );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbrunfun.c57
hbstrsh.c
TypeFunctionSourceLine
HB_FUNCHB_STRSHRINK(void)
HB_FUNC( HB_STRSHRINK )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText )
   {
      long lLen = hb_itemGetCLen( pText );
      long lShrinkBy = ISNUM( 2 ) ? hb_parnl( 2 ) : 1;

      if( lShrinkBy > 0 )
      {
         if( lShrinkBy < lLen )
            lLen -= lShrinkBy;
         else
            lLen = 0;
      }

      hb_retclen( hb_itemGetCPtr( pText ), lLen );
   }
   else
      hb_retc( NULL );
}
hbstrsh.c56
hbtoken.c
TypeFunctionSourceLine
STATIC ULONGhb_tokenCount( const char * szLine, ULONG ulLen, const char * szDelim, ULONG ulDelim, BOOL fSkipStrings, BOOL fDoubleQuoteOnly )
static ULONG hb_tokenCount( const char * szLine, ULONG ulLen,
                            const char * szDelim, ULONG ulDelim,
                            BOOL fSkipStrings, BOOL fDoubleQuoteOnly )
{
   ULONG ul = 0, ulTokens = 1;
   char cQuote = 0;

   while( ul < ulLen )
   {
      if( cQuote )
      {
         if( szLine[ ul ] == cQuote )
            cQuote = 0;
      }
      else if( fSkipStrings && ( szLine[ ul ] == '"' ||
               ( !fDoubleQuoteOnly && szLine[ ul ] == '\'' ) ) )
         cQuote = szLine[ ul ];
      else if( szLine[ ul ] == szDelim[ 0 ] &&
               ( ulDelim == 1 || !memcmp( szLine + ul, szDelim, ulDelim ) ) )
      {
         ++ulTokens;
         if( ulDelim == 1 && *szDelim == ' ' )
         {
            while( ul + 1 < ulLen && szLine[ ul + 1 ] == ' ' )
               ++ul;
         }
         ul += ulDelim - 1;
      }
      ++ul;
   }

   return ulTokens;
}
hbtoken.c57
STATIC CONST CHAR *hb_tokenGet( const char * szLine, ULONG ulLen, const char * szDelim, ULONG ulDelim, BOOL fSkipStrings, BOOL fDoubleQuoteOnly, ULONG ulToken, ULONG * pulLen )
static const char * hb_tokenGet( const char * szLine, ULONG ulLen,
                                 const char * szDelim, ULONG ulDelim,
                                 BOOL fSkipStrings, BOOL fDoubleQuoteOnly,
                                 ULONG ulToken, ULONG * pulLen )
{
   ULONG ul, ulStart;
   char cQuote = 0;
   
   for( ul = ulStart = 0; ul < ulLen; ++ul )
   {
      if( cQuote )
      {
         if( szLine[ ul ] == cQuote )
            cQuote = 0;
      }
      else if( fSkipStrings && ( szLine[ ul ] == '"' ||
               ( !fDoubleQuoteOnly && szLine[ ul ] == '\'' ) ) )
         cQuote = szLine[ ul ];
      else if( szLine[ ul ] == szDelim[ 0 ] &&
               ( ulDelim == 1 || !memcmp( szLine + ul, szDelim, ulDelim ) ) )
      {
         if( --ulToken == 0 )
         {
            * pulLen = ul - ulStart;
            return szLine + ulStart;
         }
         if( ulDelim == 1 && *szDelim == ' ' )
         {
            while( ul + 1 < ulLen && szLine[ ul + 1 ] == ' ' )
               ++ul;
         }
         ulStart = ul + ulDelim;
      }
   }
   if( --ulToken == 0 )
   {
      * pulLen = ul - ulStart;
      return szLine + ulStart;
   }
   * pulLen = 0;
   return NULL;
}
hbtoken.c91
STATIC PHB_ITEMhb_tokenArray( const char * szLine, ULONG ulLen, const char * szDelim, ULONG ulDelim, BOOL fSkipStrings, BOOL fDoubleQuoteOnly )
static PHB_ITEM hb_tokenArray( const char * szLine, ULONG ulLen,
                               const char * szDelim, ULONG ulDelim,
                               BOOL fSkipStrings, BOOL fDoubleQuoteOnly )
{
   ULONG ulTokens = hb_tokenCount( szLine, ulLen, szDelim, ulDelim,
                                   fSkipStrings, fDoubleQuoteOnly );
   PHB_ITEM pArray = hb_itemArrayNew( ulTokens );

   if( ulTokens )
   {
      ULONG ul, ulStart, ulToken;
      char cQuote = 0;
      
      for( ul = ulStart = ulToken = 0; ul < ulLen; ++ul )
      {
         if( cQuote )
         {
            if( szLine[ ul ] == cQuote )
               cQuote = 0;
         }
         else if( fSkipStrings && ( szLine[ ul ] == '"' ||
                  ( !fDoubleQuoteOnly && szLine[ ul ] == '\'' ) ) )
            cQuote = szLine[ ul ];
         else if( szLine[ ul ] == szDelim[ 0 ] &&
                  ( ulDelim == 1 || !memcmp( szLine + ul, szDelim, ulDelim ) ) )
         {
            hb_arraySetCL( pArray, ++ulToken, szLine + ulStart, ul - ulStart );
            if( ulDelim == 1 && *szDelim == ' ' )
            {
               while( ul + 1 < ulLen && szLine[ ul + 1 ] == ' ' )
                  ++ul;
            }
            ulStart = ul + ulDelim;
         }
      }
      hb_arraySetCL( pArray, ++ulToken, szLine + ulStart, ul - ulStart );
   }

   return pArray;
}
hbtoken.c134
STATIC VOIDhb_tokenParam( int iDelim, ULONG ulSkip, const char ** pszLine, ULONG * pulLen, const char ** pszDelim, ULONG * pulDelim )
static void hb_tokenParam( int iDelim, ULONG ulSkip,
                           const char ** pszLine, ULONG * pulLen,
                           const char ** pszDelim, ULONG * pulDelim )
{
   const char * szLine = hb_parc( 1 ), * szDelim = NULL;
   ULONG ulLen = hb_parclen( 1 ), ulDelim = 0;

   if( ulLen )
   {
      if( ulSkip )
      {
         szLine += ulSkip;
         if( ulLen <= ulSkip )
            ulLen = 0;
         else
            ulLen -= ulSkip;
      }

      ulDelim = hb_parclen( iDelim );
      if( ulDelim )
         szDelim = hb_parc( iDelim );
      else
      {
         szDelim = " ";
         ulDelim = 1;
      }

      if( ulDelim == 1 && *szDelim == ' ' )
      {
         while( ulLen && * szLine == ' ' )
         {
            ++szLine;
            --ulLen;
         }
         while( ulLen && szLine[ ulLen - 1 ] == ' ' )
            --ulLen;
      }
   }

   *pulLen = ulLen;
   *pulDelim = ulDelim;
   *pszLine = szLine;
   *pszDelim = szDelim;
}
hbtoken.c175
HB_FUNCHB_TOKENCOUNT(void)
HB_FUNC( HB_TOKENCOUNT )
{
   const char * szLine, * szDelim;
   ULONG ulLen, ulDelim;

   hb_tokenParam( 2, 0, &szLine, &ulLen, &szDelim, &ulDelim );

   if( szLine )
      hb_retnint( hb_tokenCount( szLine, ulLen, szDelim, ulDelim,
                                 hb_parl( 3 ), hb_parl( 4 ) ) );
   else
      hb_retni( 0 );
}
hbtoken.c220
HB_FUNCHB_TOKENGET(void)
HB_FUNC( HB_TOKENGET )
{
   const char * szLine, * szDelim;
   ULONG ulLen, ulDelim;

   hb_tokenParam( 3, 0, &szLine, &ulLen, &szDelim, &ulDelim );

   if( szLine )
   {
      szLine = hb_tokenGet( szLine, ulLen, szDelim, ulDelim,
                            hb_parl( 4 ), hb_parl( 5 ),
                            hb_parnl( 2 ), &ulLen );
      hb_retclen( szLine, ulLen );
   }
   else
      hb_retc( NULL );
}
hbtoken.c234
HB_FUNCHB_TOKENPTR(void)
HB_FUNC( HB_TOKENPTR )
{
   const char * szLine, * szDelim, * szToken;
   ULONG ulLen, ulDelim, ulSkip, ulToken;

   hb_tokenParam( 3, hb_parnl( 2 ), &szLine, &ulLen, &szDelim, &ulDelim );

   if( szLine )
   {
      szToken = hb_tokenGet( szLine, ulLen, szDelim, ulDelim,
                             hb_parl( 4 ), hb_parl( 5 ),
                             1, &ulToken );
      if( szToken && ulLen > ulToken )
         ulSkip = szToken - hb_parc( 1 ) + ulToken + ulDelim;
      else
         ulSkip = hb_parclen( 1 ) + 1;

      /* return position to start next search from */
      hb_stornl( ulSkip, 2 );
      /* return token */
      hb_retclen( szToken, ulToken );
   }
   else
      hb_retc( NULL );
}
hbtoken.c252
HB_FUNCHB_ATOKENS(void)
HB_FUNC( HB_ATOKENS )
{
   const char * szLine, * szDelim;
   ULONG ulLen, ulDelim;

   hb_tokenParam( 2, 0, &szLine, &ulLen, &szDelim, &ulDelim );

   if( szLine )
      hb_itemReturnRelease( hb_tokenArray( szLine, ulLen, szDelim, ulDelim,
                                           hb_parl( 3 ), hb_parl( 4 ) ) );
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1123, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbtoken.c282
HB_FUNC__STRTOKEN(void)
HB_FUNC( __STRTOKEN )
{
   HB_FUNC_EXEC( HB_TOKENGET );
}
hbtoken.c296
HB_FUNC__STRTKPTR(void)
HB_FUNC( __STRTKPTR )
{
   HB_FUNC_EXEC( HB_TOKENPTR );
}
hbtoken.c301
HB_FUNC__STRTOKENCOUNT(void)
HB_FUNC( __STRTOKENCOUNT )
{
   HB_FUNC_EXEC( HB_TOKENCOUNT );
}
hbtoken.c306
hbzlib.c
TypeFunctionSourceLine
STATIC ULONGhb_zlibUncompressedSize( const char * szSrc, ULONG ulLen )
static ULONG hb_zlibUncompressedSize( const char * szSrc, ULONG ulLen )
{
   Byte buffer[ 1024 ];
   z_stream stream;
   ULONG ulDest = 0;

   memset( &stream, 0, sizeof( z_stream ) );

   stream.next_in   = ( Bytef * ) szSrc;
   stream.avail_in  = ( uInt ) ulLen;
/*
   stream.zalloc    = Z_NULL;
   stream.zfree     = Z_NULL;
   stream.opaque    = NULL;
*/
   if( inflateInit( &stream ) == Z_OK )
   {
      int iStatus;
      do
      {
         stream.next_out  = buffer;
         stream.avail_out = sizeof( buffer );
         iStatus = inflate( &stream, Z_NO_FLUSH );
      }
      while( iStatus == Z_OK );
      if( iStatus == Z_STREAM_END )
         ulDest = stream.total_out;
      inflateEnd( &stream );
   }

   return ulDest;
}
hbzlib.c58
HB_FUNCHB_ZLIBVERSION(void)
HB_FUNC( HB_ZLIBVERSION )
{
   if( hb_parni( 1 ) == 1 )
      hb_retc( ZLIB_VERSION );
   else
      hb_retc( zlibVersion() );
}
hbzlib.c91
HB_FUNCHB_ZCOMPRESSBOUND(void)
HB_FUNC( HB_ZCOMPRESSBOUND )
{
   if( ISCHAR( 1 ) )
      hb_retnint( compressBound( hb_parclen( 1 ) ) );
   else if( ISNUM( 1 ) )
      hb_retnint( compressBound( ( uLong ) hb_parnint( 1 ) ) );
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c102
HB_FUNCHB_ZUNCOMPRESSLEN(void)
HB_FUNC( HB_ZUNCOMPRESSLEN )
{
   ULONG ulLen = hb_parclen( 1 );

   hb_retnint( ulLen ? hb_zlibUncompressedSize( hb_parc( 1 ), ulLen ) : 0 );
}
hbzlib.c115
HB_FUNCHB_ZCOMPRESS(void)
HB_FUNC( HB_ZCOMPRESS )
{
   char * szData = hb_parc( 1 );
   if( szData )
   {
      ULONG ulLen = hb_parclen( 1 );

      if( ulLen )
      {
         PHB_ITEM pBuffer = ISBYREF( 2 ) ? hb_param( 2, HB_IT_STRING ) : NULL;
         uLong ulDstLen;
         char * pDest;
         int iResult;

         if( pBuffer )
         {
            pBuffer = hb_itemUnShareString( pBuffer );
            ulDstLen = hb_itemGetCLen( pBuffer );
            pDest = hb_itemGetCPtr( pBuffer );
         }
         else
         {
            ulDstLen = ISNUM( 2 ) ? ( uLong ) hb_parnint( 2 ) :
                                    compressBound( ulLen );
            pDest = ( char * ) hb_xalloc( ulDstLen + 1 );
         }

         if( pDest )
         {
            if( ISNUM( 4 ) )
               iResult = compress2( ( Bytef * ) pDest, &ulDstLen, ( Bytef * ) szData, ulLen, hb_parni( 4 ) );
            else
               iResult = compress( ( Bytef * ) pDest, &ulDstLen, ( Bytef * ) szData, ulLen );

            if( !pBuffer )
            {
               if( iResult == Z_OK )
                  hb_retclen_buffer( pDest, ulDstLen );
               else
                  hb_xfree( pDest );
            }
            else if( iResult == Z_OK )
               hb_retclen( pDest, ulDstLen );
         }
         else
            iResult = Z_MEM_ERROR;

         hb_storni( iResult, 3 );
      }
      else
      {
         hb_retc( NULL );
         hb_storni( Z_OK, 3 );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c125
HB_FUNCHB_ZUNCOMPRESS(void)
HB_FUNC( HB_ZUNCOMPRESS )
{
   PHB_ITEM pBuffer = ISBYREF( 2 ) ? hb_param( 2, HB_IT_STRING ) : NULL;
   char * szData = hb_parc( 1 );

   if( szData )
   {
      ULONG ulLen = hb_parclen( 1 );

      if( ulLen )
      {
         uLong ulDstLen;
         char * pDest;
         int iResult;

         if( pBuffer )
         {
            pBuffer = hb_itemUnShareString( pBuffer );
            ulDstLen = hb_itemGetCLen( pBuffer );
            pDest = hb_itemGetCPtr( pBuffer );
         }
         else
         {
            ulDstLen = ISNUM( 2 ) ? ( uLong ) hb_parnint( 2 ) :
                                    hb_zlibUncompressedSize( szData, ulLen );
            pDest = ( char * ) hb_xalloc( ulDstLen + 1 );
         }

         if( pDest )
         {
            iResult = uncompress( ( Bytef * ) pDest, &ulDstLen, ( Bytef * ) szData, ulLen );

            if( !pBuffer )
            {
               if( iResult == Z_OK )
                  hb_retclen_buffer( pDest, ulDstLen );
               else
                  hb_xfree( pDest );
            }
            else if( iResult == Z_OK )
               hb_retclen( pDest, ulDstLen );
         }
         else
            iResult = Z_MEM_ERROR;

         hb_storni( iResult, 3 );
      }
      else
      {
         hb_retc( NULL );
         hb_storni( Z_OK, 3 );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c188
STATIC HB_GARBAGE_FUNC(hb_gz_Destructor )
static HB_GARBAGE_FUNC( hb_gz_Destructor )
{
   gzFile * gz = ( gzFile * ) Cargo;
   if( * gz )
   {
      gzclose( * gz );
      * gz = NULL;
   }
}
hbzlib.c250
STATIC GZFILEhb_gzParam( int iParam )
static gzFile hb_gzParam( int iParam )
{
   gzFile * gzHolder = ( gzFile * ) hb_parptrGC( hb_gz_Destructor, iParam );

   if( gzHolder && * gzHolder )
      return * gzHolder;

   hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   return NULL;
}
hbzlib.c261
HB_FUNCHB_GZOPEN(void)
HB_FUNC( HB_GZOPEN )
{
   char * cFile = hb_parc( 1 ), * cMode = hb_parc( 2 );
   if( cFile && cMode )
   {
      gzFile gz = gzopen( cFile, cMode );
      if( gz )
      {
         gzFile * gzHolder = ( gzFile * ) hb_gcAlloc( sizeof( gzFile ),
                                                      hb_gz_Destructor );
         * gzHolder = gz;
         hb_retptrGC( gzHolder );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c272
HB_FUNCHB_GZDOPEN(void)
HB_FUNC( HB_GZDOPEN )
{
   char * cMode = hb_parc( 2 );
   if( ISNUM( 1 ) && cMode )
   {
      gzFile gz = gzdopen( hb_parni( 1 ), cMode );
      if( gz )
      {
         gzFile * gzHolder = ( gzFile * ) hb_gcAlloc( sizeof( gzFile ),
                                                      hb_gz_Destructor );
         * gzHolder = gz;
         hb_retptrGC( gzHolder );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c293
HB_FUNCHB_GZCLOSE(void)
HB_FUNC( HB_GZCLOSE )
{
   gzFile * gzHolder = ( gzFile * ) hb_parptrGC( hb_gz_Destructor, 1 );

   if( gzHolder )
   {
      gzFile gz = * gzHolder;
      * gzHolder = NULL;
      hb_retni( gzclose( gz ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c314
HB_FUNCHB_GZSETPARAMS(void)
HB_FUNC( HB_GZSETPARAMS )
{
   if( ISNUM( 2 ) && ISNUM( 3 ) )
   {
      gzFile gz = hb_gzParam( 1 );
      if( gz )
         hb_retni( gzsetparams( gz, hb_parni( 2 ), hb_parni( 3 ) ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c331
HB_FUNCHB_GZREAD(void)
HB_FUNC( HB_GZREAD )
{
   PHB_ITEM pBuffer = ISBYREF( 2 ) ? hb_param( 2, HB_IT_STRING ) : NULL;

   if( pBuffer )
   {
      gzFile gz = hb_gzParam( 1 );
      if( gz )
      {
         pBuffer = hb_itemUnShareString( pBuffer );
         hb_retni( gzread( gz, hb_itemGetCPtr( pBuffer ), ISNUM( 3 ) ?
                     ( ULONG ) hb_parnl( 3 ) : hb_itemGetCLen( pBuffer ) ) );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c346
HB_FUNCHB_GZWRITE(void)
HB_FUNC( HB_GZWRITE )
{
   char * szData = hb_parc( 2 );
   if( szData )
   {
      gzFile gz = hb_gzParam( 1 );
      if( gz )
         hb_retni( gzwrite( gz, szData, ISNUM( 3 ) ?
                            ( ULONG ) hb_parnl( 3 ) : hb_parclen( 2 ) ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c367
HB_FUNCHB_GZGETS(void)
HB_FUNC( HB_GZGETS )
{
   int iLen = hb_parni( 2 );
   if( iLen > 0 )
   {
      gzFile gz = hb_gzParam( 1 );
      if( gz )
      {
         char * szBuffer = ( char * ) hb_xalloc( iLen + 1 );

         if( szBuffer )
         {
            if( gzgets( gz, szBuffer, iLen ) != Z_NULL )
               hb_retc_buffer( szBuffer );
            else
               hb_xfree( szBuffer );
         }
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c384
HB_FUNCHB_GZPUTS(void)
HB_FUNC( HB_GZPUTS )
{
   char * szData = hb_parc( 2 );
   if( szData )
   {
      gzFile gz = hb_gzParam( 1 );
      if( gz )
         hb_retni( gzputs( gz, szData ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c410
HB_FUNCHB_GZGETC(void)
HB_FUNC( HB_GZGETC )
{
   gzFile gz = hb_gzParam( 1 );
   if( gz )
      hb_retni( gzgetc( gz ) );
}
hbzlib.c426
HB_FUNCHB_GZUNGETC(void)
HB_FUNC( HB_GZUNGETC )
{
   if( ISNUM( 1 ) )
   {
      gzFile gz = hb_gzParam( 2 );
      if( gz )
         hb_retni( gzungetc( hb_parni( 1 ), gz ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c436
HB_FUNCHB_GZFLUSH(void)
HB_FUNC( HB_GZFLUSH )
{
   gzFile gz = hb_gzParam( 1 );
   if( gz )
      hb_retni( gzflush( gz, ISNUM( 2 ) ? hb_parni( 2 ) : Z_SYNC_FLUSH ) );
}
hbzlib.c451
HB_FUNCHB_GZSEEK(void)
HB_FUNC( HB_GZSEEK )
{
   if( ISNUM( 2 ) )
   {
      gzFile gz = hb_gzParam( 1 );
      if( gz )
         hb_retnint( gzseek( gz, ( z_off_t ) hb_parnint( 2 ), ISNUM( 3 ) ?
                             hb_parni( 3 ) : SEEK_SET ) );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
hbzlib.c461
HB_FUNCHB_GZREWIND(void)
HB_FUNC( HB_GZREWIND )
{
   gzFile gz = hb_gzParam( 1 );
   if( gz )
      hb_retni( gzrewind( gz ) );
}
hbzlib.c477
HB_FUNCHB_GZTELL(void)
HB_FUNC( HB_GZTELL )
{
   gzFile gz = hb_gzParam( 1 );
   if( gz )
      hb_retnint( gztell( gz ) );
}
hbzlib.c487
HB_FUNCHB_GZEOF(void)
HB_FUNC( HB_GZEOF )
{
   gzFile gz = hb_gzParam( 1 );
   if( gz )
      hb_retl( gzeof( gz ) != 0 );
}
hbzlib.c497
HB_FUNCHB_GZDIRECT(void)
HB_FUNC( HB_GZDIRECT )
{
   gzFile gz = hb_gzParam( 1 );
   if( gz )
      hb_retl( gzdirect( gz ) != 0 );
}
hbzlib.c508
HB_FUNCHB_GZERROR(void)
HB_FUNC( HB_GZERROR )
{
   gzFile gz = hb_gzParam( 1 );
   if( gz )
   {
      int iErrNum = 0;

      hb_retc( gzerror( gz, &iErrNum ) );
      hb_storni( iErrNum, 2 );
   }
}
hbzlib.c519
HB_FUNCHB_GZCLEARERR(void)
HB_FUNC( HB_GZCLEARERR )
{
   gzFile gz = hb_gzParam( 1 );
   if( gz )
      gzclearerr( gz );
}
hbzlib.c534
idle.c
TypeFunctionSourceLine
STATIC VOIDhb_idleDataRelease( void * Cargo )
static void hb_idleDataRelease( void * Cargo )
{
   PHB_IDLEDATA pIdleData = ( PHB_IDLEDATA ) Cargo;

   if( pIdleData->pIdleTasks )
   {
      do
      {
         hb_itemRelease( pIdleData->pIdleTasks[ --pIdleData->iIdleMaxTask ] );
      }
      while( pIdleData->iIdleMaxTask );
      hb_xfree( pIdleData->pIdleTasks );
   }
}

static HB_TSD_NEW( s_idleData, sizeof( HB_IDLEDATA ), NULL, hb_idleDataRelease );
idle.c96
VOIDhb_releaseCPU( void )
void hb_releaseCPU( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_releaseCPU()"));

   hb_vmUnlock();

   /* TODO: Add code to release time slices on all platforms */

#if defined(HB_OS_WIN_32) || defined(__CYGWIN__)
   /* Forfeit the remainder of the current time slice. */
   Sleep( 20 );

#elif defined(HB_OS_OS2)
   /* 23/nov/2000 - maurilio.longo@libero.it
      Minimum time slice under OS/2 is 32 milliseconds, passed 1 will be rounded to 32 and
      will give a chance to threads of lower priority to get executed.
      Passing 0 causes current thread to give up its time slice only if there are threads of
      equal priority waiting to be dispatched. Note: certain versions of OS/2 kernel have a
      bug which causes DosSleep(0) not to work as expected.  */
   DosSleep( 1 ); /* Duration is in milliseconds */

#elif defined(HB_OS_DOS)

   /* NOTE: there is a bug under NT 4 and 2000 -  if the app is running
      in protected mode, time slices will _not_ be released - you must switch
      to real mode first, execute the following, and switch back.

      It just occurred to me that this is actually by design.  Since MS doesn't
      want you to do this from a console app, their solution was to not allow
      the call to work in protected mode - screw the rest of the planet .

      returns zero on failure. (means not supported)
   */

   {
      union REGS regs;

      regs.h.ah = 2;
      regs.HB_XREGS.ax = 0x1680;

      HB_DOS_INT86( 0x2F, ®s, ®s );
   }
#elif defined(HB_OS_UNIX)
   {
      struct timeval tv;
      tv.tv_sec = 0;
      tv.tv_usec = 1000;
      select( 0, NULL, NULL, NULL, &tv );
   }

   /* the code below is simpler but seems that some Linux kernels
    * (f.e. from  Centos 5.1) have problems with nanosleep()
    * so it was replaced by above code
    */

   /*
   {
      static const struct timespec nanosecs = { 0, 1000000 };
      nanosleep( &nanosecs, NULL );
   }
   */
#else

   /* Do nothing */

#endif

   hb_vmLock();
}
idle.c113
VOIDhb_idleState( void )
void hb_idleState( void )
{
   PHB_IDLEDATA pIdleData = ( PHB_IDLEDATA ) hb_stackGetTSD( &s_idleData );

   if( ! pIdleData->fIamIdle )
   {
      pIdleData->fIamIdle = TRUE;

      hb_releaseCPU();
      if( hb_vmRequestQuery() == 0 )
      {
         if( pIdleData->fCollectGarbage )
         {
            hb_gcCollectAll( FALSE );
            pIdleData->fCollectGarbage = FALSE;
         }

         if( pIdleData->pIdleTasks && pIdleData->iIdleTask < pIdleData->iIdleMaxTask )
         {
            hb_itemRelease( hb_itemDo( pIdleData->pIdleTasks[ pIdleData->iIdleTask ], 0 ) );
            ++pIdleData->iIdleTask;
            if( pIdleData->iIdleTask == pIdleData->iIdleMaxTask && hb_setGetIdleRepeat() )
            {
               pIdleData->iIdleTask = 0;    /* restart processing of idle tasks */
               pIdleData->fCollectGarbage = TRUE;
            }
         }
         pIdleData->fIamIdle = FALSE;
      }
   }
}
idle.c183
VOIDhb_idleReset( void )
void hb_idleReset( void )
{
   PHB_IDLEDATA pIdleData = ( PHB_IDLEDATA ) hb_stackGetTSD( &s_idleData );

   if( pIdleData->iIdleTask == pIdleData->iIdleMaxTask && !hb_setGetIdleRepeat() )
   {
      pIdleData->iIdleTask = 0;
   }

   pIdleData->fCollectGarbage = TRUE;
}
idle.c216
VOIDhb_idleSleep( double dSeconds )
void hb_idleSleep( double dSeconds )
{
   if( dSeconds >= 0 )
   {
      HB_ULONG end_timer = hb_dateMilliSeconds() + ( HB_ULONG ) ( dSeconds * 1000 );

      while( hb_dateMilliSeconds() < end_timer && hb_vmRequestQuery() == 0 )
         hb_idleState();

      hb_idleReset();
   }
}
idle.c228
HB_FUNCHB_IDLESTATE(void)
HB_FUNC( HB_IDLESTATE )
{
   PHB_IDLEDATA pIdleData = ( PHB_IDLEDATA ) hb_stackGetTSD( &s_idleData );
   pIdleData->fCollectGarbage = TRUE;
   hb_idleState();
}
idle.c241
HB_FUNCHB_IDLERESET(void)
HB_FUNC( HB_IDLERESET )
{
   hb_idleReset();
}
idle.c249
HB_FUNCHB_IDLESLEEP(void)
HB_FUNC( HB_IDLESLEEP )
{
   hb_idleSleep( hb_parnd( 1 ) );
}
idle.c255
HB_FUNCHB_IDLEADD(void)
HB_FUNC( HB_IDLEADD )
{
   HB_ITEM_PTR pBlock = hb_param( 1, HB_IT_BLOCK );

   if( pBlock )
   {
      PHB_IDLEDATA pIdleData = ( PHB_IDLEDATA ) hb_stackGetTSD( &s_idleData );

      ++pIdleData->iIdleMaxTask;
      if( !pIdleData->pIdleTasks )
      {
         pIdleData->pIdleTasks = ( HB_ITEM_PTR * ) hb_xgrab( sizeof( HB_ITEM_PTR ) );
      }
      else
      {
         pIdleData->pIdleTasks = ( HB_ITEM_PTR * ) hb_xrealloc( pIdleData->pIdleTasks, sizeof( HB_ITEM_PTR ) * pIdleData->iIdleMaxTask );
      }
      /* store a copy of passed codeblock
      */
      pIdleData->pIdleTasks[ pIdleData->iIdleMaxTask - 1 ] = hb_itemNew( pBlock );

      /* return a pointer as a handle to this idle task
      */
      hb_retptr( ( void * ) hb_codeblockId( pBlock ) );    /* TODO: access to pointers from harbour code */
   }
}
idle.c261
HB_FUNCHB_IDLEDEL(void)
HB_FUNC( HB_IDLEDEL )
{
   PHB_IDLEDATA pIdleData = ( PHB_IDLEDATA ) hb_stackTestTSD( &s_idleData );
   void * pID = hb_parptr( 1 );

   if( pID && pIdleData && pIdleData->pIdleTasks )
   {
      SHORT iTask;
      HB_ITEM_PTR pItem;

      iTask = 0;
      while( iTask < pIdleData->iIdleMaxTask )
      {
         pItem = pIdleData->pIdleTasks[ iTask ];
         if( pID == hb_codeblockId( pItem ) )
         {
             hb_itemClear( hb_itemReturn( pItem ) ); /* return a codeblock */
             hb_itemRelease( pItem );

             --pIdleData->iIdleMaxTask;
             if( pIdleData->iIdleMaxTask )
             {
                if( iTask != pIdleData->iIdleMaxTask )
                {
                   memmove( &pIdleData->pIdleTasks[ iTask ], &pIdleData->pIdleTasks[ iTask + 1 ],
                            sizeof( HB_ITEM_PTR ) * ( pIdleData->iIdleMaxTask - iTask ) );
                }
                pIdleData->pIdleTasks = ( HB_ITEM_PTR * ) hb_xrealloc( pIdleData->pIdleTasks, sizeof( HB_ITEM_PTR ) * pIdleData->iIdleMaxTask );
                if( pIdleData->iIdleTask >= pIdleData->iIdleMaxTask )
                   pIdleData->iIdleTask = 0;
             }
             else
             {
                hb_xfree( pIdleData->pIdleTasks );
                pIdleData->pIdleTasks = NULL;
                pIdleData->iIdleTask = 0;
             }
             break;
         }
         ++iTask;
      }
   }
}
idle.c289
HB_FUNCHB_RELEASECPU(void)
HB_FUNC( HB_RELEASECPU )
{
   hb_releaseCPU();
}
idle.c334
inkey.c
TypeFunctionSourceLine
STATIC VOIDhb_inkeyBlockRelease( void * cargo )
static void hb_inkeyBlockRelease( void * cargo )
{
   PHB_INKEYBLOCK pInkeyBlock = ( PHB_INKEYBLOCK ) cargo;

   if( pInkeyBlock->before )
      hb_itemRelease( pInkeyBlock->before );
   if( pInkeyBlock->after )
      hb_itemRelease( pInkeyBlock->after );
}

static HB_TSD_NEW( s_inkeyBlock, sizeof( HB_INKEYBLOCK ), NULL, hb_inkeyBlockRelease );
inkey.c86
HB_FUNCINKEY(void)
HB_FUNC( INKEY )
{
   PHB_INKEYBLOCK pInkeyBlock = ( PHB_INKEYBLOCK ) hb_stackTestTSD( &s_inkeyBlock );
   USHORT uiPCount = ( USHORT ) hb_pcount();
   PHB_ITEM pKey = NULL;
   int iKey;

   if( pInkeyBlock && pInkeyBlock->before )
      hb_vmEvalBlock( pInkeyBlock->before );

   do
   {
      iKey = hb_inkey( uiPCount == 1 || ( uiPCount > 1 && ISNUM( 1 ) ),
                       hb_parnd( 1 ),
                       ISNUM( 2 ) ? hb_parni( 2 ) : hb_setGetEventMask() );

      if( iKey == 0 || !pInkeyBlock || !pInkeyBlock->after )
         break;

      pKey = hb_itemPutNI( pKey, iKey );
      iKey = hb_itemGetNI( hb_vmEvalBlockV( pInkeyBlock->after, 1, pKey ) );
      hb_inkeySetLast( iKey );
   }
   while( iKey == 0 );

   if( pKey )
      hb_itemRelease( pKey );

   hb_retni( iKey );
}
inkey.c98
HB_FUNCHB_SETINKEYBEFOREBLOCK(void)
HB_FUNC( HB_SETINKEYBEFOREBLOCK )
{
   PHB_INKEYBLOCK pInkeyBlock = ( PHB_INKEYBLOCK ) hb_stackGetTSD( &s_inkeyBlock );

   if( pInkeyBlock->before )
      hb_itemReturn( pInkeyBlock->before );

   if( hb_pcount() > 0 )
   {
      PHB_ITEM pBlock = hb_param( 1, HB_IT_BLOCK );

      if( pInkeyBlock->before )
         hb_itemRelease( pInkeyBlock->before );
      pInkeyBlock->before = pBlock ? hb_itemNew( pBlock ) : pBlock;
   }
}
inkey.c131
HB_FUNCHB_SETINKEYAFTERBLOCK(void)
HB_FUNC( HB_SETINKEYAFTERBLOCK )
{
   PHB_INKEYBLOCK pInkeyBlock = ( PHB_INKEYBLOCK ) hb_stackGetTSD( &s_inkeyBlock );

   if( pInkeyBlock->after )
      hb_itemReturn( pInkeyBlock->after );

   if( hb_pcount() > 0 )
   {
      PHB_ITEM pBlock = hb_param( 1, HB_IT_BLOCK );

      if( pInkeyBlock->after )
         hb_itemRelease( pInkeyBlock->after );
      pInkeyBlock->after = pBlock ? hb_itemNew( pBlock ) : pBlock;
   }
}
inkey.c148
HB_FUNC__KEYBOARD(void)
HB_FUNC( __KEYBOARD )
{
   /* Clear the typeahead buffer without reallocating the keyboard buffer */
   hb_inkeyReset();

   if( ISCHAR( 1 ) )
      hb_inkeySetText( hb_parc( 1 ), hb_parclen( 1 ) );
}
inkey.c167
HB_FUNCHB_KEYPUT(void)
HB_FUNC( HB_KEYPUT )
{
   if( ISNUM( 1 ) )
   {
      hb_inkeyPut( hb_parni( 1 ) );
   }
   else if( ISCHAR( 1 ) )
   {
      hb_inkeySetText( hb_parc( 1 ), hb_parclen( 1 ) );
   }
   else if( ISARRAY( 1 ) )
   {
      PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
      ULONG ulIndex;
      ULONG ulElements = hb_arrayLen( pArray );

      for( ulIndex = 1; ulIndex <= ulElements; ulIndex++ )
      {
         HB_TYPE type = hb_arrayGetType( pArray, ulIndex );

         if( type & HB_IT_NUMERIC )
         {
            hb_inkeyPut( hb_arrayGetNI( pArray, ulIndex ) );
         }
         else if( type & HB_IT_STRING )
         {
            hb_inkeySetText( ( const char * ) hb_arrayGetCPtr( pArray, ulIndex ), hb_arrayGetCLen( pArray, ulIndex ) );
         }
      }
   }
}
inkey.c176
HB_FUNCHB_KEYINS(void)
HB_FUNC( HB_KEYINS )
{
   if( ISNUM( 1 ) )
   {
      hb_inkeyIns( hb_parni( 1 ) );
   }
   else if( ISCHAR( 1 ) )
   {
      hb_inkeySetText( hb_parc( 1 ), hb_parclen( 1 ) );
   }
   else if( ISARRAY( 1 ) )
   {
      PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
      ULONG ulIndex;
      ULONG ulElements = hb_arrayLen( pArray );

      for( ulIndex = 1; ulIndex <= ulElements; ulIndex++ )
      {
         HB_TYPE type = hb_arrayGetType( pArray, ulIndex );

         if( type & HB_IT_NUMERIC )
         {
            hb_inkeyIns( hb_arrayGetNI( pArray, ulIndex ) );
         }
         else if( type & HB_IT_STRING )
         {
            hb_inkeySetText( ( const char * ) hb_arrayGetCPtr( pArray, ulIndex ), hb_arrayGetCLen( pArray, ulIndex ) );
         }
      }
   }
}
inkey.c208
HB_FUNCNEXTKEY(void)
HB_FUNC( NEXTKEY )
{
   hb_retni( hb_inkeyNext( ISNUM( 1 ) ? hb_parni( 1 ) : hb_setGetEventMask() ) );
}
inkey.c240
HB_FUNCLASTKEY(void)
HB_FUNC( LASTKEY )
{
   hb_retni( hb_inkeyLast( ISNUM( 1 ) ? hb_parni( 1 ) : INKEY_ALL ) );
}
inkey.c245
HB_FUNCHB_SETLASTKEY(void)
HB_FUNC( HB_SETLASTKEY )
{
   if( ISNUM( 1 ) )
      hb_retni( hb_inkeySetLast( hb_parni( 1 ) ) );
}
inkey.c250
inkeyapi.c
TypeFunctionSourceLine
HB_EXPORT INThb_inkey( BOOL fWait, double dSeconds, int iEventMask )
HB_EXPORT int  hb_inkey( BOOL fWait, double dSeconds, int iEventMask )
{
   int iKey = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_inkey(%d, %f, %d)", (int) fWait, dSeconds, iEventMask));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iKey = HB_GTSELF_INKEYGET( pGT, fWait, dSeconds, iEventMask );
      hb_gt_BaseFree( pGT );
   }
   return iKey;
}
inkeyapi.c55
HB_EXPORT VOIDhb_inkeyPut( int iKey )
HB_EXPORT void hb_inkeyPut( int iKey )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_inkeyPut(%d)", iKey));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_INKEYPUT( pGT, iKey );
      hb_gt_BaseFree( pGT );
   }
}
inkeyapi.c71
HB_EXPORT VOIDhb_inkeyIns( int iKey )
HB_EXPORT void hb_inkeyIns( int iKey )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_inkeyIns(%d)", iKey));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_INKEYINS( pGT, iKey );
      hb_gt_BaseFree( pGT );
   }
}
inkeyapi.c85
HB_EXPORT INThb_inkeyLast( int iEventMask )
HB_EXPORT int  hb_inkeyLast( int iEventMask )
{
   int iKey = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_inkeyLast(%d)", iEventMask));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iKey = HB_GTSELF_INKEYLAST( pGT, iEventMask );
      hb_gt_BaseFree( pGT );
   }
   return iKey;
}
inkeyapi.c99
HB_EXPORT INThb_inkeyNext( int iEventMask )
HB_EXPORT int  hb_inkeyNext( int iEventMask )
{
   int iKey = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_inkeyNext(%d)", iEventMask));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iKey = HB_GTSELF_INKEYNEXT( pGT, iEventMask );
      hb_gt_BaseFree( pGT );
   }
   return iKey;
}
inkeyapi.c115
HB_EXPORT VOIDhb_inkeyPoll( void )
HB_EXPORT void hb_inkeyPoll( void )
{
   PHB_GT pGT;

   HB_TRACE( HB_TR_DEBUG, ("hb_inkeyPoll()") );

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_INKEYPOLL( pGT );
      hb_gt_BaseFree( pGT );
   }
}
inkeyapi.c131
HB_EXPORT INThb_inkeySetLast( int iKey )
HB_EXPORT int  hb_inkeySetLast( int iKey )
{
   int iLast = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_inkeySetLast(%d)", iKey));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iLast = HB_GTSELF_INKEYSETLAST( pGT, iKey );
      hb_gt_BaseFree( pGT );
   }
   return iLast;
}
inkeyapi.c145
HB_EXPORT VOIDhb_inkeySetText( const char * szText, ULONG ulLen )
HB_EXPORT void hb_inkeySetText( const char * szText, ULONG ulLen )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_inkeySetText(%s,%lu)", szText, ulLen));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_INKEYSETTEXT( pGT, szText, ulLen );
      hb_gt_BaseFree( pGT );
   }
}
inkeyapi.c161
HB_EXPORT VOIDhb_inkeyReset( void )
HB_EXPORT void hb_inkeyReset( void )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_inkeyReset()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_INKEYRESET( pGT );
      hb_gt_BaseFree( pGT );
   }
}
inkeyapi.c175
HB_EXPORT VOIDhb_inkeySetCancelKeys( int iCancelKey, int iCancelKeyEx )
HB_EXPORT void hb_inkeySetCancelKeys( int iCancelKey, int iCancelKeyEx )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_inkeySetCancelKeys(%d,%d)", iCancelKey, iCancelKeyEx));

/*
   s_InkeyAltC = iCancelKey;
   s_InkeyAltCEx = iCancelKeyEx;
*/
   HB_SYMBOL_UNUSED( iCancelKey );
   HB_SYMBOL_UNUSED( iCancelKeyEx );
}
inkeyapi.c189
is.c
TypeFunctionSourceLine
HB_FUNCISALPHA(void)
HB_FUNC( ISALPHA )
{
   char * szString = hb_parc( 1 );

   if( szString )
   {
      if( isalpha( ( unsigned char ) * szString ) )
         hb_retl( TRUE );
      else
      {
#ifndef HB_CDP_SUPPORT_OFF
         PHB_CODEPAGE cdp = hb_vmCDP();
         if( cdp && cdp->nChars && szString[0] &&
             ( strchr( cdp->CharsUpper,* szString ) ||
               strchr( cdp->CharsLower,* szString ) ) )
            hb_retl( TRUE );
         else
#endif
            hb_retl( FALSE );
      }
   }
   else
      hb_retl( FALSE );
}
is.c60
HB_FUNCISDIGIT(void)
HB_FUNC( ISDIGIT )
{
   char * szString = hb_parc( 1 );

   hb_retl( szString && isdigit( ( unsigned char ) * szString ) );
}
is.c87
HB_FUNCISUPPER(void)
HB_FUNC( ISUPPER )
{
   char * szString = hb_parc( 1 );

   if( szString )
   {
      if( isupper( ( unsigned char ) * szString ) )
         hb_retl( TRUE );
      else
      {
#ifndef HB_CDP_SUPPORT_OFF
         PHB_CODEPAGE cdp = hb_vmCDP();
         if( cdp && cdp->nChars && szString[0] &&
             strchr( cdp->CharsUpper, * szString ) )
            hb_retl( TRUE );
         else
#endif
            hb_retl( FALSE );
      }
   }
   else
      hb_retl( FALSE );
}
is.c96
HB_FUNCISLOWER(void)
HB_FUNC( ISLOWER )
{
   char * szString = hb_parc( 1 );

   if( szString )
   {
      if( islower( ( unsigned char ) * szString ) )
         hb_retl( TRUE );
      else
      {
#ifndef HB_CDP_SUPPORT_OFF
         PHB_CODEPAGE cdp = hb_vmCDP();
         if( cdp && cdp->nChars && szString[0] &&
             strchr( cdp->CharsLower,* szString ) )
            hb_retl( TRUE );
#endif
         else
            hb_retl( FALSE );
      }
   }
   else
      hb_retl( FALSE );
}
is.c122
isprint.c
TypeFunctionSourceLine
HB_EXPORT BOOLhb_printerIsReady( char * pszPrinterName )
HB_EXPORT BOOL hb_printerIsReady( char * pszPrinterName )
{
   BOOL bIsPrinter;

#if defined(HB_OS_DOS)

   /* NOTE: DOS specific solution, using BIOS interrupt */

   {
      USHORT uiPort;
      
      if( pszPrinterName == NULL )
         pszPrinterName = "LPT1";

      if( hb_strnicmp( pszPrinterName, "PRN", 3 ) == 0 )
      {
         union REGS regs;
      
         regs.h.ah = 2;
         regs.HB_XREGS.dx = 0; /* LPT1 */
      
         HB_DOS_INT86( 0x17, ®s, ®s );
      
         bIsPrinter = ( regs.h.ah == 0x90 );
      }
      else if( strlen( pszPrinterName ) >= 4 && 
               hb_strnicmp( pszPrinterName, "LPT", 3 ) == 0 && 
               ( uiPort = atoi( pszPrinterName + 3 ) ) > 0 )
      {
         union REGS regs;
      
         regs.h.ah = 2;
         regs.HB_XREGS.dx = uiPort - 1;
      
         HB_DOS_INT86( 0x17, ®s, ®s );
      
         bIsPrinter = ( regs.h.ah == 0x90 );
      }
      else
         bIsPrinter = FALSE;
   }

#elif defined(HB_OS_WIN_32)

   /* NOTE: Platform independent method, at least it will compile and run
            on any platform, but the result may not be the expected one,
            since Unix/Linux doesn't support LPT/COM by nature, other OSs
            may not reflect the actual physical presence of the printer when
            trying to open it, since we are talking to the spooler.
            [vszakats] */

   {
      HB_FHANDLE fhnd;
      
      if( pszPrinterName == NULL )
         pszPrinterName = "LPT1";

      fhnd = hb_fsOpen( ( BYTE * ) pszPrinterName, FO_WRITE | FO_SHARED | FO_PRIVATE );
      bIsPrinter = ( fhnd != FS_ERROR );
      hb_fsClose( fhnd );
   }

#else

   {
      /* TODO */

      HB_SYMBOL_UNUSED( pszPrinterName );

      bIsPrinter = FALSE;
   }

#endif

   return bIsPrinter;
}
isprint.c56
HB_FUNCHB_ISPRINTER(void)
HB_FUNC( HB_ISPRINTER )
{
   hb_retl( hb_printerIsReady( hb_parc( 1 ) ) );
}
isprint.c133
HB_FUNCISPRINTER(void)
HB_FUNC( ISPRINTER )
{
#ifdef HB_COMPAT_XPP
   HB_FUNC_EXEC( HB_ISPRINTER );
#else
   hb_retl( hb_printerIsReady( NULL ) );
#endif
}
isprint.c140
itemseri.c
TypeFunctionSourceLine
STATIC BOOLhb_itemSerialValueRef( PHB_CYCLIC_REF * pRefPtr, void * value, ULONG ulOffset )
static BOOL hb_itemSerialValueRef( PHB_CYCLIC_REF * pRefPtr, void * value,
                                   ULONG ulOffset )
{
   while( * pRefPtr )
   {
      if( ( * pRefPtr )->value == value )
      {
         ( * pRefPtr )->fRef = TRUE;
         return TRUE;
      }
      pRefPtr = &( * pRefPtr )->pNext;
   }

   * pRefPtr = ( PHB_CYCLIC_REF ) hb_xgrab( sizeof( HB_CYCLIC_REF ) );
   ( * pRefPtr )->value = value;
   ( * pRefPtr )->ulOffset = ulOffset;
   ( * pRefPtr )->fRef = FALSE;
   ( * pRefPtr )->pNext = NULL;

   return FALSE;
}
itemseri.c147
STATIC VOIDhb_itemSerialUnRefFree( PHB_CYCLIC_REF * pRefPtr )
static void hb_itemSerialUnRefFree( PHB_CYCLIC_REF * pRefPtr )
{
   PHB_CYCLIC_REF pRef;

   while( * pRefPtr )
   {
      pRef = * pRefPtr;
      if( ! pRef->fRef )
      {
         * pRefPtr =pRef->pNext;
         hb_xfree( pRef );
      }
      else
         pRefPtr = &pRef->pNext;
   }
}
itemseri.c169
STATIC BOOLhb_itemSerialValueOffset( PHB_CYCLIC_REF pRef, void * value, ULONG ulOffset, ULONG * pulRef )
static BOOL hb_itemSerialValueOffset( PHB_CYCLIC_REF pRef, void * value,
                                      ULONG ulOffset, ULONG * pulRef )
{
   while( pRef )
   {
      if( pRef->value == value )
      {
         * pulRef = pRef->ulOffset;
         return pRef->ulOffset < ulOffset;
      }
      pRef = pRef->pNext;
   }

   * pulRef = HB_SERIAL_DUMMYOFFSET;
   return FALSE;
}
itemseri.c186
STATIC BOOLhb_itemSerialOffsetRef( PHB_CYCLIC_REF * pRefPtr, void * value, ULONG ulOffset )
static BOOL hb_itemSerialOffsetRef( PHB_CYCLIC_REF * pRefPtr, void * value,
                                    ULONG ulOffset )
{
   while( * pRefPtr )
   {
      if( ( * pRefPtr )->ulOffset == ulOffset )
         return TRUE;
      pRefPtr = &( * pRefPtr )->pNext;
   }

   * pRefPtr = ( PHB_CYCLIC_REF ) hb_xgrab( sizeof( HB_CYCLIC_REF ) );
   ( * pRefPtr )->value = value;
   ( * pRefPtr )->ulOffset = ulOffset;
   ( * pRefPtr )->fRef = FALSE;
   ( * pRefPtr )->pNext = NULL;

   return FALSE;
}
itemseri.c203
STATIC VOIDhb_itemSerialOffsetSet( PHB_CYCLIC_REF pRef, PHB_ITEM pItem, ULONG ulOffset )
static void hb_itemSerialOffsetSet( PHB_CYCLIC_REF pRef, PHB_ITEM pItem,
                                    ULONG ulOffset )
{
   while( pRef )
   {
      if( pRef->ulOffset == ulOffset )
      {
         pRef->value = ( void * ) pItem;
         break;
      }
      pRef = pRef->pNext;
   }
}
itemseri.c222
STATIC VOIDhb_itemSerialOffsetGet( PHB_CYCLIC_REF pRef, PHB_ITEM pItem, ULONG ulOffset )
static void hb_itemSerialOffsetGet( PHB_CYCLIC_REF pRef, PHB_ITEM pItem,
                                    ULONG ulOffset )
{
   while( pRef )
   {
      if( pRef->ulOffset == ulOffset )
      {
         hb_itemCopy( pItem, ( PHB_ITEM ) pRef->value );
         break;
      }
      pRef = pRef->pNext;
   }
}
itemseri.c236
STATIC VOIDhb_itemSerialRefFree( PHB_CYCLIC_REF pRef )
static void hb_itemSerialRefFree( PHB_CYCLIC_REF pRef )
{
   while( pRef )
   {
      PHB_CYCLIC_REF pNext = pRef->pNext;
      hb_xfree( pRef );
      pRef = pNext;
   }
}
itemseri.c250
STATIC ULONGhb_itemSerialSize( PHB_ITEM pItem, PHB_CYCLIC_REF * pRefPtr, ULONG ulOffset )
static ULONG hb_itemSerialSize( PHB_ITEM pItem, PHB_CYCLIC_REF * pRefPtr, ULONG ulOffset )
{
   ULONG ulSize, ulLen, u;
   HB_LONG lVal;
   double d;
   USHORT uiClass;
   const char * szVal;

   switch( hb_itemType( pItem ) )
   {
      case HB_IT_NIL:
      case HB_IT_LOGICAL:
         ulSize = 1;
         break;

      case HB_IT_DATE:
         ulSize = 4;
         break;

      case HB_IT_INTEGER:
      case HB_IT_LONG:
         lVal = hb_itemGetNInt( pItem );
         if( lVal == 0 )
            ulSize = 1;
         else if( HB_LIM_INT8( lVal ) )
            ulSize = 2;
         else if( HB_LIM_INT16( lVal ) )
            ulSize = 3;
         else if( HB_LIM_INT24( lVal ) )
            ulSize = 4;
         else if( HB_LIM_INT32( lVal ) )
            ulSize = 5;
         else
            ulSize = 9;
         break;

      case HB_IT_DOUBLE:
         d = hb_itemGetND( pItem );
         if( d == 0.0 )
            ulSize = 1;
         else
            ulSize = 9;
         break;

      case HB_IT_SYMBOL:
         ulSize = 2 + strlen( hb_itemGetSymbol( pItem )->szName );
         break;

      case HB_IT_STRING:
      case HB_IT_MEMO:
         szVal = hb_itemGetCPtr( pItem );
         ulLen = hb_itemGetCLen( pItem );
         if( ulLen == 0 )
            ulSize = 1;
         else
         {
            u = ulLen;
            while( u && szVal[ u - 1 ] == ' ' )
               --u;
            u = ulLen - u;
            if( ulLen <= 255 )
               ulSize = u > 1 ? ulLen - u + 3: ulLen + 2;
            else if( ulLen <= UINT16_MAX )
               ulSize = u > 2 ? ulLen - u + 5: ulLen + 3;
            else
               ulSize = u > 4 ? ulLen - u + 9: ulLen + 5;
         }
         break;

      case HB_IT_ARRAY:
         ulSize = 0;
         uiClass = hb_objGetClass( pItem );
         if( uiClass )
         {
            const char * szClass = hb_clsName( uiClass ),
                       * szFunc = hb_clsFuncName( uiClass );
            if( szClass && szFunc )
               ulSize += strlen( szClass ) + strlen( szFunc ) + 3;
         }
         if( hb_itemSerialValueRef( pRefPtr, hb_arrayId( pItem ), ulOffset + ulSize ) )
         {
            ulSize = 5;
         }
         else
         {
            ulLen = hb_arrayLen( pItem );
            if( ulLen <= 255 )
               ulSize += 2;
            else if( ulLen <= UINT16_MAX )
               ulSize += 3;
            else
               ulSize += 5;
            for( u = 1; u <= ulLen; u++ )
               ulSize += hb_itemSerialSize( hb_arrayGetItemPtr( pItem, u ),
                                            pRefPtr, ulOffset + ulSize );
         }
         break;

      case HB_IT_HASH:
         if( hb_itemSerialValueRef( pRefPtr, hb_hashId( pItem ), ulOffset ) )
         {
            ulSize = 5;
         }
         else
         {
            ulLen = hb_hashLen( pItem );
            if( ulLen <= 255 )
               ulSize = 2;
            else if( ulLen <= UINT16_MAX )
               ulSize = 3;
            else
               ulSize = 5;
            for( u = 1; u <= ulLen; u++ )
            {
               ulSize += hb_itemSerialSize( hb_hashGetKeyAt( pItem, u ),
                                            pRefPtr, ulOffset + ulSize );
               ulSize += hb_itemSerialSize( hb_hashGetValueAt( pItem, u ),
                                            pRefPtr, ulOffset + ulSize );
            }
         }
         break;

      default:
         /* map to NIL */
         ulSize = 1;
   }

   return ulSize;
}
itemseri.c260
STATIC ULONGhb_serializeItem( PHB_ITEM pItem, UCHAR * pBuffer, ULONG ulOffset, PHB_CYCLIC_REF pRef )
static ULONG hb_serializeItem( PHB_ITEM pItem, UCHAR * pBuffer,
                               ULONG ulOffset, PHB_CYCLIC_REF pRef )
{
   HB_LONG lVal;
   ULONG ulRef, ulLen, u;
   LONG l;
   double d;
   const char * szVal;

   switch( hb_itemType( pItem ) )
   {
      case HB_IT_NIL:
         pBuffer[ ulOffset++ ] = HB_SERIAL_NIL;
         break;

      case HB_IT_LOGICAL:
         pBuffer[ ulOffset++ ] = hb_itemGetL( pItem ) ? HB_SERIAL_TRUE : HB_SERIAL_FALSE;
         break;

      case HB_IT_DATE:
         pBuffer[ ulOffset++ ] = HB_SERIAL_DATE;
         l = hb_itemGetDL( pItem );
         HB_PUT_LE_UINT24( &pBuffer[ ulOffset ], l );
         ulOffset += 3;
         break;

      case HB_IT_INTEGER:
      case HB_IT_LONG:
         lVal = hb_itemGetNInt( pItem );
         if( lVal == 0 )
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_ZERO;
         }
         else if( HB_LIM_INT8( lVal ) )
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_INT8;
            pBuffer[ ulOffset++ ] = ( UCHAR ) lVal;
         }
         else if( HB_LIM_INT16( lVal ) )
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_INT16;
            HB_PUT_LE_UINT16( &pBuffer[ ulOffset ], lVal );
            ulOffset += 2;
         }
         else if( HB_LIM_INT24( lVal ) )
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_INT24;
            HB_PUT_LE_UINT24( &pBuffer[ ulOffset ], lVal );
            ulOffset += 3;
         }
         else if( HB_LIM_INT32( lVal ) )
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_INT32;
            HB_PUT_LE_UINT32( &pBuffer[ ulOffset ], lVal );
            ulOffset += 4;
         }
         else
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_INT64;
            HB_PUT_LE_UINT64( &pBuffer[ ulOffset ], lVal );
            ulOffset += 8;
         }
         break;

      case HB_IT_DOUBLE:
         d = hb_itemGetND( pItem );
         if( d == 0.0 )
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_ZERO;
         }
         else
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_DOUBLE;
            HB_PUT_LE_DOUBLE( &pBuffer[ ulOffset ], d );
            ulOffset += 8;
         }
         break;

      case HB_IT_SYMBOL:
         szVal = hb_itemGetSymbol( pItem )->szName;
         ulLen = strlen( szVal );
         if( ulLen > 0xFF )
            ulLen = 0xFF;
         pBuffer[ ulOffset++ ] = HB_SERIAL_SYMBOL;
         pBuffer[ ulOffset++ ] = ( UCHAR ) ulLen;
         memcpy( &pBuffer[ ulOffset ], szVal, ulLen );
         ulOffset += ulLen;
         break;

      case HB_IT_STRING:
      case HB_IT_MEMO:
         szVal = hb_itemGetCPtr( pItem );
         ulLen = hb_itemGetCLen( pItem );
         if( ulLen == 0 )
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_STRNUL;
         }
         else
         {
            u = ulLen;
            while( u && szVal[ u - 1 ] == ' ' )
               --u;
            u = ulLen - u;
            if( ulLen <= 255 )
            {
               if( u > 1 )
               {
                  ulLen -= u;
                  pBuffer[ ulOffset++ ] = HB_SERIAL_STRPAD8;
                  pBuffer[ ulOffset++ ] = ( UCHAR ) ulLen;
                  pBuffer[ ulOffset++ ] = ( UCHAR ) u;
               }
               else
               {
                  pBuffer[ ulOffset++ ] = HB_SERIAL_STRING8;
                  pBuffer[ ulOffset++ ] = ( UCHAR ) ulLen;
               }
            }
            else if( ulLen <= UINT16_MAX )
            {
               if( u > 2 )
               {
                  ulLen -= u;
                  pBuffer[ ulOffset++ ] = HB_SERIAL_STRPAD16;
                  HB_PUT_LE_UINT16( &pBuffer[ ulOffset ], ulLen );
                  ulOffset += 2;
                  HB_PUT_LE_UINT16( &pBuffer[ ulOffset ], u );
                  ulOffset += 2;
               }
               else
               {
                  pBuffer[ ulOffset++ ] = HB_SERIAL_STRING16;
                  HB_PUT_LE_UINT16( &pBuffer[ ulOffset ], ulLen );
                  ulOffset += 2;
               }
            }
            else
            {
               if( u > 4 )
               {
                  ulLen -= u;
                  pBuffer[ ulOffset++ ] = HB_SERIAL_STRPAD32;
                  HB_PUT_LE_UINT32( &pBuffer[ ulOffset ], ulLen );
                  ulOffset += 4;
                  HB_PUT_LE_UINT32( &pBuffer[ ulOffset ], u );
                  ulOffset += 4;
               }
               else
               {
                  pBuffer[ ulOffset++ ] = HB_SERIAL_STRING32;
                  HB_PUT_LE_UINT32( &pBuffer[ ulOffset ], ulLen );
                  ulOffset += 4;
               }
            }
            memcpy( &pBuffer[ ulOffset ], szVal, ulLen );
            ulOffset += ulLen;
         }
         break;

      case HB_IT_ARRAY:
         if( hb_itemSerialValueOffset( pRef, hb_arrayId( pItem ), ulOffset, &ulRef ) )
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_REF;
            HB_PUT_LE_UINT32( &pBuffer[ ulOffset ], ulRef );
            ulOffset += 4;
         }
         else
         {
            USHORT uiClass = hb_objGetClass( pItem );
            if( uiClass )
            {
               const char * szClass = hb_clsName( uiClass ),
                          * szFunc = hb_clsFuncName( uiClass );
               if( szClass && szFunc )
               {
                  pBuffer[ ulOffset++ ] = HB_SERIAL_OBJ;
                  ulLen = strlen( szClass ) + 1;
                  memcpy( &pBuffer[ ulOffset ], szClass, ulLen );
                  ulOffset += ulLen;
                  ulLen = strlen( szFunc ) + 1;
                  memcpy( &pBuffer[ ulOffset ], szFunc, ulLen );
                  ulOffset += ulLen;
               }
            }
            ulLen = hb_arrayLen( pItem );
            if( ulLen <= 255 )
            {
               pBuffer[ ulOffset++ ] = ulRef == HB_SERIAL_DUMMYOFFSET ?
                                       HB_SERIAL_ARRAY8 : HB_SERIAL_ARRAYREF8;
               pBuffer[ ulOffset++ ] = ( UCHAR ) ulLen;
            }
            else if( ulLen <= UINT16_MAX )
            {
               pBuffer[ ulOffset++ ] = ulRef == HB_SERIAL_DUMMYOFFSET ?
                                       HB_SERIAL_ARRAY16 : HB_SERIAL_ARRAYREF16;
               HB_PUT_LE_UINT16( &pBuffer[ ulOffset ], ulLen );
               ulOffset += 2;
            }
            else
            {
               pBuffer[ ulOffset++ ] = ulRef == HB_SERIAL_DUMMYOFFSET ?
                                       HB_SERIAL_ARRAY32 : HB_SERIAL_ARRAYREF32;
               HB_PUT_LE_UINT32( &pBuffer[ ulOffset ], ulLen );
               ulOffset += 4;
            }
            for( u = 1; u <= ulLen; u++ )
               ulOffset = hb_serializeItem( hb_arrayGetItemPtr( pItem, u ), pBuffer, ulOffset, pRef );
         }
         break;

      case HB_IT_HASH:
         if( hb_itemSerialValueOffset( pRef, hb_hashId( pItem ), ulOffset, &ulRef ) )
         {
            pBuffer[ ulOffset++ ] = HB_SERIAL_REF;
            HB_PUT_LE_UINT32( &pBuffer[ ulOffset ], ulRef );
            ulOffset += 4;
         }
         else
         {
            ulLen = hb_hashLen( pItem );
            if( ulLen <= 255 )
            {
               pBuffer[ ulOffset++ ] = ulRef == HB_SERIAL_DUMMYOFFSET ?
                                       HB_SERIAL_HASH8 : HB_SERIAL_HASHREF8;
               pBuffer[ ulOffset++ ] = ( UCHAR ) ulLen;
            }
            else if( ulLen <= UINT16_MAX )
            {
               pBuffer[ ulOffset++ ] = ulRef == HB_SERIAL_DUMMYOFFSET ?
                                       HB_SERIAL_HASH16 : HB_SERIAL_HASHREF16;
               HB_PUT_LE_UINT16( &pBuffer[ ulOffset ], ulLen );
               ulOffset += 2;
            }
            else
            {
               pBuffer[ ulOffset++ ] = ulRef == HB_SERIAL_DUMMYOFFSET ?
                                       HB_SERIAL_HASH32 : HB_SERIAL_HASHREF32;
               HB_PUT_LE_UINT32( &pBuffer[ ulOffset ], ulLen );
               ulOffset += 4;
            }
            for( u = 1; u <= ulLen; u++ )
            {
               ulOffset = hb_serializeItem( hb_hashGetKeyAt( pItem, u ), pBuffer, ulOffset, pRef );
               ulOffset = hb_serializeItem( hb_hashGetValueAt( pItem, u ), pBuffer, ulOffset, pRef );
            }
         }
         break;

      default:
         /* map to NIL */
         pBuffer[ ulOffset++ ] = HB_SERIAL_NIL;
         break;
   }

   return ulOffset;
}
itemseri.c390
STATIC ULONGhb_deserializeHash( PHB_ITEM pItem, UCHAR * pBuffer, ULONG ulOffset, ULONG ulLen, PHB_CYCLIC_REF pRef )
static ULONG hb_deserializeHash( PHB_ITEM pItem, UCHAR * pBuffer, ULONG ulOffset,
                                 ULONG ulLen, PHB_CYCLIC_REF pRef )
{
   hb_hashNew( pItem );

   if( ulLen )
   {
      PHB_ITEM pKey = hb_itemNew( NULL );
      PHB_ITEM pVal = hb_itemNew( NULL );

      hb_hashPreallocate( pItem, ulLen );
      while( ulLen-- )
      {
         ulOffset = hb_deserializeItem( pKey, pBuffer, ulOffset, pRef );
         ulOffset = hb_deserializeItem( pVal, pBuffer, ulOffset, pRef );
         hb_hashAdd( pItem, pKey, pVal );
      }
      hb_itemRelease( pKey );
      hb_itemRelease( pVal );
   }

   return ulOffset;
}
itemseri.c647
STATIC ULONGhb_deserializeArray( PHB_ITEM pItem, UCHAR * pBuffer, ULONG ulOffset, ULONG ulLen, PHB_CYCLIC_REF pRef )
static ULONG hb_deserializeArray( PHB_ITEM pItem, UCHAR * pBuffer, ULONG ulOffset,
                                  ULONG ulLen, PHB_CYCLIC_REF pRef )
{
   ULONG u;

   hb_arrayNew( pItem, ulLen );
   for( u = 1; u <= ulLen; u++ )
      ulOffset = hb_deserializeItem( hb_arrayGetItemPtr( pItem, u ),
                                     pBuffer, ulOffset, pRef );

   return ulOffset;
}
itemseri.c671
STATIC ULONGhb_deserializeItem( PHB_ITEM pItem, UCHAR * pBuffer, ULONG ulOffset, PHB_CYCLIC_REF pRef )
static ULONG hb_deserializeItem( PHB_ITEM pItem, UCHAR * pBuffer,
                                 ULONG ulOffset, PHB_CYCLIC_REF pRef )
{
   ULONG ulLen, ulPad;
   char * szVal;

   switch( pBuffer[ ulOffset++ ] )
   {
      case HB_SERIAL_NIL:
         hb_itemClear( pItem );
         break;

      case HB_SERIAL_TRUE:
         hb_itemPutL( pItem, TRUE );
         break;

      case HB_SERIAL_FALSE:
         hb_itemPutL( pItem, FALSE );
         break;

      case HB_SERIAL_ZERO:
         hb_itemPutNI( pItem, 0 );
         break;

      case HB_SERIAL_INT8:
         hb_itemPutNI( pItem, pBuffer[ ulOffset++ ] );
         break;

      case HB_SERIAL_INT16:
         hb_itemPutNI( pItem, HB_GET_LE_INT16( &pBuffer[ ulOffset ] ) );
         ulOffset += 2;
         break;

      case HB_SERIAL_INT24:
         hb_itemPutNInt( pItem, HB_GET_LE_INT24( &pBuffer[ ulOffset ] ) );
         ulOffset += 3;
         break;

      case HB_SERIAL_INT32:
         hb_itemPutNInt( pItem, HB_GET_LE_INT32( &pBuffer[ ulOffset ] ) );
         ulOffset += 4;
         break;

      case HB_SERIAL_INT64:
         hb_itemPutNInt( pItem, HB_GET_LE_INT64( &pBuffer[ ulOffset ] ) );
         ulOffset += 8;
         break;

      case HB_SERIAL_DOUBLE:
         hb_itemPutND( pItem, HB_GET_LE_DOUBLE( &pBuffer[ ulOffset ] ) );
         ulOffset += 8;
         break;

      case HB_SERIAL_DATE:
         hb_itemPutDL( pItem, HB_GET_LE_UINT24( &pBuffer[ ulOffset ] ) );
         ulOffset += 3;
         break;

      case HB_SERIAL_SYMBOL:
         ulLen = pBuffer[ ulOffset++ ];
         szVal = hb_strndup( ( char * ) &pBuffer[ ulOffset ], ulLen );
         hb_itemPutSymbol( pItem, hb_dynsymGetSymbol( szVal ) );
         hb_xfree( szVal );
         ulOffset += ulLen;
         break;

      case HB_SERIAL_STRNUL:
         hb_itemPutCL( pItem, NULL, 0 );
         break;
      case HB_SERIAL_STRING8:
         ulLen = pBuffer[ ulOffset++ ];
         hb_itemPutCL( pItem, ( char * ) &pBuffer[ ulOffset ], ulLen );
         ulOffset += ulLen;
         break;
      case HB_SERIAL_STRING16:
         ulLen = HB_GET_LE_UINT16( &pBuffer[ ulOffset ] );
         ulOffset += 2;
         hb_itemPutCL( pItem, ( char * ) &pBuffer[ ulOffset ], ulLen );
         ulOffset += ulLen;
         break;
      case HB_SERIAL_STRING32:
         ulLen = HB_GET_LE_UINT32( &pBuffer[ ulOffset ] );
         ulOffset += 4;
         hb_itemPutCL( pItem, ( char * ) &pBuffer[ ulOffset ], ulLen );
         ulOffset += ulLen;
         break;
      case HB_SERIAL_STRPAD8:
         ulLen = pBuffer[ ulOffset++ ];
         ulPad = pBuffer[ ulOffset++ ];
         szVal = ( char * ) hb_xgrab( ulLen + ulPad + 1 );
         memcpy( szVal, &pBuffer[ ulOffset ], ulLen );
         memset( szVal + ulLen, ' ', ulPad + 1 );
         hb_itemPutCLPtr( pItem, szVal, ulLen + ulPad );
         ulOffset += ulLen;
         break;
      case HB_SERIAL_STRPAD16:
         ulLen = HB_GET_LE_UINT16( &pBuffer[ ulOffset ] );
         ulOffset += 2;
         ulPad = HB_GET_LE_UINT16( &pBuffer[ ulOffset ] );
         ulOffset += 2;
         szVal = ( char * ) hb_xgrab( ulLen + ulPad + 1 );
         memcpy( szVal, &pBuffer[ ulOffset ], ulLen );
         memset( szVal + ulLen, ' ', ulPad + 1 );
         hb_itemPutCLPtr( pItem, szVal, ulLen + ulPad );
         ulOffset += ulLen;
         break;
      case HB_SERIAL_STRPAD32:
         ulLen = HB_GET_LE_UINT32( &pBuffer[ ulOffset ] );
         ulOffset += 4;
         ulPad = HB_GET_LE_UINT32( &pBuffer[ ulOffset ] );
         ulOffset += 4;
         szVal = ( char * ) hb_xgrab( ulLen + ulPad + 1 );
         memcpy( szVal, &pBuffer[ ulOffset ], ulLen );
         hb_xmemset( szVal + ulLen, ' ', ulPad + 1 );
         hb_itemPutCLPtr( pItem, szVal, ulLen + ulPad );
         ulOffset += ulLen;
         break;

      case HB_SERIAL_ARRAYREF8:
         hb_itemSerialOffsetSet( pRef, pItem, ulOffset - 1 );
      case HB_SERIAL_ARRAY8:
         ulLen = pBuffer[ ulOffset++ ];
         ulOffset = hb_deserializeArray( pItem, pBuffer, ulOffset, ulLen, pRef );
         break;
      case HB_SERIAL_ARRAYREF16:
         hb_itemSerialOffsetSet( pRef, pItem, ulOffset - 1 );
      case HB_SERIAL_ARRAY16:
         ulLen = HB_GET_LE_UINT16( &pBuffer[ ulOffset ] );
         ulOffset = hb_deserializeArray( pItem, pBuffer, ulOffset + 2, ulLen, pRef );
         break;
      case HB_SERIAL_ARRAYREF32:
         hb_itemSerialOffsetSet( pRef, pItem, ulOffset - 1 );
      case HB_SERIAL_ARRAY32:
         ulLen = HB_GET_LE_UINT32( &pBuffer[ ulOffset ] );
         ulOffset = hb_deserializeArray( pItem, pBuffer, ulOffset + 4, ulLen, pRef );
         break;

      case HB_SERIAL_HASHREF8:
         hb_itemSerialOffsetSet( pRef, pItem, ulOffset - 1 );
      case HB_SERIAL_HASH8:
         ulLen = pBuffer[ ulOffset++ ];
         ulOffset = hb_deserializeHash( pItem, pBuffer, ulOffset, ulLen, pRef );
         break;
      case HB_SERIAL_HASHREF16:
         hb_itemSerialOffsetSet( pRef, pItem, ulOffset - 1 );
      case HB_SERIAL_HASH16:
         ulLen = HB_GET_LE_UINT16( &pBuffer[ ulOffset ] );
         ulOffset = hb_deserializeHash( pItem, pBuffer, ulOffset + 2, ulLen, pRef );
         break;
      case HB_SERIAL_HASHREF32:
         hb_itemSerialOffsetSet( pRef, pItem, ulOffset - 1 );
      case HB_SERIAL_HASH32:
         ulLen = HB_GET_LE_UINT32( &pBuffer[ ulOffset ] );
         ulOffset = hb_deserializeHash( pItem, pBuffer, ulOffset + 4, ulLen, pRef );
         break;

      case HB_SERIAL_REF:
         hb_itemSerialOffsetGet( pRef, pItem,
                                 HB_GET_LE_UINT32( &pBuffer[ ulOffset ] ) );
         ulOffset += 4;
         break;

      case HB_SERIAL_OBJ:
      {
         char * szClass, * szFunc;
         szClass = ( char * ) &pBuffer[ ulOffset ];
         ulLen = strlen( szClass );
         szFunc = szClass + ulLen + 1;
         ulOffset = hb_deserializeItem( pItem, pBuffer,
                              ulOffset + ulLen + strlen( szFunc ) + 2, pRef );
         hb_objSetClass( pItem, szClass, szFunc );
         break;
      }

      default:
         hb_itemClear( pItem );
         break;
   }

   return ulOffset;
}
itemseri.c684
STATIC BOOLhb_deserializeTest( UCHAR ** pBufferPtr, ULONG * pulSize, ULONG ulOffset, PHB_CYCLIC_REF * pRefPtr )
static BOOL hb_deserializeTest( UCHAR ** pBufferPtr, ULONG * pulSize,
                                ULONG ulOffset, PHB_CYCLIC_REF * pRefPtr )
{
   UCHAR * pBuffer = * pBufferPtr;
   ULONG ulSize = * pulSize, ulLen = 0;

   if( ulSize == 0 )
      return FALSE;

   switch( *pBuffer++ )
   {
      case HB_SERIAL_NIL:
      case HB_SERIAL_TRUE:
      case HB_SERIAL_FALSE:
      case HB_SERIAL_ZERO:
      case HB_SERIAL_STRNUL:
         ulSize = 1;
         break;
      case HB_SERIAL_INT8:
         ulSize = 2;
         break;
      case HB_SERIAL_INT16:
         ulSize = 3;
         break;
      case HB_SERIAL_INT24:
      case HB_SERIAL_DATE:
         ulSize = 4;
         break;
      case HB_SERIAL_INT32:
         ulSize = 5;
         break;
      case HB_SERIAL_INT64:
      case HB_SERIAL_DOUBLE:
         ulSize = 9;
         break;
      case HB_SERIAL_SYMBOL:
      case HB_SERIAL_STRING8:
         ulSize = 2 + ( ulSize >= 2 ? *pBuffer : ulSize );
         break;
      case HB_SERIAL_STRING16:
         ulSize = 3 + ( ulSize >= 3 ? HB_GET_LE_UINT16( pBuffer ) : ulSize );
         break;
      case HB_SERIAL_STRING32:
         ulSize = 5 + ( ulSize >= 5 ? HB_GET_LE_UINT32( pBuffer ) : ulSize );
         break;
      case HB_SERIAL_STRPAD8:
         ulSize = 3 + ( ulSize >= 3 ? *pBuffer : ulSize );
         break;
      case HB_SERIAL_STRPAD16:
         ulSize = 5 + ( ulSize >= 5 ? HB_GET_LE_UINT16( pBuffer ) : ulSize );
         break;
      case HB_SERIAL_STRPAD32:
         ulSize = 9 + ( ulSize >= 9 ? HB_GET_LE_UINT32( pBuffer ) : ulSize );
         break;
      case HB_SERIAL_ARRAYREF8:
         if( hb_itemSerialOffsetRef( pRefPtr, NULL, ulOffset ) )
            return FALSE;
      case HB_SERIAL_ARRAY8:
         if( ulSize >= 2 )
         {
            ulSize = 2;
            ulLen = *pBuffer;
         }
         else
            ulSize++;
         break;
      case HB_SERIAL_ARRAYREF16:
         if( hb_itemSerialOffsetRef( pRefPtr, NULL, ulOffset ) )
            return FALSE;
      case HB_SERIAL_ARRAY16:
         if( ulSize >= 3 )
         {
            ulSize = 3;
            ulLen = HB_GET_LE_UINT16( pBuffer );
         }
         else
            ulSize++;
         break;
      case HB_SERIAL_ARRAYREF32:
         if( hb_itemSerialOffsetRef( pRefPtr, NULL, ulOffset ) )
            return FALSE;
      case HB_SERIAL_ARRAY32:
         if( ulSize >= 5 )
         {
            ulSize = 5;
            ulLen = HB_GET_LE_UINT32( pBuffer );
         }
         else
            ulSize++;
         break;
      case HB_SERIAL_HASHREF8:
         if( hb_itemSerialOffsetRef( pRefPtr, NULL, ulOffset ) )
            return FALSE;
      case HB_SERIAL_HASH8:
         if( ulSize >= 2 )
         {
            ulSize = 2;
            ulLen = *pBuffer << 1;
         }
         else
            ulSize++;
         break;
      case HB_SERIAL_HASHREF16:
         if( hb_itemSerialOffsetRef( pRefPtr, NULL, ulOffset ) )
            return FALSE;
      case HB_SERIAL_HASH16:
         if( ulSize >= 3 )
         {
            ulSize = 3;
            ulLen = HB_GET_LE_UINT16( pBuffer ) << 1;
         }
         else
            ulSize++;
         break;
      case HB_SERIAL_HASHREF32:
         if( hb_itemSerialOffsetRef( pRefPtr, NULL, ulOffset ) )
            return FALSE;
      case HB_SERIAL_HASH32:
         if( ulSize >= 5 )
         {
            ulSize = 5;
            ulLen = HB_GET_LE_UINT32( pBuffer ) << 1;
         }
         else
            ulSize++;
         break;
      case HB_SERIAL_REF:
         if( !hb_itemSerialOffsetRef( pRefPtr, NULL, HB_GET_LE_UINT32( pBuffer ) ) )
            return FALSE;
         ulSize = 5;
         break;
      case HB_SERIAL_OBJ:
         ulLen = hb_strnlen( ( char * ) pBuffer, ulSize - 1 ) + 1;
         if( ulLen >= ulSize )
            ulSize++;
         else
         {
            ulLen += hb_strnlen( ( char * ) pBuffer + ulLen, ulSize - ulLen - 1 ) + 2;
            if( ulLen >= ulSize )
               ulSize++;
            else
               ulSize = ulLen;
         }
         ulLen = 1;
         break;
      default:
         ulSize = 1;
         break;
   }

   if( ulSize > * pulSize )
      return FALSE;

   * pulSize -= ulSize;
   * pBufferPtr += ulSize;

   while( ulLen )
   {
      ulOffset += ulSize;
      ulSize = * pulSize;
      if( !hb_deserializeTest( pBufferPtr, pulSize, ulOffset, pRefPtr ) )
         return FALSE;
      ulSize -= * pulSize;
      --ulLen;
   }

   return TRUE;
}
itemseri.c866
STATIC CHAR *hb_itemSerial( PHB_ITEM pItem, ULONG *pulSize )
static char * hb_itemSerial( PHB_ITEM pItem, ULONG *pulSize )
{
   PHB_CYCLIC_REF pRef = NULL;
   ULONG ulSize = hb_itemSerialSize( pItem, &pRef, 0 );
   UCHAR * pBuffer = ( UCHAR * ) hb_xgrab( ulSize + 1 );

   hb_itemSerialUnRefFree( &pRef );
   hb_serializeItem( pItem, pBuffer, 0, pRef );
   pBuffer[ ulSize ] = '\0';
   if( pulSize )
      *pulSize = ulSize;

   hb_itemSerialRefFree( pRef );

   return ( char * ) pBuffer;
}
itemseri.c1035
STATIC PHB_ITEMhb_itemDeSerial( char ** pBufferPtr, ULONG * pulSize )
static PHB_ITEM hb_itemDeSerial( char ** pBufferPtr, ULONG * pulSize )
{
   PHB_CYCLIC_REF pRef = NULL;
   UCHAR * pBuffer = ( UCHAR * ) *pBufferPtr;
   PHB_ITEM pItem = NULL;

   if( !pulSize || hb_deserializeTest( ( UCHAR ** ) pBufferPtr, pulSize, 0, &pRef ) )
   {
      pItem = hb_itemNew( NULL );
      hb_deserializeItem( pItem, pBuffer, 0, pRef );
   }
   hb_itemSerialRefFree( pRef );

   return pItem;
}
itemseri.c1055
HB_FUNCHB_SERIALIZE(void)
HB_FUNC( HB_SERIALIZE )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

   if( pItem )
   {
      ULONG ulSize;
      char * pBuffer = hb_itemSerial( pItem, &ulSize );
      hb_retclen_buffer( pBuffer, ulSize );
   }
}
itemseri.c1074
HB_FUNCHB_DESERIALIZE(void)
HB_FUNC( HB_DESERIALIZE )
{
   PHB_ITEM pItem, pParam = hb_param( 1, HB_IT_BYREF );
   ULONG ulSize = hb_parclen( 1 );

   if( ulSize )
   {
      char * pBuffer = hb_parc( 1 );

      pItem = hb_itemDeSerial( &pBuffer, &ulSize );
      if( pItem )
      {
         hb_itemReturn( pItem );
         if( pParam )
         {
            hb_itemPutCL( pItem, pBuffer, ulSize );
            hb_itemMove( pParam, pItem );
         }
         hb_itemRelease( pItem );
      }
      else if( pParam )
         hb_itemClear( pParam );
   }
   else if( pParam )
      hb_itemClear( pParam );
}
itemseri.c1086
langapi.c
TypeFunctionSourceLine
STATIC INThb_langFindPos( const char * pszID )
static int hb_langFindPos( const char * pszID )
{
   int iPos;

   if( pszID )
   {
      for( iPos = 0; iPos < HB_LANG_MAX_; iPos++ )
      {
         if( s_langList[ iPos ] && strcmp( ( const char * ) s_langList[ iPos ]->pItemList[ HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ], pszID ) == 0 )
            return iPos;
      }
   }

   return -1;
}
langapi.c219
BOOLhb_langRegister( PHB_LANG lang )
BOOL hb_langRegister( PHB_LANG lang )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_langRegister(%p)", lang));

   if( lang )
   {
      int iPos = hb_langFindPos( ( const char * ) lang->pItemList[ HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ] );

      if( iPos == -1 )
      {
         for( iPos = 0; iPos < HB_LANG_MAX_; iPos++ )
         {
            if( s_langList[ iPos ] == NULL )
            {
               s_langList[ iPos ] = lang;
               return TRUE;
            }
         }
      }
      else
      {
         s_langList[ iPos ] = lang;
         return TRUE;
      }
   }

   return FALSE;
}
langapi.c235
BOOLhb_langDeRegister( const char * pszID )
BOOL hb_langDeRegister( const char * pszID )
{
   int iPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_langDeRegister(%s)", pszID));

   iPos = hb_langFindPos( pszID );

   if( iPos != -1 )
   {
      s_langList[ iPos ] = NULL;
      return TRUE;
   }
   else
      return FALSE;
}
langapi.c264
PHB_LANGhb_langFind( const char * pszID )
PHB_LANG hb_langFind( const char * pszID )
{
   int iPos;

   HB_TRACE(HB_TR_DEBUG, ("hb_langFind(%s)", pszID));

   iPos = hb_langFindPos( pszID );

   return ( iPos != -1 ) ? s_langList[ iPos ] : NULL;
}
langapi.c281
PHB_LANGhb_langSelect( PHB_LANG lang )
PHB_LANG hb_langSelect( PHB_LANG lang )
{
   PHB_LANG langOld;

   HB_TRACE(HB_TR_DEBUG, ("hb_langSelect(%p)", lang));

   langOld = hb_vmLang();
   if( lang )
      hb_vmSetLang( lang );

   return langOld;
}
langapi.c292
CHAR *hb_langSelectID( const char * pszID )
char * hb_langSelectID( const char * pszID )
{
   char * pszIDOld = hb_langID();

   HB_TRACE(HB_TR_DEBUG, ("hb_langSelectID(%s)", pszID));

   hb_langSelect( hb_langFind( pszID ) );

   return pszIDOld;
}
langapi.c305
CHAR *hb_langDGetItem( int iIndex )
char * hb_langDGetItem( int iIndex )
{
   PHB_LANG lang;

   HB_TRACE(HB_TR_DEBUG, ("hb_langDGetItem(%i)", iIndex));

   lang = hb_vmLang();
   if( lang && iIndex >= 0 && iIndex < HB_LANG_ITEM_MAX_ )
      return ( char * ) lang->pItemList[ iIndex ];
   else
      return NULL;
}
langapi.c316
CHAR *hb_langID( void )
char * hb_langID( void )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_langID()"));

   return hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID );
}
langapi.c329
CHAR *hb_langName( void )
char * hb_langName( void )
{
   char * pszName;
   PHB_LANG lang;

   lang = hb_vmLang();
   if( lang )
   {
      pszName = ( char * ) hb_xgrab( 128 );
      snprintf( pszName, 128, "Harbour Language: %s %s (%s)",
         ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ),
         ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAME ),
         ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAMENAT ) );
   }
   else
      pszName = hb_strdup( "Harbour Language: (not installed)" );

   return pszName;
}
langapi.c338
CHAR *hb_langDGetErrorDesc( ULONG ulIndex )
char * hb_langDGetErrorDesc( ULONG ulIndex )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_langDGetErrorDesc(%lu)", ulIndex));

   return ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ERRDESC + ulIndex );
}
langapi.c360
HB_FUNCHB_LANGSELECT(void)
HB_FUNC( HB_LANGSELECT )
{
   char * szNewLang;

   hb_retc( hb_langID() );

   szNewLang = hb_parc( 1 );
   if( szNewLang )
      hb_langSelectID( szNewLang );
}
langapi.c369
HB_FUNCHB_LANGNAME(void)
HB_FUNC( HB_LANGNAME )
{
   hb_retc_buffer( hb_langName() );
}
langapi.c380
HB_FUNCHB_LANGERRMSG(void)
HB_FUNC( HB_LANGERRMSG )
{
   hb_retc( hb_langDGetErrorDesc( hb_parnl( 1 ) ) );
}
langapi.c385
HB_FUNCHB_LANGMESSAGE(void)
HB_FUNC( HB_LANGMESSAGE )
{
   hb_retc( hb_langDGetItem( hb_parnl( 1 ) ) );
}
langapi.c390
left.c
TypeFunctionSourceLine
HB_FUNCLEFT(void)
HB_FUNC( LEFT )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText && ISNUM( 2 ) )
   {
      long lLen = hb_parnl( 2 );
      if( lLen <= 0 )
         hb_retc( NULL );
      else
      {
         ULONG ulText = hb_itemGetCLen( pText );
         if( ( ULONG ) lLen >= ulText )
            hb_itemReturn( pText );
         else
            hb_retclen( hb_itemGetCPtr( pText ), lLen );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1124, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
left.c59
len.c
TypeFunctionSourceLine
HB_FUNCLEN(void)
HB_FUNC( LEN )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

   /* NOTE: Double safety to ensure that a parameter was really passed,
            compiler checks this, but a direct hb_vmDo() call
            may not do so. [vszakats] */

   if( pItem )
   {
      if( HB_IS_STRING( pItem ) )
      {
         hb_retnl( hb_itemGetCLen( pItem ) );
         return;
      }
      else if( HB_IS_ARRAY( pItem ) )
      {
         hb_retnl( hb_arrayLen( pItem ) );
         return;
      }
      else if( HB_IS_HASH( pItem ) )
      {
         hb_retnl( hb_hashLen( pItem ) );
         return;
      }
   }

   hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
len.c57
lennum.c
TypeFunctionSourceLine
HB_FUNCLENNUM(void)
HB_FUNC( LENNUM )
{
   PHB_ITEM pNumber = hb_param( 1, HB_IT_NUMERIC );
   ULONG ulLen = 0;

   if( pNumber )
   {
      char * pszString = hb_itemStr( pNumber, NULL, NULL );

      if( pszString )
      {
         ulLen = strlen( pszString );
         hb_strLTrim( pszString, &ulLen );
         hb_xfree( pszString );
      }
   }

   hb_retnl( ulLen );
}
lennum.c56
math.c
TypeFunctionSourceLine
STATIC VOIDhb_mathErrDataInit( void * Cargo )
static void hb_mathErrDataInit( void * Cargo )
{
   PHB_MATHERRDATA pMathErr = ( PHB_MATHERRDATA ) Cargo;

   pMathErr->mode = HB_MATH_ERRMODE_DEFAULT;

   pMathErr->handler = hb_matherr;

#if defined(HB_MATH_HANDLER)
   pMathErr->exception.type = HB_MATH_ERR_NONE;
   pMathErr->exception.funcname = "";
   pMathErr->exception.error = "";
   pMathErr->exception.arg1 = 0.0;
   pMathErr->exception.arg2 = 0.0;
   pMathErr->exception.retval = 0.0;
   pMathErr->exception.retvalwidth = -1;   /* we don't know */
   pMathErr->exception.retvaldec = -1;     /* use standard SET DECIMALS */
   pMathErr->exception.handled = 1;
#endif
}
math.c90
STATIC VOIDhb_mathErrDataRelease( void * Cargo )
static void hb_mathErrDataRelease( void * Cargo )
{
   PHB_MATHERRDATA pMathErr = ( PHB_MATHERRDATA ) Cargo;

   hb_itemRelease( pMathErr->block );
}

static HB_TSD_NEW( s_mathErrData, sizeof( HB_MATHERRDATA ),
                   hb_mathErrDataInit, hb_mathErrDataRelease );
math.c111
VOIDhb_mathResetError( HB_MATH_EXCEPTION * phb_exc )
void hb_mathResetError( HB_MATH_EXCEPTION * phb_exc )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_mathResetError(%p)", phb_exc ) );

   HB_SYMBOL_UNUSED( phb_exc );

#if defined(HB_MATH_HANDLER)
   {
      PHB_MATHERRDATA pMathErr = hb_mathErrData();
      pMathErr->exception.type = HB_MATH_ERR_NONE;
      pMathErr->exception.funcname = "";
      pMathErr->exception.error = "";
      pMathErr->exception.arg1 = 0.0;
      pMathErr->exception.arg2 = 0.0;
      pMathErr->exception.retval = 0.0;
      pMathErr->exception.retvalwidth = -1;   /* we don't know */
      pMathErr->exception.retvaldec = -1;     /* use standard SET DECIMALS */
      pMathErr->exception.handled = 1;
   }
#elif defined(HB_MATH_ERRNO)
   errno = 0;
#endif
}
math.c131
HB_EXPORT INTmatherr( struct exception *err )
HB_EXPORT int matherr( struct exception *err )
{
   int retval;
   HB_MATH_HANDLERPROC mathHandler;
   HB_MATH_EXCEPTION * pExc;

   HB_TRACE( HB_TR_DEBUG, ( "matherr(%p)", err ) );

   pExc = &hb_mathErrData()->exception;

   /* map math error types */
   switch( err->type )
   {
      case DOMAIN:
         pExc->type = HB_MATH_ERR_DOMAIN;
         pExc->error = "Argument not in domain of function";
         break;

      case SING:
         pExc->type = HB_MATH_ERR_SING;
         pExc->error = "Calculation results in singularity";
         break;

      case OVERFLOW:
         pExc->type = HB_MATH_ERR_OVERFLOW;
         pExc->error = "Calculation result too large to represent";
         break;

      case UNDERFLOW:
         pExc->type = HB_MATH_ERR_UNDERFLOW;
         pExc->error = "Calculation result too small to represent";
         break;

      case TLOSS:
         pExc->type = HB_MATH_ERR_TLOSS;
         pExc->error = "Total loss of significant digits";
         break;

      case PLOSS:
         pExc->type = HB_MATH_ERR_PLOSS;
         pExc->error = "Partial loss of significant digits";
         break;

      default:
         pExc->type = HB_MATH_ERR_UNKNOWN;
         pExc->error = "Unknown math error";
         break;
   }

   pExc->funcname = ( char * ) err->name;    /* (char *) Avoid warning in DJGPP */
   pExc->arg1 = err->arg1;
   pExc->arg2 = err->arg2;
   pExc->retval = err->retval;
   pExc->handled = 0;

   mathHandler = hb_mathGetHandler();
   if( mathHandler )
   {
      retval = ( *( mathHandler ) ) ( pExc );
      err->retval = pExc->retval;
   }
   else
   {
      /* there is no custom math handler */
      retval = 1;               /* don't print any message, don't set errno and use return value provided by C RTL */
   }
   return retval;
}
math.c159
BOOLhb_mathGetError( HB_MATH_EXCEPTION * phb_exc, const char *szFunc, double arg1, double arg2, double dResult )
BOOL hb_mathGetError( HB_MATH_EXCEPTION * phb_exc, const char *szFunc,
                      double arg1, double arg2, double dResult )
{
#if defined(HB_MATH_ERRNO)

   int errCode;

   HB_TRACE( HB_TR_DEBUG, ( "hb_mathGetError(%p,%s,%lf,%lf,%lf)", phb_exc, szFunc, arg1, arg2, dResult ) );

   switch( errno )
   {
      case 0:
         return FALSE;
      case EDOM:
      case ERANGE:
#   if defined(EOVERFLOW)
      case EOVERFLOW:
#   endif
         errCode = errno;
         break;

      default:
         if( isnan( dResult ) )
            errCode = EDOM;
#   if defined(HB_OS_SUNOS)
         else if( !finite( dResult ) )
#   elif defined(HB_OS_OS2)
         else if( !isfinite( dResult ) )
#   else
         else if( isinf( dResult ) )
#   endif
            errCode = ERANGE;
         else
            errCode = errno;
   }

   /* map math error types */
   switch( errCode )
   {
      case EDOM:
         phb_exc->type = HB_MATH_ERR_DOMAIN;
         phb_exc->error = "Argument not in domain of function";
         break;

      case ERANGE:
         phb_exc->type = HB_MATH_ERR_SING;
         phb_exc->error = "Calculation results in singularity";
         break;
#   if defined(EOVERFLOW)
      case EOVERFLOW:
         phb_exc->type = HB_MATH_ERR_OVERFLOW;
         phb_exc->error = "Calculation result too large to represent";
         break;
#   endif
      default:
         phb_exc->type = HB_MATH_ERR_UNKNOWN;
         phb_exc->error = "Unknown math error";
         break;
   }

   phb_exc->funcname = szFunc;
   phb_exc->arg1 = arg1;
   phb_exc->arg2 = arg2;
   phb_exc->retval = dResult;
   phb_exc->handled = 0;
   phb_exc->retvalwidth = -1; /* we don't know */
   phb_exc->retvaldec = -1;   /* use standard SET DECIMALS */

   {
      HB_MATH_HANDLERPROC mathHandler = hb_mathGetHandler();
      if( mathHandler )
         ( *mathHandler )( phb_exc );
   }
   return TRUE;
#else
   HB_TRACE( HB_TR_DEBUG, ( "hb_mathGetError(%p,%s,%lf,%lf,%lf)", phb_exc, szFunc, arg1, arg2, dResult ) );

   HB_SYMBOL_UNUSED( dResult );
   HB_SYMBOL_UNUSED( arg1 );
   HB_SYMBOL_UNUSED( arg2 );
   HB_SYMBOL_UNUSED( szFunc );

#  if defined(HB_MATH_HANDLER)

   memcpy( phb_exc, &hb_mathErrData()->exception, sizeof( HB_MATH_EXCEPTION ) );
   return phb_exc->type != HB_MATH_ERR_NONE;

#  else

   HB_SYMBOL_UNUSED( phb_exc );
   return FALSE;

#  endif

#endif
}
math.c229
INThb_mathSetErrMode( int imode )
int hb_mathSetErrMode( int imode )
{
   PHB_MATHERRDATA pMathErr;
   int oldmode;

   HB_TRACE( HB_TR_DEBUG, ( "hb_mathSetErrMode (%i)", imode ) );

   pMathErr = hb_mathErrData();
   oldmode = pMathErr->mode;

   if( imode == HB_MATH_ERRMODE_DEFAULT ||
       imode == HB_MATH_ERRMODE_CDEFAULT ||
       imode == HB_MATH_ERRMODE_USER ||
       imode == HB_MATH_ERRMODE_USERDEFAULT ||
       imode == HB_MATH_ERRMODE_USERCDEFAULT )
   {
      pMathErr->mode = imode;
   }

   return oldmode;
}
math.c334
INThb_mathGetErrMode( void )
int hb_mathGetErrMode( void )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_mathGetErrMode()" ) );
   return hb_mathErrData()->mode;
}
math.c357
HB_FUNCHB_MATHERMODE(void)
HB_FUNC( HB_MATHERMODE )        /* ([]) ->  */
{
   hb_retni( hb_mathGetErrMode() );

   /* set new mode */
   if( ISNUM( 1 ) )
      hb_mathSetErrMode( hb_parni( 1 ) );
}
math.c364
INThb_matherr( HB_MATH_EXCEPTION * pexc )
int hb_matherr( HB_MATH_EXCEPTION * pexc )
{
   int mode = hb_mathGetErrMode();
   int iRet = 1;

   HB_TRACE( HB_TR_DEBUG, ( "hb_matherr(%p)", pexc ) );

   if( pexc == NULL || pexc->handled != 0 )
   {
      /* error already handled by other handlers ! */
      return 1;
   }

   if( mode == HB_MATH_ERRMODE_USER || mode == HB_MATH_ERRMODE_USERDEFAULT ||
       mode == HB_MATH_ERRMODE_USERCDEFAULT )
   {
      PHB_ITEM pArg1, pArg2, pError;
      PHB_ITEM pMatherrResult;

      /* create an error object */
      /* NOTE: In case of HB_MATH_ERRMODE_USER[C]DEFAULT, I am setting both EF_CANSUBSTITUTE and EF_CANDEFAULT to .T. here.
         This is forbidden according to the original Cl*pper docs, but I think this reflects the situation best here:
         The error handler can either substitute the errorneous value (by returning a numeric value) or choose the
         default error handling (by returning .F., as usual) [martin vogel] */
      pError = hb_errRT_New_Subst( ES_ERROR, "MATH", EG_NUMERR, pexc->type,
                                   pexc->error, pexc->funcname, 0, EF_CANSUBSTITUTE |
                                   ( mode == HB_MATH_ERRMODE_USER ? 0 : EF_CANDEFAULT ) );

      /* Assign the new array to the object data item. */
      /* NOTE: Unfortunately, we cannot decide whether one or two parameters have been used when the
         math function has been called, so we always take two */
      pArg1 = hb_itemPutND( NULL, pexc->arg1 );
      pArg2 = hb_itemPutND( NULL, pexc->arg2 );
      hb_errPutArgs( pError, 2, pArg1, pArg2 );
      hb_itemRelease( pArg1 );
      hb_itemRelease( pArg2 );

      /* launch error codeblock */
      pMatherrResult = hb_errLaunchSubst( pError );
      hb_errRelease( pError );

      if( pMatherrResult )
      {
         if( HB_IS_NUMERIC( pMatherrResult ) )
         {
            pexc->retval = hb_itemGetND( pMatherrResult );
            hb_itemGetNLen( pMatherrResult, &pexc->retvalwidth, &pexc->retvaldec );
            pexc->handled = 1;
         }
         hb_itemRelease( pMatherrResult );
      }
   }

   /* math exception not handled by Harbour error routine above ? */
   if( pexc->handled == 0 )
   {
      switch( mode )
      {
         case HB_MATH_ERRMODE_USER:
            /* user failed to handle the math exception, so quit the app [yes, that's the meaning of this mode !!] */
            iRet = 0;
            hb_vmRequestQuit();
            break;

         case HB_MATH_ERRMODE_DEFAULT:
         case HB_MATH_ERRMODE_USERDEFAULT:
            /* return 1 to suppress C RTL error msgs, but leave error handling to the calling Harbour routine */
            break;

         case HB_MATH_ERRMODE_CDEFAULT:
         case HB_MATH_ERRMODE_USERCDEFAULT:
            /* use the correction value supplied in pexc->retval */
            pexc->handled = 1;
            break;
      }
   }

   return iRet;                 /* error handling successful */
}
math.c374
HB_MATH_HANDLERPROChb_mathSetHandler( HB_MATH_HANDLERPROC handlerproc )
HB_MATH_HANDLERPROC hb_mathSetHandler( HB_MATH_HANDLERPROC handlerproc )
{
   HB_MATH_HANDLERPROC oldHandlerProc;
   PHB_MATHERRDATA pMathErr;

   HB_TRACE( HB_TR_DEBUG, ( "hb_mathSetHandler (%p)", handlerproc ) );

   pMathErr = hb_mathErrData();
   oldHandlerProc = pMathErr->handler;
   pMathErr->handler = handlerproc;

   return oldHandlerProc;
}
math.c463
HB_MATH_HANDLERPROChb_mathGetHandler( void )
HB_MATH_HANDLERPROC hb_mathGetHandler( void )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_mathGetHandler ()" ) );

   return hb_mathErrData()->handler;
}
math.c478
STATIC INThb_matherrblock( HB_MATH_EXCEPTION * pexc )
static int hb_matherrblock( HB_MATH_EXCEPTION * pexc )
{
   PHB_MATHERRDATA pMathErr = hb_mathErrData();
   int retval;

   /* call codeblock for both case: handled and unhandled exceptions */

   if( pMathErr->block )
   {
      PHB_ITEM pArray, pRet;
      PHB_ITEM pType, pFuncname, pError, pArg1, pArg2, pRetval, pHandled;

      pType = hb_itemPutNI( NULL, pexc->type );
      pFuncname = hb_itemPutC( NULL, pexc->funcname );
      pError = hb_itemPutC( NULL, pexc->error );
      pArg1 = hb_itemPutND( NULL, pexc->arg1 );
      pArg2 = hb_itemPutND( NULL, pexc->arg2 );
      pRetval = hb_itemPutNDLen( NULL, pexc->retval, pexc->retvalwidth, pexc->retvaldec );
      pHandled = hb_itemPutL( NULL, pexc->handled );

      pArray = hb_itemArrayNew( 2 );
      hb_itemArrayPut( pArray, 1, pRetval );
      hb_itemArrayPut( pArray, 2, pHandled );

      /* launch error codeblock that can
         a) change the members of the array = {dRetval, lHandled} to set the return value of the math C RTL routine and
         the  and it
         b) can return an integer value to set the return value of matherr().
         NOTE that these values are only used if lHandled was .F. and is set to .T. within the codeblock */
      pRet = hb_itemDo( pMathErr->block, 6, pType, pFuncname, pError, pArg1, pArg2, pArray );

      hb_itemRelease( pType );
      hb_itemRelease( pFuncname );
      hb_itemRelease( pError );
      hb_itemRelease( pArg1 );
      hb_itemRelease( pArg2 );
      hb_itemRelease( pRetval );
      hb_itemRelease( pHandled );

      if( pexc->handled )
      {
         /* math exception has already been handled, so codeblock call above was only informative */
         retval = 1;
      }
      else
      {
         /* exception handled by codeblock ? */
         pHandled = hb_itemArrayGet( pArray, 2 );
         if( pHandled )
         {
            pexc->handled = hb_itemGetL( pHandled );
            hb_itemRelease( pHandled );
         }

         if( pexc->handled )
         {
            /* YES ! */
            /* extract retval for math routine and matherr() */
            pRetval = hb_itemArrayGet( pArray, 1 );
            if( pRetval )
            {
               pexc->retval = hb_itemGetND( pRetval );
               hb_itemGetNLen( pRetval, &pexc->retvalwidth, &pexc->retvaldec );
               hb_itemRelease( pRetval );
            }
            if( pRet && HB_IS_NUMERIC( pRet ) )
            {
               retval = hb_itemGetNI( pRet );   /* block may also return 0 to force C math lib warnings */
               hb_itemRelease( pRet );
            }
            else
            {
               retval = 1;      /* default return value to suppress C math lib warnings */
            }
         }
         else
         {
            /* NO ! */
            retval = 1;
         }
      }
      hb_itemRelease( pArray );
   }
   else
   {
      retval = 1;               /* default return value to suppress C math lib warnings */
   }

   if( pMathErr->prevHandler )
   {
      if( pexc->handled )
      {
         /* the error is handled, so simply inform the previous handler */
         ( *pMathErr->prevHandler ) ( pexc );
      }
      else
      {
         /* else go on error handling within previous handler */
         retval = ( *pMathErr->prevHandler ) ( pexc );
      }
   }
   return retval;
}
math.c494
HB_FUNCHB_MATHERBLOCK(void)
HB_FUNC( HB_MATHERBLOCK )       /* ([]) ->  */
{
   PHB_MATHERRDATA pMathErr = hb_mathErrData();

   /* immediately install hb_matherrblock and keep it permanently installed !
      This is not dangerous because hb_matherrorblock will always call the previous error handler */
   if( pMathErr->prevHandler == NULL )
   {
      pMathErr->prevHandler = hb_mathSetHandler( hb_matherrblock );
   }

   /* return old math handler */
   if( pMathErr->block == NULL )
   {
      hb_ret();
   }
   else
   {
      hb_itemReturn( pMathErr->block );
   }

   if( hb_pcount() > 0 )
   {
      /* set new error block */
      PHB_ITEM pNewErrorBlock = hb_param( 1, HB_IT_BLOCK );

      if( pNewErrorBlock )
      {
         if( pMathErr->block == NULL )
         {
            pMathErr->block = hb_itemNew( NULL );
         }
         hb_itemCopy( pMathErr->block, pNewErrorBlock );
      }
      else
      {
         /* a parameter other than a block has been passed -> delete error handler ! */
         if( pMathErr->block )
         {
            hb_itemRelease( pMathErr->block );
            pMathErr->block = NULL;
         }
      }
   }
}
math.c598
HB_FUNCEXP(void)
HB_FUNC( EXP )
{
   if( ISNUM( 1 ) )
   {
      HB_MATH_EXCEPTION hb_exc;
      double dResult, dArg = hb_parnd( 1 );

      hb_mathResetError( &hb_exc );
      dResult = exp( dArg );
      if( hb_mathGetError( &hb_exc, "EXP", dArg, 0.0, dResult ) )
      {
         if( hb_exc.handled )
            hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
         else
         {
            /* math exception is up to the Harbour function, so do this as Clipper compatible as possible */
            if( hb_exc.type == HB_MATH_ERR_OVERFLOW )
               hb_retndlen( HUGE_VAL, -1, -1 );
            else
               hb_retnd( 0.0 );
         }
      }
      else
         hb_retnd( dResult );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1096, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
math.c652
HB_FUNCLOG(void)
HB_FUNC( LOG )
{
   if( ISNUM( 1 ) )
   {
      HB_MATH_EXCEPTION hb_exc;
      double dResult, dArg = hb_parnd( 1 );

      if( dArg <= 0 )
         hb_retndlen( -HUGE_VAL, -1, -1 );  /* return -infinity */
      else
      {
         hb_mathResetError( &hb_exc );
         dResult = log( dArg );
         if( hb_mathGetError( &hb_exc, "LOG", dArg, 0.0, dResult ) )
         {
            if( hb_exc.handled )
               hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
            else
            {
               /* math exception is up to the Harbour function, so do this as Clipper compatible as possible */
               switch( hb_exc.type )
               {
                  case HB_MATH_ERR_SING:       /* argument to log was 0.0 */
                  case HB_MATH_ERR_DOMAIN:     /* argument to log was < 0.0 */
                     hb_retndlen( -HUGE_VAL, -1, -1 );  /* return -infinity */
                     break;

                  default:
                     hb_retnd( 0.0 );
                     break;
               }
            }
         }
         else
            hb_retnd( dResult );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1095, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
math.c681
HB_FUNCSQRT(void)
HB_FUNC( SQRT )
{
   if( ISNUM( 1 ) )
   {
      HB_MATH_EXCEPTION hb_exc;
      double dResult, dArg = hb_parnd( 1 );

      if( dArg <= 0 )
         hb_retnd( 0.0 );
      else
      {
         hb_mathResetError( &hb_exc );
         dResult = sqrt( dArg );
         if( hb_mathGetError( &hb_exc, "SQRT", dArg, 0.0, dResult ) )
         {
            if( hb_exc.handled )
               hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
            else
               /* math exception is up to the Harbour function, so do this as Clipper compatible as possible */
               hb_retnd( 0.0 ); /* return 0.0 on all errors (all (?) of type DOMAIN) */
         }
         else
            hb_retnd( dResult );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1097, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
math.c722
maxrow.c
TypeFunctionSourceLine
HB_FUNCMAXROW(void)
HB_FUNC( MAXROW ) /* Return the maximum screen/window row number (zero origin) */
{
#ifdef HB_COMPAT_CT3
   /*
    * if called with logical .T. parameter then return real screen high - 1
    * It gives exactly the same result in all standard GT drivers so we
    * are still Clipper compatible. The difference can appear in some extended
    * GT drivers which have additional functionality, f.e. CTW GT which
    * is upper level GT and add CTIII Window support. When it's activated
    * then MaxRow() will return current window max row and MaxRow(.T.) real
    * screen (window 0) max row what is the exact behavior of MaxRow()
    * in CT3, [druzus]
    */

   if( ISLOG( 1 ) && hb_parl( 1 ) )
   {
      USHORT uiRows, uiCols;
      hb_gtScrDim( &uiRows, &uiCols );
      hb_retni( uiRows - 1 );
   }
   else
#endif
      hb_retni( hb_gtMaxRow() );
}
maxrow.c68
HB_FUNCMAXCOL(void)
HB_FUNC( MAXCOL ) /* Return the maximum screen/window column number (zero origin) */
{
#ifdef HB_COMPAT_CT3
   /* See notes about MaxRow(.T.) above */
   if( ISLOG( 1 ) && hb_parl( 1 ) )
   {
      USHORT uiRows, uiCols;
      hb_gtScrDim( &uiRows, &uiCols );
      hb_retni( uiCols - 1 );
   }
   else
#endif
      hb_retni( hb_gtMaxCol() );
}
maxrow.c93
memofile.c
TypeFunctionSourceLine
HB_FUNCMEMOREAD(void)
HB_FUNC( MEMOREAD )
{
   PHB_ITEM pFileName = hb_param( 1, HB_IT_STRING );

   if( pFileName )
   {
      HB_FHANDLE fhnd = hb_fsOpen( ( BYTE * ) hb_itemGetCPtr( pFileName ), FO_READ | FO_SHARED | FO_PRIVATE );

      if( fhnd != FS_ERROR )
      {
         ULONG ulSize = hb_fsSeek( fhnd, 0, FS_END );

         if( ulSize != 0 )
         {
            BYTE * pbyBuffer;

            /* Don't read the file terminating EOF character */

            #if ! defined(HB_OS_UNIX_COMPATIBLE)
            {
               BYTE byEOF = HB_CHAR_NUL;

               hb_fsSeek( fhnd, -1, FS_END );
               hb_fsRead( fhnd, &byEOF, sizeof( BYTE ) );

               if( byEOF == HB_CHAR_EOF )
                  ulSize--;
            }
            #endif

            pbyBuffer = ( BYTE * ) hb_xgrab( ulSize + sizeof( char ) );

            hb_fsSeek( fhnd, 0, FS_SET );
            hb_fsReadLarge( fhnd, pbyBuffer, ulSize );

            hb_retclen_buffer( ( char * ) pbyBuffer, ulSize );
         }
         else
            hb_retc( NULL );

         hb_fsClose( fhnd );
      }
      else
         hb_retc( NULL );
   }
   else
      hb_retc( NULL );
}
memofile.c61
STATIC BOOLhb_memowrit( BOOL bWriteEOF )
static BOOL hb_memowrit( BOOL bWriteEOF )
{
   PHB_ITEM pFileName = hb_param( 1, HB_IT_STRING );
   PHB_ITEM pString   = hb_param( 2, HB_IT_STRING );
   BOOL bRetVal       = FALSE;

   if( pFileName && pString )
   {
      HB_FHANDLE fhnd = hb_fsCreate( ( BYTE * ) hb_itemGetCPtr( pFileName ), FC_NORMAL );

      if( fhnd != FS_ERROR )
      {
         ULONG ulSize = hb_itemGetCLen( pString );

         bRetVal = ( hb_fsWriteLarge( fhnd, ( BYTE * ) hb_itemGetCPtr( pString ), ulSize ) == ulSize );

         /* NOTE: CA-Cl*pper will add the EOF even if the write failed. [vszakats] */
         /* NOTE: CA-Cl*pper will not return .F. when the EOF could not be written. [vszakats] */
#if ! defined(HB_OS_UNIX_COMPATIBLE)
         if( bWriteEOF )  /* if true, then write EOF */
         {
            BYTE byEOF = HB_CHAR_EOF;
            hb_fsWrite( fhnd, &byEOF, sizeof( BYTE ) );
         }
#else
         HB_SYMBOL_UNUSED( bWriteEOF );
#endif

         hb_fsClose( fhnd );
      }
   }

   return bRetVal;
}
memofile.c110
HB_FUNCHB_MEMOWRIT(void)
HB_FUNC( HB_MEMOWRIT )
{
   hb_retl( hb_memowrit( FALSE ) );
}
memofile.c145
HB_FUNCMEMOWRIT(void)
HB_FUNC( MEMOWRIT )
{
#ifdef HB_EXTENSION
   hb_retl( hb_memowrit( hb_parinfo(0) == 3 && ISLOG( 3 ) ? hb_parl( 3 ) : TRUE ) );
#else
   hb_retl( hb_memowrit( TRUE ) );
#endif
}
memofile.c150
minmax.c
TypeFunctionSourceLine
HB_FUNCMAX(void)
HB_FUNC( MAX )
{
   PHB_ITEM p1 = hb_param( 1, HB_IT_ANY );
   PHB_ITEM p2 = hb_param( 2, HB_IT_ANY );

   if( p1 && p2 )
   {
      if( HB_IS_NUMINT( p1 ) && HB_IS_NUMINT( p2 ) )
      {
         HB_LONG l1 = hb_itemGetNInt( p1 );
         HB_LONG l2 = hb_itemGetNInt( p2 );
   
         hb_retnint( l1 >= l2 ? l1 : l2 );
         return;
      }
      else if( HB_IS_NUMERIC( p1 ) && HB_IS_NUMERIC( p2 ) )
      {
         double d1 = hb_itemGetND( p1 );
         double d2 = hb_itemGetND( p2 );
   
         int iDec1;
         int iDec2;
   
         hb_itemGetNLen( p1, NULL, &iDec1 );
         hb_itemGetNLen( p2, NULL, &iDec2 );
   
         if( d1 >= d2 )
            hb_retndlen( d1, 0, iDec1 );
         else
            hb_retndlen( d2, 0, iDec2 );
         return;
      }
      else if( HB_IS_LOGICAL( p1 ) && HB_IS_LOGICAL( p2 ) )
      {
         BOOL b1 = hb_itemGetL( p1 );
         BOOL b2 = hb_itemGetL( p2 );
   
         hb_retl( b1 >= b2 ? b1 : b2 );
         return;
      }
      else if( HB_IS_DATE( p1 ) && HB_IS_DATE( p2 ) )
      {
         char szDate[ 9 ];
   
         hb_retds( hb_itemGetDL( p1 ) >= hb_itemGetDL( p2 ) ? hb_pardsbuff( szDate, 1 ) : hb_pardsbuff( szDate, 2 ) );
         return;
      }
   }
   hb_errRT_BASE_SubstR( EG_ARG, 1093, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
minmax.c57
HB_FUNCMIN(void)
HB_FUNC( MIN )
{
   PHB_ITEM p1 = hb_param( 1, HB_IT_ANY );
   PHB_ITEM p2 = hb_param( 2, HB_IT_ANY );

   if( p1 && p2 )
   {
      if( HB_IS_NUMINT( p1 ) && HB_IS_NUMINT( p2 ) )
      {
         HB_LONG l1 = hb_itemGetNInt( p1 );
         HB_LONG l2 = hb_itemGetNInt( p2 );
   
         hb_retnint( l1 <= l2 ? l1 : l2 );
         return;
      }
      else if( HB_IS_NUMERIC( p1 ) && HB_IS_NUMERIC( p2 ) )
      {
         double d1 = hb_itemGetND( p1 );
         double d2 = hb_itemGetND( p2 );
   
         int iDec1;
         int iDec2;
   
         hb_itemGetNLen( p1, NULL, &iDec1 );
         hb_itemGetNLen( p2, NULL, &iDec2 );
   
         if( d1 <= d2 )
            hb_retndlen( d1, 0, iDec1 );
         else
            hb_retndlen( d2, 0, iDec2 );
         return;
      }
      else if( HB_IS_LOGICAL( p1 ) && HB_IS_LOGICAL( p2 ) )
      {
         BOOL b1 = hb_itemGetL( p1 );
         BOOL b2 = hb_itemGetL( p2 );
   
         hb_retl( b1 <= b2 ? b1 : b2 );
         return;
      }
      else if( HB_IS_DATE( p1 ) && HB_IS_DATE( p2 ) )
      {
         char szDate[ 9 ];
   
         hb_retds( hb_itemGetDL( p1 ) <= hb_itemGetDL( p2 ) ? hb_pardsbuff( szDate, 1 ) : hb_pardsbuff( szDate, 2 ) );
         return;
      }
   }

   hb_errRT_BASE_SubstR( EG_ARG, 1092, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
minmax.c109
mlcfunc.c
TypeFunctionSourceLine
STATIC INThb_mlEol( char * pszString, ULONG ulLen, PHB_EOL_INFO pEOLs, int iEOLs )
static int hb_mlEol( char * pszString, ULONG ulLen,
                     PHB_EOL_INFO pEOLs, int iEOLs )
{
   int i;
   for( i = 0; i < iEOLs; ++i )
   {
      if( ulLen >= pEOLs[ i ].ulLen &&
          memcmp( pszString, pEOLs[ i ].szEOL, pEOLs[ i ].ulLen ) == 0 )
         return i;
   }
   return -1;
}
mlcfunc.c63
STATIC ULONGhb_mlGetLine( char * pszString, ULONG ulLen, ULONG ulOffset, ULONG ulLineLength, ULONG ulTabSize, ULONG ulMaxPos, BOOL fWordWrap, PHB_EOL_INFO pEOLs, int iEOLs, ULONG * pulLen, ULONG * pulEOL )
static ULONG hb_mlGetLine( char * pszString, ULONG ulLen, ULONG ulOffset,
                           ULONG ulLineLength, ULONG ulTabSize, ULONG ulMaxPos,
                           BOOL fWordWrap, PHB_EOL_INFO pEOLs, int iEOLs,
                           ULONG * pulLen, ULONG * pulEOL )
{
   ULONG ulCol = 0, ulBlankCol = 0, ulBlankPos = 0;
   int i;

   if( pulEOL )
      * pulEOL = 0;

   while( ulOffset < ulLen && ( ulMaxPos == 0 || ulOffset < ulMaxPos ) )
   {
      if( pszString[ ulOffset ] == HB_CHAR_SOFT1 &&
          pszString[ ulOffset + 1 ] == HB_CHAR_SOFT2 )
      {
         ulOffset += 2;
         if( !fWordWrap )
            break;
         continue;
      }

      i = hb_mlEol( pszString + ulOffset, ulLen - ulOffset, pEOLs, iEOLs );
      if( i >= 0 )
      {
         if( ulMaxPos )
            ulCol += pEOLs[ i ].ulLen;
         else
            ulOffset += pEOLs[ i ].ulLen;
         if( pulEOL )
            * pulEOL = pEOLs[ i ].ulLen;
         break;
      }

      if( pszString[ ulOffset ] == ' ' || pszString[ ulOffset ] == HB_CHAR_HT )
      {
         ulBlankCol = ulCol;
         ulBlankPos = ulOffset;
      }

      if( ulCol >= ulLineLength )
      {
         if( fWordWrap )
         {
            if( ulBlankCol == 0 || pszString[ ulOffset ] == ' ' ||
                                   pszString[ ulOffset ] == HB_CHAR_HT )
            {
               ulCol = ulLineLength;
               if( pszString[ ulOffset ] == ' ' )
                  ++ulOffset;
               if( pszString[ ulOffset ] == HB_CHAR_SOFT1 &&
                   pszString[ ulOffset + 1 ] == HB_CHAR_SOFT2 )
                  ulOffset += 2;
            }
            else
            {
               ulCol = ulBlankCol;
               ulOffset = ulBlankPos + 1;
            }
         }
         else
         {
            if( ulCol > ulLineLength )
               --ulOffset;
            ulCol = ulLineLength;
         }
         break;
      }

      ulCol += pszString[ ulOffset ] == HB_CHAR_HT ?
               ulTabSize - ( ulCol % ulTabSize ) : 1;
      ulOffset++;
   }
   * pulLen = ulCol;

   return ulOffset;
}
mlcfunc.c76
STATIC PHB_EOL_INFOhb_mlGetEOLs( int iParam, int * piEOLs )
static PHB_EOL_INFO hb_mlGetEOLs( int iParam, int * piEOLs )
{
   PHB_EOL_INFO pEOLs = NULL;
   int iEOLs = 0;

#ifdef HB_EXTENSION
   char * szEOL;
   ULONG ulLen, ul;

   szEOL = hb_parc( iParam );
   if( szEOL )
   {
      ulLen = hb_parclen( iParam );
      if( ulLen )
      {
         pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) );
         pEOLs->szEOL = szEOL;
         pEOLs->ulLen = ulLen;
         iEOLs = 1;
      }
   }
   else if( ISARRAY( iParam ) )
   {
      PHB_ITEM pArray = hb_param( iParam, HB_IT_ARRAY );
      ULONG ulSize = hb_arrayLen( pArray );
      for( ul = 1; ul <= ulSize; ++ul )
      {
         if( hb_arrayGetCLen( pArray, ul ) > 0 )
            ++iEOLs;
      }
      if( iEOLs )
      {
         iEOLs = 0;
         pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) * iEOLs );
         for( ul = 1; ul <= ulSize; ++ul )
         {
            ulLen = hb_arrayGetCLen( pArray, ul );
            if( ulLen > 0 )
            {
               pEOLs[ iEOLs ].szEOL = hb_arrayGetCPtr( pArray, ul );
               pEOLs[ iEOLs ].ulLen = ulLen;
               ++iEOLs;
            }
         }
      }
   }
#else
   HB_SYMBOL_UNUSED( iParam );
#endif

   if( iEOLs == 0 )
   {
      pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) );
      pEOLs->szEOL = hb_setGetEOL();
      if( !pEOLs->szEOL || !pEOLs->szEOL[ 0 ] )
         pEOLs->szEOL = hb_conNewLine();
      pEOLs->ulLen = strlen( pEOLs->szEOL );
      iEOLs = pEOLs->ulLen ? 1 : 0;
   }

   * piEOLs = iEOLs;
   return pEOLs;
}
mlcfunc.c154
STATIC CHAR *hb_mlGetParams( int iParAdd, ULONG * pulLen, ULONG * pulLineLength, ULONG * pulTabSize, BOOL * pfWordWrap, PHB_EOL_INFO * pEOLs, int * piEOLs )
static char * hb_mlGetParams( int iParAdd, ULONG * pulLen, ULONG * pulLineLength,
                              ULONG * pulTabSize, BOOL * pfWordWrap,
                              PHB_EOL_INFO * pEOLs, int * piEOLs )
{
   char * pszString = hb_parc( 1 );
   if( pszString )
   {
      if( ISNUM( 2 ) )
      {
         if( hb_parnd( 2 ) <= 0 )
            return NULL;
         * pulLineLength = hb_parnl( 2 );
      }
      else
         * pulLineLength = 79;
      * pulLen = hb_parclen( 1 );
      * pulTabSize = ISNUM( 3 + iParAdd ) ? hb_parnl( 3 + iParAdd ) : 4;
      * pfWordWrap = ISLOG( 4 + iParAdd ) ? hb_parl( 4 + iParAdd ) : TRUE;
      * pEOLs = hb_mlGetEOLs( 5 + iParAdd, piEOLs );
#ifdef HB_C52_STRICT
      if( * pulLineLength > 254 )
         * pulLineLength = 79;
#endif
      if( * pulTabSize >= * pulLineLength )
         * pulTabSize = * pulLineLength - 1;
      else if( * pulTabSize == 0 )
         * pulTabSize = 1;
   }
   return pszString;
}
mlcfunc.c218
HB_FUNCMEMOLINE(void)
HB_FUNC( MEMOLINE )
{
   ULONG  ulLen, ulLineLength, ulTabSize;
   BOOL   fWordWrap;
   PHB_EOL_INFO pEOLs;
   int    iEOLs;
   char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength,
                                      &ulTabSize, &fWordWrap, &pEOLs, &iEOLs );
   char * szLine;
   ULONG  ulLine   = hb_parnl( 3 );
   ULONG  ulOffset = 0;
   ULONG  ulCols   = 0;

   if( !pszString )
   {
      hb_retc( NULL );
      return;
   }

   if( ulLine == 0 )
      ulLine = 1;

   while( --ulLine && ulOffset < ulLen )
   {
      ulOffset = hb_mlGetLine( pszString, ulLen, ulOffset,
                               ulLineLength, ulTabSize, 0, fWordWrap,
                               pEOLs, iEOLs, &ulCols, NULL );
   }
   if( ulOffset < ulLen )
   {
      ULONG ulCol = 0;
      hb_mlGetLine( pszString, ulLen, ulOffset,
                    ulLineLength, ulTabSize, 0, fWordWrap,
                    pEOLs, iEOLs, &ulCols, NULL );
      szLine = ( char * ) hb_xgrab( ulLineLength + 1 );
      while( ulCol < ulCols )
      {
         if( pszString[ ulOffset ] == HB_CHAR_HT )
         {
            ULONG ul = ulTabSize - ( ulCol % ulTabSize );
            do
               szLine[ ulCol++ ] = ' ';
            while( --ul && ulCol < ulCols );
         }
         else if( pszString[ ulOffset ] == HB_CHAR_SOFT1 &&
                  pszString[ ulOffset + 1 ] == HB_CHAR_SOFT2 )
            ulOffset++;
         else
            szLine[ ulCol++ ] = pszString[ ulOffset ];
         ulOffset++;
      }
      if( ulCols < ulLineLength )
         memset( szLine + ulCols, ' ', ulLineLength - ulCols );
      szLine[ ulLineLength ] = 0;
      hb_retclen_buffer( szLine, ulLineLength );
   }
   else
      hb_retc( NULL );
   hb_xfree( pEOLs );
}
mlcfunc.c249
HB_FUNCMLCOUNT(void)
HB_FUNC( MLCOUNT )
{
   ULONG  ulLen, ulLineLength, ulTabSize;
   BOOL   fWordWrap;
   PHB_EOL_INFO pEOLs;
   int    iEOLs;
   char * pszString = hb_mlGetParams( 0, &ulLen, &ulLineLength,
                                      &ulTabSize, &fWordWrap, &pEOLs, &iEOLs );
   ULONG  ulLines  = 0;
   ULONG  ulOffset = 0;
   ULONG  ulCols   = 0;

   if( pszString )
   {
      while( ulOffset < ulLen )
      {
         ++ulLines;
         ulOffset = hb_mlGetLine( pszString, ulLen, ulOffset,
                                  ulLineLength, ulTabSize, 0, fWordWrap,
                                  pEOLs, iEOLs, &ulCols, NULL );
      }
      hb_xfree( pEOLs );
   }
   hb_retnl( ulLines );
}
mlcfunc.c310
HB_FUNCMLPOS(void)
HB_FUNC( MLPOS )
{
   ULONG  ulLen, ulLineLength, ulTabSize;
   BOOL   fWordWrap;
   PHB_EOL_INFO pEOLs;
   int    iEOLs;
   char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength,
                                      &ulTabSize, &fWordWrap, &pEOLs, &iEOLs );
   ULONG  ulLine   = hb_parnl( 3 );
   ULONG  ulOffset = 0;
   ULONG  ulCols   = 0;

   if( pszString )
   {
      if( ulLine == 0 )
         ulLine = 1;
      while( --ulLine && ulOffset < ulLen )
         ulOffset = hb_mlGetLine( pszString, ulLen, ulOffset,
                                  ulLineLength, ulTabSize, 0, fWordWrap,
                                  pEOLs, iEOLs, &ulCols, NULL );
      if( ulOffset < ulLen )
         ++ulOffset;
      hb_xfree( pEOLs );
   }
   hb_retnl( ulOffset );
}
mlcfunc.c336
HB_FUNCMLCTOPOS(void)
HB_FUNC( MLCTOPOS )
{
   ULONG  ulLen, ulLineLength, ulTabSize;
   BOOL   fWordWrap;
   PHB_EOL_INFO pEOLs;
   int    iEOLs;
   char * pszString = hb_mlGetParams( 2, &ulLen, &ulLineLength,
                                      &ulTabSize, &fWordWrap, &pEOLs, &iEOLs );
   ULONG  ulLine   = hb_parnl( 3 );
   ULONG  ulCol    = hb_parnl( 4 );
   ULONG  ulOffset = 0;
   ULONG  ulCols   = 0;

   if( pszString )
   {
      if( ulLineLength > 4 && ulLine && ISNUM( 4 ) )
      {
         while( --ulLine && ulOffset < ulLen )
            ulOffset = hb_mlGetLine( pszString, ulLen, ulOffset,
                                     ulLineLength, ulTabSize, 0, fWordWrap,
                                     pEOLs, iEOLs, &ulCols, NULL );
         if( ulOffset < ulLen && ulCol )
            ulOffset = hb_mlGetLine( pszString, ulLen, ulOffset,
                                     ulCol, ulTabSize, ulLen, FALSE,
                                     pEOLs, iEOLs, &ulCols, NULL );
      }
      hb_xfree( pEOLs );
   }
   ++ulOffset;
   hb_retnl( ulOffset );
}
mlcfunc.c363
HB_FUNCMPOSTOLC(void)
HB_FUNC( MPOSTOLC )
{
   ULONG  ulLen, ulLineLength, ulTabSize;
   BOOL   fWordWrap;
   PHB_EOL_INFO pEOLs;
   int    iEOLs;
   char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength,
                                      &ulTabSize, &fWordWrap, &pEOLs, &iEOLs );
   ULONG  ulPos    = hb_parnl( 3 );
   ULONG  ulOffset = 0;
   ULONG  ulLine   = 0;
   ULONG  ulCol    = 0;
   ULONG  ulEOL    = 0;

   if( pszString )
   {
      if( ulPos && ulLen )
      {
         if( --ulPos )
         {
            do
            {
               ++ulLine;
               ulOffset = hb_mlGetLine( pszString, ulLen, ulOffset,
                                        ulLineLength, ulTabSize, ulPos, fWordWrap,
                                        pEOLs, iEOLs, &ulCol, &ulEOL );
               if( ulEOL )
               {
                  if( ulOffset + ulEOL == ulPos )
                  {
                     ulCol = 0;
                     ++ulLine;
                     break;
                  }
                  ulOffset += ulEOL;
               }
            }
            while( ulOffset < ulLen && ulOffset < ulPos );

            if( ulLine && ulCol == ulLineLength && ulPos <= ulLen &&
                ( hb_mlEol( pszString + ulPos, ulLen - ulPos, pEOLs, iEOLs ) >= 0 ||
                  ( pszString[ ulPos ] == HB_CHAR_SOFT1 &&
                    pszString[ ulPos + 1 ] == HB_CHAR_SOFT2 ) ||
                  ( ulPos > 0 && pszString[ ulPos - 1 ] == HB_CHAR_SOFT1 &&
                                 pszString[ ulPos ] == HB_CHAR_SOFT2 ) ||
                  ( ulPos > 1 && pszString[ ulPos - 2 ] == HB_CHAR_SOFT1 &&
                                 pszString[ ulPos - 1 ] == HB_CHAR_SOFT2 ) ) )
            {
               ulCol = 0;
               ++ulLine;
            }
         }
         else
            ++ulLine;
      }
      hb_xfree( pEOLs );
   }
   hb_reta( 2 );
   hb_stornl( ulLine, -1, 1 );
   hb_stornl( ulCol, -1, 2 );
}
mlcfunc.c395
mod.c
TypeFunctionSourceLine
HB_FUNCMOD(void)
HB_FUNC( MOD )
{
   PHB_ITEM pNumber = hb_param( 1, HB_IT_NUMERIC );
   PHB_ITEM pBase = hb_param( 2, HB_IT_NUMERIC );

   if( pNumber && pBase )
   {
      double dNumber = hb_itemGetND( pNumber );
      double dBase = hb_itemGetND( pBase ); /* dBase! Cool! */

      if( dBase )
      {
         double dResult = fmod( dNumber, dBase );

         if( dResult && ( dNumber > 0 ? dBase < 0 : dBase > 0 ) )
            dResult += dBase;
         hb_retnd( dResult );
      }
      else
      {
         PHB_ITEM pResult = hb_errRT_BASE_Subst( EG_ZERODIV, 1341, NULL, "%", HB_ERR_ARGS_BASEPARAMS );

         /* In CA-Cl*pper MOD() function ignores substitution result
          * and return original numeric item keeping its internal
          * representation: integer or double, size and number of
          * decimal places, it can be seen in code like:
          *    proc main()
          *       set fixed on
          *       ? transform(mod( 12345, 0 ),"")
          *    return
          *
          * [druzus]
          */
         if( pResult )
         {
            hb_itemReturn( pNumber );
            hb_itemRelease( pResult );
         }
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1085, NULL, "%", 2, hb_param( 1, HB_IT_ANY ), hb_param( 2, HB_IT_ANY ) );
}
mod.c68
mouse53.c
TypeFunctionSourceLine
HB_FUNCMPRESENT(void)
HB_FUNC( MPRESENT )
{
   hb_retl( hb_mouseIsPresent() );
}
mouse53.c63
HB_FUNCMHIDE(void)
HB_FUNC( MHIDE )
{
   hb_mouseSetCursor( FALSE );
}
mouse53.c68
HB_FUNCMSHOW(void)
HB_FUNC( MSHOW )
{
   hb_mouseSetCursor( TRUE );
}
mouse53.c73
HB_FUNCMSETCURSOR(void)
HB_FUNC( MSETCURSOR )
{
   hb_retl( hb_mouseGetCursor() );

   if( ISLOG( 1 ) )
      hb_mouseSetCursor( hb_parl( 1 ) );
}
mouse53.c78
HB_FUNCMROW(void)
HB_FUNC( MROW )
{
   if( ISLOG( 1 ) && hb_parl( 1 ) )
   {
      int iRow, iCol;

      hb_mouseGetPos( &iRow, &iCol );
      hb_retni( iRow );
   }
   else
      hb_retni( hb_mouseRow() );
}
mouse53.c86
HB_FUNCMCOL(void)
HB_FUNC( MCOL )
{
   if( ISLOG( 1 ) && hb_parl( 1 ) )
   {
      int iRow, iCol;

      hb_mouseGetPos( &iRow, &iCol );
      hb_retni( iCol );
   }
   else
      hb_retni( hb_mouseCol() );
}
mouse53.c99
HB_FUNCMSETPOS(void)
HB_FUNC( MSETPOS )
{
   if( ISNUM( 1 ) && ISNUM( 2 ) )
      hb_mouseSetPos( hb_parni( 1 ), hb_parni( 2 ) );
}
mouse53.c112
HB_FUNCMLEFTDOWN(void)
HB_FUNC( MLEFTDOWN )
{
   hb_retl( hb_mouseButtonState( M_BUTTON_LEFT ) );
}
mouse53.c118
HB_FUNCMRIGHTDOWN(void)
HB_FUNC( MRIGHTDOWN )
{
   hb_retl( hb_mouseButtonState( M_BUTTON_RIGHT ) );
}
mouse53.c123
HB_FUNCMDBLCLK(void)
HB_FUNC( MDBLCLK )
{
   hb_retni( hb_mouseGetDoubleClickSpeed() );

   if( ISNUM( 1 ) )
   {
      hb_mouseSetDoubleClickSpeed( hb_parni( 1 ) );
   }
}
mouse53.c128
HB_FUNCMSAVESTATE(void)
HB_FUNC( MSAVESTATE )
{
   int iLen = hb_mouseStorageSize();

   if( iLen > 0 )
   {
      BYTE * pBuffer = ( BYTE * ) hb_xgrab( iLen + 1 );

      hb_mouseSaveState( pBuffer );
      hb_retclen_buffer( ( char * ) pBuffer, iLen );
   }
   else
      hb_retc( NULL );
}
mouse53.c138
HB_FUNCMRESTSTATE(void)
HB_FUNC( MRESTSTATE )
{
   if( ISCHAR( 1 ) && hb_parclen( 1 ) == ( ULONG ) hb_mouseStorageSize() )
   {
      hb_mouseRestoreState( ( BYTE * ) hb_parc( 1 ) );
   }
}
mouse53.c153
HB_FUNCMSETBOUNDS(void)
HB_FUNC( MSETBOUNDS )
{
   hb_mouseSetBounds( hb_parni( 1 ), /* Defaults to zero on bad type */
                      hb_parni( 2 ), /* Defaults to zero on bad type */
                      ISNUM( 3 ) ? hb_parni( 3 ) : hb_gtMaxRow(),
                      ISNUM( 4 ) ? hb_parni( 4 ) : hb_gtMaxCol() );
}
mouse53.c161
mouseapi.c
TypeFunctionSourceLine
HB_EXPORT BOOLhb_mouseIsPresent( void )
HB_EXPORT BOOL hb_mouseIsPresent( void )
{
   BOOL fPresent = FALSE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseIsPresent()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      fPresent = HB_GTSELF_MOUSEISPRESENT( pGT );
      hb_gt_BaseFree( pGT );
   }
   return fPresent;
}
mouseapi.c73
HB_EXPORT BOOLhb_mouseGetCursor( void )
HB_EXPORT BOOL hb_mouseGetCursor( void )
{
   BOOL fVisible = FALSE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseGetCursor()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      fVisible = HB_GTSELF_MOUSEGETCURSOR( pGT );
      hb_gt_BaseFree( pGT );
   }
   return fVisible;
}
mouseapi.c89
HB_EXPORT VOIDhb_mouseSetCursor( BOOL fVisible )
HB_EXPORT void hb_mouseSetCursor( BOOL fVisible )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseSetCursor(%d)", (int) fVisible));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_MOUSESETCURSOR( pGT, fVisible );
      hb_gt_BaseFree( pGT );
   }
}
mouseapi.c105
HB_EXPORT INThb_mouseCol( void )
HB_EXPORT int hb_mouseCol( void )
{
   int iCol = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseCol()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iCol = HB_GTSELF_MOUSECOL( pGT );
      hb_gt_BaseFree( pGT );
   }
   return iCol;
}
mouseapi.c119
HB_EXPORT INThb_mouseRow( void )
HB_EXPORT int hb_mouseRow( void )
{
   int iRow = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseRow()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iRow = HB_GTSELF_MOUSEROW( pGT );
      hb_gt_BaseFree( pGT );
   }
   return iRow;
}
mouseapi.c135
HB_EXPORT VOIDhb_mouseGetPos( int * piRow, int * piCol )
HB_EXPORT void hb_mouseGetPos( int * piRow, int * piCol )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseSetPos(%p, %p)", piRow, piCol));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_MOUSEGETPOS( pGT, piRow, piCol );
      hb_gt_BaseFree( pGT );
   }
}
mouseapi.c151
HB_EXPORT VOIDhb_mouseSetPos( int iRow, int iCol )
HB_EXPORT void hb_mouseSetPos( int iRow, int iCol )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseSetPos(%d, %d)", iRow, iCol));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_MOUSESETPOS( pGT, iRow, iCol );
      hb_gt_BaseFree( pGT );
   }
}
mouseapi.c165
HB_EXPORT VOIDhb_mouseSetBounds( int iTop, int iLeft, int iBottom, int iRight )
HB_EXPORT void hb_mouseSetBounds( int iTop, int iLeft, int iBottom, int iRight )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseSetBounds(%d, %d, %d, %d)", iTop, iLeft, iBottom, iRight));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_MOUSESETBOUNDS( pGT, iTop, iLeft, iBottom, iRight );
      hb_gt_BaseFree( pGT );
   }
}
mouseapi.c179
HB_EXPORT VOIDhb_mouseGetBounds( int * piTop, int * piLeft, int * piBottom, int * piRight )
HB_EXPORT void hb_mouseGetBounds( int * piTop, int * piLeft, int * piBottom, int * piRight )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseSetBounds(%p, %p, %p, %p)", piTop, piLeft, piBottom, piRight));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_MOUSEGETBOUNDS( pGT, piTop, piLeft, piBottom, piRight );
      hb_gt_BaseFree( pGT );
   }
}
mouseapi.c193
HB_EXPORT INThb_mouseStorageSize( void )
HB_EXPORT int hb_mouseStorageSize( void )
{
   int iSize = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseStorageSize()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iSize = HB_GTSELF_MOUSESTORAGESIZE( pGT );
      hb_gt_BaseFree( pGT );
   }
   return iSize;
}
mouseapi.c207
HB_EXPORT VOIDhb_mouseSaveState( BYTE * pBuffer )
HB_EXPORT void hb_mouseSaveState( BYTE * pBuffer )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseSaveState(%p)", pBuffer));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_MOUSESAVESTATE( pGT, pBuffer );
      hb_gt_BaseFree( pGT );
   }
}
mouseapi.c223
HB_EXPORT VOIDhb_mouseRestoreState( BYTE * pBuffer )
HB_EXPORT void hb_mouseRestoreState( BYTE * pBuffer )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseRestoreState(%p)", pBuffer));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_MOUSERESTORESTATE( pGT, pBuffer );
      hb_gt_BaseFree( pGT );
   }
}
mouseapi.c237
HB_EXPORT INThb_mouseGetDoubleClickSpeed( void )
HB_EXPORT int hb_mouseGetDoubleClickSpeed( void )
{
   int iSpeed = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseGetDoubleClickSpeed()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iSpeed = HB_GTSELF_MOUSEGETDOUBLECLICKSPEED( pGT );
      hb_gt_BaseFree( pGT );
   }
   return iSpeed;
}
mouseapi.c251
HB_EXPORT VOIDhb_mouseSetDoubleClickSpeed( int iSpeed )
HB_EXPORT void hb_mouseSetDoubleClickSpeed( int iSpeed )
{
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseSetDoubleClickSpeed(%d)", iSpeed));

   pGT = hb_gt_Base();
   if( pGT )
   {
      HB_GTSELF_MOUSESETDOUBLECLICKSPEED( pGT, iSpeed );
      hb_gt_BaseFree( pGT );
   }
}
mouseapi.c267
HB_EXPORT INThb_mouseCountButton( void )
HB_EXPORT int hb_mouseCountButton( void )
{
   int iButtons = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseCountButton()"));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iButtons = HB_GTSELF_MOUSECOUNTBUTTON( pGT );
      hb_gt_BaseFree( pGT );
   }
   return iButtons;
}
mouseapi.c281
HB_EXPORT BOOLhb_mouseButtonState( int iButton )
HB_EXPORT BOOL hb_mouseButtonState( int iButton )
{
   BOOL fPressed = FALSE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseButtonState(%d)", iButton));

   pGT = hb_gt_Base();
   if( pGT )
   {
      fPressed = HB_GTSELF_MOUSEBUTTONSTATE( pGT, iButton );
      hb_gt_BaseFree( pGT );
   }
   return fPressed;
}
mouseapi.c297
HB_EXPORT BOOLhb_mouseButtonPressed( int iButton, int * piRow, int * piCol )
HB_EXPORT BOOL hb_mouseButtonPressed( int iButton, int * piRow, int * piCol )
{
   BOOL fPressed = FALSE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseButtonPressed(%d,%p,%p)", iButton, piRow, piCol));

   pGT = hb_gt_Base();
   if( pGT )
   {
      fPressed = HB_GTSELF_MOUSEBUTTONPRESSED( pGT, iButton, piRow, piCol );
      hb_gt_BaseFree( pGT );
   }
   return fPressed;
}
mouseapi.c313
HB_EXPORT BOOLhb_mouseButtonReleased( int iButton, int * piRow, int * piCol )
HB_EXPORT BOOL hb_mouseButtonReleased( int iButton, int * piRow, int * piCol )
{
   BOOL fReleased = FALSE;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseButtonReleased(%d,%p,%p)", iButton, piRow, piCol));

   pGT = hb_gt_Base();
   if( pGT )
   {
      fReleased = HB_GTSELF_MOUSEBUTTONRELEASED( pGT, iButton, piRow, piCol );
      hb_gt_BaseFree( pGT );
   }
   return fReleased;
}
mouseapi.c329
HB_EXPORT INThb_mouseReadKey( int iEventMask )
HB_EXPORT int hb_mouseReadKey( int iEventMask )
{
   int iKey = 0;
   PHB_GT pGT;

   HB_TRACE(HB_TR_DEBUG, ("hb_mouseReadKey(%d)", iEventMask));

   pGT = hb_gt_Base();
   if( pGT )
   {
      iKey = HB_GTSELF_MOUSEREADKEY( pGT, iEventMask );
      hb_gt_BaseFree( pGT );
   }
   return iKey;
}
mouseapi.c345
mousex.c
TypeFunctionSourceLine
HB_FUNCNUMBUTTONS(void)
HB_FUNC( NUMBUTTONS )
{
   hb_retni( hb_mouseCountButton() );
}
mousex.c61
HB_FUNCSETMOUSE(void)
HB_FUNC( SETMOUSE )
{
   BOOL fRow, fCol;

   hb_retl( hb_mouseGetCursor() );

   if( ISLOG( 1 ) )
      hb_mouseSetCursor( hb_parl( 1 ) );

   fRow = ISNUM( 2 );
   fCol = ISNUM( 3 );

   if( fRow || fCol )
   {
      int iRow = 0, iCol = 0;

      if( !fRow || !fCol )
         hb_mouseGetPos( &iRow, &iCol );

      if( fRow )
         iRow = hb_parni( 2 );
      if( fCol )
         iCol = hb_parni( 3 );

      hb_mouseSetPos( iRow, iCol );
   }
}
mousex.c66
mtran.c
TypeFunctionSourceLine
STATIC CHAR *hb_strMemotran( char * pszResult, ULONG * ulResultLen, const char * pszString, ULONG ulStringLen, char cHardcr, char cSoftcr )
static char * hb_strMemotran( char * pszResult, ULONG * ulResultLen, const char * pszString, ULONG ulStringLen, char cHardcr, char cSoftcr )
{
   ULONG ulStringPos = 0;
   ULONG ulResultPos = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_strMemotran(%s, %p, %s, %lu, %x, %x)", pszResult, ulResultLen, pszString, ulStringLen, cHardcr, cSoftcr));

   while( ulStringPos < ulStringLen )
   {
      if(      pszString[ ulStringPos ]     == HB_CHAR_HARD1 &&
               pszString[ ulStringPos + 1 ] == HB_CHAR_HARD2 )
      {
         pszResult[ ulResultPos++ ] = cHardcr;
         ulStringPos += 2;
      }
      else if( pszString[ ulStringPos ]     == HB_CHAR_SOFT1 &&
               pszString[ ulStringPos + 1 ] == HB_CHAR_SOFT2 )
      {
         pszResult[ ulResultPos++ ] = cSoftcr;
         ulStringPos += 2;
      }
      else
         pszResult[ ulResultPos++ ] = pszString[ ulStringPos++ ];
   }

   pszResult[ ulResultPos ] = '\0';

   *ulResultLen = ulResultPos;

   return pszResult;
}
mtran.c58
HB_FUNCMEMOTRAN(void)
HB_FUNC( MEMOTRAN )
{
   PHB_ITEM pString = hb_param( 1, HB_IT_STRING );

   if( pString )
   {
      char * pszResult = ( char * ) hb_xgrab( hb_itemGetCLen( pString ) + 1 );
      char cHardcr = ISCHAR( 2 ) ? *hb_parc( 2 ) : ';';
      char cSoftcr = ISCHAR( 3 ) ? *hb_parc( 3 ) : ' ';
      ULONG ulResultLen;

      hb_strMemotran( pszResult, &ulResultLen, hb_itemGetCPtr( pString ), hb_itemGetCLen( pString ), cHardcr, cSoftcr );
      hb_retclen_buffer( pszResult, ulResultLen );
   }
   else
      hb_retc( NULL );
}
mtran.c90
natmsg.c
TypeFunctionSourceLine
STATIC CHAR *hb_nationGetMsg( int iMsg )
static char * hb_nationGetMsg( int iMsg )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_nationGetMsg(%hu)", iMsg));

   return ( iMsg >= 1 && iMsg <= 13 ) ? ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + iMsg - 1 ) : ( char * ) "";
}
natmsg.c89
HB_FUNC__NATISAFFIRM(void)
HB_FUNC( __NATISAFFIRM )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );

   hb_retl( pItem && hb_itemGetCLen( pItem ) >= 1 && toupper( hb_itemGetCPtr( pItem )[ 0 ] ) == ( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 ) )[ 0 ] );
}
natmsg.c96
HB_FUNC__NATISNEGATIVE(void)
HB_FUNC( __NATISNEGATIVE )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_STRING );

   hb_retl( pItem && hb_itemGetCLen( pItem ) >= 1 && toupper( hb_itemGetCPtr( pItem )[ 0 ] ) == ( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 ) )[ 2 ] );
}
natmsg.c103
HB_FUNC__NATMSG(void)
HB_FUNC( __NATMSG )
{
   if( hb_pcount() == 0 )
      /* TODO: Replace this with Language API call. */
      hb_retc( "Invalid argument" );
   else if( ISNUM( 1 ) )
      hb_retc( hb_nationGetMsg( hb_parni( 1 ) ) );
   else
      hb_retc( NULL );
}
natmsg.c110
HB_FUNC__NATSORTVER(void)
HB_FUNC( __NATSORTVER )
{
   /* NOTE: CA-Cl*pper 5.2e Intl. will return: "NATSORT v1.2i x14 19/Mar/93" */
   /* NOTE: CA-Cl*pper 5.3  Intl. will return: "NATSORT v1.3i x19 06/Mar/95" */

   hb_retc( "NATSORT (Harbour)" );
}
natmsg.c121
HB_FUNC__NATMSGVER(void)
HB_FUNC( __NATMSGVER )
{
   /* NOTE: CA-Cl*pper 5.2e Intl. will return: "NATMSGS v1.2i x14 19/Mar/93" */
   /* NOTE: CA-Cl*pper 5.3  Intl. will return: "NATMSGS v1.3i x19 06/Mar/95" */

   hb_retc( "NATMSGS (Harbour)" );
}
natmsg.c129
natmsgu.c
TypeFunctionSourceLine
HB_FUNCISAFFIRM(void)
HB_FUNC( ISAFFIRM )
{
   HB_FUNC_EXEC( __NATISAFFIRM )
}

HB_FUNC_EXTERN( __NATISNEGATIVE );
natmsgu.c71
HB_FUNCISNEGATIVE(void)
HB_FUNC( ISNEGATIVE )
{
   HB_FUNC_EXEC( __NATISNEGATIVE )
}

HB_FUNC_EXTERN( __NATMSG );
natmsgu.c78
HB_FUNCNATIONMSG(void)
HB_FUNC( NATIONMSG )
{
   HB_FUNC_EXEC( __NATMSG )
}

/* NOTE: Intentionally using one leading underscore, like in Clipper.
         [vszakats] */

HB_FUNC_EXTERN( __NATSORTVER );
natmsgu.c85
HB_FUNC_NATSORTVER(void)
HB_FUNC( _NATSORTVER )
{
   HB_FUNC_EXEC( __NATSORTVER )
}

/* NOTE: Intentionally using one leading underscore, like in Clipper.
         [vszakats] */

HB_FUNC_EXTERN( __NATMSGVER );
natmsgu.c95
HB_FUNC_NATMSGVER(void)
HB_FUNC( _NATMSGVER )
{
   HB_FUNC_EXEC( __NATMSGVER )
}
natmsgu.c105
net.c
TypeFunctionSourceLine
CHAR *hb_netname( void )
char * hb_netname( void )
{
#if defined(HB_OS_UNIX) || ( defined(HB_OS_OS2) && defined(__GNUC__) )

#  if defined(__WATCOMC__)
      return hb_getenv( "HOSTNAME" );
#  else
      char * pszValue = ( char * ) hb_xgrab( MAXGETHOSTNAME + 1 );
      pszValue[ 0 ] = '\0';
      gethostname( pszValue, MAXGETHOSTNAME );
      return pszValue;
#  endif

#elif defined(HB_OS_DOS)

#  if defined(__DJGPP__) || defined(__RSX32__) || defined(__GNUC__)
      char * pszValue = ( char * ) hb_xgrab( MAXGETHOSTNAME + 1 );
      pszValue[ 0 ] = '\0';
      gethostname( pszValue, MAXGETHOSTNAME );
      return pszValue;
#  else
      union REGS regs;
      char * pszValue = ( char * ) hb_xgrab( 16 );
      pszValue[ 0 ] = '\0';

      regs.HB_XREGS.ax = 0x5E00;

      {
         struct SREGS sregs;

         regs.HB_XREGS.dx = FP_OFF( pszValue );
         sregs.ds = FP_SEG( pszValue );

         HB_DOS_INT86X( 0x21, ®s, ®s, &sregs );
      }

      return regs.h.ch == 0 ? hb_strdup( "" ) : pszValue;
#  endif

#elif defined(HB_OS_WIN_32)

   DWORD ulLen = MAX_COMPUTERNAME_LENGTH + 1;
   char * pszValue = ( char * ) hb_xgrab( ulLen );

   pszValue[ 0 ] = '\0';
   GetComputerNameA( pszValue, &ulLen );
   return pszValue;

#else

   return hb_strdup( "" );

#endif
}
net.c110
CHAR *hb_username( void )
char * hb_username( void )
{
#if defined(HB_OS_UNIX) || ( defined(HB_OS_OS2) && defined(__GNUC__) )

#  if defined(__WATCOMC__)
      return hb_getenv( "USER" );
#  else
      struct passwd * pwd;
      pwd = getpwuid( getuid() );
      return pwd ? hb_strdup( pwd->pw_name ) : hb_getenv( "USER" );
#  endif

#elif defined(HB_OS_WIN_32)

   DWORD ulLen = 256;
   char * pszValue = ( char * ) hb_xgrab( ulLen );

   pszValue[ 0 ] = '\0';
   GetUserNameA( pszValue, &ulLen );
   return pszValue;

#else

   return hb_strdup( "" );

#endif
}
net.c167
HB_FUNCNETNAME(void)
HB_FUNC( NETNAME )
{
   hb_retc_buffer( hb_netname() );
}
net.c195
HB_FUNCHB_USERNAME(void)
HB_FUNC( HB_USERNAME )
{
   hb_retc_buffer( hb_username() );
}
net.c200
oemansi.c
TypeFunctionSourceLine
HB_FUNCHB_ANSITOOEM(void)
HB_FUNC( HB_ANSITOOEM )
{
   PHB_ITEM pString = hb_param( 1, HB_IT_STRING );

   if( pString )
#if defined(HB_OS_WIN_32)
   {
      DWORD ulLen = hb_itemGetCLen( pString );
      char * pszDst = ( char * ) hb_xgrab( ulLen + 1 );

      CharToOemBuffA( ( LPCSTR ) hb_itemGetCPtr( pString ), ( LPSTR ) pszDst, ulLen );

      hb_retclen_buffer( pszDst, ulLen );
   }
#else
      hb_itemReturn( pString );
#endif
   else
      hb_retc( NULL );
}
oemansi.c61
HB_FUNCHB_OEMTOANSI(void)
HB_FUNC( HB_OEMTOANSI )
{
   PHB_ITEM pString = hb_param( 1, HB_IT_STRING );

   if( pString )
#if defined(HB_OS_WIN_32)
   {
      DWORD ulLen = hb_itemGetCLen( pString );
      char * pszDst = ( char * ) hb_xgrab( ulLen + 1 );

      OemToCharBuffA( ( LPCSTR ) hb_itemGetCPtr( pString ), ( LPSTR ) pszDst, ulLen );

      hb_retclen_buffer( pszDst, ulLen );
   }
#else
      hb_itemReturn( pString );
#endif
   else
      hb_retc( NULL );
}
oemansi.c82
oemansix.c
TypeFunctionSourceLine
HB_FUNCCONVTOOEMCP(void)
HB_FUNC( CONVTOOEMCP )
{
   HB_FUNC_EXEC( HB_ANSITOOEM );
}
oemansix.c60
HB_FUNCCONVTOANSICP(void)
HB_FUNC( CONVTOANSICP )
{
   HB_FUNC_EXEC( HB_OEMTOANSI );
}
oemansix.c65
oldbox.c
TypeFunctionSourceLine
HB_FUNC__BOX(void)
HB_FUNC( __BOX )
{
   PHB_ITEM pTop    = hb_param( 1, HB_IT_NUMERIC );
   PHB_ITEM pLeft   = hb_param( 2, HB_IT_NUMERIC );
   PHB_ITEM pBottom = hb_param( 3, HB_IT_NUMERIC );
   PHB_ITEM pRight  = hb_param( 4, HB_IT_NUMERIC );
   char * pszBox = hb_parc( 5 );

   if( pTop && pLeft && pBottom && pRight && pszBox )
      hb_gtBox( ( SHORT ) hb_itemGetNI( pTop ),
                ( SHORT ) hb_itemGetNI( pLeft),
                ( SHORT ) hb_itemGetNI( pBottom ),
                ( SHORT ) hb_itemGetNI( pRight ),
                ( BYTE * ) ( *pszBox ? pszBox : "         " ) );
}
oldbox.c59
HB_FUNC__BOXD(void)
HB_FUNC( __BOXD )
{
   PHB_ITEM pTop    = hb_param( 1, HB_IT_NUMERIC );
   PHB_ITEM pLeft   = hb_param( 2, HB_IT_NUMERIC );
   PHB_ITEM pBottom = hb_param( 3, HB_IT_NUMERIC );
   PHB_ITEM pRight  = hb_param( 4, HB_IT_NUMERIC );

   if( pTop && pLeft && pBottom && pRight )
      hb_gtBoxD( ( SHORT ) hb_itemGetNI( pTop ),
                 ( SHORT ) hb_itemGetNI( pLeft),
                 ( SHORT ) hb_itemGetNI( pBottom ),
                 ( SHORT ) hb_itemGetNI( pRight ) );
}
oldbox.c75
HB_FUNC__BOXS(void)
HB_FUNC( __BOXS )
{
   PHB_ITEM pTop    = hb_param( 1, HB_IT_NUMERIC );
   PHB_ITEM pLeft   = hb_param( 2, HB_IT_NUMERIC );
   PHB_ITEM pBottom = hb_param( 3, HB_IT_NUMERIC );
   PHB_ITEM pRight  = hb_param( 4, HB_IT_NUMERIC );

   if( pTop && pLeft && pBottom && pRight )
      hb_gtBoxS( ( SHORT ) hb_itemGetNI( pTop ),
                 ( SHORT ) hb_itemGetNI( pLeft),
                 ( SHORT ) hb_itemGetNI( pBottom ),
                 ( SHORT ) hb_itemGetNI( pRight ) );
}
oldbox.c89
oldclear.c
TypeFunctionSourceLine
HB_FUNC__ATCLEAR(void)
HB_FUNC( __ATCLEAR )
{
   if( hb_pcount() == 4 )
   {
      hb_gtSetPos( ( SHORT ) hb_parni( 1 ), ( SHORT ) hb_parni( 2 ) );
      hb_gtScroll( ( USHORT ) hb_parni( 1 ),
                   ( USHORT ) hb_parni( 2 ),
                   ( USHORT ) hb_parni( 3 ),
                   ( USHORT ) hb_parni( 4 ), 0, 0 );
   }
}
oldclear.c57
HB_FUNC__CLEAR(void)
HB_FUNC( __CLEAR )
{
   hb_gtScroll( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), 0, 0 );
   hb_gtSetPos( 0, 0 );
}
oldclear.c69
pad.c
TypeFunctionSourceLine
HB_FUNCPAD(void)
HB_FUNC( PAD )
{
   HB_FUNC_EXEC( PADR );
}
pad.c57
padc.c
TypeFunctionSourceLine
HB_FUNCPADC(void)
HB_FUNC( PADC )
{
   ULONG ulSize;
   BOOL bFreeReq;
   char * szText;
   long lLen = hb_parnl( 2 );

   if( lLen > 0 )
   {
      PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

      if( pItem && HB_IS_STRING( pItem ) && ( ULONG ) lLen == hb_itemGetCLen( pItem ) )
      {
         hb_itemReturn( pItem );
      }
      else
      {
         szText = hb_itemPadConv( pItem, &ulSize, &bFreeReq );
         if( szText )
         {
            if( ( ULONG ) lLen > ulSize )
            {
               char * szResult = ( char * ) hb_xgrab( lLen + 1 );
               char cPad;
               long ulPad = ( ( ULONG ) lLen - ulSize ) >> 1;

               cPad = ( ISCHAR( 3 ) ? *( hb_parc( 3 ) ) : ' ' );
               hb_xmemset( szResult, cPad, ulPad );
               hb_xmemcpy( szResult + ulPad, szText, ulSize );
               hb_xmemset( szResult + ulPad + ulSize, cPad,
                           ( ULONG ) lLen - ulSize - ulPad );

               hb_retclen_buffer( szResult, ( ULONG ) lLen );
               if( bFreeReq )
                  hb_xfree( szText );
            }
            else
            {
               if( bFreeReq )
                  hb_retclen_buffer( szText, ( ULONG ) lLen );
               else
                  hb_retclen( szText, lLen );
            }
         }
         else
            hb_retc( NULL );
      }
   }
   else
      hb_retc( NULL );
}
padc.c57
padl.c
TypeFunctionSourceLine
HB_FUNCPADL(void)
HB_FUNC( PADL )
{
   ULONG ulSize;
   BOOL bFreeReq;
   char * szText;
   long lLen = hb_parnl( 2 );

   if( lLen > 0 )
   {
      PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

      if( pItem && HB_IS_STRING( pItem ) && ( ULONG ) lLen == hb_itemGetCLen( pItem ) )
      {
         hb_itemReturn( pItem );
      }
      else
      {
         szText = hb_itemPadConv( pItem, &ulSize, &bFreeReq );
         if( szText )
         {
            if( ( ULONG ) lLen > ulSize )
            {
               char * szResult = ( char * ) hb_xgrab( lLen + 1 );
               char cPad;

               cPad = ( ISCHAR( 3 ) ? *( hb_parc( 3 ) ) : ' ' );
               hb_xmemset( szResult, cPad, ( ULONG ) lLen - ulSize );
               hb_xmemcpy( szResult + ( ULONG ) lLen - ulSize, szText, ulSize );

               hb_retclen_buffer( szResult, ( ULONG ) lLen );
               if( bFreeReq )
                  hb_xfree( szText );
            }
            else
            {
               if( bFreeReq )
                  hb_retclen_buffer( szText, ( ULONG ) lLen );
               else
                  hb_retclen( szText, lLen );
            }
         }
         else
            hb_retc( NULL );
      }
   }
   else
      hb_retc( NULL );
}
padl.c57
padr.c
TypeFunctionSourceLine
HB_FUNCPADR(void)
HB_FUNC( PADR )
{
   ULONG ulSize;
   BOOL bFreeReq;
   char * szText;
   long lLen = hb_parnl( 2 );

   if( lLen > 0 )
   {
      PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

      if( pItem && HB_IS_STRING( pItem ) && ( ULONG ) lLen == hb_itemGetCLen( pItem ) )
      {
         hb_itemReturn( pItem );
      }
      else
      {
         szText = hb_itemPadConv( pItem, &ulSize, &bFreeReq );
         if( szText )
         {
            if( ( ULONG ) lLen > ulSize )
            {
               char * szResult = ( char * ) hb_xgrab( lLen + 1 );
               char cPad;

               cPad = ( ISCHAR( 3 ) ? *( hb_parc( 3 ) ) : ' ' );
               hb_xmemcpy( szResult, szText, ulSize );
               hb_xmemset( szResult + ulSize, cPad, ( ULONG ) lLen - ulSize );

               hb_retclen_buffer( szResult, ( ULONG ) lLen );
               if( bFreeReq )
                  hb_xfree( szText );
            }
            else
            {
               if( bFreeReq )
                  hb_retclen_buffer( szText, ( ULONG ) lLen );
               else
                  hb_retclen( szText, lLen );
            }
         }
         else
            hb_retc( NULL );
      }
   }
   else
      hb_retc( NULL );
}
padr.c57
philes.c
TypeFunctionSourceLine
HB_FUNCFOPEN(void)
HB_FUNC( FOPEN )
{
   if( ISCHAR( 1 ) )
   {
      hb_retnint( ( HB_NHANDLE ) hb_fsOpen( ( BYTE * ) hb_parc( 1 ),
                  ISNUM( 2 ) ? ( USHORT ) hb_parni( 2 ) : FO_READ | FO_COMPAT ) );
      hb_fsSetFError( hb_fsError() );
   }
   else
   {
      hb_fsSetFError( 0 );
      /* NOTE: Undocumented but existing Clipper Run-time error */
      hb_errRT_BASE( EG_ARG, 2021, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
   }
}
philes.c57
HB_FUNCFCREATE(void)
HB_FUNC( FCREATE )
{
   if( ISCHAR( 1 ) )
   {
      hb_retnint( ( HB_NHANDLE ) hb_fsCreate( ( BYTE * ) hb_parc( 1 ),
                  ISNUM( 2 ) ? hb_parni( 2 ) : FC_NORMAL ) );
      hb_fsSetFError( hb_fsError() );
   }
   else
   {
      hb_retni( F_ERROR );
      hb_fsSetFError( 0 );
   }
}
philes.c73
HB_FUNCHB_FCREATE(void)
HB_FUNC( HB_FCREATE )
{
   if( ISCHAR( 1 ) )
   {
      hb_retnint( ( HB_NHANDLE ) hb_fsCreateEx( ( BYTE * ) hb_parc( 1 ),
                  ISNUM( 2 ) ? hb_parni( 2 ) : FC_NORMAL,
                  ISNUM( 3 ) ? ( USHORT ) hb_parni( 3 ) : FO_COMPAT ) );
      hb_fsSetFError( hb_fsError() );
   }
   else
   {
      hb_retni( F_ERROR );
      hb_fsSetFError( 0 );
   }
}
philes.c88
HB_FUNCFREAD(void)
HB_FUNC( FREAD )
{
   PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING );
   USHORT uiError = 0;
   ULONG ulRead = 0;

   if( ISNUM( 1 ) && pBuffer && ISBYREF( 2 ) && ISNUM( 3 ) )
   {
      ulRead = hb_parnl( 3 );

      /* NOTE: CA-Cl*pper determines the maximum size by calling _parcsiz()
               instead of _parclen(), this means that the maximum read length
               will be one more than the length of the passed buffer, because
               the terminating zero could be used if needed. [vszakats] */

      if( ulRead <= hb_parcsiz( 2 ) )
      {
         /* NOTE: Warning, the read buffer will be directly modified,
                  this is normal here ! [vszakats] */

         /* Unshare the item to avoid GPF on static buffers and changing
            other items which shares this buffer. [druzus] */
         pBuffer = hb_itemUnShareString( pBuffer );

         ulRead = hb_fsReadLarge( hb_numToHandle( hb_parnint( 1 ) ),
                                  ( BYTE * ) hb_itemGetCPtr( pBuffer ),
                                  ulRead );
         uiError = hb_fsError();
      }
      else
         ulRead = 0;
   }

   hb_retnint( ulRead );
   hb_fsSetFError( uiError );
}
philes.c104
HB_FUNCFWRITE(void)
HB_FUNC( FWRITE )
{
   USHORT uiError = 0;

   if( ISNUM( 1 ) && ISCHAR( 2 ) )
   {
      hb_retnl( hb_fsWriteLarge( hb_numToHandle( hb_parnint( 1 ) ),
                                 ( BYTE * ) hb_parc( 2 ),
                                 ISNUM( 3 ) ? ( ULONG ) hb_parnl( 3 ) : hb_parclen( 2 ) ) );
      uiError = hb_fsError();
   }
   else
      hb_retni( 0 );
   hb_fsSetFError( uiError );
}
philes.c141
HB_FUNCFERROR(void)
HB_FUNC( FERROR )
{
   hb_retni( hb_fsGetFError() );
}
philes.c157
HB_FUNCFCLOSE(void)
HB_FUNC( FCLOSE )
{
   USHORT uiError = 0;
   if( ISNUM( 1 ) )
   {
      hb_fsClose( hb_numToHandle( hb_parnint( 1 ) ) );
      uiError = hb_fsError();
      hb_retl( uiError == 0 );
   }
   else
      hb_retl( FALSE );
   hb_fsSetFError( uiError );
}
philes.c162
HB_FUNCFERASE(void)
HB_FUNC( FERASE )
{
   USHORT uiError = 3;

   if( ISCHAR( 1 ) )
   {
      hb_retni( hb_fsDelete( ( BYTE * ) hb_parc( 1 ) ) ? 0 : F_ERROR );
      uiError = hb_fsError();
   }
   else
      hb_retni( F_ERROR );
   hb_fsSetFError( uiError );
}
philes.c176
HB_FUNCFRENAME(void)
HB_FUNC( FRENAME )
{
   USHORT uiError = 2;

   if( ISCHAR( 1 ) && ISCHAR( 2 ) )
   {
      hb_retni( hb_fsRename( ( BYTE * ) hb_parc( 1 ),
                             ( BYTE * ) hb_parc( 2 ) ) ? 0 : F_ERROR );
      uiError = hb_fsError();
   }
   else
      hb_retni( F_ERROR );
   hb_fsSetFError( uiError );
}
philes.c190
HB_FUNCFSEEK(void)
HB_FUNC( FSEEK )
{
   USHORT uiError = 0;

   if( ISNUM( 1 ) && ISNUM( 2 ) )
   {
      hb_retnint( hb_fsSeekLarge( hb_numToHandle( hb_parnint( 1 ) ),
                                  hb_parnint( 2 ),
                                  ISNUM( 3 ) ? ( USHORT ) hb_parni( 3 ) : FS_SET ) );
      uiError = hb_fsError();
   }
   else
      hb_retni( 0 );

   hb_fsSetFError( uiError );
}
philes.c205
HB_FUNCFREADSTR(void)
HB_FUNC( FREADSTR )
{
   USHORT uiError = 0;

   if( ISNUM( 1 ) && ISNUM( 2 ) )
   {
      ULONG ulToRead = ( ULONG ) hb_parnl( 2 );

      if( ulToRead > 0 )
      {
         HB_FHANDLE fhnd = ( HB_FHANDLE ) hb_parni( 1 );
         BYTE * buffer = ( BYTE * ) hb_xgrab( ulToRead + 1 );
         ULONG ulRead;

         ulRead = hb_fsReadLarge( fhnd, buffer, ulToRead );
         uiError = hb_fsError();
         buffer[ ulRead ] = '\0';

         /* NOTE: Clipper will not return zero chars from this functions. */
         hb_retc_buffer( ( char * ) buffer );
      }
      else
         hb_retc( NULL );
   }
   else
      hb_retc( NULL );
   hb_fsSetFError( uiError );
}

/* NOTE: This function should not return the leading and trailing */
philes.c222
HB_FUNCCURDIR(void)
HB_FUNC( CURDIR )
{
   BYTE byBuffer[ _POSIX_PATH_MAX + 1 ];

   hb_fsCurDirBuff( ( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) ?
      ( USHORT )( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) : 0, byBuffer, _POSIX_PATH_MAX + 1 );

   hb_retc( ( char * ) byBuffer );
}
philes.c256
HB_FUNCHB_FEOF(void)
HB_FUNC( HB_FEOF )
{
   USHORT uiError = 6;

   if( ISNUM( 1 ) )
   {
      hb_retl( hb_fsEof( hb_numToHandle( hb_parnint( 1 ) ) ) );
      uiError = hb_fsError();
   }
   else
      hb_retl( TRUE );
   hb_fsSetFError( uiError );
}
philes.c266
HB_FUNCHB_FCOMMIT(void)
HB_FUNC( HB_FCOMMIT )
{
   USHORT uiError = 6;

   if( ISNUM( 1 ) )
   {
      hb_fsCommit( hb_numToHandle( hb_parnint( 1 ) ) );
      uiError = hb_fsError();
   }

   hb_fsSetFError( uiError );
}
philes.c280
HB_FUNCHB_OSERROR(void)
HB_FUNC( HB_OSERROR )
{
   hb_retni( hb_fsOsError() );
}
philes.c293
HB_FUNCHB_OSPATHSEPARATOR(void)
HB_FUNC( HB_OSPATHSEPARATOR )
{
   const char ret[ 2 ] = { HB_OS_PATH_DELIM_CHR, 0 };
   hb_retc( ret );
}
philes.c298
HB_FUNCHB_OSPATHLISTSEPARATOR(void)
HB_FUNC( HB_OSPATHLISTSEPARATOR )
{
   const char ret[ 2 ] = { HB_OS_PATH_LIST_SEP_CHR, 0 };
   hb_retc( ret );
}
philes.c304
HB_FUNCHB_OSPATHDELIMITERS(void)
HB_FUNC( HB_OSPATHDELIMITERS )
{
   hb_retc( HB_OS_PATH_DELIM_CHR_LIST );
}
philes.c310
HB_FUNCHB_OSDRIVESEPARATOR(void)
HB_FUNC( HB_OSDRIVESEPARATOR )
{
#ifdef HB_OS_HAS_DRIVE_LETTER
   const char ret[ 2 ] = { HB_OS_DRIVE_DELIM_CHR, 0 };
   hb_retc( ret );
#else
   hb_retc( NULL );
#endif
}
philes.c315
HB_FUNCHB_OSFILEMASK(void)
HB_FUNC( HB_OSFILEMASK )
{
   hb_retc( HB_OS_ALLFILE_MASK );
}
philes.c325
philes53.c
TypeFunctionSourceLine
HB_FUNCFSETDEVMOD(void)
HB_FUNC( FSETDEVMOD )
{
   /* C53 checks only number of parameters: hb_pcount() == 2 */
   if( ISNUM( 1 ) && ISNUM( 2 ) )
   {
      hb_fsSetDevMode( hb_numToHandle( hb_parnint( 1 ) ), ( USHORT ) hb_parni( 2 ) );
      hb_fsSetFError( hb_fsError() );
   }
   /* NOTE: INCOMPATIBILITY! C53 will return the device flags 
            before applying the new setting, Harbour will 
            always return 0. [vszakats] */
   hb_retni( 0 );
}
philes53.c60
philesx.c
TypeFunctionSourceLine
HB_FUNCCURDRIVE(void)
HB_FUNC( CURDRIVE )
{
   char szDrive[ 1 ];

   szDrive[ 0 ] = ( ( char ) hb_fsCurDrv() ) + 'A';
   hb_retclen( szDrive, 1 );

   if( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 )
   {
      while( hb_fsChDrv( ( BYTE )( toupper( *hb_parc( 1 ) ) - 'A' ) ) != 0 )
      {
         USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 6001, "Operating system error", HB_ERR_FUNCNAME, 0, EF_CANDEFAULT | EF_CANRETRY, HB_ERR_ARGS_BASEPARAMS );

         if( uiAction != E_RETRY )
            break;
      }
   }
}
philesx.c63
rat.c
TypeFunctionSourceLine
HB_FUNCRAT(void)
HB_FUNC( RAT )
{
   ULONG ulSubLen = hb_parclen( 1 );

   if( ulSubLen )
   {
      long lPos = hb_parclen( 2 ) - ulSubLen;

      if( lPos >= 0 )
      {
         char * pszSub = hb_parc( 1 );
         char * pszText = hb_parc( 2 );
         BOOL bFound = FALSE;

         while( lPos >= 0 && !bFound )
         {
            if( *( pszText + lPos ) == *pszSub )
               bFound = ( memcmp( pszSub, pszText + lPos, ulSubLen ) == 0 );
            lPos--;
         }

         hb_retnl( bFound ? lPos + 2 : 0 );
      }
      else
         hb_retni( 0 );
   }
   else
      /* This function never seems to raise an error */
      hb_retni( 0 );
}
rat.c55
replic.c
TypeFunctionSourceLine
HB_FUNCREPLICATE(void)
HB_FUNC( REPLICATE )
{
   if( ISCHAR( 1 ) && ISNUM( 2 ) )
   {
      long lTimes = hb_parnl( 2 );

      if( lTimes > 0 )
      {
         ULONG ulLen = hb_parclen( 1 );

         if( ( double ) ( ( double ) ulLen * ( double ) lTimes ) < ( double ) ULONG_MAX )
         {
            char * szText = hb_parc( 1 );
            char * szResult = ( char * ) hb_xgrab( ( ulLen * lTimes ) + 1 );
            char * szPtr = szResult;
            long i;

            for( i = 0; i < lTimes; i++ )
            {
               hb_xmemcpy( szPtr, szText, ulLen );
               szPtr += ulLen;
            }

            hb_retclen_buffer( szResult, ulLen * lTimes );
         }
         else
            hb_errRT_BASE_SubstR( EG_STROVERFLOW, 1234, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
      }
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1106, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
replic.c59
right.c
TypeFunctionSourceLine
HB_FUNCRIGHT(void)
HB_FUNC( RIGHT )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText && ISNUM( 2 ) )
   {
      long lLen = hb_parnl( 2 );
      if( lLen <= 0 )
         hb_retc( NULL );
      else
      {
         ULONG ulText = hb_itemGetCLen( pText );
         if( ( ULONG ) lLen >= ulText )
            hb_itemReturn( pText );
         else
            hb_retclen( hb_itemGetCPtr( pText ) + ulText - lLen, lLen );
      }
   }
   else
      hb_retc( NULL ); /* Clipper doesn't error */
}
right.c59
round.c
TypeFunctionSourceLine
HB_FUNCINT(void)
HB_FUNC( INT )
{
   PHB_ITEM pNumber = hb_param( 1, HB_IT_NUMERIC );

   if( pNumber )
   {
      if( HB_IS_NUMINT( pNumber ) )
         hb_itemReturn( pNumber );
      else
      {
         int iWidth;

         hb_itemGetNLen( pNumber, &iWidth, NULL );
         hb_retnlen( hb_numInt( hb_itemGetND( pNumber ) ), iWidth, 0 );
      }
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1090, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
round.c73
HB_FUNCROUND(void)
HB_FUNC( ROUND )
{
   PHB_ITEM pNumber = hb_param( 1, HB_IT_NUMERIC );

   if( pNumber && ISNUM( 2 ) )
   {
      int iDec = hb_parni( 2 );

#ifdef HB_C52_STRICT
      /* In CA-Cl*pper ROUND() always returns double item, what in some
       * applications may be important due to different formatting rules
       * when SET FIXED is ON [druzus]
       */
      hb_retndlen( hb_numRound( hb_itemGetND( pNumber ), iDec ), 0, HB_MAX( iDec, 0 ) );
#else
      if( iDec == 0 && HB_IS_NUMINT( pNumber ) )
         hb_retnint( hb_itemGetNInt( pNumber ) );
      else
         hb_retnlen( hb_numRound( hb_itemGetND( pNumber ), iDec ), 0, HB_MAX( iDec, 0 ) );
#endif
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1094, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
round.c93
run.c
TypeFunctionSourceLine
HB_FUNC__RUN(void)
HB_FUNC( __RUN )
{
   if( ISCHAR( 1 ) && hb_gtSuspend() == 0 )
   {
      system( hb_parc( 1 ) );

      if( hb_gtResume() != 0 )
      {
         /* an error should be generated here !! Something like */
         /* hb_errRT_BASE_Ext1( EG_GTRESUME, 6002, NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT ); */
      }
   }
}
run.c60
samples.c
TypeFunctionSourceLine
STATIC CHAR *hb_SecToTimeStr( char * pszTime, ULONG ulTime )
static char * hb_SecToTimeStr( char * pszTime, ULONG ulTime )
{
   USHORT uiValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_SecToTimeStr(%s, %lu)", pszTime, ulTime));

   uiValue = ( USHORT ) ( ( ulTime / 3600 ) % 24 );
   pszTime[ 0 ] = ( char ) ( uiValue / 10 ) + '0';
   pszTime[ 1 ] = ( char ) ( uiValue % 10 ) + '0';
   pszTime[ 2 ] = ':';
   uiValue = ( USHORT ) ( ( ulTime / 60 ) % 60 );
   pszTime[ 3 ] = ( char ) ( uiValue / 10 ) + '0';
   pszTime[ 4 ] = ( char ) ( uiValue % 10 ) + '0';
   pszTime[ 5 ] = ':';
   uiValue = ( USHORT ) ( ulTime % 60 );
   pszTime[ 6 ] = ( char ) ( uiValue / 10 ) + '0';
   pszTime[ 7 ] = ( char ) ( uiValue % 10 ) + '0';
   pszTime[ 8 ] = '\0';

   return pszTime;
}
samples.c57
STATIC ULONGhb_TimeStrToSec( char * pszTime )
static ULONG hb_TimeStrToSec( char * pszTime )
{
   ULONG ulLen;
   ULONG ulTime = 0;

   HB_TRACE(HB_TR_DEBUG, ("hb_TimeStrToSec(%s)", pszTime));

   ulLen = strlen( pszTime );

   if( ulLen >= 1 )
      ulTime += ( ULONG ) hb_strVal( pszTime, ulLen ) * 3600;

   if( ulLen >= 4 )
      ulTime += ( ULONG ) hb_strVal( pszTime + 3, ulLen - 3 ) * 60;

   if( ulLen >= 7 )
      ulTime += ( ULONG ) hb_strVal( pszTime + 6, ulLen - 6 );

   return ulTime;
}
samples.c79
HB_FUNCDAYS(void)
HB_FUNC( DAYS )
{
   hb_retnl( hb_parnl( 1 ) / 86400 );
}
samples.c100
HB_FUNCELAPTIME(void)
HB_FUNC( ELAPTIME )
{
   ULONG ulStart = hb_TimeStrToSec( hb_parcx( 1 ) );
   ULONG ulEnd = hb_TimeStrToSec( hb_parcx( 2 ) );
   char szTime[ 9 ];

   hb_retc( hb_SecToTimeStr( szTime, ( ulEnd < ulStart ? 86400 : 0 ) + ulEnd - ulStart ) );
}
samples.c105
HB_FUNCSECS(void)
HB_FUNC( SECS )
{
   hb_retnl( hb_TimeStrToSec( hb_parcx( 1 ) ) );
}
samples.c114
HB_FUNCTSTRING(void)
HB_FUNC( TSTRING )
{
   char szTime[ 9 ];

   hb_retc( hb_SecToTimeStr( szTime, hb_parnl( 1 ) ) );
}
samples.c119
saverest.c
TypeFunctionSourceLine
STATIC VOIDhb_getScreenRange( USHORT * pusMin, USHORT * pusMax, BOOL fNoCheck, BOOL fVertical )
static void hb_getScreenRange( USHORT * pusMin, USHORT * pusMax,
                               BOOL fNoCheck, BOOL fVertical )
{
   int iFrom, iTo, iMax;

   if( fVertical )
   {
      iMax  = hb_gtMaxRow();
      iFrom = hb_parni( 1 );
      iTo   = ISNUM( 3 ) ? hb_parni( 3 ) : iMax;
   }
   else
   {
      iMax = hb_gtMaxCol();
      iFrom = hb_parni( 2 );
      iTo   = ISNUM( 4 ) ? hb_parni( 4 ) : iMax;
   }

   if( iFrom < 0 )
      iFrom = 0;
   else if( iFrom > iMax && !fNoCheck )
      iFrom = iMax;

   if( iTo < 0 )
      iTo = 0;
   else if( iTo > iMax && !fNoCheck )
      iTo = iMax;

   if( iFrom > iTo )
   {
      *pusMin = ( USHORT ) iTo;
      *pusMax = ( USHORT ) iFrom;
   }
   else
   {
      *pusMin = ( USHORT ) iFrom;
      *pusMax = ( USHORT ) iTo;
   }
}
saverest.c56
HB_FUNCSAVESCREEN(void)
HB_FUNC( SAVESCREEN )
{
   USHORT uiTop, uiLeft, uiBottom, uiRight;
   ULONG  ulSize;
   void * pBuffer;
#if defined( HB_EXTENSION )
   BOOL fNoCheck = hb_parl( 5 );
#else
   BOOL fNoCheck = FALSE;
#endif

   hb_getScreenRange( &uiTop, &uiBottom, fNoCheck, TRUE );
   hb_getScreenRange( &uiLeft, &uiRight, fNoCheck, FALSE );

   hb_gtRectSize( uiTop, uiLeft, uiBottom, uiRight, &ulSize );
   pBuffer = hb_xgrab( ulSize + 1 );

   hb_gtSave( uiTop, uiLeft, uiBottom, uiRight, pBuffer );
   hb_retclen_buffer( ( char * ) pBuffer, ulSize );
}
saverest.c96
HB_FUNCRESTSCREEN(void)
HB_FUNC( RESTSCREEN )
{
   if( ISCHAR( 5 ) )
   {
      USHORT uiTop, uiLeft, uiBottom, uiRight;
#if defined( HB_EXTENSION )
      BOOL fNoCheck = hb_parl( 6 );
#else
      BOOL fNoCheck = FALSE;
#endif

      hb_getScreenRange( &uiTop, &uiBottom, fNoCheck, TRUE );
      hb_getScreenRange( &uiLeft, &uiRight, fNoCheck, FALSE );

      hb_gtRest( uiTop, uiLeft, uiBottom, uiRight, ( void * ) hb_parc( 5 ) );
   }
}
saverest.c117
scroll.c
TypeFunctionSourceLine
HB_FUNCSCROLL(void)
HB_FUNC( SCROLL )
{
   int iMaxRow = hb_gtMaxRow();
   int iMaxCol = hb_gtMaxCol();

   int iTop;
   int iLeft;
   int iBottom;
   int iRight;

   /* Enforce limits of (0,0) to (MAXROW(),MAXCOL()) */

   iTop = hb_parni( 1 ); /* Defaults to zero on bad type */
   if( iTop < 0 )
      iTop = 0;
   else if( iTop > iMaxRow )
      iTop = iMaxRow;

   iLeft = hb_parni( 2 ); /* Defaults to zero on bad type */
   if( iLeft < 0 )
      iLeft = 0;
   else if( iLeft > iMaxCol )
      iLeft = iMaxCol;

   if( ISNUM( 3 ) )
   {
      iBottom = hb_parni( 3 );
      if( iBottom < 0 )
         iBottom = 0;
      else if( iBottom > iMaxRow )
         iBottom = iMaxRow;
   }
   else
      iBottom = iMaxRow;

   if( ISNUM( 4 ) )
   {
      iRight = hb_parni( 4 );
      if( iRight < 0 )
         iRight = 0;
      else if( iRight > iMaxCol )
         iRight = iMaxCol;
   }
   else
      iRight = iMaxCol;

   hb_gtScroll( ( USHORT ) iTop,
                ( USHORT ) iLeft,
                ( USHORT ) iBottom,
                ( USHORT ) iRight,
                ( SHORT ) hb_parni( 5 ), /* Defaults to zero on bad type */
                ( SHORT ) hb_parni( 6 ) ); /* Defaults to zero on bad type */
}
scroll.c58
scrrow.c
TypeFunctionSourceLine
HB_FUNCHB_SCRMAXROW(void)
HB_FUNC( HB_SCRMAXROW ) /* Return the maximum screen row number (zero origin) */
{
   USHORT uiRows, uiCols;
   hb_gtScrDim( &uiRows, &uiCols );
   hb_retni( uiRows - 1 );
}
scrrow.c66
HB_FUNCHB_SCRMAXCOL(void)
HB_FUNC( HB_SCRMAXCOL ) /* Return the maximum screen column number (zero origin) */
{
   USHORT uiRows, uiCols;
   hb_gtScrDim( &uiRows, &uiCols );
   hb_retni( uiCols - 1 );
}
scrrow.c73
secondfs.c
TypeFunctionSourceLine
HB_FUNCSECONDSCPU(void)
HB_FUNC( SECONDSCPU )
{
   hb_retnd( hb_secondsCPU( hb_parni( 1 ) ) );
}
secondfs.c58
seconds.c
TypeFunctionSourceLine
HB_EXPORT VOIDhb_dateTimeStamp( LONG * plJulian, LONG * plMilliSec )
HB_EXPORT void hb_dateTimeStamp( LONG * plJulian, LONG * plMilliSec )
{
#if defined(HB_OS_WIN_32)
   SYSTEMTIME st;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStamp(%p,%p)", plJulian, plMilliSec));

   GetLocalTime( &st );

   *plJulian = hb_dateEncode( st.wYear, st.wMonth, st.wDay );
   *plMilliSec = ( ( st.wHour * 60 + st.wMinute ) * 60 + st.wSecond ) * 1000 +
                 st.wMilliseconds;
#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
   struct timeval tv;
   struct tm st;
   time_t seconds;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStamp(%p,%p)", plJulian, plMilliSec));

   gettimeofday( &tv, NULL );
   seconds = tv.tv_sec;
   localtime_r( &seconds, &st );
   *plJulian = hb_dateEncode( st.tm_year + 1900, st.tm_mon + 1, st.tm_mday );
   *plMilliSec = ( ( st.tm_hour * 60 + st.tm_min ) * 60 + st.tm_sec ) * 1000 +
                 tv.tv_usec / 1000;
#elif defined( HB_OS_BSD )
   struct timeval tv;
   struct tm * st;
   time_t seconds;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStamp(%p,%p)", plJulian, plMilliSec));

   gettimeofday( &tv, NULL );
   seconds = tv.tv_sec;
   st = localtime( &seconds );
   *plJulian = hb_dateEncode( st->tm_year + 1900, st->tm_mon + 1, st->tm_mday );
   *plMilliSec = ( ( st->tm_hour * 60 + st->tm_min ) * 60 + st->tm_sec ) * 1000 +
                 tv.tv_usec / 1000.0;
#else
   struct timeb tb;
   struct tm * st;
   time_t seconds;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateTimeStamp(%p,%p)", plJulian, plMilliSec));

   ftime( &tb );
   seconds = tb.time;
   st = localtime( &seconds );

   *plJulian = hb_dateEncode( st->tm_year + 1900, st->tm_mon + 1, st->tm_mday );
   *plMilliSec = ( ( st->tm_hour * 60 + st->tm_min ) * 60 + st->tm_sec ) * 1000 +
                 tb.millitm;
#endif
}
seconds.c76
HB_EXPORT HB_ULONGhb_dateMilliSeconds( void )
HB_EXPORT HB_ULONG hb_dateMilliSeconds( void )
{
#if defined(HB_OS_WIN_32)
   SYSTEMTIME st;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()"));

   GetLocalTime( &st );

   return ( HB_ULONG ) hb_dateEncode( st.wYear, st.wMonth, st.wDay ) * 86400000L +
          ( ( st.wHour * 60 + st.wMinute ) * 60 + st.wSecond ) * 1000 +
          st.wMilliseconds;
#elif ( defined( HB_OS_LINUX ) || defined( HB_OS_BSD ) ) && !defined( __WATCOMC__ )
   struct timeval tv;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()"));

   gettimeofday( &tv, NULL );

   return ( HB_ULONG ) tv.tv_sec * 1000 + tv.tv_usec / 1000;
#else
   struct timeb tb;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateMilliSeconds()"));

   ftime( &tb );

   return ( HB_ULONG ) tb.time * 1000 + tb.millitm;
#endif
}
seconds.c131
HB_EXPORT DOUBLEhb_dateSeconds( void )
HB_EXPORT double hb_dateSeconds( void )
{
#if defined(HB_OS_WIN_32)
   SYSTEMTIME SystemTime;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateSeconds()"));

   GetLocalTime( &SystemTime );

   return ( SystemTime.wHour * 3600 ) +
          ( SystemTime.wMinute * 60 ) +
            SystemTime.wSecond +
          ( ( double ) SystemTime.wMilliseconds / 1000.0 );
#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
   struct timeval tv;
   struct tm oTime;
   time_t seconds;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateSeconds()"));

   gettimeofday( &tv, NULL );
   seconds = tv.tv_sec;
   localtime_r( &seconds, &oTime );
   return ( oTime.tm_hour * 3600 ) +
          ( oTime.tm_min * 60 ) +
            oTime.tm_sec +
          ( ( double ) tv.tv_usec / 1000000.0 );
#elif defined( HB_OS_BSD )
   struct timeval tv;
   struct tm * oTime;
   time_t seconds;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateSeconds()"));

   gettimeofday( &tv, NULL );
   seconds = tv.tv_sec;
   oTime = localtime( &seconds );
   return ( oTime->tm_hour * 3600 ) +
          ( oTime->tm_min * 60 ) +
            oTime->tm_sec +
          ( ( double ) tv.tv_usec / 1000000.0 );
#else
   struct timeb tb;
   struct tm * oTime;
   time_t seconds;

   HB_TRACE(HB_TR_DEBUG, ("hb_dateSeconds()"));

   ftime( &tb );
   seconds = tb.time;
   oTime = localtime( &seconds );

   return ( oTime->tm_hour * 3600 ) +
          ( oTime->tm_min * 60 ) +
            oTime->tm_sec +
          ( ( double ) tb.millitm / 1000.0 );
#endif
}
seconds.c162
HB_FUNCSECONDS(void)
HB_FUNC( SECONDS )
{
   hb_retnd( hb_dateSeconds() );
}
seconds.c221
HB_FUNCHB_CLOCKS2SECS(void)
HB_FUNC( HB_CLOCKS2SECS )
{
#ifdef CLOCKS_PER_SEC
   hb_retnd( ( double ) hb_parnint( 1 ) / CLOCKS_PER_SEC );
#else
   hb_retnd( ( double ) hb_parnint( 1 ) / 1000 );
#endif
}
seconds.c226
HB_EXPORT DOUBLEhb_secondsCPU( int n )
HB_EXPORT double hb_secondsCPU( int n )
{
   double d = 0.0;
#if defined( HB_OS_WIN_32 ) && !defined( HB_OS_UNIX_COMPATIBLE )
   FILETIME Create, Exit, Kernel, User;
#endif

   if( ( n < 1 || n > 3 ) && ( n < 11 || n > 13 ) )
      n = 3;

#if defined( HB_OS_UNIX_COMPATIBLE )
   {
      struct tms tm;

      times(&tm);

      if( n > 10 )
      {
         n -= 10;
         if( n & 1 )
            d += tm.tms_cutime;
         if( n & 2 )
            d += tm.tms_cstime;
      }
      if( n & 1 )
         d += tm.tms_utime;
      if( n & 2 )
         d += tm.tms_stime;

      /* In POSIX-1996 the CLK_TCK symbol is mentioned as obsolescent */
      /* d /= CLK_TCK; */
      d /= (double) sysconf(_SC_CLK_TCK);
   }
#else
   if( n > 10 )
      n -= 10;
#if defined( HB_OS_WIN_32 )
   if( hb_iswinnt() &&
       GetProcessTimes( GetCurrentProcess(), &Create, &Exit, &Kernel, &User ) )
   {
      if( n & 1 )
      {
         d += ( double ) ( ( ( HB_LONG ) User.dwHighDateTime << 32 ) +
                             ( HB_LONG ) User.dwLowDateTime );
      }
      if( n & 2 )
      {
         d += ( double ) ( ( ( HB_LONG ) Kernel.dwHighDateTime << 32 ) +
                             ( HB_LONG ) Kernel.dwLowDateTime );
      }
      d /= 10000000.0;
   }
   else
#endif
   {
      /* TODO: this code is only for DOS and other platforms which cannot
               calculate process time */
      if( n & 1 )
         d = hb_dateSeconds(  );
   }
#endif
   return d;
}
seconds.c235
setcolor.c
TypeFunctionSourceLine
CHAR *hb_conSetColor( const char * szColor )
char * hb_conSetColor( const char * szColor )
{
   char * szOldColor;

   HB_TRACE(HB_TR_DEBUG, ("hb_conSetColor(%s)", szColor));

   szOldColor = hb_setGetColor();
   hb_gtGetColorStr( szOldColor );

   if( szColor != ( char * ) NULL )
      hb_gtSetColorStr( szColor );

   return szOldColor;
}
setcolor.c57
HB_FUNCSETCOLOR(void)
HB_FUNC( SETCOLOR )
{
   hb_retc( hb_conSetColor( hb_parc( 1 ) ) );
}
setcolor.c72
HB_FUNCCOLORSELECT(void)
HB_FUNC( COLORSELECT )
{
   if( ISNUM( 1 ) )
      hb_gtColorSelect( ( USHORT ) hb_parni( 1 ) );
}
setcolor.c77
HB_FUNCSETBLINK(void)
HB_FUNC( SETBLINK )
{
   BOOL bPreviousBlink;

   hb_gtGetBlink( &bPreviousBlink );

   if( ISLOG( 1 ) )
      hb_gtSetBlink( hb_parl( 1 ) );

   hb_retl( bPreviousBlink );
}
setcolor.c83
HB_FUNCHB_COLORTON(void)
HB_FUNC( HB_COLORTON )
{
   if( ISCHAR( 1 ) )
      hb_retni( hb_gtColorToN( hb_parc( 1 ) ) );
   else
      hb_retni( 0 );
}
setcolor.c95
HB_FUNCHB_NTOCOLOR(void)
HB_FUNC( HB_NTOCOLOR )
{
   if( ISNUM( 1 ) )
   {
      char szColorString[ 10 ];
      int colors[ 1 ];

      colors[ 0 ] = hb_parni( 1 );

      hb_gtColorsToString( colors, 1, szColorString, 10 );

      hb_retc( szColorString );
   }
   else
      hb_retc( "N/N" );
}
setcolor.c103
setcurs.c
TypeFunctionSourceLine
USHORThb_conSetCursor( BOOL bSetCursor, USHORT uiNewCursor )
USHORT hb_conSetCursor( BOOL bSetCursor, USHORT uiNewCursor )
{
   USHORT uiCursor;

   HB_TRACE(HB_TR_DEBUG, ("hb_conSetCursor(%d, %hu)", (int) bSetCursor, uiNewCursor));

   hb_gtGetCursor( &uiCursor );

   if( bSetCursor )
      hb_gtSetCursor( uiNewCursor );

   return uiCursor;
}
setcurs.c56
HB_FUNCSETCURSOR(void)
HB_FUNC( SETCURSOR )
{
   USHORT uiCursor;

   hb_gtGetCursor( &uiCursor );

   hb_retni( uiCursor );

   if( ISNUM( 1 ) )
      hb_gtSetCursor( ( USHORT ) hb_parni( 1 ) );
}
setcurs.c70
setkey.c
TypeFunctionSourceLine
STATIC VOIDhb_setkeyRelease( void * cargo )
static void hb_setkeyRelease( void * cargo )
{
   PHB_SETKEY sk_list = ( ( PHB_SK_DATA ) cargo )->sk_list;

   while( sk_list )
   {
      PHB_SETKEY sk_list_tmp;

      hb_itemRelease( sk_list->pAction );
      if( sk_list->pIsActive )
         hb_itemRelease( sk_list->pIsActive );
      sk_list_tmp = sk_list;
      sk_list = sk_list->next;
      hb_xfree( ( void * ) sk_list_tmp );
   }

   ( ( PHB_SK_DATA ) cargo )->sk_list = NULL;
}

static HB_TSD_NEW( s_skData, sizeof( HB_SK_DATA ), NULL, hb_setkeyRelease );
setkey.c78
STATIC PHB_SETKEYsk_findkey( int iKeyCode, PHB_SETKEY sk_list, PHB_SETKEY * sk_list_end )
static PHB_SETKEY sk_findkey( int iKeyCode, PHB_SETKEY sk_list,
                              PHB_SETKEY * sk_list_end )
{
   PHB_SETKEY sk_list_tmp;

   *sk_list_end = NULL;
   for( sk_list_tmp = sk_list;
        sk_list_tmp && sk_list_tmp->iKeyCode != iKeyCode;
        sk_list_tmp = sk_list_tmp->next )
      *sk_list_end = sk_list_tmp;

   return sk_list_tmp;
}
setkey.c99
STATIC VOIDsk_add( PHB_SETKEY * sk_list_ptr, BOOL bReturn, int iKeyCode, PHB_ITEM pAction, PHB_ITEM pIsActive )
static void sk_add( PHB_SETKEY * sk_list_ptr, BOOL bReturn,
                    int iKeyCode, PHB_ITEM pAction, PHB_ITEM pIsActive )
{
   if( iKeyCode )
   {
      PHB_SETKEY sk_list_tmp, sk_list_end;

      if( pIsActive && !HB_IS_BLOCK( pIsActive ) )
         pIsActive = NULL;
      if( pAction && !HB_IS_BLOCK( pAction ) )
         pAction = NULL;

      sk_list_tmp = sk_findkey( iKeyCode, *sk_list_ptr, &sk_list_end );
      if( sk_list_tmp == NULL )
      {
         if( pAction )
         {
            sk_list_tmp = ( PHB_SETKEY ) hb_xgrab( sizeof( HB_SETKEY ) );
            sk_list_tmp->next = NULL;
            sk_list_tmp->iKeyCode = iKeyCode;
            sk_list_tmp->pAction = hb_itemNew( pAction );
            sk_list_tmp->pIsActive = pIsActive ? hb_itemNew( pIsActive ) : NULL;

            if( sk_list_end == NULL )
               *sk_list_ptr = sk_list_tmp;
            else
               sk_list_end->next = sk_list_tmp;
         }
      }
      else
      {
         /* Return the previous value */

         if( bReturn )
            hb_itemReturn( sk_list_tmp->pAction );

         /* Free the previous values */

         hb_itemRelease( sk_list_tmp->pAction );
         if( sk_list_tmp->pIsActive )
         {
            hb_itemRelease( sk_list_tmp->pIsActive );
         }
         /* Set the new values or free the entry */

         if( pAction )
         {
            sk_list_tmp->pAction = hb_itemNew( pAction );
            sk_list_tmp->pIsActive = pIsActive ? hb_itemNew( pIsActive ) : NULL;
         }
         else
         {
            /* if this is true, then the key found is the first key in the list */
            if( sk_list_end == NULL )
            {
               sk_list_tmp = *sk_list_ptr;
               *sk_list_ptr = sk_list_tmp->next;
               hb_xfree( sk_list_tmp );
            }
            else
            {
               sk_list_end->next = sk_list_tmp->next;
               hb_xfree( sk_list_tmp );
            }
         }
      }
   }
}
setkey.c113
HB_FUNCSETKEY(void)
HB_FUNC( SETKEY )
{
   PHB_ITEM pKeyCode = hb_param( 1, HB_IT_NUMERIC );

   if( pKeyCode )
   {
      PHB_SK_DATA sk_data = ( PHB_SK_DATA ) hb_stackGetTSD( &s_skData );

      if( hb_pcount() == 1 )
      {
         /* Get a SETKEY value */
         PHB_SETKEY sk_list_tmp, sk_list_end;

         /* sk_list_end is not used in this context */
         sk_list_tmp = sk_findkey( hb_itemGetNI( pKeyCode ), sk_data->sk_list, &sk_list_end );

         if( sk_list_tmp )
         {
#if defined( HB_EXTENSION )
            PHB_ITEM pIsActiveResults = sk_list_tmp->pIsActive ? hb_vmEvalBlockV( sk_list_tmp->pIsActive, 1, pKeyCode ) : NULL;

            if( pIsActiveResults == NULL || ! HB_IS_LOGICAL( pIsActiveResults ) || hb_itemGetL( pIsActiveResults ) )
#endif
               hb_itemReturn( sk_list_tmp->pAction );
         }
      }
      else
      {
         /* Set a SETKEY value */
#if defined( HB_EXTENSION )
         sk_add( &sk_data->sk_list, TRUE, hb_itemGetNI( pKeyCode ),
                 hb_param( 2, HB_IT_BLOCK ), hb_param( 3, HB_IT_BLOCK ) );
#else
         sk_add( &sk_data->sk_list, TRUE, hb_itemGetNI( pKeyCode ),
                 hb_param( 2, HB_IT_BLOCK ), NULL );
#endif
      }
   }
}
setkey.c182
HB_FUNCHB_SETKEYARRAY(void)
HB_FUNC( HB_SETKEYARRAY )
{
   PHB_ITEM pKeyCodeArray = hb_param( 1, HB_IT_ARRAY );
   PHB_ITEM pAction = hb_param( 2, HB_IT_BLOCK );

   if( pKeyCodeArray && pAction )
   {
      PHB_SK_DATA sk_data = ( PHB_SK_DATA ) hb_stackGetTSD( &s_skData );
      PHB_ITEM pIsActive = hb_param( 3, HB_IT_BLOCK );
      ULONG nLen = hb_arrayLen( pKeyCodeArray );
      ULONG nPos;

      for( nPos = 1; nPos <= nLen; nPos++ )
         sk_add( &sk_data->sk_list, FALSE, hb_arrayGetNI( pKeyCodeArray, nPos ), pAction, pIsActive );
   }
}
setkey.c224
HB_FUNCHB_SETKEYGET(void)
HB_FUNC( HB_SETKEYGET )
{
   PHB_ITEM pKeyCode = hb_param( 1, HB_IT_NUMERIC );

   if( pKeyCode )
   {
      PHB_SK_DATA sk_data = ( PHB_SK_DATA ) hb_stackGetTSD( &s_skData );
      PHB_SETKEY sk_list_tmp, sk_list_end;

      /* sk_list_end is not used in this context */
      sk_list_tmp = sk_findkey( hb_itemGetNI( pKeyCode ), sk_data->sk_list, &sk_list_end );

      if( sk_list_tmp )
      {
         PHB_ITEM pIsActive = hb_param( 2, HB_IT_ANY );

         hb_itemReturn( sk_list_tmp->pAction );

         if( pIsActive )
            hb_itemCopy( pIsActive, sk_list_tmp->pIsActive );
      }
   }
}
setkey.c241
HB_FUNCHB_SETKEYSAVE(void)
HB_FUNC( HB_SETKEYSAVE )
{
   PHB_SK_DATA sk_data = ( PHB_SK_DATA ) hb_stackGetTSD( &s_skData );
   PHB_ITEM pKeys, pKeyElements, pParam;
   PHB_SETKEY sk_list_tmp;
   ULONG itemcount, nitem;

   /* build an multi-dimensional array from existing hot-keys, and return it */

   /* count the number of items in the list */
   for( itemcount = 0, sk_list_tmp = sk_data->sk_list;
        sk_list_tmp;
        itemcount++, sk_list_tmp = sk_list_tmp->next )
      ;

   pKeys = hb_itemArrayNew( itemcount );
   pKeyElements = hb_itemNew( NULL );

   for( nitem = 1, sk_list_tmp = sk_data->sk_list;
        nitem <= itemcount;
        nitem++, sk_list_tmp = sk_list_tmp->next )
   {
      hb_arrayNew( pKeyElements, 3 );
      hb_arraySetNI( pKeyElements, 1, sk_list_tmp->iKeyCode );
      hb_arraySet( pKeyElements, 2, sk_list_tmp->pAction );
      if( sk_list_tmp->pIsActive )
         hb_arraySet( pKeyElements, 3, sk_list_tmp->pIsActive );
      hb_arraySetForward( pKeys, nitem, pKeyElements );
   }
   hb_itemRelease( pKeyElements );
   hb_itemReturnRelease( pKeys );

   pParam = hb_param( 1, HB_IT_ANY );
   if( pParam )
   {
      hb_setkeyRelease( sk_data ); /* destroy the internal list */

      if( HB_IS_ARRAY( pParam ) )
      {
         itemcount = hb_arrayLen( pParam );

         for( nitem = 1; nitem <= itemcount; nitem++ )
         {
            PHB_ITEM itmKeyElements = hb_arrayGetItemPtr( pParam, nitem );

            sk_add( &sk_data->sk_list, FALSE,
                    hb_arrayGetNI( itmKeyElements, 1 ),
                    hb_arrayGetItemPtr( itmKeyElements, 2 ),
                    hb_arrayGetItemPtr( itmKeyElements, 3 ) );
         }
      }
   }
}
setkey.c265
HB_FUNCHB_SETKEYCHECK(void)
HB_FUNC( HB_SETKEYCHECK )
{
   PHB_ITEM pKeyCode = hb_param( 1, HB_IT_NUMERIC );
   BOOL bIsKeySet = FALSE;

   if( pKeyCode )
   {
      PHB_SK_DATA sk_data = ( PHB_SK_DATA ) hb_stackGetTSD( &s_skData );
      PHB_SETKEY sk_list_tmp, sk_list_end;

      /* sk_list_end is not used in this context */
      sk_list_tmp = sk_findkey( hb_itemGetNI( pKeyCode ), sk_data->sk_list, &sk_list_end );

      if( sk_list_tmp )
      {
         PHB_ITEM pIsActiveResults = sk_list_tmp->pIsActive ? hb_vmEvalBlockV( sk_list_tmp->pIsActive, 1, pKeyCode ) : NULL;

         if( pIsActiveResults == NULL || ! HB_IS_LOGICAL( pIsActiveResults ) || hb_itemGetL( pIsActiveResults ) )
         {
            bIsKeySet = TRUE;

            switch( hb_pcount() )
            {
               case 1:  hb_vmEvalBlockV( sk_list_tmp->pAction, 1, pKeyCode ); break;
               case 2:  hb_vmEvalBlockV( sk_list_tmp->pAction, 2, hb_param( 2, HB_IT_ANY ), pKeyCode ); break;
               case 3:  hb_vmEvalBlockV( sk_list_tmp->pAction, 3, hb_param( 2, HB_IT_ANY ), hb_param( 3, HB_IT_ANY ), pKeyCode ); break;
               default: hb_vmEvalBlockV( sk_list_tmp->pAction, 4, hb_param( 2, HB_IT_ANY ), hb_param( 3, HB_IT_ANY ), hb_param( 4, HB_IT_ANY ), pKeyCode ); break;
            }
         }
      }
   }

   hb_retl( bIsKeySet );
}
setkey.c319
setpos.c
TypeFunctionSourceLine
HB_FUNCSETPOS(void)
HB_FUNC( SETPOS ) /* Sets the screen position */
{
   if( ISNUM( 1 ) && ISNUM( 2 ) )
      hb_gtSetPos( ( SHORT ) hb_parni( 1 ), ( SHORT ) hb_parni( 2 ) );
}
setpos.c67
HB_FUNCROW(void)
HB_FUNC( ROW ) /* Return the current screen row position (zero origin) */
{
   SHORT iRow;
   SHORT iCol;

   hb_gtGetPos( &iRow, &iCol );

   hb_retni( iRow );
}
setpos.c73
HB_FUNCCOL(void)
HB_FUNC( COL ) /* Return the current screen column position (zero origin) */
{
   SHORT iRow;
   SHORT iCol;

   hb_gtGetPos( &iRow, &iCol );

   hb_retni( iCol );
}
setpos.c83
setposbs.c
TypeFunctionSourceLine
HB_FUNCSETPOSBS(void)
HB_FUNC( SETPOSBS ) /* Move the screen position to the right by one column */
{
   SHORT iRow;
   SHORT iCol;

   /* NOTE: CA-Cl*pper does no checks about reaching the border or anything.
            [vszakats] */

   hb_gtGetPos( &iRow, &iCol );
   hb_gtSetPos( iRow, iCol + 1 );
}
setposbs.c61
shadow.c
TypeFunctionSourceLine
HB_FUNCHB_SHADOW(void)
HB_FUNC( HB_SHADOW )
{
   if( hb_pcount() >= 4 )
      hb_gtDrawShadow( ( USHORT ) hb_parni( 1 ),
                       ( USHORT ) hb_parni( 2 ),
                       ( USHORT ) hb_parni( 3 ),
                       ( USHORT ) hb_parni( 4 ),
                       ISNUM( 5 ) ? ( BYTE ) hb_parni( 5 ) : 7 );
}
shadow.c56
HB_FUNCHB_CLRAREA(void)
HB_FUNC( HB_CLRAREA )
{
   if( hb_pcount() > 4 )
      hb_gtSetAttribute( ( USHORT ) hb_parni( 1 ),
                         ( USHORT ) hb_parni( 2 ),
                         ( USHORT ) hb_parni( 3 ),
                         ( USHORT ) hb_parni( 4 ),
                         ( BYTE ) hb_parni( 5 ) );
}
shadow.c66
shadowu.c
TypeFunctionSourceLine
HB_FUNCDBGSHADOW(void)
HB_FUNC( DBGSHADOW )
{
   HB_FUNC_EXEC( HB_SHADOW );
}
shadowu.c59
soundex.c
TypeFunctionSourceLine
HB_FUNCSOUNDEX(void)
HB_FUNC( SOUNDEX )
{
   PHB_ITEM pString = hb_param( 1, HB_IT_STRING );
   char szResult[ SOUNDEX_LEN_MAX + 1 ];

   /* NOTE: The result will always be a zero terminated string without any
            embedded zeros and special characters. [vszakats] */

   memset( szResult, '0', SOUNDEX_LEN_MAX );
   szResult[ SOUNDEX_LEN_MAX ] = '\0';

   if( pString )
   {
      char * pszString = hb_itemGetCPtr( pString );
      ULONG ulLen = hb_itemGetCLen( pString );
      ULONG nPos = 0;
      ULONG nResultPos = 0;
      char cCharPrev = '0';

      while( nPos < ulLen && nResultPos < SOUNDEX_LEN_MAX )
      {
         char cChar = pszString[ nPos ];

         /* NOTE: Intentionally not using toupper()/isalpha() to be 100%
                  Clipper compatible here, these ANSI C functions may behave
                  differently for accented and national characters. It's also
                  faster this way. [vszakats] */

         /* Convert to uppercase: toupper() */
         if( cChar >= 'a' && cChar <= 'z' )
            cChar -= ( 'a' - 'A' );

         /* Check if isalpha() */
         if( cChar >= 'A' && cChar <= 'Z' )
         {
            static const char s_szTable[] = "01230120022455012623010202"; /* NOTE: SoundEx result codes for letters from "A" to "Z" */
                                         /* "ABCDEFGHIJKLMNOPQRSTUVWXYZ" */
            char cCharConverted = ( ( cChar - 'A' ) > ( ( int ) sizeof( s_szTable ) - 1 ) ) ? '9' : s_szTable[ cChar - 'A' ];

            if( nResultPos == 0 )
               szResult[ nResultPos++ ] = cChar;
            else if( cCharConverted != '0' && cCharConverted != cCharPrev )
               szResult[ nResultPos++ ] = cCharConverted;

            cCharPrev = cCharConverted;
         }

         nPos++;
      }
   }

   hb_retc( szResult );
}
soundex.c60
space.c
TypeFunctionSourceLine
HB_FUNCSPACE(void)
HB_FUNC( SPACE )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_NUMERIC );

   if( pItem )
   {
      long lLen = hb_itemGetNL( pItem );

      if( lLen > 0 )
      {
         char * szResult = ( char * ) hb_xgrab( lLen + 1 );

         /* NOTE: String overflow could never occure since a string can
                  be as large as ULONG_MAX, and the maximum length that
                  can be specified is LONG_MAX here. [vszakats] */
         /* hb_errRT_BASE( EG_STROVERFLOW, 1233, NULL, HB_ERR_FUNCNAME ); */

         hb_xmemset( szResult, ' ', lLen );
         hb_retclen_buffer( szResult, lLen );
      }
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1105, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
space.c59
spfiles.c
TypeFunctionSourceLine
BOOLhb_spFile( BYTE * pFilename, BYTE * pRetPath )
BOOL hb_spFile( BYTE * pFilename, BYTE * pRetPath )
{
   BYTE *Path;
   BOOL bIsFile = FALSE;
   PHB_FNAME pFilepath;

   HB_TRACE(HB_TR_DEBUG, ("hb_spFile(%s, %p)", (char*) pFilename, pRetPath));

   if( pRetPath )
   {
      Path = pRetPath;
   }
   else
   {
      Path = (BYTE *) hb_xgrab( _POSIX_PATH_MAX + 1 );
   }

   pFilepath = hb_fsFNameSplit( (char*) pFilename );

   if( pFilepath->szPath )
   {
      hb_fsFNameMerge( (char*) Path, pFilepath );
      bIsFile = hb_fsFile( Path );
   }
   else
   {
      char * szDefault = hb_setGetDefault();
      if( szDefault )
      {
         pFilepath->szPath = szDefault;
         hb_fsFNameMerge( (char*) Path, pFilepath );
         bIsFile = hb_fsFile( Path );
      }

      if( !bIsFile && hb_setGetPath() )
      {
         HB_PATHNAMES *NextPath = hb_setGetFirstSetPath();

         while( bIsFile == FALSE && NextPath )
         {
            pFilepath->szPath = NextPath->szPath;
            hb_fsFNameMerge( (char*) Path, pFilepath );
            bIsFile = hb_fsFile( Path );
            NextPath = NextPath->pNext;
         }
      }

      /*
       * This code is intentional. To eliminate race condition,
       * in pending hb_spCreate()/hb_spOpen() call when we have to know
       * real path and file name we have to set its deterministic value
       * here. If it's not necessary the caller may drop this value.
       */
      if( ! bIsFile )
      {
         pFilepath->szPath = szDefault ? szDefault : ( char * ) ".";
         hb_fsFNameMerge( (char*) Path, pFilepath );
      }
   }

   hb_xfree( pFilepath );

   if( pRetPath == NULL )
   {
      hb_xfree( Path );
   }

   return bIsFile;
}
spfiles.c56
HB_FHANDLEhb_spOpen( BYTE * pFilename, USHORT uiFlags )
HB_FHANDLE hb_spOpen( BYTE * pFilename, USHORT uiFlags )
{
   BYTE path[ _POSIX_PATH_MAX + 1 ];

   HB_TRACE(HB_TR_DEBUG, ("hb_spOpen(%p, %hu)", pFilename, uiFlags));

   if( hb_spFile( pFilename, path ) )
      return hb_fsOpen( path, uiFlags );
   else
      return hb_fsOpen( pFilename, uiFlags );
}
spfiles.c126
HB_FHANDLEhb_spCreate( BYTE * pFilename, ULONG ulAttr )
HB_FHANDLE hb_spCreate( BYTE * pFilename, ULONG ulAttr )
{
   BYTE path[ _POSIX_PATH_MAX + 1 ];
   PHB_FNAME pFilepath;

   HB_TRACE(HB_TR_DEBUG, ("hb_spCreate(%p, %lu)", pFilename, ulAttr));

   pFilepath = hb_fsFNameSplit( (char*) pFilename );
   if( ! pFilepath->szPath )
      pFilepath->szPath = hb_setGetDefault();

   hb_fsFNameMerge( (char*) path, pFilepath );
   hb_xfree( pFilepath );

   return hb_fsCreate( path, ulAttr );
}
spfiles.c138
HB_FHANDLEhb_spCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags )
HB_FHANDLE hb_spCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags )
{
   BYTE path[ _POSIX_PATH_MAX + 1 ];
   PHB_FNAME pFilepath;

   HB_TRACE(HB_TR_DEBUG, ("hb_spCreateEx(%p, %lu, %hu)", pFilename, ulAttr, uiFlags));

   pFilepath = hb_fsFNameSplit( (char*) pFilename );
   if( ! pFilepath->szPath )
      pFilepath->szPath = hb_setGetDefault();

   hb_fsFNameMerge( (char*) path, pFilepath );
   hb_xfree( pFilepath );

   return hb_fsCreateEx( path, ulAttr, uiFlags );
}
spfiles.c155
str.c
TypeFunctionSourceLine
HB_FUNCSTR(void)
HB_FUNC( STR )
{
   int iParams = hb_pcount();
   PHB_ITEM pNumber = hb_param( 1, HB_IT_NUMERIC );
   PHB_ITEM pWidth  = NULL;
   PHB_ITEM pDec    = NULL;

   if( iParams >= 2 )
   {
      pWidth = hb_param( 2, HB_IT_NUMERIC );
      if( pWidth == NULL )
         pNumber = NULL;
      else if( iParams >= 3 )
      {
         pDec = hb_param( 3, HB_IT_NUMERIC );
         if( pDec == NULL )
            pNumber = NULL;
      }
   }

   if( pNumber )
   {
      char * szResult = hb_itemStr( pNumber, pWidth, pDec );

      if( szResult )
         hb_retc_buffer( szResult );
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
str.c57
strcase.c
TypeFunctionSourceLine
CHAR *hb_strLower( char * szText, ULONG ulLen )
char * hb_strLower( char * szText, ULONG ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_strLower(%s, %lu)", szText, ulLen));

   {
      ULONG i;
#ifndef HB_CDP_SUPPORT_OFF
      PHB_CODEPAGE cdp = hb_vmCDP();
      if( cdp && cdp->nChars )
         for( i = 0; i < ulLen; i++ )
            szText[ i ] = ( char ) cdp->s_lower[ ( UCHAR ) szText[ i ] ];
      else
#endif
         for( i = 0; i < ulLen; i++ )
            szText[ i ] = ( char ) tolower( ( UCHAR ) szText[ i ] );
   }

   return szText;
}
strcase.c60
CHAR *hb_strUpper( char * szText, ULONG ulLen )
char * hb_strUpper( char * szText, ULONG ulLen )
{

   HB_TRACE(HB_TR_DEBUG, ("hb_strUpper(%s, %lu)", szText, ulLen));

   {
      ULONG i;
#ifndef HB_CDP_SUPPORT_OFF
      PHB_CODEPAGE cdp = hb_vmCDP();
      if( cdp && cdp->nChars )
         for( i = 0; i < ulLen; i++ )
            szText[ i ] = ( char ) cdp->s_upper[ ( UCHAR ) szText[ i ] ];
      else
#endif
         for( i = 0; i < ulLen; i++ )
            szText[ i ] = ( char ) toupper( ( UCHAR ) szText[ i ] );
   }

   return szText;
}
strcase.c81
INThb_charUpper( int iChar )
int hb_charUpper( int iChar )
{
#ifndef HB_CDP_SUPPORT_OFF
   PHB_CODEPAGE cdp = hb_vmCDP();
   if( cdp && cdp->nChars )
      return (unsigned char) cdp->s_upper[ (unsigned char) iChar ];
   else
#endif
      return toupper( (unsigned char) iChar );
}
strcase.c103
INThb_charLower( int iChar )
int hb_charLower( int iChar )
{
#ifndef HB_CDP_SUPPORT_OFF
   PHB_CODEPAGE cdp = hb_vmCDP();
   if( cdp && cdp->nChars )
      return (unsigned char) cdp->s_lower[ (unsigned char) iChar ];
   else
#endif
      return tolower( (unsigned char) iChar );
}
strcase.c115
HB_FUNCLOWER(void)
HB_FUNC( LOWER )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText )
   {
      char * pszBuffer = hb_itemGetC( pText );
      ULONG ulLen = hb_itemGetCLen( pText );

      hb_retclen_buffer( hb_strLower( pszBuffer, ulLen ), ulLen );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1103, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
strcase.c127
HB_FUNCUPPER(void)
HB_FUNC( UPPER )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText )
   {
      char * pszBuffer = hb_itemGetC( pText );
      ULONG ulLen = hb_itemGetCLen( pText );

      hb_retclen_buffer( hb_strUpper( pszBuffer, ulLen ), ulLen );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1102, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
strcase.c143
strmatch.c
TypeFunctionSourceLine
HB_EXPORT BOOLhb_strMatchWild( const char *szString, const char *szPattern )
HB_EXPORT BOOL hb_strMatchWild( const char *szString, const char *szPattern )
{
   BOOL fMatch = TRUE, fAny = FALSE;
   ULONG pulBufPosP[ HB_MAX_WILDPATTERN ], pulBufPosV[ HB_MAX_WILDPATTERN ],
         ulBufSize = HB_MAX_WILDPATTERN;
   ULONG * ulAnyPosP = pulBufPosP, * ulAnyPosV = pulBufPosV,
         ulSize, ulLen, ulAny, i, j;

   i = j = ulAny = 0;
   ulLen = strlen( szString );
   ulSize = strlen( szPattern );
   while( i < ulSize )
   {
      if( szPattern[i] == '*' )
      {
         fAny = TRUE;
         i++;
      }
      else if( j < ulLen && ( szPattern[i] == '?' || szPattern[i] == szString[j] ) )
      {
         if( fAny )
         {
            if( ulAny >= ulBufSize )
            {
               if( ( ulBufSize <<= 1 ) == ( HB_MAX_WILDPATTERN << 1 ) )
               {
                  ulAnyPosP = ( ULONG * ) hb_xgrab( ulBufSize * sizeof( ULONG ) );
                  ulAnyPosV = ( ULONG * ) hb_xgrab( ulBufSize * sizeof( ULONG ) );
                  memcpy( ulAnyPosP, pulBufPosP, HB_MAX_WILDPATTERN * sizeof( ULONG ) );
                  memcpy( ulAnyPosV, pulBufPosV, HB_MAX_WILDPATTERN * sizeof( ULONG ) );
               }
               else
               {
                  ulAnyPosP = ( ULONG * ) hb_xrealloc( ulAnyPosP, ulBufSize * sizeof( ULONG ) );
                  ulAnyPosV = ( ULONG * ) hb_xrealloc( ulAnyPosV, ulBufSize * sizeof( ULONG ) );
               }
            }
            ulAnyPosP[ulAny] = i;
            ulAnyPosV[ulAny] = j;
            ulAny++;
            fAny = FALSE;
         }
         j++;
         i++;
      }
      else if( fAny && j < ulLen )
      {
         j++;
      }
      else if( ulAny > 0 )
      {
         ulAny--;
         i = ulAnyPosP[ulAny];
         j = ulAnyPosV[ulAny] + 1;
         fAny = TRUE;
      }
      else
      {
         fMatch = FALSE;
         break;
      }
   }
   if( ulBufSize > HB_MAX_WILDPATTERN )
   {
      hb_xfree( ulAnyPosP );
      hb_xfree( ulAnyPosV );
   }
   return fMatch;
}
strmatch.c62
HB_EXPORT BOOLhb_strMatchWildExact( const char *szString, const char *szPattern )
HB_EXPORT BOOL hb_strMatchWildExact( const char *szString, const char *szPattern )
{
   BOOL fMatch = TRUE, fAny = FALSE;
   ULONG pulBufPosP[ HB_MAX_WILDPATTERN ], pulBufPosV[ HB_MAX_WILDPATTERN ],
         ulBufSize = HB_MAX_WILDPATTERN;
   ULONG * ulAnyPosP = pulBufPosP, * ulAnyPosV = pulBufPosV,
         ulSize, ulLen, ulAny, i, j;

   i = j = ulAny = 0;
   ulLen = strlen( szString );
   ulSize = strlen( szPattern );
   while( i < ulSize || ( j < ulLen && !fAny ) )
   {
      if( i < ulSize && szPattern[i] == '*' )
      {
         fAny = TRUE;
         i++;
      }
      else if( j < ulLen && i < ulSize &&
               ( szPattern[i] == '?' || szPattern[i] == szString[j] ) )
      {
         if( fAny )
         {
            if( ulAny >= ulBufSize )
            {
               if( ( ulBufSize <<= 1 ) == ( HB_MAX_WILDPATTERN << 1 ) )
               {
                  ulAnyPosP = ( ULONG * ) hb_xgrab( ulBufSize * sizeof( ULONG ) );
                  ulAnyPosV = ( ULONG * ) hb_xgrab( ulBufSize * sizeof( ULONG ) );
                  memcpy( ulAnyPosP, pulBufPosP, HB_MAX_WILDPATTERN * sizeof( ULONG ) );
                  memcpy( ulAnyPosV, pulBufPosV, HB_MAX_WILDPATTERN * sizeof( ULONG ) );
               }
               else
               {
                  ulAnyPosP = ( ULONG * ) hb_xrealloc( ulAnyPosP, ulBufSize * sizeof( ULONG ) );
                  ulAnyPosV = ( ULONG * ) hb_xrealloc( ulAnyPosV, ulBufSize * sizeof( ULONG ) );
               }
            }
            ulAnyPosP[ulAny] = i;
            ulAnyPosV[ulAny] = j;
            ulAny++;
            fAny = FALSE;
         }
         j++;
         i++;
      }
      else if( fAny && j < ulLen )
      {
         j++;
      }
      else if( ulAny > 0 )
      {
         ulAny--;
         i = ulAnyPosP[ulAny];
         j = ulAnyPosV[ulAny] + 1;
         fAny = TRUE;
      }
      else
      {
         fMatch = FALSE;
         break;
      }
   }
   if( ulBufSize > HB_MAX_WILDPATTERN )
   {
      hb_xfree( ulAnyPosP );
      hb_xfree( ulAnyPosV );
   }
   return fMatch;
}
strmatch.c132
HB_EXPORT BOOLhb_strMatchCaseWildExact( const char *szString, const char *szPattern )
HB_EXPORT BOOL hb_strMatchCaseWildExact( const char *szString, const char *szPattern )
{
   BOOL fMatch = TRUE, fAny = FALSE;
   ULONG pulBufPosP[ HB_MAX_WILDPATTERN ], pulBufPosV[ HB_MAX_WILDPATTERN ],
         ulBufSize = HB_MAX_WILDPATTERN;
   ULONG * ulAnyPosP = pulBufPosP, * ulAnyPosV = pulBufPosV,
         ulSize, ulLen, ulAny, i, j;

   i = j = ulAny = 0;
   ulLen = strlen( szString );
   ulSize = strlen( szPattern );
   while ( i < ulSize || ( j < ulLen && !fAny ) )
   {
      if( i < ulSize && szPattern[i] == '*' )
      {
         fAny = TRUE;
         i++;
      }
      else if( j < ulLen && i < ulSize &&
               ( szPattern[i] == '?' ||
                 hb_charUpper( szPattern[i] ) == hb_charUpper( szString[j] ) ) )
      {
         if( fAny )
         {
            if( ulAny >= ulBufSize )
            {
               if( ( ulBufSize <<= 1 ) == ( HB_MAX_WILDPATTERN << 1 ) )
               {
                  ulAnyPosP = ( ULONG * ) hb_xgrab( ulBufSize * sizeof( ULONG ) );
                  ulAnyPosV = ( ULONG * ) hb_xgrab( ulBufSize * sizeof( ULONG ) );
                  memcpy( ulAnyPosP, pulBufPosP, HB_MAX_WILDPATTERN * sizeof( ULONG ) );
                  memcpy( ulAnyPosV, pulBufPosV, HB_MAX_WILDPATTERN * sizeof( ULONG ) );
               }
               else
               {
                  ulAnyPosP = ( ULONG * ) hb_xrealloc( ulAnyPosP, ulBufSize * sizeof( ULONG ) );
                  ulAnyPosV = ( ULONG * ) hb_xrealloc( ulAnyPosV, ulBufSize * sizeof( ULONG ) );
               }
            }
            ulAnyPosP[ulAny] = i;
            ulAnyPosV[ulAny] = j;
            ulAny++;
            fAny = FALSE;
         }
         j++;
         i++;
      }
      else if( fAny && j < ulLen )
      {
         j++;
      }
      else if( ulAny > 0 )
      {
         ulAny--;
         i = ulAnyPosP[ulAny];
         j = ulAnyPosV[ulAny] + 1;
         fAny = TRUE;
      }
      else
      {
         fMatch = FALSE;
         break;
      }
   }
   if( ulBufSize > HB_MAX_WILDPATTERN )
   {
      hb_xfree( ulAnyPosP );
      hb_xfree( ulAnyPosV );
   }
   return fMatch;
}
strmatch.c203
BOOLhb_strMatchRegExp( const char * szString, const char * szPattern )
BOOL hb_strMatchRegExp( const char * szString, const char * szPattern )
{
   PHB_REGEX pRegEx;

   HB_TRACE(HB_TR_DEBUG, ("hb_strMatchRegExp(%s, %s)", szString, szPattern));

   pRegEx = hb_regexCompile( szPattern, strlen( szPattern ), HBREG_EXTENDED );
   if( pRegEx )
   {
      BOOL fMatch;
      fMatch = hb_regexMatch( pRegEx, szString, strlen( szString ), TRUE );
      hb_regexFree( pRegEx );
      return fMatch;
   }
   else
      return hb_strMatchWildExact( szString, szPattern );
}
strmatch.c275
HB_EXPORT BOOLhb_strMatchFile( const char * szString, const char * szPattern )
HB_EXPORT BOOL hb_strMatchFile( const char * szString, const char * szPattern )
{
#if defined( HB_OS_UNIX )
#  if defined( __WATCOMC__ )
   return hb_strMatchWildExact( szString, szPattern );
#  else
   return fnmatch( szPattern, szString, FNM_PERIOD | FNM_PATHNAME ) == 0;
#  endif
#else
   return hb_strMatchCaseWildExact( szString, szPattern );
#endif
}

strmatch.c293
HB_FUNCHB_WILDMATCH(void)
HB_FUNC( HB_WILDMATCH )
{
   hb_retl( ( ! ISCHAR( 1 ) || ! ISCHAR( 2 ) ) ? FALSE :
            hb_parl( 3 ) ? hb_strMatchWildExact( hb_parc( 2 ), hb_parc( 1 ) ) :
                           hb_strMatchWild( hb_parc( 2 ), hb_parc( 1 ) ) );
}
strmatch.c317
HB_FUNCHB_FILEMATCH(void)
HB_FUNC( HB_FILEMATCH )
{
   hb_retl( ( ! ISCHAR( 1 ) || ! ISCHAR( 2 ) ) ? FALSE :
            hb_strMatchFile( hb_parc( 1 ), hb_parc( 2 ) ) );
}
strmatch.c324
strpeek.c
TypeFunctionSourceLine
HB_FUNCSTRPEEK(void)
HB_FUNC( STRPEEK )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText && ISNUM( 2 ) )
   {
      ULONG ulPos = hb_parnl( 2 );

      if( ulPos > 0 && ulPos <= hb_itemGetCLen( pText ) )
         hb_retni( ( BYTE ) * ( hb_itemGetCPtr( pText ) + ulPos - 1 ) );
      else
         hb_retni( 0 );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
strpeek.c59
HB_FUNCSTRPOKE(void)
HB_FUNC( STRPOKE )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText && ISNUM( 2 ) && ISNUM( 3 ) )
   {
      ULONG ulPos = hb_parnl( 2 );

      if( ulPos > 0 && ulPos <= hb_itemGetCLen( pText ) )
      {
         pText = hb_itemUnShareString( pText );
         hb_itemGetCPtr( pText )[ ulPos - 1 ] = (char) ( hb_parni( 3 ) & 0xff );
      }
      hb_itemReturn( pText );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
strpeek.c77
strtran.c
TypeFunctionSourceLine
HB_FUNCSTRTRAN(void)
HB_FUNC( STRTRAN )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );
   PHB_ITEM pSeek = hb_param( 2, HB_IT_STRING );

   if( pText && pSeek )
   {
      const char * szText = hb_itemGetCPtr( pText );
      ULONG ulText = hb_itemGetCLen( pText );
      ULONG ulSeek = hb_itemGetCLen( pSeek );

      if( ulSeek && ulSeek <= ulText )
      {
         const char * szSeek = hb_itemGetCPtr( pSeek );
         const char * szReplace;
         ULONG ulStart;

         ulStart = ( ISNUM( 4 ) ? hb_parnl( 4 ) : 1 );

         if( !ulStart )
         {
            /* Clipper seems to work this way */
            hb_retc( NULL );
         }
         else if( ulStart > 0 )
         {
            PHB_ITEM pReplace = hb_param( 3, HB_IT_STRING );
            ULONG ulReplace;
            ULONG ulCount;
            BOOL bAll;

            if( pReplace )
            {
               szReplace = hb_itemGetCPtr( pReplace );
               ulReplace = hb_itemGetCLen( pReplace );
            }
            else
            {
               szReplace = ""; /* shouldn't matter that we don't allocate */
               ulReplace = 0;
            }

            if( ISNUM( 5 ) )
            {
               ulCount = hb_parnl( 5 );
               bAll = FALSE;
            }
            else
            {
               ulCount = 0;
               bAll = TRUE;
            }

            if( bAll || ulCount > 0 )
            {
               ULONG ulFound = 0;
               long lReplaced = 0;
               ULONG i = 0;
               ULONG ulLength = ulText;
               ULONG ulStop = ulText - ulSeek + 1;

               while( i < ulStop )
               {
                  if( ( bAll || lReplaced < ( long ) ulCount ) &&
                      ! memcmp( szText + i, szSeek, ulSeek ) )
                  {
                     ulFound++;
                     if( ulFound >= ulStart )
                     {
                        lReplaced++;
                        ulLength = ulLength - ulSeek + ulReplace;
                        i += ulSeek;
                     }
                     else
                        i++;
                  }
                  else
                     i++;
               }

               if( ulFound )
               {
                  char * szResult = ( char * ) hb_xgrab( ulLength + 1 );
                  char * szPtr = szResult;

                  ulFound = 0;
                  i = 0;
                  while( i < ulText )
                  {
                     if( lReplaced && ! memcmp( szText + i, szSeek, ulSeek ) )
                     {
                        ulFound++;
                        if( ulFound >= ulStart )
                        {
                           lReplaced--;
                           memcpy( szPtr, szReplace, ulReplace );
                           szPtr += ulReplace;
                           i += ulSeek;
                        }
                        else
                        {
                           *szPtr = szText[ i ];
                           szPtr++;
                           i++;
                        }
                     }
                     else
                     {
                        *szPtr = szText[ i ];
                        szPtr++;
                        i++;
                     }
                  }
                  hb_retclen_buffer( szResult, ulLength );
               }
               else
                  hb_itemReturn( pText );
            }
            else
               hb_itemReturn( pText );
         }
         else
            hb_itemReturn( pText );
      }
      else
         hb_itemReturn( pText );
   }
   else
   {
      /* NOTE: Undocumented but existing Clipper Run-time error [vszakats] */
#ifdef HB_C52_STRICT
      hb_errRT_BASE_SubstR( EG_ARG, 1126, NULL, HB_ERR_FUNCNAME, 0 );
#else
      hb_errRT_BASE_SubstR( EG_ARG, 1126, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
#endif
   }
}
strtran.c61
strzero.c
TypeFunctionSourceLine
HB_FUNCSTRZERO(void)
HB_FUNC( STRZERO )
{
   int iParams = hb_pcount();

   if( iParams >= 1 && iParams <= 3 )
   {
      PHB_ITEM pNumber = hb_param( 1, HB_IT_NUMERIC );
      PHB_ITEM pWidth  = NULL;
      PHB_ITEM pDec    = NULL;

      if( iParams >= 2 )
      {
         pWidth = hb_param( 2, HB_IT_NUMERIC );
         if( pWidth == NULL )
            pNumber = NULL;
         else if( iParams >= 3 )
         {
            pDec = hb_param( 3, HB_IT_NUMERIC );
            if( pDec == NULL )
               pNumber = NULL;
         }
      }

      if( pNumber )
      {
         char * szResult = hb_itemStr( pNumber, pWidth, pDec );

         if( szResult )
         {
            ULONG ulPos = 0;

            while( szResult[ ulPos ] != '\0' && szResult[ ulPos ] != '-' )
               ulPos++;

            if( szResult[ ulPos ] == '-' )
            {
               /* NOTE: Negative sign found, put it to the first position */

               szResult[ ulPos ] = ' ';

               ulPos = 0;
               while( szResult[ ulPos ] != '\0' && szResult[ ulPos ] == ' ' )
                  szResult[ ulPos++ ] = '0';

               szResult[ 0 ] = '-';
            }
            else
            {
               /* Negative sign not found */

               ulPos = 0;
               while( szResult[ ulPos ] != '\0' && szResult[ ulPos ] == ' ' )
                  szResult[ ulPos++ ] = '0';
            }

            hb_retc_buffer( szResult );
         }
         else
            hb_retc( NULL );
      }
      else
#ifdef HB_C52_STRICT
         /* NOTE: In CA-Cl*pper STRZERO() is written in Clipper, and will call
                  STR() to do the job, the error (if any) will also be thrown
                  by STR().  [vszakats] */
         hb_errRT_BASE_SubstR( EG_ARG, 1099, NULL, "STR", HB_ERR_ARGS_BASEPARAMS );
#else
         hb_errRT_BASE_SubstR( EG_ARG, 6003, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
#endif
   }
}
strzero.c57
stuff.c
TypeFunctionSourceLine
HB_FUNCSTUFF(void)
HB_FUNC( STUFF )
{
   if( ISCHAR( 1 ) && ISNUM( 2 ) && ISNUM( 3 ) && ISCHAR( 4 ) )
   {
      char * szText = hb_parc( 1 );
      ULONG ulText = hb_parclen( 1 );
      ULONG ulPos = hb_parnl( 2 );
      ULONG ulDel = hb_parnl( 3 );
      ULONG ulInsert = hb_parclen( 4 );

      ULONG ulTotalLen;

      if( ulPos > 0 )
         ulPos--;

      if( ulPos > ulText )
         ulPos = ulText;

      if( ulDel > ulText - ulPos )
         ulDel = ulText - ulPos;

      if( ( ulTotalLen = ulText + ulInsert - ulDel ) > 0 )
      {
         char * szResult = ( char * ) hb_xgrab( ulTotalLen + 1 );

         hb_xmemcpy( szResult, szText, ulPos );
         hb_xmemcpy( szResult + ulPos, hb_parc( 4 ), ulInsert );
         hb_xmemcpy( szResult + ulPos + ulInsert, szText + ulPos + ulDel, ulText - ( ulPos + ulDel ) );

         szResult[ ulTotalLen ] = '\0';
         hb_retclen_buffer( szResult, ulTotalLen );
      }
      else
         hb_retc( NULL );
   }
   else
      hb_retc( NULL );
}
stuff.c55
substr.c
TypeFunctionSourceLine
HB_FUNCSUBSTR(void)
HB_FUNC( SUBSTR )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText && ISNUM( 2 ) )
   {
      long lPos = hb_parnl( 2 );
      long lSize = ( long ) hb_itemGetCLen( pText );

      if( lPos < 0 )
      {
         lPos += lSize;
         if( lPos < 0 )
            lPos = 0;
      }
      else if( lPos )
      {
         lPos--;
      }

      if( lPos < lSize )
      {
         long lLen;

         if( hb_pcount() >= 3 )
         {
            if( ISNUM( 3 ) )
            {
               lLen = hb_parnl( 3 );

               if( lLen > lSize - lPos )
                  lLen = lSize - lPos;
            }
            else
            {
               hb_errRT_BASE_SubstR( EG_ARG, 1110, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
               /* NOTE: Exit from inside [vszakats] */
               return;
            }
         }
         else
            lLen = lSize - lPos;

         if( lLen > 0 )
         {
            if( lLen == lSize )
               hb_itemReturn( pText );
            else
               hb_retclen( hb_itemGetCPtr( pText ) + lPos, lLen );
         }
         else
            hb_retc( NULL );
      }
      else
         hb_retc( NULL );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1110, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
substr.c59
tone.c
TypeFunctionSourceLine
HB_FUNCTONE(void)
HB_FUNC( TONE )
{
   if( ISNUM( 1 ) )
      hb_gtTone( hb_parnd( 1 ), ( ISNUM( 2 ) ? hb_parnd( 2 ) : 1.0 ) );
}
tone.c56
trace.c
TypeFunctionSourceLine
HB_FUNCHB_TRACESTATE(void)
HB_FUNC( HB_TRACESTATE )
{
   hb_retni( hb_tracestate( ISNUM( 1 ) ? hb_parni( 1 ) : -1 ) );
}
trace.c56
HB_FUNCHB_TRACELEVEL(void)
HB_FUNC( HB_TRACELEVEL )
{
   hb_retni( hb_tracelevel( ISNUM( 1 ) ? hb_parni( 1 ) : -1 ) );
}
trace.c61
HB_FUNCHB_TRACESTRING(void)
HB_FUNC( HB_TRACESTRING )
{
   char * szMessage = hb_parc( 1 );
   if( szMessage )
   {
      HB_TRACE(HB_TR_ALWAYS, (szMessage) );
   }
}
trace.c66
transfrm.c
TypeFunctionSourceLine
HB_FUNCTRANSFORM(void)
HB_FUNC( TRANSFORM )
{
   PHB_ITEM pValue = hb_param( 1, HB_IT_ANY ); /* Input parameter */
   PHB_ITEM pPic = hb_param( 2, HB_IT_STRING ); /* Picture string */

   BOOL bError = FALSE;

   if( pPic && hb_itemGetCLen( pPic ) > 0 )
   {
      char szPicDate[ 11 ];
      char * szPic = hb_itemGetCPtr( pPic );
      ULONG  ulPicLen = hb_itemGetCLen( pPic );
      USHORT uiPicFlags; /* Function flags */

      ULONG  ulParamS = 0; /* To avoid GCC -O2 warning */
      BYTE   byParamL = '\0'; /* To avoid GCC -O2 warning */

      char * szResult;
      ULONG  ulResultPos;

      ULONG  ulOffset = 0;

      /* ======================================================= */
      /* Analyze picture functions                               */
      /* ======================================================= */

      uiPicFlags = 0;

      /* If an "@" char is at the first pos, we have picture function */

      if( *szPic == '@' )
      {
         BOOL bDone = FALSE;

         /* Skip the "@" char */

         szPic++;
         ulPicLen--;

         /* Go through all function chars, until the end of the picture string
            or any whitespace found. */

         while( ulPicLen && ! bDone )
         {
            switch( hb_charUpper( *szPic ) )
            {
               case HB_CHAR_HT:
               case ' ':
                  bDone = TRUE;     /* End of function string */
                  break;
               case '!':
                  uiPicFlags |= PF_UPPER;
                  break;
               case '(':
                  uiPicFlags |= PF_PARNEG;
                  break;
               case ')':
                  uiPicFlags |= PF_PARNEGWOS;
                  break;
#if defined(HB_COMPAT_XPP) || defined(HB_COMPAT_FOXPRO)
               case 'L':
               case '0':
                  uiPicFlags |= PF_PADL;  /* FoxPro/XPP extension */
                  byParamL = '0';
                  break;
#endif
               case 'B':
                  uiPicFlags |= PF_LEFT;
                  break;
               case 'C':
                  uiPicFlags |= PF_CREDIT;
                  break;
               case 'D':
                  uiPicFlags |= PF_DATE;
                  break;
               case 'E':
                  uiPicFlags |= PF_BRITISH;
                  break;
               case 'R':
                  uiPicFlags |= PF_REMAIN;
                  break;
               case 'S':
                  uiPicFlags |= PF_WIDTH;
                  ulParamS = 0;
                  while( ulPicLen > 1 && *( szPic + 1 ) >= '0' && *( szPic + 1 ) <= '9' )
                  {
                     szPic++;
                     ulPicLen--;
                     ulParamS = ( ulParamS * 10 ) + ( ( ULONG ) ( *szPic - '0' ) );
                  }
                  break;
               case 'X':
                  uiPicFlags |= PF_DEBIT;
                  break;
               case 'Z':
                  uiPicFlags |= PF_EMPTY;
                  break;
            }

            szPic++;
            ulPicLen--;
         }
      }

      /* ======================================================= */
      /* Handle STRING values                                    */
      /* ======================================================= */

      if( HB_IS_STRING( pValue ) )
      {
         char * szExp = hb_itemGetCPtr( pValue );
         ULONG  ulExpLen = hb_itemGetCLen( pValue );
         ULONG  ulExpPos = 0;
         BOOL bAnyPic = FALSE;
         BOOL bFound  = FALSE;

         /* Grab enough */

         /* Support date function for strings */
         if( uiPicFlags & ( PF_DATE | PF_BRITISH ) )
         {
            hb_dateFormat( "XXXXXXXX", szPicDate, hb_setGetDateFormat() );
            szPic = szPicDate;
            ulPicLen = strlen( szPicDate );
         }

         szResult = ( char * ) hb_xgrab( ulExpLen + ulPicLen + 1 );
         ulResultPos = 0;

         /* Template string */
         if( ulPicLen )
         {
            while( ulPicLen )                        /* Analyze picture mask */
            {
               if( ulExpPos < ulExpLen )
               {
                  switch( *szPic )
                  {
                     /* Upper */
                     case '!':
                     {
                        szResult[ ulResultPos++ ] = ( char ) hb_charUpper( szExp[ ulExpPos ] );
                        ulExpPos++;
                        bAnyPic = TRUE;
                        break;
                     }

                     /* Out the character */
                     case '#':
                     case '9':
                     case 'a':
                     case 'A':
                     case 'l':
                     case 'L':
                     case 'n':
                     case 'N':
                     case 'x':
                     case 'X':
                     {
                        szResult[ ulResultPos++ ] = ( uiPicFlags & PF_UPPER ) ? ( char ) hb_charUpper( szExp[ ulExpPos ] ) : szExp[ ulExpPos ];
                        ulExpPos++;
                        bAnyPic = TRUE;
                        break;
                     }

                     /* Logical */
                     case 'y':
                     case 'Y':
                     {
                        szResult[ ulResultPos++ ] = ( szExp[ ulExpPos ] == 't' ||
                                                      szExp[ ulExpPos ] == 'T' ||
                                                      szExp[ ulExpPos ] == 'y' ||
                                                      szExp[ ulExpPos ] == 'Y' ) ? ( char ) 'Y' : ( char ) 'N';
                        ulExpPos++;
                        bAnyPic = TRUE;
                        break;
                     }

                     /* Other choices */
                     default:
                     {
                        szResult[ ulResultPos++ ] = *szPic;

                        if( !( uiPicFlags & PF_REMAIN ) )
                           ulExpPos++;
                     }
                  }
               }
               else if( !( uiPicFlags & PF_REMAIN ) )
                  break;

               else
               {
/* NOTE: This is a FoxPro compatible [jarabal] */
#if defined(HB_COMPAT_FOXPRO)
                  ulPicLen = 0;
                  break;
#else
                  switch( *szPic )
                  {
                     case '!':
                     case '#':
                     case '9':
                     case 'a':
                     case 'A':
                     case 'l':
                     case 'L':
                     case 'n':
                     case 'N':
                     case 'x':
                     case 'X':
                     case 'y':
                     case 'Y':
                     {
                        szResult[ ulResultPos++ ] = ' ';
                        break;
                     }

                     default:
                        szResult[ ulResultPos++ ] = *szPic;
                  }
#endif                  
               }

               szPic++;
               ulPicLen--;
            }
         }
         else
         {
            while( ulExpPos++ < ulExpLen )
            {
               if( uiPicFlags & PF_EXCHANG )
               {
                  switch( *szExp )
                  {
                     case ',':
                     {
                        szResult[ ulResultPos++ ] = '.';
                        break;
                     }
                     case '.':
                     {
                        if( !bFound && ulResultPos )
                        {
                           szResult[ ulResultPos++ ] = ',';
                           bFound = TRUE;
                        }

                        break;
                     }
                     default:
                        szResult[ ulResultPos++ ] = ( uiPicFlags & PF_UPPER ) ? ( char ) hb_charUpper( *szExp ) : *szExp;
                  }
               }
               else
               {
                  szResult[ ulResultPos++ ] = ( uiPicFlags & PF_UPPER ) ? ( char ) hb_charUpper( *szExp ) : *szExp;
               }
               szExp++;
            }
         }

         if( ( uiPicFlags & PF_REMAIN ) && ! bAnyPic )
         {
            while( ulExpPos++ < ulExpLen )
            {
               szResult[ ulResultPos++ ] = ( uiPicFlags & PF_UPPER ) ? ( char ) hb_charUpper( *szExp ) : *szExp;
               szExp++;
            }
         }

         /* Any chars left ? */
         if( ( uiPicFlags & PF_REMAIN ) && ulPicLen )
         {
            /* Export remainder */
            while( ulPicLen-- )
               szResult[ ulResultPos++ ] = ' ';
         }

         if( uiPicFlags & PF_BRITISH )
         {
            /* CA-Cl*pper do not check result size and always exchanges
             * bytes 1-2 with bytes 4-5. It's buffer overflow bug and I do
             * not want to replicate it. It also causes that the results of
             * @E conversion used for strings smaller then 5 bytes behaves
             * randomly.
             * In fact precise tests can show that it's not random behavior
             * but CA-Cl*pper uses static buffer for result and when current
             * one is smaller then 5 bytes then first two bytes are exchanged
             * with 4-5 bytes from previous result which was length enough,
             * f.e.:
             *          ? transform( "0123456789", "" )
             *          ? transform( "AB", "@E" )
             *          ? transform( "ab", "@E" )
             * [druzus]
             */
            if( ulResultPos >= 5 )
            {
               szPicDate[ 0 ] = szResult[ 0 ];
               szPicDate[ 1 ] = szResult[ 1 ];
               szResult[ 0 ] = szResult[ 3 ];
               szResult[ 1 ] = szResult[ 4 ];
               szResult[ 3 ] = szPicDate[ 0 ];
               szResult[ 4 ] = szPicDate[ 1 ];
            }
         }
      }

      /* ======================================================= */
      /* Handle NUMERIC values                                   */
      /* ======================================================= */

      else if( HB_IS_NUMERIC( pValue ) )
      {
         int      iWidth;                             /* Width of string          */
         int      iDec;                               /* Number of decimals       */
         int      iCount;
         ULONG    i;
         char     cPic;
         PHB_ITEM pNumber = NULL;

         double dValue = hb_itemGetND( pValue );

         /* Support date function for numbers */
         if( uiPicFlags & PF_DATE )
         {
            hb_dateFormat( "99999999", szPicDate, hb_setGetDateFormat() );
            szPic = szPicDate;
            ulPicLen = strlen( szPicDate );
         }

         for( i = iWidth = iDec = 0; i < ulPicLen; i++ )
         {
            if( szPic[ i ] == '.' )
            {
               while( ++i < ulPicLen )
               {
                  if( szPic[ i ] == '9' || szPic[ i ] == '#' ||
                      szPic[ i ] == '$' || szPic[ i ] == '*' )
                  {
                     iWidth++;
                     iDec++;
                  }
               }
               if( iDec )
                  iWidth++;
               break;
            }
            else if( szPic[ i ] == '9' || szPic[ i ] == '#' ||
                     szPic[ i ] == '$' || szPic[ i ] == '*' )
               iWidth++;
         }

         iCount = 0;
         if( iWidth == 0 )                             /* Width calculated ??      */
         {
            hb_itemGetNLen( pValue, &iWidth, &iDec );
            if( hb_setGetFixed() )
            {
               if( HB_IS_NUMINT( pValue ) )
                  iWidth += 2 + ( hb_setGetDecimals() << 1 );
               else
                  iDec = hb_setGetDecimals();
            }
            if( iDec )
               iWidth += iDec + 1;
         }
         else if( iDec > 0 && iWidth - iDec == 1 )
         {
            iCount = 1;
            iWidth++;
         }

         if( ( uiPicFlags & ( PF_DEBIT | PF_PARNEG | PF_PARNEGWOS ) ) && dValue < 0 )
         {
            /* Always convert absolute val */
            if( HB_IS_NUMINT( pValue ) ) /* workaround for 64bit integer conversion */
               pNumber = hb_itemPutNInt( NULL, - hb_itemGetNInt( pValue ) );
            else
               pNumber = hb_itemPutND( NULL, -dValue );
            pValue = pNumber;
         }

         if( dValue != 0 )
            /* Don't empty the result if the number is not zero */
            uiPicFlags &= ~PF_EMPTY;

         /* allocate 4 additional bytes for possible ") CR" or ") DB" suffix */
         szResult = ( char * ) hb_xgrab( iWidth + 5 );
         hb_itemStrBuf( szResult, pValue, iWidth, iDec );
         if( pNumber )
            hb_itemRelease( pNumber );

         if( iCount )
         {
            iWidth--;
            if( *szResult != '0' )
            {
               memset( szResult + 1, '*', iWidth );
               *szResult = '.';
            }
            else
               memmove( szResult, szResult + 1, iWidth );
            szResult[ iWidth ] = '\0';
         }

         /* Pad with padding char */
         if( uiPicFlags & PF_PADL )
         {
            for( i = 0; szResult[ i ] == ' '; i++ )
               szResult[ i ] = byParamL;

            /* please test it with FoxPro and xbase++ to check
             * if they made the same [druzus]
             */
            if( i && szResult[ i ] == '-' )
            {
               szResult[ 0 ] = '-';
               szResult[ i ] = byParamL;
            }
         }

         if( ulPicLen == 0 )
         {
            if( uiPicFlags & PF_EXCHANG )
            {
               for( i = 0; i < ( ULONG ) iWidth; ++i )
               {
                  if( szResult[ i ] == '.' )
                  {
                     szResult[ i ] = ',';
                     break;
                  }
               }
            }
            i = iWidth;
         }
         else
         {
            char * szStr = szResult;

            /* allocate 4 additional bytes for possible ") CR" or ") DB" suffix */
            szResult = ( char * ) hb_xgrab( ulPicLen + 5 );

            for( i = iCount = 0; i < ulPicLen; i++ )
            {
               cPic = szPic[ i ];
               if( cPic == '9' || cPic == '#' )
               {
                  szResult[ i ] = iCount < iWidth ? szStr[ iCount++ ] : ' ';
               }
               else if( cPic == '$' || cPic == '*' )
               {
                  if( iCount < iWidth )
                  {
                     szResult[ i ] = szStr[ iCount ] == ' ' ? cPic : szStr[ iCount ];
                     iCount++;
                  }
                  else
                     szResult[ i ] = ' ';
               }
               else if( cPic == '.' && iCount < iWidth )
               {
                  szResult[ i ] = ( uiPicFlags & PF_EXCHANG ) ? ',' : '.';
                  iCount++;
               }
               else if( cPic == ',' && i && iCount < iWidth )
               {
                  if( isdigit( ( UCHAR ) szResult[ i - 1 ] ) )
                     szResult[ i ] = ( uiPicFlags & PF_EXCHANG ) ? '.' : ',';
                  else
                  {
                     szResult[ i ] = szResult[ i - 1 ];
                     if( szResult[ i - 1 ] == '-' )
                     {
                        szResult[ i - 1 ] = i > 1 && szResult[ i - 2 ] != '$' ?
                                            szResult[ i - 2 ] : ' ';
                     }
                  }
               }
               else
                  szResult[ i ] = cPic;
            }
            hb_xfree( szStr );
         }

         if( dValue < 0 )
         {
            /* PF_PARNEGWOS has higher priority then PF_PARNEG */
            if( ( uiPicFlags & PF_PARNEGWOS ) )
            {
               iCount = 0;
               if( ulPicLen && i > 1 )
               {
                  if( *szPic == *szResult && ( *szPic == '*' || *szPic == '$' ) &&
                      szResult[ 1 ] == ' ' )
                     ++iCount;
               }
               while( ( ULONG ) iCount + 1 < i && szResult[ iCount + 1 ] == ' ' )
                  ++iCount;

#ifndef HB_C52_STRICT
               /* This is not Clipper compatible */
               if( szResult[ iCount ] >= '1' && szResult[ iCount ] <= '9' &&
                   ( ulPicLen == 0 || szPic[ iCount ] == '9' ||
                     szPic[ iCount ] != szResult[ iCount ] ) )
               {
                  szResult[ iCount ] = '(';
                  for( ++iCount; ( ULONG ) iCount < i; iCount++ )
                  {
                     if( szResult[ iCount ] >= '0' && szResult[ iCount ] <= '9' &&
                         ( ulPicLen == 0 || szPic[ iCount ] == '9' ||
                           szPic[ iCount ] != szResult[ iCount ] ) )
                        szResult[ iCount ] = '*';
                  }
               }
               else
#endif
                  szResult[ iCount ] = '(';
               szResult[ i++ ] = ')';
            }
            else if( ( uiPicFlags & PF_PARNEG ) )
            {
#ifndef HB_C52_STRICT
               /* This is not Clipper compatible */
               if( *szResult >= '1' && *szResult <= '9' &&
                   ( ulPicLen == 0 || *szPic == '9' || *szPic != *szResult ) )
               {
                  for( iCount = 1; ( ULONG ) iCount < i; iCount++ )
                  {
                     if( szResult[ iCount ] >= '0' && szResult[ iCount ] <= '9' &&
                         ( ulPicLen == 0 || szPic[ iCount ] == '9' ||
                           szPic[ iCount ] != szResult[ iCount ] ) )
                        szResult[ iCount ] = '*';
                  }
               }
#endif
               *szResult       = '(';
               szResult[ i++ ] = ')';
               ulOffset = 1;
            }

            if( ( uiPicFlags & PF_DEBIT ) )
            {
               szResult[ i++ ] = ' ';
               szResult[ i++ ] = 'D';
               szResult[ i++ ] = 'B';
            }
         }
         else if( ( uiPicFlags & PF_CREDIT ) && dValue > 0 )
         {
            szResult[ i++ ] = ' ';
            szResult[ i++ ] = 'C';
            szResult[ i++ ] = 'R';
         }

         ulResultPos = i;
         szResult[ i ] = '\0';
      }

      /* ======================================================= */
      /* Handle DATE values                                      */
      /* ======================================================= */

      else if( HB_IS_DATE( pValue ) )
      {
         char szDate[ 9 ];
         char * szDateFormat;
         char szNewFormat[ 11 ];
         UINT nFor;

         szResult = ( char * ) hb_xgrab( 13 );
         szDateFormat = hb_setGetDateFormat();

#ifndef HB_C52_STRICT
         if( uiPicFlags & PF_BRITISH )
         {
            /* When @E is used CA-Cl*pper do not update date format
             * pattern but wrongly moves 4-th and 5-th bytes of
             * formatted date to the beginning (see below). It causes
             * that date formats formats different then MM?DD?YY[YY]
             * are wrongly translated. The code below is not CA-Cl*pper
             * compatible but it tries to respect user date format
             * [druzus]
             */
            const char * szBritish = hb_setGetCentury() ?
                                     "DDMMYYYY" : "DDMMYY";
            char cLast = 'x';

            for( nFor = 0; nFor < 10; nFor++ )
            {
               if( *szBritish == cLast )
               {
                  szNewFormat[ nFor ] = cLast;
                  szBritish++;
               }
               else if( ! *szDateFormat )
                  break;
               else if( *szBritish &&
                        ( *szDateFormat == 'Y' || *szDateFormat == 'y' ||
                          *szDateFormat == 'D' || *szDateFormat == 'd' ||
                          *szDateFormat == 'M' || *szDateFormat == 'm' ) )
               {
                  szNewFormat[ nFor ] = cLast = *szBritish++;
                  do
                     szDateFormat++;
                  while( szDateFormat[ -1 ] == szDateFormat[ 0 ] );
               }
               else
                  szNewFormat[ nFor ] = *szDateFormat++;
            }
            szNewFormat[ nFor ] = '\0';
            szDateFormat = szNewFormat;
         }
#endif

         hb_dateFormat( hb_itemGetDS( pValue, szDate ), szResult, szDateFormat );
         ulResultPos = strlen( szResult );

#ifdef HB_C52_STRICT
         if( uiPicFlags & PF_BRITISH )
         {
            /* replicated wrong Clipper behavior, see note above.
             * It's not exact CA-Cl*pper behavior because it does
             * not check for size of results and can extract data
             * from static memory buffer used in previous conversions
             * (see my note for @E in string conversion above)
             * but this is buffer overflow and I do not plan to
             * replicated it too [druzus]
             */
            if( ulResultPos >= 5 )
            {
               szNewFormat[ 0 ] = szResult[ 0 ];
               szNewFormat[ 1 ] = szResult[ 1 ];
               szResult[ 0 ] = szResult[ 3 ];
               szResult[ 1 ] = szResult[ 4 ];
               szResult[ 3 ] = szNewFormat[ 0 ];
               szResult[ 4 ] = szNewFormat[ 1 ];
            }
         }
#endif
         if( uiPicFlags & PF_REMAIN )
         {
            /* Here we also respect the date format modified for @E [druzus]
             */
            hb_dateFormat( "99999999", szPicDate, szDateFormat );
            ulPicLen = strlen( szPicDate );

            for( nFor = 0; nFor < ulPicLen; nFor++ )
            {
               if( szPicDate[ nFor ] != '9' )
               {
                  memmove( szResult + nFor + 1, szResult + nFor, 12 - nFor );
                  szResult[ nFor ] = szPicDate[ nFor ];
                  ulResultPos++;
               }
            }
         }
      }

      /* ======================================================= */
      /* Handle LOGICAL values                                   */
      /* ======================================================= */

      else if( HB_IS_LOGICAL( pValue ) )
      {
         BOOL bDone = FALSE;
         BOOL bExit = FALSE;
         char cPic;

         if( uiPicFlags & ( PF_DATE | PF_BRITISH ) )
         {
            hb_dateFormat( "99999999", szPicDate, hb_setGetDateFormat() );
            szPic = szPicDate;
            ulPicLen = strlen( szPicDate );
         }

         ulResultPos = 0;
         szResult = ( char * ) hb_xgrab( ulPicLen + 2 );

         for( ; ( ulPicLen || !bDone ) && !bExit ; ulResultPos++, szPic++, ulPicLen-- )
         {
            if( ulPicLen )
               cPic = *szPic;
            else
            {
               cPic  = 'L';
               bExit = TRUE;
            }

            switch( cPic )
            {
               case 'y':                     /* Yes/No                   */
               case 'Y':                     /* Yes/No                   */
               {
                  if( !bDone )
                  {
                     szResult[ ulResultPos ] = hb_itemGetL( pValue ) ? 'Y' : 'N';
                     bDone = TRUE;           /* Logical written          */
                  }
                  else
                     szResult[ ulResultPos ] = ' ';

                  break;
               }

               case '#':
               case 'l':                     /* True/False               */
               case 'L':                     /* True/False               */
               {
                  if( !bDone )
                  {
                     szResult[ ulResultPos ] = hb_itemGetL( pValue ) ? 'T' : 'F';
                     bDone = TRUE;
                  }
                  else
                     szResult[ ulResultPos ] = ' ';

                  break;
               }

               default:
                  szResult[ ulResultPos ] = cPic;
            }

            if( !( uiPicFlags & PF_REMAIN ) )
               bExit = TRUE;
         }
      }

      /* ======================================================= */

      else
      {
         szResult = NULL; /* To avoid GCC -O2 warning */
         ulResultPos = 0; /* To avoid GCC -O2 warning */
         bError = TRUE;
      }

      if( ! bError )
      {
         if( uiPicFlags & PF_EMPTY )
            memset( szResult, ' ', ulResultPos );
         else if( uiPicFlags & PF_LEFT )
         {
            /* Trim left and pad with spaces */
            ULONG ulFirstChar = ulOffset;

            while( ulFirstChar < ulResultPos && szResult[ ulFirstChar ] == ' ' )
               ulFirstChar++;

            if( ulFirstChar > ulOffset && ulFirstChar < ulResultPos )
            {
               memmove( szResult + ulOffset, szResult + ulFirstChar, ulResultPos - ulFirstChar );
               memset( szResult + ulOffset + ulResultPos - ulFirstChar, ' ', ulFirstChar - ulOffset );
            }
         }

         hb_retclen_buffer( szResult, ( ulParamS && ulResultPos > ulParamS ) ? ulParamS : ulResultPos );
      }
   }
   else if( pPic || ISNIL( 2 ) ) /* Picture is an empty string or NIL */
   {
      if( HB_IS_STRING( pValue ) )
      {
         hb_itemReturn( pValue );
      }
      else if( HB_IS_NUMERIC( pValue ) )
      {
         char * szStr;

         if( HB_IS_NUMINT( pValue ) && hb_setGetFixed() )
         {
            int iWidth, iDec;
            hb_itemGetNLen( pValue, &iWidth, &iDec );
            iWidth += 2 + ( hb_setGetDecimals() << 1 );
            szStr = ( char * ) hb_xgrab( iWidth + 1 );
            hb_itemStrBuf( szStr, pValue, iWidth, iDec );
            hb_retclen_buffer( szStr, iWidth );
         }
         else
         {
            ULONG ulLen;
            BOOL bFreeReq;

            szStr = hb_itemString( pValue, &ulLen, &bFreeReq );
            if( bFreeReq )
               hb_retclen_buffer( szStr, ulLen );
            else
               hb_retclen( szStr, ulLen );
         }
      }
      else if( HB_IS_DATE( pValue ) )
      {
         char szDate[ 9 ];
         char szResult[ 11 ];

         hb_retc( hb_dateFormat( hb_itemGetDS( pValue, szDate ), szResult, hb_setGetDateFormat() ) );
      }
      else if( HB_IS_LOGICAL( pValue ) )
      {
         hb_retc( hb_itemGetL( pValue ) ? "T" : "F" );
      }
      else
         bError = TRUE;
   }
   else
      bError = TRUE;

   /* If there was any parameter error, launch a runtime error */

   if( bError )
      hb_errRT_BASE_SubstR( EG_ARG, 1122, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
transfrm.c88
trim.c
TypeFunctionSourceLine
CHAR *hb_strLTrim( const char * szText, ULONG * ulLen )
char * hb_strLTrim( const char * szText, ULONG * ulLen )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_strLTrim(%s, %p)", szText, ulLen));

   while( *ulLen && HB_ISSPACE( *szText ) )
   {
      szText++;
      ( *ulLen )--;
   }

   return ( char * ) szText;
}
trim.c57
ULONGhb_strRTrimLen( const char * szText, ULONG ulLen, BOOL bAnySpace )
ULONG hb_strRTrimLen( const char * szText, ULONG ulLen, BOOL bAnySpace )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_strRTrimLen(%s, %lu. %d)", szText, ulLen, (int) bAnySpace));

   if( bAnySpace )
   {
      while( ulLen && HB_ISSPACE( szText[ ulLen - 1 ] ) )
         ulLen--;
   }
   else
   {
      while( ulLen && szText[ ulLen - 1 ] == ' ' )
         ulLen--;
   }

   return ulLen;
}
trim.c72
HB_FUNCLTRIM(void)
HB_FUNC( LTRIM )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText )
   {
      ULONG ulLen, ulSrc;
      char * szText;

      ulLen = ulSrc = hb_itemGetCLen( pText );
      szText = hb_strLTrim( hb_itemGetCPtr( pText ), &ulLen );

      if( ulLen == ulSrc )
         hb_itemReturn( pText );
      else
         hb_retclen( szText, ulLen );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1101, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}

trim.c93
HB_FUNCRTRIM(void)
HB_FUNC( RTRIM )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText )
   {
      ULONG ulLen, ulSrc;
      char * szText = hb_itemGetCPtr( pText );

      ulSrc = hb_itemGetCLen( pText );
#ifdef HB_EXTENSION
      ulLen = hb_strRTrimLen( szText, ulSrc, ISLOG( 2 ) && hb_parl( 2 ) );
#else
      ulLen = hb_strRTrimLen( szText, ulSrc, FALSE );
#endif

      if( ulLen == ulSrc )
         hb_itemReturn( pText );
      else
         hb_retclen( szText, ulLen );
   }
   else
      /* NOTE: "TRIM" is right here [vszakats] */
      hb_errRT_BASE_SubstR( EG_ARG, 1100, NULL, "TRIM", HB_ERR_ARGS_BASEPARAMS );
}
trim.c118
HB_FUNCTRIM(void)
HB_FUNC( TRIM )
{
   HB_FUNC_EXEC( RTRIM );
}

trim.c144
HB_FUNCALLTRIM(void)
HB_FUNC( ALLTRIM )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText )
   {
      ULONG ulLen, ulSrc;
      char * szText = hb_itemGetCPtr( pText );

      ulSrc = hb_itemGetCLen( pText );
#ifdef HB_EXTENSION
      ulLen = hb_strRTrimLen( szText, ulSrc, ISLOG( 2 ) && hb_parl( 2 ) );
#else
      ulLen = hb_strRTrimLen( szText, ulSrc, FALSE );
#endif
      szText = hb_strLTrim( szText, &ulLen );

      if( ulLen == ulSrc )
         hb_itemReturn( pText );
      else
         hb_retclen( szText, ulLen );
   }
   else
#ifdef HB_COMPAT_C53
      /* NOTE: This runtime error appeared in CA-Cl*pper 5.3 [vszakats] */
#ifdef HB_C52_STRICT
      hb_errRT_BASE_SubstR( EG_ARG, 2022, NULL, HB_ERR_FUNCNAME, 0 );
#else
      hb_errRT_BASE_SubstR( EG_ARG, 2022, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
#endif
#else
      hb_retc( NULL );
#endif
}
trim.c154
tscalara.c
TypeFunctionSourceLine
HB_FUNCHBARRAY(void)
HB_FUNC( HBARRAY )
{
   HB_FUNC_EXEC( __HBARRAY );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalara.c58
tscalarb.c
TypeFunctionSourceLine
HB_FUNCHBBLOCK(void)
HB_FUNC( HBBLOCK )
{
   HB_FUNC_EXEC( __HBBLOCK );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalarb.c58
tscalarc.c
TypeFunctionSourceLine
HB_FUNCHBCHARACTER(void)
HB_FUNC( HBCHARACTER )
{
   HB_FUNC_EXEC( __HBCHARACTER );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalarc.c58
tscalard.c
TypeFunctionSourceLine
HB_FUNCHBDATE(void)
HB_FUNC( HBDATE )
{
   HB_FUNC_EXEC( __HBDATE );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalard.c58
tscalarh.c
TypeFunctionSourceLine
HB_FUNCHBHASH(void)
HB_FUNC( HBHASH )
{
   HB_FUNC_EXEC( __HBHASH );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalarh.c58
tscalarl.c
TypeFunctionSourceLine
HB_FUNCHBLOGICAL(void)
HB_FUNC( HBLOGICAL )
{
   HB_FUNC_EXEC( __HBLOGICAL );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalarl.c58
tscalarn.c
TypeFunctionSourceLine
HB_FUNCHBNUMERIC(void)
HB_FUNC( HBNUMERIC )
{
   HB_FUNC_EXEC( __HBNUMERIC );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalarn.c58
tscalarp.c
TypeFunctionSourceLine
HB_FUNCHBPOINTER(void)
HB_FUNC( HBPOINTER )
{
   HB_FUNC_EXEC( __HBPOINTER );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalarp.c58
tscalars.c
TypeFunctionSourceLine
HB_FUNCHBSYMBOL(void)
HB_FUNC( HBSYMBOL )
{
   HB_FUNC_EXEC( __HBSYMBOL );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalars.c58
tscalaru.c
TypeFunctionSourceLine
HB_FUNCHBNIL(void)
HB_FUNC( HBNIL )
{
   HB_FUNC_EXEC( __HBNIL );

   if( hb_vmRequestQuery() == 0 )
   {
      PHB_ITEM pItem = hb_param( -1, HB_IT_ANY );

      if( HB_IS_OBJECT( pItem ) )
      {
         hb_vmPushDynSym( hb_dynsymGetCase( "NEW" ) );
         hb_vmPush( pItem );
         hb_vmSend( 0 );
      }
   }
}
tscalaru.c58
type.c
TypeFunctionSourceLine
HB_FUNCTYPE(void)
HB_FUNC( TYPE )
{
   HB_ITEM_PTR pItem = hb_param( 1, HB_IT_STRING );

   if( pItem )
   {
      hb_retc( hb_macroGetType( pItem ) );
      hb_memvarUpdatePrivatesBase();
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1121, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
type.c56
val.c
TypeFunctionSourceLine
HB_FUNCVAL(void)
HB_FUNC( VAL )
{
   PHB_ITEM pText = hb_param( 1, HB_IT_STRING );

   if( pText )
   {
      char * szText = hb_itemGetCPtr( pText );
      int iWidth, iDec, iLen = ( int ) hb_itemGetCLen( pText );
      BOOL fDbl;
      HB_LONG lValue;
      double dValue;

      fDbl = hb_valStrnToNum( szText, iLen, &lValue, &dValue , &iDec, &iWidth );

      if( !fDbl )
         hb_retnintlen( lValue, iWidth );
      else
         hb_retnlen( dValue, iWidth, iDec );
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 1098, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
val.c57
valtostr.c
TypeFunctionSourceLine
HB_FUNCHB_VALTOSTR(void)
HB_FUNC( HB_VALTOSTR )
{
   ULONG ulLen;
   BOOL bFreeReq;
   char * buffer = hb_itemString( hb_param( 1, HB_IT_ANY ), &ulLen, &bFreeReq );

   if( bFreeReq )
      hb_retclen_buffer( buffer, ulLen );
   else
      hb_retclen( buffer, ulLen );
}
valtostr.c56
HB_FUNCHB_STRTOEXP(void)
HB_FUNC( HB_STRTOEXP )
{
   char * pszString = hb_parc( 1 );
   if( pszString )
   {
      ULONG ulLen = hb_parclen( 1 ), ulRet, ul;
      int iType = 0, iQ = 0;
      char ch, * pDst, * pszResult;

      for( ul = 0; ul < ulLen; ++ul )
      {
         if( pszString[ ul ] == '"' )
         {
            ++iQ;
            iType |= 1;
         }
         else if( pszString[ ul ] == '\\' )
            ++iQ;
         else if( pszString[ ul ] == '\'' )
            iType |= 2;
         else if( pszString[ ul ] == ']' )
            iType |= 4;
         else if( pszString[ ul ] == '\r' ||
                  pszString[ ul ] == '\n' ||
                  pszString[ ul ] == '\0' )
         {
            iType |= 7;
            iQ += 3;
         }
      }
      if( iType == 7 )
      {
         ulRet = ulLen + 3 + iQ;
         pDst = pszResult = ( char * ) hb_xgrab( ulRet + 1 );
         *pDst++ = 'e';
         *pDst++ = '"';
         for( ul = 0; ul < ulLen; ++ul )
         {
            ch = pszString[ ul ];
            if( ch == '"' )
            {
               *pDst++ = '\\';
               *pDst++ = '"';
            }
            else if( ch == '\\' )
            {
               *pDst++ = '\\';
               *pDst++ = '\\';
            }
            else if( ch == '\r' || ch == '\n' || ch == '\0' )
            {
               *pDst++ = '\\';
               *pDst++ = '0';
               *pDst++ = '0' + ( ch >> 3 );
               *pDst++ = '0' + ( ch & 7 );
            }
            else
               *pDst++ = ch;
         }
         *pDst++ = '"';
      }
      else
      {
         ulRet = ulLen + 2;
         pDst = pszResult = ( char * ) hb_xgrab( ulRet + 1 );
         if( ( iType & 1 ) == 0 )
            *pDst++ = ch = '"';
         else if( ( iType & 2 ) == 0 )
            *pDst++ = ch = '\'';
         else
         {
            *pDst++ = '[';
            ch = ']';
         }
         memcpy( pDst, pszString, ulLen );
         pDst += ulLen;
         *pDst++ = ch;
      }
      *pDst = '\0';
      hb_retclen_buffer( pszResult, ulRet );
   }
}
valtostr.c68
valtype.c
TypeFunctionSourceLine
HB_FUNCVALTYPE(void)
HB_FUNC( VALTYPE )
{
   hb_retc( hb_itemTypeStr( hb_param( 1, HB_IT_ANY ) ) );
}
valtype.c70
HB_FUNCHB_ISNIL(void)
HB_FUNC( HB_ISNIL )
{
   hb_retl( ISNIL( 1 ) );
}
valtype.c89
HB_FUNCHB_ISNUMERIC(void)
HB_FUNC( HB_ISNUMERIC )
{
   hb_retl( ISNUM( 1 ) );
}
valtype.c94
HB_FUNCHB_ISLOGICAL(void)
HB_FUNC( HB_ISLOGICAL )
{
   hb_retl( ISLOG( 1 ) );
}
valtype.c99
HB_FUNCHB_ISDATE(void)
HB_FUNC( HB_ISDATE )
{
   hb_retl( ISDATE( 1 ) );
}
valtype.c104
HB_FUNCHB_ISBLOCK(void)
HB_FUNC( HB_ISBLOCK )
{
   hb_retl( ISBLOCK( 1 ) );
}
valtype.c109
HB_FUNCHB_ISPOINTER(void)
HB_FUNC( HB_ISPOINTER )
{
   hb_retl( ISPOINTER( 1 ) );
}
valtype.c114
HB_FUNCHB_ISSYMBOL(void)
HB_FUNC( HB_ISSYMBOL )
{
   hb_retl( ISSYMBOL( 1 ) );
}
valtype.c119
HB_FUNCHB_ISSTRING(void)
HB_FUNC( HB_ISSTRING )
{
   hb_retl( ISCHAR( 1 ) );
}
valtype.c124
HB_FUNCHB_ISCHAR(void)
HB_FUNC( HB_ISCHAR )
{
   hb_retl( ( hb_parinfo( 1 ) & HB_IT_MEMO ) == HB_IT_STRING );
}
valtype.c129
HB_FUNCHB_ISMEMO(void)
HB_FUNC( HB_ISMEMO )
{
   hb_retl( ( hb_parinfo( 1 ) & HB_IT_MEMOFLAG ) != 0 );
}
valtype.c134
HB_FUNCHB_ISARRAY(void)
HB_FUNC( HB_ISARRAY )
{
   hb_retl( hb_extIsArray( 1 ) );
}
valtype.c139
HB_FUNCHB_ISOBJECT(void)
HB_FUNC( HB_ISOBJECT )
{
   hb_retl( ISOBJECT( 1 ) );
}
valtype.c144
HB_FUNCHB_ISHASH(void)
HB_FUNC( HB_ISHASH )
{
   hb_retl( ISHASH( 1 ) );
}
valtype.c149
HB_FUNCHB_ISNULL(void)
HB_FUNC( HB_ISNULL )
{
   PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );

   if( pItem )
   {
      if( HB_IS_STRING( pItem ) )
      {
         hb_retl( hb_itemGetCLen( pItem ) == 0 );
         return;
      }
      else if( HB_IS_ARRAY( pItem ) )
      {
         hb_retl( hb_arrayLen( pItem ) == 0 );
         return;
      }
      else if( HB_IS_HASH( pItem ) )
      {
         hb_retl( hb_hashLen( pItem ) == 0 );
         return;
      }
   }
   hb_errRT_BASE_SubstR( EG_ARG, 1111, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
valtype.c154
version.c
TypeFunctionSourceLine
HB_FUNCOS(void)
HB_FUNC( OS )
{
   hb_retc_buffer( hb_verPlatform() );
}
version.c66
HB_FUNCHB_COMPILER(void)
HB_FUNC( HB_COMPILER )
{
   hb_retc_buffer( hb_verCompiler() );
}
version.c71
HB_FUNCVERSION(void)
HB_FUNC( VERSION )
{
   hb_retc_buffer( hb_verHarbour() );
}
version.c76
HB_FUNCHB_PCODEVER(void)
HB_FUNC( HB_PCODEVER )
{
   hb_retc_buffer( hb_verPCode() );
}
version.c81
HB_FUNCHB_BUILDDATE(void)
HB_FUNC( HB_BUILDDATE )
{
   hb_retc_buffer( hb_verBuildDate() );
}
version.c86
word.c
TypeFunctionSourceLine
HB_FUNCWORD(void)
HB_FUNC( WORD )
{
   if( ISNUM( 1 ) )
      hb_retni( hb_parni( 1 ) );
   else
      hb_errRT_BASE( EG_ARG, 1091, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
word.c60
xhelp.c
TypeFunctionSourceLine
HB_FUNC__XHELP(void)
HB_FUNC( __XHELP )
{
   static PHB_DYNS s_pDynSym = NULL;

   if( s_pDynSym == NULL )
      s_pDynSym = hb_dynsymGetCase( "HELP" );

   if( hb_dynsymIsFunction( s_pDynSym ) )
   {
      /* awhite: push the existing params after the dyn symbol */

      USHORT uiPCount = ( USHORT ) hb_pcount();
      USHORT uiParam;

      hb_vmPushDynSym( s_pDynSym );
      hb_vmPushNil();
      /* CA-Cl*pper respects references so hb_stackItemFromBase() is
       * used insted of hb_param() [druzus]
       */
      for( uiParam = 1; uiParam <= uiPCount; uiParam++ )
         hb_vmPush( hb_stackItemFromBase( uiParam ) );

      hb_vmDo( uiPCount );
      /* NOTE: Leave the return value as it is. */
   }
}
xhelp.c57
xsavescr.c
TypeFunctionSourceLine
STATIC VOIDhb_xSaveRestRelease( void * cargo )
static void hb_xSaveRestRelease( void * cargo )
{
   PHB_SCRDATA pScrData = ( PHB_SCRDATA ) cargo;

   if( pScrData->buffer )
      hb_xfree( pScrData->buffer );
}

static HB_TSD_NEW( s_scrData, sizeof( HB_SCRDATA ), NULL, hb_xSaveRestRelease );
xsavescr.c77
HB_FUNC__XSAVESCREEN(void)
HB_FUNC( __XSAVESCREEN )
{
   PHB_SCRDATA pScrData = ( PHB_SCRDATA ) hb_stackGetTSD( &s_scrData );
   ULONG ulSize;

   hb_gtGetPos( &pScrData->row, &pScrData->col );
   hb_gtRectSize( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), &ulSize );
   if( pScrData->buffer )
      hb_xfree( pScrData->buffer );
   pScrData->buffer = hb_xgrab( ulSize );
   hb_gtSave( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), pScrData->buffer );
}
xsavescr.c87
HB_FUNC__XRESTSCREEN(void)
HB_FUNC( __XRESTSCREEN )
{
   PHB_SCRDATA pScrData = ( PHB_SCRDATA ) hb_stackGetTSD( &s_scrData );

   if( pScrData->buffer )
   {
      hb_gtRest( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), pScrData->buffer );
      hb_xfree( pScrData->buffer );
      pScrData->buffer = NULL;

      hb_gtSetPos( pScrData->row, pScrData->col );
   }
}
xsavescr.c105
achoice.prg
TypeFunctionSourceLine
FUNCTIONAChoice( nTop, nLeft, nBottom, nRight, acItems, xSelect, xUserFunc, nPos, nHiLiteRow )
FUNCTION AChoice( nTop, nLeft, nBottom, nRight, acItems, xSelect, xUserFunc, nPos, nHiLiteRow )

   LOCAL nNumCols                          // Number of columns in the window
   LOCAL nNumRows                          // Number of rows in the window
   LOCAL nRowsClr                          // Number of rows to clear
   LOCAL acCopy    := {}                   // A padded copy of the items
   LOCAL alSelect                          // Select permission
   LOCAL nNewPos   := 0                    // The next item to be selected
   LOCAL lFinished := .F.                  // Is processing finished?
   LOCAL nKey      := 0                    // The keystroke to be processed
   LOCAL nMode     := AC_IDLE              // The current operating mode
   LOCAL nAtTop    := 1                    // The number of the item at the top
   LOCAL nAtBtm    := 1                    // The number of the item at the bottom
   LOCAL nItems    := 0                    // The number of items
   LOCAL nGap      := 0                    // The number of lines between top and current lines
                                           // Block used to search for items
   LOCAL lUserFunc                         // Is a user function to be used?
   LOCAL nUserFunc := 0                    // Return value from user function
   LOCAL nSaveCsr  := SetCursor( SC_NONE )
   LOCAL nFrstItem := 0
   LOCAL nLastItem := 0

   LOCAL bAction
   LOCAL cKey
   LOCAL nAux

   LOCAL bSelect   := { | x, y | iif( ISLOGICAL( x ), x, iif( !Empty( x ), ( y := &( x ), iif( ISLOGICAL( y ), y, .T. ) ), .T.) ) }

   ColorSelect( CLR_STANDARD )

   lUserFunc := !Empty( xUserFunc ) .AND. ValType( xUserFunc ) $ "CB"


   DEFAULT nTop       TO 0                 // The topmost row of the window
   DEFAULT nLeft      TO 0                 // The leftmost column of the window
   DEFAULT nBottom    TO MaxRow()          // The bottommost row of the window
   DEFAULT nRight     TO MaxCol()          // The rightmost column of the window

   DEFAULT acItems    TO {}                // The items from which to choose
   DEFAULT xSelect    TO .T.               // Array or logical, what is selectable
   DEFAULT nPos       TO 1                 // The number of the selected item
   DEFAULT nHiLiteRow TO 0                 // The row to be highlighted

   nNumCols := nRight - nLeft + 1
   IF nRight > MaxCol()
      nRight := MaxCol()
   ENDIF

   IF nBottom > MaxRow()
      nBottom := MaxRow()
   ENDIF

   nNumRows := nBottom - nTop + 1


   IF VALTYPE( xSelect ) $ "A"
      alSelect := xSelect
   ELSE
      alSelect := ARRAY( LEN( acItems ) )
      AFill( alSelect, xSelect )
   ENDIF


   IF !lFinished

      nMode := Ach_Limits( @nFrstItem, @nLastItem, @nItems, bSelect, alSelect, acItems )
      IF nMode == AC_NOITEM
         nPos := 0
      ENDIF

      // Ensure hilighted item can be selected
      nPos := BETWEEN( nFrstItem, nPos, nLastItem )

      // Force hilighted row to be valid
      nHiLiteRow := BETWEEN( 0, nHiLiteRow, nNumRows - 1 )

      // Force the topmost item to be a valid index of the array
      nAtTop := BETWEEN( 1, Max( 1, nPos - nHiLiteRow ), nItems )

      // Ensure as much of the selection area as possible is covered
      IF ( nAtTop + nNumRows - 1 ) > nItems
         nAtTop := Max( 1, nItems - nNumrows + 1 )
      ENDIF

      DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect, nItems )

   ENDIF

   DO WHILE !lFinished

      IF nMode != AC_GOTO .AND. nMode != AC_NOITEM
         nKey  := Inkey( 0 ) 
         nMode := AC_IDLE
      ENDIF

      DO CASE
      CASE ( bAction := SetKey( nKey ) ) != NIL

         Eval( bAction, ProcName( 1 ), ProcLine( 1 ), "" )
         IF Empty( NextKey() )
            KEYBOARD Chr( 255 )
            Inkey()
            nKey := 0
         ENDIF

         nRowsClr := Min( nNumRows, nItems )
         nMode := Ach_Limits( @nFrstItem, @nLastItem, @nItems, bSelect, alSelect, acItems )

         IF nMode == AC_NOITEM
            nPos := 0
            nAtTop := Max( 1, nPos - nNumRows + 1 )
         ELSE
            DO WHILE nPos < nLastItem .AND. !Eval( bSelect, alSelect[ nPos ] )
               nPos++
            ENDDO

            IF nPos > nLastItem
               nPos := BETWEEN( nFrstItem, nPos, nLastItem )
            ENDIF

            nAtTop := MIN( nAtTop, nPos )

            IF nAtTop + nNumRows - 1 > nItems
               nAtTop := BETWEEN( 1, nPos - nNumRows + 1, nItems - nNumRows + 1 )
            ENDIF

            IF nAtTop < 1
               nAtTop := 1
            ENDIF

         ENDIF

         DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect, nRowsClr )

      CASE ( nKey == K_ESC .OR. nMode == AC_NOITEM ) .AND. !lUserFunc

         nMode     := AC_ABORT
         nPos      := 0
         lFinished := .T.

      CASE nKey == K_LDBLCLK .OR. nKey == K_LBUTTONDOWN
         nAux := HitTest( nTop, nLeft, nBottom, nRight, MRow(), MCol() )
         IF nAux != 0 .AND. ( nNewPos := nAtTop + nAux - 1 ) <= nItems
            IF Eval( bSelect, alSelect[ nNewPos ] )
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               nPos := nNewPos
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
               IF nKey == K_LDBLCLK
                  Keyboard( Chr( K_ENTER ) )
               ENDIF
            ENDIF
         ENDIF

#ifdef HB_C52_STRICT
      CASE nKey == K_UP
#else
      CASE nKey == K_UP .OR. nKey == K_MWFORWARD
#endif

         IF nPos == nFrstItem
            nMode := AC_HITTOP
            IF nAtTop > Max( 1, nPos - nNumRows + 1 )
               nAtTop := Max( 1, nPos - nNumRows + 1 )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ELSE
            nNewPos := nPos - 1
            DO WHILE !Eval( bSelect, alSelect[ nNewPos ] )
               nNewPos--
            ENDDO
            IF INRANGE( nAtTop, nNewPos, nAtTop + nNumRows - 1 )
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               nPos := nNewPos
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
            ELSE
               DispBegin()
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               Scroll( nTop, nLeft, nBottom, nRight, ( nNewPos - ( nAtTop + nNumRows - 1 ) ) )
               nAtTop := nNewPos
               nPos   := Max( nPos, nAtTop + nNumRows - 1 )
               DO WHILE nPos > nNewPos
                  DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
                  nPos--
               ENDDO
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
               DispEnd()
            ENDIF
         ENDIF

#ifdef HB_C52_STRICT
      CASE nKey == K_DOWN
#else
      CASE nKey == K_DOWN .OR. nKey == K_MWBACKWARD
#endif

         // Find the next selectable item to display
         IF nPos == nLastItem
            nMode := AC_HITBOTTOM
            IF nAtTop < Min( nPos, nItems - nNumRows + 1 )
               nAtTop := Min( nPos, nItems - nNumRows + 1 )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ELSE

            nNewPos := nPos + 1

            DO WHILE !Eval( bSelect, alSelect[ nNewPos ] )
               nNewPos++
            ENDDO

            IF INRANGE( nAtTop, nNewPos, nAtTop + nNumRows - 1 )
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               nPos := nNewPos
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
            ELSE
               DispBegin()
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               Scroll( nTop, nLeft, nBottom, nRight, ( nNewPos - ( nAtTop + nNumRows - 1 ) ) )
               nAtTop := nNewPos - nNumRows + 1
               nPos   := Max( nPos, nAtTop )
               DO WHILE nPos < nNewPos
                  DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
                  nPos++
               ENDDO
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
               DispEnd()
            ENDIF

         ENDIF

      CASE nKey == K_CTRL_PGUP .OR. ( nKey == K_HOME .AND. !lUserFunc )

         IF nPos == nFrstItem
            IF nAtTop == Max( 1, nPos - nNumRows + 1 )
               nMode := AC_HITTOP
            ELSE
               nAtTop := Max( 1, nPos - nNumRows + 1 )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ELSE
            nPos   := nFrstItem
            nAtTop := nPos
            DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
         ENDIF

      CASE nKey == K_CTRL_PGDN .OR. ( nKey == K_END .AND. !lUserFunc )

         IF nPos == nLastItem
            IF nAtTop == Min( nLastItem, nItems - nNumRows + 1 )
               nMode := AC_HITBOTTOM
            ELSE
               nAtTop := Min( nLastItem, nItems - nNumRows + 1 )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ELSE
            IF INRANGE( nAtTop, nLastItem, nAtTop + nNumRows - 1 )
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               nPos := nLastItem
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
            ELSE
               nPos   := nLastItem
               nAtTop := Max( 1, nPos - nNumRows + 1 )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ENDIF

      CASE nKey == K_CTRL_HOME

         IF nPos == nFrstItem
            IF nAtTop == Max( 1, nPos - nNumRows + 1 )
               nMode := AC_HITTOP
            ELSE
               nAtTop := Max( 1, nPos - nNumRows + 1 )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ELSE
            nNewPos := nAtTop
            DO WHILE !Eval( bSelect, alSelect[ nNewPos ] )
               nNewPos++
            ENDDO
            IF nNewPos != nPos
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               nPos := nNewPos
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
            ENDIF
         ENDIF

      CASE nKey == K_CTRL_END

         IF nPos == nLastItem
            IF nAtTop == Min( nPos, nItems - nNumRows + 1 )
               nMode := AC_HITBOTTOM
            ELSE
               nAtTop := Min( nPos, nItems - nNumRows + 1 )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ELSE
            nNewPos := Min( nAtTop + nNumRows - 1, nItems )
            DO WHILE !Eval( bSelect, alSelect[ nNewPos ] )
               nNewPos--
            ENDDO
            IF nNewPos != nPos
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               nPos := nNewPos
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
            ENDIF
         ENDIF

      CASE nKey == K_PGUP

         IF nPos == nFrstItem
            nMode := AC_HITTOP
            IF nAtTop > Max( 1, nPos - nNumRows + 1 )
               nAtTop := Max( 1, nPos - nNumRows + 1 )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ELSE
            IF INRANGE( nAtTop, nFrstItem, nAtTop + nNumRows - 1 )
               // On same page as nFrstItem
               nPos   := nFrstItem
               nAtTop := Max( nPos - nNumRows + 1, 1 )
            ELSE
               IF ( nPos - nNumRows + 1 ) < nFrstItem
                  nPos   := nFrstItem
                  nAtTop := nFrstItem
               ELSE
                  nPos   := Max( nFrstItem, nPos - nNumRows + 1 )
                  nAtTop := Max( 1, nAtTop - nNumRows + 1 )
                  DO WHILE nPos > nFrstItem .AND. !Eval( bSelect, alSelect[ nPos ] )
                     nPos--
                     nAtTop--
                  ENDDO
                  nAtTop := Max( 1, nAtTop )
               ENDIF
            ENDIF
            DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
         ENDIF

      CASE nKey == K_PGDN

         IF nPos == nLastItem
            nMode := AC_HITBOTTOM
            IF nAtTop < Min( nPos, nItems - nNumRows + 1 )
               nAtTop := Min( nPos, nItems - nNumRows + 1 )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ELSE
            IF INRANGE( nAtTop, nLastItem, nAtTop + nNumRows - 1 )
               // On the same page as nLastItem
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               nPos := nLastItem
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
            ELSE
               nGap := nPos - nAtTop
               nPos := Min( nLastItem, nPos + nNumRows - 1 )
               IF ( nPos + nNumRows - 1 ) > nLastItem
                  // On the last page
                  nAtTop := nLastItem - nNumRows + 1
                  nPos   := Min( nLastItem, nAtTop + nGap )
               ELSE
                  // Not on the last page
                  nAtTop := nPos - nGap
               ENDIF
               // Make sure that the item is selectable
               DO WHILE nPos < nLastItem .AND. !Eval( bSelect, alSelect[ nPos ] )
                  nPos++
                  nAtTop++
               ENDDO
               // Don't leave blank space on the page
               DO WHILE ( nAtTop + nNumRows - 1 ) > nItems
                  nAtTop--
               ENDDO
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ENDIF

      CASE nKey == K_ENTER .AND. !lUserFunc

         nMode     := AC_SELECT
         lFinished := .T.

      CASE nKey == K_RIGHT .AND. !lUserFunc

         nPos      := 0
         lFinished := .T.

      CASE nKey == K_LEFT .AND. !lUserFunc

         nPos      := 0
         lFinished := .T.

      CASE INRANGE( 32, nKey, 255 ) .AND. ( !lUserFunc .OR. nMode == AC_GOTO )

         cKey := Upper( Chr( nKey ) )

         // Find next selectable item
         FOR nNewPos := nPos + 1 TO nItems
            IF Eval( bSelect, alSelect[ nNewPos ] ) .AND. Upper( Left( acItems[ nNewPos ], 1 ) ) == cKey
               EXIT
            ENDIF
         NEXT
         IF nNewPos == nItems + 1
            FOR nNewPos := 1 TO nPos - 1
               IF Eval( bSelect, alSelect[ nNewPos ] ) .AND. Upper( Left( acItems[ nNewPos ], 1 ) ) == cKey
                  EXIT
               ENDIF
            NEXT
         ENDIF

         IF nNewPos != nPos
            IF INRANGE( nAtTop, nNewPos, nAtTop + nNumRows - 1 )
               // On same page
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .F., nNumCols )
               nPos := nNewPos
               DispLine( acItems[ nPos ], nTop + ( nPos - nAtTop ), nLeft, Eval( bSelect, alSelect[ nPos ] ), .T., nNumCols )
            ELSE
               // On different page
               nPos   := nNewPos
               nAtTop := BETWEEN( 1, nPos - nNumRows + 1, nItems )
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect )
            ENDIF
         ENDIF

         nMode := AC_IDLE

      CASE nMode == AC_GOTO

         // Garbage collect gotos which aren't valid ASCII characters
         nMode := AC_IDLE

      OTHERWISE

         IF nMode != AC_NOITEM
            IF nKey == 0  // No keystroke
               nMode := AC_IDLE
            ELSE
               nMode := AC_EXCEPT
            ENDIF
         ENDIF

      ENDCASE

      IF lUserFunc

         nUserFunc := Do( xUserFunc, nMode, nPos, nPos - nAtTop )

         IF ISNUMBER( nUserFunc )
            
            DO CASE
            CASE nUserFunc == AC_ABORT .OR. nMode == AC_NOITEM
               lFinished := .T.
               nPos      := 0
            CASE nUserFunc == AC_SELECT
               lFinished := .T.
            CASE nUserFunc == AC_CONT .OR. nUserFunc == AC_REDRAW
               // Do nothing
               nMode := AC_CONT
            CASE nUserFunc == AC_GOTO
               // Do nothing. The next keystroke won't be read and
               // this keystroke will be processed as a goto.
               nMode := AC_GOTO
            ENDCASE
            
            IF nPos > 0 .AND. nMode != AC_GOTO
            
               nRowsClr := Min( nNumRows, nItems )
               nMode := Ach_Limits( @nFrstItem, @nLastItem, @nItems, bSelect, alSelect, acItems )
            
               IF nMode == AC_NOITEM
                  nPos := 0
                  nAtTop := Max( 1, nPos - nNumRows + 1 )
               ELSE
                  DO WHILE nPos < nLastItem .AND. !Eval( bSelect, alSelect[ nPos ] )
                     nPos++
                  ENDDO
            
                  IF nPos > nLastItem
                     nPos := BETWEEN( nFrstItem, nPos, nLastItem )
                  ENDIF
            
                  nAtTop := MIN( nAtTop, nPos )
            
                  IF nAtTop + nNumRows - 1 > nItems
                     nAtTop := BETWEEN( 1, nPos - nNumRows + 1, nItems - nNumRows + 1 )
                  ENDIF
            
                  IF nAtTop < 1
                     nAtTop := 1
                  ENDIF
            
               ENDIF
            
               DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nItems, bSelect, nRowsClr )
            ENDIF
         ELSE
            nPos      := 0
            lFinished := .T.
         ENDIF
      ENDIF

   ENDDO

   SetCursor( nSaveCsr )

   RETURN nPos
achoice.prg23
STATIC FUNCTIONHitTest( nTop, nLeft, nBottom, nRight, mRow, mCol )
STATIC FUNCTION HitTest( nTop, nLeft, nBottom, nRight, mRow, mCol )

   IF mCol >= nLeft .AND. ;
      mCol <= nRight .AND. ;
      mRow >= nTop .AND. ;
      mRow <= nBottom
      RETURN mRow - nTop + 1
   ENDIF

   RETURN 0
achoice.prg529
STATIC PROCEDUREDispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nArrLen, bSelect, nRowsClr )
STATIC PROCEDURE DispPage( acItems, alSelect, nTop, nLeft, nRight, nNumRows, nPos, nAtTop, nArrLen, bSelect, nRowsClr )

   LOCAL nCntr
   LOCAL nRow                              // Screen row
   LOCAL nIndex                            // Array index
   LOCAL nSaveRow := Row()                 // Position at start of routine
   LOCAL nSaveCol := Col()                 // Position at start of routine

   DEFAULT nRowsClr TO nNumRows

   DispBegin()

   FOR nCntr := 1 TO Min( nNumRows, nRowsClr )

      nRow   := nTop + nCntr - 1
      nIndex := nCntr + nAtTop - 1

      IF INRANGE( 1, nIndex, nArrLen )
         DispLine( acItems[ nIndex ], nRow, nLeft, Eval( bSelect, alSelect[ nIndex ] ), nIndex == nPos, nRight - nLeft + 1 )
      ELSE
         ColorSelect( CLR_STANDARD )
         DispOutAt( nRow, nLeft, Space( nRight - nLeft + 1 ) )
      ENDIF
   NEXT

   DispEnd()

   SetPos( nSaveRow, nSaveCol )

   RETURN
achoice.prg540
STATIC PROCEDUREDispLine( cLine, nRow, nCol, lSelect, lHiLite, nNumCols )
STATIC PROCEDURE DispLine( cLine, nRow, nCol, lSelect, lHiLite, nNumCols )

   ColorSelect( iif( lSelect .AND. ISCHARACTER( cLine ), ;
                iif( lHiLite, CLR_ENHANCED, CLR_STANDARD ), CLR_UNSELECTED ) )

   DispOutAt( nRow, nCol, iif( ISCHARACTER( cLine ), PadR( cLine, nNumCols ), Space( nNumCols ) ) )

   ColorSelect( CLR_STANDARD )

   RETURN
achoice.prg571
STATIC FUNCTIONAch_Limits( nFrstItem, nLastItem, nItems, bSelect, alSelect, acItems )
STATIC FUNCTION Ach_Limits( nFrstItem, nLastItem, nItems, bSelect, alSelect, acItems )

   LOCAL nMode
   LOCAL nCntr

   nItems := 0

   FOR nCntr := 1 TO LEN( acItems )
      IF ISCHARACTER( acItems[ nCntr ] )
         nItems++
      ELSE
         EXIT
      ENDIF
   NEXT

   nFrstItem := AScan( alSelect, bSelect )  // First valid item

   IF nFrstItem == 0
      nLastItem := 0
   ELSE
      nMode     := AC_IDLE
      nLastItem := nItems               // Last valid item
      DO WHILE nLastItem > 0 .AND. !Eval( bSelect, alSelect[ nLastItem ] )
         nLastItem--
      ENDDO
   ENDIF

   IF nLastItem <= 0
      nMode     := AC_NOITEM
      nLastItem := nItems
   ENDIF

   RETURN nMode
achoice.prg582
adir.prg
TypeFunctionSourceLine
FUNCTIONADir( cFileMask, aName, aSize, aDate, aTime, aAttr )
FUNCTION ADir( cFileMask, aName, aSize, aDate, aTime, aAttr )

   LOCAL aDir
   LOCAL nDirLen
   LOCAL nDirPos

   LOCAL nNameLen, nSizeLen, nDateLen, nTimeLen, nAttrLen

   LOCAL aFileInfo

   LOCAL cDir
   LOCAL cName
   LOCAL cExt

   // ; CA-Cl*pper would fail on this case.

   IF !ISCHARACTER( cFileMask )
      RETURN 0
   ENDIF

   // ; If no drive/dir specified, use the SET DEFAULT setting.

   hb_FNameSplit( cFileMask, @cDir, @cName, @cExt )

   IF Empty( cDir )
      cFileMask := hb_FNameMerge( __DefPath(), cName, cExt )
   ENDIF

   // ;

   IF ISARRAY( aAttr )
      aDir := Directory( cFileMask, "HSD" )
   ELSE
      aDir := Directory( cFileMask )
   ENDIF

   IF ISARRAY( aName )
      nNameLen := Len( aName )
   ENDIF
   IF ISARRAY( aSize )
      nSizeLen := Len( aSize )
   ENDIF
   IF ISARRAY( aDate )
      nDateLen := Len( aDate )
   ENDIF
   IF ISARRAY( aTime )
      nTimeLen := Len( aTime )
   ENDIF
   IF ISARRAY( aAttr )
      nAttrLen := Len( aAttr )
   ENDIF

   // ;

   nDirLen := Len( aDir )

   FOR nDirPos := 1 TO nDirLen

      aFileInfo := aDir[ nDirPos ]

      IF nNameLen != NIL .AND. nNameLen >= nDirPos
         aName[ nDirPos ] := aFileInfo[ F_NAME ]
      ENDIF
      IF nSizeLen != NIL .AND. nSizeLen >= nDirPos
         aSize[ nDirPos ] := aFileInfo[ F_SIZE ]
      ENDIF
      IF nDateLen != NIL .AND. nDateLen >= nDirPos
         aDate[ nDirPos ] := aFileInfo[ F_DATE ]
      ENDIF
      IF nTimeLen != NIL .AND. nTimeLen >= nDirPos
         aTime[ nDirPos ] := aFileInfo[ F_TIME ]
      ENDIF
      IF nAttrLen != NIL .AND. nAttrLen >= nDirPos
         aAttr[ nDirPos ] := aFileInfo[ F_ATTR ]
      ENDIF

   NEXT

   RETURN nDirLen
adir.prg56
alert.prg
TypeFunctionSourceLine
FUNCTIONAlert( xMessage, aOptions, cColorNorm, nDelay )
FUNCTION Alert( xMessage, aOptions, cColorNorm, nDelay )
   LOCAL cMessage
   LOCAL cColorHigh
   LOCAL aOptionsOK
   LOCAL nEval
#ifdef HB_EXTENSION
   LOCAL lFirst
   LOCAL cLine
#endif

#ifdef HB_C52_UNDOC

   DEFAULT s_lNoAlert TO hb_argCheck( "NOALERT" )

   IF s_lNoAlert
      RETURN NIL
   ENDIF

#endif

#ifdef HB_EXTENSION

   IF PCount() == 0
      RETURN NIL
   ENDIF

   cMessage := ""

   IF ISARRAY( xMessage )

      lFirst := .T.
      FOR nEval := 1 TO Len( xMessage )
         IF ISCHARACTER( cLine := xMessage[ nEval ] )
            cMessage += iif( lFirst, "", Chr( 10 ) ) + cLine
            lFirst := .F.
         ENDIF
      NEXT

   ELSE

      DO CASE
      CASE ValType( xMessage ) $ "CM" ; cMessage := StrTran( xMessage, ";", Chr( 10 ) )
      CASE ValType( xMessage ) == "N" ; cMessage := LTrim( Str( xMessage ) )
      CASE ValType( xMessage ) == "D" ; cMessage := DToC( xMessage )
      CASE ValType( xMessage ) == "L" ; cMessage := iif( xMessage, ".T.", ".F." )
      CASE ValType( xMessage ) == "O" ; cMessage := xMessage:className + " Object"
      CASE ValType( xMessage ) == "S" ; cMessage := "@" + xMessage:Name + "()"
      CASE ValType( xMessage ) == "B" ; cMessage := "{||...}"
      OTHERWISE                       ; cMessage := "NIL"
      ENDCASE

   ENDIF

#else

   IF !ISCHARACTER( xMessage )
      RETURN NIL
   ENDIF

   cMessage := StrTran( xMessage, ";", Chr( 10 ) )

#endif

   IF !ISARRAY( aOptions )
      aOptions := {}
   ENDIF

   IF !ISCHARACTER( cColorNorm ) .OR. EMPTY( cColorNorm )
      cColorNorm := "W+/R" // first pair color (Box line and Text)
      cColorHigh := "W+/B" // second pair color (Options buttons)
   ELSE
      cColorHigh := StrTran( StrTran( iif( At( "/", cColorNorm ) == 0, "N", SubStr( cColorNorm, At( "/", cColorNorm ) + 1 ) ) + "/" +;
                                      iif( At( "/", cColorNorm ) == 0, cColorNorm, Left( cColorNorm, At( "/", cColorNorm ) - 1 ) ), "+", "" ), "*", "" )
   ENDIF

   IF nDelay == NIL
      nDelay := 0
   ENDIF

   aOptionsOK := {}
   FOR nEval := 1 TO Len( aOptions )
      IF ISCHARACTER( aOptions[ nEval ] ) .AND. !Empty( aOptions[ nEval ] )
         AAdd( aOptionsOK, aOptions[ nEval ] )
      ENDIF
   NEXT

   IF Len( aOptionsOK ) == 0
      aOptionsOK := { "Ok" }
#ifdef HB_C52_STRICT
   /* NOTE: Clipper allows only four options [vszakats] */
   ELSEIF Len( aOptionsOK ) > 4
      ASize( aOptionsOK, 4 )
#endif
   ENDIF

   RETURN hb_gtAlert( cMessage, aOptionsOK, cColorNorm, cColorHigh, nDelay );
alert.prg48
PROCEDURE__NONOALERT()
PROCEDURE __NONOALERT()

   s_lNoAlert := .F.

   RETURN
alert.prg147
altd.prg
TypeFunctionSourceLine
PROCEDUREAltD( nAction )
PROCEDURE AltD( nAction )

   IF PCOUNT() == 0

      /* do not activate the debugger imediatelly because the module
         where ALTD() was called can have no debugger info - stop
         on first LINE with debugged info 
      */
      __dbgINVOKEDEBUG( SET( _SET_DEBUG ) )

   ELSEIF HB_ISNUMERIC( nAction )

      IF nAction == ALTD_DISABLE
         SET( _SET_DEBUG, .F. )
      ELSEIF nAction == ALTD_ENABLE
         SET( _SET_DEBUG, .T. )
      ENDIF

   ENDIF

RETURN
altd.prg61
browdb.prg
TypeFunctionSourceLine
FUNCTIONTBrowseDB( nTop, nLeft, nBottom, nRight )
FUNCTION TBrowseDB( nTop, nLeft, nBottom, nRight )

   LOCAL oBrowse := TBrowseNew( nTop, nLeft, nBottom, nRight )

#ifdef HB_COMPAT_XPP
   oBrowse:SkipBlock     := { | nRecs | DbSkipper( nRecs ) }
#else
   oBrowse:SkipBlock     := { | nRecs | Skipped( nRecs ) }
#endif
   oBrowse:GoTopBlock    := { || dbGoTop() }
   oBrowse:GoBottomBlock := { || dbGoBottom() }

   RETURN oBrowse
browdb.prg53
STATIC FUNCTIONSkipped( nRecs )
STATIC FUNCTION Skipped( nRecs )

   LOCAL nSkipped := 0

   IF LastRec() != 0
      IF nRecs == 0
         dbSkip( 0 )
      ELSEIF nRecs > 0 .AND. RecNo() != LastRec() + 1
         DO WHILE nSkipped < nRecs
            dbSkip( 1 )
            IF Eof()
               dbSkip( -1 )
               EXIT
            ENDIF
            nSkipped++
         ENDDO
      ELSEIF nRecs < 0
         DO WHILE nSkipped > nRecs
            dbSkip( -1 )
            IF Bof()
               EXIT
            ENDIF
            nSkipped--
         ENDDO
      ENDIF
   ENDIF

   RETURN nSkipped
browdb.prg68
browdbx.prg
TypeFunctionSourceLine
FUNCTIONdbSkipper( nRecs )
FUNCTION dbSkipper( nRecs )

   LOCAL nSkipped := 0

   IF LastRec() != 0
      IF nRecs == 0
         dbSkip( 0 )
      ELSEIF nRecs > 0 .AND. RecNo() != LastRec() + 1
         DO WHILE nSkipped < nRecs
            dbSkip( 1 )
            IF Eof()
               dbSkip( -1 )
               EXIT
            ENDIF
            nSkipped++
         ENDDO
      ELSEIF nRecs < 0
         DO WHILE nSkipped > nRecs
            dbSkip( -1 )
            IF Bof()
               EXIT
            ENDIF
            nSkipped--
         ENDDO
      ENDIF
   ENDIF

   RETURN nSkipped
browdbx.prg63
browse.prg
TypeFunctionSourceLine
FUNCTIONBrowse( nTop, nLeft, nBottom, nRight )
FUNCTION Browse( nTop, nLeft, nBottom, nRight )

   LOCAL oBrw
   LOCAL lExit, lGotKey, lAppend, lKeyPressed, lRefresh
   LOCAL n, nOldCursor, nKey
   LOCAL cOldScreen
   LOCAL bAction

   IF ! Used()
      RETURN .F.
   ENDIF

   lExit := lGotKey := lAppend := lKeyPressed := lRefresh := .F.

   IF PCount() < 4
      nTop    := 1
      nLeft   := 0
      nBottom := MaxRow()
      nRight  := MaxCol()
   ENDIF

   DispBegin()

   nOldCursor := SetCursor( SC_NONE )
   cOldScreen := SaveScreen( nTop, nLeft, nBottom, nRight )

   DispBox( nTop, nLeft, nBottom, nRight, B_DOUBLE_SINGLE )
   DispBox( nTop + 3, nLeft, nTop + 3, nLeft, chr( 198 ) )
   DispBox( nTop + 3, nRight, nTop + 3, nRight, chr( 181 ) )
   DispOutAt( nTop + 1, nLeft + 1, Space( nRight - nLeft - 1 ) )

   oBrw := TBrowseDB( nTop + 2, nLeft + 1, nBottom - 1, nRight - 1 )
   oBrw:HeadSep   := " " + Chr( 205 )
   oBrw:SkipBlock := { | nRecs | Skipped( nRecs, lAppend ) }

   FOR n := 1 to FCount()
      oBrw:AddColumn( TBColumnNew( FieldName( n ), FieldBlock( FieldName( n ) ) ) )
   NEXT

   IF Eof()
      DbGoTop()
   ENDIF

   oBrw:ForceStable()

   DispEnd()

   IF LastRec() == 0
      nKey := K_DOWN
      lKeyPressed := .T.
   ENDIF

   DO WHILE ! lExit

      DO WHILE ! lKeyPressed .AND. ! oBrw:Stabilize()
         lKeyPressed := ( nKey := Inkey() ) != 0
      ENDDO

      IF ! lKeyPressed

         IF oBrw:HitBottom() .AND. ( ! lAppend .OR. RecNo() != LastRec() + 1 )
            IF lAppend
               oBrw:RefreshCurrent()
               oBrw:ForceStable()
               dbGoBottom()
            ELSE
               lAppend := .T.
               SetCursor( IIF( ReadInsert(), SC_INSERT, SC_NORMAL ) )
            ENDIF
            oBrw:Down()
            oBrw:ForceStable()
            oBrw:ColorRect( { oBrw:RowPos, 1, oBrw:RowPos, oBrw:ColCount() }, ;
                            { 2, 2 } )
         ENDIF

         StatLine( oBrw, lAppend )

         oBrw:ForceStable()

         nKey := InKey( 0 )
         IF ( bAction := SetKey( nKey ) ) != NIL
            Eval( bAction, ProcName( 1 ), ProcLine( 1 ), "")
            LOOP
         ENDIF
      ELSE
         lKeyPressed := .F.
      ENDIF

      SWITCH nKey

#ifdef HB_COMPAT_C53
         CASE K_LBUTTONDOWN
         CASE K_LDBLCLK
            TBMOUSE( oBrw, MRow(), MCol() )
            EXIT
#endif
#ifndef HB_C52_STRICT
         CASE K_MWFORWARD
#endif
         CASE K_UP
            IF lAppend
               lRefresh := .T.
            ELSE
               oBrw:Up()
            ENDIF
            EXIT

#ifndef HB_C52_STRICT
         CASE K_MWBACKWARD
#endif
         CASE K_DOWN
            IF lAppend
               oBrw:HitBottom( .T. )
            ELSE
               oBrw:Down()
            ENDIF
            EXIT

         CASE K_PGUP
            IF lAppend
               lRefresh := .T.
            ELSE
               oBrw:PageUp()
            ENDIF
            EXIT

         CASE K_PGDN
            IF lAppend
               oBrw:HitBottom( .T. )
            ELSE
               oBrw:PageDown()
            ENDIF
            EXIT

         CASE K_CTRL_PGUP
            IF lAppend
               lRefresh := .T.
            ELSE
               oBrw:GoTop()
            ENDIF
            EXIT

         CASE K_CTRL_PGDN
            IF lAppend
               lRefresh := .T.
            ELSE
               oBrw:GoBottom()
            ENDIF
            EXIT

         CASE K_LEFT
            oBrw:Left()
            EXIT

         CASE K_RIGHT
            oBrw:Right()
            EXIT

         CASE K_HOME
            oBrw:Home()
            EXIT

         CASE K_END
            oBrw:End()
            EXIT

         CASE K_CTRL_LEFT
            oBrw:panLeft()
            EXIT

         CASE K_CTRL_RIGHT
            oBrw:panRight()
            EXIT

         CASE K_CTRL_HOME
            oBrw:panHome()
            EXIT

         CASE K_CTRL_END
            oBrw:panEnd()
            EXIT

         CASE K_INS
            IF lAppend
               SetCursor( IIF( ReadInsert( ! ReadInsert() ), ;
                               SC_NORMAL, SC_INSERT ) )
            ENDIF
            EXIT

         CASE K_DEL
            IF RecNo() != LastRec() + 1
               IF Deleted()
                  DbRecall()
               ELSE
                  DbDelete()
               ENDIF
            ENDIF
            EXIT

         CASE K_ENTER
            IF lAppend .OR. RecNo() != LastRec() + 1
               lKeyPressed := ( nKey := DoGet( oBrw, lAppend ) ) != 0
            ELSE
               nKey := K_DOWN
               lKeyPressed := .T.
            ENDIF
            EXIT

         CASE K_ESC
            lExit := .t.
            EXIT

         OTHERWISE
            IF nKey >= 32 .AND. nKey <= 255
               KEYBOARD Chr( nKey )
               nKey := K_ENTER
               lKeyPressed := .T.
            ENDIF
            EXIT
      ENDSWITCH

      IF lRefresh
         lRefresh := lAppend := .F.
         FreshOrder( oBrw )
         SetCursor( SC_NONE )
      ENDIF

   ENDDO

   RestScreen( nTop, nLeft, nBottom, nRight, cOldScreen )
   SetCursor( nOldCursor )

   RETURN .T.
browse.prg57
STATIC PROCEDUREStatLine( oBrw, lAppend )
STATIC PROCEDURE StatLine( oBrw, lAppend )

   LOCAL nTop   := oBrw:nTop - 1
   LOCAL nRight := oBrw:nRight

   DispOutAt( nTop, nRight - 27, "Record " )

   IF LastRec() == 0 .AND. ! lAppend
      DispOutAt( nTop, nRight - 20, "               " )
   ELSEIF RecNo() == LastRec() + 1
      DispOutAt( nTop, nRight - 40, "         " )
      DispOutAt( nTop, nRight - 20, "                " )
   ELSE
      DispOutAt( nTop, nRight - 40, IIF( Deleted(), "", "         " ) )
      DispOutAt( nTop, nRight - 20, PadR( LTrim( Str( RecNo() ) ) + "/" + ;
                                          LTrim( Str( LastRec() ) ), 16 ) + ;
                                    IIF( oBrw:HitTop(), "", "     " ) )
   ENDIF

   RETURN
browse.prg291
STATIC FUNCTIONDoGet( oBrw, lAppend )
STATIC FUNCTION DoGet( oBrw, lAppend )

   LOCAL lScore, lExit, bIns, nCursor
   LOCAL oCol, oGet
   LOCAL cIndexKey, cForExp, xKeyValue
   LOCAL lSuccess, nKey, xValue

   oBrw:HitTop( .F. )
   StatLine( oBrw, lAppend )
   oBrw:ForceStable()

   lScore := Set( _SET_SCOREBOARD, .F. )
   lExit := Set( _SET_EXIT, .T. )
   bIns := SetKey( K_INS, {|| SetCursor( IIF( ReadInsert( ! ReadInsert() ), ;
                                              SC_NORMAL, SC_INSERT ) ) } )
   nCursor := SetCursor( IIF( ReadInsert(), SC_INSERT, SC_NORMAL ) )
   IF !Empty( cIndexKey := IndexKey( 0 ) )
      xKeyValue := &cIndexKey
   ENDIF

   oCol := oBrw:GetColumn( oBrw:ColPos )
   xValue := Eval( oCol:Block )
   oGet := GetNew( Row(), Col(), ;
               { |xNewVal| IIF( PCount() == 0, xValue, xValue := xNewVal ) }, ;
               "mGetVar", NIL, oBrw:ColorSpec )
   lSuccess := .F.
   IF ReadModal( { oGet } )
      IF lAppend .AND. RecNo() == LastRec() + 1
         dbAppend()
      ENDIF
      Eval( oCol:Block, xValue )

      IF !lAppend .AND. !Empty( cForExp := OrdFor( IndexOrd() ) ) .AND. ;
         ! &cForExp
         dbGoTop()
      ENDIF
      IF !lAppend .AND. !Empty( cIndexKey ) .AND. ! xKeyValue == &cIndexKey
         lSuccess := .T.
      ENDIF
   ENDIF

   IF lSuccess
      FreshOrder( oBrw )
      nKey := 0
   ELSE
      oBrw:RefreshCurrent()
      nKey := ExitKey( lAppend )
   ENDIF

   IF lAppend
      oBrw:ColorRect( { oBrw:rowpos, 1, oBrw:rowpos, oBrw:colcount }, ;
                      { 2, 2 } )
   ENDIF

   SetCursor( nCursor )
   SetKey( K_INS, bIns )
   Set( _SET_EXIT, lExit )
   Set( _SET_SCOREBOARD, lScore )

   RETURN nKey
browse.prg312
STATIC FUNCTIONExitKey( lAppend )
STATIC FUNCTION ExitKey( lAppend )

   LOCAL nKey := LastKey()

   SWITCH nKey
      CASE K_PGDN
         nKey := IIF( lAppend, 0, K_DOWN )
         EXIT

      CASE K_PGUP
         nKey := IIF( lAppend, 0, K_UP )

      CASE K_DOWN
      CASE K_UP
         EXIT

      OTHERWISE
         nKey := IIF( nKey == 13 .OR. ;
                      ( nKey >= 32 .AND. nKey <= 255 ), K_RIGHT, 0 )
         EXIT
   ENDSWITCH

   RETURN nKey
browse.prg373
STATIC PROCEDUREFreshOrder( oBrw )
STATIC PROCEDURE FreshOrder( oBrw )

   LOCAL nRec := RecNo()

   oBrw:RefreshAll()
   oBrw:ForceStable()

   IF nRec != LastRec() + 1
      DO WHILE RecNo() != nRec .AND. !BOF()
         oBrw:Up()
         oBrw:ForceStable()
      ENDDO
   ENDIF

   RETURN
browse.prg397
STATIC FUNCTIONSkipped( nRecs, lAppend )
STATIC FUNCTION Skipped( nRecs, lAppend )

   LOCAL nSkipped := 0

   IF LastRec() != 0
      IF nRecs == 0
         dbSkip( 0 )
      ELSEIF nRecs > 0 .AND. RecNo() != LastRec() + 1
         DO WHILE nSkipped < nRecs
            dbSkip()
            IF Eof()
               IF lAppend
                  nSkipped++
               ELSE
                  dbSkip( -1 )
               ENDIF
               EXIT
            ENDIF
            nSkipped++
         ENDDO
      ELSEIF nRecs < 0
         DO WHILE nSkipped > nRecs
            dbSkip( -1 )
            IF Bof()
               EXIT
            ENDIF
            nSkipped--
         ENDDO
      ENDIF
   ENDIF

   RETURN nSkipped
browse.prg413
checkbox.prg
TypeFunctionSourceLine
METHODdisplay()
   METHOD display()
checkbox.prg75
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )
checkbox.prg76
METHODkillFocus()
   METHOD killFocus()
checkbox.prg77
METHODselect()
   METHOD select()
checkbox.prg78
METHODsetFocus()
   METHOD setFocus()
checkbox.prg79
METHODbitmaps( aBitmaps ) SETGET
   METHOD bitmaps( aBitmaps ) SETGET
checkbox.prg81
METHODbuffer() SETGET
   METHOD buffer() SETGET
checkbox.prg82
METHODcapCol( nCapCol ) SETGET
   METHOD capCol( nCapCol ) SETGET
checkbox.prg83
METHODcapRow( nCapRow ) SETGET
   METHOD capRow( nCapRow ) SETGET
checkbox.prg84
METHODcaption( cCaption ) SETGET
   METHOD caption( cCaption ) SETGET
checkbox.prg85
METHODcol( nCol ) SETGET
   METHOD col( nCol ) SETGET
checkbox.prg86
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
checkbox.prg87
METHODfBlock( bFBlock ) SETGET
   METHOD fBlock( bFBlock ) SETGET
checkbox.prg88
METHODhasFocus() SETGET
   METHOD hasFocus() SETGET
checkbox.prg89
METHODmessage( cMessage ) SETGET
   METHOD message( cMessage ) SETGET
checkbox.prg90
METHODrow( nRow ) SETGET
   METHOD row( nRow ) SETGET
checkbox.prg91
METHODsBlock( bSBlock ) SETGET
   METHOD sBlock( bSBlock ) SETGET
checkbox.prg92
METHODstyle( cStyle ) SETGET
   METHOD style( cStyle ) SETGET
checkbox.prg93
METHODtypeOut() SETGET
   METHOD typeOut() SETGET
checkbox.prg94
METHODNew( nRow, nCol, cCaption )
   METHOD New( nRow, nCol, cCaption ) /* NOTE: This method is a Harbour extension [vszakats] */

   PROTECTED:

   VAR aBitmaps   INIT { "check_f.bmu", "check_e.bmu" }
   VAR lBuffer    INIT .F.
   VAR nCapCol
   VAR nCapRow
   VAR cCaption
   VAR nCol
   VAR cColorSpec
   VAR bFBlock
   VAR lHasFocus  INIT .F.
   VAR cMessage   INIT ""
   VAR nRow
   VAR bSBlock
   VAR cStyle     INIT "[" + Chr( 251 ) + " ]"

   VAR nCursor

ENDCLASS
checkbox.prg96
CHECKBOX:METHODsetFocus() CLASS CHECKBOX
METHOD setFocus() CLASS CHECKBOX

   IF !::lHasFocus
      ::nCursor := SetCursor( SC_NONE )
      ::lHasFocus := .T.
      ::display()

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF
   ENDIF

   RETURN Self
checkbox.prg118
CHECKBOX:METHODselect( lState ) CLASS CHECKBOX
METHOD select( lState ) CLASS CHECKBOX

   LOCAL lOldState := ::lBuffer

   ::lBuffer := iif( ISLOGICAL( lState ), lState, !::lBuffer )

   IF lOldState != ::lBuffer
      ::display()

      IF ISBLOCK( ::bSBlock )
         Eval( ::bSBlock )
      ENDIF
   ENDIF

   RETURN Self
checkbox.prg132
CHECKBOX:METHODkillFocus() CLASS CHECKBOX
METHOD killFocus() CLASS CHECKBOX

   IF ::lHasFocus
      ::lHasFocus := .F.

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF

      ::display()
      SetCursor( ::nCursor )

   ENDIF

   RETURN Self
checkbox.prg148
CHECKBOX:METHODhitTest( nMRow, nMCol ) CLASS CHECKBOX
METHOD hitTest( nMRow, nMCol ) CLASS CHECKBOX

   LOCAL nPosAccel
   LOCAL nLenCaption

   IF nMRow == ::nRow .AND. ;
      nMCol >= ::nCol .AND. ;
      nMCol < ::nCol + 3
      RETURN HTCLIENT
   ENDIF
   
   nLenCaption := Len( ::cCaption )
   
   IF ( nPosAccel := At( "&", ::cCaption ) ) > 0 .AND. ;
      nPosAccel < nLenCaption
      nLenCaption--
   ENDIF

   IF nMRow == ::nCapRow .AND. ;
      nMCol >= ::nCapCol .AND. ;
      nMCol < ::nCapCol + nLenCaption
      RETURN HTCAPTION
   ENDIF

   RETURN HTNOWHERE
checkbox.prg164
CHECKBOX:METHODdisplay() CLASS CHECKBOX
METHOD display() CLASS CHECKBOX

   LOCAL cOldColor := SetColor()      
   LOCAL nOldRow := Row()             
   LOCAL nOldCol := Col()             
   LOCAL lOldMCur := MSetCursor( .F. )

   LOCAL cStyle := ::cStyle
   LOCAL cCaption
   LOCAL nPos

   DispBegin()

   DispOutAt( ::nRow, ::nCol + 1, iif( ::lBuffer, SubStr( cStyle, 2, 1 ), SubStr( cStyle, 3, 1 ) ),;
      hb_ColorIndex( ::cColorSpec, iif( ::lHasFocus, 1, 0 ) ) )

   SetColor( hb_ColorIndex( ::cColorSpec, 2 ) )
   DispOutAt( ::nRow, ::nCol, Left( cStyle, 1 ) )
   DispOutAt( ::nRow, ::nCol + 2, Right( cStyle, 1 ) )

   IF !Empty( cCaption := ::cCaption )

      IF ( nPos := At( "&", cCaption ) ) == 0
      ELSEIF nPos == Len( cCaption )
         nPos := 0
      ELSE
         cCaption := Stuff( cCaption, nPos, 1, "" )
      ENDIF

      IF ::lHasFocus
         SetColor( hb_ColorIndex( ::cColorSpec, 3 ) )
      ENDIF

      DispOutAt( ::nCapRow, ::nCapCol, cCaption )

      IF !::lHasFocus .AND. nPos != 0
         DispOutAt( ::nCapRow, ::nCapCol + nPos - 1, SubStr( cCaption, nPos, 1 ), hb_ColorIndex( ::cColorSpec, 3 ) )
      ENDIF

   ENDIF

   DispEnd()

   MSetCursor( lOldMCur )
   SetColor( cOldColor )
   SetPos( nOldRow, nOldCol )

   RETURN Self
checkbox.prg190
CHECKBOX:METHODbitmaps( aBitmaps ) CLASS CHECKBOX
METHOD bitmaps( aBitmaps ) CLASS CHECKBOX

   IF aBitmaps != NIL
      ::aBitmaps := __eInstVar53( Self, "BITMAPS", aBitmaps, "A", 1001 )
   ENDIF

   RETURN ::aBitmaps
checkbox.prg239
CHECKBOX:METHODbuffer() CLASS CHECKBOX
METHOD buffer() CLASS CHECKBOX
   RETURN ::lBuffer
checkbox.prg247
CHECKBOX:METHODcapCol( nCapCol ) CLASS CHECKBOX
METHOD capCol( nCapCol ) CLASS CHECKBOX

   IF nCapCol != NIL
      ::nCapCol := __eInstVar53( Self, "CAPCOL", nCapCol, "N", 1001 )
   ENDIF

   RETURN ::nCapCol
checkbox.prg250
CHECKBOX:METHODcapRow( nCapRow ) CLASS CHECKBOX
METHOD capRow( nCapRow ) CLASS CHECKBOX

   IF nCapRow != NIL
      ::nCapRow := __eInstVar53( Self, "CAPROW", nCapRow, "N", 1001 )
   ENDIF

   RETURN ::nCapRow
checkbox.prg258
CHECKBOX:METHODcaption( cCaption ) CLASS CHECKBOX
METHOD caption( cCaption ) CLASS CHECKBOX

   IF cCaption != NIL
      ::cCaption := __eInstVar53( Self, "CAPTION", cCaption, "C", 1001 )
   ENDIF

   RETURN ::cCaption
checkbox.prg266
CHECKBOX:METHODcol( nCol ) CLASS CHECKBOX
METHOD col( nCol ) CLASS CHECKBOX

   IF nCol != NIL
      ::nCol := __eInstVar53( Self, "COL", nCol, "N", 1001 )
   ENDIF

   RETURN ::nCol
checkbox.prg274
CHECKBOX:METHODcolorSpec( cColorSpec ) CLASS CHECKBOX
METHOD colorSpec( cColorSpec ) CLASS CHECKBOX

   IF cColorSpec != NIL
      ::cColorSpec := __eInstVar53( Self, "COLORSPEC", cColorSpec, "C", 1001,;
         {|| !Empty( hb_ColorIndex( cColorSpec, 3 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 4 ) ) } )
   ENDIF

   RETURN ::cColorSpec
checkbox.prg282
CHECKBOX:METHODfBlock( bFBlock ) CLASS CHECKBOX
METHOD fBlock( bFBlock ) CLASS CHECKBOX
   
   IF PCount() > 0
      ::bFBlock := iif( bFBlock == NIL, NIL, __eInstVar53( Self, "FBLOCK", bFBlock, "B", 1001 ) )
   ENDIF

   RETURN ::bFBlock
checkbox.prg291
CHECKBOX:METHODhasFocus() CLASS CHECKBOX
METHOD hasFocus() CLASS CHECKBOX
   RETURN ::lHasFocus
checkbox.prg299
CHECKBOX:METHODmessage( cMessage ) CLASS CHECKBOX
METHOD message( cMessage ) CLASS CHECKBOX

   IF cMessage != NIL
      ::cMessage := __eInstVar53( Self, "MESSAGE", cMessage, "C", 1001 )
   ENDIF

   RETURN ::cMessage
checkbox.prg302
CHECKBOX:METHODrow( nRow ) CLASS CHECKBOX
METHOD row( nRow ) CLASS CHECKBOX

   IF nRow != NIL
      ::nRow := __eInstVar53( Self, "ROW", nRow, "N", 1001 )
   ENDIF

   RETURN ::nRow
checkbox.prg310
CHECKBOX:METHODsBlock( bSBlock ) CLASS CHECKBOX
METHOD sBlock( bSBlock ) CLASS CHECKBOX
   
   IF PCount() > 0
      ::bSBlock := iif( bSBlock == NIL, NIL, __eInstVar53( Self, "SBLOCK", bSBlock, "B", 1001 ) )
   ENDIF

   RETURN ::bSBlock
checkbox.prg318
CHECKBOX:METHODstyle( cStyle ) CLASS CHECKBOX
METHOD style( cStyle ) CLASS CHECKBOX

   IF cStyle != NIL
      ::cStyle := __eInstVar53( Self, "STYLE", cStyle, "C", 1001, {|| Len( cStyle ) == 0 .OR. Len( cStyle ) == 4 } )
   ENDIF

   RETURN ::cStyle
checkbox.prg326
CHECKBOX:METHODtypeOut() CLASS CHECKBOX
METHOD typeOut() CLASS CHECKBOX
   RETURN .F.
checkbox.prg334
CHECKBOX:METHODNew( nRow, nCol, cCaption ) CLASS CHECKBOX
METHOD New( nRow, nCol, cCaption ) CLASS CHECKBOX

   LOCAL cColor

   DEFAULT cCaption TO ""

   ::caption  := cCaption
   ::capRow   := nRow
   ::capCol   := nCol + 3 + 1
   ::row      := nRow
   ::col      := nCol

   IF IsDefColor()
      ::cColorSpec := "W/N,W+/N,W/N,W+/N"
   ELSE
      cColor := SetColor()
      ::cColorSpec := hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," +;
                      hb_ColorIndex( cColor, CLR_ENHANCED   ) + "," +;
                      hb_ColorIndex( cColor, CLR_STANDARD   ) + "," +;
                      hb_ColorIndex( cColor, CLR_BACKGROUND )
   ENDIF

   RETURN Self
checkbox.prg337
FUNCTION_CHECKBOX_( lState, cCaption, cMessage, cColorSpec, bFBlock, bSBlock, cStyle, aBitmaps )
FUNCTION _CHECKBOX_( lState, cCaption, cMessage, cColorSpec, bFBlock, bSBlock, cStyle, aBitmaps )
   LOCAL o := HBCheckBox():New( Row(), Col(), cCaption )
   
   o:select( lState )
   o:caption   := cCaption
   o:message   := cMessage
   o:colorSpec := cColorSpec
   o:fBlock    := bFBlock
   o:sBlock    := bSBlock
   o:style     := cStyle
   o:bitmaps   := aBitmaps

   RETURN o
checkbox.prg361
FUNCTIONCheckBox( nRow, nCol, cCaption )
FUNCTION CheckBox( nRow, nCol, cCaption )
   RETURN HBCheckBox():New( nRow, nCol, cCaption )
checkbox.prg375
color53.prg
TypeFunctionSourceLine
FUNCTIONGetClrPair( cColor, nColor )
FUNCTION GetClrPair( cColor, nColor )
   LOCAL nPos

   IF ( nPos := GetPairPos( cColor, nColor ) ) == 0
      RETURN ""
   ENDIF

   RETURN SubStr( cColor, nPos, GetPairLen( cColor, nColor ) )
color53.prg57
FUNCTIONSetClrPair( cColor, nColor, cNewColor )
FUNCTION SetClrPair( cColor, nColor, cNewColor )
   LOCAL nPos

   IF ( nPos := GetPairPos( cColor, nColor ) ) == 0
      RETURN ""
   ENDIF

   RETURN Stuff( cColor, nPos, GetPairLen( cColor, nColor ), cNewColor )
color53.prg66
FUNCTIONGetPairPos( cColor, nColor )
FUNCTION GetPairPos( cColor, nColor )
   LOCAL nPos := 1
   LOCAL nSep
   LOCAL n

   FOR n := 2 TO nColor
      IF ( nSep := At( ",", SubStr( cColor, nPos ) ) ) == 0
         RETURN 0
      ENDIF
      nPos += nSep
   NEXT

   RETURN nPos
color53.prg75
FUNCTIONGetPairLen( cColor, nColor )
FUNCTION GetPairLen( cColor, nColor )
   LOCAL nPos := GetPairPos( cColor, nColor )
   LOCAL nLen

   IF nPos == 0
      RETURN 0
   ENDIF

   nLen := At( ",", SubStr( cColor, nPos ) )
   
   RETURN iif( nLen == 0, Len( cColor ) - nPos + 1, nLen - 1 )
color53.prg89
FUNCTIONGetClrFore( cColor )
FUNCTION GetClrFore( cColor )
   LOCAL nPos

   IF ( nPos := At( "/", cColor ) ) == 0
      RETURN ""
   ENDIF

   RETURN SubStr( cColor, 1, nPos - 1 )
color53.prg101
FUNCTIONGetClrBack( cColor )
FUNCTION GetClrBack( cColor )
   LOCAL nPos

   IF ( nPos := At( "/", cColor ) ) == 0
      RETURN ""
   ENDIF

   RETURN SubStr( cColor, nPos + 1 )
color53.prg110
FUNCTIONRADGRDefCo( cColor )
FUNCTION RADGRDefCo( cColor )
   RETURN iif( IsDefColor(),;
      ApplyDefau( cColor, "W/N", "W/N", "W+/N" ),;
      ApplyDefau( cColor, 3, 1, 4 ) )
color53.prg119
FUNCTIONRADITDefCo( cColor )
FUNCTION RADITDefCo( cColor )
   RETURN iif( IsDefColor(),;
      ApplyDefau( cColor, "W/N", "W+/N", "W+/N", "N/W", "W/N", "W/N", "W+/N" ),;
      ApplyDefau( cColor, 5, 5, 2, 2, 1, 1, 4 ) )
color53.prg124
FUNCTIONLISTBDefCo( cColor )
FUNCTION LISTBDefCo( cColor )
   RETURN iif( IsDefColor(),;
      ApplyDefau( cColor, "W/N", "W+/N", "W+/N", "N/W", "W/N", "W/N", "W+/N" ),;
      ApplyDefau( cColor, 5, 5, 5, 2, 3, 1, 4 ) )
color53.prg129
FUNCTIONCOMBODefCo( cColor )
FUNCTION COMBODefCo( cColor )
   RETURN iif( IsDefColor(),;
      ApplyDefau( cColor, "W/N", "W+/N", "W+/N", "N/W", "W/N", "W/N", "W+/N", "W/N" ),;
      ApplyDefau( cColor, 5, 5, 5, 2, 3, 1, 4, 1 ) )
color53.prg134
FUNCTIONCHECKDefCo( cColor )
FUNCTION CHECKDefCo( cColor )
   RETURN iif( IsDefColor(),;
      ApplyDefau( cColor, "W/N", "W+/N", "W/N", "W+/N" ),;
      ApplyDefau( cColor, 5, 2, 1, 4 ) )
color53.prg139
FUNCTIONBUTTNDefCo( cColor )
FUNCTION BUTTNDefCo( cColor )
   RETURN iif( IsDefColor(),;
      ApplyDefau( cColor, "W/N", "N/W", "W+/N", "W+/N" ),;
      ApplyDefau( cColor, 5, 2, 1, 4 ) )
color53.prg144
FUNCTIONMENUDefCol( cColor )
FUNCTION MENUDefCol( cColor )
   RETURN iif( IsDefColor(),;
      ApplyDefau( cColor, "N/W", "W/N", "W+/W", "W+/N", "N+/W", "W/N" ),;
      ApplyDefau( cColor, 5, 2, 4, 2, 1, 3 ) )
color53.prg149
FUNCTIONApplyDefau( cColor, xClr1, xClr2, xClr3, xClr4, xClr5, xClr6, xClr7, xClr8 )
FUNCTION ApplyDefau( cColor, xClr1, xClr2, xClr3, xClr4, xClr5, xClr6, xClr7, xClr8 )

   LOCAL cSetColor
   LOCAL aSetColor
   LOCAL aNewcolor
   LOCAL nColors
   LOCAL cClrDefa
   LOCAL cClrToSet
   LOCAL cClrFore
   LOCAL cClrBack
   LOCAL xNewColor
   LOCAL n

   IF PCount() == 0
      RETURN ""
   ELSEIF PCount() == 1
      RETURN cColor
   ENDIF

   cSetColor := SetColor()

   aSetColor := {;
      GetClrPair( cSetColor, 1 ) ,;
      GetClrPair( cSetColor, 2 ) ,;
      GetClrPair( cSetColor, 3 ) ,;
      GetClrPair( cSetColor, 4 ) ,;
      GetClrPair( cSetColor, 5 ) }

   aNewColor := {;
      xClr1 ,;
      xClr2 ,;
      xClr3 ,;
      xClr4 ,;
      xClr5 ,;
      xClr6 ,;
      xClr7 ,;
      xClr8 }

   nColors  := PCount() - 1
   cClrDefa := cColor

   FOR n := 1 TO nColors

      xNewColor := aNewColor[ n ]
      cClrToSet := GetClrPair( cClrDefa, n )

      IF "/" $ cClrToSet

         IF ( cClrFore := GetClrFore( cClrToSet ) ) == ""
            cClrFore := GetClrFore( iif( ISNUMBER( xNewColor ), aSetColor[ xNewColor ], xNewColor ) )
         ENDIF
         IF ( cClrBack := GetClrBack( cClrToSet ) ) == ""
            cClrBack := GetClrBack( iif( ISNUMBER( xNewColor ), aSetColor[ xNewColor ], xNewColor ) )
         ENDIF

         cClrDefa := SetClrPair( cClrDefa, n, cClrFore + "/" + cClrBack )
      ELSE
         cClrDefa := SetClrPair( cClrDefa, n, iif( ISNUMBER( xNewColor ), aSetColor[ xNewColor ], xNewColor ) )
      ENDIF
   NEXT

   RETURN cClrDefa
color53.prg154
dbedit.prg
TypeFunctionSourceLine
FUNCTIONDBEDIT( nTop, nLeft, nBottom, nRight, acColumns, xUserFunc, xColumnSayPictures, xColumnHeaders, xHeadingSeparators, xColumnSeparators, xFootingSeparators, xColumnFootings )
FUNCTION DBEDIT( nTop, nLeft, nBottom, nRight, ;
                 acColumns, xUserFunc, ;
                 xColumnSayPictures, xColumnHeaders, ;
                 xHeadingSeparators, xColumnSeparators, ;
                 xFootingSeparators, xColumnFootings )

   LOCAL nOldCUrsor, nKey, lContinue, nPos, nAliasPos, nColCount
   LOCAL lDoIdleCall, lAppend, lFlag
   LOCAL cHeading, cBlock
   LOCAL bBlock
   LOCAL oBrowse
   LOCAL oColumn
   LOCAL aCol

   IF !Used()
      RETURN .F.
   ELSEIF EOF()
      dbGoBottom()
   ENDIF

   IF !ISNUMBER( nTop ) .OR. nTop < 0
      nTop := 0
   ENDIF
   IF !ISNUMBER( nLeft ) .OR. nLeft < 0
      nLeft := 0
   ENDIF
   IF !ISNUMBER( nBottom ) .OR. nBottom > MaxRow() .OR. nBottom < nTop
      nBottom := MaxRow()
   ENDIF
   IF !ISNUMBER( nRight ) .OR. nRight > MaxCol() .OR. nRight < nLeft
      nRight := MaxCol()
   ENDIF

   oBrowse := TBrowseDb( nTop, nLeft, nBottom, nRight )
   oBrowse:headSep   := iif( ISCHARACTER( xHeadingSeparators ), xHeadingSeparators, Chr( 205 ) + Chr( 209 ) + Chr( 205 ) )
   oBrowse:colSep    := iif( ISCHARACTER( xColumnSeparators ), xColumnSeparators, " " + Chr( 179 ) + " " )
   oBrowse:footSep   := iif( ISCHARACTER( xFootingSeparators ), xFootingSeparators, "" )
   oBrowse:skipBlock := {| nRecs | Skipped( nRecs, lAppend ) }
   oBrowse:autoLite  := .F. /* Set to .F. just like in CA-Cl*pper. [vszakats] */

   IF ISARRAY( acColumns )
      nColCount := 0
      FOR EACH aCol IN acColumns
         IF ISCHARACTER( aCol ) .AND. !Empty( aCol )
            nColCount++
         ELSE
            EXIT
         ENDIF
      NEXT
   ELSE
      nColCount := FCount()
   ENDIF

   IF nColCount == 0
      RETURN .F.
   ENDIF

   /* Generate the TBrowse columns */

   FOR nPos := 1 TO nColCount

      IF ISARRAY( acColumns )
         cBlock := acColumns[ nPos ]
         IF ( nAliasPos := At( "->", cBlock ) ) > 0
            cHeading := SubStr( cBlock, 1, nAliasPos - 1 ) + "->;" + ;
                        SubStr( cBlock, nAliasPos + 2 )
         ELSE
            cHeading := cBlock
         ENDIF
      ELSE
         cBlock := FieldName( nPos )
         cHeading := cBlock
      ENDIF
      
      /* Simplified logic compared to CA-Cl*pper. In the latter there 
         is logic to detect several typical cBlock types (memvar, 
         aliased field, field) and using MemvarBlock()/FieldWBlock()/FieldBlock() 
         calls to create codeblocks for them if possible. In Harbour, 
         simple macro compilation will result in faster code for all 
         situations. As Maurilio Longo has pointed, there is no point in 
         creating codeblocks which are able to _assign_ values, as dbEdit() 
         is a read-only function. [vszakats] */
      
      bBlock := iif( Type( cBlock ) == "M", {|| "    " }, &( "{||" + cBlock + "}" ) )

      /* ; */

      IF ISARRAY( xColumnHeaders ) .AND. Len( xColumnHeaders ) >= nPos .AND. ISCHARACTER( xColumnHeaders[ nPos ] )
         cHeading := xColumnHeaders[ nPos ]
      ELSEIF ISCHARACTER( xColumnHeaders )
         cHeading := xColumnHeaders
      ENDIF

      oColumn := TBColumnNew( cHeading, bBlock )

      IF ISARRAY( xColumnSayPictures ) .AND. nPos <= Len( xColumnSayPictures ) .AND. ISCHARACTER( xColumnSayPictures[ nPos ] ) .AND. !Empty( xColumnSayPictures[ nPos ] )
         oColumn:picture := xColumnSayPictures[ nPos ]
      ELSEIF ISCHARACTER( xColumnSayPictures ) .AND. !Empty( xColumnSayPictures )
         oColumn:picture := xColumnSayPictures
      ENDIF

      IF ISARRAY( xColumnFootings ) .AND. nPos <= Len( xColumnFootings ) .AND. ISCHARACTER( xColumnFootings[ nPos ] )
         oColumn:footing := xColumnFootings[ nPos ]
      ELSEIF ISCHARACTER( xColumnFootings )
         oColumn:footing := xColumnFootings
      ENDIF

      IF ISARRAY( xHeadingSeparators ) .AND. nPos <= Len( xHeadingSeparators ) .AND. ISCHARACTER( xHeadingSeparators[ nPos ] )
         oColumn:headSep := xHeadingSeparators[ nPos ]
      ENDIF

      IF ISARRAY( xColumnSeparators ) .AND. nPos <= Len( xColumnSeparators ) .AND. ISCHARACTER( xColumnSeparators[ nPos ] )
         oColumn:colSep := xColumnSeparators[ nPos ]
      ENDIF

      IF ISARRAY( xFootingSeparators ) .AND. nPos <= Len( xFootingSeparators ) .AND. ISCHARACTER( xFootingSeparators[ nPos ] )
         oColumn:footSep := xFootingSeparators[ nPos ]
      ENDIF

      oBrowse:addColumn( oColumn )

   NEXT

   nOldCUrsor := SetCursor( SC_NONE )

   /* --------------------------- */
   /* Go into the processing loop */
   /* --------------------------- */

   lAppend := .F.
   lFlag := .T.
   lDoIdleCall := .T.
   lContinue := .T.

   WHILE lContinue

      WHILE ! oBrowse:stabilize()
         nKey := Nextkey()
#ifdef HB_COMPAT_C53
         IF nKey != 0 .AND. nKey != K_MOUSEMOVE
#else
         IF nKey != 0
#endif
            EXIT
         ENDIF
      ENDDO

      IF ( nKey := Inkey() ) == 0
         IF lDoIdleCall
            lContinue := CallUser( oBrowse, xUserFunc, 0, @lAppend, @lFlag )
            oBrowse:forceStable()
         ENDIF
         IF lContinue .AND. lFlag
            oBrowse:hiLite()
#ifdef HB_COMPAT_C53
            WHILE ( nKey := Inkey( 0 ) ) == K_MOUSEMOVE
            ENDDO
#else
            nKey := Inkey( 0 )
#endif
            oBrowse:deHilite()
            IF ( bBlock := SetKey( nKey ) ) != NIL
               Eval( bBlock, ProcName( 1 ), ProcLine( 1 ), "" )
               LOOP
            ENDIF
         ELSE
            lFlag := .T.
         ENDIF
      ENDIF

      lDoIdleCall := .T.

      IF nKey != 0
#ifdef HB_C52_UNDOC
         IF lAppend
            SWITCH nKey
               CASE K_DOWN
               CASE K_PGDN
               CASE K_CTRL_PGDN
                  oBrowse:hitBottom := .T.
                  LOOP
               CASE K_UP
               CASE K_PGUP
               CASE K_CTRL_PGUP
                  oBrowse:hitTop := .T.
                  LOOP
            ENDSWITCH
         ENDIF
#endif
         SWITCH nKey
#ifdef HB_COMPAT_C53
            CASE K_LBUTTONDOWN
            CASE K_LDBLCLK
               TBMouse( oBrowse, MRow(), MCol() )
               EXIT
#endif
            CASE K_DOWN          ; oBrowse:down()     ; EXIT
            CASE K_UP            ; oBrowse:up()       ; EXIT
            CASE K_PGDN          ; oBrowse:pageDown() ; EXIT
            CASE K_PGUP          ; oBrowse:pageUp()   ; EXIT
            CASE K_CTRL_PGUP     ; oBrowse:goTop()    ; EXIT
            CASE K_CTRL_PGDN     ; oBrowse:goBottom() ; EXIT
            CASE K_RIGHT         ; oBrowse:right()    ; EXIT
            CASE K_LEFT          ; oBrowse:left()     ; EXIT
            CASE K_HOME          ; oBrowse:home()     ; EXIT
            CASE K_END           ; oBrowse:end()      ; EXIT
            CASE K_CTRL_LEFT     ; oBrowse:panLeft()  ; EXIT
            CASE K_CTRL_RIGHT    ; oBrowse:panRight() ; EXIT
            CASE K_CTRL_HOME     ; oBrowse:panHome()  ; EXIT
            CASE K_CTRL_END      ; oBrowse:panEnd()   ; EXIT
            OTHERWISE
               lContinue := CallUser( oBrowse, xUserFunc, nKey, @lAppend, @lFlag )
               lDoIdleCall := .F.
               EXIT
         ENDSWITCH
      ENDIF
   ENDDO

   SetCursor( nOldCUrsor )

   RETURN .T.
dbedit.prg67
STATIC FUNCTIONCallUser( oBrowse, xUserFunc, nKey, lAppend, lFlag )
STATIC FUNCTION CallUser( oBrowse, xUserFunc, nKey, lAppend, lFlag )

   LOCAL nPrevRecNo

   LOCAL nAction
   LOCAL nMode := IIF( nKey != 0,                  DE_EXCEPT,    ;
                  IIF( !lAppend .AND. IsDbEmpty(), DE_EMPTY,     ;
                  IIF( oBrowse:hitBottom,          DE_HITBOTTOM, ;
                  IIF( oBrowse:hitTop,             DE_HITTOP, DE_IDLE ) ) ) )

   oBrowse:forceStable()

   nPrevRecNo := RecNo()

   /* NOTE: CA-Cl*pper won't check the type of the return value here, 
            and will crash if it's a non-NIL, non-numeric type. We're 
            replicating this behavior. */
   nAction := IIF( ISBLOCK( xUserFunc ), ;
                                 Eval( xUserFunc, nMode, oBrowse:colPos ), ;
              IIF( ISCHARACTER( xUserFunc ) .AND. !Empty( xUserFunc ), ;
                                 &xUserFunc( nMode, oBrowse:colPos ), ;
              IIF( nKey == K_ENTER .OR. nKey == K_ESC, DE_ABORT, DE_CONT ) ) )

   IF !lAppend .AND. EOF() .AND. !IsDbEmpty()
      dbSkip( -1 )
   ENDIF

#ifdef HB_C52_UNDOC
   IF nAction == DE_APPEND

      IF ( lAppend := !( lAppend .AND. EOF() ) )
         dbGoBottom()
         oBrowse:down()
      ELSE
         oBrowse:refreshAll():forceStable()
      ENDIF
      lFlag := .F.
      RETURN .T.
   ENDIF
#endif

   IF nAction == DE_REFRESH .OR. nPrevRecNo != RecNo()

      IF nAction != DE_ABORT

         lAppend := .F.

         IF ( Set( _SET_DELETED ) .AND. Deleted() ) .OR. ;
            ( !Empty( dbfilter() ) .AND. !&( dbFilter() ) )
            dbSkip()
         ENDIF
         IF EOF()
            dbGoBottom()
         ENDIF
         
         nPrevRecNo := RecNo()
         oBrowse:refreshAll():forceStable()
         WHILE nPrevRecNo != RecNo()
            oBrowse:Up():forceStable()
         ENDDO
         
         lFlag := .F.

      ENDIF
   ELSE
      oBrowse:refreshCurrent()
   ENDIF

   RETURN nAction != DE_ABORT
dbedit.prg294
STATIC FUNCTIONIsDbEmpty()
STATIC FUNCTION IsDbEmpty()

   RETURN LastRec() == 0 .OR. ;
          ( BOF() .AND. ( EOF() .OR. RecNo() == LastRec() + 1 ) )
dbedit.prg368
STATIC FUNCTIONSkipped( nRecs, lAppend )
STATIC FUNCTION Skipped( nRecs, lAppend )

   LOCAL nSkipped := 0

   IF LastRec() != 0
      IF nRecs == 0
         IF EOF() .AND. !lAppend
            dbSkip( -1 )
            nSkipped := -1
         ELSE
            dbSkip( 0 )
         ENDIF
      ELSEIF nRecs > 0 .AND. RecNo() != LastRec() + 1
         DO WHILE nSkipped < nRecs
            dbSkip()
            IF Eof()
               IF lAppend
                  nSkipped++
               ELSE
                  dbSkip( -1 )
               ENDIF
               EXIT
            ENDIF
            nSkipped++
         ENDDO
      ELSEIF nRecs < 0
         DO WHILE nSkipped > nRecs
            dbSkip( -1 )
            IF Bof()
               EXIT
            ENDIF
            nSkipped--
         ENDDO
      ENDIF
   ENDIF

   RETURN nSkipped
dbedit.prg374
devoutp.prg
TypeFunctionSourceLine
PROCEDUREDevOutPict( xValue, cPicture, cColor )
PROCEDURE DevOutPict( xValue, cPicture, cColor )

   IF Valtype( xValue ) $ "CMNDL"
      DevOut( Transform( xValue, cPicture ), cColor )
   ENDIF

RETURN
devoutp.prg53
dircmd.prg
TypeFunctionSourceLine
PROCEDURE__Dir( cFileMask )
PROCEDURE __Dir( cFileMask )
   LOCAL cPath
   LOCAL cName
   LOCAL cExt

   IF Empty( cFileMask )

      /* NOTE: Although Cl*pper has this string in the national language
               modul, it will not use it from there.
               This is hard wired to English. So this is a small
               incompatibility. */

#ifdef HB_C52_STRICT
      QOut( "Database Files    # Records    Last Update     Size" )
#else
      QOut( __NatMsg( _DIR_HEADER ) )
#endif

      AEval( Directory( hb_FNameMerge( Set( _SET_DEFAULT ), "*", ".dbf" ) ),;
         {| aDirEntry | PutDbf( aDirEntry ) } )
   ELSE

      hb_FNameSplit( LTrim( cFileMask ), @cPath, @cName, @cExt )
      IF Empty( cPath )
         cPath := Set( _SET_DEFAULT )
      ENDIF

      AEval( Directory( hb_FNameMerge( cPath, cName, cExt ) ),;
         {| aDirEntry | PutNormal( aDirEntry ) } )
   ENDIF

   QOut()

   RETURN
dircmd.prg58
STATIC PROCEDUREPutDBF( aDirEntry )
STATIC PROCEDURE PutDBF( aDirEntry )
   LOCAL fhnd
   LOCAL buffer
   LOCAL nRecCount := 0
   LOCAL dLastUpdate := hb_SToD( "" )

   IF ( fhnd := FOpen( aDirEntry[ F_NAME ] ) ) != F_ERROR

      buffer := Replicate( Chr( 0 ), 8 )

      IF FRead( fhnd, @buffer, 8 ) == 8 .AND. ;
         AScan( { 0x03, 0x06, 0x30, 0x31, 0x83, 0x86, 0xE5, 0xE6, 0xF5, 0xF6 }, ;
                Asc( buffer ) ) != 0

         nRecCount := Bin2L( SubStr( buffer, 5, 4 ) )
         dLastUpdate := hb_SToD( StrZero( ASC( SubStr( buffer, 2, 1 ) ) + 1900, 4 ) +;
                                 StrZero( ASC( SubStr( buffer, 3, 1 ) ), 2 ) +;
                                 StrZero( ASC( SubStr( buffer, 4, 1 ) ), 2 ) )

      ENDIF

      FClose( fhnd )

   ENDIF

   QOut( PadR( aDirEntry[ F_NAME ], 15 ) +;
         Str( nRecCount, 12 ) + "    " +;
         DToC( dLastUpdate ) +;
         Str( aDirEntry[ F_SIZE ], 12 ) )

   RETURN
dircmd.prg93
STATIC PROCEDUREPutNormal( aDirEntry )
STATIC PROCEDURE PutNormal( aDirEntry )
   LOCAL cName
   LOCAL cExt

   hb_FNameSplit( aDirEntry[ F_NAME ], NIL, @cName, @cExt )

   QOut( PadR( cName, 8 ) + " " +;
         PadR( cExt, 3 ) + " " +;
         Str( aDirEntry[ F_SIZE ], 8 ) + "  " +;
         DToC( aDirEntry[ F_DATE ] ) )

   RETURN
dircmd.prg125
dirscan.prg
TypeFunctionSourceLine
STATIC FUNCTIONHB_doScan( cPath, cMask, cAttr, cPathSep )
STATIC FUNCTION HB_doScan( cPath, cMask, cAttr, cPathSep )

   LOCAL aFile
   LOCAL lMatch
   LOCAL aResult := {}

   FOR EACH aFile IN Directory( cPath + hb_osFileMask(), cAttr + "D" )
      lMatch = HB_FileMatch( aFile[ 1 ], cMask )
      IF "D" $ aFile[ 5 ]
         IF lMatch .AND. "D" $ cAttr
            AAdd( aResult, aFile )
         ENDIF
         IF !( aFile[ 1 ] == "." .OR. aFile[ 1 ] == ".." .OR. aFile[ 1 ] == "" )
            AEval( HB_DoScan( cPath + aFile[ 1 ] + cPathSep, cMask, cAttr, cPathSep ), ;
                   { |x| x[ 1 ] := aFile[ 1 ] + cPathSep + x[ 1 ], ;
                         AAdd( aResult, x ) } )
         ENDIF
      ELSEIF lMatch
         AAdd( aResult, aFile )
      ENDIF
   NEXT

   RETURN aResult
dirscan.prg53
FUNCTIONHB_DirScan( cPath, cFileMask, cAttr )
FUNCTION HB_DirScan( cPath, cFileMask, cAttr )

   LOCAL cFilePath
   LOCAL cPathSep := hb_osPathSeparator()

   IF Empty( cPath )
      cFilePath := ""
   ELSE
      cFilePath := cPath
      IF !Right( cPath, 1 ) $ hb_osPathDelimiters()
         cFilePath += cPathSep
      ENDIF
   ENDIF

   RETURN HB_DoScan( cFilePath, ;
                     IIF( Empty( cFileMask ), hb_osFileMask(), cFileMask ), ;
                     IIF( ValType( cAttr ) $ "CM", cAttr, "" ), ;
                     cPathSep )
dirscan.prg77
einstv52.prg
TypeFunctionSourceLine
FUNCTION__eInstVar52( oVar, cMethod, xValue, cType, nSubCode, xMin, xMax )
FUNCTION __eInstVar52( oVar, cMethod, xValue, cType, nSubCode, xMin, xMax )

   LOCAL oError
   LOCAL lError

   IF VALTYPE( xValue ) == cType
      lError := .F.
      IF xMin != NIL
         lError := !( xValue >= xMin )
      ENDIF
      /* NOTE: In CA-Cl*pper 5.2, xMin validation result is 
               ignored when xMax != NIL. Harbour is doing the same. */
      IF xMax != NIL
         lError := !( xValue <= xMax )
      ENDIF
   ELSE
      lError := .T.
   ENDIF

   IF lError
      oError := ErrorNew()
      oError:description := HB_LANGERRMSG( 1 )
      oError:gencode := 1
      oError:severity := 2
      oError:cansubstitute := .T.
      oError:subsystem := oVar:className
#ifdef HB_C52_STRICT
      HB_SYMBOL_UNUSED( cMethod )
#else
      oError:operation := cMethod
#endif
      oError:subcode := nSubCode
      oError:args := { xValue }
      xValue := EVAL( ERRORBLOCK(), oError )
      IF !( VALTYPE( xValue ) == cType )
         __errInHandler()
      ENDIF
   ENDIF

   RETURN xValue
einstv52.prg58
einstvar.prg
TypeFunctionSourceLine
FUNCTION__eInstVar53( oVar, cMethod, xValue, cType, nSubCode, bValid )
FUNCTION __eInstVar53( oVar, cMethod, xValue, cType, nSubCode, bValid )

   LOCAL oError

   IF !( VALTYPE( xValue ) == cType ) .OR. ;
      ( bValid != NIL .AND. !EVAL( bValid, oVar, xValue ) )
      oError := ErrorNew()
      oError:description := HB_LANGERRMSG( 1 )
      oError:gencode := 1
      oError:severity := 2
      oError:cansubstitute := .T.
      oError:subsystem := oVar:className
#ifdef HB_C52_STRICT
      HB_SYMBOL_UNUSED( cMethod )
#else
      oError:operation := cMethod
#endif
      oError:subcode := nSubCode
      oError:args := { xValue }
      xValue := EVAL( ERRORBLOCK(), oError )
      IF !( VALTYPE( xValue ) == cType )
         __errInHandler()
      ENDIF
   ENDIF

   RETURN xValue
einstvar.prg58
einstvau.prg
TypeFunctionSourceLine
FUNCTION_eInstVar( ... )
FUNCTION _eInstVar( ... )
#ifdef HB_COMPAT_C53
   RETURN __eInstVar53( ... )
#else
   RETURN __eInstVar52( ... )
einstvau.prg56
errorsys.prg
TypeFunctionSourceLine
PROCEDUREErrorSys()
PROCEDURE ErrorSys()

   ErrorBlock( { | oError | DefError( oError ) } )

   RETURN
errorsys.prg56
STATIC FUNCTIONDefError( oError )
STATIC FUNCTION DefError( oError )
   LOCAL cMessage
   LOCAL cDOSError

   LOCAL aOptions
   LOCAL nChoice

   LOCAL n

   // By default, division by zero results in zero
   IF oError:genCode == EG_ZERODIV .AND. ;
      oError:canSubstitute
      RETURN 0
   ENDIF

   // By default, retry on RDD lock error failure */
   IF oError:genCode == EG_LOCK .AND. ;
      oError:canRetry
      // oError:tries++
      RETURN .T.
   ENDIF

   // Set NetErr() of there was a database open error
   IF oError:genCode == EG_OPEN .AND. ;
      oError:osCode == 32 .AND. ;
      oError:canDefault
      NetErr( .T. )
      RETURN .F.
   ENDIF

   // Set NetErr() if there was a lock error on dbAppend()
   IF oError:genCode == EG_APPENDLOCK .AND. ;
      oError:canDefault
      NetErr( .T. )
      RETURN .F.
   ENDIF

   cMessage := ErrorMessage( oError )
   IF ! Empty( oError:osCode )
      cDOSError := "(DOS Error " + LTrim( Str( oError:osCode ) ) + ")"
   ENDIF

   // Build buttons

   aOptions := {}

   AAdd( aOptions, "Quit" )

   IF oError:canRetry
      AAdd( aOptions, "Retry" )
   ENDIF

   IF oError:canDefault
      AAdd( aOptions, "Default" )
   ENDIF

   // Show alert box

   nChoice := 0
   DO WHILE nChoice == 0

      IF ISNIL( cDOSError )
         nChoice := Alert( cMessage, aOptions )
      ELSE
         nChoice := Alert( cMessage + ";" + cDOSError, aOptions )
      ENDIF

   ENDDO

   IF ! Empty( nChoice )
      DO CASE
      CASE aOptions[ nChoice ] == "Break"
         Break( oError )
      CASE aOptions[ nChoice ] == "Retry"
         RETURN .T.
      CASE aOptions[ nChoice ] == "Default"
         RETURN .F.
      ENDCASE
   ENDIF

   // "Quit" selected

   IF ! ISNIL( cDOSError )
      cMessage += " " + cDOSError
   ENDIF

   OutErr( hb_OSNewLine() )
   OutErr( cMessage )

   n := 1
   DO WHILE ! Empty( ProcName( ++n ) )

      OutErr( hb_OSNewLine() )
      OutErr( "Called from " + ProcName( n ) + ;
               "(" + LTrim( Str( ProcLine( n ) ) ) + ")  " )

   ENDDO

   ErrorLevel( 1 )
   QUIT

   RETURN .F.
errorsys.prg62
STATIC FUNCTIONErrorMessage( oError )
STATIC FUNCTION ErrorMessage( oError )

   // start error message
   LOCAL cMessage := iif( oError:severity > ES_WARNING, "Error", "Warning" ) + " "

   // add subsystem name if available
   IF ISCHARACTER( oError:subsystem )
      cMessage += oError:subsystem()
   ELSE
      cMessage += "???"
   ENDIF

   // add subsystem's error code if available
   IF ISNUMBER( oError:subCode )
      cMessage += "/" + LTrim( Str( oError:subCode ) )
   ELSE
      cMessage += "/???"
   ENDIF

   // add error description if available
   IF ISCHARACTER( oError:description )
      cMessage += "  " + oError:description
   ENDIF

   // add either filename or operation
   DO CASE
   CASE !Empty( oError:filename )
      cMessage += ": " + oError:filename
   CASE !Empty( oError:operation )
      cMessage += ": " + oError:operation
   ENDCASE

   RETURN cMessage
errorsys.prg165
fieldbl.prg
TypeFunctionSourceLine
FUNCTIONFIELDBLOCK( cFieldName )
FUNCTION FIELDBLOCK( cFieldName )

   IF ISCHARACTER( cFieldName )
      RETURN {| x | iif( x == NIL, FieldGet( FieldPos( cFieldName ) ),;
                                   FieldPut( FieldPos( cFieldName ), x ) ) }
   ENDIF

   RETURN NIL
fieldbl.prg55
FUNCTIONFIELDWBLOCK( cFieldName, nWorkArea )
FUNCTION FIELDWBLOCK( cFieldName, nWorkArea )

   IF ISCHARACTER( cFieldName ) .AND. ISNUMBER( nWorkArea )
      RETURN {| x | iif( x == NIL, ( nWorkArea )->( FieldGet( FieldPos( cFieldName ) ) ),;
                                   ( nWorkArea )->( FieldPut( FieldPos( cFieldName ), x ) ) ) }
   ENDIF

   RETURN NIL
fieldbl.prg64
getlist.prg
TypeFunctionSourceLine
PROCEDURE__GetListSetActive( oGetList )
PROCEDURE __GetListSetActive( oGetList )

   IF s_oGetListActive != NIL
      s_oGetListActive:HasFocus := .F.
   ENDIF

   s_oGetListActive := oGetList

   IF s_oGetListActive != NIL
      s_oGetListActive:HasFocus := .T.
   ENDIF

   RETURN
getlist.prg57
FUNCTION__GetListActive()
FUNCTION __GetListActive()
   RETURN s_oGetListActive
getlist.prg73
FUNCTION__GetListLast( oGetListLast )
FUNCTION __GetListLast( oGetListLast )
   THREAD STATIC s_oGetListLast

   IF oGetListLast != NIL
      s_oGetListLast := oGetListLast
   ENDIF

   RETURN s_oGetListLast
getlist.prg76
getsys.prg
TypeFunctionSourceLine
FUNCTIONReadModal( GetList, nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )
FUNCTION ReadModal( GetList, nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )
getsys.prg72
FUNCTIONReadModal( GetList )
FUNCTION ReadModal( GetList )
#endif

   LOCAL oGetList
   LOCAL oSaveGetList

   IF Empty( GetList )
      SetPos( MaxRow() - 1, 0 )
      RETURN .F.
   ENDIF

   oGetList := HBGetList():New( GetList )

   oSaveGetList := __GetListActive( )
#ifdef HB_COMPAT_C53
// oSaveGetList:ReadStats( SLUPDATED, .F. )
// oSaveGetList:ReadStats( SXREADVAR, ReadVar( "" ) )
// oSaveGetList:ReadStats( SOACTIVEGET, GetActive( NIL ) )
#endif

   __GetListSetActive( oGetList )
   __GetListLast( oGetList )

#ifdef HB_COMPAT_C53
   oGetList:ReadModal( nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )
#else
   oGetList:ReadModal()
#endif

   __GetListSetActive( oSaveGetList )
#ifdef HB_COMPAT_C53
// oSaveGetList:ReadStats( SLUPDATED, oGetList:Updated() )
// ReadVar( oSaveGetList:ReadStats( SXREADVAR ) )
// GetActive( oSaveGetList:ReadStats( SOACTIVEGET ) )
#endif

   SetPos( MaxRow() - 1, 0 )

   RETURN oGetList:Updated()
getsys.prg74
PROCEDUREGetReader( oGet, oGetList, oMenu, aMsg )
PROCEDURE GetReader( oGet, oGetList, oMenu, aMsg )

   HB_SYMBOL_UNUSED( oGetList )

   oGet:Reader( oMenu, aMsg )

   RETURN
getsys.prg115
PROCEDUREGetReader( oGet )
PROCEDURE GetReader( oGet )

   oGet:Reader()

   RETURN
getsys.prg123
FUNCTIONGetActive( oGet )
FUNCTION GetActive( oGet )
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      IF PCount() > 0
         RETURN oGetList:GetActive( oGet )
      ELSE
         RETURN oGetList:GetActive()
      ENDIF
   ENDIF

   RETURN NIL
getsys.prg130
PROCEDUREGetDoSetKey( bKeyBlock, oGet )
PROCEDURE GetDoSetKey( bKeyBlock, oGet )
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      oGetList:GetDoSetKey( bKeyBlock, oGet )
   ENDIF

   RETURN
getsys.prg143
PROCEDUREGetApplyKey( oGet, nKey, oGetList, oMenu, aMsg )
PROCEDURE GetApplyKey( oGet, nKey, oGetList, oMenu, aMsg )
   IF !ISOBJECT( oGetList )
      oGetList := __GetListActive()
   ENDIF
getsys.prg153
PROCEDUREGetApplyKey( oGet, nKey )
PROCEDURE GetApplyKey( oGet, nKey )
   LOCAL oGetList := __GetListActive()
#endif

   IF oGetList != NIL
#ifdef HB_COMPAT_C53
      oGetList:GetApplyKey( nKey, oGet, oMenu, aMsg )
#else
      oGetList:GetApplyKey( nKey, oGet )
#endif
   ENDIF

   RETURN
getsys.prg158
FUNCTIONGetPreValidate( oGet, aMsg )
FUNCTION GetPreValidate( oGet, aMsg )
getsys.prg173
FUNCTIONGetPreValidate( oGet )
FUNCTION GetPreValidate( oGet )
#endif
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
#ifdef HB_COMPAT_C53
      RETURN oGetList:GetPreValidate( oGet, aMsg )
#else
      RETURN oGetList:GetPreValidate( oGet )
#endif
   ENDIF

   RETURN .F.
getsys.prg175
FUNCTIONGetPostValidate( oGet, aMsg )
FUNCTION GetPostValidate( oGet, aMsg )
getsys.prg190
FUNCTIONGetPostValidate( oGet )
FUNCTION GetPostValidate( oGet )
#endif
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
#ifdef HB_COMPAT_C53
      RETURN oGetList:GetPostValidate( oGet, aMsg )
#else
      RETURN oGetList:GetPostValidate( oGet )
#endif
   ENDIF

   RETURN .F.
getsys.prg192
FUNCTIONReadExit( lExit )
FUNCTION ReadExit( lExit )
   RETURN Set( _SET_EXIT, lExit )
getsys.prg206
FUNCTIONReadInsert( lInsert )
FUNCTION ReadInsert( lInsert )
   RETURN Set( _SET_INSERT, lInsert )
getsys.prg209
FUNCTIONUpdated()
FUNCTION Updated()
   LOCAL oGetList := __GetListLast()

   RETURN iif( oGetList != NIL, oGetList:Updated(), .F. )
getsys.prg212
PROCEDURE__KillRead()
PROCEDURE __KillRead()
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      oGetList:KillRead( .T. )
   ENDIF

   RETURN
getsys.prg217
FUNCTIONReadUpdated( lUpdated )
FUNCTION ReadUpdated( lUpdated )
   LOCAL oGetList := __GetListLast()

   IF oGetList != NIL
      IF PCount() > 0
         RETURN oGetList:ReadUpdated( lUpdated )
      ELSE
         RETURN oGetList:ReadUpdated()
      ENDIF
   ENDIF

   RETURN .F.
getsys.prg226
FUNCTIONReadKill( lKill )
FUNCTION ReadKill( lKill )
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      IF PCount() > 0
         RETURN oGetList:KillRead( lKill )
      ELSE
         RETURN oGetList:KillRead()
      ENDIF
   ENDIF

   RETURN .F.
getsys.prg239
FUNCTIONReadFormat( bFormat )
FUNCTION ReadFormat( bFormat )
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      IF PCount() > 0
         RETURN oGetList:SetFormat( bFormat )
      ELSE
         RETURN oGetList:SetFormat()
      ENDIF
   ENDIF

   RETURN NIL
getsys.prg252
PROCEDURE__SetFormat( bFormat )
PROCEDURE __SetFormat( bFormat )
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      IF ISBLOCK( bFormat )
         oGetList:SetFormat( bFormat )
      ELSE
         oGetList:SetFormat()
      ENDIF
   ENDIF

   RETURN
getsys.prg265
FUNCTIONRangeCheck( oGet, xDummy, xLow, xHigh )
FUNCTION RangeCheck( oGet, xDummy, xLow, xHigh )
   LOCAL xValue
   LOCAL cMessage
   LOCAL nOldRow
   LOCAL nOldCol

   HB_SYMBOL_UNUSED( xDummy )

   IF !oGet:changed
      RETURN .T.
   ENDIF

   xValue := oGet:varGet()

   IF xValue >= xLow .AND. xValue <= xHigh
      RETURN .T.
   ENDIF

   IF Set( _SET_SCOREBOARD )
      
      cMessage := Left( __NatMsg( _GET_RANGE_FROM ) + LTrim( Transform( xLow, "" ) ) + ;
                        __NatMsg( _GET_RANGE_TO ) + LTrim( Transform( xHigh, "" ) ), MaxCol() )

      nOldRow := Row()
      nOldCol := Col()

      DispOutAt( SCORE_ROW, Min( 60, MaxCol() - Len( cMessage ) ), cMessage )
      SetPos( nOldRow, nOldCol )

      DO WHILE NextKey() == 0
      ENDDO

      DispOutAt( SCORE_ROW, Min( 60, MaxCol() - Len( cMessage ) ), Space( Len( cMessage ) ) )
      SetPos( nOldRow, nOldCol )

   ENDIF

   RETURN .F.
getsys.prg284
FUNCTIONhb_GetReadVar( oGet )
FUNCTION hb_GetReadVar( oGet )
   LOCAL cName := Upper( oGet:name )
   LOCAL n

   IF oGet:subScript != NIL
      FOR n := 1 TO Len( oGet:subScript )
         cName += "[" + LTrim( Str( oGet:subScript[ n ] ) ) + "]"
      NEXT
   ENDIF

   RETURN cName
getsys.prg323
getsys53.prg
TypeFunctionSourceLine
PROCEDUREGUIReader( oGet, oGetlist, oMenu, aMsg )
PROCEDURE GUIReader( oGet, oGetlist, oMenu, aMsg )

   IF !ISOBJECT( oGetList )
      oGetList := __GetListActive()
   ENDIF
 
   IF oGetList != NIL
      oGetlist:GUIReader( oGet, oMenu, aMsg )
   ENDIF

   RETURN
getsys53.prg68
PROCEDUREGUIApplyKey( oGet, oGUI, oGetList, nKey, oMenu, aMsg )
PROCEDURE GUIApplyKey( oGet, oGUI, oGetList, nKey, oMenu, aMsg )

   IF !ISOBJECT( oGetList )
      oGetList := __GetListActive()
   ENDIF

   IF oGetList != NIL
      oGetList:GUIApplyKey( oGet, oGUI, nKey, oMenu, aMsg )
   ENDIF

   RETURN
getsys53.prg80
FUNCTIONGUIPreValidate( oGet, oGUI, aMsg )
FUNCTION GUIPreValidate( oGet, oGUI, aMsg )
   LOCAL oGetList := __GetListActive()

   RETURN iif( oGetList != NIL, oGetList:GUIPreValidate( oGet, oGUI, aMsg ), .F. )
getsys53.prg92
FUNCTIONGUIPostValidate( oGet, oGUI, aMsg )
FUNCTION GUIPostValidate( oGet, oGUI, aMsg )
   LOCAL oGetList := __GetListActive()

   RETURN iif( oGetList != NIL, oGetList:GUIPostValidate( oGet, oGUI, aMsg ), .F. )
getsys53.prg97
PROCEDURETBReader( oGet, oGetList, oMenu, aMsg )
PROCEDURE TBReader( oGet, oGetList, oMenu, aMsg )

   IF !ISOBJECT( oGetList )
      oGetList := __GetListActive()
   ENDIF

   IF oGetList != NIL
      oGetlist:TBReader( oGet, oMenu, aMsg )
   ENDIF

   RETURN
getsys53.prg102
PROCEDURETBApplyKey( oGet, oTB, oGetList, nKey, aMsg )
PROCEDURE TBApplyKey( oGet, oTB, oGetList, nKey, aMsg )

   IF !ISOBJECT( oGetList )
      oGetList := __GetListActive()
   ENDIF

   IF oGetList != NIL
      oGetList:TBApplyKey( oGet, oTB, nKey, aMsg )
   ENDIF

   RETURN 
getsys53.prg114
FUNCTIONAccelerator( oGetList, nKey, aMsg )
FUNCTION Accelerator( oGetList, nKey, aMsg )

   IF !ISOBJECT( oGetList )
      oGetList := __GetListActive()
   ENDIF

   RETURN iif( oGetList != NIL, oGetlist:Accelerator( nKey, aMsg ), 0 )
getsys53.prg126
FUNCTIONHitTest( oGetList, nMRow, nMCol, aMsg )
FUNCTION HitTest( oGetList, nMRow, nMCol, aMsg )

   IF !ISOBJECT( oGetList )
      oGetList := __GetListActive()
   ENDIF

   RETURN iif( oGetList != NIL, oGetlist:hitTest( nMRow, nMCol, aMsg ), 0 )
getsys53.prg134
PROCEDUREShowGetMsg( oGet, aMsg )
PROCEDURE ShowGetMsg( oGet, aMsg )
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      oGetList:ShowGetMsg( oGet, aMsg )
   ENDIF

   RETURN
getsys53.prg142
PROCEDUREEraseGetMsg( oGet, aMsg )
PROCEDURE EraseGetMsg( oGet, aMsg )
   LOCAL oGetList := __GetListActive()

   HB_SYMBOL_UNUSED( oGet )

   IF oGetList != NIL
      oGetList:EraseGetMsg( aMsg )
   ENDIF

   RETURN
getsys53.prg151
FUNCTIONReadStats( nElement, xNewValue )
FUNCTION ReadStats( nElement, xNewValue )
   LOCAL oGetList := __GetListActive()

   IF oGetList != NIL
      IF PCount() > 1
         RETURN oGetList:ReadStats( nElement, xNewValue )
      ELSE
         RETURN oGetList:ReadStats( nElement )
      ENDIF
   ENDIF

   RETURN NIL
getsys53.prg162
gui.prg
TypeFunctionSourceLine
FUNCTION_IsGraphic()
FUNCTION _IsGraphic()
   RETURN Set( _SET_VIDEOMODE ) != NIL .AND. ;
          Set( _SET_VIDEOMODE ) != 0 .AND. ;
          Set( _SET_VIDEOMODE ) != LLG_VIDEO_TXT
gui.prg59
FUNCTION_SetVideoMode( nMode )
FUNCTION _SetVideoMode( nMode )

   HB_SYMBOL_UNUSED( nMode )

   RETURN 0
gui.prg64
FUNCTION_GetNumCol( cColor )
FUNCTION _GetNumCol( cColor )
   LOCAL nPos

   IF ( nPos := At( "/", cColor ) ) > 0
      cColor := Left( cColor, nPos - 1 )
   ENDIF
   IF ( nPos := At( ",", cColor ) ) > 0
      cColor := Left( cColor, nPos - 1 )
   ENDIF

   RETURN AScan( { "B", "G", "BG", "R", "RB", "GR", "W", "N+", "B+", "G+", "BG+", "R+", "RB+", "GR+", "W+" }, {| tmp | tmp == cColor } )
gui.prg74
FUNCTION__GUIColor( cColor, nPos )
FUNCTION __GUIColor( cColor, nPos )
   RETURN hb_ColorIndex( cColor, nPos - 1 )
gui.prg86
FUNCTIONIsDefColor()
FUNCTION IsDefColor()
   RETURN SetColor() == "W/N,N/W,N/N,N/N,N/W" /* NOTE: Color must match with the one in set.c */
gui.prg89
FUNCTION__Caption( cCaption )
FUNCTION __Caption( cCaption )
   LOCAL nPos

   RETURN iif( ( nPos := At( "&", cCaption ) ) > 0, Stuff( cCaption, nPos, 1, "" ), cCaption )
gui.prg93
FUNCTION__CapLength( cCaption )
FUNCTION __CapLength( cCaption )
   LOCAL nCaptionLen := Len( cCaption )
   LOCAL nPos

   RETURN iif( ( nPos := At( "&", cCaption ) ) > 0 .AND. nPos < nCaptionLen, nCaptionLen - 1, nCaptionLen )
gui.prg98
FUNCTION__CapMetrics( o )
FUNCTION __CapMetrics( o )
   RETURN __CapLength( o:caption ) + iif( o:isPopup(), 3, 2 )
gui.prg104
hbini.prg
TypeFunctionSourceLine
PROCEDUREhb_IniSetComment( cLc, cHlc )
PROCEDURE hb_IniSetComment( cLc, cHlc )

   s_cLineComment := cLc
   s_cHalfLineComment := cHlc

   RETURN
hbini.prg85
FUNCTIONHB_IniNew( lAutoMain )
FUNCTION HB_IniNew( lAutoMain )
   LOCAL hIni := hb_Hash()

   IF lAutoMain
      hIni[ "MAIN" ] := hb_Hash()
   ENDIF

   RETURN hIni
hbini.prg92
FUNCTIONhb_IniRead( cFileSpec, lKeyCaseSens, cSplitters, lAutoMain )
FUNCTION hb_IniRead( cFileSpec, lKeyCaseSens, cSplitters, lAutoMain )
   LOCAL hIni := hb_Hash()

   /* Default case sensitiveness for keys */
   DEFAULT lKeyCaseSens TO .T.
   DEFAULT cSplitters TO "="
   DEFAULT lAutoMain TO .T.

   hb_HCaseMatch( hIni, lKeyCaseSens )

   IF lAutoMain
      hIni[ "MAIN" ] := hb_Hash()
   ENDIF

   RETURN hb_IniRdLow( hIni, cFileSpec, lKeyCaseSens, cSplitters, lAutoMain )
hbini.prg102
STATIC FUNCTIONhb_IniRdLow( hIni, cFileSpec, lKeyCaseSens, cSplitters, lAutoMain )
STATIC FUNCTION hb_IniRdLow( hIni, cFileSpec, lKeyCaseSens, cSplitters, lAutoMain )
   LOCAL cFile, nLen
   LOCAL aKeyVal, hCurrentSection
   LOCAL hFile, nLineEnd
   LOCAL cData, cLine
   LOCAL reComment, reInclude, reSection, reSplitters
   LOCAL aFiles := hb_aTokens( cFileSpec, hb_OSPathListSeparator() )

   IF Empty( aFiles )
      aFiles := { cFileSpec }
   ENDIF

   hFile := F_ERROR
   FOR EACH cFile IN aFiles
      IF ! Empty( cFile ) .AND. File( cFile )
         IF ( hFile := FOpen( cFile ) ) != F_ERROR
            EXIT
         ENDIF
      ENDIF
   NEXT

   IF hFile == F_ERROR
      RETURN NIL
   ENDIF

   reComment := hb_RegexComp( s_cHalfLineComment + "|^[ \t]*" + s_cLineComment )
   reInclude := hb_RegexComp( "include (.*)" )
   reSection := hb_RegexComp( "[[](.*)[]]" )
   reSplitters := hb_RegexComp( cSplitters )

   /* we'll read the whole file, then we'll break it in lines. */
   cData := Space( FSeek( hFile, 0, FS_END ) )
   FSeek( hFile, 0, FS_SET )
   nLen := FRead( hFile, @cData, Len( cData ) )
   cData := Left( cData, nLen )
   FClose( hFile )

   /* Always begin with the MAIN section */
   IF lAutoMain
      hCurrentSection := hIni[ "MAIN" ]
   ELSE
      hCurrentSection := hIni
   ENDIF

   cLine := ""
   DO WHILE Len( cData ) > 0
      nLen := 2
      nLineEnd := At( Chr( 13 ) + Chr( 10 ), cData )
      IF nLineEnd == 0
         nLineEnd := At( Chr( 10 ) + Chr( 13 ), cData )
         IF nLineEnd == 0
            nLen := 1
            nLineEnd := At( Chr( 10 ), cData )
            IF nLineEnd == 0
               nLineEnd := At( Chr( 13 ), cData )
               IF nLineEnd == 0
                  nLineEnd := Len( cData )
               ENDIF
            ENDIF
         ENDIF
      ENDIF

      /* Get the current line */
      cLine += AllTrim( SubStr( cData, 1, nLineEnd - 1 ) )
      /* remove current line */
      cData := SubStr( cData, nLineEnd + nLen )

      /* Skip void lines */
      IF Empty( cLine )
         LOOP
      ENDIF

      /* Sum up lines terminating with "||" ...*/
      IF Len( cLine ) > 3 .AND. SubStr( cLine, -3, 3 ) == " ||"

         cLine := SubStr( cLine, 1, Len( cLine ) - 2 )
         /* ... but proceed if stream over */
         IF Len( cData ) > 0
            LOOP
         ENDIF

      ENDIF

      /* remove eventual comments */
      aKeyVal := hb_RegexSplit( reComment, cLine )
      IF ! Empty( aKeyVal )
         cLine := AllTrim( aKeyVal[ 1 ] )
      ENDIF

      /* Skip all comment lines */
      IF Empty( cLine )
         LOOP
      ENDIF

      /* Is it an "INCLUDE" statement ? */
      aKeyVal := hb_RegEx( reInclude, cLine )
      IF ! Empty( aKeyVal )
         /* ignore void includes */
         aKeyVal[ 2 ] := AllTrim( aKeyVal[ 2 ] )
         IF Len( aKeyVal[ 2 ] ) == 0
            LOOP
         ENDIF
         hb_IniRdLow( hIni, aKeyVal[ 2 ], lKeyCaseSens, cSplitters, lAutoMain )
         cLine := ""
         LOOP
      ENDIF

      /* Is it a NEW section? */
      aKeyVal := hb_Regex( reSection, cLine )
      IF ! Empty( aKeyVal )
         cLine := AllTrim( aKeyVal[ 2 ] )
         IF Len( cLine ) != 0
            hCurrentSection := hb_Hash()
            IF ! lKeyCaseSens
               cLine := Upper( cLine )
            ENDIF
            hIni[ cLine ] := hCurrentSection
         ENDIF
         cLine := ""
         LOOP
      ENDIF

      /* Is it a valid key */
      aKeyVal := hb_RegexSplit( reSplitters, cLine,,, 2 )
      IF Len( aKeyVal ) == 1
         /* TODO: Signal error */
         cLine := ""
         LOOP
      ENDIF

      /* If not case sensitive, use upper keys */
      IF ! lKeyCaseSens
         aKeyVal[ 1 ] := Upper( aKeyVal[ 1 ] )
      ENDIF

      hCurrentSection[ AllTrim( aKeyVal[ 1 ] ) ] := AllTrim( aKeyVal[ 2 ] )
      cLine := ""
   ENDDO

   RETURN hIni
hbini.prg118
FUNCTIONhb_IniWrite( xFileName, hIni, cCommentBegin, cCommentEnd, lAutoMain )
FUNCTION hb_IniWrite( xFileName, hIni, cCommentBegin, cCommentEnd, lAutoMain )
   LOCAL hFile
   LOCAL lClose
   LOCAL cNewLine := hb_OSNewLine()
   LOCAL cSection
   LOCAL cBuffer

   IF ISCHARACTER( xFileName )
      hFile := FCreate( xFileName )
      lClose := .T.
   ELSEIF ISNUMBER( xFileName )
      hFile := xFileName
      lClose := .F.
   ELSE
      RETURN .F.
   ENDIF

   IF hFile == F_ERROR
      RETURN .F.
   ENDIF

   IF ! Empty( cCommentBegin )
      cBuffer := cCommentBegin + cNewLine
      IF FWrite( hFile, cBuffer ) != Len( cBuffer )
         IF lClose
            FClose( hFile )
         ENDIF
         RETURN .F.
      ENDIF
   ENDIF

   DEFAULT lAutoMain TO .T.

   /* Write toplevel section */
   IF lAutoMain
      /* When automain is on, write the main section */
      hb_HEval( hIni[ "MAIN" ], ;
               { |cKey, xVal| FWrite( hFile, hb_CStr( cKey ) + " = " + ;
                                             hb_CStr( xVal ) + cNewLine ) } )
           
   ELSE
      /* When automain is off, just write all the toplevel variables. */
      hb_HEval( hIni, { |cKey, xVal| IIF( ! hb_IsHash( xVal ),;
                FWrite( hFile, hb_CStr( cKey ) + " = " + ;
                               hb_CStr( xVal ) + cNewLine ), /* nothing */ ) } )
   ENDIF

   FOR EACH cSection IN hIni

      /* Avoid re-processing main section */
      IF lAutoMain
         /* When automain is on, skip section named MAIN */
         IF cSection:__enumKey == "MAIN"
            LOOP
         ENDIF
      ELSE
         /* When automain is off, skip all the toplevel variables. */
         IF ! hb_IsHash( cSection )
            LOOP
         ENDIF
      ENDIF

      cBuffer := cNewLine + "[" + hb_CStr( cSection:__enumKey ) + "]" + cNewLine
      IF FWrite( hFile, cBuffer ) != Len( cBuffer )
         IF lClose
            FClose( hFile )
         ENDIF
         RETURN .F.
      ENDIF

      hb_HEval( cSection, ;
                { |cKey, xVal| FWrite( hFile, hb_CStr( cKey ) + "=" + ;
                                              hb_CStr( xVal ) + cNewLine ) } )
   NEXT

   IF ! Empty( cCommentEnd )
      cBuffer := cCommentEnd + cNewLine
      IF FWrite( hFile, cBuffer ) != Len( cBuffer )
         IF lClose
            FClose( hFile )
         ENDIF
         RETURN .F.
      ENDIF
   ENDIF

   IF lClose
      FClose( hFile )
   ENDIF

   RETURN .T.
hbini.prg260
input.prg
TypeFunctionSourceLine
FUNCTION__Input( xPrompt )
FUNCTION __Input( xPrompt )
   LOCAL cString := __Accept( xPrompt )

   RETURN iif( Empty( cString ), NIL, &cString )
input.prg55
listbox.prg
TypeFunctionSourceLine
METHODaddItem( cText, cData )
   METHOD addItem( cText, cData )
listbox.prg82
METHODclose()
   METHOD close()
listbox.prg83
METHODdelItem( nPos )
   METHOD delItem( nPos )
listbox.prg84
METHODdisplay()
   METHOD display()
listbox.prg85
METHODfindText( cText, nPos, lCaseSensitive, lExact )
   METHOD findText( cText, nPos, lCaseSensitive, lExact )
listbox.prg86
METHODfindData( cData, nPos, lCaseSensitive, lExact )
   METHOD findData( cData, nPos, lCaseSensitive, lExact ) /* NOTE: Undocumented CA-Cl*pper method. */
listbox.prg87
METHODgetData( nPos )
   METHOD getData( nPos )
listbox.prg88
METHODgetItem( nPos )
   METHOD getItem( nPos )
listbox.prg89
METHODgetText( nPos )
   METHOD getText( nPos )
listbox.prg90
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )
listbox.prg91
METHODinsItem( nPos, cText, cData )
   METHOD insItem( nPos, cText, cData )
listbox.prg92
METHODkillFocus()
   METHOD killFocus()
listbox.prg93
METHODnextItem()
   METHOD nextItem()
listbox.prg94
METHODopen()
   METHOD open()
listbox.prg95
METHODprevItem()
   METHOD prevItem()
listbox.prg96
METHODscroll( n )
   METHOD scroll( n )
listbox.prg97
METHODselect( nValue )
   METHOD select( nValue )
listbox.prg98
METHODsetData( nPos, cData )
   METHOD setData( nPos, cData )
listbox.prg99
METHODsetFocus()
   METHOD setFocus()
listbox.prg100
METHODsetItem( nPos, aItem )
   METHOD setItem( nPos, aItem )
listbox.prg101
METHODsetText( nPos, cText )
   METHOD setText( nPos, cText )
listbox.prg102
METHODbitmap( cBitmap ) SETGET
   METHOD bitmap( cBitmap ) SETGET
listbox.prg104
METHODbottom( nBottom ) SETGET
   METHOD bottom( nBottom ) SETGET
listbox.prg105
METHODbuffer() SETGET
   METHOD buffer() SETGET
listbox.prg106
METHODcapCol( nCapCol ) SETGET
   METHOD capCol( nCapCol ) SETGET
listbox.prg107
METHODcapRow( nCapRow ) SETGET
   METHOD capRow( nCapRow ) SETGET
listbox.prg108
METHODcaption( cCaption ) SETGET
   METHOD caption( cCaption ) SETGET
listbox.prg109
METHODcoldBox( cColdBox ) SETGET
   METHOD coldBox( cColdBox ) SETGET
listbox.prg110
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
listbox.prg111
METHODdropDown( lDropDown ) SETGET
   METHOD dropDown( lDropDown ) SETGET
listbox.prg112
METHODfBlock( bFBlock ) SETGET
   METHOD fBlock( bFBlock ) SETGET
listbox.prg113
METHODhasFocus() SETGET
   METHOD hasFocus() SETGET
listbox.prg114
METHODhotBox( cHotBox ) SETGET
   METHOD hotBox( cHotBox ) SETGET
listbox.prg115
METHODisOpen() SETGET
   METHOD isOpen() SETGET
listbox.prg116
METHODitemCount() SETGET
   METHOD itemCount() SETGET
listbox.prg117
METHODleft( nLeft ) SETGET
   METHOD left( nLeft ) SETGET
listbox.prg118
METHODmessage( cMessage ) SETGET
   METHOD message( cMessage ) SETGET
listbox.prg119
METHODright( nRight ) SETGET
   METHOD right( nRight ) SETGET
listbox.prg120
METHODsBlock( bSBlock ) SETGET
   METHOD sBlock( bSBlock ) SETGET
listbox.prg121
METHODstyle( cStyle ) SETGET
   METHOD style( cStyle ) SETGET                          /* NOTE: Undocumented CA-Cl*pper method. */
listbox.prg122
METHODtextValue() SETGET
   METHOD textValue() SETGET                              /* NOTE: Undocumented CA-Cl*pper method. */
listbox.prg123
METHODtop( nTop ) SETGET
   METHOD top( nTop ) SETGET
listbox.prg124
METHODtopItem( nTopItem ) SETGET
   METHOD topItem( nTopItem ) SETGET
listbox.prg125
METHODtypeOut() SETGET
   METHOD typeOut() SETGET
listbox.prg126
METHODvalue() SETGET
   METHOD value() SETGET                                  /* NOTE: Undocumented CA-Cl*pper method. */
listbox.prg127
METHODvScroll( oVScroll ) SETGET
   METHOD vScroll( oVScroll ) SETGET
listbox.prg128
METHODNew( nTop, nLeft, nBottom, nRight, lDrop )
   METHOD New( nTop, nLeft, nBottom, nRight, lDrop ) /* NOTE: This method is a Harbour extension [vszakats] */

   PROTECTED:

   VAR cBitmap    INIT "dropbox.bmu"
   VAR nBottom
   VAR xBuffer
   VAR nCapCol
   VAR nCapRow
   VAR cCaption   INIT ""
   VAR cColdBox   INIT Chr( 218 ) + Chr( 196 ) + Chr( 191 ) + Chr( 179 ) + Chr( 217 ) + Chr( 196 ) + Chr( 192 ) + Chr( 179 )
   VAR cColorSpec
   VAR lDropDown
   VAR bFBlock
   VAR lHasFocus  INIT .F.
   VAR cHotBox    INIT Chr( 201 ) + Chr( 205 ) + Chr( 187 ) + Chr( 186 ) + Chr( 188 ) + Chr( 205 ) + Chr( 200 ) + Chr( 186 )
   VAR lIsOpen
   VAR nItemCount INIT 0
   VAR nLeft
   VAR cMessage   INIT ""
   VAR nRight
   VAR bSBlock
   VAR cStyle     INIT Chr( 31 )
   VAR cTextValue INIT ""
   VAR nTop
   VAR nTopItem   INIT 0
   VAR nValue     INIT 0
   VAR oVScroll

   VAR aItems     INIT {}
   VAR aSaveScr
   VAR nCursor
listbox.prg130
METHODchangeItem( nOldPos, nNewPos )
   METHOD changeItem( nOldPos, nNewPos )
listbox.prg163
METHODscrollbarPos()
   METHOD scrollbarPos()

ENDCLASS
listbox.prg164
LISTBOX:METHODaddItem( cText, cData ) CLASS LISTBOX
METHOD addItem( cText, cData ) CLASS LISTBOX

   IF ISCHARACTER( cText ) .AND. Valtype( cData ) $ "CU"

      AAdd( ::aItems, { cText, cData } )

      ::nItemCount++

      IF ::nItemCount == 1
         ::nTopItem := 1
         IF ::oVScroll != NIL
            ::oVScroll:total := ( ::nItemCount - ( ::nBottom - ::nTop - 2 ) )
         ENDIF
      ENDIF
   ENDIF

   RETURN Self
listbox.prg168
LISTBOX:METHODclose() CLASS LISTBOX
METHOD close() CLASS LISTBOX

   IF ::lIsOpen
      RestScreen( ::aSaveScr[ 1 ], ::aSaveScr[ 2 ], ::aSaveScr[ 3 ], ::aSaveScr[ 4 ], ::aSaveScr[ 5 ] )
      ::lIsOpen := .F.
      ::aSaveScr := NIL
   ENDIF

   RETURN Self
listbox.prg186
LISTBOX:METHODdelItem( nPos )
METHOD delItem( nPos )

   IF nPos >= 1 .AND. nPos <= ::nItemCount

      ADel( ::aItems, nPos )
      ASize( ::aItems, --::nItemCount )

      IF ::nValue > ::nItemCount
         ::nValue := ::nItemCount

         ::cTextValue := iif( ::nValue == 0, "", _LISTBOX_ITEMDATA( ::aItems[ ::nItemCount ] ) )

         IF ::xBuffer == NIL
         ELSEIF ISNUMBER( ::xBuffer )
            ::xBuffer := ::nItemCount
         ELSEIF ::nValue > 0
            ::xBuffer := ::cTextValue
         ENDIF

      ENDIF

      IF ::nTopItem > ::nItemCount
         ::nTopItem := ::nItemCount
      ENDIF

      IF ::oVScroll != NIL
         ::oVScroll:total := ::nItemCount - ( ::nBottom - ::nTop - 2 )
      ENDIF
   ENDIF

   RETURN Self
listbox.prg196
LISTBOX:METHODdisplay() CLASS LISTBOX
METHOD display() CLASS LISTBOX

   LOCAL cOldColor := SetColor()      
   LOCAL nOldRow := Row()             
   LOCAL nOldCol := Col()             
   LOCAL lOldMCur := MSetCursor( .F. )

   LOCAL nItem
   LOCAL nEnd
   LOCAL cColor4
   LOCAL cColor3
   LOCAL cColorAny
   LOCAL nTop := ::nTop
   LOCAL nLeft := ::nLeft
   LOCAL nSize := ::nRight - nLeft + 1
   LOCAL cHotBox
   LOCAL cCaption
   LOCAL nPos
   
   IF ::lHasFocus
      cHotBox   := ::cHotBox
      cColor3   := hb_ColorIndex( ::cColorSpec, 2 )
      cColor4   := hb_ColorIndex( ::cColorSpec, 3 )
      cColorAny := iif( ::lIsOpen, hb_ColorIndex( ::cColorSpec, 1 ), hb_ColorIndex( ::cColorSpec, 3 ) )
   ELSE
      cHotBox   := ::cColdBox
      cColor3   := hb_ColorIndex( ::cColorSpec, 0 )
      cColor4   := hb_ColorIndex( ::cColorSpec, 1 )
      cColorAny := hb_ColorIndex( ::cColorSpec, 1 )
   ENDIF

   DispBegin()

   nEnd := ::nTopItem + ::nBottom - ::nTop

   IF ::lDropDown

      DispOutAt( nTop++, nLeft,;
         iif( ::nValue == 0, Space( nSize - 1 ), PadR( ::aItems[ ::nValue ][ _ITEM_cTEXT ], nSize - 1 ) ),;
         cColorAny )

      DispOut( ::cStyle, hb_ColorIndex( ::cColorSpec, 7 ) )

      nEnd--
   ENDIF

   IF ::lIsOpen
      IF !Empty( cHotBox )

         SetColor( hb_ColorIndex( ::cColorSpec, 4 ) )
         Scroll( nTop, nLeft, ::nBottom, ::nRight )
         DispBox( nTop, nLeft, ::nBottom, ::nRight, cHotBox )

         IF ::oVScroll != NIL
            ::oVScroll:display()
         ENDIF

         nTop++
         nLeft++
         nSize -= 2
         nEnd -= 2

      ENDIF

      IF nEnd > ::nItemCount
         nEnd := ::nItemCount
      ENDIF

      FOR nItem := ::nTopItem TO nEnd
         DispOutAt( nTop++, nLeft, PadR( ::aItems[ nItem ][ _ITEM_cTEXT ], nSize ), iif( nItem == ::nValue, cColor4, cColor3 ) )
      NEXT
   ENDIF

   IF !Empty( cCaption := ::cCaption )

      IF ( nPos := At( "&", cCaption ) ) == 0
      ELSEIF nPos == Len( cCaption )
         nPos := 0
      ELSE
         cCaption := Stuff( cCaption, nPos, 1, "" )
      ENDIF

      DispOutAt( ::nCapRow, ::nCapCol - 1, cCaption, hb_ColorIndex( ::cColorSpec, 5 ) )

      IF nPos != 0
         DispOutAt( ::nCapRow, ::nCapCol + nPos - 2, SubStr( cCaption, nPos, 1 ), hb_ColorIndex( ::cColorSpec, 6 ) )
      ENDIF

   ENDIF

   DispEnd()

   MSetCursor( lOldMCur )
   SetColor( cOldColor )
   SetPos( nOldRow, nOldCol )

   RETURN Self
listbox.prg228
LISTBOX:METHODfindText( cText, nPos, lCaseSensitive, lExact ) CLASS LISTBOX
METHOD findText( cText, nPos, lCaseSensitive, lExact ) CLASS LISTBOX

   LOCAL nPosFound
   LOCAL nPass
   LOCAL nPasses
   LOCAL nSize
   LOCAL lOldExact

   IF !ISCHARACTER( cText )
      RETURN 0
   ENDIF
   IF !ISNUMBER( nPos )
      nPos := 1
   ENDIF
   IF !ISLOGICAL( lCaseSensitive )
      lCaseSensitive := .T.
   ENDIF
   IF !lCaseSensitive
      cText := Lower( cText )
   ENDIF
   IF ISLOGICAL( lExact )
      lOldExact := Set( _SET_EXACT, lExact )
   ENDIF

   nSize := Len( ::aItems ) - nPos + 1
   nPasses := iif( nPos > 1, 2, 1 )

   FOR nPass := 1 TO nPasses

      /* NOTE: Intentionally using "=" comparison to honor the _SET_EXACT setting. */
      IF ( nPosFound := AScan( ::aItems, iif( lCaseSensitive,;
                                              { | aItem | aItem[ _ITEM_cTEXT ] = cText },;
                                              { | aItem | Lower( aItem[ _ITEM_cTEXT ] ) = cText } ), nPos, nSize ) ) > 0
         EXIT
      ENDIF

      nSize := nPos - 1
      nPos := 1
   NEXT

   IF lOldExact != NIL
      Set( _SET_EXACT, lOldExact )
   ENDIF

   RETURN nPosFound
listbox.prg326
LISTBOX:METHODfindData( cData, nPos, lCaseSensitive, lExact ) CLASS LISTBOX
METHOD findData( cData, nPos, lCaseSensitive, lExact ) CLASS LISTBOX

   LOCAL nPosFound
   LOCAL nPass
   LOCAL nPasses
   LOCAL nSize
   LOCAL lOldExact

   IF !ISCHARACTER( cData )
      RETURN 0
   ENDIF
   IF !ISNUMBER( nPos )
      nPos := 1
   ENDIF
   IF !ISLOGICAL( lCaseSensitive )
      lCaseSensitive := .T.
   ENDIF
   IF !lCaseSensitive
      cData := Lower( cData )
   ENDIF
   IF ISLOGICAL( lExact )
      lOldExact := Set( _SET_EXACT, lExact )
   ENDIF

   nSize := Len( ::aItems ) - nPos + 1
   nPasses := iif( nPos > 1, 2, 1 )

   FOR nPass := 1 TO nPasses

      /* NOTE: Intentionally using "=" comparison to honor the _SET_EXACT setting. */
      IF ( nPosFound := AScan( ::aItems, iif( lCaseSensitive,;
                                              { | aItem | _LISTBOX_ITEMDATA( aItem ) = cData },;
                                              { | aItem | Lower( _LISTBOX_ITEMDATA( aItem ) ) = cData } ), nPos, nSize ) ) > 0
         EXIT
      ENDIF

      nSize := nPos - 1
      nPos := 1
   NEXT

   IF lOldExact != NIL
      Set( _SET_EXACT, lOldExact )
   ENDIF

   RETURN nPosFound
listbox.prg372
LISTBOX:METHODgetData( nPos ) CLASS LISTBOX
METHOD getData( nPos ) CLASS LISTBOX
   RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ][ _ITEM_cDATA ], NIL )
listbox.prg418
LISTBOX:METHODgetItem( nPos ) CLASS LISTBOX
METHOD getItem( nPos ) CLASS LISTBOX
   RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ], NIL )
listbox.prg421
LISTBOX:METHODgetText( nPos ) CLASS LISTBOX
METHOD getText( nPos ) CLASS LISTBOX
   RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ][ _ITEM_cTEXT ], NIL )
listbox.prg424
LISTBOX:METHODhitTest( nMRow, nMCol ) CLASS LISTBOX
METHOD hitTest( nMRow, nMCol ) CLASS LISTBOX

   LOCAL nRet
   LOCAL nTop
   LOCAL nHit := 0

   /* Check hit on the scrollbar */
   IF ::lIsOpen .AND. ;
      ::oVScroll != NIL .AND. ;
      ( nHit := ::oVScroll:hitTest( nMRow, nMCol ) ) != 0

      RETURN nHit
   ENDIF

   IF ! ::lIsOpen .OR. Empty( ::cHotBox + ::cColdBox )
      nRet := 0
   ELSE
      nTop := ::nTop
      IF ::lDropDown
         nTop++
      ENDIF

      DO CASE
      CASE nMRow == nTop
         IF nMCol == ::nLeft
            RETURN HTTOPLEFT
         ELSEIF nMCol == ::nRight
            RETURN HTTOPRIGHT
         ELSEIF nMCol >= ::nLeft .AND. nMCol <= ::nRight
            RETURN HTTOP
         ENDIF
      CASE nMRow == ::nBottom
         IF nMCol == ::nLeft
            RETURN HTBOTTOMLEFT
         ELSEIF nMCol == ::nRight
            RETURN HTBOTTOMRIGHT
         ELSEIF nMCol >= ::nLeft .AND. nMCol <= ::nRight
            RETURN HTBOTTOM
         ENDIF
      CASE nMCol == ::nLeft
         IF nMRow >= ::nTop .AND. nMRow <= ::nBottom
            RETURN HTLEFT
         ELSE
            RETURN HTNOWHERE
         ENDIF
      CASE nMCol == ::nRight
         IF nMRow >= ::nTop .AND. nMRow <= ::nBottom
            RETURN HTRIGHT
         ELSE
            RETURN HTNOWHERE
         ENDIF
      ENDCASE
      nRet := 1
   ENDIF

   DO CASE
   CASE ! ::lIsOpen
   CASE nMRow < nTop + nRet
   CASE nMRow > ::nBottom - nRet
   CASE nMCol < ::nLeft + nRet
   CASE nMCol <= ::nRight - nRet
      RETURN ::nTopItem + nMRow - ( nTop + nRet )
   ENDCASE

   DO CASE
   CASE ! ::lDropDown
   CASE nMRow != ::nTop
   CASE nMCol < ::nLeft
   CASE nMCol < ::nRight
      RETURN HTCLIENT
   CASE nMCol == ::nRight
      RETURN HTDROPBUTTON
   ENDCASE

   DO CASE
   CASE Empty( ::cCaption )
   CASE nMRow != ::nCapRow
   CASE nMCol < ::nCapCol
   CASE nMCol < ::nCapCol + __CapLength( ::cCaption )
      RETURN HTCAPTION
   ENDCASE

   RETURN 0
listbox.prg427
LISTBOX:METHODinsItem( nPos, cText, cData )
METHOD insItem( nPos, cText, cData )

   IF ISCHARACTER( cText ) .AND. ;
      ISNUMBER( nPos ) .AND. ;
      nPos < ::nItemCount

      ASize( ::aItems, ++::nItemCount )
      AIns( ::aItems, nPos )
      ::aItems[ nPos ] := { cText, cData }

      IF ::nItemCount == 1
         ::nTopItem := 1
      ENDIF

      IF ::oVScroll != NIL
         ::oVScroll:total := ::nItemCount - ( ::nBottom - ::nTop - 2 )
      ENDIF
   ENDIF

   RETURN Self
listbox.prg511
LISTBOX:METHODkillFocus() CLASS LISTBOX
METHOD killFocus() CLASS LISTBOX
   LOCAL nOldMCur

   IF ::lHasFocus
      ::lHasFocus := .F.

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF

      nOldMCur := MSetCursor( .F. )
      DispBegin()

      IF ::lDropDown .AND. ::lIsOpen
         ::close()
      ENDIF
      ::display()

      DispEnd()
      MSetCursor( nOldMCur )

      SetCursor( ::nCursor )
   ENDIF

   RETURN Self
listbox.prg532
LISTBOX:METHODnextItem() CLASS LISTBOX
METHOD nextItem() CLASS LISTBOX

   LOCAL nOldValue

   IF ::lHasFocus .AND. ::nItemCount > 0
      ::changeItem( nOldValue := ::nValue, iif( nOldValue == ::nItemCount, nOldValue, nOldValue + 1 ) )
   ENDIF

   RETURN Self
listbox.prg558
LISTBOX:METHODopen() CLASS LISTBOX
METHOD open() CLASS LISTBOX

   IF ! ::lIsOpen

      ::aSaveScr := { ::nTop + 1,;
                      ::nLeft,;
                      ::nBottom,;
                      ::nRight,;
                      Savescreen( ::nTop + 1, ::nLeft, ::nBottom, ::nRight ) }
      ::lIsOpen := .T.
      ::display()
   ENDIF

   RETURN Self
listbox.prg568
LISTBOX:METHODprevItem() CLASS LISTBOX
METHOD prevItem() CLASS LISTBOX

   LOCAL nOldValue

   IF ::lHasFocus .AND. ::nItemCount > 0

      IF ( nOldValue := ::nValue ) == 0
         ::changeItem( nOldValue, 1 )
      ELSEIF nOldValue > 1
         ::changeItem( nOldValue, nOldValue - 1 )
      ENDIF
   ENDIF

   RETURN Self
listbox.prg583
LISTBOX:METHODscroll( nMethod ) CLASS LISTBOX
METHOD scroll( nMethod ) CLASS LISTBOX

   LOCAL nPos
   LOCAL nTopItem
   LOCAL nItemCount
   LOCAL nThumbPos
   LOCAL nCurrent
   LOCAL nBarLength
   LOCAL nTotal
   LOCAL nSize
   LOCAL nMRow
   LOCAL nPrevMRow
   LOCAL nKey
   LOCAL nCount

   DO CASE
   CASE nMethod == HTSCROLLTHUMBDRAG

      nPrevMRow := MRow()

      DO WHILE ( ( nKey := Inkey( 0 ) ) != K_LBUTTONUP )

         IF nKey == K_MOUSEMOVE

            nMRow := MRow()

            IF nMRow <= ::oVScroll:start()
               nMRow := ::oVScroll:start() + 1
            ENDIF
            IF nMRow >= ::oVScroll:end()
               nMRow := ::oVScroll:end() - 1
            ENDIF

            IF nMRow != nPrevMRow
               nThumbPos  := ::oVScroll:thumbPos() + ( nMRow - nPrevMRow )
               nBarLength := ::oVScroll:barLength()
               nTotal     := ::oVScroll:total()
               nSize      := Min( Max( ( nThumbPos * ( nTotal - nBarLength - 2 ) + 2 * nBarLength + 1 - nTotal ) / ( nBarLength - 1 ), 1 ), nTotal )
               nCurrent   := ::oVScroll:current()
               IF nSize - nCurrent > 0
                  FOR nCount := 1 TO nSize - nCurrent
                     ::scroll( HTSCROLLUNITINC )
                  NEXT
               ELSE
                  FOR nCount := 1 TO nCurrent - nSize
                     ::scroll( HTSCROLLUNITDEC )
                  NEXT
               ENDIF

               nPrevMRow := nMRow
            ENDIF
         ENDIF
      ENDDO

   CASE nMethod == HTSCROLLUNITDEC

      IF ::nTopItem > 1
         ::nTopItem--
         ::oVScroll:current := ::scrollbarPos()
         ::display()
      ENDIF

   CASE nMethod == HTSCROLLUNITINC

      IF ( ::nTopItem + ::nBottom - ::nTop ) <= ::nItemCount + 1
         ::nTopItem++
         ::oVScroll:current := ::scrollbarPos()
         ::display()
      ENDIF

   CASE nMethod == HTSCROLLBLOCKDEC

      nPos     := ::nBottom - ::nTop - iif( ::lDropDown, 2, 1 )
      nTopItem := ::nTopItem - nPos
      IF ::nTopItem > 1
         ::nTopItem := Max( nTopItem, 1 )
         ::oVScroll:current := ::scrollbarPos()
         ::display()
      ENDIF

   CASE nMethod == HTSCROLLBLOCKINC

      nPos       := ::nBottom - ::nTop - 1
      nItemCount := ::nItemCount
      nTopItem   := ::nTopItem + nPos
      IF ::nTopItem < nItemCount - nPos + 1
         IF nTopItem + nPos - 1 > nItemCount
            nTopItem := nItemCount - nPos + 1
         ENDIF
         ::nTopItem := nTopItem
         ::oVScroll:current := ::scrollbarPos()
         ::display()
      ENDIF

   ENDCASE

   RETURN Self
listbox.prg598
LISTBOX:METHODselect( xPos ) CLASS LISTBOX
METHOD select( xPos ) CLASS LISTBOX

   LOCAL nValue
   LOCAL nPos
   LOCAL cType := Valtype( xPos )

   DO CASE
   CASE cType == "C"
      nPos := ::findData( xPos )
      IF !( Valtype( ::xBuffer ) $ "CU" )
         ::xBuffer := nPos
      ELSEIF ::nValue == 0
         ::xBuffer := xPos
      ELSE
         ::xBuffer := _LISTBOX_ITEMDATA( ::aItems[ nPos ] )
      ENDIF
   CASE !( cType == "N" )
      RETURN ::nValue
   CASE xPos < 1
      RETURN ::nValue
   CASE xPos > ::nItemCount
      RETURN ::nValue
   CASE xPos == ::nValue
      RETURN ::nValue
   OTHERWISE
      nPos := xPos
      IF Valtype( ::xBuffer ) $ "NU"
         ::xBuffer := nPos
      ELSEIF nPos == 0
         ::xBuffer := ""
      ELSE
         ::xBuffer := _LISTBOX_ITEMDATA( ::aItems[ nPos ] )
      ENDIF
   ENDCASE
   ::nValue := nPos

   ::cTextValue := iif( nPos == 0, "", _LISTBOX_ITEMDATA( ::aItems[ nPos ] ) )

   nPos := iif( Empty( ::cHotBox + ::cColdBox ), 0, 2 )

   nValue := ::nValue - ( ::nBottom - ::nTop - nPos )
   IF ::nTopItem <= nValue
      ::nTopItem := nValue
      IF ::oVScroll != NIL
         ::oVScroll:current := ::scrollbarPos()
      ENDIF
   ELSEIF ::nValue != 0 .AND. ::nTopItem > ::nValue
      ::nTopItem := ::nValue
      IF ::oVScroll != NIL
         ::oVScroll:current := ::scrollbarPos()
      ENDIF
   ENDIF

   ::display()

   IF ISBLOCK( ::bSBlock )
      Eval( ::bSBlock )
   ENDIF

   RETURN ::nValue
listbox.prg696
LISTBOX:METHODsetData( nPos, cData ) CLASS LISTBOX
METHOD setData( nPos, cData ) CLASS LISTBOX

   IF nPos >= 1 .AND. nPos <= ::nItemCount
      ::aItems[ nPos ][ _ITEM_cDATA ] := cData
   ENDIF

   RETURN Self
listbox.prg757
LISTBOX:METHODsetFocus() CLASS LISTBOX
METHOD setFocus() CLASS LISTBOX

   IF ! ::lHasFocus

      ::nCursor := SetCursor( SC_NONE )
      ::lHasFocus := .T.

      ::display()

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF

   ENDIF

   RETURN Self
listbox.prg765
LISTBOX:METHODsetItem( nPos, aItem ) CLASS LISTBOX
METHOD setItem( nPos, aItem ) CLASS LISTBOX

   IF nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;
      Len( aItem ) == 2 .AND. ;
      ISCHARACTER( aItem[ _ITEM_cTEXT ] )

      ::aItems[ nPos ] := aItem
   ENDIF

   RETURN Self
listbox.prg782
LISTBOX:METHODsetText( nPos, cText ) CLASS LISTBOX
METHOD setText( nPos, cText ) CLASS LISTBOX

   IF nPos >= 1 .AND. nPos <= ::nItemCount
      ::aItems[ nPos ][ _ITEM_cTEXT ] := cText
   ENDIF

   RETURN Self
listbox.prg793
LISTBOX:METHODchangeItem( nOldPos, nNewPos ) CLASS LISTBOX
METHOD changeItem( nOldPos, nNewPos ) CLASS LISTBOX

   LOCAL nValue

   IF nOldPos != nNewPos

      ::nValue := nNewPos
      ::cTextValue := iif( ::nValue == 0, "", _LISTBOX_ITEMDATA( ::aItems[ ::nValue ] ) )

      IF ::xBuffer == NIL
      ELSEIF ISNUMBER( ::xBuffer )
         ::xBuffer := ::nValue
      ELSEIF ::nValue > 0
         ::xBuffer := ::cTextValue
      ENDIF

      IF ::nTopItem > ::nValue
         ::nTopItem := ::nValue
         IF ::oVScroll != NIL
            ::oVScroll:current := ::scrollbarPos()
         ENDIF
      ELSE
         nValue := ::nValue - ( ::nBottom - ::nTop - iif( Empty( ::cHotBox + ::cColdBox ), 0, 2 ) + iif( ::lDropDown, 1, 0 ) )

         IF ::nTopItem <= nValue
            ::nTopItem := nValue
            IF ::oVScroll != NIL
               ::oVScroll:current := ::scrollbarPos()
            ENDIF
         ENDIF
      ENDIF

      ::display()

      IF ISBLOCK( ::bSBlock )
         Eval( ::bSBlock )
      ENDIF
   ENDIF

   RETURN Self
listbox.prg803
LISTBOX:METHODscrollbarPos() CLASS LISTBOX
METHOD scrollbarPos() CLASS LISTBOX

   LOCAL nSize     := ::nBottom - ::nTop - iif( ::lDropDown, 2, 1 )
   LOCAL nCount    := ::nItemCount
   LOCAL nLength   := ::oVScroll:barLength

   RETURN ( ( nCount - nLength ) * ::nTopItem + nLength - nSize ) / ( nCount - nSize )
listbox.prg844
LISTBOX:METHODbitmap( cBitmap ) CLASS LISTBOX
METHOD bitmap( cBitmap ) CLASS LISTBOX

   IF cBitmap != NIL .AND. ::lDropDown
      ::cBitmap := __eInstVar53( Self, "BITMAP", cBitmap, "C", 1001 )
   ENDIF

   RETURN ::cBitmap
listbox.prg854
LISTBOX:METHODbottom( nBottom ) CLASS LISTBOX
METHOD bottom( nBottom ) CLASS LISTBOX

   IF nBottom != NIL
      ::nBottom := __eInstVar53( Self, "BOTTOM", nBottom, "N", 1001 )
      IF ::oVScroll != NIL
         ::oVScroll:end := ::nBottom - 1
      ENDIF
   ENDIF

   RETURN ::nBottom
listbox.prg862
LISTBOX:METHODbuffer() CLASS LISTBOX
METHOD buffer() CLASS LISTBOX
   RETURN ::xBuffer
listbox.prg873
LISTBOX:METHODcapCol( nCapCol ) CLASS LISTBOX
METHOD capCol( nCapCol ) CLASS LISTBOX

   IF nCapCol != NIL
      ::nCapCol := __eInstVar53( Self, "CAPCOL", nCapCol, "N", 1001 )
   ENDIF

   RETURN ::nCapCol
listbox.prg876
LISTBOX:METHODcapRow( nCapRow ) CLASS LISTBOX
METHOD capRow( nCapRow ) CLASS LISTBOX

   IF nCapRow != NIL
      ::nCapRow := __eInstVar53( Self, "CAPROW", nCapRow, "N", 1001 )
   ENDIF

   RETURN ::nCapRow
listbox.prg884
LISTBOX:METHODcaption( cCaption ) CLASS LISTBOX
METHOD caption( cCaption ) CLASS LISTBOX

   IF cCaption != NIL
      ::cCaption := __eInstVar53( Self, "CAPTION", cCaption, "C", 1001 )
      IF ::nCapCol == NIL
         ::nCapRow := ::nTop
         ::nCapCol := ::nLeft - Len( ::cCaption )
      ENDIF
   ENDIF

   RETURN ::cCaption
listbox.prg892
LISTBOX:METHODcoldBox( cColdBox ) CLASS LISTBOX
METHOD coldBox( cColdBox ) CLASS LISTBOX

   IF cColdBox != NIL
      ::cColdBox := __eInstVar53( Self, "COLDBOX", cColdBox, "C", 1001, {|| Len( cColdBox ) == 0 .OR. Len( cColdBox ) == 8 } )
   ENDIF

   RETURN ::cColdBox
listbox.prg904
LISTBOX:METHODcolorSpec( cColorSpec ) CLASS LISTBOX
METHOD colorSpec( cColorSpec ) CLASS LISTBOX

   IF cColorSpec != NIL
      ::cColorSpec := __eInstVar53( Self, "COLORSPEC", cColorSpec, "C", 1001,;
         iif( ::lDropDown,;
            {|| !Empty( hb_ColorIndex( cColorSpec, 7 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 8 ) ) },;
            {|| !Empty( hb_ColorIndex( cColorSpec, 6 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 7 ) ) } ) )
   ENDIF

   RETURN ::cColorSpec
listbox.prg912
LISTBOX:METHODdropDown( lDropDown ) CLASS LISTBOX
METHOD dropDown( lDropDown ) CLASS LISTBOX

   IF lDropDown != NIL

      ::lDropDown := __eInstVar53( Self, "DROPDOWN", lDropDown, "L", 1001 )

      IF !::lDropDown .AND. !::lIsOpen
         ::lIsOpen := .T.
      ENDIF

      ::display()
   ENDIF

   RETURN ::lDropDown
listbox.prg923
LISTBOX:METHODfBlock( bFBlock ) CLASS LISTBOX
METHOD fBlock( bFBlock ) CLASS LISTBOX
   
   IF PCount() > 0
      ::bFBlock := iif( bFBlock == NIL, NIL, __eInstVar53( Self, "FBLOCK", bFBlock, "B", 1001 ) )
   ENDIF

   RETURN ::bFBlock
listbox.prg938
LISTBOX:METHODhasFocus() CLASS LISTBOX
METHOD hasFocus() CLASS LISTBOX
   RETURN ::lHasFocus
listbox.prg946
LISTBOX:METHODhotBox( cHotBox ) CLASS LISTBOX
METHOD hotBox( cHotBox ) CLASS LISTBOX

   IF cHotBox != NIL
      ::cHotBox := __eInstVar53( Self, "HOTBOX", cHotBox, "C", 1001, {|| Len( cHotBox ) == 0 .OR. Len( cHotBox ) == 8 } )
   ENDIF

   RETURN ::cHotBox
listbox.prg949
LISTBOX:METHODisOpen() CLASS LISTBOX
METHOD isOpen() CLASS LISTBOX
   RETURN ::lIsOpen
listbox.prg957
LISTBOX:METHODitemCount() CLASS LISTBOX
METHOD itemCount() CLASS LISTBOX
   RETURN ::nItemCount
listbox.prg960
LISTBOX:METHODleft( nLeft ) CLASS LISTBOX
METHOD left( nLeft ) CLASS LISTBOX

   IF nLeft != NIL
      ::nLeft := __eInstVar53( Self, "LEFT", nLeft, "N", 1001 )
   ENDIF

   RETURN ::nLeft
listbox.prg963
LISTBOX:METHODmessage( cMessage ) CLASS LISTBOX
METHOD message( cMessage ) CLASS LISTBOX

   IF cMessage != NIL
      ::cMessage := __eInstVar53( Self, "MESSAGE", cMessage, "C", 1001 )
   ENDIF

   RETURN ::cMessage
listbox.prg971
LISTBOX:METHODright( nRight ) CLASS LISTBOX
METHOD right( nRight ) CLASS LISTBOX

   IF nRight != NIL
      ::nRight := __eInstVar53( Self, "RIGHT", nRight, "N", 1001 )
      IF ::oVScroll != NIL
         ::oVScroll:offset := ::nRight
      ENDIF
   ENDIF

   RETURN ::nRight
listbox.prg979
LISTBOX:METHODsBlock( bSBlock ) CLASS LISTBOX
METHOD sBlock( bSBlock ) CLASS LISTBOX
   
   IF PCount() > 0
      ::bSBlock := iif( bSBlock == NIL, NIL, __eInstVar53( Self, "SBLOCK", bSBlock, "B", 1001 ) )
   ENDIF

   RETURN ::bSBlock
listbox.prg990
LISTBOX:METHODstyle( cStyle ) CLASS LISTBOX
METHOD style( cStyle ) CLASS LISTBOX

   IF cStyle != NIL
      ::cStyle := __eInstVar53( Self, "STYLE", cStyle, "C", 1001, {|| Len( cStyle ) == 1 } )
   ENDIF

   RETURN ::cStyle
listbox.prg998
LISTBOX:METHODtextValue() CLASS LISTBOX
METHOD textValue() CLASS LISTBOX
   RETURN ::cTextValue
listbox.prg1006
LISTBOX:METHODtop( nTop ) CLASS LISTBOX
METHOD top( nTop ) CLASS LISTBOX

   IF nTop != NIL
      ::nTop := __eInstVar53( Self, "TOP", nTop, "N", 1001 )
      IF ::oVScroll != NIL
         ::oVScroll:start := ::nTop + 1
      ENDIF
   ENDIF

   RETURN ::nTop
listbox.prg1009
LISTBOX:METHODtopItem( nTopItem ) CLASS LISTBOX
METHOD topItem( nTopItem ) CLASS LISTBOX

   IF nTopItem != NIL

      __eInstVar53( Self, "TOPITEM", nTopItem, "N", 1001, {|| nTopItem > 0 .AND. nTopItem <= ::nItemCount } )

      nTopItem := Min( nTopItem, ::nItemCount - ( ::nBottom - ::nTop - iif( Empty( ::cHotBox + ::cColdBox ), 0, 2 ) ) )

      IF ::nTopItem != nTopItem
         ::nTopItem := nTopItem

         IF ::oVScroll != NIL
            ::oVScroll:current := ::scrollbarPos()
         ENDIF

         ::display()
      ENDIF
   ENDIF

   RETURN ::nTopItem
listbox.prg1020
LISTBOX:METHODtypeOut() CLASS LISTBOX
METHOD typeOut() CLASS LISTBOX
   RETURN ::nItemCount == 0
listbox.prg1041
LISTBOX:METHODvalue() CLASS LISTBOX
METHOD value() CLASS LISTBOX
   RETURN ::nValue
listbox.prg1044
LISTBOX:METHODvScroll( oVScroll ) CLASS LISTBOX
METHOD vScroll( oVScroll ) CLASS LISTBOX

   IF PCount() > 0
      IF oVScroll == NIL
         ::oVScroll := NIL
      ELSE
         ::oVScroll := __eInstVar53( Self, "VSCROLL", oVScroll, "O", 1001, {|| oVScroll:ClassName() == "SCROLLBAR" .AND. oVScroll:orient == SCROLL_VERTICAL } )
         ::oVScroll:total := ::nItemCount
      ENDIF
   ENDIF

   RETURN ::oVScroll
listbox.prg1047
LISTBOX:METHODNew( nTop, nLeft, nBottom, nRight, lDropDown )
METHOD New( nTop, nLeft, nBottom, nRight, lDropDown )

   LOCAL cColor

   IF !ISNUMBER( nTop ) .OR. ;
      !ISNUMBER( nLeft ) .OR. ;
      !ISNUMBER( nBottom ) .OR. ;
      !ISNUMBER( nRight )
      RETURN NIL
   ENDIF

   DEFAULT lDropDown TO .F.

   ::nBottom   := nBottom
   ::nRight    := nRight
   ::nTop      := nTop
   ::nLeft     := nLeft
   ::nCapCol   := nLeft
   ::nCapRow   := nTop
   ::lIsOpen   := !lDropDown
   ::lDropDown := lDropDown
   ::aSaveScr  := { nTop + 1, nleft, nBottom, nRight, SaveScreen( nTop + 1, nLeft, nBottom, nRight ) }

   IF IsDefColor()
      ::cColorSpec := "W/N,W+/N,W+/N,N/W,W/N,W/N,W+/N,W/N"
   ELSE
      cColor := SetColor()
      ::cColorSpec := hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," +;
                      hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," +;
                      hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," +;
                      hb_ColorIndex( cColor, CLR_ENHANCED   ) + "," +;
                      hb_ColorIndex( cColor, CLR_BORDER     ) + "," +;
                      hb_ColorIndex( cColor, CLR_STANDARD   ) + "," +;
                      hb_ColorIndex( cColor, CLR_BACKGROUND )
   ENDIF

   RETURN Self
listbox.prg1062
FUNCTIONListBox( nTop, nLeft, nBottom, nRight, lDropDown )
FUNCTION ListBox( nTop, nLeft, nBottom, nRight, lDropDown )
   RETURN HBListBox():New( nTop, nLeft, nBottom, nRight, lDropDown )
listbox.prg1100
FUNCTION_LISTBOX_( nTop, nLeft, nBottom, nRight, nSelect, aItems, cCaption, cMessage, cColorSpec, bFBlock, bSBlock, lDropDown, lIsOpen, cBitmap )
FUNCTION _LISTBOX_( nTop, nLeft, nBottom, nRight, nSelect, aItems, cCaption,;
                    cMessage, cColorSpec, bFBlock, bSBlock, lDropDown, lIsOpen, cBitmap )

   LOCAL o := HBListBox():New( nTop, nLeft, nBottom, nRight, lDropDown )

   LOCAL nPos
   LOCAL nLen
   LOCAL xItem

   IF o != NIL

      IF ISCHARACTER( cCaption )
         o:caption := cCaption
         o:capCol  := nLeft - __CapLength( cCaption )
      ENDIF

      o:colorSpec := cColorSpec
      o:message   := cMessage
      o:fBlock    := bFBlock
      o:sBlock    := bSBlock
      o:isOpen    := lIsOpen

      nLen := Len( aItems )
      FOR nPos := 1 TO nLen

         xItem := aItems[ nPos ]

         IF ! ISARRAY( xItem )
            o:addItem( xItem )
         ELSEIF Len( xItem ) == _ITEM_cTEXT
            o:addItem( xItem[ _ITEM_cTEXT ] )
         ELSE
            o:addItem( xItem[ _ITEM_cTEXT ], xItem[ _ITEM_cDATA ] )
         ENDIF
      NEXT

      IF ISLOGICAL( lIsOpen ) .AND. lIsOpen
         IF ISLOGICAL( lDropDown ) .AND. lDropDown
            nTop++
         ENDIF
         o:VScroll := ScrollBar( nTop + 1, nBottom - 1, nRight,, SCROLL_VERTICAL )
      ENDIF

      IF ISCHARACTER( cBitmap )
         o:bitmap := cBitmap
      ENDIF

      o:select( nSelect )
   ENDIF

   RETURN o
listbox.prg1103
memoedit.prg
TypeFunctionSourceLine
METHODMemoInit( xUserFunction )
   METHOD MemoInit( xUserFunction )       // This method is called after ::New() returns to perform ME_INIT actions
memoedit.prg64
METHODEdit()
   METHOD Edit()                          // Calls super:Edit( nKey ) but is needed to handle configurable keys
memoedit.prg65
METHODKeyboardHook( nKey )
   METHOD KeyboardHook( nKey )            // Gets called every time there is a key not handled directly by HBEditor
memoedit.prg66
METHODIdleHook()
   METHOD IdleHook()                      // Gets called every time there are no more keys to hanlde
memoedit.prg67
METHODHandleUserKey( nKey, nUserKey )
   METHOD HandleUserKey( nKey, nUserKey ) // Handles keys returned to MemoEdit() by user function
memoedit.prg69
METHODxDo( nStatus )
   METHOD xDo( nStatus )                  // Calls xUserFunction saving and restoring cursor position and shape
memoedit.prg70
METHODMoveCursor( nKey )
   METHOD MoveCursor( nKey )              // Redefined to properly managed CTRL-W

ENDCLASS
memoedit.prg72
HBMEMOEDITOR:METHODMemoInit( xUserFunction ) CLASS HBMemoEditor
METHOD MemoInit( xUserFunction ) CLASS HBMemoEditor

   LOCAL nKey

   // Save/Init object internal representation of user function
   ::xUserFunction := xUserFunction

   IF ISCHARACTER( ::xUserFunction )
      // Keep calling user function until it returns ME_DEFAULT
      DO WHILE ( nKey := ::xDo( ME_INIT ) ) != ME_DEFAULT

         // At this time there is no input from user of MemoEdit() only handling
         // of values returned by ::xUserFunction, so I pass these value on both
         // parameters of ::HandleUserKey()
         ::HandleUserKey( nKey, nKey )

      ENDDO

   ENDIF

   RETURN Self
memoedit.prg76
HBMEMOEDITOR:METHODEdit() CLASS HBMemoEditor
METHOD Edit() CLASS HBMemoEditor

   LOCAL nKey

   // NOTE: K_ALT_W is not compatible with clipper exit memo and save key, but I cannot discriminate
   //       K_CTRL_W and K_CTRL_END from harbour code.
   LOCAL aConfigurableKeys := { K_CTRL_Y, K_CTRL_T, K_CTRL_B, K_CTRL_V, K_ALT_W, K_ESC }
   LOCAL bKeyBlock

   // If I have an user function I need to trap configurable keys and ask to
   // user function if handle them the standard way or not
   IF ::lEditAllow .AND. ISCHARACTER( ::xUserFunction )

      DO WHILE ! ::lExitEdit

         // I need to test this condition here since I never block inside HBEditor:Edit()
         // if there is an user function
         IF NextKey() == 0
            ::IdleHook()
         ENDIF

         nKey := Inkey( 0 )

         IF ( bKeyBlock := SetKey( nKey ) ) != NIL
            Eval( bKeyBlock )
            LOOP
         ENDIF

         // Is it a configurable key ?
         IF AScan( aConfigurableKeys, nKey ) > 0
            ::HandleUserKey( nKey, ::xDo( iif( ::lDirty, ME_UNKEYX, ME_UNKEY ) ) )
         ELSE
            ::super:Edit( nKey )
         ENDIF
      ENDDO
   ELSE
      // If I can't edit text buffer or there is not a user function enter standard HBEditor
      // ::Edit() method which is able to handle everything
      ::super:Edit()
   ENDIF

   RETURN Self
memoedit.prg98
HBMEMOEDITOR:METHODKeyboardHook( nKey ) CLASS HBMemoEditor
METHOD KeyboardHook( nKey ) CLASS HBMemoEditor

   LOCAL nYesNoKey
   LOCAL cBackScr
   LOCAL nRow
   LOCAL nCol

   IF ISCHARACTER( ::xUserFunction )
      ::HandleUserKey( nKey, ::xDo( iif( ::lDirty, ME_UNKEYX, ME_UNKEY ) ) )
   ELSE
      IF nKey == K_ESC
         IF ::lDirty .AND. Set( _SET_SCOREBOARD )
            cBackScr := SaveScreen( ::nTop, ::nRight - 18, ::nTop, ::nRight )
            
            nRow := Row()
            nCol := Col()
            @ ::nTop, ::nRight - 18 SAY "Abort Edit? (Y/N)"
            
            nYesNoKey := Inkey( 0 )
            
            RestScreen( ::nTop, ::nRight - 18, ::nTop, ::nRight, cBackScr )
            SetPos( nRow, nCol )
            
            IF Upper( Chr( nYesNoKey ) ) == "Y"
               ::lSaved := .F.
               ::lExitEdit := .T.
            ENDIF
         ELSE
            ::lExitEdit := .T.
         ENDIF
      ENDIF
   ENDIF

   RETURN Self
memoedit.prg143
HBMEMOEDITOR:METHODIdleHook() CLASS HBMemoEditor
METHOD IdleHook() CLASS HBMemoEditor

   IF ISCHARACTER( ::xUserFunction )
      ::xDo( ME_IDLE )
   ENDIF

   RETURN Self
memoedit.prg178
HBMEMOEDITOR:METHODHandleUserKey( nKey, nUserKey ) CLASS HBMemoEditor
METHOD HandleUserKey( nKey, nUserKey ) CLASS HBMemoEditor

   // HBEditor does not handle these keys and would call ::KeyboardHook() causing infinite loop
   LOCAL aUnHandledKeys := { K_CTRL_J, K_CTRL_K, K_CTRL_L, K_CTRL_N, K_CTRL_O,;
                             K_CTRL_P, K_CTRL_Q, K_CTRL_T, K_CTRL_U, K_F1 }

   DO CASE
   // I won't reach this point during ME_INIT since ME_DEFAULT ends initialization phase of MemoEdit()
   CASE nUserKey == ME_DEFAULT

      // HBEditor is not able to handle keys with a value higher than 256, but I have to tell him
      // that user wants to save text
      IF ( nKey <= 256 .OR. nKey == K_ALT_W ) .AND. AScan( aUnHandledKeys, nKey ) == 0
         ::super:Edit( nKey )
      ENDIF

   // TOFIX: Not clipper compatible, see teditor.prg
   CASE ( nUserKey >= 1 .AND. nUserKey <= 31 ) .OR. nUserKey == K_ALT_W
      IF AScan( aUnHandledKeys, nUserKey ) == 0
         ::super:Edit( nUserKey )
      ENDIF

   CASE nUserKey == ME_DATA
      IF nKey <= 256 .AND. AScan( aUnHandledKeys, nKey ) == 0
         ::super:Edit( nKey )
      ENDIF

   CASE nUserKey == ME_TOGGLEWRAP
      ::lWordWrap := !::lWordWrap

   CASE nUserKey == ME_TOGGLESCROLL
      // TODO: HBEditor does not support vertical scrolling of text inside window without moving cursor position

   CASE nUserKey == ME_WORDRIGHT
      ::MoveCursor( K_CTRL_RIGHT )

   CASE nUserKey == ME_BOTTOMRIGHT
      ::MoveCursor( K_CTRL_END )

#ifdef HB_COMPAT_XPP
   CASE nUserKey == ME_PASTE
      // TODO
#endif

   OTHERWISE
      // Do nothing
   ENDCASE

   RETURN Self
memoedit.prg186
HBMEMOEDITOR:METHODxDo( nStatus ) CLASS HBMemoEditor
METHOD xDo( nStatus ) CLASS HBMemoEditor

   LOCAL nOldRow := ::Row()
   LOCAL nOldCol := ::Col()
   LOCAL nOldCur := SetCursor()
   
   LOCAL xResult := Do( ::xUserFunction, nStatus, ::nRow, ::nCol - 1 )

   IF ! ISNUMBER( xResult )
      xResult := ME_DEFAULT
   ENDIF

   ::SetPos( nOldRow, nOldCol )
   SetCursor( nOldCur )

   RETURN xResult
memoedit.prg236
HBMEMOEDITOR:METHODMoveCursor( nKey ) CLASS HBMemoEditor
METHOD MoveCursor( nKey ) CLASS HBMemoEditor

   IF nKey == K_CTRL_END // same value as CTRL-W
      ::lSaved := .T.
      ::lExitEdit := .T.
   ELSE
      RETURN ::Super:MoveCursor( nKey )
   ENDIF

   RETURN .f.
memoedit.prg253
FUNCTIONMemoEdit( cString, nTop, nLeft, nBottom, nRight, lEditMode, xUserFunction, nLineLength, nTabSize, nTextBuffRow, nTextBuffColumn, nWindowRow, nWindowColumn )
FUNCTION MemoEdit( cString,;
                   nTop,;
                   nLeft,;
                   nBottom,;
                   nRight,;
                   lEditMode,;
                   xUserFunction,;
                   nLineLength,;
                   nTabSize,;
                   nTextBuffRow,;
                   nTextBuffColumn,;
                   nWindowRow,;
                   nWindowColumn )

   LOCAL oEd

   DEFAULT nTop            TO 0
   DEFAULT nLeft           TO 0
   DEFAULT nBottom         TO MaxRow()
   DEFAULT nRight          TO MaxCol()
   DEFAULT lEditMode       TO .T.
   DEFAULT nLineLength     TO nRight - nLeft
   DEFAULT nTabSize        TO 4
   DEFAULT nTextBuffRow    TO 1
   DEFAULT nTextBuffColumn TO 0
   DEFAULT nWindowRow      TO 0
   DEFAULT nWindowColumn   TO nTextBuffColumn
   DEFAULT cString         TO ""

   // Original MemoEdit() converts Tabs into spaces;
   oEd := HBMemoEditor():New( StrTran( cString, Chr( K_TAB ), Space( 1 ) ), nTop, nLeft, nBottom, nRight, lEditMode, nLineLength, nTabSize, nTextBuffRow, nTextBuffColumn, nWindowRow, nWindowColumn )
   oEd:MemoInit( xUserFunction )
   oEd:display()

   IF ! ISLOGICAL( xUserFunction ) .OR. xUserFunction == .T.
      oEd:Edit()
      IF oEd:Changed()
         cString := oEd:GetText()
         // dbu tests for LastKey() == K_CTRL_END, so I try to make it happy
         HB_SetLastKey( K_CTRL_END )
      ENDIF
   ENDIF

   RETURN cString
memoedit.prg266
memvarbl.prg
TypeFunctionSourceLine
FUNCTIONMEMVARBLOCK( cMemvar )
FUNCTION MEMVARBLOCK( cMemvar )

   IF ISCHARACTER( cMemvar ) .AND. __mvEXIST( cMemvar )
      RETURN {| x | iif( x == NIL, __mvGET( cMemvar ), __mvPUT( cMemvar, x ) ) }
   ENDIF

   RETURN NIL
memvarbl.prg57
menusys.prg
TypeFunctionSourceLine
FUNCTIONMenuModal( oTopMenu, nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )
FUNCTION MenuModal( oTopMenu, nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )
   RETURN HBMenuSys():New( oTopMenu ):modal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )
menusys.prg66
FUNCTIONShowMsg( aMsg, lMode )
FUNCTION ShowMsg( aMsg, lMode )

   HB_SYMBOL_UNUSED( aMsg )
   HB_SYMBOL_UNUSED( lMode )

   RETURN .F.
menusys.prg70
FUNCTIONIsShortCut( oMenu, nKey, nID )
FUNCTION IsShortCut( oMenu, nKey, nID )
   LOCAL nItem
   LOCAL nTotal
   LOCAL nShortCut
   LOCAL oItem
   LOCAL i

   // Test for top menu item not a TopBar Menu:
   IF !( oMenu:ClassName() == "TOPBARMENU" )

      RETURN IsQuick( oMenu, nKey, @nID )

   // Test and assign top menu item shortCut, enabled, and !PopUp:
   // Changed by enclosing assignment before ':Enabled':
   ELSEIF ( nShortCut := oMenu:getShortCt( nKey ) ) > 0 .AND. ;
          ( oItem := oMenu:getItem( nShortcut ) ):enabled .AND. ;
          !oItem:isPopUp()

      oMenu:select( nShortCut )
      Eval( oItem:data, oItem )
      nID := oItem:ID

      RETURN .T.

   // Test and assignment for TopBar MenuItem:
   ELSEIF nShortCut == 0

      nTotal := oMenu:itemCount
      nItem  := oMenu:current

      IF nItem == 0
         nItem := 1
      ENDIF

      // Loop to wrap around through TopMenu from Current Item:
      FOR i := 1 TO nTotal

         IF ( oItem := oMenu:getItem( nItem ) ):enabled .AND. ;
            oItem:isPopUp() .AND. ;
            IsQuick( oItem:data, nKey, @nID )

            RETURN .T.
         ENDIF

         IF ++nItem > nTotal
            nItem := 1
         ENDIF
      NEXT

   ENDIF

   RETURN .F.
menusys.prg82
FUNCTIONIsQuick( oMenu, nKey, nID )
FUNCTION IsQuick( oMenu, nKey, nID )
   LOCAL nItem
   LOCAL nTotal
   LOCAL nShortCut
   LOCAL oItem

   IF ( nShortCut := oMenu:getShortCt( nKey ) ) == 0

      nTotal := oMenu:itemCount

      FOR nItem := 1 TO nTotal

         IF ( oItem := oMenu:getItem( nItem ) ):enabled .AND. ;
            oItem:isPopUp() .AND. ;
            IsQuick( oItem:data, nKey, @nID )

            RETURN .T.
         ENDIF
      NEXT

   ELSEIF !( oItem := oMenu:getItem( nShortCut ) ):isPopUp() .AND. oItem:enabled

      oMenu:select( nShortCut )
      Eval( oItem:data, oItem )
      nID := oItem:ID

      RETURN .T.

   ENDIF

   RETURN .F.
menusys.prg141
menuto.prg
TypeFunctionSourceLine
FUNCTION__AtPrompt( nRow, nCol, cPrompt, cMsg, cColor )
FUNCTION __AtPrompt( nRow, nCol, cPrompt, cMsg, cColor )

   IF s_nPointer < 1
      s_nPointer := 1
   ENDIF

   // add the current level empty array.
   DO WHILE Len( s_aLevel ) < s_nPointer
      AAdd( s_aLevel, {} )
   ENDDO

   // add to the static array
   AAdd( s_aLevel[ s_nPointer ], { nRow, nCol, cPrompt, cMsg, cColor } )

   // put this prompt on the screen right now
   DispOutAt( nRow, nCol, cPrompt, cColor )

   RETURN .F.
menuto.prg27
FUNCTION__MenuTo( bBlock, cVariable )
FUNCTION __MenuTo( bBlock, cVariable )

   LOCAL nKey
   LOCAL y
   LOCAL q
   LOCAL n
   LOCAL lExit
   LOCAL nArrLen
   LOCAL xMsg
   LOCAL nMsgCol
   LOCAL nMsgRow
   LOCAL lMsgCenter
   LOCAL nSaveCursor
   LOCAL cSaveReadVar

   LOCAL lDeclared
   LOCAL bAction
#ifdef HB_COMPAT_C53
   LOCAL nMouseClik
#endif

   LOCAL nPointer
   LOCAL aColor
   LOCAL cBackColor
   LOCAL cFrontColor

   // Detect if a memvar was passed
   lDeclared := !__mvEXIST( cVariable )
   IF lDeclared
      __mvPUBLIC( cVariable )
   ENDIF

   n := Eval( bBlock )

   // if no prompts were defined, exit with 0

   IF s_nPointer < 1 .OR. s_nPointer > Len( s_aLevel )

      n := 0

   ELSE

      s_nPointer ++
      nPointer := s_nPointer

      nArrLen := Len( s_aLevel[ nPointer - 1 ] )

      // put choice in a valid range

      IF !ISNUMBER( n ) .OR. n < 1
         n := 1
      ENDIF

      IF n > nArrLen
         n := nArrLen
      ENDIF

      //

      nSaveCursor := SetCursor( iif( Set( _SET_INTENSITY ), SC_NONE, NIL ) )
      cSaveReadVar := ReadVar( Upper( cVariable ) )
      xMsg := ""
      nMsgCol := 0
      nMsgRow := Set( _SET_MESSAGE )
      lMsgCenter := Set( _SET_MCENTER )
      lExit := .F.


      DO WHILE n != 0

         // should we display messages?
         IF nMsgRow > 0

            IF ! Empty( xMsg )
               DispOutAt( nMsgRow, nMsgCol, Space( Len( xMsg ) ) )
            ENDIF

            xMsg := s_aLevel[ nPointer - 1, n, 4 ]

            // Code Block messages ( yes, they are documented! )
            IF ISBLOCK( xMsg )
               xMsg := Eval( xMsg )
            ENDIF

            IF !ISCHARACTER( xMsg )
               xMsg := ""
            ENDIF

            IF lMsgCenter
               nMsgCol := Int( ( MaxCol() - Len( xMsg ) ) / 2 )
            ENDIF

            DispOutAt( nMsgRow, nMsgCol, xMsg )

         ENDIF

         // save the current row
         q := n

         IF s_aLevel[ s_nPointer - 1, n, 5 ] != NIL
             aColor := COLORARRAY( s_aLevel[ s_nPointer - 1, n, 5 ] )
             cFrontColor := iif( Empty( aColor[ 1 ] ), NIL, aColor[ 1 ] )
             cBackColor  := iif( Len( aColor ) > 1, aColor[ 2 ], NIL )
         ENDIF

         IF Set( _SET_INTENSITY )
            IF cBackColor == NIL    // Only select Color Enhace if no color was passed
               ColorSelect( CLR_ENHANCED )
            ENDIF
         ENDIF

         // highlight the prompt
         DispOutAt( s_aLevel[ nPointer - 1, n, 1 ],;
                    s_aLevel[ nPointer - 1, n, 2 ],;
                    s_aLevel[ nPointer - 1, n, 3 ],;
                    cBackColor )

         IF Set( _SET_INTENSITY )
            IF cFrontColor == NIL    // Only select Color Enhace if no color was passed
              ColorSelect( CLR_STANDARD )
            ENDIF
         ENDIF

         IF lExit
            EXIT
         ENDIF

         nKey := 0
         DO WHILE nKey == 0

            // wait for a keystroke
            nKey := Inkey( 0 )

            IF ( bAction := SetKey( nKey ) ) != NIL

               Eval( bBlock, n )
               Eval( bAction, ProcName( 1 ), ProcLine( 1 ), Upper( cVariable ) )
               n := Eval( bBlock )

               IF n < 1
                  n := 1
               ELSEIF n > nArrLen
                  n := nArrLen
               ENDIF

               nKey := 0

            ENDIF
         ENDDO

         // check for keystrokes
         SWITCH nKey
#ifdef HB_COMPAT_C53
            CASE K_MOUSEMOVE
               EXIT
            CASE K_LBUTTONDOWN
            CASE K_LDBLCLK
               IF ( nMouseClik := HitTest( s_aLevel[ nPointer - 1 ], ;
                                           MRow(), MCol() ) ) > 0
                  n := nMouseClik
               ENDIF
               IF nKey == K_LDBLCLK
                   lExit := .T.
               ENDIF
               EXIT
#endif
            CASE K_DOWN
            CASE K_RIGHT
               IF ++n > nArrLen
                  n := iif( Set( _SET_WRAP ), 1, nArrLen )
               ENDIF
               EXIT
            CASE K_UP
            CASE K_LEFT
               IF --n < 1
                  n := iif( Set( _SET_WRAP ), nArrLen, 1 )
               ENDIF
               EXIT
            CASE K_HOME
               n := 1
               EXIT
            CASE K_END
               n := nArrLen
               EXIT
            CASE K_ENTER
            CASE K_PGUP
            CASE K_PGDN
               lExit := .T.
               EXIT
            CASE K_ESC
               n := 0
               EXIT
            OTHERWISE
               // did user hit a hot key?
               FOR y := 1 TO nArrLen
                  IF Upper( Left( LTrim( s_aLevel[ nPointer - 1, y, 3 ] ), 1 ) ) == Upper( Chr( nKey ) )
                     n := y
                     lExit := .T.
                     EXIT
                  ENDIF
               NEXT
         ENDSWITCH

         IF n != 0
            DispOutAt( s_aLevel[ nPointer - 1, q, 1 ],;
                       s_aLevel[ nPointer - 1, q, 2 ],;
                       s_aLevel[ nPointer - 1, q, 3 ],;
                       cFrontColor )
         ENDIF

      ENDDO

      ReadVar( cSaveReadVar )
      SetCursor( nSaveCursor )

      s_nPointer := nPointer
      s_nPointer --
      ASize( s_aLevel, s_nPointer - 1 )

   ENDIF

   Eval( bBlock, n )

   IF lDeclared
      __mvXRELEASE( cVariable )
   ENDIF

   SetPos( MaxRow() - 1, 0 )

   RETURN n
menuto.prg46
STATIC FUNCTIONHitTest( aMenu, nMRow, nMCol )
STATIC FUNCTION HitTest( aMenu, nMRow, nMCol )

   LOCAL aMenuItem

   FOR EACH aMenuItem IN aMenu
      IF nMRow == aMenuItem[ 1 ] .AND. ;
         nMCol >= aMenuItem[ 2 ] .AND. ;
         nMCol < aMenuItem[ 2 ] + LEN( aMenuItem[ 3 ] )

         RETURN aMenuItem:__enumIndex()
      ENDIF
   NEXT

   RETURN 0
menuto.prg279
objfunc.prg
TypeFunctionSourceLine
FUNCTION__objHasData( oObject, cSymbol )
FUNCTION __objHasData( oObject, cSymbol )

   IF !ISOBJECT( oObject ) .OR. !ISCHARACTER( cSymbol )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ENDIF

   RETURN __objHasMsg( oObject, cSymbol ) .AND. ;
          __objHasMsg( oObject, "_" + cSymbol )
objfunc.prg73
FUNCTION__objHasMethod( oObject, cSymbol )
FUNCTION __objHasMethod( oObject, cSymbol )

   IF !ISOBJECT( oObject ) .OR. !ISCHARACTER( cSymbol )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ENDIF

   RETURN __objHasMsg( oObject, cSymbol ) .AND. ;
          !__objHasMsg( oObject, "_" + cSymbol )
objfunc.prg82
FUNCTION__objGetMsgList( oObject, lDataMethod, nClassType )
FUNCTION __objGetMsgList( oObject, lDataMethod, nClassType )
   LOCAL aInfo
   LOCAL aData
   LOCAL n
   LOCAL nLen

   IF !ISOBJECT( oObject )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ENDIF

   IF !ISLOGICAL( lDataMethod )
      lDataMethod := .T.
   ENDIF

   IF !ISNUMBER( nClassType  )
      nClasstype  := HB_MSGLISTALL
   ENDIF

   aInfo := ASort( oObject:ClassSel(nClassType) )
   aData := {}
   n     := 1
   nLen  := Len( aInfo )

   DO WHILE n <= nLen .AND. !( Substr( aInfo[ n ], 1, 1 ) == "_" )

      /* If in range and no set function found yet ( set functions */
      /* begin with a leading underscore ).                        */

      // If found -> DATA
      //     else    METHOD

      /* Find position of matching set function in array with all symbols */

      IF ( AScan( aInfo, {| tmp | tmp == ( "_" + aInfo[ n ] ) }, n + 1 ) != 0 ) == lDataMethod
         AAdd( aData, aInfo[ n ] )
      ENDIF

      n++

   ENDDO

   RETURN aData
objfunc.prg97
FUNCTION__objGetMethodList( oObject )
FUNCTION __objGetMethodList( oObject )

   IF !ISOBJECT( oObject )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ENDIF

   RETURN __objGetMsgList( oObject, .F. )
objfunc.prg140
FUNCTION__objGetValueList( oObject, aExcept )
FUNCTION __objGetValueList( oObject, aExcept )
   LOCAL aDataSymbol
   LOCAL nLen
   LOCAL aData
   LOCAL cSymbol
   LOCAL n

   IF !ISOBJECT( oObject )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ENDIF

   IF !ISARRAY( aExcept )
      aExcept := {}
   ENDIF

   aDataSymbol := __objGetMsgList( oObject )
   nLen        := Len( aDataSymbol )
   aData       := {}

   FOR n := 1 to nLen
      cSymbol := aDataSymbol[ n ]
      IF AScan( aExcept, {| tmp | tmp == cSymbol } ) == 0
         AAdd( aData, { cSymbol, __objSendMsg( oObject, cSymbol ) } )
      ENDIF
   NEXT

   RETURN aData
objfunc.prg148
FUNCTION__ObjSetValueList( oObject, aData )
FUNCTION __ObjSetValueList( oObject, aData )

   IF !ISOBJECT( oObject )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ELSE
      AEval( aData, {| aItem | __objSendMsg( oObject, "_" + aItem[ HB_OO_DATA_SYMBOL ], aItem[ HB_OO_DATA_VALUE ] ) } )
   ENDIF

   RETURN oObject
objfunc.prg176
FUNCTION__objAddMethod( oObject, cSymbol, nFuncPtr )
FUNCTION __objAddMethod( oObject, cSymbol, nFuncPtr )

   IF !ISOBJECT( oObject ) .OR. !ISCHARACTER( cSymbol ) .OR. !hb_ISSYMBOL( nFuncPtr )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ELSEIF !__objHasMsg( oObject, cSymbol )
      __clsAddMsg( oObject:ClassH, cSymbol, nFuncPtr, HB_OO_MSG_METHOD, NIL, 1 )
   ENDIF

   RETURN oObject
objfunc.prg186
FUNCTION__objAddInline( oObject, cSymbol, bInline )
FUNCTION __objAddInline( oObject, cSymbol, bInline )

   IF !ISOBJECT( oObject ) .OR. !ISCHARACTER( cSymbol )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ELSEIF !__objHasMsg( oObject, cSymbol )
      __clsAddMsg( oObject:ClassH, cSymbol, bInline, HB_OO_MSG_INLINE, NIL, 1 )
   ENDIF

   RETURN oObject
objfunc.prg196
FUNCTION__objAddData( oObject, cSymbol )
FUNCTION __objAddData( oObject, cSymbol )
   LOCAL nSeq, hClass

   IF !ISOBJECT( oObject ) .OR. !ISCHARACTER( cSymbol )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ELSEIF !__objHasMsg( oObject, cSymbol ) .AND. !__objHasMsg( oObject, "_" + cSymbol )
      hClass := oObject:ClassH
      nSeq   := __cls_IncData( hClass )         // Allocate new Seq#
      __clsAddMsg( hClass,       cSymbol, nSeq, HB_OO_MSG_ACCESS, NIL, 1 )
      __clsAddMsg( hClass, "_" + cSymbol, nSeq, HB_OO_MSG_ASSIGN, NIL, 1 )
   ENDIF

   RETURN oObject
objfunc.prg206
FUNCTION__objModMethod( oObject, cSymbol, nFuncPtr )
FUNCTION __objModMethod( oObject, cSymbol, nFuncPtr )

   IF !ISOBJECT( oObject ) .OR. !ISCHARACTER( cSymbol ) .OR. !hb_ISSYMBOL( nFuncPtr )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ELSEIF __objHasMethod( oObject, cSymbol )
      __clsModMsg( oObject:ClassH, cSymbol, nFuncPtr )
   ENDIF

   RETURN oObject
objfunc.prg220
FUNCTION__objModInline( oObject, cSymbol, bInline )
FUNCTION __objModInline( oObject, cSymbol, bInline )

   IF !ISOBJECT( oObject ) .OR. !ISCHARACTER( cSymbol ) .OR. !ISBLOCK( bInline )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ELSEIF __objHasMethod( oObject, cSymbol )
      __clsModMsg( oObject:ClassH, cSymbol, bInline )
   ENDIF

   RETURN oObject
objfunc.prg230
FUNCTION__objDelMethod( oObject, cSymbol )
FUNCTION __objDelMethod( oObject, cSymbol )

   IF !ISOBJECT( oObject ) .OR. !ISCHARACTER( cSymbol )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ELSEIF __objHasMethod( oObject, cSymbol )
      __clsDelMsg( oObject:ClassH, cSymbol )
   ENDIF

   RETURN oObject
objfunc.prg240
FUNCTION__objDelInline( oObject, cSymbol )
FUNCTION __objDelInline( oObject, cSymbol )
   RETURN __objDelMethod( oObject, cSymbol )              // Same story
objfunc.prg250
FUNCTION__objDelData( oObject, cSymbol )
FUNCTION __objDelData( oObject, cSymbol )

   IF !ISOBJECT( oObject ) .OR. !ISCHARACTER( cSymbol )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ELSEIF __objHasData( oObject, cSymbol )
      __clsDelMsg( oObject:ClassH, cSymbol )
      __clsDelMsg( oObject:ClassH, "_" + cSymbol )
      __cls_DecData( oObject:ClassH )         // Decrease wData
   ENDIF

   RETURN oObject
objfunc.prg253
FUNCTION__objDerivedFrom( oObject, xSuper )
FUNCTION __objDerivedFrom( oObject, xSuper )
   LOCAL cClassName

   IF !ISOBJECT( oObject )
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ENDIF

   IF ISOBJECT( xSuper )
      cClassName := xSuper:ClassName()
   ELSEIF ISCHARACTER( xSuper )
      cClassName := Upper( xSuper )
   ELSE
      __errRT_BASE( EG_ARG, 3101, NIL, ProcName( 0 ) )
   ENDIF

   RETURN __clsParent( oObject:ClassH, cClassName )
objfunc.prg265
FUNCTION__objGetProperties( oObject, lAllExported )
FUNCTION __objGetProperties( oObject, lAllExported )
   LOCAL msg
   LOCAL aMsgList := __clsGetProperties( oObject:classH, lAllExported )

   FOR EACH msg IN aMsgList
      msg := { msg, __objSendMsg( oObject, msg ) }
   NEXT

   RETURN aMsgList
objfunc.prg283
perfuncs.prg
TypeFunctionSourceLine
FUNCTIONHB_SetObject( oSelf, bConstructor )
function HB_SetObject( oSelf, bConstructor )

   if s_aObjects == nil
      s_aObjects := {}
      AAdd( s_aObjects, oSelf )
   else
      AAdd( s_aObjects, oSelf := Eval( bConstructor ) )
   endif

return oSelf
perfuncs.prg55
FUNCTIONHB_EndObject()
function HB_EndObject()

   local oSelf

   if Len( s_aObjects ) > 1
      ASize( s_aObjects, Len( s_aObjects ) - 1 )
      oSelf := ATail( s_aObjects )
   else
      oSelf := s_aObjects[ 1 ]
      s_aObjects := nil
   endif

return oSelf
perfuncs.prg66
persist.prg
TypeFunctionSourceLine
METHODCreateNew() INLINE Self
   METHOD CreateNew() INLINE Self
persist.prg58
METHOD LOADFROMFILE( CFILENAME ) INLINE ::LOADFROMTEXT(MemoRead( cFileName ) )
   METHOD LoadFromFile( cFileName ) INLINE ::LoadFromText( MemoRead( cFileName ) )
persist.prg59
METHODLoadFromText( cObjectText )
   METHOD LoadFromText( cObjectText )
persist.prg60
METHODSaveToText( cObjectName, nIndent )
   METHOD SaveToText( cObjectName, nIndent )
persist.prg61
METHOD SAVETOFILE( CFILENAME ) INLINE MEMOWRIT( CFILENAME, :SaveToText() )
   METHOD SaveToFile( cFileName ) INLINE MemoWrit( cFileName, ::SaveToText() )

ENDCLASS
persist.prg62
HBPERSISTENT:METHODLoadFromText( cObjectText ) CLASS HBPersistent
METHOD LoadFromText( cObjectText ) CLASS HBPersistent

   local nFrom  := 1, cLine, cToken
   local lStart := .t.
   private oSelf

   if empty( cObjectText )
      return .F.
   endif

   do while Empty( ExtractLine( cObjectText, @nFrom ) ) // We skip the first empty lines
   enddo

   do while nFrom <= Len( cObjectText )
      cLine  := ExtractLine( cObjectText, @nFrom )

      do case
         case Upper( LTrim( hb_TokenGet( cLine, 1 ) ) ) == "OBJECT"
              if lStart
                 lStart := .f.
              else
              endif

         case Upper( LTrim( hb_TokenGet( cLine, 1 ) ) ) == "ARRAY"
              cLine := SubStr( cLine, At( "::", cLine ) )
              M->oSelf := Self
              cLine := StrTran( cLine, "::", "oSelf:" )
              cLine := StrTran( cLine, " LEN ", " = Array( " )
              cLine := RTrim( StrTran( cLine, "=", ":=", , 1 ) ) + " )"
              cLine := &( cLine )

         case Left( cToken := LTrim( hb_TokenGet( cLine, 1, "=" ) ), 2 ) == "::"
              M->oSelf := Self
              cLine := StrTran( cLine, "::", "oSelf:" )
              cLine := StrTran( cLine, "=", ":=", , 1 )
              cLine := &( cLine )

      endcase

   enddo

return .T.
persist.prg66
HBPERSISTENT:METHODSaveToText( cObjectName, nIndent ) CLASS HBPersistent
METHOD SaveToText( cObjectName, nIndent ) CLASS HBPersistent

   local oNew := &( ::ClassName() + "()" ):CreateNew()
   local aProperties, n, uValue, uNewValue, cObject, cType

   DEFAULT cObjectName TO "o" + ::ClassName()

   if nIndent == NIL
      nIndent := 0
   else
      nIndent += 3
   endif

   cObject := iif( nIndent > 0, hb_OSNewLine(), "" ) + Space( nIndent ) + ;
              "OBJECT " + iif( nIndent != 0, "::", "" ) + cObjectName + " AS " + ;
              ::ClassName() + hb_OSNewLine()

   aProperties := __ClsGetProperties( ::ClassH )

   for n := 1 to Len( aProperties )
      uValue := __objSendMsg( Self, aProperties[ n ] )
      uNewValue := __objSendMsg( oNew, aProperties[ n ] )
      cType  := ValType( uValue )

      if !( cType == ValType( uNewValue ) ) .OR. ! uValue == uNewValue

         do case
            case cType == "A"
                 nIndent += 3
                 cObject += ArrayToText( uValue, aProperties[ n ], nIndent )
                 nIndent -= 3
                 if n < Len( aProperties )
                    cObject += hb_OSNewLine()
                 endif

            case cType == "O"
                 if __objDerivedFrom( uValue, "HBPERSISTENT" )
                    cObject += uValue:SaveToText( aProperties[ n ], nIndent )
                 endif
                 if n < Len( aProperties )
                    cObject += hb_OSNewLine()
                 endif

            otherwise
                 if n == 1
                    cObject += hb_OSNewLine()
                 endif
                 cObject += Space( nIndent ) + "   ::" + ;
                            aProperties[ n ] + " = " + ValToText( uValue ) + ;
                            hb_OSNewLine()
         endcase

      endif

   next

   cObject += hb_OSNewLine() + Space( nIndent ) + "ENDOBJECT" + hb_OSNewLine()

return cObject
persist.prg109
STATIC FUNCTIONArrayToText( aArray, cName, nIndent )
static function ArrayToText( aArray, cName, nIndent )

   local cArray := hb_OSNewLine() + Space( nIndent ) + "ARRAY ::" + cName + ;
                   " LEN " + AllTrim( Str( Len( aArray ) ) ) + hb_OSNewLine()
   local n, uValue, cType

   for n := 1 to Len( aArray )
      uValue := aArray[ n ]
      cType  := ValType( uValue )

      do case
         case cType == "A"
              nIndent += 3
              cArray += ArrayToText( uValue, cName + "[ " + ;
                        AllTrim( Str( n ) ) + " ]", nIndent ) + hb_OSNewLine()
              nIndent -= 3

         case cType == "O"
              if __objDerivedFrom( uValue, "HBPERSISTENT" )
                 cArray += uValue:SaveToText( cName + "[ " + AllTrim( Str( n ) ) + ;
                                              " ]", nIndent )
              endif

         otherwise
              if n == 1
                 cArray += hb_OSNewLine()
              endif
              cArray += Space( nIndent ) + "   ::" + cName + ;
                        + "[ " + AllTrim( Str( n ) ) + " ]" + " = " + ;
                        ValToText( uValue ) + hb_OSNewLine()
      endcase
   next

   cArray += hb_OSNewLine() + Space( nIndent ) + "ENDARRAY" + hb_OSNewLine()

return cArray
persist.prg169
STATIC FUNCTIONValToText( uValue )
static function ValToText( uValue )

   local cType := ValType( uValue )
   local cText

   do case
      case cType == "C"
           cText := hb_StrToExp( uValue )

      case cType == "N"
           cText := AllTrim( Str( uValue ) )

      case cType == "D"
           cText := DToS( uValue )
           cText := "0d" + iif( Empty( cText ), "00000000", cText )

      otherwise
           cText := hb_ValToStr( uValue )
   endcase

return cText
persist.prg206
STATIC FUNCTIONExtractLine( cText, nFrom )
static function ExtractLine( cText, nFrom )

   local nAt := hb_At( Chr( 10 ), cText, nFrom )
  
   if nAt > 0
      cText := SubStr( cText, nFrom, nAt - nFrom )
      if Right( cText, 1 ) == Chr( 13 )
         cText := hb_StrShrink( cText, 1 )
      endif
      nFrom := nAt + 1
   else
      cText := SubStr( cText, nFrom )
      if Right( cText, 1 ) == Chr( 13 )
         cText := hb_StrShrink( cText, 1 )
      endif
      nFrom += Len( cText ) + 1
   endif

return cText
persist.prg230
profiler.prg
TypeFunctionSourceLine
PROCEDUREMain()
Procedure Main()
Local oProfile := HBProfile():new()
Local n

   // Turn on profiling.
   __setProfiler( .T. )

   // Make sure we've got something to see timewise.
   DrawScreen( "Doing nothing for a couple of seconds" )
   DoNothingForTwoSeconds()

   // Make sure we've got something to see callwise.
   For n := 1 To 500
      CallMe500Times()
   Next

   // Take a profile snapshot.
   oProfile:gather()

   // Report on calls greater than 0
   DrawScreen( "All methods/functions called one or more times" )
   memoedit( HBProfileReportToString():new( oProfile:callSort() ):generate( {| o | o:nCalls > 0 } ), 1,,,, .F. )

   // Sorted by name
   DrawScreen( "All methods/functions called one or more times, sorted by name" )
   memoedit( HBProfileReportToString():new( oProfile:nameSort() ):generate( {| o | o:nCalls > 0 } ), 1,,,, .F. )

   // Sorted by time
   DrawScreen( "All methods/functions taking measurable time, sorted by time" )
   memoedit( HBProfileReportToString():new( oProfile:timeSort() ):generate( {| o | o:nTicks > 0 } ), 1,,,, .F. )

   // TBrowse all calls greater than 0
   DrawScreen( "TBrowse all methods/functions called one or more times" )
   Browser( HBProfileReportToTBrowse():new( oProfile:callSort() ):generate( {| o | o:nCalls > 0 }, 1 ) )

   // Some closing stats
   DrawScreen( "Totals" )
   @ 2, 0 Say "  Total Calls: " + str( oProfile:totalCalls() )
   @ 3, 0 Say "  Total Ticks: " + str( oProfile:totalTicks() )
   @ 4, 0 Say "Total Seconds: " + str( oProfile:totalSeconds() )

Return
profiler.prg109
STATIC PROCEDUREDrawScreen( cTitle )
Static Procedure DrawScreen( cTitle )

   Scroll()

   @ 0, 0 SAY PadR( cTitle, MaxCol() + 1 ) COLOR "N/W"

Return
profiler.prg152
PROCEDUREDoNothingForTwoSeconds()
Procedure DoNothingForTwoSeconds()

   Inkey( 2 )

Return
profiler.prg160
PROCEDURECallMe500Times()
Procedure CallMe500Times()
Return
profiler.prg166
STATIC PROCEDUREBrowser( oBrowse )
Static Procedure Browser( oBrowse )
Local lBrowsing := .T.
Local nKey

   Do While lBrowsing

      oBrowse:forceStable()

      nKey := Inkey( 0 )

      Do Case

         Case nKey == K_ESC
            lBrowsing := .F.

         Case nKey == K_DOWN
            oBrowse:down()

         Case nKey == K_UP
            oBrowse:up()

         Case nKey == K_LEFT
            oBrowse:left()

         Case nKey == K_RIGHT
            oBrowse:right()

         Case nKey == K_PGDN
            oBrowse:pageDown()

         Case nKey == K_PGUP
            oBrowse:pageUp()

         // And so on.... (not really necessary for this test)

      EndCase

   EndDo

Return

#endif

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileEntity

Create Class HBProfileEntity

   Exported:

      Var cName    ReadOnly
      Var nCalls   ReadOnly
      Var nTicks   ReadOnly

      Access nSeconds
      Access nMeanTicks
      Access nMeanSeconds
profiler.prg169
METHODinit
      Method init
profiler.prg227
METHODdescribe
      Method describe

Endclass
profiler.prg228
METHODinit( cName, aInfo ) Class HBProfileEntity
Method init( cName, aInfo ) Class HBProfileEntity

   ::cName  := cName
   ::nCalls := aInfo[ 1 ]
   ::nTicks := aInfo[ 2 ]

Return Self

/////

Access nSeconds Class HBProfileEntity
Return HB_Clocks2Secs( ::nTicks )

/////

Access nMeanTicks Class HBProfileEntity
Return iif( ::nCalls == 0, 0, ::nTicks / ::nCalls )

/////

Access nMeanSeconds Class HBProfileEntity
Return iif( ::nCalls == 0, 0, ::nSeconds / ::nCalls )
profiler.prg234
METHODdescribe Class HBProfileEntity
Method describe Class HBProfileEntity
Return "Base Entity"

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileFunction

Create Class HBProfileFunction Inherit HBProfileEntity

   Exported:
profiler.prg259
METHODdescribe
      Method describe

Endclass
profiler.prg269
METHODdescribe Class HBProfileFunction
Method describe Class HBProfileFunction
Return "Function"

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileMethod

Create Class HBProfileMethod Inherit HBProfileEntity

   Exported:
profiler.prg275
METHODdescribe
      Method describe

Endclass
profiler.prg285
METHODdescribe Class HBProfileMethod
Method describe Class HBProfileMethod
Return "Method"

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileOPCode

Create Class HBProfileOPCode Inherit HBProfileEntity

   Exported:
profiler.prg291
METHODdescribe
      Method describe

Endclass
profiler.prg301
METHODdescribe Class HBProfileOPCode
Method describe Class HBProfileOPCode
Return "OPCode"

////////////////////////////////////////////////////////////////////////////
// Class: HBProfile

Create Class HBProfile

   Exported:

      Var aProfile
profiler.prg307
METHODinit
      Method init
profiler.prg319
METHODgather
      Method gather
profiler.prg320
METHODforEach
      Method forEach
profiler.prg321
METHODsort
      Method sort
profiler.prg322
METHODnameSort
      Method nameSort
profiler.prg323
METHODcallSort
      Method callSort
profiler.prg324
METHODtimeSort
      Method timeSort
profiler.prg325
METHODtotalCalls
      Method totalCalls
profiler.prg326
METHODtotalTicks
      Method totalTicks
profiler.prg327
METHODtotalSeconds
      Method totalSeconds

   Protected:
profiler.prg328
METHODgatherFunctions
      Method gatherFunctions
profiler.prg332
METHODgatherMethods
      Method gatherMethods
profiler.prg333
METHODreset
      Method reset
profiler.prg334
METHODignoreSymbol
      Method ignoreSymbol

Endclass
profiler.prg335
METHODinit Class HBProfile
Method init Class HBProfile
Local lProfile := __setProfiler( .F. )

   ::reset()

   __setProfiler( lProfile )

Return Self
profiler.prg341
METHODreset Class HBProfile
Method reset Class HBProfile

   ::aProfile := {}

Return Self
profiler.prg352
METHODignoreSymbol( cSymbol ) Class HBProfile
Method ignoreSymbol( cSymbol ) Class HBProfile
Local cProfPrefix := "HBPROFILE"
Return Left( cSymbol, Len( cProfPrefix ) ) == cProfPrefix .Or. cSymbol == "__SETPROFILER"
profiler.prg360
METHODgatherFunctions Class HBProfile
Method gatherFunctions Class HBProfile
Local lProfile  := __setProfiler( .F. )
Local nSymCount := __DynSCount()
Local cName
Local n

   // For each known symbol.
   // TODO: Question: Will the symbol count have changed because
   //                 we've created variables?
   For n := 1 To nSymCount

      // Is the symbol a function?
      If __DynSIsFun( n )

         // If we're not ignoring the symbol...
         If !::ignoreSymbol( cName := __DynSGetName( n ) )
            // Yes, it is, add it to the profile.
            AAdd( ::aProfile, HBProfileFunction():new( cName, __DynSGetPrf( n ) ) )
         EndIf

      EndIf

   Next

   __setProfiler( lProfile )

Return Self
profiler.prg366
METHODgatherMethods Class HBProfile
Method gatherMethods Class HBProfile
Local lProfile  := __setProfiler( .F. )
Local n         := 1
Local cClass
Local nMembers
Local aMembers
Local nMember

   // For each class in the environment...
   Do While !Empty( cClass := __className( n ) )

      // If we're not ignoring the class' methods...
      If !::ignoreSymbol( cClass )

         // Collect class members.
         nMembers := Len( aMembers := __classSel( n ) )

         For nMember := 1 To nMembers

            // If we've got a member name...
            If !empty( aMembers[ nMember ] )
               // Add it to the profile.
               AAdd( ::aProfile, HBProfileMethod():new( cClass + ":" + aMembers[ nMember ], __GetMsgPrf( n, aMembers[ nMember ] ) ) )
            EndIf

         Next

      EndIf

      ++n

   EndDo

   __setProfiler( lProfile )

Return Self
profiler.prg396
METHODgather Class HBProfile
Method gather Class HBProfile
Local lProfile  := __setProfiler( .F. )

   // Reset the profile.
   ::reset()

   // Gather function calls
   ::gatherFunctions()

   // Gather method calls
   ::gatherMethods()   

   __setProfiler( lProfile )

Return Self
profiler.prg435
METHODforEach( b ) Class HBProfile
Method forEach( b ) Class HBProfile
Local lProfile := __setProfiler( .F. )

   AEval( ::aProfile, b )

   __setProfiler( lProfile )

Return Self
profiler.prg453
METHODsort( b ) Class HBProfile
Method sort( b ) Class HBProfile
Local lProfile := __setProfiler( .F. )

   ASort( ::aProfile,,, b )

   __setProfiler( lProfile )

Return Self
profiler.prg464
METHODnameSort Class HBProfile
Method nameSort Class HBProfile
Local lProfile := __setProfiler( .F. )

   ::sort( {| oX, oY | oX:cName < oY:cName } )

   __setProfiler( lProfile )

Return Self
profiler.prg475
METHODcallSort Class HBProfile
Method callSort Class HBProfile
Local lProfile := __setProfiler( .F. )

   ::sort( {| oX, oY | oX:nCalls > oY:nCalls } )

   __setProfiler( lProfile )

Return Self
profiler.prg486
METHODtimeSort Class HBProfile
Method timeSort Class HBProfile
Local lProfile := __setProfiler( .F. )

   ::sort( {| oX, oY | oX:nTicks > oY:nTicks } )

   __setProfiler( lProfile )

Return Self
profiler.prg497
METHODtotalCalls Class HBProfile
Method totalCalls Class HBProfile
Local lProfile := __setProfiler( .F. )
Local nCalls   := 0

   ::forEach( {| o | nCalls += o:nCalls } )

   __setProfiler( lProfile )

Return nCalls
profiler.prg508
METHODtotalTicks Class HBProfile
Method totalTicks Class HBProfile
Local lProfile := __setProfiler( .F. )
Local nTicks   := 0

   ::forEach( {| o | nTicks += o:nTicks } )

   __setProfiler( lProfile )

Return nTicks
profiler.prg520
METHODtotalSeconds Class HBProfile
Method totalSeconds Class HBProfile
Local lProfile := __setProfiler( .F. )
Local nSeconds := 0

   ::forEach( {| o | nSeconds += o:nSeconds } )

   __setProfiler( lProfile )

Return nSeconds

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileLowLevel

Create Class HBProfileLowLevel Inherit HBProfile

   Exported:
profiler.prg532
METHODgather
      Method gather

   Protected:
profiler.prg549
METHODgatherOPCodes
      Method gatherOPCodes

Endclass
profiler.prg553
METHODgather Class HBProfileLowLevel
Method gather Class HBProfileLowLevel
Local lProfile := __setProfiler( .F. )

   // Gather functions and methods.
   ::super:gather()

   // Also gather opcodes.   
   ::gatherOPCodes()

   __setProfiler( lProfile )

Return Self
profiler.prg559
METHODgatherOPCodes Class HBProfileLowLevel
Method gatherOPCodes Class HBProfileLowLevel
Local nMax := __opcount()
Local cName
Local nOP

   // Loop over all the harbour OP codes. Note that they start at 0.
   For nOP := 0 To ( nMax - 1 )
      // If we're not ignoring this opcode.
      If !::ignoreSymbol( cName := "OPCODE( " + PadL( nOP, 3 ) + " )" )
         // Add it to the profile.
         AAdd( ::aProfile, HBProfileOPCode():new( cName, __OpGetPrf( nOP ) ) )
      EndIf
   Next

Return Self

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileReport

Create Class HBProfileReport

   Protected:

      Var oProfile
profiler.prg574
METHODwriteLines
      Method writeLines
profiler.prg599
METHODheader
      Method header
profiler.prg600
METHODemitHeader
      Method emitHeader
profiler.prg601
METHODline
      Method line
profiler.prg602
METHODemitLine
      Method emitLine

   Exported:
profiler.prg603
METHODinit
      Method init
profiler.prg607
METHODgenerate
      Method generate

Endclass
profiler.prg608
METHODinit( oProfile ) Class HBProfileReport
Method init( oProfile ) Class HBProfileReport
Local lProfile := __setProfiler( .F. )

   ::oProfile := oProfile

   __setProfiler( lProfile )

Return Self
profiler.prg614
METHODwriteLines( aLines ) Class HBProfileReport
Method writeLines( aLines ) Class HBProfileReport

   AEval( aLines, {| c | QOut( c ) } )

Return Self
profiler.prg625
METHODheader Class HBProfileReport
Method header Class HBProfileReport
Return { "Name                                Type       Calls    Ticks       Seconds",;
         "=================================== ========== ======== =========== ===========" }
profiler.prg633
METHODemitHeader Class HBProfileReport
Method emitHeader Class HBProfileReport

   ::writeLines( ::header() )

Return Self
profiler.prg639
METHODline( oEntity ) Class HBProfileReport
Method line( oEntity ) Class HBProfileReport
Return { PadR( oEntity:cName,      35 ) + " " + ;
         PadR( oEntity:describe(),  8 ) + " " + ;
         PadL( oEntity:nCalls,     10 ) + " " + ;
         PadL( oEntity:nTicks,     11 ) + " " + ;
         Str( oEntity:nSeconds,    11, 2 ) }
profiler.prg647
METHODemitLine( oEntity ) Class HBProfileReport
Method emitLine( oEntity ) Class HBProfileReport

   ::writeLines( ::line( oEntity ) )

Return Self
profiler.prg656
METHODgenerate( bFilter ) Class HBProfileReport
Method generate( bFilter ) Class HBProfileReport
Local lProfile := __setProfiler( .F. )

   Default bFilter To {|| .T. }

   ::emitHeader():oProfile:forEach( {| o | iif( Eval( bFilter, o ), ::emitLine( o ), NIL ) } )

   __setProfiler( lProfile )

Return Self

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileReportToFile

Create Class HBProfileReportToFile Inherit HBProfileReport

   Protected:

      Var hFile
profiler.prg664
METHODwriteLines
      Method writeLines

   Exported:
profiler.prg684
METHODgenerate
      Method generate

Endclass
profiler.prg688
METHODwriteLines( aLines ) Class HBProfileReportToFile
Method writeLines( aLines ) Class HBProfileReportToFile

   If ::hFile != F_ERROR
      AEval( aLines, {| c | FWrite( ::hFile, c + HB_OSNewLine() ) } )
   EndIf

Return Self
profiler.prg694
METHODgenerate( bFilter, cFile ) Class HBProfileReportToFile
Method generate( bFilter, cFile ) Class HBProfileReportToFile
Local lProfile := __setProfiler( .F. )

   Default cFile To "hbprof.txt"

   If ( ::hFile := fcreate( cFile ) ) != F_ERROR
      ::super:generate( bFilter )
      fclose( ::hFile )
   Else
      // TODO: Throw an error
   EndIf

   __setProfiler( lProfile )

Return Self

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileReportToArray

Create Class HBProfileReportToArray Inherit HBProfileReport

   Protected:

      Var aReport
profiler.prg704
METHODwriteLines
      Method writeLines

   Exported:
profiler.prg729
METHODgenerate
      Method generate

Endclass
profiler.prg733
METHODwriteLines( aLines ) Class HBProfileReportToArray
Method writeLines( aLines ) Class HBProfileReportToArray

   AEval( aLines, {| c | AAdd( ::aReport, c ) } )

Return Self
profiler.prg739
METHODgenerate( bFilter ) Class HBProfileReportToArray
Method generate( bFilter ) Class HBProfileReportToArray

   ::aReport := {}
   ::super:generate( bFilter )

Return ::aReport

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileReportToString

Create Class HBProfileReportToString Inherit HBProfileReportToArray

   Exported:
profiler.prg747
METHODgenerate
      Method generate

Endclass
profiler.prg761
METHODgenerate( bFilter ) Class HBProfileReportToString
Method generate( bFilter ) Class HBProfileReportToString
Local cReport := ""

   AEval( ::super:generate( bFilter ), {| c | cReport += c + HB_OSNewLine() } )

Return cReport

////////////////////////////////////////////////////////////////////////////
// Class: HBProfileReportToTBrowse


Create Class HBProfileReportToTBrowse Inherit HBProfileReportToArray

   Protected:

      Var nEntity
profiler.prg767
METHODemitHeader
      Method emitHeader
profiler.prg784
METHODemitLine
      Method emitLine
profiler.prg785
METHODaddColumns
      Method addColumns

   Exported:
profiler.prg786
METHODgenerate
      Method generate
profiler.prg790
METHODcurrentEntity
      Method currentEntity

Endclass
profiler.prg791
METHODemitHeader Class HBProfileReportToTBrowse
Method emitHeader Class HBProfileReportToTBrowse

   // No header required.

Return Self
profiler.prg797
METHODemitLine( oEntity ) Class HBProfileReportToTBrowse
Method emitLine( oEntity ) Class HBProfileReportToTBrowse

   // Don't "emit" anything, simply add the entity to the array.
   AAdd( ::aReport, oEntity )

Return Self
profiler.prg805
METHODgenerate( bFilter, nTop, nLeft, nBottom, nRight ) Class HBProfileReportToTBrowse
Method generate( bFilter, nTop, nLeft, nBottom, nRight ) Class HBProfileReportToTBrowse
Local lProfile := __setProfiler( .F. )
Local oBrowse

   // Start with the first entity.
   ::nEntity := 1

   // Generate the array.
   ::super:generate( bFilter )

   // Build the browse.
   oBrowse := TBrowseNew( nTop, nLeft, nBottom, nRight )

   oBrowse:goTopBlock    := {|| ::nEntity := 1 }
   oBrowse:goBottomBlock := {|| ::nEntity := Len( ::aReport ) }
   oBrowse:skipBlock     := {| nSkip, nPos | nPos := ::nEntity,                                   ;
                                             ::nEntity := iif( nSkip > 0,                         ;
                                                      Min( Len( ::aReport ), ::nEntity + nSkip ), ;
                                                      Max( 1, ::nEntity + nSkip ) ), ::nEntity - nPos }

   ::addColumns( oBrowse )

   __setProfiler( lProfile )

Return oBrowse
profiler.prg814
METHODaddColumns( oBrowse ) Class HBProfileReportToTBrowse
Method addColumns( oBrowse ) Class HBProfileReportToTBrowse

   oBrowse:addColumn( TBColumnNew( "Name",         {|| PadR( ::currentEntity():cName,        35    ) } ) )
   oBrowse:addColumn( TBColumnNew( "Type",         {|| PadR( ::currentEntity():describe(),    8    ) } ) )
   oBrowse:addColumn( TBColumnNew( "Calls",        {|| PadL( ::currentEntity():nCalls,       10    ) } ) )
   oBrowse:addColumn( TBColumnNew( "Ticks",        {|| PadL( ::currentEntity():nTicks,       11    ) } ) )
   oBrowse:addColumn( TBColumnNew( "Seconds",      {|| Str(  ::currentEntity():nSeconds,     11, 2 ) } ) )
   oBrowse:addColumn( TBColumnNew( "Mean;Ticks",   {|| Str(  ::currentEntity():nMeanTicks,   11, 2 ) } ) )
   oBrowse:addColumn( TBColumnNew( "Mean;Seconds", {|| Str(  ::currentEntity():nMeanSeconds, 11, 2 ) } ) )

Return Self
profiler.prg842
METHODcurrentEntity Class HBProfileReportToTBrowse
Method currentEntity Class HBProfileReportToTBrowse
Return ::aReport[ ::nEntity ]
profiler.prg856
pushbtn.prg
TypeFunctionSourceLine
METHODdisplay()
   METHOD display()
pushbtn.prg82
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )
pushbtn.prg83
METHODkillFocus()
   METHOD killFocus()
pushbtn.prg84
METHODselect()
   METHOD select()
pushbtn.prg85
METHODsetFocus()
   METHOD setFocus()
pushbtn.prg86
METHODbitmap( cBitmap ) SETGET
   METHOD bitmap( cBitmap ) SETGET
pushbtn.prg88
METHODbuffer() SETGET
   METHOD buffer() SETGET
pushbtn.prg89
METHODcaption( cCaption ) SETGET
   METHOD caption( cCaption ) SETGET
pushbtn.prg90
METHODcol( nCol ) SETGET
   METHOD col( nCol ) SETGET
pushbtn.prg91
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
pushbtn.prg92
METHODfBlock( bFBlock ) SETGET
   METHOD fBlock( bFBlock ) SETGET
pushbtn.prg93
METHODhasFocus() SETGET
   METHOD hasFocus() SETGET
pushbtn.prg94
METHODmessage( cMessage ) SETGET
   METHOD message( cMessage ) SETGET
pushbtn.prg95
METHODrow( nRow ) SETGET
   METHOD row( nRow ) SETGET
pushbtn.prg96
METHODsBlock( bSBlock ) SETGET
   METHOD sBlock( bSBlock ) SETGET
pushbtn.prg97
METHODtypeOut() SETGET
   METHOD typeOut() SETGET
pushbtn.prg98
METHODstyle( cStyle ) SETGET
   METHOD style( cStyle ) SETGET
pushbtn.prg99
METHODNew( nRow, nCol, cCaption )
   METHOD New( nRow, nCol, cCaption ) /* NOTE: This method is a Harbour extension [vszakats] */

   PROTECTED:

   VAR cBitmap    INIT ""
   VAR lBuffer    INIT .F.
   VAR cCaption
   VAR nCol
   VAR cColorSpec
   VAR bFBlock
   VAR lHasFocus  INIT .F.
   VAR cMessage   INIT ""
   VAR nRow
   VAR bSBlock
   VAR cStyle     INIT "<>"
   VAR lTypeOut   INIT .F.

ENDCLASS
pushbtn.prg101
PUSHBUTTON:METHODsetFocus() CLASS PUSHBUTTON
METHOD setFocus() CLASS PUSHBUTTON

   IF !::lHasFocus
      ::lHasFocus := .T.
      ::display()

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF
   ENDIF

   RETURN Self
pushbtn.prg120
PUSHBUTTON:METHODselect( nPos ) CLASS PUSHBUTTON
METHOD select( nPos ) CLASS PUSHBUTTON

   LOCAL nCurPos := nPos

   IF ::lHasFocus
      ::lbuffer := .T.
      ::display()

      IF ISNUMBER( nPos )

         IF nPos == 32

            Inkey( 0.4 )
            DO WHILE nCurPos == 32
               nCurPos := Inkey( 0.1 )
            ENDDO
         ELSE
            DO WHILE nPos == Inkey( 0 )
            ENDDO
         ENDIF
      ENDIF

      IF ISBLOCK( ::bSBlock )
         Eval( ::bSBlock )
      ENDIF

      ::lBuffer := .F.
      ::display()
   ENDIF

   RETURN Self
pushbtn.prg133
PUSHBUTTON:METHODkillFocus() CLASS PUSHBUTTON
METHOD killFocus() CLASS PUSHBUTTON

   IF ::lHasFocus
      ::lHasFocus := .F.

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF

      ::display()
   ENDIF

   RETURN Self
pushbtn.prg165
PUSHBUTTON:METHODhitTest( nMRow, nMCol ) CLASS PUSHBUTTON
METHOD hitTest( nMRow, nMCol ) CLASS PUSHBUTTON

   LOCAL nCurrentPos := 1
   LOCAL nLen := Len( ::cCaption )
   LOCAL nStyleLen
   LOCAL nAccelPos

   IF ( nAccelPos := At( "&", ::cCaption ) ) > 0 .AND. nAccelPos < nLen
      nLen--
   ENDIF

   IF ( nStyleLen := Len( ::cStyle ) ) == 2
      nLen += 2
   ELSEIF nStyleLen == 8
      nCurrentPos := 3
      nLen += 2
   ENDIF

   IF nMRow >= ::Row .AND. ;
      nMCol >= ::Col .AND. ;
      nMRow < ::Row + nCurrentPos .AND. ;
      nMCol < ::Col + nLen
      RETURN HTCLIENT
   ENDIF

   RETURN HTNOWHERE
pushbtn.prg179
PUSHBUTTON:METHODdisplay() CLASS PUSHBUTTON
METHOD display() CLASS PUSHBUTTON

   LOCAL cOldColor := SetColor()      
   LOCAL nOldRow := Row()             
   LOCAL nOldCol := Col()             
   LOCAL lOldMCur := MSetCursor( .F. )

   LOCAL cStyle := ::cStyle
   LOCAL cCaption := ::cCaption
   LOCAL nRow := ::nRow
   LOCAL nCol := ::nCol
   LOCAL nPos

   DispBegin()

   IF ::lBuffer
      SetColor( hb_ColorIndex( ::cColorSpec, 2 ) )
   ELSEIF ::lHasFocus
      SetColor( hb_ColorIndex( ::cColorSpec, 1 ) )
   ELSE
      SetColor( hb_ColorIndex( ::cColorSpec, 0 ) )
   ENDIF

   IF ( nPos := At( "&", cCaption ) ) == 0
   ELSEIF nPos == Len( cCaption )
      nPos := 0
   ELSE
      cCaption := Stuff( cCaption, nPos, 1, "" )
   ENDIF

   IF !Empty( cStyle )

      nCol++

      IF Len( cStyle ) == 2
         DispOutAt( ::nRow, ::nCol, SubStr( cStyle, 1, 1 ) )
         DispOutAt( ::nRow, ::nCol + Len( cCaption ) + 1, SubStr( cStyle, 2, 1 ) )
      ELSE
         nRow++
         DispBox( ::nRow, ::nCol, ::nRow + 2, ::nCol + Len( cCaption ) + 1, cStyle )
      ENDIF
   ENDIF

   IF !Empty( cCaption )

      DispOutAt( nRow, nCol, cCaption )

      IF nPos != 0
         DispOutAt( nRow, nCol + nPos - 1, SubStr( cCaption, nPos, 1 ), hb_ColorIndex( ::cColorSpec, 3 ) )
      ENDIF

   ENDIF

   DispEnd()

   MSetCursor( lOldMCur )
   SetColor( cOldColor )
   SetPos( nOldRow, nOldCol )

   RETURN Self
pushbtn.prg206
PUSHBUTTON:METHODbitmap( cBitmap ) CLASS PUSHBUTTON
METHOD bitmap( cBitmap ) CLASS PUSHBUTTON

   IF cBitmap != NIL
      ::cBitmap := __eInstVar53( Self, "BITMAP", cBitmap, "C", 1001 )
   ENDIF

   RETURN ::cBitmap
pushbtn.prg267
PUSHBUTTON:METHODbuffer() CLASS PUSHBUTTON
METHOD buffer() CLASS PUSHBUTTON
   RETURN ::lBuffer
pushbtn.prg275
PUSHBUTTON:METHODcaption( cCaption ) CLASS PUSHBUTTON
METHOD caption( cCaption ) CLASS PUSHBUTTON

   IF cCaption != NIL
      ::cCaption := __eInstVar53( Self, "CAPTION", cCaption, "C", 1001 )
   ENDIF

   RETURN ::cCaption
pushbtn.prg278
PUSHBUTTON:METHODcol( nCol ) CLASS PUSHBUTTON
METHOD col( nCol ) CLASS PUSHBUTTON

   IF nCol != NIL
      ::nCol := __eInstVar53( Self, "COL", nCol, "N", 1001 )
   ENDIF

   RETURN ::nCol
pushbtn.prg286
PUSHBUTTON:METHODcolorSpec( cColorSpec ) CLASS PUSHBUTTON
METHOD colorSpec( cColorSpec ) CLASS PUSHBUTTON

   IF cColorSpec != NIL
      ::cColorSpec := __eInstVar53( Self, "COLORSPEC", cColorSpec, "C", 1001,;
         {|| !Empty( hb_ColorIndex( cColorSpec, 3 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 5 ) ) } )
   ENDIF

   RETURN ::cColorSpec
pushbtn.prg294
PUSHBUTTON:METHODfBlock( bFBlock ) CLASS PUSHBUTTON
METHOD fBlock( bFBlock ) CLASS PUSHBUTTON
   
   IF PCount() > 0
      ::bFBlock := iif( bFBlock == NIL, NIL, __eInstVar53( Self, "FBLOCK", bFBlock, "B", 1001 ) )
   ENDIF

   RETURN ::bFBlock
pushbtn.prg303
PUSHBUTTON:METHODhasFocus() CLASS PUSHBUTTON
METHOD hasFocus() CLASS PUSHBUTTON
   RETURN ::lHasFocus
pushbtn.prg311
PUSHBUTTON:METHODmessage( cMessage ) CLASS PUSHBUTTON
METHOD message( cMessage ) CLASS PUSHBUTTON

   IF cMessage != NIL
      ::cMessage := __eInstVar53( Self, "MESSAGE", cMessage, "C", 1001 )
   ENDIF

   RETURN ::cMessage
pushbtn.prg314
PUSHBUTTON:METHODrow( nRow ) CLASS PUSHBUTTON
METHOD row( nRow ) CLASS PUSHBUTTON

   IF nRow != NIL
      ::nRow := __eInstVar53( Self, "ROW", nRow, "N", 1001 )
   ENDIF

   RETURN ::nRow
pushbtn.prg322
PUSHBUTTON:METHODsBlock( bSBlock ) CLASS PUSHBUTTON
METHOD sBlock( bSBlock ) CLASS PUSHBUTTON
   
   IF PCount() > 0
      ::bSBlock := iif( bSBlock == NIL, NIL, __eInstVar53( Self, "SBLOCK", bSBlock, "B", 1001 ) )
   ENDIF

   RETURN ::bSBlock
pushbtn.prg330
PUSHBUTTON:METHODtypeOut() CLASS PUSHBUTTON
METHOD typeOut() CLASS PUSHBUTTON
   RETURN .F.
pushbtn.prg338
PUSHBUTTON:METHODstyle( cStyle ) CLASS PUSHBUTTON
METHOD style( cStyle ) CLASS PUSHBUTTON

   IF cStyle != NIL
      ::cStyle := __eInstVar53( Self, "STYLE", cStyle, "C", 1001, {|| Len( cStyle ) == 0 .OR. Len( cStyle ) == 2 .OR. Len( cStyle ) == 8 } )
   ENDIF

   RETURN ::cStyle
pushbtn.prg341
PUSHBUTTON:METHODNew( nRow, nCol, cCaption ) CLASS PUSHBUTTON
METHOD New( nRow, nCol, cCaption ) CLASS PUSHBUTTON

   LOCAL cColor

   IF !ISNUMBER( nRow ) .OR. ;
      !ISNUMBER( nCol )
      RETURN NIL
   ENDIF

   DEFAULT cCaption TO ""

   ::caption  := cCaption
   ::nCol     := nCol
   ::nRow     := nRow

   IF IsDefColor()
      ::cColorSpec := "W/N,N/W,W+/N,W+/N"
   ELSE
      cColor := SetColor()
      ::cColorSpec := hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," +;
                      hb_ColorIndex( cColor, CLR_ENHANCED   ) + "," +;
                      hb_ColorIndex( cColor, CLR_STANDARD   ) + "," +;
                      hb_ColorIndex( cColor, CLR_BACKGROUND )
   ENDIF

   RETURN Self
pushbtn.prg349
FUNCTIONPushButton( nRow, nCol, cCaption )
FUNCTION PushButton( nRow, nCol, cCaption )
   RETURN HBPushButton():New( nRow, nCol, cCaption )
pushbtn.prg376
FUNCTION_PUSHBUTT_( cCaption, cMessage, cColorSpec, bFBlock, bSBlock, cStyle, nSizeX, nSizeY, nCapXOff, nCapYOff, cBitmap, nBmpXOff, nBmpYOff )
FUNCTION _PUSHBUTT_( cCaption, cMessage, cColorSpec, bFBlock, bSBlock, cStyle, nSizeX, nSizeY, nCapXOff, nCapYOff, cBitmap, nBmpXOff, nBmpYOff )
   LOCAL o := HBPushButton():New( Row(), Col(), cCaption )

   o:message   := cMessage
   o:colorSpec := cColorSpec
   o:fBlock    := bFBlock
   o:sBlock    := bSBlock
   o:style     := cStyle
   o:sizeX     := nSizeX
   o:sizeY     := nSizeY
   o:capXOff   := nCapXOff
   o:capYOff   := nCapYOff
   o:bitmap    := cBitmap
   o:bmpXOff   := nBmpXOff
   o:bmpYOff   := nBmpYOff

   RETURN o
pushbtn.prg379
radiobtn.prg
TypeFunctionSourceLine
METHODdisplay()
   METHOD display()
radiobtn.prg74
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )
radiobtn.prg75
METHODisAccel( xKey )
   METHOD isAccel( xKey )
radiobtn.prg76
METHODkillFocus()
   METHOD killFocus()
radiobtn.prg77
METHODselect( lState )
   METHOD select( lState )
radiobtn.prg78
METHODsetFocus()
   METHOD setFocus()
radiobtn.prg79
METHODbitmaps( aBitmaps ) SETGET
   METHOD bitmaps( aBitmaps ) SETGET
radiobtn.prg81
METHODbuffer() SETGET
   METHOD buffer() SETGET
radiobtn.prg82
METHODdata( cData ) SETGET
   METHOD data( cData ) SETGET               /* NOTE: Undocumented CA-Cl*pper 5.3 method. */
radiobtn.prg83
METHODcapCol( nCapCol ) SETGET
   METHOD capCol( nCapCol ) SETGET
radiobtn.prg84
METHODcapRow( nCapRow ) SETGET
   METHOD capRow( nCapRow ) SETGET
radiobtn.prg85
METHODcaption( cCaption ) SETGET
   METHOD caption( cCaption ) SETGET
radiobtn.prg86
METHODcol( nCol ) SETGET
   METHOD col( nCol ) SETGET
radiobtn.prg87
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
radiobtn.prg88
METHODfBlock( bFBlock ) SETGET
   METHOD fBlock( bFBlock ) SETGET
radiobtn.prg89
METHODhasFocus() SETGET
   METHOD hasFocus() SETGET
radiobtn.prg90
METHODrow( nRow ) SETGET
   METHOD row( nRow ) SETGET
radiobtn.prg91
METHODsBlock( bSBlock ) SETGET
   METHOD sBlock( bSBlock ) SETGET
radiobtn.prg92
METHODstyle( cStyle ) SETGET
   METHOD style( cStyle ) SETGET
radiobtn.prg93
METHODNew( nRow, nCol, cCaption, cData )
   METHOD New( nRow, nCol, cCaption, cData ) /* NOTE: This method is a Harbour extension [vszakats] */

   PROTECTED:

   VAR aBitmaps   INIT { "radio_f.bmu", "radio_e.bmu" }
   VAR lBuffer    INIT .F.
   VAR cData
   VAR nCapCol
   VAR nCapRow
   VAR cCaption
   VAR nCol
   VAR cColorSpec
   VAR bFBlock
   VAR lHasFocus  INIT .F.
   VAR nRow
   VAR bSBlock
   VAR cStyle     INIT "(* )"

ENDCLASS
radiobtn.prg95
RADIOBUTTN:METHODsetFocus() CLASS RADIOBUTTN
METHOD setFocus() CLASS RADIOBUTTN

   IF !::lHasFocus
      ::lHasFocus := .T.
      ::display()

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF
   ENDIF

   RETURN Self
radiobtn.prg115
RADIOBUTTN:METHODselect( lState ) CLASS RADIOBUTTN
METHOD select( lState ) CLASS RADIOBUTTN

   LOCAL lOldState := ::lBuffer

   ::lBuffer := iif( ISLOGICAL( lState ), lState, !::lBuffer )

   IF lOldState != ::lBuffer .AND. ;
      ISBLOCK( ::bSBlock )

      Eval( ::bSBlock )
   ENDIF

   RETURN Self
radiobtn.prg128
RADIOBUTTN:METHODkillFocus() CLASS RADIOBUTTN
METHOD killFocus() CLASS RADIOBUTTN
   
   IF ::lHasFocus
      ::lHasFocus := .F.

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF

      ::display()
   ENDIF

   RETURN Self
radiobtn.prg142
RADIOBUTTN:METHODdisplay() CLASS RADIOBUTTN
METHOD display() CLASS RADIOBUTTN
   
   LOCAL cOldColor := SetColor()      
   LOCAL nOldRow := Row()             
   LOCAL nOldCol := Col()             
   LOCAL lOldMCur := MSetCursor( .F. )

   LOCAL cStyle := ::cStyle
   LOCAL nPos
   LOCAL cOldCaption

   DispBegin()

   SetColor( iif( ::lBuffer, hb_ColorIndex( ::cColorSpec, 3 ), hb_ColorIndex( ::cColorSpec, 1 ) ) )
   SetPos( ::nRow, ::nCol )
   DispOut( Left( cStyle, 1 ) )
   DispOut( iif( ::lBuffer, SubStr( cStyle, 2, 1 ), SubStr( cStyle, 3, 1 ) ) )
   DispOut( Right( cStyle, 1 ) )

   IF !Empty( cOldCaption := ::cCaption )

      IF ( nPos := At( "&", cOldCaption ) ) == 0
      ELSEIF nPos == Len( cOldCaption )
         nPos := 0
      ELSE
         cOldCaption := Stuff( cOldCaption, nPos, 1, "" )
      ENDIF

      DispOutAt( ::nCapRow, ::nCapCol, cOldCaption, hb_ColorIndex( ::cColorSpec, 4 ) )

      IF nPos != 0
         DispOutAt( ::nCapRow, ::nCapCol + nPos - 1, SubStr( cOldCaption, nPos, 1 ), iif( ::lHasfocus, hb_ColorIndex( ::cColorSpec, 6 ), hb_ColorIndex( ::cColorSpec, 5 ) ) )
      ENDIF
   ENDIF

   DispEnd()

   MSetCursor( lOldMCur )
   SetColor( cOldColor )
   SetPos( nOldRow, nOldCol )

   RETURN Self
radiobtn.prg156
RADIOBUTTN:METHODisAccel( xKey ) CLASS RADIOBUTTN
METHOD isAccel( xKey ) CLASS RADIOBUTTN
   
   LOCAL nPos
   LOCAL cCaption

   IF ISNUMBER( xKey )
      xKey := Chr( xKey )
   ELSEIF !ISCHARACTER( xKey )
      RETURN .F.
   ENDIF

   cCaption := ::cCaption

   RETURN ( nPos := At( "&", cCaption ) ) > 0 .AND. ;
          Lower( SubStr( cCaption, nPos + 1, 1 ) ) == Lower( xKey )
radiobtn.prg199
RADIOBUTTN:METHODhitTest( nMRow, nMCol ) CLASS RADIOBUTTN
METHOD hitTest( nMRow, nMCol ) CLASS RADIOBUTTN

   LOCAL nPos
   LOCAL nLen

   IF nMRow == ::Row .AND. ;
      nMCol >= ::Col .AND. ;
      nMCol < ::Col + 3
      RETURN HTCLIENT
   ENDIF

   nLen := Len( ::cCaption )

   IF ( nPos := At( "&", ::cCaption ) ) == 0 .AND. nPos < nLen
      nLen--
   ENDIF

   IF nMRow == ::CapRow .AND. ;
      nMCol >= ::CapCol .AND. ;
      nMCol < ::CapCol + nLen
      RETURN HTCLIENT
   ENDIF

   RETURN HTNOWHERE
radiobtn.prg215
RADIOBUTTN:METHODbitmaps( aBitmaps ) CLASS RADIOBUTTN
METHOD bitmaps( aBitmaps ) CLASS RADIOBUTTN

   IF aBitmaps != NIL
      ::aBitmaps := __eInstVar53( Self, "BITMAPS", aBitmaps, "A", 1001, {|| Len( aBitmaps ) == 2 } )
   ENDIF

   RETURN ::aBitmaps
radiobtn.prg240
RADIOBUTTN:METHODbuffer() CLASS RADIOBUTTN
METHOD buffer() CLASS RADIOBUTTN
   RETURN ::lBuffer
radiobtn.prg248
RADIOBUTTN:METHODdata( cData ) CLASS RADIOBUTTN
METHOD data( cData ) CLASS RADIOBUTTN
   
   IF PCount() > 0
      ::cData := iif( cData == NIL, NIL, __eInstVar53( Self, "DATA", cData, "C", 1001 ) )
   ENDIF

   RETURN iif( ::cData == NIL, __Caption( ::Caption ), ::cData )
radiobtn.prg251
RADIOBUTTN:METHODcapCol( nCapCol ) CLASS RADIOBUTTN
METHOD capCol( nCapCol ) CLASS RADIOBUTTN

   IF nCapCol != NIL
      ::nCapCol := __eInstVar53( Self, "CAPCOL", nCapCol, "N", 1001 )
   ENDIF

   RETURN ::nCapCol
radiobtn.prg259
RADIOBUTTN:METHODcapRow( nCapRow ) CLASS RADIOBUTTN
METHOD capRow( nCapRow ) CLASS RADIOBUTTN

   IF nCapRow != NIL
      ::nCapRow := __eInstVar53( Self, "CAPROW", nCapRow, "N", 1001 )
   ENDIF

   RETURN ::nCapRow
radiobtn.prg267
RADIOBUTTN:METHODcaption( cCaption ) CLASS RADIOBUTTN
METHOD caption( cCaption ) CLASS RADIOBUTTN

   IF cCaption != NIL
      ::cCaption := __eInstVar53( Self, "CAPTION", cCaption, "C", 1001 )
   ENDIF

   RETURN ::cCaption
radiobtn.prg275
RADIOBUTTN:METHODcol( nCol ) CLASS RADIOBUTTN
METHOD col( nCol ) CLASS RADIOBUTTN

   IF nCol != NIL
      ::nCol := __eInstVar53( Self, "COL", nCol, "N", 1001 )
   ENDIF

   RETURN ::nCol
radiobtn.prg283
RADIOBUTTN:METHODcolorSpec( cColorSpec ) CLASS RADIOBUTTN
METHOD colorSpec( cColorSpec ) CLASS RADIOBUTTN

   IF cColorSpec != NIL
      ::cColorSpec := __eInstVar53( Self, "COLORSPEC", cColorSpec, "C", 1001,;
         {|| !Empty( hb_ColorIndex( cColorSpec, 6 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 7 ) ) } )
   ENDIF

   RETURN ::cColorSpec
radiobtn.prg291
RADIOBUTTN:METHODfBlock( bFBlock ) CLASS RADIOBUTTN
METHOD fBlock( bFBlock ) CLASS RADIOBUTTN
   
   IF PCount() > 0
      ::bFBlock := iif( bFBlock == NIL, NIL, __eInstVar53( Self, "FBLOCK", bFBlock, "B", 1001 ) )
   ENDIF

   RETURN ::bFBlock
radiobtn.prg300
RADIOBUTTN:METHODhasFocus() CLASS RADIOBUTTN
METHOD hasFocus() CLASS RADIOBUTTN
   RETURN ::lHasFocus
radiobtn.prg308
RADIOBUTTN:METHODrow( nRow ) CLASS RADIOBUTTN
METHOD row( nRow ) CLASS RADIOBUTTN

   IF nRow != NIL
      ::nRow := __eInstVar53( Self, "ROW", nRow, "N", 1001 )
   ENDIF

   RETURN ::nRow
radiobtn.prg311
RADIOBUTTN:METHODsBlock( bSBlock ) CLASS RADIOBUTTN
METHOD sBlock( bSBlock ) CLASS RADIOBUTTN
   
   IF PCount() > 0
      ::bSBlock := iif( bSBlock == NIL, NIL, __eInstVar53( Self, "SBLOCK", bSBlock, "B", 1001 ) )
   ENDIF

   RETURN ::bSBlock
radiobtn.prg319
RADIOBUTTN:METHODstyle( cStyle ) CLASS RADIOBUTTN
METHOD style( cStyle ) CLASS RADIOBUTTN

   IF cStyle != NIL
      ::cStyle := __eInstVar53( Self, "STYLE", cStyle, "C", 1001, {|| Len( cStyle ) == 0 .OR. Len( cStyle ) == 4 } )
   ENDIF

   RETURN ::cStyle
radiobtn.prg327
RADIOBUTTN:METHODNew( nRow, nCol, cCaption, cData ) CLASS RADIOBUTTN
METHOD New( nRow, nCol, cCaption, cData ) CLASS RADIOBUTTN

   LOCAL cColor

   IF !ISNUMBER( nRow ) .OR. ;
      !ISNUMBER( nCol )
      RETURN NIL
   ENDIF

   IF !ISCHARACTER( cCaption )
      cCaption := ""
   ENDIF

   ::nCapRow  := nRow
   ::nCapCol  := nCol + 3 + 1
   ::cCaption := cCaption
   ::nCol     := nCol
   ::nRow     := nRow
   ::cData    := cData /* NOTE: Every type is allowed here to be fully compatible */

   IF IsDefColor()
      ::cColorSpec := "W/N,W+/N,W+/N,N/W,W/N,W/N,W+/N"
   ELSE
      cColor := SetColor()
      ::cColorSpec := hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," +;
                      hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," +;
                      hb_ColorIndex( cColor, CLR_ENHANCED   ) + "," +;
                      hb_ColorIndex( cColor, CLR_ENHANCED   ) + "," +;
                      hb_ColorIndex( cColor, CLR_STANDARD   ) + "," +;
                      hb_ColorIndex( cColor, CLR_STANDARD   ) + "," +;
                      hb_ColorIndex( cColor, CLR_BACKGROUND )
   ENDIF

   RETURN Self
radiobtn.prg335
FUNCTIONRadioButto( nRow, nCol, cCaption, cData )
FUNCTION RadioButto( nRow, nCol, cCaption, cData ) /* NOTE: cData argument is undocumented */
   RETURN HBRadioButton():New( nRow, nCol, cCaption, cData )
radiobtn.prg370
FUNCTIONRadioButton( nRow, nCol, cCaption, cData )
FUNCTION RadioButton( nRow, nCol, cCaption, cData ) /* NOTE: cData argument is undocumented */
   RETURN HBRadioButton():New( nRow, nCol, cCaption, cData )
radiobtn.prg375
radiogrp.prg
TypeFunctionSourceLine
METHODaddItem( oRadioButton )
   METHOD addItem( oRadioButton )
radiogrp.prg75
METHODdelItem( oRadioButton )
   METHOD delItem( oRadioButton )
radiogrp.prg76
METHODdisplay()
   METHOD display()
radiogrp.prg77
METHODgetAccel( oRadioButton )
   METHOD getAccel( oRadioButton )
radiogrp.prg78
METHODgetItem( oRadioButton )
   METHOD getItem( oRadioButton )
radiogrp.prg79
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )
radiogrp.prg80
METHODinsItem( nPos, oRadioButton )
   METHOD insItem( nPos, oRadioButton )
radiogrp.prg81
METHODkillFocus()
   METHOD killFocus()
radiogrp.prg82
METHODnextItem()
   METHOD nextItem()
radiogrp.prg83
METHODprevItem()
   METHOD prevItem()
radiogrp.prg84
METHODselect( xPos )
   METHOD select( xPos )
radiogrp.prg85
METHODsetColor( cColorSpec )
   METHOD setColor( cColorSpec )
radiogrp.prg86
METHODsetFocus()
   METHOD setFocus()
radiogrp.prg87
METHODsetStyle( cStyle )
   METHOD setStyle( cStyle )
radiogrp.prg88
METHODbottom( nBottom ) SETGET
   METHOD bottom( nBottom ) SETGET
radiogrp.prg90
METHODbuffer() SETGET
   METHOD buffer() SETGET
radiogrp.prg91
METHODcapCol( nCapCol ) SETGET
   METHOD capCol( nCapCol ) SETGET
radiogrp.prg92
METHODcapRow( nCapRow ) SETGET
   METHOD capRow( nCapRow ) SETGET
radiogrp.prg93
METHODcaption( cCaption ) SETGET
   METHOD caption( cCaption ) SETGET
radiogrp.prg94
METHODcoldBox( cColdBox ) SETGET
   METHOD coldBox( cColdBox ) SETGET
radiogrp.prg95
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
radiogrp.prg96
METHODfBlock( bFBlock ) SETGET
   METHOD fBlock( bFBlock ) SETGET
radiogrp.prg97
METHODhasFocus() SETGET
   METHOD hasFocus() SETGET
radiogrp.prg98
METHODhotBox( cHotBox ) SETGET
   METHOD hotBox( cHotBox ) SETGET
radiogrp.prg99
METHODitemCount() SETGET
   METHOD itemCount() SETGET
radiogrp.prg100
METHODleft( nLeft ) SETGET
   METHOD left( nLeft ) SETGET
radiogrp.prg101
METHODmessage( cMessage ) SETGET
   METHOD message( cMessage ) SETGET
radiogrp.prg102
METHODright( nRight ) SETGET
   METHOD right( nRight ) SETGET
radiogrp.prg103
METHODtextValue() SETGET
   METHOD textValue() SETGET                  /* NOTE: Undocumented CA-Cl*pper var. */
radiogrp.prg104
METHODtop( nTop ) SETGET
   METHOD top( nTop ) SETGET
radiogrp.prg105
METHODtypeOut() SETGET
   METHOD typeOut() SETGET
radiogrp.prg106
METHODvalue() SETGET
   METHOD value() SETGET                      /* NOTE: Undocumented CA-Cl*pper var. */
radiogrp.prg107
METHODNew( nTop, nLeft, nBottom, nRight )
   METHOD New( nTop, nLeft, nBottom, nRight ) /* NOTE: This method is a Harbour extension [vszakats] */

   PROTECTED:

   VAR nBottom
   VAR xBuffer
   VAR nCapCol
   VAR nCapRow
   VAR cCaption   INIT ""
   VAR cColdBox   INIT Chr( 218 ) + Chr( 196 ) + Chr( 191 ) + Chr( 179 ) + Chr( 217 ) + Chr( 196 ) + Chr( 192 ) + Chr( 179 )
   VAR cColorSpec
   VAR bFBlock
   VAR lHasFocus  INIT .F.
   VAR cHotBox    INIT Chr( 201 ) + Chr( 205 ) + Chr( 187 ) + Chr( 186 ) + Chr( 188 ) + Chr( 205 ) + Chr( 200 ) + Chr( 186 )
   VAR nItemCount INIT 0
   VAR nLeft
   VAR cMessage   INIT ""
   VAR nRight
   VAR cTextValue INIT ""
   VAR nTop
   VAR nValue     INIT 0

   VAR aItems     INIT {}
   VAR nCursor    INIT 0
radiogrp.prg109
METHODchangeButton( xVal, nPos )
   METHOD changeButton( xVal, nPos )

ENDCLASS
radiogrp.prg134
RADIOGROUP:METHODaddItem( oRadioButton ) CLASS RADIOGROUP
METHOD addItem( oRadioButton ) CLASS RADIOGROUP

   IF ISOBJECT( oRadioButton ) .AND. oRadioButton:ClassName() == "RADIOBUTTN"
      AAdd( ::aItems, oRadioButton )
      ::nItemCount++
   ENDIF

   RETURN Self
radiogrp.prg138
RADIOGROUP:METHODdelItem( nPos ) CLASS RADIOGROUP
METHOD delItem( nPos ) CLASS RADIOGROUP

   IF nPos >= 1 .AND. nPos <= ::nItemCount
      ADel( ::aItems[ nPos ] )
      ASize( ::aItems, --::nItemCount )
   ENDIF

   IF ::lHasFocus .AND. ::nItemCount < ::nValue
      ::nValue := ::nItemCount
      ::cTextValue := ::aItems[ ::nValue ]:data
      ::xBuffer := iif( ISNUMBER( ::xBuffer ), ::nValue, ::cTextValue )
   ENDIF

   RETURN Self
radiogrp.prg147
RADIOGROUP:METHODdisplay() CLASS RADIOGROUP
METHOD display() CLASS RADIOGROUP

   LOCAL cOldColor := SetColor()      
   LOCAL nOldRow := Row()             
   LOCAL nOldCol := Col()             
   LOCAL lOldMCur := MSetCursor( .F. )

   LOCAL cSelBox
   LOCAL cUnSelBox
   LOCAL cCaption
   LOCAL nPos

   DispBegin()

   IF ::lHasFocus
      cSelBox := ::cHotBox
      cUnSelBox := ::cColdbox
   ELSE
      cSelBox := ::cColdbox
      cUnSelBox := ::cHotBox
   ENDIF

   SetColor( hb_ColorIndex( ::cColorSpec, 0 ) )

   IF !Empty( cSelBox )
      DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, cSelBox )
   ELSEIF !Empty( cUnSelBox )
      DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, cUnSelBox )
   ENDIF

   IF !Empty( cCaption := ::cCaption )

      IF !( ( nPos := At( "&", cCaption ) ) == 0 )
         IF nPos == Len( cCaption )
            nPos := 0
         ELSE
            cCaption := Stuff( cCaption, nPos, 1, "" )
         ENDIF
      ENDIF

      DispOutAt( ::nCapRow, ::nCapCol, cCaption, hb_ColorIndex( ::cColorSpec, 1 ) )

      IF nPos != 0
         DispOutAt( ::nCapRow, ::nCapCol + nPos - 1, SubStr( cCaption, nPos, 1 ), hb_ColorIndex( ::cColorSpec, 2 ) )
      ENDIF

   ENDIF

   AEval( ::aItems, {| o | o:display() } )

   DispEnd()

   MSetCursor( lOldMCur )
   SetColor( cOldColor )
   SetPos( nOldRow, nOldCol )

   RETURN Self
radiogrp.prg162
RADIOGROUP:METHODgetAccel( xValue ) CLASS RADIOGROUP
METHOD getAccel( xValue ) CLASS RADIOGROUP

   DO CASE
   CASE ISNUMBER( xValue )
      xValue := Chr( xValue )
   CASE !ISCHARACTER( xValue )
      RETURN 0
   ENDCASE

   xValue := Lower( xValue )

   RETURN AScan( ::aItems, {| o | o:isAccel( xValue ) } )
radiogrp.prg220
RADIOGROUP:METHODgetItem( nPos ) CLASS RADIOGROUP
METHOD getItem( nPos ) CLASS RADIOGROUP
   RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ], NIL )
radiogrp.prg233
RADIOGROUP:METHODhitTest( nMRow, nMCol ) CLASS RADIOGROUP
METHOD hitTest( nMRow, nMCol ) CLASS RADIOGROUP

   LOCAL nLen
   LOCAL nPos
   LOCAL aItems

   DO CASE
   CASE Empty( ::cColdbox + ::cHotBox )
   CASE nMRow == ::nTop
      IF nMCol == ::nLeft
         RETURN HTTOPLEFT
      ELSEIF nMCol == ::nRight
         RETURN HTTOPRIGHT
      ELSEIF nMCol >= ::nLeft .AND. nMCol <= ::nRight
         RETURN HTTOP
      ENDIF
   CASE nMRow == ::nBottom
      IF nMCol == ::nLeft
         RETURN HTBOTTOMLEFT
      ELSEIF nMCol == ::nRight
         RETURN HTBOTTOM
      ELSEIF nMCol >= ::nLeft .AND. nMCol <= ::nRight
         RETURN HTBOTTOMRIGHT
      ENDIF
   CASE nMCol == ::nLeft
      IF nMRow >= ::nTop .AND. nMRow <= ::nBottom
         RETURN HTLEFT
      ELSE
         RETURN HTNOWHERE
      ENDIF
   CASE nMCol == ::nRight
      IF nMRow >= ::nTop .AND. nMRow <= ::nBottom
         RETURN HTRIGHT
      ELSE
         RETURN HTNOWHERE
      ENDIF
   ENDCASE

   nLen := Len( ::cCaption )

   IF ( nPos := At( "&", ::cCaption ) ) == 0
   ELSEIF nPos < nLen
      nLen--
   ENDIF

   DO CASE
   CASE Empty( ::cCaption )
   CASE nMRow != ::nCapRow
   CASE nMCol < ::nCapCol
   CASE nMCol < ::nCapCol + nLen
      RETURN HTCAPTION
   ENDCASE

   DO CASE
   CASE nMRow < ::nTop
   CASE nMRow > ::nBottom
   CASE nMCol < ::nLeft
   CASE nMCol <= ::nRight
      aItems := ::aItems
      nLen := ::nItemCount
      FOR nPos := 1 TO nLen
         IF aItems[ nPos ]:hitTest( nMRow, nMCol ) != HTNOWHERE
            RETURN nPos
         ENDIF
      NEXT
      RETURN HTCLIENT
   ENDCASE

   RETURN HTNOWHERE
radiogrp.prg236
RADIOGROUP:METHODinsItem( nPos, oRadioButtom ) CLASS RADIOGROUP
METHOD insItem( nPos, oRadioButtom ) CLASS RADIOGROUP

   IF ISOBJECT( oRadioButtom ) .AND. oRadioButtom:ClassName() == "RADIOBUTTN" .AND. ;
      nPos < ::nItemCount

      ASize( ::aItems, ++::nItemCount )
      AIns( ::aItems, nPos, oRadioButtom )
      ::aItems[ nPos ] := oRadioButtom
   ENDIF

   RETURN ::aItems[ nPos ]
radiogrp.prg306
RADIOGROUP:METHODkillFocus() CLASS RADIOGROUP
METHOD killFocus() CLASS RADIOGROUP

   LOCAL nPos
   LOCAL nLen
   LOCAL aItems

   LOCAL nOldMCur

   IF ::lHasFocus

      ::lHasFocus := .F.

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF

      aItems := ::aItems
      nLen := ::nItemCount

      nOldMCur := MSetCursor( .F. )

      DispBegin()

      FOR nPos := 1 TO nLen
         aItems[ nPos ]:killFocus()
      NEXT

      ::display()

      DispEnd()

      MSetCursor( nOldMCur )
      SetCursor( ::nCursor )

   ENDIF

   RETURN Self
radiogrp.prg318
RADIOGROUP:METHODsetFocus() CLASS RADIOGROUP
METHOD setFocus() CLASS RADIOGROUP

   LOCAL nPos
   LOCAL nLen
   LOCAL aItems

   LOCAL nOldMCur

   IF !::lHasFocus

      ::nCursor := SetCursor( SC_NONE )
      ::lHasFocus := .T.

      aItems := ::aItems
      nLen := ::nItemCount

      nOldMCur := MSetCursor( .F. )

      DispBegin()

      FOR nPos := 1 TO nLen
         aItems[ nPos ]:setFocus()
      NEXT

      ::display()

      DispEnd()

      MSetCursor( nOldMCur )

      IF ISBLOCK( ::bFBlock )
         Eval( ::bFBlock )
      ENDIF
   ENDIF

   RETURN Self
radiogrp.prg356
RADIOGROUP:METHODnextItem() CLASS RADIOGROUP
METHOD nextItem() CLASS RADIOGROUP
   LOCAL nValue

   IF ::lHasFocus .AND. ::nItemCount > 0
      ::changeButton( nValue := ::nValue, iif( nValue == ::nItemCount, 1, nValue + 1 ) )
   ENDIF

   RETURN Self
radiogrp.prg393
RADIOGROUP:METHODprevItem() CLASS RADIOGROUP
METHOD prevItem() CLASS RADIOGROUP

   LOCAL nValue
   LOCAL nPos

   IF ::lHasFocus .AND. ::nItemCount > 0

      nValue := ::nValue

      DO CASE
      CASE nValue == 0 ; nPos := 1
      CASE nValue == 1 ; nPos := ::nItemCount
      OTHERWISE        ; nPos := nValue - 1
      ENDCASE

      ::changeButton( nValue, nPos )

   ENDIF

   RETURN Self
radiogrp.prg402
RADIOGROUP:METHODselect( xValue ) CLASS RADIOGROUP
METHOD select( xValue ) CLASS RADIOGROUP

   LOCAL cType := ValType( xValue )
   LOCAL nPos
   LOCAL nLen

   IF cType == "C"

      nLen := ::nItemCount
      FOR nPos := 1 TO nLen
         IF ::aItems[ nPos ]:data == xValue

            DEFAULT ::xBuffer TO ""
            ::changeButton( ::nValue, nPos )

            EXIT
         ENDIF
      NEXT

      IF nPos > nLen
         ::xBuffer := xValue
      ENDIF

   ELSEIF cType == "N" .AND. xValue >= 1 .AND. xValue <= ::nItemCount

      DEFAULT ::xBuffer TO 0
      ::changeButton( ::nValue, xValue )

   ENDIF

   RETURN Self
radiogrp.prg423
RADIOGROUP:METHODsetColor( cColorSpec ) CLASS RADIOGROUP
METHOD setColor( cColorSpec ) CLASS RADIOGROUP

   LOCAL nPos
   LOCAL nLen := ::nItemCount
   LOCAL aItems := ::aItems

   FOR nPos := 1 TO nLen
      aItems[ nPos ]:colorSpec := cColorSpec
   NEXT

   RETURN Self
radiogrp.prg455
RADIOGROUP:METHODsetStyle( cStyle ) CLASS RADIOGROUP
METHOD setStyle( cStyle ) CLASS RADIOGROUP
   
   LOCAL nPos
   LOCAL nLen := ::nItemCount
   LOCAL aItems := ::aItems

   FOR nPos := 1 TO nLen
      aItems[ nPos ]:style := cStyle
   NEXT

   RETURN Self
radiogrp.prg467
RADIOGROUP:METHODchangeButton( nUnselect, nSelect ) CLASS RADIOGROUP
METHOD changeButton( nUnselect, nSelect ) CLASS RADIOGROUP
   LOCAL nOldMCur := MSetCursor( .F. )

   IF nUnselect != nSelect

      DispBegin()

      IF nUnselect > 0
         ::aItems[ nUnselect ]:select( .F. )
         ::aItems[ nUnselect ]:display()
      ENDIF
      IF nSelect > 0
         ::aItems[ nSelect ]:select( .T. )
         ::aItems[ nSelect ]:display()
      ENDIF

      DispEnd()

      ::nValue := nSelect
      ::cTextValue := ::aItems[ nSelect ]:data
      ::xBuffer := iif( ISNUMBER( ::xBuffer ), nSelect, ::cTextValue )

   ENDIF

   MSetCursor( nOldMCur )

   RETURN Self
radiogrp.prg479
RADIOGROUP:METHODbottom( nBottom ) CLASS RADIOGROUP
METHOD bottom( nBottom ) CLASS RADIOGROUP

   IF nBottom != NIL
      ::nBottom := __eInstVar53( Self, "BOTTOM", nBottom, "N", 1001 )
   ENDIF

   RETURN ::nBottom
radiogrp.prg507
RADIOGROUP:METHODbuffer() CLASS RADIOGROUP
METHOD buffer() CLASS RADIOGROUP
   RETURN ::xBuffer
radiogrp.prg515
RADIOGROUP:METHODcapCol( nCapCol ) CLASS RADIOGROUP
METHOD capCol( nCapCol ) CLASS RADIOGROUP

   IF nCapCol != NIL
      ::nCapCol := __eInstVar53( Self, "CAPCOL", nCapCol, "N", 1001 )
   ENDIF

   RETURN ::nCapCol
radiogrp.prg518
RADIOGROUP:METHODcapRow( nCapRow ) CLASS RADIOGROUP
METHOD capRow( nCapRow ) CLASS RADIOGROUP

   IF nCapRow != NIL
      ::nCapRow := __eInstVar53( Self, "CAPROW", nCapRow, "N", 1001 )
   ENDIF

   RETURN ::nCapRow
radiogrp.prg526
RADIOGROUP:METHODcaption( cCaption ) CLASS RADIOGROUP
METHOD caption( cCaption ) CLASS RADIOGROUP

   IF cCaption != NIL
      ::cCaption := __eInstVar53( Self, "CAPTION", cCaption, "C", 1001 )
   ENDIF

   RETURN ::cCaption
radiogrp.prg534
RADIOGROUP:METHODcoldBox( cColdBox ) CLASS RADIOGROUP
METHOD coldBox( cColdBox ) CLASS RADIOGROUP

   IF cColdBox != NIL
      ::cColdBox := __eInstVar53( Self, "COLDBOX", cColdBox, "C", 1001, {|| Len( cColdBox ) == 0 .OR. Len( cColdBox ) == 8 } )
   ENDIF

   RETURN ::cColdBox
radiogrp.prg542
RADIOGROUP:METHODcolorSpec( cColorSpec ) CLASS RADIOGROUP
METHOD colorSpec( cColorSpec ) CLASS RADIOGROUP

   IF cColorSpec != NIL
      ::cColorSpec := __eInstVar53( Self, "COLORSPEC", cColorSpec, "C", 1001,;
         {|| !Empty( hb_ColorIndex( cColorSpec, 2 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 3 ) ) } )
   ENDIF

   RETURN ::cColorSpec
radiogrp.prg550
RADIOGROUP:METHODfBlock( bFBlock ) CLASS RADIOGROUP
METHOD fBlock( bFBlock ) CLASS RADIOGROUP
   
   IF PCount() > 0
      ::bFBlock := iif( bFBlock == NIL, NIL, __eInstVar53( Self, "FBLOCK", bFBlock, "B", 1001 ) )
   ENDIF

   RETURN ::bFBlock
radiogrp.prg559
RADIOGROUP:METHODhasFocus() CLASS RADIOGROUP
METHOD hasFocus() CLASS RADIOGROUP
   RETURN ::lHasFocus
radiogrp.prg567
RADIOGROUP:METHODhotBox( cHotBox ) CLASS RADIOGROUP
METHOD hotBox( cHotBox ) CLASS RADIOGROUP

   IF cHotBox != NIL
      ::cHotBox := __eInstVar53( Self, "HOTBOX", cHotBox, "C", 1001, {|| Len( cHotBox ) == 0 .OR. Len( cHotBox ) == 8 } )
   ENDIF

   RETURN ::cHotBox
radiogrp.prg570
RADIOGROUP:METHODitemCount() CLASS RADIOGROUP
METHOD itemCount() CLASS RADIOGROUP
   RETURN ::nItemCount
radiogrp.prg578
RADIOGROUP:METHODleft( nLeft ) CLASS RADIOGROUP
METHOD left( nLeft ) CLASS RADIOGROUP

   IF nLeft != NIL
      ::nLeft := __eInstVar53( Self, "LEFT", nLeft, "N", 1001 )
   ENDIF

   RETURN ::nLeft
radiogrp.prg581
RADIOGROUP:METHODmessage( cMessage ) CLASS RADIOGROUP
METHOD message( cMessage ) CLASS RADIOGROUP

   IF cMessage != NIL
      ::cMessage := __eInstVar53( Self, "MESSAGE", cMessage, "C", 1001 )
   ENDIF

   RETURN ::cMessage
radiogrp.prg589
RADIOGROUP:METHODright( nRight ) CLASS RADIOGROUP
METHOD right( nRight ) CLASS RADIOGROUP

   IF nRight != NIL
      ::nRight := __eInstVar53( Self, "RIGHT", nRight, "N", 1001 )
   ENDIF

   RETURN ::nRight
radiogrp.prg597
RADIOGROUP:METHODtextValue() CLASS RADIOGROUP
METHOD textValue() CLASS RADIOGROUP 
   RETURN ::cTextValue
radiogrp.prg605
RADIOGROUP:METHODtop( nTop ) CLASS RADIOGROUP
METHOD top( nTop ) CLASS RADIOGROUP

   IF nTop != NIL
      ::nTop := __eInstVar53( Self, "TOP", nTop, "N", 1001 )
   ENDIF

   RETURN ::nTop
radiogrp.prg608
RADIOGROUP:METHODtypeOut() CLASS RADIOGROUP
METHOD typeOut() CLASS RADIOGROUP
   RETURN ::nItemCount == 0 .OR. ::nValue > ::nItemCount
radiogrp.prg616
RADIOGROUP:METHODvalue() CLASS RADIOGROUP
METHOD value() CLASS RADIOGROUP
   RETURN ::nValue
radiogrp.prg619
RADIOGROUP:METHODNew( nTop, nLeft, nBottom, nRight ) CLASS RADIOGROUP
METHOD New( nTop, nLeft, nBottom, nRight ) CLASS RADIOGROUP

   LOCAL cColor

   IF !ISNUMBER( nTop ) .OR. ;
      !ISNUMBER( nLeft ) .OR. ;
      !ISNUMBER( nBottom ) .OR. ;
      !ISNUMBER( nRight )
      RETURN NIL
   ENDIF

   ::nTop    := nTop
   ::nLeft   := nLeft
   ::nBottom := nBottom
   ::nRight  := nRight
   ::nCapCol := nLeft + 2
   ::nCapRow := nTop

   IF IsDefColor()
      ::cColorSpec := "W/N,W/N,W+/N"
   ELSE
      cColor := SetColor()
      ::cColorSpec := hb_ColorIndex( cColor, CLR_BORDER     ) + "," + ;
                      hb_ColorIndex( cColor, CLR_STANDARD   ) + "," + ;
                      hb_ColorIndex( cColor, CLR_BACKGROUND )
   ENDIF

   RETURN Self
radiogrp.prg622
FUNCTIONRadioGroup( nTop, nLeft, nBottom, nRight )
FUNCTION RadioGroup( nTop, nLeft, nBottom, nRight )
   RETURN HBRadioGroup():New( nTop, nLeft, nBottom, nRight )
radiogrp.prg651
FUNCTION_RADIOGRP_( nTop, nLeft, nBottom, nRight, xValue, aItems, cCaption, cMessage, cColorSpec, bFBlock )
FUNCTION _RADIOGRP_( nTop, nLeft, nBottom, nRight, xValue, aItems, cCaption, cMessage, cColorSpec, bFBlock )

   LOCAL o := RadioGroup( nTop, nLeft, nBottom, nRight )

   IF o != NIL

      o:caption := cCaption
      o:message := cMessage
      o:colorSpec := cColorSpec
      o:fBlock := bFBlock

      AEval( aItems, {| aItem | o:AddItem( aItem ) } )

      o:select( xValue )

   ENDIF

   RETURN o
radiogrp.prg654
readkey.prg
TypeFunctionSourceLine
FUNCTIONReadKey()
FUNCTION ReadKey()
   LOCAL nKey := LastKey()

   SWITCH nKey
      CASE K_UP        ; nKey :=  4 ; EXIT /* NOTE: NG says 5 incorrectly */
      CASE K_DOWN      ; nKey :=  5 ; EXIT /* NOTE: NG says 2 incorrectly */
      CASE K_PGUP      ; nKey :=  6 ; EXIT
      CASE K_PGDN      ; nKey :=  7 ; EXIT
      CASE K_CTRL_PGUP ; nKey := 34 ; EXIT /* NOTE: NG says 31 incorrectly */
      CASE K_CTRL_PGDN ; nKey := 35 ; EXIT /* NOTE: NG says 30 incorrectly */
      CASE K_ESC       ; nKey := 12 ; EXIT
      CASE K_CTRL_W    ; nKey := 14 ; EXIT
      CASE K_ENTER     ; nKey := 15 ; EXIT
      OTHERWISE
         IF nKey >= K_SPACE ; nKey := 15
         ELSE               ; RETURN 0
         ENDIF
   ENDSWITCH

   IF Updated()
      nKey += 256
   ENDIF

   RETURN nKey
readkey.prg55
readvar.prg
TypeFunctionSourceLine
FUNCTIONReadVar( cVarName )
FUNCTION ReadVar( cVarName )
   THREAD STATIC s_cVarName := ""

   LOCAL cOldVarName
   LOCAL oGetList

   IF ( oGetList := __GetListActive() ) != NIL
      RETURN oGetList:ReadVar( cVarName )
   ENDIF

   cOldVarName := s_cVarName

   IF ISCHARACTER( cVarName )
      s_cVarName := cVarName
   ENDIF

RETURN cOldVarName
readvar.prg55
scrollbr.prg
TypeFunctionSourceLine
METHODbarLength() SETGET
   METHOD barLength() SETGET
scrollbr.prg74
METHODbitmaps( aBitmaps ) SETGET
   METHOD bitmaps( aBitmaps ) SETGET
scrollbr.prg75
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
scrollbr.prg76
METHODcurrent( nCurrent ) SETGET
   METHOD current( nCurrent ) SETGET
scrollbr.prg77
METHODend( nEnd ) SETGET
   METHOD end( nEnd ) SETGET
scrollbr.prg78
METHODoffset( nOffset ) SETGET
   METHOD offset( nOffset ) SETGET
scrollbr.prg79
METHODorient( nOrient ) SETGET
   METHOD orient( nOrient ) SETGET
scrollbr.prg80
METHODsBlock( bSBlock ) SETGET
   METHOD sBlock( bSBlock ) SETGET
scrollbr.prg81
METHODstart( nStart ) SETGET
   METHOD start( nStart ) SETGET
scrollbr.prg82
METHODstyle( cStyle ) SETGET
   METHOD style( cStyle ) SETGET
scrollbr.prg83
METHODthumbPos( nThumbPos ) SETGET
   METHOD thumbPos( nThumbPos ) SETGET
scrollbr.prg84
METHODtotal( nTotal ) SETGET
   METHOD total( nTotal ) SETGET
scrollbr.prg85
METHODdisplay()
   METHOD display()
scrollbr.prg87
METHODupdate()
   METHOD update()
scrollbr.prg88
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )
scrollbr.prg89
METHODNew( nStart, nEnd, nOffset, bSBlock, nOrient )
   METHOD New( nStart, nEnd, nOffset, bSBlock, nOrient ) /* NOTE: This method is a Harbour extension [vszakats] */

   PROTECTED:

   VAR aBitmaps
   VAR nBarLength
   VAR cColorSpec
   VAR cStyle
   VAR nCurrent   INIT 1
   VAR nEnd       INIT 0
   VAR nOffset
   VAR nOrient
   VAR nStart     INIT 0
   VAR nThumbPos  INIT 1
   VAR nTotal     INIT 100
   VAR bSBlock

   VAR lOverride  INIT .F.
scrollbr.prg91
METHODCalcThumbPos()
   METHOD CalcThumbPos()

ENDCLASS
scrollbr.prg110
SCROLLBAR:METHODdisplay() CLASS SCROLLBAR
METHOD display() CLASS SCROLLBAR

   LOCAL cOldColor
   LOCAL nOldRow
   LOCAL nOldCol
   LOCAL lOldMCur

   LOCAL cStyle
   LOCAL nOffset
   LOCAL nStart
   LOCAL nEnd
   LOCAL nPos

   IF ::CalcThumbPos()

      cOldColor := SetColor()      
      nOldRow := Row()             
      nOldCol := Col()             
      lOldMCur := MSetCursor( .F. )

      cStyle    := ::cStyle
      nOffset   := ::nOffset
      nStart    := ::nStart
      nEnd      := ::nEnd - 1
      
      DispBegin()
      
      SetColor( hb_ColorIndex( ::cColorSpec, 0 ) )
      
      IF ::nOrient == SCROLL_VERTICAL

         FOR nPos := nStart + 1 TO nEnd
            DispOutAt( nPos, nOffset, SubStr( cStyle, 2, 1 ) )
         NEXT

         SetColor( hb_ColorIndex( ::cColorSpec, 1 ) )
         DispOutAt( nStart, nOffset, SubStr( cStyle, 1, 1 ) )
         DispOutAt( nStart + ::nThumbPos, nOffset, SubStr( cStyle, 3, 1 ) )
         DispOutAt( nEnd + 1, nOffset, SubStr( cStyle, 4, 1 ) )
      ELSE

         DispOutAt( nOffset, nStart + 1, Replicate( SubStr( cStyle, 2, 1 ), nEnd - nStart ) )
      
         SetColor( hb_ColorIndex( ::cColorSpec, 1 ) )
         DispOutAt( nOffset, nStart, SubStr( cStyle, 1, 1 ) )
         DispOutAt( nOffset, nStart + ::nThumbPos, SubStr( cStyle, 3, 1 ) )
         DispOutAt( nOffset, nEnd + 1, SubStr( cStyle, 4, 1 ) )

      ENDIF
      
      DispEnd()
      
      MSetCursor( lOldMCur )
      SetColor( cOldColor )
      SetPos( nOldRow, nOldCol )

      RETURN .T.
   ENDIF

   RETURN .F.
scrollbr.prg114
SCROLLBAR:METHODupdate() CLASS SCROLLBAR
METHOD update() CLASS SCROLLBAR

   LOCAL nOldRow
   LOCAL nOldCol
   LOCAL lOldMCur

   LOCAL nOldThumbPos := ::nThumbPos

   IF ISBLOCK( ::bSBlock )
      Eval( ::bSBlock )
   ENDIF

   IF ::CalcThumbPos() .AND. nOldThumbPos != ::nThumbPos

      nOldRow := Row()
      nOldCol := Col()
      lOldMCur := MSetCursor( .F. )

      DispBegin()

      IF ::nOrient == SCROLL_VERTICAL
         DispOutAt( ::nStart + nOldThumbPos, ::nOffSet, SubStr( ::cStyle, 2,  1), hb_ColorIndex( ::cColorSpec, 0 ) )
         DispOutAt( ::nStart + ::nThumbPos, ::nOffset, SubStr( ::cStyle, 3, 1 ), hb_ColorIndex( ::cColorSpec, 1 ) )
      ELSE
         DispOutAt( ::nOffset, ::nStart + nOldThumbPos, SubStr( ::cStyle, 2, 1 ), hb_ColorIndex( ::cColorSpec, 0 ) )
         DispOutAt( ::nOffset, ::nStart + ::nThumbPos, SubStr( ::cStyle, 3, 1 ), hb_ColorIndex( ::cColorSpec, 1 ) )
      ENDIF

      DispEnd()

      MSetCursor( lOldMCur )
      SetPos( nOldRow, nOldCol )

      RETURN .T.
   ENDIF

   RETURN .F.
scrollbr.prg175
SCROLLBAR:METHODhitTest( nMRow, nMCol ) CLASS SCROLLBAR
METHOD hitTest( nMRow, nMCol ) CLASS SCROLLBAR

   IF ::nOrient == SCROLL_VERTICAL

      DO CASE
      CASE nMCol != ::nOffset
      CASE nMRow < ::nStart
      CASE nMRow > ::nEnd
      CASE nMRow == ::nStart
         RETURN HTSCROLLUNITDEC
      CASE nMRow == ::nEnd
         RETURN HTSCROLLUNITINC
      CASE nMRow < ::nThumbPos + ::nStart
         RETURN HTSCROLLBLOCKDEC
      CASE nMRow > ::nThumbPos + ::nStart
         RETURN HTSCROLLBLOCKINC
      CASE nMRow == ::nThumbPos + ::nStart
         RETURN HTSCROLLTHUMBDRAG
      ENDCASE

      IF nMCol == ::nOffset + 1 .OR. nMCol == ::nOffset

         DO CASE
         CASE nMCol != ::nOffset .AND. nMCol != ::nOffset + 1
         CASE nMRow < ::nStart
         CASE nMRow > ::nEnd
         CASE nMRow == ::nStart
            RETURN HTSCROLLUNITDEC
         CASE nMRow == ::nEnd
            RETURN HTSCROLLUNITINC
         CASE nMRow < ::nThumbPos + ::nStart
            RETURN HTSCROLLBLOCKDEC
         CASE nMRow > ::nThumbPos + ::nStart
            RETURN HTSCROLLBLOCKINC
         CASE nMRow == ::nThumbPos + ::nStart
            RETURN HTSCROLLTHUMBDRAG
         ENDCASE

      ENDIF

   ELSE

      DO CASE
      CASE nMRow != ::nOffset
      CASE nMCol < ::nStart
      CASE nMCol > ::nEnd
      CASE nMCol == ::nStart
         RETURN HTSCROLLUNITDEC
      CASE nMCol == ::nEnd
         RETURN HTSCROLLUNITINC
      CASE nMCol < ::nThumbPos + ::nStart
         RETURN HTSCROLLBLOCKDEC
      CASE nMCol > ::nThumbPos + ::nStart
         RETURN HTSCROLLBLOCKINC
      CASE nMCol == ::nThumbPos + ::nStart
         RETURN HTSCROLLTHUMBDRAG
      ENDCASE

   ENDIF

   RETURN HTNOWHERE
scrollbr.prg213
SCROLLBAR:METHODbarLength() CLASS SCROLLBAR
METHOD barLength() CLASS SCROLLBAR
   RETURN ::nBarLength
scrollbr.prg275
SCROLLBAR:METHODbitmaps( aBitmaps ) CLASS SCROLLBAR
METHOD bitmaps( aBitmaps ) CLASS SCROLLBAR

   IF ISARRAY( aBitmaps ) .AND. ;
      Len( aBitmaps ) == 3

      ::aBitmaps := aBitmaps
   ENDIF

   RETURN ::aBitmaps
scrollbr.prg278
SCROLLBAR:METHODcolorSpec( cColorSpec ) CLASS SCROLLBAR
METHOD colorSpec( cColorSpec ) CLASS SCROLLBAR

   IF ISCHARACTER( cColorSpec ) .AND. ;
      !Empty( hb_ColorIndex( cColorSpec, 1 ) ) .AND. ;
       Empty( hb_ColorIndex( cColorSpec, 2 ) )

      ::cColorSpec := cColorSpec
   ENDIF

   RETURN ::cColorSpec
scrollbr.prg288
SCROLLBAR:METHODcurrent( nCurrent ) CLASS SCROLLBAR
METHOD current( nCurrent ) CLASS SCROLLBAR

   IF ISNUMBER( nCurrent ) .AND. ;
      nCurrent <= ::nTotal .AND. ;
      nCurrent != ::nCurrent

      ::nCurrent := nCurrent
   ENDIF

   RETURN ::nCurrent
scrollbr.prg299
SCROLLBAR:METHODend( nEnd ) CLASS SCROLLBAR
METHOD end( nEnd ) CLASS SCROLLBAR

   IF ISNUMBER( nEnd ) .AND. ;
      nEnd >= ::nStart .AND. ;
      nEnd != ::nEnd

      ::nEnd := nEnd
      ::nBarLength := nEnd - ::nStart - 1
   ENDIF

   RETURN ::nEnd
scrollbr.prg310
SCROLLBAR:METHODoffset( nOffset ) CLASS SCROLLBAR
METHOD offset( nOffset ) CLASS SCROLLBAR

   IF ISNUMBER( nOffset ) .AND. ;
      nOffset != ::nOffset

      ::nOffset := nOffset
   ENDIF

   RETURN ::nOffset
scrollbr.prg322
SCROLLBAR:METHODorient( nOrient ) CLASS SCROLLBAR
METHOD orient( nOrient ) CLASS SCROLLBAR

   IF ISNUMBER( nOrient ) .AND. ;
      ( nOrient == SCROLL_VERTICAL .OR. nOrient == SCROLL_HORIZONTAL )

      ::nOrient := nOrient
   ENDIF

   RETURN ::nOrient
scrollbr.prg332
SCROLLBAR:METHODsBlock( bSBlock ) CLASS SCROLLBAR
METHOD sBlock( bSBlock ) CLASS SCROLLBAR

   IF ISBLOCK( bSBlock )
      ::bSBlock := bSBlock
   ENDIF

   RETURN ::bSBlock
scrollbr.prg342
SCROLLBAR:METHODstart( nStart ) CLASS SCROLLBAR
METHOD start( nStart ) CLASS SCROLLBAR

   IF ISNUMBER( nStart ) .AND. ;
      nStart <= ::nEnd .AND. ;
      nStart != ::nStart

      ::nStart := nStart
      ::nBarLength := ::nEnd - nStart - 1
   ENDIF

   RETURN ::nStart
scrollbr.prg350
SCROLLBAR:METHODstyle( cStyle ) CLASS SCROLLBAR
METHOD style( cStyle ) CLASS SCROLLBAR

   IF ISCHARACTER( cStyle ) .AND. ;
      Len( cStyle ) == 4

      ::cStyle := cStyle
   ENDIF

   RETURN ::cStyle
scrollbr.prg362
SCROLLBAR:METHODthumbPos( nThumbPos ) CLASS SCROLLBAR
METHOD thumbPos( nThumbPos ) CLASS SCROLLBAR

   IF ISNUMBER( nThumbPos )

      IF nThumbPos < 1
         ::nThumbPos := 1
      ELSEIF nThumbPos >= ::nBarLength
         ::nThumbPos := ::nBarLength
      ELSEIF nThumbPos >= ::nBarLength - 1
         ::nThumbPos := nThumbPos
      ELSE
         ::nThumbPos := nThumbPos
      ENDIF

      ::lOverride := ( nThumbPos != 0 )
   ENDIF

   RETURN ::nThumbPos
scrollbr.prg372
SCROLLBAR:METHODtotal( nTotal ) CLASS SCROLLBAR
METHOD total( nTotal ) CLASS SCROLLBAR

   IF ISNUMBER( nTotal ) .AND. ;
      nTotal >= 2 .AND. ;
      nTotal != ::nTotal

      ::nTotal := nTotal
   ENDIF

   RETURN ::nTotal
scrollbr.prg391
SCROLLBAR:METHODCalcThumbPos() CLASS SCROLLBAR
METHOD CalcThumbPos() CLASS SCROLLBAR

   LOCAL nBarLength := ::nBarLength
   LOCAL nTotal := ::nTotal

   IF nBarLength < 2 .OR. nTotal < 2
      RETURN .F.
   ENDIF

   IF !::lOverride
      ::nThumbPos := Min( Max( Round( ::nCurrent * ( ( nBarLength - 1 ) / nTotal ) + 1, 0 ), 1 ), nBarLength )
   ENDIF

   RETURN .T.
scrollbr.prg402
SCROLLBAR:METHODNew( nStart, nEnd, nOffset, bSBlock, nOrient ) CLASS SCROLLBAR
METHOD New( nStart, nEnd, nOffset, bSBlock, nOrient ) CLASS SCROLLBAR

   LOCAL cColor

   DEFAULT nOrient TO SCROLL_VERTICAL

   IF !ISNUMBER( nStart ) .OR. ;
      !ISNUMBER( nEnd ) .OR. ;
      !ISNUMBER( nOffset ) .OR. ;
      !ValType( bSBlock ) $ "BU" .OR. ;
      !ISNUMBER( nOrient ) .OR. ;
      ( nOrient != SCROLL_VERTICAL .AND. nOrient != SCROLL_HORIZONTAL )
      RETURN NIL
   ENDIF

   ::end        := nEnd
   ::offSet     := nOffset
   ::orient     := nOrient
   ::sBlock     := bSBlock
   ::start      := nStart
   ::nBarLength := nEnd - nStart - 1

   IF nOrient == SCROLL_VERTICAL
      ::cStyle := SB_UPARROW + SB_THUMB + SB_TRACK + SB_DNARROW
      ::aBitmaps := { "arrow_u.bmu", "arrow_d.bmu", "arrow_e.bmu" }
   ELSEIF nOrient == SCROLL_HORIZONTAL
      ::cStyle := SB_LEFTARROW + SB_THUMB + SB_TRACK + SB_RIGHTARROW
      ::aBitmaps := { "arrow_l.bmu", "arrow_r.bmu", "arrow_e.bmu" }
   ENDIF

   cColor := SetColor()
   ::cColorSpec := hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," + ;
                   hb_ColorIndex( cColor, CLR_ENHANCED )

   RETURN Self
scrollbr.prg426
FUNCTIONScrollBar( nStart, nEnd, nOffset, bSBlock, nOrient )
FUNCTION ScrollBar( nStart, nEnd, nOffset, bSBlock, nOrient )
   RETURN HBScrollBar():New( nStart, nEnd, nOffset, bSBlock, nOrient )
scrollbr.prg462
setfunc.prg
TypeFunctionSourceLine
PROCEDURE__SetFunction( nFunctionKey, xKeySeq )
PROCEDURE __SetFunction( nFunctionKey, xKeySeq )

   /* NOTE: CA-Cl*pper will not handle F11 and F12 here. 
            This is a Harbour extension. [vszakats] */

   DO CASE
      CASE nFunctionKey == 1  ; nFunctionKey := K_F1
#ifdef HB_EXTENSION
      CASE nFunctionKey == 11 ; nFunctionKey := K_F11
      CASE nFunctionKey == 12 ; nFunctionKey := K_F12
#endif
      OTHERWISE               ; nFunctionKey := -nFunctionKey + 1
   ENDCASE

#ifdef HB_EXTENSION
   IF ISCHARACTER( xKeySeq ) .OR. ISNUMBER( xKeySeq ) .OR. ISARRAY( xKeySeq )
#else
   IF ISCHARACTER( xKeySeq )
#endif
      SetKey( nFunctionKey, {|| __Keyboard(), hb_KeyPut( xKeySeq ) } )
   ELSE
      SetKey( nFunctionKey, NIL )
   ENDIF

RETURN
setfunc.prg56
setta.prg
TypeFunctionSourceLine
FUNCTIONSetTypeahead( nSize )
FUNCTION SetTypeahead( nSize )
   RETURN Set( _SET_TYPEAHEAD, nSize )
setta.prg55
symbol.prg
TypeFunctionSourceLine
METHODNew( cSymName )
   METHOD New( cSymName )    // Constructor. cSymName may already exists or not
symbol.prg59
METHODname()
   METHOD name()             // retrieves the symbol name
symbol.prg60
METHODisEqual( oSymbol )
   METHOD isEqual( oSymbol ) // Compares two symbol objects
symbol.prg61
METHODexec()
   METHOD exec()             // Executes the function referred to by the
                             // Symbol object, with an optional parameters list
   PROTECTED:

   VAR nSym                  // internal pointer to the Symbols table symbol

ENDCLASS
symbol.prg62
SYMBOL:METHODNew( cSymName ) CLASS Symbol
METHOD New( cSymName ) CLASS Symbol
   ::nSym := __DynSN2Sym( cSymName )
   RETURN Self
symbol.prg70
SYMBOL:METHODname() CLASS Symbol
METHOD name() CLASS Symbol
   RETURN ::nSym:Name
symbol.prg74
SYMBOL:METHODisEqual( oSymbol ) CLASS Symbol
METHOD isEqual( oSymbol ) CLASS Symbol
   RETURN ::ClassH == oSymbol:ClassH .AND. ::nSym:Name == oSymbol:nSym:Name
symbol.prg77
SYMBOL:METHODexec( ... ) CLASS Symbol
METHOD exec( ... ) CLASS Symbol
   RETURN ::nSym:exec( ... )
symbol.prg80
tbcolumn.prg
TypeFunctionSourceLine
METHODblock( bBlock ) SETGET
   METHOD block( bBlock ) SETGET                     /* Code block to retrieve data for the column */
tbcolumn.prg90
METHODcolorBlock( bColorBlock ) SETGET
   METHOD colorBlock( bColorBlock ) SETGET           /* Code block that determines color of data items */
tbcolumn.prg91
METHODdefColor( aDefColor ) SETGET
   METHOD defColor( aDefColor ) SETGET               /* Array of numeric indexes into the color table */
tbcolumn.prg92
METHODcolSep( cColSep ) SETGET
   METHOD colSep( cColSep ) SETGET                   /* Column separator character */
tbcolumn.prg93
METHODheading( cHeading ) SETGET
   METHOD heading( cHeading ) SETGET                 /* Column heading */
tbcolumn.prg94
METHODfooting( cFooting ) SETGET
   METHOD footing( cFooting ) SETGET                 /* Column footing */
tbcolumn.prg95
METHODheadSep( cHeadSep ) SETGET
   METHOD headSep( cHeadSep ) SETGET                 /* Heading separator character */
tbcolumn.prg96
METHODfootSep( cFootSep ) SETGET
   METHOD footSep( cFootSep ) SETGET                 /* Footing separator character */
tbcolumn.prg97
METHODwidth( nWidth ) SETGET
   METHOD width( nWidth ) SETGET                     /* Column display width */
tbcolumn.prg98
METHODpreBlock( bPreBlock ) SETGET
   METHOD preBlock( bPreBlock ) SETGET               /* Code block determining editing */
tbcolumn.prg100
METHODpostBlock( bPostBlock ) SETGET
   METHOD postBlock( bPostBlock ) SETGET             /* Code block validating values */
tbcolumn.prg101
METHODsetStyle( nStyle, lSetting )
   METHOD setStyle( nStyle, lSetting )               
tbcolumn.prg102
METHODNew( cHeading, bBlock )
   METHOD New( cHeading, bBlock )                    /* NOTE: This method is a Harbour extension [vszakats] */

ENDCLASS
tbcolumn.prg105
TBCOLUMN:METHODblock( bBlock ) CLASS TBColumn
METHOD block( bBlock ) CLASS TBColumn

   IF bBlock != NIL
      ::bBlock := __eInstVar53( Self, "BLOCK", bBlock, "B", 1001 )
   ENDIF

   RETURN ::bBlock
tbcolumn.prg109
TBCOLUMN:METHODcolorBlock( bColorBlock ) CLASS TBColumn
METHOD colorBlock( bColorBlock ) CLASS TBColumn

   IF bColorBlock != NIL
      ::bColorBlock := __eInstVar53( Self, "COLORBLOCK", bColorBlock, "B", 1001 )
   ENDIF

   RETURN ::bColorBlock
tbcolumn.prg117
TBCOLUMN:METHODdefColor( aDefColor ) CLASS TBColumn
METHOD defColor( aDefColor ) CLASS TBColumn

   IF aDefColor != NIL
      ::aDefColor := __eInstVar53( Self, "DEFCOLOR", aDefColor, "A", 1001 )
   ENDIF

   RETURN ::aDefColor
tbcolumn.prg125
TBCOLUMN:METHODcolSep( cColSep ) CLASS TBColumn
METHOD colSep( cColSep ) CLASS TBColumn

   IF cColSep != NIL
      ::cColSep := __eInstVar53( Self, "COLSEP", cColSep, "C", 1001 )
   ENDIF

   RETURN ::cColSep
tbcolumn.prg133
TBCOLUMN:METHODheading( cHeading ) CLASS TBColumn
METHOD heading( cHeading ) CLASS TBColumn

   IF cHeading != NIL
      ::cHeading := __eInstVar53( Self, "HEADING", cHeading, "C", 1001 )
   ENDIF

   RETURN ::cHeading
tbcolumn.prg141
TBCOLUMN:METHODfooting( cFooting ) CLASS TBColumn
METHOD footing( cFooting ) CLASS TBColumn

   IF cFooting != NIL
      ::cFooting := __eInstVar53( Self, "FOOTING", cFooting, "C", 1001 )
   ENDIF

   RETURN ::cFooting
tbcolumn.prg149
TBCOLUMN:METHODheadSep( cHeadSep ) CLASS TBColumn
METHOD headSep( cHeadSep ) CLASS TBColumn

   IF cHeadSep != NIL
      ::cHeadSep := __eInstVar53( Self, "HEADSEP", cHeadSep, "C", 1001 )
   ENDIF

   RETURN ::cHeadSep
tbcolumn.prg157
TBCOLUMN:METHODfootSep( cFootSep ) CLASS TBColumn
METHOD footSep( cFootSep ) CLASS TBColumn

   IF cFootSep != NIL
      ::cFootSep := __eInstVar53( Self, "FOOTSEP", cFootSep, "C", 1001 )
   ENDIF

   RETURN ::cFootSep
tbcolumn.prg165
TBCOLUMN:METHODwidth( nWidth ) CLASS TBColumn
METHOD width( nWidth ) CLASS TBColumn

   IF nWidth != NIL
      ::nWidth := __eInstVar53( Self, "WIDTH", nWidth, "N", 1001 )
   ENDIF

   RETURN ::nWidth
tbcolumn.prg173
TBCOLUMN:METHODpreBlock( bPreBlock ) CLASS TBColumn
METHOD preBlock( bPreBlock ) CLASS TBColumn

   IF bPreBlock != NIL
      ::bPreBlock := __eInstVar53( Self, "PREBLOCK", bPreBlock, "B", 1001 )
   ENDIF

   RETURN ::bPreBlock
tbcolumn.prg183
TBCOLUMN:METHODpostBlock( bPostBlock ) CLASS TBColumn
METHOD postBlock( bPostBlock ) CLASS TBColumn

   IF bPostBlock != NIL
      ::bPostBlock := __eInstVar53( Self, "POSTBLOCK", bPostBlock, "B", 1001 )
   ENDIF

   RETURN ::bPostBlock
tbcolumn.prg191
TBCOLUMN:METHODsetStyle( nStyle, lNewValue ) CLASS TBColumn
METHOD setStyle( nStyle, lNewValue ) CLASS TBColumn

   /* NOTE: CA-Cl*pper 5.3 does no checks on the value of nStyle, so in case 
            it is zero or non-numeric, a regular RTE will happen. [vszakats] */
  
   IF nStyle > Len( ::aSetStyle ) .AND. nStyle <= 4096 /* Some reasonable limit for maximum number of styles */
      ASize( ::aSetStyle, nStyle )
   ENDIF
  
   IF ISLOGICAL( lNewValue )
      ::aSetStyle[ nStyle ] := lNewValue
   ENDIF

   RETURN ::aSetStyle[ nStyle ]
tbcolumn.prg199
TBCOLUMN:METHODNew( cHeading, bBlock ) CLASS TBColumn
METHOD New( cHeading, bBlock ) CLASS TBColumn

   ::cHeading := cHeading /* NOTE: CA-Cl*pper will allow any types for the heading here. [vszakats] */
   ::bBlock := bBlock /* NOTE: CA-Cl*pper allows any types here. [vszakats] */

   RETURN Self
tbcolumn.prg216
FUNCTIONTBColumnNew( cHeading, bBlock )
FUNCTION TBColumnNew( cHeading, bBlock )
   RETURN TBColumn():New( cHeading, bBlock )
tbcolumn.prg223
tbrowse.prg
TypeFunctionSourceLine
METHODmRowPos SETGET
   METHOD mRowPos SETGET                        // numeric value indicating the data row of the mouse position
tbrowse.prg161
METHODmColPos SETGET
   METHOD mColPos SETGET                        // numeric value indicating the data column of the mouse position
tbrowse.prg162
METHODsetStyle( nStyle, lNewValue )
   METHOD setStyle( nStyle, lNewValue )         // maintains a dictionary within an object
tbrowse.prg165
METHODsetKey( nKey, bBlock )
   METHOD setKey( nKey, bBlock )                // get/set a code block associated with an INKEY() value
tbrowse.prg166
METHODapplyKey( nKey )
   METHOD applyKey( nKey )                      // evaluate the code block associated with given INKEY() value
tbrowse.prg167
METHODhitTest( mRow, mCol )
   METHOD hitTest( mRow, mCol )                 // indicate position of mouse cursor relative to TBrowse
tbrowse.prg168
METHODnRow SETGET
   METHOD nRow SETGET                           // screen row number for the actual cell
tbrowse.prg169
METHODnCol SETGET
   METHOD nCol SETGET                           // screen column number for the actual cell
tbrowse.prg170
METHODborder( cBorder ) SETGET
   METHOD border( cBorder ) SETGET              // get/set character value used for TBrowse are border
tbrowse.prg171
METHODmessage( cMessage ) SETGET
   METHOD message( cMessage ) SETGET            // get/set character string displayed on status bar
tbrowse.prg172
METHODnTop( nTop ) SETGET
   METHOD nTop( nTop ) SETGET                   // get/set top row number for the TBrowse display
tbrowse.prg175
METHODnLeft( nLeft ) SETGET
   METHOD nLeft( nLeft ) SETGET                 // get/set leftmost column for the TBrowse display
tbrowse.prg176
METHODnBottom( nBottom ) SETGET
   METHOD nBottom( nBottom ) SETGET             // get/set bottom row number for the TBrowse display
tbrowse.prg177
METHODnRight( nRight ) SETGET
   METHOD nRight( nRight ) SETGET               // get/set rightmost column for the TBrowse display
tbrowse.prg178
METHODheadSep( cHeadSep ) SETGET
   METHOD headSep( cHeadSep ) SETGET            // get/set heading separator characters
tbrowse.prg180
METHODcolSep( cColSep ) SETGET
   METHOD colSep( cColSep ) SETGET              // get/set column separator characters 
tbrowse.prg181
METHODfootSep( cFootSep ) SETGET
   METHOD footSep( cFootSep ) SETGET            // get/set footing separator characters
tbrowse.prg182
METHODskipBlock( bSkipBlock ) SETGET
   METHOD skipBlock( bSkipBlock ) SETGET        // get/set code block used to reposition data source
tbrowse.prg183
METHODgoTopBlock( bBlock ) SETGET
   METHOD goTopBlock( bBlock ) SETGET           // get/set code block executed by TBrowse:goTop()   
tbrowse.prg184
METHODgoBottomBlock( bBlock ) SETGET
   METHOD goBottomBlock( bBlock ) SETGET        // get/set code block executed by TBrowse:goBottom()
tbrowse.prg185
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET        // get/set string value with color table for the TBrowse display

   ACCESS rowPos    METHOD getRowPos            // get current cursor row position
   ASSIGN rowPos    METHOD setRowPos            // set current cursor row position

   ACCESS colPos    METHOD getColPos            // get current cursor column position
   ASSIGN colPos    METHOD setColPos            // set current cursor column position

   ACCESS freeze    METHOD getFrozen            // get number of frozen columns
   ASSIGN freeze    METHOD freeze               // set number of columns to freeze

   ACCESS hitTop    METHOD getTopFlag           // get the beginning of available data flag
   ASSIGN hitTop    METHOD setTopFlag           // set the beginning of available data flag

   ACCESS hitBottom METHOD getBottomFlag        // get the end of available data flag
   ASSIGN hitBottom METHOD setBottomFlag        // set the end of available data flag

   ACCESS autoLite  METHOD getAutoLite          // get automatic highlighting state
   ASSIGN autoLite  METHOD setAutoLite          // set automatic highlighting

   ACCESS stable    METHOD getStableFlag        // get flag indicating if the TBrowse object is stable
   ASSIGN stable    METHOD setStableFlag        // set flag indicating if the TBrowse object is stable
tbrowse.prg187
METHODaddColumn( oCol )
   METHOD addColumn( oCol )                     // adds a TBColumn object to the TBrowse object
tbrowse.prg210
METHODdelColumn( nColumn )
   METHOD delColumn( nColumn )                  // delete a column object from a browse
tbrowse.prg211
METHODinsColumn( nColumn, oCol )
   METHOD insColumn( nColumn, oCol )            // insert a column object in a browse
tbrowse.prg212
METHODsetColumn( nColumn, oCol )
   METHOD setColumn( nColumn, oCol )            // replaces one TBColumn object with another
tbrowse.prg213
METHODgetColumn( nColumn )
   METHOD getColumn( nColumn )                  // gets a specific TBColumn object
tbrowse.prg214
METHODrowCount()
   METHOD rowCount()                            // number of visible data rows in the TBrowse display
tbrowse.prg216
METHODcolCount()
   METHOD colCount()                            // number of browse columns
tbrowse.prg217
METHODcolWidth( nColumn )
   METHOD colWidth( nColumn )                   // returns the display width of a particular column
tbrowse.prg219
METHODleftVisible()
   METHOD leftVisible()                         // indicates position of leftmost unfrozen column in display
tbrowse.prg221
METHODrightVisible()
   METHOD rightVisible()                        // indicates position of rightmost unfrozen column in display
tbrowse.prg222
METHODhilite()
   METHOD hilite()                              // highlights the current cell
tbrowse.prg224
METHODdeHilite()
   METHOD deHilite()                            // dehighlights the current cell
tbrowse.prg225
METHODrefreshAll()
   METHOD refreshAll()                          // causes all data to be recalculated during the next stabilize
tbrowse.prg226
METHODrefreshCurrent()
   METHOD refreshCurrent()                      // causes the current row to be refilled and repainted on next stabilize
tbrowse.prg227
METHODforceStable()
   METHOD forceStable()                         // performs a full stabilization
tbrowse.prg228
METHODinvalidate()
   METHOD invalidate()                          // forces entire redraw during next stabilization
tbrowse.prg229
METHODup()
   METHOD up()                                  // moves the cursor up one row
tbrowse.prg231
METHODdown()
   METHOD down()                                // moves the cursor down one row
tbrowse.prg232
METHODleft()
   METHOD left()                                // moves the cursor left one column
tbrowse.prg233
METHODright()
   METHOD right()                               // moves the cursor right one column
tbrowse.prg234
METHODpageUp()
   METHOD pageUp()                              // repositions the data source upward
tbrowse.prg235
METHODpageDown()
   METHOD pageDown()                            // repositions the data source downward
tbrowse.prg236
METHODhome()
   METHOD home()                                // moves the cursor to the leftmost visible data column
tbrowse.prg237
METHODend()
   METHOD end()                                 // moves the cursor to the rightmost visible data column
tbrowse.prg238
METHODgoTop()
   METHOD goTop()                               // repositions the data source to the top of file
tbrowse.prg240
METHODgoBottom()
   METHOD goBottom()                            // repositions the data source to the bottom of file
tbrowse.prg241
METHODpanLeft()
   METHOD panLeft()                             // pans left without changing the cursor position
tbrowse.prg243
METHODpanRight()
   METHOD panRight()                            // pans right without changing the cursor position
tbrowse.prg244
METHODpanHome()
   METHOD panHome()                             // moves the cursor to the leftmost visible data column
tbrowse.prg245
METHODpanEnd()
   METHOD panEnd()                              // moves the cursor to the rightmost data column
tbrowse.prg246
METHODstabilize()
   METHOD stabilize()                           // performs incremental stabilization
tbrowse.prg248
METHODcolorRect( aRect, aColors )
   METHOD colorRect( aRect, aColors )           // alters the color of a rectangular group of cells
tbrowse.prg249
METHODconfigure( nMode )
   METHOD configure( nMode )                    // mark that the internal settings of the TBrowse object should be reconfigured
tbrowse.prg252
METHODviewArea()
   METHOD viewArea()                            // Xbase++ compatible method
tbrowse.prg255
METHODfirstScrCol()
   METHOD firstScrCol()                         // Xbase++ compatible method

   MESSAGE _left() METHOD Left()
   MESSAGE _right() METHOD Right()
   MESSAGE _end() METHOD End()
tbrowse.prg256
METHODnew( nTop, nLeft, nBottom, nRight )
   METHOD new( nTop, nLeft, nBottom, nRight )   // constructor, NOTE: This method is a Harbour extension [vszakats]

PROTECTED:
   VAR nRowPos       AS INTEGER INIT 1          // current cursor row position
   VAR nColPos       AS INTEGER INIT 1          // current cursor column position
   VAR nLeftVisible  AS INTEGER INIT 0          // indicates position of leftmost unfrozen column in display
   VAR nRightVisible AS INTEGER INIT 0          // indicates position of rightmost unfrozen column in display
   VAR n_Row         AS INTEGER INIT 0          // current cursor screen row position
   VAR n_Col         AS INTEGER INIT 0          // current cursor screen column position
   VAR nHeadHeight   AS INTEGER INIT 0          // heading vertical size
   VAR nFootHeight   AS INTEGER INIT 0          // footing vertical size
   VAR nFrozen       AS INTEGER INIT 0          // number of frozen columns
   VAR nBufferPos    AS INTEGER INIT 1          // position in row buffer
   VAR nMoveOffset   AS INTEGER INIT 0          // requested repositioning
   VAR nLastRow      AS INTEGER INIT 0          // last row in the buffer
   VAR nLastScroll   AS INTEGER INIT 0          // last srcoll value
   VAR nConfigure    AS INTEGER INIT _TBR_CONF_ALL // configuration status
   VAR nLastPos      AS INTEGER INIT 0          // last calculated column position
   VAR lHitTop       AS LOGICAL INIT .F.        // indicates the beginning of available data
   VAR lHitBottom    AS LOGICAL INIT .F.        // indicates the end of available data
   VAR lHiLited      AS LOGICAL INIT .F.        // indicates if current cell is highlighted
   VAR lAutoLite     AS LOGICAL INIT .T.        // logical value to control highlighting
   VAR lStable       AS LOGICAL INIT .F.        // indicates if the TBrowse object is stable
   VAR lInvalid      AS LOGICAL INIT .T.        // indicates that TBrowse object data should be fully redrawn
   VAR lRefresh      AS LOGICAL INIT .F.        // indicates that record buffer should be discarded in next stabilization
   VAR lFrames       AS LOGICAL INIT .F.        // indicates that headings and footings should be redrawn
   VAR lHeadSep      AS LOGICAL INIT .F.        // indicates if heading separator exists
   VAR lFootSep      AS LOGICAL INIT .F.        // indicates if footing separator exists
   VAR aColData      AS ARRAY   INIT {}         // column information, see _TBCI_*
   VAR aColors       AS ARRAY   INIT {}         // array with TBrowse colors, see _TBC_CLR_*
   VAR aDispStatus   AS ARRAY   INIT {}         // record buffer status
   VAR aCellStatus   AS ARRAY   INIT {}         // record buffer status
   VAR aCellValues   AS ARRAY   INIT {}         // cell values buffers for each record
   VAR aCellColors   AS ARRAY   INIT {}         // cell colors buffers for each record
tbrowse.prg263
METHODdoConfigure()
   METHOD doConfigure()                         // reconfigures the internal settings of the TBrowse object
tbrowse.prg298
METHODsetUnstable()
   METHOD setUnstable()                         // set TBrows in unstable mode resetting flags
tbrowse.prg299
METHODsetPosition( nPos )
   METHOD setPosition( nPos )                   // synchronize record position with the buffer
tbrowse.prg300
METHODreadRecord()
   METHOD readRecord()                          // read current record into the buffer
tbrowse.prg301
METHODsetVisible()
   METHOD setVisible()                          // set visible columns
tbrowse.prg303
METHODsetCursorPos()
   METHOD setCursorPos()                        // set screen cursor position at current cell
tbrowse.prg304
METHODscrollBuffer( nRows )
   METHOD scrollBuffer( nRows )                 // scroll internal buffer for given row numbers
tbrowse.prg305
METHODcolorValue( nColorIndex )
   METHOD colorValue( nColorIndex )             // get color value for given index
tbrowse.prg306
METHODcellValue( nRow, nCol )
   METHOD cellValue( nRow, nCol )               // get cell color indexes
tbrowse.prg307
METHODcellColor( nRow, nCol )
   METHOD cellColor( nRow, nCol )               // get cell formatted value
tbrowse.prg308
METHODdispFrames()
   METHOD dispFrames()                          // display TBrowse border, columns' headings, footings and separators
tbrowse.prg309
METHODdispRow( nRow )
   METHOD dispRow( nRow )                       // display TBrowse data

   FRIEND FUNCTION _mBrwPos                     // helper function for mRow() and mCol() methods

ENDCLASS
tbrowse.prg310
FUNCTIONTBrowseNew( nTop, nLeft, nBottom, nRight )
FUNCTION TBrowseNew( nTop, nLeft, nBottom, nRight )

   RETURN TBrowse():new( nTop, nLeft, nBottom, nRight )
tbrowse.prg318
TBROWSE:METHODnew( nTop, nLeft, nBottom, nRight ) CLASS TBROWSE
METHOD new( nTop, nLeft, nBottom, nRight ) CLASS TBROWSE

   DEFAULT nTop    TO 0
   DEFAULT nLeft   TO 0
   DEFAULT nBottom TO MaxRow()
   DEFAULT nRight  TO MaxCol()

   ::nTop    := nTop
   ::nLeft   := nLeft
   ::nBottom := nBottom
   ::nRight  := nRight

   ::colorSpec := SetColor()

   RETURN Self
tbrowse.prg323
STATIC FUNCTION_SKIP_RESULT( xResult )
STATIC FUNCTION _SKIP_RESULT( xResult )

   RETURN IIF( ValType( xResult ) == "N", Int( xResult ), 0 )
tbrowse.prg339
STATIC PROCEDURE_DISP_FHSEP( nRow, nType, cColor, aColData )
STATIC PROCEDURE _DISP_FHSEP( nRow, nType, cColor, aColData )
   LOCAL aCol
   LOCAL cSep
   LOCAL nLen
   LOCAL nWidth
   LOCAL lFirst := .T.
   LOCAL lFirstVisible := .T.

   FOR EACH aCol IN aColData
      IF aCol[ _TBCI_COLPOS ] != NIL
         cSep := aCol[ nType ]
         nWidth := aCol[ _TBCI_COLWIDTH ]

         /* This is in my opinion bug which should be fixed
          * and the First column should be shown with the
          * same conditions as first visible column.
          * Now I replicated exact CA-Cl*pper behavior but
          * probably in the future it will be changed. [druzus]
          */
         IF lFirst
            lFirst := lFirstVisible := .F.
            cSep := Replicate( Right( cSep, 1 ), nWidth + ;
                               aCol[ _TBCI_FROZENSPACE ] )
         ELSEIF lFirstVisible
            lFirstVisible := .F.
            nLen := Len( cSep )
            IF nLen <= aCol[ _TBCI_SEPWIDTH ]
               cSep := Replicate( Right( cSep, 1 ), nWidth + ;
                                  aCol[ _TBCI_FROZENSPACE ] )
            ELSE
               cSep := Substr( cSep, aCol[ _TBCI_SEPWIDTH ] + 1, nWidth )
               IF ( nLen -= aCol[ _TBCI_SEPWIDTH ] + nWidth ) < 0
                  cSep += Replicate( Right( cSep, 1 ), -nLen )
               ENDIF
               IF aCol[ _TBCI_FROZENSPACE ] > 0
                  cSep := Replicate( Left( cSep, 1 ), aCol[ _TBCI_FROZENSPACE ] ) + ;
                                     cSep
               ENDIF
            ENDIF
         ELSE
            nLen := Len( cSep ) - aCol[ _TBCI_SEPWIDTH ] - nWidth
            IF nLen > 0
               cSep := Left( cSep, aCol[ _TBCI_SEPWIDTH ] + nWidth )
            ELSEIF nLen < 0
               cSep += Replicate( Right( cSep, 1 ), -nLen )
            ENDIF
            IF aCol[ _TBCI_FROZENSPACE ] > 0
               cSep := Stuff( cSep, aCol[ _TBCI_SEPWIDTH ] + 1, 0, ;
                              Replicate( Substr( cSep, aCol[ _TBCI_SEPWIDTH ] + 1, 1 ), ;
                                         aCol[ _TBCI_FROZENSPACE ] ), cSep )
            ENDIF
         ENDIF
         IF aCol[ _TBCI_LASTSPACE ] > 0
            cSep += Replicate( Right( cSep, 1 ), aCol[ _TBCI_LASTSPACE ] )
         ELSEIF aCol[ _TBCI_LASTSPACE ] < 0
            cSep := Left( cSep, Len( cSep ) + aCol[ _TBCI_LASTSPACE ] )
         ENDIF
         DispOutAt( nRow, aCol[ _TBCI_COLPOS ] - aCol[ _TBCI_FROZENSPACE ], ;
                    cSep, cColor )
      ELSEIF aCol[ _TBCI_CELLWIDTH ] > 0
         lFirst := .F.
      ENDIF
   NEXT

   RETURN
tbrowse.prg344
STATIC PROCEDURE_DISP_FHNAME( nRow, nHeight, nLeft, nRight, nType, nColor, aColors, aColData )
STATIC PROCEDURE _DISP_FHNAME( nRow, nHeight, nLeft, nRight, nType, nColor, aColors, aColData )

   LOCAL aCol
   LOCAL cName
   LOCAL nPos
   LOCAL nCol
   LOCAL nWidth
   LOCAL lFirst := .T.

   DispBox( nRow, nLeft, nRow + nHeight - 1, nRight, ;
            Space( 9 ), aColors[ _TBC_CLR_STANDARD ] )

   FOR EACH aCol IN aColData
      IF aCol[ _TBCI_COLPOS ] != NIL
         cName := aCol[ nType ]
         nCol := aCol[ _TBCI_COLPOS ]
         IF lFirst
            lFirst := .F.
         ELSE
            nCol += aCol[ _TBCI_SEPWIDTH ]
         ENDIF
         nWidth := aCol[ _TBCI_COLWIDTH ]
         IF aCol[ _TBCI_LASTSPACE ] < 0
            nWidth += aCol[ _TBCI_LASTSPACE ]
         ENDIF
         FOR nPos := 1 TO nHeight
            DispOutAt( nRow + nPos - 1, nCol, ;
                       PadR( hb_tokenGet( cName, nPos, _TBR_CHR_LINEDELIMITER ), nWidth ), ;
                       IIF( aCol[ _TBCI_DEFCOLOR ][ nColor ] == 0, "N/N", ;
                            aColors[ aCol[ _TBCI_DEFCOLOR ][ nColor ] ] ) )
         NEXT
      ENDIF
   NEXT

   RETURN
tbrowse.prg411
TBROWSE:METHODdispFrames() CLASS TBROWSE
METHOD dispFrames() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   DispBegin()

   IF ::lInvalid .AND. !Empty( ::cBorder )
      DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cBorder, ::colorValue( _TBC_CLR_STANDARD ) )
   ENDIF

   IF ::nHeadHeight > 0
      _DISP_FHNAME( ::n_Top, ::nHeadHeight, ::n_Left, ::n_Right, _TBCI_HEADING, ;
                    IIF( ::lHeadSep, _TBC_CLR_HEADING, _TBC_CLR_STANDARD ), ;
                    ::aColors, ::aColData )
   ENDIF
   IF ::lHeadSep
      _DISP_FHSEP( ::n_Top + ::nHeadHeight, _TBCI_HEADSEP, ;
                   ::colorValue( _TBC_CLR_STANDARD ), ::aColData )
   ENDIF
   IF ::lFootSep
      _DISP_FHSEP( ::n_Bottom - ::nFootHeight, _TBCI_FOOTSEP, ;
                   ::colorValue( _TBC_CLR_STANDARD ), ::aColData )
   ENDIF
   IF ::nFootHeight > 0
      _DISP_FHNAME( ::n_Bottom - ::nFootHeight + 1, ::nFootHeight, ::n_Left, ::n_Right, _TBCI_FOOTING, ;
                    IIF( ::lFootSep, _TBC_CLR_FOOTING, _TBC_CLR_STANDARD ), ;
                    ::aColors, ::aColData )
   ENDIF

   DispEnd()

   ::lFrames := .F.

   RETURN Self
tbrowse.prg448
TBROWSE:METHODdispRow( nRow ) CLASS TBROWSE
METHOD dispRow( nRow ) CLASS TBROWSE

   LOCAL nRowPos, nColPos
   LOCAL aCol
   LOCAL lFirst
   LOCAL cValue, cColor, cStdColor
   LOCAL aColors

   IF nRow >= 1 .AND. nRow <= ::rowCount

      DispBegin()

      nRowPos := ::n_Top + ::nHeadHeight + IIF( ::lHeadSep, 1, 0 ) + nRow - 1
      cStdColor := ::colorValue( _TBC_CLR_STANDARD )

      DispBox( nRowPos, ::n_Left, nRowPos, ::n_Right, Space( 9 ), cStdColor )

      lFirst := .T.
      FOR EACH aCol, cValue, aColors IN ::aColData, ::aCellValues[ nRow ], ::aCellColors[ nRow ]
         IF aCol[ _TBCI_COLPOS ] != NIL
            nColPos := aCol[ _TBCI_COLPOS ]
            IF lFirst
               lFirst := .F.
            ELSEIF aCol[ _TBCI_SEPWIDTH ] > 0
               DispOutAt( nRowPos, aCol[ _TBCI_COLPOS ] - aCol[ _TBCI_FROZENSPACE ], ;
                          aCol[ _TBCI_COLSEP ], cStdColor )
               nColPos += aCol[ _TBCI_SEPWIDTH ]
            ENDIF
            nColPos += aCol[ _TBCI_CELLPOS ]
            cColor := ::colorValue( aColors[ _TBC_CLR_STANDARD ] )
            IF aCol[ _TBCI_LASTSPACE ] < 0
               DispOutAt( nRowPos, nColPos, ;
                          Left( cValue, ::n_Right - nColPos + 1 ), cColor )
            ELSE
#ifdef HB_C52_STRICT
               DispOutAt( nRowPos, nColPos, ;
                          Left( cValue, aCol[ _TBCI_COLWIDTH ] - aCol[ _TBCI_CELLPOS ] ), cColor )
#else
               DispOutAt( nRowPos, nColPos, cValue, cColor )
#endif
            ENDIF
         ENDIF
      NEXT

      ::aDispStatus[ nRow ] := .F.

      DispEnd()
   ENDIF

   RETURN Self
tbrowse.prg486
TBROWSE:METHODcolorRect( aRect, aColors ) CLASS TBROWSE
METHOD colorRect( aRect, aColors ) CLASS TBROWSE

   LOCAL nRow := ::rowCount
   LOCAL nCol := ::colCount

   /* CA-Cl*pper checks all this conditions */
   IF ISARRAY( aRect ) .AND. Len( aRect ) >= 4 .AND. ;
      ISNUMBER( aRect[ 1 ] ) .AND. ISNUMBER( aRect[ 2 ] ) .AND. ;
      ISNUMBER( aRect[ 3 ] ) .AND. ISNUMBER( aRect[ 4 ] ) .AND. ;
      aRect[ 1 ] >= 1 .AND. aRect[ 1 ] <= nRow .AND. ;
      aRect[ 2 ] >= 1 .AND. aRect[ 2 ] <= nCol .AND. ;
      aRect[ 3 ] >= aRect[ 1 ] .AND. aRect[ 3 ] <= nRow .AND. ;
      aRect[ 4 ] >= aRect[ 2 ] .AND. aRect[ 4 ] <= nCol .AND. ;
      ;
      ISARRAY( aColors ) .AND. Len( aColors ) >= 2 .AND. ;
      ISNUMBER( aColors[ 1 ] ) .AND. ISNUMBER( aColors[ 2 ] ) .AND. ;
      ; /* in colorRect() index 0 is not supported */
      aColors[ 1 ] >= 1 .AND. aColors[ 1 ] <= Len( ::aColors ) .AND. ;
      aColors[ 2 ] >= 1 .AND. aColors[ 2 ] <= Len( ::aColors )

      FOR nRow := aRect[ 1 ] TO aRect[ 3 ]
         ::readRecord( nRow )
         FOR nCol := aRect[ 2 ] TO aRect[ 4 ]
            ::aCellColors[ nRow, nCol, 1 ] := aColors[ 1 ]
            ::aCellColors[ nRow, nCol, 2 ] := aColors[ 2 ]
            ::dispRow( nRow )
         NEXT
      NEXT
   ENDIF

   RETURN Self
tbrowse.prg538
TBROWSE:METHODscrollBuffer( nRows ) CLASS TBROWSE
METHOD scrollBuffer( nRows ) CLASS TBROWSE

   LOCAL nRowCount := ::rowCount
   LOCAL aValues, aColors
   LOCAL cOldColor

   /* Store last scroll value to chose refresh order. [druzus] */
   ::nLastScroll := nRows

   IF nRows >= nRowCount .OR. nRows <= -nRowCount
      AFill( ::aCellStatus, .F. )
   ELSE
      cOldColor := SetColor( ::colorValue( _TBC_CLR_STANDARD ) )
      Scroll( ::n_Top + ::nHeadHeight + IIF( ::lHeadSep, 1, 0 ), ::n_Left, ;
              ::n_Bottom - ::nFootHeight - IIF( ::lFootSep, 1, 0 ), ::n_Right, ;
              nRows )
      SetColor( cOldColor )
      IF nRows > 0
         WHILE --nRows >= 0
            aValues := ::aCellValues[ 1 ]
            aColors := ::aCellColors[ 1 ]
            ADel( ::aCellValues, 1 )
            ADel( ::aCellColors, 1 )
            ADel( ::aCellStatus, 1 )
            ADel( ::aDispStatus, 1 )
            ::aCellValues[ nRowCount ] := aValues
            ::aCellColors[ nRowCount ] := aColors
            ::aCellStatus[ nRowCount ] := .F.
            ::aDispStatus[ nRowCount ] := .T.
         ENDDO
      ELSEIF nRows < 0
         WHILE ++nRows <= 0
            HB_AIns( ::aCellValues, 1, ATail( ::aCellValues ) )
            HB_AIns( ::aCellColors, 1, ATail( ::aCellColors ) )
            HB_AIns( ::aCellStatus, 1, .F. )
            HB_AIns( ::aDispStatus, 1, .T. )
         ENDDO
      ENDIF
   ENDIF

   RETURN Self
tbrowse.prg571
TBROWSE:METHODreadRecord( nRow ) CLASS TBROWSE
METHOD readRecord( nRow ) CLASS TBROWSE

   LOCAL aCol
   LOCAL oCol
   LOCAL cValue
   LOCAL aColor
   LOCAL nColors, nToMove, nMoved
   LOCAL nRowCount := ::rowCount
   LOCAL lRead := .F.

   IF nRow >= 1 .AND. nRow <= nRowCount .AND. !::aCellStatus[ nRow ]

      IF nRow <= ::nLastRow
         nToMove := nRow - ::nBufferPos
         nMoved := _SKIP_RESULT( Eval( ::bSkipBlock, nToMove ) )
         /* TOFIX: add protection against unexpected results
          *        CA-Cl*pper does not fully respect here the returned
          *        value and current code below replicates what Clipper
          *        seems to do but it means that in network environment
          *        with concurent modifications wrong records can be
          *        shown. [druzus]
          */
         IF nToMove > 0
            IF nMoved < 0
               nMoved := 0
            ENDIF
         ELSEIF nToMove < 0
            nMoved := nToMove
         ELSE
            nMoved := 0
         ENDIF
         ::nBufferPos += nMoved
         IF nToMove > 0 .AND. nMoved < nToMove
            ::nLastRow := ::nBufferPos
         ELSE
            lRead := .T.
         ENDIF
      ENDIF

      nColors := Len( ::aColors )
      IF nRow <= ::nLastRow
         FOR EACH aCol, cValue, aColor IN ::aColData, ::aCellValues[ nRow ], ::aCellColors[ nRow ]
            oCol := aCol[ _TBCI_COLOBJECT ]
            cValue := Eval( oCol:block )
            aColor := _CELLCOLORS( aCol, cValue, nColors )
            IF ValType( cValue ) $ "CMNDL"
               cValue := PadR( Transform( cValue, oCol:picture ), aCol[ _TBCI_CELLWIDTH ] )
            ELSE
               cValue := Space( aCol[ _TBCI_CELLWIDTH ] )
            ENDIF
         NEXT
      ELSE
         FOR EACH aCol, cValue, aColor IN ::aColData, ::aCellValues[ nRow ], ::aCellColors[ nRow ]
            aColor := { aCol[ _TBCI_DEFCOLOR ][ 1 ], aCol[ _TBCI_DEFCOLOR ][ 2 ] }
            cValue := Space( aCol[ _TBCI_CELLWIDTH ] )
         NEXT
      ENDIF

      ::aCellStatus[ nRow ] := .T.
      ::aDispStatus[ nRow ] := .T.

   ENDIF

   RETURN lRead
tbrowse.prg614
TBROWSE:METHODsetPosition() CLASS TBROWSE
METHOD setPosition() CLASS TBROWSE

   LOCAL nMoved
   LOCAL nRowCount := ::rowCount
   LOCAL nMoveOffset := ::nMoveOffset + ( ::nRowPos - ::nBufferPos )
   LOCAL nNewPos := ::nBufferPos + nMoveOffset
   LOCAL lSetPos := .T.

   IF nNewPos < 1
      IF ::nMoveOffset < -1
         nMoveOffset -= ::nRowPos - 1
      ENDIF
   ELSEIF nNewPos > ::nLastRow
      IF ::nMoveOffset > 1
         nMoveOffset += ::nLastRow - ::nRowPos
      ENDIF
   ELSEIF lSetPos
      ::nRowPos := nNewPos
   ENDIF

   nMoved := _SKIP_RESULT( Eval( ::bSkipBlock, nMoveOffset ) )

   IF nMoved > 0
      ::nBufferPos += nMoved
      IF ::nBufferPos > ::nLastRow
         AFill( ::aCellStatus, .F., ::nLastRow + 1, ::nBufferPos - ::nLastRow )
      ENDIF
      IF ::nBufferPos > nRowCount
         ::scrollBuffer( ::nBufferPos - nRowCount )
         ::nBufferPos := nRowCount
         lSetPos := .F.
      ENDIF
      IF ::nBufferPos > ::nLastRow
         ::nLastRow := ::nBufferPos
         IF nMoved != nMoveOffset
            lSetPos := .F.
         ENDIF
      ENDIF
   ELSEIF nMoved < 0
      ::nBufferPos += nMoved
      IF ::nBufferPos < 1
         ::nLastRow := Min( nRowCount, ::nLastRow - ::nBufferPos + 1 )
         ::scrollBuffer( ::nBufferPos - 1 )
         ::nBufferPos := 1
         lSetPos := .F.
      ENDIF
   ELSE  /* nMoved == 0 */
      IF nMoveOffset > 0
         IF nMoveOffset != 0 .AND. ::nBufferPos == ::nRowPos
            ::lHitBottom := .T.
         ENDIF
         ::nLastRow := ::nBufferPos
         /* CA-Cl*pper does not do that */
         AFill( ::aCellStatus, .F., ::nLastRow + 1 )
      ELSEIF nMoveOffset < 0
         IF nMoveOffset != 0 .AND. ::nBufferPos == ::nRowPos
            ::lHitTop := .T.
         ENDIF
         /* CA-Cl*pper does not do that */
         IF ::nBufferPos > 1
            ::scrollBuffer( ::nBufferPos - 1 )
            ::nBufferPos := 1
         ENDIF
      ENDIF
   ENDIF

   IF lSetPos
      ::nRowPos := ::nBufferPos
   ENDIF

   ::nMoveOffset := 0

   RETURN Self
tbrowse.prg680
TBROWSE:METHODstabilize() CLASS TBROWSE
METHOD stabilize() CLASS TBROWSE

   LOCAL nCol, nRowCount, nToMove, nMoved
   LOCAL lDisp, lRead, lStat

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   IF !::lStable .OR. ::lInvalid .OR. ::lFrames .OR. ::lRefresh .OR. ;
      ::nMoveOffset != 0 .OR. ::nBufferPos != ::nRowPos

      nRowCount := ::rowCount

      IF ::lRefresh
         AFill( ::aCellStatus, .F. )
         ::nLastRow := nRowCount
         ::nLastScroll := 0
         ::lRefresh := .F.
      ENDIF

      nCol := ::nColPos
      IF nCol < 1 .OR. nCol > ::colCount .OR. ::nLastPos != nCol .OR. ;
         ::lFrames .OR. ::nLeftVisible == 0 .OR. ::nRightVisible == 0 .OR. ;
         ::aColData[ nCol ][ _TBCI_COLPOS ] == NIL

         ::setVisible()
      ENDIF

      IF ::lFrames
         ::dispFrames()
         AFill( ::aDispStatus, .T. )
      ENDIF

      lRead := .F.
      IF ::nMoveOffset != 0
         ::setPosition()
         lRead := .T.
      ENDIF

      IF ::nLastScroll > 0
         FOR EACH lStat, lDisp IN ::aCellStatus, ::aDispStatus DESCEND
            IF !lStat
               IF lRead
                  RETURN .F.
               ENDIF
               lRead := ::readRecord( lStat:__enumIndex() )
            ENDIF
            IF lDisp
               ::dispRow( lDisp:__enumIndex() )
            ENDIF
         NEXT
      ELSE
         FOR EACH lStat, lDisp IN ::aCellStatus, ::aDispStatus
            IF !lStat
               IF lRead
                  RETURN .F.
               ENDIF
               lRead := ::readRecord( lStat:__enumIndex() )
            ENDIF
            IF lDisp
               ::dispRow( lDisp:__enumIndex() )
            ENDIF
         NEXT
      ENDIF

      IF ::nRowPos > ::nLastRow
         ::nRowPos := ::nLastRow
      ENDIF
      IF ::nBufferPos != ::nRowPos
         /* TOFIX: add protection against unexpected results
          *        CA-Cl*pper does not fully respect here the returned
          *        value and current code below replicates what Clipper
          *        seems to do but it means that in network environment
          *        with concurent modifications wrong records can be
          *        shown. [druzus]
          */
         nToMove := ::nRowPos - ::nBufferPos
         nMoved := _SKIP_RESULT( Eval( ::bSkipBlock, nToMove ) )
         IF nToMove > 0
            IF nMoved < 0
               nMoved := 0
            ENDIF
         ELSEIF nToMove < 0
            nMoved := nToMove
         ELSE
            nMoved := 0
         ENDIF
         ::nBufferPos += nMoved
         ::nRowPos := ::nBufferPos
      ENDIF
      ::lStable := .T.
      ::lInvalid := .F.
   ENDIF

   IF ::autoLite
      ::hilite()
   ELSE
      ::setCursorPos()
   ENDIF

   RETURN .T.
tbrowse.prg755
TBROWSE:METHODforceStable() CLASS TBROWSE
METHOD forceStable() CLASS TBROWSE

   /* TODO: CA-Cl*pper does not call ::stabilize() if TBrowse object
    *       is stable and does not need screen update. It may be important
    *       for applications which do not expect that cursor position may
    *       be changed. I'll change it in the future but first I will have
    *       to revert my stupid modifications in Harbour core code. Looking
    *       at old TBrowse implementation I replaced some:
    *             WHILE !oBrw:stabilize(); END
    *       with:
    *             oBrw:forceStable()
    *       In Clipper it's not the same because oBrw:forceStable()
    *       may not set cursor position and only ::stabilize() does it.
    *       [druzus]
    */
   WHILE !::stabilize()
   ENDDO

   RETURN Self
tbrowse.prg859
TBROWSE:METHODcolorValue( nColorIndex ) CLASS TBROWSE
METHOD colorValue( nColorIndex ) CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   IF ISNUMBER( nColorIndex )
      IF nColorIndex >= 1 .AND. nColorIndex <= Len( ::aColors )
         RETURN ::aColors[ nColorIndex ]
      /* In CA-Cl*pper index 0 has special meaning - it's always N/N color */
      ELSEIF nColorIndex == 0
         RETURN "N/N"
      ENDIF
   ENDIF

   RETURN ::aColors[ _TBC_CLR_STANDARD ]
tbrowse.prg880
TBROWSE:METHODcellValue( nRow, nCol ) CLASS TBROWSE
METHOD cellValue( nRow, nCol ) CLASS TBROWSE

   IF nRow >= 1 .AND. nRow <= ::rowCount .AND. ;
      nCol >= 1 .AND. nCol <= ::colCount .AND. ;
      ::aCellStatus[ nRow ]

      RETURN ::aCellValues[ nRow, nCol ]
   ENDIF

   RETURN NIL
tbrowse.prg898
TBROWSE:METHODcellColor( nRow, nCol ) CLASS TBROWSE
METHOD cellColor( nRow, nCol ) CLASS TBROWSE

   IF nRow >= 1 .AND. nRow <= ::rowCount .AND. ;
      nCol >= 1 .AND. nCol <= ::colCount .AND. ;
      ::aCellStatus[ nRow ]

      RETURN ::aCellColors[ nRow, nCol ]
   ENDIF

   RETURN NIL
tbrowse.prg910
STATIC FUNCTION_DECODECOLORS( cColorSpec )
STATIC FUNCTION _DECODECOLORS( cColorSpec )
   LOCAL aColors := {}
   LOCAL nColors := hb_TokenCount( cColorSpec, "," )
   LOCAL cColor
   LOCAL nPos

   FOR nPos := 1 TO nColors
      cColor := hb_tokenGet( cColorSpec, nPos, "," )
      /* For 1-st two colors CA-Cl*pper checks if given color
       * definition has at least one of the following characters:
       * "*+/bBgGrRwWnNiIxXuU0123456789"
       * If not then it takes default color value.
       * In Harbour this validation is redirected to GT system which
       * decides if passed string is valid color definition. The default
       * GT implementation accepts exactly the same color definitions
       * as CA-Cl*pper but some new GTs may accept extended color
       * definitions and use a little bit different rules. [druzus]
       */
      IF nPos <= 2 .AND. hb_colorToN( cColor ) == -1
         cColor := IIF( nPos == 1, "W/N", "N/W" )
      ENDIF
      AAdd( aColors, cColor )
   NEXT
   IF Empty( aColors )
      AAdd( aColors, "W/N" )
   ENDIF
   IF Len( aColors ) < 2
      AAdd( aColors, "N/W" )
   ENDIF
   WHILE Len( aColors ) < _TBC_CLR_MAX
      AAdd( aColors, aColors[ _TBC_CLR_STANDARD ] )
   ENDDO

   RETURN aColors
tbrowse.prg922
STATIC FUNCTION_COLDEFCOLORS( aDefColorsIdx, nMaxColorIndex )
STATIC FUNCTION _COLDEFCOLORS( aDefColorsIdx, nMaxColorIndex )
   LOCAL aColorsIdx := { _TBC_CLR_STANDARD, _TBC_CLR_SELECTED, ;
                         _TBC_CLR_STANDARD, _TBC_CLR_STANDARD }
   LOCAL nColorIndex
   LOCAL nPos

   IF ISARRAY( aDefColorsIdx )
      FOR nPos := 1 TO _TBC_CLR_MAX
         IF nPos <= Len( aDefColorsIdx ) .AND. ;
            ISNUMBER( nColorIndex := aDefColorsIdx[ nPos ] ) .AND. ;
            ( nColorIndex := Int( nColorIndex ) ) >= 0 .AND. ;
            nColorIndex <= nMaxColorIndex

            aColorsIdx[ nPos ] := nColorIndex
         ELSEIF nPos > 2
            aColorsIdx[ nPos ] := aColorsIdx[ 1 ]
         ENDIF
      NEXT
   ENDIF

   RETURN aColorsIdx
tbrowse.prg965
STATIC FUNCTION_CELLCOLORS( aCol, xValue, nMaxColorIndex )
STATIC FUNCTION _CELLCOLORS( aCol, xValue, nMaxColorIndex )
   LOCAL aColors := { aCol[ _TBCI_DEFCOLOR ][ _TBC_CLR_STANDARD ], ;
                      aCol[ _TBCI_DEFCOLOR ][ _TBC_CLR_SELECTED ] }
   LOCAL xColor := Eval( aCol[ _TBCI_COLOBJECT ]:colorBlock, xValue )
   LOCAL nColorIndex
   LOCAL nPos, nMax

   IF ISARRAY( xColor )
      nMax := Min( Len( xColor ), 2 )
      FOR nPos := 1 TO nMax
         nColorIndex := xColor[ nPos ]
         IF ISNUMBER( nColorIndex )
            nColorIndex := Int( nColorIndex )
            IF nColorIndex >= 0 .AND. nColorIndex <= nMaxColorIndex
               aColors[ nPos ] := nColorIndex
            ENDIF
         ENDIF
      NEXT
   ENDIF

   RETURN aColors
tbrowse.prg993
TBROWSE:METHODsetCursorPos() CLASS TBROWSE
METHOD setCursorPos() CLASS TBROWSE

   LOCAL aCol
   LOCAL nRow, nCol

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   nRow := ::nRowPos
   nCol := ::nColPos

   IF nRow >= 1 .AND. nRow <= ::rowCount .AND. ;
      nCol >= 1 .AND. nCol <= ::colCount .AND. ;
      ( aCol := ::aColData[ nCol ] )[ _TBCI_COLPOS ] != NIL

      ::n_Row := ::n_Top + ::nHeadHeight + IIF( ::lHeadSep, 0, -1 ) + nRow
      ::n_Col := ::aColData[ nCol ][ _TBCI_COLPOS ] + ;
                 ::aColData[ nCol ][ _TBCI_CELLPOS ]
      IF aCol[ _TBCI_SEPWIDTH ] > 0
         WHILE --nCol >= 1
            IF ::aColData[ nCol ][ _TBCI_COLPOS ] != NIL
               ::n_Col += aCol[ _TBCI_SEPWIDTH ]
               EXIT
            ENDIF
         ENDDO
      ENDIF
      SetPos( ::n_Row, ::n_Col )
      RETURN .T.
   ENDIF

   RETURN .F.
tbrowse.prg1016
TBROWSE:METHODsetUnstable() CLASS TBROWSE
METHOD setUnstable() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   /* CA-Cl*pper dehighlights the current cell */
   IF ::lHiLited
      ::deHilite()
   ENDIF

   ::lHitTop    := .F.
   ::lHitBottom := .F.
   ::lStable    := .F.

   RETURN Self
tbrowse.prg1050
TBROWSE:METHODinvalidate() CLASS TBROWSE
METHOD invalidate() CLASS TBROWSE

   ::setUnstable()
   ::lInvalid := .T.
   ::lFrames := .T.

   RETURN Self
tbrowse.prg1068
TBROWSE:METHODrefreshAll() CLASS TBROWSE
METHOD refreshAll() CLASS TBROWSE

   ::setUnstable()

   Eval( ::bSkipBlock, 1 - ::nBufferPos )
   ::nBufferPos := 1
   ::lFrames := .T.
   /* In CA-Cl*pper refreshAll() method does not discards
    * record buffer here but only set's flag that the record
    * buffer should be reloaded in stabilize method. [druzus]
    */
   ::lRefresh := .T.

   RETURN Self
tbrowse.prg1077
TBROWSE:METHODrefreshCurrent() CLASS TBROWSE
METHOD refreshCurrent() CLASS TBROWSE

   ::setUnstable()

   IF ::nRowPos >= 1 .AND. ::nRowPos <= ::rowCount
      ::aCellStatus[ ::nRowPos ] := .F.
   ENDIF

   RETURN Self
tbrowse.prg1093
TBROWSE:METHODup() CLASS TBROWSE
METHOD up() CLASS TBROWSE

   ::setUnstable()
   ::nMoveOffset--

   RETURN Self
tbrowse.prg1104
TBROWSE:METHODdown() CLASS TBROWSE
METHOD down() CLASS TBROWSE

   ::setUnstable()
   ::nMoveOffset++

   RETURN Self
tbrowse.prg1112
TBROWSE:METHODpageUp() CLASS TBROWSE
METHOD pageUp() CLASS TBROWSE

   ::setUnstable()
   ::nMoveOffset -= ::rowCount

   RETURN Self
tbrowse.prg1120
TBROWSE:METHODpageDown() CLASS TBROWSE
METHOD pageDown() CLASS TBROWSE

   ::setUnstable()
   ::nMoveOffset += ::rowCount

   RETURN Self
tbrowse.prg1128
TBROWSE:METHODleft() CLASS TBROWSE
METHOD left() CLASS TBROWSE

   ::setUnstable()
   WHILE .T.
      ::nColPos--
      IF ::nColPos < 1 .OR. ::nColPos > ::colCount .OR. ;
         ::aColData[ ::nColPos, _TBCI_CELLWIDTH ] != 0
         EXIT
      ENDIF
   ENDDO

   RETURN Self
tbrowse.prg1136
TBROWSE:METHODright() CLASS TBROWSE
METHOD right() CLASS TBROWSE

   ::setUnstable()
   WHILE .T.
      ::nColPos++
      IF ::nColPos < 1 .OR. ::nColPos > ::colCount .OR. ;
         ::aColData[ ::nColPos, _TBCI_CELLWIDTH ] != 0
         EXIT
      ENDIF
   ENDDO

   RETURN Self
tbrowse.prg1150
TBROWSE:METHODhome() CLASS TBROWSE
METHOD home() CLASS TBROWSE

   ::setUnstable()
   ::nColPos := IIF( ::nLeftVisible < ::nRightVisible, ;
                     ::nLeftVisible, ::nRightVisible )
   RETURN Self
tbrowse.prg1164
TBROWSE:METHODend() CLASS TBROWSE
METHOD end() CLASS TBROWSE

   ::setUnstable()
   ::nColPos := ::nRightVisible

   RETURN Self
tbrowse.prg1172
TBROWSE:METHODpanLeft() CLASS TBROWSE
METHOD panLeft() CLASS TBROWSE

   LOCAL nNewPos

   ::setUnstable()
   nNewPos := _PREVCOLUMN( ::aColData, Min( ::colCount, ::nLeftVisible - 1 ) )

   IF nNewPos != 0 .AND. nNewPos != ::nLeftVisible
      /* It's replicated CA-Cl*pper behavior */
      ::nRightVisible := 0
      ::nLeftVisible := nNewPos
   ENDIF

   RETURN Self
tbrowse.prg1180
TBROWSE:METHODpanRight() CLASS TBROWSE
METHOD panRight() CLASS TBROWSE

   LOCAL nNewPos

   ::setUnstable()
   nNewPos := _NEXTCOLUMN( ::aColData, Max( 1, ::nRightVisible + 1 ) )

   IF nNewPos != 0 .AND. nNewPos != ::nRightVisible
      /* It's replicated CA-Cl*pper behavior */
      ::nLeftVisible := 0
      ::nRightVisible := nNewPos
   ENDIF

   RETURN Self
tbrowse.prg1196
TBROWSE:METHODpanHome() CLASS TBROWSE
METHOD panHome() CLASS TBROWSE

   ::setUnstable()
   ::nColPos := _NEXTCOLUMN( ::aColData, 1 )

   RETURN Self
tbrowse.prg1212
TBROWSE:METHODpanEnd() CLASS TBROWSE
METHOD panEnd() CLASS TBROWSE

   ::setUnstable()
   ::nColPos := _PREVCOLUMN( ::aColData, ::colCount )

   RETURN Self
tbrowse.prg1220
TBROWSE:METHODgoTop() CLASS TBROWSE
METHOD goTop() CLASS TBROWSE

   ::setUnstable()

   Eval( ::bGoTopBlock )
   /* In CA-Cl*pper goTop() method does not discards
    * record buffer here but only set's flag that the record
    * buffer should be reloaded in stabilize method. [druzus]
    */
   ::lRefresh := .T.
   ::nRowPos := 1
   ::nBufferPos := 1
   ::nMoveOffset := 0
   Eval( ::bSkipBlock, 0 )

   RETURN Self
tbrowse.prg1228
TBROWSE:METHODgoBottom() CLASS TBROWSE
METHOD goBottom() CLASS TBROWSE

   LOCAL nMoved

   ::setUnstable()

   Eval( ::bGoBottomBlock )
   nMoved := _SKIP_RESULT( Eval( ::bSkipBlock, -( ::rowCount - 1 ) ) )
   /* In CA-Cl*pper goBottom() method does not discards
    * record buffer here but only set's flag that the record
    * buffer should be reloaded in stabilize method. [druzus]
    */
   ::lRefresh := .T.
   ::nRowPos := 1
   ::nBufferPos := 1
   ::nMoveOffset := -nMoved
   Eval( ::bSkipBlock, 0 )

   RETURN Self
tbrowse.prg1246
TBROWSE:METHODconfigure( nMode ) CLASS TBROWSE
METHOD configure( nMode ) CLASS TBROWSE

   /* method configure() does not touch the screen contents or
    * cursor position. In CA-Cl*pper it only sets flag indicating
    * that some internal data should be recalculated before
    * accessing [druzus]
    */

   IF !ISNUMBER( nMode ) .OR. nMode == 0 .OR. nMode > _TBR_CONF_ALL
      nMode := _TBR_CONF_ALL
   ENDIF
   ::nConfigure := HB_BITOR( ::nConfigure, nMode )

   RETURN Self
tbrowse.prg1267
TBROWSE:METHODdoConfigure() CLASS TBROWSE
METHOD doConfigure() CLASS TBROWSE

   LOCAL oCol
   LOCAL aCol, aVal
   LOCAL nWidth, nHeight, nColCount, nRowCount
   LOCAL xValue
   LOCAL cType
   LOCAL cColSep
   LOCAL cHeadSep, cHeading
   LOCAL nHeadHeight
   LOCAL cFootSep, cFooting
   LOCAL nFootHeight
   LOCAL lHeadSep, lFootSep

   /* TODO: I do not know yet the exact flags behavior (::nConfigure)
    *       and internal conditions so I'll reconfigure all elements.
    *       [druzus]
    */

   ::nConfigure := 0

   /* update color table */
   ::aColors := _DECODECOLORS( ::cColorSpec )

   /* update column data */
   nHeadHeight := nFootHeight := 0
   lHeadSep := lFootSep := .F.
   nColCount := Len( ::columns )
   ASize( ::aColData, nColCount )
   FOR EACH oCol, aCol IN ::columns, ::aColData
      /* CA-Cl*pper always evaluates column block even if column is
       * hidden by setting :width to 0. [druzus]
       */
      xValue := Eval( oCol:block )
      cType  := ValType( xValue )
      nWidth := LEN( Transform( xValue, oCol:picture ) )
      cColSep := oCol:colSep
      IF cColSep == NIL
         cColSep := ::cColSep
      ENDIF
      cHeadSep := oCol:headSep
      IF !ISCHARACTER( cHeadSep ) .OR. cHeadSep == ""
         cHeadSep := ::cHeadSep
         IF !ISCHARACTER( cHeadSep )
            cHeadSep := ""
         ENDIF
      ENDIF
      cFootSep := oCol:footSep
      IF !ISCHARACTER( cFootSep ) .OR. cFootSep == ""
         cFootSep := ::cFootSep
         IF !ISCHARACTER( cFootSep )
            cFootSep := ""
         ENDIF
      ENDIF
      aCol := Array( _TBCI_SIZE )
      aCol[ _TBCI_COLOBJECT   ] := oCol
      aCol[ _TBCI_COLWIDTH    ] := nWidth
      aCol[ _TBCI_COLPOS      ] := NIL
      aCol[ _TBCI_CELLWIDTH   ] := nWidth
      aCol[ _TBCI_CELLPOS     ] := 0
      aCol[ _TBCI_COLSEP      ] := cColSep
      aCol[ _TBCI_SEPWIDTH    ] := Len( cColSep )
      aCol[ _TBCI_HEADSEP     ] := cHeadSep
      aCol[ _TBCI_FOOTSEP     ] := cFootSep
      aCol[ _TBCI_DEFCOLOR    ] := _COLDEFCOLORS( oCol:defColor, LEN( ::aColors ) )
      aCol[ _TBCI_FROZENSPACE ] := 0
      aCol[ _TBCI_LASTSPACE   ] := 0
      IF Len( cHeadSep ) > 0
         lHeadSep := .T.
      ENDIF
      IF Len( cFootSep ) > 0
         lFootSep := .T.
      ENDIF
      cHeading := oCol:heading
      IF _DECODE_FH( @cHeading, @nHeight, @nWidth )
         aCol[ _TBCI_COLWIDTH ] := Max( aCol[ _TBCI_COLWIDTH ], nWidth )
         IF nHeight > nHeadHeight
            nHeadHeight := nHeight
         ENDIF
      ENDIF
      aCol[ _TBCI_HEADING ] := cHeading
      cFooting := oCol:footing
      IF _DECODE_FH( @cFooting, @nHeight, @nWidth )
         aCol[ _TBCI_COLWIDTH ] := Max( aCol[ _TBCI_COLWIDTH ], nWidth )
         IF nHeight > nFootHeight
            nFootHeight := nHeight
         ENDIF
      ENDIF
      aCol[ _TBCI_FOOTING ] := cFooting
      nWidth := oCol:width
      IF nWidth != NIL
         IF nWidth > 0
            aCol[ _TBCI_COLWIDTH ] := nWidth
            IF nWidth < aCol[ _TBCI_CELLWIDTH ] .OR. cType == "C"
               aCol[ _TBCI_CELLWIDTH ] := nWidth
            ENDIF
         ELSE
            aCol[ _TBCI_CELLWIDTH ] := 0
         ENDIF
      ENDIF
      IF aCol[ _TBCI_CELLWIDTH ] > 0
         IF aCol[ _TBCI_COLWIDTH ] > aCol[ _TBCI_CELLWIDTH ]
            IF cType == "N"
               aCol[ _TBCI_CELLPOS ] := aCol[ _TBCI_COLWIDTH ] - aCol[ _TBCI_CELLWIDTH ]
            ELSEIF cType == "L"
               aCol[ _TBCI_CELLPOS ] := Int( ( aCol[ _TBCI_COLWIDTH ] - aCol[ _TBCI_CELLWIDTH ] ) / 2 )
            ENDIF
         ENDIF
#ifdef HB_C52_STRICT
         /* This is bug in CA-Cl*pper TBrowse. It causes that column
          * is not well centered when picture increase the field size
          * it also has other bad side effects in Clipper. :hiLite()
          * method does not check for the cell size and shows the whole
          * formatted string starting from the middle of column. When
          * string is long enough it causes buffer overflow and other
          * TBrowse data becomes corrupted. I do not want to replicate
          * it. [druzus]
          */
         IF cType == "L"
            aCol[ _TBCI_CELLPOS ] := Int( aCol[ _TBCI_COLWIDTH ] / 2 )
         ENDIF
#endif
      ENDIF
   NEXT

   nHeight := Max( _TBR_COORD( ::n_Bottom ) - _TBR_COORD( ::n_Top ), 0 )
   IF lHeadSep .AND. nHeight > 0
      --nHeight
   ELSE
      lHeadSep := .F.
   ENDIF
   IF lFootSep .AND. nHeight > 0
      --nHeight
   ELSE
      lFootSep := .F.
   ENDIF
   IF nHeadHeight >= nHeight
      nHeadHeight := nHeight
      nHeight := 0
   ELSE
      nHeight -= nHeadHeight
   ENDIF
   IF nFootHeight >= nHeight
      nFootHeight := nHeight
      nHeight := 0
   ENDIF
   ::lHeadSep := lHeadSep
   ::nHeadHeight := nHeadHeight
   ::nFootHeight := nFootHeight
   ::lFootSep := lFootSep

   /* update headings to maximum size and missing head/foot separators */
   FOR EACH aCol IN ::aColData
      aCol[ _TBCI_HEADING ] := Replicate( _TBR_CHR_LINEDELIMITER, nHeadHeight - hb_TokenCount( aCol[ _TBCI_HEADING ], _TBR_CHR_LINEDELIMITER ) ) + ;
                               aCol[ _TBCI_HEADING ]
      IF lHeadSep .AND. aCol[ _TBCI_HEADSEP ] == ""
         aCol[ _TBCI_HEADSEP ] := " "
      ENDIF
      IF lFootSep .AND. aCol[ _TBCI_FOOTSEP ] == ""
         aCol[ _TBCI_FOOTSEP ] := " "
      ENDIF
   NEXT

   nRowCount := ::rowCount
   IF nRowCount == 0
      _GENLIMITRTE()
   ENDIF

   /* create new record buffer */
   ASize( ::aCellStatus, nRowCount )
   ASize( ::aDispStatus, nRowCount )
   ASize( ::aCellValues, nRowCount )
   ASize( ::aCellColors, nRowCount )
   AFill( ::aCellStatus, .F. )
   AFill( ::aDispStatus, .T. )
   FOR EACH aVal, aCol IN ::aCellValues, ::aCellColors
      IF aVal == NIL
         aVal := Array( nColCount )
      ELSE
         ASize( aVal, nColCount )
      ENDIF
      IF aCol == NIL
         aCol := Array( nColCount )
      ELSE
         ASize( aCol, nColCount )
      ENDIF
   NEXT

   ::lStable := .F.
   ::lFrames := .T.
   ::lRefresh := .T.

   /* CA-Cl*pper update visible columns here but without
    * colPos repositioning. [druzus]
    */
   _SETVISIBLE( ::aColData, _TBR_COORD( ::n_Right ) - _TBR_COORD( ::n_Left ) + 1, ;
                @::nFrozen, @::nLeftVisible, @::nRightVisible )

   ::nLastPos := 0

   IF ::nRowPos > nRowCount
      ::nRowPos := nRowCount
   ELSEIF ::nRowPos < 1
      ::nRowPos := 1
   ENDIF

   RETURN Self
tbrowse.prg1283
STATIC PROCEDURE_GENLIMITRTE()
STATIC PROCEDURE _GENLIMITRTE()

   LOCAL oError := ErrorNew()

   oError:severity    := ES_ERROR
   oError:genCode     := EG_LIMIT
   oError:subSystem   := "TBROWSE"
   oError:subCode     := 0
   oError:description := hb_LangErrMsg( EG_LIMIT )
   oError:canRetry    := .F.
   oError:canDefault  := .F.
   oError:fileName    := ""
   oError:osCode      := 0

   Eval( ErrorBlock(), oError )
   __errInHandler()

   RETURN
tbrowse.prg1492
STATIC FUNCTION_DECODE_FH( cName, nHeight, nWidth )
STATIC FUNCTION _DECODE_FH( cName, nHeight, nWidth )

   LOCAL i

   nHeight := nWidth := 0
   IF ISCHARACTER( cName )

      IF Len( cName ) > 0
         /* When last character of heading/footing is ';' then CA-Cl*pper
          * does not calculate it as separator
          */
         IF Right( cName, 1 ) == _TBR_CHR_LINEDELIMITER
            cName := Left( cName, Len( cName ) - 1 )
         ENDIF
         nHeight := hb_TokenCount( cName, _TBR_CHR_LINEDELIMITER )
         FOR i := 1 TO nHeight
            nWidth := Max( nWidth, Len( hb_TokenGet( cName, i, _TBR_CHR_LINEDELIMITER ) ) )
         NEXT
      ENDIF

   ELSE
#ifndef HB_C52_STRICT
      /* CA-Cl*per bug, it accepts non character values though cannot
       * display them properly
       */
      nHeight := 1
#else
      nHeight := 0
#endif
      cName := ""
   ENDIF

   RETURN nHeight != 0
tbrowse.prg1513
STATIC FUNCTION_MAXFREEZE( nColumns, aColData, nWidth )
STATIC FUNCTION _MAXFREEZE( nColumns, aColData, nWidth )
   LOCAL aCol
   LOCAL lFirst
   LOCAL nCol, nColWidth, nTot

   IF nColumns > Len( aColData ) .OR. nColumns < 1
      RETURN 0
   ENDIF

   nTot := nWidth
   lFirst := .T.
   FOR nCol := 1 TO nColumns
      aCol := aColData[ nCol ]
      IF aCol[ _TBCI_CELLWIDTH ] > 0
         nColWidth := aCol[ _TBCI_COLWIDTH ]
         IF lFirst
            lFirst := .F.
         ELSE
            nColWidth += aCol[ _TBCI_SEPWIDTH ]
         ENDIF
         IF ( nWidth -= nColWidth ) < 0
            EXIT
         ENDIF
      ENDIF
   NEXT

   /* CA-Cl*pper allows to freeze all columns only when they
    * are fully visible, otherwise it reserves at least one
    * character for 1-st unfrozen column [druzus]
    */
   IF nWidth > 0 .OR. ;
      nWidth == 0 .AND. _NEXTCOLUMN( aColData, nColumns + 1 ) == 0

      RETURN nColumns
   ENDIF

   nWidth := nTot

   RETURN 0
tbrowse.prg1548
STATIC FUNCTION_NEXTCOLUMN( aColData, nCol )
STATIC FUNCTION _NEXTCOLUMN( aColData, nCol )
   LOCAL aCol

   WHILE nCol <= LEN( aColData )
      aCol := aColData[ nCol ]
      IF aCol[ _TBCI_CELLWIDTH ] > 0
         RETURN nCol
      ENDIF
      ++nCol
   ENDDO

   RETURN 0
tbrowse.prg1589
STATIC FUNCTION_PREVCOLUMN( aColData, nCol )
STATIC FUNCTION _PREVCOLUMN( aColData, nCol )
   LOCAL aCol

   WHILE nCol >= 1
      aCol := aColData[ nCol ]
      IF aCol[ _TBCI_CELLWIDTH ] > 0
         RETURN nCol
      ENDIF
      --nCol
   ENDDO

   RETURN 0
tbrowse.prg1603
STATIC FUNCTION_SETCOLUMNS( nFrom, nTo, nStep, aColData, nFirst, nWidth, lFirst )
STATIC FUNCTION _SETCOLUMNS( nFrom, nTo, nStep, aColData, nFirst, nWidth, lFirst )
   LOCAL aCol
   LOCAL nCol, nColWidth
   LOCAL nLast := 0

   IF nWidth > 0
      FOR nCol := nFrom TO nTo STEP nStep
         aCol := aColData[ nCol ]
         IF aCol[ _TBCI_CELLWIDTH ] > 0
            IF nFirst == 0 .OR. nCol == nFirst
               nColWidth := aCol[ _TBCI_COLWIDTH ]
            ELSEIF nCol < nFirst
               nColWidth := aCol[ _TBCI_COLWIDTH ] + aColData[ nFirst ][ _TBCI_SEPWIDTH ]
            ELSE
               nColWidth := aCol[ _TBCI_COLWIDTH ] + aCol[ _TBCI_SEPWIDTH ]
            ENDIF
            IF nWidth >= nColWidth
               nLast := nCol
               nWidth -= nColWidth
               lFirst := .F.
               IF nFirst == 0 .OR. nCol < nFirst
                  nFirst := nCol
               ENDIF
            ELSE
               IF lFirst
                  nLast := nCol
                  nWidth := 0
                  lFirst := .F.
               ENDIF
               EXIT
            ENDIF
         ENDIF
      NEXT
   ENDIF

   RETURN IIF( nLast == 0, nFrom - nStep, nLast )
tbrowse.prg1617
STATIC PROCEDURE_SETVISIBLE( aColData, nWidth, nFrozen, nLeft, nRight )
STATIC PROCEDURE _SETVISIBLE( aColData, nWidth, nFrozen, nLeft, nRight )

   LOCAL nPos, nFirst
   LOCAL lLeft, lRight, lFirst
   LOCAL nColCount := Len( aColData )

   /* Check if frozen columns are still valid, if not reset it to 0
    * It also calculates the size left for unfrozen columns [druzus]
    */
   nFrozen := _MAXFREEZE( nFrozen, aColData, @nWidth )

   /* CA-Cl*pper checks here only for columns number and does not check
    * if at least one column is visible (oCol:width > 0) and if not then
    * wrongly calculates visible columns and some internal indexes.
    * Using linkers like EXOSPACE with memory protection it causes
    * application crash with GPF. [druzus]
    */
   IF nColCount == 0 .OR. _NEXTCOLUMN( aColData, 1 ) == 0
      nLeft := nRight := 0
   ELSE
      /* This algorithms keeps CA-Cl*pper precedence in visible column
       * updating. It's also important for proper working panLeft and
       * panRight methods which use leftVisible and rightVisible values
       * for horizontal scrolling just like in CA-Cl*pper. [druzus]
       */
      IF nWidth >= 1
         lRight := nRight > nFrozen .AND. nRight <= nColCount .AND. ;
                   aColData[ nRight ][ _TBCI_CELLWIDTH ] > 0
         lLeft  := nLeft > nFrozen .AND. nLeft <= nColCount .AND. ;
                   aColData[ nLeft ][ _TBCI_CELLWIDTH ] > 0
         IF !lLeft
            IF lRight
               IF ( nLeft := _PREVCOLUMN( aColData, nRight ) ) < nFrozen
                  nLeft := nRight
               ENDIF
            ELSE
               nPos := _NEXTCOLUMN( aColData, Max( nLeft + 1, nFrozen + 1 ) )
               IF nPos == 0
                  nPos := _PREVCOLUMN( aColData, Min( nColCount, nLeft - 1 ) )
               ENDIF
               IF nPos > nFrozen
                  nLeft := nPos
                  lLeft := .T.
               ENDIF
            ENDIF
         ENDIF
         lFirst := .T.
         nFirst := _PREVCOLUMN( aColData, nFrozen )
      ELSE
         lLeft := lRight := .F.
      ENDIF
      IF lLeft
         nRight := _SETCOLUMNS( nLeft, nColCount, 1, aColData, @nFirst, @nWidth, @lFirst )
         nLeft := _SETCOLUMNS( nLeft - 1, nFrozen + 1, -1, aColData, @nFirst, @nWidth, @lFirst )
      ELSEIF lRight
         nLeft := _SETCOLUMNS( nRight, nFrozen + 1, -1, aColData, @nFirst, @nWidth, @lFirst )
         nRight := _SETCOLUMNS( nRight + 1, nColCount, 1, aColData, @nFirst, @nWidth, @lFirst )
      ELSE
         nLeft := nFrozen + 1
         nRight := nFrozen
      ENDIF
   ENDIF

   RETURN
tbrowse.prg1655
TBROWSE:METHODsetVisible() CLASS TBROWSE
METHOD setVisible() CLASS TBROWSE

   LOCAL aCol
   LOCAL nCol
   LOCAL nLeft
   LOCAL nFrozen
   LOCAL nLast
   LOCAL nColumns := Len( ::aColData )
   LOCAL nWidth := _TBR_COORD( ::n_Right ) - _TBR_COORD( ::n_Left ) + 1
   LOCAL nColPos := ::nColPos
   LOCAL lFirst
   LOCAL lFrames := .F.

   IF nColPos > nColumns
      ::nColPos := nColumns
      ::nLeftVisible := nColumns
      ::nRightVisible := nColumns
   ELSEIF ::nColPos < 1
      ::nColPos := 1
      ::nLeftVisible := 1
      ::nRightVisible := 1
   ELSEIF nColPos != ::nLastPos
      IF nColPos > ::nRightVisible
         ::nRightVisible := ::nColPos
         ::nLeftVisible := 0
      ELSEIF nColPos < ::nLeftVisible
         ::nLeftVisible := ::nColPos
         ::nRightVisible := 0
      ENDIF
   ELSEIF ::nColPos <= ::nFrozen .AND. ::nLeftVisible == 0
      nCol := _NEXTCOLUMN( ::aColData, ::nFrozen + 1 )
      ::nColPos := IIF( nCol == 0, nColumns, nCol )
   ENDIF

   _SETVISIBLE( ::aColData, @nWidth, ;
                @::nFrozen, @::nLeftVisible, @::nRightVisible )

   IF ::nColPos > ::nRightVisible
      ::nColPos := ::nRightVisible
   ELSEIF ::nColPos > ::nFrozen .AND. ::nColPos < ::nLeftVisible
      ::nColPos := ::nLeftVisible
   ENDIF

#if 0
   /* Always try to locate visible column.
    * CA-Cl*pper does not have such condition. [druzus]
    */
   IF ::nColPos >= 1 .AND. ::aColData[ ::nColPos ][ _TBCI_CELLWIDTH ] <= 0
      nCol := _PREVCOLUMN( ::aColData, ::nColPos - 1 )
      ::nColPos := IIF( nCol == 0, _NEXTCOLUMN( ::aColData, ::nColPos + 1 ), nCol )
   ENDIF
#endif

   /* update column size and positions on the screen */
   nLeft := _TBR_COORD( ::n_Left )
   lFirst := .T.
   FOR nCol := 1 TO ::nRightVisible
      aCol := ::aColData[ nCol ]
      IF aCol[ _TBCI_CELLWIDTH ] > 0 .AND. ;
         ( nCol <= ::nFrozen .OR. nCol >= ::nLeftVisible )

         nFrozen := IIF( nCol == ::nLeftVisible, Int( nWidth / 2 ), 0 )
         nColPos := nLeft += nFrozen
         nLeft += aCol[ _TBCI_COLWIDTH ]
         IF lFirst
            lFirst := .F.
         ELSE
            nLeft += aCol[ _TBCI_SEPWIDTH ]
         ENDIF
         nLast := IIF( nCol == ::nRightVisible, _TBR_COORD( ::n_Right ) - nLeft + 1, 0 )

         IF aCol[ _TBCI_COLPOS      ] != nColPos  .OR. ;
            aCol[ _TBCI_FROZENSPACE ] != nFrozen  .OR. ;
            aCol[ _TBCI_LASTSPACE   ] != nLast

            lFrames := .T.
            aCol[ _TBCI_COLPOS      ] := nColPos
            aCol[ _TBCI_FROZENSPACE ] := nFrozen
            aCol[ _TBCI_LASTSPACE   ] := nLast
         ENDIF
      ELSE
         IF aCol[ _TBCI_COLPOS ] != NIL
            lFrames := .T.
         ENDIF
         aCol[ _TBCI_COLPOS ] := NIL
      ENDIF
   NEXT
   FOR nCol := ::nRightVisible + 1 TO nColumns
      aCol := ::aColData[ nCol ]
      IF aCol[ _TBCI_COLPOS ] != NIL
         lFrames := .T.
      ENDIF
      aCol[ _TBCI_COLPOS ] := NIL
   NEXT

   ::nLastPos := ::nColPos

   IF lFrames
      ::lFrames := .T.
   ENDIF

   RETURN Self
tbrowse.prg1722
TBROWSE:METHODhiLite() CLASS TBROWSE
METHOD hiLite() CLASS TBROWSE

   LOCAL cValue, cColor

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   DispBegin()

   IF ::setCursorPos()
      IF ( cValue := ::cellValue( ::nRowPos, ::nColPos ) ) != NIL
         cColor := ::colorValue( ::cellColor( ::nRowPos, ::nColPos )[ _TBC_CLR_SELECTED ] )
         IF ::n_Col + Len( cValue ) > _TBR_COORD( ::n_Right )
            cValue := Left( cValue, _TBR_COORD( ::n_Right ) - ::n_Col + 1 )
         ENDIF
         DispOut( cValue, cColor )
         SetPos( ::n_Row, ::n_Col )
         ::lHiLited := .T.
      ENDIF
   ENDIF

   DispEnd()

   RETURN Self
tbrowse.prg1826
TBROWSE:METHODdeHilite() CLASS TBROWSE
METHOD deHilite() CLASS TBROWSE

   LOCAL cValue, cColor

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   DispBegin()

   IF ::setCursorPos()
      IF ( cValue := ::cellValue( ::nRowPos, ::nColPos ) ) != NIL
         cColor := ::colorValue( ::cellColor( ::nRowPos, ::nColPos )[ _TBC_CLR_STANDARD ] )
         IF ::n_Col + Len( cValue ) > _TBR_COORD( ::n_Right )
            cValue := Left( cValue, _TBR_COORD( ::n_Right ) - ::n_Col + 1 )
         ENDIF
         DispOut( cValue, cColor )
         SetPos( ::n_Row, ::n_Col )
      ENDIF
   ENDIF
   ::lHiLited := .F.

   DispEnd()

   RETURN Self
tbrowse.prg1853
TBROWSE:METHODcolWidth( nColumn ) CLASS TBROWSE
METHOD colWidth( nColumn ) CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   IF ISNUMBER( nColumn ) .AND. nColumn >= 1 .AND. nColumn <= ::colCount
      RETURN ::aColData[ nColumn ][ _TBCI_COLWIDTH ]
   ENDIF

   RETURN 0
tbrowse.prg1881
TBROWSE:METHODgetFrozen() CLASS TBROWSE
METHOD getFrozen() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::nFrozen
tbrowse.prg1895
TBROWSE:METHODfreeze( nColumns ) CLASS TBROWSE
METHOD freeze( nColumns ) CLASS TBROWSE

   LOCAL nCols

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   IF ISNUMBER( nColumns )

      nCols := Int( nColumns )
      IF _MAXFREEZE( nCols, ::aColData, _TBR_COORD( ::n_Right ) - _TBR_COORD( ::n_Left ) + 1 ) == nCols

         ::nFrozen := nCols
         ::lFrames := .T.
         ::nLastPos := 0
         /* CA-Cl*pper update visible columns here but without
          * colPos repositioning. [druzus]
          */
         _SETVISIBLE( ::aColData, _TBR_COORD( ::n_Right ) - _TBR_COORD( ::n_Left ) + 1, ;
                      @::nFrozen, @::nLeftVisible, @::nRightVisible )
      ENDIF
      /* NOTE: CA-Cl*pper compatible behaviour. [vszakats] */
      RETURN nCols
   ENDIF

   RETURN ::nFrozen
tbrowse.prg1905
TBROWSE:METHODcolorSpec( cColorSpec ) CLASS TBROWSE
METHOD colorSpec( cColorSpec ) CLASS TBROWSE

   IF cColorSpec != NIL
      ::cColorSpec := __eInstVar53( Self, "COLORSPEC", cColorSpec, "C", 1001 )
      ::configure( _TBR_CONF_COLORS )
   ENDIF

   RETURN ::cColorSpec
tbrowse.prg1935
TBROWSE:METHODcolCount() CLASS TBROWSE
METHOD colCount() CLASS TBROWSE

   RETURN LEN( ::columns )
tbrowse.prg1945
TBROWSE:METHODrowCount() CLASS TBROWSE
METHOD rowCount() CLASS TBROWSE

   LOCAL nRows

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   nRows := _TBR_COORD( ::n_Bottom ) - _TBR_COORD( ::n_Top ) + 1 - ;
            ::nHeadHeight - IIF( ::lHeadSep, 1, 0 ) - ;
            ::nFootHeight - IIF( ::lFootSep, 1, 0 )

   RETURN IIF( nRows > 0, nRows, 0 )
tbrowse.prg1950
TBROWSE:METHODsetRowPos( nRowPos ) CLASS TBROWSE
METHOD setRowPos( nRowPos ) CLASS TBROWSE

   LOCAL nRow
   LOCAL nRowCount := ::rowCount    /* executes doConfigure internally */

   IF ISNUMBER( nRowPos )
      nRow := Int( nRowPos )
      ::nRowPos := IIF( nRow > nRowCount, nRowCount, ;
                     IIF( nRow < 1, 1, nRow ) )
      RETURN nRow
   ELSE
      ::nRowPos := Min( nRowCount, 1 )
      RETURN 0
   ENDIF

   RETURN ::nRowPos
tbrowse.prg1968
TBROWSE:METHODgetRowPos() CLASS TBROWSE
METHOD getRowPos() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::nRowPos
tbrowse.prg1986
TBROWSE:METHODsetColPos( nColPos ) CLASS TBROWSE
METHOD setColPos( nColPos ) CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   IF ISNUMBER( nColPos )
      ::nColPos := nColPos
   ELSE
      ::nColPos := 0
   ENDIF

   RETURN ::nColPos
tbrowse.prg1998
TBROWSE:METHODgetColPos() CLASS TBROWSE
METHOD getColPos() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::nColPos
tbrowse.prg2013
TBROWSE:METHODgetTopFlag() CLASS TBROWSE
METHOD getTopFlag() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::lHitTop
tbrowse.prg2022
TBROWSE:METHODsetTopFlag( lTop ) CLASS TBROWSE
METHOD setTopFlag( lTop ) CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   IF !ISLOGICAL( lTop )
      RETURN .T.
   ENDIF

   ::lHitTop := lTop

   RETURN lTop
tbrowse.prg2031
TBROWSE:METHODgetBottomFlag() CLASS TBROWSE
METHOD getBottomFlag() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::lHitBottom
tbrowse.prg2046
TBROWSE:METHODsetBottomFlag( lBottom ) CLASS TBROWSE
METHOD setBottomFlag( lBottom ) CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   IF !ISLOGICAL( lBottom )
      RETURN .T.
   ENDIF

   ::lHitBottom := lBottom

   RETURN lBottom
tbrowse.prg2055
TBROWSE:METHODgetAutoLite() CLASS TBROWSE
METHOD getAutoLite() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::lAutoLite
tbrowse.prg2070
TBROWSE:METHODsetAutoLite( lAutoLite ) CLASS TBROWSE
METHOD setAutoLite( lAutoLite ) CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   IF !ISLOGICAL( lAutoLite )
      RETURN .T.
   ENDIF

   ::lAutoLite := lAutoLite

   RETURN lAutoLite
tbrowse.prg2079
TBROWSE:METHODgetStableFlag() CLASS TBROWSE
METHOD getStableFlag() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::lStable
tbrowse.prg2094
TBROWSE:METHODsetStableFlag( lStable ) CLASS TBROWSE
METHOD setStableFlag( lStable ) CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   IF !ISLOGICAL( lStable )
      RETURN .T.
   ENDIF

   ::lStable := lStable

   RETURN lStable
tbrowse.prg2103
TBROWSE:METHODleftVisible() CLASS TBROWSE
METHOD leftVisible() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::nLeftVisible
tbrowse.prg2118
TBROWSE:METHODrightVisible() CLASS TBROWSE
METHOD rightVisible() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::nRightVisible
tbrowse.prg2127
TBROWSE:METHODaddColumn( oCol ) CLASS TBROWSE
METHOD addColumn( oCol ) CLASS TBROWSE

   /* NOTE: CA-Cl*pper doesn't check the parameters. */

   AAdd( ::columns, oCol )
   ::configure( _TBR_CONF_COLUMNS )

   RETURN Self
tbrowse.prg2137
TBROWSE:METHODdelColumn( nColumn ) CLASS TBROWSE
METHOD delColumn( nColumn ) CLASS TBROWSE

   LOCAL oCol

   /* NOTE: CA-Cl*pper doesn't check the parameters. */
#ifndef HB_C52_STRICT
   IF nColumn >= 1 .AND. nColumn <= ::colCount
#else
   IF .T.      /* It's optimized by compiler without any RT overhead */
#endif
      oCol := ::columns[ nColumn ]
      ADel( ::columns, nColumn )
      ASize( ::columns, LEN( ::columns ) - 1 )
      ::configure( _TBR_CONF_COLUMNS )
   ENDIF

   RETURN oCol
tbrowse.prg2148
TBROWSE:METHODinsColumn( nColumn, oCol ) CLASS TBROWSE
METHOD insColumn( nColumn, oCol ) CLASS TBROWSE

   /* NOTE: CA-Cl*pper doesn't check the parameters. */
#ifndef HB_C52_STRICT
   IF nColumn >= 1 .AND. nColumn <= ::colCount + 1
#else
   IF .T.      /* It's optimized by compiler without any RT overhead */
#endif
      HB_AIns( ::columns, nColumn, oCol, .T. )
      ::configure( _TBR_CONF_COLUMNS )
   ENDIF

   RETURN oCol
tbrowse.prg2168
TBROWSE:METHODsetColumn( nColumn, oCol ) CLASS TBROWSE
METHOD setColumn( nColumn, oCol ) CLASS TBROWSE

   LOCAL oPrevCol

   IF nColumn != NIL .AND. oCol != NIL

      nColumn := __eInstVar53( Self, "COLUMN", nColumn, "N", 1001 )
      oCol := __eInstVar53( Self, "COLUMN", oCol, "O", 1001 )

      /* NOTE: CA-Cl*pper doesn't check nColumn range (and type in C5.3 - I didn't implement this behaviour), 
               but crashes instead. */

#ifndef HB_C52_STRICT
      IF nColumn >= 1 .AND. nColumn <= ::colCount
#else
      IF .T.      /* It's optimized by compiler without any RT overhead */
#endif
         oPrevCol := ::columns[ nColumn ]
         ::columns[ nColumn ] := oCol
         ::configure( _TBR_CONF_COLUMNS )
      ENDIF
   ENDIF

   /* NOTE: CA-Cl*pper 5.2 NG says this will return the previously set 
            column, but it's returning Self instead. In C5.3 this bug 
            was fixed and it works as expected (except when wrong
            parameter is passed, when it returns NIL). [vszakats] */
#ifdef HB_C52_STRICT
   RETURN Self
#else
   RETURN oPrevCol
tbrowse.prg2184
TBROWSE:METHODgetColumn( nColumn ) CLASS TBROWSE
METHOD getColumn( nColumn ) CLASS TBROWSE

#ifdef HB_C52_STRICT
   RETURN ::columns[ nColumn ]
#else
   RETURN IIF( nColumn >= 1 .AND. nColumn <= ::colCount, ::columns[ nColumn ], NIL )
tbrowse.prg2219
TBROWSE:METHODfootSep( cFootSep ) CLASS TBROWSE
METHOD footSep( cFootSep ) CLASS TBROWSE

   IF cFootSep != NIL
      ::cFootSep := __eInstVar53( Self, "FOOTSEP", cFootSep, "C", 1001 )
   ENDIF

   RETURN ::cFootSep
tbrowse.prg2228
TBROWSE:METHODcolSep( cColSep ) CLASS TBROWSE
METHOD colSep( cColSep ) CLASS TBROWSE

   IF cColSep != NIL
      ::cColSep := __eInstVar53( Self, "COLSEP", cColSep, "C", 1001 )
   ENDIF

   RETURN ::cColSep
tbrowse.prg2237
TBROWSE:METHODheadSep( cHeadSep ) CLASS TBROWSE
METHOD headSep( cHeadSep ) CLASS TBROWSE

   IF cHeadSep != NIL
      ::cHeadSep := __eInstVar53( Self, "HEADSEP", cHeadSep, "C", 1001 )
   ENDIF

   RETURN ::cHeadSep
tbrowse.prg2246
TBROWSE:METHODskipBlock( bSkipBlock ) CLASS TBROWSE
METHOD skipBlock( bSkipBlock ) CLASS TBROWSE

   IF bSkipBlock != NIL
      ::bSkipBlock := __eInstVar53( Self, "SKIPBLOCK", bSkipBlock, "B", 1001 )
   ENDIF

   RETURN ::bSkipBlock
tbrowse.prg2255
TBROWSE:METHODgoTopBlock( bBlock ) CLASS TBROWSE
METHOD goTopBlock( bBlock ) CLASS TBROWSE

   IF bBlock != NIL
      ::bGoTopBlock := __eInstVar53( Self, "GOTOPBLOCK", bBlock, "B", 1001 )
   ENDIF

   RETURN ::bGoTopBlock
tbrowse.prg2264
TBROWSE:METHODgoBottomBlock( bBlock ) CLASS TBROWSE
METHOD goBottomBlock( bBlock ) CLASS TBROWSE

   IF bBlock != NIL
      /* NOTE: In CA-Cl*pper the string is: "GOBOTTOMBL" */
      ::bGoBottomBlock := __eInstVar53( Self, "GOBOTTOMBLOCK", bBlock, "B", 1001 )
   ENDIF

   RETURN ::bGoBottomBlock
tbrowse.prg2273
TBROWSE:METHODnTop( nTop ) CLASS TBROWSE
METHOD nTop( nTop ) CLASS TBROWSE

   IF nTop != NIL
      #ifdef HB_COMPAT_C53
         ::n_Top := __eInstVar53( Self, "NTOP", nTop, "N", 1001 )
         IF !Empty( ::cBorder )
            ::n_Top++
         ENDIF
      #else
         ::n_Top := __eInstVar53( Self, "NTOP", nTop, "N", 1001, {| o, x | HB_SYMBOL_UNUSED( o ), x >= 0 } )
      #endif
      ::configure( _TBR_CONF_COLUMNS )
   ENDIF

   #ifdef HB_COMPAT_C53
      IF !Empty( ::cBorder )
         RETURN ::n_Top - 1
      ENDIF
   #endif

   RETURN ::n_Top
tbrowse.prg2283
TBROWSE:METHODnLeft( nLeft ) CLASS TBROWSE
METHOD nLeft( nLeft ) CLASS TBROWSE

   IF nLeft != NIL
      #ifdef HB_COMPAT_C53
         ::n_Left := __eInstVar53( Self, "NLEFT", nLeft, "N", 1001 )
         IF !Empty( ::cBorder )
            ::n_Left++
         ENDIF
      #else
         ::n_Left := __eInstVar53( Self, "NLEFT", nLeft, "N", 1001, {| o, x | HB_SYMBOL_UNUSED( o ), x >= 0 } )
      #endif
      ::configure( _TBR_CONF_COLUMNS )
   ENDIF

   #ifdef HB_COMPAT_C53
      IF !Empty( ::cBorder )
         RETURN ::n_Left - 1
      ENDIF
   #endif

   RETURN ::n_Left
tbrowse.prg2306
TBROWSE:METHODnBottom( nBottom ) CLASS TBROWSE
METHOD nBottom( nBottom ) CLASS TBROWSE

   IF nBottom != NIL
      ::n_Bottom := __eInstVar53( Self, "NBOTTOM", nBottom, "N", 1001, {| o, x | x >= o:nTop } )
      #ifdef HB_COMPAT_C53
         IF !Empty( ::cBorder )
            ::n_Bottom--
         ENDIF
      #endif
      ::configure( _TBR_CONF_COLUMNS )
   ENDIF

   #ifdef HB_COMPAT_C53
      IF !Empty( ::cBorder )
         RETURN ::n_Bottom + 1
      ENDIF
   #endif

   RETURN ::n_Bottom
tbrowse.prg2329
TBROWSE:METHODnRight( nRight ) CLASS TBROWSE
METHOD nRight( nRight ) CLASS TBROWSE

   IF nRight != NIL
      ::n_Right := __eInstVar53( Self, "NRIGHT", nRight, "N", 1001, {| o, x | x >= o:nLeft } )
      #ifdef HB_COMPAT_C53
         IF !Empty( ::cBorder )
            ::n_Right--
         ENDIF
      #endif
      ::configure( _TBR_CONF_COLUMNS )
   ENDIF

   #ifdef HB_COMPAT_C53
      IF !Empty( ::cBorder )
         RETURN ::n_Right + 1
      ENDIF
   #endif

   RETURN ::n_Right
tbrowse.prg2350
TBROWSE:METHODviewArea() CLASS TBROWSE
METHOD viewArea() CLASS TBROWSE

   LOCAL nWidth, nFrozenWidth

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   // TOFIX

   nWidth := nFrozenWidth := _TBR_COORD( ::n_Right ) - _TBR_COORD( ::n_Left ) + 1
   _MAXFREEZE( ::nFrozen, ::aColData, @nWidth )
   nFrozenWidth -= nWidth

   RETURN { ::n_Top + ::nHeadHeight + iif( ::lHeadSep, 1, 0 ),;
            ::n_Left,;
            ::n_Bottom - ::nFootHeight - iif( ::lFootSep, 1, 0 ),;
            ::n_Right,; 
            nFrozenWidth }
tbrowse.prg2373
TBROWSE:METHODfirstScrCol() CLASS TBROWSE
METHOD firstScrCol() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   // TOFIX

   RETURN IIF( ::leftVisible == 0, 0, ::aColData[ ::leftVisible ][ _TBCI_COLPOS ] )
tbrowse.prg2396
TBROWSE:METHODnRow() CLASS TBROWSE
METHOD nRow() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::n_Row
tbrowse.prg2410
TBROWSE:METHODnCol() CLASS TBROWSE
METHOD nCol() CLASS TBROWSE

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   RETURN ::n_Col
tbrowse.prg2419
TBROWSE:METHODhitTest( mRow, mCol ) CLASS TBROWSE
METHOD hitTest( mRow, mCol ) CLASS TBROWSE

   LOCAL nTop, nLeft, nBottom, nRight, nRet, nCol
   LOCAL lFirst
   LOCAL aCol

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

#ifdef HB_BRW_STATICMOUSE
   /* This is not CA-Cl*pper compatible, in Clipper ::mRowPos and ::mColPos
    * is calculated dynamically by call to MCOL() and MROW()
    */
   ::mRowPos := ::mColPos := 0
#endif

   IF !ISNUMBER( mRow ) .OR. !ISNUMBER( mCol ) .OR. ;
      mRow < ( nTop    := _TBR_COORD( ::n_Top    ) ) .OR. ;
      mRow > ( nBottom := _TBR_COORD( ::n_Bottom ) ) .OR. ;
      mCol < ( nLeft   := _TBR_COORD( ::n_Left   ) ) .OR. ;
      mCol > ( nRight  := _TBR_COORD( ::n_Right  ) )
      RETURN HTNOWHERE
   ENDIF

   nRet := HTNOWHERE

   IF !Empty( ::cBorder )
      IF mRow == nTop - 1
         IF mCol == nLeft - 1
            nRet := HTTOPLEFT
         ELSEIF mCol == nRight + 1
            nRet := HTTOPRIGHT
         ELSE
            nRet := HTTOP
         ENDIF
      ELSEIF mRow == nBottom + 1
         IF mCol == nLeft - 1
            nRet := HTBOTTOMLEFT
         ELSEIF mCol == nRight + 1
            nRet := HTBOTTOMRIGHT
         ELSE
            nRet := HTBOTTOM
         ENDIF
      ELSEIF mCol == nLeft - 1
         nRet := HTLEFT
      ELSEIF mCol == nRight + 1
         nRet := HTRIGHT
      ENDIF
   ENDIF

   IF nRet == HTNOWHERE
      IF mRow < nTop + ::nHeadHeight
         nRet := HTHEADING
      ELSEIF ::lHeadSep .AND. mRow == nTop + ::nHeadHeight
         nRet := HTHEADSEP
      ELSEIF ::lFootSep .AND. mRow == nBottom - ::nFootHeight
         nRet := HTFOOTSEP
      ELSEIF mRow > nBottom - ::nFootHeight
         nRet := HTFOOTING
      ELSE
         nRet := HTCELL
#ifdef HB_BRW_STATICMOUSE
         ::mRowPos := mRow - nTop - ::nHeadHeight - IIF( ::lHeadSep, 1, 0 )
#endif
         lFirst := .T.
         nCol := 1
         WHILE nCol <= ::nRightVisible
            aCol := ::aColData[ nCol ]
            IF aCol[ _TBCI_COLPOS ] != NIL
               IF lFirst
                  lFirst := .F.
               ELSE
                  /* NOTE: CA-Cl*pper has bug here, it takes the size of
                   *       next column separator instead of the current one
                   */
                  IF ( nLeft += aCol[ _TBCI_SEPWIDTH ] ) > mCol
                     nRet := HTCOLSEP
                     EXIT
                  ENDIF
               ENDIF
#ifdef HB_BRW_STATICMOUSE
               ::mColPos := nCol
#endif
               IF ( nLeft += aCol[ _TBCI_COLWIDTH ] + ;
                             aCol[ _TBCI_FROZENSPACE ] + ;
                             aCol[ _TBCI_LASTSPACE ] ) > mCol
                  EXIT
               ENDIF
            ENDIF
            IF nCol == ::nFrozen .AND. nCol < ::nLeftVisible
               nCol := ::nLeftVisible
            ELSE
               nCol++
            ENDIF
         ENDDO
      ENDIF
   ENDIF

   RETURN nRet
tbrowse.prg2428
STATIC PROCEDURE_mBrwPos( oBrw, mRow, mCol )
STATIC PROCEDURE _mBrwPos( oBrw, mRow, mCol )

   LOCAL nTop, nLeft, nBottom, nRight, nPos, nCol, aCol

   mRow := MRow()
   mCol := MCol()

   IF mRow >= ( nTop    := _TBR_COORD( oBrw:n_Top    ) ) .AND. ;
      mRow <= ( nBottom := _TBR_COORD( oBrw:n_Bottom ) ) .AND. ;
      mCol >= ( nLeft   := _TBR_COORD( oBrw:n_Left   ) ) .AND. ;
      mCol <= ( nRight  := _TBR_COORD( oBrw:n_Right  ) )

      IF mRow < nTop + oBrw:nHeadHeight + IIF( oBrw:lHeadSep, 1, 0 ) .OR. ;
         mRow > nBottom - oBrw:nFootHeight - IIF( oBrw:lFootSep, 1, 0 )
         mRow := 0
      ELSE
         mRow -= nTop + oBrw:nHeadHeight - IIF( oBrw:lHeadSep, 0, 1 )
      ENDIF

      nPos := 0
      nCol := 1
      WHILE nCol <= oBrw:nRightVisible
         aCol := oBrw:aColData[ nCol ]
         IF aCol[ _TBCI_COLPOS ] != NIL
            IF nPos != 0
               IF ( nLeft += aCol[ _TBCI_SEPWIDTH ] ) > mCol
                  EXIT
               ENDIF
            ENDIF
            nPos := nCol
            IF ( nLeft += aCol[ _TBCI_COLWIDTH ] + ;
                          aCol[ _TBCI_FROZENSPACE ] + ;
                          aCol[ _TBCI_LASTSPACE ] ) > mCol
               EXIT
            ENDIF
         ENDIF
         IF nCol == oBrw:nFrozen .AND. nCol < oBrw:nLeftVisible
            nCol := oBrw:nLeftVisible
         ELSE
            nCol++
         ENDIF
      ENDDO
      mCol := nPos
      IF nPos == 0
         mRow := 0
      ENDIF
   ELSE
      mRow := mCol := 0
   ENDIF

   RETURN
tbrowse.prg2531
TBROWSE:METHODmRowPos() CLASS TBROWSE
METHOD mRowPos() CLASS TBROWSE

   LOCAL mRow, mCol

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   _mBrwPos( self, @mRow, @mCol )

   RETURN mRow
tbrowse.prg2584
TBROWSE:METHODmColPos() CLASS TBROWSE
METHOD mColPos() CLASS TBROWSE
   LOCAL mRow, mCol

   IF ::nConfigure != 0
      ::doConfigure()
   ENDIF

   _mBrwPos( self, @mRow, @mCol )

   RETURN mCol
tbrowse.prg2597
TBROWSE:METHODborder( cBorder ) CLASS TBROWSE
METHOD border( cBorder ) CLASS TBROWSE

   IF cBorder != NIL

      cBorder := __eInstVar53( Self, "BORDER", cBorder, "C", 1001 )

      IF Len( cBorder ) == 0 .OR. Len( cBorder ) == 8
      
         IF Empty( ::cBorder ) .AND. !Empty( cBorder )
            ::n_Top++
            ::n_Left++
            ::n_Bottom--
            ::n_Right--
            ::configure( _TBR_CONF_COLUMNS )
         ELSEIF !Empty( ::cBorder ) .AND. Empty( cBorder )
            ::n_Top--
            ::n_Left--
            ::n_Bottom++
            ::n_Right++
            ::configure( _TBR_CONF_COLUMNS )
         ENDIF

         ::cBorder := cBorder
      ENDIF
   ENDIF

   RETURN ::cBorder
tbrowse.prg2610
TBROWSE:METHODmessage( cMessage ) CLASS TBROWSE
METHOD message( cMessage ) CLASS TBROWSE

   IF cMessage != NIL
      ::cMessage := __eInstVar53( Self, "MESSAGE", cMessage, "C", 1001 )
   ENDIF

   RETURN ::cMessage
tbrowse.prg2639
TBROWSE:METHODapplyKey( nKey ) CLASS TBROWSE
METHOD applyKey( nKey ) CLASS TBROWSE

   LOCAL bBlock := ::SetKey( nKey )

   IF bBlock == NIL
      bBlock := ::SetKey( 0 )

      IF bBlock == NIL
         RETURN TBR_EXCEPTION
      ENDIF
   ENDIF

   RETURN Eval( bBlock, Self, nKey )
tbrowse.prg2648
TBROWSE:METHODsetKey( nKey, bBlock ) CLASS TBROWSE
METHOD setKey( nKey, bBlock ) CLASS TBROWSE

   LOCAL bReturn
   LOCAL nPos

   /* NOTE: Assigned codeblock receives two parameters:
            {| oTBrowse, nKey |  } */

   IF ::keys == NIL
      ::keys := { { K_DOWN       , {| o | o:Down()    , TBR_CONTINUE   } },;
                  { K_END        , {| o | o:End()     , TBR_CONTINUE   } },;
                  { K_CTRL_PGDN  , {| o | o:GoBottom(), TBR_CONTINUE   } },;
                  { K_CTRL_PGUP  , {| o | o:GoTop()   , TBR_CONTINUE   } },;
                  { K_HOME       , {| o | o:Home()    , TBR_CONTINUE   } },;
                  { K_LEFT       , {| o | o:Left()    , TBR_CONTINUE   } },;
                  { K_PGDN       , {| o | o:PageDown(), TBR_CONTINUE   } },;
                  { K_PGUP       , {| o | o:PageUp()  , TBR_CONTINUE   } },;
                  { K_CTRL_END   , {| o | o:PanEnd()  , TBR_CONTINUE   } },;
                  { K_CTRL_HOME  , {| o | o:PanHome() , TBR_CONTINUE   } },;
                  { K_CTRL_LEFT  , {| o | o:PanLeft() , TBR_CONTINUE   } },;
                  { K_CTRL_RIGHT , {| o | o:PanRight(), TBR_CONTINUE   } },;
                  { K_RIGHT      , {| o | o:Right()   , TBR_CONTINUE   } },;
                  { K_UP         , {| o | o:Up()      , TBR_CONTINUE   } },;
                  { K_ESC        , {|   |               TBR_EXIT       } },;
                  { K_LBUTTONDOWN, {| o | TBMouse( o, MRow(), MCol() ) } } }

      #ifndef HB_C52_STRICT
         AAdd( ::keys, { K_MWFORWARD  , {| o | o:Up()      , TBR_CONTINUE   } } )
         AAdd( ::keys, { K_MWBACKWARD , {| o | o:Down()    , TBR_CONTINUE   } } )
      #endif
   ENDIF

   IF ( nPos := AScan( ::keys, {| x | x[ _TBC_SETKEY_KEY ] == nKey } ) ) == 0
      IF ISBLOCK( bBlock )
         AAdd( ::keys, { nKey, bBlock } )
      ENDIF
      bReturn := bBlock
   ELSEIF ISBLOCK( bBlock )
      ::keys[ nPos ][ _TBC_SETKEY_BLOCK ] := bBlock
      bReturn := bBlock
   ELSEIF PCount() == 1
      bReturn := ::keys[ nPos ][ _TBC_SETKEY_BLOCK ]
   ELSE
      bReturn := ::keys[ nPos ][ _TBC_SETKEY_BLOCK ]
      IF PCount() == 2 .AND. bBlock == NIL .AND. nKey != 0
         ADel( ::keys, nPos )
         ASize( ::keys, Len( ::keys ) - 1 )
      ENDIF
   ENDIF

   RETURN bReturn
tbrowse.prg2663
TBROWSE:METHODsetStyle( nStyle, lNewValue ) CLASS TBROWSE
METHOD setStyle( nStyle, lNewValue ) CLASS TBROWSE

   /* NOTE: CA-Cl*pper 5.3 will initialize this var on the first 
            :setStyle() method call. [vszakats] */

   DEFAULT ::styles TO { .F., .F., .F., .F., .F., NIL }

   /* NOTE: CA-Cl*pper 5.3 does no checks on the value of nStyle, so in case 
            it is zero or non-numeric, a regular RTE will happen. [vszakats] */

   IF nStyle > LEN( ::styles ) .AND. ;
      nStyle <= 4096 /* some reasonable limit for maximum number of styles */
      ASIZE( ::styles, nStyle )
   ENDIF

   IF ISLOGICAL( lNewValue )
      ::styles[ nStyle ] := lNewValue
   ENDIF

   RETURN ::styles[ nStyle ]
tbrowse.prg2716
FUNCTIONTBMouse( oBrw, nMRow, nMCol )
FUNCTION TBMouse( oBrw, nMRow, nMCol )

   LOCAL n

   IF oBrw:hitTest( nMRow, nMCol ) == HTCELL

      IF ( n := oBrw:mRowPos - oBrw:rowPos ) < 0
         WHILE ++n <= 0
            oBrw:up()
         ENDDO
      ELSEIF n > 0
         WHILE --n >= 0
            oBrw:down()
         ENDDO
      ENDIF

      IF ( n := oBrw:mColPos - oBrw:colPos ) < 0
         WHILE ++n <= 0
            oBrw:left()
         ENDDO
      ELSEIF n > 0
         WHILE --n >= 0
            oBrw:right()
         ENDDO
      ENDIF

      RETURN TBR_CONTINUE
   ENDIF

   RETURN TBR_EXCEPTION
tbrowse.prg2738
tbrowsys.prg
TypeFunctionSourceLine
FUNCTIONTApplyKey( nKey, oBrowse )
FUNCTION TApplyKey( nKey, oBrowse )

   RETURN oBrowse:applyKey( nKey )
tbrowsys.prg59
FUNCTIONTBAddCol()
FUNCTION TBAddCol()
   /* TODO */
   RETURN NIL
tbrowsys.prg63
FUNCTIONTBBBlock()
FUNCTION TBBBlock()
   /* TODO */
   RETURN NIL
tbrowsys.prg67
FUNCTIONTBClose()
FUNCTION TBClose()
   /* TODO */
   RETURN NIL
tbrowsys.prg71
FUNCTIONTBCreate()
FUNCTION TBCreate()
   /* TODO */
   RETURN NIL
tbrowsys.prg75
FUNCTIONTBDelCol()
FUNCTION TBDelCol()
   /* TODO */
   RETURN NIL
tbrowsys.prg79
FUNCTIONTBDisplay()
FUNCTION TBDisplay()
   /* TODO */
   RETURN NIL
tbrowsys.prg83
FUNCTIONTBEditCell()
FUNCTION TBEditCell()
   /* TODO */
   RETURN NIL
tbrowsys.prg87
FUNCTIONTBFBlock()
FUNCTION TBFBlock()
   /* TODO */
   RETURN NIL
tbrowsys.prg91
FUNCTIONTBGoBot()
FUNCTION TBGoBot()
   /* TODO */
   RETURN NIL
tbrowsys.prg95
FUNCTIONTBGoTop()
FUNCTION TBGoTop()
   /* TODO */
   RETURN NIL
tbrowsys.prg99
FUNCTIONTBInsCol()
FUNCTION TBInsCol()
   /* TODO */
   RETURN NIL
tbrowsys.prg103
FUNCTIONTBModal()
FUNCTION TBModal()
   /* TODO */
   RETURN NIL
tbrowsys.prg107
FUNCTIONTBSBlock()
FUNCTION TBSBlock()
   /* TODO */
   RETURN NIL
tbrowsys.prg111
FUNCTIONTBSkip()
FUNCTION TBSkip()
   /* TODO */
   RETURN NIL
tbrowsys.prg115
tclass.prg
TypeFunctionSourceLine
FUNCTIONHBClass()
FUNCTION HBClass()

   STATIC s_hClass /* NOTE: Automatically default to NIL */

   IF s_hClass == NIL
      s_hClass := __clsNew( "HBCLASS", 16,, @HBClass() )
/*    s_hClass := __clsNew( "HBCLASS", 17,, @HBClass())  */

      __clsAddMsg( s_hClass, "New"            , @New()            , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "Create"         , @Create()         , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddData"        , @AddData()        , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddMultiData"   , @AddMultiData()   , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddClassData"   , @AddClassData()   , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddMultiClsData", @AddMultiClsData(), HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddInline"      , @AddInline()      , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddMethod"      , @AddMethod()      , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddClsMethod"   , @AddClsMethod()   , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddVirtual"     , @AddVirtual()     , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddDelegate"    , @AddDelegate()    , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddFriendFunc"  , @AddFriendFunc()  , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "AddFriendClass" , @AddFriendClass() , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "Instance"       , @Instance()       , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "SetOnError"     , @SetOnError()     , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "SetDestructor"  , @SetDestructor()  , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "InitClass"      , @InitClass()      , HB_OO_MSG_METHOD )
      __clsAddMsg( s_hClass, "cSuper"         , {| Self | iif( Empty( ::asSuper ), NIL, ::asSuper[ 1 ]:name ) }, HB_OO_MSG_INLINE )
      __clsAddMsg( s_hClass, "hClass"         ,  1, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_hClass"        ,  1, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "cName"          ,  2, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_cName"         ,  2, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "aDatas"         ,  3, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_aDatas"        ,  3, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "aMethods"       ,  4, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_aMethods"      ,  4, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "aClsDatas"      ,  5, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_aClsDatas"     ,  5, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "aClsMethods"    ,  6, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_aClsMethods"   ,  6, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "aInlines"       ,  7, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_aInlines"      ,  7, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "aVirtuals"      ,  8, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_aVirtuals"     ,  8, HB_OO_MSG_ASSIGN )

      __clsAddMsg( s_hClass, "aDelegates"     ,  9, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_aDelegates"    ,  9, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "asSuper"        , 10, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_asSuper"       , 10, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "nOnError"       , 11, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_nOnError"      , 11, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "nDestructor"    , 12, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_nDestructor"   , 12, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "lModFriendly"   , 13, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_lModFriendly"  , 13, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "asFriendClass"  , 14, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_asFriendClass" , 14, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "asFriendFunc"   , 15, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_asFriendFunc"  , 15, HB_OO_MSG_ASSIGN )
      __clsAddMsg( s_hClass, "sClassFunc"     , 16, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_sClassFunc"    , 16, HB_OO_MSG_ASSIGN )
  /*  __clsAddMsg( s_hClass, "class"          , 17, HB_OO_MSG_ACCESS )
      __clsAddMsg( s_hClass, "_class"         , 17, HB_OO_MSG_ASSIGN ) */

   ENDIF

   RETURN __clsInst( s_hClass )
tclass.prg81
STATIC FUNCTIONNew( cClassName, xSuper, sClassFunc, lModuleFriendly )
STATIC FUNCTION New( cClassName, xSuper, sClassFunc, lModuleFriendly )

   LOCAL Self := QSelf()
   LOCAL nSuper, i

   DEFAULT lModuleFriendly TO .F.

   IF Empty( xSuper )
      ::asSuper := {}
   ELSEIF VALTYPE( xSuper ) == "C"
      ::asSuper := { __DynsN2Sym( xSuper ) }
   ELSEIF VALTYPE( xSuper ) == "S"
      ::asSuper := { xSuper }
   ELSEIF VALTYPE( xSuper ) == "A"
      ::asSuper := {}
      nSuper := Len( xSuper )
      FOR i := 1 TO nSuper
         IF !Empty( xSuper[ i ] )
            IF VALTYPE( xSuper[ i ] ) == "C"
               AADD( ::asSuper, __DynsN2Sym( xSuper[ i ] ) )
            ELSEIF VALTYPE( xSuper[ i ] ) == "S"
               AADD( ::asSuper, xSuper[ i ] )
            ENDIF
         ENDIF
      NEXT
   ENDIF

   ::cName         := Upper( cClassName )
   ::sClassFunc    := sClassFunc
   ::lModFriendly  := lModuleFriendly

   ::aDatas        := {}
   ::aMethods      := {}
   ::aClsDatas     := {}
   ::aClsMethods   := {}
   ::aInlines      := {}
   ::aVirtuals     := {}
   ::aDelegates    := {}
   ::asFriendClass := {}
   ::asFriendFunc  := {}

   RETURN QSelf()
tclass.prg154
STATIC PROCEDURECreate()
STATIC PROCEDURE Create()

   LOCAL Self := QSelf()
   LOCAL n
   LOCAL nLenDatas := Len( ::aDatas ) //Datas local to the class !!
   LOCAL nLen := Len( ::asSuper )
   LOCAL nClassBegin
   LOCAL hClass
   LOCAL ahSuper := {}

/* Self:Class := MetaClass */

   FOR n := 1 TO nLen
      hClass := __clsInstSuper( ::asSuper[ n ] ) // Super handle available
      IF hClass != 0
         AAdd( ahSuper, hClass )
      ENDIF
   NEXT

   hClass := __clsNew( ::cName, nLenDatas, ahSuper, ::sClassFunc, ::lModFriendly )
   ::hClass := hClass

   IF !EMPTY( ahSuper )
      IF ahSuper[ 1 ] != 0
         __clsAddMsg( hClass, "SUPER"  , 0, HB_OO_MSG_SUPER, ahSuper[ 1 ], HB_OO_CLSTP_EXPORTED )
         __clsAddMsg( hClass, "__SUPER", 0, HB_OO_MSG_SUPER, ahSuper[ 1 ], HB_OO_CLSTP_EXPORTED )
      ENDIF
   ENDIF
   __clsAddMsg( hClass, "REALCLASS" , 0, HB_OO_MSG_REALCLASS, 0     , HB_OO_CLSTP_EXPORTED )

   // We will work here on the MetaClass object to add the Class Method
   // as needed
   //nLen := Len( ::aClsMethods )
   //FOR n := 1 TO nLen
   // // do it
   //NEXT
   ////

   //Local message...

   FOR n := 1 TO nLenDatas
      __clsAddMsg( hClass, ::aDatas[ n ][ HB_OO_DATA_SYMBOL ]       , n, ;
                   HB_OO_MSG_ACCESS, ::aDatas[ n ][ HB_OO_DATA_VALUE ], ::aDatas[ n ][ HB_OO_DATA_SCOPE ] )
      __clsAddMsg( hClass, "_" + ::aDatas[ n ][ HB_OO_DATA_SYMBOL ] , n, ;
                   HB_OO_MSG_ASSIGN, ::aDatas[ n ][ HB_OO_DATA_TYPE ] , ::aDatas[ n ][ HB_OO_DATA_SCOPE ] )
   NEXT

   nLen := Len( ::aMethods )
   FOR n := 1 TO nLen
      __clsAddMsg( hClass, ::aMethods[ n ][ HB_OO_MTHD_SYMBOL ], ::aMethods[ n ][ HB_OO_MTHD_PFUNCTION ],;
                   HB_OO_MSG_METHOD, NIL, ::aMethods[ n ][ HB_OO_MTHD_SCOPE ] )
   NEXT

   nLen := Len( ::aClsDatas )
   nClassBegin := __CLS_CNTCLSDATA( hClass )
   FOR n := 1 TO nLen
      __clsAddMsg( hClass, ::aClsDatas[ n ][ HB_OO_CLSD_SYMBOL ]      , n + nClassBegin,;
                   HB_OO_MSG_CLSACCESS, ::aClsDatas[ n ][ HB_OO_CLSD_VALUE ], ::aClsDatas[ n ][ HB_OO_CLSD_SCOPE ] )
      __clsAddMsg( hClass, "_" + ::aClsDatas[ n ][ HB_OO_CLSD_SYMBOL ], n + nClassBegin,;
                   HB_OO_MSG_CLSASSIGN,                                     , ::aClsDatas[ n ][ HB_OO_CLSD_SCOPE ] )
   NEXT

   nLen := Len( ::aInlines )
   FOR n := 1 TO nLen
      __clsAddMsg( hClass, ::aInlines[ n ][ HB_OO_MTHD_SYMBOL ], ::aInlines[ n ][ HB_OO_MTHD_PFUNCTION ],;
                   HB_OO_MSG_INLINE, NIL, ::aInlines[ n ][ HB_OO_MTHD_SCOPE ] )
   NEXT

   nLen := Len( ::aVirtuals )
   FOR n := 1 TO nLen
      __clsAddMsg( hClass, ::aVirtuals[ n ], n, HB_OO_MSG_VIRTUAL )
   NEXT

   IF ::nOnError != NIL
      __clsAddMsg( hClass, "__OnError", ::nOnError, HB_OO_MSG_ONERROR )
   ENDIF

   IF ::nDestructor != NIL
      __clsAddMsg( hClass, "__Destructor", ::nDestructor, HB_OO_MSG_DESTRUCTOR )
   ENDIF

   //Friend Classes
   nLen := Len( ::asFriendClass )
   FOR n := 1 TO nLen
      __clsAddFriend( ::hClass, ::asFriendClass[ n ] )
   NEXT

   //Friend Functions
   nLen := Len( ::asFriendFunc )
   FOR n := 1 TO nLen
      __clsAddFriend( ::hClass, ::asFriendFunc[ n ] )
   NEXT

   RETURN
tclass.prg200
STATIC FUNCTIONInstance()
STATIC FUNCTION Instance()
   LOCAL Self := QSelf()
   LOCAL oInstance := __clsInst( ::hClass )

   /*oInstance:Class := Self:Class*/

   RETURN oInstance
tclass.prg297
STATIC PROCEDUREAddData( cData, xInit, cType, nScope, lNoinit )
STATIC PROCEDURE AddData( cData, xInit, cType, nScope, lNoinit )

   LOCAL c

   DEFAULT lNoInit TO .F.
   DEFAULT nScope TO HB_OO_CLSTP_EXPORTED

   // Default Init for Logical and numeric
   IF ! lNoInit .AND. cType != NIL .AND. xInit == NIL
      c := Upper( Left( cType, 1 ) )
      IF c == "L"       /* Logical */
         xInit := .F.
      ELSEIF c $ "NI"   /* Numeric or Integer */
         xInit := 0
      ELSEIF c == "D"   /* Date */
         xInit := Ctod("")
      ENDIF
   ENDIF

   AAdd( QSelf():aDatas, { cData, xInit, cType, nScope } )

   RETURN
tclass.prg307
STATIC PROCEDUREAddMultiData( cType, xInit, nScope, aData, lNoInit )
STATIC PROCEDURE AddMultiData( cType, xInit, nScope, aData, lNoInit )

   LOCAL i
   LOCAL nParam := Len( aData )

   FOR i := 1 TO nParam
      IF VALTYPE( aData[ i ] ) == "C"
         QSelf():AddData( aData[ i ], xInit, cType, nScope, lNoInit )
      ENDIF
   NEXT

   RETURN
tclass.prg332
STATIC PROCEDUREAddClassData( cData, xInit, cType, nScope, lNoInit )
STATIC PROCEDURE AddClassData( cData, xInit, cType, nScope, lNoInit )

   LOCAL c

   DEFAULT lNoInit TO .F.

   // Default Init for Logical and numeric
   IF ! lNoInit .AND. cType != NIL .AND. xInit == NIL
      c := Upper( Left( cType, 1 ) )
      IF c == "L"       /* Logical */
         xInit := .F.
      ELSEIF c $ "NI"   /* Numeric or Integer */
         xInit := 0
      ELSEIF c == "D"   /* Date */
         xInit := Ctod("")
      ENDIF
   ENDIF

   AAdd( QSelf():aClsDatas, { cData, xInit, cType, nScope } )

   RETURN
tclass.prg347
STATIC PROCEDUREAddMultiClsData( cType, xInit, nScope, aData, lNoInit )
STATIC PROCEDURE AddMultiClsData( cType, xInit, nScope, aData, lNoInit )

   LOCAL i
   LOCAL nParam := Len( aData )

   FOR i := 1 TO nParam
      IF VALTYPE( aData[ i ] ) == "C"
         QSelf():AddClassData( aData[ i ], xInit, cType, nScope, lNoInit )
      ENDIF
   NEXT

   RETURN
tclass.prg371
STATIC PROCEDUREAddInline( cMethod, bCode, nScope )
STATIC PROCEDURE AddInline( cMethod, bCode, nScope )

   DEFAULT nScope TO HB_OO_CLSTP_EXPORTED

   AAdd( QSelf():aInlines, { cMethod, bCode, nScope } )

   RETURN
tclass.prg386
STATIC PROCEDUREAddMethod( cMethod, nFuncPtr, nScope )
STATIC PROCEDURE AddMethod( cMethod, nFuncPtr, nScope )

   DEFAULT nScope TO HB_OO_CLSTP_EXPORTED

   AAdd( QSelf():aMethods, { cMethod, nFuncPtr, nScope } )

   RETURN
tclass.prg396
STATIC PROCEDUREAddClsMethod( cMethod, nFuncPtr, nScope )
STATIC PROCEDURE AddClsMethod( cMethod, nFuncPtr, nScope )

   AAdd( QSelf():aClsMethods, { cMethod, nFuncPtr, nScope } )

   RETURN
tclass.prg406
STATIC PROCEDUREAddVirtual( cMethod )
STATIC PROCEDURE AddVirtual( cMethod )

   AAdd( QSelf():aVirtuals, cMethod )

   RETURN
tclass.prg414
STATIC PROCEDUREAddDelegate( xMethod, nAccScope, nAsgScope, cType, cDelegMsg, cDelegClass )
STATIC PROCEDURE AddDelegate( xMethod, nAccScope, nAsgScope, cType, cDelegMsg, cDelegClass )

   LOCAL i

   IF VALTYPE( xMethod ) == "C"
      AAdd( QSelf():aDelegates, { xMethod, nAccScope, nAsgScope, cType, cDelegMsg, cDelegClass } )
   ELSEIF VALTYPE( xMethod ) == "A"
      FOR i := 1 TO LEN( xMethod )
         AAdd( QSelf():aDelegates, { xMethod[ i ], nAccScope, nAsgScope, cType, cDelegMsg, cDelegClass } )
      NEXT
   ENDIF

   RETURN
tclass.prg420
STATIC PROCEDUREAddFriendClass( ... )
STATIC PROCEDURE AddFriendClass( ... )

   LOCAL Self := QSelf()

   AEval( HB_AParams(), { | sClass | AAdd( ::asFriendClass, sClass ) } )

   RETURN
tclass.prg436
STATIC PROCEDUREAddFriendFunc( ... )
STATIC PROCEDURE AddFriendFunc( ... )

   LOCAL Self := QSelf()

   AEval( HB_AParams(), { | sFunc | AAdd( ::asFriendFunc, sFunc ) } )

   RETURN
tclass.prg446
STATIC PROCEDURESetOnError( nFuncPtr )
STATIC PROCEDURE SetOnError( nFuncPtr )

   QSelf():nOnError := nFuncPtr

   RETURN
tclass.prg456
STATIC PROCEDURESetDestructor( nFuncPtr )
STATIC PROCEDURE SetDestructor( nFuncPtr )

   QSelf():nDestructor := nFuncPtr

   RETURN
tclass.prg462
STATIC FUNCTIONInitClass()
STATIC FUNCTION InitClass()

   RETURN QSelf()
tclass.prg470
teditor.prg
TypeFunctionSourceLine
METHODLoadFile( cFileName )
   METHOD LoadFile( cFileName )                          // Load cFileName into active editor
teditor.prg67
METHODLoadText( cString )
   METHOD LoadText( cString )                            // Load cString into active editor
teditor.prg68
METHODSaveFile()
   METHOD SaveFile()                                     // Save active file (not for MemoEdit() emulation)
teditor.prg69
METHODAddLine( cLine, lSoftCR )
   METHOD AddLine( cLine, lSoftCR )                      // Add a new Line of text at end of current text
teditor.prg71
METHODInsertLine( cLine, lSoftCR, nRow )
   METHOD InsertLine( cLine, lSoftCR, nRow )             // Insert a line of text at a defined row
teditor.prg72
METHODRemoveLine( nRow )
   METHOD RemoveLine( nRow )                             // Remove a line of text
teditor.prg73
METHODGetLine( nRow )
   METHOD GetLine( nRow )                                // Return line n of text
teditor.prg74
METHODLineLen( nRow )
   METHOD LineLen( nRow )                                // Return text length of line n
teditor.prg75
METHODSplitLine( nRow )
   METHOD SplitLine( nRow )                              // If a line of text is longer than nWordWrapCol divides it into multiple lines
teditor.prg76
METHODGotoLine( nRow )
   METHOD GotoLine( nRow )                               // Put line nRow at cursor position
teditor.prg77
METHODGetText()
   METHOD GetText()                                      // Returns aText as a string (for MemoEdit())
teditor.prg79
METHODdisplay()
   METHOD display()                                      // Redraw a window
teditor.prg81
METHODRefreshLine()
   METHOD RefreshLine()                                  // Redraw a line
teditor.prg82
METHODRefreshColumn()
   METHOD RefreshColumn()                                // Redraw a column of text
teditor.prg83
METHODLineColor( nRow )
   METHOD LineColor( nRow )                              // Returns color string to use to draw nRow (current line if nRow is empty)
teditor.prg84
METHODMoveCursor( nKey )
   METHOD MoveCursor( nKey )                             // Move cursor inside text / window (needs a movement key)
teditor.prg86
METHODInsertState( lInsState )
   METHOD InsertState( lInsState )                       // Changes lInsert value and insertion / overstrike mode of editor
teditor.prg87
METHODEdit( nPassedKey )
   METHOD Edit( nPassedKey )                             // Handles input (can receive a key in which case handles only this key and then exits)
teditor.prg88
METHODKeyboardHook( nKey )
   METHOD KeyboardHook( nKey )                           // Gets called every time there is a key not handled directly by HBEditor
teditor.prg90
METHODIdleHook()
   METHOD IdleHook()                                     // Gets called every time there are no more keys to hanlde just before HBEditor blocks itself waiting for a char
teditor.prg91
METHODResize( nTop, nLeft, nBottom, nRight )
   METHOD Resize( nTop, nLeft, nBottom, nRight )         // Redefines editor window size and refreshes it
teditor.prg93
METHODSetColor( cColorString )
   METHOD SetColor( cColorString )                       // Sets/retrieves color used for screen writes
teditor.prg94
METHODHilite()
   METHOD Hilite()                                       // Start Hilighting swapping first two color definitions inside cColorSpec
teditor.prg95
METHODDeHilite()
   METHOD DeHilite()                                     // Stop Hilighting
teditor.prg96
METHODSetPos( nRow, nCol )
   METHOD SetPos( nRow, nCol )                           // Updates ::nPhysRow, ::nPhysCol and then calls SetPos() to move hardware cursor
teditor.prg98
METHODRow()
   METHOD Row()                                          // Same as clipper ones, returns ::nPhysRow
teditor.prg99
METHODCol()
   METHOD Col()                                          // Same as clipper ones, returns ::nPhysCol
teditor.prg100
METHODRowPos()
   METHOD RowPos()                                       // Returns ::nRow
teditor.prg101
METHODColPos()
   METHOD ColPos()                                       // Returns ::nCol value
teditor.prg102
METHODSaved()
   METHOD Saved()                                        // Returns ::lSaved
teditor.prg103
METHODChanged()
   METHOD Changed()                                      // Returns ::lDirty
teditor.prg104
METHODIsWordWrap()
   METHOD IsWordWrap()                                   // Returns ::lWordWrap
teditor.prg105
METHODWordWrapCol()
   METHOD WordWrapCol()                                  // Returns ::nWordWrapCol
teditor.prg106
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )                        // UI control compatible method

   MESSAGE RefreshWindow() METHOD display()              // for compatibility
teditor.prg107
METHODNew( cString, nTop, nLeft, nBottom, nRight, lEditMode, nLineLength, nTabSize )
   METHOD New( cString, nTop, nLeft, nBottom,;           // Converts a string to an array of strings splitting input string at EOL boundaries
               nRight, lEditMode, nLineLength, nTabSize )

   PROTECTED:

   VAR cFile          AS STRING      INIT ""             // name of file being edited
                                                           
   VAR aText          AS ARRAY       INIT {}             // array with lines of text being edited
   VAR naTextLen      AS NUMERIC     INIT 0              // number of lines of text inside aText.
                                                           
   VAR nTop           AS NUMERIC                         // boundaries of editor window, without box around
   VAR nLeft          AS NUMERIC                         
   VAR nBottom        AS NUMERIC                         
   VAR nRight         AS NUMERIC                         
                                                           
   VAR nFirstCol      AS NUMERIC     INIT 1              // FirstCol/Row of current text visible inside editor window
   VAR nFirstRow      AS NUMERIC     INIT 1              
   VAR nRow           AS NUMERIC     INIT 1              // Cursor position inside aText (nRow) and inside current line of text (nCol)
   VAR nCol           AS NUMERIC     INIT 1              
                                                           
   VAR nPhysRow       AS NUMERIC     INIT 0              // Hardware cursor position, I cannot rely on Row()/Col() because I could be inside another
   VAR nPhysCol       AS NUMERIC     INIT 0              // application/object and this one could be moving real cursor. If I'm running full
                                                         // screen nPhysRow will always have the same value as Row() and nPhysCol as Col()
                                                           
   VAR nNumCols       AS NUMERIC     INIT 1              // How many columns / rows can be displayed inside editor window
   VAR nNumRows       AS NUMERIC     INIT 1              
                                                           
   VAR lInsert        AS LOGICAL     INIT .F.            // Is editor in Insert mode or in Overstrike one?
   VAR nTabWidth      AS NUMERIC     INIT 8              // Size of Tab chars
   VAR lEditAllow     AS LOGICAL     INIT .T.            // Are changes to text allowed?
   VAR lSaved         AS LOGICAL     INIT .F.            // True if user exited editor with K_CTRL_W
   VAR lWordWrap      AS LOGICAL     INIT .F.            // True if word wrapping is active
   VAR nWordWrapCol   AS NUMERIC     INIT 0              // At which column word wrapping occurs
   VAR lDirty         AS LOGICAL     INIT .F.            // .T. if there are changes not saved
   VAR lExitEdit      AS LOGICAL     INIT .F.            // .T. if user requested to end Edit() method
                                                           
   VAR cColorSpec     AS CHARACTER                       // Color string used for screen writes
teditor.prg112
METHODGetParagraph( nRow )
   METHOD GetParagraph( nRow )
teditor.prg150
METHODBrowseText( nPassedKey )
   METHOD BrowseText( nPassedKey )

ENDCLASS
teditor.prg151
HBEDITOR:METHODResize( nTop, nLeft, nBottom, nRight ) CLASS HBEditor
METHOD Resize( nTop, nLeft, nBottom, nRight ) CLASS HBEditor

   // don't change coordinates not given
   DEFAULT nTop    TO ::nTop
   DEFAULT nLeft   TO ::nLeft
   DEFAULT nBottom TO ::nBottom
   DEFAULT nRight  TO ::nRight

   ::nTop := nTop
   ::nLeft := nLeft
   ::nBottom := nBottom
   ::nRight := nRight

   // How many cols and rows are available
   ::nNumCols := ::nRight - ::nLeft + 1
   ::nNumRows := ::nBottom - ::nTop + 1

   IF ( ::nRow - ::nFirstRow ) > ::nNumRows
      //current row is outide the editor window - display it at the top
      ::nFirstRow := ::nRow
   ENDIF
   // FirstCol/Row of current text visible inside editor window
   ::nFirstCol := 1
   // Cursor position inside aText (nRow) and inside current line of text (nCol)
   ::nCol := 1

   // Set cursor upper left corner
   ::SetPos( ::nTop + ::nRow - ::nFirstRow, ::nLeft )

   ::display()

   RETURN Self
teditor.prg158
HBEDITOR:METHODLoadFile( cFileName ) CLASS HBEditor
METHOD LoadFile( cFileName ) CLASS HBEditor

   LOCAL cString

   IF File( cFileName )
      ::cFile := cFileName
      cString := MemoRead( cFileName )
   ELSE
      cString := ""
   ENDIF

   ::aText := Text2Array( cString, iif( ::lWordWrap, ::nNumCols, NIL ) )
   ::naTextLen := Len( ::aText )

   IF ::naTextLen == 0
      AAdd( ::aText, HBTextLine():New() )
      ::naTextLen++
   ENDIF

   ::lDirty := .F.
   ::MoveCursor( K_CTRL_PGUP )

   RETURN Self
teditor.prg191
HBEDITOR:METHODLoadText( cString ) CLASS HBEditor
METHOD LoadText( cString ) CLASS HBEditor

   ::aText := Text2Array( cString, iif( ::lWordWrap, ::nNumCols, NIL ) )
   ::naTextLen := Len( ::aText )

   IF ::naTextLen == 0
      AAdd( ::aText, HBTextLine():New() )
      ::naTextLen++
   ENDIF

   ::lDirty := .F.
   ::MoveCursor( K_CTRL_PGUP )

   RETURN Self
teditor.prg215
HBEDITOR:METHODSaveFile() CLASS HBEditor
METHOD SaveFile() CLASS HBEditor

   IF !Empty( ::cFile )

      ::lDirty := !MemoWrit( ::cFile, ::GetText() )

      RETURN !::lDirty
   ENDIF

   RETURN .F.
teditor.prg231
HBEDITOR:METHODAddLine( cLine, lSoftCR ) CLASS HBEditor
METHOD AddLine( cLine, lSoftCR ) CLASS HBEditor

   AAdd( ::aText, HBTextLine():New( cLine, lSoftCR ) )
   ::naTextLen++

   RETURN Self
teditor.prg243
HBEDITOR:METHODInsertLine( cLine, lSoftCR, nRow ) CLASS HBEditor
METHOD InsertLine( cLine, lSoftCR, nRow ) CLASS HBEditor

   ::AddLine()
   AIns( ::aText, nRow )
   ::aText[ nRow ] := HBTextLine():New( cLine, lSoftCR )

   RETURN Self
teditor.prg251
HBEDITOR:METHODRemoveLine( nRow ) CLASS HBEditor
METHOD RemoveLine( nRow ) CLASS HBEditor

   ADel( ::aText, nRow )
   ASize( ::aText, --::naTextLen )

   RETURN Self
teditor.prg260
HBEDITOR:METHODGetLine( nRow ) CLASS HBEditor
METHOD GetLine( nRow ) CLASS HBEditor
   RETURN iif( nRow <= ::naTextLen .AND. nRow > 0, ::aText[ nRow ]:cText, "" )
teditor.prg268
HBEDITOR:METHODLineLen( nRow ) CLASS HBEditor
METHOD LineLen( nRow ) CLASS HBEditor
   RETURN Len( ::aText[ nRow ]:cText )
teditor.prg272
HBEDITOR:METHODGetText() CLASS HBEditor
METHOD GetText() CLASS HBEditor

   LOCAL cString := ""
   LOCAL cEOL := HB_OSNewLine()

   IF ::lWordWrap
      AEval( ::aText, {| cItem | cString += cItem:cText + iif( cItem:lSoftCR, "", cEOL ) },, ::naTextLen - 1 )
   ELSE
      AEval( ::aText, {| cItem | cString += cItem:cText + cEOL },, ::naTextLen - 1 )
   ENDIF

   // Last line does not need a cEOL delimiter
   cString += ::aText[ ::naTextLen ]:cText

   RETURN cString
teditor.prg276
HBEDITOR:METHODGotoLine( nRow ) CLASS HBEditor
METHOD GotoLine( nRow ) CLASS HBEditor

   IF nRow <= ::naTextLen .AND. nRow > 0

      // Back one line
      IF ::nRow - nRow == 1
         ::MoveCursor( K_UP )

      ELSEIF ::nRow - nRow == -1
         ::MoveCursor( K_DOWN )

      ELSE
         // I need to move cursor if is past requested line number and if requested line is
         // inside first screen of text otherwise ::nFirstRow would be wrong
         IF ::nFirstRow > 1
            IF nRow < ::nNumRows .AND. ( ::nTop + nRow ) < ::Row()
               ::SetPos( ::nTop + nRow, ::Col() )
            ENDIF
         ELSE
            IF nRow <= ::nNumRows
               ::SetPos( ::nTop + nRow - 1, ::Col() )
            ENDIF
         ENDIF

         ::nRow := nRow

         IF ! ( ::nFirstRow == 1 .AND. nRow <= ::nNumRows )
            ::nFirstRow := Max( 1, nRow - ( ::Row() - ::nTop ) )
         ENDIF

         ::display()
      ENDIF
   ENDIF

   RETURN Self
teditor.prg292
HBEDITOR:METHODSplitLine( nRow ) CLASS HBEditor
METHOD SplitLine( nRow ) CLASS HBEditor

   LOCAL nFirstSpace
   LOCAL cLine
   LOCAL cSplittedLine
   LOCAL nStartRow
   LOCAL nOCol
   LOCAL nORow
   LOCAL lMoveToNextLine
   LOCAL nPosInWord
   LOCAL nI

   // Do something only if Word Wrapping is on
   IF ::lWordWrap .AND. ::LineLen( nRow ) > ::nWordWrapCol

      nOCol := ::Col()
      nORow := ::Row()

      // Move cursor to next line if you will move the word which I'm over to next line
      // ie, since word wrapping happens at spaces if first space is behind cursor
      lMoveToNextLine := RAt( " ", RTrim( ::GetLine( nRow ) ) ) < ::nCol
      nPosInWord := Len( ::GetLine( nRow ) ) - ::nCol

      nStartRow := nRow
      cLine := ::GetParagraph( nRow )

      DO WHILE !Empty(cLine)

         IF Len( cLine ) > ::nWordWrapCol
            nFirstSpace := ::nWordWrapCol

            // Split line at fist space before current position
            DO WHILE !( SubStr( cLine, --nFirstSpace, 1 ) == " " ) .AND. nFirstSpace > 1
            ENDDO

            // If there is a space before beginning of line split there
            IF nFirstSpace > 1
               cSplittedLine := Left( cLine, nFirstSpace )
            ELSE
               // else split at current cursor position
               cSplittedLine := Left( cLine, ::nCol - 1 )
            ENDIF

            ::InsertLine( cSplittedLine, .T., nStartRow++ )

         ELSE
            // remainder of line
            cSplittedLine := cLine
            ::InsertLine( cSplittedLine, .F., nStartRow++ )
         ENDIF

         cLine := Right( cLine, Len( cLine ) - Len( cSplittedLine ) )
      ENDDO

      IF lMoveToNextLine
         ::MoveCursor( K_DOWN )
         ::MoveCursor( K_HOME )
         ::MoveCursor( K_CTRL_RIGHT )
         IF nPosInWord > 0
            // from 0 since I have to take into account previous K_CTRL_RIGHT which moves me past end of word
            FOR nI := 0 TO nPosInWord
               ::MoveCursor( K_LEFT )
            NEXT
         ENDIF
      ELSE
         ::SetPos( nORow, nOCol )
      ENDIF
      ::display()
   ENDIF

   RETURN Self
teditor.prg330
HBEDITOR:METHODdisplay() CLASS HBEditor
METHOD display() CLASS HBEditor

   LOCAL i
   LOCAL nOCol := ::Col()
   LOCAL nORow := ::Row()
   LOCAL nOCur := SetCursor( SC_NONE )
   LOCAL cOldColor

   FOR i := 0 TO Min( ::nNumRows - 1, ::naTextLen - 1 )
      DispOutAt( ::nTop + i, ::nLeft, PadR( SubStr( ::GetLine( ::nFirstRow + i ), ::nFirstCol, ::nNumCols ), ::nNumCols, " " ), ::LineColor( ::nFirstRow + i ) )
   NEXT

   // Clear rest of editor window (needed when deleting lines of text)
   IF ::naTextLen < ::nNumRows
      cOldColor := SetColor( ::cColorSpec )
      Scroll( ::nTop + ::naTextLen, ::nLeft, ::nBottom, ::nRight )
      SetColor( cOldColor )
   ENDIF

   SetCursor( nOCur )
   ::SetPos( nORow, nOCol )

   RETURN Self
teditor.prg403
HBEDITOR:METHODRefreshLine() CLASS HBEditor
METHOD RefreshLine() CLASS HBEditor

   LOCAL nOCol := ::Col()
   LOCAL nORow := ::Row()

   DispOutAt( ::Row(), ::nLeft, PadR( SubStr( ::GetLine( ::nRow ), ::nFirstCol, ::nNumCols ), ::nNumCols, " " ), ::LineColor( ::nRow ) )

   ::SetPos( nORow, nOCol )

   RETURN Self
teditor.prg428
HBEDITOR:METHODRefreshColumn() CLASS HBEditor
METHOD RefreshColumn() CLASS HBEditor

   LOCAL i
   LOCAL nOCol := ::Col()
   LOCAL nORow := ::Row()
   LOCAL nOCur := SetCursor( SC_NONE )

   FOR i := 0 TO Min( ::nNumRows - 1, ::naTextLen - 1 )
      DispOutAt( ::nTop + i, nOCol, SubStr( ::GetLine( ::nFirstRow + i ), ::nCol, 1 ), ::LineColor( ::nFirstRow + i ) )
   NEXT

   SetCursor( nOCur )
   ::SetPos( nORow, nOCol )

   RETURN Self
teditor.prg440
HBEDITOR:METHODLineColor( nRow ) CLASS HBEditor
METHOD LineColor( nRow ) CLASS HBEditor

   HB_SYMBOL_UNUSED( nRow )

   RETURN ::cColorSpec
teditor.prg457
HBEDITOR:METHODMoveCursor( nKey ) CLASS HBEditor
METHOD MoveCursor( nKey ) CLASS HBEditor

   LOCAL lMoveKey := .T.

   DO CASE
   CASE nKey == K_DOWN
      IF !::lEditAllow
         DO WHILE ::Row() < ::nBottom .AND. ::nRow < ::naTextLen
            ::nRow++
            ::SetPos( ::Row() + 1, ::Col() )
         ENDDO
      ENDIF
      IF ::Row() == ::nBottom
         IF ::nRow < ::naTextLen
            Scroll( ::nTop, ::nLeft, ::nBottom, ::nRight, 1 )
            ::nFirstRow++
            ::nRow++
            ::RefreshLine()
         ENDIF
      ELSE
         IF ::nRow < ::naTextLen
            ::nRow++
            ::SetPos( ::Row() + 1, ::Col() )
         ENDIF
      ENDIF

   CASE nKey == K_PGDN
      IF ::nRow + ::nNumRows < ::naTextLen
         ::nRow += ::nNumRows
         ::nFirstRow += ::nNumRows
         IF ::nFirstRow + ::nNumRows > ::naTextLen
            ::nFirstRow -= ( ( ::nFirstRow + ::nNumRows ) - ::naTextLen ) + 1
         ENDIF
      ELSE
         ::nFirstRow := Max( ::naTextLen - ::nNumRows + 1, 1 )
         ::nRow := ::naTextLen
         ::SetPos( Min( ::nTop + ::naTextLen - 1, ::nBottom ), ::Col() )
      ENDIF
      ::display()

   CASE nKey == K_CTRL_PGDN
      ::nRow := ::naTextLen
      ::nCol := Max( ::LineLen( ::nRow ), 1 )
      ::nFirstRow := Max( ::naTextLen - ::nNumRows + 1, 1 )
      ::nFirstCol := Max( ::nCol - ::nNumCols + 1, 1 )
      ::SetPos( Min( ::nTop + ::naTextLen - 1, ::nBottom ), Min( ::nLeft + ::nCol - 1, ::nRight ) )
      ::display()

   CASE nKey == K_UP
      IF ! ::lEditAllow
         DO WHILE ::Row() > ::nTop .AND. ::nRow > 1
            ::nRow--
            ::SetPos( ::Row() - 1, ::Col() )
         ENDDO
      ENDIF
      IF ::Row() == ::nTop
         IF ::nRow > 1
            Scroll( ::nTop, ::nLeft, ::nBottom, ::nRight, -1 )
            ::nFirstRow--
            ::nRow--
            ::RefreshLine()
         ENDIF
      ELSE
         ::nRow--
         ::SetPos( ::Row() - 1, ::Col() )
      ENDIF

   CASE nKey == K_PGUP
      IF ( ::nRow - ::nNumRows ) > 1
         ::nRow -= ::nNumRows
         ::nFirstRow -= ::nNumRows
         IF ::nFirstRow < 1
            ::nFirstRow := 1
         ENDIF
      ELSE
         ::nFirstRow := 1
         ::nRow := 1
         ::SetPos( ::nTop, ::Col() )
      ENDIF
      ::display()

   CASE nKey == K_CTRL_PGUP
      ::nRow := 1
      ::nCol := 1
      ::nFirstCol := 1
      ::nFirstRow := 1
      ::SetPos( ::nTop, ::nLeft )
      ::display()

   CASE nKey == K_RIGHT
      IF ::Col() == ::nRight
         IF ::nCol <= iif( ::lWordWrap, ::nWordWrapCol, ::LineLen( ::nRow ) )
            Scroll( ::nTop, ::nLeft, ::nBottom, ::nRight,, 1 )
            ::nFirstCol++
            ::nCol++
            ::RefreshColumn()
         ENDIF
      ELSE
         ::nCol++
         ::SetPos( ::Row(), ::Col() + 1 )
      ENDIF

   CASE nKey == K_CTRL_RIGHT
      // NOTE: should be faster without call to ::GetLine()
      DO WHILE ::nCol <= iif( ::lWordWrap, Min( ::nWordWrapCol, ::LineLen( ::nRow ) ), ::LineLen( ::nRow ) ) .AND. !( SubStr( ::aText[ ::nRow ]:cText, ::nCol, 1 ) == " " )
         ::MoveCursor( K_RIGHT )
      ENDDO
      DO WHILE ::nCol <= iif( ::lWordWrap, Min( ::nWordWrapCol, ::LineLen( ::nRow ) ), ::LineLen( ::nRow ) ) .AND. SubStr( ::aText[ ::nRow ]:cText, ::nCol, 1 ) == " "
         ::MoveCursor( K_RIGHT )
      ENDDO

   CASE nKey == K_LEFT
      IF ::Col() == ::nLeft
         IF ::nCol > 1
            Scroll( ::nTop, ::nLeft, ::nBottom, ::nRight,, -1 )
            ::nFirstCol--
            ::nCol--
            ::RefreshColumn()
         ENDIF
      ELSE
         ::nCol--
         ::SetPos( ::Row(), ::Col() - 1 )
      ENDIF

   CASE nKey == K_CTRL_LEFT
      DO WHILE ::nCol > 1 .AND. !( SubStr( ::aText[ ::nRow ]:cText, ::nCol, 1 ) == " " )
         ::MoveCursor( K_LEFT )
      ENDDO
      DO WHILE ::nCol > 1 .AND. SubStr( ::aText[ ::nRow ]:cText, ::nCol, 1 ) == " "
         ::MoveCursor( K_LEFT )
      ENDDO

   CASE nKey == K_HOME
      ::nCol := 1
      ::nFirstCol := 1
      ::SetPos( ::Row(), ::nLeft )
      ::display()

   CASE nKey == K_CTRL_HOME
      ::nCol := 1
      ::nFirstCol := 1
      ::nRow -= ( ::Row() - ::nTop )
      ::SetPos( ::nTop, ::nLeft )
      ::display()

   CASE nKey == K_END
      // Empty lines have 0 len
      ::nCol := Max( ::LineLen( ::nRow ) + 1, 1 )
      ::nFirstCol := Max( ::nCol - ::nNumCols + 1, 1 )
      ::SetPos( ::Row(), Min( ::nLeft + ::nCol - 1, ::nRight ) )
      ::display()

   CASE nKey == K_CTRL_END
      ::nRow += ::nBottom - ::Row()
      IF ::nRow > ::naTextLen
         ::nRow := ::naTextLen
      ENDIF
      ::nCol := Max( ::LineLen( ::nRow ), 1 )
      ::nFirstCol := Max( ::nCol - ::nNumCols + 1, 1 )
      ::SetPos( Min( ::nTop + ::naTextLen - 1, ::nBottom ), Min( ::nLeft + ::nCol - 1, ::nRight ) )
      ::display()

   OTHERWISE
      lMoveKey := .F.

   ENDCASE

   RETURN lMoveKey
teditor.prg464
HBEDITOR:METHODInsertState( lInsState ) CLASS HBEditor
METHOD InsertState( lInsState ) CLASS HBEditor

   IF ISLOGICAL( lInsState )
      ::lInsert := lInsState
      SET( _SET_INSERT, lInsState )
   ENDIF

   RETURN Self
teditor.prg634
HBEDITOR:METHODEdit( nPassedKey ) CLASS HBEditor
METHOD Edit( nPassedKey ) CLASS HBEditor

   LOCAL i
   LOCAL nKey
   LOCAL lDelAppend
   LOCAL bKeyBlock
   LOCAL lSingleKeyProcess := .F.         // .T. if I have to process passed key and then exit

   IF ! ::lEditAllow
      ::BrowseText( nPassedKey )

   ELSE

      // If user pressed an exiting key (K_ESC or K_ALT_W) or I've received a key to handle and then exit
      DO WHILE ! ::lExitEdit .AND. ! lSingleKeyProcess

         // If I haven't been called with a key already preset, evaluate this key and then exit
         IF nPassedKey == NIL

            IF NextKey() == 0
               ::IdleHook()
            ENDIF

            nKey := InKey( 0 )
         ELSE
            lSingleKeyProcess := .T.
            nKey := nPassedKey
         ENDIF

         // 03/sept/2002 - maurilio.longo@libero.it
         // NOTE: I think this code should only be present on classes derived from TEditor which is
         //       a low level "editing engine".. For now I leave it here...
         IF ( bKeyBlock := SetKey( nKey ) ) != NIL
            Eval( bKeyBlock )
            LOOP
         ENDIF

         DO CASE
         CASE nKey >= K_SPACE .AND. nKey < 256
            ::lDirty := .T.
            // If I'm past EOL I need to add as much spaces as I need to reach ::nCol
            IF ::nCol > ::LineLen( ::nRow )
               ::aText[ ::nRow ]:cText += Space( ::nCol - ::LineLen( ::nRow ) )
            ENDIF
            // insert char if in insert mode or at end of current line
            IF ::lInsert .OR. ( ::nCol > ::LineLen( ::nRow ) )
               ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, ::nCol, 0, Chr( nKey ) )
            ELSE
               ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, ::nCol, 1, Chr( nKey ) )
            ENDIF
            ::MoveCursor( K_RIGHT )
            ::RefreshLine()
            ::SplitLine( ::nRow )

         CASE nKey == K_RETURN
            ::lDirty := .T.
            IF ::lInsert .OR. ::nRow == ::naTextLen
               IF ::LineLen( ::nRow ) > 0
                  // Split current line at cursor position
                  ::InsertLine( Right( ::aText[ ::nRow ]:cText, ::LineLen( ::nRow ) - ::nCol + 1 ), ::aText[ ::nRow ]:lSoftCR, ::nRow + 1 )
                  ::aText[ ::nRow ]:cText := Left( ::aText[ ::nRow ]:cText, ::nCol - 1 )
                  IF ::lWordWrap
                     ::aText[ ::nRow ]:lSoftCR := .F.
                  ENDIF
               ELSE
                  ::InsertLine( "", .F., ::nRow + 1 )
               ENDIF
            ENDIF
            ::MoveCursor( K_DOWN )
            ::MoveCursor( K_HOME )

         CASE nKey == K_INS
            ::InsertState( !::lInsert )

         CASE nKey == K_DEL
            // If there is a wordwrapping limit and I'm past it
            IF ::lWordWrap .AND. ::nCol > ::nWordWrapCol
               ::MoveCursor( K_DOWN )
               ::MoveCursor( K_HOME )

            ELSE
               ::lDirty := .T.
               // If I'm on last char of a line and there are more lines, append next line to current one
               lDelAppend := ::nCol > ::LineLen( ::nRow )
               ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, ::nCol, 1, "" )
               IF lDelAppend
                  IF ::nRow < ::naTextLen
                     ::aText[ ::nRow ]:cText += ::GetLine( ::nRow + 1 )
                     ::RemoveLine( ::nRow + 1 )
                     ::SplitLine( ::nRow )
                     ::display()
                  ELSE
                     ::RefreshLine()
                  ENDIF
               ELSE
                  ::RefreshLine()
               ENDIF
            ENDIF

         CASE nKey == K_TAB
            // insert char if in insert mode or at end of current line
            IF ::lInsert .OR. ( ::nCol == ::LineLen( ::nRow ) )
               ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, ::nCol, 0, Space( ::nTabWidth ) )
               ::lDirty := .T.
            ENDIF
            FOR i := 1 TO ::nTabWidth
               ::MoveCursor( K_RIGHT )
            NEXT
            ::RefreshLine()

         CASE nKey == K_BS
            ::lDirty := .T.
            // delete previous character
            ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, --::nCol, 1, "" )
            // correct column position for next call to MoveCursor()
            ::nCol++
            ::MoveCursor( K_LEFT )
            ::RefreshLine()

         CASE nKey == K_CTRL_Y
            ::lDirty := .T.
            IF ::naTextLen > 1
               ::RemoveLine( ::nRow )
               // if we have less lines of text than our current position, up one line
               IF ::nRow > ::naTextLen
                  ::nRow := Max( ::nRow - 1, 1 )
                  // if our position on screen exceeds text length, up one row
                  IF ( ::nFirstRow + ::nNumRows - 1 ) > ::naTextLen
                     ::SetPos( Max( ::Row() - 1, ::nTop ), ::Col() )
                  ENDIF
                  // if first line of displayed text is less than length of text
                  IF ::nFirstRow > ::naTextLen
                     ::nFirstRow := Max( ::nFirstRow - 1, 1 )
                  ENDIF
               ENDIF
               ::display()
            ELSE
               ::aText[ ::nRow ]:cText := ""
               ::RefreshLine()
            ENDIF

         CASE ::MoveCursor( nKey )
            // if it's a movement key ::MoveCursor() handles it

         CASE nKey == K_ALT_W
            /* TOFIX: Not clipper compatible */
            ::lSaved := .T.
            ::lExitEdit := .T.

         OTHERWISE
            /* NOTE: if you call ::Edit() with a key that is passed to ::KeyboardHook() and then
                     ::KeyboardHook() calls ::Edit() with the same key you end up with an endless loop */
            ::KeyboardHook( nKey )
         ENDCASE
      ENDDO
   ENDIF

   RETURN Self
teditor.prg644
HBEDITOR:METHODKeyboardHook( nKey ) CLASS HBEditor
METHOD KeyboardHook( nKey ) CLASS HBEditor

   IF nKey == K_ESC
      ::lSaved := .F.
      ::lExitEdit := .T.
   ENDIF

   RETURN Self
teditor.prg805
HBEDITOR:METHODIdleHook() CLASS HBEditor
METHOD IdleHook() CLASS HBEditor
   RETURN Self
teditor.prg815
HBEDITOR:METHODSetColor( cColorString ) CLASS HBEditor
METHOD SetColor( cColorString ) CLASS HBEditor

   LOCAL cOldColor := ::cColorSpec

   IF ISCHARACTER( cColorString )
      ::cColorSpec := cColorString
   ENDIF

   RETURN cOldColor
teditor.prg818
HBEDITOR:METHODHilite() CLASS HBEditor
METHOD Hilite() CLASS HBEditor

   // Swap CLR_STANDARD and CLR_ENHANCED
   LOCAL cEnhanced := hb_TokenGet( ::cColorSpec, 2, "," ) + "," +;
                      hb_TokenGet( ::cColorSpec, 1, "," )

   ::SetColor( cEnhanced + Right( ::cColorSpec, Len( ::cColorSpec ) - Len( cEnhanced ) ) )

   RETURN Self
teditor.prg828
HBEDITOR:METHODDeHilite() CLASS HBEditor
METHOD DeHilite() CLASS HBEditor

   // Swap CLR_STANDARD and CLR_ENHANCED back to their original position inside cColorSpec
   LOCAL cStandard := hb_TokenGet( ::cColorSpec, 2, "," ) + "," +;
                      hb_TokenGet( ::cColorSpec, 1, "," )

   ::SetColor( cStandard + Right( ::cColorSpec, Len( ::cColorSpec ) - Len( cStandard ) ) )

   RETURN Self
teditor.prg838
HBEDITOR:METHODSetPos( nRow, nCol ) CLASS HBEditor
METHOD SetPos( nRow, nCol ) CLASS HBEditor

   DEFAULT nRow TO ::nPhysRow
   DEFAULT nCol TO ::nPhysCol

   ::nPhysRow := nRow
   ::nPhysCol := nCol

   SetPos( ::nPhysRow, ::nPhysCol )

   RETURN ::nPhysRow
teditor.prg848
HBEDITOR:METHODRow() CLASS HBEditor
METHOD Row() CLASS HBEditor
   RETURN ::nPhysRow
teditor.prg861
HBEDITOR:METHODCol() CLASS HBEditor
METHOD Col() CLASS HBEditor
   RETURN ::nPhysCol
teditor.prg865
HBEDITOR:METHODRowPos() CLASS HBEditor
METHOD RowPos() CLASS HBEditor
   RETURN ::nRow
teditor.prg868
HBEDITOR:METHODColPos() CLASS HBEditor
METHOD ColPos() CLASS HBEditor
   RETURN ::nCol
teditor.prg871
HBEDITOR:METHODSaved() CLASS HBEditor
METHOD Saved() CLASS HBEditor
   RETURN ::lSaved
teditor.prg874
HBEDITOR:METHODChanged() CLASS HBEditor
METHOD Changed() CLASS HBEditor
   RETURN ::lDirty
teditor.prg877
HBEDITOR:METHODIsWordWrap() CLASS HBEditor
METHOD IsWordWrap() CLASS HBEditor
   RETURN ::lWordWrap
teditor.prg880
HBEDITOR:METHODWordWrapCol() CLASS HBEditor
METHOD WordWrapCol() CLASS HBEditor
   RETURN ::nWordWrapCol
teditor.prg883
HBEDITOR:METHODhitTest( nMRow, nMCol ) CLASS HBEditor
METHOD hitTest( nMRow, nMCol ) CLASS HBEditor

   IF nMRow >= ::nTop .AND. ;
      nMRow <= ::nBottom .AND. ;
      nMCol >= ::nLeft .AND. ;
      nMCol <= ::nRight
      RETURN HTCLIENT
   ENDIF

   RETURN HTNOWHERE
teditor.prg886
HBEDITOR:METHODGetParagraph( nRow )
METHOD GetParagraph( nRow )

   LOCAL cLine := ""

   DO WHILE nRow <= Len( ::aText ) .AND. ::aText[ nRow ]:lSoftCR
      cLine += ::aText[ nRow ]:cText
      // I don't need to increment nRow since I'm removing lines, ie line n is
      // a different line each time I add it to cLine
      ::RemoveLine( nRow )
   ENDDO

   IF nRow <= Len( ::aText )
      // Last line, or only one line
      cLine += ::aText[ nRow ]:cText
      ::RemoveLine( nRow )
   ENDIF

   RETURN cLine
teditor.prg900
HBEDITOR:METHODBrowseText( nPassedKey )
METHOD BrowseText( nPassedKey )

   LOCAL nKey
   LOCAL bKeyBlock

   DO WHILE ! ::lExitEdit

      // If I haven't been called with a key already preset, evaluate this key and then exit
      IF nPassedKey == NIL

         IF NextKey() == 0
            ::IdleHook()
         ENDIF

         nKey := InKey( 0 )
      ELSE
         nKey := nPassedKey
      ENDIF

      IF ( bKeyBlock := Setkey( nKey ) ) != NIL
         Eval( bKeyBlock )
         LOOP
      ENDIF

      IF nKey == K_ESC
         ::lExitEdit := .T.
      ELSE
         IF !::MoveCursor( nKey )
            ::KeyboardHook( nKey )
         ENDIF
      ENDIF

   ENDDO

   RETURN Self
teditor.prg921
HBEDITOR:METHODNew( cString, nTop, nLeft, nBottom, nRight, lEditMode, nLineLength, nTabSize, nTextRow, nTextCol, nWndRow, nWndCol ) CLASS HBEditor
METHOD New( cString, nTop, nLeft, nBottom, nRight, lEditMode, nLineLength, nTabSize, nTextRow, nTextCol, nWndRow, nWndCol ) CLASS HBEditor

   DEFAULT cString     TO ""
   DEFAULT nTop        TO 0
   DEFAULT nLeft       TO 0
   DEFAULT nBottom     TO MaxRow()
   DEFAULT nRight      TO MaxCol()
   DEFAULT lEditMode   TO .T.
   DEFAULT nLineLength TO NIL
   DEFAULT nTabSize    TO NIL
   DEFAULT nTextRow    TO 1
   DEFAULT nTextCol    TO 0 
   DEFAULT nWndRow     TO 0 
   DEFAULT nWndCol     TO 0 

   ::aText := Text2Array( cString, nLineLength )
   ::naTextLen := Len( ::aText )

   IF ::naTextLen == 0
      AAdd( ::aText, HBTextLine():New() )
      ::naTextLen++
   ENDIF

   // editor window boundaries
   ::nTop := nTop
   ::nLeft := nLeft
   ::nBottom := nBottom
   ::nRight := nRight

   ::cColorSpec := SetColor()

   // How many cols and rows are available
   ::nNumCols := nRight - nLeft + 1
   ::nNumRows := nBottom - nTop + 1

   IF ISLOGICAL( lEditMode )
      ::lEditAllow := lEditMode
   ENDIF

   // set correct insert state
   IF ::lEditAllow
      ::InsertState( ::lInsert )
   ENDIF

   // is word wrap required?
   IF ISNUMBER( nLineLength )
      ::lWordWrap := .T.
      ::nWordWrapCol := nLineLength
   ENDIF

   // how many spaces for each tab?
   IF ISNUMBER( nTabSize )
      ::nTabWidth := nTabSize
   ENDIF

   // textrow/col, wndrow/col management
   nTextRow    := Max( 1, nTextRow )
   nTextCol    := Max( 0, nTextCol )
   nWndRow     := Max( 0, nWndRow  )
   nWndCol     := Max( 0, nWndCol  )

   ::nFirstRow := Max( 1, nTextRow - nWndRow )
   ::nFirstCol := Max( 1, nTextCol - nWndCol )

   ::nRow := Max( 1, Min( nTextRow, ::naTextLen ) )
   ::nCol := Max( 1, Min( Len( ::aText[ ::nRow ]:cText ), nTextCol + 1 ) )

   // extra sanitization over max bounds
   IF ::nFirstRow >  ::naTextLen
      ::nFirstRow := ::naTextLen
   ENDIF

   IF ::nFirstCol >  ::LineLen( ::nRow ) + 1
      ::nFirstCol := ::LineLen( ::nRow ) + 1
   ENDIF
   
   IF ( ::nFirstRow + nWndRow ) > ::naTextLen
      DO WHILE ( ::nFirstRow + ( --nWndRow ) ) > ::naTextLen
      ENDDO
   ENDIF

   // Empty area of screen which will hold editor window
   Scroll( nTop, nLeft, nBottom, nRight )

   // Set cursor upper left corner
   //::SetPos( ::nTop, ::nLeft )
   ::SetPos( ::nTop + nWndRow, ::nLeft + nWndCol )

   RETURN Self
teditor.prg959
STATIC FUNCTIONWhichEOL( cString )
STATIC FUNCTION WhichEOL( cString )

   LOCAL nCRPos := At( Chr( 13 ), cString )
   LOCAL nLFPos := At( Chr( 10 ), cString )

   IF nCRPos > 0 .AND. nLFPos == 0
      RETURN Chr( 13 )
   ELSEIF nCRPos == 0 .AND. nLFPos >  0
      RETURN Chr( 10 )
   ELSEIF nCRPos > 0 .AND. nLFPos == nCRPos + 1
      RETURN Chr( 13 ) + Chr( 10 )
   ENDIF

   RETURN HB_OSNewLine()
teditor.prg1052
STATIC FUNCTIONText2Array( cString, nWordWrapCol )
STATIC FUNCTION Text2Array( cString, nWordWrapCol )

   LOCAL nTokNum := 1
   LOCAL aArray := {}
   LOCAL cEOL := WhichEOL( cString )
   LOCAL nEOLLen := Len( cEOL )
   LOCAL nRetLen := 0
   LOCAL ncSLen := Len( cString )
   LOCAL nTokPos := 0

   LOCAL cLine
   LOCAL nFirstSpace
   LOCAL cSplittedLine

   DO WHILE nRetLen < ncSLen

      cLine := hb_TokenPtr( @cString, @nTokPos, cEOL )

      nRetLen += Len( cLine ) + nEOLLen

      IF nWordWrapCol != NIL .AND. Len( cLine ) > nWordWrapCol

         DO WHILE !Empty( cLine )

            // Split line at nWordWrapCol boundary
            IF Len( cLine ) > nWordWrapCol

               nFirstSpace := nWordWrapCol
               DO WHILE !( SubStr( cLine, --nFirstSpace, 1 ) == " " ) .AND. nFirstSpace > 1
               ENDDO

               IF nFirstSpace > 1
                  cSplittedLine := Left( cLine, nFirstSpace )
               ELSE
                  cSplittedLine := Left( cLine, nWordWrapCol )
               ENDIF

               AAdd( aArray, HBTextLine():New( cSplittedLine, .T. ) )

            ELSE

               // remainder of line is shorter than split point
               cSplittedLine := cLine
               AAdd( aArray, HBTextLine():New( cSplittedLine, .F. ) )

            ENDIF

            cLine := Right( cLine, Len( cLine ) - Len( cSplittedLine ) )
         ENDDO

      ELSE
         AAdd( aArray, HBTextLine():New( cLine, .F. ) )

      ENDIF

   ENDDO

   RETURN aArray
teditor.prg1068
text.prg
TypeFunctionSourceLine
PROCEDURE__TextSave( cFile )
PROCEDURE __TextSave( cFile )

   s_cFile := cFile

   IF s_cFile == "PRINTER"
      s_lOldPrinter := Set( _SET_PRINTER, .T. )
   ELSE
      s_lOldExtra := Set( _SET_EXTRA, .T. )
      s_cOldExtraFile := Set( _SET_EXTRAFILE, cFile )
   ENDIF

   RETURN
text.prg58
PROCEDURE__TextRestore()
PROCEDURE __TextRestore()

   IF s_cFile == "PRINTER"
      Set( _SET_PRINTER, s_lOldPrinter )
   ELSE
      Set( _SET_EXTRAFILE, s_cOldExtraFile )
      Set( _SET_EXTRA, s_lOldExtra )
   ENDIF

   RETURN
text.prg71
tget.prg
TypeFunctionSourceLine
METHODNew( nRow, nCol, bVarBlock, cVarName, cPicture, cColorSpec )
   METHOD New( nRow, nCol, bVarBlock, cVarName, cPicture, cColorSpec ) /* NOTE: This method is a Harbour extension [vszakats] */
tget.prg113
METHODassign()
   METHOD assign()
tget.prg115
METHODbadDate()
   METHOD badDate()
tget.prg116
METHODblock( bBlock ) SETGET
   METHOD block( bBlock ) SETGET
tget.prg117
METHODbuffer( cBuffer ) SETGET
   METHOD buffer( cBuffer ) SETGET
tget.prg118
METHODchanged( lChanged ) SETGET
   METHOD changed( lChanged ) SETGET
tget.prg119
METHODclear( lClear ) SETGET
   METHOD clear( lClear ) SETGET
tget.prg120
METHODcol( nCol ) SETGET
   METHOD col( nCol ) SETGET
tget.prg121
METHODcolorDisp( cColorSpec )
   METHOD colorDisp( cColorSpec )
tget.prg122
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
tget.prg123
METHODdisplay()
   METHOD display()
tget.prg124
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )
tget.prg126
METHODcontrol( oControl ) SETGET
   METHOD control( oControl ) SETGET    /* NOTE: Undocumented CA-Cl*pper 5.3 method. */
tget.prg127
METHODmessage( cMessage ) SETGET
   METHOD message( cMessage ) SETGET    /* NOTE: Undocumented CA-Cl*pper 5.3 method. */
tget.prg128
METHODcaption( cCaption ) SETGET
   METHOD caption( cCaption ) SETGET    /* NOTE: Undocumented CA-Cl*pper 5.3 method. */
tget.prg129
METHODcapRow( nCapRow ) SETGET
   METHOD capRow( nCapRow ) SETGET      /* NOTE: Undocumented CA-Cl*pper 5.3 method. */
tget.prg130
METHODcapCol( nCapCol ) SETGET
   METHOD capCol( nCapCol ) SETGET      /* NOTE: Undocumented CA-Cl*pper 5.3 method. */
tget.prg131
METHODkillFocus()
   METHOD killFocus()
tget.prg133
METHODminus( lMinus ) SETGET
   METHOD minus( lMinus ) SETGET
tget.prg134
METHODname( cName ) SETGET
   METHOD name( cName ) SETGET
tget.prg135
METHODpicture( cPicture ) SETGET
   METHOD picture( cPicture ) SETGET
tget.prg136
METHODpos( nPos ) SETGET
   METHOD pos( nPos ) SETGET
tget.prg137
METHODposInBuffer( nRow, nCol )
   METHOD posInBuffer( nRow, nCol )
tget.prg139
METHODreform()
   METHOD reform()
tget.prg142
METHODreset()
   METHOD reset()
tget.prg144
METHODrow( nRow ) SETGET
   METHOD row( nRow ) SETGET
tget.prg145
METHODsetFocus()
   METHOD setFocus()
tget.prg146
METHODtype()
   METHOD type()
tget.prg147
METHODundo()
   METHOD undo()
tget.prg148
METHODunTransform()
   METHOD unTransform()
tget.prg149
METHODupdateBuffer()
   METHOD updateBuffer()
tget.prg150
METHODvarGet()
   METHOD varGet()
tget.prg151
METHODvarPut( xValue )
   METHOD varPut( xValue )
tget.prg152
METHODend()
   METHOD end()
tget.prg154
METHODhome()
   METHOD home()
tget.prg155
METHODleft()
   METHOD left()
tget.prg156
METHODright()
   METHOD right()
tget.prg157
METHODtoDecPos()
   METHOD toDecPos()
tget.prg158
METHODwordLeft()
   METHOD wordLeft()
tget.prg159
METHODwordRight()
   METHOD wordRight()
tget.prg160
METHODbackSpace()
   METHOD backSpace()
tget.prg162
METHODdelete()
   METHOD delete()
tget.prg163
METHODdelEnd()
   METHOD delEnd()
tget.prg164
METHODdelLeft()
   METHOD delLeft()
tget.prg165
METHODdelRight()
   METHOD delRight()
tget.prg166
METHODdelWordLeft()
   METHOD delWordLeft()
tget.prg167
METHODdelWordRight()
   METHOD delWordRight()
tget.prg168
METHODinsert( cChar )
   METHOD insert( cChar )
tget.prg170
METHODoverStrike( cChar )
   METHOD overStrike( cChar )
tget.prg171
METHODhideInput( lHideInput ) SETGET
   METHOD hideInput( lHideInput ) SETGET
tget.prg174
METHODstyle( cStyle ) SETGET
   METHOD style( cStyle ) SETGET
#endif

#ifdef HB_COMPAT_XPP
   MESSAGE _end() METHOD end()
   MESSAGE _assign() METHOD assign()
   MESSAGE _delete() METHOD delete()
#endif

   PROTECTED:

#ifndef HB_COMPAT_C53
   VAR nDispLen                /* NOTE: This one is placed inside the instance area for CA-Cl*pper 5.3 [vszakats] */
#endif
   VAR cColorSpec
   VAR nPos           INIT 0
   VAR lChanged       INIT .F.
   VAR lClear         INIT .F.
   VAR nRow
   VAR nCol
   VAR lRejected      INIT .F.
   VAR lHideInput     INIT .F.
   VAR cStyle         INIT "*" /* NOTE: First char is to be used as mask character when :hideInput is .T. [vszakats] */
   VAR nMaxLen
   VAR lEdit          INIT .F.
   VAR nDispPos       INIT 1
   VAR nOldPos        INIT 0
   VAR nMaxEdit
   VAR lMinus         INIT .F.
   VAR lMinus2        INIT .F.
   VAR lMinusPrinted  INIT .F.
   VAR lSuppDisplay   INIT .F.

   VAR nPicLen
   VAR cPicMask       INIT ""
   VAR cPicFunc       INIT ""
   VAR lPicComplex    INIT .F.
   VAR lPicBlankZero  INIT .F.
tget.prg175
METHODleftLow()
   METHOD leftLow()
tget.prg214
METHODrightLow()
   METHOD rightLow()
tget.prg215
METHODbackSpaceLow()
   METHOD backSpaceLow()
tget.prg216
METHODdeleteLow()
   METHOD deleteLow()
tget.prg217
METHODDeleteAll()
   METHOD DeleteAll()
tget.prg219
METHODIsEditable( nPos )
   METHOD IsEditable( nPos )
tget.prg220
METHODInput( cChar )
   METHOD Input( cChar )
tget.prg221
METHODPutMask( xValue, lEdit )
   METHOD PutMask( xValue, lEdit )
tget.prg222
METHODFirstEditable()
   METHOD FirstEditable()
tget.prg223
METHODLastEditable()
   METHOD LastEditable()

ENDCLASS
tget.prg224
GET:METHODassign() CLASS Get
METHOD assign() CLASS Get
   LOCAL xValue

   IF ::hasFocus
      xValue := ::unTransform()
      IF ::cType == "C"
         xValue += SubStr( ::original, Len( xValue ) + 1 )
      ENDIF   
      ::varPut( xValue )
   ENDIF

   RETURN Self
tget.prg228
GET:METHODupdateBuffer() CLASS Get
METHOD updateBuffer() CLASS Get

   IF ::hasFocus
      ::cBuffer := ::PutMask( ::varGet() )
      ::xVarGet := ::original
      ::display()
   ELSE
      ::varGet()
   ENDIF

   RETURN Self
tget.prg241
GET:METHODdisplay() CLASS Get
METHOD display() CLASS Get

   LOCAL nOldCursor := SetCursor( SC_NONE )
   LOCAL cBuffer
   LOCAL nDispPos

#ifdef HB_COMPAT_C53
   LOCAL nPos
   LOCAL cCaption
#endif

   IF ::hasFocus
      cBuffer   := ::cBuffer
   ELSE
      ::cType   := ValType( ::xVarGet := ::varGet() )
      ::picture := ::cPicture
      cBuffer   := ::PutMask( ::xVarGet )
   ENDIF

   ::nMaxLen := Len( cBuffer )
   ::nDispLen := iif( ::nPicLen == NIL, ::nMaxLen, ::nPicLen )

   IF ::cType == "N" .AND. ::hasFocus .AND. ! ::lMinusPrinted .AND. ;
      ::decPos != 0 .AND. ::lMinus2 .AND. ;
      ::nPos > ::decPos .AND. Val( Left( cBuffer, ::decPos - 1 ) ) == 0

      /* Display "-." only in case when value on the left side of
         the decimal point is equal 0 */
      cBuffer := SubStr( cBuffer, 1, ::decPos - 2 ) + "-." + SubStr( cBuffer, ::decPos + 1 )
   ENDIF

   IF ::nDispLen != ::nMaxLen .AND. ::nPos != 0 /* ; has scroll? */
      IF ::nDispLen > 8
         nDispPos := Max( 1, Min( ::nPos - ::nDispLen + 4       , ::nMaxLen - ::nDispLen + 1 ) )
      ELSE
         nDispPos := Max( 1, Min( ::nPos - Int( ::nDispLen / 2 ), ::nMaxLen - ::nDispLen + 1 ) )
      ENDIF
   ELSE
      nDispPos := 1
   ENDIF

#ifdef HB_COMPAT_C53

   /* Handle C5.3 caption. */

   IF !Empty( ::cCaption )

      cCaption := ::cCaption
      IF ( nPos := At( "&", cCaption ) ) > 0
         IF nPos == Len( cCaption )
            nPos := 0
         ELSE
            cCaption := Stuff( cCaption, nPos, 1, "" )
         ENDIF
      ENDIF

      DispOutAt( ::nCapRow, ::nCapCol, cCaption, hb_ColorIndex( ::cColorSpec, GET_CLR_CAPTION ) )
      IF nPos > 0
         DispOutAt( ::nCapRow, ::nCapCol + nPos - 1, SubStr( cCaption, nPos, 1 ), hb_ColorIndex( ::cColorSpec, GET_CLR_ACCEL ) )
      ENDIF
   ENDIF

#endif

   /* Display the GET */

   IF !::lSuppDisplay .OR. nDispPos != ::nOldPos

      DispOutAt( ::nRow, ::nCol,;
                 iif( ::lHideInput, PadR( Replicate( SubStr( ::cStyle, 1, 1 ), Len( RTrim( cBuffer ) ) ), ::nDispLen ), SubStr( cBuffer, nDispPos, ::nDispLen ) ),;
                 hb_ColorIndex( ::cColorSpec, iif( ::hasFocus, GET_CLR_ENHANCED, GET_CLR_UNSELECTED ) ) )

      IF Set( _SET_DELIMITERS ) .AND. !::hasFocus
#ifdef HB_COMPAT_C53
         DispOutAt( ::nRow, ::nCol - 1, SubStr( Set( _SET_DELIMCHARS ), 1, 1 ), hb_ColorIndex( ::cColorSpec, GET_CLR_UNSELECTED ) )
         DispOutAt( ::nRow, ::nCol + ::nDispLen, SubStr( Set( _SET_DELIMCHARS ), 2, 1 ), hb_ColorIndex( ::cColorSpec, GET_CLR_UNSELECTED ) )
#else
         /* NOTE: C5.2 will use the default color. We're replicating this here. [vszakats] */
         DispOutAt( ::nRow, ::nCol - 1, SubStr( Set( _SET_DELIMCHARS ), 1, 1 ) )
         DispOutAt( ::nRow, ::nCol + ::nDispLen, SubStr( Set( _SET_DELIMCHARS ), 2, 1 ) )
#endif
      ENDIF
   ENDIF

   IF ::nPos != 0
      SetPos( ::nRow, ::nCol + ::nPos - nDispPos )
   ENDIF

   ::nOldPos := nDispPos
   ::lSuppDisplay := .F.

   SetCursor( nOldCursor )

   RETURN Self
tget.prg253
GET:METHODcolorDisp( cColorSpec ) CLASS Get
METHOD colorDisp( cColorSpec ) CLASS Get

   ::colorSpec( cColorSpec )
   ::display()

   RETURN Self
tget.prg350
GET:METHODend() CLASS Get
METHOD end() CLASS Get

   LOCAL nLastCharPos
   LOCAL nPos
   LOCAL nFor

   IF ::hasFocus
      nLastCharPos := Min( Len( RTrim( ::cBuffer ) ) + 1, ::nMaxEdit )
      IF ::nPos != nLastCharPos
         nPos := nLastCharPos
      ELSE
         nPos := ::nMaxEdit
      ENDIF
      FOR nFor := nPos TO ::FirstEditable() STEP -1
         IF ::IsEditable( nFor )
            ::pos := nFor
            EXIT
         ENDIF
      NEXT
      ::lClear := .F.
      ::typeOut := ( ::nPos == 0 )
      ::lSuppDisplay := .T.
      ::display()
   ENDIF

   RETURN Self
tget.prg357
GET:METHODhome() CLASS Get
METHOD home() CLASS Get

   IF ::hasFocus
      ::pos := ::FirstEditable()
      ::lClear := .F.
      ::typeOut := ( ::nPos == 0 )
      ::lSuppDisplay := .T.
      ::display()
   ENDIF

   RETURN Self
tget.prg384
GET:METHODreset() CLASS Get
METHOD reset() CLASS Get

   IF ::hasFocus
      ::cBuffer  := ::PutMask( ::varGet(), .F. )
      ::xVarGet  := ::original
      ::cType    := ValType( ::xVarGet )
      ::pos      := ::FirstEditable() /* ; Simple 0 in CA-Cl*pper [vszakats] */
      ::lClear   := ( "K" $ ::cPicFunc .OR. ::cType == "N" )
      ::lEdit    := .F.
      ::lMinus   := .F.
      ::rejected := .F.
      ::typeOut  := !( ::type $ "CNDL" ) .OR. ( ::nPos == 0 ) /* ; Simple .F. in CA-Cl*pper [vszakats] */
      ::display()
   ENDIF

   RETURN Self
tget.prg396
GET:METHODundo() CLASS Get
METHOD undo() CLASS Get

   IF ::hasFocus
      IF ::original != NIL
         ::varPut( ::original )
      ENDIF
      ::reset()
      ::lChanged := .F.
   ENDIF

   RETURN Self
tget.prg413
GET:METHODsetFocus() CLASS Get
METHOD setFocus() CLASS Get

   LOCAL xVarGet

   IF !::hasFocus

      xVarGet := ::xVarGet := ::varGet()
      
      ::hasFocus := .T.
      ::rejected := .F.
      
      ::original := xVarGet
      ::cType    := ValType( xVarGet )
      ::picture  := ::cPicture
      ::cBuffer  := ::PutMask( xVarGet, .F. )
      
      ::lChanged := .F.
      ::lClear   := ( "K" $ ::cPicFunc .OR. ::cType == "N" )
      ::lEdit    := .F.
      ::pos      := 1
      
      ::lMinusPrinted := .F.
      ::lMinus        := .F.
      
      IF ::cType == "N"
         ::decPos := At( iif( "E" $ ::cPicFunc, ",", "." ), ::cBuffer )
         IF ::decPos == 0
            ::decPos := Len( ::cBuffer ) + 1
         ENDIF
         ::lMinus2 := ( ::xVarGet < 0 )
      ELSE
         ::decPos := 0 /* ; CA-Cl*pper NG says that it contains NIL, but in fact it contains zero. [vszakats] */
      ENDIF
      
      ::display()
   ENDIF

   RETURN Self
tget.prg425
GET:METHODkillFocus() CLASS Get
METHOD killFocus() CLASS Get

   LOCAL lHadFocus := ::hasFocus

   ::hasFocus := .F.
   ::nPos     := 0
   ::lClear   := .F.
   ::lMinus   := .F.
   ::lChanged := .F.
   ::decPos   := 0 /* ; CA-Cl*pper NG says that it contains NIL, but in fact it contains zero. [vszakats] */
   ::typeOut  := .F.

   IF lHadFocus
      ::display()
   ENDIF

   ::xVarGet  := NIL
   ::original := NIL
   ::cBuffer  := NIL

   RETURN Self
tget.prg464
GET:METHODvarPut( xValue ) CLASS Get
METHOD varPut( xValue ) CLASS Get

   LOCAL aSubs
   LOCAL nLen
   LOCAL i
   LOCAL aValue

   IF ISBLOCK( ::bBlock ) .AND. ValType( xValue ) $ "CNDLU"
      aSubs := ::subScript
      IF ISARRAY( aSubs ) .AND. ! Empty( aSubs ) 
         nLen := Len( aSubs )
         aValue := Eval( ::bBlock )
         FOR i := 1 TO nLen - 1
            IF ISNUMBER( aSubs[ i ] )
               aValue := aValue[ aSubs[ i ] ]
            ELSE
               EXIT
            ENDIF
         NEXT
         IF ISNUMBER( aSubs[ i ] )
            aValue[ aSubs[ i ] ] := xValue
         ENDIF
      ELSE
         Eval( ::bBlock, xValue )
      ENDIF
   ELSE
      xValue := NIL
   ENDIF

   RETURN xValue
tget.prg486
GET:METHODvarGet() CLASS Get
METHOD varGet() CLASS Get

   LOCAL aSubs
   LOCAL nLen
   LOCAL i
   LOCAL xValue

   IF ISBLOCK( ::bBlock )
      aSubs := ::subScript
      IF ISARRAY( aSubs ) .AND. ! Empty( aSubs ) 
         nLen := Len( aSubs )
         xValue := Eval( ::bBlock )
         FOR i := 1 TO nLen
            IF ISNUMBER( aSubs[ i ] )
               xValue := xValue[ aSubs[ i ] ]
            ELSE
               EXIT
            ENDIF
         NEXT
      ELSE
         xValue := Eval( ::bBlock )
      ENDIF
   ELSE
      xValue := ::xVarGet
   ENDIF

   RETURN xValue
tget.prg517
GET:METHODoverStrike( cChar ) CLASS Get
METHOD overStrike( cChar ) CLASS Get

   IF ::hasFocus

      IF ::cType == "N" .AND. ! ::lEdit .AND. ::lClear
         ::pos := ::FirstEditable()
      ENDIF
      
      IF ::pos <= ::nMaxEdit
      
         cChar := ::Input( cChar )
         
         IF cChar == ""
            ::rejected := .T.
         ELSE
            ::rejected := .F.
         
            IF ::lClear .AND. ::nPos == ::FirstEditable()
               ::DeleteAll()
               ::lClear := .F.
            ENDIF
            
            ::lEdit := .T.
            
            IF ::nPos == 0
               ::pos := 1
            ENDIF
            
            DO WHILE ! ::IsEditable( ::nPos ) .AND. ::nPos <= ::nMaxEdit
               ::pos++
            ENDDO
            
            IF ::nPos > ::nMaxEdit
               ::pos := ::FirstEditable()
            ENDIF
            ::cBuffer := SubStr( ::cBuffer, 1, ::nPos - 1 ) + cChar + SubStr( ::cBuffer, ::nPos + 1 )
            
            ::lChanged := .T.
            
            ::rightLow()
         ENDIF
      ENDIF

      ::display()
   ENDIF

   RETURN Self
tget.prg548
GET:METHODinsert( cChar ) CLASS Get
METHOD insert( cChar ) CLASS Get

   LOCAL nFor
   LOCAL nMaxEdit

   IF ::hasFocus

      nMaxEdit := ::nMaxEdit
      
      IF ::cType == "N" .AND. ! ::lEdit .AND. ::lClear
         ::pos := ::FirstEditable()
      ENDIF
      
      IF ::nPos <= ::nMaxEdit
      
         cChar := ::Input( cChar )
         
         IF cChar == ""
            ::rejected := .T.
         ELSE
            ::rejected := .F.
         
            IF ::lClear .AND. ::nPos == ::FirstEditable()
               ::DeleteAll()
               ::lClear := .F.
            ENDIF
            
            ::lEdit := .T.
            
            IF ::nPos == 0
               ::pos := 1
            ENDIF
            
            DO WHILE ! ::IsEditable( ::nPos ) .AND. ::nPos <= ::nMaxEdit
               ::pos++
            ENDDO
            
            IF ::nPos > ::nMaxEdit
               ::pos := ::FirstEditable()
            ENDIF
            
            IF ::lPicComplex
               /* Calculating different nMaxEdit for ::lPicComplex */
               FOR nFor := ::nPos TO nMaxEdit
                  IF !::IsEditable( nFor )
                     EXIT
                  ENDIF
               NEXT
               nMaxEdit := nFor
               ::cBuffer := Left( SubStr( ::cBuffer, 1, ::nPos - 1 ) + cChar +;
                            SubStr( ::cBuffer, ::nPos, nMaxEdit - 1 - ::nPos ) +;
                            SubStr( ::cBuffer, nMaxEdit ), ::nMaxLen )
            ELSE
               ::cBuffer := Left( SubStr( ::cBuffer, 1, ::nPos - 1 ) + cChar + SubStr( ::cBuffer, ::nPos ), ::nMaxEdit )
            ENDIF
            
            ::lChanged := .T.
            
            ::rightLow()
         ENDIF
      ENDIF

      ::display()
   ENDIF

   RETURN Self
tget.prg599
GET:METHODright() CLASS Get
METHOD right() CLASS Get

   IF ::hasFocus .AND. ;
      ::rightLow()

      ::lSuppDisplay := .T.
      ::display()
   ENDIF

   RETURN Self
tget.prg666
GET:METHODleft() CLASS Get
METHOD left() CLASS Get

   IF ::hasFocus .AND. ;
      ::leftLow()

      ::lSuppDisplay := .T.
      ::display()
   ENDIF

   RETURN Self
tget.prg677
GET:METHODwordLeft() CLASS Get
METHOD wordLeft() CLASS Get

   LOCAL nPos

   IF ::hasFocus

      ::lClear := .F.
      
      IF ::nPos == ::FirstEditable()
         ::typeOut := .T.
      ELSE
         ::typeOut := .F.
      
         nPos := ::nPos - 1
         
         DO WHILE nPos > 0
            IF SubStr( ::cBuffer, nPos, 1 ) == " "
               DO WHILE nPos > 0 .AND. SubStr( ::cBuffer, nPos, 1 ) == " "
                  nPos--
               ENDDO
               DO WHILE nPos > 0 .AND. !( SubStr( ::cBuffer, nPos, 1 ) == " " )
                  nPos--
               ENDDO
               IF nPos > 0
                  nPos++
               ENDIF
               EXIT
            ENDIF
            nPos--
         ENDDO
         
         IF nPos < 1
            nPos := 1
         ENDIF
         
         IF nPos > 0
            ::pos := nPos
         ENDIF
         
         ::lSuppDisplay := .T.
         ::display()
      ENDIF
   ENDIF

   RETURN Self
tget.prg688
GET:METHODwordRight() CLASS Get
METHOD wordRight() CLASS Get

   LOCAL nPos

   IF ::hasFocus

      ::lClear := .F.
      
      IF ::nPos == ::nMaxEdit
         ::typeOut := .T.
      ELSE
         ::typeOut := .F.
         
         nPos := ::nPos + 1
         
         DO WHILE nPos <= ::nMaxEdit
            IF SubStr( ::cBuffer, nPos, 1 ) == " "
               DO WHILE nPos <= ::nMaxEdit .AND. SubStr( ::cBuffer, nPos, 1 ) == " "
                  nPos++
               ENDDO
               EXIT
            ENDIF
            nPos++
         ENDDO
         
         IF nPos > ::nMaxEdit
            nPos := ::nMaxEdit
         ENDIF
         
         IF nPos <= ::nMaxEdit
            ::pos := nPos
         ENDIF
         
         ::lSuppDisplay := .T.
         ::display()
      ENDIF
   ENDIF

   RETURN Self
tget.prg734
GET:METHODtoDecPos() CLASS Get
METHOD toDecPos() CLASS Get

   IF ::hasFocus

      IF ::lClear
         ::delEnd()
      ENDIF

      ::cBuffer := ::PutMask( ::unTransform(), .F. )
      ::pos := ::decPos
      ::lChanged := .T.

      IF ::type == "N" .AND. ::lMinus .AND. ::unTransform() == 0
         ::backSpace()
         ::overStrike("-")
      ENDIF

      ::display()
   ENDIF

   RETURN Self
tget.prg774
GET:METHODbackSpace() CLASS Get
METHOD backSpace() CLASS Get

   IF ::hasFocus .AND. ;
      ::backSpaceLow()

      ::display()
   ENDIF

   RETURN Self
tget.prg796
GET:METHODdelete() CLASS Get
METHOD delete() CLASS Get

   IF ::hasFocus
      ::deleteLow()
      ::display()
   ENDIF

   RETURN Self
tget.prg806
GET:METHODdelEnd() CLASS Get
METHOD delEnd() CLASS Get

   LOCAL nPos

   IF ::hasFocus

      nPos := ::nPos
      ::pos := ::nMaxEdit
      
      ::deleteLow()
      DO WHILE ::nPos > nPos
         ::backSpaceLow()
      ENDDO
      
      ::display()
   ENDIF

   RETURN Self
tget.prg815
GET:METHODdelLeft() CLASS Get
METHOD delLeft() CLASS Get

   ::leftLow()
   ::deleteLow()
   ::right()

   RETURN Self
tget.prg834
GET:METHODdelRight() CLASS Get
METHOD delRight() CLASS Get

   ::rightLow()
   ::deleteLow()
   ::left()

   RETURN Self
tget.prg842
GET:METHODdelWordLeft() CLASS Get
METHOD delWordLeft() CLASS Get

   IF ::hasFocus

      IF !( SubStr( ::cBuffer, ::nPos, 1 ) == " " )
         IF SubStr( ::cBuffer, ::nPos - 1, 1 ) == " "
            ::backSpaceLow()
         ELSE
            ::wordRight()
            ::left()
         ENDIF
      ENDIF
      
      IF SubStr( ::cBuffer, ::nPos, 1 ) == " "
         ::deleteLow()
      ENDIF
      
      DO WHILE ::nPos > 1 .AND. !( SubStr( ::cBuffer, ::nPos - 1, 1 ) == " " )
         ::backSpaceLow()
      ENDDO
      
      ::display()
   ENDIF

   RETURN Self
tget.prg853
GET:METHODdelWordRight() CLASS Get
METHOD delWordRight() CLASS Get

   IF ::hasFocus

      ::lClear := .F.
      
      IF ::nPos == ::nMaxEdit
         ::typeOut := .T.
      ELSE
         ::typeOut := .F.
      
         DO WHILE ::nPos <= ::nMaxEdit .AND. !( SubStr( ::cBuffer, ::nPos, 1 ) == " " )
            ::deleteLow()
         ENDDO
         
         IF ::nPos <= ::nMaxEdit
            ::deleteLow()
         ENDIF
         
         ::display()
      ENDIF
   ENDIF

   RETURN Self
tget.prg879
GET:METHODcolorSpec( cColorSpec ) CLASS Get
METHOD colorSpec( cColorSpec ) CLASS Get

   LOCAL nClrUns
   LOCAL nClrOth
   LOCAL cClrOth

   IF PCount() == 0
      RETURN ::cColorSpec
   ENDIF

   IF ISCHARACTER( cColorSpec )

#ifdef HB_COMPAT_C53
      ::cColorSpec := hb_NToColor( nClrUns := Max( hb_ColorToN( hb_ColorIndex( cColorSpec, GET_CLR_UNSELECTED ) ), 0 ) ) +;
                      "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_ENHANCED ) ) ) != -1, nClrOth, nClrUns ) ) +;
                      "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_CAPTION  ) ) ) != -1, nClrOth, nClrUns ) ) +;
                      "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_ACCEL    ) ) ) != -1, nClrOth, nClrUns ) )
#else
      ::cColorSpec := hb_NToColor( nClrUns := Max( hb_ColorToN( hb_ColorIndex( cColorSpec, GET_CLR_UNSELECTED ) ), 0 ) ) +;
                      "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_ENHANCED ) ) ) != -1, nClrOth, nClrUns ) )
#endif

   /* NOTE: CA-Cl*pper oddity. [vszakats] */
   ELSEIF ValType( cColorSpec ) $ "UNDBA"

      RETURN NIL

#ifdef HB_COMPAT_C53
   /* NOTE: This code doesn't seem to make any sense, but seems to 
            replicate some original C5.3 behaviour. */
   ELSE
      IF Set( _SET_INTENSITY )
         ::cColorSpec := hb_ColorIndex( SetColor(), CLR_UNSELECTED ) + "," +; 
                         hb_ColorIndex( SetColor(), CLR_ENHANCED ) + "," +;   
                         hb_ColorIndex( SetColor(), CLR_STANDARD ) + "," +;   
                         hb_ColorIndex( SetColor(), CLR_BACKGROUND )
      ELSE
         ::cColorSpec := hb_ColorIndex( SetColor(), CLR_STANDARD ) + "," +; 
                         hb_ColorIndex( SetColor(), CLR_STANDARD ) + "," +;   
                         hb_ColorIndex( SetColor(), CLR_STANDARD ) + "," +;   
                         hb_ColorIndex( SetColor(), CLR_STANDARD )
      ENDIF
#endif
   ENDIF

   RETURN cColorSpec
tget.prg911
GET:METHODpos( nPos ) CLASS Get
METHOD pos( nPos ) CLASS Get

   LOCAL tmp

   IF PCount() == 0
      RETURN ::nPos
   ENDIF

   IF ISNUMBER( nPos )

      nPos := Int( nPos )

      IF ::hasFocus

         DO CASE
         CASE nPos > ::nMaxLen

            ::nPos := iif( ::nMaxLen == 0, 1, ::nMaxLen )
            ::typeOut := .T.

         CASE nPos > 0

            /* NOTE: CA-Cl*pper has a bug where negative nPos value will be translated to 16bit unsigned int, 
                     so the behaviour will be different in this case. [vszakats] */

            FOR tmp := nPos TO ::nMaxLen
               IF ::IsEditable( tmp )
                  ::nPos := tmp
                  RETURN nPos
               ENDIF
            NEXT
            FOR tmp := nPos - 1 TO 1 STEP -1
               IF ::IsEditable( tmp )
                  ::nPos := tmp
                  RETURN nPos
               ENDIF
            NEXT
            
            ::nPos := ::nMaxLen + 1
            ::typeOut := .T.

         ENDCASE

      ENDIF

      RETURN nPos

   ENDIF

   RETURN 0
tget.prg958
GET:METHODpicture( cPicture ) CLASS Get
METHOD picture( cPicture ) CLASS Get

   LOCAL nAt
   LOCAL nFor
   LOCAL cNum

   IF PCount() > 0

      IF cPicture != NIL

         ::cPicture      := cPicture
         ::nPicLen       := NIL
         ::cPicFunc      := ""
         ::cPicMask      := ""
         ::lPicBlankZero := .F.
         
         IF ISCHARACTER( cPicture )
         
            cNum := ""
            
            IF Left( cPicture, 1 ) == "@"
            
               nAt := At( " ", cPicture )
            
               IF nAt == 0
                  ::cPicFunc := Upper( cPicture )
                  ::cPicMask := ""
               ELSE
                  ::cPicFunc := Upper( SubStr( cPicture, 1, nAt - 1 ) )
                  ::cPicMask := SubStr( cPicture, nAt + 1 )
               ENDIF
            
               IF "D" $ ::cPicFunc
            
                  ::cPicMask := Set( _SET_DATEFORMAT )
                  ::cPicMask := StrTran( ::cPicmask, "y", "9" )
                  ::cPicMask := StrTran( ::cPicmask, "Y", "9" )
                  ::cPicMask := StrTran( ::cPicmask, "m", "9" )
                  ::cPicMask := StrTran( ::cPicmask, "M", "9" )
                  ::cPicMask := StrTran( ::cPicmask, "d", "9" )
                  ::cPicMask := StrTran( ::cPicmask, "D", "9" )
            
               ENDIF
            
               IF ( nAt := At( "S", ::cPicFunc ) ) > 0
                  FOR nFor := nAt + 1 TO Len( ::cPicFunc )
                     IF IsDigit( SubStr( ::cPicFunc, nFor, 1 ) )
                        cNum += SubStr( ::cPicFunc, nFor, 1 )
                     ELSE
                        EXIT
                     ENDIF
                  NEXT
                  IF Val( cNum ) > 0
                     ::nPicLen := Val( cNum )
                  ENDIF
                  ::cPicFunc := SubStr( ::cPicFunc, 1, nAt - 1 ) + SubStr( ::cPicFunc, nFor )
               ENDIF
            
               IF "Z" $ ::cPicFunc
                  ::lPicBlankZero := .T.
                  ::cPicFunc := StrTran( ::cPicFunc, "Z", "" )
               ENDIF
            
               IF ::cPicFunc == "@"
                  ::cPicFunc := ""
               ENDIF
            ELSE
               ::cPicMask := cPicture
            ENDIF
            
            IF ::cType == "D"
               ::cPicMask := LTrim( ::cPicMask )
            ENDIF
         ENDIF
      ENDIF
         
      /* Generate default picture mask if not specified. */
      
      IF Empty( ::cPicMask ) .OR. ::cPicture == NIL
      
         DO CASE
         CASE ::cType == "D"
      
            ::cPicMask := Set( _SET_DATEFORMAT )
            ::cPicMask := StrTran( ::cPicmask, "y", "9" )
            ::cPicMask := StrTran( ::cPicmask, "Y", "9" )
            ::cPicMask := StrTran( ::cPicmask, "m", "9" )
            ::cPicMask := StrTran( ::cPicmask, "M", "9" )
            ::cPicMask := StrTran( ::cPicmask, "d", "9" )
            ::cPicMask := StrTran( ::cPicmask, "D", "9" )
      
         CASE ::cType == "N"
      
            cNum := Str( ::xVarGet )
            IF ( nAt := At( ".", cNum ) ) > 0
               ::cPicMask := Replicate( "9", nAt - 1 ) + "."
               ::cPicMask += Replicate( "9", Len( cNum ) - Len( ::cPicMask ) )
            ELSE
               ::cPicMask := Replicate( "9", Len( cNum ) )
            ENDIF
      
         CASE ::cType == "C" .AND. ::cPicFunc == "@9"
      
            ::cPicMask := Replicate( "9", Len( ::xVarGet ) )
            ::cPicFunc := ""
      
         ENDCASE
      
      ENDIF
      
      /* To verify if it has non-modifiable embedded characters in the group. */
      
      ::lPicComplex := .F.
      IF ! Empty( ::cPicMask )
         FOR nFor := 1 TO Len( ::cPicMask )
            IF !( SubStr( ::cPicMask, nFor, 1 ) $ "!ANX9#" )
               ::lPicComplex := .T.
               EXIT
            ENDIF
         NEXT
      ENDIF
   ENDIF

   RETURN ::cPicture
tget.prg1017
GET:METHODPutMask( xValue, lEdit ) CLASS Get
METHOD PutMask( xValue, lEdit ) CLASS Get

   LOCAL cChar
   LOCAL cBuffer
   LOCAL cPicFunc := ::cPicFunc
   LOCAL cPicMask := ::cPicMask
   LOCAL nFor
   LOCAL nNoEditable := 0

   DEFAULT lEdit TO ::hasFocus

   IF !( ValType( xValue ) $ "CNDL" )
      xValue := ""
   ENDIF

   IF ::hasFocus
      cPicFunc := StrTran( cPicfunc, "B", "" )
      IF cPicFunc == "@"
         cPicFunc := ""
      ENDIF
   ENDIF
   IF lEdit .AND. ::lEdit
      IF "*" $ cPicMask .OR. ;
         "$" $ cPicMask
         cPicMask := StrTran( StrTran( cPicMask, "*", "9" ), "$", "9" )
      ENDIF
   ENDIF

   cBuffer := Transform( xValue, ;
               iif( Empty( cPicFunc ), ;
                             iif( ::lPicBlankZero .AND. !::hasFocus, "@Z ", "" ), ;
                  cPicFunc + iif( ::lPicBlankZero .AND. !::hasFocus, "Z"  , "" ) + " " ) ;
               + cPicMask )

   IF ::cType == "N"
      IF ( "(" $ cPicFunc .OR. ")" $ cPicFunc ) .AND. xValue >= 0
         cBuffer += " "
      ENDIF

      IF ( ( "C" $ cPicFunc .AND. xValue <  0 ) .OR.;
           ( "X" $ cPicFunc .AND. xValue >= 0 ) ) .AND.;
           !( "X" $ cPicFunc .AND. "C" $ cPicFunc )
         cBuffer += "   "
      ENDIF

      ::lMinusPrinted := ( xValue < 0 )
   ENDIF

   ::nMaxLen  := Len( cBuffer )
   ::nMaxEdit := ::nMaxLen

   IF lEdit .AND. ::cType == "N" .AND. ! Empty( cPicMask )
      FOR nFor := 1 TO ::nMaxLen
         cChar := SubStr( cPicMask, nFor, 1 )
         IF cChar $ ",." .AND. SubStr( cBuffer, nFor, 1 ) $ ",." // " " TOFIX
            IF "E" $ cPicFunc
               cChar := IIF( cChar == ",", ".", "," )
            ENDIF
            cBuffer := SubStr( cBuffer, 1, nFor - 1 ) + cChar + SubStr( cBuffer, nFor + 1 )
         ENDIF
      NEXT
      IF ::lEdit .AND. Empty( xValue )
         cBuffer := StrTran( cBuffer, "0", " " )
      ENDIF
   ENDIF

   IF ::cType == "N"
      IF "(" $ ::cPicFunc .OR. ")" $ ::cPicFunc
         ::nMaxEdit--
      ENDIF
      IF "C" $ ::cPicFunc .OR. "X" $ ::cPicFunc
         ::nMaxEdit -= 3
      ENDIF
   ENDIF

   IF ::cType == "D" .AND. ::badDate
      cBuffer := ::cBuffer
   ENDIF

   ::nMaxLen := Len( cBuffer )

   RETURN cBuffer
tget.prg1142
GET:METHODunTransform() CLASS Get
METHOD unTransform() CLASS Get

   LOCAL cBuffer
   LOCAL xValue
   LOCAL nFor
   LOCAL lMinus
   LOCAL lHasDec

   IF ::hasFocus

      cBuffer := ::cBuffer
      
      IF ISCHARACTER( cBuffer ) 
      
         DO CASE
         CASE ::cType == "C"
         
            IF "R" $ ::cPicFunc
               xValue := ""
               FOR nFor := 1 TO Len( ::cPicMask )
                  IF SubStr( ::cPicMask, nFor, 1 ) $ "ANX9#!LY"
                     xValue += SubStr( cBuffer, nFor, 1 )
                  ENDIF
               NEXT
            ELSE
               xValue := cBuffer
            ENDIF
         
         CASE ::cType == "N"
         
            lMinus := .F.
            IF "X" $ ::cPicFunc
               IF Right( cBuffer, 2 ) == "DB"
                  lMinus := .T.
               ENDIF
            ENDIF
            IF !lMinus
               FOR nFor := 1 TO ::nMaxLen
                  IF ::IsEditable( nFor ) .AND. IsDigit( SubStr( cBuffer, nFor, 1 ) )
                     EXIT
                  ENDIF
                  IF SubStr( cBuffer, nFor, 1 ) $ "-(" .AND. !( SubStr( cBuffer, nFor, 1 ) == SubStr( ::cPicMask, nFor, 1 ) )
                     lMinus := .T.
                     EXIT
                  ENDIF
               NEXT
            ENDIF
            cBuffer := Space( ::FirstEditable() - 1 ) + SubStr( cBuffer, ::FirstEditable(), ::LastEditable() - ::FirstEditable() + 1 )
         
            IF "D" $ ::cPicFunc
               FOR nFor := ::FirstEditable() TO ::LastEditable()
                  IF !::IsEditable( nFor )
                     cBuffer := Left( cBuffer, nFor - 1 ) + Chr( 1 ) + SubStr( cBuffer, nFor + 1 )
                  ENDIF
               NEXT
            ELSE
               IF "E" $ ::cPicFunc
                  cBuffer := Left( cBuffer, ::FirstEditable() - 1 ) +; 
                             StrTran( StrTran( SubStr( cBuffer, ::FirstEditable(), ::LastEditable() - ::FirstEditable() + 1 ), ".", " " ), ",", "." ) +;
                             SubStr( cBuffer, ::LastEditable() + 1 )
               ELSE
                  cBuffer := Left( cBuffer, ::FirstEditable() - 1 ) +;
                                      StrTran( SubStr( cBuffer, ::FirstEditable(), ::LastEditable() - ::FirstEditable() + 1 ), ",", " " ) +;
                             SubStr( cBuffer, ::LastEditable() + 1 )
               ENDIF
         
               lHasDec := .F.
               FOR nFor := ::FirstEditable() TO ::LastEditable()
                  IF ::IsEditable( nFor )
                     IF lHasDec .AND. SubStr( cBuffer, nFor, 1 ) == " "
                        cBuffer := Left( cBuffer, nFor - 1 ) + "0" + SubStr( cBuffer, nFor + 1 )
                     ENDIF
                  ELSE
                     IF SubStr( cBuffer, nFor, 1 ) == "."
                        lHasDec := .T.
                     ELSE
                        cBuffer := Left( cBuffer, nFor - 1 ) + Chr( 1 ) + SubStr( cBuffer, nFor + 1 )
                     ENDIF
                  ENDIF
               NEXT
            ENDIF
         
            cBuffer := StrTran( cBuffer, Chr( 1 ), "" )
         
            cBuffer := StrTran( cBuffer, "$", " " )
            cBuffer := StrTran( cBuffer, "*", " " )
            cBuffer := StrTran( cBuffer, "-", " " )
            cBuffer := StrTran( cBuffer, "(", " " )
            cBuffer := StrTran( cBuffer, ")", " " )
         
            cBuffer := PadL( StrTran( cBuffer, " ", "" ), Len( cBuffer ) )
         
            IF lMinus
               FOR nFor := 1 TO Len( cBuffer )
                  IF IsDigit( SubStr( cBuffer, nFor, 1 ) ) .OR. SubStr( cBuffer, nFor, 1 ) == "."
                     EXIT
                  ENDIF
               NEXT
               nFor--
               IF nFor > 0
                  cBuffer := Left( cBuffer, nFor - 1 ) + "-" + SubStr( cBuffer, nFor + 1 )
               ELSE
                  cBuffer := "-" + cBuffer
               ENDIF
            ENDIF
         
            xValue := Val( cBuffer )
         
         CASE ::cType == "L"
         
            cBuffer := Upper( cBuffer )
               xValue := "T" $ cBuffer .OR. ;
                         "Y" $ cBuffer .OR. ;
                         hb_LangMessage( HB_LANG_ITEM_BASE_TEXT + 1 ) $ cBuffer
         
         CASE ::cType == "D"
         
            IF "E" $ ::cPicFunc
               cBuffer := SubStr( cBuffer, 4, 3 ) + SubStr( cBuffer, 1, 3 ) + SubStr( cBuffer, 7 )
            ENDIF
            xValue := CToD( cBuffer )
         
         ENDCASE

      ELSE
         ::lClear  := .F.
         ::decPos  := 0
         ::nPos    := 0
         ::typeOut := .F.
      ENDIF
   ENDIF

   RETURN xValue
tget.prg1225
GET:METHODtype() CLASS Get
METHOD type() CLASS Get

   RETURN ::cType := ValType( iif( ::hasFocus, ::xVarGet, ::varGet() ) )
tget.prg1359
GET:METHODblock( bBlock ) CLASS Get
METHOD block( bBlock ) CLASS Get

   IF PCount() == 0 .OR. bBlock == NIL
      RETURN ::bBlock
   ENDIF

   ::bBlock   := bBlock
   ::xVarGet  := ::original
   ::cType    := ValType( ::xVarGet )

   RETURN bBlock
tget.prg1372
GET:METHODfirstEditable() CLASS Get
METHOD firstEditable() CLASS Get

   LOCAL nFor

   IF ::nMaxLen != NIL

      IF ::IsEditable( 1 )
         RETURN 1
      ENDIF

      FOR nFor := 2 TO ::nMaxLen
         IF ::IsEditable( nFor )
            RETURN nFor
         ENDIF
      NEXT

   ENDIF

   RETURN 0
tget.prg1384
GET:METHODlastEditable() CLASS Get
METHOD lastEditable() CLASS Get

   LOCAL nFor

   IF ::nMaxLen != NIL

      FOR nFor := ::nMaxLen TO 1 STEP -1
         IF ::IsEditable( nFor )
            RETURN nFor
         ENDIF
      NEXT

   ENDIF

   RETURN 0
tget.prg1404
GET:METHODbadDate() CLASS Get
METHOD badDate() CLASS Get

   LOCAL xValue

   RETURN ::hasFocus .AND. ;
      ::type == "D" .AND. ;
      ( xValue := ::unTransform() ) == hb_SToD( "" ) .AND. ;
      !( ::cBuffer == Transform( xValue, ::cPicture ) )
tget.prg1420
GET:METHODreform() CLASS Get
METHOD reform() CLASS Get

   IF ::hasFocus
      ::cBuffer := ::PutMask( ::unTransform(), .F. )
      ::nDispLen := iif( ::nPicLen == NIL, ::nMaxLen, ::nPicLen ) // ; ?
   ENDIF

   RETURN Self
tget.prg1431
GET:METHODhitTest( nMRow, nMCol ) CLASS Get
METHOD hitTest( nMRow, nMCol ) CLASS Get

   IF ISOBJECT( ::oControl )
      RETURN ::oControl:hitTest( nMRow, nMCol )
   ELSE
      DO CASE
      CASE nMRow == ::nRow .AND. ;
           nMCol >= ::nCol .AND. ;
           nMCol < ::nCol + iif( ::nDispLen == NIL, 0, ::nDispLen )
         RETURN HTCLIENT
      CASE nMRow == ::nCapRow .AND. ;
           nMCol >= ::nCapCol .AND. ;
           nMCol < ::nCapCol + Len( ::cCaption ) /* NOTE: C5.3 doesn't care about the shortcut key. */
         RETURN HTCAPTION
      ENDCASE
   ENDIF

   RETURN HTNOWHERE
tget.prg1444
GET:METHODcontrol( oControl ) CLASS Get
METHOD control( oControl ) CLASS Get

   IF PCount() == 1 .AND. ( oControl == NIL .OR. ISOBJECT( oControl ) )
      ::oControl := oControl
   ENDIF

   RETURN ::oControl
tget.prg1463
GET:METHODcaption( cCaption ) CLASS Get
METHOD caption( cCaption ) CLASS Get

   IF ISCHARACTER( cCaption )
      ::cCaption := cCaption
   ENDIF

   RETURN ::cCaption
tget.prg1471
GET:METHODcapRow( nCapRow ) CLASS Get
METHOD capRow( nCapRow ) CLASS Get

   IF ISNUMBER( nCapRow )
      ::nCapRow := Int( nCapRow )
   ENDIF

   RETURN ::nCapRow
tget.prg1479
GET:METHODcapCol( nCapCol ) CLASS Get
METHOD capCol( nCapCol ) CLASS Get

   IF ISNUMBER( nCapCol )
      ::nCapCol := Int( nCapCol )
   ENDIF

   RETURN ::nCapCol
tget.prg1487
GET:METHODmessage( cMessage ) CLASS Get
METHOD message( cMessage ) CLASS Get

   IF ISCHARACTER( cMessage )
      ::cMessage := cMessage
   ENDIF

   RETURN ::cMessage

#endif

#ifdef HB_COMPAT_XPP

tget.prg1495
GET:METHODposInBuffer( nRow, nCol ) CLASS Get
METHOD posInBuffer( nRow, nCol ) CLASS Get

   IF ::hasFocus .AND. ;
      nRow == ::nRow .AND. ;
      nCol >= ::nCol + ::nPos - 1 .AND. ;
      nCol <= ::nCol + ::nDispLen

      RETURN nCol - ::nCol + 1
   ENDIF

   RETURN 0
tget.prg1510
GET:METHODrightLow() CLASS Get
METHOD rightLow() CLASS Get

   LOCAL nPos
   
   ::typeOut := .F.
   ::lClear  := .F.
   
   IF ::nPos == ::nMaxEdit
      ::typeOut := .T.
      RETURN .F.
   ENDIF
   
   nPos := ::nPos + 1
   
   DO WHILE ! ::IsEditable( nPos ) .AND. nPos <= ::nMaxEdit
      nPos++
   ENDDO
   
   IF nPos <= ::nMaxEdit
      ::pos := nPos
   ELSE
      ::typeOut := .T.
   ENDIF
   
   RETURN .T.
tget.prg1526
GET:METHODleftLow() CLASS Get
METHOD leftLow() CLASS Get

   LOCAL nPos

   ::typeOut := .F.
   ::lClear  := .F.

   IF ::nPos == ::FirstEditable()
      ::typeOut := .T.
      RETURN .F.
   ENDIF

   nPos := ::nPos - 1

   DO WHILE ! ::IsEditable( nPos ) .AND. nPos > 0
      nPos--
   ENDDO

   IF nPos > 0
      ::pos := nPos
   ELSE
      ::typeOut := .T.
   ENDIF

   RETURN .T.
tget.prg1552
GET:METHODbackSpaceLow() CLASS Get
METHOD backSpaceLow() CLASS Get

   LOCAL nMinus
   LOCAL nPos := ::nPos

   IF nPos > 1 .AND. nPos == ::FirstEditable() .AND. ::lMinus2

      /* To delete the parenthesis (negative indicator) in a non editable position */

      nMinus := At( "(", SubStr( ::cBuffer, 1, nPos - 1 ) )

      IF nMinus > 0 .AND. !( SubStr( ::cPicMask, nMinus, 1 ) == "(" )

         ::cBuffer := SubStr( ::cBuffer, 1, nMinus - 1 ) + " " +;
                      SubStr( ::cBuffer, nMinus + 1 )

         ::lEdit := .T.
         ::lChanged := .T.

         RETURN .T.
      ENDIF
   ENDIF

   ::left()

   IF ::nPos < nPos
      ::deleteLow()
      RETURN .T.
   ENDIF

   RETURN .F.
tget.prg1578
GET:METHODdeleteLow() CLASS Get
METHOD deleteLow() CLASS Get

   LOCAL nMaxLen := ::nMaxLen
   LOCAL n

   ::lClear := .F.
   ::lEdit := .T.

   IF ::lPicComplex
      /* Calculating different nMaxLen for ::lPicComplex */
      FOR n := ::nPos TO nMaxLen
         IF !::IsEditable( n )
            EXIT
         ENDIF
      NEXT
      nMaxLen := n - 1
   ENDIF

   IF ::cType == "N" .AND. SubStr( ::cBuffer, ::nPos, 1 ) $ "(-"
      ::lMinus2 := .F.
   ENDIF

   ::cBuffer := PadR( SubStr( ::cBuffer, 1, ::nPos - 1 ) + ;
                SubStr( ::cBuffer, ::nPos + 1, nMaxLen - ::nPos ) + " " +;
                SubStr( ::cBuffer, nMaxLen + 1 ), ::nMaxLen )

   ::lChanged := .T.

   RETURN NIL
tget.prg1610
GET:METHODDeleteAll() CLASS Get
METHOD DeleteAll() CLASS Get

   LOCAL xValue

   IF ::hasFocus

      ::lEdit := .T.
      
      DO CASE
      CASE ::cType == "C"
         xValue := Space( ::nMaxlen )
      CASE ::cType == "N"
         xValue   := 0
         ::lMinus2 := .F.
      CASE ::cType == "D"
         xValue := CToD( "" )
      CASE ::cType == "L"
         xValue := .F.
      ENDCASE
      
      ::cBuffer := ::PutMask( xValue )
      ::pos     := ::FirstEditable()
   ENDIF

   RETURN Self
tget.prg1640
GET:METHODIsEditable( nPos ) CLASS Get
METHOD IsEditable( nPos ) CLASS Get

   LOCAL cChar

   IF Empty( ::cPicMask )
      RETURN .T.
   ENDIF

   /* ; This odd behaviour helps to be more compatible with CA-Cl*pper in some rare situations.
        xVar := 98 ; o := _GET_( xVar, "xVar" ) ; o:SetFocus() ; o:picture := "99999" ; o:UnTransform() -> result 
        We're still not 100% compatible in slighly different situations because the CA-Cl*pper 
        behaviour is pretty much undefined here. [vszakats] */
   IF nPos > Len( ::cPicMask ) .AND. nPos <= ::nMaxLen
      RETURN .T.
   ENDIF

   cChar := SubStr( ::cPicMask, nPos, 1 )

   DO CASE
   CASE ::cType == "C"
      RETURN cChar $ "!ANX9#LY"
   CASE ::cType == "N"
      RETURN cChar $ "9#$*"
   CASE ::cType == "D"
      RETURN cChar == "9"
   CASE ::cType == "L"
      RETURN cChar $ "LY#" /* CA-Cl*pper 5.2 undocumented: # allow T,F,Y,N for Logical [ckedem] */
   ENDCASE

   RETURN .F.
tget.prg1666
GET:METHODInput( cChar ) CLASS Get
METHOD Input( cChar ) CLASS Get

   LOCAL cPic

   DO CASE
   CASE ::cType == "N"

      DO CASE
      CASE cChar == "-"
         ::lMinus2 := .T.  /* The minus symbol can be written in any place */
         ::lMinus := .T.

      CASE cChar $ ".,"
         ::toDecPos()
         RETURN ""

      CASE ! ( cChar $ "0123456789+" )
         RETURN ""
      ENDCASE

   CASE ::cType == "D"

      IF !( cChar $ "0123456789" )
         RETURN ""
      ENDIF

   CASE ::cType == "L"

      IF !( Upper( cChar ) $ "YNTF" )
         RETURN ""
      ENDIF

   ENDCASE

   IF ! Empty( ::cPicFunc )
      cChar := Left( Transform( cChar, ::cPicFunc ), 1 ) /* Left needed for @D */
   ENDIF

   IF ! Empty( ::cPicMask )
      cPic  := SubStr( ::cPicMask, ::nPos, 1 )

//    cChar := Transform( cChar, cPic )
// Above line eliminated because some get picture template symbols for
// numeric input not work in text input. eg: $ and *

      DO CASE
      CASE cPic == "A"
         IF ! IsAlpha( cChar )
            cChar := ""
         ENDIF

      CASE cPic == "N"
         IF ! IsAlpha( cChar ) .AND. ! IsDigit( cChar )
            cChar := ""
         ENDIF

      CASE cPic == "9"
         IF ! IsDigit( cChar ) .AND. ! cChar $ "-+"
            cChar := ""
         ENDIF
         IF !( ::cType == "N" ) .AND. cChar $ "-+"
            cChar := ""
         ENDIF

      /* Clipper 5.2 undocumented: # allow T,F,Y,N for Logical [ckedem] */
      CASE cPic == "L" .OR. ( cPic == "#" .AND. ::cType == "L" )
         IF !( Upper( cChar ) $ "YNTF" + ;
                                hb_LangMessage( HB_LANG_ITEM_BASE_TEXT + 1 ) + ;
                                hb_LangMessage( HB_LANG_ITEM_BASE_TEXT + 2 ) )
            cChar := ""
         ENDIF

      CASE cPic == "#"
         IF ! IsDigit( cChar ) .AND. !( cChar == " " ) .AND. !( cChar $ ".+-" )
            cChar := ""
         ENDIF

      CASE cPic == "Y"
         IF !( Upper( cChar ) $ "YN" )
            cChar := ""
         ENDIF

      CASE ( cPic == "$" .OR. cPic == "*" ) .AND. ::cType == "N"
         IF ! IsDigit( cChar ) .AND. !( cChar == "-" )
            cChar := ""
         ENDIF
      OTHERWISE
         cChar := Transform( cChar, cPic )
      ENDCASE
   ENDIF

   RETURN cChar
tget.prg1697
GET:METHODbuffer( cBuffer ) CLASS Get
METHOD buffer( cBuffer ) CLASS Get

   IF PCount() == 0
      RETURN ::cBuffer
   ENDIF

   RETURN iif( ::hasFocus, ::cBuffer := cBuffer, cBuffer )
tget.prg1792
GET:METHODchanged( lChanged ) CLASS Get
METHOD changed( lChanged ) CLASS Get

   IF PCount() == 0
      RETURN ::lChanged
   ENDIF

   IF ISLOGICAL( lChanged )
      RETURN iif( ::hasFocus, ::lChanged := lChanged, lChanged )
   ENDIF

   RETURN .F.
tget.prg1802
GET:METHODclear( lClear ) CLASS Get
METHOD clear( lClear ) CLASS Get

   IF PCount() == 0
      RETURN ::lClear
   ENDIF

   IF ISLOGICAL( lClear )
      RETURN iif( ::hasFocus, ::lClear := lClear, lClear )
   ENDIF

   RETURN .F.
tget.prg1814
GET:METHODminus( lMinus ) CLASS Get
METHOD minus( lMinus ) CLASS Get

   IF PCount() == 0
      RETURN ::lMinus
   ENDIF

   IF ISLOGICAL( lMinus )
      RETURN iif( ::hasFocus, ::lMinus := lMinus, lMinus )
   ENDIF

   RETURN .F.
tget.prg1826
GET:METHODrow( nRow ) CLASS Get
METHOD row( nRow ) CLASS Get

   IF PCount() > 0
      ::nRow := iif( ISNUMBER( nRow ), Int( nRow ), 0 )
   ENDIF

   RETURN ::nRow
tget.prg1841
GET:METHODcol( nCol ) CLASS Get
METHOD col( nCol ) CLASS Get

   IF PCount() > 0
      ::nCol := iif( ISNUMBER( nCol ), Int( nCol ), 0 )
   ENDIF

   RETURN ::nCol
tget.prg1852
GET:METHODname( cName ) CLASS Get
METHOD name( cName ) CLASS Get

   IF PCount() > 0 .AND. cName != NIL
      ::cName := cName
   ENDIF

   RETURN ::cName
tget.prg1860
GET:METHODhideInput( lHideInput ) CLASS Get
METHOD hideInput( lHideInput ) CLASS Get

   IF lHideInput != NIL
      ::lHideInput := __eInstVar53( Self, "HIDEINPUT", lHideInput, "L", 1001 )
   ENDIF

   RETURN ::lHideInput
tget.prg1870
GET:METHODstyle( cStyle ) CLASS Get
METHOD style( cStyle ) CLASS Get

   IF cStyle != NIL
      ::cStyle := __eInstVar53( Self, "STYLE", cStyle, "C", 1001, {|| Len( cStyle ) == 1 } )
   ENDIF

   RETURN ::cStyle
tget.prg1878
GET:METHODNew( nRow, nCol, bVarBlock, cVarName, cPicture, cColorSpec ) CLASS Get
METHOD New( nRow, nCol, bVarBlock, cVarName, cPicture, cColorSpec ) CLASS Get

   DEFAULT nRow       TO Row()
   DEFAULT nCol       TO Col() + iif( Set( _SET_DELIMITERS ), 1, 0 )
   DEFAULT cVarName   TO ""
   DEFAULT bVarBlock  TO iif( ISCHARACTER( cVarName ), MemvarBlock( cVarName ), NIL )
#ifdef HB_COMPAT_C53
   DEFAULT cColorSpec TO hb_ColorIndex( SetColor(), CLR_UNSELECTED ) + "," +;
                         hb_ColorIndex( SetColor(), CLR_ENHANCED ) + "," +;
                         hb_ColorIndex( SetColor(), CLR_STANDARD ) + "," +;
                         iif( IsDefColor(), iif( Set( _SET_INTENSITY ), "W+/N", "W/N" ), hb_ColorIndex( SetColor(), CLR_BACKGROUND ) )
#else
   DEFAULT cColorSpec TO hb_ColorIndex( SetColor(), CLR_UNSELECTED ) + "," +;
                         hb_ColorIndex( SetColor(), CLR_ENHANCED )
#endif

   ::nRow      := nRow
   ::nCol      := nCol
   ::bBlock    := bVarBlock
   ::cName     := cVarName
   ::picture   := cPicture
   ::colorSpec := cColorSpec

   RETURN Self
tget.prg1890
tgetint.prg
TypeFunctionSourceLine
FUNCTIONGetNew( nRow, nCol, bVarBlock, cVarName, cPicture, cColor )
FUNCTION GetNew( nRow, nCol, bVarBlock, cVarName, cPicture, cColor )
   RETURN Get():New( nRow, nCol, bVarBlock, cVarName, cPicture, cColor )
tgetint.prg67
FUNCTION__GET( bSetGet, cVarName, cPicture, bValid, bWhen )
FUNCTION __GET( bSetGet, cVarName, cPicture, bValid, bWhen )

   LOCAL oGet

   IF bSetGet == NIL
      IF FieldPos( cVarName ) > 0
         bSetGet := &( "{|| IIF( PCOUNT()==0, FIELD->" + cVarName + ", FIELD->" + cVarName + " := HB_PVALUE(1) ) }" )
      ELSEIF __MVEXIST( cVarName )
         bSetGet := {|_1| iif( _1 == NIL,  __MVGET( cVarName ), __MVPUT( cVarName, _1 ) ) }
      ELSE
         bSetGet := &( "{|| IIF( PCOUNT()==0, " + cVarName + ", " + cVarName + " := HB_PVALUE(1) ) }" )
      ENDIF
   ENDIF

   oGet := Get():New( , , bSetGet, cVarName, cPicture )

   oGet:PreBlock := bWhen
   oGet:PostBlock := bValid

   RETURN oGet
tgetint.prg72
FUNCTION__GETA( bGetArray, cVarName, cPicture, bValid, bWhen, aIndex )
FUNCTION __GETA( bGetArray, cVarName, cPicture, bValid, bWhen, aIndex )

   LOCAL oGet

   IF bGetArray == NIL
      IF FieldPos( cVarName ) > 0
         bGetArray := &( "{|| FIELD->" + cVarName + "}" )
      ELSEIF __MVEXIST( cVarName )
         bGetArray := {|| __MVGET( cVarName ) }
      ELSE
         bGetArray := &( "{|| " + cVarName + "}" )
      ENDIF
   ENDIF

   oGet := Get():New( , , bGetArray, cVarName, cPicture )
   oGet:SubScript := aIndex

   oGet:PreBlock := bWhen
   oGet:PostBlock := bValid

   RETURN oGet
tgetint.prg93
tgetlist.prg
TypeFunctionSourceLine
METHODReadModal( nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )
   METHOD ReadModal( nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor )
tgetlist.prg95
METHODReadModal()
   METHOD ReadModal()
tgetlist.prg97
METHODSettle( nPos, lInit )
   METHOD Settle( nPos, lInit )
tgetlist.prg99
METHODReader( oMenu, aMsg )
   METHOD Reader( oMenu, aMsg )
tgetlist.prg100
METHODGetApplyKey( nKey, oGet, oMenu, aMsg )
   METHOD GetApplyKey( nKey, oGet, oMenu, aMsg )
tgetlist.prg101
METHODGetPreValidate( oGet, aMsg )
   METHOD GetPreValidate( oGet, aMsg )
tgetlist.prg102
METHODGetPostValidate( oGet, aMsg )
   METHOD GetPostValidate( oGet, aMsg )
tgetlist.prg103
METHODGetDoSetKey( bKeyBlock, oGet )
   METHOD GetDoSetKey( bKeyBlock, oGet )
tgetlist.prg104
METHODPostActiveGet()
   METHOD PostActiveGet()
tgetlist.prg105
METHODGetReadVar()
   METHOD GetReadVar()
tgetlist.prg106
METHODSetFormat( bFormat )
   METHOD SetFormat( bFormat )
tgetlist.prg107
METHODKillRead( lKill )
   METHOD KillRead( lKill )
tgetlist.prg108
METHODGetActive( oGet )
   METHOD GetActive( oGet )
tgetlist.prg109
METHODDateMsg()
   METHOD DateMsg()
tgetlist.prg110
METHODShowScoreBoard()
   METHOD ShowScoreBoard()
tgetlist.prg111
METHODReadUpdated( lUpdated )
   METHOD ReadUpdated( lUpdated )
tgetlist.prg112
METHODReadVar( cNewVarName )
   METHOD ReadVar( cNewVarName )
tgetlist.prg113
METHODSetFocus()
   METHOD SetFocus()
tgetlist.prg114
METHODUpdated()
   METHOD Updated()                                  // returns ::lUpdated
tgetlist.prg115
METHODGet()
   METHOD Get()                                      // returns ::oGet
tgetlist.prg116
METHODGUIReader( oGet, oMenu, aMsg )
   METHOD GUIReader( oGet, oMenu, aMsg )
tgetlist.prg119
METHODGUIApplyKey( oGet, oGUI, nKey, oMenu, aMsg )
   METHOD GUIApplyKey( oGet, oGUI, nKey, oMenu, aMsg )
tgetlist.prg120
METHODGUIPreValidate( oGet, oGUI, aMsg )
   METHOD GUIPreValidate( oGet, oGUI, aMsg )
tgetlist.prg121
METHODGUIPostValidate( oGet, oGUI, aMsg )
   METHOD GUIPostValidate( oGet, oGUI, aMsg )
tgetlist.prg122
METHODTBApplyKey( oGet, oTB, nKey, oMenu, aMsg )
   METHOD TBApplyKey( oGet, oTB, nKey, oMenu, aMsg )
tgetlist.prg123
METHODTBReader( oGet, oMenu, aMsg )
   METHOD TBReader( oGet, oMenu, aMsg )
tgetlist.prg124
METHODAccelerator( nKey, aMsg )
   METHOD Accelerator( nKey, aMsg )
tgetlist.prg125
METHODhitTest( nMRow, nMCol, aMsg )
   METHOD hitTest( nMRow, nMCol, aMsg )
tgetlist.prg126
METHODReadStats( nElement, xNewValue )
   METHOD ReadStats( nElement, xNewValue )
tgetlist.prg128
METHODShowGetMsg( oGet, aMsg )
   METHOD ShowGetMsg( oGet, aMsg )
tgetlist.prg129
METHODEraseGetMsg( aMsg )
   METHOD EraseGetMsg( aMsg )
tgetlist.prg130
METHODNew( GetList )
   METHOD New( GetList )

   PROTECTED:

   VAR oGet
   VAR aGetList

   VAR lUpdated        AS LOGICAL   INIT .F.
   VAR bFormat
   VAR lKillRead       AS LOGICAL   INIT .F.
   VAR lBumpTop        AS LOGICAL   INIT .F.
   VAR lBumpBot        AS LOGICAL   INIT .F.
   VAR nLastExitState               INIT 0
   VAR nLastPos        AS NUMERIC   INIT 0
   VAR oActiveGet
   VAR xReadVar
   VAR cVarName
   VAR cReadProcName   AS CHARACTER INIT ""
   VAR nReadProcLine                INIT 0
   VAR nNextGet                     INIT 0
   VAR nHitCode        AS NUMERIC   INIT 0
   VAR nPos            AS NUMERIC   INIT 1
   VAR cMsgSaveS
   VAR nMenuID
   VAR nSaveCursor

ENDCLASS
tgetlist.prg132
HBGETLIST:METHODReadModal( nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor ) CLASS HBGetList
METHOD ReadModal( nPos, oMenu, nMsgRow, nMsgLeft, nMsgRight, cMsgColor ) CLASS HBGetList
tgetlist.prg163
HBGETLIST:METHODReadModal() CLASS HBGetList
METHOD ReadModal() CLASS HBGetList
#endif

#ifdef HB_COMPAT_C53
   LOCAL lMsgFlag
   LOCAL aMsg
#endif

#ifdef HB_COMPAT_C53
   ::nSaveCursor   := SetCursor( SC_NONE )
#endif
   ::cReadProcName := ProcName( 2 )
   ::nReadProcLine := ProcLine( 2 )

#ifdef HB_COMPAT_C53
   ::nPos := ::Settle( iif( ISNUMBER( nPos ), nPos, 0 ), .T. )

   IF ( lMsgFlag := ISNUMBER( nMsgRow ) .AND. ;
                    ISNUMBER( nMsgLeft ) .AND. ;
                    ISNUMBER( nMsgRight ) )

      IF !ISCHARACTER( cMsgColor )
         cMsgColor := GetClrPair( SetColor(), 1 )
      ENDIF

      Scroll( nMsgRow, nMsgLeft, nMsgRow, nMsgRight )

      ::cMsgSaveS := SaveScreen( nMsgRow, nMsgLeft, nMsgRow, nMsgRight )
   ENDIF

   ::nNextGet := 0
   ::nHitCode := 0
   ::nMenuID := 0

   aMsg := { lMsgFlag, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, , , , , }
#else
   ::nPos := ::Settle( 0 )
#endif

   DO WHILE ::nPos != 0

      ::oGet := ::aGetList[ ::nPos ]
      ::PostActiveGet()

#ifdef HB_COMPAT_C53
      IF ISBLOCK( ::oGet:reader )
         Eval( ::oGet:reader, ::oGet, Self, oMenu, aMsg )
      ELSE
         ::Reader( oMenu, aMsg )
      ENDIF
#else
      IF ISBLOCK( ::oGet:reader )
         Eval( ::oGet:reader, ::oGet )
      ELSE
         ::Reader()
      ENDIF
#endif

      ::nPos := ::Settle( ::nPos )

   ENDDO

#ifdef HB_COMPAT_C53
   IF lMsgFlag
      RestScreen( nMsgRow, nMsgLeft, nMsgRow, nMsgRight, ::cMsgSaveS )
   ENDIF

   SetCursor( ::nSaveCursor )
#endif

   RETURN Self
tgetlist.prg165
HBGETLIST:METHODUpdated() CLASS HBGetList
METHOD Updated() CLASS HBGetList
   RETURN ::lUpdated
tgetlist.prg237
HBGETLIST:METHODGet() CLASS HBGetList
METHOD Get() CLASS HBGetList
   RETURN ::oGet
tgetlist.prg240
HBGETLIST:METHODSetFocus() CLASS HBGetList
METHOD SetFocus() CLASS HBGetList

   __GetListSetActive( Self )
   __GetListLast( Self )
   ::aGetList[ ::nPos ]:setFocus()

   RETURN Self
tgetlist.prg243
HBGETLIST:METHODReader( oMenu, aMsg ) CLASS HBGetList
METHOD Reader( oMenu, aMsg ) CLASS HBGetList

   LOCAL oGet := ::oGet
   LOCAL nRow
   LOCAL nCol
#ifdef HB_COMPAT_C53
   LOCAL nOldCursor
   LOCAL nKey
#endif

#ifdef HB_COMPAT_C53
   IF ::nLastExitState == GE_SHORTCUT .OR.;
      ::nLastExitState == GE_MOUSEHIT .OR.;
      ::GetPreValidate( oGet, aMsg )
#else
   IF ::GetPreValidate( oGet, aMsg )
#endif

      ::ShowGetMsg( oGet, aMsg )

      ::nHitCode := 0
      ::nLastExitState := 0
      oGet:setFocus()

      DO WHILE oGet:exitState == GE_NOEXIT .AND. !::lKillRead
         IF oGet:typeOut
            oGet:exitState := GE_ENTER
         ENDIF

//       IF oGet:buffer == NIL
//          oGet:exitState := GE_ENTER
//       ENDIF

         DO WHILE oGet:exitState == GE_NOEXIT .AND. !::lKillRead
#ifdef HB_COMPAT_C53
            SetCursor( iif( ::nSaveCursor == SC_NONE, SC_NORMAL, ::nSaveCursor ) )
            nKey := Inkey( 0 )
            SetCursor( SC_NONE )
            ::GetApplyKey( nKey, oGet, oMenu, aMsg )
#else
            ::GetApplyKey( Inkey( 0 ), oGet, oMenu, aMsg )
#endif
            nRow := Row()
            nCol := Col()
            ::ShowGetMsg( oGet, aMsg )
            SetPos( nRow, nCol )
         ENDDO

#ifdef HB_COMPAT_C53
         IF !::nLastExitState == GE_SHORTCUT .AND. ;
            !::nLastExitState == GE_MOUSEHIT .AND. ;
            !::GetPostValidate( oGet, aMsg )
#else
         IF !::GetPostValidate( oGet, aMsg )
#endif
            oGet:exitState := GE_NOEXIT
         ENDIF
      ENDDO

#ifdef HB_COMPAT_C53
      nRow := Row()
      nCol := Col()
      nOldCursor := SetCursor()
#endif
      oGet:killFocus()
#ifdef HB_COMPAT_C53
      SetCursor( nOldCursor )
      SetPos( nRow, nCol )
#endif

      ::EraseGetMsg( aMsg )
   ENDIF

   RETURN Self
tgetlist.prg251
HBGETLIST:METHODGetApplyKey( nKey, oGet, oMenu, aMsg ) CLASS HBGetList
METHOD GetApplyKey( nKey, oGet, oMenu, aMsg ) CLASS HBGetList

   LOCAL cKey
   LOCAL bKeyBlock
   LOCAL lSetKey

#ifdef HB_COMPAT_C53
   LOCAL nMRow
   LOCAL nMCol
   LOCAL nButton
   LOCAL nHotItem
#endif

   DEFAULT oGet TO ::oGet

   IF ( bKeyBlock := SetKey( nKey ) ) != NIL
      IF ( lSetKey := ::GetDoSetKey( bKeyBlock, oGet ) )
         RETURN Self
      ENDIF
   ENDIF

#ifdef HB_COMPAT_C53
   IF ::aGetList != NIL .AND. ( nHotItem := ::Accelerator( nKey, aMsg ) ) != 0

      oGet:exitState := GE_SHORTCUT
      ::nNextGet := nHotItem
      ::nLastExitState := GE_SHORTCUT
   ELSEIF !ISOBJECT( oMenu )
   ELSEIF ( nHotItem := oMenu:getAccel( nKey ) ) != 0
      ::nMenuID := MenuModal( oMenu, nHotItem, aMsg[ MSGROW ], aMsg[ MSGLEFT ], aMsg[ MSGRIGHT ], aMsg[ MSGCOLOR ] )
      nKey := 0
   ELSEIF IsShortCut( oMenu, nKey )
      nKey := 0
   ENDIF
#else
   HB_SYMBOL_UNUSED( oMenu )
   HB_SYMBOL_UNUSED( aMsg )
#endif

   DO CASE
   CASE nKey == K_UP
      oGet:exitState := GE_UP
   
   CASE nKey == K_SH_TAB
      oGet:exitState := GE_UP
   
   CASE nKey == K_DOWN
      oGet:exitState := GE_DOWN
   
   CASE nKey == K_TAB
      oGet:exitState := GE_DOWN
   
   CASE nKey == K_ENTER
      oGet:exitState := GE_ENTER

   CASE nKey == K_ESC
      IF Set( _SET_ESCAPE )
         oGet:undo()
         oGet:exitState := GE_ESCAPE
      ENDIF

   CASE nKey == K_PGUP
      oGet:exitState := GE_WRITE

   CASE nKey == K_PGDN
      oGet:exitState := GE_WRITE

   CASE nKey == K_CTRL_HOME
      oGet:exitState := GE_TOP

#ifdef CTRL_END_SPECIAL
   CASE nKey == K_CTRL_END
      oGet:exitState := GE_BOTTOM
#else
   CASE nKey == K_CTRL_W
      oGet:exitState := GE_WRITE
#endif

#ifdef HB_COMPAT_C53
   CASE nKey == K_LBUTTONDOWN .OR. nKey == K_LDBLCLK

      nMRow := MRow()
      nMCol := MCol()

      IF !ISOBJECT( oMenu )
         nButton := 0
      ELSEIF !( oMenu:ClassName() == "TOPBARMENU" )
         nButton := 0
      ELSEIF ( nButton := oMenu:hitTest( nMRow, nMCol ) ) != 0
         ::nMenuID := MenuModal( oMenu, nHotItem, aMsg[ MSGROW ], aMsg[ MSGLEFT ], aMsg[ MSGRIGHT ], aMsg[ MSGCOLOR ] )
         nButton := 1
      ENDIF

      IF nButton != 0
      ELSEIF ( nButton := oGet:hitTest( nMRow, nMCol ) ) == HTCLIENT

         DO WHILE oGet:col + oGet:pos - 1 > nMCol
            oGet:left()

            // Handle editing buffer if first character is non-editable:
            IF oGet:typeOut
               // reset typeout:
               oGet:home()
               EXIT
            ENDIF

         ENDDO

         DO WHILE oGet:col + oGet:pos - 1 < nMCol
            oGet:right()

            // Handle editing buffer if last character is non-editable:
            IF oGet:typeOut
               // reset typeout:
               oGet:end()
               EXIT
            ENDIF

         ENDDO

      ELSEIF nButton != HTNOWHERE
      ELSEIF ::aGetList != NIL .AND. ::hitTest( nMRow, nMCol, aMsg ) != 0
         oGet:exitState := GE_MOUSEHIT
         ::nLastExitState := GE_MOUSEHIT
      ELSE
         oGet:exitState := GE_NOEXIT
      ENDIF
#endif

   CASE nKey == K_UNDO
      oGet:undo()

   CASE nKey == K_HOME
      oGet:home()

   CASE nKey == K_END
      oGet:end()

   CASE nKey == K_RIGHT
      oGet:right()

   CASE nKey == K_LEFT
      oGet:left()

   CASE nKey == K_CTRL_RIGHT
      oGet:wordRight()

   CASE nKey == K_CTRL_LEFT
      oGet:wordLeft()

   CASE nKey == K_BS
      oGet:backSpace()

   CASE nKey == K_DEL
      oGet:delete()

   CASE nKey == K_CTRL_T
      oGet:delWordRight()

   CASE nKey == K_CTRL_Y
      oGet:delEnd()

   CASE nKey == K_CTRL_BS
      oGet:delWordLeft()

   CASE nKey == K_INS
      Set( _SET_INSERT, ! Set( _SET_INSERT ) )
      ::ShowScoreboard()

   OTHERWISE

      IF nKey >= 32 .AND. nKey <= 255
         cKey := Chr( nKey )

         IF oGet:type == "N" .AND. ( cKey == "." .OR. cKey == "," )
            oGet:toDecPos()
         ELSE
            IF Set( _SET_INSERT )
               oGet:insert( cKey )
            ELSE
               oGet:overStrike( cKey )
            ENDIF

            IF oGet:typeOut
               IF Set( _SET_BELL )
                  ?? Chr( 7 )
               ENDIF
               IF ! Set( _SET_CONFIRM )
                  oGet:exitState := GE_ENTER
               ENDIF
            ENDIF
         ENDIF
      ENDIF
   ENDCASE

   RETURN Self
tgetlist.prg326
HBGETLIST:METHODGetPreValidate( oGet, aMsg ) CLASS HBGetList
METHOD GetPreValidate( oGet, aMsg ) CLASS HBGetList

   LOCAL lUpdated
   LOCAL lWhen := .T.

   DEFAULT oGet TO ::oGet

   IF oGet:preBlock != NIL

      lUpdated  := ::lUpdated

      lWhen := Eval( oGet:preBlock, oGet, aMsg )

      IF ! ISOBJECT( oGet:control ) .AND. ! lWhen
         oGet:display()
      ENDIF

      ::ShowScoreBoard()

      ::lUpdated := lUpdated

      __GetListLast( Self )
   ENDIF

   IF ::lKillRead
      lWhen := .F.
      oGet:exitState := GE_ESCAPE
   ELSEIF ! lWhen
      oGet:exitState := GE_WHEN
   ELSE
      oGet:exitState := GE_NOEXIT
   ENDIF

   RETURN lWhen
tgetlist.prg523
HBGETLIST:METHODGetPostValidate( oGet, aMsg ) CLASS HBGetList
METHOD GetPostValidate( oGet, aMsg ) CLASS HBGetList

   LOCAL lUpdated
   LOCAL lValid := .T.
#ifdef HB_COMPAT_C53
   LOCAL nOldCursor
#endif

   DEFAULT oGet TO ::oGet

   IF oGet:exitState == GE_ESCAPE
      RETURN .T.
   ENDIF

   IF oGet:badDate
      oGet:home()
      ::DateMsg()
      ::ShowScoreboard()
      RETURN .F.
   ENDIF

   IF oGet:changed
      oGet:assign()
      ::lUpdated := .T.
   ENDIF

#ifdef HB_COMPAT_C53
   nOldCursor := SetCursor()
#endif
   oGet:reset()
#ifdef HB_COMPAT_C53
   SetCursor( nOldCursor )
#endif

   IF oGet:postBlock != NIL

      lUpdated := ::lUpdated

      IF ISCHARACTER( oGet:buffer )
         SetPos( oGet:row, oGet:col + Len( oGet:buffer ) )
      ENDIF
      lValid := Eval( oGet:postBlock, oGet, aMsg )
      SetPos( oGet:row, oGet:col )

      ::ShowScoreBoard()
      oGet:updateBuffer()
      
#ifdef HB_COMPAT_C53
      ::lUpdated := iif( oGet:changed, .T., lUpdated )
#else
      ::lUpdated := lUpdated
#endif

      __GetListLast( Self )

      IF ::lKillRead
         oGet:exitState := GE_ESCAPE
         lValid := .T.
      ENDIF
   ENDIF

   RETURN lValid
tgetlist.prg558
HBGETLIST:METHODGetDoSetKey( bKeyBlock, oGet ) CLASS HBGetList
METHOD GetDoSetKey( bKeyBlock, oGet ) CLASS HBGetList

   LOCAL lUpdated
   LOCAL lSetKey

   DEFAULT oGet TO ::oGet

   IF oGet:changed
      oGet:assign()
      ::lUpdated := .T.
   ENDIF

   lUpdated := ::lUpdated

   lSetKey := Eval( bKeyBlock, ::cReadProcName, ::nReadProcLine, ::ReadVar() )

   IF !ISLOGICAL( lSetKey )
      lSetKey := .T.
   ENDIF

   ::ShowScoreboard()
   oGet:updateBuffer()

   ::lUpdated := lUpdated

   __GetListLast( Self )

   IF ::lKillRead
      oGet:exitState := GE_ESCAPE
   ENDIF

   RETURN lSetKey
tgetlist.prg621
HBGETLIST:METHODSettle( nPos, lInit ) CLASS HBGetList
METHOD Settle( nPos, lInit ) CLASS HBGetList

   LOCAL nExitState

   DEFAULT nPos  TO ::nPos
   DEFAULT lInit TO .F.

   IF nPos == 0
      nExitState := GE_DOWN
   ELSEIF nPos > 0 .AND. lInit /* NOTE: Never .T. in C5.2 mode. */
      nExitState := GE_NOEXIT
   ELSE
      nExitState := ::aGetList[ nPos ]:exitState
   ENDIF

   IF nExitState == GE_ESCAPE .OR. nExitState == GE_WRITE
      RETURN 0
   ENDIF

   IF nExitState != GE_WHEN
      ::nLastPos := nPos
      ::lBumpTop := .F.
      ::lBumpBot := .F.
   ELSE
      IF ::nLastExitState != 0
         nExitState := ::nLastExitState
      ELSEIF ::nNextGet < ::nLastPos 
         nExitState := GE_UP
      ELSE
         nExitState := GE_DOWN
      ENDIF

   ENDIF

   DO CASE
   CASE nExitState == GE_UP
      nPos--

   CASE nExitState == GE_DOWN
      nPos++

   CASE nExitState == GE_TOP
      nPos := 1
      ::lBumpTop := .T.
      nExitState := GE_DOWN

   CASE nExitState == GE_BOTTOM
      nPos := Len( ::aGetList )
      ::lBumpBot := .T.
      nExitState := GE_UP

   CASE nExitState == GE_ENTER
      nPos++

   CASE nExitState == GE_SHORTCUT 
      RETURN ::nNextGet

   CASE nExitState == GE_MOUSEHIT
      RETURN ::nNextGet

   ENDCASE

   IF nPos == 0
      IF ! Set( _SET_EXIT ) .AND. ! ::lBumpBot
         ::lBumpTop := .T.
         nPos       := ::nLastPos
         nExitState := GE_DOWN
      ENDIF

   ELSEIF nPos == Len( ::aGetList ) + 1
      IF ! Set( _SET_EXIT ) .AND. nExitState != GE_ENTER .AND. ! ::lBumpTop
         ::lBumpBot := .T.
         nPos       := ::nLastPos
         nExitState := GE_UP
      ELSE
         nPos := 0
      ENDIF
   ENDIF

   ::nLastExitState := nExitState

   IF nPos != 0
      ::aGetList[ nPos ]:exitState := nExitState
   ENDIF

   RETURN nPos
tgetlist.prg654
HBGETLIST:METHODPostActiveGet() CLASS HBGetList
METHOD PostActiveGet() CLASS HBGetList

   ::GetActive( ::oGet )
   ::ReadVar( ::GetReadVar() )
   ::ShowScoreBoard()

   RETURN Self
tgetlist.prg741
HBGETLIST:METHODGetReadVar() CLASS HBGetList
METHOD GetReadVar() CLASS HBGetList

   LOCAL oGet := ::oGet
   LOCAL cName := Upper( oGet:Name )
   LOCAL n

   IF oGet:Subscript != NIL
      FOR n := 1 TO Len( oGet:Subscript )
         cName += "[" + LTrim( Str( oGet:Subscript[ n ] ) ) + "]"
      NEXT
   ENDIF

   RETURN cName
tgetlist.prg749
HBGETLIST:METHODSetFormat( bFormat ) CLASS HBGetList
METHOD SetFormat( bFormat ) CLASS HBGetList

   LOCAL bSavFormat := ::bFormat

   IF ISBLOCK( bFormat )
      ::bFormat := bFormat
   ENDIF

   RETURN bSavFormat
tgetlist.prg763
HBGETLIST:METHODKillRead( lKill ) CLASS HBGetList
METHOD KillRead( lKill ) CLASS HBGetList

   LOCAL lSavKill := ::lKillRead

   IF PCount() > 0
      ::lKillRead := lKill
   ENDIF

   RETURN lSavKill
tgetlist.prg773
HBGETLIST:METHODGetActive( oGet ) CLASS HBGetList
METHOD GetActive( oGet ) CLASS HBGetList

   LOCAL oOldGet := ::oActiveGet

   IF PCount() > 0
      ::oActiveGet := oGet
   ENDIF

   RETURN oOldGet
tgetlist.prg783
HBGETLIST:METHODShowScoreboard() CLASS HBGetList
METHOD ShowScoreboard() CLASS HBGetList

   LOCAL nRow
   LOCAL nCol
   LOCAL nOldCursor

   IF Set( _SET_SCOREBOARD )

      nRow := Row()
      nCol := Col()

      nOldCursor := SetCursor( SC_NONE )

      DispOutAt( SCORE_ROW, SCORE_COL, iif( Set( _SET_INSERT ), __NatMsg( _GET_INSERT_ON ), __NatMsg( _GET_INSERT_OFF ) ) )
      SetPos( nRow, nCol )

      SetCursor( nOldCursor )

   ENDIF

   RETURN Self
tgetlist.prg793
HBGETLIST:METHODDateMsg() CLASS HBGetList
METHOD DateMsg() CLASS HBGetList

   LOCAL nRow
   LOCAL nCol

   IF Set( _SET_SCOREBOARD )

      nRow := Row()
      nCol := Col()

      DispOutAt( SCORE_ROW, SCORE_COL, __NatMsg( _GET_INVD_DATE ) )
      SetPos( nRow, nCol )

      DO WHILE NextKey() == 0
      ENDDO

      DispOutAt( SCORE_ROW, SCORE_COL, Space( Len( __NatMsg( _GET_INVD_DATE ) ) ) )
      SetPos( nRow, nCol )

   ENDIF

   RETURN Self
tgetlist.prg815
HBGETLIST:METHODReadVar( cNewVarName ) CLASS HBGetList
METHOD ReadVar( cNewVarName ) CLASS HBGetList

   LOCAL cOldName := ::cVarName

   IF ISCHARACTER( cNewVarName )
      ::cVarName := cNewVarName
   ENDIF

   RETURN cOldName
tgetlist.prg838
HBGETLIST:METHODReadUpdated( lUpdated ) CLASS HBGetList
METHOD ReadUpdated( lUpdated ) CLASS HBGetList

   LOCAL lSavUpdated := ::lUpdated

   IF PCount() > 0
      ::lUpdated := lUpdated
   ENDIF

   RETURN lSavUpdated
tgetlist.prg848
HBGETLIST:METHODGUIReader( oGet, oMenu, aMsg ) CLASS HBGetList
METHOD GUIReader( oGet, oMenu, aMsg ) CLASS HBGetList

   LOCAL oGUI

   IF ISOBJECT( oGet:control ) .AND. ;
      ::nLastExitState == GE_SHORTCUT .OR. ;
      ::nLastExitState == GE_MOUSEHIT .OR. ;
      ::GetPreValidate( oGet, aMsg )

      ::ShowGetMsg( oGet, aMsg )

      ::nLastExitState := 0

      // Activate the GET for reading
      oGUI := oGet:control
      oGUI:Select( oGet:varGet() )
      oGUI:setFocus()

      IF oGet:exitState == GE_NOEXIT  // Added.
         IF ::nHitCode > 0
            oGUI:Select( ::nHitCode )
         ELSEIF ::nHitCode == HTCAPTION
            oGUI:Select()
         ELSEIF ::nHitCode == HTCLIENT
            oGUI:Select( K_LBUTTONDOWN )
         ELSEIF ::nHitCode == HTDROPBUTTON
            oGUI:Open()
         ELSEIF ::nHitCode >= HTSCROLLFIRST .AND. ;
                ::nHitCode <= HTSCROLLLAST
            oGUI:Scroll( ::nHitCode )
         ENDIF
      ENDIF

      ::nHitCode := 0

      DO WHILE oGet:exitState == GE_NOEXIT .AND. !::lKillRead

         // Check for initial typeout (no editable positions)
         IF oGUI:typeOut
            oGet:exitState := GE_ENTER
         ENDIF

         // Apply keystrokes until exit
         DO WHILE oGet:exitState == GE_NOEXIT .AND. !::lKillRead
            ::GUIApplyKey( oGet, oGUI, Inkey( 0 ), oMenu, aMsg )

            ::ShowGetMsg( oGet, aMsg )
         ENDDO

         IF ::nLastExitState != GE_SHORTCUT .AND. ;
            ::nLastExitState != GE_MOUSEHIT .AND. ;
            !::GetPostValidate( oGet, aMsg )
            oGet:exitState := GE_NOEXIT
         ENDIF
      ENDDO

      // De-activate the GET
      IF oGUI:ClassName() $ "LISTBOX|RADIOGROUP" .AND. ISNUMBER( oGet:varGet() )
         oGet:varPut( oGUI:value )
      ELSE
         oGet:varPut( oGUI:buffer )
      ENDIF
      oGUI:killFocus()

      ::EraseGetMsg( aMsg )

      IF oGUI:ClassName() == "LISTBOX" .AND. ;
         oGUI:dropDown .AND. ;
         oGUI:isOpen 

         oGUI:Close()
      ENDIF

   ENDIF

   RETURN Self
tgetlist.prg860
HBGETLIST:METHODGUIApplyKey( oGet, oGUI, nKey, oMenu, aMsg ) CLASS HBGetList
METHOD GUIApplyKey( oGet, oGUI, nKey, oMenu, aMsg ) CLASS HBGetList

   LOCAL bKeyBlock
   LOCAL oTheClass
   LOCAL nHotItem
   LOCAL lClose
   LOCAL nMRow
   LOCAL nMCol
   LOCAL nButton
   LOCAL lSetKey

   // Check for SET KEY first
   IF ( bKeyBlock := SetKey( nKey ) ) != NIL
      IF ( lSetKey := ::GetDoSetKey( bKeyBlock, oGet ) )
         RETURN Self
      ENDIF
   ENDIF

   IF ( nHotItem := ::Accelerator( nKey, aMsg ) ) != 0
      oGet:exitState := GE_SHORTCUT
      ::nNextGet := nHotItem
   ELSEIF !ISOBJECT( oMenu )
   ELSEIF ( nHotItem := oMenu:getAccel( nKey ) ) != 0
      ::nMenuID := MenuModal( oMenu, nHotItem, aMsg[ MSGROW ], aMsg[ MSGLEFT ], aMsg[ MSGRIGHT ], aMsg[ MSGCOLOR ] )
      nKey := 0
   ELSEIF IsShortCut( oMenu, nKey )
      nKey := 0
   ENDIF

   IF nKey == 0
   ELSEIF ( oTheClass := oGUI:ClassName() ) == "RADIOGROUP"
      IF nKey == K_UP
         oGUI:PrevItem()
         nKey := 0

      ELSEIF nKey == K_DOWN
         oGUI:NextItem()
         nKey := 0

      ELSEIF ( nHotItem := oGUI:getAccel( nKey ) ) != 0
         oGUI:Select( nHotItem )

      ENDIF

      IF ISNUMBER( oGet:varGet() )
         oGet:varPut( oGUI:Value )
      ENDIF

   ELSEIF oTheClass == "CHECKBOX"
      IF nKey == K_SPACE
         oGUI:Select()
      ENDIF

   ELSEIF oTheClass == "PUSHBUTTON"
      IF nKey == K_SPACE
         oGUI:Select( K_SPACE )

      ELSEIF nKey == K_ENTER
         oGUI:Select()
         nKey := 0

      ENDIF

   ELSEIF oTheClass == "LISTBOX"
      IF nKey == K_UP
         oGUI:PrevItem()
         nKey := 0

      ELSEIF nKey == K_DOWN
         oGUI:NextItem()
         nKey := 0

      ELSEIF nKey == K_SPACE
         IF ! oGUI:DropDown
         ELSEIF ! oGUI:IsOpen
            oGUI:Open()
            nKey := 0
         ENDIF

      ELSEIF ( nButton := oGUI:FindText( chr(nKey), oGUI:Value + 1, .F., .F. ) ) != 0
         oGUI:Select( nButton )

      ENDIF

      IF ISNUMBER( oGet:varGet() )
         oGet:varPut( oGUI:Value )
      ENDIF

   ENDIF

   DO CASE
   CASE nKey == K_UP
      oGet:exitState := GE_UP

   CASE nKey == K_SH_TAB
      oGet:exitState := GE_UP

   CASE nKey == K_DOWN
      oGet:exitState := GE_DOWN

   CASE nKey == K_TAB
      oGet:exitState := GE_DOWN

   CASE nKey == K_ENTER
      oGet:exitState := GE_ENTER

   CASE nKey == K_ESC
      IF Set( _SET_ESCAPE )
         oGet:exitState := GE_ESCAPE
      ENDIF

   CASE nKey == K_PGUP
      oGet:exitState := GE_WRITE

   CASE nKey == K_PGDN
      oGet:exitState := GE_WRITE

   CASE nKey == K_CTRL_HOME
      oGet:exitState := GE_TOP


#ifdef CTRL_END_SPECIAL

   // Both ^W and ^End go to the last GET
   CASE nKey == K_CTRL_END
      oGet:exitState := GE_BOTTOM

#else

   // Both ^W and ^End terminate the READ (the default)
   CASE nKey == K_CTRL_W
      oGet:exitState := GE_WRITE

#endif

   CASE nKey == K_LBUTTONDOWN .OR. nKey == K_LDBLCLK

      nMRow := MRow()
      nMCol := MCol()

      IF !ISOBJECT( oMenu )
         nButton := 0
      ELSEIF !( oMenu:ClassName() == "TOPBARMENU" )
         nButton := 0
      ELSEIF ( nButton := oMenu:hitTest( nMRow, nMCol ) ) != 0
         ::nMenuID := MenuModal( oMenu, nHotItem, aMsg[ MSGROW ], aMsg[ MSGLEFT ], aMsg[ MSGRIGHT ], aMsg[ MSGCOLOR ] )
         nButton := 1
      ENDIF

      lClose := .T.

      IF nButton != 0
      ELSEIF ( nButton := oGUI:hitTest( nMRow, nMCol ) ) == HTNOWHERE
         IF ::HitTest( nMRow, nMCol, aMsg ) != 0
            oGet:exitState := GE_MOUSEHIT
            ::nLastExitState := GE_MOUSEHIT
         ELSE
            oGet:exitState := GE_NOEXIT
         ENDIF

      ELSEIF nButton >= HTCLIENT
         oGUI:Select( nButton )

      ELSEIF nButton == HTDROPBUTTON
         IF !oGUI:IsOpen
            oGUI:Open()
            lClose := .F.
         ENDIF

      ELSEIF nButton >= HTSCROLLFIRST .AND. nButton <= HTSCROLLLAST
         oGUI:Scroll( nButton )
         lClose := .F.

      ENDIF

      IF ! lClose
      ELSEIF ! oTheClass == "LISTBOX"
      ELSEIF ! oGUI:DropDown
      ELSEIF oGUI:IsOpen
         oGUI:Close()
         oGUI:Display()
      ENDIF

   ENDCASE

   RETURN Self
tgetlist.prg937
HBGETLIST:METHODGUIPreValidate( oGet, oGUI, aMsg ) CLASS HBGetList
METHOD GUIPreValidate( oGet, oGUI, aMsg ) CLASS HBGetList

   LOCAL lUpdated
   LOCAL lWhen := .T.

   DEFAULT oGet TO ::oGet

   IF oGet:preBlock != NIL

      lUpdated := ::lUpdated

      lWhen := Eval( oGet:preBlock, oGet, aMsg )

      IF !( oGUI:ClassName() == "TBROWSE" )
         oGet:display()
      ENDIF

      ::ShowScoreBoard()
      ::lUpdated := lUpdated

      __GetListLast( Self )
   ENDIF

   IF ::lKillRead
      lWhen := .F.
      oGet:exitState := GE_ESCAPE
   ELSEIF !lWhen
      oGet:exitState := GE_WHEN
   ELSE
      oGet:exitState := GE_NOEXIT
   ENDIF

   RETURN lWhen
tgetlist.prg1124
HBGETLIST:METHODGUIPostValidate( oGet, oGUI, aMsg ) CLASS HBGetList
METHOD GUIPostValidate( oGet, oGUI, aMsg ) CLASS HBGetList

   LOCAL lUpdated
   LOCAL lValid := .T.
   LOCAL xOldValue
   LOCAL xNewValue

   DEFAULT oGet TO ::oGet

   IF oGet:exitState == GE_ESCAPE
      RETURN .T.                   // NOTE
   ENDIF

   IF !( oGUI:ClassName() == "TBROWSE" )
      xOldValue := oGet:varGet()
      IF oGUI:ClassName() $ "LISTBOX|RADIOGROUP" .AND. ISNUMBER( oGet:varGet() )
         xNewValue := oGUI:Value
      ELSE
         xNewValue := oGUI:Buffer
      ENDIF
   ENDIF

   IF !( xOldValue == xNewValue )
      oGet:varPut( xNewValue )
      ::lUpdated := .T.
   ENDIF

   // Check VALID condition if specified
   IF oGet:postBlock != NIL

      lUpdated := ::lUpdated

      lValid := Eval( oGet:postBlock, oGet, aMsg )

      // Reset S'87 compatibility cursor position
      SetPos( oGet:row, oGet:col )

      ::ShowScoreBoard()
      IF ! ( oGUI:ClassName == "TBROWSE" )
         oGUI:Select( oGet:varGet() )
      ENDIF

      ::lUpdated := lUpdated

      __GetListLast( Self )

      IF ::lKillRead
         oGet:exitState := GE_ESCAPE      // Provokes ReadModal() exit
         lValid := .T.
      ENDIF

   ENDIF

   RETURN lValid 
tgetlist.prg1158
HBGETLIST:METHODTBApplyKey( oGet, oTB, nKey, oMenu, aMsg ) CLASS HBGetList
METHOD TBApplyKey( oGet, oTB, nKey, oMenu, aMsg ) CLASS HBGetList

   LOCAL bKeyBlock
   LOCAL nMRow
   LOCAL nMCol
   LOCAL nButton
   LOCAL nHotItem
   LOCAL lSetKey

   // Check for SET KEY first
   IF ( bKeyBlock := SetKey( nKey ) ) != NIL
      IF ( lSetKey := ::GetDoSetKey( bKeyBlock, oGet ) )
         RETURN Self
      ENDIF
   ENDIF

   IF ( nHotItem := ::Accelerator( nKey, aMsg ) ) != 0
      oGet:exitState := GE_SHORTCUT
      ::nNextGet := nHotItem
   ELSEIF !ISOBJECT( oMenu )
   ELSEIF ( nHotItem := oMenu:getAccel( nKey ) ) != 0
      ::nMenuID := MenuModal( oMenu, nHotItem, aMsg[ MSGROW ], aMsg[ MSGLEFT ], aMsg[ MSGRIGHT ], aMsg[ MSGCOLOR ] )
      nKey := 0
   ELSEIF IsShortCut( oMenu, nKey )
      nKey := 0
   ENDIF

   DO CASE
   CASE nKey == K_TAB 
      oGet:exitState := GE_DOWN

   CASE nKey == K_SH_TAB
      oGet:exitState := GE_UP

   CASE nKey == K_ENTER
#ifndef HB_C52_STRICT
      IF !oTb:Stable()
         oTb:ForceStable()
      ENDIF
#endif
      oGet:exitState := GE_ENTER

   CASE nKey == K_ESC 
      IF Set( _SET_ESCAPE )
         oGet:exitState := GE_ESCAPE
      ENDIF

#ifdef CTRL_END_SPECIAL

   // Both ^W and ^End go to the last GET
   CASE nKey == K_CTRL_END
      oGet:exitState := GE_BOTTOM

#else

   // Both ^W and ^End terminate the READ (the default)
   CASE nKey == K_CTRL_W
      oGet:exitState := GE_WRITE

#endif

   CASE nKey == K_LBUTTONDOWN .OR. nKey == K_LDBLCLK

      nMRow := MRow()
      nMCol := MCol()

      IF !ISOBJECT( oMenu )
         nButton := 0
      ELSEIF !( oMenu:ClassName() == "TOPBARMENU" )
         nButton := 0
      ELSEIF ( nButton := oMenu:hitTest( nMRow, nMCol ) ) != 0
         ::nMenuID := MenuModal( oMenu, nHotItem, aMsg[ MSGROW ], aMsg[ MSGLEFT ], aMsg[ MSGRIGHT ], aMsg[ MSGCOLOR ] )
         nButton := 1
      ENDIF

      IF nButton != 0
      ELSEIF ( nButton := oTB:hitTest( nMRow, nMCol ) ) == HTNOWHERE
         IF ::hitTest( nMRow, nMCol, aMsg ) != 0
            oGet:exitState := GE_MOUSEHIT
            ::nLastExitState := GE_MOUSEHIT
         ELSE
            oGet:exitState := GE_NOEXIT
         ENDIF
      ENDIF

   ENDCASE

   RETURN Self
tgetlist.prg1213
HBGETLIST:METHODTBReader( oGet, oMenu, aMsg ) CLASS HBGetList
METHOD TBReader( oGet, oMenu, aMsg ) CLASS HBGetList

   LOCAL oTB
   LOCAL nKey
   LOCAL lAutoLite
   LOCAL nSaveCursor
   LOCAL nProcessed
// LOCAL oGUI := oGet:control

   // Read the GET if the WHEN condition is satisfied
   IF ISOBJECT( oGet:control ) .AND. ;
      ::nLastExitState == GE_SHORTCUT .OR. ;
      ::nLastExitState == GE_MOUSEHIT .OR. ;
      ::GetPreValidate( oGet, aMsg )

      ::ShowGetMsg( oGet, aMsg )
      ::nLastExitState := 0

      nSaveCursor := SetCursor( SC_NONE )

      // Activate the GET for reading
      oTB := oGet:control

      lAutoLite := oTB:Autolite
      oTB:Autolite := .T.
      oTB:Hilite()

      IF oGet:exitState == GE_NOEXIT
         IF ::nHitcode == HTCELL
            // Replaces call to TBMouse( oTB, mROW(), mCOL() ):
            oTB:RowPos := oTb:mRowPos
            oTB:ColPos := oTb:mColPos
            oTB:Invalidate()
         ENDIF
      ENDIF

      ::nHitcode := 0

      DO WHILE oGet:exitState == GE_NOEXIT .AND. !::lKillRead

         // Apply keystrokes until exit
         DO WHILE oGet:exitState == GE_NOEXIT .AND. !::lKillRead
            nKey := 0

            DO WHILE !oTB:Stabilize() .AND. nKey == 0
               nKey := Inkey()
            ENDDO

            IF nKey == 0
               nKey := Inkey(0)
            ENDIF

            nProcessed := oTB:ApplyKey( nKey )
            IF nProcessed == TBR_EXIT
               oGet:exitState := GE_ESCAPE
               EXIT

            ELSEIF nProcessed == TBR_EXCEPTION
               ::TBApplyKey( oGet, oTB, nKey, oMenu, aMsg )

               ::ShowGetMsg( oGet, aMsg )

            ENDIF

         ENDDO

         // Disallow exit if the VALID condition is not satisfied
         IF ::nLastExitState == GE_SHORTCUT
         ELSEIF ::nLastExitState == GE_MOUSEHIT
         ELSEIF !::GetPostValidate( oGet, aMsg )
            oGet:exitState := GE_NOEXIT
         ENDIF

      ENDDO

      // De-activate the GET
      oTB:Autolite := lAutoLite
      oTB:DeHilite()

      ::EraseGetMsg( aMsg )

      SetCursor( nSaveCursor )
   ENDIF

   RETURN Self
tgetlist.prg1302
HBGETLIST:METHODAccelerator( nKey, aMsg ) CLASS HBGetList
METHOD Accelerator( nKey, aMsg ) CLASS HBGetList

   LOCAL nGet
   LOCAL oGet
   LOCAL nHotPos
   LOCAL cKey
   LOCAL cCaption
   LOCAL nStart
   LOCAL nEnd
   LOCAL nIteration
   LOCAL lGUI

   IF nKey >= K_ALT_Q .AND. nKey <= K_ALT_P
      cKey := SubStr( "qwertyuiop", nKey - K_ALT_Q + 1, 1 )

   ELSEIF nKey >= K_ALT_A .AND. nKey <= K_ALT_L
      cKey := SubStr( "asdfghjkl", nKey - K_ALT_A + 1, 1 )

   ELSEIF nKey >= K_ALT_Z .AND. nKey <= K_ALT_M
      cKey := SubStr( "zxcvbnm", nKey - K_ALT_Z + 1, 1 )

   ELSEIF nKey >= K_ALT_1 .AND. nKey <= K_ALT_0
      cKey := SubStr( "1234567890", nKey - K_ALT_1 + 1, 1 )

   ELSE
      RETURN 0

   ENDIF

   nStart := ::nPos + 1
   nEnd   := Len( ::aGetList )

   FOR nIteration := 1 TO 2
      FOR nGet := nStart TO nEnd

         oGet  := ::aGetList[ nGet ]

         IF ISOBJECT( oGet:control ) .AND. ;
            !( oGet:Control:ClassName() == "TBROWSE" )

            cCaption := oGet:control:caption
         ELSE
            cCaption := oGet:caption
         ENDIF

         IF ( nHotPos := At( "&", cCaption ) ) == 0
         ELSEIF nHotPos == Len( cCaption )
         ELSEIF Lower( SubStr( cCaption, nHotPos + 1, 1 ) ) == cKey

            // Test the current GUI-GET or Get PostValidation:
            lGUI := ISOBJECT( ::aGetList[ ::nPos ]:control )

            IF lGUI .AND. !::GUIPostValidate( ::aGetList[ ::nPos ], ::aGetList[ ::nPos ]:control, aMsg )
               RETURN 0

            ELSEIF !lGUI .AND. !::GetPostValidate( ::aGetList[ ::nPos ], aMsg )
               RETURN 0

            ENDIF
      
            // Test the next GUI-GET or Get PreValidation:
            lGUI := ISOBJECT( oGet:control )

            IF lGUI .AND. !::GUIPreValidate( oGet, oGet:control, aMsg )
               // RETURN 0  // Commented out.
               RETURN nGet  // Changed.

            ELSEIF !lGUI .AND. !::GetPreValidate( oGet, aMsg )
               // RETURN 0  // Commented out.
               RETURN nGet  // Changed.

            ENDIF

            RETURN nGet
         ENDIF
      NEXT

      nStart := 1
      nEnd   := ::nPos - 1
   NEXT

   RETURN 0
tgetlist.prg1388
HBGETLIST:METHODHitTest( nMRow, nMCol, aMsg ) CLASS HBGetList
METHOD HitTest( nMRow, nMCol, aMsg ) CLASS HBGetList

   LOCAL nCount
   LOCAL nTotal := Len( ::aGetList )
   LOCAL lGUI

   ::nNextGet := 0

   FOR nCount := 1 TO nTotal
      IF ( ::nHitCode := ::aGetList[ nCount ]:hitTest( nMRow, nMCol ) ) != HTNOWHERE
         ::nNextGet := nCount
         EXIT
      ENDIF
   NEXT

   // DO WHILE ::nNextGet != 0  // Commented out.

   IF ::nNextGet != 0  // Changed.

      // Test the current GUI-GET or Get PostValidation:
      lGUI := ISOBJECT( ::aGetList[ ::nPos ]:control )

      IF lGUI .AND. !::GUIPostValidate( ::aGetList[ ::nPos ], ::aGetList[ ::nPos ]:control, aMsg )

         ::nNextGet := 0
         // EXIT  // Commented out.
         RETURN 0  // Changed.

      ELSEIF !lGUI .AND. !::GetPostValidate( ::aGetList[ ::nPos ], aMsg )

         ::nNextGet := 0
         // EXIT  // Commented out.
         RETURN 0  // Changed.

      ENDIF
      
      // Test the next GUI-GET or Get PreValidation:
      lGUI := ISOBJECT( ::aGetList[ ::nNextGet ]:control )

      IF lGUI .AND. !::GUIPreValidate( ::aGetList[ ::nNextGet ], ::aGetList[ ::nNextGet ]:control, aMsg )

         ::nNextGet := 0
         // EXIT  // Commented out.
         RETURN ::nNextGet  // Changed.

      ELSEIF !lGUI .AND. !::GetPreValidate( ::aGetList[ ::nNextGet ], aMsg )

         ::nNextGet := 0
         // EXIT  // Commented out.
         RETURN ::nNextGet  // Changed.

      ENDIF

      // EXIT  // Commented out.
      RETURN ::nNextGet  // Changed.
   // ENDDO  // Commented out.

   ENDIF

   // RETURN ::nNextGet != 0  // Commented out.
   RETURN 0
tgetlist.prg1471
HBGETLIST:METHODReadStats( nElement, xNewValue ) CLASS HBGetList
METHOD ReadStats( nElement, xNewValue ) CLASS HBGetList
   LOCAL xRetVal

   DO CASE
   CASE nElement == SLUPDATED      ; xRetVal := ::lUpdated
   CASE nElement == SBFORMAT       ; xRetVal := ::bFormat
   CASE nElement == SLKILLREAD     ; xRetVal := ::lKillRead
   CASE nElement == SLBUMPTOP      ; xRetVal := ::lBumpTop
   CASE nElement == SLBUMPBOT      ; xRetVal := ::lBumpBot
   CASE nElement == SNLASTEXIT     ; xRetVal := ::nLastExitState
   CASE nElement == SNLASTPOS      ; xRetVal := ::nLastPos
   CASE nElement == SOACTIVEGET    ; xRetVal := ::oActiveGet
   CASE nElement == SXREADVAR      ; xRetVal := ::cVarName
   CASE nElement == SCREADPROCNAME ; xRetVal := ::cReadProcName
   CASE nElement == SNREADPROCLINE ; xRetVal := ::nReadProcLine
   CASE nElement == SNNEXTGET      ; xRetVal := ::nNextGet     
   CASE nElement == SNHITCODE      ; xRetVal := ::nHitCode     
   CASE nElement == SNPOS          ; xRetVal := ::nPos
   CASE nElement == SCSCRSVMSG     ; xRetVal := ::cMsgSaveS  
   CASE nElement == SNMENUID       ; xRetVal := ::nMenuID    
   CASE nElement == SNSVCURSOR     ; xRetVal := ::nSaveCursor
   OTHERWISE                       ; xRetVal := NIL
   ENDCASE

   IF PCount() > 1

      DO CASE
      CASE nElement == SLUPDATED      ; ::lUpdated       := xNewValue
      CASE nElement == SBFORMAT       ; ::bFormat        := xNewValue
      CASE nElement == SLKILLREAD     ; ::lKillRead      := xNewValue
      CASE nElement == SLBUMPTOP      ; ::lBumpTop       := xNewValue
      CASE nElement == SLBUMPBOT      ; ::lBumpBot       := xNewValue
      CASE nElement == SNLASTEXIT     ; ::nLastExitState := xNewValue
      CASE nElement == SNLASTPOS      ; ::nLastPos       := xNewValue
      CASE nElement == SOACTIVEGET    ; ::oActiveGet     := xNewValue
      CASE nElement == SXREADVAR      ; ::xReadVar       := xNewValue
      CASE nElement == SCREADPROCNAME ; ::cReadProcName  := xNewValue
      CASE nElement == SNREADPROCLINE ; ::nReadProcLine  := xNewValue
      CASE nElement == SNNEXTGET      ; ::nNextGet       := xNewValue
      CASE nElement == SNHITCODE      ; ::nHitCode       := xNewValue
      CASE nElement == SNPOS          ; ::nPos           := xNewValue
      CASE nElement == SCSCRSVMSG     ; ::cMsgSaveS      := xNewValue
      CASE nElement == SNMENUID       ; ::nMenuID        := xNewValue
      CASE nElement == SNSVCURSOR     ; ::nSaveCursor    := xNewValue
      ENDCASE
   ENDIF

   RETURN xRetVal
tgetlist.prg1553
HBGETLIST:METHODShowGetMsg( oGet, aMsg ) CLASS HBGetList
METHOD ShowGetMsg( oGet, aMsg ) CLASS HBGetList

#ifdef HB_COMPAT_C53
   LOCAL cMsg
   LOCAL lMOldState

   IF !Empty( aMsg ) .AND. aMsg[ MSGFLAG ]

      DEFAULT oGet TO ::oGet

      cMsg := iif( ISOBJECT( oGet:control ), oGet:control:message, oGet:message )

      IF !Empty( cMsg )
         lMOldState := MSetCursor( .F. )
         DispOutAt( aMsg[ MSGROW ], aMsg[ MSGLEFT ], PadC( cMsg, aMsg[ MSGRIGHT ] - aMsg[ MSGLEFT ] + 1 ), aMsg[ MSGCOLOR ] )
         MSetCursor( lMOldState )
      ENDIF
   ENDIF
#else
   HB_SYMBOL_UNUSED( oGet )
   HB_SYMBOL_UNUSED( aMsg )
#endif

   RETURN Self
tgetlist.prg1602
HBGETLIST:METHODEraseGetMsg( aMsg ) CLASS HBGetList
METHOD EraseGetMsg( aMsg ) CLASS HBGetList

#ifdef HB_COMPAT_C53
   LOCAL nRow := Row()
   LOCAL nCol := Col()
   LOCAL lMOldState

   IF !Empty( aMsg ) .AND. aMsg[ MSGFLAG ]
      lMOldState := MSetCursor( .F. )
      RestScreen( aMsg[ MSGROW ], aMsg[ MSGLEFT ], aMsg[ MSGROW ], aMsg[ MSGRIGHT ], ::cMsgSaveS )
      MSetCursor( lMOldState )
   ENDIF

   SetPos( nRow, nCol )
#else
   HB_SYMBOL_UNUSED( aMsg )
#endif

   RETURN Self
tgetlist.prg1627
HBGETLIST:METHODNew( GetList ) CLASS HBGetList
METHOD New( GetList ) CLASS HBGetList

   ::aGetList := GetList

   IF ISARRAY( GetList ) .AND. Len( GetList ) >= 1
      ::oGet := GetList[ 1 ]
   ENDIF

   RETURN Self
tgetlist.prg1649
tlabel.prg
TypeFunctionSourceLine
METHODNew( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, bWhile, nNext, nRecord, lRest, lSample )
   METHOD New( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, ;
                          bWhile, nNext, nRecord, lRest, lSample )
tlabel.prg110
METHODExecuteLabel()
   METHOD ExecuteLabel()
tlabel.prg113
METHODSampleLabels()
   METHOD SampleLabels()
tlabel.prg114
METHODLoadLabel( cLblFile )
   METHOD LoadLabel( cLblFile )

ENDCLASS
tlabel.prg115
HBLABELFORM:METHODNew( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, bWhile, nNext, nRecord, lRest, lSample ) CLASS HBLabelForm
METHOD New( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, ;
                       bWhile, nNext, nRecord, lRest, lSample ) CLASS HBLabelForm

   LOCAL lPrintOn := .F.               // PRINTER status
   LOCAL lConsoleOn                    // CONSOLE status
   LOCAL cExtraFile, lExtraState       // EXTRA file status
   LOCAL xBreakVal, lBroke := .F.
   LOCAL err
   LOCAL OldMargin
   LOCAL cExt

   ::aBandToPrint := {} // ARRAY(5)
   ::nCurrentCol := 1

   // Resolve parameters
   IF cLBLName == NIL
      err := ErrorNew()
      err:severity := ES_ERROR
      err:genCode := EG_ARG
      err:subSystem := "FRMLBL"
      Eval(ErrorBlock(), err)
   ELSE
      /* NOTE: CA-Cl*pper does an RTrim() on the filename here, 
               but in Harbour we're using _SET_TRIMFILENAME. [vszakats] */
      IF Set( _SET_DEFEXTENSIONS )
         hb_FNameSplit( cLBLName, NIL, NIL, @cExt )
         IF Empty( cExt )
            cLBLName += ".lbl"
         ENDIF
      ENDIF
   ENDIF

   DEFAULT lPrinter TO .F.
   DEFAULT lSample TO .F.

   // Set output devices
   IF lPrinter             // To the printer
      lPrintOn  := SET( _SET_PRINTER, lPrinter )
   ENDIF

   lConsoleOn := SET( _SET_CONSOLE )
   SET( _SET_CONSOLE, ! ( lNoConsole .OR. !lConsoleOn ) )

   IF !Empty(cAltFile)         // To file
      lExtraState := SET( _SET_EXTRA, .T. )
      cExtraFile  := SET( _SET_EXTRAFILE, cAltFile )
   ENDIF

   OldMargin := SET( _SET_MARGIN, 0)

   BEGIN SEQUENCE

      ::aLabelData := ::LoadLabel( cLBLName )  // Load the (.lbl) into an array

      // Add to the left margin if a SET MARGIN has been defined
      ::aLabelData[ LBL_LMARGIN ] := ::aLabelData[ LBL_LMARGIN ] + OldMargin

      ASIZE( ::aBandToPrint, LEN( ::aLabelData[ LBL_FIELDS ]))
      AFILL( ::aBandToPrint, SPACE( ::aLabelData[ LBL_LMARGIN ] ) )

      // Create enough space for a blank record
      ::cBlank := SPACE( ::aLabelData[ LBL_WIDTH ] + ::aLabelData[ LBL_SPACES ] )

      // Handle sample labels
      IF lSample
         ::SampleLabels()
      ENDIF

      // Execute the actual label run based on matching records
      DBEval( { || ::ExecuteLabel() }, bFor, bWhile, nNext, nRecord, lRest )

      // Print the last band if there is one
      IF ::lOneMoreBand
         // Print the band
         AEVAL( ::aBandToPrint, { | BandLine | PrintIt( BandLine ) } )
      ENDIF

   RECOVER USING xBreakVal

      lBroke := .T.

   END SEQUENCE

   // Clean up and leave
   ::aLabelData   := {}                // Recover the space
   ::aBandToPrint := {}
   ::nCurrentCol  := 1
   ::cBlank       := ""
   ::lOneMoreBand :=.T.

   // clean up
   SET( _SET_PRINTER, lPrintOn ) // Set the printer back to prior state
   SET( _SET_CONSOLE, lConsoleOn )  // Set the console back to prior state

   IF !Empty(cAltFile)            // Set extrafile back
      SET( _SET_EXTRAFILE, cExtraFile )
      SET( _SET_EXTRA, lExtraState )
   ENDIF

   IF lBroke
      BREAK xBreakVal               // continue breaking
   ENDIF

   SET( _SET_MARGIN, OldMargin )

   RETURN Self
tlabel.prg119
HBLABELFORM:METHODExecuteLabel() CLASS HBLabelForm
METHOD ExecuteLabel() CLASS HBLabelForm
   LOCAL nField, nMoreLines, aBuffer := {}, cBuffer
   LOCAL v

   // Load the current record into aBuffer
   FOR nField := 1 TO LEN( ::aLabelData[ LBL_FIELDS ] )

      if ::aLabelData[ LBL_FIELDS, nField ] != NIL

         v := Eval( ::aLabelData[ LBL_FIELDS, nField, LF_EXP ] )

         cBuffer := PadR( v, ::aLabelData[ LBL_WIDTH ] )
         cBuffer := cBuffer + Space( ::aLabelData[ LBL_SPACES ] )

         if ( ::aLabelData[ LBL_FIELDS, nField, LF_BLANK ] )
            if ( !Empty( cBuffer ) )
               AADD( aBuffer, cBuffer )
            endif
         else
            AADD( aBuffer, cBuffer )
         endif

      else

         AADD( aBuffer, NIL )

      endif

   NEXT

   ASIZE( aBuffer, LEN( ::aLabelData[ LBL_FIELDS ] ) )

   // Add aBuffer to ::aBandToPrint
   FOR nField := 1 TO LEN( ::aLabelData[ LBL_FIELDS ] )
      IF aBuffer[ nField ] == NIL
         ::aBandToPrint[ nField ] := ::aBandToPrint[ nField ] + ::cBlank
      ELSE
         ::aBandToPrint[ nField ] := ::aBandToPrint[ nField ]  + aBuffer[ nField ]
      ENDIF
   NEXT

   IF ::nCurrentCol == ::aLabelData[ LBL_ACROSS ]

      // trim
      FOR nField := 1 TO LEN( ::aBandToPrint )
         ::aBandToPrint[ nField ] := Trim( ::aBandToPrint[ nField ] )
      NEXT


      ::lOneMoreBand := .F.
      ::nCurrentCol  := 1

      // Print the band
      AEVAL( ::aBandToPrint, { | BandLine | PrintIt( BandLine ) } )

      nMoreLines := ::aLabelData[ LBL_HEIGHT ] - LEN( ::aBandToPrint )
      IF nMoreLines > 0
         FOR nField := 1 TO nMoreLines
            PrintIt()
         NEXT
      ENDIF
      IF ::aLabelData[ LBL_LINES ] > 0

         // Add the spaces between the label lines
         FOR nField := 1 TO ::aLabelData[ LBL_LINES ]
            PrintIt()
         NEXT

      ENDIF

      // Clear out the band
      AFILL( ::aBandToPrint, SPACE( ::aLabelData[ LBL_LMARGIN ] ) )
   ELSE
      ::lOneMoreBand := .T.
      ::nCurrentCol :=  ::nCurrentCol + 1
   ENDIF

   RETURN Self
tlabel.prg226
HBLABELFORM:METHODSampleLabels() CLASS HBLabelForm
METHOD SampleLabels() CLASS HBLabelForm
   LOCAL nGetKey, lMoreSamples := .T., nField
   LOCAL aBand := {}

   // Create the sample label row
   ASIZE( aBand, ::aLabelData[ LBL_HEIGHT ] )
   AFILL( aBand, SPACE( ::aLabelData[ LBL_LMARGIN ] ) +;
              REPLICATE( REPLICATE( "*", ;
              ::aLabelData[ LBL_WIDTH ] ) + ;
              SPACE( ::aLabelData[ LBL_SPACES ] ), ;
              ::aLabelData[ LBL_ACROSS ] ) )

   // Prints sample labels
   DO WHILE lMoreSamples

      // Print the samples
      AEVAL( aBand, { | BandLine | PrintIt( BandLine ) } )

      IF ::aLabelData[ LBL_LINES ] > 0
         // Add the spaces between the label lines
         FOR nField := 1 TO ::aLabelData[ LBL_LINES ]
            PrintIt()
         NEXT nField
      ENDIF

      // Prompt for more
      @ ROW(), 0 SAY __NatMsg(_LF_SAMPLES)+" ("+__NatMsg(_LF_YN)+")"
      nGetKey := INKEY(0)
      @ ROW(), COL() SAY CHR(nGetKey)
      IF ROW() == MAXROW()
         SCROLL( 0, 0, MAXROW(), MAXCOL(), 1 )
         @ MAXROW(), 0 SAY ""
      ELSE
         @ ROW()+1, 0 SAY ""
      ENDIF
      IF __NatIsNegative(CHR(nGetKey))   // Don't give sample labels
         lMoreSamples := .F.
      ENDIF
   ENDDO

   RETURN Self
tlabel.prg305
HBLABELFORM:METHODLoadLabel( cLblFile ) CLASS HBLabelForm
METHOD LoadLabel( cLblFile ) CLASS HBLabelForm
   LOCAL i, j       := 0                  // Counters
   LOCAL cBuff      := SPACE(BUFFSIZE)    // File buffer
   LOCAL nHandle    := 0                  // File handle
   LOCAL nReadCount := 0                  // Bytes read from file
   LOCAL lStatus    := .F.                // Status
   LOCAL nOffset    := FILEOFFSET         // Offset into file
   LOCAL nFileError := F_OK               // File error
   LOCAL cFieldText := ""                 // Text expression container
   LOCAL err                              // error object

   LOCAL cDefPath          // contents of SET DEFAULT string
   LOCAL aPaths            // array of paths
   LOCAL nPathIndex := 0   // iteration counter

   // Create and initialize default label array
   LOCAL aLabel[ LBL_COUNT ]
   aLabel[ LBL_REMARK ]  := SPACE(60)      // Label remark
   aLabel[ LBL_HEIGHT ]  := 5              // Label height
   aLabel[ LBL_WIDTH ]   := 35             // Label width
   aLabel[ LBL_LMARGIN ] := 0              // Left margin
   aLabel[ LBL_LINES ]   := 1              // Lines between labels
   aLabel[ LBL_SPACES ]  := 0              // Spaces between labels
   aLabel[ LBL_ACROSS ]  := 1              // Number of labels across
   aLabel[ LBL_FIELDS ]  := {}             // Array of label fields

   // Open the label file
   nHandle := FOPEN( cLblFile )

   IF ! EMPTY( nFileError := FERROR() ) .AND. !( "\" $ cLblFile .OR. ":" $ cLblFile )

      // Search through default path; attempt to open label file
      cDefPath := SET( _SET_DEFAULT )
      cDefPath := STRTRAN( cDefPath, ",", ";" )
      aPaths := ListAsArray( cDefPath, ";" )

      FOR nPathIndex := 1 TO LEN( aPaths )
         nHandle := FOPEN( aPaths[ nPathIndex ] + "\" + cLblFile )
         // if no error is reported, we have our label file
         IF EMPTY( nFileError := FERROR() )
            EXIT

         ENDIF

      NEXT nPathIndex

   ENDIF

   // File error
   IF nFileError != F_OK
      err := ErrorNew()
      err:severity := ES_ERROR
      err:genCode := EG_OPEN
      err:subSystem := "FRMLBL"
      err:osCode := nFileError
      err:filename := cLblFile
      Eval(ErrorBlock(), err)
   ENDIF

   // If we got this far, assume the label file is open and ready to go
   // and so go ahead and read it
   nReadCount := FREAD( nHandle, @cBuff, BUFFSIZE )

   // READ ok?
   IF nReadCount == 0
      nFileError := F_EMPTY             // File is empty
   ELSE
      nFileError := FERROR()            // Check for DOS errors
   ENDIF

   IF nFileError == 0

      // Load label dimension into aLabel
      aLabel[ LBL_REMARK ] := SUBSTR(cBuff, REMARKOFFSET, REMARKSIZE)
      aLabel[ LBL_HEIGHT ] := BIN2W(SUBSTR(cBuff, HEIGHTOFFSET, HEIGHTSIZE))
      aLabel[ LBL_WIDTH  ] := BIN2W(SUBSTR(cBuff, WIDTHOFFSET, WIDTHSIZE))
      aLabel[ LBL_LMARGIN] := BIN2W(SUBSTR(cBuff, LMARGINOFFSET, LMARGINSIZE))
      aLabel[ LBL_LINES  ] := BIN2W(SUBSTR(cBuff, LINESOFFSET, LINESSIZE))
      aLabel[ LBL_SPACES ] := BIN2W(SUBSTR(cBuff, SPACESOFFSET, SPACESSIZE))
      aLabel[ LBL_ACROSS ] := BIN2W(SUBSTR(cBuff, ACROSSOFFSET, ACROSSSIZE))

      FOR i := 1 TO aLabel[ LBL_HEIGHT ]

         // Get the text of the expression
         cFieldText := TRIM( SUBSTR( cBuff, nOffset, FIELDSIZE ) )
         nOffset :=nOffSet + 60

         IF !EMPTY( cFieldText )

            AADD( aLabel[ LBL_FIELDS ], {} )

            // Field expression
            AADD( aLabel[ LBL_FIELDS, i ], &( "{ || " + cFieldText + "}" ) )

            // Text of field
            AADD( aLabel[ LBL_FIELDS, i ], cFieldText )

            // Compression option
            AADD( aLabel[ LBL_FIELDS, i ], .T. )

         ELSE

            AADD( aLabel[ LBL_FIELDS ], NIL )

         ENDIF

      NEXT

      // Close file
      FCLOSE( nHandle )

      nFileError := FERROR()

   ENDIF

   RETURN aLabel
tlabel.prg347
FUNCTION__LabelForm( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, bWhile, nNext, nRecord, lRest, lSample )
FUNCTION __LabelForm( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, ;
                       bWhile, nNext, nRecord, lRest, lSample )

   RETURN HBLabelForm():New( cLBLName, lPrinter, cAltFile, lNoConsole, bFor, ;
                          bWhile, nNext, nRecord, lRest, lSample )
tlabel.prg464
STATIC PROCEDUREPrintIt( cString )
STATIC PROCEDURE PrintIt( cString )

   DEFAULT cString TO ""

   QQOUT( cString )
   QOUT()

   RETURN
tlabel.prg470
STATIC FUNCTIONListAsArray( cList, cDelimiter )
STATIC FUNCTION ListAsArray( cList, cDelimiter )

   LOCAL nPos
   LOCAL aList := {}                  // Define an empty array
   LOCAL lDelimLast := .F.

   DEFAULT cDelimiter TO ","

   DO WHILE LEN(cList) != 0

      nPos := AT(cDelimiter, cList)

      IF nPos == 0
         nPos := LEN(cList)
      ENDIF

      IF SUBSTR( cList, nPos, 1 ) == cDelimiter
         lDelimLast := .T.
         AADD(aList, SUBSTR(cList, 1, nPos - 1)) // Add a new element
      ELSE
         lDelimLast := .F.
         AADD(aList, SUBSTR(cList, 1, nPos)) // Add a new element
      ENDIF

      cList := SUBSTR(cList, nPos + 1)

   ENDDO

   IF lDelimLast
      AADD(aList, "")
   ENDIF

   RETURN aList                       // Return the array
tlabel.prg479
tmenuitm.prg
TypeFunctionSourceLine
METHODcaption( cCaption ) SETGET
   METHOD caption( cCaption ) SETGET
tmenuitm.prg69
METHODchecked( lChecked ) SETGET
   METHOD checked( lChecked ) SETGET
tmenuitm.prg70
METHODdata( boData ) SETGET
   METHOD data( boData ) SETGET
tmenuitm.prg71
METHODenabled( lEnabled ) SETGET
   METHOD enabled( lEnabled ) SETGET
tmenuitm.prg72
METHODid( nID ) SETGET
   METHOD id( nID ) SETGET
tmenuitm.prg73
METHODmessage( cMessage ) SETGET
   METHOD message( cMessage ) SETGET
tmenuitm.prg74
METHODshortcut( nShortcut ) SETGET
   METHOD shortcut( nShortcut ) SETGET
tmenuitm.prg75
METHODstyle( cStyle ) SETGET
   METHOD style( cStyle ) SETGET

   VAR __col      INIT -1 AS NUMERIC                    /* NOTE: This is a Harbour extension. */
   VAR __row      INIT -1 AS NUMERIC                    /* NOTE: This is a Harbour extension. */
tmenuitm.prg76
METHODisPopUp()
   METHOD isPopUp()
tmenuitm.prg81
METHODNew( cCaption, boData, nShortcut, cMsg, nID )
   METHOD New( cCaption, boData, nShortcut, cMsg, nID ) /* NOTE: This method is a Harbour extension [vszakats] */

   PROTECTED:

   VAR cCaption   INIT ""
   VAR lChecked   INIT .F.
   VAR boData
   VAR lEnabled   INIT .T.
   VAR nID
   VAR cMessage
   VAR nShortcut
   VAR cStyle     INIT Chr( 251 ) + Chr( 16 )

ENDCLASS
tmenuitm.prg83
MENUITEM:METHODcaption( cCaption ) CLASS MENUITEM
METHOD caption( cCaption ) CLASS MENUITEM

   IF cCaption != NIL

      ::cCaption := __eInstVar53( Self, "CAPTION", cCaption, "C", 1001 )

      IF ::cCaption == MENU_SEPARATOR
         ::boData   := NIL
         ::lChecked := .F.
         ::lEnabled := .F.
      ENDIF
   ENDIF

   RETURN ::cCaption
tmenuitm.prg98
MENUITEM:METHODchecked( lChecked ) CLASS MENUITEM
METHOD checked( lChecked ) CLASS MENUITEM

   IF lChecked != NIL .AND. !( ::cCaption == MENU_SEPARATOR )
      ::lChecked := __eInstVar53( Self, "CHECKED", lChecked, "L", 1001 )
   ENDIF

   RETURN ::lChecked
tmenuitm.prg113
MENUITEM:METHODdata( boData ) CLASS MENUITEM
METHOD data( boData ) CLASS MENUITEM

   IF boData != NIL
      IF ISBLOCK( boData )
         ::boData := boData
      ELSE
         ::boData := __eInstVar53( Self, "DATA", boData, "O", 1001, {|| boData:ClassName() == "POPUPMENU" } )
      ENDIF
   ENDIF

   RETURN ::boData
tmenuitm.prg121
MENUITEM:METHODenabled( lEnabled ) CLASS MENUITEM
METHOD enabled( lEnabled ) CLASS MENUITEM

   IF lEnabled != NIL .AND. !( ::cCaption == MENU_SEPARATOR )
      ::lEnabled := __eInstVar53( Self, "ENABLED", lEnabled, "L", 1001 )
   ENDIF

   RETURN ::lEnabled
tmenuitm.prg133
MENUITEM:METHODid( nID ) CLASS MENUITEM
METHOD id( nID ) CLASS MENUITEM

   IF nID != NIL
      ::nID := __eInstVar53( Self, "ID", nID, "N", 1001 )
   ENDIF

   RETURN ::nID
tmenuitm.prg141
MENUITEM:METHODmessage( cMessage ) CLASS MENUITEM
METHOD message( cMessage ) CLASS MENUITEM

   IF cMessage != NIL
      ::cMessage := __eInstVar53( Self, "MESSAGE", cMessage, "C", 1001 )
   ENDIF

   RETURN ::cMessage
tmenuitm.prg149
MENUITEM:METHODshortcut( nShortcut ) CLASS MENUITEM
METHOD shortcut( nShortcut ) CLASS MENUITEM

   IF nShortcut != NIL
      ::nShortcut := __eInstVar53( Self, "SHORTCUT", nShortcut, "N", 1001 )
   ENDIF

   RETURN ::nShortcut
tmenuitm.prg157
MENUITEM:METHODstyle( cStyle ) CLASS MENUITEM
METHOD style( cStyle ) CLASS MENUITEM

   IF cStyle != NIL
      ::cStyle := __eInstVar53( Self, "STYLE", cStyle, "C", 1001, {|| Len( cStyle ) == 2 } )
   ENDIF

   RETURN ::cStyle
tmenuitm.prg165
MENUITEM:METHODisPopUp() CLASS MENUITEM
METHOD isPopUp() CLASS MENUITEM
   RETURN ISOBJECT( ::data ) .AND. ::data:ClassName() == "POPUPMENU"
tmenuitm.prg173
MENUITEM:METHODNew( cCaption, boData, nShortcut, cMessage, nID ) CLASS MENUITEM
METHOD New( cCaption, boData, nShortcut, cMessage, nID ) CLASS MENUITEM

   IF !ISNUMBER( nShortcut )
      nShortcut := 0
   ENDIF
   IF !ISCHARACTER( cMessage )
      cMessage := ""
   ENDIF
   IF !ISNUMBER( nID )
      nID := 0
   ENDIF

   ::data      := boData
   ::nID       := nID
   ::cMessage  := cMessage
   ::nShortcut := nShortcut
   ::caption   := cCaption

   RETURN Self
tmenuitm.prg176
FUNCTIONMenuItem( cCaption, boData, nShortcut, cMessage, nID )
FUNCTION MenuItem( cCaption, boData, nShortcut, cMessage, nID )
   RETURN HBMenuItem():New( cCaption, boData, nShortcut, cMessage, nID )
tmenuitm.prg196
FUNCTION__miColumn( o, nColumn )
FUNCTION __miColumn( o, nColumn )

   IF ISOBJECT( o ) .AND. o:ClassName() == "MENUITEM"

      IF ISNUMBER( nColumn )
         o:__col := nColumn
      ENDIF

      RETURN o:__col
   ENDIF

   RETURN -1
tmenuitm.prg201
FUNCTION__miRow( o, nRow )
FUNCTION __miRow( o, nRow )

   IF ISOBJECT( o ) .AND. o:ClassName() == "MENUITEM"

      IF ISNUMBER( nRow )
         o:__row := nRow
      ENDIF

      RETURN o:__row
   ENDIF

   RETURN -1
tmenuitm.prg214
tmenusys.prg
TypeFunctionSourceLine
METHODModal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )
   METHOD Modal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList )
tmenusys.prg75
METHODNew( oMenu )
   METHOD New( oMenu )

   PROTECTED:
tmenusys.prg76
METHODPushMenu()
   METHOD PushMenu()
tmenusys.prg80
METHODPopMenu()
   METHOD PopMenu()
tmenusys.prg81
METHODPopChild( nNewLevel )
   METHOD PopChild( nNewLevel )
tmenusys.prg82
METHODPopAll()
   METHOD PopAll()
tmenusys.prg83
METHODExecute()
   METHOD Execute()
tmenusys.prg84
METHODMHitTest( oNewMenu, nNewLevel, nNewItem )
   METHOD MHitTest( oNewMenu, nNewLevel, nNewItem )
tmenusys.prg85
METHODShowMsg( lMode )
   METHOD ShowMsg( lMode )
tmenusys.prg86
METHODGetMsgArray()
   METHOD GetMsgArray()

   VAR oMenu
   VAR lOldMsgFlag
   VAR cOldMessage
   VAR aMenuList
   VAR nMenuLevel
   VAR nOldRow
   VAR nOldCol
   VAR nOldCursor
   VAR lMsgFlag
   VAR nMsgRow
   VAR nMsgLeft
   VAR nMsgRight
   VAR cMsgColor
   VAR cMsgSaveS

ENDCLASS
tmenusys.prg87
HBMENUSYS:METHODModal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList ) CLASS HBMenuSys
METHOD Modal( nSelection, nMsgRow, nMsgLeft, nMsgRight, cMsgColor, GetList ) CLASS HBMenuSys

   LOCAL oTopMenu := ::oMenu

   LOCAL nReturn := 0

   LOCAL nKey
   LOCAL nNewItem
   LOCAL lLeftDown
   LOCAL oNewMenu
   LOCAL nNewLevel
   LOCAL nEvent
   LOCAL oMenuItem
   LOCAL nMenuItem
   LOCAL nTemp
   LOCAL bKeyBlock
   LOCAL lSubMenu

   ::nOldRow    := Row()  
   ::nOldCol    := Col()  
   ::nOldCursor := SetCursor( SC_NONE )  

   ::nMsgRow    := nMsgRow
   ::nMsgLeft   := nMsgLeft
   ::nMsgRight  := nMsgRight
   ::cMsgColor  := cMsgColor

   IF ( ::lMsgFlag := ISNUMBER( ::nMsgRow ) .AND. ;
                      ISNUMBER( ::nMsgLeft ) .AND. ;
                      ISNUMBER( ::nMsgRight ) )

      IF !ISCHARACTER( ::cMsgColor )
         ::cMsgColor := GetClrPair( SetColor(), 1 )
      ENDIF

      Scroll( ::nMsgRow, ::nMsgLeft, ::nMsgRow, ::nMsgRight )

      ::cMsgSaveS := SaveScreen( ::nMsgRow, ::nMsgLeft, ::nMsgRow, ::nMsgRight )

   ENDIF

   oTopMenu:select( nSelection )

   IF !( oTopMenu:ClassName() == "TOPBARMENU" ) .AND. !oTopMenu:isOpen
      oTopMenu:open()
   ELSE
      oTopMenu:display()
   ENDIF

   IF nSelection <= 0

      DO WHILE nSelection <= 0

         nEvent := Set( _SET_EVENTMASK, INKEY_KEYBOARD + INKEY_LDOWN )
         nKey := Inkey( 0 )
         Set( _SET_EVENTMASK, nEvent )

         IF nKey == K_LBUTTONDOWN .OR. nKey == K_LDBLCLK
            nSelection := oTopMenu:hitTest( MRow(), MCol() )

         ELSEIF ( nSelection := oTopMenu:getAccel( nKey ) ) != 0

         ELSEIF IsShortCut( oTopMenu, nKey, @nReturn )
            RETURN nReturn

         ELSE
            nSelection := 1

         ENDIF

      ENDDO

      oTopMenu:select( nSelection )
      oTopMenu:display()

   ENDIF

   IF !oTopMenu:getItem( nSelection ):enabled
      RETURN 0
   ENDIF

   ::aMenuList      := Array( 16 )
   ::nMenuLevel     := 1
   ::aMenuList[ 1 ] := ::oMenu

   lLeftDown := MLeftDown()

   ::ShowMsg( .T. )

   DO WHILE .T.

      nKey := Inkey( 0 )

      IF ( bKeyBlock := SetKey( nKey ) ) != NIL
         Eval( bKeyBlock, ProcName( 1 ), ProcLine( 1 ), "" )
         LOOP
      ENDIF

      DO CASE
      CASE nKey == K_MOUSEMOVE

         IF lLeftDown

            IF !::MHitTest( @oNewMenu, @nNewLevel, @nNewItem ) // ; hit nowhere.

            ELSEIF nNewLevel != ::nMenuLevel // ; menu level change.

               IF nNewItem != oNewMenu:current .AND. oNewMenu:GetItem( nNewItem ):enabled
                  ::oMenu := oNewMenu
                  ::PopChild( nNewLevel )
                  ::oMenu:select( nNewItem )
                  ::oMenu:display()
                  ::PushMenu()
                  ::ShowMsg( .T. )
               ENDIF

            ELSEIF nNewItem != oNewMenu:Current() // ; menu item change.

               ::PopChild( ::nMenuLevel )

               IF ::oMenu:getItem( nNewItem ):enabled
                  ::oMenu:select( nNewItem )
                  ::oMenu:display()
                  ::PushMenu()
                  ::ShowMsg( .T. )
               ENDIF

            ENDIF

         ENDIF

      CASE nKey == K_DOWN

         IF ::oMenu:ClassName() == "TOPBARMENU"
            IF ::PushMenu()
               ::ShowMsg( .T. )
            ENDIF
         ELSE
            nTemp := ::oMenu:getNext()
            IF nTemp == 0
               nTemp := ::oMenu:getFirst()
            ENDIF
            ::oMenu:select( nTemp )
            ::oMenu:display()
            ::ShowMsg( .T. )
         ENDIF

      CASE nKey == K_UP

         IF !( ::oMenu:ClassName() == "TOPBARMENU" )
            nTemp := ::oMenu:getPrev()
            IF nTemp == 0
               nTemp := ::oMenu:getLast()
            ENDIF
            ::oMenu:select( nTemp )
            ::oMenu:display()
            ::ShowMsg( .T. )

         ENDIF

      CASE nKey == K_LEFT

         IF ( lSubMenu := ( ::nMenuLevel > 1 ) )
            ::PopMenu()
         ENDIF
         IF ::oMenu:ClassName() == "TOPBARMENU"
            nTemp := ::oMenu:getPrev()
            IF nTemp == 0
               nTemp := ::oMenu:getLast()
            ENDIF
            ::oMenu:select( nTemp )
            ::oMenu:display()
            IF lSubMenu
               ::PushMenu()
            ENDIF
         ENDIF
         ::ShowMsg( .T. )

      CASE nKey == K_RIGHT

         IF ( lSubMenu := ( ::nMenuLevel > 1 ) )
            ::PopMenu()
         ENDIF

         IF ::oMenu:ClassName() == "TOPBARMENU"
            nTemp := ::oMenu:getNext()
            IF nTemp == 0
               nTemp := ::oMenu:getFirst()
            ENDIF
            ::oMenu:select( nTemp )
            ::oMenu:display()
            IF lSubMenu
               ::PushMenu()
            ENDIF
         ENDIF
         ::ShowMsg( .T. )

      CASE nKey == K_ENTER

         IF ::PushMenu()
            ::ShowMsg( .T. )
         ELSE
            ::ShowMsg( .F. )
            nReturn := ::execute()
            IF nReturn != 0
               EXIT
            ENDIF
         ENDIF

      CASE nKey == K_ESC // go to previous menu

         IF ::PopMenu()
            ::oMenu:display()
            ::ShowMsg( .T. )
         ELSE

            IF ::oMenu:ClassName() == "POPUPMENU"
               ::oMenu:close()
            ENDIF
            
            nReturn := -1 // Bail out if at the top menu item
            EXIT

         ENDIF

      CASE nKey == K_LBUTTONDOWN

         IF !::MHitTest( @oNewMenu, @nNewLevel, @nNewItem )

            IF GetList != NIL .AND. HitTest( GetList, MRow(), MCol(), ::GetMsgArray() ) != 0
               GetActive():ExitState := GE_MOUSEHIT
               ReadStats( SNLASTEXIT, GE_MOUSEHIT ) // Reset Get System values
               IF ::oMenu:ClassName() == "POPUPMENU"
                  ::PopMenu()
               ENDIF
               nReturn := -1
               EXIT
            ENDIF

            IF ::oMenu:ClassName() == "POPUPMENU"
               ::PopMenu()
            ENDIF

         ELSEIF nNewLevel == ::nMenuLevel
            ::oMenu:select( nNewItem )
            ::oMenu:display()
            ::PushMenu()
            ::ShowMsg( .T. )

         ELSE
            ::nMenuLevel := nNewLevel
            ::oMenu      := ::aMenuList[ ::nMenuLevel ]

            nMenuItem := ::oMenu:current
            oMenuItem := ::oMenu:getItem( nMenuItem )
            IF ( oMenuItem := ::oMenu:getItem( ::oMenu:Current ) ):isPopUp()
               oMenuItem:data:close()
            ENDIF

            IF nMenuItem != nNewItem
               nMenuItem := nNewItem
               ::oMenu:select( nNewItem )
               ::oMenu:display()
               ::PushMenu()
            ENDIF

            ::ShowMsg( .T. )
         ENDIF

         lLeftDown := .T.

      CASE nKey == K_LBUTTONUP

         lLeftDown := .F.

         IF ::MHitTest( @oNewMenu, @nNewLevel, @nNewItem ) .AND. ;
            nNewLevel == ::nMenuLevel

            IF nNewItem == ::oMenu:current
               ::ShowMsg( .F. )
               nReturn := ::execute()
               IF nReturn != 0
                  EXIT
               ENDIF
            ENDIF
         ENDIF

      CASE ( nNewItem := ::oMenu:getAccel( nKey ) ) != 0

         IF ::oMenu:getItem( nNewItem ):enabled
            ::oMenu:select( nNewItem )
            ::oMenu:display()

            IF !::PushMenu()
               ::ShowMsg( .F. )
               nReturn := ::execute()
               IF nReturn != 0
                  EXIT
               ENDIF
            ENDIF
            ::ShowMsg( .T. )

         ENDIF

      CASE IsShortCut( oTopMenu, nKey, @nReturn )

         IF nReturn != 0
            EXIT
         ENDIF

      CASE GetList != NIL .AND. ( nNewItem := Accelerator( GetList, nKey, ::GetMsgArray() ) ) != 0

         GetActive():ExitState := GE_SHORTCUT
         ReadStats( SNNEXTGET, nNewItem ) // Reset Get System values
         IF ::oMenu:ClassName() == "POPUPMENU"
            ::PopMenu()
         ENDIF

         nReturn := -1
         EXIT

      CASE ( nNewItem := oTopMenu:getAccel( nKey ) ) != 0 // ; check for the top menu item accelerator key

         IF oTopMenu:getItem( nNewItem ):enabled
            ::PopAll()
            ::oMenu:select( nNewItem )
            ::oMenu:display()
            IF oTopMenu:getItem( nNewItem ):isPopUp()
               ::PushMenu()
            ELSE
               ::ShowMsg( .F. )
               nReturn := ::execute()
               IF nReturn != 0
                  EXIT
               ENDIF
            ENDIF
            ::ShowMsg( .T. )
         ENDIF

      ENDCASE

   ENDDO

   IF ::lMsgFlag
      RestScreen( ::nMsgRow, ::nMsgLeft, ::nMsgRow, ::nMsgRight, ::cMsgSaveS )
   ENDIF

   ::PopAll()

   SetPos( ::nOldRow, ::nOldCol )
   SetCursor( ::nOldCursor )

   RETURN nReturn
tmenusys.prg111
HBMENUSYS:METHODPushMenu() CLASS HBMenuSys
METHOD PushMenu() CLASS HBMenuSys
   LOCAL oNewMenu := ::oMenu:getItem( ::oMenu:current )

   IF ISOBJECT( oNewMenu ) .AND. oNewMenu:IsPopUp

      ::oMenu := oNewMenu:data
      ::aMenuList[ ++::nMenuLevel ] := ::oMenu
      ::oMenu:select( ::oMenu:getFirst() )

      IF !::oMenu:isOpen
         ::oMenu:open()
      ENDIF

      RETURN .T.

   ENDIF

   RETURN .F.
tmenusys.prg471
HBMENUSYS:METHODPopMenu() CLASS HBMenuSys
METHOD PopMenu() CLASS HBMenuSys

   IF ::nMenuLevel > 1
      ::oMenu:select( 0 )
      ::oMenu:close( .T. )
      ::oMenu := ::aMenuList[ --::nMenuLevel ] // Decrement MenuItem level and assign
      RETURN .T.
   ENDIF

   RETURN .F.
tmenusys.prg495
HBMENUSYS:METHODPopChild( nNewLevel ) CLASS HBMenuSys
METHOD PopChild( nNewLevel ) CLASS HBMenuSys
   LOCAL oOldMenuItem
   LOCAL nCurrent

   IF ( nCurrent := ::oMenu:current ) != 0
      oOldMenuItem := ::oMenu:getItem( nCurrent )
      IF oOldMenuItem:isPopUp
         oOldMenuItem:data:close()
         ::nMenuLevel := nNewLevel
         RETURN .T.
      ENDIF

   ENDIF

   RETURN .F.
tmenusys.prg511
HBMENUSYS:METHODPopAll() CLASS HBMenuSys
METHOD PopAll() CLASS HBMenuSys

   IF ::aMenuList[ 2 ] != NIL
      ::aMenuList[ 2 ]:close()
   ENDIF
   // Set the menu level and position relative to the top menu item:
   ::nMenuLevel := 1
   ::oMenu      := ::aMenuList[ 1 ]

   RETURN .T.
tmenusys.prg532
HBMENUSYS:METHODExecute() CLASS HBMenuSys
METHOD Execute() CLASS HBMenuSys
   LOCAL oNewMenu := ::oMenu:getItem( ::oMenu:current )
   LOCAL lPas := .T.

   // Execute the Data block if selected MenuItem is !IsPopUp:
   IF ISOBJECT( oNewMenu ) .AND. !oNewMenu:IsPopUp

      IF ::oMenu:ClassName() $ "TOPBARMENU|POPUPMENU"
         SetPos( ::nOldRow, ::nOldCol )
         SetCursor( ::nOldCursor )
         Eval( oNewMenu:data, oNewMenu )
         SetCursor( SC_NONE )
         lPas := .F.
      ENDIF

      // Pop the Menu:
      ::oMenu:select( iif( ::PopMenu(), ::oMenu:current, 0 ) )

      // Display newly selected current menu item:
      IF ::oMenu:ClassName() == "POPUPMENU" .AND. ;
         ::nMenuLevel == 1 .AND. ;
         !::oMenu:isOpen

         ::oMenu:open()
      ENDIF

      IF lPas
         ::oMenu:close()
         SetPos( ::nOldRow, ::nOldCol )
         SetCursor( ::nOldCursor )
         Eval( oNewMenu:data, oNewMenu )
         SetCursor( SC_NONE )
      ENDIF

      RETURN oNewMenu:Id

   ENDIF

   RETURN 0
tmenusys.prg548
HBMENUSYS:METHODMHitTest( oNewMenu, nNewLevel, nNewItem ) CLASS HBMenuSys
METHOD MHitTest( oNewMenu, nNewLevel, nNewItem ) CLASS HBMenuSys

   FOR nNewLevel := ::nMenuLevel TO 1 STEP -1

      oNewMenu := ::aMenuList[ nNewLevel ]
      nNewItem := oNewMenu:hitTest( MRow(), MCol() )

      IF nNewItem < 0
         RETURN .F. // Test for the mouse on Menu separator or border
      ELSEIF nNewItem > 0 .AND. oNewMenu:getItem( nNewItem ):enabled
         RETURN .T. // Test for the mouse on an enabled item in the menu
      ENDIF

   NEXT

   RETURN .F.
tmenusys.prg594
HBMENUSYS:METHODShowMsg( lMode ) CLASS HBMenuSys
METHOD ShowMsg( lMode ) CLASS HBMenuSys
   LOCAL nCurrent
   LOCAL cMsg
   LOCAL lMOldState := MSetCursor( .F. )

   IF ISLOGICAL( ::lOldMsgFlag ) .AND. ::lOldMsgFlag
      RestScreen( ::nMsgRow, ::nMsgLeft, ::nMsgRow, ::nMsgRight, ::cMsgSaveS )
   ENDIF

   IF lMode
      IF !ISCHARACTER( ::cMsgColor )
         ::cMsgColor := GetClrPair( SetColor(), 1 )
      ENDIF

      IF ::lMsgFlag .AND. ;
         ( nCurrent := ::oMenu:current ) != 0 .AND. ;
         !Empty( cMsg := ::oMenu:getItem( nCurrent ):message )

         DispOutAt( ::nMsgRow, ::nMsgLeft, PadC( cMsg, ::nMsgRight - ::nMsgLeft + 1 ), ::cMsgColor )
      ENDIF

      ::cOldMessage := cMsg
      ::lOldMsgFlag := ::lMsgFlag

   ENDIF

   MSetCursor( lMOldState )

   RETURN .T.
tmenusys.prg620
HBMENUSYS:METHODGetMsgArray() CLASS HBMenuSys
METHOD GetMsgArray() CLASS HBMenuSys
   RETURN { , ::nMsgRow, ::nMsgLeft, ::nMsgRight, ::cMsgColor, , , , , }
tmenusys.prg653
HBMENUSYS:METHODNew( oMenu ) CLASS HBMenuSys
METHOD New( oMenu ) CLASS HBMenuSys
   ::oMenu := oMenu
   RETURN Self
tmenusys.prg658
tobject.prg
TypeFunctionSourceLine
FUNCTIONHBObject()
FUNCTION HBObject()
   STATIC s_oClass

   IF s_oClass == NIL

      s_oClass := HBClass():New( "HBObject",, @HBObject() )

      /* Those Five worked fine but their C version from classes.c are probably better in term of speed */
      /*s_oClass:AddInline( "CLASSNAME"      , {| Self | __OBJGETCLSNAME( Self )     }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "CLASSH"         , {| Self | __CLASSH( Self )            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "CLASSSEL"       , {| Self | __CLASSSEL( Self:CLASSH() ) }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "EVAL"           , {| Self | __EVAL( Self )              }, HB_OO_CLSTP_EXPORTED ) */

      /* xBase++ */
#ifdef HB_COMPAT_XPP
      s_oClass:AddInline( "ISDERIVEDFROM"  , {| Self, xPar1 | __ObjDerivedFrom( Self, xPar1 ) }, HB_OO_CLSTP_EXPORTED )
#endif
      /* Class(y) */
      s_oClass:AddInline( "ISKINDOF"       , {| Self, xPar1 | __ObjDerivedFrom( Self, xPar1 ) }, HB_OO_CLSTP_EXPORTED )
                                    
      s_oClass:AddMethod( "NEW"  , @HBObject_New()  , HB_OO_CLSTP_EXPORTED )
      s_oClass:AddMethod( "INIT" , @HBObject_Init() , HB_OO_CLSTP_EXPORTED )

      s_oClass:AddMethod( "ERROR", @HBObject_Error() , HB_OO_CLSTP_EXPORTED )

      s_oClass:SetOnError( @HBObject_DftonError() )

      s_oClass:AddInline( "MSGNOTFOUND" , {| Self, cMsg | ::Error( "Message not found", Self:className, cMsg, IIF( Left( cMsg, 1 ) == "_", 1005, 1004 ) ) }, HB_OO_CLSTP_EXPORTED )

      /*s_oClass:AddMultiData( , , HB_OO_CLSTP_EXPORTED, { "CLASS" }, .F. ) */

      /*s_oClass:AddInline( "ADDMETHOD" , { | Self, cMeth, pFunc, nScopeMeth         | __clsAddMsg( __CLASSH( Self ) , cMeth , pFunc ,HB_OO_MSG_METHOD , NIL, iif( nScopeMeth == NIL, 1, nScopeMeth ) ) }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "ADDVAR"    , { | Self, cVAR, nScopeMeth, uiData, hClass | __clsAddMsg( hClass:=__CLASSH( Self ) ,     cVar , uidata := __CLS_INCDATA( hClass ), HB_OO_MSG_ACCESS, NIL, iif( nScopeMeth == NIL, 1, nScopeMeth ) )  , ; */
      /*                                                                               __clsAddMsg( hClass                   , "_"+cVar , uiData                           , HB_OO_MSG_ASSIGN, NIL, iif( nScopeMeth == NIL, 1, nScopeMeth ) ) }, HB_OO_CLSTP_EXPORTED ) */

      /* Those one exist within Class(y), so we will probably try to implement it               */

      /*s_oClass:AddInline( "asString"       , {| Self | ::class:name + " object"   }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "asExpStr"       , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "basicSize"      , {| Self | Len( Self )                }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "become"         , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "isEqual"        , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "isScalar"       , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "copy"           , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "deepCopy"       , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */

      /*s_oClass:AddInline( "deferred"       , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */

      /*s_oClass:AddInline( "exec"           , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "error           , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "hash"           , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "null"           , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "size"           , {| Self | Len( Self )                }, HB_OO_CLSTP_EXPORTED ) */

      /* Those three are already treated within Classes.c */
      /*s_oClass:AddInline( "protectErr"     , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "hiddenErr"      , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "readOnlyErr"    , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */

      /* No idea when those two could occur !!? */
      /*s_oClass:AddInline( "wrongClass"     , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */
      /*s_oClass:AddInline( "badMethod"      , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */

      /* this one exist within VO and seem to be Auto Called when object ran out of scope */
      /*s_oClass:AddInline( "Axit"           , {| Self |                            }, HB_OO_CLSTP_EXPORTED ) */

      s_oClass:Create()

   ENDIF

/*
   oInstance := s_oClass:Instance()
   oInstance:class := s_oClass
   RETURN oInstance
*/

   RETURN s_oClass:Instance()
tobject.prg78
STATIC FUNCTIONHBObject_New( ... )
STATIC function HBObject_New( ... )
   RETURN QSelf():Init( ... )
tobject.prg157
STATIC FUNCTIONHBObject_Init()
STATIC FUNCTION HBObject_Init()
   RETURN QSelf()
tobject.prg160
STATIC FUNCTIONHBObject_Dftonerror( ... )
STATIC FUNCTION HBObject_Dftonerror( ... )
   RETURN QSelf():MSGNOTFOUND( __GetMessage(), ... )
tobject.prg163
STATIC FUNCTIONHBObject_Error( cDesc, cClass, cMsg, nCode )
STATIC FUNCTION HBObject_Error( cDesc, cClass, cMsg, nCode )

   DEFAULT nCode TO 1004

   RETURN __errRT_SBASE( iif( nCode == 1005, EG_NOVARMETHOD, EG_NOMETHOD ), nCode, cDesc, cClass + ":" + cMsg, 1, QSelf() )
tobject.prg166
tpopup.prg
TypeFunctionSourceLine
METHODaddItem( oItem )
   METHOD addItem( oItem )
tpopup.prg78
METHODclose( lCloseChild )
   METHOD close( lCloseChild )
tpopup.prg79
METHODdelItem( nPos )
   METHOD delItem( nPos )
tpopup.prg80
METHODdisplay()
   METHOD display()
tpopup.prg81
METHODgetAccel( xKey )
   METHOD getAccel( xKey )
tpopup.prg82
METHODgetFirst()
   METHOD getFirst()
tpopup.prg83
METHODgetItem( nPos )
   METHOD getItem( nPos )
tpopup.prg84
METHODgetLast()
   METHOD getLast()
tpopup.prg85
METHODgetNext()
   METHOD getNext()
tpopup.prg86
METHODgetPrev()
   METHOD getPrev()
tpopup.prg87
METHODgetShortCt( nKey )
   METHOD getShortCt( nKey )
tpopup.prg88
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )
tpopup.prg89
METHODinsItem( nPos, oItem )
   METHOD insItem( nPos, oItem )
tpopup.prg90
METHODisOpen()
   METHOD isOpen()
tpopup.prg91
METHODopen()
   METHOD open()
tpopup.prg92
METHODselect( nPos )
   METHOD select( nPos )
tpopup.prg93
METHODsetItem( nPos, oItem )
   METHOD setItem( nPos, oItem )
tpopup.prg94
METHODborder( cBorder ) SETGET
   METHOD border( cBorder ) SETGET
tpopup.prg96
METHODbottom( nBottom ) SETGET
   METHOD bottom( nBottom ) SETGET
tpopup.prg97
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
tpopup.prg98
METHODcurrent() SETGET
   METHOD current() SETGET
tpopup.prg99
METHODitemCount() SETGET
   METHOD itemCount() SETGET
tpopup.prg100
METHODleft( nLeft ) SETGET
   METHOD left( nLeft ) SETGET
tpopup.prg101
METHODright( nRight ) SETGET
   METHOD right( nRight ) SETGET
tpopup.prg102
METHODtop( nTop ) SETGET
   METHOD top( nTop ) SETGET
tpopup.prg103
METHODwidth() SETGET
   METHOD width() SETGET
tpopup.prg104
METHODNew( nTop, nLeft, nBottom, nRight )
   METHOD New( nTop, nLeft, nBottom, nRight ) /* NOTE: This method is a Harbour extension [vszakats] */
tpopup.prg106
METHODsetCoors( nRow, nCol, lTop )
   METHOD setCoors( nRow, nCol, lTop )        /* NOTE: This method is a Harbour extension [vszakats] */
tpopup.prg109
METHODisShortCut( nKey, nID )
   METHOD isShortCut( nKey, nID )             /* NOTE: This method is a Harbour extension [vszakats] */
tpopup.prg110
METHODisQuick( nKey, nID )
   METHOD isQuick( nKey, nID )                /* NOTE: This method is a Harbour extension [vszakats] */
#endif

   PROTECTED:

   VAR cBorder    INIT B_SINGLE + SEPARATOR_SINGLE
   VAR nBottom
   VAR cColorSpec
   VAR nCurrent   INIT 0
   VAR nItemCount INIT 0
   VAR nLeft
   VAR nRight
   VAR nTop
   VAR nWidth     INIT 0

   VAR aItems     INIT {}
   VAR aSaveScr
tpopup.prg111
METHODsetMetrics()
   METHOD setMetrics()

ENDCLASS
tpopup.prg129
POPUPMENU:METHODaddItem( oItem ) CLASS POPUPMENU
METHOD addItem( oItem ) CLASS POPUPMENU

   IF ISOBJECT( oItem ) .AND. oItem:ClassName() == "MENUITEM"

      AAdd( ::aItems, oItem )
      ::nItemCount++
      
      ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )

   ENDIF

   RETURN Self
tpopup.prg133
POPUPMENU:METHODclose( lCloseChild ) CLASS POPUPMENU
METHOD close( lCloseChild ) CLASS POPUPMENU

   DEFAULT lCloseChild TO .T.

   IF ::isOpen()

      ::setMetrics()

      IF ::nCurrent > 0 .AND. ;
         ::aItems[ ::nCurrent ]:isPopUp() .AND. ;
         ::aItems[ ::nCurrent ]:data:isOpen()

         ::aItems[ ::nCurrent ]:data:Close()
      ENDIF

      RestScreen( ::aSaveScr[ 1 ], ::aSaveScr[ 2 ], ::aSaveScr[ 3 ], ::aSaveScr[ 4 ], ::aSaveScr[ 5 ] )

      ::aSaveScr := NIL
      ::nCurrent := 0
   ENDIF

   RETURN Self
tpopup.prg146
POPUPMENU:METHODdelItem( nPos ) CLASS POPUPMENU
METHOD delItem( nPos ) CLASS POPUPMENU
   LOCAL nLen
   LOCAL aItems
   LOCAL nWidth

   IF nPos >= 1 .AND. nPos <= ::nItemCount

      nLen := Len( ::aItems[ nPos ]:caption )

      ADel( ::aItems, nPos )
      ASize( ::aItems, --::nItemCount )

      IF ::nWidth == nLen + 2
          aItems := ::aItems
          nLen := ::nItemCount
          nWidth := 0
          FOR nPos := 1 TO nLen
             nWidth := Max( __CapMetrics( aItems[ nPos ] ), nWidth )
          NEXT
          ::nWidth := nWidth
      ENDIF
   ENDIF

   RETURN Self
tpopup.prg169
POPUPMENU:METHODdisplay() CLASS POPUPMENU
METHOD display() CLASS POPUPMENU

   LOCAL nOldRow
   LOCAL nOldCol
   LOCAL lOldMCur

   LOCAL nTop    
   LOCAL nLeft   
   LOCAL aItems  
   LOCAL nCurrent
   LOCAL nLen    
   LOCAL nPos
   LOCAL nWidth  
   LOCAL oPopup
   LOCAL nHotKeyPos
   LOCAL cCaption
   LOCAL nCharPos

   IF ::isOpen()

      nOldRow := Row()             
      nOldCol := Col()             
      lOldMCur := MSetCursor( .F. )

      ::setMetrics()

      nTop     := ::nTop
      nLeft    := ::nLeft
      aItems   := ::aItems
      nCurrent := ::nCurrent
      nLen     := ::nItemCount
      nWidth   := ::nWidth

      DispBegin()
      
      DispBox( nTop, nLeft, ::nBottom, ::nRight, ;
               SubStr( ::cBorder, 1, 8 ) + " ", ;
               hb_ColorIndex( ::cColorSpec, 5 ) )
      
#ifdef HB_EXTENSION
      IF ::shadowed
         hb_Shadow( nTop + 1, nLeft + 1, ::nBottom + 1, ::nRight + 1 )
      ENDIF
#endif

      nLeft++
      FOR nPos := 1 TO nLen

         nTop++

         IF aItems[ nPos ]:caption == MENU_SEPARATOR

            DispOutAt( nTop, nLeft - 1, SubStr( ::cBorder, 9, 1 ) + Replicate( SubStr( ::cBorder, 10, 1 ), nWidth ) + SubStr( ::cBorder, 11, 1 ), hb_ColorIndex( ::cColorSpec, 5 ) )

         ELSE
            cCaption := PadR( aItems[ nPos ]:caption, nWidth - 1 )

            IF aItems[ nPos ]:checked
               cCaption := SubStr( aItems[ nPos ]:style, 1, 1 ) + cCaption
            ELSE
               cCaption := " " + cCaption
            ENDIF

            IF aItems[ nPos ]:isPopup()

               oPopup := aItems[ nPos ]:data
               oPopup:top    := nTop
               oPopup:left   := ::nRight + 1
               oPopup:bottom := NIL
               oPopup:right  := NIL

               cCaption += SubStr( aItems[ nPos ]:style, 2, 1 )
            ELSE
               cCaption += " "
            ENDIF

            aItems[ nPos ]:__row := nTop
            aItems[ nPos ]:__col := nLeft

            IF ( nHotKeyPos := At( "&", cCaption ) ) == 0
               IF ( nCharPos := RAt( SubStr( aItems[ nPos ]:style, 2, 1 ), cCaption ) ) > 0
                  cCaption := Stuff( cCaption, nCharPos - 1, 1, "" )
               ELSE
                  cCaption := SubStr( cCaption, 1, Len( cCaption ) - 1 )
               ENDIF
            ELSEIF nHotKeyPos == Len( Trim( cCaption ) )
               cCaption := SubStr( cCaption, 1, Len( cCaption ) - 1 )
               nHotKeyPos := 0
            ELSE
               cCaption := Stuff( cCaption, nHotKeyPos, 1, "" )
            ENDIF

            DispOutAt( nTop, nLeft, cCaption, hb_ColorIndex( ::cColorSpec, iif( nPos == nCurrent, 1, iif( aItems[ nPos ]:enabled, 0, 4 ) ) ) )

            IF aItems[ nPos ]:enabled .AND. nHotKeyPos != 0
               DispOutAt( nTop, nLeft + nHotKeyPos - 1, SubStr( cCaption, nHotKeyPos, 1 ), hb_ColorIndex( ::cColorSpec, iif( nPos == nCurrent, 3, 2 ) ) )
            ENDIF
         ENDIF
      NEXT
      
      DispEnd()

      MSetCursor( lOldMCur )
      SetPos( nOldRow, nOldCol )

   ENDIF

   RETURN Self
tpopup.prg194
POPUPMENU:METHODgetAccel( xKey ) CLASS POPUPMENU
METHOD getAccel( xKey ) CLASS POPUPMENU
   LOCAL nLen := ::nItemCount
   LOCAL aItems := ::aItems
   LOCAL nPos
   LOCAL tmp
   LOCAL cCaption

   IF ISNUMBER( xKey )
      xKey := Chr( xKey )
   ENDIF

   xKey := Lower( xKey )

   FOR tmp := 1 TO nLen

      cCaption := aItems[ tmp ]:caption

      IF ( nPos := At( "&", cCaption ) ) > 0 .AND. ;
         nPos != Len( cCaption ) .AND. ;
         xKey == Lower( SubStr( cCaption, nPos + 1, 1 ) )

         RETURN tmp
      ENDIF
   NEXT

   RETURN 0
tpopup.prg303
POPUPMENU:METHODgetFirst() CLASS POPUPMENU
METHOD getFirst() CLASS POPUPMENU
   LOCAL nPos
   LOCAL nLen := ::nItemCount
   LOCAL aItems := ::aItems

   FOR nPos := 1 TO nLen
      IF aItems[ nPos ]:enabled
         RETURN nPos
      ENDIF
   NEXT

   RETURN 0
tpopup.prg330
POPUPMENU:METHODgetItem( nPos ) CLASS POPUPMENU
METHOD getItem( nPos ) CLASS POPUPMENU
   RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ], NIL )
tpopup.prg343
POPUPMENU:METHODgetLast() CLASS POPUPMENU
METHOD getLast() CLASS POPUPMENU
   LOCAL nPos
   LOCAL nLen := ::nItemCount
   LOCAL aItems := ::aItems

   FOR nPos := nLen TO 1 STEP -1
      IF aItems[ nPos ]:enabled
         RETURN nPos
      ENDIF
   NEXT

   RETURN 0
tpopup.prg346
POPUPMENU:METHODgetNext() CLASS POPUPMENU
METHOD getNext() CLASS POPUPMENU
   LOCAL nPos

   IF ::nCurrent < ::nItemCount
      FOR nPos := ::nCurrent + 1 TO ::nItemCount
         IF ::aItems[ nPos ]:enabled
            RETURN nPos
         ENDIF
      NEXT
   ENDIF

   RETURN 0
tpopup.prg359
POPUPMENU:METHODgetPrev() CLASS POPUPMENU
METHOD getPrev() CLASS POPUPMENU
   LOCAL nPos

   IF ::nCurrent > 1
      FOR nPos := ::nCurrent - 1 TO 1 STEP -1
         IF ::aItems[ nPos ]:enabled
            RETURN nPos
         ENDIF
      NEXT
   ENDIF

   RETURN 0
tpopup.prg372
POPUPMENU:METHODgetShortCt( nKey ) CLASS POPUPMENU
METHOD getShortCt( nKey ) CLASS POPUPMENU
   LOCAL nPos
   LOCAL nLen := ::nItemCount
   LOCAL aItems := ::aItems

   FOR nPos := 1 TO nLen
      IF aItems[ nPos ]:shortcut == nKey
#ifdef HB_EXTENSION
         IF aItems[ nPos ]:enabled
            RETURN nPos
         ENDIF
#else
         RETURN nPos
#endif
      ENDIF
   NEXT

   RETURN 0
tpopup.prg388
POPUPMENU:METHODhitTest( nMRow, nMCol ) CLASS POPUPMENU
METHOD hitTest( nMRow, nMCol ) CLASS POPUPMENU
   LOCAL nPos

   ::setMetrics()

   DO CASE
   CASE nMRow == ::nTop
      IF nMCol == ::nLeft
         RETURN HTTOPLEFT
      ELSEIF nMCol == ::nRight
         RETURN HTTOPRIGHT
      ELSEIF nMCol >= ::nLeft .AND. nMCol <= ::nRight
         RETURN HTTOP
      ENDIF
   CASE nMRow == ::nBottom
      IF nMCol == ::nLeft
         RETURN HTBOTTOMLEFT
      ELSEIF nMCol == ::nRight
         RETURN HTBOTTOMRIGHT
      ELSEIF nMCol >= ::nLeft .AND. nMCol <= ::nRight
         RETURN HTBOTTOM
      ENDIF
   CASE nMCol == ::nLeft
      IF nMRow >= ::nTop .AND. nMRow <= ::nBottom
         RETURN HTLEFT
      ELSE
         RETURN HTNOWHERE
      ENDIF
   CASE nMCol == ::nRight
      IF nMRow >= ::nTop .AND. nMRow <= ::nBottom
         RETURN HTRIGHT
      ELSE
         RETURN HTNOWHERE
      ENDIF
   CASE nMRow > ::nTop .AND. ;
        nMRow < ::nBottom .AND. ;
        nMCol > ::nLeft .AND. ;
        nMCol < ::nRight

      nPos := nMRow - ::nTop
      DO CASE
#ifdef HB_EXTENSION
      CASE !::aItems[ nPos ]:enabled
         RETURN HTNOWHERE
#endif
      CASE ::aItems[ nPos ]:caption == MENU_SEPARATOR
         RETURN HTSEPARATOR
      OTHERWISE
         RETURN nPos
      ENDCASE
   ENDCASE

   RETURN HTNOWHERE
tpopup.prg410
POPUPMENU:METHODinsItem( nPos, oItem ) CLASS POPUPMENU
METHOD insItem( nPos, oItem ) CLASS POPUPMENU

   IF nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;
      ISOBJECT( oItem ) .AND. oItem:ClassName() == "MENUITEM"

      ASize( ::aItems, ++::nItemCount )
      AIns( ::aItems, nPos )
      ::aItems[ nPos ] := oItem

      ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )

   ENDIF

   RETURN Self
tpopup.prg464
POPUPMENU:METHODisOpen() CLASS POPUPMENU
METHOD isOpen() CLASS POPUPMENU
   RETURN ::aSaveScr != NIL
tpopup.prg479
POPUPMENU:METHODopen() CLASS POPUPMENU
METHOD open() CLASS POPUPMENU

   LOCAL nTop
   LOCAL nLeft
   LOCAL nBottom
   LOCAL nRight

   ::setMetrics()

   nTop := ::nTop
   nLeft := ::nLeft

   IF ( nBottom := ::nBottom ) < 0
      nBottom := nTop + ::nItemCount + 1
   ENDIF
   IF ( nRight := ::nRight ) < 0
      nRight := nLeft + ::nWidth + 1
   ENDIF
   IF nRight < 0 .OR. nRight > MaxCol()
      ::nLeft := MaxCol() - ::nWidth - 1
      ::nRight := MaxCol()
      ::nTop++
      ::nBottom++
      nLeft := ::nLeft
      nRight := ::nRight
      nTop := ::nTop
      nBottom := ::nBottom
   ENDIF

   ::aSaveScr := { nTop, nLeft, nBottom, nRight, SaveScreen( nTop, nLeft, nBottom, nRight ) }

   ::display()

   RETURN Self
tpopup.prg482
POPUPMENU:METHODselect( nPos ) CLASS POPUPMENU
METHOD select( nPos ) CLASS POPUPMENU

   IF ( nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;
      ::nCurrent != nPos .AND. ;
      ::aItems[ nPos ]:enabled ) .OR. nPos == 0

//    IF ::isOpen() .AND. ;
//       ::nCurrent > 0 .AND. ;
//       ::aItems[ ::nCurrent ]:isPopUp()
//
//       ::aItems[ ::nCurrent ]:data:close()
//    ENDIF

      ::nCurrent := nPos
   ENDIF

   RETURN Self
tpopup.prg517
POPUPMENU:METHODsetItem( nPos, oItem ) CLASS POPUPMENU
METHOD setItem( nPos, oItem ) CLASS POPUPMENU

   IF nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;
      ISOBJECT( oItem ) .AND. oItem:ClassName() == "MENUITEM"

      ::aItems[ nPos ] := oItem
      ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )
   ENDIF

   RETURN Self /* NOTE: CA-Cl*pper returns NIL, which is wrong. */
tpopup.prg535
POPUPMENU:METHODsetCoors( nRow, nCol, lTop ) CLASS POPUPMENU
METHOD setCoors( nRow, nCol, lTop ) CLASS POPUPMENU
   LOCAL oItem
   LOCAL nDif

   ::setMetrics()

   IF ::nTop == -1 .OR. ::nLeft == -1
      ::nTop    := nRow
      ::nLeft   := nCol
      ::nBottom := ::nTop + ::nItemCount + 1
      ::nRight  := ::nLeft + ::nWidth - 1

      IF ::nRight > MaxCol()
         nDif     := ::nRight - MaxCol()
         ::nRight -= nDif
         ::nLeft  -= nDif
         IF !lTop
            ::nTop++
            ::nBottom++
         ENDIF
      ENDIF

      IF ::nLeft < 0
         nDif     := ::nLeft
         ::nRight -= nDif
         ::nLeft  -= nDif
      ENDIF

      IF ::nBottom > MaxRow()
         nDif      := ::nBottom - MaxRow()
         ::nBottom -= nDif
         ::nTop    -= nDif
      ENDIF

      IF ::nTop < 0
         nDif      := ::nTop
         ::nBottom -= nDif
         ::nTop    -= nDif
      ENDIF

      FOR EACH oItem IN ::aItems
         IF oItem:isPopup()
            oItem:data:setCoors( nRow + oItem:__enumIndex(), ::nRight + 1, .F. )
         ENDIF
      NEXT
   ENDIF

   RETURN Self
tpopup.prg548
POPUPMENU:METHODisShortCut( nKey, nID ) CLASS POPUPMENU
METHOD isShortCut( nKey, nID ) CLASS POPUPMENU

   LOCAL nItem
   LOCAL nTotal
   LOCAL nShortCut
   LOCAL oItem
   LOCAL i

   DO CASE
   // Test and assign top menu item shortCut, enabled, and !PopUp:
   // Changed by enclosing assignment before ':Enabled':
   CASE ( ( nShortCut := ::getShortCt( nKey ) ) > 0 ) .AND. ;
          ( ( oItem := ::getItem( nShortcut ) ):enabled ) .AND. ;
          ( !( oItem:isPopUp() ) )
      ::select( nShortCut )
      Eval( oItem:data, oItem )
      nID := oItem:id

      RETURN .T.

   // Test and assignment for TopBar MenuItem:
   CASE nShortCut == 0
      nTotal := ::nItemCount
      nItem  := ::nCurrent
      IF nItem == 0
         nItem := 1
      ENDIF

      // Loop to wrap around through TopMenu from Current Item:
      FOR i := 1 TO nTotal
         IF !( oItem := ::getItem( nItem ) ):enabled
         ELSEIF !oItem:isPopUp()
         ELSEIF oItem:data:isQuick( nKey, @nID )
            RETURN .T.
         ENDIF
         IF ++nItem > nTotal
            nItem := 1
         ENDIF
      NEXT

   ENDCASE

   RETURN .F.
tpopup.prg597
POPUPMENU:METHODisQuick( nKey, nID ) CLASS POPUPMENU
METHOD isQuick( nKey, nID ) CLASS POPUPMENU

   LOCAL nItem
   LOCAL nTotal
   LOCAL nShortCut
   LOCAL oItem

   IF ( nShortCut := ::getShortCt( nKey ) ) == 0

      nTotal := ::nItemCount

      FOR nItem := 1 TO nTotal
         IF !( oItem := ::getItem( nItem ) ):Enabled
         ELSEIF ! oItem:isPopUp()
         ELSEIF oItem:Data:isQuick( nKey, @nID )
            RETURN .T.
         ENDIF
      NEXT

   ELSEIF !( oItem := ::getItem( nShortCut ) ):IsPopUp()

      IF oItem:enabled
         ::select( nShortCut )
         Eval( oItem:Data, oItem )
         nID := oItem:id
         RETURN .T.
      ENDIF

   ENDIF

   RETURN .F.
tpopup.prg641
POPUPMENU:METHODsetMetrics() CLASS POPUPMENU
METHOD setMetrics() CLASS POPUPMENU

   IF ::nTop != NIL
   ELSEIF ::nBottom == NIL
      ::nTop := Int( ( MaxRow() - ( ::nItemCount + 2 ) ) / 2 )
   ELSE
      ::nTop := ::nBottom - ::nItemCount - 1
   ENDIF

   IF ::nLeft != NIL
   ELSEIF ::nRight == NIL
      ::nLeft := Int( ( MaxCol() - ( ::nWidth + 2 ) ) / 2 )
   ELSE
      ::nLeft := ::nRight - ::nWidth - 1
   ENDIF

   ::nBottom := ::nTop + ::nItemCount + 1
   ::nRight := ::nLeft + ::nWidth + 1

   RETURN Self
tpopup.prg675
POPUPMENU:METHODborder( cBorder ) CLASS POPUPMENU
METHOD border( cBorder ) CLASS POPUPMENU

   IF cBorder != NIL
      ::cBorder := __eInstVar53( Self, "BORDER", cBorder, "C", 1001, {|| Len( cBorder ) == 0 .OR. Len( cBorder ) == 11 } )
   ENDIF

   RETURN ::cBorder
tpopup.prg696
POPUPMENU:METHODbottom( nBottom ) CLASS POPUPMENU
METHOD bottom( nBottom ) CLASS POPUPMENU

#ifdef HB_C52_STRICT
   IF nBottom != NIL
      ::nBottom := __eInstVar53( Self, "BOTTOM", nBottom, "N", 1001 )
   ENDIF
#else
   IF PCount() > 0
      ::nBottom := iif( nBottom == NIL, NIL, __eInstVar53( Self, "BOTTOM", nBottom, "N", 1001 ) )
   ENDIF
#endif

   RETURN ::nBottom
tpopup.prg704
POPUPMENU:METHODcolorSpec( cColorSpec ) CLASS POPUPMENU
METHOD colorSpec( cColorSpec ) CLASS POPUPMENU

   IF cColorSpec != NIL
      ::cColorSpec := __eInstVar53( Self, "COLORSPEC", cColorSpec, "C", 1001,;
         {|| !Empty( hb_ColorIndex( cColorSpec, 5 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 6 ) ) } )
   ENDIF

   RETURN ::cColorSpec
tpopup.prg718
POPUPMENU:METHODcurrent() CLASS POPUPMENU
METHOD current() CLASS POPUPMENU
   RETURN ::nCurrent
tpopup.prg727
POPUPMENU:METHODitemCount() CLASS POPUPMENU
METHOD itemCount() CLASS POPUPMENU
   RETURN ::nItemCount
tpopup.prg730
POPUPMENU:METHODleft( nLeft ) CLASS POPUPMENU
METHOD left( nLeft ) CLASS POPUPMENU

#ifdef HB_C52_STRICT
   IF nLeft != NIL
      ::nLeft := __eInstVar53( Self, "LEFT", nLeft, "N", 1001 )
   ENDIF
#else
   IF PCount() > 0
      ::nLeft := iif( nLeft == NIL, NIL, __eInstVar53( Self, "LEFT", nLeft, "N", 1001 ) )
   ENDIF
#endif

   RETURN ::nLeft
tpopup.prg733
POPUPMENU:METHODright( nRight ) CLASS POPUPMENU
METHOD right( nRight ) CLASS POPUPMENU

#ifdef HB_C52_STRICT
   IF nRight != NIL
      ::nRight := __eInstVar53( Self, "RIGHT", nRight, "N", 1001 )
   ENDIF
#else
   IF PCount() > 0
      ::nRight := iif( nRight == NIL, NIL, __eInstVar53( Self, "RIGHT", nRight, "N", 1001 ) )
   ENDIF
#endif

   RETURN ::nRight
tpopup.prg747
POPUPMENU:METHODtop( nTop ) CLASS POPUPMENU
METHOD top( nTop ) CLASS POPUPMENU

#ifdef HB_C52_STRICT
   IF nTop != NIL
      ::nTop := __eInstVar53( Self, "TOP", nTop, "N", 1001 )
   ENDIF
#else
   IF PCount() > 0
      ::nTop := iif( nTop == NIL, NIL, __eInstVar53( Self, "TOP", nTop, "N", 1001 ) )
   ENDIF
#endif

   RETURN ::nTop
tpopup.prg761
POPUPMENU:METHODwidth() CLASS POPUPMENU
METHOD width() CLASS POPUPMENU
   RETURN ::nWidth
tpopup.prg775
POPUPMENU:METHODNew( nTop, nLeft, nBottom, nRight ) CLASS POPUPMENU
METHOD New( nTop, nLeft, nBottom, nRight ) CLASS POPUPMENU
   LOCAL cColor

   IF ISNUMBER( nTop )
      ::nTop := nTop
   ENDIF
   IF ISNUMBER( nLeft )
      ::nLeft := nLeft
   ENDIF
   IF ISNUMBER( nBottom )
      ::nBottom := nBottom
   ENDIF
   IF ISNUMBER( nRight )
      ::nRight := nRight
   ENDIF

   IF IsDefColor()
      ::cColorSpec := "N/W,W/N,W+/W,W+/N,N+/W,W/N"
   ELSE
      cColor := SetColor()
      ::cColorSpec := hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," +;
                      hb_ColorIndex( cColor, CLR_ENHANCED   ) + "," +;
                      hb_ColorIndex( cColor, CLR_BACKGROUND ) + "," +;
                      hb_ColorIndex( cColor, CLR_ENHANCED   ) + "," +;
                      hb_ColorIndex( cColor, CLR_STANDARD   ) + "," +;
                      hb_ColorIndex( cColor, CLR_BORDER     )
   ENDIF

   RETURN Self
tpopup.prg778
FUNCTIONPopUp( nTop, nLeft, nBottom, nRight )
FUNCTION PopUp( nTop, nLeft, nBottom, nRight )
   RETURN HBPopUpMenu():New( nTop, nLeft, nBottom, nRight )
tpopup.prg808
treport.prg
TypeFunctionSourceLine
METHODNew( cFrmName AS STRING, lPrinter AS LOGICAL, cAltFile AS STRING, lNoConsole AS LOGICAL, bFor AS CODEBLOCK, bWhile AS CODEBLOCK, nNext AS NUMERIC, nRecord AS NUMERIC, lRest AS LOGICAL, lPlain AS LOGICAL, cHeading AS STRING, lBEject AS LOGICAL, lSummary AS LOGICAL )
   METHOD New( cFrmName AS STRING,;
               lPrinter AS LOGICAL,;
               cAltFile AS STRING,;
               lNoConsole AS LOGICAL,;
               bFor AS CODEBLOCK,;
               bWhile AS CODEBLOCK,;
               nNext AS NUMERIC,;
               nRecord AS NUMERIC,;
               lRest AS LOGICAL,;
               lPlain AS LOGICAL, ;
               cHeading AS STRING,;
               lBEject AS LOGICAL,;
               lSummary AS LOGICAL )
treport.prg167
METHODExecuteReport()
   METHOD ExecuteReport()
treport.prg181
METHODReportHeader()
   METHOD ReportHeader()
treport.prg182
METHODEjectPage()
   METHOD EjectPage()
treport.prg183
METHODPrintIt( cString AS STRING )
   METHOD PrintIt( cString AS STRING )
treport.prg184
METHODLoadReportFile( cFile AS STRING )
   METHOD LoadReportFile( cFile AS STRING )
treport.prg185
METHODGetExpr( nPointer AS NUMERIC )
   METHOD GetExpr( nPointer AS NUMERIC )
treport.prg186
METHODGetColumn( cFieldsBuffer AS STRING, nOffset AS NUMERIC )
   METHOD GetColumn( cFieldsBuffer AS STRING, nOffset AS NUMERIC )

ENDCLASS
treport.prg187
HBREPORTFORM:METHODNew( cFrmName, lPrinter, cAltFile, lNoConsole, bFor, bWhile, nNext, nRecord, lRest, lPlain, cHeading, lBEject, lSummary ) CLASS HBReportForm
METHOD New( cFrmName, lPrinter, cAltFile, lNoConsole, bFor, bWhile, nNext, nRecord,;
           lRest, lPlain, cHeading, lBEject, lSummary ) CLASS HBReportForm

   LOCAL lPrintOn, lConsoleOn // Status of PRINTER and CONSOLE
   LOCAL cExtraFile, lExtraState // Status of EXTRA
   LOCAL nCol, nGroup
   LOCAL xBreakVal, lBroke := .F.
   LOCAL err
   LOCAL cExt

   LOCAL lAnyTotals
   LOCAL lAnySubTotals

   // Resolve parameters
   IF cFRMName == NIL
      err := ErrorNew()
      err:severity := ES_ERROR
      err:genCode := EG_ARG
      err:subSystem := "FRMLBL"
      Eval(ErrorBlock(), err)
   ELSE
      /* NOTE: CA-Cl*pper does an RTrim() on the filename here, 
               but in Harbour we're using _SET_TRIMFILENAME. [vszakats] */
      IF Set( _SET_DEFEXTENSIONS )
         hb_FNameSplit( cFRMName, NIL, NIL, @cExt )
         IF Empty( cExt )
            cFRMName += ".frm"
         ENDIF
      ENDIF
   ENDIF

#ifdef OLDCODE
   DEFAULT lPrinter TO .F.
#endif
   DEFAULT cHeading TO ""

   // Set output devices

   lPrintOn   := iif( lPrinter, SET( _SET_PRINTER, lPrinter ), SET( _SET_PRINTER ) )

   lConsoleOn := iif( lNoConsole, SET( _SET_CONSOLE, .F.), SET( _SET_CONSOLE ) )

   IF lPrinter                   // To the printer
      ::lFormFeeds := .T.
   ELSE
      ::lFormFeeds := .F.
   ENDIF

   IF !Empty(cAltFile)            // To file
      lExtraState := SET( _SET_EXTRA, .T. )
      cExtraFile := SET( _SET_EXTRAFILE, cAltFile )
   ENDIF


   BEGIN SEQUENCE

      ::aReportData := ::LoadReportFile( cFRMName )  // Load the frm into an array
      ::nMaxLinesAvail := ::aReportData[RPT_LINES]

      // Modify ::aReportData based on the report parameters
      IF lSummary                    // Set the summary only flag
         ::aReportData[ RPT_SUMMARY ] := lSummary
      ENDIF
      IF lBEject != NIL .AND. lBEject
         ::aReportData[ RPT_BEJECT ]  := .F.
      ENDIF
      IF lPlain                      // Set plain report flag
         ::aReportData[ RPT_PLAIN ]   := .T.
         cHeading                     := ""
         ::lFormFeeds                 := .F.
      ENDIF
      ::aReportData[ RPT_HEADING ]    := cHeading

      // Add to the left margin if a SET MARGIN has been defined
      // NOTE: uncommenting this line will cause REPORT FORM to respect
      // SET MARGIN to screen/to file, but double the margin TO PRINT
      // ::aReportData[ RPT_LMARGIN ] += SET( _SET_MARGIN )

      ::nPageNumber := 1                  // Set the initial page number
      ::lFirstPass  := .T.             // Set the first pass flag

      ::nLinesLeft  := ::aReportData[ RPT_LINES ]


      // Check to see if a "before report" eject, or TO FILE has been specified
      IF ::aReportData[ RPT_BEJECT ]
         ::EjectPage()

      ENDIF

      // Generate the initial report header manually (in case there are no
      // records that match the report scope)
      ::ReportHeader()

      // Initialize ::aReportTotals to track both group and report totals, then
      // set the column total elements to 0 if they are to be totaled, otherwise
      // leave them NIL
      ::aReportTotals := ARRAY( LEN(::aReportData[RPT_GROUPS]) + 1, ;
                        LEN(::aReportData[RPT_COLUMNS]) )

      // Column total elements
      FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
         IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL]
            FOR nGroup := 1 TO LEN(::aReportTotals)
               ::aReportTotals[nGroup,nCol] := 0
            NEXT
         ENDIF
      NEXT

      // Initialize ::aGroupTotals as an array
      ::aGroupTotals := ARRAY( LEN(::aReportData[RPT_GROUPS]) )

      // Execute the actual report based on matching records
      DBEval( { || ::ExecuteReport() }, bFor, bWhile, nNext, nRecord, lRest )

      // Generate any totals that may have been identified
      // Make a pass through all the groups
      FOR nGroup := LEN(::aReportData[RPT_GROUPS]) TO 1 STEP -1


         // make sure group has subtotals
         lAnySubTotals := .F.
         FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
            IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL]
               lAnySubTotals := .T.
               EXIT              // NOTE
            ENDIF
         NEXT

         IF !lAnySubTotals
            LOOP                 // NOTE
         ENDIF


         // Check to see if we need to eject the page
         IF ::nLinesLeft < 2
            ::EjectPage()
            IF ::aReportData[ RPT_PLAIN ]
               ::nLinesLeft := 1000
            ELSE
               ::ReportHeader()
            ENDIF
         ENDIF

         // Print the first line
         ::PrintIt( SPACE( ::aReportData[RPT_LMARGIN] ) + ;
               iif( nGroup == 1, __NatMsg( _RFRM_SUBTOTAL ),;
                                 __NatMsg( _RFRM_SUBSUBTOTAL ) ) )

         // Print the second line
         QQOUT( SPACE(::aReportData[RPT_LMARGIN]) )
         FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
            IF nCol > 1
               QQOUT( " " )
            ENDIF
            IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL]
               QQOUT( TRANSFORM(::aReportTotals[nGroup+1,nCol], ;
               ::aReportData[RPT_COLUMNS,nCol,RCT_PICT]) )
            ELSE
               QQOUT( SPACE(::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH]) )
            ENDIF
         NEXT

         // Send a cr/lf for the last line
         QOUT()

      NEXT

      // Any report totals?
      lAnyTotals := .F.
      FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
         IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL]
            lAnyTotals := .T.
            EXIT
         ENDIF
      NEXT nCol


      IF lAnyTotals

         // Check to see if we need to eject the page
         IF ::nLinesLeft < 2
            ::EjectPage()
            IF ::aReportData[ RPT_PLAIN ]
               ::nLinesLeft := 1000
            ELSE
               ::ReportHeader()
            ENDIF
         ENDIF

         // Print the first line
         ::PrintIt( SPACE(::aReportData[RPT_LMARGIN]) + __NatMsg(_RFRM_TOTAL ) )

         // Print the second line
         QQOUT( SPACE(::aReportData[RPT_LMARGIN]) )
         FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
            IF nCol > 1
               QQOUT( " " )
            ENDIF
            IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL]
               QQOUT( TRANSFORM(::aReportTotals[1,nCol], ;
                  ::aReportData[RPT_COLUMNS,nCol,RCT_PICT]) )
            ELSE
               QQOUT( SPACE(::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH]) )
            ENDIF
         NEXT nCol

         // Send a cr/lf for the last line
         QOUT()

      ENDIF

      // Check to see if an "after report" eject, or TO FILE has been specified
      IF ::aReportData[ RPT_AEJECT ]
         ::EjectPage()
      ENDIF


   RECOVER USING xBreakVal

      lBroke := .T.

   END SEQUENCE


   // Clean up and leave
   ::aReportData    := NIL          // Recover the space
   ::aReportTotals  := NIL
   ::aGroupTotals   := NIL
   ::nPageNumber    := NIL
   ::lFirstPass     := NIL
   ::nLinesLeft     := NIL
   ::lFormFeeds     := NIL
   ::nMaxLinesAvail := NIL

   // clean up
   SET( _SET_PRINTER, lPrintOn )    // Set the printer back to prior state
   SET( _SET_CONSOLE, lConsoleOn )     // Set the console back to prior state

   IF !Empty(cAltFile)            // Set extrafile back
      SET( _SET_EXTRAFILE, cExtraFile )
      SET( _SET_EXTRA, lExtraState )
   ENDIF

   IF lBroke
      // keep the break value going
      BREAK xBreakVal
   ENDIF

   RETURN NIL
treport.prg191
HBREPORTFORM:METHODPrintIt( cString ) CLASS HBReportForm
METHOD PrintIt( cString ) CLASS HBReportForm

   DEFAULT cString TO ""

   QQOUT( cString )
   QOUT()

   RETURN Self
treport.prg442
HBREPORTFORM:METHODEjectPage() CLASS HBReportForm
METHOD EjectPage() CLASS HBReportForm

   IF ::lFormFeeds
      EJECT
   ENDIF

   RETURN Self
treport.prg451
HBREPORTFORM:METHODReportHeader() CLASS HBReportForm
METHOD ReportHeader() CLASS HBReportForm

   LOCAL nLinesInHeader := 0
   LOCAL aPageHeader    := {}
   LOCAL nHeadingLength := ::aReportData[RPT_WIDTH] - ::aReportData[RPT_LMARGIN] -30
   LOCAL nCol, nLine, nMaxColLength, cHeader
   LOCAL nHeadline
   LOCAL nRPageSize
   LOCAL aTempPgHeader
   LOCAL nHeadSize

   nRPageSize := ::aReportData[RPT_WIDTH] - ::aReportData[RPT_RMARGIN]

   IF !::aReportData[RPT_PLAIN]
      IF ::aReportData[RPT_HEADING] == ""
         AADD( aPageHeader,__NatMsg(_RFRM_PAGENO) + STR(::nPageNumber,6))

      ELSE
         aTempPgHeader:=ParseHeader( ::aReportData[RPT_HEADING],;
            Occurs(";",::aReportData[RPT_HEADING]) +1 )

         FOR nLine := 1 to LEN( aTempPgHeader)
            nLinesInHeader:=MAX( XMLCOUNT( LTRIM( aTempPgHeader[ nLine ] ) , ;
               nHeadingLength),1)

            FOR nHeadLine := 1 to nLinesInHeader
               AADD( aPageHeader, SPACE( 15 ) + ;
                  PADC( TRIM( XMEMOLINE( LTRIM( aTempPgHeader[ nLine ]),;
                  nHeadingLength,nHeadLine)), nHeadingLength))

            NEXT nHeadLine
         NEXT nLine
         aPageHeader[ 1 ] := STUFF(aPageHeader[ 1 ], 1, 14, ;
                                   __NatMsg(_RFRM_PAGENO)+STR(::nPageNumber,6))

      ENDIF
      AADD( aPageHeader, DTOC(DATE()) )

   ENDIF
   FOR nLine := 1  TO LEN( ::aReportData[ RPT_HEADER])
      nLinesInHeader := MAX( XMLCOUNT(LTRIM( ::aReportData[RPT_HEADER,;
         nLine ] ), nHeadSize),1 )

      FOR nHeadLine := 1 to nLinesInHeader

         cHeader:=TRIM( XMEMOLINE( LTRIM( ::aReportData[RPT_HEADER, nLine ]),;
            nHeadSize,nHeadLine))
         AADD( aPageHeader, SPACE((nRPageSize - ::aReportData[ RPT_LMARGIN ] -;
             LEN( cHeader ) ) / 2   ) + cHeader )

      NEXT nHeadLine

   NEXT nLine

   nLinesInHeader := LEN( aPageHeader)
   nMaxColLength :=0
   FOR nCol := 1 TO LEN( ::aReportData[RPT_COLUMNS] )
      nMaxColLength := MAX(LEN(::aReportData[RPT_COLUMNS,nCol,RCT_HEADER]), ;
                            nMaxColLength)
   NEXT
   FOR nCol := 1 to LEN( ::aReportData[RPT_COLUMNS] )
      ASIZE( ::aReportData[RPT_COLUMNS,nCol,RCT_HEADER] ,nMaxColLength)
   NEXT
   FOR nLine:=1 TO nMaxColLength
      AADD( aPageHeader, "")
   NEXT

   FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])    // Cycle through the columns
      FOR nLine := 1 TO nMaxColLength
         IF nCol > 1
            aPageHeader[ nLinesInHeader + nLine ] += " "
         ENDIF
         IF ::aReportData[RPT_COLUMNS,nCol,RCT_HEADER,nLine] == NIL
            aPageHeader[ nLinesInHeader + nLine ] += ;
                           SPACE( ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH] )
         ELSE
            IF ::aReportData[RPT_COLUMNS,nCol,RCT_TYPE] == "N"
               aPageHeader[ nLinesInHeader + nLine ] += ;
                           PADL(::aReportData[RPT_COLUMNS,nCol,RCT_HEADER,nLine],;
                           ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH])
            ELSE
               aPageHeader[ nLinesInHeader + nLine ] += ;
                           PADR(::aReportData[RPT_COLUMNS,nCol,RCT_HEADER,nLine],;
                           ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH])
            ENDIF
         ENDIF
      NEXT
   NEXT

   // Insert the two blank lines between the heading and the actual data
   AADD( aPageHeader, "" )
   AADD( aPageHeader, "" )
   AEVAL( aPageHeader, { | HeaderLine | ;
         ::PrintIt( SPACE(::aReportData[RPT_LMARGIN])+ HeaderLine ) } )

   // Set the page number and number of available lines
   ::nPageNumber++

   // adjust the line count to account for Summer '87 behavior
   ::nLinesLeft := ::aReportData[RPT_LINES] - LEN( aPageHeader )
   ::nMaxLinesAvail := ::aReportData[RPT_LINES] - LEN( aPageHeader )

   RETURN SELF
treport.prg459
HBREPORTFORM:METHODExecuteReport() CLASS HBReportForm
METHOD ExecuteReport() CLASS HBReportForm

   LOCAL aRecordHeader  := {}          // Header for the current record
   LOCAL aRecordToPrint := {}          // Current record to print
   LOCAL nCol                          // Counter for the column work
   LOCAL nGroup                        // Counter for the group work
   LOCAL lGroupChanged  := .F.         // Has any group changed?
   LOCAL lEjectGrp := .F.              // Group eject indicator
   LOCAL nMaxLines                     // Number of lines needed by record
   LOCAL nLine                         // Counter for each record line
   LOCAL cLine                         // Current line of text for parsing

   LOCAL lAnySubTotals

   // Add to the main column totals
   FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
      IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL]
         // If this column should be totaled, do it
         ::aReportTotals[ 1 ,nCol] += ;
                  EVAL( ::aReportData[RPT_COLUMNS,nCol,RCT_EXP] )
      ENDIF
   NEXT

   // Determine if any of the groups have changed.  If so, add the appropriate
   // line to aRecordHeader for totaling out the previous records
   IF !::lFirstPass                       // Don't bother first time through

      // Make a pass through all the groups
      FOR nGroup := LEN(::aReportData[RPT_GROUPS]) TO 1 STEP -1


         // make sure group has subtotals
         lAnySubTotals := .F.
         FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
            IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL]
               lAnySubTotals := .T.
               EXIT              // NOTE
            ENDIF
         NEXT

         // retrieve group eject state from report form
         IF nGroup == 1
            lEjectGrp := ::aReportData[ RPT_GROUPS, nGroup, RGT_AEJECT ]
         ENDIF

         IF !lAnySubTotals
            LOOP                 // NOTE
         ENDIF

         //  For subgroup processing: check if group has been changed
         IF MakeAStr(EVAL(::aReportData[RPT_GROUPS, 1, RGT_EXP]),;
              ::aReportData[RPT_GROUPS, 1, RGT_TYPE]) != ::aGroupTotals[1]
            lGroupChanged  := .T.
         ENDIF

         //  If this (sub)group has changed since the last record
         IF lGroupChanged .OR. MakeAStr(EVAL(::aReportData[RPT_GROUPS,nGroup,RGT_EXP]),;
             ::aReportData[RPT_GROUPS,nGroup,RGT_TYPE]) != ::aGroupTotals[nGroup]

            AADD( aRecordHeader, iif( nGroup == 1, __NatMsg(_RFRM_SUBTOTAL),;
                                                   __NatMsg(_RFRM_SUBSUBTOTAL) ) )
            AADD( aRecordHeader, "" )


            // Cycle through the columns, adding either the group
            // amount from ::aReportTotals or spaces wide enough for
            // the non-totaled columns
            FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
               IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL]
                  aRecordHeader[ LEN(aRecordHeader) ] += ;
                     TRANSFORM(::aReportTotals[nGroup+1,nCol], ;
                     ::aReportData[RPT_COLUMNS,nCol,RCT_PICT])
                  // Zero out the group totals column from aReportTotals
                  ::aReportTotals[nGroup+1,nCol] := 0
               ELSE
                  aRecordHeader[ LEN(aRecordHeader) ] += ;
                        SPACE(::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH])
               ENDIF
               aRecordHeader[ LEN(aRecordHeader) ] += " "
            NEXT
            // Get rid of the extra space from the last column
            aRecordHeader[LEN(aRecordHeader)] := ;
                  LEFT( aRecordHeader[LEN(aRecordHeader)], ;
                  LEN(aRecordHeader[LEN(aRecordHeader)]) - 1 )
         ENDIF
      NEXT

   ENDIF


   IF LEN( aRecordHeader ) > 0 .AND. lEjectGrp .AND. lGroupChanged
      IF LEN( aRecordHeader ) > ::nLinesLeft
         ::EjectPage()

         IF ::aReportData[ RPT_PLAIN ]
            ::nLinesLeft := 1000
         ELSE
            ::ReportHeader()
         ENDIF

      ENDIF

      AEVAL( aRecordHeader, { | HeaderLine | ;
         ::PrintIt( SPACE( ::aReportData[ RPT_LMARGIN ] ) + HeaderLine ) } )

      aRecordHeader := {}

      ::EjectPage()

      IF ::aReportData[ RPT_PLAIN ]
         ::nLinesLeft := 1000

      ELSE
         ::ReportHeader()

      ENDIF

   ENDIF

   // Add to aRecordHeader in the event that the group has changed and
   // new group headers need to be generated

   // Cycle through the groups
   FOR nGroup := 1 TO LEN(::aReportData[RPT_GROUPS])
      // If the group has changed
      IF MakeAStr(EVAL(::aReportData[RPT_GROUPS,nGroup,RGT_EXP]),;
            ::aReportData[RPT_GROUPS,nGroup,RGT_TYPE]) == ::aGroupTotals[nGroup]
      ELSE
         AADD( aRecordHeader, "" )   // The blank line

         // page eject after group

         //  put CRFF after group
         IF nGroup == 1 .AND. !::lFirstPass .AND. !lAnySubTotals
            IF lEjectGrp := ::aReportData[ RPT_GROUPS, nGroup, RGT_AEJECT ]
               ::nLinesLeft  := 0
            ENDIF
         ENDIF


         AADD( aRecordHeader, iif( nGroup == 1, "** ", "* " ) +;
               ::aReportData[RPT_GROUPS,nGroup,RGT_HEADER] + " " +;
               MakeAStr(EVAL(::aReportData[RPT_GROUPS,nGroup,RGT_EXP]), ;
               ::aReportData[RPT_GROUPS,nGroup,RGT_TYPE]) )
      ENDIF
   NEXT

   ::lFirstPass := .F.

   // Is there anything in the record header?
   IF LEN( aRecordHeader ) > 0
      // Determine if aRecordHeader will fit on the current page.  If not,
      // start a new header
      IF LEN( aRecordHeader ) > ::nLinesLeft
         ::EjectPage()
         IF ::aReportData[ RPT_PLAIN ]
            ::nLinesLeft := 1000
         ELSE
            ::ReportHeader()
         ENDIF
      ENDIF

      // Send aRecordHeader to the output device, resetting nLinesLeft
      AEVAL( aRecordHeader, { | HeaderLine | ;
              ::PrintIt( SPACE(::aReportData[RPT_LMARGIN])+ HeaderLine ) } )

      ::nLinesLeft -= LEN( aRecordHeader )

      // Make sure it didn't hit the bottom margin
      IF ::nLinesLeft == 0
         ::EjectPage()
         IF ::aReportData[ RPT_PLAIN ]
            ::nLinesLeft := 1000
         ELSE
            ::ReportHeader()
         ENDIF
      ENDIF
   ENDIF

   // Add to the group totals
   FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
      // If this column should be totaled, do it
      IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL]
         // Cycle through the groups
         FOR nGroup := 1 TO LEN( ::aReportTotals ) - 1
            ::aReportTotals[nGroup+1,nCol] += ;
               EVAL( ::aReportData[RPT_COLUMNS,nCol,RCT_EXP] )
         NEXT
      ENDIF
   NEXT

   // Reset the group expressions in aGroupTotals
   FOR nGroup := 1 TO LEN(::aReportData[RPT_GROUPS])
      ::aGroupTotals[nGroup] := MakeAStr(EVAL(::aReportData[RPT_GROUPS,nGroup,RGT_EXP]),;
                                    ::aReportData[RPT_GROUPS,nGroup,RGT_TYPE])
   NEXT

   // Only run through the record detail if this is NOT a summary report
   IF !::aReportData[ RPT_SUMMARY ]
      // Determine the max number of lines needed by each expression
      nMaxLines := 1
      FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])

         IF ::aReportData[RPT_COLUMNS,nCol,RCT_TYPE] $ "M"
            nMaxLines := MAX(XMLCOUNT(EVAL(::aReportData[RPT_COLUMNS,nCol,RCT_EXP]),;
                         ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH]), nMaxLines)
         ELSEIF ::aReportData[RPT_COLUMNS,nCol,RCT_TYPE] $ "C"
            nMaxLines := MAX( XMLCOUNT( STRTRAN( EVAL( ::aReportData[RPT_COLUMNS,nCol,RCT_EXP]),;
                         ";", CHR(13)+CHR(10)),;
                         ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH]), nMaxLines)
         ENDIF
      NEXT

      // Size aRecordToPrint to the maximum number of lines it will need, then
      // fill it with nulls
      ASIZE( aRecordToPrint, nMaxLines )
      AFILL( aRecordToPrint, "" )

      // Load the current record into aRecordToPrint
      FOR nCol := 1 TO LEN(::aReportData[RPT_COLUMNS])
         FOR nLine := 1 TO nMaxLines
            // Check to see if it's a memo or character
            IF ::aReportData[RPT_COLUMNS,nCol,RCT_TYPE] $ "CM"
               //  Load the current line of the current column into cLine
               //  with multi-lines per record ";"- method
               IF ::aReportData[RPT_COLUMNS,nCol,RCT_TYPE] $ "C"
                  cLine := XMEMOLINE( TRIM( STRTRAN( EVAL(::aReportData[RPT_COLUMNS,nCol,RCT_EXP]),;
                             ";", CHR(13)+CHR(10)) ),;
                             ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH], nLine )
               ELSE
                  cLine := XMEMOLINE(TRIM(EVAL(::aReportData[RPT_COLUMNS,nCol,RCT_EXP])),;
                             ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH], nLine )
               ENDIF
               cLine := PADR( cLine, ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH] )
            ELSE
               IF nLine == 1
                  cLine := TRANSFORM(EVAL(::aReportData[RPT_COLUMNS,nCol,RCT_EXP]),;
                           ::aReportData[RPT_COLUMNS,nCol,RCT_PICT])
                  cLine := PADR( cLine, ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH] )
               ELSE
                  cLine := SPACE( ::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH])
               ENDIF
            ENDIF
            // Add it to the existing report line
            IF nCol > 1
               aRecordToPrint[ nLine ] += " "
            ENDIF
            aRecordToPrint[ nLine ] += cLine
         NEXT
      NEXT

      // Determine if aRecordToPrint will fit on the current page
      IF LEN( aRecordToPrint ) > ::nLinesLeft
         // The record will not fit on the current page - will it fit on
         // a full page?  If not, break it up and print it.
         IF LEN( aRecordToPrint ) > ::nMaxLinesAvail
            // This record is HUGE!  Break it up...
            nLine := 1
            DO WHILE nLine < LEN( aRecordToPrint )
               ::PrintIt( SPACE(::aReportData[RPT_LMARGIN]) + aRecordToPrint[nLine] )
               nLine++
               ::nLinesLeft--
               IF ::nLinesLeft == 0
                  ::EjectPage()
                  IF ::aReportData[ RPT_PLAIN ]
                     ::nLinesLeft := 1000
                  ELSE
                     ::ReportHeader()
                  ENDIF
               ENDIF
            ENDDO
         ELSE
            ::EjectPage()
            IF ::aReportData[ RPT_PLAIN ]
               ::nLinesLeft := 1000
            ELSE
               ::ReportHeader()
            ENDIF
            AEVAL( aRecordToPrint, ;
               { | RecordLine | ;
                 ::PrintIt( SPACE(::aReportData[RPT_LMARGIN])+ RecordLine ) ;
               } ;
            )
            ::nLinesLeft -= LEN( aRecordToPrint )
         ENDIF
      ELSE
         // Send aRecordToPrint to the output device, resetting ::nLinesLeft
         AEVAL( aRecordToPrint, ;
            { | RecordLine | ;
              ::PrintIt( SPACE(::aReportData[RPT_LMARGIN])+ RecordLine ) ;
            } ;
         )
         ::nLinesLeft -= LEN( aRecordToPrint )
      ENDIF


      // Tack on the spacing for double/triple/etc.
      IF ::aReportData[ RPT_SPACING ] > 1

         /*  Double space problem in REPORT FORM at the bottom of the page  */
         IF ::nLinesLeft >= ::aReportData[ RPT_SPACING ] - 1

            FOR nLine := 2 TO ::aReportData[ RPT_SPACING ]
               ::PrintIt()
               ::nLinesLeft--
            NEXT
         ENDIF
      ENDIF

   ENDIF    // Was this a summary report?

   RETURN NIL
treport.prg563
HBREPORTFORM:METHODLoadReportFile( cFrmFile ) CLASS HBReportForm
METHOD LoadReportFile( cFrmFile ) CLASS HBReportForm
   LOCAL cFieldsBuff
   LOCAL cParamsBuff
   LOCAL nFieldOffset   := 0
   LOCAL cFileBuff      := SPACE(SIZE_FILE_BUFF)
   LOCAL cGroupExp      := SPACE(200)
   LOCAL cSubGroupExp   := SPACE(200)
   LOCAL nColCount      := 0        // Number of columns in report
   LOCAL nCount
   LOCAL nFrmHandle                 // (.frm) file handle
   LOCAL nBytesRead                 // Read/write and content record counter
   LOCAL nPointer       := 0        // Points to an offset into EXPR_BUFF string
   LOCAL nFileError                 // Contains current file error
   LOCAL cOptionByte                // Contains option byte

   LOCAL aReport[ RPT_COUNT ]        // Create report array
   LOCAL err                        // error object

   LOCAL cDefPath          // contents of SET DEFAULT string
   LOCAL aPaths            // array of paths
   LOCAL nPathIndex := 0   // iteration counter

   LOCAL aHeader                           // temporary storage for report form headings
   LOCAL nHeaderIndex              // index into temporary header array

   // Initialize STATIC buffer values
   ::cLengthsBuff  := ""
   ::cOffSetsBuff  := ""
   ::cExprBuff     := ""

   // Default report values
   aReport[ RPT_HEADER ]    := {}
   aReport[ RPT_WIDTH ]     := 80
   aReport[ RPT_LMARGIN ]   := 8
   aReport[ RPT_RMARGIN ]   := 0
   aReport[ RPT_LINES ]     := 58
   aReport[ RPT_SPACING ]   := 1
   aReport[ RPT_BEJECT ]    := .T.
   aReport[ RPT_AEJECT ]    := .F.
   aReport[ RPT_PLAIN ]     := .F.
   aReport[ RPT_SUMMARY ]   := .F.
   aReport[ RPT_COLUMNS ]   := {}
   aReport[ RPT_GROUPS ]    := {}
   aReport[ RPT_HEADING ]   := ""

   // Open the report file
   nFrmHandle := FOPEN( cFrmFile )

   IF !EMPTY( nFileError := FERROR() ) .AND. !( "\" $ cFrmFile .OR. ":" $ cFrmFile )

      // Search through default path; attempt to open report file
      cDefPath := SET( _SET_DEFAULT ) + ";" + SET( _SET_PATH )
      cDefPath := STRTRAN( cDefPath, ",", ";" )
      aPaths := ListAsArray( cDefPath, ";" )

      FOR nPathIndex := 1 TO LEN( aPaths )
         nFrmHandle := FOPEN( aPaths[ nPathIndex ] + "\" + cFrmFile )
         // if no error is reported, we have our report file
         IF EMPTY( nFileError := FERROR() )
            EXIT

         ENDIF

      NEXT nPathIndex

   ENDIF

   // File error
   IF nFileError != F_OK
      err := ErrorNew()
      err:severity := ES_ERROR
      err:genCode := EG_OPEN
      err:subSystem := "FRMLBL"
      err:osCode := nFileError
      err:filename := cFrmFile
      Eval(ErrorBlock(), err)
   ENDIF

   // OPEN ok?
   IF nFileError == F_OK

      // Go to START of report file
      FSEEK(nFrmHandle, 0)

      // SEEK ok?
      nFileError := FERROR()
      IF nFileError == F_OK

         // Read entire file into process buffer
         nBytesRead := FREAD(nFrmHandle, @cFileBuff, SIZE_FILE_BUFF)

         // READ ok?
         IF nBytesRead == 0
            nFileError := F_EMPTY        // file is empty
         ELSE
            nFileError := FERROR()       // check for DOS errors
         ENDIF

         IF nFileError == F_OK

            // Is this a .FRM type file (2 at start and end of file)
            IF BIN2W(SUBSTR(cFileBuff, 1, 2)) == 2 .AND.;
               BIN2W(SUBSTR(cFileBuff, SIZE_FILE_BUFF - 1, 2)) == 2

               nFileError := F_OK
            ELSE
               nFileError := F_ERROR
            ENDIF

         ENDIF

      ENDIF

      // Close file
      IF !FCLOSE(nFrmHandle)
         nFileError := FERROR()
      ENDIF

   ENDIF

   // File existed, was opened and read ok and is a .FRM file
   IF nFileError == F_OK

      // Fill processing buffers
      ::cLengthsBuff := SUBSTR(cFileBuff, LENGTHS_OFFSET, SIZE_LENGTHS_BUFF)
      ::cOffSetsBuff := SUBSTR(cFileBuff, OFFSETS_OFFSET, SIZE_OFFSETS_BUFF)
      ::cExprBuff    := SUBSTR(cFileBuff, EXPR_OFFSET, SIZE_EXPR_BUFF)
      cFieldsBuff  := SUBSTR(cFileBuff, FIELDS_OFFSET, SIZE_FIELDS_BUFF)
      cParamsBuff  := SUBSTR(cFileBuff, PARAMS_OFFSET, SIZE_PARAMS_BUFF)


      // Process report attributes
      // Report width
      aReport[ RPT_WIDTH ]   := BIN2W(SUBSTR(cParamsBuff, PAGE_WIDTH_OFFSET, 2))

      // Lines per page
      aReport[ RPT_LINES ]   := BIN2W(SUBSTR(cParamsBuff, LNS_PER_PAGE_OFFSET, 2))

      // Page offset (left margin)
      aReport[ RPT_LMARGIN ] := BIN2W(SUBSTR(cParamsBuff, LEFT_MRGN_OFFSET, 2))

      // Page right margin (not used)
      aReport[ RPT_RMARGIN ] := BIN2W(SUBSTR(cParamsBuff, RIGHT_MGRN_OFFSET, 2))

      nColCount  := BIN2W(SUBSTR(cParamsBuff, COL_COUNT_OFFSET, 2))

      // Line spacing
      // Spacing is 1, 2, or 3
      aReport[ RPT_SPACING ] := iif( SUBSTR( cParamsBuff, ;
       DBL_SPACE_OFFSET, 1) $ "YyTt", 2, 1)

      // Summary report flag
      aReport[ RPT_SUMMARY ] := iif( SUBSTR( cParamsBuff, ;
       SUMMARY_RPT_OFFSET, 1) $ "YyTt", .T., .F.)

      // Process report eject and plain attributes option byte
      cOptionByte := ASC(SUBSTR(cParamsBuff, OPTION_OFFSET, 1))

      IF INT(cOptionByte / 4) == 1
         aReport[ RPT_PLAIN ] := .T.          // Plain page
         cOptionByte -= 4
      ENDIF

      IF INT(cOptionByte / 2) == 1
         aReport[ RPT_AEJECT ] := .T.         // Page eject after report
         cOptionByte -= 2
      ENDIF

      IF INT(cOptionByte / 1) == 1
         aReport[ RPT_BEJECT ] := .F.         // Page eject before report
         cOptionByte -= 1
      ENDIF

      // Page heading, report title
      nPointer := BIN2W(SUBSTR(cParamsBuff, PAGE_HDR_OFFSET, 2))

      // Retrieve the header stored in the .FRM file
      nHeaderIndex := 4
      aHeader := ParseHeader( ::GetExpr( nPointer ), nHeaderIndex )

      // certain that we have retrieved all heading entries from the .FRM file, we
      // now retract the empty headings
      DO WHILE ( nHeaderIndex > 0 )
         IF ! EMPTY( aHeader[ nHeaderIndex ] )
            EXIT
         ENDIF
         nHeaderIndex--
      ENDDO

      aReport[ RPT_HEADER ] := iif( EMPTY( nHeaderIndex ) , {}, ;
                   ASIZE( aHeader, nHeaderIndex ) )

      // Process Groups
      // Group
      nPointer := BIN2W(SUBSTR(cParamsBuff, GRP_EXPR_OFFSET, 2))

      IF !EMPTY(cGroupExp := ::GetExpr( nPointer ))

         // Add a new group array
         AADD( aReport[ RPT_GROUPS ], ARRAY( RGT_COUNT ))

         // Group expression
         aReport[ RPT_GROUPS ][1][ RGT_TEXT ] := cGroupExp
         aReport[ RPT_GROUPS ][1][ RGT_EXP ] := &( "{ || " + cGroupExp + "}" )
         IF USED()
            aReport[ RPT_GROUPS ][1][ RGT_TYPE ] := ;
                           VALTYPE( EVAL( aReport[ RPT_GROUPS ][1][ RGT_EXP ] ) )
         ENDIF

         // Group header
         nPointer := BIN2W(SUBSTR(cParamsBuff, GRP_HDR_OFFSET, 2))
         aReport[ RPT_GROUPS ][1][ RGT_HEADER ] := ::GetExpr( nPointer )

         // Page eject after group
         aReport[ RPT_GROUPS ][1][ RGT_AEJECT ] := iif( SUBSTR( cParamsBuff, ;
         PE_OFFSET, 1) $ "YyTt", .T., .F.)

      ENDIF

      // Subgroup
      nPointer := BIN2W(SUBSTR(cParamsBuff, SUB_EXPR_OFFSET, 2))

      IF !EMPTY(cSubGroupExp := ::GetExpr( nPointer ))

         // Add new group array
         AADD( aReport[ RPT_GROUPS ], ARRAY( RGT_COUNT ))

         // Subgroup expression
         aReport[ RPT_GROUPS ][2][ RGT_TEXT ] := cSubGroupExp
         aReport[ RPT_GROUPS ][2][ RGT_EXP ] := &( "{ || " + cSubGroupExp + "}" )
         IF USED()
            aReport[ RPT_GROUPS ][2][ RGT_TYPE ] := ;
                           VALTYPE( EVAL( aReport[ RPT_GROUPS ][2][ RGT_EXP ] ) )
         ENDIF

         // Subgroup header
         nPointer := BIN2W(SUBSTR(cParamsBuff, SUB_HDR_OFFSET, 2))
         aReport[ RPT_GROUPS ][2][ RGT_HEADER ] := ::GetExpr( nPointer )

         // Page eject after subgroup
         aReport[ RPT_GROUPS ][2][ RGT_AEJECT ] := .F.

      ENDIF

      // Process columns
      nFieldOffset := 12      // dBASE skips first 12 byte fields block.
      FOR nCount := 1 to nColCount

         AADD( aReport[ RPT_COLUMNS ], ::GetColumn( cFieldsBuff, @nFieldOffset ) )

      NEXT nCount

   ENDIF

   RETURN aReport
treport.prg876
HBREPORTFORM:METHODGetExpr( nPointer ) CLASS HBReportForm
METHOD GetExpr( nPointer ) CLASS HBReportForm
   LOCAL nExprOffset   := 0
   LOCAL nExprLength   := 0
   LOCAL nOffsetOffset := 0
   LOCAL cString := ""

   // Stuff for dBASE compatability.
   IF nPointer != 65535

      // Convert DOS FILE offset to CLIPPER string offset
      nPointer++

      // Calculate offset into OFFSETS_BUFF
      IF nPointer > 1
         nOffsetOffset := (nPointer * 2) - 1
      ENDIF

      nExprOffset := BIN2W(SUBSTR(::cOffsetsBuff, nOffsetOffset, 2))
      nExprLength := BIN2W(SUBSTR(::cLengthsBuff, nOffsetOffset, 2))

      // EXPR_OFFSET points to a NULL, so add one (+1) to get the string
      // and subtract one (-1) from EXPR_LENGTH for correct length

      nExprOffset++
      nExprLength--

      // Extract string
      cString := SUBSTR(::cExprBuff, nExprOffset, nExprLength)

      // dBASE does this so we must do it too
      // Character following character pointed to by pointer is NULL
      IF CHR(0) == SUBSTR(cString, 1, 1) .AND. LEN(SUBSTR(cString,1,1)) == 1
         cString := ""
      ENDIF
   ENDIF

   RETURN cString
treport.prg1147
STATIC FUNCTIONOccurs( cSearch, cTarget )
STATIC FUNCTION Occurs( cSearch, cTarget )
   LOCAL nPos, nCount := 0

   DO WHILE !EMPTY( cTarget )
      IF (nPos := AT( cSearch, cTarget )) != 0
         nCount++
         cTarget := SUBSTR( cTarget, nPos + 1 )
      ELSE
         // End of string
         cTarget := ""
      ENDIF
   ENDDO

   RETURN nCount
treport.prg1185
STATIC FUNCTIONXMLCOUNT( cString, nLineLength, nTabSize, lWrap )
STATIC FUNCTION XMLCOUNT( cString, nLineLength, nTabSize, lWrap )

   DEFAULT nLineLength TO 79
   DEFAULT nTabSize TO 4
   DEFAULT lWrap TO .T.

   IF nTabSize >= nLineLength
      nTabSize := nLineLength - 1
   ENDIF

   RETURN MLCOUNT( TRIM(cString), nLineLength, nTabSize, lWrap )
treport.prg1200
STATIC FUNCTIONXMEMOLINE( cString, nLineLength, nLineNumber, nTabSize, lWrap )
STATIC FUNCTION XMEMOLINE( cString, nLineLength, nLineNumber, nTabSize, lWrap )

   DEFAULT nLineLength TO 79
   DEFAULT nLineNumber TO 1
   DEFAULT nTabSize TO 4
   DEFAULT lWrap TO .T.

   IF nTabSize >= nLineLength
      nTabSize := nLineLength - 1
   ENDIF

   RETURN MEMOLINE( cString, nLineLength, nLineNumber, nTabSize, lWrap )
treport.prg1218
STATIC FUNCTIONParseHeader( cHeaderString, nFields )
STATIC FUNCTION ParseHeader( cHeaderString, nFields )
   LOCAL cItem
   LOCAL nItemCount := 0
   LOCAL aPageHeader := {}
   LOCAL nHeaderLen := 254
   LOCAL nPos

   DO WHILE ++nItemCount <= nFields

      cItem := SUBSTR( cHeaderString, 1, nHeaderLen )

      // check for explicit delimiter
      nPos := AT( ";", cItem )

      IF ! EMPTY( nPos )
         // delimiter present
         AADD( aPageHeader, SUBSTR( cItem, 1, nPos - 1 ) )
      ELSE
         IF EMPTY( cItem )
            // empty string for S87 and 5.0 compatibility
            AADD( aPageHeader, "" )
         ELSE
            // exception
            AADD( aPageHeader, cItem )

         ENDIF
         // empty or not, we jump past the field
         nPos := nHeaderLen
      ENDIF

      cHeaderString := SUBSTR( cHeaderString, nPos + 1 )

   ENDDO

   RETURN aPageHeader
treport.prg1231
HBREPORTFORM:METHODGetColumn( cFieldsBuffer, nOffset ) CLASS HBReportForm
METHOD GetColumn( cFieldsBuffer, nOffset ) CLASS HBReportForm
   LOCAL nPointer := 0, nNumber := 0, aColumn[ RCT_COUNT ], cType, cExpr

   // Column width
   aColumn[ RCT_WIDTH ] := BIN2W(SUBSTR(cFieldsBuffer, nOffset + ;
                FIELD_WIDTH_OFFSET, 2))

   // Total column?
   aColumn[ RCT_TOTAL ] := iif(SUBSTR(cFieldsBuffer, nOffset + ;
    FIELD_TOTALS_OFFSET, 1) $ "YyTt", .T., .F.)

   // Decimals width
   aColumn[ RCT_DECIMALS ] := BIN2W(SUBSTR(cFieldsBuffer, nOffset + ;
                FIELD_DECIMALS_OFFSET, 2))

   // Offset (relative to FIELDS_OFFSET), 'point' to
   // expression area via array OFFSETS[]

   // Content expression
   nPointer := BIN2W(SUBSTR(cFieldsBuffer, nOffset +;
               FIELD_CONTENT_EXPR_OFFSET, 2))
   aColumn[ RCT_TEXT ] := ::GetExpr( nPointer )
   cExpr := aColumn[ RCT_TEXT ]
   aColumn[ RCT_EXP ] := &( "{ || " + cExpr + "}" )

   // Header expression
   nPointer := BIN2W(SUBSTR(cFieldsBuffer, nOffset +;
               FIELD_HEADER_EXPR_OFFSET, 2))

   aColumn[ RCT_HEADER ] := ListAsArray(::GetExpr( nPointer ), ";")

   // Column picture
   // Setup picture only if a database file is open
   IF USED()
      cType := VALTYPE( EVAL(aColumn[ RCT_EXP ]) )
      aColumn[ RCT_TYPE ] := cType
      DO CASE
      CASE cType == "C" .OR. cType == "M"
         aColumn[ RCT_PICT ] := REPLICATE("X", aColumn[ RCT_WIDTH ])
      CASE cType == "D"
         aColumn[ RCT_PICT ] := "@D"
      CASE cType == "N"
         IF aColumn[ RCT_DECIMALS ] != 0
            aColumn[ RCT_PICT ] := REPLICATE("9", aColumn[ RCT_WIDTH ] - aColumn[ RCT_DECIMALS ] -1) + "." + ;
                                  REPLICATE("9", aColumn[ RCT_DECIMALS ])
         ELSE
            aColumn[ RCT_PICT ] := REPLICATE("9", aColumn[ RCT_WIDTH ])
         ENDIF
      CASE cType == "L"
         aColumn[ RCT_PICT ] := "@L" + REPLICATE("X",aColumn[ RCT_WIDTH ]-1)
      ENDCASE
   ENDIF

   // Update offset into ?_buffer
   nOffset += 12

   RETURN aColumn
treport.prg1279
STATIC FUNCTIONListAsArray( cList, cDelimiter )
STATIC FUNCTION ListAsArray( cList, cDelimiter )

   LOCAL nPos
   LOCAL aList := {}                  // Define an empty array
   LOCAL lDelimLast := .F.

   DEFAULT cDelimiter TO ","

   DO WHILE LEN(cList) != 0

      nPos := AT(cDelimiter, cList)

      IF nPos == 0
         nPos := LEN(cList)
      ENDIF

      IF SUBSTR( cList, nPos, 1 ) == cDelimiter
         lDelimLast := .T.
         AADD(aList, SUBSTR(cList, 1, nPos - 1)) // Add a new element
      ELSE
         lDelimLast := .F.
         AADD(aList, SUBSTR(cList, 1, nPos)) // Add a new element
      ENDIF

      cList := SUBSTR(cList, nPos + 1)

   ENDDO

   IF lDelimLast
      AADD(aList, "")
   ENDIF

   RETURN aList                       // Return the array
treport.prg1343
STATIC FUNCTIONMakeAStr( uVar, cType )
STATIC FUNCTION MakeAStr( uVar, cType )
   LOCAL cString

   DO CASE
   CASE UPPER(cType) == "D"
      cString := DTOC( uVar )
   CASE UPPER(cType) == "L"
      cString := iif( uVar, "T", "F" )
   CASE UPPER(cType) == "N"
      cString := STR( uVar )
   CASE UPPER(cType) == "C"
      cString := uVar
   OTHERWISE
      cString := "INVALID EXPRESSION"
   ENDCASE

   RETURN cString
treport.prg1377
FUNCTION__ReportForm( cFRMName, lPrinter, cAltFile, lNoConsole, bFor, bWhile, nNext, nRecord, lRest, lPlain, cHeading, lBEject, lSummary )
FUNCTION __ReportForm( cFRMName, lPrinter, cAltFile, lNoConsole, bFor, ;
                       bWhile, nNext, nRecord, lRest, lPlain, cHeading, ;
                       lBEject, lSummary )
   RETURN HBReportForm():New( cFrmName, lPrinter, cAltFile, lNoConsole, bFor, bWhile, nNext, nRecord,;
              lRest, lPlain, cHeading, lBEject, lSummary)
treport.prg1395
tscalar.prg
TypeFunctionSourceLine
METHODCopy()
   METHOD Copy()
tscalar.prg62
METHODIsScalar()
   METHOD IsScalar()
tscalar.prg63
METHODAsString()
   METHOD AsString()
tscalar.prg64
METHODAsExpStr()
   METHOD AsExpStr()

   MESSAGE Become    METHOD BecomeErr()  /* a scalar cannot "become" another object */
   MESSAGE DeepCopy  METHOD Copy()

ENDCLASS
tscalar.prg65
SCALAROBJECT:METHODCopy() CLASS ScalarObject
METHOD Copy() CLASS ScalarObject
   RETURN Self
tscalar.prg72
SCALAROBJECT:METHODIsScalar() CLASS ScalarObject
METHOD IsScalar() CLASS ScalarObject
   RETURN .T.
tscalar.prg75
SCALAROBJECT:METHODAsString() CLASS ScalarObject
METHOD AsString() CLASS ScalarObject

   SWITCH ValType( Self )
   CASE "B" ; RETURN "{ || ... }"
   CASE "M"
   CASE "C" ; RETURN Self
   CASE "D" ; RETURN DToC( Self )
   CASE "H" ; RETURN "{ ... => ... }"
   CASE "L" ; RETURN iif( Self, ".T.", ".F." )
   CASE "N" ; RETURN LTrim( Str( Self ) )
   CASE "S" ; RETURN "@" + Self:name + "()"
   CASE "P" ; RETURN "<0x...>"
   CASE "U" ; RETURN "NIL"
   ENDSWITCH

   RETURN "Error!"
tscalar.prg78
SCALAROBJECT:METHODAsExpStr() CLASS ScalarObject
METHOD AsExpStr() CLASS ScalarObject

   SWITCH ValType( Self )
   CASE "M"
   CASE "C" ; RETURN '"' + Self + '"'
   CASE "D" ; RETURN 'CToD("' + DToC( Self ) + '")'
   ENDSWITCH

   RETURN ::AsString()
tscalar.prg95
SCALAROBJECT:METHODBecomeErr() CLASS ScalarObject
METHOD BecomeErr() CLASS ScalarObject
   // Not implemented yet
   // ::error( CSYERR_BECOME, "Message 'become' illegally sent to scalar", ::ClassName() )
   RETURN NIL

/* -------------------------------------------- */

CREATE CLASS Array INHERIT HBScalar FUNCTION __HBArray
tscalar.prg105
SCALAROBJECT:METHODInit
   METHOD Init
tscalar.prg114
SCALAROBJECT:METHODAsString
   METHOD AsString
tscalar.prg116
SCALAROBJECT:METHODAt
   METHOD At
tscalar.prg117
SCALAROBJECT:METHODAtPut
   METHOD AtPut
tscalar.prg118
SCALAROBJECT:METHODAdd
   METHOD Add
tscalar.prg119
SCALAROBJECT:METHODAddAll
   METHOD AddAll
tscalar.prg120
SCALAROBJECT:METHODCollect
   METHOD Collect
tscalar.prg121
SCALAROBJECT:METHODCopy
   METHOD Copy
tscalar.prg122
SCALAROBJECT:METHODDo
   METHOD Do
tscalar.prg123
SCALAROBJECT:METHODDeleteAt
   METHOD DeleteAt
tscalar.prg124
SCALAROBJECT:METHODInsertAt
   METHOD InsertAt
tscalar.prg125
SCALAROBJECT:METHODIndexOf
   METHOD IndexOf
tscalar.prg126
SCALAROBJECT:METHODIsScalar
   METHOD IsScalar
tscalar.prg127
SCALAROBJECT:METHODRemove
   METHOD Remove
tscalar.prg128
SCALAROBJECT:METHODScan
   METHOD Scan
tscalar.prg129
SCALAROBJECT:METHOD_Size
   METHOD _Size                          // assignment method

   MESSAGE Append  METHOD Add

ENDCLASS
tscalar.prg130
ARRAY:METHODInit( nElements ) CLASS Array
METHOD Init( nElements ) CLASS Array

   ::size := iif( nElements == NIL, 0, nElements )

   RETURN Self
tscalar.prg136
ARRAY:METHODAddAll( aOtherCollection ) CLASS Array
METHOD AddAll( aOtherCollection ) CLASS Array

   aOtherCollection:Do( {| e | ::Add( e ) } )

   RETURN Self
tscalar.prg142
ARRAY:METHODAsString() CLASS Array
METHOD AsString() CLASS Array
   RETURN "{ ... }"
tscalar.prg148
ARRAY:METHODAt( n ) CLASS Array
METHOD At( n ) CLASS Array
   RETURN Self[ n ]
tscalar.prg151
ARRAY:METHODAtPut( n, x ) CLASS Array
METHOD AtPut( n, x ) CLASS Array
   RETURN Self[ n ] := x
tscalar.prg154
ARRAY:METHODAdd( x ) CLASS Array
METHOD Add( x ) CLASS Array

   AAdd( Self, x )

   RETURN .T.
tscalar.prg157
ARRAY:METHODCollect( b ) CLASS Array
METHOD Collect( b ) CLASS Array

   LOCAL i
   LOCAL currElem
   LOCAL result := {}
   LOCAL nElems := Len( Self )

   FOR i := 1 to nElems
      currElem := Self[ i ]
      IF Eval( b, currElem )
         AAdd( result, currElem )
      ENDIF
   NEXT

   RETURN result
tscalar.prg163
ARRAY:METHODCopy() CLASS Array
METHOD Copy() CLASS Array
   RETURN ACopy( Self, Array( Len( Self ) ) )
tscalar.prg179
ARRAY:METHODDeleteAt( n ) CLASS Array
METHOD DeleteAt( n ) CLASS Array

   IF n > 0 .AND. n <= Len( Self )
      ADel( Self, n )
      ASize( Self, Len( Self ) - 1 )
   ENDIF

   RETURN Self
tscalar.prg182
ARRAY:METHODInsertAt( n, x ) CLASS Array
METHOD InsertAt( n, x ) CLASS Array

   IF n > Len( Self )
      ASize( Self, n )
      Self[ n ] := x
   ELSEIF n > 0
      ASize( Self, Len( Self ) + 1 )
      AIns( Self, n )
      Self[ n ] := x
   ENDIF

   RETURN Self
tscalar.prg191
ARRAY:METHODIsScalar() CLASS Array
METHOD IsScalar() CLASS Array
   RETURN .T.
tscalar.prg204
ARRAY:METHODDo( b ) CLASS Array
METHOD Do( b ) CLASS Array

   LOCAL i

   FOR i := 1 TO Len( Self )
      b:Eval( Self[ i ], i )
   NEXT

   RETURN Self
tscalar.prg207
ARRAY:METHODIndexOf( x ) CLASS Array
METHOD IndexOf( x ) CLASS Array

   LOCAL elem

   FOR EACH elem IN Self
      IF elem == x
         RETURN elem:__enumIndex()
      ENDIF
   NEXT

   RETURN 0
tscalar.prg217
ARRAY:METHODRemove( e ) CLASS Array
METHOD Remove( e ) CLASS Array

   ::DeleteAt( ::IndexOf( e ) )

   RETURN NIL
tscalar.prg229
ARRAY:METHODScan( b ) CLASS Array
METHOD Scan( b ) CLASS Array
   RETURN AScan( Self, b )
tscalar.prg235
ARRAY:METHOD_Size( newSize ) CLASS Array
METHOD _Size( newSize ) CLASS Array

   ASize( Self, newSize )

   RETURN newSize  // so that assignment works according to standard rules

/* -------------------------------------------- */

CREATE CLASS Block INHERIT HBScalar FUNCTION __HBBlock
tscalar.prg238
ARRAY:METHODAsString()
   METHOD AsString()

ENDCLASS
tscalar.prg248
BLOCK:METHODAsString() CLASS Block
METHOD AsString() CLASS Block
   RETURN "{ || ... }"

/* -------------------------------------------- */

CREATE CLASS Character INHERIT HBScalar FUNCTION __HBCharacter
tscalar.prg252
BLOCK:METHODAsString()
   METHOD AsString()
tscalar.prg259
BLOCK:METHODAsExpStr()
   METHOD AsExpStr()

ENDCLASS
tscalar.prg260
CHARACTER:METHODAsString() CLASS Character
METHOD AsString() CLASS Character
   RETURN Self
tscalar.prg264
CHARACTER:METHODAsExpStr() CLASS Character
METHOD AsExpStr() CLASS Character
   RETURN '"' + Self + '"'

/* -------------------------------------------- */

CREATE CLASS Date INHERIT HBScalar FUNCTION __HBDate
tscalar.prg267
CHARACTER:METHODAsString()
   METHOD AsString()
tscalar.prg274
CHARACTER:METHODAsExpStr()
   METHOD AsExpStr()

ENDCLASS
tscalar.prg275
DATE:METHODAsString() CLASS Date
METHOD AsString() CLASS Date
   RETURN DToC( Self )
tscalar.prg279
DATE:METHODAsExpStr() CLASS Date
METHOD AsExpStr() CLASS Date
   RETURN 'CToD("' + ::AsString() + '")'

/* -------------------------------------------- */

CREATE CLASS Hash INHERIT HBScalar FUNCTION __HBHash
tscalar.prg282
DATE:METHODAsString()
   METHOD AsString()

ENDCLASS
tscalar.prg289
HASH:METHODAsString() CLASS Hash
METHOD AsString() CLASS Hash
   RETURN "{ ... => ... }"

/* -------------------------------------------- */

CREATE CLASS Logical INHERIT HBScalar FUNCTION __HBLogical
tscalar.prg293
HASH:METHODAsString()
   METHOD AsString()

ENDCLASS
tscalar.prg300
LOGICAL:METHODAsString() CLASS Logical
METHOD AsString() CLASS Logical
   RETURN iif( Self, ".T.", ".F." )

/* -------------------------------------------- */

CREATE CLASS Nil INHERIT HBScalar FUNCTION __HBNil
tscalar.prg304
LOGICAL:METHODAsString()
   METHOD AsString()

ENDCLASS
tscalar.prg311
NIL:METHODAsString() CLASS Nil
METHOD AsString() CLASS Nil
   RETURN "NIL"

/* -------------------------------------------- */

CREATE CLASS Numeric INHERIT HBScalar FUNCTION __HBNumeric
tscalar.prg315
NIL:METHODAsString()
   METHOD AsString()

ENDCLASS
tscalar.prg322
NUMERIC:METHODAsString() CLASS Numeric
METHOD AsString() CLASS Numeric
   RETURN LTrim( Str( Self ) )

/* -------------------------------------------- */

CREATE CLASS Symbol INHERIT HBScalar FUNCTION __HBSymbol
tscalar.prg326
NUMERIC:METHODAsString()
   METHOD AsString()

ENDCLASS
tscalar.prg333
SYMBOL:METHODAsString() CLASS Symbol
METHOD AsString() CLASS Symbol
   RETURN "@" + Self:name + "()"

/* -------------------------------------------- */

CREATE CLASS Pointer INHERIT HBScalar FUNCTION __HBPointer
tscalar.prg337
SYMBOL:METHODAsString()
   METHOD AsString()

ENDCLASS
tscalar.prg344
POINTER:METHODAsString() CLASS Pointer
METHOD AsString() CLASS Pointer
   RETURN "<0x...>"
tscalar.prg348
ttextlin.prg
TypeFunctionSourceLine
METHODNew( cLine, lSoftCR )
   METHOD New( cLine, lSoftCR )

ENDCLASS
ttextlin.prg60
HBTEXTLINE:METHODNew( cLine, lSoftCR ) CLASS HBTextLine
METHOD New( cLine, lSoftCR ) CLASS HBTextLine

   ::cText := iif( Empty( cLine ), "", cLine )
   ::lSoftCR := iif( Empty( lSoftCR ), .F., lSoftCR )

   RETURN Self
ttextlin.prg65
tthreadx.prg
TypeFunctionSourceLine
METHODnew()
   METHOD new()
tthreadx.prg61
METHODwait( nTimeOut )
   METHOD wait( nTimeOut )
tthreadx.prg62
METHODsignal()
   METHOD signal()
ENDCLASS
tthreadx.prg63
TSIGNAL:METHODnew() CLASS TSIGNAL
METHOD new() CLASS TSIGNAL
   ::mutex := hb_mutexCreate()
RETURN Self
tthreadx.prg66
TSIGNAL:METHODwait( nTimeOut ) CLASS TSIGNAL
METHOD wait( nTimeOut ) CLASS TSIGNAL
/* TOCHECK: I do not know if strict xbase++ compatibility needs
 *          hb_mutexSubscribe() or hb_mutexSubscribeNow()
 *          Please change it if necessary
 */
RETURN hb_mutexSubscribe( ::mutex, nTimeOut )
tthreadx.prg70
TSIGNAL:METHODsignal() CLASS TSIGNAL
METHOD signal() CLASS TSIGNAL
   hb_mutexNotify( ::mutex )
RETURN Self
tthreadx.prg77
ttopbar.prg
TypeFunctionSourceLine
METHODaddItem( oItem )
   METHOD addItem( oItem )
ttopbar.prg69
METHODdelItem( nPos )
   METHOD delItem( nPos )
ttopbar.prg70
METHODdisplay()
   METHOD display()
ttopbar.prg71
METHODgetFirst()
   METHOD getFirst()
ttopbar.prg72
METHODgetItem( nPos )
   METHOD getItem( nPos )
ttopbar.prg73
METHODgetLast()
   METHOD getLast()
ttopbar.prg74
METHODgetNext()
   METHOD getNext()
ttopbar.prg75
METHODgetPrev()
   METHOD getPrev()
ttopbar.prg76
METHODgetAccel( nKey )
   METHOD getAccel( nKey )
ttopbar.prg77
METHODgetShortCt( nKey )
   METHOD getShortCt( nKey )                        /* NOTE: This method exists but it is not documented in the manuals nor the NG's [jlalin] */
ttopbar.prg78
METHODhitTest( nMRow, nMCol )
   METHOD hitTest( nMRow, nMCol )
ttopbar.prg79
METHODinsItem( nPos, oItem )
   METHOD insItem( nPos, oItem )
ttopbar.prg80
METHODselect( nPos )
   METHOD select( nPos )
ttopbar.prg81
METHODsetItem( nPos, oItem )
   METHOD setItem( nPos, oItem )
ttopbar.prg82
METHODcolorSpec( cColorSpec ) SETGET
   METHOD colorSpec( cColorSpec ) SETGET
ttopbar.prg84
METHODcurrent() SETGET
   METHOD current() SETGET
ttopbar.prg85
METHODitemCount() SETGET
   METHOD itemCount() SETGET
ttopbar.prg86
METHODleft( nLeft ) SETGET
   METHOD left( nLeft ) SETGET
ttopbar.prg87
METHODright( nRight ) SETGET
   METHOD right( nRight ) SETGET
ttopbar.prg88
METHODrow( nRow ) SETGET
   METHOD row( nRow ) SETGET
ttopbar.prg89
METHODNew( nRow, nLeft, nRight )
   METHOD New( nRow, nLeft, nRight )                /* NOTE: This method is a Harbour extension [vszakats] */

   PROTECTED:

   VAR cColorSpec
   VAR nCurrent   INIT 0
   VAR nItemCount INIT 0
   VAR nLeft
   VAR nRight
   VAR nRow

   VAR aItems     INIT {}
   VAR nWidth     INIT 0

ENDCLASS
ttopbar.prg91
TOPBARMENU:METHODaddItem( oItem ) CLASS TOPBARMENU
METHOD addItem( oItem ) CLASS TOPBARMENU

   IF ISOBJECT( oItem ) .AND. oItem:ClassName() == "MENUITEM"

      ::nItemCount++
      AAdd( ::aItems, oItem )

      ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )
   ENDIF

   RETURN Self
ttopbar.prg107
TOPBARMENU:METHODdelItem( nPos ) CLASS TOPBARMENU
METHOD delItem( nPos ) CLASS TOPBARMENU
   LOCAL nLen
   LOCAL aItems
   LOCAL nWidth

   IF nPos >= 1 .AND. nPos <= ::nItemCount

      nLen := Len( ::aItems[ nPos ]:caption )

      ADel( ::aItems, nPos )
      ASize( ::aItems, --::nItemCount )

      IF ::nWidth == nLen + 2
          aItems := ::aItems
          nLen := ::nItemCount
          nWidth := 0
          FOR nPos := 1 TO nLen
             nWidth := Max( __CapMetrics( aItems[ nPos ] ), nWidth )
          NEXT
          ::nWidth := nWidth
      ENDIF
   ENDIF

   RETURN Self
ttopbar.prg119
TOPBARMENU:METHODdisplay() CLASS TOPBARMENU
METHOD display() CLASS TOPBARMENU

   LOCAL nOldRow := Row()
   LOCAL nOldCol := Col()
   LOCAL lOldMCur := MSetCursor( .F. )

   LOCAL nRow := ::nRow
   LOCAL nLeft := ::nLeft
   LOCAL nRight := ::nRight
   LOCAL aItems := ::aItems
   LOCAL nItemCount := ::nItemCount
   LOCAL nCurrent := ::nCurrent

   LOCAL cColor1 := hb_ColorIndex( ::cColorSpec, 0 )
   LOCAL cColor2 := hb_ColorIndex( ::cColorSpec, 1 )

   LOCAL oPopUp
   LOCAL nItem
   LOCAL cCaption
   LOCAL nCaptionLen
   LOCAL nPos

   DispBegin()

   DispOutAt( nRow, nLeft, Space( nRight - nLeft + 1 ), cColor1 )

   FOR nItem := 1 TO nItemCount

      cCaption := " " + RTrim( aItems[ nItem ]:caption ) + " "
      nCaptionLen := Len( cCaption )

      IF nCaptionLen == 0
         LOOP
      ENDIF

      IF nLeft > nRight - nCaptionLen
         nLeft := nRight - nCaptionLen
      ENDIF

      aItems[ nItem ]:__row := nRow
      aItems[ nItem ]:__col := nLeft

      IF aItems[ nItem ]:isPopUp()
         oPopUp := aItems[ nItem ]:data
         oPopUp:top := nRow + 1
         oPopUp:left := nLeft
         oPopUp:bottom := NIL
         oPopUp:right := NIL
      ENDIF

      IF ( nPos := At( "&", cCaption ) ) > 0
         IF nPos == Len( cCaption )
            nPos := 0
         ELSE
            cCaption := Stuff( cCaption, nPos, 1, "" )
            nCaptionLen--
         ENDIF
      ENDIF

      DispOutAt( nRow, nLeft, cCaption,;
         iif( nItem == nCurrent, cColor2,;
            iif( aItems[ nItem ]:enabled, cColor1, hb_ColorIndex( ::cColorSpec, 4 ) ) ) )

      IF aItems[ nItem ]:enabled .AND. nPos > 0
         DispOutAt( nRow, nLeft + nPos - 1, SubStr( cCaption, nPos, 1 ),;
            iif( nItem == nCurrent, hb_ColorIndex( ::cColorSpec, 3 ), hb_ColorIndex( ::cColorSpec, 2 ) ) )
      ENDIF

      nLeft += nCaptionLen
   NEXT

   IF nCurrent != 0 .AND. ;
      ::aItems[ nCurrent ]:isPopUp() .AND. ;
      ::aItems[ nCurrent ]:data:isOpen

      ::aItems[ nCurrent ]:data:display()
   ENDIF

   DispEnd()

   SetPos( nOldRow, nOldCol )
   MSetCursor( lOldMCur )

   RETURN Self
ttopbar.prg144
TOPBARMENU:METHODgetFirst() CLASS TOPBARMENU
METHOD getFirst() CLASS TOPBARMENU

   LOCAL n

   FOR n := 1 TO ::nItemCount
      IF ::aItems[ n ]:enabled
         RETURN n
      ENDIF
   NEXT

   RETURN 0
ttopbar.prg229
TOPBARMENU:METHODgetItem( nPos ) CLASS TOPBARMENU
METHOD getItem( nPos ) CLASS TOPBARMENU
   RETURN iif( nPos >= 1 .AND. nPos <= ::nItemCount, ::aItems[ nPos ], NIL )
ttopbar.prg241
TOPBARMENU:METHODgetLast() CLASS TOPBARMENU
METHOD getLast() CLASS TOPBARMENU

   LOCAL n

   FOR n := ::nItemCount TO 1 STEP -1
      IF ::aItems[ n ]:enabled
         RETURN n
      ENDIF
   NEXT

   RETURN 0
ttopbar.prg244
TOPBARMENU:METHODgetNext() CLASS TOPBARMENU
METHOD getNext() CLASS TOPBARMENU

   LOCAL n

   IF ::nCurrent < ::nItemCount
      FOR n := ::nCurrent + 1 TO ::nItemCount
         IF ::aItems[ n ]:enabled
            RETURN n
         ENDIF
      NEXT
   ENDIF

   RETURN 0
ttopbar.prg256
TOPBARMENU:METHODgetPrev() CLASS TOPBARMENU
METHOD getPrev() CLASS TOPBARMENU

   LOCAL n

   IF ::nCurrent > 1
      FOR n := ::nCurrent - 1 TO 1 STEP -1
         IF ::aItems[ n ]:enabled
            RETURN n
         ENDIF
      NEXT
   ENDIF

   RETURN 0
ttopbar.prg270
TOPBARMENU:METHODgetAccel( nKey ) CLASS TOPBARMENU
METHOD getAccel( nKey ) CLASS TOPBARMENU

   LOCAL nIndex := AScan( { K_ALT_A, K_ALT_B, K_ALT_C, K_ALT_D, K_ALT_E, K_ALT_F,;
                            K_ALT_G, K_ALT_H, K_ALT_I, K_ALT_J, K_ALT_K, K_ALT_L,;
                            K_ALT_M, K_ALT_N, K_ALT_O, K_ALT_P, K_ALT_Q, K_ALT_R,;
                            K_ALT_S, K_ALT_T, K_ALT_U, K_ALT_V, K_ALT_W, K_ALT_X,;
                            K_ALT_Y, K_ALT_Z, K_ALT_1, K_ALT_2, K_ALT_3, K_ALT_4,;
                            K_ALT_5, K_ALT_6, K_ALT_7, K_ALT_8, K_ALT_9, K_ALT_0 }, nKey )

   LOCAL cKey
   LOCAL nAt
   LOCAL n

   IF nIndex > 0

      cKey := SubStr( "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", nIndex, 1 )

      FOR n := 1 TO ::nItemCount
      
         IF ( nAt := At( "&", ::aItems[ n ]:caption ) ) > 0 .AND. ;
            Upper( SubStr( ::aItems[ n ]:caption, nAt + 1, 1 ) ) == cKey
      
#ifdef HB_EXTENSION
            IF ::aItems[ n ]:enabled
#endif
               RETURN n
#ifdef HB_EXTENSION
            ENDIF
#endif
         ENDIF
      NEXT
   ENDIF

   RETURN 0
ttopbar.prg289
TOPBARMENU:METHODgetShortCt( nKey ) CLASS TOPBARMENU
METHOD getShortCt( nKey ) CLASS TOPBARMENU

   LOCAL n

   FOR n := 1 TO ::nItemCount
      IF ::aItems[ n ]:shortcut == nKey
         RETURN n
      ENDIF
   NEXT

   RETURN 0
ttopbar.prg324
TOPBARMENU:METHODhitTest( nMRow, nMCol ) CLASS TOPBARMENU
METHOD hitTest( nMRow, nMCol ) CLASS TOPBARMENU

   LOCAL aItems
   LOCAL nColumn
   LOCAL n

   IF nMRow == ::nRow

      aItems := ::aItems

      FOR n := 1 TO ::nItemCount

         nColumn := aItems[ n ]:__col

         IF nMCol >= nColumn .AND. nMCol <= nColumn + Len( aItems[ n ]:caption )
#ifdef HB_EXTENSION
            IF aItems[ n ]:enabled
#endif
               RETURN n
#ifdef HB_EXTENSION
            ENDIF
#endif
         ENDIF
      NEXT
   ENDIF

   RETURN HTNOWHERE
ttopbar.prg343
TOPBARMENU:METHODinsItem( nPos, oItem ) CLASS TOPBARMENU
METHOD insItem( nPos, oItem ) CLASS TOPBARMENU

   IF nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;
      ISOBJECT( oItem ) .AND. oItem:ClassName() == "MENUITEM"

      ASize( ::aItems, ++::nItemCount )
      AIns( ::aItems, nPos )
      ::aItems[ nPos ] := oItem

      ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )
   ENDIF

   RETURN Self
ttopbar.prg371
TOPBARMENU:METHODselect( nPos ) CLASS TOPBARMENU
METHOD select( nPos ) CLASS TOPBARMENU

   IF ( nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;
      ::nCurrent != nPos .AND. ;
      ::aItems[ nPos ]:enabled ) .OR. nPos == 0

//    IF ::isOpen() .AND. ;
//       ::nCurrent > 0 .AND. ;
//       ::aItems[ ::nCurrent ]:isPopUp()
//
//       ::aItems[ ::nCurrent ]:data:close()
//    ENDIF

      ::nCurrent := nPos
   ENDIF

   RETURN Self
ttopbar.prg385
TOPBARMENU:METHODsetItem( nPos, oItem ) CLASS TOPBARMENU
METHOD setItem( nPos, oItem ) CLASS TOPBARMENU

   IF nPos >= 1 .AND. nPos <= ::nItemCount .AND. ;
      ISOBJECT( oItem ) .AND. oItem:ClassName() == "MENUITEM"

      ::aItems[ nPos ] := oItem

      ::nWidth := Max( __CapMetrics( oItem ), ::nWidth )
   ENDIF

   RETURN Self
ttopbar.prg403
TOPBARMENU:METHODcolorSpec( cColorSpec ) CLASS TOPBARMENU
METHOD colorSpec( cColorSpec ) CLASS TOPBARMENU

   IF cColorSpec != NIL
      ::cColorSpec := __eInstVar53( Self, "COLORSPEC", cColorSpec, "C", 1001,;
         {|| !Empty( hb_ColorIndex( cColorSpec, 5 ) ) .AND. Empty( hb_ColorIndex( cColorSpec, 6 ) ) } )
   ENDIF

   RETURN ::cColorSpec
ttopbar.prg415
TOPBARMENU:METHODcurrent() CLASS TOPBARMENU
METHOD current() CLASS TOPBARMENU
   RETURN ::nCurrent
ttopbar.prg424
TOPBARMENU:METHODitemCount() CLASS TOPBARMENU
METHOD itemCount() CLASS TOPBARMENU
   RETURN ::nItemCount
ttopbar.prg427
TOPBARMENU:METHODleft( nLeft ) CLASS TOPBARMENU
METHOD left( nLeft ) CLASS TOPBARMENU

   IF nLeft != NIL
      ::nLeft := __eInstVar53( Self, "LEFT", nLeft, "N", 1001 )
   ENDIF

   RETURN ::nLeft
ttopbar.prg430
TOPBARMENU:METHODright( nRight ) CLASS TOPBARMENU
METHOD right( nRight ) CLASS TOPBARMENU

   IF nRight != NIL
      ::nRight := __eInstVar53( Self, "RIGHT", nRight, "N", 1001 )
   ENDIF

   RETURN ::nRight
ttopbar.prg438
TOPBARMENU:METHODrow( nRow ) CLASS TOPBARMENU
METHOD row( nRow ) CLASS TOPBARMENU

   IF nRow != NIL
      /* NOTE: CA-Cl*pper 5.3 has a bug, where it would show "TOP" in case of an error. */
      ::nRow := __eInstVar53( Self, "ROW", nRow, "N", 1001 )
   ENDIF

   RETURN ::nRow
ttopbar.prg446
TOPBARMENU:METHODNew( nRow, nLeft, nRight ) CLASS TOPBARMENU
METHOD New( nRow, nLeft, nRight ) CLASS TOPBARMENU

   LOCAL cColor

   IF !ISNUMBER( nRow ) .OR. ;
      !ISNUMBER( nLeft ) .OR. ;
      !ISNUMBER( nRight )
      RETURN NIL
   ENDIF

   ::nLeft  := nLeft
   ::nRight := nRight
   ::nRow   := nRow

   IF IsDefColor()
      ::cColorSpec := "N/W,W/N,W+/W,W+/N,N+/W,W/N"
   ELSE
      cColor := SetColor()
      ::cColorSpec := hb_ColorIndex( cColor, CLR_UNSELECTED ) + "," +;
                      hb_ColorIndex( cColor, CLR_ENHANCED   ) + "," +;
                      hb_ColorIndex( cColor, CLR_BACKGROUND ) + "," +;
                      hb_ColorIndex( cColor, CLR_ENHANCED   ) + "," +;
                      hb_ColorIndex( cColor, CLR_STANDARD   ) + "," +;
                      hb_ColorIndex( cColor, CLR_BORDER     )
   ENDIF

   RETURN Self
ttopbar.prg457
FUNCTIONTopBar( nRow, nLeft, nRight )
FUNCTION TopBar( nRow, nLeft, nRight )
   RETURN HBTopBarMenu():New( nRow, nLeft, nRight )
ttopbar.prg487
typefile.prg
TypeFunctionSourceLine
PROCEDURE__TypeFile( cFile, lPrint )
PROCEDURE __TypeFile( cFile, lPrint )
   LOCAL nHandle, cBuffer, nRead := 0, nHasRead := 0, nSize := 0, nBuffer
   LOCAL oErr, xRecover, nRetries
   LOCAL aSaveSet[ 2 ]
   LOCAL cDir, cName, cExt, cTmp, aPath, i

   IF !ISLOGICAL( lPrint )
      lPrint := .F.
   ENDIF

   IF !ISCHARACTER( cFile )
      oErr := ErrorNew()
      oErr:severity    := ES_ERROR
      oErr:genCode     := EG_OPEN
      oErr:subSystem   := "BASE"
      oErr:SubCode     := 2009
      oErr:Description := "Argument error: __TYPEFILE"
      Eval( ErrorBlock(), oErr )
   ENDIF

   // If no drive/dir specified, search the SET DEFAULT and PATH directories

   hb_FNameSplit( cFile, @cDir, @cName, @cExt )
   IF Empty( cDir )
      cTmp := SET( _SET_DEFAULT ) + ";" + SET( _SET_PATH )
      cTmp := StrTran( cTmp, ",", ";" )
      i := Len( cTmp )
      DO WHILE SubStr( cTmp, i, 1 ) == ";"            // remove last ";"
         cTmp := LEFT( cTmp, --i )
      ENDDO
      aPath := HB_ATOKENS( cTmp, ";" )
      FOR i := 1 TO len( aPath )
         IF File( cTmp := hb_FNameMerge( aPath[ i ], cName, cExt ) )
            cFile := cTmp
            EXIT
         ENDIF
      NEXT
   ENDIF

   nRetries := 0
   DO WHILE ( nHandle := FOPEN( cFile, FO_READWRITE ) ) == F_ERROR
      oErr := ErrorNew()
      oErr:severity    := ES_ERROR
      oErr:genCode     := EG_OPEN
      oErr:subSystem   := "BASE"
      oErr:SubCode     := 2011
      oErr:Description := "Open Error: " + cFile
      oErr:canDefault  := .T.
      oErr:canRetry    := .T.
      oErr:OsCode      := FERROR()
      oErr:tries       := ++nRetries
      xRecover := Eval( ErrorBlock(), oErr )
      IF ISLOGICAL( xRecover ) .AND. !xRecover      // user select "Default"
         RETURN
      ENDIF
   ENDDO

   // NOTE: the NG say you should explicitly SET CONSOLE OFF if you wish to
   //       suppress output to screen. [ckedem]

   IF lPrint
      aSaveSet[ 1 ] := Set( _SET_DEVICE, "PRINTER" )
      aSaveSet[ 2 ] := Set( _SET_PRINTER, .T. )
   ENDIF

   nSize   := FSeek( nHandle, 0, FS_END )
   nBuffer := MIN( nSize, BUFFER_LENGTH )

   FSeek( nHandle, 0 )  // go top
   // here we try to read a line at a time but I think we could just
   // display the whole buffer since it said: "without any headings or formating"

   cbuffer := SPACE( nBuffer )
   ?                                                      // start in a new line
   DO WHILE ( nRead := fread( nHandle, @cbuffer, nBuffer ))  > 0
      nHasRead += nRead
      ?? cBuffer
      nBuffer := MIN( nSize - nHasRead, nBuffer )
      cbuffer := SPACE( nBuffer )
   ENDDO

   FCLOSE( nHandle )

   IF lPrint
      Set( _SET_DEVICE,  aSaveSet[ 1 ] )
      Set( _SET_PRINTER, aSaveSet[ 2 ] )
   ENDIF

   RETURN
typefile.prg59
typefilx.prg
TypeFunctionSourceLine
FUNCTION_TypeFile( cFile, lPrint )
FUNCTION _TypeFile( cFile, lPrint )
   RETURN __TypeFile( cFile, lPrint )
typefilx.prg55
valtoexp.prg
TypeFunctionSourceLine
FUNCTIONhb_VALTOEXP( xVal )
FUNCTION hb_VALTOEXP( xVal )
   LOCAL cVal
   LOCAL v := VALTYPE( xVal )

   SWITCH v
      CASE "C"
      CASE "M"
         cVal := HB_STRTOEXP( xVal )
         EXIT
      CASE "N"
         cVal := LTRIM( STR( xVal ) )
         EXIT
      CASE "D"
         cVal := IIF( EMPTY( xVal ), "0d00000000", "0d" + DTOS( xVal ) )
         EXIT
      CASE "L"
         cVal := IIF( xVal, ".T.", ".F." )
         EXIT
      CASE "S"
         cVal := "@" + xVal:name + "()"
         EXIT
      CASE "A"
      CASE "O"
         cVal := "{"
         FOR EACH v IN xVal
            cVal += IIF( v:__enumIndex() == 1, "", ", " ) + HB_VALTOEXP( v )
         NEXT
         cVal += "}"
         EXIT
      CASE "H"
         IF EMPTY( xVal )
            cVal := "{=>}"
         ELSE
            cVal := "{"
            FOR EACH v IN xVal
               cVal += IIF( v:__enumIndex() == 1, "", ", " ) + ;
                       HB_VALTOEXP( v:__enumKey() ) + "=>" + HB_VALTOEXP( v )
            NEXT
            cVal += "}"
         ENDIF
         EXIT
      CASE "P"
         cVal := ""
         EXIT
      CASE "B"
         cVal := "{|| ... }"
         EXIT
      OTHERWISE
         IF xVal == NIL
            cVal := "NIL"
         ELSE
            cVal := "???:" + v
         ENDIF
   ENDSWITCH

   RETURN cVal
valtoexp.prg53
FUNCTIONhb_CSTR( xVal )
FUNCTION hb_CSTR( xVal )
   LOCAL v := VALTYPE( xVal )

   SWITCH v
      CASE "C"
      CASE "M"
         RETURN xVal
      CASE "N"
         RETURN STR( xVal )
      CASE "D"
         RETURN IIF( EMPTY( xVal ), "0d00000000", "0d" + DTOS( xVal ) )
      CASE "L"
         RETURN IIF( xVal, ".T.", ".F." )
      CASE "S"
         RETURN "@" + xVal:name + "()"
      CASE "B"
         RETURN "{|| ... }"
      CASE "O"
         RETURN "{ " + xVal:className + " Object }"
      CASE "A"
         RETURN "{ Array of " + LTRIM( STR( LEN( xVal ) ) ) + " Items }"
      CASE "H"
         RETURN "{ Hash of " + LTRIM( STR( LEN( xVal ) ) ) + " Items }"
      CASE "P"
         RETURN ""
      OTHERWISE
         IF xVal == NIL
            RETURN "NIL"
         ENDIF
   ENDSWITCH

   RETURN "???:" + v
valtoexp.prg110
wait.prg
TypeFunctionSourceLine
FUNCTION__Wait( xPrompt )
FUNCTION __Wait( xPrompt )
   LOCAL nKey
   LOCAL bBlock

   /* TODO: Here we can use LangApi to localize default message */
   QOut( iif( xPrompt == NIL, "Press any key to continue...", xPrompt ) )

   DO WHILE .T.

      nKey := Inkey( 0 )

      IF ( bBlock := SetKey( nKey ) ) != NIL
         Eval( bBlock, ProcName( 1 ), ProcLine( 1 ), "" )
      ELSE
         IF nKey >= 32 .AND. nKey <= 255
            QQOut( Chr( nKey ) )
         ELSE
            nKey := 0
         ENDIF

         EXIT
      ENDIF
      
   ENDDO

   RETURN Chr( nKey )
wait.prg55

Page url: http://www.yourdomain.com/help/index.html?rdd.htm