Multiplatform
Previous topic  First topic  Next topic


Recomendations for coding in multiplatform in Marinas-GUI (Windows, Linux, etc).
Recomendaciones para codificar en multiplataforma en Marinas-GUI (Windows, Linux, etc).


1.- You need to have a standard at the moment of creating files and folders, I always create files and folders in lowcase (unless you need it to pass to another application in a specific mode)
1.- Es fundamental tener un estandard de nombres a la hora de crear archivos y directorios, en mi caso, siempre los creo en minúsculas (salvo que necesite explicitamente crearlos con algún nombre en particular, por ejemplo si se lo tengo que pasar a otra aplicación)

do not recommended: myDataFile.txt
recommended: my_data_file.txt

no recomendado: myDataFile.txt
recomendado: my_data_file.txt



2.- Never use an absolute folder name, unless it is strictly necessary
2.- Nunca use un nombre fijo de folder, a no ser que sea estrictamente necesario

Harbour has a functions that resolve many problems:
Harbour tiene una funcion que resuelve muchos problemas:

hb_ps() : returns Path Separator, in Windows returns "\" and in Unix (ie. Linux) returns "/"
hb_ps() : retorna el separador de directorios, en plataforma Windows retorna "\" y en plataforma Unix (ej: Linux) retorna "/"

and exists more for each requirement.
y existen muchas mas para cada requerimiento

do not recommended: C:\TEMP\my_file.txt
recommended: mg_getTempFolder() + hb_ps() + "my_file.txt"

no recomendado: C:\TEMP\my_file.txt
recomendado: mg_getTempFolder() + hb_ps() + "my_file.txt"


do not recommended: d:\systems\folder_with_my_exe
recommended: mg_getExeFolder()

no recomendado: d:\sistemas\directorio_con_mi_executable
recomendado: mg_getExeFolder()


do not recommended: dbUseArea( , "d:\systems\folder_with_my_exe\data\table1.dbf" )
recommended: dbUsearea( , mg_getExeFolder() + hb_ps() + "data" + hb_ps() + "table1.dbf" )

no recomendado: dbUseArea( , "d:\sistemas\directorio_con_mi_ejecutable\datos\tabla1.dbf" )
recomendado: dbUsearea( , mg_getExeFolder() + hb_ps() + "datos" + hb_ps() + "tabla1.dbf" )



3.- Do not use chars to coded End Of Line, Harbour has a functions that resolve its:
3.- No especifique el fin de linea con caracteres en forma explícita, Harbour tiene una funcion que resuelve este tema:

hb_eol() : returns End of Line, in Windows chr(13)+chr(10) and in Unix chr(10)
hb_eol() : retorna fin de linea, en Windows retorna chr(13)+chr(10) y en Unix retorna chr(10)

do not recommended: "first line" + chr(13)+chr(10) + "second line"
recommended: "first line" + hb_eol() + "second line"

no recomendado: "first line" + chr(13)+chr(10) + "second line"
recomendado: "first line" + hb_eol() + "second line"


It exists too this function: mg_xEol( <memo> ) change the end of line of any memo file created on any platform at the end of line, to the correct end of line of your current OS.
Tambien contamos con la funcion mg_xEol( <memo> ) que cambia el fin de linea de una variable de tipo memo (estring largo) que ha sido creada en cualquier plataforma y le coloca el fin de linea de la plataforma en la cual estamos actualmente.

For example: if you have a memo file created in Linux, you can read it in Windows without problems in this way:
Por ejemplo: si usted tiene un memo creado en Linux, usted puede leerlo en Windows sin problemas de la siguiente forma:

cMemo := mg_xEol( memoRead( "file_created_at_linux.txt" ) )
or viceversa

cMemo := mg_xEol( memoRead( "archivo_creado_en_linux.txt" ) )
y viceversa



4.- If it is absolutely necessary to do something different for Linux and Windows you have the Harbour pre-processor directives:
4.- En caso de que sea absolutamente necesario realizar cosas diferentes para cada plataforma, se pueden usar las directivas del pre-procesador Harbour:

   ...
   ...
#if defined( __PLATFORM__WINDOWS )
   ...
   Specific code for windows
   ...
#elif defined( __PLATFORM__LINUX )
   ...
   Specific code for linux
   ...
#else
   mg_log( "platform error: xxxxx" )
#endif
   ...
   ..
.



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