Back to index A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Other

Alphabetic catalog of Language elements V

vector

vector creates a vector from its arguments.

Category Primitive procedure
Format (vector obj1 ...)
Parameters
objiany object
Description vector gathers its arguments into a vector and returns it.
R4RS Compliance Full
Examples
(vector 'a -3 "hello") => #(a -3 "hello")
(vector '()) => #(())
(vector) => #()

vector->list

vector->list converts a vector to a list.

Category Native procedure
Format (vector->list vec)
Parameters
veca vector
Description vector->list returns a newly allocated list of the elements of the vector vec.
R4RS Compliance Full
Examples
(vector->list #(foo bar)) => (foo bar)
(vector->list (make-vector 10 42)) => (42 42 42 42 42 42 42 42 42 42)

vector-length

vector-length counts the elements in a vector.

Category Primitive procedure
Format (vector-length vec)
Parameters
veca vector
Description vector-length returns the number of elements in vec.
R4RS Compliance Full
Examples
(vector-length #(foo bar)) => 2
(vector-length (make-vector 97 #n)) => 97
(vector-length (vector)) => 0

vector-ref

vector-ref returns an element of a vector by index.

Category Primitive procedure
Format (vector-ref vec index)
Parameters
veca vector
indexan integer
Description vector-ref returns the indexth element of vec. The index of the first element is 0, and the index of the last element is the length of vec minus one.
R4RS Compliance Full
Examples
(vector-ref #(foo bar) 1) => bar
(vector-ref #(0 1 2 3) 5) => error

vector-set!

vector-set! modifies an element in a vector.

Category Primitive procedure
Format (vector-set! vec index obj)
Parameters
veca vector
indexan integer
objany object
Description vector-set! replaces the indexth element of vec by obj. The modified vector is returned. The index of the first element is 0, and the index of the last element is the length of vec minus one. It's no error to modify a constant vector in LispMe, as all values are heap-allocated and constant vectors are never shared, so the examples are valid.
R4RS Compliance Full
Examples
(vector-set! #(1 2 3) 2 #\r) => #(1 2 #\r)
(vector-set! (make-vector 10 'jamaica) -4 'rum) => error

vector?

vector? recognizes vectors.

Category Primitive procedure
Format (vector? obj)
Parameters
objany object
Description vector? returns #t for a vector and #f for any other object.
R4RS Compliance Full
Examples
(vector? '(1 2 3)) => #f
(vector? '#(1 2 3)) => #t
(vector? 'x) => #f

vfs-close

vfs-close closes an open file.

Category Native procedure
Format (vfs-close fileref)
Parameters
filerefa reference to an open file
Description vfs-close closes an open file or directory specified by fileref, which must be a file reference created by vfs-open.

If the file has been closed successfully, #t is returned, otherwise #f.

R4RS Compliance LispMe extension
Examples
(vfs-close fref) => #t
Assuming fref is a valid file reference.

vfs-create-dir

vfs-create-dir creates a new directory.

Category Native procedure
Format (vfs-create-dir volref pathname)
Parameters
volrefa small integer
pathnamea string
Description vfs-create-dir creates a new empty directory named pathname in the VFS volume volref. All parts of the path except the last component must already exist before.

If the directory has been created successfully, #t is returned, otherwise #f.

R4RS Compliance LispMe extension
Examples
(vfs-create-dir 4 "palm/MyToyDir") => #t

vfs-delete

vfs-delete deletes a file or directory.

Category Native procedure
Format (vfs-delete volref pathname)
Parameters
volrefa small integer
pathnamea string
Description vfs-delete deletes the file or directory specified by pathname from the VFS volume volref. The full pathname must be given, since VFS doesn't support the concept of a current directory.

A file must be closed to be deleted. When deleting a directory, it must be empty. If the file has been deleted successfully, #t is returned, otherwise #f.

R4RS Compliance LispMe extension
Examples
(vfs-delete 4 "palm/programs") => #f since directory is not empty

vfs-dir

vfs-dir reads the directory of a VFS volume.

Category Native procedure
Format (vfs-dir volref directory)
Parameters
volrefa small integer
directorya string
Description vfs-dir retrieves the files in directory of the VFS volume volref as a list of file names (strings). The root directory of a volume is specified by an empty directory name, paths are separated by forward slashes. All file names in the returned list omit the path component.

If any error occurred, #f is returned.

R4RS Compliance LispMe extension
Examples
(vfs-dir 4 "") => ("PALM" "AUDIO" "WebPro" "DCIM")
(vfs-dir 4 "palm/programs") => ("VFSMark" "DXTG")

vfs-eof?

vfs-eof? gets the end-of-file status of an open file.

Category Native procedure
Format (vfs-eof? fileref)
Parameters
filerefa reference to an open file
Description vfs-eof? gets the end-of-file status of the file specified by fileref, which must be a file reference created by vfs-open.

If the file is valid and is the file pointer is at the end, #t is returned, #f otherwise.

R4RS Compliance LispMe extension
Examples
(vfs-eof? fref) => #f
Assuming fref is a valid file reference.

vfs-get-attr

vfs-get-attr reads the attributes of an open file.

Category Native procedure
Format (vfs-get-attr fileref)
Parameters
filerefa reference to an open file
Description vfs-get-attr reads the attributes of an open file or directory specified by fileref, which must be a file reference created by vfs-open. The attributes are returned as an integer, which is in fact a disjunction of the following bit flags:
ConstantValueDescription
vfsFileAttrReadOnly #x01 Read-only file or dir
vfsFileAttrHidden #x02 Hidden file or dir
vfsFileAttrSystem #x04 System file or dir
vfsFileAttrVolumeLabel #x08 Volume label
vfsFileAttrDirectory #x10 This is a directory
vfsFileAttrArchive #x20 Archived file or dir
vfsFileAttrLink #x40 Link to another file or dir

Please note that not all attributes may be supported on a specific file system.

If any error occurred, #f is returned.

R4RS Compliance LispMe extension
Examples
(vfs-get-attr fref) => 33 (read-only and archived)
Assuming fref is a valid file reference.

vfs-get-ts

vfs-get-ts reads the timestamps of an open file.

Category Native procedure
Format (vfs-get-ts fileref which)
Parameters
filerefa reference to an open file
whicha small integer
Description vfs-get-ts reads a timestamp of an open file or directory specified by fileref, which must be a file reference created by vfs-open. Which timestamp is returned is determined by which according to the following table:
ConstantValueDescription
vfsFileDateCreated 1 File creation timestamp
vfsFileDateModified 2 File last modified timestamp
vfsFileDateAccessed 3 File last access timestamp

Please note that not all timestamps may be supported on a specific file system.

If any error occurred, #f is returned.

R4RS Compliance LispMe extension
Examples
(vfs-get-ts fref 2) => [ts 2003-12-05-01-09-02]
Assuming fref is a valid file reference.

vfs-open

vfs-open opens a (raw) file or directory.

Category Native procedure
Format (vfs-open volref pathname mode)
Parameters
volrefa small integer
pathnamea string
modea small integer
Description vfs-open opens the file or directory named pathname in the VFS volume volref using the open mode mode. The open mode is a bit flag array assembled of these constants
ConstantValueDescription
vfsModeExclusive #x01 Don't let others open this file
vfsModeRead #x02 Open for read access
vfsModeWrite #x05 Open for write access. Note that vfsModeExclusive must be set, too.
vfsModeReadWrite #x07 Open for read/write access. Note that vfsModeExclusive must be set, too.
vfsModeCreate #x08 Create the file if it doesn't exist yet.
vfsModeTruncate #x10 Truncate the file to 0 bytes after opening.
vfsModeLeaveOpen #x20 Leave the file open after quitting. Not supported by LispMe, files are always closed and re-opened automatically
The open mode is ignored when opening a directory. If the file has been opened successfully, a file reference (foreign type) is returned, otherwise #f.

If you want to open a file to be used with Scheme's port mechanism, use vfs-open-input or vfs-open-output instead.

R4RS Compliance LispMe extension
Examples
(vfs-open 4 "palm/test" #x1f) => [file "palm/test"]
The file has been created or truncated and been opened for both read and write access.

vfs-open-input

vfs-open-input opens a file for input.

Category Native procedure
Format (vfs-open-input volref pathname)
Parameters
volrefa small integer
pathnamea string
Description vfs-open-input opens the file named pathname in the VFS volume volref for input and creates a buffered Scheme input port on top of it.

If any error occurred, #f is returned. See also vfs-open for opening raw files.

R4RS Compliance LispMe extension
Examples
(vfs-open-input 4 "palm/test") => [inport 10 @0 [file "palm/test"]]

vfs-open-output

vfs-open-output opens a file for output.

Category Native procedure
Format (vfs-open-output volref pathname)
Parameters
volrefa small integer
pathnamea string
Description vfs-open-input opens the file named pathname in the VFS volume volref for output and creates a buffered Scheme output port on top of it. An existing file with the same name is overwritten.

If any error occurred, #f is returned. See also vfs-open for opening raw files.

R4RS Compliance LispMe extension
Examples
(vfs-open-output 4 "palm/test") => [outport 10 @0 [file "palm/test"]]

vfs-read

vfs-read reads from an open file.

Category Native procedure
Format (vfs-read fileref len)
Parameters
filerefa reference to an open file
lenan integer
Description vfs-read reads a block of data from an open file specified by fileref, which must be a file reference created by vfs-open. A maximum of len bytes is read (or fewer, if EOF is reached) and returned as a string. Thus the block size is limited by the max. string size, which is about 64k.

If any error occurred, #f is returned.

R4RS Compliance LispMe extension
Examples
(vfs-read fref 10) => "This is an"
Assuming fref is a valid file reference.

vfs-ref?

vfs-ref? recognizes file references.

Category Primitive procedure
Format (vfs-ref? obj)
Parameters
objany object
Description vfs-ref? returns #t for a file reference created by vfs-open and #f for any other object.
R4RS Compliance LispMe extension
Examples
(vfs-ref? "foo") => #f
(vfs-ref? (vfs-open 4 "foo" #x02)) => #t

vfs-rename

vfs-rename renames a file or directory.

Category Native procedure
Format (vfs-rename volref pathname newname)
Parameters
volrefa small integer
pathnamea string
newnamea string
Description vfs-rename renames the file or directory specified by pathname in the VFS volume volref to newname. The full pathname must be given, since VFS doesn't support the concept of a current directory.

A file must be closed to be renamed. The new name must be the name component only and may not contain a path. Therefore it's not possible to move a file with this procedure.

If the file has been renamed successfully, #t is returned, otherwise #f.

R4RS Compliance LispMe extension
Examples
(vfs-rename 4 "audio/a_song.mp3" "other.mp3") => #t

vfs-seek

vfs-seek repositions the file pointer.

Category Native procedure
Format (vfs-seek fileref origin offset)
Parameters
filerefa reference to an open file
origina small integer
offsetan integer
Description vfs-seek sets the position of the file pointer within an open filespecified by fileref, which must be a file reference created by vfs-open. Origin determines the origin from which the offset (in bytes) is counted:
ConstantValueDescription
vfsOriginBeginning 0 The beginning of the file, only non-negative offsets allowed
vfsOriginCurrent 1 The current file pointer position
vfsOriginEnd 2 The end of the file, only negative offsets allowed

If any error occurred, #f is returned, #t otherwise.

R4RS Compliance LispMe extension
Examples
(vfs-seek fref 2 -1) => #t (positioned at the last byte)
Assuming fref is a valid file reference.

vfs-set-attr

vfs-set-attr sets the attributes of an open file.

Category Native procedure
Format (vfs-set-attr fileref attr)
Parameters
filerefa reference to an open file
attra small integer
Description vfs-set-attr sets the attributes of an open file or directory specified by fileref, which must be a file reference created by vfs-open. The attributes attr are described here, but please note that vfsFileAttrVolumeLabel and vfsFileAttrDirectory may not be changed by this procedure. Also note that the file must have been opened for writing to be able to change attributes.

If the attributes have been set successfully, #t is returned, otherwise #f.

R4RS Compliance LispMe extension
Examples
(vfs-set-attr fref 32) => #t (read-only flag reset, see here)
Assuming fref is a valid file reference.

vfs-set-ts

vfs-set-ts sets the timestamps of an open file.

Category Native procedure
Format (vfs-set-ts fileref which ts)
Parameters
filerefa reference to an open file
whicha small integer
tsa timestamp
Description vfs-set-ts sets a timestamp of an open file or directory specified by fileref, which must be a file reference created by vfs-open. The timestamp to be set is specified by which (see here for allowed values).

If the attributes have been set successfully, #t is returned, otherwise #f. Please note that the file must have been opened for writing to be able to change timestamps.

If the timestamp has been set successfully, #t is returned, otherwise #f.

R4RS Compliance LispMe extension
Examples
(vfs-set-ts fref 3 (current-ts)) => #t
Assuming fref is a valid file reference.

vfs-size

vfs-size gets the size of an open file.

Category Native procedure
Format (vfs-size fileref)
Parameters
filerefa reference to an open file
Description vfs-size gets the current size of the file specified by fileref, which must be a file reference created by vfs-open.

If any error occurred, #f is returned.

R4RS Compliance LispMe extension
Examples
(vfs-size fref) => 12030
Assuming fref is a valid file reference.

vfs-supported?

vfs-supported? indicates, if VFS is supported.

Category Native procedure
Format (vfs-supported?)
Parameters none
Description vfs-supported? returns #t if the Palm Virtual File System API is supported on this device (requires at least PalmOS4) and #f otherwise.
R4RS Compliance LispMe extension
Examples
(vfs-supported?) => #t on a modern Palm :-)

vfs-tell

vfs-tell tells the position in an open file.

Category Native procedure
Format (vfs-tell fileref)
Parameters
filerefa reference to an open file
Description vfs-tell gets the current position of the file pointer within an open file specified by fileref, which must be a file reference created by vfs-open.

If any error occurred, #f is returned.

R4RS Compliance LispMe extension
Examples
(vfs-tell fref) => 4711
Assuming fref is a valid file reference.

vfs-vol-get-label

vfs-vol-get-label returns the label of a VFS volume.

Category Native procedure
Format (vfs-vol-get-label volref)
Parameters
volrefa small integer
Description vfs-vol-get-label searches for the VFS volume volref and returns its label (name) as a string. If no VFS volume exists, #f is returned.
R4RS Compliance LispMe extension
Examples
(vfs-vol-get-label 4) => "My new SD256 card"

vfs-vol-info

vfs-vol-info retrieves general information of a VFS volume.

Category Native procedure
Format (vfs-vol-info volref)
Parameters
volrefa small integer
Description vfs-vol-info searches for the VFS volume volref and returns general information about it as a list of 7 elements:
  1. Attributes
  2. File system type
  3. File system creator
  4. Mount class
  5. Slot library reference
  6. Slot library
  7. Media type
If no VFS volume exists, #f is returned.
R4RS Compliance LispMe extension
Examples
(vfs-vol-info 4) => (1 "vfat" "fatf" "libs" 2 1 "sdig")

vfs-vol-set-label

vfs-vol-set-label sets the label of a VFS volume.

Category Native procedure
Format (vfs-vol-set-label volref label)
Parameters
volrefa small integer
labela string
Description vfs-vol-set-label searches for the VFS volume volref and sets its label (name) to label. If no VFS volume exists, #f is returned.
R4RS Compliance LispMe extension
Examples
(vfs-vol-set-label 4 "Backup") => #t

vfs-vol-size

vfs-vol-size returns the size of a VFS volume.

Category Native procedure
Format (vfs-vol-size volref)
Parameters
volrefa small integer
Description vfs-vol-size searches for the VFS volume volref and returns the number of bytes used and the total capacity in bytes as a two-element list. If no VFS volume exists, #f is returned.
R4RS Compliance LispMe extension
Examples
(vfs-vol-size 4) => (203259904 258867200) on a typical 256MB SD-card

vfs-volumes

vfs-volumes returns a list of all VFS volumes.

Category Native procedure
Format (vfs-volumes)
Parameters none
Description vfs-volumes retrieves all currently mounted VFS volumes and returns them as a list of integer reference numbers. You have to use those reference numbers in other VFS calls. Current devices have only one card slot and thus only one volume available. If no card is mounted, the list is empty. Please note that reference numbers change when a card is removed and re-inserted!
R4RS Compliance LispMe extension
Examples
(vfs-volumes) => (4)

vfs-write

vfs-write writes data to an open file.

Category Native procedure
Format (vfs-write fileref data)
Parameters
filerefa reference to an open file
dataa string
Description vfs-write writes the data block data to an open file specified by fileref, which must be a file reference created by vfs-open. The entire string is written at the current file position.

The number of bytes written is returned, or #f, if an error occurred.

R4RS Compliance LispMe extension
Examples
(vfs-write fref "nonsense") => 8
Assuming fref is a valid file reference.

Back to index A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Other