Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 18:18 07 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 : Syntax questions.

     Page 1 of 2    
Author Message
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 07:08pm 27 Jun 2016
Copy link to clipboard 
Print this post

In the single line "IF expr THEN stmt ELSE stmt" is it permissible to use ":" separated statements like this,

IF a=b THEN c=d+1 : e=f+1 : g=k ELSE c=d+2 : e=f+2 : g=k+1

or do you have to use the multiline form?

IF a=b THEN
c=d+1 : e=f+1 : g=k
ELSE
c=d+2 : e=f+2 : g=k+1
ENDIF

Does the MMBasic interpreter ignore both leading blanks and leading tabs on a line or are you restricted to using leading blanks to beautify the program?
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 08:13pm 27 Jun 2016
Copy link to clipboard 
Print this post

  Paul_L said   In the single line "IF expr THEN stmt ELSE stmt" is it permissible to use ":" separated statements

Yes, but only in the last "stmt" (that is standard BASIC).
Normally it is used as in: IF expr THEN stmt : stmt : stmt : etc

  Paul_L said  Does the MMBasic interpreter ignore both leading blanks and leading tabs on a line

Yes again.

You should get yourself a Micromite to try these things out - it is a fun thing to play with.

Geoff
Geoff Graham - http://geoffg.net
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 09:51pm 27 Jun 2016
Copy link to clipboard 
Print this post

  Geoffg said  You should get yourself a Micromite to try these things out - it is a fun thing to play with.


Yes I should, but, based on what you said yesterday and on your new video, I think I have to wait for the 100 pin to become available. It really sounds like it is a fun thing to play with.

Paul

Edited by Paul_L 2016-06-29
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4036
Posted: 09:59pm 27 Jun 2016
Copy link to clipboard 
Print this post

Geoff (and anyone else!) - is the DOS (Windows) version enough to answer these sorts of questions?

John
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 10:31pm 27 Jun 2016
Copy link to clipboard 
Print this post

@John - Which DOS version???? The original cassette MSBasic on the RadioShack TRS-80 did not accept colons to make compound statements within one numbered line. (I just checked this.)

The TRS-80 Model III DOSPLUS Basic by Mark Lautenshlager did accept colons within a numbered line. ( I just check this as well.)

The original IBM PC Cassette Basic did not accept colons within a numbered line. (I just checked this on my cassette basic PC with serial number 13!)

IBM PCDOS 3.1 Basic did accept colons within a numbered line. (I also just checked this.)

(I never throw anything out and I've got a big attic full of old computers. The original cassette basic PC is sitting on top of an IBM 1401 card punch.)

I depends on whether the guy who wrote the interpreter had a brain!

We're very lucky, Geoff has a brain, he uses it to good advantage, and he answers questions!

Paul

Edited by Paul_L 2016-06-29
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1114
Posted: 10:44pm 27 Jun 2016
Copy link to clipboard 
Print this post

@Paul,
The 100 pin MM+ is not much different from the 64 pin MM+, just a few more I/O pins, so why wait, jump in and have fun😀😀😀😀

There are several sources for the 64 pin MM+ - Circuit Gizmos, Grogster, White Wizard and Silicon Chip magazine and all have had great reviews.
Re the Basic for DOS John spoke of, that is the MMBASIC for DOS version.
Regards,
Panky.
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4036
Posted: 10:59pm 27 Jun 2016
Copy link to clipboard 
Print this post

The DOS version of MMBasic

John
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 12:18am 28 Jun 2016
Copy link to clipboard 
Print this post

  Paul_L said  
  Geoffg said  You should get yourself a Micromite to try these things out - it is a fun thing to play with.


Yes I should, but, based on what you said yesterday and on your new video, I think I have to wait for the 100 pin to become available. It really sounds like it is a fun thing to play with.

Paul



Why even bother waiting?

Just grab a couple of 28 pinners, cap & a few leds, and start playing about on a bread board.

Even a PicKit3 is under $20 for a clone.

Cheers.
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 06:01am 28 Jun 2016
Copy link to clipboard 
Print this post

value = pin(26) * 0.00916666666666666666666666666667
Error: Expression syntax

I even tried
value = (pin(26) * 0.00916666666666666666666666666667))
Error: No closing brackets


What am I doing wrong?
pin 26 is an analog input, it measures the voltage and I can get it to print the voltage
but i want print the voltage * 0.00916666666666666666666666666667

Edit: I figured it out - too many decimal places (I think anyway)Edited by lew247 2016-06-29
 
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 327
Posted: 08:16am 28 Jun 2016
Copy link to clipboard 
Print this post

  Paul_L said  The TRS-80 Model III DOSPLUS Basic by Mark Lautenshlager did accept colons within a numbered line. ( I just check this as well.)


Just for the record, Mark Lautenshlager didn't write DOSPLUS, he worked for Micro-Systems and wrote their manuals did their advertising. Mark and I later worked together at another company, and my ex-wife also worked briefly for Micro-Systems. That said, Mark is a brilliant computer guy and writer and I do miss working with him. We did write a fair amount of QuickBASIC code together. Come to think of it, he was an usher at my wedding.

As for as using the DOS based MMBASIC, it will give you and overall feel for the main syntax of the Micromite version. However, none of the hardware specific commands are implemented (SETPIN, HUMID, SERVO, etc). I regularly use the DOS version just to a quick refresh my memory on how to use things like RND (always forget how it works), SELECT/CASE or test some twisted bit of logic.

Seriously, try getting your feet wet with Micormite-170. In the USA you can buy either a pre-programmed chip or a complete kit from CircuitGizmos for a very reasonable price. He is a reliable seller, I bought my first 'Mites from him.

--Curtis


I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:09am 28 Jun 2016
Copy link to clipboard 
Print this post

  lew247 said   value = pin(26) * 0.00916666666666666666666666666667
Error: Expression syntax



Hi Lew,

That number is a recurring decimal.
It is a rational number and the ratio of two integers.

Just like 1/3=0.3333333333333;
and 2/3=0.666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666 6666666666666666666666666666666666666666666666666666666666666666666666666666666667

etc.

Your number original can be more simply used in calculations as 11/1200.

11/1200=0.0091(6).

So,
[Code]value=pin(26)*11/1200[/code]
would be a whole heap neater.

Cheers.

 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3282
Posted: 11:46am 28 Jun 2016
Copy link to clipboard 
Print this post

  lew247 said   value = pin(26) * 0.00916666666666666666666666666667
Error: Expression syntax

One issue with MMBasic is that it does not give intelligent and verbose error messages. This is one of the sacrifices that came about when squeezing it into a micro controller.

Geoff
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 11:47am 28 Jun 2016
Copy link to clipboard 
Print this post

  lew247 said   value = pin(26) * 0.00916666666666666666666666666667
Error: Expression syntax

Edit: I figured it out - too many decimal places (I think anyway)

Correct.
MMBasic uses 32 bit floating point numbers.
That gives a maximum number of significant figures of around 8 so your number was way too long.
Even if you could enter the number, there is no way the extra digits could add to the precision of the calculation.

Jim
VK7JH
MMedit
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 10:45pm 28 Jun 2016
Copy link to clipboard 
Print this post

  Justplayin said  Just for the record, Mark Lautenshlager didn't write DOSPLUS, he worked for Micro-Systems and wrote their manuals did their advertising. Mark and I later worked together at another company, and my ex-wife also worked briefly for Micro-Systems. That said, Mark is a brilliant computer guy and writer and I do miss working with him. We did write a fair amount of QuickBASIC code together. Come to think of it, he was an usher at my wedding.

As for as using the DOS based MMBASIC, it will give you and overall feel for the main syntax of the Micromite version. However, none of the hardware specific commands are implemented (SETPIN, HUMID, SERVO, etc). I regularly use the DOS version just to a quick refresh my memory on how to use things like RND (always forget how it works), SELECT/CASE or test some twisted bit of logic.

Seriously, try getting your feet wet with Micormite-170. In the USA you can buy either a pre-programmed chip or a complete kit from CircuitGizmos for a very reasonable price. He is a reliable seller, I bought my first 'Mites from him.

--Curtis


Well, pleased to make your acquaintance Curtis! You're almost as old as I am.

I lost track of Mark when MSS moved from Hollywood to Boca. I'm glad to find someone else who knew Mark back when. Have you kept in touch with him down through the years? What is he doing now?

I know that circuitgizmo is a reliable seller! I don't want to waste time fooling around with mites to no purpose. The system I'm building is complex and needs a lot of inputs. It will wind up being spread all over a large single floor house. I am 76 years old and my eyes and hands (and come to think of it almost everything else) don't work very well anymore. I will design this system the way I designed the interfaces between the inertial navigation and autopilot systems for the 707-321 aircraft, on paper. Then I hope to find some kid who wants to learn about electronics to build it for me.

Circuitgizmo has already told me that he is very busy. How about you? Would you like to build this mess for me?

Paul
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 11:59am 04 Jul 2016
Copy link to clipboard 
Print this post

I have two more detailed syntax questions.

1. Will val(a$) extract only a leading numeric string if other than numeric characters follow a numeric string in a$ like this?

a$="123.6#!!xyz"
b=val(a$)
? b

result 123.6

2. Is a return command needed before the end sub command in subroutines? It seems redundant.

sub ublewit(a$)
? a$
' return ?????
end sub

 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 02:40pm 04 Jul 2016
Copy link to clipboard 
Print this post

One more stupid syntax question.

When delim$ is not contained in a$ like this,

a$="123.6" : delim$=","
pos = instr(a$,delim$)
? pos

The documentation doesn't say what pos will wind up being.

0, infinity, error, 6, or an error crash are my bets.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 03:33pm 04 Jul 2016
Copy link to clipboard 
Print this post

It returns zero if not present in the string.

From the manual:
  Quote  INSTR( [start-position,] stringsearched$,
string-pattern$ )
Returns the position at which 'string-pattern$' occurs in 'string-searched$',
beginning at 'start-position'.
Both the position returned and 'start-position' use 1 for the first character, 2
for the second, etc. The function returns zero if 'string-pattern$' is not found.


You will have problems with your code because POS is a keyword and returns the current cursor position.

Jim
VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 03:43pm 04 Jul 2016
Copy link to clipboard 
Print this post

  Paul_L said   I have two more detailed syntax questions.

1. Will val(a$) extract only a leading numeric string if other than numeric characters follow a numeric string in a$ like this?

a$="123.6#!!xyz"
b=val(a$)
? b

result 123.6

2. Is a return command needed before the end sub command in subroutines? It seems redundant.

sub ublewit(a$)
? a$
' return ?????
end sub



The result from your first question is:
  Quote  DOS MMBasic Version 4.5
Copyright 2011-2014 Geoff Graham

123.6
>


You will get into trouble if the extra characters can form part of a number such as 'e'

Returning from a SUB xxx only requires END SUB and a RETURN would not be a good idea.

If you used the old fashioned GOSUB zzz

zzz:
..
..
..
RETURN

Here RETURN is the correct way to return.

I strongly recommend getting the DOS version of MMBasic to play with.
It's syntax is V4.5 which has a few changes, especially around STR$ and FORMAT but it is still a great way to try out the various commands without sacrificing too many electrons.

Jim
VK7JH
MMedit
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 04:42am 05 Jul 2016
Copy link to clipboard 
Print this post

@Jim
Thanks. The three different manuals sometimes leave something to be desired. Either that or it's just easy to confuse polaks like me.
----------------------
GOSUB target CMM MM DOS
Initiates a subroutine call to the target, which can be a line number or a
label. The subroutine must end with RETURN.

This conflicts with the definitions of SUB and END SUB in the uM+ manual and leaves me with the idea that you must stick in a RETURN before the END SUB.
----------------------
VAL( string$ ) CMM MM DOS
Returns the numerical value of the ‘string$’. If 'string$' is an invalid
number the function will return zero.
This function will recognise the &H prefix for a hexadecimal number,
&O for octal and &B for binary.

Well, "123.6#!!xyz: in my example above might be an invalid number. The original MSBasic TRS80 manual says that val() will evaluate leading numbers and ignore following alpha stuff.
----------------------
INSTR( [start-position,] string-searched$, stringpattern$ ) CMM MM DOS
Returns the position at which 'string-pattern$' occurs in 'stringsearched$',
beginning at 'start-position'.

It fails to state what is returned if it doesn't find the pattern in the target.
----------------------

I presume that the DOS version of MMBasic runs in a command window under win7. Where do I find it?

I guess polaks are easily confused. By the way, in the Polish language "polak" means a polish male, "polka" means a polish female. That's sort of why my name is Lepkowski but my wife's name is Lepkowska. Now maybe you have some idea why us polaks are easily confused.

Paul -- no, I guess that is Pavel.
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:36am 05 Jul 2016
Copy link to clipboard 
Print this post

  Paul_L said   I don't want to waste time fooling around with mites to no purpose. The system I'm building is complex and needs a lot of inputs. It will wind up being spread all over a large single floor house.


With respect Paul,

You really should look at getting one of Geoff's Backpacks.

It would be far from a waste of time.

I currently have 3; 2 in service, and still evolving.

The third one serves a test platform for new portions of code.
Once it's debugged, I can transfer that to my working boards & make final changes there.

Not a lot of hardware assembly required, once you find someone to solder the board.
I let my 15 year old son assemble mine; he does it with the naked eye; with me generally commenting "Turn some more lights on".

Just plug it on a bread board, 4 wires to a Serial to USB adaptor & it's away.

Cheers

Phil
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025