![]() |
Forum Index : Microcontroller and PC projects : Weird Corruption!
Author | Message | ||||
PhilTilson Newbie ![]() Joined: 15/11/2015 Location: United KingdomPosts: 35 |
I would welcome some help with this, please. Here are a few lines from a fairly large MMbasic program - around 1300 lines: sub GetLog(tStart$,tEnd$,fname$) '[013] 'This routine gets a start and finish time in string format 'then opens the fname$ file and prints the relevant log entries LOCAL genin$,st%,end%,cur% IF fname$="" THEN fname$="syslog.txt" st%=(VAL(LEFT$(tStart$,2))*3600)+VAL(MID$(tStart$,4,2))*60)+VAL(RIGHT$(tStart$,2)) end%=(VAL(LEFT$(tEnd$,2))*3600)+(VAL(MID$(tEnd$,4,2))*60)+VAL(RIGHT$(tEnd$,2)) OPEN fname$ FOR INPUT AS #9 DO WHILE NOT EOF(9) LINE INPUT #9,genin$ cur%=(VAL(MID$(genin$,10,2))*3600)+(VAL(MID$(genin$,13,2))*60)+VAL(MID$(genin$,16,2)) IF cur%>=st% THEN PRINT genin$ ELSE IF cur%>end% THEN EXIT DO END IF LOOP CLOSE#9 END SUB It's a simple routine to selectively read log entries. The problem is that when I load it and try to run it, I get the following error: [1297] End%=(Val(Left$(tEnd$,2))*3600)+(Val(Mid$(tEnd$,4,2))*60)+Val(Right$(tEnd$,2)) Error: Unexpected text: %Ç(©“tEnd$,2))·3600)»(©–tEnd$,4,2))·60)»©œtEnd$,2)) What the heck is all that about? When I go to edit the line, it prints exactly as it is in the source code. Any ideas? Phil |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I would try using a different variable name instead of END% The strange characters are the tokens for the keywords which is why the error message looks odd. Jim VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Agreed. That would be the first thing I would try. Avoid using any keywords as variable names, as that could confuse the interpreter. This includes all command names, and all function names. None of them should be used for variable, array or constant names. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
PhilTilson Newbie ![]() Joined: 15/11/2015 Location: United KingdomPosts: 35 |
Thanks guys, I take your point. It was the nature of the error message that had me confused! I will try a different name and see what happens. Phil |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
As a point of note here, going from what the other guys have said, It is a good habit to get into to never use variable/constant/Sub/Function names that conflict with reserved words. I have found all manner of madnesses down that path over the years. As you have seen here, a badly confused firmware rarely gives useful error messages. This simple rule I have found restores error message usability my 2p |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |