Page 1 of 2

COPY TO oddness

PostPosted: Mon Jun 07, 2010 5:30 am
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 view

#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

Re: COPY TO oddness

PostPosted: Mon Jun 07, 2010 9:27 am
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 view

@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

Re: COPY TO oddness

PostPosted: Mon Jun 07, 2010 9:37 am
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

Re: COPY TO oddness

PostPosted: Tue Jun 08, 2010 6:51 am
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 :)

Re: COPY TO oddness

PostPosted: Tue Jun 08, 2010 1:43 pm
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 view
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

Re: COPY TO oddness

PostPosted: Tue Jun 08, 2010 2:43 pm
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.

Re: COPY TO oddness

PostPosted: Wed Jun 09, 2010 12:38 am
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

Re: COPY TO oddness

PostPosted: Wed Jun 09, 2010 1:27 am
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

Re: COPY TO oddness

PostPosted: Wed Jun 09, 2010 7:06 am
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

Re: COPY TO oddness

PostPosted: Wed Jun 09, 2010 9:37 am
by hua
Thanks Enrico! :) Finding the source of this bug and fixing it is beyond my capability

Re: COPY TO oddness

PostPosted: Tue Jun 29, 2010 9:48 am
by hua
Any update on this Enrico?

Re: COPY TO oddness

PostPosted: Tue Jun 29, 2010 1:32 pm
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

Re: COPY TO oddness

PostPosted: Wed Jun 30, 2010 2:01 am
by hua
Thank you for the update Enrico :)

Re: COPY TO oddness

PostPosted: Wed Sep 29, 2010 3:36 am
by hua
Does this issue still exist in latest xHarbour?

TIA

Re: COPY TO oddness

PostPosted: Wed Sep 29, 2010 7:30 am
by Verhoven
Try with this:

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

instead of:
copy to (cTmp)