Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getfreediskspaceex
Message
De
15/07/2020 08:56:30
 
 
À
04/04/2002 08:59:20
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00640820
Message ID:
01675184
Vues:
88
>FUNCTION Str2num
>LPARAMETERS tcStr,tnLen
>local lnRetVal
>lnRetVal = 0
>FOR ix=1 TO tnLen
> lnRetVal = lnRetVal + ASC(SUBSTR(tcStr,ix))*(256^(ix-1))
>endfor
>RETURN TRANSFORM(lnRetVal,'999,999,999,999,999')Cetin

This function can also be re-written as:
FUNCTION Str2num
LPARAMETERS tcStr, tnLen
LOCAL lnI, lnReturn
    lnReturn = 0
    FOR lnI = tnLen TO 1 STEP -1
        lnReturn = (lnReturn * 256) + ASC(SUBSTR(tcStr, lnI))
    NEXT
    RETURN TRANSFORM(lnReturn, '999,999,999,999,999')
It's a little less expensive (3.31 seconds compared to 4.13 seconds on 1M iterations), though it hardly matters.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform