Go to FCC.gov
FCC Logo - Return to the FCC Home Page  
  Audio Division                                                               COLORIT Color Generator
Fax: 202-418-1411

    Help | Advanced


Media Bureau Home
  Bureau Documents

  MB Divisions
MB Divisions
  Office of the Bureau   Chief

  Audio Division

  Video Division

  Policy Division

  Industry Analysis   Division

  Engineering Division
  Management and   Resources Staff

The Audio Division

  Alphabetical Index

  Experts list

  Internet Queries

  Radio Tools Popup


  Most Requested   Information

  Major Subject Areas

  Audio Headlines

  Electronic Filing

Electronic Filing Skip Bureau and Office Links

Visit the FirstGov Portal
Easy, one-stop access to all online U.S. Federal Government resources



HTML Color Generator
A Fortran GET CGI example

This program or CGI takes a 6 digit hexadecimal number and converts it to the corresponding HTML color, which is displayed in a band across the center of a table. In addition, the program calculates and displays the new color which results by increasing or decreasing each digit. These additional colors are shown in smaller squares, along with the corresponding hexadecimal number. Up to 48 additional colors may be shown. If the calculated increment is out of the hexadecimal range 0 through F, "No Color" will be shown.


The source code for this program (HTML and Fortran CGI) is available for download. COLORIT uses the GET method to receive data, reading the input string from the environment variable QUERY_STRING using the intrinsic routine getenv. The character string received via getenv character string is subsequently parsed to retrieve the name=value data pairs sent by the form. In a GET method string, the QUERY_STRING string consists of everything to the right of the input URL, e.g. input=8CDC5F in http://transition.fcc.gov/fcc-bin/colorit?input=8cdc6f.


    • The QUERY_STRING is a character string. If numbers are contained in the string, they are ASCII characters and must be converted to numbers before use.

    • In this example, the HTML output is established by the statements

      55 Format("Content-type: text/html"//)

      This code must be placed before any HTML statements are written to output. (Yes, you can change the Format statement number.) The two // are VERY IMPORTANT! Also, note the placement of the " quotation marks. Compare to the corrsponding C language statement

      printf("Content-type: text/html\n\n");

    • For HTML OUTPUT, the HTML tags are contained inside Format statements, as shown in the example Fortran code. BE SURE to have the usual HTML ending tags, or you may not see any HTML output or receive an execution error code.

    • Carefully watch use of  ' and " in Format statements: it's too easy to miss one ' or " or add too many.

    • When generating output, statements must be no longer than the 72 character limit in Fortran 77. Another Format statement or a continuation character in Column 6 may be used for longer statements.

    • A CGI can output a new HTML form, or call a CGI. The Fortran program can also incorporate subroutines, called in the usual manner, although none are needed for this example.

    • Fortran carriage control characters are unneeded when generating HTML output. Use the HTML tags to perform this function. However, to keep the browsers' source code view tidy, you can include returns at the end of HTML lines:

      111 format(" HTML text here! " /)

    • The program has not been optimized. There certainly are better ways to do some of the tasks or changes which could be made to reduce the code, but it's not necessary for this simple example. Please note that no Fortran or CGI library functions were used in the preparation or execution of this example. The program was designed as a stand-alone CGI.

    Dale Bickel
    Senior Electronics Engineer
    Audio Division, Media Bureau

    Original page November 1998; revised March 25, 2002


    If you would like more information pertaining to the Media Bureau, please call: (202) 418-7200.

    Skip FCC Footer and Contact InfoFederal Communications Commission
    445 12th Street SW
    Washington, DC 20554
    More FCC Contact Information...
    Phone:  1-888-CALL-FCC (1-888-225-5322)
    TTY:  1-888-TELL-FCC (1-888-835-5322)
    Fax:  1-866-418-0232
    - Privacy Policy
    - Website Policies & Notices
    - Required Browser Plug-ins
    - Freedom of Information Act