Mmc_Fat_Dir

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
Richie
Posts: 50
Joined: 21 Feb 2010 19:41

Mmc_Fat_Dir

#1 Post by Richie » 27 Mar 2012 14:30

Is it possible to write directory contents (as text) to another file on the SD card using this command ?



Thanks

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Mmc_Fat_Dir

#2 Post by janko.kaljevic » 28 Mar 2012 10:25

Hello,

It is possible and it is very simple to do.
Please try something like this:

Code: Select all

dim buffer as string[256]
dim fhandle as char

sub procedure fillbuffer(dim ch as byte)
  buffer[i] = ch
  inc(i)
end sub
....
    Mmc_Fat_Dir(@fillbuffer)
    buffer[i] = 0
    
    fhandle = Mmc_Fat_Open("newfile.txt", FILE_APPEND, 0xA0)
    Mmc_Fat_Write(buffer, length(buffer))
Best regards.

Richie
Posts: 50
Joined: 21 Feb 2010 19:41

Re: Mmc_Fat_Dir

#3 Post by Richie » 31 Mar 2012 19:47

Thankyou !


BTW it's not possible to change directory and read a file from it ?

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Mmc_Fat_Dir

#4 Post by janko.kaljevic » 02 Apr 2012 14:39

Hello,

Yes it is possible, and very simple.
Please try this:

Code: Select all

    Mmc_Fat_ChangeDir("DIR_A")
    Mmc_Fat_Open("file.txt", FILE_READ, 0)
    size = Mmc_Fat_Get_File_Size()
    for i = 0 to size
      Mmc_Fat_Read(buffer[i])
    next i
This will open file.txt for reading and store it's content in buffer.
I assumed that DIR_A is directory in root on SD card and file.txt is a file inside DIR_A.

Best regards.

Post Reply

Return to “mikroBasic PRO for PIC General”