Read - DFBaseTextEdit
Reads text file and displays it in the control
Type: Procedure
Parameters
| Parameter | Type | Description |
|---|---|---|
| sFileName | String | The name (and path to) of the text file to read |
Syntax
Procedure Read String sFileName
Call Example
Send Read sFileName
Description
Reads a text file and displays it in the control. Calling read will replace all text currently in the control with the contents of sFileName. If the file cannot be not opened, the LastErrorCode function will return ERR_RE_CANNOT_OPEN_FILE and the control's content will be unchanged.
Sample
This sample reads a file named MyFile.txt and displays its content in the oTextEdit1 control.
Procedure ReadFile
String sFileName
Move "MyFile.txt" to sFileName
Send Read of oTextEdit1 sFileName
End_Procedure
Sample
This sample allows the user to select a file using an OpenDialog control, and then displays the content of the document the user has selected in the oTextEdit1 control. This sample assumes that an OpenDialog control named oOpenDialog1 exists in your code.
Procedure ReadFile
String sFileName
Boolean bOk
Set Filter_String of oOpenDialog1 to 'Text Files (*.txt)|*.txt|All Files (*.*)|*.*'
Get Show_Dialog of oOpenDialog1 to bOk
If (bOk = True) begin
Get File_Name of oOpenDialog1 to sFileName
Send Read of oTextEdit1 sFileName
End
End_Procedure