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: 8339 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
Site Director
Joined: 23 Nov 2006 Posts: 19270 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: 6970 Location: porcelain throne




Since I am bored:
Code: 
wsalphanumeric Pic X(50).
wsholdalpha pic x(50) value spaces.
wsholdnumeric pic x(50) value spaces.
wscountalpha pic s9(3) comp value zero.
wscountnumeric pic s9(3) comp value zero.
wssubprime pic s9(3) comp.
wssubalpha pic s9(3) comp value 1.
wssubnumeric pic s9(3) comp value 1.
Perform varying wssubprime
from 1
by 1
until wssubprime > 50
If wsalphanumeric(wssubprime:1) = 0
or wsalphanumeric(wssubprime:1) = 9
or (wsalphanumeric(wssubprime:1) > 0
and
wsalphanumeric(wssubprime:1) < 9)
then
move wsalphanumeric(wssubprime:1) to wsholdnumeric(wssubnumeric)
add 1 to wssubnumeric
else
move wsalphanumeric(wssubprime:1) to wsholdalpha(wssubalpha)
add 1 to wssubalpha
endif
endperform
IF wssubalpha > 1
compute wscountalpha = wssubalpha  1 endcompute
endif
IF wssubnumeric > 1
compute wscountnumeric = wssubnumeric  1 endcompute
endif
.

if there are any numeric,
you can then NUMVAL from wsholdnumeric 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: 6970 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: 8339 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 


