HMG/WEB web development tool based on Harbour compiler and jQuery Mobile.

481 views
Skip to first unread message

Massimo Belgrano

unread,
Feb 17, 2014, 12:38:50 PM2/17/14
to Harbour Project Main Developer List.
I read on http://www.hmgforum.com/viewtopic.php?f=2&t=3533 that is born
HMG/WEB is a xBase web development tool based on Harbour compiler and jQuery Mobile.
HMG/WEB allows you to create web applications using traditional xBase syntax with added new commands.
The main goal of the project is to bring the simplicity and power of xBase to the web


On this release:
- new: List Dividers suppor for ListView. You must iniate the item with "\-"
- new: property 'AutoFocus' for Text, Number, TextArea, Currency, Date and Password.
- SetGlobal and GetGlobal functions to store and retrieve values when a session is active. Look at Session demo for details.
Syntax:
SetGlobal ( cName , xValue , cSessionId )
GetGlobal ( cName , cSessionId )

Download: http://www.sourceforge.net/projects/hmgweb


#include 'hmg.ch'

Function Main()
   cText := getvalue( 'NextFunction' )
   if len( alltrim( cText ) ) > 0
      do( cText )
      return nil
   endif


   Define Form Header 'This is a Header' Footer 'This is The Footer' Action 'hello.cgi'

      // To make the link to the image file work, we must point it,
      // to the server document root ('/') where it is located (apache/htdocs).

      Define Image 'image_1'
         Value   '/hmg.jpg'
      End Image

      Define Text 'text_1'
         Value   'this is another text!!!'
         Label   'Input Text:'
      End Text

      Define Password 'pass_1'
         Value   '1234'
         Label   'Password:'
      End Password

      Define Flip 'flip_1'
         Value   .T.
         Label   'Flip!'
         Options   {'No','Yes'}
      End Flip

      Define Radio 'radio_1'
         Label   'Radio:'
         Options   {'Moe','Larry','Curly'}
         Default   1
      End Radio

      Define TextArea 'textarea_1'
         Value   'This is a TextArea'
         Label   'TextArea:'
      End TextArea

      Define Date 'date_1'
         Value   DATE()
         Label   'Enter Date:'
      End Date

      Define Number 'num_1'
         Min   1
         Max   10
         Value   5
         Label   'Input Number (1-10):'
      End Number

      Define Select 'select_1'
         Options   {'One','Two','Three'}
         Default   2
         Label   'Select an Option:'
      End Select

      Define CheckBox 'check_1'
         Value   .T.
         Label   'CheckBox!'
      End CheckBox

      Define Submit 'submit_1'
         Value   'Send Form Data To Server'
      End Submit

      Define Reset 'reset_1'
         Value   'Undo Changes'
      End Reset

      Define BackButton 'back_1'
         Value   'Go Back!'
      End BackButton

      Define Text 'text_5'
         Value   cText
         Label   'Input Text1:'
      End Text

      outstd('<input type="hidden" name="NextFunction" value=' + '"' + 'MyFunction' + '"' + '>' )      

   End Form

Return Nil  


function MyFunction

   Define Form Header 'Show Form Content' Footer 'This is The Footer'

      Define Label 'label_1'
         Value   'text_1:' + GetValue('text_1')
      End Label

      Break

      Define Label 'label_2'
         Value   'flip_1:' + GetValue('flip_1')
      End Label

      Break

      Define Label 'label_3'
         Value   'radio_1:' + GetValue('radio_1')
      End Label

      Break

      Define Label 'label_4'
         Value   'textarea_1:' + GetValue('textarea_1')
      End Label

      Break

      Define Label 'label_5'
         Value   'check_1:' + GetValue('check_1')
      End Label

      Break

      Define Label 'label_6'
         Value   'date_1:' + GetValue('date_1')
      End Label

      Break

      Define Label 'label_7'
         Value   'num_1:' + GetValue('num_1')
      End Label

      Break

      Define Label 'label_8'
         Value   'select_1:' + GetValue('select_1')
      End Label

      Break

      Define Label 'label_9'
         Value   'pass_1:' + GetValue('pass_1')
      End Label

      Break

      Define BackButton 'back_1'
         Value   'Go Back!'
      End BackButton

   End Form
return nil
Enjoy!

_________________
Regards/Saludos,

Roberto

--
Massimo Belgrano
Delta Informatica S.r.l. (Cliccami per scoprire )

Massimo Belgrano

unread,
Feb 17, 2014, 12:47:36 PM2/17/14
to Harbour Project Main Developer List.
In the server side, we have a .prg compiled to .hrb Harbour module (ie: demo.hrb).

To run this module from the local web browser, you need the following:

http://localhost/cgi-bin/test.hrb

This application, via the RETURN statement will send anything you want to the client:

ie: RETURN cHtml (where 'cHtml' is the HTML/JavaScript code that you want to send to your web browser).

So, the application (demo.prg) should look like this:


Code:
FUNCTION HRBMAIN()
LOCAL cHtml 

   cHtml := '<button type="button">Click Me!</button>'   

RETURN cHtml



Then, the next step, could be:


Code:
FUNCTION HRBMAIN()
LOCAL cHtml 

   oButton := HButton ( 'Click Me!' )

RETURN oButton:getHtml()


Obviously, the 'getHtml' method will return the required code for the button.

The more interesting part is when you need to execute something at button click. so:


Code:
FUNCTION HRBMAIN()
LOCAL cHtml 

   // HButton ( cCaption , cAction )

   oButton := HButton ( 'Click Me!' , "/cgi-bin/testbutton.hrb" )

RETURN oButton:getHtml()



As you can imagine, testbutton.hrb comes from testbutton.prg, another harbour program.

So, you can create a button with a link to a harbour procedure without the need to use HTML or JavaScript.

Believe me, this could be extremely easy to do, and it could be that HMG programmers are waiting for.

At least, that is what me, as HMG user, could be waiting for :)

_________________
Regards/Saludos,

Roberto



Reply all
Reply to author
Forward
0 new messages