Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MisUnderstanding FOR EACH
Message
From
09/07/2008 04:42:18
 
 
To
08/07/2008 14:56:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01329767
Message ID:
01329915
Views:
18
>
>SELECT key1,key2 FROM lookup WHERE typename="ECO-STATUS" ORDER BY key2 INTO ARRAY thisform.aStatuscodes
>FOR EACH scode IN thisform.aStatuscodes
>	scode = TRIM(scode)
>ENDFOR
>
>My expectation was that scode would now be reflected back into the form's array property. I can see scode changing each time, but when the loop is done, the array is unchanged.
>
>I know I how to re-write this using ALEN(), but could somebody explain why the FOR-EACH code is not working and how to use it to update the values in the array?
>
>Thanks to all...........Rich


1. scode is a variable, FOR EACH copy an array element into the variable,
in other words, scode it is not a reference to the array element.

2. WITH VFP9 you can do RTRIM() into the SELECT:
SET VARCHARMAPPING ON
SELECT RTRIM(key1),RTRIM(key2) FROM lookup WHERE typename="ECO-STATUS" ORDER BY key2 INTO ARRAY ...
Previous
Reply
Map
View

Click here to load this message in the networking platform