@database @node main Chapter29 "SBase Personal - 29. FUNCTION KEYS" @{" 29 FUNCTION KEYS " link 0} In SBase Professional 4 Only @{" Defining a Function Key " link 1} @{" List Function Key Assignments " link 2} @{" Function Keys for Commands " link 3} @{" Examples " link 4} @{" Function Keys for Text and Program Editing " link 5} @{" Editing a Function Key String " link 6} @{" Function Key Files " link 7} @{" Saving Function Key Files " link 8} @endnode @node 0 29 FUNCTION KEYS (In SBase Professional 4 Only) The action of function keys may be defined by the user. You may attach a command line of up to 255 characters to any of forty function keys. Pressing the key to which the command line is attached executes the command line. Function key definitions may be saved as SBK files and are re-usable. The main applications for this facility are: - Creating command lines to perform multiple operations with a single keystroke. - Inserting often used words, keywords, phrases, and paragraphs in a text document or a program. There are forty function keys available by combining F1 to F10 with control keys in four different ways: Function Key alone SHIFT+Function Key CTRL+Function Key SHIFT+CTRL+Function Key @endnode @node 1 Defining a Function Key Select the Function Keys command from the Set menu. You will then be presented with the Function Key Definition requester: *** @{" See Fig 29-1 " system "ps sb2:Fgi29-1"} *** First, choose the key to which the command line is to be attached. 1. Click the radio button for the required combination in the box at the right-hand side of the requester. 2. Click the radio button for the key itself. 3. Type the command line to be executed in the text box. Do not press ENTER at the end of the command line unless you wish to exit from the requester immediately. - Multiple commands may be entered, separated by the colon character `:' - You may specify text on its own. Pressing the key prints the text in a field or in the Text or Program editor. - If you want to be able to execute the command line at any time, for example in the middle of data entry or while editing a program, type an exclamation point `!' as the first character. In data entry, this has the effect of pressing the ESC key and ends the activity. 4. Click OK to exit from the requester. The function key is ready to use. @endnode @node 2 List Function Key Assignments Select the Function Keys List command from the Set menu. SBase 4 displays the current definitions in the work area. In SBase Professional 4, the DML KEY command may be used to list output. You can redirect the oput to the printer with a DML Command Line: PRINT:KEY:DISPLAY @endnode @node 3 Function Keys for Commands If the commands can be executed as a one line program, they can also be assigned to a function key. Note Single word commands at the beginning of a function key string must have a trailing space if followed by a colon. @endnode @node 4 Examples The following function key string simply displays the current time, but it also illustrates the use of the `!' character. Placing this character at the front of the string forces SBase 4 to execute the command in all circumstances: !? NOW The second example could be adapted to any situation where you wish to select a record but are not sure what to enter as the index key. In this case, it allows you to enter just the initial letter of a customer name (or the first part of the name) and then displays a list of the names in the customer file that begin with the letter (or letters) you have entered. a$ = "":REQUEST "Enter customer initial","",4,a%,a$,15:REQUEST "Select customer","",20,a%,a$,40,Lastname,Firstname:SELECT KEY a$ The last example has a more specialized application. Suppose you are entering details of check payments in a file called Checks. For each check, you create a new record which holds details such as the amount and the date. You also want to keep a running total of the amounts as they are entered. One way of doing this would be to define the following function key string: SELECT LAST:x% = Total.checks: BLANK: ENTER: Total.Checks = Amount.Checks + x%: STORE: VIEW Pressing the function key for this string collects the total from the last cheque entered and then presents you with a blank record. When you have typed in the details of the next cheque, it updates the Total.Checks field and stores the new record. The example assumes that the file is currently indexed on a date field and that the cheques are entered in date order. @endnode @node 5 Function Keys for Text and Program Editing Function keys are useful for entering text strings which occur many times in the same document or are regularly used in different documents. They save you the trouble of having to type in the string yourself every time it is needed. Provided the text insertion point is shown on screen, pressing a function key will insert a string at that point. The same applies to the use of function keys when editing a program. You can define function keys to insert commonly used keywords in a program. For example, you might want to define the keys SHIFT+F1 to SHIFT+F5 as: REM LOAD " SAVE " OPEN FILE " WHILE Keys SHIFT+F5 to SHIFT+F10 could then be assigned commands which are useful during program development: !MEMORY !RUN !PAGING ON:? LIST !EDIT !STATUS Note the use of the `!' character here. It allows these function key commands to be executed even when the program insertion point is active. If you wish to define a text string that runs over several lines, you need to use the carriage return character. However, it is not possible to enter this character in the Function Keys requester, so you must enter it using the KEY command in a program or a DML Command Line. So to assign an address to F1, you would enter a string like this: KEY 1, "8404 Sterling Street" + CHR$(13) + "Irving" + CHR$(13) + "Texas 75063" + CHR$(13) Note SBase 4 cannot save control characters in a function key file, so to store this string on disk you need to save it as a one line program. Normally, function key strings which are intended for text entry cannot be executed as commands. Pressing a function key of this type when the cursor is not active may cause an error message. @endnode @node 6 Editing a Function Key String If a function key has already been defined, selecting the Function Keys command from the Set menu displays the contents of the key in the string entry box. Initially, the setting for the F1 key will be shown. When you choose another key with the requester controls, SBase 4 displays the setting for that key. If you wish to change the current setting, you can do so using the usual editing controls. Alternatively, click Clear to remove the current setting and type in a new function key definition. @endnode @node 7 Function Key Files Function Key definitions can be saved on disk for use in other sessions with SBase 4. Function key files are saved as ASCII files with the SBK extension. If you wish to examine a function key file, you may display it on screen or print it out with the Type option on the Utilities menu. Any keys which have not been assigned a string are shown as blank lines. @endnode @node 8 Saving Function Key Files 1. Select the Function Keys Save As command from the Set menu. 2. Enter a filename. 3. Click OK. SBase 4 saves the current function key definitions on disk, adding the SBK extension to the file name you type in. To save a function key file under a program control, use the command SAVE KEY "file name". Opening Function Key Files 1. Select the Function Keys Open command from the Set menu. 2. Choose a filename from the list. 3. Click OK. SBase 4 loads the selected file into memory and sets up the function keys ready for use. Use the LOAD KEY "file name" command to load a function key file under program control . You can include this command, followed by the name of a function key file, in SBase 4's auto-executing Start.sbp program SBase Professional owners (see DML Reference Guide). This way, the function keys will be set up for you as soon as SBase has loaded. Another way of using the LOAD KEY command is to assign it to a function key. You will then be able to load a specified function key file with a single key press. @endnode