修复错误:访问实例成员`GLib.FileStream.puts'被拒绝

时间:2015-12-26 22:02:35

标签: genie

我一直在尝试打开.html文件并在其中打印一些信息,但是有一个编译错误,我无法在线找到解决方案。也许我可以在SO找到一些指示。

代码如下:

def PrintOut(db: Database, which:string)
    var fi = FileStream.open("recipeprint.html", "w+")
    stmt:Statement = PreparedStatements.select_recipe( db, which )
    cols:int = stmt.column_count ()
    var row = new dict of string, string
    item:int = 1
    while stmt.step() == ROW
        for i:int = 0 to (cols - 1)
            row[ stmt.column_name( i ) ] = stmt.column_text( i )
        FileStream.puts( "<H1>%s</H1>", row[ "name" ])
        FileStream.puts( "<H2>Source: %s</H2>", row[ "source" ])
        FileStream.puts( "<H2>Servings: %s</H2>", row[ "servings" ])
        FileStream.puts( "<H3>Ingredient List: </H3>" )
        item++

我正在编译:

valac "%f" --pkg sdl --pkg sqlite3 --pkg gee-0.8

然而,我一直收到错误:

valac "cookbook.gs" --pkg sdl --pkg sqlite3 --pkg gee-0.8 (no diretório: /home/luis/Dropbox/Documentos/Coding/Genie Programming Language) cookbook.gs:37.9-37.54: error: Access to instance member `GLib.FileStream.puts' denied
        FileStream.puts( "<H1>%s</H1>", row[ "name" ])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cookbook.gs:38.9-38.64: error: Access to instance member `GLib.FileStream.puts' denied
        FileStream.puts( "<H2>Source: %s</H2>", row[ "source" ])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cookbook.gs:39.9-39.68: error: Access to instance member `GLib.FileStream.puts' denied
        FileStream.puts( "<H2>Servings: %s</H2>", row[ "servings" ])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

是否与我在系统中安装的gee版本有关?

1 个答案:

答案 0 :(得分:1)

我的语法错了。 Filestream是一个在变量fi中实例化的类。所以问题在于我应该写作:

var entry = "<li>"+row[ "ingredients" ]+"</li>"
fi.puts( entry )

与Gee版本无关。

帮助我了解问题的来源:here