( Latest Revision: Mon Apr 1 19:22 PDT 2013 ) edit instructions

Edit Instructions


Here are instructions on how to transform the ascii figure of the rose into C++ code for drawing the rose on the screen.

Make a copy of the MakeOneRose() function shell in a separate file

Start up a jove session to edit that file.

Paste a copy of the rose into the function body so it looks like this:

void MakeOneRose()
{
       /* code for function MakeOneJacko goes in here,
          between the braces. */

		   _
		_.;_'-._
	       {`--.-'_,}
	      {; \,__.-'/}
	      {.'-`._;-';
	       `'--._.-'
		  .-\\,-"-.
		  `- \( '-. \
		      \;---,/
		  .-""-;\
		 /  .-' )\
		 \,---'` \\
		 jgs	  \|

}
Move the cursor to where it is positioned above the rose figure.

Do the following jove command

esc r

(That means tap the escape key and then tap the r-key. You will see this prompt at the bottom of the terminal window:

: replace-string

Type this: \\

(This tells jove that you want to replace each backslash with something. You have to type two backslashes above because the backslash is the escape character for jove)

Then press the enter or return key. Now you will see this at the bottom of the screen:

: replace-string \\ with Type this: \\\\

(This means you want to replace each backslash with two backslashes. Since jove uses the backslash as an escape character, you have to type four of them when you mean two.)

The command line will now look like this:

: replace-string \\ with \\\\

Press enter again. The editor will replace each backslash in the figure with two backslashes.

Now move the cursor back so it is above the rose again and use the esc r command a second time to place a backslash character before each double-quote character.

Your final command line at the bottom of the screen for this esc r command will look like this:

: replace-string " with \\"

Once you have executed that command, you can finish off the transformation by putting

cout << "

at the start of each line of the figure, and placing

\n" ;

at the end of each line of the figure. Now it's code that draws the figure!!

You can create a macro in jove to place the

cout << "

at the start of each line, and the

\n" ;

at the end of each line.

You would move the cursor to the beginning of the first line of the ascii figure sequence, then type

ctrl-x (

Now you are defining your macro. You then type

cout << "

then you use the ctrl-e command to move to the end of the line, then type

\n" ;

then use ctrl-a followed by ctrl-n to move to the beginning of the next line. After that, type

ctrl-x )

to stop recording the macro. Now, after making sure that the cursor is at the beginning of a line of text that you want to change into a cout statement, if you type

ctrl-x e

then the macro will execute and transform the line. If you want to transform several lines at a time, you can do a command of the form

esc n ctrl-x e

This will execute the macro n times, and therefore transform n lines. For example if you type

esc 10 ctrl-x e

that transforms the next 10 lines into cout statements.