我想在模型的每个刻度处读取一个不同的文件,文件名取决于"当前刻度">
初始代码为:
to load-yield
reset-timer
ifelse ( file-exists? "AT_Yield.csv" )
[
set yield-data [[][][][][][]]
set yield-data csv:from-file "AT_Yield.csv"
user-message "File loading complete!"
print length yield-data
file-close
]
[ user-message "There is no AT_Yield.csv file in current directory!" ]
file-close-all
print timer
end
,我想要像下面这样的东西,year
是一个全局变量,最初在界面中设置,然后在每个刻度处更新set year year + 1
set yield-data csv:from-file "AT_Yield_" AND year AND ".csv"
我找不到关于如何创建某种"动态"的信息。文件名。
感谢您的宝贵时间。
多亏了LeirsW,这里是解决方案
to load-yield
set yield-file (word "AT_Yield_" year ".csv")
ifelse ( file-exists? yield-file )
[
set yield-data [[][][][][][]]
set yield-data csv:from-file yield-file
user-message "File loading complete!"
print length yield-data
file-close
]
[ user-message "There is no AT_Yield.csv file in current directory!" ]
file-close-all
end