<p>The <codeclass="xref js js-func docutils literal"><spanclass="pre">getPortHandle()</span></code> Netscript function can be used to get a handle to a Netscript Port.
This handle allows you to access several new port-related functions and the
port's underlying data structure, which is just a Javascript array. The functions are:</p>
<dlclass="method">
<dtid="NetscriptPort.write">
<codeclass="descclassname">NetscriptPort.</code><codeclass="descname">write</code><spanclass="sig-paren">(</span><em>data</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#NetscriptPort.write"title="Permalink to this definition">¶</a></dt>
<li><strong>data</strong> -- Data to write to the port</li>
</ul>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><pclass="first last">If the port is full, the item that is removed from the port is returned.
Otherwise, null is returned.</p>
</td>
</tr>
</tbody>
</table>
<p>Writes <cite>data</cite> to the port. Works the same as the Netscript function <cite>write</cite>.</p>
</dd></dl>
<dlclass="method">
<dtid="NetscriptPort.tryWrite">
<codeclass="descclassname">NetscriptPort.</code><codeclass="descname">tryWrite</code><spanclass="sig-paren">(</span><em>data</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#NetscriptPort.tryWrite"title="Permalink to this definition">¶</a></dt>
<li><strong>data</strong> -- Data to try to write to the port</li>
</ul>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><pclass="first last">True if the data is successfully written to the port, and false otherwise.</p>
</td>
</tr>
</tbody>
</table>
<p>Attempts to write <cite>data</cite> to the Netscript port. If the port is full, the data will
not be written. Otherwise, the data will be written normally.</p>
</dd></dl>
<dlclass="method">
<dtid="NetscriptPort.full">
<codeclass="descclassname">NetscriptPort.</code><codeclass="descname">full</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#NetscriptPort.full"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Returns:</th><tdclass="field-body">True if the Netscript Port is full, and false otherwise</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="method">
<dtid="NetscriptPort.empty">
<codeclass="descclassname">NetscriptPort.</code><codeclass="descname">empty</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#NetscriptPort.empty"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Returns:</th><tdclass="field-body">True if the Netscript Port is empty, and false otherwise</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="method">
<dtid="NetscriptPort.clear">
<codeclass="descclassname">NetscriptPort.</code><codeclass="descname">clear</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#NetscriptPort.clear"title="Permalink to this definition">¶</a></dt>
<dd><p>Clears all data from the port. Works the same as the Netscript function <cite>clear</cite></p>
</dd></dl>
<dlclass="attribute">
<dtid="NetscriptPort.data">
<codeclass="descclassname">NetscriptPort.</code><codeclass="descname">data</code><aclass="headerlink"href="#NetscriptPort.data"title="Permalink to this definition">¶</a></dt>
<dd><p>The Netscript port underlying data structure, which is just a Javascript array. All
valid Javascript Array methods can be called on this.</p>
<h2>Comments<aclass="headerlink"href="#comments"title="Permalink to this headline">¶</a></h2>
<p>Netscript supports comments using the same syntax as <aclass="reference external"href="https://www.w3schools.com/js/js_comments.asp">Javascript comments</a>.
Comments are not evaluated as code, and can be used to document and/or explain code:</p>
<spanclass="nb">print</span><spanclass="p">(</span><spanclass="s2">"This code will actually get executed"</span><spanclass="p">);</span>
</pre></div>
</div>
</div>
<divclass="section"id="javascript-math-module">
<h2>Javascript Math Module<aclass="headerlink"href="#javascript-math-module"title="Permalink to this headline">¶</a></h2>
<p>The <aclass="reference external"href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math">Javascript Math Module</a> is
supported in Netscript and is used in the same way:</p>
<h2>Javascript Date Module<aclass="headerlink"href="#javascript-date-module"title="Permalink to this headline">¶</a></h2>
<p>The <aclass="reference external"href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date">Javascript Date Module</a> is supported in Netscript.
However, since the 'new' operator does not work in Netscript, only the Date module's static functions can be used:</p>
<h2>Javascript Number Module<aclass="headerlink"href="#javascript-number-module"title="Permalink to this headline">¶</a></h2>
<p>The <aclass="reference external"href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">Javascript Number module</a> is supported in Netscript.</p>