Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:51 29 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 : MM.ERRNO problem...

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 03:47pm 27 Feb 2014
Copy link to clipboard 
Print this post

What the flippin' heck am I doing wrong here?


DATABASE:
timer=0:FlagSD=1
Open F$ For input As #3:T=timer
If MM.Errno<>0 Then
if MM.ERRNO=5 or mm.errno=6 then exit
else
goto errors
endif
Line Input #3,N$:Line Input #3,L$:Line Input #3,A$
Close #3:FlagSD=0
return


Simple GOSUB routine, which opens F$ to read a file.

I keep getting the error "File number is not open" with the LINE INPUT line of the code, but when I check mm.errno it is zero, so it seems that it was able to find and open the file, then says it can't read from it, cos the port is not open when it is.

There must be something I am doing wrong, but I cannot see where my bug is.



The file and directory don't actually exist - I am testing the error-trapping. In my screenshot, you can see if I manually open the port, mm.errno=5, as expected, as the file and folder can't be found, but at that point, the code should be in the IF/THEN loop, and should EXIT from the gosub, not keep going at this point - it should never get to the LINE INPUT line of code, in other words.Edited by Grogster 2014-03-01
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 04:08pm 27 Feb 2014
Copy link to clipboard 
Print this post

Nevermind - fixed it.

Was using EXIT in the IF/THEN - should have been using RETURN.

Looking at the manual, I could believe that, as EXIT exits from a loop, so it drops back to the next line of code AFTER the ENDIF, having discovered that MM.ERRNO is not zero, tries to LINE INPUT, and the file is not open - correct.

Time for a break - funny how your brain gets tired quicker sometimes, then it does other times...Edited by Grogster 2014-03-01
Smoke makes things work. When the smoke gets out, it stops!
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 761
Posted: 07:18pm 27 Feb 2014
Copy link to clipboard 
Print this post

Along those same lines, I wish we had a MM.status value that showed if an SD card was inserted BEFORE trying to do any open or other SD card related commands... To get the answer involves trying to do something with it before checking the MM.errno value... Edited by Zonker 2014-03-01
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 07:41pm 27 Feb 2014
Copy link to clipboard 
Print this post

You could use the card-detect switch on the SD card slot - depends on what SD card holder you are using. I think the CMM boards have a card-detect switch, but it is not used. If that was the case, you could wire the switch up to a MM pin, and do exactly what you want.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


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

© JAQ Software 2024