The File component empowers the NewBASIC author with the means to view and manipulate files on a hard disk with a set of input/output actions.
FileDate record
FD_YEAR:7, ; year since 1980
FD_MONTH:4 ; month (1 - 12)
FD_DAY:5, ; day of month (1 - 31)
FileDate end
FileTime record
FT_HOUR:5, ; hour (24-hour clock)
FT_MIN:6, ; minute
FT_2SEC:5, ; 2-second increments (0-29 corresponding to 0-58)
FileTime end
const ERROR_UNSUPPORTED_FUNCTION 1
const ERROR_FILE_NOT_FOUND 2
const ERROR_PATH_NOT_FOUND 3
const ERROR_TOO_MANY_OPEN_FILES 4
const ERROR_ACCESS_DENIED 5
const ERROR_INSUFFICIENT_MEMORY 8
const ERROR_INVALID_VOLUME 15
const ERROR_IS_CURRENT_DIRECTORY 16
const ERROR_DIFFERENT_DEVICE 17
const ERROR_NO_MORE_FILES 18
const ERROR_WRITE_PROTECTED 19
const ERROR_UNKNOWN_VOLUME 20
const ERROR_DRIVE_NOT_READY 21
const ERROR_CRC_ERROR 23
const ERROR_SEEK_ERROR 25
const ERROR_UNKNOWN_MEDIA 26
const ERROR_SECTOR_NOT_FOUND 27
const ERROR_WRITE_FAULT 29
const ERROR_READ_FAULT 30
const ERROR_GENERAL_FAILURE 31
const ERROR_SHARING_VIOLATION 32
const ERROR_ALREADY_LOCKED 33
const ERROR_SHARING_OVERFLOW 36
const ERROR_NETWORK_CONNECTION_BROKEN 55
const ERROR_NETWORK_ACCESS_DENIED 65
const ERROR_NETWORK_NOT_LOGGED_IN 78
const ERROR_SHORT_READ_WRITE 128
const ERROR_INVALID_LONGNAME 129
const ERROR_FILE_EXISTS 130
const ERROR_DOS_EXEC_IN_PROGRESS 131
const ERROR_FILE_IN_USE 132
const ERROR_ARGS_TOO_LONG 133
const ERROR_DISK_UNAVAILABLE 134
const ERROR_DISK_STALE 135
const ERROR_FILE_FORMAT_MISMATCH 136
const ERROR_CANNOT_MAP_NAME 137
const ERROR_DIRECTORY_NOT_EMPTY 138
const ERROR_ATTR_NOT_SUPPORTED 139
const ERROR_ATTR_NOT_FOUND 140
const ERROR_ATTR_SIZE_MISMATCH 141
const ERROR_ATTR_CANNOT_BE_SET 142
const ERROR_CANNOT_MOVE_DIRECTORY 143
const ERROR_PATH_TOO_LONG 144
const ERROR_ARGS_INVALID 145
const ERROR_CANNOT_FIND_COMMAND_INTERPRETER 146
const ERROR_NO_TASK_DRIVER_LOADED 147
const ERROR_LINK_ENCOUNTERED 148
const ERROR_NOT_A_LINK 149
const ERROR_TOO_MANY_LINKS 150
None.
open( ) as integer
This action opens the current file for access. Upon encountering an error, open( ) returns a FileError.
close( ) as integer
This action closes the current file. Upon encountering an error, close( ) returns a FileError.
delete( ) as integer
This action deletes the current file. Upon encountering an error, delete( ) returns a FileError.
create( ) as integer
This action creates a new file under with the current name. Upon encountering an error, create( ) returns a FileError.
commit( ) as integer
This action commits changes made to the current file without closing it.
write(buffer as string, numchars as integer) as integer
Ths action writes numchars characters of string buffer to the current file.
read(N as integer) as integer
This action returns the string of length N starting at the current position in the current file.
peek( ) as integer
This action returns the byte at the current position in the file as an integer. The current position is read with tell( ), set with go(N), and changed with seek(N).
Example: (read an entire file)
dim file as component
dim outputText as component
outputText = MakeComponent("text","top")
file = MakeComponent("file","top")
file.name = "test.txt"
file.open( )
while file.goes( )
outputText.AppendString(Chr(file.peek( )))
loop
file.close( )
poke(character as integer) as integer
This action writes the passed character to the current position in the file.
go(N as integer) as integer
This action moves the current file position to N (or from end -N.)
seek(N as integer) as integer
This action offsets the current file position by N.
tell( ) as long
This action returns the current file position offset as a long.
ends( ) as integer
This action returns true if the end of file (EOF) has been reached.
goes( ) as integer
This action returns true if the end of file (EOF) has not been reached yet.
move(path as string) as integer
This action moves the physical presence of the current file to the given path string.
copy(path as string) as integer
This action copies the entire file to the passed path.
mkdir(s as string) as integer
This action creates the directory given by string s.
rmdir(s as string) as integer
This action removes the directory described by string s.
chdir(s as string) as integer
This action changes the current directory path to that specified in string s.
pushd( ) as integer
This action pushes the current directory onto the file stack.
popd( ) as integer
This action pops the next directory from the file stack and makes it the current one.
dateline(N as integer) as integer
This action return a time stamp string of type N format where N is one of:
const DTF_LONG 1
const DTF_LONG_CONDENSED 2
const DTF_LONG_NO_WEEKDAY 3
const DTF_LONG_NO_WEEKDAY_CONDENSED 4
const DTF_SHORT 5
const DTF_ZERO_PADDED_SHORT 6
const DTF_MD_LONG 7
const DTF_MD_LONG_NO_WEEKDAY 8
const DTF_MD_SHORT 9
const DTF_MY_LONG 10
const DTF_MY_SHORT 11
const DTF_YEAR 12
const DTF_MONTH 13
const DTF_DAY 14
const DTF_WEEKDAY 15
const DTF_HMS 16
const DTF_HM 17
const DTF_H 18
const DTF_MS 19
const DTF_HMS_24HOUR 20
const DTF_HM_24HOUR 21
The FileBuffer component provides an alternate caching interface to the File Component based on the ANSI-C standard. This component is provided for compatibility. FileBuffer operations use an internally stored "offset" position for file operations.
None.
This action returns the byte at the current (internally stored) position as an integer
This action writes the given integer character as a byte at the current (internally stored) position.
This action returns the string of characters stored from the current position to the passed length.
This action writes length characters from the string passed in buffer to the parent file.
This action returns a 16-bit word length integer at the current position.
This action writes the passed 16-bit word length integer value to the parent file.
The FileSelector component provides a user interface component to grant the user access to select a file from the file system. This component is often used in conjunction with Open and Save menu events.
None.
None.
The Floater acts as a "floating" window--like a dialog box, it clips graphics so that it obscures whatever it is drawn over.
This is a "primitive" component type; it doesn't do much on its own. It's been left plain so that you may customize its behavior.
Standard Properties: borderBottom, borderLeft, borderRight, borderTop, children, class, height, left, numChildren, parent, proto, sizeHControl, sizeVControl, tile, tileLayout, tileSpacing, tileHAlign, tileHInset, tileVInset, tileVAlign, top, version, visible, width.
_aboutToClose( self AS floater )
This event is generated when the Floater is about to go away (when visible has changed from one to zero).
_aboutToOpen( self AS floater )
This event is generated when the Floater is about to appear (when visible has changed from zero to one).
_activeChanged( self As floater, gained AS integer )
This event is generated when a different window becomes an active window: this floater has just become (or just ceased to be) the active non-modal, modal, or system-modal window.
BringToFront( )
This action causes the floater to come to the front, appearing on top of other floaters and dialogs with the same or lesser priority. This may result in the floater becoming the active window.
Nothing.
RedoGeometry( )
This action causes the floater to re-compute the positions of all its children, their children, etc.
Nothing.
The Form acts as a full-sized window holding UI gadgetry. On small devices, Forms will typically fill up the full screen.
The following looks are available:
Standard Properties: borderBottom, borderLeft, borderRight, borderTop, caption, children, class, enabled, height, left, look, numChildren, parent, proto, sizeHControl, sizeVControl, tile, tileHAlign, tileHInset, tileLayout, tileSpacing, tileVAlign, tileVInset, top, version, visible, width.
_aboutToClose( self AS form )
This event is generated when the Form is about to go away (when visible has changed from one to zero).
_aboutToOpen( self AS form )
This event is generated when the Form is about to appear (when visible has changed from zero to one).
_activeChanged( self AS form, gained AS integer )
This event is generated when the form becomes the active form or stops being the active form.
BringToFront( )
This action causes the Form, if it is visible, to come to the front of the screen.
Nothing.