Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:55 02 Aug 2025 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 : Weird Corruption!

Author Message
PhilTilson
Newbie

Joined: 15/11/2015
Location: United Kingdom
Posts: 35
Posted: 09:36pm 02 May 2019
Copy link to clipboard 
Print this post

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: Australia
Posts: 6283
Posted: 10:56pm 02 May 2019
Copy link to clipboard 
Print this post

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 Zealand
Posts: 9610
Posted: 11:24pm 02 May 2019
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 35
Posted: 08:02am 03 May 2019
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2170
Posted: 10:52am 03 May 2019
Copy link to clipboard 
Print this post

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 2pEdited by CaptainBoing 2019-05-04
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025