<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.open-office.es/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
		<id>https://wiki.open-office.es/index.php?action=history&amp;feed=atom&amp;title=Opciones_y_directivas_del_compilador</id>
		<title>Opciones y directivas del compilador - Historial de revisiones</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.open-office.es/index.php?action=history&amp;feed=atom&amp;title=Opciones_y_directivas_del_compilador"/>
		<link rel="alternate" type="text/html" href="https://wiki.open-office.es/index.php?title=Opciones_y_directivas_del_compilador&amp;action=history"/>
		<updated>2026-06-04T05:41:52Z</updated>
		<subtitle>Historial de revisiones para esta página en el wiki</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>https://wiki.open-office.es/index.php?title=Opciones_y_directivas_del_compilador&amp;diff=14397&amp;oldid=prev</id>
		<title>Salva en 13:17 22 jun 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.open-office.es/index.php?title=Opciones_y_directivas_del_compilador&amp;diff=14397&amp;oldid=prev"/>
				<updated>2016-06-22T13:17:49Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nueva&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Menu|cat=Basic|subcat=Las variables en OpenOffice Basic|vers=4.0.x}}&lt;br /&gt;
&amp;lt;seo title=&amp;quot;Opciones y directivas del compilador - Apache OpenOffice Basic&amp;quot; &lt;br /&gt;
metakeywords=&amp;quot;opcion,directiva,compilador,macro,basic,starbasic,manual,curso,tutorial,open,office,openoffice,apache openoffice,libreoffice&amp;quot; &lt;br /&gt;
metadescription=&amp;quot;OpenOffice.org Basic, también conocido como OOo Basic o StarBasic, es el nombre de uno de los cuatro lenguajes de macros incluidos en la suites Apache OpenOffice y LibreOffice&amp;quot;/&amp;gt;&lt;br /&gt;
Al inicio de un módulo podemos fijar las siguientes opciones o directivas a nivel del compilador de OpenOffice Basic:&lt;br /&gt;
&lt;br /&gt;
{| class=mitb width=&amp;quot;780&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
!Opción&lt;br /&gt;
!Descripción&lt;br /&gt;
|-&lt;br /&gt;
|Def&lt;br /&gt;
|Especifica el tipo de las variables no declaradas en función de su nombre.&lt;br /&gt;
|-&lt;br /&gt;
|Option Base&lt;br /&gt;
|Define si el primer elemento de un array es el 0 o el 1, si no se especificó en su declaración.&lt;br /&gt;
|-&lt;br /&gt;
|Option Compatible&lt;br /&gt;
|Cambia el modo de funcionamiento de OOo Basic a uno más compatible con VBA.&lt;br /&gt;
|-&lt;br /&gt;
|Option Explicit&lt;br /&gt;
|Obliga a que se definan las variables. Si utilizamos una variable no declarada previamente, al iniciar la macro el compilador se detendrá mostrando un mensaje de error.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Option Compatible ==&lt;br /&gt;
Al incorporar esta opción del compilador al principio de un módulo, le indicas al compilador que modifique su modo de trabajo para ser más compatible con el dialecto VBA.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puedes encontrar información de esta opción del compilador en este enlace de nuestro blog: {{enlace|http://blog.open-office.es/basic/option-compatible-en-openoffice-basic-permite-mayor-compatibilidad-con-vba|Option Compatible en OOo Basic}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Option Explicit ==&lt;br /&gt;
La declaración de variables no es obligatoria, pero es muy conveniente para evitar errores.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Para forzar a que se nos exija que se declaren las variables utilizadas, debemos agregar el comando de compilador {{fosfi|Option Explicit}} al inicio de cada módulo.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
REM  *****  BASIC  *****&lt;br /&gt;
Option Explicit&lt;br /&gt;
&lt;br /&gt;
Sub MiFuncion() as string&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si utilizamos una variable no declarada previamente, al iniciar la macro el compilador se detendrá mostrando un mensaje de error y resaltada en azul, la variable no declarada.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:OpenOffice.Basic.Macros.013.png|center|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Directiva Def ==&lt;br /&gt;
Podemos declarar por la letra con la que empieza el nombre de la variable los tipos de aquellas variables cuyo tipo no sea declarado explícitamente.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Para forzar esta declaración, debemos agregar uno o más comandos de compilador {{fosfi|Def}} al inicio de cada módulo.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
En el siguiente ejemplo se definirán como variables de tipo:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::*'''''integer''''' aquellas que empiecen por las letras '''i''', '''j''', '''k''' o '''n''', utilizando '''''DefInt'''''&lt;br /&gt;
::*'''''long''''' las que empiecen por la letra '''l''', utilizando '''''DefLng'''''&lt;br /&gt;
::*'''''double''''' las que empiecen por la letra '''d''', utilizando '''''DefDbl'''''&lt;br /&gt;
::*'''''single''''' las que empiecen por la letra '''s''', utilizando '''''DefSng'''''&lt;br /&gt;
::*'''''currency''''' las que empiecen por la letra '''m''', utilizando '''''DefCur'''''&lt;br /&gt;
&lt;br /&gt;
::*'''''string''''' las que empiecen por la letra '''c''', utilizando '''''DefStr'''''&lt;br /&gt;
&lt;br /&gt;
::*'''''boolean''''' las que empiecen por la letra '''b''', utilizando '''''DefBool'''''&lt;br /&gt;
::*'''''date''''' las que empiecen por la letra '''f''' o '''h''', utilizando '''''DefDate'''''&lt;br /&gt;
&lt;br /&gt;
::*'''''objeto''''' las que empiecen por la letra '''o''', utilizando '''''DefObj'''''&lt;br /&gt;
::*'''''variable''''' las que empiecen por la letra '''v''', utilizando '''''DefVar'''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
REM  *****  BASIC  *****&lt;br /&gt;
Option Explicit&lt;br /&gt;
DefInt i-k, n&lt;br /&gt;
DefLng l&lt;br /&gt;
DefDbl d&lt;br /&gt;
DefSng s&lt;br /&gt;
DefCur m&lt;br /&gt;
&lt;br /&gt;
DefStr c&lt;br /&gt;
&lt;br /&gt;
DefBool b&lt;br /&gt;
DefDate f,h&lt;br /&gt;
&lt;br /&gt;
DefObj o&lt;br /&gt;
DefVar v&lt;br /&gt;
&lt;br /&gt;
Sub MiSubRutina() as string&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
La directiva {{fosfi|Def}} declara el tipo de la variable, pero no declara la variable, que tiene que ser declarada al nivel que corresponda.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Las variables tampoco se inicializan con su tipo de dato, por lo que antes de asignarles un valor, se presentan como vacías.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
El siguiente código utiliza las funciones {{fosfi|TypeName}} y {{fosfi|VarType}} para ilustrar este hecho.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
REM  *****  BASIC  *****&lt;br /&gt;
Option Explicit&lt;br /&gt;
DefInt i-k&lt;br /&gt;
DefLng n&lt;br /&gt;
DefDbl d&lt;br /&gt;
&lt;br /&gt;
DefBool l&lt;br /&gt;
DefDate f,h&lt;br /&gt;
DefObj o&lt;br /&gt;
DefVar v&lt;br /&gt;
&lt;br /&gt;
DefCur m&lt;br /&gt;
DefSng s&lt;br /&gt;
DefStr c&lt;br /&gt;
&lt;br /&gt;
Dim cTexto&lt;br /&gt;
&lt;br /&gt;
Sub MiSubRutina( optional nNumero )&lt;br /&gt;
Dim fFecha&lt;br /&gt;
&lt;br /&gt;
MsgBox TypeName( cTexto ) &amp;amp; chr(13) &amp;amp; _&lt;br /&gt;
       TypeName( nNumero ) &amp;amp; chr(13) &amp;amp; _&lt;br /&gt;
       TypeName( fFecha ) &lt;br /&gt;
       &lt;br /&gt;
MsgBox VarType( cTexto ) &amp;amp; chr(13) &amp;amp; _&lt;br /&gt;
       VarType( nNumero ) &amp;amp; chr(13) &amp;amp; _&lt;br /&gt;
       VarType( fFecha )  &lt;br /&gt;
       &lt;br /&gt;
cTexto = &amp;quot;Hola&amp;quot;&lt;br /&gt;
nNumero = 100&lt;br /&gt;
fFecha = date&lt;br /&gt;
             &lt;br /&gt;
MsgBox TypeName( cTexto ) &amp;amp; chr(13) &amp;amp; _&lt;br /&gt;
       TypeName( nNumero ) &amp;amp; chr(13) &amp;amp; _&lt;br /&gt;
       TypeName( fFecha ) &lt;br /&gt;
       &lt;br /&gt;
MsgBox VarType( cTexto ) &amp;amp; chr(13) &amp;amp; _&lt;br /&gt;
       VarType( nNumero ) &amp;amp; chr(13) &amp;amp; _&lt;br /&gt;
       VarType( fFecha )               &lt;br /&gt;
       &lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Pie|Basic|Volver|Larga=5}}&lt;br /&gt;
[[Category:Ver.3.4.x]][[Category:Ver.3.3.x]][[Category:Ver.3.2.x]][[Category:Ver.3.1.x]]&lt;/div&gt;</summary>
		<author><name>Salva</name></author>	</entry>

	</feed>