problem using awk

Hi there every body
I'm new to shell scripting and there is a problem facing me,, please look at the following piece of code:

awk   ' 

BEGIN{

FS="<assertion id=\1";

RS="<assertion id=\"2"}/<assertion id=\"1/{print FS$2 > "/home/ds2/test/output.txt"}
' filename

all I wanna do is to replace the 1 found in FS with a variable that can be changed dynamically as follows:

var=1
awk  -v var1="$var" ' /var1/

BEGIN{

FS="<assertion id=\"var1";

RS="<assertion id=\"2"}/<assertion id=\"var1/{print FS$2 > "/home/ds2/test/output.txt"}
' filename

but it doesn't work so pls couldany one help me???

why do you want to replace variable inside FS mean ..(inside the program).. or purpose ?
could you explain little bit?

Thanks
Sha

all what I want to do is to cut a certain text which is found between FS and RS thats all,,,, so if any one have another way or idea please tell me,, thanks in advance

Please post a sample of your input data and an example of the expected output.

the text file contains the following :

<assertions>

<assertion id="1" tag="ref:XSH6TC2:4055:4058">

aio_fsync\(\) shall asynchronously force I/O operations associated
with aio_fildes.

</assertion>

<assertion id="2" tag="ref:XSH6TC2:4060:4061">

if op is O_DSYNC, all queued I/O operations shall be completed as if
by a call to fdatasync\(\).

</assertion>

<assertion id="3" tag="ref:XSH6TC2:4060:4061">

if op is O_SYNC, all queued I/O operations shall be completed as if
by a call to fsync\(\).

</assertion>

<assertion id="4" tag="ref:XSH6TC2:4070:4071">

aio_error\(\) and aio_return\(\) may be used in order to determine
the error status and return status of aio_fsync opertation.

</assertion>

<assertion id="5" tag="ref:XSH6TC2:4072:4073">

When the request is queued, error status is [EINPROGRESS].

</assertion>

and I need to take a part from it like that :

<assertion id="4" tag="ref:XSH6TC2:4070:4071">

aio_error\(\) and aio_return\(\) may be used in order to determine
the error status and return status of aio_fsync opertation.

</assertion>

but the I need id="4" to be a variable so that I can change it and cut the part I want,,,, thanks alot for ur help,,,

Try this:

awk '/<assertion id="4"/, /<\/assertion>/ {
  sub(/id="[^"]*"/, "id=\""nid"\"")
  print
  }' nid="$var" infile

awk '/<assertion id="4"/, /<\/assertion>/ {
sub(/id="[^"]*"/, "id=\""nid"\"")
print
}' nid="$var" infile