!Program illustrating the use of the CGI_UTILS module !____________________________________________________ PROGRAM CGI_EXAMPLE USE CGI_UTILS USE ISO_VARYING_STRING LOGICAL :: ok REAL :: x INTEGER :: status ! Initialise the CGI connection and continue if ok ..... CALL CGI_INIT(ok) IF(ok) THEN ! Output the filetype and a blank line: WRITE(*,'(A/)') "Content-type: text/html" ! Output the entries (put_line is from iso_varying_string): WRITE(*,'(A/)') "Your HTML form sent this CGI script these variables:
" DO i=1, number_of_entries CALL PUT_LINE(cgi_entries(i)%name) CALL PUT_LINE(' := ') CALL PUT_LINE(cgi_entries(i)%value) CALL PUT_LINE('
') END DO ! Convert the second string to a number and square it: READ(CHAR(cgi_entries(2)%value),*,IOSTAT=status) x IF(status==0) THEN WRITE(*,*) "The square of the number you entered is",x**2 ELSE WRITE(*,*) "Please enter a meaningful number, error: ",status END IF END IF END PROGRAM CGI_EXAMPLE