【问题标题】:How to split input by ASCII control codes with Progress 4GL?如何使用 Progress 4GL 通过 ASCII 控制码拆分输入?
【发布时间】:2012-03-30 13:18:01
【问题描述】:

如何使用 Progress 按组分隔符拆分此条形码?我试过 chr(29) 没有任何运气。

条码扫描到 Notepad++:http://i.imgur.com/8DmPZ.png

条形码扫描到输入字段:2409271405202120330017100282

谢谢。

def var c as char no-undo.
def var i as int no-undo.

update c format "x(50)".

do i = 1 to length(c):
    message substr(c, i, 1) = chr(29).
end.

【问题讨论】:

  • 你当前的代码是什么样的?

标签: barcode progress-4gl


【解决方案1】:

问题在于 GS 是一个未定义的控制代码。所以你需要让它被识别。

将以下内容添加到您终端在 protermcap 中的条目中,以将 GS 定义为 F13:

:(F13)=\035:\

(GS 的八进制代码是 \035 而 F13 是未定义的功能键 - 所以组合应该可以工作。我没有可以测试的扫描仪,但这适用于我可以输入到我的控制代码键盘...)

然后使用这样的代码:

define variable bc as character no-undo format "X(50)".

update bc editing:
  if lastkey = 313 then
    apply ".".  /* 313 is the code for F13 */
   else
    apply lastkey.
end.

这应该导致“。”代替GS插入。这将允许您使用“。”解析字符串。而不是 GS。

【讨论】:

    【解决方案2】:

    这是一个疯狂的猜测,但我在想 ENTRY(entry-num,barcode-string, "group-separator-string")?

    【讨论】:

      【解决方案3】:

      这对我有用:

      /* create a test file (otherwise not needed...)
       */
      
      output to "barcode.dat".
      put control "240927140520" chr(29) "2120330017" chr(29) "100282".
      output close.
      
      /* if you already have barcode.dat start here
       */
      
      define variable m  as memptr    no-undo.
      define variable bc as character no-undo.
      
      set-size( m ) = 100.
      input from "barcode.dat" binary no-convert.
      import unformatted m.
      input close.
      
      bc = get-string( m, 1 ).
      
      display
        entry( 1, bc, chr(29)) format "x(12)" skip
        entry( 2, bc, chr(29)) format "x(12)" skip
        entry( 3, bc, chr(29)) format "x(12)" skip
      .
      

      【讨论】:

      • 感谢您的回答,但不幸的是,这并不能满足我的需求。如果我从文件中读取条形码,它可以工作,但我需要从帧输入字段中读取它(我正在使用基于字符的应用程序)。 Progress 是否忽略了 ascii 控制代码?
      • 我在我的问题中添加了代码示例,在读取条形码时它不起作用。
      • 我将把这个答案留在这里,因为它适用于文件输入。现在我们知道您真正的问题是键盘输入,请参阅我的其他答案。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-10
      • 1970-01-01
      • 2018-03-14
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多