Text Field formatting to exact length

I need to format a TEXT variable in iOS to be a specified number of characters with leading zeros.

Specifically, I am returning a record key from an iOSSQLiteRecordSet as
sRecordID = rsCustomers.Field(“pkRecID”).TextValue

Now I want to convert sRecordID so that the result is a constant number of characters with leading zeros, i.e. '12" results as “0012”. Can you do this in iOS?

There actually may be a better way of reaching my end result. What I am doing is building a single field that consist of 1st the record id then the last and first name of the customer and building a iOSTable. That way, when the user clicks a row, I can pull the record ID from the cell data. Cell would look like “0012 Smith, John”

s=right("0000"+str(number),4)

There is no str method in iOS. To do what you want, something like this should work:

result = myIntegerVar.ToText(Xojo.Core.Locale.Current, "0000")