I'm trying to find the best way to count occurrences of a string, which is telephone number, using two loops and a array. I'm wondering if using the example below can be improved upon. As you can guess, if raycnt is large can take some time. Raycnt is/was incremented before the looping starts earlier in the script following a FGETS.
string ddd1[10000]
for count1 = 0 upto raycnt
look4this = ddd1[count1]
for count2 = 0 upto raycnt
if strcmp look4this ddd1[count2]
index++
;termmsg " %4d %14s`r`n" count2 look4this
ddd1[count2] = ""
endif
endfor
if not nullstr look4this
termmsg "%15s %4d`r`n" look4this index
endif
index = 0
endfor
; Array ddd1[count1] will contain 5k numbers with several
; numbers repeating.
; 6625196074
; 6625196074
; 0115025156840
; 0115025158283
; 2703054201
; 2703054201
Thank you,
tknight
string ddd1[10000]
for count1 = 0 upto raycnt
look4this = ddd1[count1]
for count2 = 0 upto raycnt
if strcmp look4this ddd1[count2]
index++
;termmsg " %4d %14s`r`n" count2 look4this
ddd1[count2] = ""
endif
endfor
if not nullstr look4this
termmsg "%15s %4d`r`n" look4this index
endif
index = 0
endfor
; Array ddd1[count1] will contain 5k numbers with several
; numbers repeating.
; 6625196074
; 6625196074
; 0115025156840
; 0115025158283
; 2703054201
; 2703054201
Thank you,
tknight