BBCBASIC and C++

Here you can talk about anything related to BBC BASIC, not covered in another category
DDRM

Re: BBCBASIC and C++

Post by DDRM »

Hi Kendall,

A couple of interesting things there:

1) I didn't realise you could separate items in a print list with spaces (rather than commas or semicolons), but the manual also shows this, so I've learnt something useful! :-)

2) I find it surprising that the global i% gets initialised, so PROCtwo prints 0 instead of throwing a "no such variable" error! I guess it happens implicitly when a local variable is defined, so the two can be distinguished (when you leave a procedure the global value is (re)assigned to the variables, so I guess it happens as part of that). Consistent with that, if you call PROCtwo before PROCone, it DOES fail with an error.

An enumeration is a data type which can only hold certain values: for example, you might have an enumeration DAYS = {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday}. Then if you declared a variable of type DAYS it could only validly hold one of those values. Typically you'd also be able to use ordinal functions - so today + 1 = tomorrow...

Best wishes,

D
Ivan
Posts: 127
Joined: Tue 07 May 2019, 16:47

Re: BBCBASIC and C++

Post by Ivan »

@KenDown

No, Ivan is absolutely not typical. :)

My wife and I enjoy Welch crime’s and we are fascinated by Welch, which we will never understand, but it sounds and looks great.

Do you speak/read welch?

@DDRM

In basic I often name variables: left_marging = 10 ect. I only use short variable names in loops. In C++ I would use const everywhere I can, so the compiler will refuse to change them, but I think you know that.

I am also pleased, that I don’t have to write deffn for a function or similar but only the return type:

num = avg(num1, num2)

Or if the function don’t return anything, I handle the function as a basic procedure.

I also use prototypes for functions and place them in separate files (header files) and the compiler will confront you if they don’t maths.

But it's relatively easy to convert a basic program to C++, if any one will have a go.
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. C++ in 2021.
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

Re: BBCBASIC and C++

Post by KenDown »

Fortunately there are not all that many crimes in Wales - compared, say, to London. I do speak Welsh and enjoy sharing bits of the culture.

Yes, translating a simple program into C would not be too difficult, as the syntaxes are fairly similar. I'm not sure about big, complex programs with lots of SYS calls and so on. I may well dabble in C just for fun, but I can't see myself using it in preference to good old BBC BASIC!
Ivan
Posts: 127
Joined: Tue 07 May 2019, 16:47

Re: BBCBASIC and C++

Post by Ivan »

Oh oh - I misspelled crimis, I mean of course tv-series - sorry.

What do you often share about Welsh?

I think I know your feelings about BBCBASIC. I often thinks if had to do this in Basic It would have been finished. Not so often more after I got to know C++ better. You can be really stocked, but the debugger is a great help.
KenDown wrote: Tue 05 Oct 2021, 19:32 Fortunately there are not all that many crimes in Wales - compared, say, to London. I do speak Welsh and enjoy sharing bits of the culture.

Yes, translating a simple program into C would not be too difficult, as the syntaxes are fairly similar. I'm not sure about big, complex programs with lots of SYS calls and so on. I may well dabble in C just for fun, but I can't see myself using it in preference to good old BBC BASIC!
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. C++ in 2021.
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

Re: BBCBASIC and C++

Post by KenDown »

Well, one reason why I wrote my own Display program was because in many places there is a mixed English/Welsh congregation. I can run two projectors and display an English and a Welsh version of my presentation simultaneously. It is much appreciated by whichever language group is in the miority in that chapel! There are parts of the program that I wonder whether they would be faster in another language (such as C) but on the whole BBC BASIC does all I want and at a reasonable speed.
Ivan
Posts: 127
Joined: Tue 07 May 2019, 16:47

Re: BBCBASIC and C++

Post by Ivan »

In the end it's the right tool and the right programmer, that does the job.

BBC BASIC' graphics is reasonably fast and it have a very low compile time.

A few months ago I wrote a 3000 lines BBC BASIC program to measure the amount of lane of fabric for different jobs. It sometimes involves 50 or more different sized rectangles that have be redraw in different positions while scrolled sideways. It went surprisingly well. I used old style XOR drawing to emulate a moving object.

Last year I made a 3D line drawing test program with rotation, resizing, editing etc. and again the graphics was OK.

C++ status: The abstraction level is very high. I now know, why C++ is called a very difficult language. For now, I think I will end up with a kind of C++/c style and do more programming the studying.
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. C++ in 2021.
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

Re: BBCBASIC and C++

Post by KenDown »

Fascinating. Not sure what a "lane of fabric" is, but if writing your own program solves the problem, great. That's what I tell people when encouraging them to take up programming - you can make the computer do what *you* want it to do, in the way *you* want to do it, rather than being restricted by what other people, however clever, have decided to do.
Ivan
Posts: 127
Joined: Tue 07 May 2019, 16:47

Re: BBCBASIC and C++

Post by Ivan »

I thought fabric was the same as textile. To polstring seats on sofas, in boats etc.

Agreed - I think that is the idea of e.g. Raspberry Pi. To give people a better understanding of programs and computers again.

I also encourage people to use free software, instead of proprietary software.

The reason, I decided to construct my ovn relational database was, I had a made a Business Solution in a well known company's database system years ago. Every and each time "they" decided to make a new version, I had to deal with unnecessary issues.

Now I have my relations database up and running in C++, just as I did in BBC BASIC. It feels very satisfying.
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. C++ in 2021.
KenDown
Posts: 327
Joined: Wed 04 Apr 2018, 06:36

Re: BBCBASIC and C++

Post by KenDown »

To DRM: (Oct 5)
Actually, that is not so. (Assuming you're referring to the mini program I supplied with PROCone and PROCtwo. You could omit the spaces and get the same output. It is the different variable types which cause the spacing and the fact that numbers are, by default, right-justified.

Thanks for enlightening my ignorance about "enumeration". I've never heard of it before.
Ivan
Posts: 127
Joined: Tue 07 May 2019, 16:47

Re: BBCBASIC and C++

Post by Ivan »

Hi,

The transition from BBCBASIC to C++ have been a challenging journey. But now I have finished a relations database even with search facilities in 2000 lines of code. The database have a graphical design in a console and the editing facilities and even the cursor, blink-rate ec. is all coded by me. C++ have anything I can think of, but I wanted to get used to program C++ and now I feel confident although I'm not at all an expert.

If you know BBCBASIC's file handling it's relatively easy to do it in C++. But in C++ there practical no limits to anything and can be very advanced (i'm not).

It took some time to change my approach from procedural to object oriented programming. Now I have the same feeling when I learned to use 6502 assembler in the eaighties

I don't think I have changed, if BBCBASIC was continued, but now I'm glad I did it - almost nine months. I saw no perspective in learning another basic (SDL).

Regards,

Ivan
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. C++ in 2021.