bitburner-src/markdown/bitburner.ns.read.md

35 lines
1.1 KiB
Markdown
Raw Normal View History

2021-10-30 18:34:14 +02:00
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [read](./bitburner.ns.read.md)
## NS.read() method
This function is used to read data from a port or from a text file (.txt).
If the argument port/fn is a number between 1 and 20, then it specifies a port and it will read data from that port. A port is a serialized queue. This function will remove the first element from that queue and return it. If the queue is empty, then the string “NULL PORT DATA” will be returned.
If the argument port/fn is a string, then it specifies the name of a text file (.txt) and this function will return the data in the specified text file. If the text file does not exist, an empty string will be returned.
<b>Signature:</b>
```typescript
2021-11-03 05:33:14 +01:00
read(handle: string | number): string | number | object;
2021-10-30 18:34:14 +02:00
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
2021-11-03 05:33:14 +01:00
| handle | string \| number | Port or text file to read from. |
2021-10-30 18:34:14 +02:00
<b>Returns:</b>
string \| number \| object
Data in the specified text file or port.
## Remarks
2021-10-30 21:46:34 +02:00
RAM cost: 1 GB
2021-10-30 18:34:14 +02:00