HOW TO

Format AML numeric strings with commas

Last Published: April 25, 2020

Procedure

How can a numeric string, contained in a variable, be formatted to use commas to delimit digits in values greater that 999? For example, can the string 100000 be shown as 100,000?

Answer:

This can be accomplished by parsing the necessary string length and inserting
commas. The following AML inserts commas every three digits:

/* numcomma.aml
/*
&ARGS X
&SETVAR NEW
&DO &WHILE %x% >= 1000
&SETVAR temp = [SUBSTR %x% [CALC [LENGTH %x%] - 2] [LENGTH %x%]]
&SETVAR new = ,%temp%%new%
&SETVAR x = [SUBSTR %x% 1 [CALC [LENGTH %x%] - 3]]
&END
&IF [NULL %new%] &THEN &SETVAR new = %x%
&ELSE &SETVAR new = %x%%new%
&TYPE NEW IS %new%
&SETVAR .return = %new%
&RETURN

Article ID:000001289

Software:
  • Legacy Products
  • ArcMap 8 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options