Extrat data using AWK

How can I extract data using AWK
I have data as follow
01---------
02-----
03-----
03---
I want to extract data to the file 01.dat,02.dat and 03.dat
the field value should be the part of file name
OutFile="xx"
awk -F"|" '{OutFile = $1; print OutFile}' x1 > $OutFile
echo $OutFile

this won't work because the field is not passed to the KSH.

This is possible solutions of passing value to the awk script from within scripts,

#!/bin/ksh
awk -v VAL=$1 -F"|" '{ Out=VAL; print Out }' /tmp/in
  (or)
awk  -F"|" "{  Out=$1; print Out }" /tmp/in
~
cat /tmp/in
This
is
a
dummy file

Run the script

ksh awk.ksh 2
OUTPUT
2
2
2
2

Please let us know if this works.

Thanks
Nagarajan Ganesan.