Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple string manipulation problem
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00540244
Message ID:
00540283
Vues:
12
This message has been marked as a message which has helped to the initial question of the thread.
* Get the list of the fields into array in descending order by the field name lenght
Select Mytable
= Afields(laList)
FOR i=1 TO ALEN(laList,1)
  Lalist[i,2] = Len(Trim(Lalist[i,2])
ENDFOR
ASORT(laList,2, 1)

* Translate all names into unique @nnn format
FOR i=1 TO ALEN(laList,1)
  STRTRAN(lcWhere, Trim(laList[i,1]), "@" + PADL(i, 3, "0"))
ENDFOR

* Translate back adding "aa."
FOR i=1 TO ALEN(laList,1)
  STRTRAN(lcWhere, "@" + PADL(i, 3, "0"), "aa." + Trim(laList[i,1]) )
ENDFOR
>>I have an idea
>>- Put all fields into array laList and sort it in descending order by the field name lenght
>
>I had the same idea too, but how would I do N1? :)
>
>>- Loop thru array and STRTRAN(lcWhere, Trim(laList(i)), "@" + TRANSFORM(i))
>
>???????
>
>>- Loop again and STRTRAN(lcWhere, "@" + TRANSFORM(i), "aa." +Trim(laList(i)))
>>Looks like it should work
>
>Anyway, I just have to write this simple code rather than check UT each minute :)
>
>>>Hi everyone,
>>>
>>>I have some expression, which is either filter() or for() or combination of both. I'd like to insert Alias Lnd1 before each field, which may be in this expression. Example:
>>>
lcStr=where CODE#PARENTCODE.OR.PCOFLAG="P"
>>>
>>>I need to convert it to 'where lnd1.code#lnd1.parentcode OR lnd1.PCOFLAG="P"'
>>>
>>>I was thinking about checking this string against each field and do simple strtran, but it would not work, since I have fieldnames, which are part of other field names.
>>>
>>>Could you please help me?
>>>
>>>Thanks in advance.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform