Function to create record

Function to create record

is a function such as the following possible?   I can not seem to get it to work.  I am trying to create records in ANOTHER form based on every record in for 1.  IE for each record in form1 report, place a record in form2.

  1. void scripts.customFunction(fun)
  2. {
  3. for each <myvariable> in <form> 
  4.             {
  5.                   insert into <form>
  6.                   [
  7.             <field> = <expression>
  8.                   ]
  9.             }
  10. }