</head> <body> <h1>StringMid</h1> <p>Retrieves one or more characters from the specified position in a string.</p> <p class="warning"><strong>Deprecated:</strong> This command is not recommended for use in new scripts. Use the <a href="SubStr.htm">SubStr</a> function instead.</p> <pre class="Syntax"><span class="func">StringMid</span>, OutputVar, InputVar, StartChar <span class="optional">, Count, L</span></pre> <h2 id="Parameters">Parâmetros</h2> <dl> <dt>OutputVar</dt> <dd><p>The name of the output variable in which to store the substring extracted from <em>InputVar</em>.</p></dd> <dt>InputVar</dt> <dd><p>The name of the input variable from whose contents the substring will be extracted. Do not enclose the name in percent signs unless you want the <em>contents</em> of the variable to be used as the name.</p></dd> <dt>StartChar</dt> <dd><p>The position of the first character to be extracted, which can be an <a href="../Variables.htm#Expressions">expression</a>. Unlike <a href="StringGetPos.htm">StringGetPos</a>, 1 is the first character. If <em>StartChar</em> is less than 1, it will be assumed to be 1. If <em>StartChar</em> is beyond the end of the string, <em>OutputVar</em> is made empty (blank).</p></dd> <dt>Count</dt> <dd><p><span class="ver">[v1.0.43.10+]</span>: This parameter may be omitted or left blank, which is the same as specifying an integer large enough to retrieve all characters from the string.</p> <p>Otherwise, specify the number of characters to extract, which can be an <a href="../Variables.htm#Expressions">expression</a>. If <em>Count</em> is less than or equal to zero, <em>OutputVar</em> will be made empty (blank). If <em>Count</em> exceeds the length of <em>InputVar</em> measured from <em>StartChar</em>, <em>OutputVar</em> will be set equal to the entirety of <em>InputVar</em> starting at <em>StartChar</em>.</p></dd> <dt>L</dt> <dd><p>The letter L can be used to extract characters that lie to the left of <em>StartChar</em> rather than to the right. In the following example, <em>OutputVar</em> will be set to <em>Red</em>:</p> <pre>InputVar := "The Red Fox" StringMid, OutputVar, InputVar, 7, 3, L</pre> <p>If the L option is present and <em>StartChar</em> is less than 1, <em>OutputVar</em> will be made blank. If <em>StartChar</em> is beyond the length of <em>InputVar</em>, only those characters within reach of <em>Count</em> will be extracted. For example, the below will set <em>OutputVar</em> to <em>Fox</em>:</p> <pre>InputVar := "The Red Fox" StringMid, OutputVar, InputVar, 14, 6, L</pre> </dd> </dl> <h2 id="Remarks">Remarks</h2> <p>For this and all other commands, <em>OutputVar</em> is allowed to be the same variable as <em>InputVar</em>.</p> <h2 id="Related">Tópicos relacionados</h2> <p><a href="SubStr.htm">SubStr()</a>, <a href="StringLeft.htm">StringLeft</a>, <a href="StringLeft.htm">StringRight</a>, <a href="StringTrimLeft.htm">StringTrimLeft</a>, <a href="StringTrimLeft.htm">StringTrimRight</a>, <a href="IfInString.htm">IfInString</a>, <a href="StringGetPos.htm">StringGetPos</a>, <a href="StringLen.htm">StringLen</a>, <a href="StringLower.htm">StringLower</a>, <a href="StringLower.htm">StringUpper</a>, <a href="StringReplace.htm">StringReplace</a></p> <h2 id="Examples">Exemplos</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> Retrieves a substring with a length of 4 characters at position 7.</p> <pre>Source := "Hello this is a test." StringMid, the_word_this, Source, 7, 4</pre> </div> </body> </html>