Objects Deduplicate In PowerBuilder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Long ll_row String ls_array[], ls_result //Get Array ls_array[1] = "AAAA" ls_array[2] = "AAAA" ls_array[3] = "BBBB" ls_array[4] = "BBBB" ls_array[5] = "BBBB" //Deduplicator n_cst_deduplicator ln_deduplicator ln_deduplicator = Create n_cst_deduplicator ln_deduplicator.of_dedupe_array( ls_array) Destroy ln_deduplicator //Get Result Array ls_result = "" For ll_row = 1 To UpperBound(ls_array) ls_result += ls_array[ll_row] + "~r~n" Next MessageBox("Infor", ls_result) |
Objects n_cst_deduplicator
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
Forward Global Type n_cst_deduplicator From datastore End Type End Forward Global Type n_cst_deduplicator From datastore End Type Global n_cst_deduplicator n_cst_deduplicator Type Variables Protected: String DW_SYNTAX_START String DW_SYNTAX_END = ' name=sorter dbname="sorter") )' End Variables Forward Prototypes Protected Function Long dedupe (Ref Any avalues[]) Public Function Long of_dedupe_array (Ref Integer arr[]) Public Function Long of_dedupe_array (Ref Long arr[]) Public Function Long of_dedupe_array (Ref String arr[]) Public Function Long of_dedupe_array (Ref Double arr[]) End Prototypes Protected Function Long dedupe (Ref Any avalues[]); //==================================================================== // Function: n_cst_deduplicator.dedupe() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // reference any avalues[] //-------------------------------------------------------------------- // Returns: long //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/26 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== If IsNull(avalues) Then Return 0 If UpperBound(avalues) < 2 Then Return 0 Long ll_dups String ls_type, ls_dsdef, ls_err Reset() Choose Case ClassName(avalues[1]) Case "long", "unsignedlong", "ulong", "int","integer", "uint","unsignedinteger","unsignedint", "double" ls_type = "number" Case "char", "character", "string" ls_type = "char(4000)" Case Else //excercise for the reader Return 0 End Choose ls_dsdef = DW_SYNTAX_START + ls_type + DW_SYNTAX_END If Create(ls_dsdef, ls_err) <> 1 Then Return -1 Object.sorter.Primary = avalues SetSort("sorter A") Sort() SetFilter("sorter <> sorter[-1] or GetRow () = 1" ) Filter() ll_dups = FilteredCount() If ll_dups > 0 Then avalues = Object.sorter.Primary End If Return ll_dups End Function Public Function Long of_dedupe_array (Ref Integer arr[]); //==================================================================== // Function: n_cst_deduplicator.of_dedupe_array() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // reference integer arr[] //-------------------------------------------------------------------- // Returns: long //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/26 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== If IsNull (arr) Then Return -1 Long ll_dups Any temp[] temp = arr ll_dups = dedupe(temp) If ll_dups > 0 Then arr = temp End If Return ll_dups End Function Public Function Long of_dedupe_array (Ref Long arr[]); //==================================================================== // Function: n_cst_deduplicator.of_dedupe_array() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // reference long arr[] //-------------------------------------------------------------------- // Returns: long //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/26 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== If IsNull (arr) Then Return -1 Long ll_dups Any temp[] temp = arr ll_dups = dedupe(temp) If ll_dups > 0 Then arr = temp End If Return ll_dups End Function Public Function Long of_dedupe_array (Ref String arr[]); //==================================================================== // Function: n_cst_deduplicator.of_dedupe_array() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // reference string arr[] //-------------------------------------------------------------------- // Returns: long //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/26 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== If IsNull (arr) Then Return -1 Long ll_dups Any temp[] temp = arr ll_dups = dedupe(temp) If ll_dups > 0 Then arr = temp End If Return ll_dups End Function Public Function Long of_dedupe_array (Ref Double arr[]); //==================================================================== // Function: n_cst_deduplicator.of_dedupe_array() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // reference double arr[] //-------------------------------------------------------------------- // Returns: long //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2020/11/26 //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== If IsNull (arr) Then Return -1 Long ll_dups Any temp[] temp = arr ll_dups = dedupe(temp) If ll_dups > 0 Then arr = temp End If Return ll_dups End Function On n_cst_deduplicator.Create Call Super::Create TriggerEvent( This, "constructor" ) End On On n_cst_deduplicator.Destroy TriggerEvent( This, "destructor" ) Call Super::Destroy End On Event Constructor; Environment le_env GetEnvironment(le_env) DW_SYNTAX_START = 'release ' + String(le_env.PBMajorRevision) + '; datawindow() table(column=(type=' End Event |
Find Projects On Github click here
Attachments Objects Deduplicate:
Good Luck!
Subscribe
Login
0 Comments
Oldest