Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Translating C++ FOR cycle into Foxpro code
Message
From
08/12/1997 08:58:36
 
 
To
08/12/1997 01:36:52
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00064105
Message ID:
00064411
Views:
59
You have your good point here. In C, any string is from 0 to length-1. This difference leads to another modif in the VFP code, that I didn't see from the first time:

You should check for "(i-1) % 2" instead of "i%2", or, change the compared to value from 0 to 1 and from 1 to 0.

Vlad

>There seems to be an "off by one error" for the odd/even check. Compare:
>
>from length of string to 1
>
>>for i = strlen( tempCustStr ) to 1 step -1
>> ...
>> if ( i % 2 = 0 )
>
>from length of (string - 1) to 0
>
>>>for (i = strlen(tempCustStr)-1;i>=0;i--){
>...
>>> if (i % 2 == 0) {
>
>Therefore in VFP:
>
>if ( i % 2 > 0 )
>
>Also see Paul Vlad Tatavu's message.
Previous
Reply
Map
View

Click here to load this message in the networking platform