Including a Netlogo source file into another

北城余情 提交于 2019-11-30 20:18:57
Jose M Vidal

To include a file you use

__includes["libfile.nls"]

After adding this and pressing the “Check” button, a new button will appear next to the Procedures drop-down menu. There you can create and manage multiple source files.

The libfile.nls is just a text file that contains NetLogo code. It is not a netlogo model, which always end in .nlogo, as a NetLogo model contains a lot of other information besides the NetLogo code.

Including a file is the equivalent of just inserting all its contents at that point. In order to make it work in a way like reusable library files, one should create procedures which use agentsets and parameters as input variables to be independent of global definitions or interface settings.

The feature is documented in the NetLogo User Manual at http://ccl.northwestern.edu/netlogo/docs/programming.html#includes.

Hamid rar

You can create a file libfile.nls and in the same folder create your main model model.nlogo.

After that, go to your model.nlogo and write:

__includes["libfile.nls"]  

This file contains your reporters and procedures that you can call in your model.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!