IF..THEN on a partial string?

Hi, In another topic I learned how to delete special characters out of a text field. I use this beatiful function for it: gFncNumericOnly(iTxtNo : Text[30]) : Text[30] EXIT(DELCHR(iTxtNo,'=',DELCHR(iTxtNo,'=','+0123456789'))); However, before doing this, I want to execute a function which, if the field fTxtFaxNo does not start with ‘+31’ (i.e. +49 (0)571 999999), takes out the ‘(0)’. I thought about running the following code before executing the function, but this doesn’t do the trick: IF "Sales Header".fTxtFaxNo <> '+31*' THEN fTxtFaxmaker := DELCHR("Sales Header".fTxtFaxNo,'=','(0)'); Should I do someting with a STRING command in this case?

On a very basic level you will need to use this code. IF CopySTR(“Sales Header”.fTxtFaxNo,1,3) <> ‘+31*’ THEN fTxtFaxmaker := DELCHR(“Sales Header”.fTxtFaxNo,’=’,’(0)’); Hope this helps!

Hi, i would say: definitely YES. try it with:IF copystr("Sales Header".fTxtFaxNo,1,3) <> '+31*' THEN but why do you want to delete ALL zeros in the FaxNo? try it with this code if you want to delete all leadung zeros:fTxtFaxmaker := DELCHR("Sales Header".fTxtFaxNo,'<','(0)'); br Josef Metz

Good question Josef, I don’t want to delete all zeros, just the one between the brackets! And with the code I have written now: IF CopySTR("Sales Header".fTxtFaxNo,1,3) <> '+31' THEN fTxtFaxmaker := DELCHR("Sales Header".fTxtFaxNo,'=','(0)') ELSE fTxtFaxmaker := "Sales Header".fTxtFaxNo; I would definitely delete all the zeros. How should I proceed then? Take these examples: +49 (0)571 999 999 should become +49571999999 (delete zero) +31 (0)314 399 999 should become +310314399999 (not delete zero)

Unfortunately this is not going to work. The code issue you can resolve, no problem, BUT the “0” long distance pre fix just is not consistant. In the US, it is “1” instead of “0” and since this is also the Country code, international numbers to the US are generally written different that for other countries. Secondly, a number of countries now have “0” as the last digit of their country code. An example is The Czech Republic. Czechoslovakia had the country code “42” but after the country split, CZ got “420” and SK got “421”, so to dial interntaionally to CZ you MUST include the “0”, so if you tried to strip it out, then you would not get through to CZ at all. And there are quite a few countries like this now. eg to call to Kladno you would write the number as +420 (0) 312 555 555, but since you want to allow the users to make errors, they could also enter it as +420 312 555 555, in this case it is the correct international number, BUT your code would delete the 0, and it would dial +423 12 555 555 which would be a number somewhere in Lichtenstein. What you need instead is to train your users to enter numbers consistantly. My recommendation would be to add a field into the country table, “Dialing Code” and then use this to verify that the correct code is being used. eg in each country store a field something like +420 ### ### ### +1 ### ### #### +45 ## ## ## ## +44 ## #### #### Of course you still have a problem with countries that don’t have a standard phone number format.

Hi try it with:IF COPYSTR("Sales Header".fTxtFaxNo,1,3) <> '+31' THEN BEGIN Pos := STRPOS("Sales Header".fTxtFaxNo,'(0)'); IF Pos > 0 THEN fTxtFaxmaker := COPYSTR("Sales Header".fTxtFaxNo,1,Pos-1) + COPYSTR("Sales Header".fTxtFaxNo,Pos+3) ELSE fTxtFaxmaker := "Sales Header".fTxtFaxNo; fTxtFaxmaker := DELCHR(NewFaxNo,'=','( )'); END ELSE fTxtFaxmaker := DELCHR("Sales Header".fTxtFaxNo,'=','( )'); br Josef Metz

Hi David, Thanks for your extended reply. You certainly have a point there. However, the subsidiary were this solution is implemented doesn’t have that much foreign Fax No.'s. I choose for the option to train the users consistantly in keying in foreign Fax No.'s. And Josef, Thanks again for your code, but I think I leave it this way and take David’s suggestion.