The following statements display the contents of a text file in an Text component, replacing the line breaks in the text file with the HTML <BR> tag. The name of the file is typed into a Entryfield component named entryfield1, and the Text component is named text1.

f = new File( ) // Create File object

if f.exists( form.entryfield1.value ) // Make sure file exists

   f.open( form.entryfield1.value ) 

   form.text1.text = "" // Clear HTML component 

   do while not f.eof( ) 

      form.text1.text += f.gets( ) + "<BR>" // Write lines to HTML component 

   enddo 

   f.close( ) // Close file 

else

   form.text1.text = form.entryfield1.value + " not found" 

endif