forked from Krowemoh/TCL-Utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ADD-DICT
113 lines (113 loc) · 2.62 KB
/
ADD-DICT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
*
GIT.FILENAME = 'ADD-DICT'
GIT.REPO = 'https://github.com/Krowemoh/TCL-Utilities.git'
*
* VERSION
*
VERSION = '1'
*
@USER1 = 'ADD-DICT'
@USER2 = 'ADD-DICT'
*
EQU TRUE TO 1
EQU FALSE TO 0
*
CALL GET.ARGUMENTS(ARGS)
*
ARGS.LEN = DCOUNT(ARGS,@AM)
*
IF ARGS.LEN = 1 THEN
PRINT 'ADD-DICT - Add a DICT entry to a file'
PRINT
PRINT ' ADD-DICT {FILE-NAME} {ATTR.#} {DICT.NAME}'
PRINT
STOP
*
END ELSE IF ARGS.LEN # 4 THEN
PRINT 'Invalid option'
STOP
END
*
FILE.NAME = ARGS<2>
ATTRIBUTE.NUMBER = ARGS<3>
ATTRIBUTE.NAME = ARGS<4>
*
DIM ATTRIBUTE.ITEM(10)
DIM NAME.ITEM(10)
*
MAT ATTRIBUTE.ITEM = ''
MAT NAME.ITEM = ''
*
OPEN '',FILE.NAME TO FILE ELSE
PRINT 'File does not exist: ' : FILE.NAME
STOP
END
*
OPEN 'DICT',FILE.NAME TO DICT.FILE ELSE
PRINT 'DICT does not exist: ' : FILE.NAME
STOP
END
*
MATREAD NAME.ITEM FROM DICT.FILE,ATTRIBUTE.NAME THEN
PRINT 'DICT entry already exists: ' : ATTRIBUTE.NAME
PRINT 'No changes made'
STOP
END
*
EQU DICT.TYPE TO 1
EQU DICT.FIELD TO 2
EQU DICT.DESCRIPTION TO 3
EQU DICT.CONVERSION TO 7
EQU DICT.CORRELATIVE TO 8
EQU DICT.JUSTIFICATION TO 9
EQU DICT.WIDTH TO 10
*
NAME.ITEM(DICT.TYPE) = 'A'
NAME.ITEM(DICT.FIELD) = ATTRIBUTE.NUMBER
NAME.ITEM(DICT.DESCRIPTION) = ATTRIBUTE.NAME
NAME.ITEM(4) = ''
NAME.ITEM(5) = ''
NAME.ITEM(6) = ''
NAME.ITEM(DICT.CONVERSION) = ''
NAME.ITEM(DICT.CORRELATIVE) = ''
NAME.ITEM(DICT.JUSTIFICATION) = 'L'
NAME.ITEM(DICT.WIDTH) = 25
*
ATTRIBUTE.ITEM(DICT.TYPE) = 'S'
ATTRIBUTE.ITEM(DICT.FIELD) = ATTRIBUTE.NUMBER
ATTRIBUTE.ITEM(DICT.DESCRIPTION) = ATTRIBUTE.NAME
ATTRIBUTE.ITEM(4) = ''
ATTRIBUTE.ITEM(5) = ''
ATTRIBUTE.ITEM(6) = ''
ATTRIBUTE.ITEM(DICT.CONVERSION) = ''
ATTRIBUTE.ITEM(DICT.CORRELATIVE) = ''
ATTRIBUTE.ITEM(DICT.JUSTIFICATION) = 'L'
ATTRIBUTE.ITEM(DICT.WIDTH) = 25
*
MATWRITE NAME.ITEM ON DICT.FILE,ATTRIBUTE.NAME
*
ATTRIBUTE.ON.FILE = FALSE
*
MATWRITE ATTRIBUTE.ITEM ON DICT.FILE,ATTRIBUTE.NUMBER
*
READ AT.ITEM FROM DICT.FILE,'@' THEN
ATTRIBUTES = AT.ITEM<2>
*
CONVERT ' ' TO @AM IN ATTRIBUTES
*
LOCATE(ATTRIBUTE.NUMBER,ATTRIBUTES;ATTR.POS) ELSE
AT.ITEM<2> = AT.ITEM<2> : ' ' : ATTRIBUTE.NUMBER
WRITE AT.ITEM ON DICT.FILE,'@'
END
*
END ELSE
AT.ITEM = ''
AT.ITEM<1> = 'PH'
AT.ITEM<2> = ATTRIBUTE.NUMBER
WRITE AT.ITEM ON DICT.FILE,'@'
END
*
* END OF PROGRAM
*
END
*