Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Segmenting a captured string. Is it possible????

Status
Not open for further replies.

matt1981m

Technical User
Jul 1, 2006
32
US
Ok here goes.... those who have seen me post know i come up with some pretty crazy requests but here it goes. Is there a command that can be used to reformat a string (for example a 10 digit number) into smaller strings? What I am basically trying to do is take a phone number (NPANXXNXXX) and break it up into the 3 segmented strings (NPA NXX NXXX). Is this possible?
 
Yes, you could use substr to do this, probably a couple other commands as well depending on how the string is formatted when it comes across (spaces, parentheses, etc.).

 
what i basically am trying to do is to use one dialog box to enter a number into... then the captured number would need to be split into 3 separate strings without any formatting to help it determine (periods, etc...)
 
As long as the numbering and format was consistent, then substr should be able to break it up based on the first three characters, the second set of three characters, and then the last four characters. You'll probably want to use strlen in the dialog code as well to make sure that 10 digits (no more, no less) are being entered as well.

 
it works!!! thanks soooo much... i wish i would have thought to ask this before trying to do a auto tab feature... for those who want to segment a string already captured or defined using a dialog box, it looks like this does below.... the NPAcode etc stands for the new string name, the Message is going to be the source string that has the info, the first # is the starting character and the last number is how many characters should be extracted....

knob you rock!!!


substr NPAcode Message 0 3
substr NXXcode Message 3 3
substr NUMcode Message 6 4
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top