Strange behaviour in For Next

Post Reply
Willy
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Strange behaviour in For Next

Post by Willy »

This is a part of code that works already for years in an old Harbour FWH application

Code: Select all

Function RadFrm
Parameters aVelden,cDbf

Local Open1 , Open2, i:=0 , j :=0
Privat aTabs:={}, anReg:={5},Ptr:=0,lFolders := .F.,nPos := 100,;
       nButNr := 45

Dstk_Push()

Open2 := Is_Open_Dbf("Objekten",1)
Select Velden

* Bepaal of er folders voorkomen
For i := 1 To Len(aVelden)
   Goto aVelden[i]
   If !Empty(Velden->Folder)
      lFolders := .T.
      Ptr := aScan(aTabs,Velden->Folder)
      If Ptr = 0 && Niks gevonden
         Aadd(aTabs,Velden->Folder)
         Aadd(anReg,5)
      EndIf
      Ptr := Len(anReg)
   EndIf
Next


...
Now in the new HB and FWH it gives an error after executing the next line.

The error = Error Base 1086 Argument Error ++

In a small function that only consists of a for next, it works fine.

After rewriting the code with a do while structure incrementing i with the ++ operator the problem was still there.

Changing i++ in
i := i +1 gives a working solution.

But changing every for next in a do while is not the solution I think.

Any ideas ?

Greetings,

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

Post by Antonio Linares »

Willy,

Are you using xHarbour ? If yes, then please download it again from www.fivetechsoft.com/files/xharbour.exe as there was an error that got fixed by late May
regards, saludos

Antonio Linares
www.fivetechsoft.com
Willy
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Post by Willy »

No Antonio,
It was Harbour not xHarbour
Greetings,

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

Post by Antonio Linares »

Is it a very large PRG ? Whats its size ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
Willy
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Post by Willy »

The whole PRG is about 15 KB

The whole function = 2902 bytes long

Greetings

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

Post by Antonio Linares »

Its quite strange and unusual. Are you sure that the error comes from the "next" line ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
Willy
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Post by Willy »

Antonio,

I see no other explanation.

I made another for next loop in a separated module in the same application. There it works fine.

Before the next statement I placed

Code: Select all

? i , Valtype(i)
The return was correct. Then after the first execution of next statement the error occurs.

So I changed the code to Do While ... EndDo
When I use the i:= i+1 the code works.

When I change it to i++
the same error occurs.

So in fact it is in the i++.

As far as I know the next statement is also translated tot <LoopVariabele>++

In other modules I have not found such an error. I shall see in the coming days how it evoluate.

In this module I have changed the code in Do While ... and i:=i+1

... and this works fine.

Thanks for the time you spended to this

Willy Hermans
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Can you build a reduced and complete sample showing the problem?

EMG
Willy
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Post by Willy »

Enrico,

I try to build an example and I shal post it.

However it is not possible for today anymore.

Thanks

Willy
Post Reply