Can we have useful BASIC with no IF statements?
-
- Posts: 1058
- Joined: Wed Jan 27, 2016 12:50 am
- Contact:
Can we have useful BASIC with no IF statements?
... Or any other critical BASIC functions like GOSUB or whatnot?
I've been watching The Computer Programme and knew some really clever blokes had dished up all that programming to make the BBC work, plus all those other things like the lathes. Now I wonder if you clever guys are able to look at that music program I wrote and see if it's possible to have it run with no IF statements. I'm really fascinated to see how you real computer people may do, at least for a five minute think.
And if we can, can it be pared down to the most crude level possible and still work as listed? Like no INKEY$ or whatnot. It's pretty crude anyway.
Then let me run them for us on video and see how we do!
viewtopic.php?f=2&t=11512
I've been watching The Computer Programme and knew some really clever blokes had dished up all that programming to make the BBC work, plus all those other things like the lathes. Now I wonder if you clever guys are able to look at that music program I wrote and see if it's possible to have it run with no IF statements. I'm really fascinated to see how you real computer people may do, at least for a five minute think.
And if we can, can it be pared down to the most crude level possible and still work as listed? Like no INKEY$ or whatnot. It's pretty crude anyway.
Then let me run them for us on video and see how we do!
viewtopic.php?f=2&t=11512
Re: Can we have useful BASIC with no IF statements?
Could you post your program in plaintext? It's a bit hard to see what's on the screen in your photo.
Regards,
- Patrick
- Patrick
Re: Can we have useful BASIC with no IF statements?
Most of the test programs I write look like:
Not many BASIC constructs there, but very useful
even though that isn't what you meant.
Sorry (a bit anyway).
Code: Select all
10 P%=&xxxx
20{OPT 2
...
80}
90call &xxxx
Not many BASIC constructs there, but very useful

Sorry (a bit anyway).
- 1024MAK
- Posts: 7200
- Joined: Mon Apr 18, 2011 4:46 pm
- Location: Looking forward to summer in Somerset, UK...
- Contact:
Re: Can we have useful BASIC with no IF statements?
I'll raise you, can you write a paragraph (180 letters minimum) of English text which is readable out loud and which is meaningful and which makes sense without using the letter 'e'?
Mark
Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki - for answers to many questions...
BeebWiki - for answers to many questions...
Re: Can we have useful BASIC with no IF statements?
1024MAK wrote:I'll raise you, can you write a paragraph (180 letters minimum) of English text which is readable out loud and which is meaningful and which makes sense without using the letter 'e'?
Alrighty! Just switch on a BBC Micro and start coding. Try omitting all IFs, ANDs and BUTs... Oops! No BUTs in BBC BASIC. How silly I am. It's almost as if I know nothing of Acorn or its products. I think I should go. I'll shut t' door on my way out...

- Lardo Boffin
- Posts: 932
- Joined: Thu Aug 06, 2015 6:47 am
- Contact:
Re: Can we have useful BASIC with no IF statements?
1024MAK wrote:I'll raise you, can you write a paragraph (180 letters minimum) of English text which is readable out loud and which is meaningful and which makes sense without using the letter 'e'?
Mark
I don't know about e but Edward Woodward's name doesn't sound so good without the letter d.
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Retroclinic Datacentre + HDD, Viglen twin 40/80 5.25" discs, acorn cassette, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
BBC Master
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
BBC Master
- Lardo Boffin
- Posts: 932
- Joined: Thu Aug 06, 2015 6:47 am
- Contact:
Re: Can we have useful BASIC with no IF statements?
You could try something like the following for line 60:-
Let A=(B*2)*(STICK%=8)
Assuming I am reading the screen shot correctly.
In theory if stick%=8 then it will evaluate to A=B*2*1 which is correct (sort of, providing you can ignore the 0 later in without using a conditional operator) otherwise it evaluates to 0 - might be the other way round though. Although I haven't tried it in Beeb basic.
It also makes the program unreadable and impossible to debug. Further downstream the logic gets more complex and stretched.
Of course if you want a programming challenge with no IF or Inkey etc try this
https://en.m.wikipedia.org/wiki/Brainfuck
Let A=(B*2)*(STICK%=8)
Assuming I am reading the screen shot correctly.
In theory if stick%=8 then it will evaluate to A=B*2*1 which is correct (sort of, providing you can ignore the 0 later in without using a conditional operator) otherwise it evaluates to 0 - might be the other way round though. Although I haven't tried it in Beeb basic.
It also makes the program unreadable and impossible to debug. Further downstream the logic gets more complex and stretched.
Of course if you want a programming challenge with no IF or Inkey etc try this
https://en.m.wikipedia.org/wiki/Brainfuck
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Retroclinic Datacentre + HDD, Viglen twin 40/80 5.25" discs, acorn cassette, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
BBC Master
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
BBC Master
Re: Can we have useful BASIC with no IF statements?
1024MAK wrote:I'll raise you, can you write a paragraph (180 letters minimum) of English text which is readable out loud and which is meaningful and which makes sense without using the letter 'e'?
Mark
I should think so. How difficult a task... not so difficult if you watch what you do. I know of a book - A Void - amusing, if painful; worth a quick look anyway. How's that for a lipographic paragraph?
Re: Can we have useful BASIC with no IF statements?
Lardo Boffin wrote:You could try something like the following...
Yes, you can do a surprising amount with just arithmetic.
- 1024MAK
- Posts: 7200
- Joined: Mon Apr 18, 2011 4:46 pm
- Location: Looking forward to summer in Somerset, UK...
- Contact:
Re: Can we have useful BASIC with no IF statements?
BigEd wrote:Lardo Boffin wrote:You could try something like the following...
Yes, you can do a surprising amount with just arithmetic.
Also known as Boolean algebra

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki - for answers to many questions...
BeebWiki - for answers to many questions...
- 1024MAK
- Posts: 7200
- Joined: Mon Apr 18, 2011 4:46 pm
- Location: Looking forward to summer in Somerset, UK...
- Contact:
Re: Can we have useful BASIC with no IF statements?
BigEd wrote:1024MAK wrote:I'll raise you, can you write a paragraph (180 letters minimum) of English text which is readable out loud and which is meaningful and which makes sense without using the letter 'e'?
Mark
I should think so. How difficult a task... not so difficult if you watch what you do. I know of a book - A Void - amusing, if painful; worth a quick look anyway. How's that for a lipographic paragraph?

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki - for answers to many questions...
BeebWiki - for answers to many questions...
-
- Posts: 1058
- Joined: Wed Jan 27, 2016 12:50 am
- Contact:
Re: Can we have useful BASIC with no IF statements?
Whoa, I pop to a funeral and now I've all this correspondence.
I think I can say this wins the contest, in spirit!
The picture does blow up. But I think no, as I'm not sure my MMC thing works properly right now.
Lardo Boffin wrote:Of course if you want a programming challenge with no IF or Inkey etc try this
https://en.m.wikipedia.org/wiki/Brainfuck
I think I can say this wins the contest, in spirit!
dhg2 wrote:Could you post your program in plaintext? It's a bit hard to see what's on the screen in your photo.
The picture does blow up. But I think no, as I'm not sure my MMC thing works properly right now.
- FourthStone
- Posts: 479
- Joined: Thu Nov 17, 2016 2:29 am
- Location: Melbourne, Australia
- Contact:
Re: Can we have useful BASIC with no IF statements?
Here's a little (very crude and hard to debug) attempt, IF's are gone but the INKEY is still there... this could probably be replaced with a call to OSBYTE...
Let me know if it still works as the screen grab is a bit hazy and hard to read B's 8's A's and 0's
EDIT: Updated the code a bit as I left some debugging variables and conditions in... should be right now
Let me know if it still works as the screen grab is a bit hazy and hard to read B's 8's A's and 0's
EDIT: Updated the code a bit as I left some debugging variables and conditions in... should be right now
Code: Select all
5 PB%=0
10 REPEAT: RESTORE 170
20 FOR T=1 TO 10
30 J%=(?&FE60 EOR &FF) AND &FF
40 FIRE%=J% AND &10
50 STICK%=J% AND &0F
60 READ A
70 A=ABS(STICK%=8)*6+ABS(STICK%=4)*1.5+ABS(STICK%<>8 AND STICK%<>4)*A
80 B=SGN(FIRE%)*INT(RND(10))+ABS(FIRE%=0)*3
90 SOUND 3,-15,A,3
100 A$=INKEY$(1):G=ABS(A$="")*30+110:GOTO G
110 B=ABS(A$=" ")*5+ABS(A$<>" ")*B
120 PB%=ABS(STICK%=2)*(ASC(A$)/2)+ABS(STICK%=1)*(ASC(A$)*2)+ABS(STICK%<>2 AND STICK%<>1)*ASC(A$)
130 SOUND 2,-15,PB%,B
140 CLS:PRINT"T: "+STR$(T)+ " A: "+STR$(A)+ " B: "+STR$(B)+ " PB: "+STR$(PB%)
150 NEXT
160 UNTIL 0
170 DATA 200,500,300,800,600,700,900,700,100,12
Re: Can we have useful BASIC with no IF statements?
lurkio wrote:1024MAK wrote:I'll raise you, can you write a paragraph (180 letters minimum) of English text which is readable out loud and which is meaningful and which makes sense without using the letter 'e'?
Alrighty! Just switch on a BBC Micro and start coding. Try omitting all IFs, ANDs and BUTs... Oops! No BUTs in BBC BASIC. How silly I am. It's almost as if I know nothing of Acorn or its products. I think I should go. I'll shut t' door on my way out...
:wink:
Well played! So good I didn't notice.
- 1024MAK
- Posts: 7200
- Joined: Mon Apr 18, 2011 4:46 pm
- Location: Looking forward to summer in Somerset, UK...
- Contact:
Re: Can we have useful BASIC with no IF statements?
BigEd wrote:lurkio wrote:1024MAK wrote:I'll raise you, can you write a paragraph (180 letters minimum) of English text which is readable out loud and which is meaningful and which makes sense without using the letter 'e'?
Alrighty! Just switch on a BBC Micro and start coding. Try omitting all IFs, ANDs and BUTs... Oops! No BUTs in BBC BASIC. How silly I am. It's almost as if I know nothing of Acorn or its products. I think I should go. I'll shut t' door on my way out...
Well played! So good I didn't notice.



Can't believe I never noticed either. I was kinda wondering what that post was all about earlier

Brilliant

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki - for answers to many questions...
BeebWiki - for answers to many questions...
Re: Can we have useful BASIC with no IF statements?
Joining in, this discussion occurs ad-infinitum in various forums but I don't think it has shown anything significant about our grammar apart from what dubious fun it can attract. Thus, no point to it in my opinion, it’s just wasting your brain. I’d say find a distraction that has worth and don’t worry about our grammatical quirks.... 

Re: Can we have useful BASIC with no IF statements?
Computationally or Linguistically speaking? 
d.

d.
Re: Can we have useful BASIC with no IF statements?
Ha! I win Daniel, speaking has an 'e' in it... 

- 1024MAK
- Posts: 7200
- Joined: Mon Apr 18, 2011 4:46 pm
- Location: Looking forward to summer in Somerset, UK...
- Contact:
Re: Can we have useful BASIC with no IF statements?



Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki - for answers to many questions...
BeebWiki - for answers to many questions...
Re: Can we have useful BASIC with no IF statements?
*physiognomypalm*
d.
d.
Re: Can we have useful BASIC with no IF statements?
Now that's just floccinaucinihilipilification....
Re: Can we have useful BASIC with no IF statements?
I didn't say anything without worth 
d.

d.
-
- Posts: 1058
- Joined: Wed Jan 27, 2016 12:50 am
- Contact:
Re: Can we have useful BASIC with no IF statements?
FourthStone wrote:
Let me know if it still works as the screen grab is a bit hazy and hard to read B's 8's A's and 0's
I'm afraid it doesn't. I have the short video clip and there probably is a bug in it! (The upload method is the only way I found to work but if the mods are annoyed as well, they can wipe these zips.)
Once again, only one MMC card works on my BBC - the one which came with the device - but I can use that to get the plain text listing for you. (Though not before headaches with unprotects and resets. Can't just work, can it? That would be too easy.)
Code: Select all
L.
10 ?&FE62=0
20 ENVELOPE 1,1,6,6,6,2,2,1,126,0,0,-126,126,126
30 ENVELOPE 2,1,4,-4,4,10,20,10,126,0,0,-126,126,126
40 FOR T=1 TO 10
45 LET C=3
50J%=(?&FE60 EOR &FF) AND &FF
55 FIRE%=J% AND &10
60 STICK%=J% AND &0F
70 LETB=3
80 READ A
90 IF STICK%=8 THEN LET A=A*2
100 IF STICK%=4 THEN LET A=A/2
105 IF FIRE%<>0 THEN LET B=INT(RND(10))
110 SOUND 3,1,A,3
120 CLS:PRINTT
130 A$=INKEY$(1):IFA$=""THEN GOTO 200
140 IF A$=" "THENLETB=5
150 IF A$=""THEN GOTO 200
160PB%=ASC(A$)
170 IF STICK%=2 THEN LET PB%=ASC(A$)/2
180 IF STICK%=1 THEN LET PB%=ASC(A$)*2
190 SOUND 1,2,PB%,B
200 NEXT T
210 RUN
220 DATA 200,500,300,800,600,700,900,700,100,12
>
- Attachments
-
- SDC10045.part4.rar
- (5 MiB) Downloaded 9 times
-
- SDC10045.part3.rar
- (5 MiB) Downloaded 9 times
-
- SDC10045.part2.rar
- (5 MiB) Downloaded 9 times
-
- SDC10045.part5.rar
- (5 MiB) Downloaded 10 times
-
- SDC10045.part1.rar
- (5 MiB) Downloaded 11 times
-
- Posts: 1058
- Joined: Wed Jan 27, 2016 12:50 am
- Contact:
Re: Can we have useful BASIC with no IF statements?
Ah. That's not the same listing. But it's certainly the latest version of what I'm talking about. Sorry there.
...
WAIT WAIT WAIT WAIT WAIT! WHAT??
It works just fine in Beeb Em. My real Beeb just treats it with disdain.
Try it yourselves! I've provided a disk image with both versions.
I'm still grateful though. I like the new display especially, very techie-like. Thanks a great deal.
(And I fixed the MMC issue. The name and file extension of the drive image needs to be in all-caps but the software makes it in lowercase anyway, 'til I change it.)
...
WAIT WAIT WAIT WAIT WAIT! WHAT??
It works just fine in Beeb Em. My real Beeb just treats it with disdain.
Try it yourselves! I've provided a disk image with both versions.
I'm still grateful though. I like the new display especially, very techie-like. Thanks a great deal.
(And I fixed the MMC issue. The name and file extension of the drive image needs to be in all-caps but the software makes it in lowercase anyway, 'til I change it.)
- Attachments
-
- Disk_510_Untitled.zip
- (1.14 KiB) Downloaded 10 times
- FourthStone
- Posts: 479
- Joined: Thu Nov 17, 2016 2:29 am
- Location: Melbourne, Australia
- Contact:
Re: Can we have useful BASIC with no IF statements?
I see my error, I saw a B that should of been an A... try this
EDIT: If you renumber the program remember to update line 100 to ensure it jumps to the correct line (refactor so that it jumps to the current line 140)

EDIT: If you renumber the program remember to update line 100 to ensure it jumps to the correct line (refactor so that it jumps to the current line 140)
Code: Select all
1 ?&FE62=0
5 PB%=0
6 ENVELOPE 1,1,6,6,6,2,2,1,126,0,0,-126,126,126
7 ENVELOPE 2,1,4,-4,4,10,20,10,126,0,0,-126,126,126
10 REPEAT: RESTORE 170
20 FOR T=1 TO 10
30 J%=(?&FE60 EOR &FF) AND &FF
40 FIRE%=J% AND &10
50 STICK%=J% AND &0F
60 READ A
70 A=ABS(STICK%=8)*A*2+ABS(STICK%=4)*A*.5+ABS(STICK%<>8 AND STICK%<>4)*A
80 B=SGN(FIRE%)*INT(RND(10))+ABS(FIRE%=0)*3
90 SOUND 3,-15,A,3
100 A$=INKEY$(1):G=ABS(A$="")*30+110:GOTO G
110 B=ABS(A$=" ")*5+ABS(A$<>" ")*B
120 PB%=ABS(STICK%=2)*(ASC(A$)/2)+ABS(STICK%=1)*(ASC(A$)*2)+ABS(STICK%<>2 AND STICK%<>1)*ASC(A$)
130 SOUND 2,-15,PB%,B
140 CLS:PRINT"T: "+STR$(T)+ " A: "+STR$(A)+ " B: "+STR$(B)+ " PB: "+STR$(PB%)
150 NEXT
160 UNTIL 0
170 DATA 200,500,300,800,600,700,900,700,100,12
-
- Posts: 1058
- Joined: Wed Jan 27, 2016 12:50 am
- Contact:
Re: Can we have useful BASIC with no IF statements?
FourthStone wrote:I see my error, I saw a B that should of been an A...
I wonder how it still worked on Beeb-Em, then.
Yup, it works. I'm really pleased you can mess about with BASIC like that, making my program look all the more impenetrable to the computer users of today. And I've no doubt it's easy enough to convert for use with the normal joysticks on the BBC.
Once again, thanks where it's due. I'll be showing this off at some point. My program, with all you guys sharpening it to a glinty point over the months. (And the BBC lights flash nicely, too.)
I've included the video pieces, disk image and - most critically - the MP3 for my tape-only BBC with the joystick and line out. And cos, face it, it's good to rock out to the data. My reference.
- Attachments
-
- RIFFER 4 amendment (Stardot).mp3
- (859.69 KiB) Downloaded 14 times
-
- Disk_510_Untitled.zip
- (1.21 KiB) Downloaded 10 times
-
- SDC10046.part7.rar
- (5.71 MiB) Downloaded 10 times
-
- SDC10046.part6.rar
- (8 MiB) Downloaded 9 times
-
- SDC10046.part5.rar
- (8 MiB) Downloaded 9 times
-
- SDC10046.part4.rar
- (8 MiB) Downloaded 10 times
-
- SDC10046.part3.rar
- (8 MiB) Downloaded 10 times
-
- SDC10046.part2.rar
- (8 MiB) Downloaded 9 times
-
- SDC10046.part1.rar
- (8 MiB) Downloaded 12 times
Re: Can we have useful BASIC with no IF statements?
MartinB wrote:Joining in, this discussion occurs ad-infinitum in various forums but I don't think it has shown anything significant about our grammar apart from what dubious fun it can attract. Thus, no point to it in my opinion, it’s just wasting your brain. I’d say find a distraction that has worth and don’t worry about our grammatical quirks....
I miss all you mad individual’s, I did not watch this topic as I was on holiday with no ziggyzag puff cloud to my ipad. Just loads of palms with coconuts hanging as if by magic, monotony is burst only by a swim in cobalt H2O. Flying to and from my stopping off point by aircraft, with distraction of bomb arrows from DPRK (a trick with acronyms). Much food was absorb through an oral crack of my low cranium parts, lots of fish, Oryza sativa and worms from dough. Hot and humid I did allow much salty liquid to drain out from my many paws [sic]. Paws? Am I mayhap a dog or an animal that swims and lays around palms? For shadow from a star in my day sky? Sun is most hot, it can burn you to a crisp, but luckily suntan lotion will stop this from occurring. I am starting to go into random words to jump to a count of 180, I cannot go on, finish is nigh, just a paragraph to go, can I? Can I? A stanza? I will Alta Vista that but I don’t think so.
Re: Can we have useful BASIC with no IF statements?
Good work lminstur.... 

- FourthStone
- Posts: 479
- Joined: Thu Nov 17, 2016 2:29 am
- Location: Melbourne, Australia
- Contact:
Re: Can we have useful BASIC with no IF statements?
Com on guys, you'v b'n ignoring th original post'rs qu'stion about coding without IF's, I'v mangag'd to com up with at l'ast on 'xampl but i'm sur th'r's pl'nty mor? 

Re: Can we have useful BASIC with no IF statements?
Code: Select all
100 GOTO 130+20*(condition<>0)
110 PRINT "Condition-met clause"
120 GOTO 140
130 PRINT "ELSE clause"
140 PRINT "Continuing..."
(Not tested, but it ought to work, and is completely general.)