View previous topic :: View next topic |
Author |
Message |
acatano
Joined: 24 Apr 2004 Posts: 44 Location: Sunrise, USA
|
Posted: Thu Sep 09, 2004 6:11 pm Post subject: help on proper usage of "open file for input as binary& |
|
|
I need help on how to open a binary file for input.
Specifically BMP files. |
|
Back to top |
|
|
oe9vfj
Joined: 17 Jun 2004 Posts: 269 Location: Austria, Hard
|
Posted: Fri Sep 10, 2004 9:03 am Post subject: |
|
|
Hi,
Here a small example:
Code: |
Dim b1 as Byte
Open "Test.bmp" for Binary as #10
If gbDOSError = 0 then
While eof(10) = 0
Get #10, b1
Print chr(b1) ;
Wend
Close #10
Else
Print "Can not open file Test.bmp"
Print "Error: " ; gbDOSError
End IF
|
_________________ regards Josef
DOS - File System for BASCOM-AVR on http://members.aon.at/voegel |
|
Back to top |
|
|
acatano
Joined: 24 Apr 2004 Posts: 44 Location: Sunrise, USA
|
Posted: Sat Sep 11, 2004 3:11 am Post subject: Re:open file for input as binary |
|
|
When I compile your little program, I received several error messages.
gbDOSError is an invalid data type
End If If then expected.
There is something missing?
I am using a m128 |
|
Back to top |
|
|
oe9vfj
Joined: 17 Jun 2004 Posts: 269 Location: Austria, Hard
|
Posted: Sat Sep 11, 2004 6:31 pm Post subject: |
|
|
Hi,
This was only the part to handle a file in binary mode.
You need a driver for the Stoarage medium (Compact-Flash, MMC-Card, Hard-Disk ...) and AVR-DOS. AVR-DOS is a library, which provides a file-system to BASCOM-AVR.
Please check [url]http://members.aon.at/voegel [/url]
for more information or the BASCOM-AVR Help file section Libraries-AVR-DOS.
In the section Download, you get all the additional files you need for the following Example:
Code: |
$Baud = 9600
Open "Com1:" as Binary as #1 ' use #1 for fs_interpreter
Config Clock = soft
enable interrupts
Config Date = MDY , Separator = .
Dim bTemp1 as Byte
print #1 , "Wait for Drive"
' Include here you driver for Compactflash/HardDisk or other
$Include "Config_CompactFlash_M128.bas" ' Does drive init too
If gbDriveError = 0 then
' Include AVR-DOS Configuration and library
$Include "Config_AVR-DOS.BAS"
Print #1 , "Init File System ... ";
bTemp1 = InitFileSystem(1) ' Partition 1
' use 0 for drive without Master boot record
if bTemp1 <> 0 then
print #1 , "Error: " ; bTemp1 ; " at Init file system"
else
print #1 , " OK"
print #1 , "Filesystem: " ; gbFileSystem
print #1 , "FAT Start Sector: " ; glFATFirstSector
Print #1 , "Root Start Sector: " ; glRootFirstSector
Print #1 , "Data First Sector: " ; glDataFirstSector
Print #1 , "Max. Cluster Nummber: " ; gwMaxClusterNumber
Print #1 , "Sectors per Cluster: " ; gbSectorsPerCluster
Print #1 , "Root Entries: " ; gwRootEntries
Print #1 , "Sectors per FAT: " ; gwSectorsPerFAT
Print #1 , "Number of FATs: " ; gbNumberOfFATs
end if
Else
Print #1 , "Error during Drive Init: " ; gbDriveError
end
End if
Dim b1 as Byte
Open "Test.bmp" for Binary as #10
If gbDOSError = 0 then
While eof(10) = 0
Get #10, b1
Print chr(b1) ;
Wend
Close #10
Else
Print "Can not open file Test.bmp"
Print "Error: " ; gbDOSError
End IF
|
good luck _________________ regards Josef
DOS - File System for BASCOM-AVR on http://members.aon.at/voegel |
|
Back to top |
|
|
acatano
Joined: 24 Apr 2004 Posts: 44 Location: Sunrise, USA
|
Posted: Sat Sep 11, 2004 7:05 pm Post subject: Re:help on proper usage of "open file for input as bina |
|
|
I should have been more specific in my request.
I need to open a binary file (*.BMP) which I created and resides in one my hard disk directories, no CF or MMC cards drives. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|