Jump to content
Macro Express Forums

detect a 12 digit number in a text file


Recommended Posts

Pretty simple. First copy the file to a variable EG T1. Then make a repeat storing the iteration in a var EG N1. In each iteration copy 12 characters starting at position N1 to variable T2. Convert T2 to an Integer N2 and then back to a text string T3. If T2=T3 T2 is a 12 digit integer. To control the repeat simply keep going until T2 is blank. Or in the beginning you can set an integer to the length of the string in T1 and subtract 12 and repeat that many times. This way you can use the built in repeat increment.


If it's possible that there could be a 13 digit integer and you want to exclude it or if the 'number' could have left padding zeros that would count you can't use the integer converting trick. Instead repeat just as above but just copy one character at a time. If it is a number (here you can use the integer conversion trick) increment a counter If the counter reaches 12 without going over then you have found your animal. If the character is not an integer reset your counter and continue. To copy that 12 digit number simply subtract the appropriate number of spaces from the incrementor and copy 12 char from that position to another var.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...