【问题标题】:Trying to write to VIM from Genero using 4gl尝试使用 4gl 从 Genero 写入 VIM
【发布时间】:2021-01-07 08:13:06
【问题描述】:

我想在 VI 终端打开一个 .4gl 文件并写入,这是我目前的代码:

 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

这是我在调试器进入步骤 vi 时遇到的错误,然后它挂起:

(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

如果我尝试使用上面的注释代码(w 或 :w)编写它会崩溃并显示此错误:

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

还有其他方法可以在 Genero 中写入 .4gl 文件吗?

【问题讨论】:

  • 在程序中使用vim(或vi)很奇怪,特别是如果您想以编程方式控制编辑器的功能。就 I4GL 程序而言,“免提”运行它是一回事,用户可以通过正常的终端交互来做他们想做的事情,但是让程序告诉vim 该做什么显然是不平凡和非正统的.您可能不得不涉及管道、伪终端和其他深奥的功能,这意味着将 C 代码功能添加到您的 I4GL/Genero 程序中。您很可能应该重新考虑自己在做什么。
  • 这至少具有XY Problem 的一些特征。你能解释一下你希望达到的目标吗?在高层次上,不一定要描述如何使用vim 来实现它,不管“它”是什么。

标签: vim informix 4gl genero


【解决方案1】:

回答最后一句“我可以用其他方法在 Genero 中写入 .4gl 文件吗?”那么你可以使用 base.Channel 类来写入文件...

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

...关键位是使用base.Channel.openFile和w(或a)作为打开模式http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ClassChannel_openFile.html

或者,您可以在 STRING 或 base.StringBuffer 变量中构建文件并使用 TEXT writeFile 方法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

我不确定您为什么认为解决方案中需要 vi/vim 才能写入 .4gl 文件。

【讨论】:

  • 如果不是 s 或答案中的 writeLine 有办法我可以调用另一个函数
  • 我不明白你的问题,请改写
  • 在你的回答中你写过函数行或者让 s = 函数。为简单起见,我有一个报告功能,每行打印:function rpt() print 逐行打印。有没有办法让我调用这个函数?
  • 你为什么不使用 START REPORT report-name TO FILE "file.4gl" 呢?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-13
  • 1970-01-01
  • 1970-01-01
  • 2017-03-19
  • 1970-01-01
相关资源
最近更新 更多