Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: Micromite MMBasic Ver 5.04.10 Beta Post ReplyPost New Topic
<< Prev Page of 4 Next >>
Author
Message << Prev Topic | Next Topic >>
Volhout
Regular Member
Regular Member


Joined: 05 March 2018
Location: Netherlands
Online Status: Offline
Posts: 65
Posted: 24 August 2018 at 6:36pm | IP Logged Quote Volhout

Hi WhiteWizzard,

I tried with a little code in MM.STARTUP

Sub MM.STARTUP
  Const H1=26
End Sub


Did a library save (after deleting all libraries, so this is the only one in the library), checked with memory that there is actually a library (1k size) added, and rebooted the mx170.

Then typed
> print H1
0

That did not result in H1 getting a value in either commandline or in program run mode. Then I read the note in the MM.STARTUP section:

Quote:
Note that you should not use MM.STARTUP for general setup of MMBasic (like dimensioning arrays, opening
communication channels, etc) before running a program. The reason is that when you use the RUN command
MMBasic will clear the interpreter's state ready for a fresh start. If you do want to setup MMBasic like this you
can place the code for this in the LIBRARY (but not in a subroutine or function) as this is run after the RUN
command has reset the interpreter's state but before the program in main memory is run.


So that is not an option.


Edited by Volhout on 24 August 2018 at 6:40pm


__________________
If nothing goes right ... turn left


Back to Top View Volhout's Profile Search for other posts by Volhout
 
matherp
Guru
Guru


Joined: 11 December 2012
Location: United Kingdom
Online Status: Offline
Posts: 2340
Posted: 24 August 2018 at 6:58pm | IP Logged Quote matherp

Try this in the library

Sub MM.STARTUP
  DIM INTEGER H1=26
End Sub


Edited by matherp on 24 August 2018 at 6:58pm
Back to Top View matherp's Profile Search for other posts by matherp
 
Volhout
Regular Member
Regular Member


Joined: 05 March 2018
Location: Netherlands
Online Status: Offline
Posts: 65
Posted: 24 August 2018 at 7:22pm | IP Logged Quote Volhout

Hi matherp,

When I try
Sub MM.STARTUP
  DIM INTEGER H1=26
End Sub


library save, and reboot

then the result is
commandline: print H1 gives 26
run a program: print H1 gives 0
library delete

Sub MM.STARTUP
  CONST H1=26
End Sub


library save, and reboot

then the result is
commandline: print H1 gives 0
run a program: print H1 gives 0
library delete

Sub MM.STARTUP
  H1=26
End Sub


library save, and reboot

then the result is
commandline: print H1 gives 26
run a program: print H1 gives 0

Using
Micromite MKII MMBasic Ver 5.04.10 Beta 9
Copyright 2011-2018 Geoff Graham

The latest....


__________________
If nothing goes right ... turn left
Back to Top View Volhout's Profile Search for other posts by Volhout
 
matherp
Guru
Guru


Joined: 11 December 2012
Location: United Kingdom
Online Status: Offline
Posts: 2340
Posted: 24 August 2018 at 8:01pm | IP Logged Quote matherp

Quote:
then the result is
commandline: print H1 gives 26
run a program: print H1 gives 0
library delete


Just add a call to MM.STARTUP at the top of your program then H1 will be set after reset and in a program
Back to Top View matherp's Profile Search for other posts by matherp
 
Volhout
Regular Member
Regular Member


Joined: 05 March 2018
Location: Netherlands
Online Status: Offline
Posts: 65
Posted: 24 August 2018 at 8:47pm | IP Logged Quote Volhout

you are correct, that works.

The thing I do not understand is that it does not work with CONST H1=26

Using a CONST was great because it cannot be changed afterwards.
It gives robustness and prevents double use of variables especially in larger programs.
Remember, once it is saved in the library, the variables existence is invisible to the outside world (meaning commandline and the running program).

Anyway, a solution is found....

Thanks you

Volhout



__________________
If nothing goes right ... turn left
Back to Top View Volhout's Profile Search for other posts by Volhout
 
matherp
Guru
Guru


Joined: 11 December 2012
Location: United Kingdom
Online Status: Offline
Posts: 2340
Posted: 24 August 2018 at 8:57pm | IP Logged Quote matherp

Quote:
The thing I do not understand is that it does not work with CONST H1=26


Constants only have scope within the subroutine in which they are defined. Global constants are defined in the main program but that doesn't work with MM.STARTUP

Quote:
prevents double use of variables especially in larger programs.


Use OPTION EXPLICIT and LOCAL and this protects you properly

Edited by matherp on 24 August 2018 at 8:59pm
Back to Top View matherp's Profile Search for other posts by matherp
 
PicFan
Senior Member
Senior Member


Joined: 18 March 2014
Location: Austria
Online Status: Offline
Posts: 103
Posted: 25 August 2018 at 5:40am | IP Logged Quote PicFan

Try this:

CONST H1 = 25
. . .


Library save

Rem main prog.
print H1

reboot
run

Wolfgang

Edited by PicFan on 25 August 2018 at 6:50am
Back to Top View PicFan's Profile Search for other posts by PicFan
 
Volhout
Regular Member
Regular Member


Joined: 05 March 2018
Location: Netherlands
Online Status: Offline
Posts: 65
Posted: 27 August 2018 at 5:19pm | IP Logged Quote Volhout

Result is the same.
Works in the running program,
But not from commandline...

Volhout

__________________
If nothing goes right ... turn left
Back to Top View Volhout's Profile Search for other posts by Volhout
 
Azure
Guru
Guru
Avatar

Joined: 09 November 2017
Location: Australia
Online Status: Offline
Posts: 431
Posted: 27 August 2018 at 5:47pm | IP Logged Quote Azure

@Volhout

What you are trying to do is not a part of the 5.04.10 Beta. It is the way MM Basic (and most other basic interpreters) normally work.

This thread is supposed to be about new releases to beta 10 and testing the new features and changes in 5.04.10 Beta or if something is broken in this version that worked in previous verions.

I think it would be better if you continued any new posts about this in a new thread as it relates to all versions and is a feature request. That way it can continue the discussion without taking this thread off topic.
Back to Top View Azure's Profile Search for other posts by Azure
 
Volhout
Regular Member
Regular Member


Joined: 05 March 2018
Location: Netherlands
Online Status: Offline
Posts: 65
Posted: 27 August 2018 at 6:21pm | IP Logged Quote Volhout

Dear Azure,

You are correct. Apologies.
It started out as a feature request for this beta to Geoff.
And resulted in a lot of well meant good advise for work arounds.
Geoff, sorry I hijacked your thread.

Let's focus on the features of 5.04.10 beta.....

Regards,

Volhout.

__________________
If nothing goes right ... turn left
Back to Top View Volhout's Profile Search for other posts by Volhout
 
PicFan
Senior Member
Senior Member


Joined: 18 March 2014
Location: Austria
Online Status: Offline
Posts: 103
Posted: 28 August 2018 at 8:00pm | IP Logged Quote PicFan

PicFan wrote:
Try this:

CONST H1 = 25
. . .


Library save

Rem main prog.
print H1

reboot
run

Wolfgang


Ctrl-C
MM-Edit Command line: print H1
25
Back to Top View PicFan's Profile Search for other posts by PicFan
 
Grogster
Guru
Guru
Avatar

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 6128
Posted: 04 September 2018 at 5:40pm | IP Logged Quote Grogster

Pleased to be able to report that everything seems to work fine in this beta.

I must say that I LOVE the new textbox qwerty layout. Having the DEL key on both pages of keyboard makes for nice easy backspace when you type something wrong.

Also rather like the new cancel(Can) key. That too will be useful to have.(although, dealing with wrong input was easy enough once you touched Ent, but this is a nicer way to do it.)

__________________
Smoke makes things work. When the smoke gets out, it stops!
Back to Top View Grogster's Profile Search for other posts by Grogster Visit Grogster's Homepage
 


<< Prev Page of 4 Next >>
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1719 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.17