<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>MID</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">MID</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
Extracts a substring from a string. 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Returns</span>
<p>
A string; the set of characters from string, beginning at start, of length count.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
String functions
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Function syntax</span><pre>Mid(string, start, count)
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
Left, Len, Right
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Parameters</span>
<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span><pre>&lt;h3&gt;Mid Example&lt;/h3&gt;

&lt;cfif IsDefined(&quot;Form.myText&quot;)&gt;
   &lt;!--- If len returns 0 (zero), then show error message. ---&gt;
   &lt;cfif Len(Form.myText)&gt;
      &lt;cfif Len(Form.myText) LTE Form.RemoveChars&gt;
         &lt;cfoutput&gt;&lt;p style=&quot;color: red; font-weight: bold&quot;&gt;Your string
         #Form.myText# only has #Len(Form.myText)# characters. You cannot output
         the #Form.removeChars# middle characters of this string because it is
         not long enough.&lt;/p&gt;&lt;/cfoutput&gt;
      &lt;cfelseif Form.startPos GTE Len(Form.myText)&gt;
         &lt;cfoutput&gt;&lt;p style=&quot;color: red; font-weight: bold&quot;&gt;Your string
         #Form.myText# only has #Len(Form.myText)# characters. You cannot start
         at position #Form.startPos#.&lt;/p&gt;&lt;/cfoutput&gt;
      &lt;cfelse&gt;
         &lt;cfoutput&gt;&lt;p&gt;Your original string: &lt;strong&gt;#Form.myText#&lt;/strong&gt;&lt;/p&gt;
         &lt;p&gt;Your changed string, showing only the &lt;strong&gt;#Form.removeChars#
         &lt;/strong&gt; middle characters: &lt;strong&gt;#Mid(Form.myText, 
         Form.startPos, Form.removeChars)#&lt;/strong&gt;&lt;/p&gt;&lt;/cfoutput&gt;
      &lt;/cfif&gt;
   &lt;cfelse&gt;
      &lt;p style=&quot;color: red; font-weight: bold&quot;&gt;Please enter a string of more
      than 0 (zero) characters.&lt;/p&gt;
   &lt;/cfif&gt;
&lt;/cfif&gt;

&lt;form action=&quot;&lt;cfoutput&gt;#CGI.ScriptName#&lt;/cfoutput&gt;&quot; method=&quot;POST&quot;&gt;
&lt;p&gt;Type in some text&lt;br /&gt;
&lt;input type=&quot;Text&quot; name=&quot;myText&quot;&gt;&lt;/p&gt;
&lt;p&gt;Enter a starting position (from the beginning of the entered text)&lt;br /&gt;
&lt;input name=&quot;startPos&quot; type=&quot;text&quot; size=&quot;1&quot;&gt;&lt;/p&gt;
&lt;p&gt;How many characters do you want to show?
&lt;select name=&quot;RemoveChars&quot;&gt;
&lt;option value=&quot;1&quot;&gt;1
&lt;option value=&quot;3&quot; selected&gt;3
&lt;option value=&quot;5&quot;&gt;5
&lt;option value=&quot;7&quot;&gt;7
&lt;option value=&quot;9&quot;&gt;9&lt;/select&gt;
&lt;input type=&quot;Submit&quot; name=&quot;Submit&quot; value=&quot;Remove characters&quot;&gt;&lt;/p&gt;
&lt;/form&gt; 
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="STRING">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">STRING</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>A string or a variable that contains one. Must be single-quotation mark or double-quotation mark delimited. </p>

  </td>
  </tr>
  </table>
</div>
<div id="START">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">START</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>A positive integer or a variable that contains one. Position at which to start count. Positions start with 1, not 0. </p>

  </td>
  </tr>
  </table>
</div>
<div id="COUNT">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">COUNT</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>A positive integer or a variable that contains one. Number of characters to return. (Zero is not valid, but it does not throw an error.) </p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
