COPY TO oddness

COPY TO oddness

Postby hua » Mon Jun 07, 2010 5: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: 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
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Postby hua » Mon Jun 07, 2010 9: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: 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
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Postby hua » Mon Jun 07, 2010 9: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Postby hua » Tue Jun 08, 2010 6: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

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

Re: COPY TO oddness

Postby hua » Tue Jun 08, 2010 2: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

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

Re: COPY TO oddness

Postby hua » Wed Jun 09, 2010 1: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Postby Enrico Maria Giordano » Wed Jun 09, 2010 7:06 am

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8711
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: COPY TO oddness

Postby hua » Wed Jun 09, 2010 9: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Postby hua » Tue Jun 29, 2010 9:48 am

Any update on this Enrico?
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Postby Enrico Maria Giordano » Tue Jun 29, 2010 1: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
User avatar
Enrico Maria Giordano
 
Posts: 8711
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: COPY TO oddness

Postby hua » Wed Jun 30, 2010 2:01 am

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

Re: COPY TO oddness

Postby hua » Wed Sep 29, 2010 3:36 am

Does this issue still exist in latest xHarbour?

TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: COPY TO oddness

Postby Verhoven » Wed Sep 29, 2010 7:30 am

Try with this:

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

instead of:
copy to (cTmp)
Verhoven
 
Posts: 520
Joined: Sun Oct 09, 2005 7:23 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 94 guests