Difference between revisions of "BINOPEN()"
From Lianjapedia
Yvonne.milne (Talk | contribs) m (1 revision) |
Yvonne.milne (Talk | contribs) |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Function to open a binary file | Function to open a binary file | ||
− | |||
==Syntax== | ==Syntax== | ||
− | BINOPEN( | + | BINOPEN(<expC>,<expN>) |
− | + | ||
==See Also== | ==See Also== | ||
− | [[BIN2I()]], [[BIN2L()]], [[BIN2W()]], [[BINCLOSE()]], [[BINCREATE()]], [[BINREAD()]], [[BINSEEK()]], [[BINWRITE()]], [[FCLOSE()]], [[FOPEN()]], [[I2BIN()]], [[L2BIN()]] | + | [[BIN2I()]], [[BIN2L()]], [[BIN2W()]], [[BINCLOSE()]], [[BINCREATE()]], [[BINFILETOSTR()]], [[BINREAD()]], [[BINSEEK()]], [[BINSTRTOFILE()]], [[BINWRITE()]], [[FCLOSE()]], [[FOPEN()]], [[I2BIN()]], [[L2BIN()]] |
− | + | ||
==Description== | ==Description== | ||
The BINOPEN() function opens an existing binary file. The <expC> is the name of the file to be opened. The <expN> is the mode in which the file will be opened. The open mode options are: | The BINOPEN() function opens an existing binary file. The <expC> is the name of the file to be opened. The <expN> is the mode in which the file will be opened. The open mode options are: | ||
− | + | {| class="wikitable" width="100%" | |
− | {| class="wikitable" | + | |
!Mode||Description | !Mode||Description | ||
|- | |- | ||
Line 25: | Line 21: | ||
|- | |- | ||
|} | |} | ||
− | |||
BINOPEN() returns a file descriptor if it has opened the file successfully, or a -1 if unsuccessful. Since the file descriptor is used to identify open binary files, the BINOPEN() return value should always be assigned to a memory variable. The binary conversion functions may be used in conjunction with the binary file functions. | BINOPEN() returns a file descriptor if it has opened the file successfully, or a -1 if unsuccessful. Since the file descriptor is used to identify open binary files, the BINOPEN() return value should always be assigned to a memory variable. The binary conversion functions may be used in conjunction with the binary file functions. | ||
− | |||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | fd = binopen("file.obj") | + | fd = binopen("file.obj", 2) |
count = binread(fd, 4) | count = binread(fd, 4) | ||
count = bin2l(count) | count = bin2l(count) | ||
Line 41: | Line 35: | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | [[Category: | + | [[Category:Object Storage Functions]] |
− | [[Category: | + | [[Category:Lianja VFP Extensions]] |
+ | [[Category:VFP Function Extensions]] |
Latest revision as of 07:59, 4 March 2019
Contents
Purpose
Function to open a binary file
Syntax
BINOPEN(<expC>,<expN>)
See Also
BIN2I(), BIN2L(), BIN2W(), BINCLOSE(), BINCREATE(), BINFILETOSTR(), BINREAD(), BINSEEK(), BINSTRTOFILE(), BINWRITE(), FCLOSE(), FOPEN(), I2BIN(), L2BIN()
Description
The BINOPEN() function opens an existing binary file. The <expC> is the name of the file to be opened. The <expN> is the mode in which the file will be opened. The open mode options are:
Mode | Description |
---|---|
0 | Read-only |
1 | Write-only |
2 | Read/write |
BINOPEN() returns a file descriptor if it has opened the file successfully, or a -1 if unsuccessful. Since the file descriptor is used to identify open binary files, the BINOPEN() return value should always be assigned to a memory variable. The binary conversion functions may be used in conjunction with the binary file functions.
Example
fd = binopen("file.obj", 2) count = binread(fd, 4) count = bin2l(count) count = l2bin(count + 1) binseek(fd, 512, 0) binwrite(fd, count) binclose(fd)