Shop OBEX P1 Docs P2 Docs Learn Events
SD Card Folder Asscess — Parallax Forums

SD Card Folder Asscess

dermotdermot Posts: 26
edited 2011-10-16 12:18 in Propeller 1
Hi,

SD card driver that I am using is Kye's as described in an006. I want to be able to navigate into folders from the root directory and back again.

Lets say I have a folder with no sub-folders in the root directory called Drills.

Why wont the code: sd.changeDirectory("\Drills") assess the folder Drills for me.

Comments

  • dermotdermot Posts: 26
    edited 2011-10-15 08:04
    sd.changeDirectory(string("\Drills"))

    SOLVED
  • dermotdermot Posts: 26
    edited 2011-10-16 08:27
    Is is possible to read a single number back from a file using this driver.
    I have a 8digit number which I need to extract all digits one at the time? Is this possible?

    Tried using fat.fileseek(0) to navigate to file position. But cant read digit back.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-10-16 08:51
    You could use readByte or readData with a byte count of 1. That will get you an ASCII digit at a time. You'll have to do any conversion of the characters of the number to a numeric value. Typically, you'd use a routine like this to do the conversion of one or more digits.
    PUB convertDigits( count )
       ' Process count ASCII digits from left to right converting to
       ' a numeric value which is returned as the value of convertDigits.
       ' No checking is done that the characters found starting at the
       ' current file position are actually digits.  That could be added.
       repeat count
          result := result * 10 + fat.readByte - "0"
    
  • dermotdermot Posts: 26
    edited 2011-10-16 11:21
    So if I had the following digits, 456323, in a file and I wanted digit 1 only, id open the file and do the following:

    fat.fileSeek(0) 'Move to position 0
    count:=fat.readByte 'Assign count equal byte at that position
    convertDigits 'Call convert Digits Routine
    value:=result 'Assign value equal the result
    dec(value) 'To display on VGA

    Should this give me the 1st digit in decimal form value then? As it does not seem to work.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-10-16 12:18
    No. Did you read the comments at the beginning of the routine I posted? Did you understand them?

    To read just one digit, you could try

    fat.fileSeek(0)
    dec( convertDigits(1) )
Sign In or Register to comment.