Q:

Setting multiple field to awk variables at once

I am trying to set an awk variable field to several field at once. 
Right now I can only set the variables one by one.
for line in `cat file.txt`;do
    var1=`echo $line | awk -F, '{print $1}'`
    var2=`echo $line | awk -F, '{print $2}'`
    var3=`echo $line | awk -F, '{print $3}'`

    #Some complex code....
done

I think this is costly cause it parses the linux variable several times. Is there a special syntax to set the variable at once? I know that awk has a BEGIN and END block but the reason I am trying to avoid the BEGIN and END block is to avoid nested awk. 
I plan to place another loop and awk code in the #Some complex code.... part.
for line in `cat file.txt`;do
    var1=`echo $line | awk -F, '{print $1}'`
    var2=`echo $line | awk -F, '{print $2}'`
    var3=`echo $line | awk -F, '{print $3}'`

    for line2 in `cat file_old.txt`;do
        vara=`echo $line2 | awk -F, '{print $1}'`
        varb=`echo $line2 | awk -F, '{print $2}'`

        # Do comparison of $var1,var2 and $vara,$varb , then do something with either
    done
done

A:

You can use the IFS internal field separator to use a comma (instead of whitespace) and do the assignments in a while loop:
SAVEIFS=$IFS;
IFS=',';
while read line; do
    set -- $line;
    var1=$1;
    var2=$2;
    var3=$3;
    ...
done < file.txt

IFS=$SAVEIFS;

This will save a copy of your current IFS, change it to a , character, and then iterate over each line in your file. The line set -- $line; will convert each word (separated by a comma) into a numeric-variable ($1, $2, etc.). You can either use these variables directly, or assign them to other (more meaningful) variable names.
Alternatively, you could use IFS with the answer provided by William:
IFS=',';
while read var1 var2 var3; do
    ...
done < file.txt

They are functionally identical and it just comes down to whether or not you want to explicitly set var1=$1 or have it defined in the while-loop's head.

A:

Why are you using awk at all?
while IFS=, read var1 var2 var3; do
  ...
done < file.txt

