Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need help parsing
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00429941
Message ID:
00430090
Views:
13
Ok, third reply to myself :)

>>>I have a table that contains 7 columns. The first 6 columns contain payroll deductions. The 7th column has information on types of deduction being held in the columns 1 thur 6. My problem is that I have to parse the information in 7th column. The order in which the names appear in 7th column determines which 1 thru 6 columns contain the deductions. For example:
>>>
>>>first record
>>>col1 = 68
>>>col2 = 35
>>>col3 = 45
>>>col4 = 0
>>>col5 = 0
>>>col6 = 0
>>>col7 = "HLTH01 CCAPE C INS" ---> need to be parse to hlth01, ccape, c ins
>>>
>>>so HLTH01 = 68, CCAPE = 35 and C INS = 45
>>>
>>>
>>>second record
>>>col1 = 50
>>>col2 = 60
>>>col3 = 70
>>>col4 = 80
>>>col5 = 0
>>>col6 = 0
>>>col7 = "HLTH01FLXD CCAPE UTWAY" ---> need to be parse to hlth01, flxd, ccape, utway
>>>
>>>so HLTH01 = 50, FLXD = 60, CCAPE = 70 and UTWAY = 80
>>>
>>>
>>>as you can see the names in col7 can run into each such as HLTH01 and FLXD. They can also contain spaces between name such as "C INS". How can I go about searching in the sting for a particular name and also determine what position those name are in reference to deduction columns 1 thur 6. I hope I haven't confused anyone. thanks
>>>
>>>Nick Patel
>>
>>Hi Nick,
>>
>>I think about one algorithm here, though I'm not sure, it's the best from optimization point of view (Ed Rauh definitely would suggest WSH algorithm :))
>>
>>Ok, these are the steps:
>>I've just written this off the top of my head, so you should tweak this code a little. But you will get the idea.
>>
>>Hope this helps.
>
>Nick,
>
>Here is another algorithm.

<snip>

Would not work, as I realized at the way home. I was so concentrated on this problem, that got out on the wrong stop :(

This is the corrected algorithm:
    select code from LookCode into array aCodes
    lnLen=_tally && Number of possible codes
    use yourtable
    lnSize=0
     for i=1 to lnLen         
         lnPos=atc(aCodes[i,1],col7)
         if lnPos>0 && This code is found in COL7
          lnSize=lnSize+1
          dimension laPosCodes[lnSize,2] && Redemension array
          laPosCodes[lnSize,1]=aCodes[i,1]
          laPosCodes[lnSize,2]= lnPos && Position in COL7
         endif 
     next
     =asort(laPosCodes,1,2) && Check help for asort, I'd like to sort by second index
   lnCol=0
   for i=1 to lnSize
       lnCol=lnCol1+1
       store evaluate('col'+transform(lnCol)) to &laPosCodes[i,1] && Note use of macro here
    next
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform