foreach loop running but not giving results

送分小仙女□ 提交于 2019-12-07 19:32:33

It is important to note that local macros are precisely that, i.e. defined and visible only locally.

Locally means within

the same interactive session

or

the same program

or

the same do file (or do file editor contents)

or

the same part of the do file (or ...) executed by selection

Locality is, it seems, biting you here. A local macro defined in one place is not visible in another. A local macro reference will evaluate to missing, i.e. an empty string, if the macro is not visible.

Some code for the debugging. display the contents of your local datafiles to see what's going into the loop:

local datafiles : dir . files "*.txt"
display `"`datafiles'"'

local wordx : word 1 of `datafiles'
display `"`wordx'"'

foreach file in `datafiles' {
    display "`file'"
}

(The code does not format well in the comments section.)

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