Waouw ! tu es un crack de la programmation toi ! Ou alors tu lis super bien l'anglais.
Bon, j'ai eu en parallèle une réponse du support de EMSoftware, justement (ils sont vraiment serviable, là bas, c'est pas la première fois qu'ils répondent à une de mes questions. Si quark était aussi efficace
Bref, voici la réponse que j'ai reçue
Tu constateras que la première solution proposée ressemble étrangement à la tienne.
Hello Loïc,
Yes, there are a couple of ways that Xdata could do this. You could either set up a repeat loop which would set the phone number a character at a time, setting an O if the character is 0. Assuming the field name is phoneNbr:
«repeat with charCounter = 1 to length(phoneNbr)¶
«if char charCounter of phoneNbr contains 0¶
O«¶
«else»
«char charCounter of phoneNbr¶
«endif¶
«end repeat¶
This works fine for short fields, or for translating one or two characters. This would really slow the prototype down, though, for longer fields or if you had a lot of characters to translate.
A faster method is to use a Translation table, which can quickly perform any number of translations (from a single character to a string of characters, including formatting tags) on-the-fly as the data is imported.
First, you would set up the translation table, which is simply a list of translations with the character or sring to be translated followed by a tab followed by the character or string that is desired, each translation on its own line. The first line of the table defines a comment character. I am attaching a translation table which translates 0 to O for you, it would need to be in the same folder as the document that you are importing into.
Then, use a put styled statement which calls that translation as you set the field.
So, in your case, instead of «phoneNbr», you would use:
«put styled <&tt2"ZeroToOTranslation.txt"> & phoneNbr»
(notice the use of straight and typographers quotes in the above)
I am also attaching a small demo for you.
Does this help?
Regards,
Joe Mathia
Em Software Support
Cependant, j'ai opté pour la seconde solution proposée qui ralentit moins la machine.
Je re-traduis en Français au cas où ça intéresserait d'autres gens plus tard.
Donc admettons qu'on ait nommé le Field à modifier "phoneNbr" (je n'explique pas ce qu'est un field, les utilisateurs de Xdata doivent probablement comprendre de quoi il s'agit).
Donc pour faire changer les 3 en 2 (par exemple, bien sûr, je donne cet exemple car c'est plus visuel que de changer les 0 en O), on procéderait de la façon suivante.
Créer un fichier texte contenant les deux lignes suivantes
~ (le caractère ñeta qu'on obtient par alt-N) tabulation Blabla(nb'importe quel texte)
3 (le caractère de départ) tabulation 2 (le caractère d'arrivée)
donc visuellement ça donne
~ machintruc
3 2
qu'on enregistre sous le nom qu'on veut, par exemple "ChangeLesDeuxEnTrois.txt" (attention, il semble que les chiffres dans le nom fassent bugger, j'ai envoyé un mail à EM à ce sujet) et qu'on range dans le même dossier que le fichier Xpress Xdata.
Et dans Xpress, on met le code suivant
«put styled <&tt2"ChangeLesDeuxEnTrois.txt"> & phoneNbr»
Bien sûr, si on a 3 fields à changer, par exemple fax, cpostal et machinbidule, eh ben on fait d'autres lignes ou on remplace phoneNbr par fax puis cpostal et machinbidule
ATTENTION : J'AI FAIT UN GROS EDIT CI-DESSUS CAR J'AVAIS MARQUÉ DES INFORMATIONS ÉRRONÉES, SI VOUS AVEZ LU CE POST AVANT QUE JE NE LE MODIFIE, OUBLIEZ CE QUE J'AVAIS DIT.
En attendant je vais donner mon coup de boule à Starmac qui est plus que serviable, encore merci de t'être tant décarcassé, j'en demandais pas autant !!!