Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with a GOTO recnum
Message
From
28/02/2009 14:37:59
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01384533
Message ID:
01384768
Views:
52
>Hi.
>Has anybody had any problems with GOTO recnum. I have an app which seems to fail on this
> intermittently and cant see any reason for it.
>My code is as follows:
>Select Recno() as MyRecnum,Field1,Field2 from MyTable Into Cursor Cur Readwrite
>Do stuff with Cur
>Sele Cur
>Goto top
>DO WHILE OT EOF()
> If Condition met
> Sele MyTable
> Goto Cur.MyRecnum
> Update Stuff
> Endif
>
> Sele Cur
> Skip
>Enddo
>
>What seems to be happening, again infrequently , but I cannot see a pattern,
> is that the last record in MyTable is updated instead of the MyRecnum record
>
>Any ideas on this would be appreciated
>Regards.
>Gerard

I don't see anything in particular in the code that could cause this.

Is there any chance that "Do stuff with Cur" modifies the MyRecnum field?????

I don't know why the following would work where your code doesn't, but alternate techniques sometimes work for no apparant reason
SELECT myTable
lcOrder = TAG()
SET ORDER TO

SELECT RECNO() AS MyRecnum,Field1,Field2 FROM MyTable INTO CURSOR cur READWRITE

Do stuff with Cur

SELECT cur
SET RELATION TO myRecnum INTO myTable
SCAN FOR Condition met
    SELECT myTable
    Update Stuff IN myTable
ENDSCAN

SELECT cur
SET RELATION TO
SELECT myTable
SET ORDER TO (lcOrder)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform