Strange behaviour in For Next

Strange behaviour in For Next

Postby Willy » Sat Jun 16, 2007 8:24 am

This is a part of code that works already for years in an old Harbour FWH application
Code: Select all  Expand view  RUN
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
Willy
 
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Postby Antonio Linares » Sat Jun 16, 2007 9:02 am

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42100
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Willy » Sat Jun 16, 2007 9:06 am

No Antonio,
It was Harbour not xHarbour
Greetings,

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

Postby Antonio Linares » Sat Jun 16, 2007 9:12 am

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

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

Postby Willy » Sat Jun 16, 2007 9:55 am

The whole PRG is about 15 KB

The whole function = 2902 bytes long

Greetings

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

Postby Antonio Linares » Sat Jun 16, 2007 10:12 am

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

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

Postby Willy » Sat Jun 16, 2007 2:17 pm

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  Expand view  RUN
? 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
Willy
 
Posts: 117
Joined: Thu Mar 02, 2006 11:06 am
Location: Belgium

Postby Enrico Maria Giordano » Sat Jun 16, 2007 2:56 pm

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

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

Postby Willy » Sat Jun 16, 2007 3:03 pm

Enrico,

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

However it is not possible for today anymore.

Thanks

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 96 guests