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.
jman Guru Joined: 12/06/2011 Location: New ZealandPosts: 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 KingdomPosts: 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
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 ZealandPosts: 711