is it possible to pass external variable values to nawk?

Dear friends,
please tell me how to pass the external variable values to the nawk command.

length=`expr $len2 - $len1`

i need to pass $length to following nawk command as mentioned below.

nawk '{if((x=index($0,"W/X"))>0){id=substr($0,x, $length);print x;print id;}}' filename1

but I am getting follwing error,
nawk: illegal field $()
input record number 1, file filename1
source line number 1

please tell me how to pass the $length value to the nawk .

waiting for ur reeply....

swamymns

here is a simple example :

$ nawk '{ print lngth }' lngth="5" file1
5
5
5
5
5
5

you can assign the shell variable nawk variable and then use the nawk variable inside the nawk script.