Delphi AssignFile Usage

Source: Internet
Author: User

1. text File New and read use

Put a button on the form and click Enter

Procedure Tform1.button1click (Sender:tobject);
Var
Bat:textfile;
Begin
AssignFile (Bat, ' c:\123.txt '); Create and open a file
Rewrite (BAT); The Rewrite process can create a new file and open it, using the Reset
Text files are read-only, and text files opened with rewrite and append can only be written to
Writeln (Bat, ' 1111111111111111 '); Write Data
CloseFile (BAT); Close File
End

This creates a new 123.txt text file on the C drive and writes 1111111111111111 of the data.

2. Reading a text file

Procedure Tform1.button1click (Sender:tobject);
Var
Bat:textfile;
s:string;
Begin
AssignFile (Bat, ' c:\123123.bat ');
Reset (BAT);
READLN (bat,s);
Memo1. Lines.add (s);
CloseFile (BAT);
End

Procedure or

function
Description
Append
Open the existing text file (to append text to the file).

AssignFile
Specifies the filename of the external file to a file variable.

Blockread
Reads one or more records from an untyped file.

Blockwrite
Writes one or more records to an untyped file.

ChDir
Changes the current directory.

CloseFile
Close the open file.

Eof
Returns the file end (end-of-file) state of the file.

Eoln
Returns the line end (end-of-line) state of a text file.

Erase
Delete the external file.

Filepos
Returns the current location of a type file or untyped file.

FileSize
Returns the current size of the file, not for a text file.

Flush
Refreshes the buffer of the output text file.

Getdir
Returns the current directory for the specified drive.

IOResult
Returns an integer value that represents the execution state of the last I/O function.

Mkdir
Create subdirectories.

Read
Reads one or more values from a file to one or more variables.

Readln
Performs a read operation in a text file and jumps to the beginning of the next line.

Rename
Rename the external file.

Reset
Open the file that exists.

Rewrite
Create and open a new file.

RmDir
Deletes an empty subdirectory.

Seek
Moves from the current position of a type file or untyped file to the specified component, not to a text file.

Seekeof
Returns the file end (end-of-file) state of a text file.

Seekeoln
Returns the line end (end-of-line) state of a text file.

Settextbuf
Specifies the input/output (I/O) buffer to a text file.

Truncate
Truncates a file at the current location of a type file or untyped file.

Write
Writes one or more values to a file.

Writeln
Performs a write operation in a text file and then writes a line end (End-of-line) tag.
Function description

Stralloc
Assigning a character buffer of a given dimension to a heap

Strbufsize
Returns the size of the character buffer allocated with Stralloc or strnew

StrCat
Connect two strings

StrComp
Comparison of two strings

Strcopy
Copy a string

Strdispose
Releasing a character buffer allocated with Stralloc or strnew

Strecopy
Copy a string and return a tail pointer

Strend
Returns the end of the string pointer

Strfmt
Format one or more values into a string

Stricomp
Comparison of two strings (case insensitive)

Strlcat
Connect two strings (maximum length for a given result string)

Strlcomp
Comparison of two strings (given maximum length)

Strlcopy
Copies the string until the maximum length given

StrLen
Returns the length of a string

Strlfmt
Format one or more values into a string (the maximum length of a given string)

Strlicomp
Comparison of two strings (given maximum length and case insensitive)

Strlower
Convert a string to lowercase

Strmove
Move word converts sequential blocks from one string to another

Strnew
allocating strings in the heap

Strpcopy
Copy a Pascal string to an empty end string

Strplcopy
Copy a Pascal string to an empty end string (given maximum length)

Strpos
Returns the position pointer of the first occurrence of a given substring in a string

Strrscan
Returns the position pointer of the last occurrence of a given character in a string

Strscan
Returns the position pointer of the first occurrence of a given character in a string

Strupper
Convert a string to uppercase

Delphi AssignFile Usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.