TEACH RENAME_OUTPUT Aaron Sloman Nov 2011 This file shows you how to rename your output.p file and start a new empty output.p file. CONTENTS - (Use g to access required sections) -- Why do this? -- Empty old output.p file without saving old one -- Saving your old output.p file and starting a new one -- -- Save the existing output.p file -- -- Ask bash to give the linux rename command 'mv' (move) -- -- Example using ENTER bash to give a linux command -- -- Get your saved output.p file renamed (using linux 'mv') -- -- [Optional] Check that your newly named file exists -- Working with a new output.p file -- Further reading -- Why do this? ------------------------------------------------------- It is often useful to have a new output.p file that does not contain junk from previous programming sessions, e.g. old error messages and test commands. So if you don't want to save the contents of the old output.p file you can simply delete the contents and save the empty file. If you want to save the old contents, e.g. for later revision you can get the output.p file on the hard drive renamed. Both options will now be described. -- Empty old output.p file without saving old one --------------------- You can always empty your old output file and start a new one if you wish, by doing this: 1. Read the existing output.p file into Ved ENTER ved output.p RETURN (From now on "RETURN" at the end of an ENTER command will be left implicit.) This will show you your previous output.p file (which may already be empty, in which case you have nothing to do). 2. If there is some text in the output.p file, empty the contents of the output.p file (after making sure your Ved cursor is in the output.p file, not a file you want to save): ENTER clear That empties the current file. Now save it: ENTER w1 That writes the empty file to the hard drive. So the file will be registered there, but will have nothing in it. If you would prefer to save your old output.p file before starting a new one, read on. -- Saving your old output.p file and starting a new one --------------- If you wish to save your old output file so that you can look back at what you did previously, choose a name for the file that will make it easy for you to remember what to look for later when you want to read it again. E.g. the name could be like one of these, or something else you prefer, but remember NOT TO USE A SPACE in a file name, as that will cause problems: oldoutput.p old_output.p output-23-jan-1965.p output_river.p MyOldOutput.p You can use the hyphen '-' or underscore '_' to join up bits of text into one file name. Both will work, though with Pop11 it is less likely to cause a problem later if you use the underscore rather than the hyphen. Or you can use the mixed case format illustrated above to shorten a long file name. -- -- Save the existing output.p file First make sure you are editing the old output.p file: ENTER ved output.p or, if it seems to read in the wrong output.p file try this to make sure you get the output.p that is in your current directory: ENTER ved ./output.p For most users that will not be needed. Make sure the file is saved to the hard drive ENTER w1 Then quit the file, which will take you back here, or to whatever file you were previously editing. -- -- Ask bash to give the linux rename command 'mv' (move) You can ask Ved to give a linux operating system command, which I'll call by using this format in Ved ENTER bash The 'bash' bit tells the editor to get the linux system to run the 'bash' shell, which is the program that (normally) interprets user commands to linux. -- -- Example using ENTER bash to give a linux command E.g. if you do ENTER bash who Ved will ask linux to run the 'who' command which will list the people currently logged in to your machine, e.g. something like this aaron pts/3 Oct 26 11:00 (xxx.yy.zz) .... and others .... That output from the operating system, produced by the 'who' command will be read into a temporary ved file and your editor cursor will be placed in it. If you are using XVed, then depending on your setup you may have to move the mouse cursor to the temporary file showing the output of 'who'. You can quit that temporary file using ENTER q to come back here. -- -- Get your saved output.p file renamed (using linux 'mv') This is easily done by giving a ved command something like this ENTER bash mv output.p MyOldOutput.p I.e. tell Ved to tell bash to run the 'mv ....' command. The 'mv' linux command "moves" the file with the first name, to a new "location" with a new name. (Remember no spaces in file names please.) If you mistype the first name you should get a message saying no such file or directory If the renaming is successful then the Ved command line will say, confusingly '(no output)'. All that means is that your command was obeyed without any message being printed out. [Note for expert programmers: The pop11 command sys_file_move can do that without invoking bash. See REF * SYSUTIL/sys_file_move] -- -- [Optional] Check that your newly named file exists If you want to check that your file exists with the new name you can try reading it into ved, by means of the normal 'ENTER ved ' command, and then 'ENTER q' to quit the file. ENTER ved MyOldOutPut.p You may wish to make some edits (e.g. write at the top when it was created) then write and quit the file: ENTER wq So now you have no output.p file left, but you have the new file. You can ask ved to ask bash to list all your files (for which the linux command is 'ls') in the current directory: ENTER bash ls That will list the files you created, any files that were put there before e.g. by your system administrator and also possibly some 'backup' files created by Ved, with '-' or '--' at the end, e.g. output.p- You can ignore the backup files for now. [For unix experts: all the 'ls' options can be used, e.g. ENTER bash ls -ltr will list lots of details of all files in reverse chronological order. ENTER bash ls -l *.p Will list all your files whose names end in '.p' ] -- Working with a new output.p file Now you can get back to work testing programs. If you do anyting that produces printout, such as running this command (ESC d) 'Starting an empty output.p file' ==> The printout will now create a new output.p file for you in Ved (but not yet on the hard drive) and insert the result of the pop11 command in the new file. You can then continue with whatever you were doing previously, and later save your new output.p file. It will, in any case, be saved at intervals. Or you can tell ved to take you back to a specific file, e.g. something like this: ENTER teach chat1 or ENTER mygrammar.p -- Further reading ---------------------------------------------------- TEACH * BUFFERS HELP * VED_AUTOSAVE --- $usepop/pop/teach/rename_output --- Copyright University of Birmingham 2011. All rights reserved.