Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fortrancgi

23 views
Skip to first unread message

Ali Suhardiman

unread,
Feb 4, 1999, 3:00:00 AM2/4/99
to
anybody knows how to parse input in cgi using fortran and then convert it
into integer?

kma...@binghamton.edu

unread,
Feb 7, 1999, 3:00:00 AM2/7/99
to

A general sort of suggestion, since nobody else replied ...

First get all of the input into a sufficiently large character string.

Then use "internal read" to get the integer data from this string.

In article <36b997dd.0@news>,


"Ali Suhardiman" <bell...@ames.net> wrote:
> anybody knows how to parse input in cgi using fortran and then convert it
> into integer?
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

Clive Page

unread,
Feb 8, 1999, 3:00:00 AM2/8/99
to
In article <36b997dd.0@news>, Ali Suhardiman <bell...@ames.net> wrote:
>anybody knows how to parse input in cgi using fortran and then convert it
>into integer?

Have a look at http://www.nag.co.uk/nagware/Examples.html for a cgi module.
Converting string to integer has been done to death in other threads in
this group recently (hint: just use an internal file read).


--
Clive Page, e-mail: cgp (at) le (dot) ac (dot) uk
Dept of Physics & Astronomy,
University of Leicester.

LC's No-Spam Newsreading account

unread,
Feb 9, 1999, 3:00:00 AM2/9/99
to
On Thu, 4 Feb 1999, Ali Suhardiman wrote:

> anybody knows how to parse input in cgi using fortran and then convert it
> into integer?

Your question is too precise and to vague at the same time. Using a Fortran
program as a CGI executables (something I've always planned to do but
not done yet, at least without an intermediate shell script, which is
what I did so far) would imply three issues :

(1) one (which you do not mention) is the communication between html and
the CGI fortran program. There was an announcement on this NG of an
URL explaining the basic of it :

http://www.fcc.gov/mmb/asd/bickel/fortran.html

This URL addresses clearly the possibilities of POST and GET. It does
mention the portability problems, but does not supply a portable solution
for it (but a working solution on some platforms). I had some private
e-conversation with the author ... may be he had time to work on.

If THAT was your problem please re-post.

(2) I assume you have already found a way to cope with (1) so you have now
in your program a long CHARACTER*n string of "true" length m<n, in the
form :

variablename1=value1&variablename2=value2&....

Writing a parser using INDEX and the other character intrinsics should
be an easy exercise. I won't consider this a problem (no, I haven't a
canned solution ... although I have other parsers)

My suggestion would be to have two parsing routines, a general one

CALL GET_NEXT_VAR(name,value,error)

which at the first call returns name='variablename1' and value='value1'
as strings (if number, READ(value,*)NUMBER), at the second the next
variable and so on.

and another one

CALL GET_NAMED_VAR(name,value,error)

which called with name with an intent of input will return the value
of the variable (e.g. CALL GET_NAMED_VAR('variablename2',value,error)
will return value='value2'

(3) or perhaps you are referring to the final detail which should be hidden
in a service routine called by the previous two ... The URL-encoded
string will contain some %hh sequences instead of some characters.

Again it should be an easy exercise to :

store the hex value hh in a CHARACTER*2 HEXSTRING

convert HEXSTRING in an integer decimal value NDEC

generate the corresponding ascii character CHAR(NDEC)

and replace '%nn' with CHAR(NDEC)

Again I have no pre-canned solution. but for the hex to decimal
conversion. I will post immediately after a prototype ...

--
----------------------------------------------------------------------
nos...@ifctr.mi.cnr.it is a newsreading account used by more persons to
avoid unwanted spam. Any mail returning to this address will be rejected.
Users can disclose their e-mail address in the article if they wish so.


LC's No-Spam Newsreading account

unread,
Feb 9, 1999, 3:00:00 AM2/9/99
to
SUBROUTINE HEXI4(HEX,I4)
C
C----------------------------------------------------------------------
C
C.IDENTIFICATION: Subroutine HEXI4
C.LIBRARY: GENERAL
C.AUTHOR: L.Chiappetti - IFCTR Milano
C.VERSIONS: 0.0 - 16 Apr 96 - original versions
C.PURPOSE: convert hexadecimal to integer
C.METHOD: lookup in string and arithmetics
C.SYNTAX: CALL HEXI4(HEX,I4)
C.PARAMETERS: CHARACTER HEX*n : string with hex value (in)
C INTEGER I4 : converted binary value (out)
C.RESTRICTIONS: n in range 1 to 8
C string must be 0-padded on the left
C.NOTES: converts to native representation of the system
C.FILES:
C.REFERENCES
C
C----------------------------------------------------------------------
C
CHARACTER*(*) HEX
INTEGER I4
CHARACTER*16 VAL
INTEGER L,I,DIGIT,EX
DATA VAL /'0123456789ABCDEF'/
C
L=LEN(HEX)
CALL UPCASE(HEX)
I4=0
DO 1 I=L,1,-1
EX=L-I
DIGIT=INDEX(VAL,HEX(I:I))-1
I4=I4+(16**EX)*DIGIT
1 CONTINUE
RETURN
END

Dr Ivan D Reid, muSR Facility

unread,
Feb 9, 1999, 3:00:00 AM2/9/99
to
In article <Pine.OSF.4.05.990209...@poseidon.ifctr.mi.cnr.it>,
LC's No-Spam Newsreading account offered:

> SUBROUTINE HEXI4(HEX,I4)
>C
>C----------------------------------------------------------------------
>C
>C.IDENTIFICATION: Subroutine HEXI4
>C.LIBRARY: GENERAL
>C.AUTHOR: L.Chiappetti - IFCTR Milano
>C.VERSIONS: 0.0 - 16 Apr 96 - original versions
>C.PURPOSE: convert hexadecimal to integer
>C.METHOD: lookup in string and arithmetics
>C.SYNTAX: CALL HEXI4(HEX,I4)
>C.PARAMETERS: CHARACTER HEX*n : string with hex value (in)
>C INTEGER I4 : converted binary value (out)
>C.RESTRICTIONS: n in range 1 to 8
>C string must be 0-padded on the left
>C.NOTES: converts to native representation of the system
>C.FILES:
>C.REFERENCES
>C
>C----------------------------------------------------------------------
>C
> CHARACTER*(*) HEX
> INTEGER I4

read(hex,'(Z)')I4
c add error-handling routines as appropriate...

> RETURN
> END

--
Ivan Reid, Paul Scherrer Institute, CH. http://musr0.psi.ch/ re...@psi.ch
KotPT -- "for stupidity above and beyond the call of duty".

0 new messages