Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!maverick.ksu.ksu.edu!ux1.cso.uiuc.edu!milo.mcs.anl.gov!achilles.ctd.anl.gov!curtis From: curtis@achilles.ctd.anl.gov (Jeffrey Curtis ) Newsgroups: comp.sys.apple2 Subject: Re: More BASIC programs Message-ID: <1991Jun27.121832.19554@mcs.anl.gov> Date: 27 Jun 91 12:18:32 GMT References: <1991Jun27.003549.3197@clark.edu> Sender: news@mcs.anl.gov Organization: Computing and Telecommunications, Argonne National Laboratory Lines: 35 Nntp-Posting-Host: achilles.ctd.anl.gov In article <1991Jun27.003549.3197@clark.edu> apollo@pro-hindugods.cts.com (System Administrator) writes: >Ok, now this problem. What I need to do is have my program remove the >present contents of a text file, which is only one line and contains very few >characters, then replace that line with a new string of charaters. Like this: > >10 REM Another BASIC problem >20 TS$ = "/hd.1/test" >30 PRINT D$"DELETE "TS$:REM That deletes the file just fine...now... >40 PRINT D$"OPEN "TS$:PRINT D$"APPEND "TS$:PRINT TEXT$:PRINT D$"CLOSE "TS$ > >What that gives me is a syntax error. I realise this much...there is no >longer a file "hd.1/test" after it is deleted and the program cannot open a >file that does not exist. So, my question...how do I recreate the file...or >better yet, how do I delete ONLY the first line of the file "test?" No, "OPEN" under both DOS 3.3 and ProDOS will create the file if it doesn't exist. What you might be having a problem with is the "APPEND" rather than "WRITE". Since you know the file is blank, there's no need to have an APPEND. Try it the other way. If that doesn't work, separate line 40 into all of its components on different lines and see where the error occurs. Actually, now that I look at it, if that's EXACTLY your program, the problem is that "TEXT" in an AppleSoft reserved word and can't be used in a variable situation. If you list the program, it will actually print out as 40 PRINT D$"OPEN "TS$ : PRINT D$"APPEND "TS$ : PRINT TEXT $ : PRINT D$.... which should tip you off to that fact. *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+* + Jeffrey S. Curtis (708)972-8585 B41801 AT ANLVM curtis@achilles.ctd.anl.gov + * Computing and Telecommunications, Argonne National Laboratory * + Want a free copy of Heatseeker, the Apple's fastest disk utility? Mail me! + *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*