Can someone please help me with the following problem with substr.
When I run
awk -f test.awk chess
where test.awk is the script
BEGIN { print "Ol=81=E1!" }
/ActFrom\[1\]/{
S1L =3D $0;#
sub(/ActFrom\[1\]=3D"/,"",S1L);
sub(/";/,"",S1L);
p=3DS1L+0;
}
/Boards\[1\]=3D/{m1=3D$0;
sub(/Boards\[1\]=3D"/,"",m1);
P1=3Dsubstr(m1,p,1);
}
END{print p;
print m1;
print P1;
}
and the chess is a file containing the follwoing lines
Boards[0]=3D"xxxxxxxxxqxxxpkppxxxxxpxPxxxQRxxxrxxxxxxxxxxxPxxxxxxxxPPxxxxxxK=
x
b";
Boards[1]=3D"xxxxxxxxxqxxxpxppxxxxxpkPxxxQRxxxrxxxxxxxxxxxPxxxxxxxxPPxxxxxxK=
x
w";
Boards[2]=3D"xxxxxxxxxqxxxpxppxxxxxpkPxxxQxxRxrxxxxxxxxxxxPxxxxxxxxPPxxxxxxK=
x
b";
Boards[3]=3D"xxxxxxxxxqxxxpxppxxxxxxkPxxxQxxpxrxxxxxxxxxxxPxxxxxxxxPPxxxxxxK=
x
w";
Boards[4]=3D"xxxxxxxxxqxxxpxppxxxxQxkPxxxxxxpxrxxxxxxxxxxxPxxxxxxxxPPxxxxxxK=
x
b";
ActFrom[0]=3D"14";
ActTo[0]=3D"23";
I expected the result
29
xxxxxxxxxqxxxpxppxxxxxpkPxxxQRxxxrxxxxxxxxxxxPxxxxxxxxPPxxxxxxKx w";
Q
since the character "Q" is in the 29th position at the string m1 but I
get
29
xxxxxxxxxqxxxpxppxxxxxpkPxxxQRxxxrxxxxxxxxxxxPxxxxxxxxPPxxxxxxKx w";
x
where the x is the first position in the string m1.
Can someone please point out my mistake?
Th****s in advance.
Gaspar


|