-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDFCompatibilityLayer.pkg
More file actions
87 lines (67 loc) · 2.46 KB
/
DFCompatibilityLayer.pkg
File metadata and controls
87 lines (67 loc) · 2.46 KB
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
// Created by ekstrom and published on github.com/ekstrom/DFCompatibilityLayer
// Version: 0.2
// License: MIT
Define DFCompatibilityLayer for 1
// Add functionality if DataFlex < 18.1
#IF (!@ < 181)
// Replacement for StringToUCharArray if you are using DataFlex < 18.1
Function StringToUCharArray Global String asText Returns UChar[]
Integer iLength
UChar[] ucArray
Address aDestination aSource
Boolean bOk
Move (Length(asText)) to iLength
Move (ResizeArray(ucArray, iLength)) to ucArray
Move (AddressOf(ucArray)) to aDestination
Move (AddressOf(asText)) to aSource
Move (MemCopy(aDestination, aSource, iLength)) to bOk
Function_Return ucArray
End_Function
Function UCharArrayToString Global UChar[] ucArray Integer iLengthOptional Integer iOffsetOptional Returns String
Integer i iLastChar iOffset
String sResult
If (num_arguments >= 2) Begin
Move (iLengthOptional - 1) to iLastChar
End
Else Begin
Move (SizeOfArray(ucArray) - 1) to iLastChar
End
If (num_arguments >= 3) Begin
Move iOffsetOptional to iOffset
End
Else Begin
Move 0 to iOffset
End
Move (iLastChar + iOffset) to iLastChar
If (iLastChar >= SizeOfArray(ucArray)) Begin
Move (SizeOfArray(ucArray) - 1) to iLastChar
End
For i from iOffset to iLastChar
If (ucArray[i] = 0 and i = iLastChar) Break
Move (sResult + Character(ucArray[i])) to sResult
Loop
Function_Return sResult
End_Function
#ENDIF
// Add functionality if DataFlex < 20.0
#IF (!@ < 200)
// PointerToString creates a new string based on what a pointer is pointing to
Function PointerToString Global Address asText Returns String
Function_Return asText
End_Function
// SizeOfString returns the number of bytes of a string in memory
Function SizeOfString Global String sOEM Returns Integer
Function_Return (Length(sOEM))
End_Function
// File_Exist_Compat checks if a file or folder exists for the native string encoding of the DataFlex version that you are running (where input is an OEM string)
#COMMAND File_Exist_Compat R R .
File_Exist (ToAnsi(!1)) !2
#ENDCOMMAND
#ENDIF
// Add functionality if DataFlex >= 20.0
#IF (!@ >= 200)
// File_Exist_Compat checks if a file or folder exists for the native string encoding of the DataFlex version that you are running (where input is an UTF-8 string)
#COMMAND File_Exist_Compat R R .
File_Exist !1 !2
#ENDCOMMAND
#ENDIF