Date   

Re: BBC BASIC for Linux gallery

Richard Russell
 

Given that SDL uses OpenGL under the hood (on most platforms) it was somewhat ironic that one example program I had not succeeded in adapting to 'BBC BASIC for Linux' was OPENGL.BBC itself.  I have now resolved that difficulty and added a screenshot to the gallery.

Richard.



Re: BBC BASIC for Linux gallery

Richard Russell
 

The observant amongst you might have noticed that CLOCK.BBC wasn't one of the example programs included in the gallery. That's not because it was difficult to adapt (the main change was to use BMP rather than JPG images) but because it makes heavy use of the TINT() function, which is very slow in BBC BASIC for Linux (this is because getting data back from an OpenGL surface is inefficient). I have now restructured the program so that it doesn't use TINT() at all, and it runs much faster; I've also added a screen grab to the gallery.


Richard.


Re: BBC BASIC for Linux gallery

Richard Russell
 

The observant amongst you might have noticed that CLOCK.BBC wasn't one of the example programs included in the gallery.  That's not because it was difficult to adapt (the main change was to use BMP rather than JPG images) but because it makes heavy use of the TINT() function, which is very slow in BBC BASIC for Linux (this is because getting data back from an OpenGL surface is inefficient).  I have now restructured the program so that it doesn't use TINT() at all, and it runs much faster; I've also added a screen grab to the gallery.

Richard.



Re: File Selector in BASIC?

Richard Russell
 

On Mon, Dec 21, 2015 at 01:26 pm, J.G.Harston wrote:
The main problem that is difficult to work around is the rare case where a long filename that crosses more than one display column has a space in the filename in a crucial position that makes it look like another column starts.

It's an unavoidable consequence of trying to use a 'human readable' output for a purpose that it was never intended for.  One issue that arises in Linux is that *DIR does not sort filenames into alphabetical order, so if that was a concern one would have to capture the output (e.g. using *SPOOL) and then read it back into (e.g.) an array for sorting.  Probably not worth the effort initially, but might be desirable in a 'fully developed' program.

Richard.


Re: File Selector in BASIC?

J.G.Harston
 

This seems to be a close to fully working as I can easily get it. It actually looks very close to the file selector on Computer Concepts' InterWord/etc products on the BBC.

For a commented version see http://mdfs.net/System/Library/BLib/Win/FPickerCommented.bbc

The main problem that is difficult to work around is the rare case where a long filename that crosses more than one display column has a space in the filename in a crucial position that makes it look like another column starts. It's hard to work around this as it's hard for the human reader to tell unless the human reader knows from external information what the directory contents are "supposed" to look like.

REM > FPickerDemo.bbc 1.00 21-Dec-2015 J.G.Harston
REM Text-only file picker, independent of any API calls
REM Navigates between directories, returns selected filename
REM
REM Bugs:
REM If catalog scrolls the screen, display becomes messy
REM Can't tell difference between filename with spaces that matches column break
:
REM MODE 12:COLOUR 4:COLOUR 128+1
REPEAT
PRINT"File Picker Demo"'
A$=FNfile_picker
PRINT "File picked: ";A$;
A%=INKEY(200):CLS
UNTIL FALSE
END
:
DEFFNfile_picker
LOCAL width%,yp0%,yp1%,xp%,yp%,A$,A%,K%,colwidth%,colmax%,fg%,bg%,last%
colwidth%=20:REM Hard wired
LOCAL ERROR:ON ERROR LOCAL A$=FNfile_highlight(fg%,128+bg%):PRINTTAB(0,yp1%):IF ERR=17:="" ELSE RESTORE ERROR:ERROR ERR,REPORT$
fg%=@vdu%?70:bg%=@vdu%?71
REPEAT
yp0%=VPOS
*. *.*
VDU 8:width%=POS:colmax%=((width%+1) DIV colwidth%)-1:yp1%=VPOS
IF colmax%>3:colmax%=3:REM Hard wired
yp%=yp0%+1:xp%=0
REPEAT
PRINTTAB((xp% AND (yp%<>yp0%))+2,yp%);
A$=FNfile_highlight(bg%,128+fg%)
PRINTTAB((xp% AND (yp%<>yp0%))+2,yp%);
K%=TRUE
IF K%:IF yp%>yp0%:VDU8:A%=FNscrnchr:VDU9:IFA%<>32:K%=FALSE
IF K%:IF ASCA$=32:IF last%:K%=FALSE:IFyp%=yp1%:last%=last%EOR1
REPEAT IF K%:K%=GET ELSE K%=last%
UNTIL (K%>135 AND K%<140) OR K%=13 OR K%=8
last%=K%
IF K%>127:A$=FNfile_highlight(fg%,128+bg%)
IF K%=136:xp%=xp%-colwidth%:IF xp%<0:xp%=colwidth%*colmax%:K%=139
IF K%=137:xp%=xp%+LENA$+3 :IF xp%>colwidth%*colmax%:xp%=0:K%=138
IF K%=138:yp%=yp%+1 :IF yp%>yp1%:yp%=yp%-1:last%=0
IF K%=139:yp%=yp%-1 :IF yp%<yp0%:yp%=yp%+1:last%=0
UNTIL K%=13 OR K%=8:IF K%=8:A$=".."
COLOUR fg%:COLOUR 128+bg%
IF yp%=yp0%:INPUT LINE SPC(width%);TAB(0,yp%);"Enter directory: "A$
PRINT TAB(0,yp1%)
LOCAL ERROR:ON ERROR LOCAL =FNs(A$)
IF ASCA$<>32:OSCLI "CD "+A$
PRINT TAB(0,yp0%);
REPEAT:PRINTSPC(width%+1);:UNTIL VPOS>yp1%
PRINT TAB(0,yp0%);
UNTIL FALSE
=""
:
DEFFNfile_highlight(C%,B%)
COLOUR C%:COLOUR B%:C%=FALSE:A$=""
IF yp%=yp0%:VDU 8,8
REPEAT
B%=FNscrnchr:A$=A$+CHR$B%:VDU B%
IF yp%=yp0%:C%=LENA$=width% ELSE IF (LENA$ MOD colwidth%=colwidth%-3) OR POS<1:IF FNscrnchr=32:C%=TRUE
UNTIL C%:=A$
:
DEFFNscrnchr:A%=135:=((USR&FFF4)AND&FF00)DIV256
:
DEFFNs(A$)
WHILE LEFT$(A$,1)=" ":A$=MID$(A$,2):ENDWHILE
WHILE RIGHT$(A$,1)=" ":A$=LEFT$(A$,LENA$-1):ENDWHILE
=A$


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


Re: File Selector in BASIC?

J.G.Harston
 

Update 2.
Moving to the 'Directory' heading allows you to select a drive/directory.
Copes with long filenames that spread across more than one column.

Bugs:
If catalog scrolls the screen, base position lost
Blank entry can be selected, returns "" to caller - could delagate the caller to deal with that.
Can't tell apart filename with spaces that matches column break, eg:
Long filename and spaces.doc <-- this one
filename2.doc filename3.doc


REM > FilePicker
:
REM MODE 12
REPEAT
PRINT"File Picker Demo"'
A$=FNfile_picker
PRINT "File picked: ";A$;
A%=INKEY(200):CLS
UNTIL FALSE
END
:
DEFFNfile_picker
LOCAL width%,yp0%,yp1%,xp%,yp%,A$,A%,K%,colwidth%,colmax%,fg%,bg%
colwidth%=20:REM Hard wired
LOCAL ERROR:ON ERROR LOCAL A$=FNfile_highlight(fg%,128+bg%):PRINTTAB(0,yp1%):IF ERR=17:="" ELSE RESTORE ERROR:ERROR ERR,REPORT$
bg%=POINT(0,0):fg%=bg%EOR63
REPEAT
yp0%=VPOS
*. *.*
VDU 8:width%=POS:colmax%=((width%+1) DIV colwidth%)-1:yp1%=VPOS
IF colmax%>3:colmax%=3:REM Hard wired
yp%=yp0%+1:xp%=0
REPEAT
PRINTTAB((xp% AND (yp%<>yp0%))+2,yp%);
A$=FNfile_highlight(bg%,128+fg%)
PRINTTAB((xp% AND (yp%<>yp0%))+2,yp%);
K%=TRUE:IF yp%>yp0%:VDU 8:A%=FNscrnchr:VDU 9:IF A%<>32:K%=FALSE
REPEAT IF K%:K%=GET ELSE K%=136
UNTIL (K%>135 AND K%<140) OR K%=13 OR K%=8
IF K%>127:A$=FNfile_highlight(fg%,128+bg%)
IF K%=136:xp%=xp%-LENA$-3:IF xp%<0:xp%=colwidth%*colmax%:K%=139
IF K%=137:xp%=xp%+LENA$+3:IF xp%>colwidth%*colmax%:xp%=0:K%=138
IF K%=138:yp%=yp%+1 :IF yp%>yp1%:yp%=yp%-1
IF K%=139:yp%=yp%-1 :IF yp%<yp0%:yp%=yp%+1
UNTIL K%=13 OR K%=8:IF K%=8:A$=".."
COLOUR fg%:COLOUR 128+bg%
IF yp%=yp0%:INPUT LINE SPC(width%);TAB(0,yp%);"Enter directory: "A$
PRINT TAB(0,yp1%)
LOCAL ERROR:ON ERROR LOCAL =FNs(A$)
IF ASCA$<>32:OSCLI "CD "+A$
PRINT TAB(0,yp0%);
REPEAT:PRINTSPC(width%+1);:UNTIL VPOS>yp1%
PRINT TAB(0,yp0%);
UNTIL FALSE
=""
:
DEFFNfile_highlight(C%,B%)
A$="":COLOUR C%:COLOUR B%:IF yp%=yp0%:VDU 8,8
REPEAT
FOR C%=1 TO ((colwidth%-3) AND (yp%>yp0%))+(width% AND (yp%=yp0%))
B%=FNscrnchr:A$=A$+CHR$B%:VDU B%
NEXT C%
B%=FNscrnchr
IF B%<>32:VDU B%:A$=A$+CHR$B%+CHR$FNscrnchr:PRINTRIGHT$(A$,1);
UNTIL B%=32
=A$
:
DEFFNscrnchr:A%=135:=((USR&FFF4)AND&FF00)DIV256
:
DEFFNs(A$)
WHILE LEFT$(A$,1)=" ":A$=MID$(A$,2):ENDWHILE
WHILE RIGHT$(A$,1)=" ":A$=LEFT$(A$,LENA$-1):ENDWHILE
=A$

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


Re: File Selector in BASIC?

Richard Russell
 

On Mon, Dec 21, 2015 at 06:24 am, J.G.Harston wrote:

Update 1. Selecting a directory goes into it, go up by selecting '..' or pressing BACKSPACE.

Thanks again, that's actually quite functional; I'll use it, if I may, at least until something better turns up.  I just need to work out how to integrate it into a GUI framework, but hopefully a text viewport will be all that is required (I'm generally emulating 'popup' windows with a *GSAVE... open text viewport... *DISPLAY sequence to restore the GUI when the popup closes).

To create a complete GUI IDE in BASIC with no OS widgets is going to be a challenge, but apart from being rather on the sluggish side I think it is achievable.

Richard.
 


Re: File Selector in BASIC?

J.G.Harston
 

rtrussell wrote:
Thanks, but unfortunately it selects only *within* a given
directory/folder; there appears to be no ability to navigate the
filesystem hierarchy (no way to go 'up' or to select a sub-folder and
go 'down') so its usefulness as a file selector is, shall we say,
somewhat limited. :(
Update 1. Selecting a directory goes into it, go up by selecting '..' or pressing BACKSPACE. Still has problems with filenames that span more than one column, if the catalogue scrolls off the bottom of the screen, and has no ability to select a different drive. I'm to think of a way to select a drive without filling the screen with A: B: C: D: E: etc options. Possibly "Press Ctrl+DriveLetter to change drive".

REM > FilePicker
:
PRINT"File Picker Demo"'
A$=FNfile_picker
PRINT "File picked: ";A$
END
:
DEFFNfile_picker
REPEAT
xp%=0:yp%=VPOS+1:yp0%=yp%
*. *.*
yp1%=VPOS-1
REPEAT
PRINTTAB(xp%+2,yp%);
A$=FNfile_highlight(63,128)
PRINT TAB(xp%+2,yp%);
REPEAT K%=GET:UNTIL K%=13 OR K%=8 OR (K%>135 AND K%<140)
IF K%<>13:A$=FNfile_highlight(0,128+63)
IF K%=136:xp%=xp%-20:IF xp%<0 :xp%=60:K%=139
IF K%=137:xp%=xp%+20:IF xp%>60:xp%=0 :K%=138
IF K%=138:yp%=yp%+1 :IF yp%>yp1%:yp%=yp%-1:xp%=0
IF K%=139:yp%=yp%-1 :IF yp%<yp0%:yp%=yp%+1:xp%=0
UNTIL K%=13 OR K%=8:IF K%=8:A$=".."
COLOUR 0:COLOUR 128+63
PRINT TAB(0,yp1%)
LOCAL ERROR:ON ERROR LOCAL =A$
OSCLI "CD "+A$
PRINT TAB(0,yp0%);:VDU8:wd%=POS:PRINT CHR$13;
REPEAT:PRINTSPC(wd%+1);:UNTIL VPOS>yp1%
PRINT TAB(0,yp0%-1);
UNTIL FALSE
=A$
:
DEFFNfile_highlight(C%,B%)
A$="":COLOUR C%:COLOUR B%
A%=135:FOR C%=1 TO 20:B%=((USR&FFF4)AND&FF00)DIV256:A$=A$+CHR$B%:VDUB%:NEXT C%
=A$

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


Re: File Selector in BASIC?

Richard Russell
 

On Mon, Dec 21, 2015 at 05:26 am, J.G.Harston wrote:

Found it. It's got a couple of hard-wired bits in it, and it doesn't
check for filenames that span more than one column. 

Thanks, but unfortunately it selects only *within* a given directory/folder; there appears to be no ability to navigate the filesystem hierarchy (no way to go 'up' or to select a sub-folder and go 'down') so its usefulness as a file selector is, shall we say, somewhat limited.  :(

What I'm looking for is something I can use in BBCSDL programs to replace calls to the GetOpenFileName (and GetSaveFileName) API functions.  I can't expect a comparable functionality to what the Windows dialogue provides, but it's got to have at least the capability of navigating to different directories and different drives etc.

Richard.



Re: File Selector in BASIC?

J.G.Harston
 

J.G.Harston wrote:
rtrussell wrote:
Has anybody written a File Selector (Choose File dialogue) in BASIC -
Somewhere I've got some code that does *CAT then lets you move a
highlight bar over the screen and reads the underlying filename with
Found it. It's got a couple of hard-wired bits in it, and it doesn't check for filenames that span more than one column.

REM > FilePicker
:
PRINT"File Picker Demo"'
A$=FNfile_picker
PRINT "File picked: ";A$
END
:
DEFFNfile_picker
xp%=0:yp%=VPOS+1:yp0%=yp%
*. *.*
yp1%=VPOS-1
REPEAT
PRINTTAB(xp%+2,yp%);
A$=FNhighlight(63,128)
PRINTTAB(xp%+2,yp%);
REPEAT K%=GET:UNTIL K%=13 OR (K%>135 AND K%<140)
IF K%<>13:A$=FNhighlight(0,128+63)
IF K%=136:xp%=xp%-20:IF xp%<0 :xp%=60:K%=139
IF K%=137:xp%=xp%+20:IF xp%>60:xp%=0 :K%=138
IF K%=138:yp%=yp%+1 :IF yp%>yp1%:yp%=yp%-1:xp%=0
IF K%=139:yp%=yp%-1 :IF yp%<yp0%:yp%=yp%+1:xp%=0
UNTIL K%=13
COLOUR0:COLOUR128+63
PRINTTAB(0,yp1%)
=A$
:
DEFFNhighlight(C%,B%)
A$="":COLOUR C%:COLOUR B%
A%=135:FOR C%=1 TO 20:B%=((USR&FFF4)AND&FF00)DIV256:A$=A$+CHR$B%:VDUB%:NEXT C%
=A$

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


Re: File Selector in BASIC?

J.G.Harston
 

rtrussell wrote:
Has anybody written a File Selector (Choose File dialogue) in BASIC -
i.e. without any calls to the Windows API - that they would be
prepared to share?
Do you mean something more sophisticated than:
REPEAT
*CAT
INPUT LINE ":"F$
IF LEFT$(F$,1)="*" THEN OSCLI MID$(F$,2):F$=""
UNTIL F$<>""

Somewhere I've got some code that does *CAT then lets you move a highlight bar over the screen and reads the underlying filename with OSBYTE 135. I'll see if I can find it.

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


File Selector in BASIC?

Richard Russell
 

Has anybody written a File Selector (Choose File dialogue) in BASIC - i.e. without any calls to the Windows API - that they would be prepared to share?
Richard.


File Selector in BASIC?

Richard Russell
 

Has anybody written a File Selector (Choose File dialogue) in BASIC - i.e. without any calls to the Windows API - that they would be prepared to share?

Richard.



Re: BBC4W for a Linux

Richard Russell
 

---In bb4w@yahoogroups.com, <dave@davesergeant.com> wrote :
> Having just started playing with a Raspberry Pi I may be sort of
> interested. I see SDL has been installed on the Pi so it should work.


I am not sure whether that was tongue-in-cheek, but of course (and as emphasised repeatedly in these threads) the RPi uses entirely the wrong processor: an ARM rather than an x86 (IA-32-architdecture).


That SDL supports the Raspberry Pi, to a degree, is irrelevant if my BBC BASIC interpreter can't run! It's exactly the same for Android: I am always careful to state Android (86), a rarity compared with the great majority of devices which have ARM CPUs. Admittedly I am less careful always to say Linux (86), but nobody here or at other BB4W forums should be confused, any more than they are by me referring simply to Windows rather than Windows (86).


But do lend your support to the efforts being made to port compatible versions of BBC BASIC to RPi/Linux, notably Brandy and Sophie's ARM version. In fact I think Brandy is already available, although I don't have any details. I need hardly add that if you install RISC OS on the Pi you get BBC BASIC as standard!


Richard.


Re: BBC4W for a Linux

Dave Sergeant
 

Having just started playing with a Raspberry Pi I may be sort of
interested. I see SDL has been installed on the Pi so it should work.
But being totally new to it and only played occasionally with Linux in
the past, together with never having heard of SDL before you started
this, it may take a little while...

I think the demand is there but don't think it will happen overnight.

Dave

On 19 Dec 2015 at 14:33, yahoo@rtrussell.co.uk [bb4w] wrote:

But BBC Basic users will love to get BBC4L

So where are they? I have seen little evidence of any enthusiasm for
it. Like you, I thought there would be some
excitement about the new version, considering how often a Linux version
or a Mac OS version of BBC BASIC have been asked for. Perhaps those
people gave up waiting; to be fair I have always - honestly - said that
I had no plans to create either, so that might have put them off.
Somehow, although I was vaguely aware of SDL, I had not twigged until
very recently that it would allow me to create a Linux version, and
potentially also a Mac OS version, very easily.

http://davesergeant.com


Dual-platform programming

Richard Russell
 

It looks like I'll increasingly be writing code like this, to support multiple platforms:
BB4W% = (INKEY(-256) = &57)
IF BB4W% THEN
SYS "SetWindowText", @hwnd%, Title$
ON ERROR SYS "MessageBox", @hwnd%, REPORT$, "Error", 0 : QUIT
ELSE
SYS "SDL_SetWindowTitle", @hwnd%, Title$
ON ERROR SYS "SDL_ShowSimpleMessageBox", 0, "Error", REPORT$, @hwnd% : QUIT
ENDIF

Richard.


Dual-platform programming

Richard Russell
 

It looks like I'll increasingly be writing code like this, to support multiple platforms:

      BB4W% = (INKEY(-256) = &57)

      IF BB4W% THEN
        SYS "SetWindowText", @hwnd%, Title$
        ON ERROR SYS "MessageBox", @hwnd%, REPORT$, "Error", 0 : QUIT
      ELSE
        SYS "SDL_SetWindowTitle", @hwnd%, Title$
        ON ERROR SYS "SDL_ShowSimpleMessageBox", 0, "Error", REPORT$, @hwnd% : QUIT
      ENDIF

Richard.



Re: BBC4W for a Linux

svein svensson
 

I'm interested, but i do not have linux at the moment.
Have not used it for years.
When there is some spare time, i will try to get one up and running from spare parts.

Svein


Re: BBC4W for a Linux

Richard Russell
 

---In bb4w@yahoogroups.com, <davidfeugey@yahoo.com> wrote :
> don't believe people that tell you it's just a packaging issue. It's not. It's a compiling
> issue too, because of the versions of the libs present on each OS.


That confuses me, because no libraries are included when it is compiled. The only things in the executable file I create are the object code of my assembler modules, the compiled object code from a C 'wrapper' module I have written, and the compiled object code from a customised version of SDL2_gfx. There will also presumably be some startup code which is automatically added by GCC, but I would not have expected it to be specific to the flavour of Linux.


So how is it a compiling issue? I realise that the libs present on each OS are likely to be platform-specific, but so long as they are dynamically linked at run-time I don't understand why it would require my code to be recompiled. Surely the ELF file format is standardised across Linux flavours?



> the question is 'do you target Linux users or BBC Basic users'.


Well, at this stage I am targeting only people who use *both*. What I am primarily interested in is getting feedback on the functionality of the software, reports of bugs and other performance issues, suggestions for possible additions and modifications, and help with porting existing BASIC programs to the new SDL platform. The only people who can do that are those who are already very familiar with both BBC BASIC and Linux. I am assuming that such people exist!


> But BBC Basic users will love to get BBC4L


So where are they? I have seen little evidence of any enthusiasm for it. Like you, I thought there would be some excitement about the new version, considering how often a Linux version or a Mac OS version of BBC BASIC have been asked for. Perhaps those people gave up waiting; to be fair I have always - honestly - said that I had no plans to create either, so that might have put them off. Somehow, although I was vaguely aware of SDL, I had not twigged until very recently that it would allow me to create a Linux version, and potentially also a Mac OS version, very easily.


> (and even pay for it).


It will be free. I am not interested in creating additional paid-for software; BBC BASIC for Windows is, and will remain, my only commercial product.



So I will wait, not very patiently, for somebody to show some interest in the (admittedly very early) version of 'BBC BASIC for Linux' that I uploaded yesterday. I want to know if it runs on anybody else's system, particularly if it's different from my own (32-bit Ubuntu 14.04.3). I want to know if it's what people want!


Richard.


Re: BBC BASIC for Linux

David Feugey
 

"I must say that there does seem to be a disparity between what the 'experts' at the forum said and what my 'common sense' predicts. They vehemently asserted that the only way to distribute a program, such that it would run on a wide range of Linux installations, was either to use some kind of 'package manager' or to supply source code."

They are so good that they don't even mention this :
https://build.opensuse.org/ https://build.opensuse.org/

One tool too make all your packages for all distributions. Don't need to be Open Source software.

Nota: don't believe people that tell you it's just a packaging issue. It's not. It's a compiling issue too, because of the versions of the libs present on each OS.

As I said before, there is no need for package. If someone really wants one, he'll simply propose you to do one. But as it's a package for developer, no one will ask... Your current version is OK.

Nota : the question is 'do you target Linux users or BBC Basic users'. Of course, some Linux users will complain about the closed source thing. But BBC Basic users will love to get BBC4L (and even pay for it).

"To try to placate the Linux mafia, I must state that this does not constitute a 'release'. To the best of my knowledge all the relevant licensing conditions have been complied with."

There is no legal issue. Of course, some people will always complain about the license (and once in GPL they'll complain about absence on GitHub, then complain on another thing). Real users will not care.

So do as Xojo or Wolfram Alpha: make your users happy

Nota: except Stallman, there is no open source Mafia in Linux core developers. Only some shouting users. I never heard someone as Linus saying that closed source software is shit. He just don't care (he's using OS X anyway, so he really don't care).

Bye.

3341 - 3360 of 23951