Project

General

Profile

key_code_report.p

Igor Skornyakov, 06/08/2015 06:23 PM

Download (1.74 KB)

 
1
def var ikey  as int                    format ">>>>>9" label "Key Code".
2
def var st    as int  init 0.
3
def var en    as int  init 80.
4
def var redir as logical init true.
5
def var pg    as char.
6
def var out   as char init "./test.txt" format "x(65)".
7

    
8
message "Start Key?" update st.
9
message "End Key?"   update en.
10
message "Redirect?"  update redir.
11

    
12
if redir then
13
   do:
14
      message "Filename?"  update out.
15
      output to value(out) paged.
16
   end.
17

    
18
form "Key Code Mappings" with centered page-top frame head.
19
form pg with no-labels no-box centered page-bottom frame foot.
20

    
21
view frame head.
22
view frame foot.
23
def var lbl as char.
24
def var albl as char.
25
def var ch as int.
26
def var len as int.
27

    
28
repeat ikey = st to en:
29
     lbl = key-label(ikey).
30
     len = length(lbl).
31
     if len > 1 and index(lbl, "ESC-") > 0 and key-code(replace(lbl, "ESC-", "ALT-")) = ikey then do:
32
        albl = replace(lbl, "ESC-", "ALT-").
33
     end.
34
     else
35
        albl = "".
36

    
37
    if len > 1 and substring(lbl, len - 1, 1) = "-" then do:
38
      ch = asc(substring(lbl, len, 1)).
39
      if ch < 32 or 126 < ch then do:
40
        lbl = substring(lbl, 1, len - 1) + "chr(" + string(ch, ">>9") + ")".
41
        if albl <> "" then
42
          albl = substring(albl, 1, len - 1) + "chr(" + string(ch, ">>9") + ")".
43
      end.
44
    end.
45

    
46
    if len = 1 then do:
47
      ch = asc(lbl).
48
      if ch < 32 or 126 < ch then do:
49
        lbl = "chr(" + string(ch, ">>9") + ")".
50
      end.
51
    end.
52

    
53
    display ikey
54
             lbl format "x(30)" label "Key Label"
55
             albl format "x(30)" label "Alias key Label"
56
             key-function(ikey) format "x(30)" label "Key Function"
57
             with centered 20 down frame main.
58
     pg:screen-value = "Page " + string(page-number).
59
end.
60

    
61
if redir then
62
   output close.