Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

informix - Trying to write to VIM from Genero using 4gl

I would like to open a .4gl file in VI terminal and write to it, this is the code I have currently:

 let p_command = "test -f ", MTGENDIR CLIPPED,"/",p_prog clipped,".4gl"
      run p_command returning p_status

      let p_command = "vi ",p_prog clipped,".4gl"
      --let p_command = "w ",p_prog clipped,".4gl"
      --let p_command = ":w ",p_prog clipped,".4gl"
      run p_command

This is the error I get in the debugger once it gets to the step vi and then it hangs:

(fgldb) next
376       let p_command = "vi ",p_prog clipped,".4gl"
(fgldb) next
377       run p_command
(fgldb) next
Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal

if i try writing with the commented code above (w or :w) it crashes and display this error:

The DVM process crashed. Please contact FourJs support.
DVM has encountered a problem. Execution of 'mt_gen' stopped

Is there any other way i can write to .4gl file in Genero?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To answer the very last sentence "Is there any other way I can write to .4gl file in Genero?" then you can use base.Channel class to write to a file ...

MAIN
    DEFINE ch base.Channel

    LET ch = base.Channel.create()
    CALL ch.openFile("example.4gl","w")
    CALL ch.writeLine("MAIN")
    CALL ch.writeLine("    DISPLAY 'Hello World'")
    CALL ch.writeLine("END MAIN")
    CALL ch.close()
END MAIN

... the key bit being the use of base.Channel.openFile and w (or a) as the opening mode http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ClassChannel_openFile.html

Alternatively you can build up the file inside a STRING or base.StringBuffer variable and use the TEXT writeFile method http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_datatypes_TEXT_writeFile.html ...

MAIN 
    DEFINE s STRING
    DEFINE t TEXT

   LET s = 
      "MAIN", ASCII(13),
      "    DISPLAY 'Hello World'", ASCII(13),
      "END MAIN"

   LOCATE t IN MEMORY
   LET t = s
   CALL t.writeFile("example2.4gl")
END MAIN

I'm not sure why you think you need vi/vim in your solution to write to a .4gl file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...