function FormCheck(){
  //list of commands that are not allowed to use

  var cmd = new Array();
  var icount = 173;
  cmd[0]='read(';
  cmd[1]='read.table(';
  cmd[2]='write(';
  cmd[3]='write.table(';
  cmd[4]='scan(';
  cmd[5]='.C(';
  cmd[6]='.Call(';
  cmd[7]='.Call.graphics(';
  cmd[8]='.External(';
  cmd[9]='.External.graphics(';
  cmd[10]='.Fortran(';
  cmd[11]='.readRDS(';
  cmd[12]='.saveRDS(';
  cmd[13]='.Script(';
  cmd[14]='.Tcl(';
  cmd[15]='.Tcl.args(';
  cmd[16]='.Tcl.callback(';
  cmd[17]='.Tk.ID(';
  cmd[18]='.Tk.newwin(';
  cmd[19]='.Tk.subwin(';
  cmd[20]='.Tkroot(';
  cmd[21]='.Tkwin(';
  cmd[22]='basename(';
  cmd[23]='browseURL(';
  cmd[24]='bzfile(';
  cmd[25]='capture.output(';
  cmd[26]='close(';
  cmd[27]='close.screen(';
cmd[28]='closeAllConnection(';
cmd[29]='data.entry(';
cmd[30]='data.restore(';
cmd[31]='dataentry(';
cmd[32]='de(';
cmd[33]='dev.control(';
cmd[34]='dev.copy2eps(';
cmd[35]='dev.cur(';
cmd[36]='dev.list(';
cmd[37]='dev.next(';
cmd[38]='dev.prev(';
cmd[39]='dev.print(';
cmd[40]='dev.set(';
cmd[41]='dev2bitmap(';
cmd[42]='dget(';
cmd[43]='dir(';
cmd[44]='dir.create(';
cmd[45]='dirname(';
cmd[46]='do.call(';
cmd[47]='download.file(';
cmd[48]='dput(';
cmd[49]='dump(';
cmd[50]='dyn.load(';
cmd[51]='edit(';
cmd[52]='edit.data.frame(';
cmd[53]='emacs(';
cmd[54]='erase.screen(';
cmd[55]='example(';
cmd[56]='fifo(';
cmd[57]='file(';
cmd[58]='file.access(';
cmd[59]='file.append(';
cmd[60]='file.choose(';
cmd[61]='file.copy(';
cmd[62]='file.create(';
cmd[63]='file.exists(';
cmd[64]='file.info(';
cmd[65]='file.path(';
cmd[66]='file.remove(';
cmd[67]='file.rename(';
cmd[68]='file.show(';
cmd[69]='file.symlink(';
cmd[70]='fix(';
cmd[71]='getConnection(';
cmd[72]='getwd(';
cmd[73]='graphics.off(';
cmd[74]='gzcon(';
cmd[75]='gzfile(';
cmd[76]='INSTALL(';
cmd[77]='install.packages(';
cmd[78]='jpeg(';
cmd[79]='library.dynam(';
cmd[80]='list.files(';
cmd[81]='loadhistory(';
cmd[82]='locator(';
cmd[83]='lookup.xport(';
cmd[84]='make.packages.html(';
cmd[85]='make.socket(';
cmd[86]='menu(';
cmd[87]='open(';
cmd[88]='parent.frame(';
cmd[89]='path.expand(';
cmd[90]='pdf(';
cmd[91]='pico(';
cmd[92]='pictex(';
cmd[93]='pipe(';
cmd[94]='png(';
cmd[95]='postscript(';
cmd[96]='print.socket(';
cmd[97]='prompt(';
cmd[98]='promptData(';
cmd[99]='quartz(';
cmd[100]='R.home(';
cmd[101]='R.version(';
cmd[102]='read.00Index(';
cmd[103]='read.dta(';
cmd[104]='read.epiinfo(';
cmd[105]='read.fwf(';
cmd[106]='read.mtp(';
cmd[107]='read.socket(';
cmd[108]='read.spss(';
cmd[109]='read.ssd(';
cmd[110]='read.xport(';
cmd[111]='readBin(';
cmd[112]='readline(';
cmd[113]='readLines(';
cmd[114]='remove.packages(';
cmd[115]='Rprof(';
cmd[116]='save(';
cmd[117]='savehistory(';
cmd[118]='scan(';
cmd[119]='screen(';
cmd[120]='seek(';
cmd[121]='setwd(';
cmd[122]='showConnection(';
cmd[123]='sink(';
cmd[124]='sink.number(';
cmd[125]='socketConnection(';
cmd[126]='source(';
cmd[127]='split.screen(';
cmd[128]='stderr(';
cmd[129]='stdin(';
cmd[130]='stdout(';
cmd[131]='sys.call(';
cmd[132]='sys.calls(';
cmd[133]='sys.frame(';
cmd[134]='sys.frames(';
cmd[135]='sys.function(';
cmd[136]='Sys.getenv(';
cmd[137]='Sys.getlocale(';
cmd[138]='Sys.info(';
cmd[139]='sys.nframe(';
cmd[140]='sys.on.exit(';
cmd[141]='sys.parent(';
cmd[142]='sys.parents(';
cmd[143]='Sys.putenv(';
cmd[144]='Sys.sleep(';
cmd[145]='Sys.source(';
cmd[146]='sys.source(';
cmd[147]='sys.status(';
cmd[148]='Sys.time(';
cmd[149]='system(';
cmd[150]='system.file(';
cmd[151]='tempfile(';
cmd[152]='textConnection(';
cmd[153]='tkpager(';
cmd[154]='tkStartGUI(';
cmd[155]='unlink(';
cmd[156]='unz(';
cmd[157]='update.packages(';
cmd[158]='url(';
cmd[159]='url.show(';
cmd[160]='vi(';
cmd[161]='write(';
cmd[162]='write.dta(';
cmd[163]='write.ftable(';
cmd[164]='write.socket(';
cmd[165]='write.table(';
cmd[166]='writeBin(';
cmd[167]='writeLines(';
cmd[168]='x11(';
cmd[169]='X11(';
cmd[170]='xedit(';
cmd[171]='xemacs(';
cmd[172]='xfig(';
cmd[173]='zip.file.extract(';
 
  
  var codes = document.phpr.rcodes.value;
  
  var illcmd = 0;
  var matchPos1 = -1;
  
  var msg = 0;
  var nocmd = 0;
  
  if (codes.length==0){
    msg = 1;
  }
  else{
	regExp = /\s+/g;
	codes = codes.replace(regExp,'');
    for (var i=0; i<=icount; i++){
      matchPos1 = codes.indexOf(cmd[i]);
      if (matchPos1!=-1){
         msg = 2;
		 nocmd = i+1;
         break;
       } 
    }
  }
  
  if (msg==1){
    alert("Input R codes first!");
    return false;
  }
  else if(msg==2){
    alert("Illegal commands used! \r\n Please see the help for a list of illegal commands.\r\n Problem involves "+nocmd+"th commands.");
    return false;
  }
  else{
     return true;
  }
  
  
}

