Can we have useful BASIC with no IF statements?

discussion of beeb/electron applications, languages, utils and educational s/w
Commie_User
Posts: 916
Joined: Wed Jan 27, 2016 12:50 am

Can we have useful BASIC with no IF statements?

Postby Commie_User » Mon Aug 28, 2017 7:32 pm

... 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!


HPIM1902.JPG
Game for it??

Program below:

viewtopic.php?f=2&t=11512

User avatar
dhg2
Posts: 51
Joined: Tue Oct 25, 2016 7:37 pm

Re: Can we have useful BASIC with no IF statements?

Postby dhg2 » Tue Aug 29, 2017 12:20 pm

Could you post your program in plaintext? It's a bit hard to see what's on the screen in your photo.
Regards,
- Patrick

User avatar
tricky
Posts: 1918
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Can we have useful BASIC with no IF statements?

Postby tricky » Tue Aug 29, 2017 12:37 pm

Most of the test programs I write look like:

Code: Select all

10 P%=&xxxx
20{OPT 2
...
80}
90call &xxxx

Not many BASIC constructs there, but very useful :lol: even though that isn't what you meant.

Sorry (a bit anyway).

User avatar
1024MAK
Posts: 6791
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Can we have useful BASIC with no IF statements?

Postby 1024MAK » Tue Aug 29, 2017 1:00 pm

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
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
lurkio
Posts: 1290
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: Can we have useful BASIC with no IF statements?

Postby lurkio » Tue Aug 29, 2017 1:36 pm

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:

User avatar
Lardo Boffin
Posts: 671
Joined: Thu Aug 06, 2015 6:47 am

Re: Can we have useful BASIC with no IF statements?

Postby Lardo Boffin » Tue Aug 29, 2017 3:09 pm

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, matchbox co-proc, Viglen twin 40/80 5.25" discs, acorn cassette
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc, Acorn 6502 coproc

User avatar
Lardo Boffin
Posts: 671
Joined: Thu Aug 06, 2015 6:47 am

Re: Can we have useful BASIC with no IF statements?

Postby Lardo Boffin » Tue Aug 29, 2017 3:23 pm

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
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Retroclinic Datacentre + HDD, matchbox co-proc, Viglen twin 40/80 5.25" discs, acorn cassette
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc, Acorn 6502 coproc

User avatar
BigEd
Posts: 1495
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Can we have useful BASIC with no IF statements?

Postby BigEd » Tue Aug 29, 2017 3:51 pm

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?

User avatar
BigEd
Posts: 1495
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Can we have useful BASIC with no IF statements?

Postby BigEd » Tue Aug 29, 2017 3:52 pm

Lardo Boffin wrote:You could try something like the following...

Yes, you can do a surprising amount with just arithmetic.

User avatar
1024MAK
Posts: 6791
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Can we have useful BASIC with no IF statements?

Postby 1024MAK » Tue Aug 29, 2017 10:14 pm

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 :mrgreen:

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
1024MAK
Posts: 6791
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Can we have useful BASIC with no IF statements?

Postby 1024MAK » Tue Aug 29, 2017 10:17 pm

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?

=D>

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

Commie_User
Posts: 916
Joined: Wed Jan 27, 2016 12:50 am

Re: Can we have useful BASIC with no IF statements?

Postby Commie_User » Tue Aug 29, 2017 10:46 pm

Whoa, I pop to a funeral and now I've all this correspondence.




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.

User avatar
FourthStone
Posts: 400
Joined: Thu Nov 17, 2016 2:29 am
Location: Melbourne, Australia

Re: Can we have useful BASIC with no IF statements?

Postby FourthStone » Wed Aug 30, 2017 2:55 am

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

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

User avatar
BigEd
Posts: 1495
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Can we have useful BASIC with no IF statements?

Postby BigEd » Wed Aug 30, 2017 8:49 am

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.

User avatar
1024MAK
Posts: 6791
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Can we have useful BASIC with no IF statements?

Postby 1024MAK » Wed Aug 30, 2017 10:37 am

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...

:wink:


Well played! So good I didn't notice.

=D> =D> =D>
Can't believe I never noticed either. I was kinda wondering what that post was all about earlier :lol:

Brilliant 8)

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
MartinB
Posts: 4555
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Can we have useful BASIC with no IF statements?

Postby MartinB » Wed Aug 30, 2017 12:04 pm

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.... :roll:

User avatar
danielj
Posts: 5346
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester

Re: Can we have useful BASIC with no IF statements?

Postby danielj » Wed Aug 30, 2017 12:30 pm

Computationally or Linguistically speaking? :D

d.

User avatar
MartinB
Posts: 4555
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Can we have useful BASIC with no IF statements?

Postby MartinB » Wed Aug 30, 2017 1:10 pm

Ha! I win Daniel, speaking has an 'e' in it... \:D/

User avatar
1024MAK
Posts: 6791
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: Can we have useful BASIC with no IF statements?

Postby 1024MAK » Wed Aug 30, 2017 1:25 pm

:lol: :lol: :lol:

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
danielj
Posts: 5346
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester

Re: Can we have useful BASIC with no IF statements?

Postby danielj » Wed Aug 30, 2017 2:31 pm

*physiognomypalm*

d.

User avatar
MartinB
Posts: 4555
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Can we have useful BASIC with no IF statements?

Postby MartinB » Wed Aug 30, 2017 3:11 pm

Now that's just floccinaucinihilipilification....

User avatar
danielj
Posts: 5346
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester

Re: Can we have useful BASIC with no IF statements?

Postby danielj » Wed Aug 30, 2017 3:13 pm

I didn't say anything without worth :(

d.

Commie_User
Posts: 916
Joined: Wed Jan 27, 2016 12:50 am

Re: Can we have useful BASIC with no IF statements?

Postby Commie_User » Thu Aug 31, 2017 4:37 pm

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 5 times
SDC10045.part3.rar
(5 MiB) Downloaded 5 times
SDC10045.part2.rar
(5 MiB) Downloaded 5 times
SDC10045.part5.rar
(5 MiB) Downloaded 6 times
SDC10045.part1.rar
(5 MiB) Downloaded 7 times

Commie_User
Posts: 916
Joined: Wed Jan 27, 2016 12:50 am

Re: Can we have useful BASIC with no IF statements?

Postby Commie_User » Thu Aug 31, 2017 4:47 pm

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.)
Attachments
Disk_510_Untitled.zip
(1.14 KiB) Downloaded 6 times

User avatar
FourthStone
Posts: 400
Joined: Thu Nov 17, 2016 2:29 am
Location: Melbourne, Australia

Re: Can we have useful BASIC with no IF statements?

Postby FourthStone » Thu Aug 31, 2017 8:12 pm

I see my error, I saw a B that should of been an A... try this [-o<

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

Commie_User
Posts: 916
Joined: Wed Jan 27, 2016 12:50 am

Re: Can we have useful BASIC with no IF statements?

Postby Commie_User » Thu Aug 31, 2017 9:04 pm

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 10 times
Disk_510_Untitled.zip
(1.21 KiB) Downloaded 6 times
SDC10046.part7.rar
(5.71 MiB) Downloaded 6 times
SDC10046.part6.rar
(8 MiB) Downloaded 5 times
SDC10046.part5.rar
(8 MiB) Downloaded 5 times
SDC10046.part4.rar
(8 MiB) Downloaded 6 times
SDC10046.part3.rar
(8 MiB) Downloaded 6 times
SDC10046.part2.rar
(8 MiB) Downloaded 5 times
SDC10046.part1.rar
(8 MiB) Downloaded 8 times

User avatar
Elminster
Posts: 1632
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK

Re: Can we have useful BASIC with no IF statements?

Postby Elminster » Tue Sep 05, 2017 9:52 am

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.... :roll:


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.

User avatar
MartinB
Posts: 4555
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Can we have useful BASIC with no IF statements?

Postby MartinB » Tue Sep 05, 2017 12:55 pm

Good work lminstur.... =D>

User avatar
FourthStone
Posts: 400
Joined: Thu Nov 17, 2016 2:29 am
Location: Melbourne, Australia

Re: Can we have useful BASIC with no IF statements?

Postby FourthStone » Tue Sep 05, 2017 10:21 pm

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? :lol:

crj
Posts: 322
Joined: Thu May 02, 2013 4:58 pm

Re: Can we have useful BASIC with no IF statements?

Postby crj » Wed Sep 06, 2017 3:22 am

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.)


Return to “software: other”

Who is online

Users browsing this forum: No registered users and 4 guests