Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:39 25 Nov 2024 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 : accessing a file type automatically on an SD card

Author Message
jovian
Regular Member

Joined: 16/04/2017
Location: Australia
Posts: 62
Posted: 02:40am 09 Jun 2024
Copy link to clipboard 
Print this post

Hi all
I am making good progress loading a CSV file into mmbasic so I can pre-program data in a spreadsheet. I export from the sheet as CSV and it creates a generic "namexxx.csv" file name.

I can access the file from mmBasic no problem using Open "" for input as

Now I would like the program to search the card and identify the first .csv file it encounters so I may read it, without needing to name the file in advance.

When I use dir$ I get a flag error... I am not sure of the nomenclature, and can't find it in the manual.

ChatGPT is unable to help too. I can't find any use of dir$ on fruitoftheshed.

Can anyone help?

Thanks
Jo
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 896
Posted: 03:25am 09 Jun 2024
Copy link to clipboard 
Print this post

Something like this should work.You would need to enhance it to search the directories if that is not known.


dim first$,f$

   ' chdir("/")
   chdir("/tests")
   f$=DIR$("*.csv",FILE)
   first$=f$
   'Print #1, f$+":--all"
   'Print #1, f$
   ? " Added... "+f$
   Do While f$ <> ""
     f$=DIR$()
     if f$<>"" then
      'Print #1, f$
      ? " Added... "+f$
     endif
     If first$ = "" Then first$ = f$
   LOOP
  ' chdir("/")



Latest F4 Latest H7
 
Print this page


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

© JAQ Software 2024