Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
TIP of the Day: GETWORDNUM
Message
De
03/04/2003 07:40:43
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
03/04/2003 03:10:07
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00773431
Message ID:
00773476
Vues:
14
I use an equivalent function, provided by the framework - and I find it very useful.

The framework itself often uses it to pass several parameters as a single parameter.

I think the reason that the framework creates a substitute is due to the handling of empty parameters:

"par1;par2;;par4"

GetWordNum(..., 3) would return "par4", due to the definition of empty space. (The semicolon is the default delimiter in the framework.)

Regards,

Hilmar.


>All,
>
>Just wanted to point out the value of the GETWORDNUM function.
>
>Before I used this function (which also has an equivalent in FoxTools) I programmed blocks like this:
>
>
>DO CASE
>   CASE nNumber = 1
>        cOutPut = "Output string1"
>
>   CASE nNumber = 2
>        cOutPut = "Output string2"
>
>   CASE nNumber = 3
>        cOutPut = "Output string3"
>
>   CASE nNumber = 4
>        cOutPut = "Output string4"
>
>   ....
>ENDCASE
>
>
>with the GETWORDNUM function you can do this:
>
>cOutput = GETWORDNUM("Output string1~Output string1~Output string1~Output string1, nNumber, "~")
>
which clearly save lots of coding and does not distract you from more important programming lines.
>
>But what to do with a character denominator
>
>DO CASE
>   CASE cVar = "X1"
>        cOutPut = "Output string1"
>
>   CASE cVar = "X2"
>        cOutPut = "Output string2"
>
>   CASE cVar = "X3"
>        cOutPut = "Output string3"
>
>   CASE cVar = "X4"
>        cOutPut = "Output string4"
>
>   ....
>ENDCASE
>
>Well then you could use something like this:
>
>cOutput = GETWORDNUM("Output string1~Output string2~Output string3~Output string4, (AT(cVar,"X1 X2 X3 X4 ")+2)/3, "~")
>
>
>Also handy for filling arrays:
>
>DIMENSION aArray[5,2]
>FOR nT = 1 TO 5
>   aArray[nT,1] = GETWORDNUM("Item 1~Item 2~Item 3~Item 4~Item 5",nT,"~")
>   aArray[nT,2] = VAL(GETWORDNUM("1 2 3 4 5",nT))
>ENDFOR
>
>
>Not to mention decoding fields in delimited ASCII files or HL7 strings.
>
>Walter,
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform