HMGSCRIPT 2012: Programming For The Web in The Right Way :)

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

HMGSCRIPT R003.

We have now MsgInfo() and we are able to set and get the textbox value.

I've added a 'cId' parameter to controls, to give them an id, so, being able to manipulate them via DOM (Document Object Model) from JavaScript.

Look at http://www.howtocreate.co.uk/tutorials/ ... re#docnode for info about DOM.
Attachments
hmgs.003.zip
(5.67 KiB) Downloaded 346 times
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

I have to make a design decision now.

All the controls are being created by functions.

These functions could be converted in objects easily. It is very easy in JavaScript. We must invoke them with 'new' and use 'this' inside function when required.

The question is: ¿Is this necessary?

When we create an element (by any means) it is already an object for our browsers. So, we can access to its properties, events and methods via Document Object Model (DOM).

A clear example of this, is in the TextBox demo:

Code: Select all

function test_3() // TextBox Demo
{
   oWindow = new Window( "Hello World!", 600 , 300 );
   TextBox( "text_1" , oWindow , 130, 230, "TextBox!" );

   Button( 'button_1' , oWindow , 240 , 110 , "Get TxtBox Value" , "MsgInfo(document.getElementById('text_1').value,'TextBox Value')" );  
   Button( 'button_2' , oWindow , 240 , 240 , "Set TxtBox Value" , "document.getElementById('text_1').value = 'New Value' " );  
   Button( 'button_3' , oWindow , 240 , 370 , "Close" , "oWindow.Release()" );  
}
We are accesing the 'native' value property of the textbox (input text element) via document.getElementById('text_1').value.

To use the control creation functions as objects, we should construct a complete layer over each control, but ¿is that really necessary?

We don't need to know the answer right now, because it can be done at any moment, building on top the current code without loosing compatibility.

The problem that must be solved right now, is, if the window must be treated as an object or not.

The Window is currently an object, only because it requires two different elements (one div for the cover and another for window itself).

So, when we need to release the window, we must to remove its cover too.

This is currently generating some sort of consistency problem, since, IMHO, windows and controls should be treated in the same way.

A solution to create the windows in the same way as controls, is to detach the the window div from the cover that makes it modal, this way we could handle the window div directly via DOM (the same as controls).

I'm thinking about that, so, I've pressed pause on the library development.

Any other idea or suggestion is welcome.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Rathinagiri »

If my understanding is right, the line
Button( 'button_3' , oWindow , 240 , 370 , "Close" , "oWindow.Release()" );
will be
Button( 'button_3', document.getElementById( 'oWindow' ), 240, 370, "Close", "document.getElementById( 'oWindow' ).Release()" );
Am I right?

No.

It will be (is in my tests):

Code: Select all

function test_1() // Window Demo
{
   Window( "win" , "Hello World!", 600 , 300 );
   Button( 'button_1' , 'win' , 240 , 248 , "Close" , "ReleaseWindow('win')" );  
}
Where, the second parameter of button, is the parent window id.

I've decided to use this design.

This way, we can access the window div directly.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Rathinagiri »

IMHO, we have to cover the internal commands to the extent possible to make it simple. (as we covered 'C' calls in HMG) But, time is changing and we have to eventually know about some (java)scripting too.

As you have described this can be done at any time in the project, it can be continued to create other controls and data accessibility possible.

As of now, we are not using jQuery. Isn't it? I think it can also be involved in the future. The demos of jQuery from the link you have specified are fantastic. :) So, I can not remove that from my mind.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

rathinagiri wrote:IMHO, we have to cover the internal commands to the extent possible to make it simple. (as we covered 'C' calls in HMG) But, time is changing and we have to eventually know about some (java)scripting too.

As you have described this can be done at any time in the project, it can be continued to create other controls and data accessibility possible.

As of now, we are not using jQuery. Isn't it? I think it can also be involved in the future. The demos of jQuery from the link you have specified are fantastic. :) So, I can not remove that from my mind.
We are using plain JavaScript (I'll refer as JS from now) but you can add jQuery (or any other library) at any moment.

The same way, I've got rid of some of the project original goals to split in more quickly reachable stages (like xBase to JS translating) I'll do with an eventual abstraction layer too.

This could make the code look like a little bit difficult, but, the great advantage is that we are creating true DOM objects, that we can easily manipulate from JS. The web is plenty of references, tutorials and examples of JS DOM usage.

I have a deadline. I must have a minimal functionality by the end of this week, so, at the first stage, the project will be a set of functions to easily create controls, that will be manipulated from plain JS DOM (as TextBox sample shows).

The second stage, could be an abstraction layer based on JS objects and the third stage, a xBase to JS translator.

Anyway, in the first stage, as you can see, the library is extremely easy to use and intuitive.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Rathinagiri »

Wow. wonderful project plan Roberto.

I agree with you verbatim and I am eager to see the progress. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

Hi!

A new library release with changed window function and new image control.
Attachments
hmgs004.zip
(8.86 KiB) Downloaded 364 times
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by luisvasquezcl »

Estimado,
Yo creo que lo más simple es utilizar las funciones que existen.

Tenemos por ejemplo para la ventana el metodo Open del objeto window.
por ejemplo:

oWin = Window.Open("", "Ventana1", "width:300px; height: 300px;");

Si queremos agregarle escribir dentro de la ventana.
oWin.document.Write("<h1 id='1'>Hola</h1>");

Para acceder al contenido a traves de Dom.
oWin.document.write(" El contenido de la etiqueta h1=" + oWin.Document.getElementById('1').innerHTML )

Para cerrar.
oWin.Close()

Esto creo que contesta a tu pregunta si usar objetos o usar el modelo de objetos dom.
Espero que te sea útil.
Saludos cordiales,
Luis VAsquez
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

luisvasquezcl wrote:Estimado,
Yo creo que lo más simple es utilizar las funciones que existen.

Tenemos por ejemplo para la ventana el metodo Open del objeto window.
por ejemplo:

oWin = Window.Open("", "Ventana1", "width:300px; height: 300px;");

Si queremos agregarle escribir dentro de la ventana.
oWin.document.Write("<h1 id='1'>Hola</h1>");

Para acceder al contenido a traves de Dom.
oWin.document.write(" El contenido de la etiqueta h1=" + oWin.Document.getElementById('1').innerHTML )

Para cerrar.
oWin.Close()

Esto creo que contesta a tu pregunta si usar objetos o usar el modelo de objetos dom.
Espero que te sea útil.
Saludos cordiales,
Luis VAsquez
Cuando la primera fase (que consistirá en crear funciones para todos los elementos más útiles para nuestros desarrollos) esté terminada, vamos a expandirla con una capa de abstracción que haga las cosas más fáciles que DOM, que si bien es sencillom podría serlo aun más.

En este momento, necesito usar todo mi tiempo disponible para obtener la funcionalidad mínima requerida para hacer aplicaciones básicas.

Muchas gracias por tu comentario.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Rathinagiri »

Image demo is working fine in Chrome and IE and not in my Firefox 10.0 (Let me update and tell you)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply