Differences

This shows you the differences between two versions of the page.

Link to this comparison view

expression function - pad string [2016/09/14 14:19] (current)
Line 1: Line 1:
 +====== Pad String (Expression Function) ======
  
 +===== Purpose =====
 +The **Pad String** function (PAD_STRING) add the specified value to the input string up to the total length specified. ​
 +
 +{{:​pad_string_initial.png?​direct&​600|}}
 +===== Parameters =====
 +The **Pad String** function has four parameters, all of which are required:
 +
 +==== Input String ====
 +
 +Allowed Inputs: [[Field|field]] value or text string
 +
 +The first required parameter of the **Pad String** function is the string to pad. Either use the use the [[Query Builder]] to choose a field that contains the list or use type a value to start with a text string. ​ To start with an empty string use ""​.
 +==== Pad Length ====
 +
 +Allowed Inputs: [[Field|field]] value or a positive number
 +
 +The second required parameter is the total number of characters the resulting string should be.  If the input string is already the pad length or longer then the input string is returned without changes.
 +==== Pad String ====
 +
 +Allowed Inputs: [[Field|field]] value or text string
 +
 +The third parameter is a string used to pad the input string to the pad length. ​ If the pad string is longer then needed to achieve the pad length then a portion of the pad string is used starting from left to right. ​ If the pad string is shorter then is needed to achieve the pad length it will be repeated until the proper length is achieved.
 +==== Side ====
 +
 +Allowed Inputs: "​right"​ or "​left"​ or "​both"​
 +
 +The fourth parameter is a string used to determine which side of the input string the padding is applied to.  If the value is "​right"​ then all of the padding characters will be added to the right of the input string. ​ If the value is "​left"​ all of the padding characters will be added to the left of the input string. ​ If the value is "​both"​ then half the characters needed to achieve the pad length, rounded down, is applied to the left of the input string and the rest of the padding characters is added to the right of the string.
 +===== Output =====
 +
 +The output of the **Pad String** function is a string comprised of the original string plus the padding string up to the length specified. ​ For example PAD_STRING("​TestString",​15,"​x","​both"​) would produce "​xxTestStringxxx"​.
 +
 +===== Example =====
 +
 +The **Pad String** function is commonly used when dealing with fixed length data to make sure a string meets a minimum number of characters. ​ For example PAD_STRING("​TestString",​5,'​x',"​right"​) the result would be "​TestString"​ because it is already greater than 5 characters, but PAD_STRING("​Test",​5,'​x',"​right"​) would result in "​Testx"​.
expression function - pad string.txt ยท Last modified: 2016/09/14 14:19 (external edit)
Copyright WorkXpress, 2019