如何使用Scheme附加到文件? [英] How to append to a file using Scheme?
本文介绍了如何使用Scheme附加到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 TinyScheme(实际上是 GIMP 中的 Script-Fu),但找不到打开文件并向其附加一行文本的好方法.
I am using TinyScheme (actually Script-Fu in GIMP), and cannot find a good way to open a file and append a line of text to it.
我正在尝试将一些信息记录到文件中以进行调试,但似乎没有实现转录...
I am trying to log some info to the file for debugging, and transcript-on doesn't seem to be implemented...
现在我正在阅读整个文件(一次一个字符!),将其连接成一个字符串,将我的文本连接到它的末尾,然后再次将其全部写入文件.
Right now I am scraping along by reading the entire file (one character at a time!), concatenating that into a string, concatenating my text to the end of that, then writing it all out to the file again.
一定有更好的方法!
推荐答案
它会是这样的
(open-file "myfile" (file-options append))
您要查找 file-options
函数.
这是guile 版本:
(open-file "myfilename.dat" "a")
这篇关于如何使用Scheme附加到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文