nested case error

ke.han <>
Mon Jun 6 08:26:42 CEST 2005


Hello list,
I have tried many punctuation styles around this nested case code 
example, but can't get it to compile.
See line 15, where I have an end to the nested case and the last line 
where I end the outer case.  I apologize for email formating, its the 
best Thunderbird would do...
The compiler error on this code sample says I have an error before ';' 
on line 73 which is the end of the first clause of the outer case

setupSocket(State) ->
	case gen_tcp:recv(State#state.sock, 0, ?server_idle_timeout) of
	  {ok, Bin} ->
		[Two, One] = binary_to_list(Bin, 1, 2),
		Length = (Two * 256) + One,
		Version = [Major, Minor, Release] = binary_to_list(Bin, 3, 5),
		
		case binary_to_list(Bin, 6, 6) of
			[0] ->
				ClientType = type1;
			[1] ->
				ClientType = type2;
			[_Else] ->
				ClientType = unknown
		end, %% end of inner case
		[Four, Three, Two, One] = binary_to_list(Bin, 7, 10),
		SessionId = (Four * 16777216) + (Three * 65536)+ (Two * 256) + One,
		UserIdLength = binary_to_list(Bin, 11, 11),
		UserId = binary_to_list(Bin, 12, 12 + UserIdLength),
		PasswordLength = binary_to_list(Bin, 13 + UserIdLength, 13 + 
UserIdLength),
		Password = binary_to_list(Bin, 14 + UserIdLength, 14 + PasswordLength),
io:format("Length\tVersion\tClientType\tSessionId\tUserIdLength\tUserId\tPasswordLength\tPassword",[]),
		io:format("~p\t~p\t~p\t~p\t~p\t~p\t~p\t~p", [Length, Version, 
ClientType, SessionId, UserIdLength, UserId, PasswordLength, Password]; 
  %% ERROR here - end of outer case first clause
	  Else ->
		io:format(~p, [Else]) %% end of outer case second clause
	end. %% end of outer case


thanks ke han



More information about the erlang-questions mailing list