I’ve got this routine from someone on this forum. I thought I had it right but it is not the case.

I do not understand what is happening ? The purpose of the routine is to ensure I always have “Leading Zeroes”

The test seem to be faulty as it is not returning the right values.

If I get it right for number greater or equal to 10 I then do not get it OK for number less than 10.

If I change the algorithm and git it right for number that are less than 10 I do not get it right for numbers greater and equal to 10.

I do not know where to look for.

Thanks in advance!

Daniel

```
set endStr to "00.PDF"
set newInitiatorName to "AAAA" & my twoDigitStr(theEventNumber) & endStr
on twoDigitStr(theNumber)
if theNumber is less than 10 then
return "0" & theNumber
else
return theNumber as text
end if
end twoDigitStr
```