Topic
3 replies Latest Post - ‏2013-05-28T02:03:14Z by Robin400
Frank_O_Myers@IBM
Frank_O_Myers@IBM
9 Posts
ACCEPTED ANSWER

Pinned topic Can PL/I format strings or edit descriptions be stored externally?

‏2013-04-11T21:02:37Z |
Hi,
 
Is there a way to store and use format strings for messages externally (in a file) and then use them in a PUT EDIT statement?
As can be done with the "C fprintf()" format string?
 
 Mit freundlichen Grüßen / With kindest regards
 
Frank
  • Robin400
    Robin400
    19 Posts
    ACCEPTED ANSWER

    Re: Can PL/I format strings or edit descriptions be stored externally?

    ‏2013-04-20T10:21:21Z  in response to Frank_O_Myers@IBM

    As far as I know, you cannot. There is a good reason for this.

    However, because PL/I provides the means to give a format specification

    in which the field width, repeat factors, etc,

    are provided at run time, you have pretty much the same facility.

  • FF1352
    FF1352
    2 Posts
    ACCEPTED ANSWER

    Re: Can PL/I format strings or edit descriptions be stored externally?

    ‏2013-05-08T16:31:36Z  in response to Frank_O_Myers@IBM

    Hi

    Yes i think you can do this by using preprocessor features
    you can define your different formats in preprocessor variables like this"


    %dcl     (format1, format2,format3)   char;

    %format1 = '(a(5),x(2),2 f(8),x(1),a(20))' ;    
    %format2 = '(f(3),f(12))' ;
    %format3 = '(f(7,2),a(5),x(1),f(6))';

    and then later in your program do like this:


    put skip edit(str1,ix1,ix2,str2) format1 ;

    put skip edit(ix3,ix4) format2 ;

    put skip edit(flt1,str3,ix4) format3 ;




    and when you compile your program you can see in your Listing that format1,2,3 is changed with that formats that you define with
    preprocessor variables.

    and you can write all your favourite formats in a file and add this file in a Maclib with a name for example "formats" and then
    use this in your program

    %include formats;


    i hope this be usefull for you

    thanks

     

    Updated on 2013-05-09T08:39:48Z at 2013-05-09T08:39:48Z by FF1352
    • Robin400
      Robin400
      19 Posts
      ACCEPTED ANSWER

      Re: Can PL/I format strings or edit descriptions be stored externally?

      ‏2013-05-28T02:03:14Z  in response to FF1352

      That doesn't provide any additional facility than coding the format in the program,

      and certainly doesn't provide the ability to change the format specification at run-time.

      The method I previously suggested in this thread permits format specifications to be changed

      at run time.

       

      In addition to the above, a run-time picture specification can be used

      (obtained from any input file) via the EDIT built-in function.