Tutorial > Creating PV-WAVE Applications > Lesson 4: Creating a Program with JOURNAL
  

Lesson 4: Creating a Program with JOURNAL
In Lesson 3, you created a .pro file using a text editor. In this lesson, you will create a .pro file by using the JOURNAL command to record and save in a file everything you enter at the WAVE> prompt. The file created is called a batch file.
Use JOURNAL to create and save a program called gamma_bessel.pro. This program illustrates the use of two special functions from PV‑WAVE IMSL Mathematics. GAMMA and BESSJ define a surface to plot. In this example, you will plot the function:
in the interval, x = [–6, 6], y = [–3, 3] and use SHADE_SURF to plot a shaded surface.
In this lesson, you will do the following:
* Open a JOURNAL File
* Enter Commands on the PV‑WAVE Command Line
* Close the JOURNAL File
* Run the Batch File
Open a JOURNAL File
To use the JOURNAL command to create an executable file, do the following:
1. Enable the mathematics and statistics functions. By default, the functions associated with PV‑WAVE IMSL Mathematics and PV‑WAVE IMSL Statistics are disabled. To enable them, if needed, enter the following:
@waveadv
2. If you are not in one, move to a directory where you have write permission. For example:
CD, 'pathname'
3. Open a JOURNAL file:
JOURNAL, 'gamma_bessel.pro'
You are now ready to start entering PV‑WAVE commands and the prompt. The commands will be saved to the file gamma_bessel.pro.
Enter Commands on the PV‑WAVE Command Line
The commands you enter at the WAVE> prompt are being recorded directly in the JOURNAL file gamma_bessel.pro.
To enter the commands for your program, do the following:
1. Generate 100 x values in the interval [–6, 6]. Enter:
x = -6 + FINDGEN(100)/99*12
2. Generate 100 y values in the interval [–3, 3]. Enter:
y = -3 + FINDGEN(100)/99*6
3. Create a matrix to hold the z values. Enter:
z = FLTARR(100, 100)
4. Create a larger window. Enter:
WINDOW, 0, XSize=875, YSize=800
An empty window appears.
5. Load colortable 6, Prism. Enter:
LOADCT, 6
PV‑WAVE returns a message telling you the colortable has been loaded.
6. Define the surface in the 2D matrix z, using GAMMA and BESSJ. Enter:
FOR i=0,99 DO z(*,i) = $ 
SQRT(ABS(GAMMA(.01 + ABS(x)) * BESSJ(0, y(i)) * $
BESSJ(1, y(i))))
 
note
A space is required before a line continuation ($) when: (a) an equal sign (=) appears immediately before the $ or (b) when the equal sign (=) falls at the beginning of the following line.
7. Define the color 255 in the Prism color palette as white. The Prism colortable does not have white defined by default. Enter:
TVLCT, 255, 255, 255, 255
8. Plot a shaded surface of x, y, and z. Enter:
SHADE_SURF, z, CharSize=3, Color=WoColorConvert(0), $
Background=WoColorConvert(255)
A shaded surface of the result is displayed.
Add a line displaying the mathematical function. You can use the Title keyword to place the function above the plot, but you also have the ability to display the information across the plot by using XYOUTS.
A string that displays the following function requires text commands capable of producing the characters in the correct graphic relationship:
 
note
For a complete discussion of the text commands used in the next step, refer to the PV‑WAVE User’s Guide.
9. First, create a string to produce the equation. Enter:
ss = '!18f!6(x, y)=' + '(!7C!6(0.01 + !9!!!6x!9!!!6)' $
+ 'J!S!i0!r (y)J!s!i1!r (y))!e(1/2)'
 
note
The plus sign (+) is the concatenation character used for text strings in PV‑WAVE.
10. Output the string over the plot. Enter:
XYOUTS, .3, .81, ss, Size=2, Color=50, /Normal, /NoClip
The string is displayed across the plot as shown in Figure 10-2: Plot with String on page 200.
 
Figure 10-2: Plot with String
 
Close the JOURNAL File
*To close and save the JOURNAL file type:
JOURNAL
The gamma_bessel.pro file is saved in your current directory.
Run the Batch File
Now that you have created a batch file, you can run it. You may wish to view the contents first.
1. Go to a text editor or an OS window and display the file. For example, if you are using UNIX, enter:
$ more gamma_bessel.pro
If you used capitals in creating the filename, you must type the filename exactly as you did before, using capitals.
 
note
The file is displayed. Comments added by PV‑WAVE include the PV‑WAVE version number, the file type and machine identification, the working directory pathname, and the date the file was created at the top.
2. From the PV‑WAVE window, compile and run your file. Type:
@gamma_bessel.pro
 
note
The @ command is a special command used to execute batch files. As the file is read, each line is compiled and executed one after another, displaying a shaded surface as before.
3. Close the window. Enter:
WDELETE

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.