SourceForge has been redesigned. Learn more.
Close

#27 ALIAS for SELECT ... ASSIGN TO ...

invalid
closed
4
2015-06-15
2014-05-04
WillianBR
No

I have used the Fujitsu COBOL for same time. And it has a very usefull feature. On the assign item, I can use a ID without declare it. So, on a external file, I can define it as a ALIAS. Let say if a use the ID like "SELECT DADOS-EMPREGADOS ASSIGN TO FIL-EMP-TIME.", the external file will has a line like "FIL-EMP-TIME=C:\DATA\EmpWorkTime.dat". But there is some compilers that allow me to use a ENVIMENT variable with the "FIL-EMP-TIME", and make it point the full file path ("SET FIL-EMP-TIME=C:\DATA\EmpWorkTime.dat").
I guess it will be a nice feature to implement on OpenCOBOL. It'll allow us to have the same code for PC and mainframe and we can test the code without changes.

Thanks!

Discussion

  • Brian Tiffin

    Brian Tiffin - 2014-05-04

    There is a configuration option, usually set to yes, for mapping filenames.

    See http://opencobol.add1tocobol.com/gnucobol/#assign

    If this isn't what mean William, we'll look more, but this may already be a feature.

    Cheers,
    Brian

     
    • WillianBR

      WillianBR - 2014-05-04

      Brian,

      This feature really map the filename to a new one, but it require a quotation marks. It's fine for change the file location, but the code is not compliant with mainframe code. I think the code to work as I imagine, or how it would work in a COBOL / JCL. The name of the ID file should be used without quotes. Then the ID should be saved during compile time and by being an empty variable (error by file name '') should then be used to map the physical file.

      [COBOL]
      SELECT DADOS-EMPREGADOS ASSIGN TO FIL-EMP-TIME.

      [OS]
      export FIL-EMP-TIME='/tmp/opencobol.dat'

      But now I should write something like:

      [COBOL]
      SELECT DADOS-EMPREGADOS ASSIGN TO 'FIL-EMP-TIME'.

      I appreciate the information, because I did not know this mapping mechanism. Thank you for new knowledge!

      @WillianBR

       
      • Simon Sobisch

        Simon Sobisch - 2014-06-29

        Hi WillianBR,
        as Luke has posted the current implementation and you write about the third variant without the EXTERNAL keyword, please provide a link to some documentation.

        The standard simply states "The meaning and rules for the allowable specification of device-name-1 [...] are defined by the implementor", therefore one could see FIL-EMP-TIME as device-name and tweak cobc to do so if there is no variable with this name.

        Simon

         
  • Luke Smith

    Luke Smith - 2014-06-29

    These 3 ways of assigning file paths are available.

    The first uses a working storage variable.

        SELECT DADOS-EMPREGADOS ASSIGN TO FIL-EMP-TIME
        ... 
        WORKING-STORAGE SECTION.
        01  FIL-EMP-TIME    PIC X(256) VALUE "/tmp/opencobol.dat".
    

    The second assigns directly.

        SELECT DADOS-EMPREGADOS ASSIGN TO "/tmp/opencobol.dat".
    

    The third uses an EXTERNAL variable.

        export FIL-EMP-TIME='/tmp/opencobol.dat' 
        ... 
        SELECT DADOS-EMPREGADOS ASSIGN TO EXTERNAL FIL-EMP-TIME.
    

    If these are sufficient, then this ticket can be closed. If not, please explain how they may be enhanced.

    P.S. Please use all upper case for SELECT statements. There seems to be an issue with lower case selects at the moment.

     
  • WillianBR

    WillianBR - 2014-08-14

    Thank you! The EXTERNAL option solve the problem.

     
  • Simon Sobisch

    Simon Sobisch - 2014-08-16
    • status: open --> closed
     
  • Simon Sobisch

    Simon Sobisch - 2014-08-16

    As suggested by Luke and accepted as solved from WillianBR I close this ticket because of the external file name mapping which is available since years.

    Simon

     
  • Simon Sobisch

    Simon Sobisch - 2015-06-15
    • Group: unclassified --> invalid
    • Priority: 5 --> 4
     

Log in to post a comment.