Home  |  Contents 
Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: MMBasic for DOS Beta 6 Post ReplyPost New Topic
Page of 8 Next >>
Author
Message << Prev Topic | Next Topic >>
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2135
Posted: 28 July 2017 at 1:41pm | IP Logged Quote Geoffg

I have a new beta version of MMBasic for DOS: 2017-07-28_133706_DOS_MMBasic_5.04.05_Beta_6.zip

I thought it worth starting a new thread because there has been so many changes since the previous beta. A lot of them come from Rob's research showing how you can get to the Windows API from the Watcom compiler (thanks Rob).

In summary the new features are:

The CURSOR command allows you to move the cursor around the screen.

With the COLOUR command you can select the foreground and background colours.

The read only variables MM.VRES and MM.HRES will return the size of the window (in characters). You can drag the window boundaries and these will dynamically update.

The EDIT command will now run the MMBasic editor (same as on the Micromite). This has colour coded output and you can customise the colours.

You can still use an external Windows editor - the command is now WEDIT.

To keep Rob happy you can set the starting directory for MMBasic by setting the DOS environment variable MMDIR to the directory you want to use.

The command SETTITLE can be used to change the title in the console window's title bar.

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

If MMBasic is started without a program on the command line it will attempt to load a file called autoexec.bas in the startup directory or the root of the C: drive.


And last but not least, you can access serial COM ports on the PC including virtual ports created by USB/serial converters. The syntax is almost the same as the Micromite. For example:
OPEN "COM12: baud=38400" AS #5          open COM12 with a speed of 38400 baud
PRINT #5, "Hello"                       send the string "Hello" out of the serial port
dat$ = INPUT$(20, #5)                   get up to 20 characters from the serial port
CLOSE #5                                close the serial port

I have used this to remotely control a Micromite and it works well. The only hiccup is that a few times I needed to access the port using Tera Term first - I will be interested on the experience of others.

The manual has been extensively updated so it would be worth another read through.

Geoff

__________________
Geoff Graham - http://geoffg.net


Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
robert.rozee
Guru
Guru


Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 1160
Posted: 28 July 2017 at 3:35pm | IP Logged Quote robert.rozee

the following should work, but alas does not:

S$=MM.CmdLine$
Print S$
Print
If S$<>"" Then
  Do
    found = (Right$(S$,1)="\") Or (Right$(S$,1)=":")
    S$=Left$(S$,Len(S$)-1)
  Loop Until found Or S$=""
  If Left$(S$,1)=Chr$(34) Then S$=S$+Chr$(34)
  Print S$
  Print
  If found Then Chdir S$
EndIf

>
> run
C:\Documents and Settings\admin

"C:\Documents and Settings\admin\My Documents\Downloads\MMbasic\5.x firmware\DOS
 version\test2.bas"

"C:\Documents and Settings\admin\My Documents\Downloads\MMbasic\5.x firmware\DOS
 version"

[14] If found Then Chdir S$
Error: No such file or directory
>
>


the above code is intended to fix the startup directory being set wrong. looks like the problem is chdir does not accept long filenames. also (and somewhat worse) the internal editor saves to the wrong place too!

PLEASE, PLEASE, PLEASE, add the simple bit of code i posted to set the current directory to always be the location of the .bas file upon starting mmbasic. AND, also please ensure that once started the internal editor ignores changes to the current directory setting when loading and saving!

if i run the above program by dropping it onto mmbasic, then type save "test" the file is saved to "C:\Documents and Settings\admin\test.bas". this is entirely confusing and bizarre behaviour.

the mmbasic IDE should maintain it's own load/save location independently to the current directory set by a running program.


cheers,
rob :-)
Back to Top View robert.rozee's Profile Search for other posts by robert.rozee
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2135
Posted: 28 July 2017 at 4:52pm | IP Logged Quote Geoffg

From a quick glance it appears that you have spaces in the directory path and I bet that is the problem. This is something internal to Windows and I am not sure there is an answer.
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
TassyJim
Guru
Guru


Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2257
Posted: 28 July 2017 at 10:13pm | IP Logged Quote TassyJim

Rob, Try adding quotes around the path.

If found Then Chdir CHR$(34)+S$+CHR$(34)

Jim

__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
robert.rozee
Guru
Guru


Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 1160
Posted: 28 July 2017 at 10:47pm | IP Logged Quote robert.rozee

there are already quotes there, see the lines printed out from the above:
"C:\Documents and Settings\admin\My Documents\Downloads\MMbasic\5.x firmware\DOS
 version\test2.bas"

"C:\Documents and Settings\admin\My Documents\Downloads\MMbasic\5.x firmware\DOS
 version"


geoff: how are you implementing chdir? the function SetCurrentDirectory supports long file names, all i can guess is that you're using a library supplied by the watcom C compiler that uses the older pre-LFN API calls. the likes of SetCurrentDirectory are supported from XP onwards, which does break win2K and 95/98. if you wanted to support win2K and 95/98 you'd need to detect the OS version and adapt accordingly - probably not worth the effort these days.

have you considered changing over to using minGW? this is what i used for pic32prog.

there is also the deeper philosophical issue of separating the behaviour of the IDE from the behaviour of the running mmbasic program - this is a problem unique to the win32 and RPi versions of mmbasic. as a scripting language i strongly feel that while the IDE and user program should start out operating in the same current directories, changes by the user program should not affect where the IDE loads/saves from.


cheers,
rob :-)
Back to Top View robert.rozee's Profile Search for other posts by robert.rozee
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2135
Posted: 29 July 2017 at 1:14am | IP Logged Quote Geoffg

Rob, Beta 6 has no problem with spaces or long paths:



MMBasic is a programming language. So if there is to be a conflict with the "IDE" the programming aspect will take precedence. Neither should it act differently for different commands or at the command prompt.

Geoff

__________________
Geoff Graham - http://geoffg.net
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
TassyJim
Guru
Guru


Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2257
Posted: 29 July 2017 at 2:15am | IP Logged Quote TassyJim

Rob,
Apologies for posting before reading (and thinking).

Have you tried 'removing' the quotes?

If Left$(S$,1)=Chr$(34) Then S$=MID$(S$,2)


I don't have XP to test it with but works on W10

Jim

Quote:
DOS MMBasic Ver 5.04.05 Beta 6
Copyright 2011-2017 Geoff Graham

"C:\Users\Jim\Documents\apps\maximite\test spaces\test.bas"

C:\Users\Jim\Documents\apps\maximite\test spaces

>


Edited by TassyJim on 29 July 2017 at 2:29am


__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
robert.rozee
Guru
Guru


Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 1160
Posted: 29 July 2017 at 2:35am | IP Logged Quote robert.rozee

might have found one of the problems: it looks like chdir$ internally provides quote marks at begining and end of the supplied string, so the string should NOT already have the quote marks present.

the following code now appears to work, and should be placed at the start of all programs that access files in order to ensure the current directory is set correctly at program startup - ie, is set to the same location as your .bas file:

S$=MM.CmdLine$
If S$<>"" Then
' S$=ExpandFileName(S$)      ' needed to make bulletproof
  Do
    found = (Right$(S$,1)="\") Or (Right$(S$,1)=":")
    S$=Left$(S$,Len(S$)-1)
  Loop Until found Or S$=""
  If Left$(S$,1)=Chr$(34) Then S$=Mid$(S$,2)
  If found Then Chdir S$
EndIf


the windows version of mmbasic is now an IDE as well as just a programming language, and so without providing a clear line between the two functions users will get tripped up, and people will ask "what happened to the program i just saved, it just disappeared?".

i'm afraid the environment variable MMDIR is a patch that just adds another layer of confusion, while the basic solution above is an inelegant hack. for the moment i'll stick to using drop here.exe and avoid chdir$ et al like the plague.


cheers,
rob :-)
Back to Top View robert.rozee's Profile Search for other posts by robert.rozee
 
robert.rozee
Guru
Guru


Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 1160
Posted: 29 July 2017 at 2:44am | IP Logged Quote robert.rozee

TassyJim wrote:

I don't have XP to test it with but works on W10


the problem (well, part of the problem) is not specific to any version of windows, but specific to how any version of windows has been set up. when you drop a file onto an (executable) icon, the shell goes through a series of steps to determine how to proceed, the route taken depending (as far as i can tell) upon the permissions and security settings currently in force. so two machines running the exact same versions of windows may behave differently.

it is a right mess, but very few folks encounter the problem as programmers code around the issue when it affects their program.


cheers,
rob :-)
Back to Top View robert.rozee's Profile Search for other posts by robert.rozee
 
KeepIS
Regular Member
Regular Member
Avatar

Joined: 13 October 2014
Location: Australia
Online Status: Offline
Posts: 90
Posted: 29 July 2017 at 4:02am | IP Logged Quote KeepIS

Geoff - A BIG thank you for the additions and changes, most are exactly what I had been hoping for.

Mike.

__________________
It's all too hard.
Back to Top View KeepIS's Profile Search for other posts by KeepIS
 
panky
Guru
Guru
Avatar

Joined: 02 October 2012
Location: Australia
Online Status: Offline
Posts: 394
Posted: 29 July 2017 at 5:06am | IP Logged Quote panky

Rob/Geoff,

The issue appears to be with the quotes when using chdir with a string variable as the argument.

The following code runs correctly on my Win 7 Pro machine with 5.04.05 beta 6


S$=MM.CmdLine$
Print S$
Print
If S$<>"" Then
  Do
    found = (Right$(S$,1)="\" Or Right$(S$,1)=":")
    S$=Left$(S$,Len(S$)-1)
  Loop Until found Or S$=""
' Comment out add quote to end and strip quotes from front and back
'  If Left$(S$,1)=Chr$(34) Then S$=S$+Chr$(34)
   If Left$(S$,1)=Chr$(34) Then S$=Right$(S$,Len(S$)-1)
   If Right$(S$,1)=Chr$(34) Then S$=Left$(S$,1),Len(S$)-1)
 Print S$
  Print
  If found Then
   Chdir S$
  EndIf
EndIf



It appears that chdir will only accept quoted text as an argument directly and ONLY non-quoted text when a string variable is the argument.

Doug.

Edit: This appears to be true for all the files related commands eg. FILES etc. D.



Edited by panky on 29 July 2017 at 5:18am


__________________
DonTSM1,Duinomite,CGCMM1,CGCMM2,2xDimitech,3xWWuMites,MicksMuP,Grogster1A,4xPeterMuM+,Zonker DIP-600,3xCGuKits,CGuBoard2,SnadPic100,SCBP64 & Exp100,PMMZ144,PMMZ100 .. and loving it![:D
Back to Top View panky's Profile Search for other posts by panky
 
flip
Regular Member
Regular Member


Joined: 18 July 2016
Location: Australia
Online Status: Offline
Posts: 61
Posted: 29 July 2017 at 8:11am | IP Logged Quote flip

Hi all

All looking very promising! and I'm eager to get into it !!

Geoff, with beta 6 I am still getting the same failure (as per my post on previous MM DOS thread - perhaps missed or I didn't write it up very well)...
Quote:
The problem is that its returning the message for the first failed command after the SKIP 2, even though the Second command after the SKIP 2 was successful.
Before, (with same code) it reset error to 0 on the second command after the SKIP 2
...I thought I'd write an exhaustive bit of code, that would show the bug better (my previous post would not have generated the error unless run twice )...anyway can someone test/confirm/discuss/otherwise whether the following is a bug? (refer quote above for a description of the suspected bug)[EDIT: I am running Windows 10]
[Edit: code below updated 18:41 AEST
DIM AS STRING Test_File="~~..ZXZ.~~"
DIM AS INTEGER iMMERR
DIM AS STRING sMMERR
DIM i%
DIM q$

? " Test of Error codes MM.ERRNO and MM.ERRMSG$ failing to be reset to 0"
? " after a successful command"
? " Bug apparent in 5.04.05 Beta 5 & Beta 6"
? " Bug not present in previous versions."
?

' Following section is just to guarantee the test is safe and repeatable
ON ERROR SKIP
SYSTEM "DIR "+ Test_File
IF MM.ERRNO=0 THEN
  ? "program assumes the file exists...About to delete ";Test_File;
  INPUT "...continue?? (Y/N)";q$
  IF UCASE$(q$)<>"Y" THEN
    ? "Can't proceed with this bug test"
    END
  ENDIF
ENDIF
  
ON ERROR SKIP
KILL Test_File

?
? "Nothing above this line is relating to the Error codes not being reset"
?

FOR i%=1 to 2
  ON ERROR SKIP 2
  CLOSE #1
  OPEN Test_File FOR RANDOM AS #1
  iMMERR=MM.ERRNO:sMMERR=MM.ERRMSG$
  SELECT CASE iMMERR
  CASE 0: ? "opened OK...";
  CASE 1: ? "Creating New file...";
  CASE ELSE:
    ? "Failed to open ";Test_File;": ";sMMERR;"(Err#";iMMERR;")"
    ? "This message never happens for MM DOS versions 5.04.05 beta 4 or less"
    ? " NOTE the error is to do with the CLOSE command, not the OPEN command"
    END
  END SELECT
  ON ERROR SKIP
  CLOSE #1
? " ...and closed"
NEXT i%

ON ERROR SKIP
KILL Test_File
? " ...and deleted Test_File";Test_File


Regards,
Phil

Edited by flip on 29 July 2017 at 8:41am
Back to Top View flip's Profile Search for other posts by flip
 


Page of 8 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.1074 seconds.
Privacy Policy     Process times : 0, 0.02, 0, 0.09