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 : Divide by zero when using dir$()
Author | Message | ||||
Bizzie Senior Member Joined: 06/07/2014 Location: AustraliaPosts: 185 |
Hi all, Just came across the following:- ? mm.ver 5.0302 > ? mm.device$ Micromite Plus > list If files$ = "" Then Print "No files found" EndIf f$=Dir$("*.*",FILE) Do While f$ <> "" Print f$ f$ = Dir$() Loop > run No files found CPU exception #13 (possible divide by zero) at address 0x9D01BBA0 Processor restarted > > Obvious I suppose but will really toss many. Most of the code above is from the DIR$() example on page 46 of the plus manual. What is the best way to handle this situation? That is a new or blank SD card with no files. I will test files$ first to see if it is blank (hence my first if statement) and then if not recurs through the files. I think it really needs pointing out in the manual as divide by zero is not at all obvious to most. EDIT: Just realised my first if statement seems to work but for the wrong reasons. Ignore these comments. Rob White |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3165 |
Any CPU exception is not good and should never happen. I will have a look at it tomorrow and see what is going on. Geoff Geoff Graham - http://geoffg.net |
||||
Bizzie Senior Member Joined: 06/07/2014 Location: AustraliaPosts: 185 |
Thanks Geoff, I have not got much time this morning. I will try another board as I just changed SD cards and got different results! - That is SD card not present. Regards Rob White |
||||
Bizzie Senior Member Joined: 06/07/2014 Location: AustraliaPosts: 185 |
Geoff, Afraid this was yet another case of "finger trouble"! I disabled the SD card and then did another option sdcard 24 (SD card on display) and all was fine. I can not tell you if option list indicated 24 or not. Rob White |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3165 |
Yes, I just tested it and no exception. Phew!! Geoff Graham - http://geoffg.net |
||||
Print this page |