assign value to variable using AWK

Dear Friends

I have text file as like below,

AAAAA|BHBHBH|VERYSMART
AAAAA| KKKKKK|GOOD
BBBBBB|JJJJJJJ|VERYGOOD
CCCCC|HJHJHJ|BETTER
CCCCC|UUUUU|GOOD

i need to split into seperate files based on column 1 like as below

AAAAA.TXT contains
--------------------
BHBHBH.VERYSMART
KKKKKK.GOOD

BBBBB.TXT contains
---------------------
JJJJJJJ.VERYGOOD

i want to use awk program to handle this,
I would always thankfull to u if give solution to this scenarios.

waiting for reply

Thanks ,
HAA

Hi

can i do this way

for h in `cat aa.txt`
do

filename=`echo $h|awk '{print $1}'`
v_filename=filename

if filename=v_filename then
echo filename|awk '{print $1"."$3}' > $v_filename.txt
else
create new file
fi
do

Regardfs,
HAA

nawk -f haa.awk myFile.txt

haa.awk:

BEGIN {
  FS="|"
  OFS=","

  ext=".TXT"
}

{
   out=$1 ext
   print $2 OFS $3 >> out
   close(out)
}

I resolved the problem using shell and awk,

Thanks for viewing this thread.

Regards,
HAA

would you mind posting your solution for the benifits of the others, pls!