2012-10-11 11:48 UTC+0200 Viktor Szakats (harbour syenar.net)
* extras/hbxlsxml/xlsxml.prg
* extras/httpsrv/modules/info.prg
* extras/httpsrv/modules/showcounter.prg
* extras/httpsrv/modules/testajax.prg
* tests/mathtest.prg
* tests/memfile.prg
* tests/memory.prg
* tests/memtst.prg
* tests/memvar.prg
* tests/newrdd.prg
* contrib/hbmisc/hbeditc.c
* formatting
* src/rdd/usrrdd/rdds/hscdx.prg
* src/rdd/usrrdd/rdds/rlcdx.prg
* hbformat, manual fixups
* contrib/hbformat/hbfmtcls.prg
* added TOFIX for not recognizing INIT/EXIT PROCEDURE
statements
* tests/memtst.prg
! typo in comment
* tests/mathtest.prg
! added CLS to run well under hbrun
This commit is contained in:
@@ -61,6 +61,7 @@
|
||||
MEMVAR _SERVER, _REQUEST, _GET, _POST, _COOKIE, _SESSION, _HTTP_REQUEST, _HTTP_RESPONSE
|
||||
|
||||
FUNCTION HRBMAIN()
|
||||
|
||||
LOCAL cHtml
|
||||
|
||||
cHtml := ShowServerInfo()
|
||||
@@ -68,11 +69,13 @@ FUNCTION HRBMAIN()
|
||||
RETURN cHtml
|
||||
|
||||
STATIC FUNCTION ShowServerInfo()
|
||||
|
||||
LOCAL cHtml := ""
|
||||
//LOCAL oCookie
|
||||
|
||||
// LOCAL oCookie
|
||||
|
||||
cHtml += "<BIG>Server Info</BIG>"
|
||||
//cHtml += "<br><br>If it is first time you see this page reload it to see cookies<br><br>"
|
||||
// cHtml += "<br><br>If it is first time you see this page reload it to see cookies<br><br>"
|
||||
cHtml += '<br><br>Return to <a href="/">Main Page</a><br><br>'
|
||||
|
||||
cHtml += DisplayVars( _Server , "SERVER Vars" )
|
||||
@@ -87,17 +90,17 @@ STATIC FUNCTION ShowServerInfo()
|
||||
cHtml += "<br>"
|
||||
cHtml += DisplayVars( _Cookie , "COOKIE Vars" )
|
||||
cHtml += "<br>"
|
||||
//cHtml += DisplayVars( _Files , "FILE Vars" )
|
||||
//cHtml += "<br>"
|
||||
// cHtml += DisplayVars( _Files , "FILE Vars" )
|
||||
// cHtml += "<br>"
|
||||
cHtml += DisplayVars( _Request , "REQUEST Vars" )
|
||||
cHtml += "<br>"
|
||||
cHtml += DisplayVars( _Session , "SESSION Vars" )
|
||||
cHtml += "<br>"
|
||||
|
||||
// Set a simple cookie
|
||||
//oCookie := uhttpd_CookieNew( "localhost", "/", 1, 0 )
|
||||
//oCookie:SetCookie( "samplecookie", "test" )
|
||||
//oCookie:SetCookie( "samplecookie2", "test2" )
|
||||
// oCookie := uhttpd_CookieNew( "localhost", "/", 1, 0 )
|
||||
// oCookie:SetCookie( "samplecookie", "test" )
|
||||
// oCookie:SetCookie( "samplecookie2", "test2" )
|
||||
|
||||
_SESSION[ "Session_Var1" ] := "Test1"
|
||||
_SESSION[ "Session_Var2" ] := "Test2"
|
||||
@@ -105,37 +108,41 @@ STATIC FUNCTION ShowServerInfo()
|
||||
RETURN cHtml
|
||||
|
||||
STATIC FUNCTION DisplayVars( hHash, cTitle )
|
||||
|
||||
LOCAL cHtml := ""
|
||||
|
||||
cHtml += "<table width='90%' align='center' border='1'>"
|
||||
cHtml += "<th colspan=2>" + hb_cStr( cTitle ) + "</th>"
|
||||
cHtml += "<th colspan=2>" + hb_CStr( cTitle ) + "</th>"
|
||||
cHtml += "<tr>"
|
||||
cHtml += "<th width='20%'>KEY</th>"
|
||||
cHtml += "<th width='80%'>VALUE</th>"
|
||||
cHtml += "</tr>"
|
||||
cHtml += DisplayHash( hHash )
|
||||
cHtml += "</table>"
|
||||
|
||||
RETURN cHtml
|
||||
|
||||
STATIC FUNCTION DisplayHash( hHash )
|
||||
|
||||
LOCAL cHtml := ""
|
||||
LOCAL cKey, cSubKey, xValue
|
||||
|
||||
FOR EACH cKey IN hHash:Keys
|
||||
cHtml += "<tr>"
|
||||
IF HB_ISHASH( hHash[ cKey ] )
|
||||
cHtml += "<td>" + hb_cStr( cKey ) + "</td>"
|
||||
cHtml += "<td>" + hb_CStr( cKey ) + "</td>"
|
||||
cHtml += "<td>-------</td>"
|
||||
FOR EACH cSubKey IN hHash[ cKey ]:Keys
|
||||
xValue := hHash[ cKey ][ cSubKey ]
|
||||
cHtml += "<tr>"
|
||||
cHtml += "<td>" + hb_cStr( cSubKey ) + "</td>"
|
||||
cHtml += "<td>" + IIF( Empty( xValue ), "<i>no value</i>", hb_cStr( xValue ) ) + "</td>"
|
||||
cHtml += "<td>" + hb_CStr( cSubKey ) + "</td>"
|
||||
cHtml += "<td>" + iif( Empty( xValue ), "<i>no value</i>", hb_CStr( xValue ) ) + "</td>"
|
||||
cHtml += "</tr>"
|
||||
NEXT
|
||||
ELSE
|
||||
xValue := hHash[ cKey ]
|
||||
cHtml += "<td>" + hb_cStr( cKey ) + "</td>"
|
||||
cHtml += "<td>" + IIF( Empty( xValue ), "<i>no value</i>", hb_cStr( xValue ) ) + "</td>"
|
||||
cHtml += "<td>" + hb_CStr( cKey ) + "</td>"
|
||||
cHtml += "<td>" + iif( Empty( xValue ), "<i>no value</i>", hb_CStr( xValue ) ) + "</td>"
|
||||
ENDIF
|
||||
cHtml += "</tr>"
|
||||
NEXT
|
||||
|
||||
@@ -63,15 +63,16 @@ MEMVAR _REQUEST // defined in uHTTPD
|
||||
#define DISPLAY_NUM 10
|
||||
|
||||
FUNCTION HRBMAIN()
|
||||
|
||||
LOCAL cHtml
|
||||
|
||||
IF HB_HHasKey( _REQUEST, "w" )
|
||||
IF hb_HHasKey( _REQUEST, "w" )
|
||||
|
||||
cHtml := CreateCounter( hb_ntos( Val( _REQUEST[ "w" ] ) ) )
|
||||
IF !Empty( cHtml )
|
||||
uhttpd_SetHeader( "Content-Type", "image/gif" )
|
||||
uhttpd_SetHeader( "Pragma", "no-cache" )
|
||||
uhttpd_SetHeader( "Content-Disposition", "inline; filename=counter" + hb_ntos( hb_randomint( 100 ) ) + ".gif" )
|
||||
uhttpd_SetHeader( "Content-Disposition", "inline; filename=counter" + hb_ntos( hb_RandomInt( 100 ) ) + ".gif" )
|
||||
uhttpd_Write( cHtml )
|
||||
ELSE
|
||||
uhttpd_SetHeader( "Content-Type", "text/html" )
|
||||
@@ -91,50 +92,51 @@ FUNCTION HRBMAIN()
|
||||
STATIC FUNCTION CreateCounter( cValue, cBaseImage )
|
||||
|
||||
LOCAL oI, oIDigits, nWidth, nHeight, nDigits, nNumWidth, oTemp
|
||||
//LOCAL black, white, blue, red, green, cyan, gray
|
||||
//LOCAL white
|
||||
|
||||
// LOCAL black, white, blue, red, green, cyan, gray
|
||||
// LOCAL white
|
||||
LOCAL aNumberImages := {}
|
||||
LOCAL n, nValue
|
||||
//LOCAL cFile
|
||||
// LOCAL cFile
|
||||
|
||||
// A value if not passed
|
||||
hb_default( @cValue , Str( hb_RandomInt( 1, 10 ^ DISPLAY_NUM ), DISPLAY_NUM ) )
|
||||
hb_default( @cBaseImage, "57chevy.gif" )
|
||||
|
||||
IF !hb_FileExists( IMAGES_IN + cBaseImage )
|
||||
IF ! hb_FileExists( IMAGES_IN + cBaseImage )
|
||||
//hb_ToOutDebug( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' not found" )
|
||||
//THROW( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' not found" )
|
||||
RETURN NIL
|
||||
//ELSE
|
||||
// hb_ToOutDebug( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' FOUND" )
|
||||
//ELSE
|
||||
// hb_ToOutDebug( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' FOUND" )
|
||||
ENDIF
|
||||
|
||||
nValue := Val( cValue )
|
||||
|
||||
// Fix num lenght
|
||||
IF nValue > 10^DISPLAY_NUM
|
||||
nValue := 10^DISPLAY_NUM
|
||||
IF nValue > 10 ^ DISPLAY_NUM
|
||||
nValue := 10 ^ DISPLAY_NUM
|
||||
ENDIF
|
||||
|
||||
cValue := StrZero( nValue, DISPLAY_NUM )
|
||||
|
||||
//? "Value = ", cValue
|
||||
// ? "Value = ", cValue
|
||||
|
||||
// To set fonts run this command:
|
||||
// for windows: SET GDFONTPATH=%WINDIR%\fonts
|
||||
// per linux : export GDFONTPATH=/usr/share/fonts/default/TrueType
|
||||
|
||||
// SET GDFONTPATH=%WINDIR%\fonts
|
||||
//IF GetEnv( "GDFONTPATH" ) == ""
|
||||
// ? "Please set GDFONTPATH"
|
||||
// ? "On Windows: SET GDFONTPATH=%WINDIR%\fonts"
|
||||
// ? "On Linux : export GDFONTPATH=/usr/share/fonts/default/TrueType"
|
||||
// ?
|
||||
//ENDIF
|
||||
// IF GetEnv( "GDFONTPATH" ) == ""
|
||||
// ? "Please set GDFONTPATH"
|
||||
// ? "On Windows: SET GDFONTPATH=%WINDIR%\fonts"
|
||||
// ? "On Linux : export GDFONTPATH=/usr/share/fonts/default/TrueType"
|
||||
// ?
|
||||
// ENDIF
|
||||
|
||||
// Check output directory
|
||||
/*
|
||||
IF !hb_DirExists( IMAGES_OUT )
|
||||
IF ! hb_DirExists( IMAGES_OUT )
|
||||
DirMake( IMAGES_OUT )
|
||||
ENDIF
|
||||
*/
|
||||
@@ -161,58 +163,59 @@ STATIC FUNCTION CreateCounter( cValue, cBaseImage )
|
||||
ENDCASE
|
||||
nNumWidth := nWidth / nDigits
|
||||
|
||||
//? "nNumWidth, nWidth, nHeight, nDigits = ", nNumWidth, nWidth, nHeight, nDigits
|
||||
// ? "nNumWidth, nWidth, nHeight, nDigits = ", nNumWidth, nWidth, nHeight, nDigits
|
||||
|
||||
/* extracts single digits */
|
||||
FOR n := 1 TO nDigits
|
||||
oTemp := oIDigits:Copy( (n - 1) * nNumWidth, 0, nNumWidth, nHeight )
|
||||
//oTemp:SaveGif( IMAGES_OUT + StrZero( n-1, 2 ) + ".gif" )
|
||||
// Here I have to clone the image, otherwise on var destruction I loose
|
||||
// the image in memory
|
||||
aAdd( aNumberImages, oTemp:Clone() )
|
||||
oTemp := oIDigits:Copy( ( n - 1 ) * nNumWidth, 0, nNumWidth, nHeight )
|
||||
//oTemp:SaveGif( IMAGES_OUT + StrZero( n - 1, 2 ) + ".gif" )
|
||||
// Here I have to clone the image, otherwise on var destruction I loose
|
||||
// the image in memory
|
||||
AAdd( aNumberImages, oTemp:Clone() )
|
||||
NEXT
|
||||
|
||||
/* Create counter image in memory */
|
||||
oI := GDImage():New( nNumWidth * DISPLAY_NUM, nHeight ) // the counter
|
||||
//? "Image dimensions: ", oI:Width(), oI:Height()
|
||||
// ? "Image dimensions: ", oI:Width(), oI:Height()
|
||||
|
||||
/* Allocate background */
|
||||
//white := oI:SetColor( 255, 255, 255 )
|
||||
// white := oI:SetColor( 255, 255, 255 )
|
||||
|
||||
/* Allocate drawing color */
|
||||
//black := oI:SetColor( 0, 0, 0 )
|
||||
//blue := oI:SetColor( 0, 0, 255 )
|
||||
//red := oI:SetColor( 255, 0, 0 )
|
||||
//green := oI:SetColor( 0, 255, 0 )
|
||||
//cyan := oI:SetColor( 0, 255, 255 )
|
||||
// black := oI:SetColor( 0, 0, 0 )
|
||||
// blue := oI:SetColor( 0, 0, 255 )
|
||||
// red := oI:SetColor( 255, 0, 0 )
|
||||
// green := oI:SetColor( 0, 255, 0 )
|
||||
// cyan := oI:SetColor( 0, 255, 255 )
|
||||
|
||||
/* Draw rectangle */
|
||||
//oI:Rectangle( 0, 0, 200, 30, , blue )
|
||||
// oI:Rectangle( 0, 0, 200, 30, , blue )
|
||||
|
||||
/* Draw Digits */
|
||||
FOR n := 1 TO Len( cValue )
|
||||
// Retrieve the number from array in memory
|
||||
oTemp := aNumberImages[ Val( SubStr( cValue, n, 1 ) ) + 1 ]:Clone()
|
||||
// Save it to show the number for a position
|
||||
//oTemp:SaveGif( IMAGES_OUT + "Pos_" + StrZero( n, 2 ) + ".gif" )
|
||||
// Set the digit as tile that I have to use to fill position in counter
|
||||
oI:SetTile( oTemp )
|
||||
// Fill the position with the image digit
|
||||
oI:Rectangle( (n - 1) * nNumWidth, 0, (n - 1) * nNumWidth + nNumWidth, nHeight, .T., gdTiled )
|
||||
// Retrieve the number from array in memory
|
||||
oTemp := aNumberImages[ Val( SubStr( cValue, n, 1 ) ) + 1 ]:Clone()
|
||||
// Save it to show the number for a position
|
||||
//oTemp:SaveGif( IMAGES_OUT + "Pos_" + StrZero( n, 2 ) + ".gif" )
|
||||
// Set the digit as tile that I have to use to fill position in counter
|
||||
oI:SetTile( oTemp )
|
||||
// Fill the position with the image digit
|
||||
oI:Rectangle( ( n - 1 ) * nNumWidth, 0, ( n - 1 ) * nNumWidth + nNumWidth, nHeight, .T. , gdTiled )
|
||||
NEXT
|
||||
|
||||
/* Write Final Counter Image */
|
||||
//cFile := "counter" + StrZero( hb_RandomInt( 1, 99 ), 2 ) + ".gif"
|
||||
//oI:SaveGif( IMAGES_OUT + cFile )
|
||||
// cFile := "counter" + StrZero( hb_RandomInt( 1, 99 ), 2 ) + ".gif"
|
||||
// oI:SaveGif( IMAGES_OUT + cFile )
|
||||
|
||||
/* Destroy images in memory */
|
||||
// Class does it automatically
|
||||
|
||||
//?
|
||||
//? "Look at " + IMAGES_OUT + " folder for output images"
|
||||
//?
|
||||
// ?
|
||||
// ? "Look at " + IMAGES_OUT + " folder for output images"
|
||||
// ?
|
||||
|
||||
// RETURN cFile
|
||||
|
||||
RETURN oI:ToStringGif()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,10 +53,11 @@
|
||||
MEMVAR _REQUEST
|
||||
|
||||
FUNCTION HRBMAIN()
|
||||
|
||||
LOCAL cW
|
||||
LOCAL cHtml := ""
|
||||
|
||||
IF HB_HHasKey( _REQUEST, "w" )
|
||||
IF hb_HHasKey( _REQUEST, "w" )
|
||||
IF ! Empty( cW := _REQUEST[ "w" ] )
|
||||
cHtml += "This is a reply from testajax : " + cW
|
||||
ENDIF
|
||||
|
||||
Reference in New Issue
Block a user