Syntax
Previous topic  First topic  Next topic


Marinas-GUI is composed mostly by statements enclosed between two commands called CREATE and END, and between them are encoded control properties. Let's look at some recommendations:
Marinas-GUI esta compuesta en su gran mayoria por comandos encerrados entre dos sentencias denominadas CREATE y END y entre ellas se codifican las propiedades del control. Veamos a continuación algunas recomendaciones:


Order coding properties:
Orden de codificación de propiedades:

Each property within this command is executed and applied in order of appearance.
It is not necessary to respect a specific order, but in some cases, the encoding order is very important.
Cada propiedad dentro de dicho comando es ejecutada y aplicada en orden de aparición.
No es necesario respetar un orden específico, pero en algunos casos, el orden de codificación es muy relevante.

For example, given the following LABEL:
Por ejemplo, dado el siguiente LABEL:

CREATE LABEL Label01
   ROW 33
   COL 20
   WIDTH 400 - ( mg_Get( "myWin" , "Label01" , "col" ) * 2 )
   VALUE "Label 01"
END LABEL


In this case we are using the property value set in "COL" to set the width in the next line. The value of "WIDTH" would be: 400 - (20 * 2), or 360
En este caso estamos utilizando el valor configurado en la propiedad "COL" para establecer el ancho del control en la linea siguiente. El valor de "WIDTH" seria: 400 - ( 20 * 2 ), o sea 360

If we reverse the order of the properties "COL" and "WIDTH", the value of "WIDTH" would not be the same because by default, the property "COL" is initialized to 0 (zero). In this case, the value of "WIDTH" is: 400 - (0 * 2), or 400
Si invertimos el orden de las propiedades "COL" y "WIDTH", el valor de "WIDTH" no sería el mismo ya que por default, la propiedad "COL" esta inicializada con 0 (cero). En este caso, el valor de "WIDTH" sería: 400 - ( 0 * 2 ), o sea 400

Therefore, although the properties do not have a specific order, as above should be paid attention to the order of property involved.
Por eso, si bien las propiedades no tienen un orden específico, en el caso anterior habría que prestar atención al orden de las propiedades involucradas.


Another case to consider is how to encode the command:
Otro caso a tener en cuenta es la forma de codificar el comando:

For example:
Veamos un ejemplo:

#Line 14: CREATE LABEL Label01
#Line 15:    ROW 20
#Line 16:    COL 33
#Line 17:    AUTOSIZE .T.
#Line 18:    FONTBOLD .T.
#Line 19:    FONTITALIC .T.
#Line 20:    ENABLED .T.
#Line 21:    VALUE "Label 01"
#Line 22:    FONTCOLOR { 255 , 0 , 0 }
#Line 23: END LABEL


Many people choose to reduce the space that this command occupies using the same line to encode several properties , for example:
Muchas personas eligen reducir el espacio que este comando ocupa utilizando la misma linea para codificar varias sentencias, por ejemplo:

#Line 14: CREATE LABEL Label01 ; ROW 20 ; COL 33 ; AUTOSIZE .T. ; FONTBOLD .T. ; FONTITALIC .T. ; ENABLE .T.
#Line 15:        VALUE "Label 01" ; FONTCOLOR { 255 , 0 , 0 } ; END LABEL


The latter encoding works exactly like the first but has some disadvantages:
Esta última codificacion funciona exactamente igual que la primera pero tiene algunas desventajas:

Suppose that instead of writing FONTITALIC, by a typographical error we write FOMTITALIC (with "M" instead of "N"), when trying to compile the program receive the following error for each of the cases presented:
Supongamos que en lugar de escribir FONTITALIC, por un error tipográfico escribimos FOMTITALIC (con "M" en lugar de "N"), cuando intentemos compilar el programa recibiremos el siguiente error para cada uno de los casos presentados:

For recomended syntax we receive:
Para sintaxis recomendada recibiremos:

D:\factory\TESTS_~1\sintaxis.prg(19) Error E0030
Syntax error "syntax error at '.T.'"


thus clearly identify the line of error is 19:
con lo cual identificamos claramente que la linea del error es la 19:

#Line 19:    FOMTITALIC .T.

For reduced syntax we receive:
Para sintaxis reducida recibiremos:

D:\factory\TESTS_~1\sintaxis.prg(14) Error E0030
Syntax error "syntax error at '.T.'"


thus we are much more difficult to determine which is the error as the line 14 contains:
con lo cual nos es mucho mas dificil determinar cual es el error ya que la linea 14 contiene:

#Line 14: CREATE LABEL Label01 ; ROW 20 ; COL 33 ; AUTOSIZE .T. ; FONTBOLD .T. ; FOMTITALIC .T. ; ENABLE .T.

This is a simple example in a control with properties that are not complex to read, but an error in more complex properties such as those of a GRID, or a BROWSE would be much more difficult to detect.
Este es un ejemplo simple en un control con propiedades que no son complejas de leer, pero un error en propiedades mas complejas como ser las de un GRID o un BROWSE sería mucho mas complicado de detectar.

Another advantage of the recommended syntax is the ability to "suspend " command lines quickly and easily and / or add lines of comments between the properties.
Otra ventaja de la sintaxis recomendada es la posibilidad de "suspender" lineas del comando en forma rápida y fácil y/o agregar lineas de comentarios entre las propiedades.

For example: Suppose you want to suspend the AUTOSIZE and ENABLED lines
Por ejemplo: Supongamos que deseamos suspender las lineas AUTOSIZE y ENABLED

In the syntax recommended only need to add two "//" on the lines indicated:
En la sintaxis recomendada solo necesitamos agregar dos "//" en las lineas indicadas:

CREATE LABEL Label01
   ROW 20
   COL 33
// AUTOSIZE .T.
   FONTBOLD .T.
   FONTITALIC .T.
// ENABLED .T.
   VALUE "Label 01"
   FONTCOLOR { 255 , 0 , 0 }
END LABEL


In small syntax would have to make several changes:
En cambio en la sintax is reducida tendriamos que hacer varias modificaciones:

CREATE LABEL Label01 ; ROW 20 ; COL 33
//     AUTOSIZE .T.
       FONTBOLD .T. ; FONTITALIC .T.
//     
ENABLED .T.
       VALUE "Label 01" ; FONTCOLOR { 255 , 0 , 0 } ; END LABEL


The same situation would be if we need to add one or more lines of comments between the properties of the command.
La misma situación se daría si necesitamos agregar una o varias lineas de comentarios entre las propiedades del comando.



Marinas-GUI Version 03.06 and
Marinas-IDE Version 05.06 and
LEX Files Version 02.06


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: April 27
2017
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




A Harbour/QT framework to make multiplatform programs

(©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
CarozoDeQuilmes@gmail.com

2009-2017 Beta tester and full English translator: Bruno Luciani
Bruno.Luciani@gmail.com

2014-2015 Final English corrector: David Worboys
DavidWorboys@hotmail.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic