Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: A beginner (almost), woes aplenty Post ReplyPost New Topic
<< Prev Page of 2
Author
Message << Prev Topic | Next Topic >>
Grogster
Guru
Guru
Avatar

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 5887
Posted: 13 July 2018 at 7:08am | IP Logged Quote Grogster

I don't think MMBASIC does that. The channel is left open till the program explicitly closes it. Perhaps that is something worthy of change. Geoff?

__________________
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
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2343
Posted: 13 July 2018 at 9:23am | IP Logged Quote Geoffg

Well, the correct way to handle a file is to open it, transfer data then close it. You could have an automatic close on the next open and save typing in one command (Close #x) but then you would have no warning if you accidentally misused a file number.

I have never heard of this automatic close before, I suspect Sinclair was on their own with that one.
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
plover
Senior Member
Senior Member


Joined: 18 April 2013
Location: Australia
Online Status: Offline
Posts: 202
Posted: 13 July 2018 at 7:38pm | IP Logged Quote plover

So it is a matter of keeping careful count on closing filenumber as soon as one has opened it. I will try.

In the manual p.4 I pondered the DOS MMBasic variables, decided to try and print them with following statements, they do look innocent I am testing them one by one, I copy and paste:


? MM.CMDLINE$
? MM.VRES
? MM.HRES



In the bassic terminal window

> ? MM.CMDLINE$

>



> ? MM.VRES
 24
>


> ? MM.HRES
 79
>


The two last ones seem ok but what about MM.CMDLINES

Quote:
 The read only variable MM.CMDLINE$ will return the DOS command line used to start MMBasic.


An empty line?? Looks I am in trouble again?
Back to Top View plover's Profile Search for other posts by plover
 
Grogster
Guru
Guru
Avatar

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 5887
Posted: 14 July 2018 at 10:00am | IP Logged Quote Grogster

Geoffg wrote:
Well, the correct way to handle a file is to open it, transfer data then close it. You could have an automatic close on the next open and save typing in one command (Close #x) but then you would have no warning if you accidentally misused a file number.

I have never heard of this automatic close before, I suspect Sinclair was on their own with that one.


I agree with that. I have never heard of auto-close either. You might have been right there about Clive!

Even thirty years ago when I was writing BASIC for my Atari, you had to CLOSE a file you had OPEN'ed. It was left up to the programmer to close the file. .....and that was in 8-bit BASIC from 35 years ago....

__________________
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
 
plover
Senior Member
Senior Member


Joined: 18 April 2013
Location: Australia
Online Status: Offline
Posts: 202
Posted: 14 July 2018 at 11:37pm | IP Logged Quote plover

I have moved back to about p.4 in the manual, looking at environment variables, interesting because I am outdone from the start, bit of the manual, split it up abit in my exercise book, the quote from my boo:

Quote:
Environment Variables
Windows environment variables can be used to change some characteristics of MMBasic.
MMDIR can be set to the default directory that MMBasic is to start running in. For example:
SET MMDIR=C:\Temp

will start MMBasic running in the directory C:\Temp. Without this the starting directory will be specified by
the operating system and will vary depending on how MMBasic is started. The directory path must be quoted
if it includes spaces. eg: SET MMDIR="C:\Program Files"
.

Following path line is where I have my running mmbasic.exe located and files as created etc. Presently this is where mmbasix.exe will run in that location.

SET MMDIR=C:\Users\Aurak\Downloads\180630-MMBasic-DOS\DOS_MMBasic\

So the test, I am going to try and get MMBasic to run in the parent directory, or one level back up the chain. As I understand done by setting env variable:


SET MMDIR=C:\Users\Aurak\Downloads\180630-MMBasic-DOS\




Done, then I check in the MMBasic terminal window with the "files" statement:



The files showing tells me that is the original location I started in tonight, but I expected to see the file in the parent directory??

I think I did restart, MMBasic from original location again, after I had caried out the SET MMDIR=... but at the same time I happened to read agin that the path should be quoated,@#$%, i have to repeat quotes

SET MMDIR="C:\Users\Aurak\Downloads\180630-MMBasic-DOS\"


Actually tried to put red colours around the " mark, that is no go.



SET path including the quotes. Then the make sure I had closed the MMBasic terminal window I then started it up again. Do the "files" test:



What, the same result??

Well making great progress here going backwards it seems. This is the way to learn I know but one does get a weeny bit tempted skip these basic things perhaps.

As this is run under windows 764 I am qurious where can I check the ENV list settings, in Linux with a bit of luck I can run a long list and actually see what the values are that are assigned.

Has MMDIR been assigned a value? I was hoping that running the "files" in the MMBasic terminal would have shown the parent directory (notice the "files" run result does show a path line.

Somebody drag me out the quicksand before it is too late.

Edited by plover on 14 July 2018 at 11:53pm
Back to Top View plover's Profile Search for other posts by plover
 
flip
Regular Member
Regular Member


Joined: 18 July 2016
Location: Australia
Online Status: Offline
Posts: 76
Posted: 15 July 2018 at 10:41am | IP Logged Quote flip

Hi plover,
Out of interest are you setting the MMDIR globally?
One way to check from within MM environment typing 2 commands in bold as follows:
DOS MMBasic Ver 5.04.09
Copyright 2011-2018 Geoff Graham

system "set"
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\phil\AppData\Roaming
...
mmdir=C:\users\phil"
...
windir=C:\WINDOWS

files
 Volume in drive C is Windows
 Volume Serial Number is 764F-B060

 Directory of C:\Users\phil

...
>
From above you can see even though quotes not required (and are mangled by Windows) the behaviour is OK

If you can't see MMDIR then need to set it in same session as you run MMBASIC, OR set it using Admin settings.
Start...Right-Click on My Computer...Properties...Advanced System Settings...Environment Variables..and add it there.

This is probably the best way if you want it permanently set to the same folder. I don't use this personally as I find it too restrictive, but that's just me.

Aside from this, I can see you have AUTORUN.BAS in the directory. it may be that there are some commands in here that are changing your current directory which might be overriding any environment variable.(I am not 100% sure on this as it may dependent how you are starting MMBASIC...but if ENV setting MMDIR wasn't your problem, you could try temporarily renaming AUTORUN.BAS to something else and try it)

Regards,
Phil

Edited by flip on 15 July 2018 at 11:02am
Back to Top View flip's Profile Search for other posts by flip
 
plover
Senior Member
Senior Member


Joined: 18 April 2013
Location: Australia
Online Status: Offline
Posts: 202
Posted: 15 July 2018 at 12:24pm | IP Logged Quote plover

flip
Wooww, better than I hoped for, the list of env variables.
I am going to attach terminal picture, but I see my thinking about how to verify if MMDIR was set, was good idea. From the list it is not set.

My thought was setting the env in a Windows terminal that might make it Global, obviously that has failed and as I accidentally also set it in root/admin terminal this did not do the trick either (nothing showing).

Your pathway to set the env variable, seems like hard work and it does not appeal to me as I will have forgotten in 3 days how I got there but might remember it was described here. Assume I will find out later if and what may be needed.

Add to this I don't know if I need to use it, not clear to me. I am just at the moment battling my way through the manual hoping something will stick in my head.

So locally you SET in MMBasic, and globally you take the tourist path via Windows. Then to check back into MMBasic and run the "system "SET"" and files.


Back to Top View plover's Profile Search for other posts by plover
 
flip
Regular Member
Regular Member


Joined: 18 July 2016
Location: Australia
Online Status: Offline
Posts: 76
Posted: 15 July 2018 at 4:38pm | IP Logged Quote flip

hey plover
Just a note on the global environment setting - it's permanent, so you wouldn't need to remember the procedure (and its handy knowledge for Windows).
Also note the example with the SYSTEM "SET" command you can run any OS command-see MMBASIC for DOS manual, and also type help at DOS prompt (or system "help" from MMBASIC)
And also note in your program you can also force directory change e.g.
system "CD"
C:\Users\phil\Apps\MMBasic\DEV\MMDB\AppBuilder\APT
chdir ".."
system "CD"
C:\Users\phil\Apps\MMBasic\DEV\MMDB\AppBuilder
>
These all work not only in 'command mode' but in 'run mode' so you have complete control either way.

Note all the following options are able to invoke MMBASIC from the directory you're program is in (which I think may be most useful)
- MMEDIT from Jim Hiley which you can invoke MMBASIC directly from a toolbar button
- Notepad++ which gives a roughly compatible (VB language) editor from which you can set the program to run from the menu (just takes a bit of mucking around to setup)
- Windows associate .BAS file with your MMBASIC.exe...Again this is a once-off setting, and will invoke MMBASIC in whatever current director you have File Explorer open in, just by double-clicking the .BAS file
- AUTORUN.BAS which you had on your system (see manual-this file depends on Windows paths). Once successfully invoked you can include commands like above 'CHDIR'-see MMBASIC for DOS manual.

The best thing I can suggest is until you fully understand exact behaviour... as I get bitten by Murphy too often always )start small, play around a lot, save regularly to different files and backup on different USB. Eventually (as with learning any new program/system) you'll be on top of it in no time. ... And of course there's always plenty of help if you get stuck....a great bunch of people on this forum..
EDIT just notice you got Geoff Graham's demo Simple DB program running - so all good - until next problem !!...happy tinkering!
Regards Phil


Edited by flip on 15 July 2018 at 4:49pm
Back to Top View flip's Profile Search for other posts by flip
 


If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Search the forums using Google.
<< Prev Page of 2
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.1406 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.14