Date   

"Responding to a hot key " example

Chris Coxall
 

Hi,

I transfer data from spreads sheets in Mobile Ecel on a handheld computers Pocket PCs and Windows Mobile devices 5 to 6.1. These go into tables in a desk top publisher with spread sheet function ability on a windows PC..

Just transferring a block of columns and rows using the shared clipboard with the standard Copy and Paste will just try to put the text data into one cell. Using a program Autohotkey's send function to put data into the DTP's tables from the clipboard text as key stokes can be made to work but first carriage returns need to be replaced with a combination of a simulated “Down” key and“Shift plus Tab” presses.

Autohotkey will do this with the “Send %clipboard%” command if the clipboard text. has <CR> replaced with a Autohotkey script “{Shift Down} then the number of {TAB}s for the number of columns in the spread sheet block that has been selected and copied to clipboard: finally ending with {Shift Up}”.

To create this script I use BBC4W program. It calculates the number of columns in the selected spread sheet block then replaces "CR"s as described above. An Autohotkey  is then used to run the BBC compiled executable and send clipboard text with the Autohotkey script below.

^!x::
Run "C:\EXEs\ChangeEnter.exe"
Sleep, 500 ; second
Send %Clipboard%
Return 

On Wiki there BBC program example to use "Responding to a hot key "

http://bb4w.wikispaces.com/Responding+to+a+hot+key 

Currently the example only sends text to the BBCbasic's window.

If I can adapt the "Responding to a hot key " example on WIKI to send text to the current window of focus I would not need two programs for the task.

Does anyone know of or where a BbbcBasic example can be found to do this.

Thanks in advance.

Regards Chris



Transfer of BB4W to Groups.io

Richard Russell
 

I propose to transfer the BB4W Discussion Group from Yahoo! to Groups.io. Although nobody can know what the future holds, at present Groups.io has a much more attractive offering. Specifically their message editor is far superior to Yahoo's, not least in supporting the inclusion of code snippets that one can be confident will not be corrupted by the deletion of whitespace or line wrapping etc. The future of Yahoo! itself is also uncertain at the moment, with the likelihood of it being taken over.


If the transfer goes ahead you shouldn't need to do anything except perhaps to update your favourites and/or address book. All currently confirmed group members, that are not 'bouncing', will automatically be transferred to the new group. Members' subscription preferences (email, no email, digest, etc.) will be preserved, as will members' posting privileges (group default, override - moderated, etc.). I will also attempt to transfer most of the files repository.


If you are happy to be transferred to the new group check that your email address registered with Yahoo! is correct. If you have received this message by email there should be no problem, but if you normally read the group via its web interface it's possible that emails to you from Yahoo may be bouncing, in which case your membership will not be transferred automatically.


If for some reason you don't want to be transferred to the new group, please resign from the Yahoo! group as soon as possible. That will ensure that you are not included in the automatic transfer. The Yahoo group will subsequently be closed down (not even announcements being made there) although it would be my intention to leave the message archive online whilst it is still accessible.


Richard.


OS-independent equivalent of DIB Section

Richard Russell
 

A number of BBC BASIC for Windows programs make use of a Windows DIB Section to provide a memory-mapped display bitmap (for example that can be accessed using assembler code). One such program is MANDEL.BBC, supplied with BB4W, which draws the Mandelbrot Set very quickly (so quickly that you can pan and zoom in real-time).

Those of you who have been fortunate enough to try the SDL2 (Linux or Android) version of BBC BASIC will have seen that a functionally-equivalent MANDEL.BBC is supplied with that version, and you may have asked yourself how that has been achieved in the absence of the Windows API.

The answer is that by leveraging the *MDISPLAY command (or OSCLI "MDISPLAY...") an almost identical functionality to a Windows DIB Section can be achieved in an OS-independent fashion!

Conversion from one to the other is actually quite straightforward. Here is how the bitmap is created in the BB4W version of MANDEL.BBC:

Code:

      DIM bmih{biSize%, biWidth%, biHeight%, biPlanes{l&,h&}, \
      \        biBitCount{l&,h&}, biCompression%, biSizeImage%, \
      \        biXPelsPerMeter%, biYPelsPerMeter%, biClrUsed%, \
      \        biClrImportant%}
      bmih.biSize%   = DIM(bmih{})
      bmih.biWidth%  = Width%
      bmih.biHeight% = Height%
      bmih.biPlanes.l& = 1
      bmih.biBitCount.l& = 32
      bmih.biSizeImage% = Width%*Height%*4

      SYS "CreateDIBSection", @memhdc%, bmih{}, 0, ^Bits%, 0, 0 TO hbm%
      IF hbm% = 0 ERROR 100, "Couldn't create DIBSection"
      SYS "SelectObject", @memhdc%, hbm% TO oldbm%
      SYS "DeleteObject", oldbm% 


Here is how the equivalent bitmap is created in the SDL version:

Code:

      DIM bmfh{bfType{l&,h&}, bfSize%, bfReserved%, bfOffBits%}
      DIM bmih{biSize%, biWidth%, biHeight%, biPlanes{l&,h&}, \
      \        biBitCount{l&,h&}, biCompression%, biSizeImage%, \
      \        biXPelsPerMeter%, biYPelsPerMeter%, biClrUsed%, \
      \        biClrImportant%}
      DIM BMP{bf{}=bmfh{}, bi{}=bmih{}, bits%(Width%*Height%-1)}

      BMP.bf.bfType.l& = ASC"B"
      BMP.bf.bfType.h& = ASC"M"
      BMP.bf.bfSize%       = DIM(BMP{})
      BMP.bf.bfOffBits%    = DIM(bmfh{}) + DIM(bmih{})
      BMP.bi.biSize%       = DIM(bmih{})
      BMP.bi.biWidth%      = Width%
      BMP.bi.biHeight%     = Height%
      BMP.bi.biPlanes.l&   = 1
      BMP.bi.biBitCount.l& = 32
      BMP.bi.biSizeImage%  = Width%*Height%*4

      Bits% = ^BMP.bits%(0) 


In each case the variable Bits% is set to point to the bitmap data in memory, in exactly the same format for both methods.

To 'blit' the bitmap to the screen in the SDL version it is only necessary to issue a *MDISPLAY command as follows:

Code:

          OSCLI "MDISPLAY " + STR$~BMP{} 


So with this knowledge you should easily be able to convert any programs which use DIB Sections to a more generic form.

Richard.


Re: Groups.io given up the ghost?

Richard Russell
 

Groups.io seems to be working again; the last couple of messages I posted have appeared. It also looks like they've made a major improvement in the way the editor works. I can now copy-and-paste an entire post from Conforums and the formatting is maintained to a remarkable degree (as viewed via the web interface, I can't comment on their emails). Code snippets even appear in their own boxes, with a monospaced font and whitespace preserved! This makes crossposting to both Conforums and Groups.io a breeze, and for the first time I can post BASIC code to an email group with confidence that it isn't going to get mangled. That's a far cry from this awful place!


I know there are uncertainties about the long term future of Groups.io, but looking at the way Yahoo! seems to be self-destructing that must be equally true of this group. So I wonder if it's now time to consider moving this group wholesale over to Groups.io. They provide an automated transfer mechanism: "We will add all members that are currently confirmed and not bouncing to your group. Members' subscription preferences (email, no email, digest, etc.) will be preserved. Members' posting privileges (group default, override - moderated, etc.) will also be preserved". There is a precedent: effectively the same thing happened with Wiggio.


It all sounds very attractive to me and from my perspective I can't really see any downsides.


Richard.
Note: Replies to this group are disabled.


Beware this v6 difference

Richard Russell
 

One of the major differences between BB4W v5 and v6 is in the way strings are passed into functions and procedures. This change was necessitated by the support for huge (>64K) strings, but it can significantly impact performance even when modest-sized strings are used.

For example consider this test program:

Code:
A$ = STRING$(65535, "x")
TIME = 0
FOR I% = 1 TO 100000
PROC1("Hello world!")
NEXT
PRINT "Took ";TIME/100;" seconds"
END

DEF PROC1(A$)
ENDPROC

On my PC this took 2.4 seconds in v5.95a and 0.14 seconds in v6.02a, a 17-fold improvement in execution time!

However the new method of passing strings does have one undesirable consequence. If a function or procedure aborts as the result of an error, any LOCAL strings or string parameters will be leaked.

Consider this attempt to implement a 'throw' function:

Code:
DEF PROCthrow(a$)
ERROR 100,a$

Every time it is called the memory occupied by the string a$ will be leaked. If called a sufficient number of times an out-of-memory condition might arise.

So code such as this should be avoided. If you need your program to recover from an error which occurs in an FN or PROC, use local error trapping and RESTORE LOCAL to keep variables 'in scope' and avoid the memory leak. For example:

Code:
DEF PROCmightfail(a$)
LOCAL b$
ON ERROR LOCAL RESTORE LOCAL : ERROR ERR, REPORT$
REM Code which might fail here
ENDPROC

Richard.
Note: This group is closed to replies. If you want to comment on this post please do so at http://bbcbasic.conforums.com/index.cgi?board=language&;action=display&num=1460684817 http://bbcbasic.conforums.com/index.cgi?board=language&;action=display&num=1460684817


Beware this v6 difference

Richard Russell
 

One of the major differences between BB4W v5 and v6 is in the way strings are passed into functions and procedures. This change was necessitated by the support for huge (>64K) strings, but it can significantly impact performance even when modest-sized strings are used.

For example consider this test program:

Code:

      A$ = STRING$(65535, "x")
      TIME = 0
      FOR I% = 1 TO 100000
        PROC1("Hello world!")
      NEXT
      PRINT "Took ";TIME/100;" seconds"
      END

      DEF PROC1(A$)
      ENDPROC 


On my PC this took 2.4 seconds in v5.95a and 0.14 seconds in v6.02a, a 17-fold improvement in execution time!

However the new method of passing strings does have one undesirable consequence. If a function or procedure aborts as the result of an error, any LOCAL strings or string parameters will be leaked.

Consider this attempt to implement a 'throw' function:

Code:

      DEF PROCthrow(a$)
      ERROR 100,a$ 


Every time it is called the memory occupied by the string a$ will be leaked. If called a sufficient number of times an out-of-memory condition might arise.

So code such as this should be avoided. If you need your program to recover from an error which occurs in an FN or PROC, use local error trapping and RESTORE LOCAL to keep variables 'in scope' and avoid the memory leak. For example:

Code:

      DEF PROCmightfail(a$)
      LOCAL b$
      ON ERROR LOCAL RESTORE LOCAL : ERROR ERR, REPORT$
      REM Code which might fail here
      ENDPROC 


Richard.


A cautionary tale

Richard Russell
 

A user contacted me to report that his program was failing with an Access denied error, for no good reason. This was the line that was failing:

Code:
INPUT#Fnum,FXX(I,J),FYY(I,J),MZZ(I,J)

There was indeed no obvious reason for the failure, because previous INPUT# statements had executed successfully, and the arrays had been properly created.

However looking at the bigger picture revealed the explanation; can you see it?

Code:
FOR I=1 TO Nbar
INPUT#Fnum,Typs$(I)
INPUT#Fnum,Sect(I,1),Sect(I,2)
INPUT#Fnum,E(I,1),E(I,2)
PRINT#Fnum,E(I,3),E(I,4),E(I,5),E(I,6)
NEXT I
INPUT#Fnum,Kom$(2)
FOR J=1 TO Nnoe
INPUT#Fnum,N(J,1),N(J,2),N(J,3)
NEXT J
INPUT#Fnum,Kom$(3)
INPUT#Fnum,Nbch
FOR I=1 TO Nbch
INPUT#Fnum,Titcha$(I)
FOR J=1 TO Nnoe
INPUT#Fnum,FXX(I,J),FYY(I,J),MZZ(I,J)
NEXT J
NEXT I

Yes, lurking within the sequence of INPUT# statements is a rogue PRINT# statement (do you see it now?). The interesting thing, which is why it took a while to find, is that the Access Denied error didn't happen on the PRINT# statement, but later in a perfectly correct INPUT# statement!

The reason, as you can probably guess, is file buffering. For reasons of efficiency, when you do a PRINT# the data isn't immediately written to the file, but is temporarily buffered in memory. Even though the file was opened for input only (OPENIN) writing to the memory buffer is perfectly OK; it's only when that buffer eventually gets 'flushed' to the real file that the error is generated.

So the moral of the story is that when an error is raised by BASIC the actual faulty statement might have been executed some time before!



Richard.
Note: This group is closed to replies. If you want to comment on this post please do so at http://bbcbasic.conforums.com/index.cgi?board=language&;action=display&num=1460643535 http://bbcbasic.conforums.com/index.cgi?board=language&;action=display&num=1460643535


A cautionary tale

Richard Russell
 

A user contacted me to report that his program was failing with an Access denied error, for no good reason. This was the line that was failing:

Code:

              INPUT#Fnum,FXX(I,J),FYY(I,J),MZZ(I,J) 


There was indeed no obvious reason for the failure, because previous INPUT# statements had executed successfully, and the arrays had been properly created.

However looking at the bigger picture revealed the explanation; can you see it?

Code:

          FOR I=1 TO Nbar
            INPUT#Fnum,Typs$(I)
            INPUT#Fnum,Sect(I,1),Sect(I,2)
            INPUT#Fnum,E(I,1),E(I,2)
            PRINT#Fnum,E(I,3),E(I,4),E(I,5),E(I,6)
          NEXT I
          INPUT#Fnum,Kom$(2)
          FOR J=1 TO Nnoe
            INPUT#Fnum,N(J,1),N(J,2),N(J,3)
          NEXT J
          INPUT#Fnum,Kom$(3)
          INPUT#Fnum,Nbch
          FOR I=1 TO Nbch
            INPUT#Fnum,Titcha$(I)
            FOR J=1 TO Nnoe
              INPUT#Fnum,FXX(I,J),FYY(I,J),MZZ(I,J)
            NEXT J
          NEXT I 


Yes, lurking within the sequence of INPUT# statements is a rogue PRINT# statement (do you see it now?). The interesting thing, which is why it took a while to find, is that the Access Denied error didn't happen on the PRINT# statement, but later in a perfectly correct INPUT# statement!

The reason, as you can probably guess, is file buffering. For reasons of efficiency, when you do a PRINT# the data isn't immediately written to the file, but is temporarily buffered in memory. Even though the file was opened for input only (OPENIN) writing to the memory buffer is perfectly OK; it's only when that buffer eventually gets 'flushed' to the real file that the error is generated.

So the moral of the story is that when an error is raised by BASIC the actual faulty statement might have been executed some time before!

Richard.


Re: Cross-platform BBC BASIC

Richard Russell
 

on Dec 13th, 2015, 1:45pm, Richard Russell wrote

I anticipate that development of this version of BBC BASIC will be a collaborative activity,
with me contributing the run-time engine and other people the IDE and 'compiler'
By way of an update, there are currently two 'IDEs' (at this stage actually little more than program editors) under development. One, being developed by a user, is an IDE for use with the Linux (and, should it ever exist, Mac OS) versions; it runs in Windows too. This uses a fairly conventional GUI, but created entirely in generic BBC BASIC code rather than making use of any OS-specific features. From what I've seen so far it is impressive!

The other, which I am developing myself, is a touch-optimised IDE for use with the Android (86) version. This uses a simplified interface that makes full use of the screen real-estate, which is particularly important with a small device such as a smartphone. Everything is controlled using simple touch gestures, such as a 'tap', a 'swipe' or a 'long press' (it runs in BB4W too, using the mouse to perform these actions).

Richard.
Note: This group is closed to replies. If you want to comment on this message please do so at
http://bbcbasic.conforums.com/index.cgi?board=general&;action=display&num=1450017936&start=6


Re: Cross-platform BBC BASIC

Richard Russell
 

on Dec 13th, 2015, 1:45pm, Richard Russell wrote:

I anticipate that development of this version of BBC BASIC will be a collaborative activity, with me contributing the run-time engine and other people the IDE and 'compiler'


By way of an update, there are currently two 'IDEs' (at this stage actually little more than program editors) under development. One, being developed by a user, is an IDE for use with the Linux (and, should it ever exist, Mac OS) versions; it runs in Windows too. This uses a fairly conventional GUI, but created entirely in generic BBC BASIC code rather than making use of any OS-specific features. From what I've seen so far it is impressive!

The other, which I am developing myself, is a touch-optimised IDE for use with the Android (86) version. This uses a simplified interface that makes full use of the screen real-estate, which is particularly important with a small device such as a smartphone. Everything is controlled using simple touch gestures, such as a 'tap', a 'swipe' or a 'long press' (it runs in BB4W too, using the mouse to perform these actions).

Richard.


Re: BBC BASIC in the news

John Nolan
 

Many thanks again, Richard.


Sometime I may have a look at a RaspberryPie and see if can use it to control things and reduce my energy costs with some intelligent software.


Te original BBC computer was absolutely brilliant for that sort of thing. But I never got around to it.


Best wishes,


John Nolan




From: news@... <news@...>
Sent: 11 April 2016 18:54
To: bb4w@groups.io
Subject: Re: [bb4w] BBC BASIC in the news
 

> I have never tried to transfer a BASIC program, written from Virtual Acorn, piece meal to Windows

Sorry, I assumed that is what you were trying to do.  Many BBC Micro and Archimedes programs will run in BB4W with no modifications at all.  Those that don't generally require only minor alterations.

> the difficulty I found of doing anything (obvious) with the (untitled) output window, stymied me.

What you "do" with the output window is to look at it!  As with any video display its purpose is to display information, in the form of text and graphics, to the user (in that respect it's no different from the BBC Micro).  But maybe I'm missing the point.

As far as the comment about it being "untitled" is concerned, it only displays that if you haven't saved your program first.  If you have saved it, the output window will (by default) contain the name of the program in the title bar.  You can of course replace that with any text of your choosing within your own program.

Richard.



Re: BBC BASIC in the news

Richard Russell
 

> I have never tried to transfer a BASIC program, written from Virtual Acorn, piece meal to Windows

Sorry, I assumed that is what you were trying to do.  Many BBC Micro and Archimedes programs will run in BB4W with no modifications at all.  Those that don't generally require only minor alterations.

> the difficulty I found of doing anything (obvious) with the (untitled) output window, stymied me.

What you "do" with the output window is to look at it!  As with any video display its purpose is to display information, in the form of text and graphics, to the user (in that respect it's no different from the BBC Micro).  But maybe I'm missing the point.

As far as the comment about it being "untitled" is concerned, it only displays that if you haven't saved your program first.  If you have saved it, the output window will (by default) contain the name of the program in the title bar.  You can of course replace that with any text of your choosing within your own program.

Richard.



Re: BBC BASIC in the news

John Nolan
 

Many thanks for your very helpful email.
Richard Russell was good enough to reply, also and, amongst several other methods, such as yours, he suggested a very simple way. In his words, " you can always copy what is displayed in BB4W's 'output window' to the clipboard, by pressing Ctrl+Tab."
I have tried this and it worked a treat.
But, thank you so much for your response. I have been programming in BASIC since about 1983, but there is much I still do not know, because I have had no reason to use it. I am very glad that BASIC, in one for or another, is still alive.

I don't know what your interests are, but I am, at present writing a program analysing our electricity generation and use. We have PV solar, and a heat pump.

Sincerely,

John Nolan

________________________________________
From: J.G.Harston <jgh@mdfs.net>
Sent: 11 April 2016 13:12
To: bb4w@groups.io
Subject: Re: [bb4w] BBC BASIC in the news

John Nolan wrote:
For my present purposes the results will be text, which I should like
to save to a text file. I just haven't found a way to do that, so I
reverted to Virtual Acorn, where I could simply RUN the program in a
Task Window, and then Save.
The simplest way to send you program's output is with *SPOOL:

OSCLI"SPOOL "+outputfile$
PRINT "Hello world!"
*SPOOL

To write text directly to a file use BPUT#channel, just like in ARM
BASIC:

out%=OPENOUT(outputfile$)
BPUT#out%,"Hello world!"
CLOSE#out%

--
J.G.Harston - jgh@mdfs.net - mdfs.net/jgh


Re: BBC BASIC in the news

John Nolan
 

Dear Richard,

Many thanks for your rapid and very full reply.


In some cases, I don't think I had made myself clear. I have never tried to transfer a BASIC program, written from Virtual Acorn, piece meal to Windows. My own experience of writing programs is that, for anything but the simplest, you write it line by line checking all the way. This is what I did when I started out with BB4W. But the difficulty I found of doing anything (obvious) with the (untitled) output window, stymied me. The problem that at my age, 79, you use what you know well and pressure of time dictates that you do that. I have the BB4W manual, but I obviously used the wrong search words and did not have time to read it from cover to cover as I almost did for all the BBC stuff, way back in the '80's.


*SPOOL yes, I may have used this 30 years, but have forgotten. My mind, although very alert, does not remember everything.

I have tested CTRL+TAB and it did exactly what I wanted it to do


Thank you so much, Richard.


Sincerely,

John Nolan




From: news@... <news@...>
Sent: 11 April 2016 14:34
To: bb4w@groups.io
Subject: Re: [bb4w] BBC BASIC in the news
 

On Mon, Apr 11, 2016 at 04:55 am, John Nolan <patriot36@...> wrote:

For my present purposes the results will be text, which I should like to save to a text file. I just haven't found a way to do that


Perhaps the first thing to say is that BBC BASIC for Windows is designed to have a high degree of compatibility with earlier BBC BASIC platforms such as the BBC Microcomputer and the Acorn Archimedes.  It is not designed specifically to be compatible with with Virtual Acorn, a product that I know next to nothing about.  So if you have been writing programs that rely for their functionality on some feature which is unique to Virtual Acorn I'm afraid it is unlikely that they will work unmodified in BB4W.  In that case if you are looking for a 'zero effort' solution your decision to stick with Virtual Acorn is the right one.


But if you are interested in adapting your program so it isn't specific to Virtual Acorn, the question which arises is "How would you have done it on the BBC Micro or the Archimedes?" (I am presuming that you have prior experience of one or other of those platforms).  The answer is likely to depend on the objective of the program; is it to output the data to both the screen and to a file, or is it to output the data only to a file (with screen output incidental to that objective)?


If the former (i.e. you specifically want to see the output both on the screen and in a file) then by far the most straightforward way is to use the *SPOOL command, with which I expect you are familiar because it goes right back to the earliest BBC Micro days.  Anything sent to the screen whilst a *SPOOL command is active is also sent to the specified file.


If the latter (i.e. you don't need to see the output on the screen) then the conventional approach would be to use BBC BASIC's file handling statements and functions to create a data file.  There are a wide range of options available depending on the desired file format; for example if you want to create a conventional text file (with CRLF line terminations, i.e. CHR$13+CHR$10) then the method which is most compatible with ARM BASIC (and hence with Virtual Acorn) is to output each line of text using BPUT# as follows, or something similar:


      BPUT #file%, myline$ + CHR$(13) + CHR$(10) ;


You could instead choose to do it by using *SPOOL again, but disabling the screen output for the duration using VDU 21 (and enabling it afterwards with VDU 6).  But although that technique is simple you need to be careful because if an error occurs whilst the screen output is disabled you may not realise what has happened, and it may appear to have crashed.  Therefore it is recommended to include an ON ERROR statement in your program (that re-enables the screen) if you use this technique.


As a last point, bear in mind that you can always copy what is displayed in BB4W's 'output window' to the clipboard, by pressing Ctrl+Tab.  So in a case where all the output from your program is displayed in the output window that is a simple (albeit manual) way of getting it into another program such as a text editor or a word processing application.


All these methods are, of course, documented in the BBC BASIC for Windows manual.

 

Richard.



Re: BBC BASIC in the news

Richard Russell
 

On Mon, Apr 11, 2016 at 04:55 am, John Nolan <patriot36@...> wrote:

For my present purposes the results will be text, which I should like to save to a text file. I just haven't found a way to do that


Perhaps the first thing to say is that BBC BASIC for Windows is designed to have a high degree of compatibility with earlier BBC BASIC platforms such as the BBC Microcomputer and the Acorn Archimedes.  It is not designed specifically to be compatible with with Virtual Acorn, a product that I know next to nothing about.  So if you have been writing programs that rely for their functionality on some feature which is unique to Virtual Acorn I'm afraid it is unlikely that they will work unmodified in BB4W.  In that case if you are looking for a 'zero effort' solution your decision to stick with Virtual Acorn is the right one.


But if you are interested in adapting your program so it isn't specific to Virtual Acorn, the question which arises is "How would you have done it on the BBC Micro or the Archimedes?" (I am presuming that you have prior experience of one or other of those platforms).  The answer is likely to depend on the objective of the program; is it to output the data to both the screen and to a file, or is it to output the data only to a file (with screen output incidental to that objective)?


If the former (i.e. you specifically want to see the output both on the screen and in a file) then by far the most straightforward way is to use the *SPOOL command, with which I expect you are familiar because it goes right back to the earliest BBC Micro days.  Anything sent to the screen whilst a *SPOOL command is active is also sent to the specified file.


If the latter (i.e. you don't need to see the output on the screen) then the conventional approach would be to use BBC BASIC's file handling statements and functions to create a data file.  There are a wide range of options available depending on the desired file format; for example if you want to create a conventional text file (with CRLF line terminations, i.e. CHR$13+CHR$10) then the method which is most compatible with ARM BASIC (and hence with Virtual Acorn) is to output each line of text using BPUT# as follows, or something similar:


      BPUT #file%, myline$ + CHR$(13) + CHR$(10) ;


You could instead choose to do it by using *SPOOL again, but disabling the screen output for the duration using VDU 21 (and enabling it afterwards with VDU 6).  But although that technique is simple you need to be careful because if an error occurs whilst the screen output is disabled you may not realise what has happened, and it may appear to have crashed.  Therefore it is recommended to include an ON ERROR statement in your program (that re-enables the screen) if you use this technique.


As a last point, bear in mind that you can always copy what is displayed in BB4W's 'output window' to the clipboard, by pressing Ctrl+Tab.  So in a case where all the output from your program is displayed in the output window that is a simple (albeit manual) way of getting it into another program such as a text editor or a word processing application.


All these methods are, of course, documented in the BBC BASIC for Windows manual.

 

Richard.



Re: BBC BASIC in the news

J.G.Harston
 

John Nolan wrote:
For my present purposes the results will be text, which I should like
to save to a text file. I just haven't found a way to do that, so I
reverted to Virtual Acorn, where I could simply RUN the program in a
Task Window, and then Save.
The simplest way to send you program's output is with *SPOOL:

OSCLI"SPOOL "+outputfile$
PRINT "Hello world!"
*SPOOL

To write text directly to a file use BPUT#channel, just like in ARM BASIC:

out%=OPENOUT(outputfile$)
BPUT#out%,"Hello world!"
CLOSE#out%

--
J.G.Harston - jgh@mdfs.net - mdfs.net/jgh


Re: BBC BASIC in the news

John Nolan
 

Dear Richard,

Thank you for your recent email and also for BBC BASIC for Windows. I really would like to use it more often. But, I have a problem that I have not been able to overcome, and it is this.


If I write a program and Run it using the Run option, another window opens (untitled) with a file type icon.

This window shows the results.


For my present purposes the results will be text, which I should like to save to a text file. I just haven't found a way to do that, so I reverted to Virtual Acorn, where I could simply RUN the program in a Task Window, and then Save.


Robert Freeman, of whom you may have heard, was kind enough to send me 2 possibilities one of which used some # commands. Actually, since about 1983, I have never used these !!! Being a bit thick, computerwise, I decided to take the easier, Virtual Acorn, course.


If you have time to make a comment, I would welcome it. 


If it is of any interest, I am writing a program to analyse our electricity generation and use. We have PV solar cells on the roof and a heat pump and underfloor heating.


Thank you again for your huge effort and skill in writing BBC BASIC for Windows.


Yours sincerely,


John Nolan






From: news@... <news@...>
Sent: 09 April 2016 12:31
To: bb4w@groups.io
Subject: [bb4w] BBC BASIC in the news
 

It's rare to see BBC BASIC mentioned in news outlets these days, so I was interested to see this article in the online InfoWorld magazine:

Visual Basic hits the skids in language popularity

Here is what it says (quoting Tiobe MD Paul Jansen): "Classic Visual Basic is going down, but also VB.Net is about to lose its top 10 position, which means that we are on the brink of no Basic language in the top 10 since we started tracking the Tiobe index... There are alternatives available, such as PureBasic (position #43), thinBasic (#77) and BBC Basic (#79), but their communities are still too small yet to compensate the declining popularity of Visual Basic".

That sets something of a challenge: since BBC Basic is only two places below thinBasic perhaps with a bit of effort we can close the gap! The index uses the number of times a language is searched for on Google etc. as its metric for popularity. So get searching for BBC BASIC even though you know where to find it. wink

Richard.


BBC BASIC in the news

Richard Russell
 

It's rare to see BBC BASIC mentioned in news outlets these days, so I was interested to see this article in the online InfoWorld magazine:

Visual Basic hits the skids in language popularity http://www.infoworld.com/article/3054000/application-development/visual-basic-hits-the-skids-in-language-popularity.html

Here is what it says (quoting Tiobe MD Paul Jansen): "Classic Visual Basic is going down, but also VB.Net is about to lose its top 10 position, which means that we are on the brink of no Basic language in the top 10 since we started tracking the Tiobe index http://www.tiobe.com/tiobe_index... There are alternatives available, such as PureBasic (position #43), thinBasic (#77) and BBC Basic (#79), but their communities are still too small yet to compensate the declining popularity of Visual Basic".

That sets something of a challenge: since BBC Basic is only two places below thinBasic perhaps with a bit of effort we can close the gap! The index uses the number of times a language is searched for on Google etc. as its metric for popularity. So get searching for BBC BASIC even though you know where to find it.

Richard.
Note: This group is closed to replies. If you want to comment on this post please do so at
http://bbcbasic.conforums.com/index.cgi?board=general&;action=display&num=1460201412 http://bbcbasic.conforums.com/index.cgi?board=general&;action=display&num=1460201412


BBC BASIC in the news

Richard Russell
 

It's rare to see BBC BASIC mentioned in news outlets these days, so I was interested to see this article in the online InfoWorld magazine:

Visual Basic hits the skids in language popularity

Here is what it says (quoting Tiobe MD Paul Jansen): "Classic Visual Basic is going down, but also VB.Net is about to lose its top 10 position, which means that we are on the brink of no Basic language in the top 10 since we started tracking the Tiobe index... There are alternatives available, such as PureBasic (position #43), thinBasic (#77) and BBC Basic (#79), but their communities are still too small yet to compensate the declining popularity of Visual Basic".

That sets something of a challenge: since BBC Basic is only two places below thinBasic perhaps with a bit of effort we can close the gap! The index uses the number of times a language is searched for on Google etc. as its metric for popularity. So get searching for BBC BASIC even though you know where to find it. wink

Richard.


File - reminder.txt

bb4w@...
 

(This message is posted automatically once a month)

If you are currently receiving emails from the group but would
prefer not to, you can change your email delivery settings. To
do that click on 'Edit Membership' above (if you are reading this
on the group's web page) or connect to the internet and click on
this link: http://groups.yahoo.com/group/bb4w/join

Scroll down to the section entitled Message Delivery and you will
see four radio-button options:

o Individual Email
o Daily Digest
o Special Notices
o Web Only

Select 'Special Notices' or 'Web Only', then confirm by clicking
Save Changes, and you won't be troubled by group emails (if you
select Special Notices you will still receive important messages
such as announcements of new versions of BBC BASIC for Windows).

Richard.

3081 - 3100 of 23891