Main Menu

AfxSort

Started by Richard Kelly, Today at 02:31:14 AM

Previous topic - Next topic

Richard Kelly

Does anybody know why the code below gives me a compile error 42 variable not declared Afx_ArrayDWString in AfxSortStringArray(arReportData,True) ?

#INCLUDE ONCE "AfxNova\AfxArrays.inc"
#INCLUDE ONCE "AfxNova\AfxSort.inc"

DIM sReportData       AS DWSTRING
DIM nStart            AS LONG
DIM arReportData(ANY) AS DWSTRING

   sReportData = ",South,Alabama,4784762,4803689,4822023,West,Alaska,714046,723860,731449,West,Arizona,6410810,6467315,6553255" _
               + ",South,Arkansas,2922750,2938582,2949131,West,California,37334410,37683933,38041430,West,Colorado,5048472,5116302,5187582" _
               + ",Northeast,Connecticut,3576616,3586717,3590347,South,Delaware,899824,908137,917092,South,Washington DC,604989,619020,632323" _
               + ",South,Florida,18845967,19082262,19317568,South,Georgia,9714748,9812460,9919945,West,Hawaii,1364274,1378129,1392313" _
               + ",West,Idaho,1570784,1583744,1595728,Midwest,Illinois,12840459,12859752,12875255,Midwest,Indiana,6489856,6516353,6537334" _
               + ",Midwest,Iowa,3050321,3064097,3074186,Midwest,Kansas,2858837,2870386,2885905,South,Kentucky,4346655,4366814,4380415" _
               + ",South,Louisiana,4544125,4574766,4601893,Northeast,Maine,1327585,1328544,1329192,South,Maryland,5787998,5839572,5884563" _
               + ",Northeast,Massachusetts,6563259,6607003,6646144,Midwest,Michigan,9877670,9876801,9883360,Midwest,Minnesota,5310737,5347299,5379139" _
               + ",South,Mississippi,2969137,2977457,2984926,Midwest,Missouri,5996092,6008984,6021988,West,Montana,990735,997667,1005141" _
               + ",Midwest,Nebraska,1829696,1842234,1855525,West,Nevada,2703758,2720028,2758931,Northeast,New Hampshire,1316843,1317807,1320718" _
               + ",Northeast,New Jersey,8803388,8834773,8864590,West,New Mexico,2064767,2078674,2085538,Northeast,New York,19399242,19501616,19570261" _
               + ",South,North Carolina,9559048,9651103,9752073,Midwest,North Dakota,674363,684740,699628,Midwest,Ohio,11538290,11541007,11544225" _
               + ",South,Oklahoma,3759482,3784163,3814820,West,Oregon,3838212,3868229,3899353,Northeast,Pennsylvania,12711308,12743948,12763536" _
               + ",Caribbean,Puerto Rico,3721208,3694093,3667084,Northeast,Rhode Island,1052769,1050646,1050292,South,South Carolina,4635835,4673348,4723723" _
               + ",Midwest,South Dakota,816223,823593,833354,South,Tennessee,6356673,6399787,6456243,South,Texas,25242683,25631778,26059203" _
               + ",West,Utah,2775093,2814347,2855287,Northeast,Vermont,625916,626592,626011,South,Virginia,8025105,8104384,8185867" _
               + ",West,Washington,6743636,6823267,6897012,South,West Virginia,1854019,1854908,1855413,Midwest,Wisconsin,5689591,5709843,5726398" _
               + ",West,Wyoming,564367,567356,576412,"
               
   nStart = 1
   WHILE nStart < LEN(sReportData)
      sString = AfxStrExtract(nStart,sReportData,",",",")
      AppendElementToArray(arReportData,sString)
      nStart = nStart + LEN(sString) + 1
   WEND               

   AfxSortStringArray(arReportData,True)

José Roca

#1
Apparently, a problem of using a namespace in the SUBs called by the macros. I have uploaded modified AfxArrays,inc and AfxSort.inc" files.

Also do not forget to add

#define _WIN32_WINNT &h0602

before including these files.

Richard Kelly

Thank you Jose for your speedy resolution. I downloaded AfxNova and replaced those two in the Tiko toolchain. I only had to regroup my string parsing to put things in their groups of 5 and the sort works.

DIM bAscending        AS BOOLEAN = True


   nStart = 1
   WHILE nStart < LEN(sReportData)
      sRowSort = ","
      sString = AfxStrExtract(nStart,sReportData,",",",")
      sRowSort = sRowSort + sString + ","
      nStart = nStart + LEN(sString) + 1
      sString = AfxStrExtract(nStart,sReportData,",",",")
      sRowSort = sRowSort + sString + ","
      nStart = nStart + LEN(sString) + 1
      sString = AfxStrExtract(nStart,sReportData,",",",")
      sRowSort = sRowSort + sString + ","
      nStart = nStart + LEN(sString) + 1
      sString = AfxStrExtract(nStart,sReportData,",",",")
      sRowSort = sRowSort + sString + ","
      nStart = nStart + LEN(sString) + 1
      sString = AfxStrExtract(nStart,sReportData,",",",")
      sRowSort = sRowSort + sString + ","
      nStart = nStart + LEN(sString) + 1                         
      AppendElementToArray(arReportData,sRowSort)
   WEND

AfxSortStringArray(arReportData,bAscending)