Skip to content

Direct_Input

Include: Use System\FileSystem.pkg

See Also: Close_Input, Direct_Output, Read, Read_Line, Read_Block, DFPATH, Seq_New_Channel, Seq_Release_Channel, Sequential Channels, Seqeof

Purpose

Opens a sequential input source.

Syntax

Direct_Input [Channel {ChannelNumber}] {FileName}
Direct_Input [Channel {ChannelNumber}] FILE {FileName}
Direct_Input [Channel {ChannelNumber}] DIR {FolderName}

Arguments

Channel {ChannelNumber} : Optional channel selector. Use Seq_New_Channel when opening files in application code; see Sequential Channels.

FILE : Optional file driver. When omitted, Direct_Input uses FILE.

DIR : Opens a folder for reading. Read_Line returns folder entries by name. Directory names are enclosed in brackets, and file names are returned as plain names.

{FileName} : The input file to read. Relative names can be resolved through DFPATH.

{FolderName} : The folder to list when DIR is used.

Examples

Read the first line of a file.

Handle hFile
String sLine

Get Seq_New_Channel to hFile
Direct_Input Channel hFile FILE "test1.txt"
Read_Line Channel hFile sLine
Close_Input Channel hFile
Send Seq_Release_Channel hFile

Read entries from a folder.

Handle hFile
String sName

Get Seq_New_Channel to hFile
Direct_Input Channel hFile DIR "test1"
While (not(SeqEof))
    Read_Line Channel hFile sName
Loop
Close_Input Channel hFile
Send Seq_Release_Channel hFile

Read records separated by |.

Handle hFile
String sValue

Get Seq_New_Channel to hFile
Direct_Input Channel hFile FILE "cr: 0: eol: 124: test1/test.csv"
While (not(SeqEof))
    Read_Line Channel hFile sValue
Loop
Close_Input Channel hFile
Send Seq_Release_Channel hFile

Advanced: file-name options

Place supported options before the path inside the file-name string. Options are case-insensitive and end with a colon.

Default file handling is binary-style with LF line endings in the current runtime. binary: is accepted but does not change that default. pc-text: opts into CR/LF line handling and is useful when interoperating with files that require CR/LF.

Option Behavior
pc-text: Uses CR/LF line handling.
binary: Accepted; does not change the default binary-style/LF behavior.
cr: <ascii>: Sets the character treated as carriage return.
eol: <ascii>: Sets the character treated as end of line.

Custom delimiters affect line reading. For example, cr: 0: eol: 124: reads | as the line delimiter; cr: 37: eol: 124: reads %| as the line delimiter.