786.TXT
=====================================================================
WAYNE'S CORNER - AN R:BASE SLIDE SHOW
=====================================================================
PRODUCT: R:BASE VERSION: 4.5+ or Higher
=====================================================================
CATALOG: Programming in R:BASE AREA : Logic & Data Manipulation
=====================================================================
Use R:BASE to create a slide show type presentation. Display text on
the screen line by line, run command files, and return to the same
place in your presentation. Using a table to hold the information to
display lets you show text to the screen on the key points of your
presentation. You can then run R:BASE command files to demonstrate
features and provide examples for your talk.
Creating the table
Create a table in R:BASE to control the actions. This table contains
all the data necessary to draw colored boxes on the screen, display
text and run the example programs. The command file, talk.rmd,
accesses the data in this table through DECLARE CURSOR. As each row is
read, the designated action is performed.
Table Actions:
Frame INTEGER
Action TEXT (8)
Words NOTE
UpperLeftRow INTEGER
UpperLeftColumn INTEGER
LowerRightRow INTEGER
LowerRightColumn INTEGER
FColor TEXT (8)
BColor TEXT (8)
The Frame column orders the actions. By using groups of numbers
(100, 200, 300, and so on), you can group the actions by screen,
making it easier to set up your presentation. Define a single column
index for this column.
The Action column tells the program what to do. There are four
possible actions: WORDS, CLS, BOX, and RUN. Depending on the action,
the other columns are filled in appropriately.
The Words action
When the action is words, the Words column contains the text to
display. The text is displayed using the WRITE command.
The text in the Words column can be one long string that is wrapped
on display, or it can contain LINEEND characters for additional
formatting. The UpperLeftRow and UpperLeftColumn columns contain the
starting row and column locations for the text display. These
parameters are coordinated with the box display that the text is
written in - the words action always follows a box action. The row
and column positions should be one row greater and one column greater
than the UpperLeftRow and UpperLeftColumn coordinates for the
preceding box action.
The LowerRightRow column contains the display width for the text. The
LowerRightColumn column is NULL. The FColor and BColor columns contain
the foreground and background colors for the text display. The
background color matches the background color of the preceding box
action. The BColor column can have the same value for all rows in the
table. Text is emphasized by writing it in different colors, such as
black or red; the FColor column has the color of the actual text.
The Cls action
When the action is cls, all the other columns on the row are NULL.
This action executes the CLS - clear screen - command.
The Box action
When the action is box, the Words column is NULL. This action draws a
shadowed, colored box on the screen. The CLS command is used to draw
the box.
The UpperLeftRow, UpperLeftColumn, LowerRightRow, and
LowerRightColumn columns contain the screen coordinates for drawing
the box. The text from words actions is displayed in this box. The
FColor column is NULL and the BColor column has the box color. This
color matches the BColor value for the words actions that follow the
box action.
The Run action
When the action is run, the Words column contains the name of a
command file to run. This command file must be an ASCII file; you
cannot run an application file here. All the other columns on the row
are NULL. The ASCII command file is run using the QUIT TO command.
This action exits the presentation program, talk.rmd. The last line in
the ASCII command file that is run must be RUN TALK.RMD, which
restarts the presentation program at the same place. The variables
vlastcls and vresume control where the presentation program restarts -
do not clear them in the ASCII command file.
Setting up frames
Use the frame column to group the actions by screen display. A screen
is 25 lines; actual display is limited to about 20 lines for ease of
viewing. Within a frame or group, the actions begin with a cls, then
a box, then a series of words and run actions. More than one box can
be drawn per group. Using different boxes separates and emphasizes the
text. You might have the following frame numbers and actions:
screen 1
100 CLS clear the screen
101 BOX draw box for text display
102 WORDS text to display in box drawn by 101
screen 2
200 CLS clear the screen
201 BOX draw box for text display
202 WORDS text to display in box drawn by 201
203 BOX draw a second box below the first
210 WORDS text to display in box drawn by 203
220 WORDS text to display in box drawn by 203
230 WORDS text to display in box drawn by 203
screen 3
300 CLS clear the screen
301 BOX draw box for text display
302 WORDS text to display in box drawn by 301
303 BOX draw a second box below the first
310 WORDS text to display in box drawn by 303
320 RUN file to run
330 WORDS text to display in box drawn by 303
Group the actions and text by screen display to easily set up your
presentation. Remember that each group starts with a cls, then a box,
and then a words action, putting a header or title on the screen.
Then, draw additional boxes and display text as desired on the rest of
the screen below the header. The header box and text remain on the
screen while the lower boxes and text change. You don't need to clear
the screen to clear text displayed in a box - just use a box action to
redraw an empty box at the same location.
Rows of data can be added to the Actions table in any order; when the
presentation program is run, it orders the data by the frame column.
Rows are inserted or reordered by changing the frame number. For
example, insert another words action by adding a frame numbered 311.
The row is physically added to the end of the Actions table, but
ordered properly when the presentation program is run.
300 CLS clear the screen
301 BOX draw box for text display
302 WORDS text to display in box drawn by 301
303 BOX draw a second box below the first
310 WORDS text to display in box drawn by 303
311 WORDS text to display in box drawn by 303
320 RUN file to run
330 WORDS text to display in box drawn by 303
Here's the presentation program code.
*(TALK.RMD)
CONNECT talk
SET VAR vkey TEXT, vclscount INT, vresume INT, +
vlastcls INT
SET MESSAGE OFF
IF vlastcls IS NULL THEN
SET VAR vlastcls = 0
ENDIF
DECLARE c1 SCROLL CURSOR FOR SELECT * FROM actions +
WHERE Frame >= .vlastcls ORDER BY Frame
OPEN c1
FETCH NEXT FROM c1 INTO +
vFrame i1, vAction i2, vWords i3, vULR i4, +
vULC i5, vLRR i6, vLRC i7, vFColor i8, vBColor i9
WHILE sqlcode = 0 THEN
IF vresume = 0 OR vresume IS NULL THEN
SWITCH (.vAction)
CASE CLS
CLS
SET VAR vlastcls = .vFrame
BREAK
CASE BOX
SET VAR bulr = (.vULR + 1)
SET VAR bulc = (.vULC + 1)
SET VAR blrr = (.vLRR + 1)
SET VAR blrc = (.vLRC + 1)
CLS FROM .bulr .bulc TO .blrr .blrc black
CLS FROM .vULR .vULC TO .vLRR .vLRC .vBColor
BREAK
CASE WORDS
SET VAR vwords TEXT = (.vwords)
WRITE .vwords = .vLRR AT .vULR .vULC +
.vFColor ON .vBColor
SET VAR vkey = (GETKEY(0))
SWITCH (.vkey)
CASE [Esc]
SET VAR vlastcls = 0
CLS
QUIT
CASE [Up]
CASE [PgUp]
SET VAR vclscount = 0
WHILE sqlcode = 0 THEN
FETCH PRIOR FROM c1 INTO +
vFrame i1, vAction i2, vWords i3,+
vULR i4, vULC i5, vLRR i6, vLRC i7, +
vFColor i8, vBColor i9
IF vclscount >= 2 THEN
BREAK
ENDIF
IF vAction = 'CLS' THEN
SET VAR vclscount = (.vclscount + 1)
ENDIF
ENDWHILE
BREAK
CASE [PgDn]
SET VAR vclscount = 0
WHILE sqlcode = 0 THEN
FETCH NEXT FROM c1 INTO +
vFrame i1, vAction i2, vWords i3,+
vULR i4, vULC i5, vLRR i6, vLRC i7, +
vFColor i8, vBColor i9
IF vAction = 'CLS' THEN
FETCH PRIOR FROM c1 INTO +
vFrame i1, vAction i2, vWords i3,+
vULR i4, vULC i5, vLRR i6, vLRC i7, +
vFColor i8, vBColor i9
BREAK
ENDIF
ENDWHILE
BREAK
CASE [Alt][F1]
SET KEYMAP [Alt][F2] = 'run talk.rmd[enter]'
SNAP resume.scn FROM 1,1 TO 25,80
SET VAR vresume = .vFrame
QUIT
DEFAULT
BREAK
ENDSW
BREAK
CASE RUN
IF vkey <> '[F2]' THEN
SNAP resume.scn FROM 1,1 TO 25,80
SET VAR vresume = .vFrame
QUIT TO .vWords
ENDIF
BREAK
ENDSW
ELSE
IF vFrame > .vresume THEN
SET VAR vresume = 0
DISPLAY resume.scn AT 1,1
ERASE resume.scn
ENDIF
ENDIF
FETCH NEXT FROM c1 INTO +
vFrame i1, vAction i2, vWords i3,+
vULR i4, vULC i5, vLRR i6, vLRC i7, +
vFColor i8, vBColor i9
ENDWHILE
CLOSE c1
DROP CURSOR c1
SET VAR vlastcls = 0
CLS
SET MESSAGE ON
RETURN
The DECLARE CURSOR orders the data by the frame column. A scrolling
cursor is used so you can go back to previous screens. The where
clause on the DECLARE CURSOR is used when you restart the
application using the Alt-F2 function key (program exited by Alt-F1)
or when you restart after running a program.
vresume has a value only after you have run a program
This switch block, the Action switch, executes commands based on
the action defined for this row in the Actions table
The Cls action
Since each screen starts with a CLS, vlastcls is set to identify
the screen for restarting the presentation.
The Box action
Draw the black shadow
Draw the colored box.
The Words action
Display the text in the box.
The program pauses here waiting for a key press. The GETKEY function
checks for a key press to determine what to do next. Any key other
than Esc, PgUp, Up, PgDn, or Alt-F1 moves to the next row in the
Actions table and executes the next action. F2 here skips past a run
action
The Esc key exits completely.
Up arrow or Page up displays the previous screen. Previous rows are
fetched until the program finds two cls actions. Each screen starts
with a CLS, that's why the program looks for two - the screen the
cursor is on is one cls action. The cursor skips past this cls, then
finds the previous cls action. After finding the second cls action,
one more FETCH PRIOR is done. This ensures the FETCH NEXT located
after the Action switch block (this fetch always executes), retrieves
the cls action to start the previous screen.
Page down goes to the next screen, the program fetches rows until a
cls action is found. A cls action begins each screen. A FETCH PRIOR
is then done to position the cursor for the FETCH NEXT that always
executes after the Action switch block.
Alt-F1 exits the application but allows restart at the same place. The
Alt-F2 key is defined to restart the program from the R> prompt.
End of the Words switch and action
The Run action
Use the F2 key to skip by and not run the external program; any key
but F2 will execute the specified ASCII file.
Variable vresume holds the current frame number, which identifies
where the restart the DECLARE CURSOR
End of the Action switch
This section restarts after running a program. The vFrame comes from
the DECLARE CURSOR and FETCH that is done as the program is restarted.
The variable vlastcls, used in the DECLARE CURSOR WHERE clause, has
the frame number of the last cls action. The variable vresume has the
frame number of the last action executed, usually a run action.
Vresume is greater than vFrame the first time through; the program
then fetches rows until vframe is greater than vresume - the frame
and action following the run action. The screen is redisplayed,
resume.scn, the next row fetched and the action executed.
This FETCH is always executed, it gets the next row after an action
is completed.