BBC BASIC for Windows
« Syntax error??? »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:46pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Syntax error???  (Read 589 times)
coolguy
New Member
Image


member is offline

Avatar




PM


Posts: 7
xx Syntax error???
« Thread started on: Apr 4th, 2013, 1:05pm »

Hello all,

I have used the following code but am not sure where I have gone wrong, the error keeps coming up with Syntax error. My aim is to allow the user to try the program again if they don't choose from the dice given.

Code:

INPUT "Choose which dice to throw, 4, 6 or 12." Choice%
CASE Choice% OF
WHEN 4 PRINT "4 sided dice thrown, score "; Dice1
WHEN 6 PRINT "6 sided dice thrown, score ";Dice2
WHEN 12 PRINT "12 sided dice thrown, score ";Dice3
WHEN <> 4 OR 6 OR 12 PRINT "ERROR"
ENDCASE
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Syntax error???
« Reply #1 on: Apr 4th, 2013, 9:17pm »

on Apr 4th, 2013, 1:05pm, coolguy wrote:
I have used the following code but am not sure where I have gone wrong, the error keeps coming up with Syntax error.

You need to replace the last of your cases with an OTHERWISE clause:

Code:
        INPUT "Choose which dice to throw, 4, 6 or 12." Choice%
        CASE Choice% OF
          WHEN 4 PRINT "4 sided dice thrown, score "; Dice1
          WHEN 6 PRINT "6 sided dice thrown, score ";Dice2
          WHEN 12 PRINT "12 sided dice thrown, score ";Dice3
          OTHERWISE PRINT "ERROR"
        ENDCASE 

Richard.
User IP Logged

coolguy
New Member
Image


member is offline

Avatar




PM


Posts: 7
xx Re: Syntax error???
« Reply #2 on: Apr 5th, 2013, 10:13am »

Hi Richard

I was unaware of any such syntax, thank you for clearing it up, works perfectly well now. Thanks a lot.

Regards

User IP Logged

JGHarston
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 52
xx Re: Syntax error???
« Reply #3 on: May 13th, 2013, 9:36pm »

on Apr 4th, 2013, 1:05pm, coolguy wrote:
CASE Choice% OF
WHEN 4 PRINT "4 sided dice thrown, score "; Dice1
WHEN 6 PRINT "6 sided dice thrown, score "grinice2
WHEN 12 PRINT "12 sided dice thrown, score "grinice3
WHEN <> 4 OR 6 OR 12 PRINT "ERROR"
ENDCASE
The parameters to WHEN are a constant expression, just like any other constant expression. What happens if you do:
PRINT 4
PRINT 6
PRINT <> 4 OR 6 OR 12

Often the simplest way to start debugging a piece of code is to PRINT each of the parameters and see what happens.

on Apr 5th, 2013, 10:13am, coolguy wrote:
I was unaware of any such syntax, thank you for clearing it up, works perfectly well now. Thanks a lot.
Help -> Help topics -> CASE
« Last Edit: May 13th, 2013, 9:36pm by JGHarston » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls