2012-03-30 113 views
0

如何通過組分隔符將進度條分開?我嘗試過(29)沒有任何運氣。如何通過ASCII控制代碼與Progress 4GL分割輸入?

條碼掃描到記事本++: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. 
+0

你目前的代碼是什麼樣的? – 2012-03-30 13:48:33

回答

0

的問題是,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。

0

這是一個瘋狂的猜測,但我在想ENTRY(entry-num,barcode-string,「group-separator-string」)?

0

這個工作對我來說:

/* 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 
. 
+0

謝謝你的回答,但不幸的是這並不能滿足我的需求。它工作,如果我從文件讀取條碼,但我需要從幀輸入字段(即時通訊工作與基於字符的應用程序)讀取它。進度是否忽略了ascii控制代碼? – 2012-04-02 10:37:17

+0

我已經將代碼示例添加到了我的問題中,讀取條形碼時不起作用。 – 2012-04-03 06:36:01

+0

我會在這裏留下這個答案,因爲它適用於文件輸入。現在我們知道您真正的問題是鍵盤輸入,請參閱我的其他答案。 – 2012-04-03 14:52:37