Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SCAN and DO WHILE logic
Message
 
 
To
28/10/2008 19:56:28
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01357888
Message ID:
01358032
Views:
20
>I'm trying to only keep the first unique value of the GroupHeading field, blanking all others like it until I get to a different value. The code below is kicking out of the DO WHILE because the value of GroupHeading is changed by the REPLACE. I understand why, but how can I get around it?.
>
>			SELECT WorkListXMLCursor
>			SCAN
>				m.GroupHeading = GroupHeading
>				DO WHILE GroupHeading = m.GroupHeading
>					SKIP
>					REPLACE GroupHeading WITH ''
>				ENDDO
>			ENDSCAN
>
I think your logic is wrong. If you skip within the Do While, before the Replace, the first record with the *next* GroupHeading will be blanked. Try this.
LOCAL m.FirstTime, m.CurrentGroupHeading
m.FirstTime = .T.

SELECT WorkListXMLCursor
SET ORDER TO TAG GroupHeading    && or whatever it's called
m.CurrentGroupHeading = GroupHeading

SCAN
    *  Never replace the first record
    IF m.FirstTime
       m.FirstTime = .F.
       LOOP
    ENDIF
    IF GroupHeading = m.CurrentGroupHeading
        REPLACE GroupHeading WITH ''
    ELSE
        m.CurrentGroupHeading = GroupHeading
    ENDIF
ENDSCAN
Untested....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform