User manual
296
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
lename[7] = “B”
Cf_Fat_Assign(lename, 0)
Cf_Fat_Set_File_Date(2009, 1, 23, 17, 22, 0)
Cf_Fat_Append
le_contents = “ for mikroElektronika 2007” ‘ Prepare le for append
le_contents[26] = 10 ‘ LF
Cf_Fat_Write(le_contents, 27) ‘ Write data to assigned le
end sub
‘-------------- Opens an existing le, reads data from it and puts it to USART
sub procedure M_Open_File_Read()
lename[7] = “B”
Cf_Fat_Assign(lename, 0)
Cf_Fat_Reset(size) ‘ To read le, procedure returns size of le
while size > 0
Cf_Fat_Read(character)
UART1_Write(character) ‘ Write data to USART
Dec(size)
wend
end sub
‘-------------- Deletes a le. If le doesn’t exist, it will rst be created
‘ and then deleted.
sub procedure M_Delete_File()
lename[7] = “F”
Cf_Fat_Assign(lename, 0)
Cf_Fat_Delete()
end sub
‘-------------- Tests whether le exists, and if so sends its creation date
‘ and le size via USART
sub procedure M_Test_File_Exist()
dim
fsize as longint
year as word
month_, day, hour_, minute_ as byte
outstr as char[12]
lename[7] = “B” ‘ uncomment this line to search for le that DOES exists
‘ lename[7] = “F” ‘ uncomment this line to search for le that DOES NOT exist
if Cf_Fat_Assign(lename, 0) <> 0 then
‘--- le has been found - get its date
Cf_Fat_Get_File_Date(year,month_,day,hour_,minute_)
UART1_Write_Text(“ created: “)
WordToStr(year, outstr)
UART1_Write_Text(outstr)
ByteToStr(month_, outstr)
UART1_Write_Text(outstr)
WordToStr(day, outstr)
UART1_Write_Text(outstr)
WordToStr(hour_, outstr)
UART1_Write_Text(outstr)
WordToStr(minute_, outstr)
UART1_Write_Text(outstr)