COPY TO oddness

hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

COPY TO oddness

Post by hua »

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: Select all | Expand

#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
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: COPY TO oddness

Post by hua »

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: Select all | Expand

@ECHO OFFCLSECHO ┌────────────────────────────────────────────────────────────────────────────┐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 :SINTAXif NOT EXIST %1.prg GOTO :NOEXISTECHO Compiling...if "%FWDIR%" == "" set FWDIR=j:\harbour\fwhif "%XHDIR%" == "" set XHDIR=j:\harbour\xhbrem if "%2" == "/b" set GT=gtwinrem if not "%2" == "/b" set GT=gtguiset GT=gtguiset hdir=%XHDIR%set hdirl=%hdir%\libset bcdir=j:\harbour\bcc55set fwh=%FWDIR%%hdir%\bin\harbour %1 /n /p /i%fwh%\include;%hdir%\include /w /p %2 %3 > comp.logIF ERRORLEVEL 1 GOTO COMPILEERRORS@type comp.logecho -O2 -e%1.exe -I%hdir%\include -I%bcdir%\include %1.c > b32.bc%bcdir%\bin\bcc32 -M -c -v @b32.bc:ENDCOMPILEIF EXIST %1.rc %bcdir%\bin\brc32 -r %1echo %bcdir%\lib\c0w32.obj + > b32.bcecho %1.obj, + >> b32.bcecho %1.exe, + >> b32.bcecho %1.map, + >> b32.bcecho %fwh%\lib\Fivehx.lib %fwh%\lib\FiveHC.lib + >> b32.bcecho %hdirl%\rtl.lib + >> b32.bcecho %hdirl%\vm.lib + >> b32.bcecho %hdirl%\%GT%.lib + >> b32.bcecho %hdirl%\lang.lib + >> b32.bcecho %hdirl%\macro.lib + >> b32.bcecho %hdirl%\rdd.lib + >> b32.bcecho %hdirl%\dbfntx.lib + >> b32.bcecho %hdirl%\dbfcdx.lib + >> b32.bcecho %hdirl%\dbffpt.lib + >> b32.bcecho %hdirl%\hbsix.lib + >> b32.bcecho %hdirl%\debug.lib + >> b32.bcecho %hdirl%\common.lib + >> b32.bcecho %hdirl%\pp.lib + >> b32.bcecho %hdirl%\pcrepos.lib + >> b32.bcecho %hdirl%\ct.lib + >> b32.bcrem Uncomment these two lines to use Advantage RDDrem echo %hdir%\lib\rddads.lib + >> b32.bcrem echo %hdir%\lib\Ace32.lib + >> b32.bcecho %bcdir%\lib\cw32.lib + >> b32.bcecho %bcdir%\lib\import32.lib + >> b32.bcecho %bcdir%\lib\uuid.lib + >> b32.bcecho %bcdir%\lib\psdk\odbc32.lib + >> b32.bcecho %bcdir%\lib\psdk\rasapi32.lib + >> b32.bcecho %bcdir%\lib\psdk\nddeapi.lib + >> b32.bcecho %bcdir%\lib\psdk\msimg32.lib + >> b32.bcecho %bcdir%\lib\psdk\iphlpapi.lib, >> b32.bcIF EXIST %1.res echo %1.res >> b32.bcrem uncomment this line to use the debugger and comment the following oneif %GT% == gtwin %bcdir%\bin\ilink32 -Gn -Tpe -s -v @b32.bcIF ERRORLEVEL 1 GOTO LINKERRORif %GT% == gtgui %bcdir%\bin\ilink32 -Gn -aa -Tpe -s -v @b32.bcIF ERRORLEVEL 1 GOTO LINKERRORECHO * Application successfully built *%1GOTO EXITECHOrem delete temporary files@del %1.c:COMPILEERRORS@type comp.logECHO * Compile errors *GOTO EXIT:LINKERRORECHO * Linking errors *GOTO EXIT:SINTAXECHO    SYNTAX: Build [Program]     {-- No especifiques la extensión PRGECHO                                {-- Don't specify .PRG extensionGOTO EXIT:NOEXISTECHO The specified PRG %1 does not exist:EXIT
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: COPY TO oddness

Post by hua »

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
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: COPY TO oddness

Post by hua »

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
User avatar
Patricio Avalos Aguirre
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile
Contact:

Re: COPY TO oddness

Post by Patricio Avalos Aguirre »

Hello

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


Code: Select all | Expand

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
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: COPY TO oddness

Post by hua »

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
peterk
Posts: 47
Joined: Thu Jul 13, 2006 2:39 pm

Re: COPY TO oddness

Post by peterk »

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
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: COPY TO oddness

Post by hua »

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
User avatar
Enrico Maria Giordano
Posts: 8767
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 5 times
Contact:

Re: COPY TO oddness

Post by Enrico Maria Giordano »

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

EMG
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: COPY TO oddness

Post by hua »

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
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: COPY TO oddness

Post by hua »

Any update on this Enrico?
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
Enrico Maria Giordano
Posts: 8767
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 5 times
Contact:

Re: COPY TO oddness

Post by Enrico Maria Giordano »

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
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: COPY TO oddness

Post by hua »

Thank you for the update Enrico :)
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: COPY TO oddness

Post by hua »

Does this issue still exist in latest xHarbour?

TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
Verhoven
Posts: 526
Joined: Sun Oct 09, 2005 7:23 pm
Been thanked: 2 times

Re: COPY TO oddness

Post by Verhoven »

Try with this:

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

instead of:
copy to (cTmp)
Post Reply