View previous topic :: View next topic
|
Author |
Message |
srebba Warnings : 1 New User
Joined: 26 Apr 2007 Posts: 37 Location: USA
|
|
|
|
Hi,
I have searched in forum but i did not get .. please help me.
how can we check whether this is numeric or Alphanumeric field.
For Ex,,
01 ws-field Pic X(08).
in this feild , eg. AAA, AA122, 1222, 122A, 11A12, AA-12,12-124,
so numeric means only numbers.. other than numbers are alphanumeric.. iam clear now.
so i would like to know in this field wether numeric or alpha numeric
Thank you |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
IF ws-field NUMERIC.......
But leading or trailing blanks or spaces will be considered alphanumeric too. What do you want to do if is is numeric? |
|
Back to top |
|
|
srebba Warnings : 1 New User
Joined: 26 Apr 2007 Posts: 37 Location: USA
|
|
|
|
Hi,
No, I need whehter numeric or alphanumeric..
In my program , if numeric i want to pass one variable,, if alphanumeric then pass to another variable.
i want to check wether alphanumerics or numeric only are in this field..
please let me know
thank u |
|
Back to top |
|
|
srebba Warnings : 1 New User
Joined: 26 Apr 2007 Posts: 37 Location: USA
|
|
|
|
in X(8) length... '122 ' . its numeric.. so spaces also considered numeric.. My aim is in this field , whether numeric or alphanumerics.
please let me know if iam not clear
thank u |
|
Back to top |
|
|
rpuhlman
New User
Joined: 11 Jun 2007 Posts: 80 Location: Columbus, Ohio
|
|
|
|
Hi Sree,
One thing you can do is move ws-field to an intermediate field of the same attributes and then INSPECT ws-field-r REPLACING ALL SPACES WITH ZEROS. At this point you can evaluate whether ws-field-r is numeric or not. I'm not sure as to what extent you are trying to filter this data, just be aware that if you have a space in between numbers, such as '12 34 56' this will make it numeric ... any combination of numbers and spaces will become numeric after the inspect. Hope this helps.
Rick |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello Sree,
If you will post several 8-byte values including spaces, numbers, letters, and "other" characters as well as the "result" you want the code to determine, we will be able to offer suggestions.
For example one example might be |12345678| (the |s are boundary markers) which would be numeric.
Depending on your particular rules | 1234| could be numeric or not numeric - you need to provide the definition.
The same is true for any other data format that might need to be processed. If you will post your "input"s and how they should be treated using the "Code" tag, it will be far easier to read - notice how my second value has the spaces "squeezed" out - a feature of text rather than Code.
If you click Preview before you Submit your post, you can see how your post will appear to everyone. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
srebba wrote: |
so spaces also considered numeric. |
Depending on how you want to handle an all spaces field....
This one treats all spaces as numeric
Code: |
Examine ws-field replacing spaces with zeros
If ws-field not numeric
do not numeric thing
else
if ws-field = zero
do all spaces thing
else
do numeric thing
end-if
end-if |
This one allows all spaces to be treated which-ever way you want, numeric or not numeric
Code: |
Perform varying x from 1 by 1
until x > length of ws-field
or not-numeric
if ws-field(x:1) = space
add 1 to space-count
else
if ws-field(x:1) not numeric
set not-numeric to true
end-if
end-if
end-perform
if space-count = length of ws-field
do zero thing
else
if not numeric
do not numeric thing
else
do numeric thing
end-if
end-if |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
This one treats all spaces as numeric
Code:
Code: |
Examine ws-field replacing spaces with zeros
If ws-field not numeric
do not numeric thing
else
if ws-field = zero
do all spaces thing
else
do numeric thing
end-if |
|
With this code, |12 45 78| would become |12045078|, which i suspect would not be the desired result |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
He did say, "so spaces also considered numeric".....
You are right though, imbedded spaces might not be treated the same as leading or trailing spaces...I'll wait for a judgment before I account for the possibility.... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
For my $.02, the embedded spaces should be "not numeric", but we'll see what the rules for this case are . . . |
|
Back to top |
|
|
srebba Warnings : 1 New User
Joined: 26 Apr 2007 Posts: 37 Location: USA
|
|
|
|
Thanks fro your help..
really this is very usefull forum...
thank u
Sree |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
You're welcome
We are still looking for some of your sample data and the processing rules.
If you have moved beyond this question, other people could learn if you post your solution. |
|
Back to top |
|
|
Bharath Nadipally
New User
Joined: 24 Jun 2008 Posts: 22 Location: Hyderabad
|
|
|
|
I am new to this forum. Please correct me if anything is wrong
How about this way?
1) Find out the size of the content(total size - no of trailing spaces)
2) IF substring(x,size) IS NUMERIC
do numeric thing
else
do non-numeric thing
(Here i am assuming '12 34' kind of data will not come. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello Kumar and welcome to the forums,
Quote: |
I am new to this forum. Please correct me if anything is wrong |
Nothing actually "wrong" but you have replied to a topic that has been inactive for almost a year
Quote: |
Here i am assuming '12 34' kind of data will not come. |
The person who asked the question never did provide the requested info, so we never found out if this was possible or not. |
|
Back to top |
|
|
sasikaran
New User
Joined: 24 Jun 2008 Posts: 3 Location: chennai
|
|
|
|
Let me share my thoughts..
It will be treated as Alphanumeric until all the bytes are occupied with numbers.
If a single byte is space or alphabetic it will be considered as Alphanumeric only. |
|
Back to top |
|
|
|