2

ファイルに次の要素コードがあります。

IN: set-work-dir
USING: shell ;
CONSTANT: work-dir "/code" ! I also tried "c:/code" and "c:\\code"--same error
work-dir cd 

ファクターからスクリプトを実行しようとすると、次のエラーが発生します。

C:\>/usr/bin/factor/factor /usr/bin/factor/work/set-work-dir.factor
Generic word absolute-path does not define a method for the fixnum class.
Dispatching on object: 47
(U) Quotation: [ c-to-factor => ]
    Word: c-to-factor
(U) Quotation: [ [ (get-catchstack) push ] dip call => (get-catchstack) pop* ]
(O) Word: command-line-startup
(O) Word: run-script
(O) Word: set-current-directory
(O) Method: M\ object absolute-path
(O) Word: no-method
(O) Method: M\ object throw
(U) Quotation: [
        OBJ-CURRENT-THREAD special-object error-thread set-global
        current-continuation => error-continuation set-global
        [ original-error set-global ] [ rethrow ] bi
    ]

代わりにこれを実行できますUSING: shell ;USING: io.files.private、ディレクトリの変更はスクリプトの実行以外では保持されません。シェルを使用するとディレクトリの変更が持続すると思いますが、これは悪い仮定かもしれません。ディレクトリを変更するスクリプトを作成し、ディレクトリの変更をスクリプトの外に保持するにはどうすればよいですか?

Windows 7 (はい、Windows の dir セパレーターは通常\'\' も試しましたが、/実際には Windows でも動作します。パスは io.files.private を使用すると動作します)。

係数 0.98 x86.64 (1788、heads/master-e187d63d3c、Tue Oct 18 02:14:22 2016) [Microsoft Visual C++ 190023506] (Windows)

4

1 に答える 1