#include "Simpleio.ch"
FUNCTION MAIN()
?? [Content-type: text/html]
?
? [<HTML>]
? [<HEAD>]
? [<BODY>]
? [Param = ] + GETVAR( "Param" )
? [</BODY>]
? [</HTML>]
RETURN NIL
STATIC FUNCTION GETVAR( cVar )
LOCAL nLen, nPos, nSta, nEnd
STATIC cString
IF cString = NIL
nLen = VAL( GETENV( "CONTENT_LENGTH" ) )
IF nLen > 0
cString = SPACE( nLen )
FREAD( 0, @cString, nLen )
ELSE
cString = GETENV( "QUERY_STRING" )
ENDIF
ENDIF
IF EMPTY( cString ); RETURN ""; ENDIF
nPos = AT( cVar, cString )
IF nPos != 0
nSta = nPos + LEN( cVar ) + 1
nEnd = AT( "&", SUBSTR( cString, nSta ) )
IF nEnd = 0
RETURN DECODE( SUBSTR( cString, nSta ) )
ELSE
RETURN DECODE( SUBSTR( cString, nSta, nEnd - 1 ) )
ENDIF
ELSE
RETURN ""
ENDIF
RETURN NIL
STATIC FUNCTION DECODE( cString )
LOCAL cResult := ""
LOCAL i
FOR i = 1 TO LEN( cString )
IF SUBSTR( cString, i, 1 ) = "+"
cResult += " "
ELSEIF SUBSTR( cString, i, 1 ) = "%"
cResult += HEX2CHR( SUBSTR( cString, i + 1, 2 ) )
i += 2
ELSE
cResult += SUBSTR( cString, i, 1 )
ENDIF
NEXT
RETURN cResult
STATIC FUNCTION HEX2CHR( cHex )
LOCAL cHigh := UPPER( SUBSTR( cHex, 1, 1 ) )
LOCAL cLow := UPPER( SUBSTR( cHex, 2, 1 ) )
LOCAL nHigh, nLow
IF ISDIGIT( cHigh )
nHigh = ASC( cHigh ) - 48
ELSE
nHigh = ASC( cHigh ) - 55
ENDIF
IF ISDIGIT( cLow )
nLow = ASC( cLow ) - 48
ELSE
nLow = ASC( cLow ) - 55
ENDIF
RETURN CHR( nHigh * 16 + nLow )
#include "Error.ch"
FUNCTION ERRORSYS()
ERRORBLOCK( { | e | DefError( e ) } )
RETURN NIL
STATIC FUNCTION DEFERROR( e )
DO CASE
CASE e:GenCode = EG_OPEN .AND. ( e:OsCode = 32 .OR. e:OsCode = 5 ) .AND. e:CanDefault
NETERR( .T. )
RETURN .F.
CASE e:GenCode = EG_APPENDLOCK .AND. e:CanDefault
NETERR( .T. )
RETURN .F.
OTHERWISE
ERRORMESSAGE( e )
QUIT
ENDCASE
RETURN NIL
STATIC FUNCTION ERRORMESSAGE( e )
LOCAL cMessage
LOCAL n := 3
// Start error message
cMessage = IF( e:Severity > ES_WARNING, "Error ", "Warning " )
// Add subsystem name if available
IF VALTYPE( e:SubSystem ) = "C"
cMessage += e:SubSystem
ELSE
cMessage += "???"
ENDIF
// Add subsystem's error code if available
IF VALTYPE( e:SubCode ) = "N"
cMessage += "/" + LTRIM( STR( e:SubCode ) )
ELSE
cMessage += "/???"
ENDIF
// Add error description if available
IF VALTYPE( e:Description ) = "C"
cMessage += " " + e:Description
ENDIF
// Add either filename or operation
IF !EMPTY( e:Filename )
cMessage += ": " + e:Filename
ELSEIF !EMPTY( e:Operation )
cMessage += ": " + e:Operation
ENDIF
// Add function name and line number
IF EMPTY( PROCLINE( n ) )
n++
ENDIF
cMessage += ";Function: " + PROCNAME( n ) + " Line: " + LTRIM( STR( PROCLINE( n ) ) )
?? [Content-type: text/html]
?
? [<HTML>]
? [<BODY>]
? cMessage
? [</BODY>]
? [</HTML>]
RETURN NIL
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 75 guests