Question:Text searching problem

Question:Text searching problem

Am trying to analyse a set of strings.   Can anyone help?

We have 10 x10 matrix into which we need to add connection score.
ExY := [WPKCPYWFYWCXHY, WPKCTEYFHCFEEE, HYCYTFHYYWWKCE, HYHHTFHKFEYHEH, HKXWYHFECTFFTF, HKWEHPPECWWHTC, HKXWYTPXHFHWYP, HKFEXCTFECXFKP, HKFEYPPEEEPHYW, HYTHCCFEWPPEXX, HKXKXCKFCHTEWK, HYEKPPCKFTWXXW];
Here is the code to create the connection matrix
A__c = A__a+A__d;
.
Blist:=[W,P,K,C,Y,F,X,H,T,E]:# basis letters
nWords:=numelems(ExY):Wletters:=length(ExY[1]):Bletters:=numelems(Blist):A:=Matrix(Bletters,Bletters):# set up dimensions
for iW from 1 to nWords do  # loop through words
for iL from 1 to Wletters-1 do # loop through letters of each word
fromLett:=C(iW,iL); # see char extraction from ExY list above
toLett:=C(iW,iL+1); # ditto
BfromLett:=Search(fromLett,Blist);# column id   <<<<<< the search is returning 0, it works if one uses "A" rather than say fromLett=A
BtoLett:=Search(toLett,Blist);# row id   <<<<<  ditto here
A(BfromLett,BtoLett):=A(BfromLett,BtoLett)+ 1; # add statistic to the A-matrix
end do; # end letter loop
end do; # end word loop
Error, index out of bounds
The search function is failing:
Blist; Wletters; Bletters; nWords; fromLett; toLett; BfromLett; BtoLett; A; iW; iL;
[W, P, K, C, Y, F, X, H, T, E]
14
10
12
"W"
"P"
0
0

[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]
[                            ]
[0  0  0  0  0  0  0  0  0  0]

﻿