-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenericRefs.clw
98 lines (88 loc) · 3.44 KB
/
GenericRefs.clw
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
PROGRAM
MAP
END
ITEMIZE(1)
VariableType:String EQUATE
VariableType:Byte EQUATE
VariableType:Short EQUATE
VariableType:Long EQUATE
VariableType:Real EQUATE
VariableType:Date EQUATE
VariableType:Time EQUATE
END
VariableFactory CLASS,TYPE
Type BYTE
StringRef &STRING
ByteRef &BYTE
ShortRef &SHORT
LongRef &LONG
RealRef &REAL
DateRef &DATE
TimeRef &TIME
Construct PROCEDURE
Destruct PROCEDURE
Allocate PROCEDURE(BYTE Type,<LONG Length>),*?
Deallocate PROCEDURE
GetRef PROCEDURE,*?
END
Variable VariableFactory
WINDOW WINDOW('Caption'),AT(,,260,100),GRAY,SYSTEM
BUTTON('Button1'),AT(91,64),USE(?BUTTON1)
END
FEQ SIGNED
CODE
OPEN(Window)
FEQ = CREATE(0, CREATE:Entry)
SETPOSITION(FEQ, 10, 10, 80, 10)
FEQ{PROP:Use} = Variable.Allocate(VariableType:String, 20)
UNHIDE(FEQ)
ACCEPT
IF EVENT() = EVENT:Accepted
MESSAGE('Value is '& CLIP(CONTENTS(FEQ)))
END
END
VariableFactory.Construct PROCEDURE
CODE
VariableFactory.Destruct PROCEDURE
CODE
SELF.Deallocate
VariableFactory.Allocate PROCEDURE(BYTE Type,<LONG Length>)!,*?
NullRef &BYTE
CODE
SELF.Deallocate
SELF.Type = Type
CASE SELF.Type
;OF VariableType:String; SELF.StringRef &= NEW STRING(Length); RETURN SELF.StringRef
;OF VariableType:Byte ; SELF.ByteRef &= NEW BYTE ; RETURN SELF.ByteRef
;OF VariableType:Short ; SELF.ShortRef &= NEW SHORT ; RETURN SELF.ShortRef
;OF VariableType:Long ; SELF.LongRef &= NEW LONG ; RETURN SELF.LongRef
;OF VariableType:Real ; SELF.RealRef &= NEW REAL ; RETURN SELF.RealRef
;OF VariableType:Date ; SELF.DateRef &= NEW DATE ; RETURN SELF.DateRef
;OF VariableType:Time ; SELF.TimeRef &= NEW TIME ; RETURN SELF.TimeRef
;ELSE ; ; ;; ; ; ; RETURN NullRef
END
VariableFactory.Deallocate PROCEDURE
CODE
CASE SELF.Type
;OF VariableType:String; DISPOSE(SELF.StringRef)
;OF VariableType:Byte ; DISPOSE(SELF.ByteRef )
;OF VariableType:Short ; DISPOSE(SELF.ShortRef )
;OF VariableType:Long ; DISPOSE(SELF.LongRef )
;OF VariableType:Real ; DISPOSE(SELF.RealRef )
;OF VariableType:Date ; DISPOSE(SELF.DateRef )
;OF VariableType:Time ; DISPOSE(SELF.TimeRef )
END
SELF.Type = 0
VariableFactory.GetRef PROCEDURE!,*?
NullRef &BYTE
CODE
CASE SELF.Type
;OF VariableType:String; RETURN SELF.StringRef
;OF VariableType:Byte ; RETURN SELF.ByteRef
;OF VariableType:Short ; RETURN SELF.ShortRef
;OF VariableType:Long ; RETURN SELF.LongRef
;OF VariableType:Real ; RETURN SELF.RealRef
;OF VariableType:Date ; RETURN SELF.DateRef
;OF VariableType:Time ; RETURN SELF.TimeRef
;ELSE ; RETURN NullRef
END