'String.Format 'Emulates the AML [format] function for generating formatted text 'Arguments: ' - the string to be formatted. Special format variables, '%1% to %n%, can be placed within the format string to indicate where 'arguments should be substituted. A field width for each argument can 'also be specified by including a comma and the field width after the 'format variable number (e.g., %1,5%). Negative field widths cause 'output text to be right justified. '{argument1...argument_n} - the arguments to be substituted into the 'format string. These must be strings. Arguments are substituted into 'the format string with the order of the arguments corresponding to the 'order of the format variables in the format string. 'Example: 'format_string = " AREA : %1,14%(%2%) %3,-8%A" 'temp1 = "COOPER" 'temp2 = "0057" 'temp3 = 999 'temp3.SetFormat("d.dd") 'output = av.Run("String.Format", {format_string,temp1,temp2,temp3.AsString}) 'output will equal " AREA : COOPER (0057) 999.00A" FS = SELF.Get(0) i = 1 output = "" while (i <= FS.Count) char = FS.Middle(i - 1, 1) if (char = "%") then j = i + 1 statement = "" subst = "" notdone = TRUE while (notdone) char = FS.Middle(j - 1, 1) if (char = "%") then comma = statement.IndexOf(",") if (comma > 0) then varnum = statement.AsTokens(",").Get(0).AsNumber strwid = statement.AsTokens(",").Get(1).AsNumber if (strwid < 0) then strwid = strwid.Abs just = "R" else just = "L" end vartxt = SELF.Get(varnum) varwid = vartxt.Count if (varwid > strwid) then subst = String.MakeBuffer(strwid).Translate(" ","*") else buff = strwid - varwid if (buff = 0) then subst = vartxt else if (just = "L") then subst = vartxt+String.MakeBuffer(buff) else subst = String.MakeBuffer(buff)+vartxt end end end else subst=SELF.Get(statement.AsNumber) end notdone = FALSE else statement = statement+char j = j + 1 if (j > FS.Count) then notdone = FALSE end end end output = output+subst if (j <= FS.Count) then i = j end else output = output+char end i = i + 1 end return output