Page 1 of 1

mod_harbour code snippets

Posted: Mon Aug 05, 2019 3:24 pm
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

Re: mod_harbour code snippets

Posted: Wed Aug 07, 2019 12:02 pm
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 ) )

Re: mod_harbour code snippets

Posted: Wed Aug 07, 2019 12:04 pm
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>"

Re: mod_harbour code snippets

Posted: Wed Aug 07, 2019 1:36 pm
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>" )

Re: mod_harbour code snippets

Posted: Wed Aug 07, 2019 2:26 pm
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>" )

Re: mod_harbour code snippets

Posted: Wed Aug 07, 2019 3:42 pm
by Antonio Linares

Code: Select all

function Main()

   Alert( "ok" )

return nil

function Alert( cMsg )

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

Re: mod_harbour code snippets

Posted: Wed Aug 07, 2019 5:26 pm
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 )

Re: mod_harbour code snippets

Posted: Mon Aug 12, 2019 5:43 am
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

Re: mod_harbour code snippets

Posted: Sat Aug 17, 2019 12:23 pm
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>" )