![]() |
Forum Index : Microcontroller and PC projects : Error problem
Author | Message | ||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
I have some code that has been running OK and I decided to add GPS time, so I connected the receiver and copy/pasted Geoff's code which runs OK in another project. I get the error I did a search and there are only three instances of "MD" in the code the first two here Dim md(12), arg$(20) Data 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 For i = 1 To 12: Read md(i): Next i and the next one in this function. Function GetMins(yr, mth, day, hr, min) GetMins = (yr - 14) * (365 * 24 * 60) + ((yr - 13) \ 4) * (24 * 60) GetMins = GetMins + (md(mth) * (24 * 60)) GetMins = GetMins + ((day - 1) * (24 * 60)) GetMins = GetMins + (hr * 60) GetMins = GetMins + min If (yr - 16) Mod 4 = 0 And mth > 2 Then GetMins = GetMins + (24 * 60) End Function What does this error mean? "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1642 |
Deleted - sorry mis=read the code. Keep safe. Live long and prosper. |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5089 |
hi Pascal, Looks like md() is not locally found in function GetMins(xxxx) Then the function wants to create it (like any variable that is not known previous) and sees that it already exists. Is there any way to decare md() globally, or pass it to the function also? Volhout PicomiteVGA PETSCII ROBOTS |
||||
goc30![]() Guru ![]() Joined: 12/04/2017 Location: FrancePosts: 435 |
hi paslcal I have same pb I have change 2 vars md and arg$ to vmd and varg$ and it work correctly after, i have bug with "getdate' function, but it is because function is wrong (pb with computing "day" I search!! |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
@goc30 I did the same thing with the same result. @Volhout OK now I understand what is happening but md(12) is declared as a global at the start of the code. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
Do you have/need OPTION EXPLICIT Latest F4 Latest H7 FotS |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1642 |
From Geoff's "SuperClock": Dim Integer md(12) = (0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334) and ' calculate the seconds since midnight 1st Jan 2014 Function GetSec(yr As Integer, mth As Integer, day As Integer, hr As Integer, min As Integer, sec As Integer) As Integer GetSec = (yr - 14) * (365 * 24 * 60) GetSec = GetSec + ((yr - 13) \ 4) * (24 * 60) GetSec = GetSec + (md(mth) * (24 * 60)) GetSec = GetSec + ((day - 1) * (24 * 60)) GetSec = GetSec + (hr * 60) GetSec = ((GetSec + min) * 60) + sec If (yr - 16) Mod 4 = 0 And mth > 2 Then GetSec = GetSec + (24 * 3600) End Function These are the only places that md() appears and, OK, the code is a bit different but I don't see why one works and the other doesn't. Unless it's a different version of MMBasic and there is a bug. You don't say which version of MMBasic you are using or what device. I'm not familiar with any of Peter M's versions. Bill Keep safe. Live long and prosper. |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
MX170 and V5.0409 I don't know what to do? I changed this Dim md(12), arg$(20) Data 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 For i = 1 To 12: Read md(i): Next i to this Dim Integer md(12) = (0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334) and that seemed to fix that part but then got the same error with 'TIMEZONE' so I substituted 'TIMEZONE' with 10 and got past that, then got the same problem with the Daylight Saving so commented that out then got the problem with the next variable. I am going to have to go back to the working code I had before trying to add the GPS TIME and start again. I can't help thinking it has got something to do with the copy/paste of the code. Edit.... I tried using OPTION EXPLICIT, I declared all the vars but the error still surfaced. I'll START AGAIN. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1642 |
Have you considered re-flashing the chip? I think it was Grogster who said recently "When weird stuff happens try re-flashing the chip" or words to that effect. It has worked for others. I'd give it a go. Bill Keep safe. Live long and prosper. |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
Good idea, I will try that. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
I re flashed the chip, problem still there BUT since reinstalling MMedit to fix another problem I was having with SEARCH everything seems to be OK. My MMedit must have got corrupted somehow and caused a lot of weird problems. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |