Reputation: 1437
I am modelling a warehouse. each cell has been assigned to a id in a format like below.
The standard format of the external data is four digits. However, there are some ids which are only 3 like "A05". Is there a easy way to automatically add one more "0' to make it like "A005"?
Upvotes: 0
Views: 54
Reputation: 10301
Maybe this reporter will work for you- it should just add a zero in the second position until the string length is 4 or greater.
to setup
ca
print map add-zero [ "A" "A1" "A01" "A001" "A123" ]
reset-ticks
end
to-report add-zero [ string ]
if length string >= 4 [
report string
]
report add-zero insert-item 1 string "0"
end
Upvotes: 1