SP_SBUNSHADOW

SBUNSHADOW()

  Short:
  ------
  SBUNSHADOW() Removes shadow drawn with SBSHADOW()

  Returns:
  --------
  Nil

  Syntax:
  -------
  SBUNSHADOW(aSaved)

  Description:
  ------------
  Removes a shadow around a box created with
  SBSHADOW(). SBSHADOW() returns an array containing the
  coordinates and saved screens for each side of the shadow.
  SBUNSHADOW uses this array to restore the previous screens.

  Examples:
  ---------
   Dispbox(10,10,20,20)
   aSaved := sbshadow(10,10,20,20,3,8)
             // draws a shadow in the lower right
                              // of color gray on black
   sbunshadow(aSaved)         // restore old screen

  Source:
  -------
  S_BOXES.PRG

 

SP_SBSHADOW

SBSHADOW()

  Short:
  ------
  SBSHADOW() Draw a shadow around a box

  Returns:
  --------
  <aSaved> => an array containing the two saved screen
  sections

  Syntax:
  -------
  SBSHADOW(nTop,nLeft,nBottom,nRight,nShadowPos,nShadowAtt)

  Description:
  ------------
  Draws a shadow for box described in coordinates
  <nTop,nLeft,nBotton,nRight>

  The shadow is of color <nShadowAtt> and is at
  position <nShadowPos>, which is one of the following:

      LOWER LEFT    1
      LOWER RIGHT   3
      UPPER LEFT    7
      UPPER RIGHT   9

  Returns an array with the saved screens for each side
  of the shadow.

  This array can be passed to SBUNSHADOW() for
  restoring the previous screen.

  Examples:
  ---------
   Dispbox(10,10,20,20)
   aSaved := sbshadow(10,10,20,20,3,8)
              // draws a shadow in the lower right
              // of color gray on black
   sbunshadow(aSaved)         // restore old screen

  otes

  Source:
  -------
  S_BOXES.PRG

 

SP_SAVESETKEYS

SAVESETKEYS()

  Short:
  ------
  SAVESETKEYS() Saves active set keys to an array

  Returns:
  --------
  <aSaved> => setkey setting saved to an array

  Syntax:
  -------
  SAVESETKEYS([lClear])

  Description:
  ------------
  Saves the inkey codes and codeblocks associated with
  all active setkeys to an array.

  [lClear] If True, clear any active setkeys (set to NIL)

  Examples:
  ---------
   aSaved := SAVESETKEYS(.t.)

   * do stuff

   RESTSETKEYS(aSaved)

  Source:
  -------
  S_SETKEY.PRG

 

SP_RESTSETKEYS

RESTSETKEYS()

  Short:
  ------
  RESTSETKEYS() Restores  set keys saved with SAVESETKEYS()

  Returns:
  --------
  Nil

  Syntax:
  -------
  RESTSETKEYS(aSaved)

  Description:
  ------------
  SAVESETKEYS() saves the inkey codes and codeblocks
  associated with all active setkeys to an array. RESTSETKEYS()
  takes the saved array and restores the setkeys back.

  Examples:
  ---------
   aSaved := SAVESETKEYS(.t.)

   * do stuff

   RESTSETKEYS(aSaved)

  Source:
  -------
  S_SETKEY.PRG

See also : SAVESETKEYS()

 

 

SP_PULLDN

PULLDN()

  Short:
  ------
  PULLDN() Pulldown menu creator, handler

  Returns:
  --------
  <nSelection> => Selection in the form menu.prompt
  (i.e. 2.04)

  Syntax:
  -------
  PULLDN(nSelection,aOptions,[aAttributes],[aColumns])

  Description:
  ------------
  Draws a pulldown menu with up to 8 separate boxes.
  Selection process starts with <nSelection>.

  Each element of <aOptions> defines a menu.

  A menu definition is a delimited string in the form:

        "TITLE:prompt:prompt:prompt"

  with up to 99 prompts per string.

  When a selection is made, the number of the selection
  is returned, in the form BOX.OPTION . So option 2 in box 3 would
  come back as 3.02.

  [aAttributes] is a box definition array. It is 7
  elements long and defines the following:

  Element:          1. <lDraw>      Draw top bar box? T/F
                    2. <cBarColor>  Top bar color
                    3. <cBoxColor>  Menu Box color
                    4. <cBoxFrame>  Menu Box frame
                    5. <nShadowPos> Menu Box shadow position
                               (0,1,3,7,9)
                    6. <nShadowAtt> Menu Box shadow attribute
                    7. <nBarRow>    Row to start menu bar

  [aColumns] is an array of title column positions to
  override the internal 'figerin algorithm.

  Examples:
  ---------
   aOptions := { "Datafiles:Use Datafile",;
                 "Indices:Select Indices:Index order",;
                 "Editing:Replacement:Tabular Edit",;
                 "Reporting:Build Query:Print Lists",;
                 "Other:List file:Change Directory",;
                 "Quit" }

   aAttrib := { .t.,;               // draw the top bar box
                'W/B,GR/R,,,W/N',;  // top bar color
                'W/B,N/R,,,W/N',;   // drop box color
                cSingle_frame,;     // drop box frame
                3,;                 // drop box shadow position
                8,;                 // drop box shadow  attribute
                0 }                 // row # of menu bar

   nSel  := 1.01
   do while .t.
       nSel := PULLDN(nSel,aOptions,aAttrib)
       do case
       CASE nSel = 0  && TRAP 0
           nSel = 1.01
       case nSel = 1
       case nSel = 2
       case nSel = 3
       case nSel = 4
       endcase
   enddo

  Warnings:
  ----------
  It takes some work to start all options and titles
  with a first letter that is unique so that first letter selection may
  take place.

  Notes:
  -------
  First letter selection takes place on the following
  priority: next matching element first letter, next matching box
  title first letter.

  Passing a menu array element with title only will
  result in no menu box, with the title being the only selection
  and returning a selection value of <MENU>.1.
  (i.e. a 'Quit' box)

  Source:
  -------
  S_PULLDN.PRG

 

 

SP_MULTIMSGYN

MULTIMSGYN()

  Short:
  ------
  MULTIMSGYN()          Multi-line popup message - yes -no

  Returns:
  --------
  <lYesNo> => True or False for yes or no

  Syntax:
  -------
  MULTIMSGYN(aMsgs,[cYes,[cNo],[cColor],[cTitle],[lCenter],[nTop,nLeft])

  Description:
  ------------
  Pops up a multi-line message contained in array
  <aMsgs> and prompts for a Yes or No. Returns <lYesNo> based on
  response.

  Each element of the array may be of type CNDL.

  [cYes]  Yes prompt - default is "Yes"

  [cNo]   No prompt - default is "No"

  [cColor]  popup color- default is sls_popcol()

  [cTitle] string to display at box top - default is
  none

  [lCenter]  center the messages in the box (each line
  centered) - default is no - left justified.

  [nTop,nLeft]  popup box top and left. Default is
  centered on the screen.

  Examples:
  ---------
   ?multimsgyn({"Would you really like","to fly?"},"Sure","Nope")
   ?multimsgyn({"Is it ",date()+1,"yet?"},"Sure","Nope",;
         "N/W","There yet")

   ?multimsgyn({"Start with",nStart,"End with",nEnd},;
         nil,nil,,nil,nil,.t.,10,10)

  Source:
  -------
  S_MULMYN.PRG

 

SP_MOUSEHOTAT

MOUSEHOTAT()

  Short:
  ------
  MOUSEHOTAT() Checks for mouse click from array of hot coordinates

  Returns:
  --------
  <nReturn> => either number of element containing hot coordinates, or,
               if element (an array) contains > 4 elements, the value in
               the fifth element.

  Syntax:
  -------
  MOUSEHOTAT(nMouseRow, nMouseCol, aHotSpots)

  Description:
  ------------
  Checks an array of arrays for hot coordinates against <nMouseRow>
  and <nMouseCol> to see if the mouse clicked on one of the hot spots.
  The hot spot array is of the form:
         {  {nTop,nLeft,nBottom,nRight,[nValue] },...}
  Where each subarray is an array containing Top, Left, Bottom, Right
  coordinates for an area of the screen which is mouse hot. If a match
  is gotten and the subarray is four elements long, the number of the
  subarray is returned. If the subarray is 5 elements long, the value
  in the fifth element is returned.

  Examples:
  ---------
  #include "INKEY.CH"
  @10,10 say "<OK>
  @11,10 say "<Cancel>"
  aHotAreas  := {  {10,10,10,13}, {11,10,11,18} }
  nLastKey   := RAT_EVENT(0,.f.,.f.,@nMouseRow, @nMouseCol)
  nHotMouse  := MOUSEHOTAT(nMouseRow, nMouseCol, aHotAreas)
  DO CASE
  CASE nHotMouse==1    // <OK>
  CASE nHotMouse==2    // <Cancel>
  ENDCASE

  // OR ALTERNATELY....Here I'll map the hot areas to the same return
  // values as the hot keys the buttons represent...F10 and ESCAPE
  // this is useful as you'll often have a button or hot area also
  // assigned to a hot key.

  @10,10 say "<F10 Save  >
  @11,10 say "<ESC Cancel>"
  aHotAreas   := {  {10,10,10,21,K_F10}, {11,10,11,21,K_ESC} }
  nLastKey    := RAT_EVENT(0,.f.,.f.,@nMouseRow, @nMouseCol)
  nHotMouse   := MOUSEHOTAT(nMouseRow, nMouseCol, aHotAreas)
  DO CASE
  CASE nHotMouse==K_F10 .or. nLastKey==K_F10    // <F10 Save  >
  CASE nHotMouse==K_ESC .or. nLastKey==K_ESC   // <ESC Cancel>
  ENDCASE

  Source:
  -------
  S_MOOSE.PRG

 

SP_MCHOICE

MCHOICE()

  Short:
  ------
  MCHOICE() Does a boxed, achoice() style popup on an array

  Returns:
  --------
  <expN> Achoice selection

  Syntax:
  -------
  MCHOICE(aOptions,[nTop,nLeft],[nBottom,nRight],[cTitle],[lTrigger],;
                   [nStart],[@nRow],[aSelectable])

  Description:
  ------------
  Provides a box for selection from array <aOptions> of
  character elements.

  [nTop,nLeft] may be specifed to determine the
  starting top and left of the popup box.

  [nBottom,nRight] may be specified to complete the box
  dimensions.

  Default box dimensions are centered on the screen. If the dimensions
  passed are not wide enough to display the mouse hot areas on the
  bottom, the box is widened and centered on the screen.

  [cTitle] is a string to display at the top of the box.

  [lTrigger] determines (yes or no) whether a return is
  to be executed on a first letter match.(default .f.)

  [nStart] optional starting element (default 1)
  [@nRow] optional starting row. Pass by reference to retain value
  between calls.

  [aSelectable] is an array of logicals that determines which items
  are selectable. This array must be the same size as [aOptions], and
  all elements must be either True or False, not NIL. Where an element
  is False, the corresponding element in [aOptions] will be dimmed
  and will emit a BEEP when you attempt to select it.

  Examples:
  ---------
   aMeals   := {"Pizza","Chicken","Chinese"}
   nSelect  := mchoice(aMeals)

   // or box with title
   aMeals   := {"Pizza","Chicken","Chinese"}
   nSelect  := mchoice(aMeals,,,,"Meals")

   // or box with title, first letter match = return and top/left specified
   aMeals   := {"Pizza","Chicken","Chinese"}
   nSelect  := mchoice(aMeals,10,10,,,"Meals",.t.)

   //to retain element and position between calls
   nSelect := 1
   nRow    := 1
   aMeals   := {"Pizza","Chicken","Chinese"}
   while nSelect > 0
     nSelect  := mchoice(aMeals,,,,,"Meals",.t.,nSelect,@nRow)
     // code
   endif

  Notes:
  -------
  Bottom of window adjusts (shrinks) to adjust to array
  size if needed.

  Now uses Tbrowse() instead of ACHOICE().

  Source:
  -------
  S_MCHOI.PRG

 

SP_GENVAL

GENVAL()

  Short:
  ------
  GENVAL() Generic VALID clause validation with message

  Returns:
  --------
  <lValid> => logical result of passed condition

  Syntax:
  -------
  GENVAL(expValid,expMessage)

  Description:
  ------------
  Evaluates <expValid>, which is either a bode block or
  a string to be macro expanded, as a logical value. If result is
  False, displays message <expMessage> and waits for a keypress.
  <expMessage> can be a single string, or an array of strings (see
  aMsg() ).

  Examples:
  ---------
   if genval("fcount() < 60",'Too many fields')
       COPY TO TEMP
   endif

   * ...or as a VALID CLAUSE macro'd

   @10,10 get lname VALID ;
     GENVAL("!empty(lname)","Need a last name")

   * ...or as a VALID CLAUSE eval'd

   @10,10 get fname VALID ;
     GENVAL( { || !empty(fname) },"Need a last name")

  Source:
  -------
  S_GENVA.PRG

 

SP_FORMLETR

FORMLETR()

  Short:
  ------
  FORMLETR() Interactive formletter and mailmerge utility

  Returns:
  --------
  Nothing

  Syntax:
  -------
  FORMLETTER([aNames,aDesc,aTypes];
        [aMoreFuncs,aMoreDesc,aMoreHot])

  Description:
  ------------
  Provides a menu driven interface to the creation,
  modification and merging/printing of form letters with DBFs.

  Three field arrays may be passed - [aNames] is an
  array of allowable field names, [aDesc] is an array of
  field descriptions, and [aTypes] is an array of field types. All
  fields are used as a default, with field names being the default
  field descriptions. Pass all or none of the first three arrays.

  Three additional arrays may be passed for up to 30
  additional hotkeys.

  [aMoreFuncs] is an array of functions which will be
  placed between .. delimiters. [aMoreDesc] is a corresponding
  descriptive array of these functions, to be shown when the user
  presses F1. Format:

       "hotkey     description "
        | column 1 |column 17

  [aMoreHot] is the corresponding hotkeys as their
  numeric ascii values.

  All three arrays must be passed, if any, and all must
  be of same length with no null or undefined elements.

  You could use these for Printer control, special
  combined fields, etc. Be sure the functions you wish to call are
  available to the linker, usually by declaring them EXTERNAL.

  Examples:
  ---------

  USE CUSTOMER

  aFields := {"Fname","lname","mi"}
  aDesc   := {"First","Last","Middle"}
  aTypes  := {"C","C","C"}

  * hotkey arrays
  aMoreFuncs := {"BOLD_ON()","BOLD_OFF"}

  aMoreDesc  := {"F5    BOLD PRINT ON", "F6    BOLD PRINT OFF"}
  aMoreKeys  := {K_F5,K_F6}

  FORMLETR(aFields,aDesc,aTypes,  ;
             aMoreFuncs,aMoreDesc,aMoreKeys)

  //or...

  USE CUSTOMER
  FORMLETR()

  Notes:
  -------
  See index for notes on using a different file name
  for FORM.DBF

  Source:
  -------
  S_FORML.PRG