%%% File : winerl1.erl %%% Author : Yeoh HS %%% Purpose : Simple console program for Erlang explorations. %%% Created : Sep 2008 -module(winerl1). -author('Yeoh HS'). -export([start/0]). %% %% Start of program %% start() -> io:format("Welcome to the world of Erlang!~n" , []), io:format("This Erlang program was built using Erlang 5.6.4~n" , []), io:nl(), get_main_option(). %% %% The program's main menu %% get_main_option() -> io:format("~nwinerl1 v0.0.1~n" ,[]), io:nl(), io:format("Main Menu:~n",[]), io:format("----------~n",[]), io:format("1) choice 1~n2) choice 2~n3) choice 3~n0) Exit~n",[]), io:nl(), {ok,[Option]} = io:fread("Choose (1,2 or 3, 0 to quit or h for help):","~s"), case string:to_upper(Option) of "1" -> do_choice_1(), get_main_option(); "2" -> do_choice_2(), get_main_option(); "3" -> do_choice_3(), get_main_option(); "0" -> say_goodbye(), get_main_option(); "H" -> display_help(), get_main_option(); _Else -> invalid_choice(), get_main_option() end. do_choice_1() -> io:format("Now procesing choice 1...",[]), timer:sleep(1000), io:format("Done!~n",[]). do_choice_2() -> io:format("Now processing choice 2...",[]), timer:sleep(1000), io:format("Done!~n",[]). do_choice_3() -> io:format("Now processing choice 3...",[]), timer:sleep(1000), io:format("Done!~n",[]). invalid_choice() -> io:format("Invalid choice! Please try again.~n",[]). say_goodbye() -> io:format("Bye!~n",[]), init:stop(). display_help() -> io:format("Help~n",[]), io:format("====~n",[]), io:format("This is the program's help text.~n",[]).