View previous topic :: View next topic
|
Author |
Message |
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
I have one alpha numeric variable of X(50)
I want to separate the numeric and alphabetic fields into 2 separate fields.
How will i do that?
E.G. variable A has value 'a124858sdsfg5525'
So B should have asdsfg
and C should have 1248585525 |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
What was your answer? |
|
Back to top |
|
|
ashishsr123
New User
Joined: 06 May 2008 Posts: 33 Location: Chennai
|
|
|
|
You can code a logic for it i have done it.. do not have the code right now..
But kind of simple..
Use a loop ,,take each character..use function Is numeric ...and if answer si true put it in in a numeric field otherwise put in a alphanumeric field.
U can use decimal system for storing digits in numeric field
Regards
AShish |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
U can use decimal system for storing digits in numeric field |
What is "decimal system"? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Since I am bored:
Code: |
ws-alpha-numeric Pic X(50).
ws-hold-alpha pic x(50) value spaces.
ws-hold-numeric pic x(50) value spaces.
ws-count-alpha pic s9(3) comp value zero.
ws-count-numeric pic s9(3) comp value zero.
ws-sub-prime pic s9(3) comp.
ws-sub-alpha pic s9(3) comp value 1.
ws-sub-numeric pic s9(3) comp value 1.
Perform varying ws-sub-prime
from 1
by 1
until ws-sub-prime > 50
If ws-alpha-numeric(ws-sub-prime:1) = 0
or ws-alpha-numeric(ws-sub-prime:1) = 9
or (ws-alpha-numeric(ws-sub-prime:1) > 0
and
ws-alpha-numeric(ws-sub-prime:1) < 9)
then
move ws-alpha-numeric(ws-sub-prime:1) to ws-hold-numeric(ws-sub-numeric)
add 1 to ws-sub-numeric
else
move ws-alpha-numeric(ws-sub-prime:1) to ws-hold-alpha(ws-sub-alpha)
add 1 to ws-sub-alpha
end-if
end-perform
IF ws-sub-alpha > 1
compute ws-count-alpha = ws-sub-alpha - 1 end-compute
end-if
IF ws-sub-numeric > 1
compute ws-count-numeric = ws-sub-numeric - 1 end-compute
end-if
.
|
if there are any numeric,
you can then NUMVAL from ws-hold-numeric to a numeric field. |
|
Back to top |
|
|
ashishsr123
New User
Joined: 06 May 2008 Posts: 33 Location: Chennai
|
|
|
|
Quote: |
U can use decimal system for storing digits in numeric field
|
Sorry for the confusion...i meant u can store numbers like(in case u have issues...) num1*10 + num*10*2 + num*10*3.......and so on... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
Sorry for the confusion...i meant u can store numbers like(in case u have issues...) num1*10 + num*10*2 + num*10*3.......and so on.. |
you would do this only if you extracted the numbers from back to front,
and for the
units, you would specify num1*10**0
tens, num1*10**1
hundreds, num1*10**2
and not num1*10*1 which would be the number times 10
and not num1*10*2 which would be the number times 20
please be careful with your posts;
inaccuracy will wastes time.
(* means multiplication, ** is exponentiation)
and this is not a chat room.
take the time to accurately phrase your posts (use written english)
and use the preview button
the board actually added an edit post button
(yeah I like it too, keeps my flaming to a minimum)
because so many of the computer types here can't figure out how to proof their posts,
as in your case where you could not even explain what you were thinking.
Those are the only issues I have. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
the board actually added an edit post button
(yeah I like it too, keeps my flaming to a minimum) |
But the entertainment value goes down ... sigh |
|
Back to top |
|
|
|