ERROR compiled with FW , NOT without FW

Post Reply
demont frank
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

ERROR compiled with FW , NOT without FW

Post by demont frank »

Antonio,

Trying to work out the code from thread 'checking changes in folder' (28 juni , using 'HB_DBG_VMSTKLLIST()' , i have no error when compiled without FW , probably a GPF with FW

Code: Select all

# ifdef FIVEWIN
  #include "FiveWin.ch" 
# endif
#include "common.ch"

function Main() 

Test( "one", "two", "three" ) 

return nil 
***************************************************************************************************************
function Test( x, y, z ) 
************************	

local local1 := "first", local2 := {"SecondFirst","secondSecond"}
local aBegin
local aEnd
// your code... 
aBegin := aClone(ReadLocals(HB_DBG_VMSTKLLIST(),4,5))
local2[2] := "changed!" // we change a local value 
aEnd := Readlocals(HB_DBG_VMSTKLLIST(),4,5)

CompLocals(aBegin , aEnd)
return nil 

****************************************************************************************************************
FUNC ReadLocals(...)
********************
LOCAL aParam := HB_aParams()
LOCAL nFrom , nTo
LOCAL aLocals// := HB_DBG_VMSTKLLIST()
LOCAL Arr[0] , el
aLocals := aParam[1]
aDel(aParam,1,.T.)
aDel(aLocals,1,.T.)
aDel(aLocals,1,.T.)
IF LEN(aParam) == 0
  Arr := aLocals
ELSEIF LEN(aParam) <= 2
  nTo := nFrom := aParam[1]
  IF LEN(aParam) = 2
    nTO   := aParam[2]
  END
  Arr := {}
  AEVAL(aLocals , {|el| AADD(Arr,el) } , nFrom , Nto - nFrom + 1)
ELSE
  AEVAL(aParam , {|el| AADD(Arr , aLocals[el]) } )		
ENDIF
RETURN Arr
*************************************************************
FUNC CompLocals(aBegin , aEnd)
*********************************
LOCAL el , elem , lOk := .T. , i
FOR i := 1 TO LEN(aBegin)
  el   := aBegin[i]
  elem := aEnd[i]
  IF VALTYPE(el) <> VALTYPE(elem)
    lOk := .F.
    EXIT
  END
  IF IsArray(el) .AND. IsArray(elem)
    IF LEN(el) <> LEN(elem)
      lOk := .F.
      EXIT
     END
     IF ! CompLocals(el , elem )
       lOk := .F.
       EXIT
    END
ELSE
    IF el <> elem
      lOk := .F.
      EXIT
    END		 
  END
NEXT
IF ! lOk
  ? i , aBegin[i] , aEnd[i] , lOk
  # ifndef FIVEWIN
  WAIT
  # endif
END
RETURN lOk
Last edited by demont frank on Wed Jul 02, 2008 6:08 am, edited 2 times in total.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Frank,

With Harbour we get this error with your code and FWH:

Code: Select all

   Error description: Error BASE/1003  Variable does not exist: ALOCAL

Stack Calls
===========
   Called from: F:\tmp43\test.prg => (b)READLOCALS(48)
   Called from:  => AEVAL(0)
   Called from: F:\tmp43\test.prg => READLOCALS(48)
   Called from: F:\tmp43\test.prg => TEST(20)
   Called from: F:\tmp43\test.prg => MAIN(9)
Quite curiously, with xHarbour there is no error :-)

but it should be there because aLocal is not defined
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Also you have many ambiguous references in your code that you should fix (undeclared variables).

But no GPFs here :-)
Last edited by Antonio Linares on Tue Jul 01, 2008 7:50 pm, edited 1 time in total.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Antonio Linares wrote:Frank,

With Harbour we get this error with your code and FWH:

Code: Select all

   Error description: Error BASE/1003  Variable does not exist: ALOCAL

Stack Calls
===========
   Called from: F:\tmp43\test.prg => (b)READLOCALS(48)
   Called from:  => AEVAL(0)
   Called from: F:\tmp43\test.prg => READLOCALS(48)
   Called from: F:\tmp43\test.prg => TEST(20)
   Called from: F:\tmp43\test.prg => MAIN(9)
Quite curiously, with xHarbour there is no error :-)

but it should be there because aLocal is not defined
Which compiler switches are you using? I get exactly the same warnings with both Harbour or xHarbour:
Harbour 1.0.0RC1 Intl. (Rev. 8863)
Copyright (c) 1999-2008, http://www.harbour-project.org/
FRANK.prg(47) Warning W0001 Ambiguous reference: 'ALOCAL'
FRANK.prg(54) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(55) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(56) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(66) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(67) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(67) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(71) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(71) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(78) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(78) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(80) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(80) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(80) Warning W0001 Ambiguous reference: 'I'

No code generated.
xHarbour Compiler build 1.1.0 (SimpLex) (Rev. 6159)
Copyright 1999-2008, http://www.xharbour.org http://www.harbour-project.org/
FRANK.prg(47) Warning W0002 Ambiguous reference, assuming memvar: 'ALOCAL'
FRANK.prg(54) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(54) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(55) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(56) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(66) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(66) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(67) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(67) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(71) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(71) Warning W0001 Ambiguous reference: 'J'
FRANK.prg(78) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(78) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(80) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(80) Warning W0001 Ambiguous reference: 'I'
FRANK.prg(80) Warning W0001 Ambiguous reference: 'I'

No code generated.
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

The ambiguous references are the same in both compilers.

The difference is that Harbour generates an error in runtime, thats seems ok, and xHarbour ignores it.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Harbour doesn't generate any error here. At least using the following compiler switches:
SET HARBOURCMD=/a /es2 /gc0 /m /n /q /w
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

See this line:

AEVAL(aParam , {|el| AADD(Arr , aLocal[el]) } )

aLocal is not defined anywhere, and more over, is used as an array, so it should generate an error. Don't know if those compiler switches may make a difference, but I can't find a aLocal variable declaration anywhere in the code :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Code: Select all

AEVAL(aParam , {|el| AADD(Arr , aLocal[el]) } ) 
Judging from the rest of the code, it appears that aLocal is a typo--it should be aLocals (with an s). aLocals is defined and used.

James
demont frank
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Post by demont frank »

Sorry guys , i was mixting old xhb with recent fw code

I have changed the example , now it works , also when arrays are used .

I am wondering why i have to use

aBegin := aClone(ReadLocals(..))

If not , aBegin is changed with the next line , and aBegin is the same as aEnd

Frank
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Frank,

>
I am wondering why i have to use

aBegin := aClone(ReadLocals(..))
>

Probably because it is pointing to the original array, so when you modify it, then you are modifying the original. AClone() creates a copy of it, but kept on a different variable.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Antonio Linares wrote:Enrico,

See this line:

AEVAL(aParam , {|el| AADD(Arr , aLocal[el]) } )

aLocal is not defined anywhere, and more over, is used as an array, so it should generate an error. Don't know if those compiler switches may make a difference, but I can't find a aLocal variable declaration anywhere in the code :-)
Yes, and this has been considered a warning from Clipper on:

Code: Select all

FUNCTION MAIN()

    ? n

    RETURN NIL
Harbour 1.0.0RC2 Intl. (Rev. 8874)
Copyright (c) 1999-2008, http://www.harbour-project.org/
NODECL.prg(3) Warning W0001 Ambiguous reference: 'N'

No code generated.
EMG
Post Reply