SP_SMALLS

SMALLS()

  Short:
  ------
  SMALLS() Lookup tables on dbf with optional hotkeys, code block

  Returns:
  --------
  lReturn   => True if CR pressed, False otherwise

  Syntax:
  -------
  Smalls(expDisplayString,[cTitle],[expAlias],[expReturn],;
      [expStartRange,expEndRange],[bException],[lForceCaps])

  Description:
  ------------
  Popup windowed lookup tables. Many options.

  The up/down/home/end/pgup/pgdn keys are active. If
  there is an controlling index key and the user types alphanumeric
  characters, it is assumed a keysearch is wanted. A read pops up
  allowing the user to complete the search key, and a seek is then
  done.

  Pressing ENTER or ESCAPE exits the lookup and closes
  the window.

  Depending on values contained in the optional
  parameters, values may be KEYBOARDED or ASSIGNED at that time.

  Other keys may be assigned actions, depending on the
  last parameter, described below.

  <expDisplayString>  is what appears for each row in
     the lookup table.

     Think of it as a column definition for Tbrowse.
       It can be either:

       1. A Characters string like
          "LAST+MI+LEFT(FIRST,1)"
          In which case it is macro expanded and made
          into a code block to display this expression

       2. A Codeblock like
          {||LAST+MI+LEFT(FIRST,1)}

       The resulting codeblock is then used as a
       Tbrowse column definition.

  [cTitle]    is an optional lookup box title string

  [expAlias]  Determines the area/dbf/ntx to use, can be
     (expC) alias name             or
     (expN) numeric work area      or
     (expC) dbf/ndx in the format
            "%dbfname%ndxname"

     If left as nil, the current DBF/NTX are
     used and left open when done at the last record
     pointer position.

  [expReturn] This determines what happens when CR is
     pressed. It need not be anything, but it can be:

     (expC) a character expression which is
            macro expanded and KEYBOARDed. Any valid character
            expression will do.

            (Bear in mind that it must be
              character. If you want to keyboard a value into a DATE
              field, for instance, your keyboard expression could be
              "DTOC(entrydate)"

     (expB) a code block which is simply
            evaluated. this can do
            anything you wish. It could assign
            multiple values
            from the lookup file into active
            gets, for instance.

  [expStartRange-expEndRange]
     These are valid for indexed files, and
     determine the beginning and ending key ranges. The
     values must match the type of the controlling index.

  [bException]
     If this codeblock is passed, any keys
     except up/down/enter/pgup/pgdn/home/end/escape  (and
     alphanumeric keys if indexed )  will cause the block to be
     evaluated like so:

       eval(block,lastkey())

     Some interesting ideas for this would be
     to assign a key to an update routine for updating the
     lookup dbf while doing a lookup. (yikes - you didn't hear
     that from me!)

  [lForceCaps]

     Means force capital letters when user is typing in a
     lookup key.  Allows case-insensitive search when index is on
     upper(field)

  Examples:
  ---------
   // lookup on "LNAME+' '+FNAME" in current area
   smalls("LNAME+' '+FNAME")

   // lookup on "LNAME+' '+FNAME" in current area
   // use "Name" as box title
   smalls("LNAME+' '+FNAME","Name")

   // lookup on "LNAME+' '+FNAME" in current area
   // use "Name" as box title
   // go to area 5 for the lookup
   // send LNAME to the keyboard if CR pressed
   smalls({||LNAME+''+FNAME},"Name",5,"LNAME")

   // lookup on "LNAME+' '+FNAME" in current area
   // use "Name" as box title
   // go to alias CUSTOMER for the lookup
   smalls("LNAME+''+FNAME","Name","CUSTOMER")

   // open customer.dbf and do a lookup on it
   // lookup on "LNAME+' '+FNAME"
   // use "Name" as box title
   smalls("LNAME+''+FNAME","Name","%CUSTOMER")

   // open customer.dbf and do a lookup on it
   // lookup on "LNAME+' '+FNAME"
   // use "Name" as box title
   // limit lookup to between "SMITH" and "ZEBRA"
   smalls("LNAME+''+FNAME","Name","%CUSTOMER%NAME",  ;
         "SMITH","ZEBRA")

   // open CUSTOMER.DBF with ENTRYDATE.NDX and do a lookup
   // lookup on "LNAME+' '+FNAME"
   // use "Name" as box title
   // limit lookup to the last year
   smalls("LNAME+''+FNAME","Name",  ;
         "%CUSTOMER%ENTRYDATE",date()365, date())

  Notes:
  -------
  see SMALLVALID(), SMALLWHEN() and SMALLKSET() for
  various get system interfaces to SMALLS().

  Source:
  -------
  S_SMAL.PRG

 

SP_SMALLKSET

SMALLKSET()

  Short:
  ------
  SMALLKSET() Sets up GET-HOTKEY lookup combinations using smalls()

  Returns:
  --------
  Nothing

  Syntax:
  -------
  SMALLKSET(nKey,cProc,cVar,expDisplayString,[cTitle],;
  [expAlias],expReturn,[expStartRange,expEndRange],[bException])

  Description:
  ------------
  Sets key <nKey> to popup SMALLS() with parameters
  <expDisplayString> through [bException] when pressed on
  proc/function <cProc> and var/get <cVar>

  See SMALLS() for description of parameters
  <expDisplayString> through [bException] This actually sets key
  <nKey> to an internal function called SMALLKEY(), and stores the
  lookup definition in a static array. SMALLKEY() recieves
  proc,line,variable and determines lastkey(), and checks the
  static array for that set. If found, smalls() is called with the
  stored parameters.

  Examples:
  ---------

   bOldF2 := SETKEY(K_F2)  // save F2 setting
   // set up some var/lookup definitions keyed to F2

   SMALLKSET(K_F2,"EDITCUST","mState",  ;
         {||state},"State",5,"STATE")

   SMALLKSET(K_F2,"EDITCUST","mZone",  ;
         {||zone},"Zone",5,"ZONE")

   SMALLKSET(K_F2,"EDITCUST","mAgent",  ;
         {||agent},"Agent",5,"AGENT")

   //...code...

   SMALLKCLR()   // be sure to clear out the definitions

  Notes:
  -------
  Save and restore the values to any keys used with
  Clipper's  SETKEY(). Use SMALLKCLR() to clear out the SMALLKEY()
  stored definitions.

  Source:
  -------
  S_SMALK.PRG

SP_S1LABEL

S1LABEL()

  Short:
  ------
  S1LABEL() Prints a single label

  Returns:
  --------
  Nothing

  Syntax:
  -------
  S1LABEL(cLblfile)

  Description:
  ------------
  Prints a single label (1 or more copies) for the
  current record, based on the dimensions and contents definitions in
  .LBL file name <cLblfile>. The dimensions and contents are
  figured, and then presented for printing and/or editing.

  Examples:
  ---------
   setkey(K_F10,{||S1LABEL("MAILING.LBL")} )
                      // sets key F10 to call this
                     // as a popup

  Source:
  -------
  S_1LABEL.PRG

 

SP_RRLASTKEY

RRLASTKEY()

  Short:
  ------
  RRLASTKEY()  Retrieve the last key handled by ratapplykey()

  Returns:
  --------
  <nLastKey> => last key handled by ratapplykey()

  Syntax:
  -------
  RRLASTKEY()

  Description:
  ------------
  Returns the last key - including pseudo keys - handled by
  RatApplyKey().

  The [nRmKey]  and [aLmKeys] parameters of RAT_READ() allow
  emulation of keypresses. The [nRmKey] determines what key is
  emulated when the right mouse button is pressed. The [aLmKeys]
  array contains key emulations to be used for a set of screen
  hot areas for left mouse button clicks. In both cases, the
  ascii key code is passed to RatApplyKey() to handle. However,
  the keys ARE NOT STUFFED INTO THE KEYBOARD, and thus are not
  retrievable through LASTKEY(). The reason, by the way, that they
  are not stuffed into the keyboard, is that some keys cannot be
  stuffed with the KEYBOARD command  ( i.e. ALT-F10 or -39 )

  After a number of requests to be able to tell what key was
  pressed last when exiting a read, even when it is an interpreted
  key based on a mouse click, I've added this function. It will return
  the last key handled by RatApplyKey(), even if the key is based on
  a mouse click. If the last event is a mouse event that does not
  translate into a key value, it will return either K_MOUSELEFT for left
  mouse click, or K_MOUSERIGHT for right mouse click.

  Examples:
  ---------
  RAT_READ(getlist,...)
  if RRLASTKEY()==27
    * escape was pressed or mouse right button was pressed

  endif

  Notes:
  -------

  Source:
  -------
  S_RREAD.PRG

See also : RAT_READ()

 

SP_RRJUMP2

RRJUMP2()

  Short:
  ------
  RRJUMP2()  Jump to a new get in a RAT_READ()

  Returns:
  --------
  NIL

  Syntax:
  -------
  RRJUMP2(nNew)

  Description:
  ------------
  While in a RAT_READ(), causes the jump flag to be set to <nNew>, and
  and the current get's exitstate variable to be set to GE_ENTER. This
  causes an exit from the current get, and a jump to get <nNew>.

  Examples:
  ---------
   // in this example, pressing or clicking F3 causes a jump to
   // get # 1, while pressing or clicking F4 causes a jump to
   // get # 5.

   #include "inkey.ch"

   v1 := space(10)
   v2 := space(10)
   v3 := space(10)
   v4 := space(10)
   v5 := space(10)

   setkey(K_F4,{||rrjump2(5)} )
   setkey(K_F3,{||rrjump2(1)} )

   @24,0 say "[F3-Go to First Get]  [F4-Go to Last Get]"

   ahot := {{24,0,24,20,K_F3},{24,23,24,41,K_F4} }

   @10,10 get v1
   @11,10 get v2
   @12,10 get v3
   @13,10 get v4
   @14,10 get v5

   RAT_READ(getlist,1,.T.,27,nil,aHot)

  Notes:
  -------

  Source:
  -------
  S_RREAD.PRG

See also : RAT_READ()

SP_OLD

OLD()

  Short:
  ------
  OLD()  On Line Documentation - TOPIC oriented help system

  Returns:
  --------
  NIL

  Syntax:
  -------
  OLD()

  Description:
  ------------
  This is ON LINE DOCUMENTATION , similiar to NG or Windows help.
  There are no parameters, but it has a couple of additional
  exported functions that allow TOPIC selection and DEVELOPMENT

  The documentation is stored in a DBF database, with one
  record per TOPIC. A TOPIC has a TITLE, stored in the TOPIC field,
  a variable length TEXT entry (can be as long as needed) stored in the
  TEXT field, and hotlinks stored in the KEYS field, which link the TOPIC
  to other topics via a (S)ee also button.

  The options available to the user are:

    (C)ontents   -- go to the CONTENTS screen, a sort of index or
                    table of contents to the topics in the database
    (S)ee also   -- select from related topics
    (O)ther      -- not yet used
    (B)ack       -- go to previous screen

  The DBF structure is TOPIC C 35
                       KEYS  M
                       TEXT  M

  Additional Exported Functions:

  OLD_DEV(bDevelopMent)
      Where bDevelopment is a proc called during development
      of the doc system. Always pass {||OLD_MOD()} to enable
      development, and NIL to disable development. When development
      is active, a prompt called (M)odify appears at the bottom
      of the screen, allowing CREATION, EDITING, DELETING and
      LINKING of topics.

      The options avaialable to the developer are:

       Add Topic                 - create a new TOPIC record
       Edit Topic                - edit the current TOPIC record
       Delete Topic              - delete the current TOPIC record
       Modify SEEALSOs           - add/delete See Also references
       Generate CONTENTS record  - generate the CONTENTS record
                                   either by tagging selected TOPICS
                                   or using ALL topics

  OLD_TOPIC(cTopic)
      This sets the current TOPIC for OLD(). For instance, on
      entry into QUERY(), you could call OLD_TOPIC("QUERY BY EXAMPLE").
      Presuming you had a TOPIC defined called "QUERY BY EXAMPLE",
      this is what would come up when OLD() was called or activated
      with a hotkey.

      Call OLD_TOPIC("") to clear the topic. The default topic is
      the CONTENTS page.

  Examples:
  ---------
  For development:
       OLD_DEV({||OLD_MOD()})
       OLD()
  For distribution, simply comment out the OLD_DEV() call.

  For hotkey activation:
      SETKEY(K_WHATEVER,{||OLD()}  )

  When in a particular part of the program:
       OLD_TOPIC("TOPIC NAME...")
  to activate a particulat topic.

  Notes:
  -------
  There's no reason this couldn't be used alongside of the
  traditional Clipper context sensitive 'field level' help.

  Source:
  -------
  S_OLD.PRG

 

 

C5_SETKEY

 SETKEY()
 Assign an action block to a key
------------------------------------------------------------------------------
 Syntax

     SETKEY(<nInkeyCode>, [<bAction>]) --> bCurrentAction

 Arguments

     <nInkeyCode> is the INKEY() value of the key to be associated or
     queried.

     <bAction> specifies a code block that is automatically executed
     whenever the specified key is pressed during a wait state.

 Returns

     SETKEY() returns the action block currently associated with the
     specified key, or NIL if the specified key is not currently associated
     with a block.

 Description

     SETKEY() is a keyboard function that sets or queries the automatic
     action associated with a particular key during a wait state.  A wait
     state is any mode that extracts keys from the keyboard except for
     INKEY(), but including ACHOICE(), DBEDIT(), MEMOEDIT(), ACCEPT, INPUT,
     READ and WAIT.  Up to 32 keys may be assigned at any one time.  At
     startup, the system automatically assigns the F1 key to execute a
     procedure or user-defined function named Help.

     When an assigned key is pressed during a wait state, the EVAL() function
     evaluates the associated <bAction> and the parameters, PROCNAME(),
     PROCLINE(), and READVAR().  It is, however, not necessary to list
     arguments when specifying <bAction> if you do not plan to use them
     within the action block.

     SETKEY() is like the SET KEY command which associates a procedure
     invocation with a key.

 Examples

     .  This code fragment associates an action block with a key, and
        then, after getting a key using INKEY(), executes it with the EVAL()
        function:

        #include "Inkey.ch"
        SETKEY(K_DN, {|cProc, nLine, cVar| MyProc(cProc, ;
                          nLine, cVar)})
        .
        . <statements>
        .
        DO WHILE .T.
           nKey := INKEY(0)
           DO CASE
           CASE (bAction := SETKEY(nKey)) != NIL
              EVAL(bAction, PROCNAME(), PROCLINE(), READVAR())
           CASE nKey = K_PGUP
              Previous()
           CASE nKey = K_PGDN
              Next()
           CASE nKey = K_ESC
              EXIT
           ENDCASE
        ENDDO

 Files   Library is CLIPPER.LIB, header is Inkey.ch.

See Also: SET KEY



Array and GET tricks

Array and GET tricks

C5 Flow Control Commands, Statements and Funtions

Commands :

CALL* :

Execute a C or Assembler procedure

CALL <idProcedure> [WITH <exp list>]

CANCEL* :

Terminate program processing

CANCEL* | QUIT

DO* :

Call a procedure

DO <idProcedure> [WITH <argument list>]

QUIT

Terminate program processing

QUIT | CANCEL*

RUN :

Execute a DOS command or program

RUN | !* <xcCommandLine>

SET KEY :

Assign a procedure invocation to a key

SET KEY <nInkeyCode> TO [<idProcedure>]

SET PROCEDURE *:

Compile procedures/functions into the current .OBJ file

SET PROCEDURE TO [<idProgramFile>[.<ext>]]

WAIT* :

Suspend program processing until a key is pressed

WAIT [<expPrompt>] [TO <idVar>]

Statements :

ANNOUNCE :

Declare a module identifier

ANNOUNCE <idModule>

 BEGIN SEQUENCE :

Define a sequence of statements for a BREAK

BEGIN SEQUENCE
       <statements>...
    [BREAK [<exp>]]
       <statements>...
    [RECOVER [USING <idVar>]]
       <statements>...
END [SEQUENCE]

DO CASE :

Execute one of several alternative blocks of statements

DO CASE
   CASE <lCondition1>
       <statements>...
   [CASE <lCondition2>]
       <statements>...
   [OTHERWISE]
       <statements>...
END[CASE]

DO WHILE :

Execute a loop while a condition is true (.T.)

[DO] WHILE <lCondition>
    <statements>...
    [EXIT]
    <statements>...
    [LOOP]
    <statements>...
END[DO]

EXIT PROCEDURE :

Declare an exit procedure

EXIT PROCEDURE <idProcedure>
    [FIELD <idField list> [IN <idAlias>]]
    [LOCAL <identifier> [[:= <initializer>]]]
    [MEMVAR <identifer list>]
    .
    . <executable statements>
    .
[RETURN]

EXTERNAL* :

Declare a list of procedure or user-defined function names

EXTERNAL <idProcedure list>

FOR :

Execute a block of statements a specified number of times

FOR <idCounter> := <nStart> TO <nEnd> [STEP <nIncrement>]
    <statements>...
    [EXIT]
    <statements>...
    [LOOP]
NEXT

FUNCTION :

Declare a user-defined function name and formal parameters

[STATIC] FUNCTION <idFunction>[(<idParam list>)]
    [LOCAL <identifier> [[:= <initializer>], ... ]]
    [STATIC <identifier> [[:= <initializer>], ... ]]
    [FIELD <identifier list> [IN <idAlias>]]
    [MEMVAR <identifier list>]
    .
    . <executable statements>
    .
RETURN <exp>

IF :

Execute one of several alternative blocks of statements

IF <lCondition1>
    <statements>...
[ELSEIF <lCondition2>]
    <statements>...
[ELSE]
    <statements>...
END[IF]

INIT PROCEDURE :

Declare an initialization procedure

INIT PROCEDURE <idProcedure> [(<idParam list>)]
    [FIELD <idField list> [IN <idAlias>]]
    [LOCAL <identifier> [[:= <initializer>]]]
    [MEMVAR <identifer list>]
    .
    . <executable statements>
    .
[RETURN]

NOTE :

Place a single-line comment in a program file

NOTE This is a comment line

PARAMETERS :

Create private parameter variables

PARAMETERS <idPrivate list>

PROCEDURE :

Declare a procedure name and formal parameters

[STATIC] PROCEDURE <idProcedure> [(<idParam list>)]
    [FIELD <idField list> [IN <idAlias>]
    [LOCAL <identifier> [[:= <initializer>], ... ]]
    [MEMVAR <identifier list>]
    [STATIC <identifier> [[:= <initializer>], ... ]]
    .
    . <executable statements>
    .
[RETURN]

REQUEST :

Declare a module request list

REQUEST <idModule list>

RETURN :

Terminate a procedure, user-defined function or program

RETURN [<exp>]

Functions :

BREAK() :

Branch out of a BEGIN SEQUENCE…END construct

BREAK(<exp>) --> NIL

EVAL() :

Evaluate a code block

EVAL(<bBlock>, [<BlockArg list>]) --> LastBlockValue

IF() :

Return the result of an expression based on a condition

[I]IF(<lCondition>, <expTrue>, <expFalse>) --> Value

PCOUNT() :

Determine the position of the last actual parameter passed

PCOUNT() --> nLastArgumentPos

SETKEY() :

Assign an action block to a key

SETKEY(<nInkeyCode>, [<bAction>]) --> bCurrentAction

SETCANCEL() :

Toggle Alt-C and Ctrl-Break as program termination keys

SETCANCEL([<lToggle>]) --> lCurrentSetting

WORD()* :

Convert CALL command numeric parameters from double to int

WORD(<nNumber>) --> NIL