如何在每次迭代时保存新文件

问题描述 投票:1回答:1

我想在宏代码中每次迭代创建一个新文件。

我试图在文件名中输入一个count变量,但它不会被解释为变量。

(define xStart -10 )
(define xFinish 10 )
(define xIncrement 8 )

(define yStart -10 )
(define yFinish 10 )
(define yIncrement 8 )
(define count 0 )

(do ( (xValue  xStart  (+ xValue  xIncrement ) ) )
    ( (> xValue  xFinish ) xValue )
  (do ( (yValue  yStart  (+ yValue  yIncrement ) ) )
      ( (> yValue  yFinish ) yValue ) 
    (+ count 1)
    (edit:move (entity:get-by-name "source") xValue yValue -50)
    (raytrace:all-sources)
    (edit:select (cadr (entity:faces (entity:get-by-name "Block 1"))))
    (analysis:irradiance)
    (analysis:irradiance-save "Z:/shadow/maps/.txt")
    (analysis:irradiance-close)
    (display: count)    
    )
  )
scheme
1个回答
2
投票

函数number->string将数字转换为字符串。函数string-append附加字符串。

(analysis:irradiance-save (string-append "Z:/shadow/maps/" 
                                         (number->string count) 
                                         ".txt"))

(+ count 1)什么也没做。您必须将count设置为新值。

(set! count (+ count 1))
© www.soinside.com 2019 - 2024. All rights reserved.