run harbour code on browser client side (javascript)

316 views
Skip to first unread message

Antonino Perricone

unread,
Feb 29, 2020, 3:13:01 AM2/29/20
to Harbour Users
Hello, 

I've been working for a while to a project : https://github.com/APerricone/HRB-Runner
that parse HRB code and run it on browser to mix javascript code and harbour code, or use only harbour code like the last sample I wrote: 

this work is far to be complete, I implemented only 71 out of 181 operation codes.

Theorically using mod_harbour or FastCGI is possible create a compiler and client runner, I will do it... maybe :)

Regards,
Antonino

Mel Smith

unread,
Feb 29, 2020, 11:34:31 AM2/29/20
to Harbour Users
Hi Antonino:

   Nice work !

   My view:  Starting way back in the years before 2012, I decided to use the Harbour language as a complete CGI app ( under the Apache daemon server).  For the front end, I started learning HTML DOM stuff, then CSS, and Javascript.  I am now reasonably competent in building responsive front-ends for my three active sites. In fact, I spent most of January and February building a new and complex front-end for a site. However, the difficulty is switching between these 'languages' several (or many) times per day e.g., Harbour to CSS to  DOM work, then to Javascript, then back to Harbour again. For me, the major frustration is the similarity of Harbour and Javascript, and how easy it is to insert our Harbour assignment operator (:=) instead of simply the Javascript operator (=).  Then, under testing, it crashes, and ultimately, you find the reason.  One finds that the key combo Ctrl-Shift-J is invaluable in tracking down errors.

   Also, I have made my own little library of JS functions which emulate some Harbour functions  (e.g., alltrim(),left),right(),strzero(),empty(),,upper(),lower(), etc, etc). These emulating funcs are invaluable to me in speeding development.  It means, I don't have to blow up my mind in conversion between languages.

   I think the biggest need now is for someone with your depth of knowledge is to build a *complete* library of useful Harbour emulation functions for Javascript so that complex actions at the front-end can be accomplished using our knowledge of Harbour language.

   Also, using the Document Model (DOM) of HTML, there is the persistent and frequent need to use the construct: someobject = document.getElementById(cSomeId). This is long and painful to type and  is frequently spelled of 'cased' incorrectly. So, I have my own function to access an 'object' in the DOM:  someobj = getobj("someid"). Saves a lot of errors.
 
  Anyway, Good Luck in your venture !

-Mel Smith

Antonino Perricone

unread,
Mar 1, 2020, 1:42:53 AM3/1/20
to Harbour Users
Hello,
My experiment is not so practical, if itcrashes you see only the line on runner ... It was born like a bet :)
You was a precursor, using CGI back on 2012, now we have 2 active project mod_harbour and FastCGI that are similar to your.
It is like something I am looking for to do at work, Our problem is that we use Cassini that does not support anything ...

For your problem, I suggest to use jQuery, has a lot of shortcut very easy to remember. For example document.getElementById(cSomeId) become $("#cSomeId") and has a lot of libraries that helps to have a better interface for final user.

Regards,
Antonino

fdaniele

unread,
Mar 1, 2020, 5:18:22 AM3/1/20
to Harbour Users

sorry, Mel and Antonino

haven't you thought about joining your two BIG brains and working together to create the harbour of the future?

united you are stronger :-)

Daniele

Mel Smith

unread,
Mar 1, 2020, 10:14:49 AM3/1/20
to Harbour Users
Hi Antonino:
    Years ago, I 'considered' using jquery for my work, but instead, I decided to stick to 'vanilla' javascript .   So, I still do my own library and utility building when needed, and get along quite well. And my getobj() function handles my object access needs. 

    I still consider Harbour to be the ideal tool for a CGI app (under the Apache Daemon).  It does *everything* needed for the BackEnd portion of client/server apps.
    Thanks for your comments and suggestions..

-Mel

Reply all
Reply to author
Forward
0 new messages