__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<!DOCTYPE html>
<html lang="es" dir="ltr">
<head>
<base href="../../../../../">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Servicio ScriptForge.TextStream</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="es/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="es/bookmarks.js" defer></script><script type="text/javascript" src="es/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="es/text/shared/05/new_help.html"><div></div></a><a class="logo" href="es/text/shared/05/new_help.html"><p dir="auto">Ayuda de LibreOffice 25.2</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Módulo</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contenido</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Buscar en los marcadores del módulo elegido" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<noscript><div id="WarnJS"><h1 dir="auto">Active JavaScript en el navegador para mostrar las páginas de ayuda de LibreOffice.</h1></div></noscript>
<a id="ScriptForge-SF_TextStream"></a>
<a id="bm_id50158533078781"></a>
<meta itemprop="keywords" content="TextStream service">
<a id="abstract"></a>
<h1 id="bm_id351585330787295" dir="auto">
<a id="TextStreamService"></a>Servicio <span class="literal">ScriptForge</span>.<span class="literal">TextStream</span>
</h1>
<p id="par_id511585330787205" class="paragraph" dir="auto">El servicio <span class="literal">TextStream</span> se utiliza para leer y escribir secuencialmente archivos abiertos mediante el servicio <span class="literal">ScriptForge.FileSystem</span>.</p>
<p id="par_id41613596903894" class="paragraph" dir="auto">Los métodos <span class="literal">OpenTextFile</span> y <span class="literal">CreateTextFile</span> del servicio <span class="literal">FileSystem</span> devuelven una ocurrencia del servicio <span class="literal">TextStream</span>.</p>
<p id="par_id161585330787262" class="paragraph" dir="auto">Line delimiters may be specified by the user. In input operations CR, LF or CR+LF are supported. In output operations, the default line delimiter is the one used by the operating system.</p>
<p id="par_id831613598137669" class="paragraph" dir="auto">The line delimiter for the operating system where the macro is being executed can be accessed using the <span class="literal">SF_String.sfNEWLINE</span> property.</p>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id851613597445432" dir="auto">All operations needed to read from or write to a file (open, read/write and close) are presumed to happen during the same macro run.</p></div>
</div>
<br>
<h2 id="hd_id83158533078741" dir="auto">Invocación del servicio</h2>
<p id="par_id351613598192725" class="paragraph" dir="auto">Los ejemplos siguientes en BASIC y Python utilizan el método <span class="literal">OpenTextFile</span> para crear un ejemplar del servicio <span class="literal">TextStream</span>.</p>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
Dim FSO As Variant
FSO = CreateScriptService("FileSystem")
Set myFile = FSO.OpenTextFile("C:\Temp\ThisFile.txt", FSO.ForReading)
</code></pre></div>
<p id="par_id371585330787197" class="paragraph" dir="auto">El archivo debe cerrarse con el método <span class="literal">CloseFile</span> después de que todas las operaciones de lectura o escritura se hayan ejecutado:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
myFile.CloseFile()
</code></pre></div>
<p id="par_id891582733781994" class="paragraph" dir="auto">Optionally, the resources used by the <span class="literal">TextStream</span> instance can be released using the <span class="literal">Dispose</span> method:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Set myFile = myFile.Dispose()
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id121612917368946" dir="auto">Los métodos del servicio <span class="literal">TextStream</span> se basan principalmente en las interfaces <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1io_1_1XTextInputStream.html"><span class="literal">XTextInputStream</span></a> y <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1io_1_1XTextOutputStream.html"><span class="literal">XTextOutputStream</span></a> de UNO.</p></div>
</div>
<br>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import CreateScriptService
fs = CreateScriptService("FileSystem")
myFile = fs.OpenTextFile(r"C:\Temp\ThisFile.txt", fs.ForReading)
# ...
myFile.CloseFile()
myFile = myFile.Dispose()
</code></pre></div>
<h2 id="hd_id941585330787948" dir="auto">Propiedades</h2>
<a id="bm_id1001613600572485"></a>
<meta itemprop="keywords" content="TextStream service,AtEndOfStream">
<meta itemprop="keywords" content="TextStream service,Encoding">
<meta itemprop="keywords" content="TextStream service,FileName">
<meta itemprop="keywords" content="TextStream service,IOMode">
<meta itemprop="keywords" content="TextStream service,Line">
<meta itemprop="keywords" content="TextStream service,NewLine">
<a id="properties_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id631585330787267" class="tableheadintable" dir="auto">Nombre</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id401585330787370" class="tableheadintable" dir="auto">De solo lectura</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id581585330787700" class="tableheadintable" dir="auto">Tipo</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id551585330787608" class="tableheadintable" dir="auto">Descripción</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id941585330787832" class="tablecontentintable" dir="auto">AtEndOfStream</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id181585330787752" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id471585330787948" class="tablecontentintable" dir="auto">Boolean</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id901585330787680" class="tablecontentintable" dir="auto">Se utiliza en el modo de lectura. Un valor <span class="literal">True</span> indica que se ha llegado al final del archivo. Una prueba que utilice esta propiedad debe preceder a las llamadas al método <span class="literal">ReadLine</span>.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id501585330787895" class="tablecontentintable" dir="auto">Encoding</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id561585330787568" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id731585330787673" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id741585330787777" class="tablecontentintable" dir="auto">El conjunto de caracteres que debe utilizarse. La codificación predeterminada es «UTF-8».</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id361585330787241" class="tablecontentintable" dir="auto">FileName</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id641585330787207" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id9158533078741" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id281585330787614" class="tablecontentintable" dir="auto">Returns the name of the current file either in URL format or in the native operating system's format, depending on the current value of the <span class="literal">FileNaming</span> property of the <span class="literal">FileSystem</span> service.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id451585330787745" class="tablecontentintable" dir="auto">IOMode</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id111585330787410" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id981585330787716" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id861585330787417" class="tablecontentintable" dir="auto">Indica el modo de entrada/salida. Los valores posibles son «READ», «WRITE» y «APPEND».</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id721585330787688" class="tablecontentintable" dir="auto">Line</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id87158533078795" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id601585330787171" class="tablecontentintable" dir="auto">Long</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id561585330787741" class="tablecontentintable" dir="auto">Returns the number of lines read or written so far.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id12158533078767" class="tablecontentintable" dir="auto">NewLine</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id531585330787157" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id9415853307876" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id691585330787279" class="tablecontentintable" dir="auto">Establece o devuelve el delimitador actual que se insertará entre dos renglones escritos sucesivos. El valor predeterminado es el delimitador de renglón nativo del sistema operativo actual.</p>
</td>
</tr>
</table>
<br>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id141613001281573" dir="auto">Para conocer más sobre los nombres de los conjuntos de caracteres, consulte la página <a target="_blank" href="https://www.iana.org/assignments/character-sets/character-sets.xhtml">Conjuntos de caracteres de la IANA</a> (en inglés). Conviene saber que LibreOffice no admite todos los conjuntos de caracteres existentes.</p></div>
</div>
<br>
<a id="methods_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="3" class="tableheadcell" dir="auto">
<p id="par_id891611613601554" class="tableheadintable" dir="auto">Lista de métodos en el servicio TextStream</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id891611613601556" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_textstream.html#CloseFile">CloseFile</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_textstream.html#ReadAll">ReadAll</a><br>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id541611613601554" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_textstream.html#ReadLine">ReadLine</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_textstream.html#SkipLine">SkipLine</a><br>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id701611613601554" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_textstream.html#WriteBlankLines">WriteBlankLines</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_textstream.html#WriteLine">WriteLine</a><br>
</p>
</td>
</tr>
</table>
<br>
<a id="CloseFile"></a>
<a id="bm_id21585330787288"></a>
<meta itemprop="keywords" content="TextStream service,CloseFile">
<h2 id="hd_id901585330787252" dir="auto">CloseFile</h2>
<p id="par_id421585330787675" class="paragraph" dir="auto">Closes the current input or output stream and empties the output buffer if relevant. Returns <span class="literal">True</span> if the file was successfully closed.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id971626891612501" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">myFile.CloseFile(): bool</span>
</p>
<a id="ReadAll"></a>
<a id="bm_id311585330787690"></a>
<meta itemprop="keywords" content="TextStream service,ReadAll">
<h2 id="hd_id311585330787335" dir="auto">ReadAll</h2>
<p id="par_id65158533078799" class="paragraph" dir="auto">Returns all the remaining lines in the text stream as a single string. Line breaks are not removed.</p>
<p id="par_id71613600347125" class="paragraph" dir="auto">The resulting string can be split in lines either by using the <span class="literal">Split</span> built-in Basic function if the line delimiter is known, or with the <span class="literal">SF_String.SplitLines</span> method.</p>
<p id="par_id91585330787373" class="paragraph" dir="auto">For large files, using the <span class="literal">ReadAll</span> method wastes memory resources. In such cases it is recommended to read the file line by line using the <span class="literal">ReadLine</span> method.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id501626891694491" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">myFile.ReadAll(): str</span>
</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<p id="par_id921613595637851" class="paragraph" dir="auto">Considere el archivo de texto «Alumnos.txt» con este contenido (un nombre por cada renglón):</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Herbie Peggy
Hardy Jarrett
Edith Lorelle
Roderick Rosamund
Placid Everette
</code></pre></div>
<p id="par_id391613596019750" class="paragraph" dir="auto">The examples below in Basic and Python use the <span class="literal">ReadAll</span> and <span class="literal">SplitLines</span> methods to read the contents of the file into an array of strings:</p>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
'Carga el servicio FileSystem
Dim FSO : FSO = CreateScriptService("FileSystem")
'Opens the text file with the names to be read
Dim inputFile as Object
Set inputFile = FSO.OpenTextFile("/home/user/Documents/Students.txt")
'Reads all the contents in the input file as a single string
Dim allData as String
allData = inputFile.ReadAll()
'Splits the string into an array
Dim arrNames as Variant
arrNames = SF_String.SplitLines(allData)
' (...)
inputFile.CloseFile()
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
fs = CreateScriptService("FileSystem")
inputFile = fs.OpenTextFile("/home/user/Documents/Students.txt")
allData = inputFile.ReadAll()
arrNames = allData.split(inputFile.NewLine)
# ...
inputFile.CloseFile()
</code></pre></div>
<a id="ReadLine"></a>
<a id="bm_id161585330787462"></a>
<meta itemprop="keywords" content="TextStream service,ReadLine">
<h2 id="hd_id111585330787998" dir="auto">ReadLine</h2>
<p id="par_id871585330787885" class="paragraph" dir="auto">Returns the next line in the text stream as a string. Line breaks are removed from the returned string.</p>
<p id="par_id431613600221626" class="paragraph" dir="auto">The <span class="literal">AtEndOfStream</span> test should precede the <span class="literal">ReadLine</span> method like in the example below.</p>
<p id="par_id171585330787774" class="paragraph" dir="auto">An error will be raised if the <span class="literal">AtEndOfStream</span> was reached during the previous <span class="literal">ReadLine</span> or <span class="literal">SkipLine</span> method call.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id431626892013564" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">myFile.ReadLine(): str</span>
</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim sLine As String
Do While Not myFile.AtEndOfStream
sLine = myFile.ReadLine()
' (...)
Loop
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
while not myFile.AtEndOfStream:
sLine = myFile.ReadLine()
# ...
</code></pre></div>
<a id="SkipLine"></a>
<a id="bm_id381585330787551"></a>
<meta itemprop="keywords" content="TextStream service,SkipLine">
<h2 id="hd_id241585330787168" dir="auto">SkipLine</h2>
<p id="par_id11585330787847" class="paragraph" dir="auto">Skips the next line in the input stream when reading a <span class="literal">TextStream</span> file.</p>
<p id="par_id441613600704766" class="paragraph" dir="auto">This method can result in <span class="literal">AtEndOfStream</span> being set to <span class="literal">True</span>.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id41626892171105" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">myFile.SkipLine()</span>
</p>
<a id="WriteBlankLines"></a>
<a id="bm_id61585330787548"></a>
<meta itemprop="keywords" content="TextStream service,WriteBlankLines">
<h2 id="hd_id241585330787109" dir="auto">WriteBlankLines</h2>
<p id="par_id141585330787657" class="paragraph" dir="auto">Writes a specified number of empty lines to the output stream.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id531626892281078" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">myFile.WriteBlankLines(lines: int)</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id291585330787357" class="paragraph" dir="auto"><span class="emph">lines</span>: The number of empty lines to write to the file.</p>
<a id="WriteLine"></a>
<a id="bm_id371585330787255"></a>
<meta itemprop="keywords" content="TextStream service,WriteLine">
<h2 id="hd_id611585330787877" dir="auto">WriteLine</h2>
<p id="par_id101585330787215" class="paragraph" dir="auto">Writes the given string to the output stream as a single line.</p>
<p id="par_id421613601002074" class="paragraph" dir="auto">El carácter definido en la propiedad <span class="literal">NewLine</span> se utiliza como delimitador de renglones.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id791626892414752" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">myFile.WriteLine(line: str)</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id491585330787650" class="paragraph" dir="auto"><span class="emph">line</span>: The line to write, may be empty.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<p id="par_id821626894480105" class="paragraph" dir="auto">The examples below in Basic and Python create a text file in CSV format in which each line contains a value and its square until <span class="literal">lastValue</span> is reached.</p>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Sub SquaredValuesFile(lastValue as Integer)
'Instantiates the FileSystem Service
Dim FSO as Variant : FSO = CreateScriptService("FileSystem")
'Crea un archivo de texto
Dim myFile as Variant : myFile = FSO.CreateTextFile("/home/user/Documents/squares.csv")
'Writes the Value and Value squared, separated by ";"
Dim value as Integer
myFile.WriteLine("Value;Value Squared")
For value = 1 To lastValue
myFile.WriteLine(value & ";" & value ^ 2)
Next value
'Cierra el archivo y libera recursos
myFile.CloseFile()
Set myFile = myFile.Dispose()
End Sub
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
def squared_values_file(lastValue):
fs = CreateScriptService("FileSystem")
myFile = fs.CreateTextFile("/home/user/Documents/squares.csv")
myFile.WriteLine("Value;Value Squared")
for value in range(1, lastValue + 1):
myFile.WriteLine("{};{}".format(value, value ** 2))
myFile.CloseFile()
myFile = myFile.Dispose()
</code></pre></div>
<div class="embedded">
<a id="SF_InternalUse"></a>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id851506659675843" dir="auto">Todas las rutinas o identificadores BASIC de <span class="literal">ScriptForge</span> precedidas por guion bajo «_» están reservadas para uso interno. No deben utilizarse en macros BASIC o secuencias Python.</p></div>
</div>
<br>
</div>
<a id="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a id="related"></a><span class="emph">Temas relacionados</span></p>
<div class="relatedbody" itemprop="mentions">
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03/sf_filesystem.html">Servicio <span class="literal">ScriptForge</span>.<span class="literal">FileSystem</span></a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03160000.html">Input Function [VBA]</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03020103.html">Open Statement</a></p></div>
</div>
</div>
</div>
<div id="DonationFrame"></div>
<footer><h2 style="text-align: center;"><a href="https://books.libreoffice.org" target="_blank">Libros de LibreOffice</a></h2>
<div class="noteicon" dir="auto" style="display:flex;justify-content:center;flex-wrap:wrap;row-gap:15px;">
<img src="media/navigation/libo-writer.svg" alt="Writer Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-calc.svg" alt="Calc Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-impress.svg" alt="Impress Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-draw.svg" alt="Draw Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-base.svg" alt="Base Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-math.svg" alt="Math Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-symbol-black.svg" alt="Getting Started Icon" style="width:60px;height:60px;">
</div>
<div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03/sf_textstream.xhp" target="_blank">/text/sbasic/shared/03/sf_textstream.xhp</a></p>
<p dir="auto">Title is: Servicio ScriptForge.TextStream</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| avail_release.html | File | 8.05 KB | 0644 |
|
| lib_ScriptForge.html | File | 54.61 KB | 0644 |
|
| lib_depot.html | File | 5.35 KB | 0644 |
|
| lib_euro.html | File | 7.64 KB | 0644 |
|
| lib_formwizard.html | File | 5.38 KB | 0644 |
|
| lib_gimmicks.html | File | 7.76 KB | 0644 |
|
| lib_importwiz.html | File | 7.59 KB | 0644 |
|
| lib_schedule.html | File | 5.47 KB | 0644 |
|
| lib_script.html | File | 5.91 KB | 0644 |
|
| lib_template.html | File | 5.37 KB | 0644 |
|
| lib_tools.html | File | 74.88 KB | 0644 |
|
| lib_wikieditor.html | File | 5.62 KB | 0644 |
|
| sf_array.html | File | 84.5 KB | 0644 |
|
| sf_base.html | File | 45.49 KB | 0644 |
|
| sf_basic.html | File | 78.88 KB | 0644 |
|
| sf_calc.html | File | 209.75 KB | 0644 |
|
| sf_chart.html | File | 35.85 KB | 0644 |
|
| sf_database.html | File | 66.35 KB | 0644 |
|
| sf_dataset.html | File | 59.17 KB | 0644 |
|
| sf_datasheet.html | File | 42.59 KB | 0644 |
|
| sf_dialog.html | File | 164.91 KB | 0644 |
|
| sf_dialogcontrol.html | File | 92.57 KB | 0644 |
|
| sf_dictionary.html | File | 42.93 KB | 0644 |
|
| sf_document.html | File | 87.26 KB | 0644 |
|
| sf_exception.html | File | 47.22 KB | 0644 |
|
| sf_filesystem.html | File | 106.92 KB | 0644 |
|
| sf_form.html | File | 68.52 KB | 0644 |
|
| sf_formcontrol.html | File | 71.36 KB | 0644 |
|
| sf_formdocument.html | File | 24.99 KB | 0644 |
|
| sf_intro.html | File | 28.11 KB | 0644 |
|
| sf_l10n.html | File | 41.17 KB | 0644 |
|
| sf_menu.html | File | 36.53 KB | 0644 |
|
| sf_methods.html | File | 15.38 KB | 0644 |
|
| sf_platform.html | File | 32.07 KB | 0644 |
|
| sf_popupmenu.html | File | 32.73 KB | 0644 |
|
| sf_region.html | File | 48.56 KB | 0644 |
|
| sf_services.html | File | 13.42 KB | 0644 |
|
| sf_session.html | File | 58.96 KB | 0644 |
|
| sf_string.html | File | 125.2 KB | 0644 |
|
| sf_textstream.html | File | 28.87 KB | 0644 |
|
| sf_timer.html | File | 23.87 KB | 0644 |
|
| sf_toc.html | File | 136.53 KB | 0644 |
|
| sf_toolbar.html | File | 20.46 KB | 0644 |
|
| sf_toolbarbutton.html | File | 25.53 KB | 0644 |
|
| sf_ui.html | File | 63.35 KB | 0644 |
|
| sf_unittest.html | File | 62.35 KB | 0644 |
|
| sf_writer.html | File | 24.55 KB | 0644 |
|