-
Notifications
You must be signed in to change notification settings - Fork 3
/
CLIZER
194 lines (194 loc) · 4.29 KB
/
CLIZER
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
SUBROUTINE CLIZER(FILENAME,ARGS)
*
GIT.FILENAME = 'CLIZER'
GIT.REPO = 'https://github.com/Krowemoh/TCL-Utilities.git'
*
* VERSION
*
VERSION = '1'
*
@USER1 = 'CLIZER'
@USER2 = 'CLIZER'
*
EQU TRUE TO 1
EQU FALSE TO 0
*
EQU DICT.TYPE TO 1
EQU DICT.FIELD TO 2
EQU DICT.DESCRIPTION TO 3
EQU DICT.MV.RELATION TO 4
*
EQU DICT.CONVERSION TO 7
EQU DICT.CORRELATIVE TO 8
EQU DICT.JUSTIFICATION TO 9
EQU DICT.WIDTH TO 10
*
EQU DICT.SHORTHAND TO 15
EQU DICT.REQUIRED TO 16
EQU DICT.DEFAULT TO 17
*
CLEARSELECT
*
ARGS.LEN = DCOUNT(ARGS,@AM)
*
OPEN 'DICT',FILENAME TO DICT.FILE ELSE
PRINT 'Unable to open file: DICT ' : FILENAME
STOP
END
*
OPEN '',FILENAME TO FILE ELSE
PRINT 'Unable to open file: ' : FILENAME
STOP
END
*
GOSUB GET.ATTRIBUTES
*
IF ARGS.LEN = 1 THEN
PRINT 'FLAGS: '
*
FOR I = 1 TO NUMBER.OF.ATTRIBUTES
FLAG = ATTRIBUTE.LIST<1,I>
SHORTHAND = ATTRIBUTE.LIST<4,I>
*
IF SHORTHAND THEN
PRINT ' ' : SHORTHAND : ', --' : FLAG
*
END ELSE
PRINT ' --' : FLAG
END
NEXT I
*
RETURN
END
*
ITEM.ID = ''
ITEM.MATRIX = ''
*
LOCATE('--ID',ARGS;FLAG.POS) THEN
ITEM.ID = ARGS<FLAG.POS+1>
ARGS = DELETE(ARGS,FLAG.POS)
ARGS = DELETE(ARGS,FLAG.POS)
END
*
LOCATE('-ID',ARGS;FLAG.POS) THEN
ITEM.ID = ARGS<FLAG.POS+1>
ARGS = DELETE(ARGS,FLAG.POS)
ARGS = DELETE(ARGS,FLAG.POS)
END
*
IF ITEM.ID THEN
READ ITEM.MATRIX FROM FILE,ITEM.ID ELSE ITEM.MATRIX = ''
END
*
FOR I = 1 TO NUMBER.OF.ATTRIBUTES
A.NAME = ATTRIBUTE.LIST<1,I>
A.NUMBER = ATTRIBUTE.LIST<2,I>
A.CONV = ATTRIBUTE.LIST<3,I>
*
SHORTHAND = ATTRIBUTE.LIST<4,I>
REQUIRED = ATTRIBUTE.LIST<5,I>
DEFAULT = ATTRIBUTE.LIST<6,I>
*
IF DEFAULT = 'TODAY' AND A.CONV = 'D' THEN
DEFAULT = OCONV(DATE(),'D')
END
*
IF DEFAULT = 'NOW' AND A.CONV = 'MT' THEN
DEFAULT = OCONV(TIME(),'MT')
END
*
IF DEFAULT[1,1] = '@' THEN
LOCATE(DEFAULT[2,999],ATTRIBUTE.LIST,1;ANYPOS) THEN
DEFAULT = ITEM.MATRIX<ATTRIBUTE.LIST<2,ANYPOS>>
IF ATTRIBUTE.LIST<3,ANYPOS> THEN
DEFAULT = OCONV(DEFAULT,ATTRIBUTE.LIST<3,ANYPOS>)
END
END
END
*
FLAG = '--' : A.NAME
SHORT.FLAG = SHORTHAND
*
VALUE = ITEM.MATRIX<A.NUMBER>
IF VALUE # '' AND A.CONV THEN
VALUE = OCONV(VALUE,A.CONV)
END
*
LOCATE(FLAG,ARGS;FLAG.POS) THEN
VALUE = ARGS<FLAG.POS+1>
ARGS = DELETE(ARGS,FLAG.POS)
ARGS = DELETE(ARGS,FLAG.POS)
END
*
LOCATE(SHORT.FLAG,ARGS;FLAG.POS) THEN
VALUE = ARGS<FLAG.POS+1>
ARGS = DELETE(ARGS,FLAG.POS)
ARGS = DELETE(ARGS,FLAG.POS)
END
*
IF VALUE = '' AND DEFAULT # '' THEN
VALUE = DEFAULT
END
*
IF VALUE = '' AND REQUIRED = 'Y' THEN
PRINT FLAG : ' is required'
STOP
END
*
IF VALUE # '' AND A.CONV THEN
VALUE = ICONV(VALUE,A.CONV)
END
*
ITEM.MATRIX<A.NUMBER> = VALUE
NEXT I
*
IF ITEM.ID THEN
WRITE ITEM.MATRIX ON FILE,ITEM.ID
PRINT 'Updated ' : ITEM.ID : ' in ' : FILENAME
*
END ELSE
CALL GET.NEXT.ID(ITEM.ID,FILE)
*
WRITE ITEM.MATRIX ON FILE,ITEM.ID
PRINT 'Created ' : ITEM.ID : ' in ' : FILENAME
END
*
RETURN
*
********************* S U B R O U T I N E *********************
*
GET.ATTRIBUTES:NULL
*
EXECUTE 'SSELECT DICT ' : FILENAME : ' BY F2' CAPTURING RESULTS
*
ATTRIBUTE.LIST = ''
DONE = FALSE
CTR = 0
*
LOOP
READNEXT DICT.ID ELSE DONE = TRUE
*
UNTIL DONE DO
READ DICT.MATRIX FROM DICT.FILE,DICT.ID ELSE DICT.MATRIX = ''
*
IF TRIM(DICT.MATRIX<DICT.TYPE>) = 'A' AND DICT.MATRIX<DICT.FIELD> # '' THEN
CTR = CTR + 1
*
ATTRIBUTE.LIST<1,CTR> = DICT.ID
ATTRIBUTE.LIST<2,CTR> = DICT.MATRIX<DICT.FIELD>
ATTRIBUTE.LIST<3,CTR> = DICT.MATRIX<DICT.CONVERSION>
*
ATTRIBUTE.LIST<4,CTR> = DICT.MATRIX<DICT.SHORTHAND>
ATTRIBUTE.LIST<5,CTR> = DICT.MATRIX<DICT.REQUIRED>
ATTRIBUTE.LIST<6,CTR> = DICT.MATRIX<DICT.DEFAULT>
END
REPEAT
*
NUMBER.OF.ATTRIBUTES = DCOUNT(ATTRIBUTE.LIST<1>,@VM)
*
RETURN
*
* END OF PROGRAM
*
END
*