I may have found a bug with how the Length() function within complex expressions works.
In this case I'm extracting a phone number from an Array (created by CSVFileToArray) which may be either 9 or 10 digits.
The value should always be 10 digits (Australian mobile number starting with 04) however Excel formatting may drop the leading 0 causing it to be 9 digits long.
I want to check the length, if the result is 9 then add a 0 to the start, otherwise continue.
The script I've used to test is:
Code: Select all
Let>TEST_ARRAY_2_0=400123456
If>{Length(%TEST_ARRAY_2_0%) = 9}
Let>MSN=0
ConCat>MSN,TEST_ARRAY_2_0
ELSE
If>{Length(%TEST_ARRAY_2_0%) = 10}
Let>MSN=TEST_ARRAY_2_0
ELSE
//MSN not found in .csv - exception?
EndIf>
EndIf>
If there is no Excel formatting and the leading 0 is present (TEST_ARRAY_2_0=0400123456) the length result is still 9.
If I instead change TEST_ARRAY_2_0=4001234560 it counts as 10 characters.
It seems that if a variable starts with a 0 the length is -1 of what it should be.
The Length> command still works fine, so as a workaround I'll use this instead of the complex expression for this scenario.