mod harbour session js session object

Re: mod harbour session js session object

Postby Antonio Linares » Tue Jul 30, 2019 7:56 am

regards, saludos

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

Re: mod harbour session js session object

Postby Otto » Tue Jul 30, 2019 8:12 am

Dear Antonio,
would you be so kind to explain how #xtranslate <matchPattern> => <resultPattern> works.
Does this work on BLOCKS too.
Best regards
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6255
Joined: Fri Oct 07, 2005 7:07 pm

Re: mod harbour session js session object

Postby Antonio Linares » Tue Jul 30, 2019 9:31 am

Otto,

Here you have some examples to understand it from apache.prg (mod_harbour)
Code: Select all  Expand view
  __pp_addRule( hPP, "#xcommand ? [<explist,...>] => AP_RPuts( '<br>' [,<explist>] )" )
   __pp_addRule( hPP, "#xcommand ?? [<explist,...>] => AP_RPuts( [<explist>] )" )
   __pp_addRule( hPP, "#define CRLF hb_OsNewLine()" )
   __pp_addRule( hPP, "#xcommand TEXT <into:TO,INTO> <v> => #pragma __cstream|<v>:=%s" )
   __pp_addRule( hPP, "#xcommand TEXT <into:TO,INTO> <v> ADDITIVE => #pragma __cstream|<v>+=%s" )
   __pp_addRule( hPP, "#xcommand TEMPLATE [ USING <x> ] [ PARAMS [<v1>] [,<vn>] ] => " + ;
                      '#pragma __cstream | AP_RPuts( InlinePrg( %s, [@<x>] [,<(v1)>][+","+<(vn)>] [, @<v1>][, @<vn>] ) )' )
   __pp_addRule( hPP, "#xcommand BLOCKS [ PARAMS [<v1>] [,<vn>] ] => " + ;
                      '#pragma __cstream | AP_RPuts( ReplaceBlocks( %s, "{{", "}}" [,<(v1)>][+","+<(vn)>] [, @<v1>][, @<vn>] ) )' )  
   __pp_addRule( hPP, "#command ENDTEMPLATE => #pragma __endtext" )


function ReplaceBlocks() does the magic for the "{{ ... }}". In fact this function allows you to use any starting and ending characters to replace blocks:
Code: Select all  Expand view
function ReplaceBlocks( cCode, cStartBlock, cEndBlock, cParams, ... )

   local nStart, nEnd, cBlock
   local lReplaced := .F.
   
   hb_default( @cStartBlock, "{{" )
   hb_default( @cEndBlock, "}}" )
   hb_default( @cParams, "" )

   while ( nStart := At( cStartBlock, cCode ) ) != 0 .and. ;
         ( nEnd := At( cEndBlock, cCode ) ) != 0
      cBlock = SubStr( cCode, nStart + Len( cStartBlock ), nEnd - nStart - Len( cEndBlock ) )
      cCode = SubStr( cCode, 1, nStart - 1 ) + ;
              ValToChar( Eval( &( "{ |" + cParams + "| " + cBlock + " }" ), ... ) ) + ;
              SubStr( cCode, nEnd + Len( cEndBlock ) )
      lReplaced = .T.
   end
   
return If( HB_PIsByRef( 1 ), lReplaced, cCode )
regards, saludos

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

Re: mod harbour session js session object

Postby Massimo Linossi » Wed Aug 07, 2019 5:52 pm

Antonio,
is it possible to save sessions data from the mod_harbour code and not inside the HTML ?
like :

Code: Select all  Expand view

Function Main()
LOCAL nome_utente
use "data" shared new readonly alias infos
set order to tag CODICE
nome_utente = ""
seek "test"
if found()
     nome_utente = alltrim(infos->NOME)
endif
use
sessionsave(nome_utente)     <----
return nil
 
User avatar
Massimo Linossi
 
Posts: 495
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: mod harbour session js session object

Postby Antonio Linares » Wed Aug 07, 2019 8:42 pm

Massimo,

The PRG code runs on the server, so whatever you may want to save as a session identifier, it will be saved on the server.

You could store the "session" id info in a file, inside a DBF, on a SQL table, etc, but always on the remote server if PRG is being used for it
regards, saludos

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

Re: mod harbour session js session object

Postby Massimo Linossi » Thu Aug 08, 2019 6:47 am

Antonio,
even if I call a javascript that make this ?
[url] https://www.w3schools.com/jsref/prop_win_sessionstorage.asp [/url]
User avatar
Massimo Linossi
 
Posts: 495
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 110 guests