命名电影输出文件时出现奇怪的错误

Weird error in naming movie output file

我好像找不到错误原因。

工作代码:

print word "output" date-and-time
movie-start "output"

无效代码:

movie-start word "output" date-and-time

错误:

error (IllegalStateException)
 while observer running MOVIE-START
  called by procedure GO
  called by Button 'go'

NetLogo is unable to supply you with more details about this error.  Please report the problem
at https://github.com/NetLogo/NetLogo/issues, or to bugs@ccl.northwestern.edu, and paste the
contents of this window into your report.

java.lang.IllegalStateException: java.io.IOException: The filename, directory name or volume label syntax is incorrect
 at org.nlogo.workspace.DefaultFileManager.relativeToAbsolute(DefaultFileManager.java:126)
 at org.nlogo.workspace.DefaultFileManager.attachPrefix(DefaultFileManager.java:115)
 at org.nlogo.prim.gui._moviestart.perform(_moviestart.scala:15)
 at org.nlogo.nvm.Context.stepConcurrent(Context.java:91)
 at org.nlogo.nvm.ConcurrentJob.step(ConcurrentJob.java:82)
 at org.nlogo.job.JobThread.org$nlogo$job$JobThread$$runPrimaryJobs(JobThread.scala:143)
 at org.nlogo.job.JobThread$$anonfun$run.apply$mcV$sp(JobThread.scala:78)
 at org.nlogo.job.JobThread$$anonfun$run.apply(JobThread.scala:76)
 at org.nlogo.job.JobThread$$anonfun$run.apply(JobThread.scala:76)
 at scala.util.control.Exception$Catch.apply(Exception.scala:88)
 at org.nlogo.util.Exceptions$.handling(Exceptions.scala:41)
 at org.nlogo.job.JobThread.run(JobThread.scala:75)
Caused by: java.io.IOException: The filename, directory name or volume label syntax is incorrect
 at java.io.WinNTFileSystem.canonicalize0(Native Method)
 at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:396)
 at java.io.File.getCanonicalPath(File.java:559)
 at org.nlogo.workspace.DefaultFileManager.relativeToAbsolute(DefaultFileManager.java:123)
 ... 11 more

NetLogo 5.1.0
main: org.nlogo.app.AppFrame
thread: JobThread
Java HotSpot(TM) Server VM 1.6.0_45 (Sun Microsystems Inc.; 1.6.0_45-b06)
operating system: Windows 8 6.2 (x86 processor)
Scala version 2.9.2
JOGL: (3D View not initialized)
OpenGL Graphics: (3D View not initialized)
model: 70p

08:03:04.655 SwitchedTabsEvent (org.nlogo.app.Tabs) AWT-EventQueue-0
08:03:04.622 RuntimeErrorEvent (org.nlogo.app.App$$anon (org.nlogo.window.GUIWorkspace)) AWT-EventQueue-0
08:03:04.622 InterfaceGlobalEvent (org.nlogo.app.InterfacePanel (org.nlogo.window.SliderWidget)) AWT-EventQueue-0
08:03:04.622 InterfaceGlobalEvent (org.nlogo.app.InterfacePanel (org.nlogo.window.SliderWidget)) AWT-EventQueue-0
08:03:04.622 InterfaceGlobalEvent (org.nlogo.app.InterfacePanel (org.nlogo.window.SliderWidget)) AWT-EventQueue-0
08:03:04.622 InterfaceGlobalEvent (org.nlogo.app.InterfacePanel (org.nlogo.window.SliderWidget)) AWT-EventQueue-0
08:03:04.622 InterfaceGlobalEvent (org.nlogo.app.InterfacePanel (org.nlogo.window.SliderWidget)) AWT-EventQueue-0
08:03:04.622 InterfaceGlobalEvent (org.nlogo.app.InterfacePanel (org.nlogo.window.SliderWidget)) AWT-EventQueue-0
08:03:04.622 InterfaceGlobalEvent (org.nlogo.app.InterfacePanel (org.nlogo.window.SliderWidget)) AWT-EventQueue-0
08:03:04.622 InterfaceGlobalEvent (org.nlogo.app.InterfacePanel (org.nlogo.window.SliderWidget)) AWT-EventQueue-0

可能是错误

The filename, directory name, or volume label syntax is incorrect

是因为文件系统禁止在文件名中使用:这样的字符。代码中的文件名表达式:word "output" date-and-time 生成类似

的内容
output11:22:04.548 PM 14-feb-2015

根据user manual,格式是固定的,所以子串可以帮忙:

let dt date-and-time  
let fname ( word "output" substring dt 0 2 substring dt 3 5 substring dt 7 26) 
movie-start fname