| Previous | Contents | Index |
| Example 11-42 ASK | SET WINDOW: CURRENT |
|---|
print at 1,20, blink: 'Sample screen'
do
line input 'Name', at 5,1, length 30: name$
if _back or _exit then exit do
if _help then
ask window: current old_w$
clear area box: 1, 5, 10, 50
print at 3, 10, reverse: 'This is some help'
delay
set window: current old_w$
repeat do
end if
end do
end
Sample screen
Name? help___________________ <------- type in 'help'
+--------------------------------------------+
| |
| This is some help |
| |
Name| |
| |
| |
+--------------------------------------------+
Press the ENTER key to continue
|
ASK WINDOW: CURRENT and SET WINDOW: CURRENT saves the image of the current screen and later restore it easily. This is useful for help messages and menus, where you must temporarily change the screen and then restore it back to what it was.
ASK WINDOW: DATA str_var
|
| Example 11-43 ASK WINDOW: DATA statement |
|---|
print at 10, 4: 'Mary had a';
print at 11, 4: 'little lamb';
ask window: data x$
print
print x$
end
Mary had a
little lamb
.
.
.
Mary had a
little lamb
|
ASK WINDOW: DATA statement reads the text displayed on the whole screen into a string variable. The statement returns a <LF> delimited string. No screen attributes are stored.
SET WINDOW: DATA str_expr
|
| Example 11-44 SET WINDOW: DATA statement |
|---|
clear print at 1,1: ; x$ = 'Mary had a' + chr$(10) + 'little lamb' set window: data x$ print at 10,1: 'done' end Mary had a little lamb done |
SET WINDOW: DATA statement sets the whole screen to the specified string. This is the mirror image of ASK WINDOW: DATA str_var.
11.15.8 ASK | SET WINDOW: KEYMAP
ASK WINDOW: KEYMAP str_var
SET WINDOW: KEYMAP str_expr
|
| Example 11-45 ASK | SET WINDOW: KEYMAP |
|---|
print 'Save the current keymap, reset keymap to default value.' ask window: keymap old_keymap$ set window: keymap '' print 'Changing dollar sign key to *' set window keystroke '$': value '*' line input 'Press the dollar sign key, then ENTER': e$ print 'Restore saved keymap' set window: keymap old_keymap$ line input 'Press the DOWN key': down$ line input 'Press the dollar sign key, then ENTER' : e$ end Save the current keymap, reset keymap to default value. Changing DOWN key to be the EXIT key Press the DOWN key? EXIT Changing dollar sign key to * Press the dollar sign key, then ENTER? * Restore saved keymap Press the DOWN key? Press the dollar sign key, then ENTER? $ |
ASK WINDOW: KEYMAP and SET WINDOW: KEYMAP allow a generalized routine to save the current keymap, change the meaning of keys, and then restore the original keymap when done.
ASK WINDOW: KEYMAP and SET WINDOW: KEYMAP are used to save the image of the keymap and later restore it. This is helpful for applications the meaning of the keys must be temporarily changed using the SET WINDOW KEYSTROKE statement. The keymap can be restored to its default setting with SET WINDOW: KEYMAP.
SET WINDOW KEYSTROKE str_expr1: VALUE str_expr2
|
| Example 11-46 SET WINDOW KEYSTROKE: VALUE statement |
|---|
print 'Saving the current keymap.' ask window: keymap old_keymap$ set window: keymap '' print 'Changing dollar sign key to *' set window keystroke '$': value '*' line input 'Press the dollar sign key, then ENTER': e$ print 'Restoring saved keymap.' set window: keymap old_keymap$ line input 'Press the DOWN key': down$ line input 'Press the dollar sign key, then ENTER' : e$ end Saving the current keymap. Changing DOWN key to be the EXIT key Press the DOWN key? EXIT Changing dollar sign key to * Press the dollar sign key, then ENTER? * Restoring saved keymap. Press the DOWN key? Press the dollar sign key, then ENTER? $ |
SET WINDOW KEYSTROKE changes the meaning of a keystroke within a SheerPower program. This allows complete redefinition of the keyboard for a given application.
str_expr1 describes the name of a key to be changed. It can be a single keystroke name or a comma-separated list of names. Keystroke names can be a single letter, or the name of the letter (such as [Tab], or [Ctrl/Z]).
str_expr2 defines the new meaning of the keystroke. A keystroke meaning consists of one or two components: the keystroke value and the keystroke concept. For example, the [Ctrl/Z] key usually has a value of CHR$(26), and the concept of EXIT. The keystroke value and/or the keystroke concept can be changed. If changing both a value and a concept, separate the two with a comma. You can restore the original meaning of the key by using " ".
The following keystroke concepts are supported:
| Concept name | Description |
|---|---|
| _EXIT | an EXIT key |
| _BACK | a BACK key |
| _HELP | a HELP key |
| _IGNORE | ignore this keystroke |
| _INVALID | beep when pressed |
| _TERMINATOR | keystroke is a line terminator |
ASK WINDOW: ROW num_var
|
| Example 11-47 ASK WINDOW: ROW statement |
|---|
print at 5,10:; ask window: row cur_row print 'Cursor is at row'; cur_row end Cursor is at row 5 |
ASK WINDOW: ROW statement returns the current row of the cursor's position.
SET WINDOW: ROW num_expr
|
| Example 11-48 SET WINDOW: ROW statement |
|---|
set window: row 3 print 'Hi!' end Hi! |
SET WINDOW: ROW statement positions the cursor at the num_expr row within the current column.
ASK WINDOW: TYPEAHEAD str_var
|
| Example 11-49 ASK WINDOW: TYPEAHEAD statement |
|---|
do
do_process
ask window: typeahead z$
if pos(ucase$(z$), 'STA') > 0 then show_status
if pos(z$, chr$(26)) > 0 then exit do
loop
stop
routine do_process
delay 1 //<--- simulated processing
print '.';
end routine
routine show_status
print
print 'Showing status'
set window: typeahead ''
end routine
end
....... <---- type 'STA' while dots are printing
showing status
....... [Ctrl/Z] <---- to stop, press [Ctrl] and [z]
|
| Previous | Next | Contents | Index |