| |||||||
| Coding / Scripting / Programming Discussions on all manner of coding and scripting. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) | |
| I'm trying to get code working that will take a report, remove everything so that all of the words are seperated by the space delimeter, assign that big old long string to an array using the split command. Then I want to count the number of times a word exists in the array. I'm having issues with my counter, and all I can get the counter to do is count the total number of words, not how many times each word exists in the array. Thanks for any input/help | ||
| | | |
| | #3 (permalink) | |
| Build a second array; here's some pseudo code Dim SecondArray[x,2] //x is how many unique words you expect init SecondArray[x,1] = "" Init SecondArray[x,2] = 0 for i=1 to len(FirstArray) //FirstArray is where all the words are stored CurWord$ = FirstArray[i] CurDex = WhereInSecondArray(CurWord$) SecondArray[CurDex,2] = SecondArray[CurDex,2} + 1 next i function WhereInSecondArray(AWord$) as integer TheDex = 0 for i = 1 to len(SecondArray) if Aword$ = SecondArray[i,1] TheDex = i endif next i if TheDex = 0 then //You didnt find the word you have to add it to first null element for i = 1 to len(SecondArray) if SecondArray[i,1]="" then SecondArray[i,1] = AWord$ TheDex = i endif next endif //Adding a word return TheDex This is HUGELY inefficient, you could add some additional pointers and go much faster. It is however a start HTH -MF | ||
| | | |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Slashdot // Long-lived Super Heavy Element Created | Gizmo | Slashdot RSS | 0 | 28-December-06 06:00 AM |
| The Register // Boffins brew up new element | Gizmo | The Register RSS | 0 | 17-October-06 07:05 PM |
| Affiliate Review: SilverStone Element 400Watt PSU ST40EF | THRiLL KiLL | PC Apex Web News | 0 | 17-October-06 08:45 AM |
| Affiliate Review: SilverStone Element ST50EF-Plus 500W Power Supply | THRiLL KiLL | PC Apex Web News | 0 | 28-August-06 01:02 AM |
| Affiliate Review: SilverStone ELEMENT ST50EF 500w Power Supply | Twizted | PC Apex Web News | 0 | 20-July-06 03:09 AM |