Type/to search
Built-in Functions
Global
Version
IsVirtual
GetOS
GetPid
GetMeta
Sleep
Unix
UnixNano
_D
GetCommand
GetLastError
SetErrorFilter
_N
_C
_Cross
JSON.parse
JSON.stringify
Encode
MD5
UUID
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
Overlap Studies
Momentum Indicators
Volume Indicators
Volatility Indicators
Cycle Indicators
Price Transform
Statistic Functions
Math Transform
Math Operators
Pattern Recognition
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Read the entire file content at once.

fgets(filename)

Examples

Read the content of a configuration file.

javascript
function main() { // create and write the file first // let fileHandle = os.open("config.json", "w+") // let objJson = {"name": "tom", "age": 18} // fileHandle.write(JSON.stringify(objJson)) // fileHandle.close() let content = os.fgets("config.json") Log("Config content:", content) // Output: Config content: {"name":"tom","age":18} }

Returns

TypeDescription

string

Returns the complete content of the file.

Arguments

NameTypeRequiredDescription

filename

string

Yes

File path, including the filename to be read.

See Also

Remarks

Suitable for quick reading of small files, loading the entire file content into memory at once.

If the file does not exist, the fgets() function throws an exception.