Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 05:42 09 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 : MMBasic 4.4 Beta 2

Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 08:43pm 04 Jun 2013
Copy link to clipboard 
Print this post

I have another beta test version of MMBasic 4.4 to which has been added the MODULE LOAD and MODULE UNLOAD commands. These allow libraries of user defined commands or functions to be loaded into MMBasic from within a running program.

This can be used to load specialised libraries to extend the functionality of MMBasic. Examples include device drivers, libraries that provide bit manipulation and libraries of specialised mathematical functions. Another use is to extend the amount of memory available by only loading sections of code as needed and then unloading them when their task is finished so that another section of code can be loaded.

You can download the test version from: http://geoffg.net/Downloads/Maximite/MMBasic_4.4_Beta_2.zip

There are a few other fixes/changes in this version:
- The SEEK command
- FILES on drive A: includes the size of the file.
- CHAIN command now resets the DATA pointer and will not throw an error indicating too many GOSUBS, FOR LOOPS, DO LOOPS or similar.
- Fixed a bug in the CLR$() function which produced random characters.

Any bug reports, suggestions, etc gratefully received.

Thanks
GeoffEdited by Geoffg 2013-06-06
Geoff Graham - http://geoffg.net
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9070
Posted: 02:30pm 05 Jun 2013
Copy link to clipboard 
Print this post

Do you ever get any sleep Geoff? (rhetorical!)

Smoke makes things work. When the smoke gets out, it stops!
 
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 01:13am 06 Jun 2013
Copy link to clipboard 
Print this post

Geoff,
Just doing a little testing, I have a problem reading a file with

input(1, #1)

when the file #1 is open with append, I get an Error: Cannot read from file

If I open with input then I get the correct response.

Writing to a file with append is working ok.


Also, in the code examples in the language manuals you have

Data$ = INPUT$(64, #1)

Data$ does not work in a program because data$ seems to be treated as a command and not as a variable, ie when editing you type data$ = .... that later becomes Data$ which the change in capitalization seems to verify.

Anthony.

file a.txt contains abcdefghijklmnopqrstuvwxyz

open "a.txt" for append as #1
print lof(#1)
seek #1,4
print input$(3,#1)
close #1

Edited by ajkw 2013-06-07
 
TinkersALot
Regular Member

Joined: 20/11/2012
Location: United States
Posts: 72
Posted: 03:46am 06 Jun 2013
Copy link to clipboard 
Print this post

the risk in making something better is that some yahoo will come along and ask for better still [grin].

...And now if you could only make the basic interpreter a multitasking basic interpreter...
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 01:59pm 06 Jun 2013
Copy link to clipboard 
Print this post

Ah, sorry Anthony, you are right on both counts.

In this beta version I changed opening a file for random access from APPEND to RANDOM (new keyword). And you are right Data$ is not valid as a variable.

My mistake was that I forgot to update the documentation in the downloadable zip (fixed now).

This is the correct documentation for Random File I/O in Beta 2: 2013-06-06_235833_Random_File_IO_updated.pdf

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

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 10:48pm 06 Jun 2013
Copy link to clipboard 
Print this post

Random works fine. Just a thought however, should seek #1,1 position the pointer to the end of the first byte ready to read byte 2 (as it does) or should it position the pointer ready to read byte 1? I prefer the later but there may be conventions I am not aware of.

The module commands seem to be behaving as expected.

You might what a look for further uses of data$ in the manuals, ie page 43 in the main manual and further down in 2013-06-06_235833_Random_File_IO_updated.pdf

Cheers,
Anthony.
Edited by ajkw 2013-06-08
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 02:55pm 07 Jun 2013
Copy link to clipboard 
Print this post

I will have think about that. Normally the first byte in a file is byte number zero. You are suggesting that it should be byte number one, just like with strings where the first character is numbered character number one.

I might check what Bill did many years ago and see if I can remain compatible.

Geoff

P.S. Thanks for the documentation bug report.
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5915
Posted: 05:12pm 07 Jun 2013
Copy link to clipboard 
Print this post

Geoff,
I don't have my MS Basic books with me but this is from the QB64 wiki:

  Quote  
SEEK (statement)

The SEEK statement sets the next byte or record position of a file for a read or write.


Syntax:

SEEK filenumber%, position%


filenumber must be the file number that is OPEN and being read or written to.
position is a byte in BINARY or sequencial files created in OUTPUT, APPEND or INPUT (file mode)s. The first byte = 1.
position is the record in RANDOM files to read or write. Records can hold more than one variable defined in a TYPE.
Since the first SEEK file position is 1 it may require adding one to an offset value when documentation uses that position as 0.
After a SEEK statement, the next file operation starts at that SEEK byte position.
The SEEK statement can work with the SEEK function to move around in a file.



My understanding is "SEEK 1" would set things up to read the first byte of the file.
It is not something I have done recently so the grey matter may need some oiling....

Jim

PS: Love the MODULE commands, I think they will suit me more than CHAIN.

VK7JH
MMedit   MMBasic Help
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 06:34pm 07 Jun 2013
Copy link to clipboard 
Print this post

Thanks, I will change SEEK (and LOC()) so that the first byte is 1.
Geoff Graham - http://geoffg.net
 
Print this page


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

© JAQ Software 2024