1: #ifdef TOTVS
2: #include "TOTVS.CH"
3: #else
4: #include "protheus.ch"
5: #endif
6:
7: /*
8: Programa : StronglyTypedVar.prg
9: Função : STypedVar
10: Autor : Marinaldo de Jesus [ http://www.blacktdn.com.br ]
11: Data : 29/07/2012
12: Uso : Strongly Typed Variables
13: */
14: User Function STypedVar()
15:
16: // declare your variables as strongly typed
17: LOCAL bError AS BLOCK VALUE {|e|MsgRun(e:Description,"Exception: "+IF(Empty(ProcName(3)),ProcName(2),ProcName(3)),{||Sleep(1000)})}
18: LOCAL bErrorBlock AS BLOCK
19:
20: LOCAL alcVar1 AS ARRAY VALUE Array(10)
21: LOCAL alcVar2 AS ARRAY
22:
23: LOCAL blcVar1 AS BLOCK VALUE { || .T. }
24: LOCAL blcVar2 AS BLOCK
25:
26: LOCAL clcVar1 AS CHARACTER VALUE "cVar1"
27: LOCAL clcVar2 AS CHARACTER
28:
29: LOCAL nlcVar1 AS NUMERIC VALUE 15
30: LOCAL nlcVar2 AS NUMERIC
31:
32: LOCAL dlcVar1 AS DATE VALUE Date()
33: LOCAL dlcVar2 AS DATE
34:
35: LOCAL llcVar1 AS LOGICAL VALUE .T.
36: LOCAL llcVar2 AS LOGICAL
37:
38: LOCAL olcVar1 AS OBJECT CLASS "FWFORMBROWSE" VALUE FWFORMBROWSE():New()
39: LOCAL olcVar2 AS OBJECT VALUE TFTPClient():New() //Generic Object
40:
41: STATIC astVar1 AS ARRAY VALUE Array(10)
42: STATIC astVar2 AS ARRAY
43:
44: STATIC bstVar1 AS BLOCK VALUE { || .T. }
45: STATIC bstVar2 AS BLOCK
46:
47: STATIC cstVar1 AS CHARACTER VALUE "cVar1"
48: STATIC cstVar2 AS CHARACTER
49:
50: STATIC nstVar1 AS NUMERIC VALUE 15
51: STATIC nstVar2 AS NUMERIC
52:
53: STATIC dstVar1 AS DATE VALUE Date()
54: STATIC dstVar2 AS DATE
55:
56: STATIC lstVar1 AS LOGICAL VALUE .T.
57: STATIC lstVar2 AS LOGICAL
58:
59: STATIC ostVar1 AS OBJECT CLASS "FWFORMBROWSE" VALUE FWFORMBROWSE():New()
60:
61: PRIVATE aptVar1 AS ARRAY VALUE Array(10)
62: PRIVATE aptVar2 AS ARRAY
63:
64: PRIVATE bptVar1 AS BLOCK VALUE { || .T. }
65: PRIVATE bptVar2 AS BLOCK
66:
67: PRIVATE cptVar1 AS CHARACTER VALUE "cVar1"
68: PRIVATE cptVar2 AS CHARACTER
69:
70: PRIVATE nptVar1 AS NUMERIC VALUE 15
71: PRIVATE nptVar2 AS NUMERIC
72:
73: PRIVATE dptVar1 AS DATE VALUE Date()
74: PRIVATE dptVar2 AS DATE
75:
76: PRIVATE lptVar1 AS LOGICAL VALUE .T.
77: PRIVATE lptVar2 AS LOGICAL
78:
79: PRIVATE optVar1 AS OBJECT CLASS "FWFORMBROWSE" VALUE FWFORMBROWSE():New()
80:
81: PUBLIC apbVar1 AS ARRAY VALUE Array(10)
82: PUBLIC apbVar2 AS ARRAY
83:
84: PUBLIC bpbVar1 AS BLOCK VALUE { || .T. }
85: PUBLIC bpbVar2 AS BLOCK
86:
87: PUBLIC cpbVar1 AS CHARACTER VALUE "cVar1"
88: PUBLIC cpbVar2 AS CHARACTER
89:
90: PUBLIC npbVar1 AS NUMERIC VALUE 15
91: PUBLIC npbVar2 AS NUMERIC
92:
93: PUBLIC dpbVar1 AS DATE VALUE Date()
94: PUBLIC dpbVar2 AS DATE
95:
96: PUBLIC lpbVar1 AS LOGICAL VALUE .T.
97: PUBLIC lpbVar2 AS LOGICAL
98:
99: PUBLIC opbVar1 AS OBJECT CLASS "FWFORMBROWSE" VALUE FWFORMBROWSE():New()
100:
101: //This command replaces the traditional := assignment
102: ASSIGN alcVar1 := Array(10)
103: ASSIGN blcVar1 := { || .T. }
104: ASSIGN clcVar1 := "ASSIGN cVar1"
105: ASSIGN nlcVar1 := 20
106: ASSIGN dlcVar1 := MsDate()
107: ASSIGN llcVar1 := .F.
108: ASSIGN olcVar1 := FWFORMBROWSE():New()
109:
110: ASSIGN astVar1 := Array(10)
111: ASSIGN bstVar1 := { || .T. }
112: ASSIGN cstVar1 := "ASSIGN cVar1"
113: ASSIGN nstVar1 := 20
114: ASSIGN dstVar1 := MsDate()
115: ASSIGN lstVar1 := .F.
116: ASSIGN ostVar1 := FWFORMBROWSE():New()
117:
118: ASSIGN aptVar1 := Array(10)
119: ASSIGN bptVar1 := { || .T. }
120: ASSIGN cptVar1 := "ASSIGN cVar1"
121: ASSIGN nptVar1 := 20
122: ASSIGN dptVar1 := MsDate()
123: ASSIGN lptVar1 := .F.
124: ASSIGN optVar1 := FWFORMBROWSE():New()
125:
126: ASSIGN apbVar1 := Array(10)
127: ASSIGN bpbVar1 := { || .T. }
128: ASSIGN cpbVar1 := "ASSIGN cVar1"
129: ASSIGN npbVar1 := 20
130: ASSIGN dpbVar1 := MsDate()
131: ASSIGN lpbVar1 := .F.
132: ASSIGN opbVar1 := FWFORMBROWSE():New()
133:
134: //Ao Tentar Atribuir uma valor diferente do que o esperado ocorrera uma Excecao
135:
136: ASSIGN bErrorBlock := ErrorBlock(bError)
137:
138: BEGIN SEQUENCE
139: ASSIGN alcVar1 := 1
140: END SEQUENCE
141:
142: BEGIN SEQUENCE
143: ASSIGN blcVar1 := .T.
144: END SEQUENCE
145:
146: BEGIN SEQUENCE
147: ASSIGN clcVar1 := 10
148: END SEQUENCE
149:
150: BEGIN SEQUENCE
151: ASSIGN nlcVar1 := "10"
152: END SEQUENCE
153:
154: BEGIN SEQUENCE
155: ASSIGN llcVar1 := 0
156: END SEQUENCE
157:
158: BEGIN SEQUENCE
159: ASSIGN olcVar1 := FWBROWSE():NEW() //Espera "FWFORMBROWSE"
160: END SEQUENCE
161:
162: BEGIN SEQUENCE
163: ASSIGN olcVar2 := TSocketClient():New()
164: END SEQUENCE
165:
166: ASSIGN bError := { |e| MsgInfo( e:Description , "Exception: " + ProcName(3) ) }
167:
168: ErrorBlock( bError )
169:
170: BEGIN SEQUENCE
171: ParamType()
172: END SEQUENCE
173:
174: ErrorBlock( bErrorBlock )
175:
176: Return( NIL )
177:
178: /*
179: Programa : StronglyTypedVar.prg
180: Função : ParamType
181: Autor : Marinaldo de Jesus [ http://www.blacktdn.com.br ]
182: Data : 29/07/2012
183: Uso : Strongly Typed Variables
184: */
185: Static Function ParamType(cVar,nVar,lVar,dVar,bVar,uVar,aVar,oVar1,oVar2)
186:
187: PARAMTYPE 1 VAR cVar AS CHARACTER OPTIONAL DEFAULT ""
188: PARAMTYPE 2 VAR nVar AS NUMERIC OPTIONAL DEFAULT 0
189: PARAMTYPE 3 VAR lVar AS LOGICAL OPTIONAL DEFAULT .T.
190: PARAMTYPE 4 VAR dVar AS DATE OPTIONAL DEFAULT Date()
191: PARAMTYPE 5 VAR bVar AS BLOCK OPTIONAL DEFAULT { || .F. }
192: PARAMTYPE 6 VAR uVar AS CHARACTER,NUMERIC OPTIONAL DEFAULT "0"
193: PARAMTYPE 7 VAR aVar AS ARRAY OPTIONAL DEFAULT Array(0)
194: PARAMTYPE 8 VAR oVar1 AS OBJECT CLASS "FWFORMBROWSE" OPTIONAL DEFAULT FWFORMBROWSE():New()
195: PARAMTYPE 9 VAR oVar2 AS OBJECT OPTIONAL DEFAULT TSocketClient():New()
196:
197: ASSIGN cVar := cVar
198: ASSIGN nVar := nVar
199: ASSIGN lVar := lVar
200: ASSIGN dVar := dVar
201: ASSIGN bVar := bVar
202: ASSIGN uVar := uVar
203: ASSIGN aVar := aVar
204: ASSIGN oVar1 := oVar2 //Espera "FWFORMBROWSE"
205: ASSIGN oVar2 := oVar1
206:
207: Return( NIL )
208:
209: #include "paramtypex.ch"
Comentários
Postar um comentário