• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

switch statement

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to read in from a text file with a readline buffer that reads in the first string. The first string is then used in the switch statement, allowing it to assign the following number of incoming lines from the text file to certain variables and then be printed to the command line. I believe my problem is that I am trying to passed a string value into my switch statement, but I think I need this same value in my "if" statement to determine if it is at the end of the file.
Here is my code:
----------------------------------------------------------------

added UBB CODE tags to preserve indentation
[This message has been edited by Frank Carver (edited March 26, 2001).]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a few problems with this. First is that you have put quotes around 'type' in the switch, so it is not referencing the string variable, but a constant char variable instead. If what you want is to switch on the first character of the line, then use the following:
switch(type.charAt(0))
insead of
switch('type')
If this is not what you want, then please explain further what behaviour you require.
 
Keith Warzak
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you
 
reply
    Bookmark Topic Watch Topic
  • New Topic