2015-12-26 21 views
0

我一直在試圖打開一個.html文件並在其中打印一些信息,但是有一個編譯錯誤,我找不到在線解決方案。也許我可以在這裏找到一些指針。修復錯誤:訪問實例成員`GLib.FileStream.puts'被拒絕

代碼如下:

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" ]) 
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

是它做的

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++ 

我與它編譯我在系統中安裝的gee版本?

回答

0

我的語法錯了。 Filestream是一個在變量fi中實例化的類。所以問題是我應該寫:

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

與Gee的版本沒有關係。

,幫助我理解了問題的根源:here