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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string manipulation

Status
Not open for further replies.

jmd0252

Programmer
May 15, 2003
667
OK guys have a opportunity for you. I have an alpha field coming in,,, need to break it into 2 separate fields.

Example 7080.4562 becomes 7080 and 4562

Yes there is actually a period, and that is where I need to break it apart. the number before and after the period, may vary from one number to four numbers. So suggestions?????
 
if the period is static and a constant character in the val then you could use %subst to get the seperated values out

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
D Char9 S 9A
D First S 4A
D Last S 4A
D Pos S 1S 0
D*
C Eval Pos = %scan('.':Char9)
C Eval First = %subst(Char9:1:(Pos-1))
C Eval Last = %subst(Char9:(Pos+1))


You probably would want to test is Pos=0 (no period) and/or Pos=1 (period 1st char) and Pos=9(last char), etc.
 
I usually use SCAN/subst method to do this.
First scan for the period. This will give you the size/position of the first number before the period. Next scan for blanks this will give you the size/position of the next number.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top