在文件中写入数据时出错

时间:2014-03-20 23:39:14

标签: file-io netlogo

我想在文件.txt中写入数据。问题是我通过使用以下代码获取下面的错误消息:

No file has been opened.
error while wolf 1 running FILE-PRINT

代码

to setup ## Initialization
let new-file-1 "E:/IBM/IBM_outputs/File1.txt"
file-open new-file-1 
write-locations-to-file 
end 

to go 
while [ not time:is-equal (current-date) (end-date) ] [ 
ask wolves [ .... ]
set current-date time:plus current-date 5.0 "minutes" 
write-locations-to-file ] 
end 

to write-locations-to-file
let hour time:show current-date "HH" 
let minute time:show current-date "mm" 
let hourMinute read-from-string hour + ( (read-from-string minute) / 60 ) 

if hourMinute mod 1 = 0 [ 
ask wolves [  
file-print (word who " ; " display-current-date " ; " xcor " ; " ycor " ; " color " ; " [pcolor] of patch-here "\r\n" ) 
] ]
end

非常感谢你的帮助。

0 个答案:

没有答案