Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Translating C++ FOR cycle into Foxpro code
Message
De
08/12/1997 18:33:42
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00064105
Message ID:
00064543
Vues:
48
>>>Gil,
>>>
>>>I think this will give you the same result as the C code:
>>
>>>rhs = 0
>>>for i = strlen( tempCustStr ) to 1 step -1
>>
>>The following is not the correct translation from C. In C you have to substract the '0' char in order to have the numerical value of a digit character. In VFP you already applied the VAL function, which gives you the numerical value directly. So, the "- 48" substraction will give you a wrong value.
>>
>>> digit = val( substr( tempCustStr, i, 1 ) ) - 48
>>> if ( i % 2 = 0 )
>>> rhs = rhs + digit
>>> else
>>> rhs = rhs + int( 2 * digit / 10 ) + ( 2 * digit ) % 10
>>> endif
>>>endfor
>>>
>>>rhs = 99 - rhs
>>>checkdigit = int( rhs / 10 )
>>>lastdigit = rhs % 10
>>>
>
>
>How is it that you're getting such wide replies. I know this is off the subject but it almost appears as if there is no reply available.

The message I replied to had HTML tags for preformated text. I inserted my reply between those tags, but I didn't format my text with CRs. Since it is between preformated tags, the browser takes it as is and doesn't format the text. So, the message is very wide.

Sorry! I will be more careful.

Vlad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform