![]() |
Forum Index : Microcontroller and PC projects : file sizes on colour maximite
Author | Message | ||||
Yourock17 Newbie ![]() Joined: 09/01/2015 Location: AustraliaPosts: 12 |
Hey guys, is there any way to get the size of a file on the SD card as a variable while the program is running? As an example, I am trying to make a fancy .mod player and I would like to get the length of the song currently playing. I saw the LOF() function in the manual, but am unsure of it's use. Im not sure where to start or if it's even possible. Any suggestions would help. My firmware version is 4.01 on the Colour Maximite |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1629 |
Yes! A code snipped from my File Selector : Dim errText$(17) '0="No error" errText$(1) ="No SD card found" errText$(2) ="SD card is write protected" errText$(3) ="Not enough space" errText$(4) ="All root directory entries are taken" errText$(5) ="Invalid filename" errText$(6) ="Cannot find file" errText$(7) ="Cannot find directory" errText$(8) ="File is read only" errText$(9) ="Cannot open file" errText$(10)="Error reading from file" errText$(11)="Error writing to file" errText$(12)="Not a file" errText$(13)="Not a directory" errText$(14)="Directory not empty" errText$(15)="Hardware error accessing the storage media" errText$(16)="Flash memory write failure" errText$(17)="Source and destination are the same!" 'MMBasic bug Function FileSize N$ Local OpenError If n$<>".." Then Option Error Continue Open N$ For input As #10 OpenError = MM.Errno Option Error Abort If OpenError Then StatusMsg ("OpenError: "+errText$(OpenError)) FileSize=0 Else FileSize=Lof(10) Close 10 EndIf Else FileSize=0 EndIf End Function EDIT Most of the code is errror handling. The essential part is this: Open "YOURFILE.MOD" For input As #10
FileSize=Lof(10) Close 10 EDIT2 I can strongly recommend that you upgrade to 4:05 (MMBasic 4.5). It's easy to do. Regards Michael causality ≠ correlation ≠ coincidence |
||||
Yourock17 Newbie ![]() Joined: 09/01/2015 Location: AustraliaPosts: 12 |
Thanks for the help, however it errors as "Must be an open COM port". I have no idea what this means. I will update the firmware soon. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |