Author Topic: Conversion needed  (Read 80 times)

DonQuixote

  • Rock Star
  • *****
  • Posts: 177
  • To Dream the Impossible Dream...
Conversion needed
« on: July 31, 2017, 06:38:50 pm »
I need a conversion that will work in the dictionary and in a screen that will zero fill 3 digits but accepts and display a length of 4.
The purpose is that we expanded our territories to four digits but we still have many 3 digit territories.
So if a person enters  "1"  then "001" will be displayed and used to read the TERR file
If you enter "1024" then it will display "1024" and read the TERR file.

The old conversion "MR%3" does not work because it cuts the length to 3 digits; so that 1024 become 024.
Using "MR%4" does not work because "1" becomes "0001" and is invalid because we want "001".




Tom Pellitieri

  • Rock Star
  • *****
  • Posts: 216
  • Tom Pellitieri - Toledo, Ohio
Re: Conversion needed
« Reply #1 on: August 01, 2017, 02:06:50 pm »
I tried "MR#%3" which gave me these results:

1 -> " 001"
12 -> " 012"
123 -> " 123"
1234 -> "1234"
12345 -> "2345"

Note that there is a leading space, but you should be able to trim that out.

precisonline

  • President
  • Administrator
  • Rock Star
  • *****
  • Posts: 1584
    • Precision Solutions
Re: Conversion needed
« Reply #2 on: August 07, 2017, 11:26:44 am »
Tom that's awfully clever.  I don't know that I can improve upon it without writing some code.  We're really talking about an input conversion, right?  You want the value stored with the extra zeroes right?
-Kevin
Accidents "happen"; success, however, is planned and executed.

DonQuixote

  • Rock Star
  • *****
  • Posts: 177
  • To Dream the Impossible Dream...
Re: Conversion needed
« Reply #3 on: August 23, 2017, 01:08:59 pm »
Yes, input conversion.  Yes, stored with leading zeros.