( Latest Revision: Oct 9, 2014 ) edit instructions

Edit Instructions


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

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

Start up a jove session to edit that file.

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

void MakeOneJack()
{
       /* code for function MakeOneM goes in here,
          between the braces. */
                 ,
                _))._
              /`'---'`\
             |  <\ />  |
             | \  ^  / |
             \  '-'-'  /
          jgs '--'----'
}
Move the cursor to where it is positioned above the pumpkin 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.

Next, you can finish off the transformation by putting

cout << "

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

\n" ;

at the end of each line of the figure. Now it is 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 (the pumpkin), 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 3 ctrl-x e

that transforms the next 3 lines into cout statements.