Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

switch statement

 
Keith Warzak
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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).]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic