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.