Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Here's My Code: #==========

Status
Not open for further replies.

nochoice

Programmer
Jun 17, 2003
72
CA
Here's My Code:


#==========================
open(OUTF,"+>>submit.js");
flock(OUTF,2);
seek(OUTF,0,2);
close (OUTF);
#==========================


Note: As far as I'm aware, +>> allows me to open the file with read/write/append/create privileges.

Here is the structure of submit.js:


function foo_bar () {
document.writeln("Hello World!');
}


What I want, is to move my position from the very end of the file, to just before the } so I can add another document.writeln(""); before the }. How do I do this?
 
Sorry about the subject, I forgot to add one and got a little 'Submit Post' happy.
 
I think you're going to have to read the file in, and write out your first line, and then the contents of your file.

Normally I'd create a temp file, and spit the contents out to that, delete the original, and rewrite the file.

Why not just prepend &quot;\n&quot; to &quot;Hello world&quot;? Though for javascript output, that's only going to write a new line to your HTML source, not the actual page. You'd need to prepend <BR> to &quot;Hello World&quot; to get the desired results in your web page.

HTH
--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
I was thinking:

Is is possible to write a backspace character to the file?
 
nochoice,

(How it works for me)
Think of a file as what's on the disk, think of what you'd like to change, and make it so, however it works

--Paul

PS a backspace is still a characte ...

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top