Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG: With Collections or FOR EACH...
Message
From
27/10/2003 08:40:43
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00841263
Message ID:
00842892
Views:
25
>Hi,
>
>>
>This code works:
>
>lFound = .F.
>FOR EACH oProp IN oDocument.CustomDocumentProperties
>   IF oProp.Name == "iDocumentID"
>      * Found it. Get out of here
>      lFound = .T.
>      EXIT
>   ENDIF
>ENDFOR
>
>IF lFound
>   iDocID = oProp.Value
>ENDIF
>
>>
>
>But this doesn't:
>
>lFound = .F.
>oColl = CREATEOBJECT("Collection")
>oColl.ADD(CREATEOBJECT("line"))
>oColl.ADD(CREATEOBJECT("line"))
>oColl.ITEM(2).COMMENT = "Me"
>
>FOR EACH oObj IN oColl
>  IF oObj.COMMENT ="Me"
>    lFound = .T.
>    EXIT
>  ENDIF
>ENDFOR
>
>IF lFound
>  ? oObj.COMMENT
>ENDIF
>
>
>Is oDocument.CustomDocumentProperties a VFP collection ?
>

No, CustomDocumentProperties is an Office object. The example was meant to show that the loop variable had scope outside the loop.

I know there are some issues with FOR EACH.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform