Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:13 01 Jul 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 : Maximite BASIC issue

Author Message
larny
Guru

Joined: 31/10/2011
Location: Australia
Posts: 346
Posted: 07:32pm 15 Mar 2016
Copy link to clipboard 
Print this post

I have written a BASIC programme for my Maximite but it will not progress beyond Line 120. It gives me a message saying :- "[120} IF Vo(i) > 0.75 THEN ....
Error Invalid syntax"

But I cannot see anything wrong with the code.

Here is the relevant part of the code.

115 i=1
116 DO
117 PRINT FORMAT$(Vt(i), "%4.3f"),;: IF V1(i) > 0.75 THEN PRINT FORMAT$(V1(i), "%4.3f"),; ELSE PRINT "x",;
118 IF Vo(i) > 0.75 THEN PRINT FORMAT$(Vo(i), "%4.3f"),; ELSE PRINT "y"; PRINT FORMAT$(Pc, "%4.0f")
119 PRINT #1, FORMAT$(Vt(i), "%4.3f"),;: IF V1(i) > 0.75 THEN PRINT #1, FORMAT$(V1(i), "%4.4f"),; ELSE PRINT #1, "x",;:
120 IF Vo(i) > 0.75 THEN PRINT #1, FORMAT$(Vo(i), "%4.3f"),; ELSE PRINT #1, "y",; PRINT #1, FORMAT$(Pc, "%4.0f")
121 i = i+1
122
123 LOOP UNTIL Vt(i) > 8


Any assistance will be appreciated.
 
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 08:16pm 15 Mar 2016
Copy link to clipboard 
Print this post

I do not think you can have an else clause in a one line IF statement.
I would format it like this:-

IF Vo(i) > 0.75 THEN
PRINT #1, FORMAT$(Vo(i), "%4.3f"),;
ELSE
PRINT #1, "y",; PRINT #1, FORMAT$(Pc, "%4.0f")
ENDIF

Then there is the question of both , and ; at end of first print statement.
I know the above takes up more lines but it makes it so much easier to read.

Hope this helps.
Rob White
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 08:49pm 15 Mar 2016
Copy link to clipboard 
Print this post

It is difficult without a working piece of code to test with but:
The end of line 120
ELSE PRINT #1, "y",; PRINT #1, FORMAT$(Pc, "%4.0f")

You have two PRINT statements without a ':' between them.
That is likely to be the problem
You got away with it on line 118 but that's printing to the console so may be more forgiving.
As Bizzie shows, you can combine the PRINT statements into one with ; or , between the outputs

It is difficult to debug multi-statement lines so I would suggest that you start with one statement per line.
I also would prefer you to ditch the line numbers. It is much easier to modify code if you don't have to keep renumbering every time you need a new line.

Jim
VK7JH
MMedit
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2947
Posted: 08:52pm 15 Mar 2016
Copy link to clipboard 
Print this post

Hi Larny,

@Jim, You just beat me by 2 minutes.. In the time it took me to login to post you had replied with what I agree is the cause of the syntax error.

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2931
Posted: 08:57pm 15 Mar 2016
Copy link to clipboard 
Print this post

Out of interest, do you not also need some ENDIF's in there for the MaxiMite? (I can't remember the syntax as it has been a while!)
 
drkl

Senior Member

Joined: 18/10/2015
Location: Hungary
Posts: 102
Posted: 09:06pm 15 Mar 2016
Copy link to clipboard 
Print this post

Hello,

Try this:

i=1
DO
PRINT FORMAT$(Vt(i), "%4.3f"),;
IF V1(i) > 0.75 THEN
PRINT FORMAT$(V1(i), "%4.3f"),;
ELSE
PRINT "x",;
ENDIF
IF Vo(i) > 0.75 THEN
PRINT FORMAT$(Vo(i), "%4.3f"),;
ELSE
PRINT "y"; PRINT FORMAT$(Pc, "%4.0f")
ENDIF
PRINT #1, FORMAT$(Vt(i), "%4.3f"),;
IF V1(i) > 0.75 THEN
PRINT #1, FORMAT$(V1(i), "%4.4f"),;
ELSE
PRINT #1, "x",;
ENDIF
IF Vo(i) > 0.75 THEN
PRINT #1, FORMAT$(Vo(i), "%4.3f"),
ELSE
PRINT #1, "y",; PRINT #1, FORMAT$(Pc, "%4.0f")
ENDIF
i = i+1
LOOP UNTIL Vt(i) > 8]



drkl
 
drkl

Senior Member

Joined: 18/10/2015
Location: Hungary
Posts: 102
Posted: 09:12pm 15 Mar 2016
Copy link to clipboard 
Print this post

Sorry,

I made a mistake, the end of code:


IF Vo(i) > 0.75 THEN
PRINT #1, FORMAT$(Vo(i), "%4.3f"),
ELSE
PRINT #1, "y",;
PRINT #1, FORMAT$(Pc, "%4.0f")
ENDIF
i = i+1
LOOP UNTIL Vt(i) > 8




drkl
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9585
Posted: 09:59pm 15 Mar 2016
Copy link to clipboard 
Print this post

  TassyJim said  I also would prefer you to ditch the line numbers. It is much easier to modify code if you don't have to keep renumbering every time you need a new line.

Jim


TOTALLY agree.
And I am a big line-number guy from the days of the Atari.

When I first looked at numberless code, I could not see how the hell it worked WITHOUT the line numbers, but once you get the hang of it, it really is so much better and easier to work on structured code then line-numbered code, and I do speak as someone who was very in love with line numbers, so did not drop that willingly, but I am so glad that I did.
Smoke makes things work. When the smoke gets out, it stops!
 
larny
Guru

Joined: 31/10/2011
Location: Australia
Posts: 346
Posted: 10:57pm 15 Mar 2016
Copy link to clipboard 
Print this post

Thanks for the replies. I had an idea after posting this thread. I solved the issue by inserting a line feed at line 120 & I may ( I don't now remember) have added a : as someone suggested.

However, I can see that it is better to insert one statement per line, so I'll adopt that method from now on.

I'm not using Line Numbers. The numbers were inserted by MM Edit.
I'm glad to see the last of them.

Here is a view of the modified code which shows the line numbers.




 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2931
Posted: 11:18pm 15 Mar 2016
Copy link to clipboard 
Print this post

@larny

A useful tip that helps make code easier to read is to 'indent tab' the lines of code between IF....ELSE and between ELSE....ENDIF.

It also helps detect 'missing' ENDIF's which is a common problem

Remember, this is just a 'tip' to make things easier for you; especially with long programs, or programs that you return to months later!

So your code above would now look like this:


i=1
DO
PRINT FORMAT$(Vt(i), "%4.3f"),;

IF V1(i) > 0.75 THEN
PRINT FORMAT$(V1(i), "%4.3f"),;
ELSE
PRINT "x",;
ENDIF

IF Vo(i) > 0.75 THEN
PRINT FORMAT$(Vo(i), "%4.3f"),;
ELSE
PRINT "y"; PRINT FORMAT$(Pc, "%4.0f")
ENDIF

PRINT #1, FORMAT$(Vt(i), "%4.3f"),;

IF V1(i) > 0.75 THEN
PRINT #1, FORMAT$(V1(i), "%4.4f"),;
ELSE
PRINT #1, "x",;
ENDIF

IF Vo(i) > 0.75 THEN
PRINT #1, FORMAT$(Vo(i), "%4.3f"),
ELSE
PRINT #1, "y",;
PRINT #1, FORMAT$(Pc, "%4.0f")
ENDIF

i = i+1
LOOP UNTIL Vt(i) > 8


EDIT I also like to add blank lines separating IF....ENDIF blocksEdited by WhiteWizzard 2016-03-17
 
larny
Guru

Joined: 31/10/2011
Location: Australia
Posts: 346
Posted: 08:44pm 16 Mar 2016
Copy link to clipboard 
Print this post

Thanks for the response. Yes the blank lines certainly make it clearer.
 
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