Getting cobconfig to work.

I saw a post on how to get MF Visual Cobol to print to a USB printer, instead of the default LPT1. However, it was not as descriptive as I would have hoped. Since I have not worked with Cobol since 1995 and went into the business world using Fortran after that class, I never found the need to set environment variables. I also never used MF Cobol before now. The one post states to create a file called cobconfig.cfg and then set the cobconfig environment variable to point to that file. Well, I have tried a couple of ways on my own and could not get it to set the environment variable of cobconfig and work. Any help that someone can provide in getting the cobconfig environment variable to work in MF Visual Cobol for Visual Studio 2012 would be greatly appreciated. I've looked far and wide on the net and have not yet found any specific help. I did get the old program to work via sending the output to a file, but I want to get it to work as originally intended to a printer and not to the old LPT1 port. A specific example of how to set the variable would be great.

Parents
  • Mozdzierz,

    Setting cobconfig from within the program did not work because the file is read when the COBOL run-time system starts up. Once you are in the COBOL program it has already started so it is too late.

    When you said you set it in WIndows, do you mean that you set it as an environment variable from Control Panel -> System -> Advanced -> Environment variables ? That should work so if it failed it could be for one of the following reasons

    1. The file could not be found. A full path to the file should be specified as the value

    2. The file contains a spelling mistake or does not contain a newline character after the tuneable.

    3. The USB printer is not set as the default printer.

    To check that the variable has been set correctly you could add the following check to your code

    01 cobconfig-value    pic x(255).

    ...

    DISPLAY "COBCONFIG" UPON ENVIRONMENT-NAME

    ACCEPT cobconfig-value FROM ENVIRONMENT-VALUE

    IF cobconfig-value = SPACES

       DISPLAY "COBCONFIG was not set"

    END-IF

    Gael

Reply
  • Mozdzierz,

    Setting cobconfig from within the program did not work because the file is read when the COBOL run-time system starts up. Once you are in the COBOL program it has already started so it is too late.

    When you said you set it in WIndows, do you mean that you set it as an environment variable from Control Panel -> System -> Advanced -> Environment variables ? That should work so if it failed it could be for one of the following reasons

    1. The file could not be found. A full path to the file should be specified as the value

    2. The file contains a spelling mistake or does not contain a newline character after the tuneable.

    3. The USB printer is not set as the default printer.

    To check that the variable has been set correctly you could add the following check to your code

    01 cobconfig-value    pic x(255).

    ...

    DISPLAY "COBCONFIG" UPON ENVIRONMENT-NAME

    ACCEPT cobconfig-value FROM ENVIRONMENT-VALUE

    IF cobconfig-value = SPACES

       DISPLAY "COBCONFIG was not set"

    END-IF

    Gael

Children
No Data