Documentation | MentDB Weak Server
Copy a text file to local (line by line)

  • script merge "" false 1 
      "Copy a text file" 
    	-> "[source]" "/Users/jimmitry/Desktop/test.txt";
    	-> "[destination]" "/Users/jimmitry/Desktop/copy.txt";
    	try {
    		#Open a reader;
    		file reader_open "r1" [source] TEXT "utf-8";
    		file writer_open "w1" [destination] false TEXT "utf-8";
    		#Parse the file;
    		while (is not null (-> "[line]" (file reader_get_line "r1"));) {
    			file writer_add_line "w1" (concat [line] [_n_]);
    		#Force to write;
    		file writer_flush "w1";
    		#Close the reader and the writer;
    		file reader_close "r1";
    		file writer_close "w1";
    	} {
    		#Close objects;
    		try {file reader_close "r1";} {} "[sub_err]";
    		try {file writer_close "w1";} {} "[sub_err]";
    		#Generate an error;
    		exception (1) ([err]);
    	} "[err]";
    ;} "Return 1";
Services     Supporters     Contact     About     Legal notice © 2024