Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:59 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 : MMBasic for DOS. Ver 5.04 Beta

     Page 5 of 6    
Author Message
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 12:53am 20 Jul 2017
Copy link to clipboard 
Print this post

Hi Geoff,
Just finding a stopper for me with LOAD command from within a program, it seems to generate File not found. I have made it work occasionally, but can't seem to figure out the magic sequence. The LOAD command seems to always work in command mode.

In the Micromite this may happen as well(not tested), but this failure to LOAD and RUN within a program may be preferred behaviour, as it could easily be possible to write a program that recursively loads and runs the same program, thus destroying your chip pretty quickly. So if this is deliberate behaviour for the PIC, could the rule be relaxed for the DOS version?
(That is assuming this issue is confirmed to be an issue)

Also as a side issue, the ON ERROR SKIP doesn't seem to work when placed before the LOAD command in a program

Another strange one (this is not too bad) is where the INPUT command is supplied 2 parameters,
1) if the first is a string literal - fine works like the book
2) if the first is a string expression, it looks weird, but the user input goes into the variable (second parameter) OK
3) if the first is a variable, it puts the data into the first variable and nothing into the second, which I can see now thinking about it is expected behaviour - designed especially for when there are a list of input values provided.
So there's probably not much can be done about this one, and it's not a problem when combined with PRINT command (so not requiring use of the prompt string at all)...just that case 2 looks weird and seems inconsistent with 3 until you really think about it.

Attached is a test file I have written for these things..


2017-07-20_104705_test1.bas.zip

Really enjoying this stuff..
Regards,
PhilEdited by flip 2017-07-21
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 03:05pm 20 Jul 2017
Copy link to clipboard 
Print this post

Hi all,
  Quote  An alternative is to run MMBasic in DOSBox (http://www.dosbox.com/wiki/).
This would have been nice, but running this gives
C:\>mmbasic
This is a Windows NT character-mode executable
If anyone knows a work-around it may be handy...I suspect it may need to be recompiled as a 16-bit app, in any case for myself I wouldn't be using MM with DOSBox at this stage (though it is a great little program)

Regards,
Phil
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 07:00pm 20 Jul 2017
Copy link to clipboard 
Print this post

If you get that message then it means that it is a Windows program (opens its own window), not a DOS program.

Maybe call it MMBasic for Windows? :)Edited by MicroBlocks 2017-07-22
Microblocks. Build with logic.
 
cdeagle
Senior Member

Joined: 22/06/2014
Location: United States
Posts: 265
Posted: 05:37am 21 Jul 2017
Copy link to clipboard 
Print this post

It seems I have to load a program twice before MMBASIC for DOS accepts it.

> load "chebyshev_planet.bas"
Error: No such file or directory
> load "chebyshev_planet.bas"
>
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3281
Posted: 11:31pm 22 Jul 2017
Copy link to clipboard 
Print this post

I believe that I have found the cause of both the difficulty in using LOAD and the issue with OPTION ERROR SKIP before LOAD or RUN.

Attached is Beta 6 which works in all my tests: 2017-07-23_091214_DOS_MMBasic_5.04.05_Beta_6.zip

As a side comment: The command OPTION ERROR (which only worked for file errors) is superfluous so I have removed it - ON ERROR, which works much better, should be used in its place. With the next version of the Micromite Plus I will place it on the obsolete list for eventual removal.

  flip said  Another strange one (this is not too bad) is where the INPUT command is supplied 2 parameters,
1) if the first is a string literal - fine works like the book
2) if the first is a string expression, it looks weird, but the user input goes into the variable (second parameter) OK
3) if the first is a variable, it puts the data into the first variable

The prompt string, if specified, is the first parameter and it must be a quoted string constant (ie, "prompt") not a variable or an expression - so the command is OK and trying to do what it should. I will edit the manual to make it clear that only a string constant is allowed. I believe that the INPUT command harks back to the days when John Kemeny and Tom Kurtz designed the first elements of the language 50 years ago. They must have got up out of the wrong side of the bed that day.

Geoff
Geoff Graham - http://geoffg.net
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 02:54am 23 Jul 2017
Copy link to clipboard 
Print this post

Thanks Geoff !!
All fixed and more!! (and so quickly)...

This has now proved to me that we can pretty much build entirely in MM environment(s) if we want to
Dare I suggest connectivity with the real uMite?...rhetorical...I might try making a bit of middleware glue to join MM DOS with putty...

Also for anyone interested I have attached a demo program with some small improvements..unzip to its own directory and have a play.
2017-07-23_124117_DosTestsDemos.zip

Regards,
Phil



 
cdeagle
Senior Member

Joined: 22/06/2014
Location: United States
Posts: 265
Posted: 03:10am 23 Jul 2017
Copy link to clipboard 
Print this post

Thanks Geoff
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 03:18am 23 Jul 2017
Copy link to clipboard 
Print this post

the system command still starts in the wrong directory when a basic file is dropped onto the mmbasic.exe icon. it incorrectly starts in "C:\Documents and Settings\admin" rather than the current directory from which mmbasic was launched.

> system "cd"
C:\Documents and Settings\admin
>


did you have any luck with the win32 console functions located here:
https://docs.microsoft.com/en-us/windows/console/console-functions
i did look up the watcom compiler, and it looks like you can gain access to them simply by including wincon.h, see the example here:
https://cboard.cprogramming.com/c-programming/113081-moving-console-cursor-printing-color.html

i still recon a simple gotoXY(x, y) and colour(attribute) would keep many folks happy.


cheers,
rob :-)Edited by robert.rozee 2017-07-24
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3281
Posted: 12:46pm 23 Jul 2017
Copy link to clipboard 
Print this post

The starting directory is set by the operating system. On mine it is set to the location of the file being dropped.

Yes thanks, I have got access to the win32 console functions and it opens up a whole new world of things that can be done. I'm still working through the list and the next beta should have something like gotoXY(x, y) and colour(attribute) plus others.

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

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6264
Posted: 01:27pm 23 Jul 2017
Copy link to clipboard 
Print this post

Geoff,
Can we get MM.CMDLINE$ implemented to give the full command line that was used to invoke MMBasic.
That would allow more flexibility when starting MMBasic from batch files etc.

Jim

VK7JH
MMedit
 
damos
Regular Member

Joined: 15/04/2016
Location: Australia
Posts: 74
Posted: 02:41pm 23 Jul 2017
Copy link to clipboard 
Print this post

Thanks Geoff, this is really awesome.

Is there any chance that we could have a plugin system to create device emulators? I don't really want to write in C, and would prefer C#/.Net, so rather than using DLLs as the interface we could use named pipes or even web sockets which would allow the emulator to not even be on the computer.

The idea is we can write the code so that it is exactly the same as the Micromite version in Windows, so we need I2C, SPI and pin emulators. We need to option to add multiple devices to the same pin. Maybe setup a command like:

OPTION I2C Pipename
or
OPTION SPI 127.0.0.1:1234

The idea is that emulators could be created for LCD displays, touchscreens, signal sources, protocol analysers, logic analysers etc.

A could of other ideas:

A MMEdit plugin that you can just parse single lines of command to and get a response. With modern programming environments, I almost never get compile errors because they are detected by squiggly underlines as I type the code. Visual Studio does this by actually running the code through the compiler which finds the errors that it would have picked up in a compile. It is a bit different with interpreted languages, but a feature like this in MMEdit would be a big help.


Dan
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 02:56pm 23 Jul 2017
Copy link to clipboard 
Print this post

by joves, you're right, looks like a bug in (at least) XP. the workaround is to use GetModuleFileName and chop off the .exe name to get the correct working directory.

but you'd also want to check the case of when mmbasic was launched through a (.bas) file association, in which case you may NOT want to change the current directory.

SetLength(buffer, 1024);
I:=GetModuleFileName(0, pchar(buffer), length(buffer));
SetLength(buffer, I);
writeln('GetModuleFileName = ',buffer);



cheers,
rob :-)
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3281
Posted: 03:28pm 23 Jul 2017
Copy link to clipboard 
Print this post

  damos said  Is there any chance that we could have a plugin system to create device emulators? I don't really want to write in C, and would prefer C#/.Net, so rather than using DLLs as the interface we could use named pipes or even web sockets which would allow the emulator to not even be on the computer.

For the moment that is going a bit overboard. Especially from within a 32-bit DOS box.

One important point - I never intended this to be an emulator for a Micromite (ie, emulating I/O, I2C, graphics, etc). It would be impossible to get a good emulation and why bother when it is so easy to use a real Micromite with real I/O?

Also, I don't plan on turning this into a fully blown Windows development system (ie, with multiple windows, fonts, etc). There are plenty of good implementations of this type of environment already available (but at a cost).

This is just a simple and fast program for executing BASIC code. Use it for learning BASIC, testing program constructs, simple tasks and playing ancient computer games like Hamurabi.

Geoff
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 03:43pm 23 Jul 2017
Copy link to clipboard 
Print this post

not to forget, you (geoff) may find the win32 version a more convenient platform for testing out new ideas for changes in the interpreter - with far more control over the running environment that on a PIC32.

i've done a little more testing and the CD bug in XP et al only kicks in with a dropped file, not with a file extension association. but then it occurred to me that the simplest solution is to just apply the following rule:

if mmbasic.exe is started with a .bas filename as the parameter, and that parameter contains a path, then always set the current directory to that path contained in the parameter.

i believe this should work transparently with all versions of windows.


cheers,
rob :-)
Edited by robert.rozee 2017-07-25
 
damos
Regular Member

Joined: 15/04/2016
Location: Australia
Posts: 74
Posted: 04:57pm 23 Jul 2017
Copy link to clipboard 
Print this post

  Geoffg said   For the moment that is going a bit overboard. Especially from within a 32-bit DOS box.

One important point - I never intended this to be an emulator for a Micromite (ie, emulating I/O, I2C, graphics, etc). It would be impossible to get a good emulation and why bother when it is so easy to use a real Micromite with real I/O?


For me the main problem is accessibility. There are lots of times when I want to work on the Micromite projects and I just can't bring the hardware with me. With the emulator I can do the whole thing with just a laptop. Examples in include air travel, and lots of times I spend waiting, or even on the couch in front of the TV with the family, rather than being locked away in the workshop.

The Win32 environment also lends itself to better debugging tools because it is significantly more powerful. A line by line debugger with variable inspection/modify capabilities is wonderful. I even get that with a text editor/Chrome for web development. These features don't need to be part of MMBasic, we just need to be able to hook into it. I prefer MMBasic to be very simple but code-compatible.

An alternative is on-device debugging like when I run through Android Studio. It all runs on the device, but I get all the benefits of breakpoints, line by line debugging and variable inspection. This doesn't solve the accessibility issues like the emulator though.

Dan
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3281
Posted: 05:19pm 23 Jul 2017
Copy link to clipboard 
Print this post

  robert.rozee said   not to forget, you (geoff) may find the win32 version a more convenient platform for testing out new ideas for changes in the interpreter

You are right, the edit/compile/test cycle is very fast.

  robert.rozee said   apply the following rule:

if mmbasic.exe is started with a .bas filename as the parameter, and that parameter contains a path, then always set the current directory to that path contained in the parameter.

I'm planning to implement Jim's idea of MM.CMDLINE$ and that will make the full command line (including the path of the BASIC file) available to the BASIC programmer.

Geoff


Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 05:41pm 23 Jul 2017
Copy link to clipboard 
Print this post

when launched with a .bas filename as a parameter via extension association or dropped file, does watcom C provide the full (expanded) path to the C program? setting the current directory to this would save folks having to do any checks or manipulation of the current directory themselves, removing quite a bit of potential confusion.


now just an idea... what if setpin and pin()= were allowed in the win32 version, but performing the function of outputting a message to a nominated comm port?

for instance, the following code:
A=4
B=1
pin(A)=B

might cause the string "pin(4)=1" to be sent to com1: that an attached (real) micromite could then process as a direct command.

reading a pin could be handled thus:
C=5
I=pin(C)

causes the string "? pin(5)" to be sent to com1: with the response read back (with a suitable timeout) by the win32 mmbasic interpreter stored into I.

it may be possible to extend the above idea to work with a great many of the pic32 specific commands and functions. an attached micromite sitting at the command prompt could then be 'remotely controlled' by an mmbasic program running on a PC. the basic program on the PC may be considerably larger or more complicated than what could run on the micromite.

note: this is just an idea that occurred to me. it may not be a good idea, or may be far too complicated to implement. but is perhaps worthy of kicking around to see if it has any merit or usefulness


cheers,
rob :-)Edited by robert.rozee 2017-07-25
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3281
Posted: 07:52pm 23 Jul 2017
Copy link to clipboard 
Print this post

From my experiments MM.CMDLINE$ only provides the basic file name, without the path, so I guess that it will not address your issue - but I really don't want to include a hack for XP!!!! Can you use CHDIR in your programs?

On your idea of simulating I/O pins... It is just not feasible, I/O pins are dynamic and that is hard to realistically simulate. And what about SPI, I2C, etc? The reality is that it is not possible to practically simulate a Micromite in all its glory. Especially when an E28 hanging off the end of a USB cable can do it much better.

(but I do admire your tenacity!)

By the way Rob, we gave been seeing a lot about the floods in Christchurch on the news. Does it affect you? Your city has certainly been in the wars what with earthquakes, floods, etc. Have you considered moving to Perth? We could then argue these issues face to face!

And Grogster, if you are reading this, Dunedin (another delightful city by the way) has also been flooded - are you OK? Does the flooding affect you?

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

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6264
Posted: 08:08pm 23 Jul 2017
Copy link to clipboard 
Print this post

Windows has always done strange things with directories. W10 tries to be helpful and remember the last one you used for a particular program to the extent of ignoring your requested folder next time.

With MMEdit, I call MMBasic.exe with "ShellExecuteExA" and it has an option to pass the starting folder. I set the starting folder as the one with the BAS file in it. This method seems to work reliably (for now).

With Rob's cursor program, I hard coded the path to cursor.exe and then the working folder doesn't matter.

Jim
VK7JH
MMedit
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 02:26am 24 Jul 2017
Copy link to clipboard 
Print this post

it certainly does seem to not just be an XP thing. there are a great many confused fragments of discussion on the web: bottom line is it is complicated, and can depend upon not only the windows version but also how users are set up on your computer. this is the clearest comment:
https://stackoverflow.com/questions/882850/dragging-files-to-an-exe-sets-different-working-directory

while here is the most complete, but also the most complicated:
https://stackoverflow.com/questions/42057121/current-working-directory-in-a-vbscript-invoked-by-a-drag-drop-operation

a discussion about different users producing different results is here:
https://stackoverflow.com/questions/31622469/run-as-administrator-changes-batch-file-current-directory-sometimes
(it talks about the "user account control" settings for each user having an effect).

note: on almost every machine i set up, there is just one single user called 'admin' that is an Administrator and has no password. i hate passwords or multiple users on machines that can not be logged into remotely.

i still maintain that IF the first parameter refers to a .bas file AND that first parameter contains a fully qualified path THEN the current directory should be set to that path. this should be done universally, no matter what version of windows mmbasic.exe is running under.


thankfully i've not been affected by the flooding, even though i'm currently house/cat-sitting at a place that is 50m from the heathcote river. the earthquakes are another thing... have been battling with EQC for nearly 7 years now, trying to get them to release the claim for my home to my private insurer for settlement. another 6 months and i'll lose cover for the 2010/11 events due to the statute of limitations on making an insurance claim. said home will then become a financial write-off.

while it would be great to visit perth for a chat, i don't know if i'd survive the hot weather in australia for any length of time - an over-active thyroid limits me to cooler climates!


cheers,
rob :-)Edited by robert.rozee 2017-07-25
 
     Page 5 of 6    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025