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
| ** Dataset class to pack given cursors into an object to pass between data sessions
Define Class DataSet As Custom
TableCount = 0
DataSessionId = 0
Dimension TableInfo[1]
Procedure Init
This.DataSessionId = Set("Datasession")
Endproc
Procedure AddTable(tcAlias, tcAsAlias)
Local Array aStruc[1],aStripped[1]
LOCAL ix
Afields(aStruc,m.tcAlias)
Dimension aStripped[ALEN(aStruc,1),5]
For ix = 1 To Alen(aStruc,1)
aStripped[m.ix,1] = aStruc[m.ix,1]
aStripped[m.ix,2] = aStruc[m.ix,2]
aStripped[m.ix,3] = IIF(aStruc[m.ix,2]='V',MIN(aStruc[m.ix,3],254),aStruc[m.ix,3])
aStripped[m.ix,4] = aStruc[m.ix,4]
aStripped[m.ix,5] = aStruc[m.ix,5]
ENDFOR
This.TableCount = This.TableCount + 1
Dimension This.TableInfo[this.TableCount]
This.TableInfo[this.TableCount] = Createobject('Custom')
With This.TableInfo[this.TableCount]
.AddProperty('aStructure[1]')
.AddProperty('aRecords[1]')
.AddProperty('Records')
.AddProperty('Alias',m.tcAlias)
.AddProperty('AsAlias', Iif(Empty(m.tcAsAlias),m.tcAlias,m.tcAsAlias) )
Acopy(aStripped, .aStructure)
Select * From (m.tcAlias) Where !Deleted() Into Cursor __crsTemp__ nofilter
.RecordS = Reccount()
If .RecordS > 0
Dimension .aRecords[RECCOUNT()]
Scan
Scatter Name .aRecords[RECNO()] Memo
Endscan
Endif
Use In '__crsTemp__'
Endwith
Endproc
Procedure RestoreDataSet(tnDataSessionID,tlRestoreIfNotUsed) && restore all with saved aliases
Local lnCurrentSession,ix
lnCurrentSession = Set("Datasession")
For ix = 1 To This.TableCount
This.Obj2Cursor( This.TableInfo[m.ix].Alias, '', m.tnDataSessionID,m.tlRestoreIfNotUsed )
Endfor
Set DataSession To m.lnCurrentSession
Endproc
Procedure Obj2Cursor( tcStoredAlias, tcAlias, tnDataSessionID,tlRestoreIfNotUsed )
Local ix,jx
If !Empty(m.tnDataSessionID)
Set DataSession To m.tnDataSessionID
Endif
For ix = 1 To This.TableCount
With This.TableInfo[m.ix]
If Upper(.Alias) == Upper(m.tcStoredAlias)
tcAlias = Iif(Empty(m.tcAlias), .AsAlias, m.tcAlias )
If (m.tlRestoreIfNotUsed And Used(m.tcAlias))
Select (m.tcAlias)
Else
** Check array for any c(255)
Local lnArrElem
For lnArrElem=1 To Alen(.aStructure,1)
If .aStructure[m.lnArrElem,3] = 255 And .aStructure[m.lnArrElem,2]='C'
.aStructure[m.lnArrElem,3] = 254
Endif
Endfor
Create Cursor (m.tcAlias) From Array .aStructure
For jx = 1 To .RecordS
Append Blank
Gather Name .aRecords[m.jx] Memo
Endfor
EXIT
Endif
Endif
Endwith
Endfor
Set DataSession To This.DataSessionId
Endproc
Enddefine |