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

Username:   Password: 
 RegisterRegister   
 Error message: Case selector is out of range.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
renaissance




PostPosted: Wed Jan 23, 2008 5:00 pm   Post subject: Error message: Case selector is out of range.

I'm getting this error from my code:

var ans1, data : string
var contactNum, menuNum, cont, stream, counter : int
contactNum := ContactCount + 1
var nums : string
var firstName, phoneNum, aptNum, lastName, address, city, province, country : array 1 .. contactNum of string
nums := "1234567890"

counter := 0

open : stream, "contacts.txt", get

if contactNum - 1 > 0 then

for i : 1 .. contactNum - 1

loop
exit when eof (stream)
get : stream, data : *

counter := counter + 1

case counter of
label 1 :
firstName (i) := data
label 2 :
lastName (i) := data
label 3 :
phoneNum (i) := data
label 4 :
address (i) := data
label 5 :
aptNum (i) := data
label 6 :
city (i) := data
label 7 :
province (i) := data
label 8 :
country (i) := data
label 9 :
end case

end loop
end for
end if

Help please? Thanks.
Sponsor
Sponsor
Sponsor
sponsor
Gooie




PostPosted: Wed Jan 23, 2008 5:43 pm   Post subject: Re: Error message: Case selector is out of range.

You didn't declare 'ContactCount'.
renaissance




PostPosted: Wed Jan 23, 2008 5:46 pm   Post subject: RE:Error message: Case selector is out of range.

Well...that wasn't all my code :p just a snippet. And I did...I simply went through another means to complete the task I wanted to though...

Now to figure something else out.
Gooie




PostPosted: Wed Jan 23, 2008 6:04 pm   Post subject: Re: Error message: Case selector is out of range.

It probably means it picked up data it didn't find a match to, in the case statement. Make a default, label :, then it should go away.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: