PL/I to COBOL conversion 
Author Message
 PL/I to COBOL conversion

 First sorry by english level

 In PL/I (V2R3M0, IBM OS/390)  is possible to work which booleans
fields. It must be defined
as :
        DCL SWITCH BIT(1) VALUE '0'B;

 A need to know if there are a correspondence in IBM VSCOBOL II Release
3.2. I remember
that in IBM COBOL for IMB systems 36 and AS/400 (i think too) this was
supported by defining :

       01 SWITCH PIC 1 INDICATOR.
            88 SWITCH-ON  VALUE '1'B.
            88 SWITCH-OFF VALUE '0'B.

 Now I can't found any reference on VSCOBOL II manuals about this kind
of variables.

 Can you help me ? Thank a lot



Sun, 05 Aug 2001 03:00:00 GMT  
 PL/I to COBOL conversion
Josep,

There's no PIC 1 available in VS COBOL II (or its successors) and there's
no way of accessing a bit item directly.

If the size of the data is not critical, change them to PIC X and use,
for example:

  01  SWITCH  PIC X.
    88  SWITCH-ON VALUE X"01".
    88  SWITCH-OFF VALUE X"00".

One advantage with this is that you could have more values in addition to
just ON and OFF.

If the switch is alone and has character or binary items on each side,
then it's taking up a whole byte anyway and you lose nothing by using a
PIC X.

If, on the other hand, you have up to 8 bit switches together and you  
can't change them all to PIC X because of size or compatibility
considerations, then all your options are a bit ugly I'm afraid.
You'll have to define them as a PIC X, e.g.

  01  EIGHT-SWITCHES  PIC X.

then you could try:

1) using a subroutine to do a boolean AND and OR e.g. CALL "TESTSW" USING
EIGHT-SWITCHES position REPLY (where position is 1 to 8) and CALL "SETSW"
USING EIGHT-SWITCHES position.

2) using a subroutine to "UNPACK" and "PACK" to and from a PIC X item and
a PIC X OCCURS 8 field in working storage.

3) move the EIGHT-SWITCHES to the lowest byte of a PIC S9(9) COMP field
(with the higher bytes binary zeros) and then do a repeated divide by 2.
(Well, I said it gets ugly.)

John Piggott.

Quote:

>  First sorry by english level

>  In PL/I (V2R3M0, IBM OS/390)  is possible to work which booleans
> fields. It must be defined
> as :
>         DCL SWITCH BIT(1) VALUE '0'B;

>  A need to know if there are a correspondence in IBM VSCOBOL II Release
> 3.2. I remember
> that in IBM COBOL for IMB systems 36 and AS/400 (i think too) this was
> supported by defining :

>        01 SWITCH PIC 1 INDICATOR.
>             88 SWITCH-ON  VALUE '1'B.
>             88 SWITCH-OFF VALUE '0'B.

>  Now I can't found any reference on VSCOBOL II manuals about this kind
> of variables.

>  Can you help me ? Thank a lot



Sun, 05 Aug 2001 03:00:00 GMT  
 PL/I to COBOL conversion
After a week-end of saying "{*filter*}" things about the draft Standard, this is
time for my usual "plug" for the good things in it.  Both "Boolean" (usually
a 1 byte "switch" field) and "bit" fields are defined in the draft Standard
(although there is still some work.debate going on concerning groups, bits,
redefines, and where a bit field can start).

If you are interested in your vendor providing support for
either of these features in a "timely" manner, I would suggest you contact
them and request that they provide support before the next Standard is
official.

NOTE: The original question was for the OS/390 or MVS environment - where
such fields are NOT currently supported.  IBM, does, however, support
partial but not identical functionality in their COBOL/400 product.  My
memory is that it is for Boolean items but not bit-fields - but I would
easily stand corrected by our more knowledgeable OS/400 readers.

P.S. Yes, Randall, as with so many cases - like the meaning of COMP - IBM is
quite inconsistent in their COBOL extensions across platforms - and since
the "death of AD/Cycle" there has been little demand and even less
indication that such discrepancies will ever be resolved.

--
Bill Klein (wmklein at ix dot netcom dot com)



Sun, 05 Aug 2001 03:00:00 GMT  
 PL/I to COBOL conversion

Quote:

>There's no PIC 1 available in VS COBOL II (or its successors) and there's
>no way of accessing a bit item directly.

>If the size of the data is not critical, change them to PIC X and use,
>for example:

>  01  SWITCH  PIC X.
>    88  SWITCH-ON VALUE X"01".
>    88  SWITCH-OFF VALUE X"00".

>One advantage with this is that you could have more values in addition to
>just ON and OFF.

But there's also a {*filter*} class of bug lurking in this code. What happens
when the switch contains a value other than x"00" or x"01"? Are such
values to be considered "true"/"on" or "false"/"off"?

One way of dealing with such ambiguous situations (and, thanks to bugs
elsewhere in the code, they can be expected to arise) is to define only
one 88-level and then test solely against that. I would, myself, keep the
switch-off value and treat all other values as "on." This requires that
all programmers involved understand the issue and toe the line. There is
no room for originality once a convention of this nature is settled on.

In a shop I used to work in, for historic reasons Booleans were
conventially defined as pic x(1) taking the values " " and "X". Tests were
made, higgledly-piggledy, against both values. As you can imagine, a
corrupted Boolean caused the most astonishing screwups. I think that
eventually everyone realized that tests had to be made consistently
against one or the other value.

The great advantage of using a true single bit field for a Boolean is that
such corruption is impossible. If the field is corrupted, it is still
unambiguously one or the other of the two possible values.

--
Rodger Whitlock



Mon, 06 Aug 2001 03:00:00 GMT  
 PL/I to COBOL conversion
Josep,

There was a reply about using Bit fields using LE calls.  A bit of a
mixture (I would recommend upgrading to cobol for MVS anyway)

to find the bits in a single byte

move zero to comp-field.
move byte to last-part-of-comp-field.
perform 8 times
        divide comp-field by 2 giving comp-field
                               remainder bit-array(count)
end-perform

You get the idea...
Ken



Tue, 07 Aug 2001 03:00:00 GMT  
 PL/I to COBOL conversion
COBOL 370/LE allows Bit manipulation withing the Language.

The div by 2 is pretty good.

You can also code
05  MY-BITMASK.
      10  HEX-80   PIC X  VALUE X'80'   (10000000)   7F
      10  HEX-00   PIC X  VALUE X'00'.                      FF
      10  HEX-00   PIC X  VALUE X'00'.                      FF
      10  HEX-00   PIC X  VALUE X'00'.                      FF
      10  HEX-00   PIC X  VALUE X'00'.                      FF
      10  HEX-00   PIC X  VALUE X'00'.                      FF
      10  HEX-01   PIC X  VALUE X'01'   (00000001)   FF
this is hex 8000001  ( or 2147483649)
also 7FFFFFFF is = -2147483648

Quote:

>Josep,

>There was a reply about using Bit fields using LE calls.  A bit of a
>mixture (I would recommend upgrading to cobol for MVS anyway)

>to find the bits in a single byte

>move zero to comp-field.
>move byte to last-part-of-comp-field.
>perform 8 times
> divide comp-field by 2 giving comp-field
>        remainder bit-array(count)
>end-perform

>You get the idea...
>Ken



Sat, 11 Aug 2001 03:00:00 GMT  
 PL/I to COBOL conversion
Per discussion of code

Quote:
>to find the bits in a single byte

In addition to the fine discussion so far, you can consider just doing a lookup
in a table that has the 256 static values already hard coded. Just use the byte
as an index into the table. You will have to normalize 0 to 1 ... 255 to 256
for COBOL basis 1 tables.

Division is the slowest possible way. This kind of thing really does not need
to be 'calculated' dynamically.

Best Wishes,

Robert Rayhawk



Mon, 13 Aug 2001 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. PL/I to Cobol Conversions

2. PL/I to COBOL conversion

3. AUTOMATED TOOL FOR PL/1 - COBOL CONVERSION

4. Question about RM/COBOL and PL/COBOL compatibility.

5. tandem COBOL to IBM Mainframe MVS COBOL Conversion

6. COBOL to COBOL II Conversion

7. US*NC COBOL/COBOL II Conversion

8. VS COBOL II to COBOL/400 conversion query

9. R/M COBOL 85 to COBOL-WOW Conversion

10. COBOL-68 to COBOL-85 conversion

11. MF VS/Cobol to Cobol II/370 Conversion?

12. Info/Advice needed on IBM Cobol 2 to MF Unix Cobol conversion

 

 
Powered by phpBB® Forum Software