Suppose I have one data like is there contact no and char but don't know exact position of contact from which position contact is starting than how will be find the contact only using cobol logic. Which logic I will be used?
I said reference modification
Finding a random number using COBOL.
-
- New Member
- Posts: 1
- Joined: Wed Feb 24, 2016 5:46 pm
Re: Finding a random number using COBOL.
Hello.
It would depend upon the format of the data that you're accepting and what exactly you are looking for. If it's just a matter of finding the first number in the string and taking that as the start of the data then something like INSPECT would do the job. If it's something more complicated, then you may have to substring your way through the input looking for specific conditions.
What I would say about questions like this in interview situations is that it's OK to ask questions back or get clarification. Ensuring that you have a clear understanding of the problem you are trying to solve is a key part being a programmer so showing that you can ask the right questions when you need to is, and should be recognised as, a positive. In this situation, I'd want examples of what the input data is going to look like and the specifics of what is being searched for within the string before passing judgement on how to solve the problem.
It would depend upon the format of the data that you're accepting and what exactly you are looking for. If it's just a matter of finding the first number in the string and taking that as the start of the data then something like INSPECT would do the job. If it's something more complicated, then you may have to substring your way through the input looking for specific conditions.
What I would say about questions like this in interview situations is that it's OK to ask questions back or get clarification. Ensuring that you have a clear understanding of the problem you are trying to solve is a key part being a programmer so showing that you can ask the right questions when you need to is, and should be recognised as, a positive. In this situation, I'd want examples of what the input data is going to look like and the specifics of what is being searched for within the string before passing judgement on how to solve the problem.
Re: Finding a random number using COBOL.
You can use INSPECT to locate the position of numeric values or specific patterns in the string. Once found, REFERENCE MODIFICATION can extract the contact number. For more complex data, combining UNSTRING and EVALUATE conditions could help navigate through the input logically.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute