Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Do nesting level
Message
De
18/09/2001 00:47:36
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
 
 
À
17/09/2001 05:59:00
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00557186
Message ID:
00557645
Vues:
17
Hmm.. how if the list contains a set of strings, each string have length 1-4, which can be any combination of 1-9, A-Z?

such as A1, B2A, 10C, 3... etc.

is it still possible to use asort? I still cant think of a way to do it yet..

any idea?

Jimi

>
>lcStr='1, 2A, 3,2, 3A, 10,3B, 10A'
>lnVals = alines(arrVals,chrtran(lcStr,', ',chr(13)+''))
>
>for ix=1 to lnVals
>  arrVals[ix] = padl(int(val(arrVals[ix])),10)+ ;
>         max(chrtran(arrVals[ix],'0123456789',''),' ')
>endfor
>asort(arrVals)
>for ix=1 to lnVals
>  arrVals[ix] = ltrim(arrVals[ix])
>endfor
>disp memo like arrVals
>
Cetin
>
>>Yeah though it will be much work to rewrite the program, I think I better do it asap.. thanks for the suggestions
>>
>>Jimi
>>
>>>Hi!
>>>
>>>Yep.
>>>
>>>MyObjects(i,2) = padl(val(m.cObjValue),4,"0")+substr(m.cObjValue,len(val(m.cObjValue))+1)
>>>
>>>This will make them all like
>>>0001, 0002, 0002A, 0003, 0003A, 0003B, 0010, 0010A...etc.
>>>
>>>and in character comparison it will be "0002"<"0010".
>>>
>>>HTH.
>>>
>>>
>>>>hi Vlad,
>>>>
>>>>i didn't use the asort() because I'm sorting something like:
>>>>1, 2, 2A, 3, 3A, 3B, 10, 10A...etc.
>>>>
>>>>since 2A 3A are valid, I cannot use integer but strings, but at the same time 10 must be larger than 2 that for string comparsion foxpro would think 2 is larger... I dunno how to fix this so I used a custom sorting..
>>>>
>>>>any idea?
>>>>
>>>>Jimi
>>>>
>>>>>Hi!
>>>>>
>>>>>Any recursive function could be re-written to use a loop instead of recursive call.
>>>>>
>>>>>However, I'm wondered - WHY not use ASORT() function????????
>>>>>dimension MyObjects(nObjectsCount,2)
>>>>>for i=1 to nObjectsCount
>>>>> MyObjects(i,1) = ... && some object reference
>>>>> MyObjects(i,2) = ... && value used for comparison for sorting
>>>>>endfor
>>>>>
>>>>>ASORT(MyObjects,2)
>>>>>
>>>>>And thats all.
>>>>>This way should be MUCH more quick then just a custom sorting algorithm.
>>>>>
>>>>>HTH.
>>>>>
>>>>>Make array 2-dimensioned with 2 columns. One contains object reference. Another column contains value which you use for sorting. Then use ASORT(aArray,)
>>>>>
>>>>>>I have wrote a function to quick-sort' an array of objects, but when the array is a bit larger (~600), I receive an "Allowed DO nesting level exceeded." error message.
>>>>>>
>>>>>>I do not have any do-loop included in another do-loop, but maybe it still counted when a do-loop is included in my recursive function...
>>>>>>
>>>>>>Is it posible to remove this limitation, or must I rewrite my recursive function?
>>>>>>
>>>>>>Thanks,
>>>>>>Jimi
error(503): file structure failure, signature file corrupted.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform