FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour COPY TO oddness
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
COPY TO oddness
Posted: Mon Jun 07, 2010 05:30 AM
The code snippet below gave me a surprising result. The 2nd file() returns .f.. This would only happen if 'set default' isn't respected. In Clipper, a similar code would've return .t..

Test environment: FWH10.5, xHarbour 1.2.1 r6714, BCC 5.82

Could anyone else confirm that they experience this too please?

Code (fw): Select all Collapse
#include "fivewin.ch"                       
                                            
function main()                             
  local cTmp := "tmp123"                    
                                            
  makedir(".\data")                         
  set default to (".\data")                   
                                            
  dbcreate("ta_poll",{ {"id", "c", 3, 0} } )
  ? file("ta_poll.dbf")                     
                                            
  use ta_poll                               
  copy to (cTmp)                            
  ? file(cTmp+".dbf")                       
                                            
                                            
return nil


TIA
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: COPY TO oddness
Posted: Mon Jun 07, 2010 09:27 AM
Oddly enough, when I compile the program as a xHarbour console program, I get the correct result. Only when I linked-in FWH10.5 will I get the error. Anyone has any suggestion?

Just in case it helps, this is the batch file that I'm using.

Code (fw): Select all Collapse
@ECHO OFF
CLS
ECHO ┌────────────────────────────────────────────────────────────────────────────┐
ECHO │ FiveWin for xHarbour 10.5 - May. 2010           xHarbour development power │▄
ECHO │ (c) FiveTech, 1993-2010     for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7 │█
ECHO └────────────────────────────────────────────────────────────────────────────┘█
ECHO   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

if A%1 == A GOTO :SINTAX
if NOT EXIST %1.prg GOTO :NOEXIST

ECHO Compiling...

if "%FWDIR%" == "" set FWDIR=j:\harbour\fwh
if "%XHDIR%" == "" set XHDIR=j:\harbour\xhb
rem if "%2" == "/b" set GT=gtwin
rem if not "%2" == "/b" set GT=gtgui
set GT=gtgui

set hdir=%XHDIR%
set hdirl=%hdir%\lib
set bcdir=j:\harbour\bcc55
set fwh=%FWDIR%

%hdir%\bin\harbour %1 /n /p /i%fwh%\include;%hdir%\include /w /p %2 %3 > comp.log
IF ERRORLEVEL 1 GOTO COMPILEERRORS
@type comp.log

echo -O2 -e%1.exe -I%hdir%\include -I%bcdir%\include %1.c > b32.bc
%bcdir%\bin\bcc32 -M -c -v @b32.bc
:ENDCOMPILE

IF EXIST %1.rc %bcdir%\bin\brc32 -r %1

echo %bcdir%\lib\c0w32.obj + > b32.bc
echo %1.obj, + >> b32.bc
echo %1.exe, + >> b32.bc
echo %1.map, + >> b32.bc
echo %fwh%\lib\Fivehx.lib %fwh%\lib\FiveHC.lib + >> b32.bc
echo %hdirl%\rtl.lib + >> b32.bc
echo %hdirl%\vm.lib + >> b32.bc
echo %hdirl%\%GT%.lib + >> b32.bc
echo %hdirl%\lang.lib + >> b32.bc
echo %hdirl%\macro.lib + >> b32.bc
echo %hdirl%\rdd.lib + >> b32.bc
echo %hdirl%\dbfntx.lib + >> b32.bc
echo %hdirl%\dbfcdx.lib + >> b32.bc
echo %hdirl%\dbffpt.lib + >> b32.bc
echo %hdirl%\hbsix.lib + >> b32.bc
echo %hdirl%\debug.lib + >> b32.bc
echo %hdirl%\common.lib + >> b32.bc
echo %hdirl%\pp.lib + >> b32.bc
echo %hdirl%\pcrepos.lib + >> b32.bc
echo %hdirl%\ct.lib + >> b32.bc

rem Uncomment these two lines to use Advantage RDD
rem echo %hdir%\lib\rddads.lib + >> b32.bc
rem echo %hdir%\lib\Ace32.lib + >> b32.bc

echo %bcdir%\lib\cw32.lib + >> b32.bc
echo %bcdir%\lib\import32.lib + >> b32.bc
echo %bcdir%\lib\uuid.lib + >> b32.bc
echo %bcdir%\lib\psdk\odbc32.lib + >> b32.bc
echo %bcdir%\lib\psdk\rasapi32.lib + >> b32.bc
echo %bcdir%\lib\psdk\nddeapi.lib + >> b32.bc
echo %bcdir%\lib\psdk\msimg32.lib + >> b32.bc
echo %bcdir%\lib\psdk\iphlpapi.lib, >> b32.bc

IF EXIST %1.res echo %1.res >> b32.bc

rem uncomment this line to use the debugger and comment the following one
if %GT% == gtwin %bcdir%\bin\ilink32 -Gn -Tpe -s -v @b32.bc
IF ERRORLEVEL 1 GOTO LINKERROR
if %GT% == gtgui %bcdir%\bin\ilink32 -Gn -aa -Tpe -s -v @b32.bc
IF ERRORLEVEL 1 GOTO LINKERROR
ECHO * Application successfully built *
%1
GOTO EXIT
ECHO

rem delete temporary files
@del %1.c

:COMPILEERRORS
@type comp.log
ECHO * Compile errors *
GOTO EXIT

:LINKERROR
ECHO * Linking errors *
GOTO EXIT

:SINTAX
ECHO    SYNTAX: Build [Program]     {-- No especifiques la extensión PRG
ECHO                                {-- Don't specify .PRG extension
GOTO EXIT

:NOEXIST
ECHO The specified PRG %1 does not exist

:EXIT
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: COPY TO oddness
Posted: Mon Jun 07, 2010 09:37 AM

Just to rule out a possibility, I checked the ppo between console and windows program. Seems COPY TO are pre-processed to the same syntax. Running out of idea here

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: COPY TO oddness
Posted: Tue Jun 08, 2010 06:51 AM

As a last resort, I downloaded an older binary from http://downloads.sourceforge.net/xharbo ... 2.5.82.zip and that seem to solve the problem. Not ideal, but being the only programmer here I'm always in a rush :)

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
Re: COPY TO oddness
Posted: Tue Jun 08, 2010 01:43 PM
Hello

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6714)
Copyright 1999-2010, http://www.xharbour.org http://www.harbour-project.org/


Code (fw): Select all Collapse
function main()
  local cTmp := "tmp123"

  makedir(".\data")
  set default to (".\data")

  dbcreate("ta_poll",{ {"id", "c", 3, 0} }, "DBFCDX" )
  ? file("ta_poll.dbf")  // RETURN ( .T. )

  use ta_poll VIA "DBFCDX"
  copy to (cTmp)
  ? file(cTmp+".dbf") //RETURN( .F. )


return nil
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: COPY TO oddness
Posted: Tue Jun 08, 2010 02:43 PM

Yes, that's the bug that I encountered. The 2nd file() is returning .f., not the expected .t.. Thank you for the test Patricio. At least I now know it's not something that happens just to me.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 47
Joined: Thu Jul 13, 2006 02:39 PM
Re: COPY TO oddness
Posted: Wed Jun 09, 2010 12:38 AM

I have also experienced COPY TO failing unexpectedly
I concluded it was a xhb compiler bug and worked around it
Using xHb build 1.21 intl simplex rev 6406

Peter
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: COPY TO oddness
Posted: Wed Jun 09, 2010 01:27 AM
Hi Peter,
I initially thought it was a bug in xHarbour but when I created a console program to make my case I get the correct result. When I linked it with FWH, I get the wrong result. Since COPY TO is pre-processed into __dbCopy() I tried grepping for that in FWH's source but none was found.

To further confuse the matter, when I stepped down from rev 6714 to rev 6406 the bug seems to go away.

I guess the only way to diffuse this ticking time bomb is to write a workaround for COPY TO. Someone mentioned even COPY FILE is showing similar bug in this thread
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: COPY TO oddness
Posted: Wed Jun 09, 2010 07:06 AM

The problem is in xHarbour and it's there with or without FWH. I'm going to look at it.

EMG

Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: COPY TO oddness
Posted: Wed Jun 09, 2010 09:37 AM

Thanks Enrico! :) Finding the source of this bug and fixing it is beyond my capability

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: COPY TO oddness
Posted: Tue Jun 29, 2010 09:48 AM

Any update on this Enrico?

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: COPY TO oddness
Posted: Tue Jun 29, 2010 01:32 PM

Unfortunately not. Fixing that bug would create another serious path incompatibility that I'm not able to solve. We have to wait for anybody else to fix it, sorry.

EMG

Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: COPY TO oddness
Posted: Wed Jun 30, 2010 02:01 AM

Thank you for the update Enrico :)

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: COPY TO oddness
Posted: Wed Sep 29, 2010 03:36 AM

Does this issue still exist in latest xHarbour?

TIA

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 563
Joined: Sun Oct 09, 2005 07:23 PM
Re: COPY TO oddness
Posted: Wed Sep 29, 2010 07:30 AM
Try with this:

In your code use:
copy to (cTmp+".dbf")

instead of:
copy to (cTmp)