PL/I Formats 
Author Message
 PL/I Formats



 >   recognize crlf, etc.  Perhaps you could send me a sample of the PL/I

In addition, the PL/I version would be more efficient as the language could
inline more of the conversions (if it's working the way I suspect it is).

OTOH, PL/I can't read in a format and use it to parse input as C and
fortran can.

---
The above are my own opinions, and not those of my employer.



Wed, 05 Aug 1998 03:00:00 GMT  
 PL/I Formats
        /* shown initialized statically, but could just as easily been passed */
        /* as a parm to a routine, or read from a file (as we do in the       */
        /* compiler for our message processing), or even built dynamically    */
        /* based on table lookups, string ops, etc.                           */
        char fmt[1000][30] ={
             "Format1: %s %1.1d\n",
             "Format2: *  %s %2.2d\n",
             "Format3: %s *  %3.3d\n",
             ...
             "Format1000: ** %12.12s %5.5d\n"};

        /* assuming 'i' has been set to the appropriate format number ... */
        printf(fmt[i],string1,int1);

        I just can't envision what the PL/I form would look like, that would
        accomplish the same intent (regardless of any perceived merit of the
        above), without an extremely complicated intercept routine that would
        make individual calls to PUT based on passed addresses/values, and
        using a similar formatting-type string as C uses.  That routine would
        need to be able to handle every possible format, and be able to
        recognize crlf, etc.  Perhaps you could send me a sample of the PL/I
        version if you get a chance (for my own education, as I don't like to
        mislead people).

---For the specific code you provided, here is an example PL/I segment:

FMT: PROC OPTIONS (MAIN);

   DECLARE H FIXED;
   DECLARE VF FORMAT;

FM(1): FORMAT (F(3));
FM(2): FORMAT (X(1), F(3));
FM(3): FORMAT (X(2), F(3));

   H = 123;
   CALL SUB (FM(1), H);
   CALL SUB (FM(2), H);
   CALL SUB (FM(3), H);

SUB: PROCEDURE (VF, H);
      DECLARE VF FORMAT, H FIXED;
      PUT SKIP EDIT (H) (R(VF));
    END SUB;
END;
(and you can use FM(I) as well instead of FM(2) etc).



Thu, 06 Aug 1998 03:00:00 GMT  
 PL/I Formats



        > >       recognize crlf, etc.  Perhaps you could send me a sample of the PL/I

        >In addition, the PL/I version would be more efficient as the language could
        >inline more of the conversions (if it's working the way I suspect it is).

        >OTOH, PL/I can't read in a format and use it to parse input as C and
        >FORTRAN can.

---I'm sure that if it would have been useful, it would have
been done already.  (BTW, having the formats checked at
compile time means that simple syntax errors don't get
through.

   However, the main reason for not doing it is that you would
only have a limited facilty of what PL/I actually provides --
namely, PL/I enables varialble names to be used in the
format list.

   Expressions (including variable names) can appear in 2 places in
a format list:

1.  As a repeat factor:

    e.g. PUT EDIT (A) ( (N) F(7) );
    which picks up  the value of the variable N, and uses it to
    deliver N repeats of the format F(7); and

2.  As a field with specifier:

    e.g. PUT EDIT (Z) (F(j,k));

    In this example, the field width is taken from variable j, and
    the number of decimal places is taken from the variable k.

   There's sufficient flexibility in the specification of
field width, decimal places, and repeat factor to make it
unnecessary to pass character strings containing format
specifications.

   Nonetheless, that doesn't stop anyone from doing format
interpretation from an actual character string.
But, better is to pass a string or numeric value, and the
field width or whatever.



Sun, 09 Aug 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. PL/1 Data Formats

2. PL/I Data Formats

3. VA PL/I for OS/390 - Free Manuals in PDF Format

4. Logo Komeniusz PL (Logo Comenius PL)

5. Derivation of PL/I (was Usenet group for PL/M language)

6. Mapping local files to FILE declarations in PL/I with IBM VisualAge PL./I for Windows

7. Difference PL/1 PL/I

8. What is the difference between DEC PL/1 and OS/390 PL/1

9. Initialization Expressions in PL/I (was ANSI PL/I)

10. Migrating from OS/VS PL/I to VA PL/I

11. PL/I FAQ -- Frequently asked questions about PL/I (minor update)

12. The PL/I Connection (PL/I Newsletter No. 6)

 

 
Powered by phpBB® Forum Software