CodeBase - Generic File save as, save, and open commands--
Return to the CodeBase listing
Category: Complete Applications
Version: 1.1
Information
Uploaded: 20th Oct 2004 01:13
Modified: 1st Jan 1970 01:00
Author: Three Score
Summary
rem these fuinctions do basic file i/o rem use them as you please rem for the read_file you must ahve txt declared global rem made by free-space.myftp.org rem leave the last paremeter on both of them blank if you do not want silent and want them to choose a file function file_saveas(what$,name$) if name$="" ret: print "so what do you want to save this file as" input file$ if file exist(file$)=1 print "that file exist's already do you want to over write y/n" input temp$ if temp$="y" delete file file$ else goto ret endif endif print "saving file" open to write 1,file$ write string 1,what$ cls else if file exist(name$)=1 then delete file name$ print "saving file" if file exist(name$)=1 then delete file name$ open to write 1,name$ write string 1,what$ cls endif if file open(1)=1 then close file 1 print "done" endfunction function read_file(num,fname$) if fname$="" ret2: print "what file do you want to open" input flname$ if file exist(flname$)=0 print "file does not exist" goto ret2 endif open to read 2,flname$ for i=1 to num+1 read string 2,temp$ if i=num-1 then read string 2,txt$ next i else if file exist(fname$)=0 print "error file don't exist" print "please report this to the maker of this program" txt$="error the file was not found" exitfunction else open to read 2,fname$ for i=1 to num+1 read string 2,temp$ if i=num-1 then read string 2,txt$ next i endif endif if file open(2)=1 then close file 2 endfunction
Full Description
rem these fuinctions do basic file i/o<br /> rem use them as you please<br /> rem for the read_file you must ahve txt declared global<br /> rem made by free-space.myftp.org<br /> rem leave the last paremeter on both of them blank if you do not want silent and want them to choose a file<br /> <br /> <br /> <br /> <br /> <br /> <br /> function file_saveas(what$,name$)<br /> if name$=""<br /> ret:<br /> print "so what do you want to save this file as"<br /> input file$<br /> if file exist(file$)=1<br /> print "that file exist's already do you want to over write y/n"<br /> input temp$<br /> if temp$="y"<br /> delete file file$<br /> else<br /> goto ret<br /> endif<br /> endif<br /> print "saving file"<br /> open to write 1,file$<br /> write string 1,what$<br /> cls<br /> else<br /> if file exist(name$)=1 then delete file name$<br /> print "saving file"<br /> if file exist(name$)=1 then delete file name$<br /> open to write 1,name$<br /> write string 1,what$<br /> cls<br /> endif<br /> if file open(1)=1 then close file 1<br /> print "done"<br /> endfunction<br /> <br /> <br /> <br /> <br /> <br /> <br /> function read_file(num,fname$)<br /> if fname$=""<br /> ret2:<br /> print "what file do you want to open"<br /> input flname$<br /> if file exist(flname$)=0<br /> print "file does not exist"<br /> goto ret2<br /> endif<br /> open to read 2,flname$<br /> for i=1 to num+1<br /> read string 2,temp$<br /> if i=num-1 then read string 2,txt$<br /> next i<br /> else<br /> if file exist(fname$)=0<br /> print "error file don't exist"<br /> print "please report this to the maker of this program"<br /> txt$="error the file was not found"<br /> exitfunction<br /> else<br /> open to read 2,fname$<br /> for i=1 to num+1<br /> read string 2,temp$<br /> if i=num-1 then read string 2,txt$<br /> next i<br /> endif<br /> endif<br /> if file open(2)=1 then close file 2<br /> endfunction
Comments
No comments yet.