Beginners Interactive NetLogo Dictionary (BIND)
Farsi / Persian
NetLogo Models Library:
Note: If you download the NetLogo application, every model in the Models Library is included.
This code example shows how to read in information from a file directly from NetLogo code.
In this example, we use the data to make a complicated patch maze.
load-patch-data will load in patch data from a file to a list, where
show-patch-data will display all the data that was loaded in the view. By default, there is only one file that is included that can be loaded in. It is called "File IO Patch Data.txt" and it is located in the code example's directory. You can use
load-own-patch-data to see how one would let the user decide which file to choose. The function
save-patch-data is in the procedures if you wish to see how the file "File IO Patch Data.txt" was created. For more information about file output, see File Output Example.
File input can be used to load in complicated information or to give the user the option to choose data. A good example is loading in patch information (such a maze in this case), or turtle information (such as coordinates). The difference between doing this and
import-world is that the user can customize the way the data is imported or exported -- you can save or load only the relevant data.
File Output Example