Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 30 APR 1998 11:19:46AM John K. wrote:

Hi,

  I am in the midst of converting alpha (A-Z) characters in a

Vehicle Identification Number for a subroutine to verify the

accuracy of a VIN. My trouble is I am not sure how to change

those letters to numbers.

  Each letter is assgined a value (0-9), so that your VIN is all

numeric. I have a table that defines what each letter should be,

for example: A=2 and so on.

  Can someone show me how and what to use to convert these. I

think I'm supposed to use the CONVERT function for this, I'm just

not sure.

TIA

John


At 30 APR 1998 11:48AM Victor Engel wrote:

If the numbers are all single digit numbers, then you can do something like this:

CONVERT "ABCDEF" TO '123456' IN VIN

If, however, some of them will be more than two digit numbers, you will have to do something like this:

SUBSTITUTE_STRING=12':@FM:'13':@FM:'14':@FM … whatever your mapping is

DIM SUBSTITUTES(26)

MATPARSE SUBSTITUTE_STRING INTO SUBSTITUTES

NEW_STRING='

LENGTH=LEN(VIN)

FOR STRING_POS=1 TO LENGTH

 CHARACTER=VINSTRING_POS,1
 CHAR_POS=INDEX(@UPPER.CASE,CHARACTER,1)
 NEW_STRING := SUBSTITUTES(CHAR_POS)

NEXT

Here is another piece of code that will work but will be slower. You will have to set up the substitute string as in the previous example.

NEW_STRING=VIN

FOR POS=1 TO 26

 SWAP @UPPER.CASEPOS,1 WITH SUBSTITUTE_STRING IN NEW_STRING

NEXT

Finally, if your substitute numbers are in the same sequential order as the alphabet, the thing to do would be to use the SEQ function, remembering that SEQ('A')=65, SEQ('B')=66, etc. So if your substitutions are:

A=2

B=3

C=4

etc.

Then you would loop through the string and build the new string using SEQ(character) - 63.

I hope you can work out the details from what I've given you here.


At 01 MAY 1998 10:30AM Michael Slack wrote:

If you have a specific range of number that the letters are to fall into, then you might want to use the MOD function. Converting each letter should be a three step process.

Get the alpha character.

Subtract the SEQ() value of the character you are holding from SEQ("A") to get the position number of the character within the alphabet. Example: SEQ("F") - SEQ("A")=5 (rember A will be 0) or SEQ("P") - SEQ("A")=15

Then take the MOD of your relutant number. Like 5=MOD(5,10) or 5=MOD(15,10).

So the code would be something like:

SINGLE_CHAR= VINI,1 ;* OR HOWEVER YOU GET THE CHARACTER.

ALPHA_NO=SEQ(SINGLE_CHAR) - SEQ("A")

SINGLE_DIGIT=MOD(ALPHA_NO,10)

SINGLE_DIGIT will evalutate to a number of 0 to 9 (inclusive).

I hope this helps.

Michael Slack

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/14faaa5d5854c5f9852565f60054353f.txt
  • Last modified: 2023/12/28 07:40
  • by 127.0.0.1