Jump to content
Macro Express Forums

Recommended Posts

Posted

Can you give a little more information? Are you trying to detect ANY number that is 12 digits, or one specific number? Can it be anywhere in the file, or is it always at the beginning of a line, etc.

Posted

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.

Posted

pretty smart :lol: , especially the conversion to an integer before going back to a string type.

 

the question now is how to know that we have reached the end of the file ? I shall have another variable for the length of the file, right?

Posted

In my post I suggested setting an integer to the length of the string in T1-12. T1 is the string to be searched so this would be the number of repeats.

Posted
In my post I suggested setting an integer to the length of the string in T1-12. T1 is the string to be searched so this would be the number of repeats.

:P Oooops, sorry for the disturb, and thanks again.

Join the conversation

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

Guest
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.

Loading...
×
×
  • Create New...