What you really need is a "here document". Basically, you are telling it to pass everything between a pair of tags into the command that is running. In your case, you would ...
Code:
ftp -i $1 <<EOF
use $2
$3
cd $4
mget *.txt
quit
EOF
Note that EOF can be anything that you want. I changed it a bit to better facilitate getting multiple files as well (ftp -i will not prompt you for a response because of the mget which you will want to use if you are getting all of the txt files in that directory).
To learn more about here documents, check out the Advanced Bash Scripting Guide at
The Linux Documentation Project.