mod_harbour code snippets

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!
Post Reply
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

mod_harbour code snippets

Post by Antonio Linares »

Code: Select all

function Main()

   local n
   
   ? __DYNSCOUNT(), "symbols"
   
   for n = __DYNSCOUNT() to 1 step -1
      ? __DYNSCOUNT() - n + 1, __DYNSGETNAME( n )
   next  
   
   ? "<" + "script>$('#result').css('overflow', 'auto');<" + "/script>"

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod_harbour code snippets

Post by Antonio Linares »

Code: Select all

#xcommand DO <prg> => _Do( <prg> )

function Main()

   DO "info.prg"

return nil

function _Do( cFileName )

   cFileName = hb_GetEnv( "PRGPATH" ) + "/../" + cFileName

return AP_RPuts( If( File( cFileName ), Execute( MemoRead( cFileName ) ),;
                 "File not found " + cFileName ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod_harbour code snippets

Post by Antonio Linares »

Code: Select all

#xcommand DO <prg> => _Do( <prg> )
#xcommand CLEAR => ClearResult()

function Main()

   CLEAR
   // DO "info.prg"

return nil

function _Do( cFileName )

   cFileName = hb_GetEnv( "PRGPATH" ) + "/../" + cFileName

return AP_RPuts( If( File( cFileName ), Execute( MemoRead( cFileName ) ),;
                 "File not found " + cFileName ) )
                 
function ClearResult()

return "<" + "script>$('#result').html( '' );<" + "/script>"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod_harbour code snippets

Post by Antonio Linares »

Code: Select all

function Main()

   Popup( "Hello world", "Using Popups" )

return nil

function Popup( cMsg, cTitle )

   DEFAULT cTitle TO "Popups"

return AP_RPuts( "<" + "script>MsgMemo( '" + cMsg + "','" + cTitle + "');<" + "/script>" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod_harbour code snippets

Post by Antonio Linares »

Code: Select all

function Main()

   MsgInfo( "Hello world", "move me with the mouse" )

return nil

function MsgInfo( cMsg, cTitle )

   DEFAULT cTitle TO "Popups"

return AP_RPuts( "<" + "script>MsgInfo( '" + cMsg + "','" + cTitle + "');<" + "/script>" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod_harbour code snippets

Post by Antonio Linares »

Code: Select all

function Main()

   Alert( "ok" )

return nil

function Alert( cMsg )

return AP_RPuts( "<" + "script>alert( '" + cMsg + "' );<" + "/script>" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod_harbour code snippets

Post by Antonio Linares »

Code: Select all

function Main()

   Popup( _Do( "info.prg" ), "info.prg" )

return nil

function Popup( cMsg, cTitle )

return AP_RPuts( "<" + "script>RunCode( '" + cMsg + "');MsgMemo('','" + ;
                 cTitle + "', true );<" + "/script>" )

function _Do( cFileName )

   cFileName = hb_GetEnv( "PRGPATH" ) + "/../" + cFileName

return If( File( cFileName ), HB_BASE64ENCODE( MemoRead( cFileName ) ),;
           "File not found " + cFileName )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod_harbour code snippets

Post by Antonio Linares »

Review all code snippets:

Code: Select all

function Main()

   local cCode

   USE ( hb_GetEnv( "PRGPATH" ) + "/snippets" ) SHARED NEW
   
   ? "<" + "script>$( '#result' ).css( 'overflow', 'auto' );<" + "/script>"

   while ! Eof()
      ? "<" + "font color='red'>id: " + Field->Id + "<" + "/font>"
      ? 
      cCode = Field->Code
      cCode = StrTran( cCode, CRLF, "<" + "br>" )
      cCode = StrTran( cCode, " ", "&" + "nbsp;" )
      cCode = StrTran( cCode, "<" + "d", "<" + " " + "d" )
      ? cCode
      ? "<" + "hr>"
      SKIP
   end
   
   USE

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: mod_harbour code snippets

Post by Antonio Linares »

Code: Select all

function Main()

   MsgGet( "number:  ", "Goto line" )

return nil

function MsgGet( cLabel, cTitle )

return AP_RPuts( "<" + "script>MsgGet('" + cLabel + "','" + cTitle + "')<" + "/script>" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply