Search the Community
Showing results for tags 'code'.
-
i'm having trouble Leading Zeros and Zip Code Formatting
andym posted a topic in Issues, Questions, Etc.
I am referencing a list of addresses from an external data file. There are a few addresses in Massachusetts with leading zeros. Once the spreadsheet is put on MarcomCentral, the formatting defaults to drop leading zeros. The rule I wrote for this is below: var Address = ""; var Name = ""; var Street = ""; var City = ""; var State = ""; var Zip = ""; var Country = ""; myXDF= new ExternalDataFileEx("ATLocations.txt", "\t"); for (i = 1; i < myXDF.recordCount+1; i++) { FirstVar = myXDF.GetFieldValue(i, 0); { if (FirstVar==Field("Address")) { Name = myXDF.GetFieldValue(i, 1); Street = myXDF.GetFieldValue(i, 2); City = myXDF.GetFieldValue(i, 3); State = myXDF.GetFieldValue(i, 4); Zip = myXDF.GetFieldValue(i, 5); Country = myXDF.GetFieldValue(i, 6); } } } return ' | ' + City+", "+State+" "+FormatNumber("00000", Zip); The last part of the returned text is the zip code. In previous templates this seemed to work for me, but I am now getting different results, i.e." MA, 1913 00000" where it drops the leading zero and puts five zeros after the actual zip code. Finally, one extra item that we need to work. There are also Canadian addresses. Whatever rule(s) we use also needs to work for those locations. Now, the result looks like this: "Ontario, L6T 3V1 00000." Is the rule I have on the right track? Should the zip code part be left out and made into an independent rule? Any help is greatly appreciated. Thank you, Andy- 4 replies
-
- code
- formatting
-
(and 2 more)
Tagged with: