Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to declare random bunch of PUBLIC variables?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00692500
Message ID:
00692510
Vues:
15
>Gee... I am full of questions today.
>
>I have a VFP 6.0 .PRG program with a bunch of variables declared as shown below.
>My question is -
>I can have up to 50 medic, O_att, O_succ, and O_pts variables each.
>What's the best way to declare them as the number of medics can fall anywhere between 0 and 50? Same with O_att and the others. I don't want to waste time making medic7, medic8 and so on up to 50 if there is a better way.
>Thanks for the advice.
>
>
>PUBLIC medic1 medic2 medic3 medic4 medic5 medic6
>PUBLIC O_att1 O_att2 O_att3 O_att4 O_att5 O_att6
>PUBLIC O_succ1 O_succ2 O_succ3 O_succ4 O_succ5 O_succ6
>PUBLIC O_pts1 O_pts2 O_pts3 O_pts4 O_pts5 O_pts6
>
steve,

something like this ?
=makePublicVar('medic', 1, 50)
=makePublicVar('O_att', 1, 50)
=makePublicVar('O_succ' , 1, 50)
=makePublicVar('O_pts', 1, 50)

function MakePublicVar(Prefix, valFrom, ValTo)
    local i, xx
    
    for i = ValFrom to ValTo
        xx = Prefix + ltrim(str(i, 18,0))
        public &xx
    endfor
endfunc
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform