FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index mod_harbour W3Schools webpage template "COMPANY" to mod harbour
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
W3Schools webpage template "COMPANY" to mod harbour
Posted: Wed Mar 16, 2022 07:10 AM
Hello friends,
In this video, I show how to change port the W3Schools webpage template "COMPANY" to mod harbour.
Best regards,
Otto
https://www.w3schools.com/boo.../bootstrap_theme_company.asp

https://mybergland.com/fwforum/startwithharbourino.mp4
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: W3Schools webpage template "COMPANY" to mod harbour
Posted: Mon May 16, 2022 11:41 AM
dear friends,

I set out today to understand in detail what happens in this small piece of code ... but I quickly realized I would very much appreciate and need your help. please...

here is the link to the small website:
https://winhotel.space/submarine_newsletter_ruth/portfolio.prg
And I put the code at the end of this post.
_____________________________________________

questions I tried to google:

* why do you use "static" for hSLIDER and "local" for hCards
* what does dbf2hash do? (maybe this question is ridiculous to some...sorry...)
* what does hb_jsonEncode do?
* hSLIDER provides me with content of the data.dbf but I don´t get where in the code the connection between hSLIDER and data.dbf ist made...
* and my last question...good wikis for mod-harbour and harbour
Which link should I use?

Thank you very much and kind regards
Ruth


Code (fw): Select all Collapse
REQUEST DBFCDX
REQUEST DBFFPT
static hSLIDER := {=>}
function main
local hCards := {=>}
local cdbf_file     :=   hb_GetEnv( "PRGPATH" ) + "/data/cards.DBF"
hCards := dbf2hash( cdbf_file )
TEMPLATE PARAMS hCards, hSLIDER
<!DOCTYPE html>
<html lang="en">
-> HEAD
<body>
<script>
var oSLIDER=<?prg return hb_jsonEncode( hSLIDER, .T. )?>;
var cKeySLIDER =  1;
var iSLIDER =1;
var nRecSLIDER = oSLIDER[ "RECREAD" ] ;
</script>
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: W3Schools webpage template &quot;COMPANY&quot; to mod harbour
Posted: Mon May 16, 2022 06:22 PM
Dear Ruth,
please search your source code for
function dbf2hash.
This is your own function.

***
static and local is very similar to JS. If you declare a variable inside a function, then it is like local.
You only can access it inside the function in which you declared the variable.

static is similar to JS variables declared globally (outside any function) have Global Scope.

Static declaration in HARBOUR must be done before the main function.

With TEMPLATE PARAMS you pass the variables to HTML/JS part

***
hb_jsonenconde/hb_jsondecode
Turns a Harbour HASH into a JS jsonobject and vice versa
***
Please, if you post code here, use only code from the prg file after you have pressed "Publish" in Harbourino.

-> HEAD without the code does not help here.

The source code of HEAD is patched thanks to Harbourino into the release prg.

Here you have a list of help-files:

https://winhotel.space/modharbour/modharbouronline.prg

Best regards,
Otto
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: W3Schools webpage template &quot;COMPANY&quot; to mod harbour
Posted: Tue May 17, 2022 05:58 AM

Thank you very much!!!! Now everything is much clearer!!!
I read the whole code like a book from top to bottom... :oops:
does the prefix "hb_" indicate all the functions that come from "outside"...not my own?

thank you again, kind regards and a nice day to all of you...

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: W3Schools webpage template &quot;COMPANY&quot; to mod harbour
Posted: Tue May 17, 2022 06:28 AM

I think it is the abbreviation for harbour (hb).
But I have never looked it up.

Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: W3Schools webpage template &quot;COMPANY&quot; to mod harbour
Posted: Tue May 17, 2022 06:38 AM

thanks again...:-)

I can´t stop thinking about the dbf2hash ... I can remember working with SELECT * FROM ... is it something like that?
is there a way to extract what I need from a database and start working?

kind regards again...

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: W3Schools webpage template &quot;COMPANY&quot; to mod harbour
Posted: Tue May 17, 2022 07:10 AM
Ruth,


You have included a function here that fills 2 HASHs.

The database is opened with USE().

Then you browse the database with
do while .not. eof()
skip
enddo

You then fill the local HASH
local hDBF_Recs := {=>}

and the hSLIDER (static) HASH.

The local HASH is returned as a return param.
return( hDBF_Recs )



hCards := dbf2hash( cdbf_file )
Here you call the function.
The locale HASH of the function dbf2hash() is assigned to your locale HASH hCards.



The HASH hSLIDER is only filled if the condition is met.
if TMPDBF_FILE->slider = "J"


The number of records read is stored here.
hDBF_Recs[ "RECREAD" ] := str( nDBF_RecRead + 1 )
hSLIDER[ "RECREAD" ] := str( nKeySLIDER + 1 )

You then need this in JS to display the data.



Best regards,
Otto
Posts: 179
Joined: Fri Dec 07, 2007 01:26 PM
Re: W3Schools webpage template &quot;COMPANY&quot; to mod harbour
Posted: Tue May 17, 2022 12:19 PM
Again...thank you :-)

I was able to put some <img> files directly from the database in here
https://winhotel.space/mh_bergland_bs5/pages/kulinarik.prg


now when you click on a photo it opens in full-format. this took me quite some time again ... but now I am happy and proud :-)

for
Code (fw): Select all Collapse
 document.write("data-bigpicture='{"gallery":"#home-gallery"}'") ;


I had to escape the "double quote" character and wasn´t successful with
\' but found out that &#34; worked instead.

kind regards to all of you again...

Continue the discussion