mod harbour session js session object

mod harbour session js session object

Postby Otto » Sun Jul 28, 2019 7:28 pm

Dear Antonio,
I am try to use the session object from javascript.
Can you show me how I could substitude generateUUID() - javascript function for example date() and time() as GUID with harbour and then pass harbour variable to javascript.
Thank you in advance
Otto

Image


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: mod harbour session js session object

Postby cnavarro » Sun Jul 28, 2019 7:41 pm

Dear Otto
Function in harbour is
win_UuidCreateString( [@<nStatus>] )

contrib/hbwin/win_rpc.c
contrib/hbwin/tests/testrpc.prg
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: mod harbour session js session object

Postby Otto » Sun Jul 28, 2019 8:50 pm

Dear Cristobal,
thank you.
Can you show me how to pass harbour variable to javascript.
Also a little sample how to show harbour variables inside html code would be great.
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: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: mod harbour session js session object

Postby Antonio Linares » Sun Jul 28, 2019 8:56 pm

Otto,

Your code is fine. The only observation is that you are generating it on the client side.

On a next example lets see how to generate it on the server side
regards, saludos

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

Re: mod harbour session js session object

Postby Antonio Linares » Sun Jul 28, 2019 8:59 pm

Otto,

Using fields values in HTML code:

use < and > in both extremes, can't write them here:
input id="builder" name="builder" type="text" class="form-control" value="{{_Value('builder')}}"

Where function _Value( cFieldName ) is:

function _Value( cFieldName )

return FieldGet( FieldPos( cFieldName ) )
regards, saludos

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

Re: mod harbour session js session object

Postby Antonio Linares » Sun Jul 28, 2019 9:22 pm

This is an example of an UUID generated from the server side using mod_harbour:

C5843854-4DB4-1DB9-CCDB08473109
UUID generated on the server


Code: Select all  Expand view
function Main()

   BLOCKS
      ... begins the script
         var value = sessionStorage.getItem( "MyId" );
       
         if( value == null )
         {
            value = "{{generateUUID()}}";
            sessionStorage.setItem( "MyId", value );
         }

         d ocument.write( value );
      ... ends the script
   ENDTEXT

   ? "UUID generated on the server"

return nil

function GenerateUUID()

   local cChars := "0123456789ABCDEF"
   local cUUID  := ""

   for n = 1 to 8
      cUUID += SubStr( cChars, hb_Random( 1, 16 ), 1 )
   next
   
   cUUID += "-4"

   for n = 1 to 3
      cUUID += SubStr( cChars, hb_Random( 1, 16 ), 1 )
   next

   cUUID += "-"

   for n = 1 to 4
      cUUID += SubStr( cChars, hb_Random( 1, 16 ), 1 )
   next

   cUUID += "-"

   for n = 1 to 12
      cUUID += SubStr( cChars, hb_Random( 1, 16 ), 1 )
   next
 
return cUUID
regards, saludos

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

Re: mod harbour session js session object

Postby Otto » Mon Jul 29, 2019 1:31 pm

Dear Antonio,
thank you so much.


Best regards
Otto

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: mod harbour session js session object

Postby Otto » Mon Jul 29, 2019 1:33 pm

Dear Antonio,
would you please be so kind to make me a screenshot of the code insite the post.
Best regards
Otto

Otto,

Using fields values in HTML code:

use < and > in both extremes, can't write them here:
input id="builder" name="builder" type="text" class="form-control" value="{{_Value('builder')}}"

Where function _Value( cFieldName ) is:

function _Value( cFieldName )

return FieldGet( FieldPos( cFieldName ) )
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: mod harbour session js session object

Postby Antonio Linares » Mon Jul 29, 2019 5:16 pm

Image
regards, saludos

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

Re: mod harbour session js session object

Postby Otto » Mon Jul 29, 2019 5:54 pm

Dear Antonio,
thank you.
can you make me a sceenshot of this code too.
Thank you and best regards
Otto

Using fields values in HTML code:

use < and > in both extremes, can't write them here:
input id="builder" name="builder" type="text" class="form-control" value="{{_Value('builder')}}"

Where function _Value( cFieldName ) is:

function _Value( cFieldName )

return FieldGet( FieldPos( cFieldName ) )
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: mod harbour session js session object

Postby Antonio Linares » Mon Jul 29, 2019 6:22 pm

Image
regards, saludos

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

Re: mod harbour session js session object

Postby Otto » Tue Jul 30, 2019 5:59 am

Dear Antonio,
thank you.
Is it possible to change "{{_Value('builder')}}" with xZTranslate.
to HB2HTML('builder').
input id="builder" name="builder" type="text" class="form-control" value=" & HB2HTML('builder').
Thank you in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: mod harbour session js session object

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

Otto,

We need to use {{ ... }} so mod_harbour knows what to replace in the view.

You can use ANY function from inside it :-)
regards, saludos

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

Re: mod harbour session js session object

Postby Otto » Tue Jul 30, 2019 7:38 am

Dear Antonio,
I mean hb_htlm() {{ ... }} would be more familiar to us CLIPPER heads.
Does xTranslate also translate code inside BLOCKS ?
Thank you in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: mod harbour session js session object

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

Otto,

BLOCKS
...
ENDTEXT

search for {{ ... }} and whatever is inside {{ ... }} is "macro expanded" and replaced there and sent to Apache

{{ ... }} is a standard from many "templates" systems, thats why mod_harbour use them too

mod_harbour also supports {% ... %} to receive "instructions" from the user. In example:

// {% hb_SetEnv( "HB_INCLUDE", "c:\harbour\include" ) %}

this code will be processed by mod_harbour PREVIOUS to the execution of the PRG code
regards, saludos

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests