[News] BBC BASIC Beta Testing - 2009/03/06 r720
Moderator: benryves
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [News] BBC BASIC Beta Testing - 2009/01/23 r599
It's nice to be able to see and edit multiple lines at once, and using a cursor you can easily insert edit and delete text anywhere in the file. This is not especially practical on the BBC BASIC command-line, albeit possible with copy-key editing.
It would be possible to write a rich text editor, but it's not a very easy task, and even then it's difficult to convert into a BASIC program (it's possible but slow and unwieldy via *EXEC).
What would be ideal is if I could find out how BBC BASIC tokenises the input text (without having to write my own Z80 tokeniser), that way files in alternative formats could be converted.
It would be possible to write a rich text editor, but it's not a very easy task, and even then it's difficult to convert into a BASIC program (it's possible but slow and unwieldy via *EXEC).
What would be ideal is if I could find out how BBC BASIC tokenises the input text (without having to write my own Z80 tokeniser), that way files in alternative formats could be converted.
Re: [News] BBC BASIC Beta Testing - 2009/01/23 r599
I wondered: could you make an Automatic Power Down?? Or a command to turn off the calc???
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [News] BBC BASIC Beta Testing - 2009/01/23 r599
Good idea.
The CPU does drop down to 6MHz and HALTs when waiting for a key but a proper APD would be nice.
Maybe something like:
![Smile :)](./images/smilies/grayscale_smile.gif)
Maybe something like:
- *SLEEP - go immediately into "sleep" mode (LCD off, low power consumption).
- *SLEEP 500 - set the APD delay to 500cs (5 seconds).
- *SLEEP OFF - disable the APD completely.
Re: [News] BBC BASIC Beta Testing - 2009/01/23 r599
These look pretty good as additions.benryves wrote:Good idea.The CPU does drop down to 6MHz and HALTs when waiting for a key but a proper APD would be nice.
Maybe something like:
- *SLEEP - go immediately into "sleep" mode (LCD off, low power consumption).
- *SLEEP 500 - set the APD delay to 500cs (5 seconds).
- *SLEEP OFF - disable the APD completely.
Also, is there anyway to just view all of the contents in a file in a nice, scrolling manner? I know how to do things like L.10.200, but it is annoying to have to retype commands like that when you are just viewing the file.
Finally, I did figure out how the bbc file loading / etc system works (I _probably_ should have read through some tutorials on bbc basic first...)! However, after loading a simple 5 line program that I wrote, I used L.250 (I cannot remember the exact number; just that it was way beyond the end of my program) and it gave me a line of text from what looked like the clock program...
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [News] BBC BASIC Beta Testing - 2009/01/23 r599
Not really.benryves wrote:Also, is there anyway to just view all of the contents in a file in a nice, scrolling manner? I know how to do things like L.10.200, but it is annoying to have to retype commands like that when you are just viewing the file.
![Sad :(](./images/smilies/grayscale_sad.gif)
Can you find a way to replicate this? If you run a program (eg via CHAIN) then start typing program lines afterwards it will still have the old program in memory. Maybe you accidentally saved the end of a previously loaded program onto yours? (Or it could be a bug, but I know I accidentally merge two programs together from time to time).Finally, I did figure out how the bbc file loading / etc system works (I _probably_ should have read through some tutorials on bbc basic first...)! However, after loading a simple 5 line program that I wrote, I used L.250 (I cannot remember the exact number; just that it was way beyond the end of my program) and it gave me a line of text from what looked like the clock program...
Re: [News] BBC BASIC Beta Testing - 2009/01/23 r599
I cannot replicate this, so I'll just assume that I accidentally wrote the clock program onto the end of my own program (it is very possible; I wasn't entirely sure of what I was doing at the time).
Also, is there a way to control how you are reading from a file? For example, are there equivalent commands to in.next(), in.nextLine(), in.previous(), in.previousLine(), etc (assuming that in is reading from some file)? Also, it would be cool if there was a way to do something like filename.linenumber to read a specific line from a file...
Also, is there a way to control how you are reading from a file? For example, are there equivalent commands to in.next(), in.nextLine(), in.previous(), in.previousLine(), etc (assuming that in is reading from some file)? Also, it would be cool if there was a way to do something like filename.linenumber to read a specific line from a file...
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [News] BBC BASIC Beta Testing - 2009/01/23 r599
I may be able to put together a star command that deletes ranges of line numbers from a program in case it happens again.b-flat wrote:I cannot replicate this, so I'll just assume that I accidentally wrote the clock program onto the end of my own program (it is very possible; I wasn't entirely sure of what I was doing at the time).
I'm not 100% sure what you're asking, but there are several ways to control how files are read. INPUT# reads a line from an open file (I guess that's your in.nextLine()); BGET# reads a single byte. Both advance the internal file pointer - which can be read or modified using PTR# - after reading.Also, is there a way to control how you are reading from a file? For example, are there equivalent commands to in.next(), in.nextLine(), in.previous(), in.previousLine(), etc (assuming that in is reading from some file)?
Re: [News] BBC BASIC Beta Testing - 2009/01/23 r599
Basically, what I am wanting is a routine that will search backwards in the file for the beginning of the previous line and give it, so you can read in both directions. I know that this could be done fairly easily using ptr#, but it would be much nicer to have a routine like that already built in.
Another, optional thing to add to file reading would be something that would allow you to access line x of the file (aka perform a linear search until you have found the start of the xth line). This one isn't as necessary, but it would be nice if you could add it.
Right now, I'm going to attempt to write my own file viewer in BBC Basic (I'll post if I manage to get anything running).
Another, optional thing to add to file reading would be something that would allow you to access line x of the file (aka perform a linear search until you have found the start of the xth line). This one isn't as necessary, but it would be nice if you could add it.
Right now, I'm going to attempt to write my own file viewer in BBC Basic (I'll post if I manage to get anything running).
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [News] BBC BASIC Beta Testing - 2009/01/23 r599
One solution that presents itself it is to create an array that stores the offset in the file to each line (updated every time you read a line) from the file; that way you can seek almost instantly to any line in the file by looking up its start offset in the array. The downside is that this take up rather large amount of RAM!
You can always work programmatically, working backwards from the current cursor position looking for a CR (13). Supposing you had a file TEXT.VAR containing the following:
Then the following program:
would output
After each INPUT# the file pointer is pointing at the next line, so you need to call PROC_PrevLine twice to move the pointer to the previous line.
You can always work programmatically, working backwards from the current cursor position looking for a CR (13). Supposing you had a file TEXT.VAR containing the following:
Code: Select all
LINE 1
LINE 2
LINE 3
LINE 4
LINE 5
Code: Select all
10 h=OPENIN"TEST.VAR"
20 INPUT#h,line$:PRINT line$
30 INPUT#h,line$:PRINT line$
40 PROC_PrevLine(h):PROC_PrevLine(h)
50 INPUT#h,line$:PRINT line$
60 INPUT#h,line$:PRINT line$
70 INPUT#h,line$:PRINT line$
80 PROC_PrevLine(h):PROC_PrevLine(h)
90 INPUT#h,line$:PRINT line$
100 CLOSE#h
110 END
120 :
130 DEF FN_BPEEK#(h)LOCALB%:B%=BGET#h:PTR#h=PTR#h-1:=B%
140 DEF PROC_PrevLine(h)
150 PTR#h=PTR#h-1
160 REPEAT:IF PTR#h>0 THEN PTR#h=PTR#h-1
170 UNTIL PTR#h=0 OR FN_BPEEK#(h)=13
180 IF PTR#h>0 THEN PTR#h=PTR#h+1
190 ENDPROC
Code: Select all
LINE 1
LINE 2
LINE 1
LINE 2
LINE 3
LINE 2
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [News] BBC BASIC Beta Testing - 2009/01/25 r627
There's a new release with a few new features; chiefly *SLEEP along with proper APD and a new assembly API (see the manual and the ASMAPI.8XP sample) that can be used to access a few extra features (currently a glob function (pattern matching) as well as UCASE$, LCASE$, LTRIM$, RTRIM$ and TRIM$ functions).
There are two (experimental) commands, *LOADTEXT and *RUNTEXT that can be used to load and run text files. These are regular ASCII text files, though, with CR line-breaks. They're slightly faster than using *EXEC, though.
For those of you with a PS/2 mouse adapter there's a MOUSE.8XP sample too.
There are two (experimental) commands, *LOADTEXT and *RUNTEXT that can be used to load and run text files. These are regular ASCII text files, though, with CR line-breaks. They're slightly faster than using *EXEC, though.
For those of you with a PS/2 mouse adapter there's a MOUSE.8XP sample too.
Re: [News] BBC BASIC Beta Testing - 2009/01/25 r627
Too bad I've got just about every kind of mouse except anordinary PS/2 mouse but the ball-mouse built into my big old clicky keyboard is PS/2...it would be interesting to try this out.
I
I
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [News] BBC BASIC Beta Testing - 2009/01/25 r627
Most USB devices are compatible with PS/2 in my experience. I have a wireless USB mouse that works fine over PS/2, even though it didn't come with an adapter. ![Smile :)](./images/smilies/grayscale_smile.gif)
Full USB support in BBC BASIC (for mass-storage devices as well as keyboard and mouse peripherals) would be very nice, but I don't know how I'd implement it, not owning a TI-84+.![Sad :(](./images/smilies/grayscale_sad.gif)
![Smile :)](./images/smilies/grayscale_smile.gif)
Full USB support in BBC BASIC (for mass-storage devices as well as keyboard and mouse peripherals) would be very nice, but I don't know how I'd implement it, not owning a TI-84+.
![Sad :(](./images/smilies/grayscale_sad.gif)
Re: [News] BBC BASIC Beta Testing - 2009/01/25 r627
The APD works great!! It's very cool!
Could you prevent the coder from putting a lower number than 5 in it??
Could you prevent the coder from putting a lower number than 5 in it??
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [News] BBC BASIC Beta Testing - 2009/01/25 r627
I can do that. ![Smile :)](./images/smilies/grayscale_smile.gif)
On the BBC Micro there was a trick you could do to add extra statements to the language. When an unrecognised statement is encountered an error 4, "Mistake", is triggered. The error routine is vectored on the BBC Micro, so you could handle this error yourself. By inspecting the place in the program the error occurred you could detect an additional keyword, cancel the error and implement the statement yourself. By patching the error handler in the Z80 version I've been able to add support for statements that are available in the Windows version (including WAIT, ELLIPSE and SWAP) as a proof of concept.
Such a patch requires overwriting (ie, modification) of the BASIC interpreter, though. When I contacted Richard Russell asking if he was OK with this technique he pointed me to this Z88 patch that adds commands to the Z88 version of BBC BASIC. Being stored in ROM BBC BASIC could not be patched directly, so it must be using some other trick, and I can't work it out for the life of me.![Confused :?](./images/smilies/grayscale_confused.gif)
![Smile :)](./images/smilies/grayscale_smile.gif)
On the BBC Micro there was a trick you could do to add extra statements to the language. When an unrecognised statement is encountered an error 4, "Mistake", is triggered. The error routine is vectored on the BBC Micro, so you could handle this error yourself. By inspecting the place in the program the error occurred you could detect an additional keyword, cancel the error and implement the statement yourself. By patching the error handler in the Z80 version I've been able to add support for statements that are available in the Windows version (including WAIT, ELLIPSE and SWAP) as a proof of concept.
Such a patch requires overwriting (ie, modification) of the BASIC interpreter, though. When I contacted Richard Russell asking if he was OK with this technique he pointed me to this Z88 patch that adds commands to the Z88 version of BBC BASIC. Being stored in ROM BBC BASIC could not be patched directly, so it must be using some other trick, and I can't work it out for the life of me.
![Confused :?](./images/smilies/grayscale_confused.gif)
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [News] BBC BASIC Beta Testing - 2009/01/28 r654
I've uploaded a new version:
- Helper keywords for drawing shapes: CIRCLE, ELLIPSE, RECTANGLE, FILL, BY.
- PLOT [BY] X,Y plots single points.
- New control structure: WHILE. This works in a similar fashion to REPEAT except it evaluates the conditional first and skips the entire block if it evaluates to FALSE.
- EXIT FOR, EXIT REPEAT and EXIT WHILE allow you to break out of loops - even if different loop structures are nested inside eachother.
- WAIT - does what it says on the tin.
- SPC - not strictly new, but I had overlooked it when compiling the documentation.
- SWAP - this one needs to be used with care as it permits silly usage (eg swapping literals).