View previous topic :: View next topic
|
Author |
Message |
Lavanya_Dhushetty Warnings : 2 New User
Joined: 30 Aug 2007 Posts: 24 Location: Chennai
|
|
|
|
. Consider the following code snippet:
01 WS-VAR PIC X(6) VALUE 'INDEPENDENCE'.
…
…
EXAMINE WS-VAR REPLACING UNTIL FIRST "E" by "D".
What will WS-VAR contain after the EXAMINE statement is executed?
Answers:
a. INDDPENDENCE
b. INEDPDNEDNCD
c. INDDPDNDDNCD
d. DDDDPENDENCE
e. DDDEPENDENCE |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Lavanya,
You are kidding, right?
Is this some kind of trick question? |
|
Back to top |
|
|
RamsIBM
New User
Joined: 08 Jan 2007 Posts: 53 Location: Chennai
|
|
|
|
Ans ) E
Guys correct me if am wrong |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Lavanya,
Quote: |
01 WS-VAR PIC X(6) VALUE 'INDEPENDENCE'. |
Provided options are all wrong. |
|
Back to top |
|
|
diwa_thilak
Active User
Joined: 13 Jul 2006 Posts: 205 Location: At my desk
|
|
|
|
Lavanya,
I dont see any correct options are available for this question.
Quote: |
If identifier is a nonnumeric data item, examination begins with the
leftmost character, and proceeds to the right. Each character is
examined in turn.
If identifier is a numeric data item, the data item may contain a sign,
and examination proceeds on a digit by digit basis. This examination
starts with the leftmost digit and proceeds to the right. If a sign is
included in the data item being examined, it is ignored regardless of its
physical location |
.
Quote: |
* If REPLACING ALL is specified, all occurrences of literal-3 in
identifier are replaced by literal-4.
* If REPLACING LEADING is specified, each occurrence of literal-3 is
replaced by literal-4 until the first occurrence of a character
other than literal-3 or the rightmost character of the data item
is examined.
* If REPLACING UNTIL FIRST is specified, every character of the data
item represented by identifier is replaced by literal-4 until
literal-3 is encountered in the data item. If literal-3 does not
appear in the data item, the entire data item is filled with
literal-4.
* If REPLACING FIRST is specified, only the first occurrence of
literal-3 is replaced by literal-4. If literal-3 does not appear
in the data item represented by identifier, the data item is
unchanged after execution of the EXAMINE statement. |
I beleive the correct answer should be INDEPENDENCD
One more information, Examine is now replaced with INSPECT statement
Cheers,
Diwakar
-----------------------------------------
Nobody is Perfect. I am Nobody |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
All of the answers are wrong.
The answers are 12 characters but the field is defined as 6. . . .
Here, the compiler complains if the value exceeds the defined length. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
With the right (or wrong) compiler options, you will receive a warning message indicating that you were a little dumb allocating less space than the value you wanted to have contained.
compiler will truncate your value to the length provided in the picture clause and generate an object (if that was your only error).
I believe that the compiler will not generate an object if you provide a value that exceeds the pic clause length associated with a level-88 item. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi Dick,
Quote: |
compiler will truncate your value to the length provided in the picture clause and generate an object (if that was your only error). |
I used the following definition
Code: |
01 VARIABLE.
05 FIELDA PIC X(06) VALUE 'ABCDEFGHI'. |
There was below error message in the compiler listing:
Code: |
VALUE" literal "'ABCDEFGHI'" exceeded the length specified in the "PICTURE" definition. The literal was truncated to the "PICTURE" definition length. |
and the compilation was failed, load module was not created.
So I think, even for some other level, load module will not be created..
Quote: |
I believe that the compiler will not generate an object if you provide a value that exceeds the pic clause length associated with a level-88 item. |
Quote: |
With the right (or wrong) compiler options, |
Can you please tell me, what right & wrong options you are talking about here ? Can compiler option play a role in above case, if yes, how ? Please let me know. |
|
Back to top |
|
|
Lavanya_Dhushetty Warnings : 2 New User
Joined: 30 Aug 2007 Posts: 24 Location: Chennai
|
|
|
|
If that is pic x(12).Can U tell me what would be the result?????? |
|
Back to top |
|
|
raviprasath_kp Warnings : 1 New User
Joined: 20 Feb 2005 Posts: 65 Location: chennai
|
|
|
|
then the ans is
e. DDDEPENDENCE |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Got to agree, but what manual did you find the EXAMINE in?
I could only find INSPECT as in:
INSPECT indentifier-1 REPLACING CHARACTERS BY literal-1 BEFORE INITIAL literal-2 |
|
Back to top |
|
|
diwa_thilak
Active User
Joined: 13 Jul 2006 Posts: 205 Location: At my desk
|
|
|
|
Hi All,
I apologize for the wrong answer, correct answer has to be DDDEPENDENCE
Godd catch Dick and Anuj, I didnt notice the length of the picture clause.
CICS Guy you can check out this link for examine statement.
http://docs.hp.com/cgi-bin/doc3k/B3150090013.11820/84
Cheers,
Diwakar
--------------------------------------
Nobody is Perfect. I am Nobody |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
diwa_thilak wrote: |
CICS Guy you can check out this link for examine statement. |
Oh, thanks, I do remember EXAMINE, I just couldn't find it in current documnetation....
From your link: "HP COBOL II includes the EXAMINE statement for compatibility with COBOL'68" |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
And the only HP cobol i've worked with is run on UNIX. |
|
Back to top |
|
|
|