The following function pads the left side of a string with a specified character to make the result at least as long as needed.

? padl( "Test", 7, "*" ) // Displays ***Test

function padl( cArg, nLen, cPad )

   if argcount( ) < 3 

      cPad = "" 

   endif 

return replicate( left( cPad + " ", 1 ), nLen - len( cArg ) ) + cArg 

To make sure only one character is repeated, a space is added to the parameter (in case the parameter is an empty string or was omitted), and the LEFT( ) function is used to extract the first character (in case the parameter was more than one character).