Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Case statement error (Variable has no value)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Chris974




PostPosted: Wed Jun 18, 2014 7:44 pm   Post subject: Case statement error (Variable has no value)

What is the problem you are having?
I keep getting Variable has no value. I get the error in the " case menu_choice of "


Describe what you have tried to solve this problem
I have tried changing the variables, but I still get Variable has no value.


Turing:


var PName : string
var SCups : int
var menu_choice : int

%Stanley cups won
SCups := 5

procedure start
    put "--------------------------------------------------------------------------------"
    put "                             NHL Team tracker                                 "
    put "      This program is made to track stats for the Pittsburg Penguins          "
    put "--------------------------------------------------------------------------------"
end start

procedure Choices
    put ""
    put "    What would you like to do?"
    put ""
    put "1.  Player info"
    put "2.  Stanley Cup"
    put "3.  Team hall of fame"
    put "4.  Quick info"
end Choices

procedure decision
    case menu_choice of
       label 1 :
            put ""
            put "   You can view: Crosby, Malkin, Letang or Fluery"
            put "   What player do you want to view?"
            get PName
        label 2 :
            put ""
        label 3 :
            put ""
        label 4 :
            put ""
        label :
            put "   This is not an option!"
    end case
   
end decision

start
Choices
decision




Please specify what version of Turing you are using
Turing 4.1
Sponsor
Sponsor
Sponsor
sponsor
Srlancelot39




PostPosted: Wed Jun 18, 2014 7:51 pm   Post subject: RE:Case statement error (Variable has no value)

Try initialising PName.

EDIT: I reread your code and realised that you try to use their choice without them ever entering one...that's mush more likely what your problem is.
EDIT2: I just read your edit...that confirms my previous edit Razz
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: