[ PowerBASIC Reference Guide ] parallel to chapter 14 in PG

POPUP function

Purpose The POPUP function returns status information about

the popup features of the program

Syntax POPUP(n)

Remarks ----------------------------------------------------------

n Meaning of information returned

----------------------------------------------------------

1 Safe-to-uninstall flag TRUE/FALSE

2 Ticks left till activation, for POPUP TIMER

3 Free keyboard strokes, for POPUP STUFF

4 POPUP activation method

----------------------------------------------

Value Popup activation method

----------------------------------------------

1 POPUP KEY

2 POPUP QUIET

4 POPUP TIMER

8 POPUP INTERRUPT

16 POPUP MULTIPLEX

----------------------------------------------

5 Number of failed attempts by PowerBASIC to activate

this popup program, due to timeouts

6 Number of times that PowerBASIC was asked to activate

this still popped-up program

----------------------------------------------------------

See also POPUP statement, SETMEM, ISFALSE, ISTRUE

Examples

SafeToUninstallFlag%=POPUP(1)

rem false (busy) is zero

rem true (ready) is nonzero

IF ISFALSE SafeToUninstallFlag% THEN

print"Unable to uninstall"

ELSE

print"Uninstalling"

END

END IF

PopupTimerTickCount%=POPUP(2)

rem used in POPUP TIMER

FreeKBbufferChars%=POPUP(3)

rem used with POPUP STUFF

PopupMethod%=POPUP(4)

Select case PopupMethod%

case 1: 'POPUP KEY

case 2: 'POPUP QUIET

case 4: 'POPUP TIMER

case 8: 'POPUP INTERRUPT

case 16: 'POPUP MULTIPLEX

end select

PopupFailuresDueToTimeouts%=POPUP(5)

if PopupFailuresDueToTimeouts%>0 then

print"Numerous Popup Failures Due To Timeouts"

end if

PopupFailuresDueToAlreadyUp%=POPUP(6)

if PopupFailuresDueToAlreadyUp%>0 then

print"Numerous Popup Failures Due To Being Already Popped Up"

end if

POPUP STATEMENT

Purpose The POPUP statement allows the user to define, with a minimum

of effort, the method of inactivation, "popping down", and

the method of activation, "popping up". An extra POPUP command,

POPUP STUFF, allows simulating keyboard input.

POPPING DOWN

Popup Inactivation Methods

POPUP SLEEP USING EMS

POPUP SLEEP USING FileName$

POPUP SLEEP USING EMS, FileName$

POPUP SLEEP

POPPING UP

Popup activation methods

POPUP KEY CHR$( RequiredShiftKeys, scancode (, OptionalShiftKeys) )

POPUP INTERRUPT InterruptNo%, timeout, ChainBefore, ChainAfter

POPUP MULTIPLEX AXmask, DXmask

POPUP QUIET Ticks

POPUP TIMER Ticks

DISABLING A POPUP PROGRAM

POPUP KEY OFF

POPUP INTERRUPT OFF

POPUP MULTIPLEX OFF

POPUP QUIET OFF

POPUP TIMER OFF

RE-ENABLING A POPUP PROGRAM

POPUP KEY ON

POPUP INTERRUPT ON

POPUP MULTIPLEX ON

POPUP QUIET ON

POPUP TIMER ON

UNINSTALLING

END

Finishing execution of the popup program without popping down again

POPUP STUFF

POPUP STUFF TextString$, InitialDelayTicks%, TicksBetweenChar%

POPUP SLEEP

Popup Inactivation Methods

POPUP SLEEP USING EMS

PowerBASIC swaps out a memory image of your popup program and its data

into expanded or extended memory, then "pops the program down", making

it dormant. The portion that remains resident in lower 640kb of RAM memory

can be as little as 5kb.

Example of using a DEF FN to simplify programming

rem this popup needs 8000 bytes for dynamic arrays

dummy=FNPopDownUsingEMS (8000)

def FNPopDownUsingEMS (DynamicMemory%)

dummy=setmem(-700000)

if DynamicMemory%>0 then dummy=setmem(DynamicMemory%)

POPUP SLEEP USING EMS

end def

POPUP SLEEP USING FileName$

PowerBASIC swaps out a memory image of your popup program and its data in

RAM memory, to a hard disk file, then "pops the program down", making it

dormant. The portion that remains resident in lower 640kb RAM memory can

be as little as 5kb each. The filename must be a fully expanded pathname,

complete with drive letter and colon and the slash. The drive must be a

nonremovable drive, i.e., not a floppy disk drive. The file created

will be given the hidden attribute, to prevent it from being deleted.

Example of using a DEF FN to simplify programming

rem this popup needs 8000 bytes for dynamic arrays

dummy=FNPopDownUsingFile (8000)

def FNPopDownUsingFile (DynamicMemory%, FileName$)

dummy=setmem(-700000)

if DynamicMemory%>0 then dummy=setmem(DynamicMemory%)

POPUP SLEEP USING FileName$

end def

POPUP SLEEP USING EMS, FileName$

PowerBASIC swaps out a memory image of your popup program and its data in

RAM memory, either into expanded or extended memory, or to a hard disk

file, then "pops the program down", making it dormant. It will first

try swapping it to expanded or extended memory, as the preferred method.

If that operation fails, it will try to use the disk file that you have

defined. If both attempts fail, you will get a runtime error.

The portion that remains resident in lower 640kb RAM memory can

be as little as 5kb each. The filename must be a fully expanded pathname,

complete with drive letter and colon and the slash. The drive must be a

nonremovable drive, i.e., not a floppy disk drive. The file created

will be given the hidden attribute, to prevent it from being deleted.

Example of using a DEF FN to simplify programming

rem this popup needs 8000 bytes for dynamic arrays

dummy=FNPopDownUsingBoth (8000)

def FNPopDownUsingBoth (DynamicMemory%, FileName$)

dummy=setmem(-700000)

if DynamicMemory%>0 then dummy=setmem(DynamicMemory%)

POPUP SLEEP USING EMS, FileName$

end def

POPUP SLEEP

PowerBASIC will make this popup program memory resident, and dormant,

but it will not swap it out to conserve RAM memory.

Example of using a DEF FN to simplify programming

rem this popup needs 8000 bytes for dynamic arrays

dummy=FNPopDownWithoutSwapping (8000)

def FNPopDownWithoutSwapping (DynamicMemory%)

dummy=setmem(-700000)

if DynamicMemory%>0 then dummy=setmem(DynamicMemory%)

POPUP SLEEP

end def

POPPING UP

Popup activation methods

POPUP KEY Hot key program loading

User-controlled activation of a popup program can be accomplished with

the POPUP KEY command. This kind of popup program can be called up to the

foreground whenever you want to use it.

POPUP KEY CHR$( RequiredShiftKeys, scancode (, OptionalShiftKeys) )

The limit of how many modules can be activated this way is the number of

combinations of Control, Alternate, and Shift keys (right, left, or

either), with the characters listed in the Reference Guide, Table A.3,

Keyboard Scan Codes. Function keys F11 and F12 scan codes are not supported.

These parameters are all hex numbers, expressed as &Hnn.

RequiredShiftKeys, also called "shiftstatus", are assigned the following

values, according to their bit positions. These are the keys which must

be pressed or held down.

Table A.4 ----------------------------------------------

Shift flags Key Binary value Hex value

----------------------------------------------

RightShift 0000 0001 01

LeftShift 0000 0010 02

EitherShift 0000 0011 03

Ctrl 0000 0100 04

Alt 0000 1000 08

ScrollLock 0001 0000 10

NumLock 0010 0000 20

CapsLock 0100 0000 40

----------------------------------------------

*********************for final version, be sure of alignment

OptionalShiftKeys, also called "any", use the same values as above,

according to their bit positions. These are the keys which may be pressed

or held down, but are not necessarily required. In other words, these

keys are to be ignored. Generally, this number is the inverse of the bit

pattern in the RequiredShiftKeys number.

In most cases, you would want to ignore the ScrollLock, NumLock, and

CapsLock keys, which might be accidentally touched and left in a "locked"

condition.

For even more detail, see PowerBASIC Reference Guide, Appendix A.

Scan codes are listed in Table A.3.

Examples of use of DEF FN to simplify programming

RightShift%=&H01: RVRightShift%=&H7E

LeftShift%=&H02: RVLeftShift%=&H7D

EitherShift%=&H03: RVEitherShift%=&H7C

Ctrl%=&H04: RVCtrl%=&H7B

Alt%=&H08: RVAlt%=&H77

ScrollLock%=&H10: RVScrollLock%=&H6F

NumLock%=&H20: RVNumLock%=&H5F

CapsLock%=&H40: RVCapsLock%=&H3F

rem F10's scancode is &H44

rem To assign ShiftF10 as the hot key

dummy=FNSetPopupHotKeyWithEitherShiftKey (&H44)

or

F10%=&H44

dummy=FNSetPopupHotKeyWithEitherShiftKey (F10%)

'---

def FNSetPopupHotKeyWithEitherShiftKey (scancode)

EitherShift%=&H03: RVEitherShift%=&H7C

POPUP KEY CHR$( EitherShift%, scancode, RVEitherShift%)

end def

'---

def FNSetPopupHotKeyWithCtrlKey (scancode)

Ctrl%=&H04: RVCtrl%=&H7B

POPUP KEY CHR$( Ctrl%, scancode, RVCtrl%)

end def

'---

def FNSetPopupHotKeyWithAltKey (scancode)

Alt%=&H08: RVAlt%=&H77

POPUP KEY CHR$( Alt%, scancode, RVAlt%)

end def

'---

def FNSetShiftStatusBits

RightShift%=&H01: RVRightShift%=&H7E

LeftShift%=&H02: RVLeftShift%=&H7D

EitherShift%=&H03: RVEitherShift%=&H7C

Ctrl%=&H04: RVCtrl%=&H7B

Alt%=&H08: RVAlt%=&H77

ScrollLock%=&H10: RVScrollLock%=&H6F

NumLock%=&H20: RVNumLock%=&H5F

CapsLock%=&H40: RVCapsLock%=&H3F

end def

POPUP INTERRUPT

Software-controlled or hardware-controlled activation of a popup program

can be accomplished with the POPUP INTERRUPT command.

POPUP INTERRUPT InterruptNo%, timeout, ChainBefore, ChainAfter

Popup programs can be "popped up" to the foreground when needed, by a

software interrupt from another program, or by a hardware interrupt.

Your main program will use a CALL INTERRUPT to that interrupt number.

POPUP INTERRUPT uses a unique interrupt number for each popup program.

Each POPUP INTERRUPT program works like a "private" telephone line.

It does not have to ignore program calls not addressed to it, like in

POPUP MULTIPLEX.

Examples are programs operating a fax computer board, or your modem in

Answer mode, where the hardware sends an interrupt demanding service,

and speed is required to capture all the characters or bits coming in.

These types of popup programs would probably not be swapped out.

POPUP INTERRUPT

Options

InterruptNo% The user-assigned interrupt number that

will cause the program to pop up.

Timeout Defines, in ticks, how long PowerBASIC

should try to pop up this program, after

the interrupt occurs.

ChainBefore Set it to ON for PowerBASIC to call the

program that was monitoring this interrupt

before executing your popup code. Other-

wise, set it to OFF.

ChainAfter Set it to ON for PowerBASIC to call the

program that was monitoring this interrupt

after executing your popup code. Other-

wise, set it to OFF.

POPUP MULTIPLEX

Software-controlled activation of a popup program can be accomplished with

the POPUP MULTIPLEX command.

POPUP MULTIPLEX AXmask, DXmask

POPUP MULTIPLEX uses the same interrupt number &H2F for each popup program

attached to it, but also uses two register masks, in registers AX and DX,

to identify which popup program is being called, like a mailbox or extension

number, and a password or PIN (personal identification number).

Each POPUP MULTIPLEX program must check these two register masks and

ignore all "party-line calls" except its own calls.

It is possible to handle many more popup programs with the same interrupt

number, using POPUP MULTIPLEX.

Example:

POPUP MULTIPLEX AXmask, DXmask

POPUP QUIET

Software-controlled activation of a popup program can be accomplished with

the POPUP QUIET command.

POPUP QUIET Ticks%

A variation of POPUP TIMER command, a POPUP QUIET program will only be

activated when the human operator does not use the computer for a while.

A period of time with no keyboard or mouse activity will activate this

type of popup program.

Each second is approximately 18.2 timer ticks. To simplify using this

method, the following example functions are suggested.

Example of using a DEF FN to simplify programming

dummy=FNSetPopupQuiet (5)

def FNSetPopupQuiet (Minutes%)

Ticks%=Minutes%*60*18.2

POPUP QUIET Ticks%

end def

POPUP TIMER

Software-controlled activation of a popup program can be accomplished with

the POPUP TIMER command.

POPUP TIMER Ticks%

Popup programs can stay loaded, dormant in the background, and "pop up" to

the foreground to run only at intervals. This "timeslicing", sharing

microprocessor time-slots, is similar to multitasking. You can use a

background level to do work that does not need operator attention, like

printing pages, or reading data from your investment delayed quote service.

Example of using a DEF FN to simplify programming

dummy=FNSetPopupTimer (5)

def FNSetPopupTimer (Minutes%)

Ticks=Minutes%*60*18.2

POPUP TIMER Ticks

end def

POPUP STUFF

Software-controlled simulation of operator input can be accomplished with

the POPUP STUFF command.

POPUP STUFF TextString$, InitialDelayTicks%, TicksBetweenChar%

TextString$ String of characters to stuff into the

keyboard buffer. To stuff extended key codes,

also stuff a CHR$(0), to simulate the null

first character. See Table A.2 for codes.

InitialDelayTicks% Pop down, then wait this many ticks, before

starting to stuff the keyboard buffer

TicksBetweenChar% Wait this many ticks, between stuffing each

character into the keyboard buffer

Example of using a DEF FN to simplify programming

dummy=FNStuffKBBuffer ("Unseen hands")

'---

def FNStuffKBBuffer (TextString$)

InitialDelaySeconds%=2: InitialDelayTicks%=InitialDelaySeconds%*18.2

TicksBetweenChar%=6

POPUP STUFF TextString$, InitialDelayTicks%, TicksBetweenChar%

end def

POPUP <Mode> { ON | OFF }

One way to be able to temporarily regain use of a certain hot key is to

disable the popup activation checking, using the option OFF.

DISABLING A POPUP PROGRAM

POPUP KEY OFF

POPUP INTERRUPT OFF

POPUP MULTIPLEX OFF

POPUP QUIET OFF

POPUP TIMER OFF

To re-enable the popup activation checking, use the option ON.

RE-ENABLING A POPUP PROGRAM

POPUP KEY ON

POPUP INTERRUPT ON

POPUP MULTIPLEX ON

POPUP QUIET ON

POPUP TIMER ON

This file has been created with the evaluation or unregistered copy of
EasyHelp from Eon Solutions
(Tel: UK 0973 209667, Email: eon@cix.compulink.co.uk)