Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 08:55 05 May 2024 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 Line numbers/Labels

Author Message
nnvpaul
Newbie

Joined: 12/12/2014
Location: United States
Posts: 7
Posted: 06:52pm 11 Dec 2014
Copy link to clipboard 
Print this post

Hello
I am new to this forum and new to the maximite so please forgive me if I sound stupid. I have a colormax2. I can get it to respond to commands if I do not use line numbers or labels but it will not respond if I do use line numbers or labels. I do not get an error, it simply gives me a new line does not respond to the command. If I give it a GOTO command back to a line number I get an error that says it is an invalid line number. Does anyone have any suggestions? Also I have 'Beginning maximite" from circuit gizmos. Is there any other good info for a beginner to maximite?. Thanks.
Paul
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9066
Posted: 06:57pm 11 Dec 2014
Copy link to clipboard 
Print this post

Hi. Welcome to the forums.

Can you please post your code you are trying to get working, then we can examine it and help you find where/why it is going wrong.
Smoke makes things work. When the smoke gets out, it stops!
 
nnvpaul
Newbie

Joined: 12/12/2014
Location: United States
Posts: 7
Posted: 07:22pm 11 Dec 2014
Copy link to clipboard 
Print this post

If I write

setpin 11, 8
pin(11)= 1

I can measure 3.3 volts on pin 11 (I thought it should be 5 volts but it is 3.3)

If I write

print 2+2

I will see the result. 4

However if I write

10 setpin 11, 8
20 pin(11)= 1

It will seemingly accept the code but the pin will not be set and will not measure any voltage.

If I write

10 print 2+2

it will simply give me another prompt without printing 4.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5913
Posted: 07:39pm 11 Dec 2014
Copy link to clipboard 
Print this post

It's a long time since I've used line numbers but,
MMBasic doesn't like line numbers on the command line.
You CAN use them if you are in the editor but it is advisable to leave line numbers in the past....

If you have an existing program with line numbers that you are trying to convert, there are tools to help you.

  Quote  I can measure 3.3 volts on pin 11 (I thought it should be 5 volts but it is 3.3)


The CPU runs on 3.3V.
Some of the pins are 5V tolerant but any analog input needs to be between zero and 3.3V. If there is any chance of the input going higher than 3.3V, a resistor in series with the pin can help prevent disasters.

All outputs will be 3.3V unless you use open collector with a pullup resistor to 5V.

JimEdited by TassyJim 2014-12-13
VK7JH
MMedit   MMBasic Help
 
nnvpaul
Newbie

Joined: 12/12/2014
Location: United States
Posts: 7
Posted: 07:55pm 11 Dec 2014
Copy link to clipboard 
Print this post

I am getting the same result if I use labels or line numbers.

If I write

[label]: setpin 10, 8
[label]: pin(10)= 1

The same thing happens. New prompt no action.
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 08:00pm 11 Dec 2014
Copy link to clipboard 
Print this post

  nnvpaul said   I am getting the same result if I use labels or line numbers.

If I write

[label]: setpin 10, 8
[label]: pin(10)= 1

The same thing happens. New prompt no action.

Paul
You are actually writing code. The labels are an alternative to line numbers as a target in a GOTO statement. Having done the above you could input RUN and it would run your program. That program wouldn't do anything obvious for you as there are no output statements. You need to read a Getting Started section in your doco if it exists.
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 08:22pm 11 Dec 2014
Copy link to clipboard 
Print this post

Look at this page http://geoffg.net/maximite.html and download the MMBasic Language Manual. Have a quick scan through it. This is the reference for the latest firmware for the Maximite and the CGColorMax2. That latest version is 4.5. You should ensure that your machine has that firmware once you get familiar with it all.
 
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 09:54pm 11 Dec 2014
Copy link to clipboard 
Print this post

I thought MMbasic on a Maximite still did support line numbers, however I only use the editor and no line numbers like many others now too.

my example of the old way if it helps.

>10 PRINT "A"
>20 PRINT "C"
>15 PRINT "B"
>LIST
10 PRINT "A"
15 PRINT "B"
20 PRINT "C"
>RUN
A
B
C
>10 PRINT "a"
>LIST
10 PRINT "a"
20 PRINT "B"
30 PRINT "C"
>40 GOTO 30
>RUN
a
B
C
C
C
C
C 'until CTRL-C


 
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 12:27am 12 Dec 2014
Copy link to clipboard 
Print this post

Right .....
If you use the line numbers,
then you must type RUN (without number)
and enter
and the numbered code will do it's stuff
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 12:31am 12 Dec 2014
Copy link to clipboard 
Print this post

This seems to have been answered but just to be clear...

When you prefix a line with a number, that line is stored in memory as part of a program. You can keep doing this and slowly build up the program line by line. It is very tedious but that is how the BASIC language worked in the early days, and the Maximite supports that method of program entry.

Note that this method of entry does not work with the Micromite, only the Maximite.

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

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 12:36am 12 Dec 2014
Copy link to clipboard 
Print this post

@Paul,

As the others have pointed out Paul, what you are doing when you put in line numbers like that is that you are writing a program directly to your CGColorMax2. When you type your lines in, the MMBasic interpreter which is already running as soon as the power is turned on, "interprets" the line. If the line starts with a number followed by a space, it assumes that line is part of a program you are entering. If it doesn't start with a number it assumes you are entering a direct command that should be executed immediately - that's why you get "4" when you type "print 2+2" and why you just get a prompt when you type "10 print 2+2".

Most programs these days are written without line numbers because it improves program "structure". The problem with that though is that the MMBasic interpreter will execute these lines if they're typed in as you're doing because it doesn't know they're a program. The way to do it without line numbers is to use the "EDIT" command which brings up a section of MMBasic (the Editor) which is there for this purpose and can save your program to the SD card or load it straight to your CGColorMax2. You can read about how to use the "Editor" in the MMBasic Manual or the CGCOLORMAX Manual.

You can use any text editor to produce your program, e.g. Notepad in Windows and you can save the file to the SD card, but you need to change the file type to .BAS instead of .TXT. The best editor for this job though is the one that Jim Hiley wrote specifically for the job, MMEdit, which runs under Windows or Mac. MMEdit can also download your program to the CGColorMax2 via the USB cable. This is the way most of us do program development. You can also use "CircuitGizmos" MMIDE editor/IDE that was written when CG was developing the CGCOLORMAX, this also runs on your PC.

Try this to get the feel of what's happening.
-----------------

This program can be typed in at the terminal.

10 for i = 1 to 5
20 print "The count is: ",i
30 Next i
40 end

Now if you type in RUN, it will give you it's output.

This is that same program but you have to enter it via the EDIT command or an 'external' editor.

for i = 1 to 5
print "The count is: ",i
Next i
end

If you try to type the above code in at the terminal you will immediately get an ERROR when you enter the first line because it thinks it's a program and there's no matching NEXT statement for the FOR statement.

Hope this helps.

Greg


 
nnvpaul
Newbie

Joined: 12/12/2014
Location: United States
Posts: 7
Posted: 05:17am 12 Dec 2014
Copy link to clipboard 
Print this post

Thanks everyone for your responses. I appreciate your taking the time to help me. I understand what is happening now and I will learn how to use the editor.
Paul
 
Print this page


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

© JAQ Software 2024