模块代码
%%%-------------------------------------------------------------------
%%% @author hasee
%%% @copyright (C) 2024, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 10. 6月 2024 15:57
%%%-------------------------------------------------------------------
-module(hello_World).
-author("hasee").
%% API
-export([hello_world/0,test/1]).
% 1
% 2
% 3
hello_world()->
io:format("Hello World!").
% 使用变量名都要大写
test(X)->
A = 3,
B = 4,
io:format("Hello World!"),
io:format("Value of A: ~p, Value of B: ~p~n Value of X: ~p~n", [A, B ,X]).
1.打开Werl.exe(在Erlang的bin文件夹下)
2. cd到你要编辑的模块文件的目录下,window下的 \ 要换成 /
如E:\idea Project\Erlang_Study\src 要变成 E:/idea Project/Erlang_Study/src
cd("E:/idea Project/Erlang_Study/src").
可以使用pwd().查看当前所在文件路径
3.使用c()函数编译模块,会在模块文件的目录下生成一个同名的beam文件
c("hello_World").
4.调用函数
模块名:函数名(参数列表)
hello_World:test(1).