How to change the current working path of Erlang

Source: Internet
Author: User

The following example is mentioned in many of the basic Erlang tutorials on the web today:

-module (tut).
-export ([DOUBLE/1]).

Double (X)
2 * X.

Then compile the Tut.erl source file in the Erlang shell:

1> C (tut).

But for a beginner who has just touched Erlang, the following errors often occur:

./tut.erl:none:no such file or directory
Error

The prompt message tells the user that the Tut.erl file is not found, which makes it confusing to many beginners that the Tut.erl source file should be in the directory under which the Erlang compiler can find it. For Windows users, the working path of the Erlang shell launched by the user clicking on the Erlang icon is under the USR directory in the Erlang installation directory, where the Tut.erl or other user-authored Erlang source files are copied to the directory for direct C ( XXXX) command is compiled with XXXX as the module name, which is the source file name without the. erl extension.

If the user does not want to use the directory as the default working directory, you can right-click on the Erlang chart punctuation, select the pop-up menu item "Properties", and then modify the value of "start position" in the Erlang Properties dialog box with the original value "(Erlang installation path)/usr", Change to the working directory value you want.

You can query the current Erlang working directory by executing the following name:

2> pwd ().
E:/erl5.6.5/usr
Ok

Note that the directory name returned by PWD () is not the same as the standard Windows directory name, using the forward slash delimiter "/", and if you want to switch the current working directory in the Erlang shell, you can use the following command:

3> CD ("E:/mynewwork").
E:/mynewwork
Ok

Similarly, the working directory name in the CD (dir) command is also used as a forward slash delimiter "/" instead of using the Windows standard backslash delimiter "/", and if you use the Windows standard directory name, the CD (dir) command does not prompt for an error message when it executes. is not correctly switched to the new working directory.

If the user executes erl.exe directly into the Erlang Shell in command-line mode, the current directory is the working directory of Erlang, not affected by the "Start position" setting in the Erlang icon property, if the user wants to enter Erlang in any way When the shell is automatically switched to the specified working directory, you can edit an. erlang file in the user directory:

C:CD ("E:/mynewwork").
Io:format ("My new work in: ~p!n", [Element (2, FILE:GET_CWD ())]).

It is also important to note that the user directory is generally c:/documents and settings/(currently logged in user name), such as the current login to the Windows system with Heangel account, the user directory is c:/documents and Settings /heangel, the file under the Windows platform, can be understood as a file with only the extension has no file name, such a file in the Windows file Browser can be a general browse, delete operations, but unable to rename a normal file name to such a file, So it is generally necessary to use Notepad to edit the above code into an empty document, and then save the file, select the Save type is "All Files", the file name is ". Erlang" to save.

As an Erlang beginner, you can develop real Erlang learning by carefully reading the above and practicing the first step above.

How to change the current working path of Erlang

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.