我很困惑如何接受来自 Erlang shell 或 eclipse 控制台的输入?我想接受来自用户的变量“输入”的输入。
p1()->
io:format(" Codes for business logic of task one \n"),
spawn(xorgateway, xor_split, []).
xor_split()->
io:format("enter your decision \n").
case Value of
decision1 ->
spawn(xorgateway, p2, []);
decision2 ->
spawn(xorgateway, p3, []);
decision3 ->
spawn(xorgateway, p4, []);
_->
io:format("invalid input \n")end.
我很困惑如何接受来自 Erlang shell 的输入
-module(my).
-compile(export_all).
get_data() ->
{ok, Term} = io:read("Enter a number: "),
io:format("The number you entered plus one is: ~w~n",
[Term + 1]).
在外壳中:
8> c(my).
my.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,my}
9> my:get_data().
Enter a number: 10.
The number you entered plus one is: 11
ok
10>
请注意,用户需要在输入后输入一个句点。另请参阅io:getline()和io:fread()
我想接受变量“输入”的输入
input
不是 Erlang 中的变量。Erlang 变量以大写字母开头。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句