Дополнительные команды AVR-DOS — различия между версиями
MiBBiM (обсуждение | вклад) (→InitFileSystem) |
MiBBiM (обсуждение | вклад) м (→См. также) |
||
(не показано 65 промежуточных версий этого же участника) | |||
Строка 1: | Строка 1: | ||
[[Категория:AVR-DOS]] | [[Категория:AVR-DOS]] | ||
− | '''Список команд AVR-DOS''' — список функций библиотеки | + | '''Список команд AVR-DOS''' — список функций библиотеки [[AVR-DOS]]. |
− | |||
− | [[AVR-DOS]]. | ||
== Диск/Директория == | == Диск/Директория == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== FileDate === | === FileDate === | ||
− | Возвращает дату создания или изменения | + | Возвращает дату создания или последнего изменения файла. |
<code>sDate = FileDate ()</code> | <code>sDate = FileDate ()</code> | ||
Строка 205: | Строка 15: | ||
|- | |- | ||
| File(String) | | File(String) | ||
− | | Имя файла в текущей директории. Если не указано, | + | | Имя файла в текущей директории<ref name="dosnames">'''8.3''': имя - 8 символов, расширение - 3 символа, разделитель(точка) - 1 символ, всего не более 12 символов</ref><ref name="dirnames">Если не указано, параметром считается последний файл, выбранный с помощью [[Основные команды AVR-DOS#Dir|DIR]]</ref> |
− | |||
− | параметром считается последний файл, выбранный с помощью | ||
− | |||
− | DIR | ||
|} | |} | ||
Пример вызова: | Пример вызова: | ||
− | <source lang="vb">Print "File demo" | + | <source lang="vb"> Print "File demo" |
Print Filelen( "josef.img") ; " length" ' length of file | Print Filelen( "josef.img") ; " length" ' length of file | ||
− | Print Filetime( "josef.img") ; " time" ' time file was | + | Print Filetime( "josef.img") ; " time" ' time file was changed |
− | |||
− | changed | ||
Print Filedate( "josef.img") ; " date" ' file date | Print Filedate( "josef.img") ; " date" ' file date | ||
</source> | </source> | ||
=== FileTime === | === FileTime === | ||
− | Возвращает время создания или изменения | + | Возвращает время создания или последнего изменения файла. |
<code>sTime = FileTime ()</code> | <code>sTime = FileTime ()</code> | ||
Строка 234: | Строка 38: | ||
|- | |- | ||
| File(String) | | File(String) | ||
− | | Имя файла в текущей директории. Если не указано, | + | | Имя файла в текущей директории<ref name="dosnames">'''8.3''': имя - 8 символов, расширение - 3 символа, разделитель(точка) - 1 символ, всего не более 12 символов</ref><ref name="dirnames">Если не указано, параметром считается последний файл, выбранный с помощью [[Основные команды AVR-DOS#Dir|DIR]]</ref> |
− | |||
− | параметром считается последний файл, выбранный с помощью | ||
− | |||
− | DIR | ||
|} | |} | ||
Пример вызова: | Пример вызова: | ||
− | <source lang="vb">Print "File demo" | + | <source lang="vb"> Print "File demo" |
Print Filelen( "josef.img") ; " length" ' length of file | Print Filelen( "josef.img") ; " length" ' length of file | ||
− | Print Filetime( "josef.img") ; " time" ' time file was | + | Print Filetime( "josef.img") ; " time" ' time file was changed |
− | |||
− | changed | ||
Print Filedate( "josef.img") ; " date" ' file date | Print Filedate( "josef.img") ; " date" ' file date | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
== Файлы == | == Файлы == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Flush === | === Flush === | ||
− | + | Скидывает кеш текущего файла на диск и обновляет информацию раздела, директории. | |
− | |||
− | |||
− | |||
− | |||
− | + | Процедура осуществляет запись всей несохраненной информации о/в файле на диск. Обычно запись на диск производится при закрытии файлового потока или переходе на другой сектор файла, однако вы можете поменять параметр [[Окружение AVR-DOS#Конфигурация файловой системы|cFATDirSaveAtEnd]], в этом случае вам придется принудительно сбрасывать изменения файла на диск. | |
− | |||
− | |||
− | |||
− | |||
<code>Flush #bFileNumber</code> | <code>Flush #bFileNumber</code> | ||
Строка 795: | Строка 61: | ||
{| class="wikitable" | {| class="wikitable" | ||
| BFileNumber(Byte) | | BFileNumber(Byte) | ||
− | | | + | | Идентификационный номер открытого файлового потока<ref name="identnumber">Принадлежит целому множеству 0..255, может быть переменной или константой. Используйте числа 1..127 для пользовательских идентификаторов. Для получения свободного идентификатора используйте функцию [[Основные команды AVR-DOS#FreeFile|FreeFile]](возвращает 128..255)</ref>. Если не указан, то изменения всех открытых файлов сбрасываются на диск. |
− | |||
− | |||
|} | |} | ||
Пример вызова: | Пример вызова: | ||
− | <source lang="vb">$include "startup.inc" | + | <source lang="vb"> $include "startup.inc" |
'open the file in BINARY mode | 'open the file in BINARY mode | ||
Строка 810: | Строка 74: | ||
Put #2 , L ' write a long | Put #2 , L ' write a long | ||
Ltemp = Loc(#2) + 1 ' get the position of the next byte | Ltemp = Loc(#2) + 1 ' get the position of the next byte | ||
− | Print Ltemp ; " LOC" ' store the location of the file | + | Print Ltemp ; " LOC" ' store the location of the file pointer |
− | |||
− | pointer | ||
Print Lof(#2) ; " length of file" | Print Lof(#2) ; " length of file" | ||
− | Print Fileattr(#2) ; " file mode" ' should be 32 for | + | Print Fileattr(#2) ; " file mode" ' should be 32 for binary |
− | |||
− | binary | ||
Put #2 , Sn ' write a single | Put #2 , Sn ' write a single | ||
Put #2 , Stxt ' write a string | Put #2 , Stxt ' write a string | ||
Строка 822: | Строка 82: | ||
Flush #2 ' flush to disk | Flush #2 ' flush to disk | ||
Close #2 | Close #2 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
=== Get === | === Get === | ||
− | Reads a byte from the hardware or software UART. Reads | + | Reads a byte from the hardware or software UART. Reads data from a file opened in BINARY mode. |
− | |||
− | data from a file opened in BINARY mode. | ||
− | GET in combination with the software/hardware UART is | + | GET in combination with the software/hardware UART is provided for compatibility with BASCOM-8051. It reads one byte. |
− | + | GET in combination with the AVR-DOS filesystem is very flexible and versatile. It works on files opened in BINARY mode and you can reads all data types. | |
− | provided for compatibility with BASCOM-8051. It reads | + | By default you only need to provide the variable name. When the variable is a byte, 1 byte wil be read. When the variable is a word or integer, 2 bytes will be read. When the variable is a long or single, 4 bytes will be read. When the variable is a string, the number of bytes that will be read is equal to the dimensioned size of the string. DIM S as string * 10 , would read 10 bytes. |
− | + | Note that when you specify the length for a string, the maximum length is 255. The maximum length for a non-string array is 65535. | |
− | one byte. | + | <source lang="vb"> Example : |
− | GET in combination with the AVR-DOS filesystem is very | + | GET #1 , var ,,2 ‘ read 2 bytes, start at current position |
− | |||
− | flexible and versatile. It works on files opened in | ||
− | |||
− | BINARY mode and you can reads all data types. | ||
− | By default you only need to provide the variable name. | ||
− | |||
− | When the variable is a byte, 1 byte wil be read. When | ||
− | |||
− | the variable is a word or integer, 2 bytes will be read. | ||
− | |||
− | When the variable is a long or single, 4 bytes will be | ||
− | |||
− | read. When the variable is a string, the number of bytes | ||
− | |||
− | that will be read is equal to the dimensioned size of | ||
− | |||
− | the string. DIM S as string * 10 , would read 10 bytes. | ||
− | Note that when you specify the length for a string, the | ||
− | |||
− | maximum length is 255. The maximum length for a | ||
− | |||
− | non-string array is 65535. | ||
− | <source lang="vb">Example : | ||
− | GET #1 , var ,,2 ‘ read 2 bytes, start at current | ||
− | |||
− | position | ||
GET #1, var , PS ‘ start at position stored in long PS | GET #1, var , PS ‘ start at position stored in long PS | ||
− | GET #1, var , PS, 2 ‘ start at position stored in long | + | GET #1, var , PS, 2 ‘ start at position stored in long PS and read 2 bytes</source> |
− | |||
− | PS and read 2 bytes</source> | ||
<code>GET #channel, var</code> | <code>GET #channel, var</code> | ||
Строка 1063: | Строка 102: | ||
{| class="wikitable" | {| class="wikitable" | ||
| #channel(...) | | #channel(...) | ||
− | | A channel number, which identifies an opened file. | + | | A channel number, which identifies an opened file. This can be a hard coded constant or a variable |
− | |||
− | This can be a hard coded constant or a variable | ||
|- | |- | ||
| Var(...) | | Var(...) | ||
− | | The variable or variable array that will be assigned | + | | The variable or variable array that will be assigned with the data from the file |
− | |||
− | with the data from the file | ||
|- | |- | ||
| Pos(...) | | Pos(...) | ||
− | | This is an optional parameter that may be used to | + | | This is an optional parameter that may be used to specify the postion where the reading must start from. This must be a long variable |
− | |||
− | specify the postion where the reading must start from. | ||
− | |||
− | This must be a long variable | ||
|- | |- | ||
| Length(...) | | Length(...) | ||
− | | This is an optional parameter that may be used to | + | | This is an optional parameter that may be used to specify how many bytes must be read from the file. |
− | |||
− | specify how many bytes must be read from the file. | ||
|} | |} | ||
Пример вызова: | Пример вызова: | ||
− | <source lang="vb">'for the binary file demo we need some variables of | + | <source lang="vb"> 'for the binary file demo we need some variables of different types |
− | + | Dim B As Byte , W As Word , L As Long , Sn As Single , Ltemp As Long | |
− | different types | ||
− | Dim B As Byte , W As Word , L As Long , Sn As Single , | ||
− | |||
− | Ltemp As Long | ||
Dim Stxt As String * 10 | Dim Stxt As String * 10 | ||
− | B = 1 : W = 50000 : L = 12345678 : Sn = 123.45 : Stxt = | + | B = 1 : W = 50000 : L = 12345678 : Sn = 123.45 : Stxt = "test" |
− | |||
− | "test" | ||
'open the file in BINARY mode | 'open the file in BINARY mode | ||
Строка 1104: | Строка 127: | ||
Put #2 , L ' write a long | Put #2 , L ' write a long | ||
Ltemp = Loc(#2) + 1 ' get the position of the next byte | Ltemp = Loc(#2) + 1 ' get the position of the next byte | ||
− | Print Ltemp ; " LOC" ' store the location of the file | + | Print Ltemp ; " LOC" ' store the location of the file pointer |
− | |||
− | pointer | ||
Print Seek(#2) ; " = LOC+1" | Print Seek(#2) ; " = LOC+1" | ||
Print Lof(#2) ; " length of file" | Print Lof(#2) ; " length of file" | ||
− | Print Fileattr(#2) ; " file mode" ' should be 32 for | + | Print Fileattr(#2) ; " file mode" ' should be 32 for binary |
− | |||
− | binary | ||
Put #2 , Sn ' write a single | Put #2 , Sn ' write a single | ||
Put #2 , Stxt ' write a string | Put #2 , Stxt ' write a string | ||
Строка 1132: | Строка 151: | ||
=== Put === | === Put === | ||
− | Writes a byte to the hardware or software UART. Writes | + | Writes a byte to the hardware or software UART. Writes data to a file opened in BINARY mode. |
− | |||
− | data to a file opened in BINARY mode. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | number of bytes that will be written is equal to the | + | PUT in combination with the software/hardware UART is provided for compatibility with BASCOM-8051. It writes one byte |
− | + | PUT in combination with the AVR-DOS filesystem is very flexible and versatile. It works on files opened in BINARY mode and you can write all data types. | |
− | dimensioned size of the string. DIM S as string * 10 , | + | By default you only need to provide the variable name. When the variable is a byte, 1 byte wil be written. When the variable is a word or integer, 2 bytes will be written. When the variable is a long or single, 4 bytes will be written. When the variable is a string, the number of bytes that will be written is equal to the dimensioned size of the string. DIM S as string * 10 , would write 10 bytes. |
− | + | Note that when you specify the length for a string, the maximum length is 255. The maximum length for a non-string array is 65535. | |
− | would write 10 bytes. | ||
− | Note that when you specify the length for a string, the | ||
− | |||
− | maximum length is 255. The maximum length for a | ||
− | |||
− | non-string array is 65535. | ||
Example: | Example: | ||
− | <source lang="vb">PUT #1, var | + | <source lang="vb"> PUT #1, var |
PUT #1, var , , 2 ‘ write 2 bytes at default position | PUT #1, var , , 2 ‘ write 2 bytes at default position | ||
− | PUT #1, var ,PS, 2 ‘ write 2 bytes at location storied | + | PUT #1, var ,PS, 2 ‘ write 2 bytes at location storied in variable PS</source> |
− | |||
− | in variable PS</source> | ||
− | |||
− | |||
<code>PUT #channel, var</code> | <code>PUT #channel, var</code> | ||
Строка 1181: | Строка 168: | ||
{| class="wikitable" | {| class="wikitable" | ||
| #channel(...) | | #channel(...) | ||
− | | A channel number, which identifies an opened file. | + | | A channel number, which identifies an opened file. This can be a hard coded constant or a variable. |
− | |||
− | This can be a hard coded constant or a variable. | ||
|- | |- | ||
| Var(...) | | Var(...) | ||
− | | The variable or variable array that will be written to | + | | The variable or variable array that will be written to the file |
− | |||
− | the file | ||
|- | |- | ||
| Pos(...) | | Pos(...) | ||
− | | This is an optional parameter that may be used to | + | | This is an optional parameter that may be used to specify the postion where the data must be written to. This must be a long variable. |
− | |||
− | specify the postion where the data must be written to. | ||
− | |||
− | This must be a long variable. | ||
|- | |- | ||
| Length(...) | | Length(...) | ||
− | | This is an optional parameter that may be used to | + | | This is an optional parameter that may be used to specify how many bytes must be written to the file. |
− | |||
− | specify how many bytes must be written to the file. | ||
|} | |} | ||
Пример вызова: | Пример вызова: | ||
− | <source lang="vb">'for the binary file demo we need some variables of | + | <source lang="vb"> 'for the binary file demo we need some variables of different types |
− | + | Dim B As Byte , W As Word , L As Long , Sn As Single , Ltemp As Long | |
− | different types | ||
− | Dim B As Byte , W As Word , L As Long , Sn As Single , | ||
− | |||
− | Ltemp As Long | ||
Dim Stxt As String * 10 | Dim Stxt As String * 10 | ||
− | B = 1 : W = 50000 : L = 12345678 : Sn = 123.45 : Stxt = | + | B = 1 : W = 50000 : L = 12345678 : Sn = 123.45 : Stxt = "test" |
− | |||
− | "test" | ||
'open the file in BINARY mode | 'open the file in BINARY mode | ||
Строка 1222: | Строка 193: | ||
Put #2 , L ' write a long | Put #2 , L ' write a long | ||
Ltemp = Loc(#2) + 1 ' get the position of the next byte | Ltemp = Loc(#2) + 1 ' get the position of the next byte | ||
− | Print Ltemp ; " LOC" ' store the location of the file | + | Print Ltemp ; " LOC" ' store the location of the file pointer |
− | |||
− | pointer | ||
Print Seek(#2) ; " = LOC+1" | Print Seek(#2) ; " = LOC+1" | ||
Print Lof(#2) ; " length of file" | Print Lof(#2) ; " length of file" | ||
− | Print Fileattr(#2) ; " file mode" ' should be 32 for | + | Print Fileattr(#2) ; " file mode" ' should be 32 for binary |
− | |||
− | binary | ||
Put #2 , Sn ' write a single | Put #2 , Sn ' write a single | ||
Put #2 , Stxt ' write a string | Put #2 , Stxt ' write a string | ||
Строка 1250: | Строка 217: | ||
=== Seek === | === Seek === | ||
− | Function: Returns the position of the next Byte to be | + | Function: Returns the position of the next Byte to be read or written. |
+ | Statement: Sets the position of the next Byte to be read or written. | ||
− | + | This function returns the position of the next Byte to be read or written. If an error occures, 0 is returned. Check DOS-Error in variable gbDOSError<ref name="OkrDOS">[[Окружение AVR-DOS#Коды ошибок|Коды ошибок]]</ref>.. | |
− | + | The statetement also returns an error in the gbDOSerror variable in the event that an error occurs. | |
− | + | You can for example not set the fileposition behinds the filesize. | |
− | + | In QB/VB the file is filled with 0 bytes when you set the filepointer behind the size of the file. For embedded systems this does not seem a good idea. | |
− | + | Seek and Loc seems to do the same function, but take care : the seek function will return the position of the next read/write, while the Loc function returns the position of the last read/write. You may say that Seek = Loc+1. | |
− | This function returns the position of the next Byte to | ||
− | |||
− | be read or written. If an error occures, 0 is returned. | ||
− | |||
− | Check DOS-Error in variable gbDOSError<ref | ||
− | |||
− | name="OkrDOS"> | ||
− | The statetement also returns an error in the gbDOSerror | ||
− | |||
− | variable in the event that an error occurs. | ||
− | You can for example not set the fileposition behinds the | ||
− | |||
− | filesize. | ||
− | In QB/VB the file is filled with 0 bytes when you set | ||
− | |||
− | the filepointer behind the size of the file. For | ||
− | |||
− | embedded systems this does not seem a good idea. | ||
− | Seek and Loc seems to do the same function, but take | ||
− | |||
− | care : the seek function will return the position of the | ||
− | |||
− | next read/write, while the Loc function returns the | ||
− | |||
− | position of the last read/write. You may say that Seek = | ||
− | |||
− | Loc+1. | ||
'''Difference with QB''' | '''Difference with QB''' | ||
− | In QB/VB you can use seek to make the file bigger. When | + | In QB/VB you can use seek to make the file bigger. When a file is 100 bytes long, setting the filepointer to 200 will increase the file with 0 bytes. By design this is not the case in AVR-DOS. |
− | |||
− | a file is 100 bytes long, setting the filepointer to 200 | ||
− | |||
− | will increase the file with 0 bytes. By design this is | ||
− | |||
− | not the case in AVR-DOS. | ||
<code>Function: NextReadWrite = Seek (#bFileNumber) | <code>Function: NextReadWrite = Seek (#bFileNumber) | ||
Строка 1302: | Строка 237: | ||
|- | |- | ||
| NextReadWrite(Long) | | NextReadWrite(Long) | ||
− | | A Long Variable, which is assigned with the Position | + | | A Long Variable, which is assigned with the Position of the next Byte to be read or written (1-based) |
− | |||
− | of the next Byte to be read or written (1-based) | ||
|- | |- | ||
| NewPos(Long) | | NewPos(Long) | ||
− | | A Long variable that holds the new position the | + | | A Long variable that holds the new position the filepointer must be set too. |
− | |||
− | filepointer must be set too. | ||
|} | |} | ||
Пример вызова: | Пример вызова: | ||
− | <source lang="vb">Open "test.biN" For Binary As #2 | + | <source lang="vb"> Open "test.biN" For Binary As #2 |
Put #2 , B ' write a byte | Put #2 , B ' write a byte | ||
Put #2 , W ' write a word | Put #2 , W ' write a word | ||
Put #2 , L ' write a long | Put #2 , L ' write a long | ||
Ltemp = Loc(#2) + 1 ' get the position of the next byte | Ltemp = Loc(#2) + 1 ' get the position of the next byte | ||
− | Print Ltemp ; " LOC" ' store the location of the file | + | Print Ltemp ; " LOC" ' store the location of the file pointer |
− | |||
− | pointer | ||
Print Seek(#2) ; " = LOC+1" | Print Seek(#2) ; " = LOC+1" | ||
Строка 1329: | Строка 258: | ||
Open "test.bin" For Binary As #2 | Open "test.bin" For Binary As #2 | ||
Seek #2 , Ltemp ' set the filepointer | Seek #2 , Ltemp ' set the filepointer | ||
− | Sn = 1.23 ' change the single value so we can check it | + | Sn = 1.23 ' change the single value so we can check it better |
− | |||
− | better | ||
Put #2 , Sn = 1 'specify the file position | Put #2 , Sn = 1 'specify the file position | ||
Close #2 | Close #2 | ||
Строка 1337: | Строка 264: | ||
== Свойства файла == | == Свойства файла == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== LOC === | === LOC === | ||
− | Returns the position of last read or written Byte of the | + | Returns the position of last read or written Byte of the file. |
− | + | This function returns the position of the last read or written Byte. If an error occurs, 0 is returned. Check DOS-Error in variable gbDOSError<ref name="OkrDOS">[[Окружение AVR-DOS#Коды ошибок|Коды ошибок]]</ref>.. If the file position pointer is changed with the command SEEK, this function can not be used till the next read/write operation. | |
− | |||
− | This function returns the position of the last read or | ||
− | |||
− | written Byte. If an error occurs, 0 is returned. Check | ||
− | |||
− | DOS-Error in variable gbDOSError<ref | ||
− | |||
− | name="OkrDOS"> | ||
− | |||
− | the file position pointer is changed with the command | ||
− | |||
− | SEEK, this function can not be used till the next | ||
− | |||
− | read/write operation. | ||
'''Difference with QB''' | '''Difference with QB''' | ||
− | This function differs from QB. In QB the byte position | + | This function differs from QB. In QB the byte position is divided by 128. |
− | |||
− | is divided by 128. | ||
<code>lLastReadWritten = Loc (#bFileNumber)</code> | <code>lLastReadWritten = Loc (#bFileNumber)</code> | ||
Строка 1420: | Строка 278: | ||
|- | |- | ||
| lLastReadWritten(Long) | | lLastReadWritten(Long) | ||
− | | Variable, whichsigned with the Position of last read | + | | Variable, whichsigned with the Position of last read or written Byte (1-based) |
− | |||
− | or written Byte | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | (1-based) | ||
|} | |} | ||
Пример вызова: | Пример вызова: | ||
− | <source lang="vb">'open the file in BINARY mode | + | <source lang="vb"> 'open the file in BINARY mode |
Open "test.biN" For Binary As #2 | Open "test.biN" For Binary As #2 | ||
Put #2 , B ' write a byte | Put #2 , B ' write a byte | ||
Строка 1478: | Строка 289: | ||
Put #2 , L ' write a long | Put #2 , L ' write a long | ||
Ltemp = Loc(#2) + 1 ' get the position of the next byte | Ltemp = Loc(#2) + 1 ' get the position of the next byte | ||
− | Print Ltemp ; " LOC" ' store the location of the file | + | Print Ltemp ; " LOC" ' store the location of the file pointer |
− | |||
− | pointer | ||
Print Lof(#2) ; " length of file" | Print Lof(#2) ; " length of file" | ||
− | Print Fileattr(#2) ; " file mode" ' should be 32 for | + | Print Fileattr(#2) ; " file mode" ' should be 32 for binary |
− | |||
− | binary | ||
Put #2 , Sn ' write a single | Put #2 , Sn ' write a single | ||
Put #2 , Stxt ' write a string | Put #2 , Stxt ' write a string | ||
Строка 1493: | Строка 300: | ||
=== FileAttr === | === FileAttr === | ||
− | + | Возвращает [[Окружение AVR-DOS#Использование команд ввода-вывода в различных режимах|режим открытия]] файлового потока. | |
− | |||
− | |||
− | |||
− | |||
<code>bFileAttribut = FileAttr (bFileNumber)</code> | <code>bFileAttribut = FileAttr (bFileNumber)</code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{| class="wikitable" | {| class="wikitable" | ||
| bFileAttribut(Long) | | bFileAttribut(Long) | ||
− | | | + | | Режим: |
+ | '''1''' - INPUT<br/> | ||
+ | '''2''' - OUTPUT<br/> | ||
+ | '''8''' - APPEND<br/> | ||
+ | '''32''' - BINARY | ||
|- | |- | ||
| bFileNumber(Byte) | | bFileNumber(Byte) | ||
− | | | + | | Идентификационный номер открытого файлового потока<ref name="identnumber">Принадлежит целому множеству 0..255, может быть переменной или константой. Используйте числа 1..127 для пользовательских идентификаторов. Для получения свободного идентификатора используйте функцию [[#FreeFile|FreeFile]](возвращает 128..255)</ref> |
|} | |} | ||
− | |||
Пример вызова: | Пример вызова: | ||
− | <source lang="vb">'open the file in BINARY mode | + | <source lang="vb"> 'open the file in BINARY mode |
Open "test.biN" For Binary As #2 | Open "test.biN" For Binary As #2 | ||
− | Print Fileattr(#2) ; " file mode" ' should be 32 for | + | Print Fileattr(#2) ; " file mode" ' should be 32 for binary |
− | |||
− | binary | ||
Put #2 , Sn ' write a single | Put #2 , Sn ' write a single | ||
Put #2 , Stxt ' write a string | Put #2 , Stxt ' write a string | ||
Строка 1544: | Строка 330: | ||
Writes the Content of a File into SRAM. | Writes the Content of a File into SRAM. | ||
− | This function writes the content of a file to a desired | + | This function writes the content of a file to a desired space in SRAM. A free handle is needed for this function. |
− | |||
− | space in SRAM. A free handle is needed for this | ||
− | |||
− | function. | ||
<code>BLoad sFileName, wSRAMPointer</code> | <code>BLoad sFileName, wSRAMPointer</code> | ||
Строка 1557: | Строка 339: | ||
|- | |- | ||
| wSRAMPointer(Word) | | wSRAMPointer(Word) | ||
− | | Variable, which holds the SRAM Address to which the | + | | Variable, which holds the SRAM Address to which the content of the file should be written |
− | |||
− | content of the file should be written | ||
|} | |} | ||
Пример вызова: | Пример вызова: | ||
− | <source lang="vb">'now the good old bsave and bload | + | <source lang="vb"> 'now the good old bsave and bload |
Dim Ar(100) As Byte , I As Byte | Dim Ar(100) As Byte , I As Byte | ||
For I = 1 To 100 | For I = 1 To 100 | ||
Строка 1589: | Строка 369: | ||
Save a range in SRAM to a Fileю | Save a range in SRAM to a Fileю | ||
− | This function writes a range from the SRAM to a file. A | + | This function writes a range from the SRAM to a file. A free file handle is needed for this function. |
− | |||
− | free file handle is needed for this function. | ||
<code>BSave sFileName, wSRAMPointer, wLength</code> | <code>BSave sFileName, wSRAMPointer, wLength</code> | ||
Строка 1600: | Строка 378: | ||
|- | |- | ||
| wSRAMPointer(Word) | | wSRAMPointer(Word) | ||
− | | Variable, which holds the SRAM Address, from where | + | | Variable, which holds the SRAM Address, from where SRAM should be written to a File |
− | |||
− | SRAM should be written to a File | ||
|- | |- | ||
| wLength(Word) | | wLength(Word) | ||
− | | Count of Bytes from SRAM, which should be written to | + | | Count of Bytes from SRAM, which should be written to the file |
− | |||
− | the file | ||
|} | |} | ||
Строка 1639: | Строка 413: | ||
== См. также == | == См. также == | ||
* [[AVR-DOS]] | * [[AVR-DOS]] | ||
+ | * [[Основные команды AVR-DOS]] |
Текущая версия на 08:29, 9 января 2009
Список команд AVR-DOS — список функций библиотеки AVR-DOS.
Содержание
Диск/Директория
FileDate
Возвращает дату создания или последнего изменения файла.
sDate = FileDate ()
sDate = FileDate (file)
sDate(String) | Дата создания или изменения(?) файла |
File(String) | Имя файла в текущей директории[1][2] |
Пример вызова:
<source lang="vb"> Print "File demo" Print Filelen( "josef.img") ; " length" ' length of file Print Filetime( "josef.img") ; " time" ' time file was changed Print Filedate( "josef.img") ; " date" ' file date </source>
FileTime
Возвращает время создания или последнего изменения файла.
sTime = FileTime ()
sTime = FileTime (file)
sTime(String) | Время создания или изменения(?) файла |
File(String) | Имя файла в текущей директории[1][2] |
Пример вызова:
<source lang="vb"> Print "File demo" Print Filelen( "josef.img") ; " length" ' length of file Print Filetime( "josef.img") ; " time" ' time file was changed Print Filedate( "josef.img") ; " date" ' file date </source>
Файлы
Flush
Скидывает кеш текущего файла на диск и обновляет информацию раздела, директории.
Процедура осуществляет запись всей несохраненной информации о/в файле на диск. Обычно запись на диск производится при закрытии файлового потока или переходе на другой сектор файла, однако вы можете поменять параметр cFATDirSaveAtEnd, в этом случае вам придется принудительно сбрасывать изменения файла на диск.
Flush #bFileNumber
Flush
BFileNumber(Byte) | Идентификационный номер открытого файлового потока[3]. Если не указан, то изменения всех открытых файлов сбрасываются на диск. |
Пример вызова:
<source lang="vb"> $include "startup.inc"
'open the file in BINARY mode Open "test.biN" For Binary As #2 Put #2 , B ' write a byte Put #2 , W ' write a word Put #2 , L ' write a long Ltemp = Loc(#2) + 1 ' get the position of the next byte Print Ltemp ; " LOC" ' store the location of the file pointer Print Lof(#2) ; " length of file" Print Fileattr(#2) ; " file mode" ' should be 32 for binary Put #2 , Sn ' write a single Put #2 , Stxt ' write a string
Flush #2 ' flush to disk Close #2 </source>
Get
Reads a byte from the hardware or software UART. Reads data from a file opened in BINARY mode.
GET in combination with the software/hardware UART is provided for compatibility with BASCOM-8051. It reads one byte. GET in combination with the AVR-DOS filesystem is very flexible and versatile. It works on files opened in BINARY mode and you can reads all data types. By default you only need to provide the variable name. When the variable is a byte, 1 byte wil be read. When the variable is a word or integer, 2 bytes will be read. When the variable is a long or single, 4 bytes will be read. When the variable is a string, the number of bytes that will be read is equal to the dimensioned size of the string. DIM S as string * 10 , would read 10 bytes. Note that when you specify the length for a string, the maximum length is 255. The maximum length for a non-string array is 65535. <source lang="vb"> Example : GET #1 , var ,,2 ‘ read 2 bytes, start at current position GET #1, var , PS ‘ start at position stored in long PS GET #1, var , PS, 2 ‘ start at position stored in long PS and read 2 bytes</source>
GET #channel, var
GET #channel, var , [pos] [, length]
#channel(...) | A channel number, which identifies an opened file. This can be a hard coded constant or a variable |
Var(...) | The variable or variable array that will be assigned with the data from the file |
Pos(...) | This is an optional parameter that may be used to specify the postion where the reading must start from. This must be a long variable |
Length(...) | This is an optional parameter that may be used to specify how many bytes must be read from the file. |
Пример вызова:
<source lang="vb"> 'for the binary file demo we need some variables of different types Dim B As Byte , W As Word , L As Long , Sn As Single , Ltemp As Long Dim Stxt As String * 10 B = 1 : W = 50000 : L = 12345678 : Sn = 123.45 : Stxt = "test"
'open the file in BINARY mode Open "test.biN" For Binary As #2 Put #2 , B ' write a byte Put #2 , W ' write a word Put #2 , L ' write a long Ltemp = Loc(#2) + 1 ' get the position of the next byte Print Ltemp ; " LOC" ' store the location of the file pointer Print Seek(#2) ; " = LOC+1"
Print Lof(#2) ; " length of file" Print Fileattr(#2) ; " file mode" ' should be 32 for binary Put #2 , Sn ' write a single Put #2 , Stxt ' write a string
Flush #2 ' flush to disk Close #2
'now open the file again and write only the single Open "test.bin" For Binary As #2 L = 1 'specify the file position B = Seek(#2 , L) ' reset is the same as using SEEK #2,L Get #2 , B ' get the byte Get #2 , W ' get the word Get #2 , L ' get the long Get #2 , Sn ' get the single Get #2 , Stxt ' get the string Close #2 </source>
Put
Writes a byte to the hardware or software UART. Writes data to a file opened in BINARY mode.
PUT in combination with the software/hardware UART is provided for compatibility with BASCOM-8051. It writes one byte PUT in combination with the AVR-DOS filesystem is very flexible and versatile. It works on files opened in BINARY mode and you can write all data types. By default you only need to provide the variable name. When the variable is a byte, 1 byte wil be written. When the variable is a word or integer, 2 bytes will be written. When the variable is a long or single, 4 bytes will be written. When the variable is a string, the number of bytes that will be written is equal to the dimensioned size of the string. DIM S as string * 10 , would write 10 bytes. Note that when you specify the length for a string, the maximum length is 255. The maximum length for a non-string array is 65535. Example: <source lang="vb"> PUT #1, var PUT #1, var , , 2 ‘ write 2 bytes at default position PUT #1, var ,PS, 2 ‘ write 2 bytes at location storied in variable PS</source>
PUT #channel, var
PUT #channel, var ,[pos] [,length]
#channel(...) | A channel number, which identifies an opened file. This can be a hard coded constant or a variable. |
Var(...) | The variable or variable array that will be written to the file |
Pos(...) | This is an optional parameter that may be used to specify the postion where the data must be written to. This must be a long variable. |
Length(...) | This is an optional parameter that may be used to specify how many bytes must be written to the file. |
Пример вызова:
<source lang="vb"> 'for the binary file demo we need some variables of different types Dim B As Byte , W As Word , L As Long , Sn As Single , Ltemp As Long Dim Stxt As String * 10 B = 1 : W = 50000 : L = 12345678 : Sn = 123.45 : Stxt = "test"
'open the file in BINARY mode Open "test.biN" For Binary As #2 Put #2 , B ' write a byte Put #2 , W ' write a word Put #2 , L ' write a long Ltemp = Loc(#2) + 1 ' get the position of the next byte Print Ltemp ; " LOC" ' store the location of the file pointer Print Seek(#2) ; " = LOC+1"
Print Lof(#2) ; " length of file" Print Fileattr(#2) ; " file mode" ' should be 32 for binary Put #2 , Sn ' write a single Put #2 , Stxt ' write a string
Flush #2 ' flush to disk Close #2
'now open the file again and write only the single Open "test.bin" For Binary As #2 L = 1 'specify the file position B = Seek(#2 , L) ' reset is the same as using SEEK #2,L Get #2 , B ' get the byte Get #2 , W ' get the word Get #2 , L ' get the long Get #2 , Sn ' get the single Get #2 , Stxt ' get the string Close #2 </source>
Seek
Function: Returns the position of the next Byte to be read or written. Statement: Sets the position of the next Byte to be read or written.
This function returns the position of the next Byte to be read or written. If an error occures, 0 is returned. Check DOS-Error in variable gbDOSError[4].. The statetement also returns an error in the gbDOSerror variable in the event that an error occurs. You can for example not set the fileposition behinds the filesize. In QB/VB the file is filled with 0 bytes when you set the filepointer behind the size of the file. For embedded systems this does not seem a good idea. Seek and Loc seems to do the same function, but take care : the seek function will return the position of the next read/write, while the Loc function returns the position of the last read/write. You may say that Seek = Loc+1. Difference with QB In QB/VB you can use seek to make the file bigger. When a file is 100 bytes long, setting the filepointer to 200 will increase the file with 0 bytes. By design this is not the case in AVR-DOS.
Function: NextReadWrite = Seek (#bFileNumber)
Statement: Seek #bFileNumber, NewPos)
bFileNumber(Byte) | Filenumber, which identifies an opened file |
NextReadWrite(Long) | A Long Variable, which is assigned with the Position of the next Byte to be read or written (1-based) |
NewPos(Long) | A Long variable that holds the new position the filepointer must be set too. |
Пример вызова:
<source lang="vb"> Open "test.biN" For Binary As #2 Put #2 , B ' write a byte Put #2 , W ' write a word Put #2 , L ' write a long Ltemp = Loc(#2) + 1 ' get the position of the next byte Print Ltemp ; " LOC" ' store the location of the file pointer Print Seek(#2) ; " = LOC+1"
Close #2
'now open the file again and write only the single Open "test.bin" For Binary As #2 Seek #2 , Ltemp ' set the filepointer Sn = 1.23 ' change the single value so we can check it better Put #2 , Sn = 1 'specify the file position Close #2 </source>
Свойства файла
LOC
Returns the position of last read or written Byte of the file.
This function returns the position of the last read or written Byte. If an error occurs, 0 is returned. Check DOS-Error in variable gbDOSError[4].. If the file position pointer is changed with the command SEEK, this function can not be used till the next read/write operation. Difference with QB This function differs from QB. In QB the byte position is divided by 128.
lLastReadWritten = Loc (#bFileNumber)
bFileNumber(Byte) | Filenumber, which identifies an opened file |
lLastReadWritten(Long) | Variable, whichsigned with the Position of last read or written Byte (1-based) |
Пример вызова:
<source lang="vb"> 'open the file in BINARY mode Open "test.biN" For Binary As #2 Put #2 , B ' write a byte Put #2 , W ' write a word Put #2 , L ' write a long Ltemp = Loc(#2) + 1 ' get the position of the next byte Print Ltemp ; " LOC" ' store the location of the file pointer Print Lof(#2) ; " length of file" Print Fileattr(#2) ; " file mode" ' should be 32 for binary Put #2 , Sn ' write a single Put #2 , Stxt ' write a string
Flush #2 ' flush to disk Close #2 </source>
FileAttr
Возвращает режим открытия файлового потока.
bFileAttribut = FileAttr (bFileNumber)
bFileAttribut(Long) | Режим:
1 - INPUT |
bFileNumber(Byte) | Идентификационный номер открытого файлового потока[3] |
Пример вызова:
<source lang="vb"> 'open the file in BINARY mode Open "test.biN" For Binary As #2 Print Fileattr(#2) ; " file mode" ' should be 32 for binary Put #2 , Sn ' write a single Put #2 , Stxt ' write a string Close #2 </source>
Другие
Bload
Writes the Content of a File into SRAM.
This function writes the content of a file to a desired space in SRAM. A free handle is needed for this function.
BLoad sFileName, wSRAMPointer
sFileName(Long) | Name of the File to be read |
wSRAMPointer(Word) | Variable, which holds the SRAM Address to which the content of the file should be written |
Пример вызова:
<source lang="vb"> 'now the good old bsave and bload Dim Ar(100) As Byte , I As Byte For I = 1 To 100 Ar(i) = I ' fill the array Next
Wait 2
W = Varptr(ar(1)) Bsave "josef.img" , W , 100 For I = 1 To 100 Ar(i) = 0 ' reset the array Next
Bload "josef.img" , W ' Josef you are amazing !
For I = 1 To 10 Print Ar(i) ; " " ; Next Print </source>
Bsave
Save a range in SRAM to a Fileю
This function writes a range from the SRAM to a file. A free file handle is needed for this function.
BSave sFileName, wSRAMPointer, wLength
sFileName(Long) | Name of the File to be written |
wSRAMPointer(Word) | Variable, which holds the SRAM Address, from where SRAM should be written to a File |
wLength(Word) | Count of Bytes from SRAM, which should be written to the file |
Пример вызова:
<source lang="vb">'now the good old bsave and bload Dim Ar(100) As Byte , I As Byte For I = 1 To 100 Ar(i) = I ' fill the array Next
Wait 2
W = Varptr(ar(1)) Bsave "josef.img" , W , 100 For I = 1 To 100 Ar(i) = 0 ' reset the array Next
Bload "josef.img" , W ' Josef you are amazing !
For I = 1 To 10 Print Ar(i) ; " " ; Next Print </source>
Сноски
- ↑ 1 2 8.3: имя - 8 символов, расширение - 3 символа, разделитель(точка) - 1 символ, всего не более 12 символов
- ↑ 1 2 Если не указано, параметром считается последний файл, выбранный с помощью DIR
- ↑ 1 2 Принадлежит целому множеству 0..255, может быть переменной или константой. Используйте числа 1..127 для пользовательских идентификаторов. Для получения свободного идентификатора используйте функцию FreeFile(возвращает 128..255) Ошибка цитирования Неверный тег
<ref>
: название «identnumber» определено несколько раз для различного содержимого - ↑ 1 2 Коды ошибок