COPY TO oddness

hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

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

#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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

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

@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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
Patricio Avalos Aguirre
Posts: 1028
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

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: 861
Joined: Fri Oct 28, 2005 2:27 am

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
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: 861
Joined: Fri Oct 28, 2005 2:27 am

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
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: 861
Joined: Fri Oct 28, 2005 2:27 am

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.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Post by hua »

Any update on this Enrico?
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
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: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Post by hua »

Thank you for the update Enrico :)
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Post by hua »

Does this issue still exist in latest xHarbour?

TIA
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
Verhoven
Posts: 435
Joined: Sun Oct 09, 2005 7:23 pm

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