Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:13 10 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : SD Card help

Author Message
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 11:50pm 08 Jul 2017
Copy link to clipboard 
Print this post

Hi
Could somebody post an example of the required synatx for the DIR$ function
"DIR$( fspec, type )
Will search an SD card for files and return the names of entries found."

And while we are at it is a there a simple way to check if an SD card is present?

Regards
Jman
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10565
Posted: 12:41am 09 Jul 2017
Copy link to clipboard 
Print this post

dir$ is a function that returns one filename at a time

type can be DIR, FILE, or ALL
fspec is a search string

so

a$=dir$("*.bas",FILE)

will return the first filename with the extension ".bas"

a$=dir$("*",DIR)

will return any sub directories

To get subsequent files/directories with the same search parameters use

a$=dir$()

if a$="" then end of matching files

  Quote  And while we are at it is a there a simple way to check if an SD card is present?


If the sdcard has a card detect pin enabled in the OPTION command then you can read this with a normal PIN(n) function, otherwise no

Edited by matherp 2017-07-10
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 09:41am 09 Jul 2017
Copy link to clipboard 
Print this post

Thank you Peter
That explains it perfectly.

Regards
Jman
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025