Importing and exporting DataWindow data  Chapter 20: Using External Functions and Other Processing Extensions

Chapter 19: Working with Unicode

Reading and writing text or binary files

You use PowerScript text file functions to read and write text in line mode or stream mode, or to read and write binary files in stream mode.

The FileOpen function can open Unicode and ANSI files. If the file does not exist, FileOpen creates a Unicode file. The FileClose function saves the file in the format in which it was opened.

NoteReading a file into a MultiLineEdit You can use stream mode to read an entire file into a MultiLineEdit, and then write it out after it has been modified.

Understanding the position pointer

When PocketBuilder opens a file, it assigns the file a unique integer and sets the position pointer for the file to the position you specify (the beginning or end of the file). You use the integer to identify the file when you want to read the file, write to it, or close it. The position pointer defines where the next read or write will begin. PocketBuilder advances the pointer automatically after each read or write.

You can also set the position pointer with the FileSeek function.

File functions

Table 19-3 lists the built-in PowerScript functions that manipulate files.

Table 19-3: PowerScript functions that manipulate files

Function

Datatype returned

Action

FileClose

Integer

Closes the specified file

FileDelete

Boolean

Deletes the specified file

FileExists

Boolean

Determines whether the specified file exists

FileLength

Long

Obtains the length of the specified file

FileOpen

Integer

Opens the specified file

FileRead

Integer

Reads from the specified file

FileSeek

Long

Seeks to a position in the specified file

FileWrite

Integer

Writes to the specified file





Copyright © 2004. Sybase Inc. All rights reserved. Chapter 20: Using External Functions and Other Processing Extensions

View this book as PDF