Input Translation

Hi, can you help with this.

I have a TEXT field, used for employee number. The number can be a combination of alphabets and numbers.

The input translation needs to be like, if anyone puts in less than eight charecters it shoud at 01 from the left and then 0s.

ex, if you put 123 as employee number, its should get saved as

ex, if you put 123456 then the number gets saved as 01123456.

Please let me know,

cheers,

Raj

Subject: Input Translation

One way: You need to know the length of the value input by your user; e.g. someone inputs ‘3445’, the length is 4 and your requirements are for an id of 8 characters, so prefix ‘0’ to the value input ‘0’ + varInput -Where varInput is a temp variable in a formula representing the user’s input. Increment until you get the desired/required length.

That’s the concept, many ways to execute, look at @For in help.

Subject: RE: Input Translation

thanks…got it from my TL …smart way of doing it.

somethin like…

@If(@Length(test) = 0 ; “000000”+test;

@Length(test) = 1; “00000”+test;

@Length(test) = 2; “0000”+test;

@Length(test) = 3; “000”+test;

@Length(test) = 4; “00”+test;

@Length(test) = 5; “0”+test;

@Length(test) = 6; test;

@Left(test;6))

Thanks anyways…the above code works superb

Subject: RE: Input Translation

Or how about:

@Right(“000000” + test; 6)

Subject: RE: Input Translation

and that’s another way that works.

Subject: RE: Input Translation

you could also have done something like this:

“01” + @right(“000000” + test; 6)

so basically you pad what ever number you have with 6 leading “0”, then cut the last 6 and prefix it with “01”.

The only trouble with that is if you have a number “test” that is longer than 6 digit, you are going to miss the first few…

Subject: Input Translation

This is kind of what you need, but you should check the Pad to make sure it is a positive number (the user has not entered a number longer than 6 chars). I didn’t test it you may have to play around with it a little. HTH

TotalLength := 8;

UserEntryLength := @Length(FieldName);

Prefix := “01”;

PrefixLength := @Length(Prefix);

Pad := 8 - UserEntryLength - PrefixLength;

Prefix + @Repeat(“0”;Pad) + FieldName

Subject: RE: Input Translation

Thanks all of you…learnt several ways of doing it,and all of them worked.thanks a lot folks…