Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Grumpfish Library 3.2 - <b>popnote()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
POPNOTE()

    This notepad lets you do everything that MEMOEDIT() offers, along
    with text block commands (move/copy/delete), cut-and-paste from
    the underlying screen, and the ability to create do merge mailings
    by inserting fieldnames into your documents.

    Active Keys

    Alt-A  (A)ppend a file to current file
    Alt-B  Place block marker (or execute block command if both block
           markers have already been placed)
    Alt-F  insert (F)ield (for merge mailings)
    Alt-G  (G)oto line number
    Alt-H  (H)elp screen listing all commands
    Alt-I  (I)nsert buffer  (new for Version 3.0)
    Alt-K  (K)ut and Paste  (new for Version 3.0)
    Alt-L  page (L)ength for printing
    Alt-M  change (M)argins
    Alt-N  edit (N)ew file
    Alt-P  (P)rint file
    Alt-Q  (Q)uit but save edits
    Alt-R  search and (R)eplace
    Alt-S  (S)ave file & continue
    Alt-T  (T)oggle wordwrap on/off
    Alt-V  (V)iew buffer  (new for Version 3.0)
    Alt-W  (W)rite to new file
    Alt-X  e(X)it immediately without saving
    Alt-Y  change director(Y)/wildcard

    Edit Window/Status Line

    When you enter the notepad, the edit window takes up nearly the full
    screen.  You will be prompted to enter the name of the file you wish
    to edit.  (This may be circumvented by declaring a variable
    NOTEFILE; please see the discussion below under "Files".)

    There is a status line at the bottom of the screen, which displays
    the name of the file being edited (minus the directory), the current
    line and column position of the cursor, the left and right margins,
    and the status of wordwrap and insert modes (displayed when active
    as "<Wrap>" and "<Ins>    respectively).  When a file has been
    edited, an asterisk will appear at the right side of the top row
    next to the "Alt-H=Help" message.

    Current Directory/Wildcard

    The notepad gives you the ability to change the working directory
    and/or filemask at any time.  When you first enter the notepad, the
    current directory will be set to the default DOS directory, and the
    wildcard will be set to '*.*'.  If you would like to change either
    the directory where the notepad looks for files or the wildcard used
    (e.g., "*.TXT    "*.PRG"), press Alt-Y and enter the new information.
    You do not have to enter slashes in front or back of the directory
    name UNLESS you include a wildcard.  For example, to change the
    current directory to "\GRUMP\    you need only enter "GRUMP".
    However, if you want the notepad to look for all the .PRG files in
    subdirectory GRUMP, you must enter "\GRUMP\*.PRG".

    If you enter just the wildcard, the current directory will remain
    unchanged.  If you enter a directory name only, the wildcard will be
    reset to "*.*".  If you press Enter without typing in anything,
    neither the current directory nor the wildcard will be changed.

    Examples: let's assume that your application is in a subdirectory
    named \WORKSTUF.  The initial current directory/wildcard will be set
    to "\WORKSTUF\*.*".  If you press Alt-Y and enter "*.PRG <CR>", the
    directory/wildcard will be changed to "\WORKSTUF\*.PRG".  If you
    wish to change to the \GRUMP subdirectory, press Alt-Y and enter
    "GRUMP <CR>".  The directory/wildcard will then be changed to
    "\GRUMP\*.*". Suppose you then want to look at only the .PRG files
    starting with the letter P in the directory \WORKSTUF\DEVEL. You
    would press Alt-Y again, and type in "\WORKSTUF\DEVEL\P*.PRG".

    To retain the current directory and wildcard, you may declare PUBLIC
    variables CURR_DIR and WILDCARD before calling the notepad. This
    feature allows you to exit the notepad, and return later without
    having to reset the directory and wildcard.  You may also wish to
    initialize these variables to suit your specific needs (see the
    example below).

    Files - Changing, New, Default

    When you press Alt-N to edit a new file or Alt-W to write to another
    file, a scrolling window will appear containing all files that match
    the current directory and wildcard mask. The directory and wildcard
    mask will be shown at the top of this window for reference.  Note
    that files with the following extensions will not appear in this
    directory, based on the assumption that there should be no need to
    edit binary files: .EXE, .COM, .DBF, .NTX, .DBT, .NDX, .OBJ.  If you
    wish to strip out other types of files, you can easily modify the
    line of source code that contains these extensions.

    To select a file, move the highlight bar to it and press Enter.

    To create a new file, select the option 'NEW FILE', then enter the
    filename.  Pressing Esc will abort the file selection process.

    If you attempt to write to a file that already exists, or append
    from a file that does not exist, you will get a non-fatal error
    message to that effect.

    To retain the working filename, declare a PUBLIC variable named
    NOTEFILE before calling the notepad.  This feature allows you to
    edit a file, exit the notepad, and return to the notepad later to
    find the same file waiting for you.  You may also wish to initialize
    this variable to the name of the default file for editing (the
    internal default is "TEMPFILE").

    Alt-B: Block Commands

    Blocks of text may be deleted, copied, moved, printed, or case
    converted. You must first mark a block by pressing Alt-B at the
    beginning, and again at the end of the block.  If you wish to move
    or copy this text block, move to the target location. Then press
    Alt-B again to get a pop-up menu of block commands ("Move", "Copy",
    "Kill", "Print", "Uppercase", "Lowercase", "Erase Markers"). Select
    one by highlighting it and pressing Enter.

    Alt-F: Field Insertion for Merge Mailings

    You can easily insert fields from any or all open databases into
    your documents to create merge mailings.  Note that this feature
    will only be available if a database is open when the notepad is
    called.

    First, move the cursor to the location where you wish to insert the
    field.  Then press Alt-F to display a window containing all
    available fieldnames (along with the corresponding database or alias
    names).  Move the highlight bar to the desired field name and press
    Enter to insert it, or press Esc to exit without inserting a field.

    Notice that the alias and fieldname are surrounded by curly braces
    ("{" and "}").  When the document is printed, anything that is
    surrounded by curly braces will be replaced by the actual contents
    of the appropriate field.  However, you can also embed function
    names within the curly braces.  For example, if you wanted to make
    sure that a field NAME was printed in upper-case, you could modify
    "{NAME}" to read "{UPPER(NAME)}".  As you will discover, this will
    open up many avenues of customization.  If you decide to insert
    function names such as this, you should be sure that the function(s)
    called has been linked into your program.  But have no fear; if an
    undefined function or expression is inserted, rather than crashing
    your program when you try to print, the notepad will merely replace
    that expression with a null string.

    Important Note Regarding Work Areas: if you have more than one
    database open and wish to have fields from all databases available,
    they must be opened in sequential work area order (e.g., 1, 2, 3,
    4... as opposed to 1, 4, 5, 6...).  If there are any breaks in
    sequence, fields from all databases beyond the break will NOT be
    available.  Here are two examples to better illustrate this:

    Work Area      Alias        Fields
        1          CUSTOMER       28
        2          PAYMENTS        8
        3          INVOICES       14
        4          CREDIT          6

    Available fields: 56 (all)

        1          CUSTOMER       28
        2          PAYMENTS        8
        5          INVOICES       14
        8          CREDIT          6

    Available fields: 36 (only from CUSTOMER and PAYMENTS)

    One Other Important Note: if you are inserting fields from more than
    one database, you will be responsible for making sure that the
    necessary relations are established.  The notepad will do absolutely
    no checking of relations!

    Insert/Wordwrap

    The start-up values for these modes is on. They may toggled off and
    on at any time by pressing Insert and Alt-W, respectively. The
    status of these modes appears at the right side of the status line.
    Also, the cursor size will change from large (insert) to small
    (overwrite) based on the current mode, just like a <I>real word
    processor.

    Alt-K: Kut and Paste

    You may cut and paste portions of the underlying screen into the
    paste buffer, which can then be inserted into your document.  Press
    Alt-K to restore the underlying screen.  Use the arrow keys to place
    the cursor at the beginning of the block to be marked.  Then press
    Enter to begin highlighting the block.  Move the arrow keys to
    highlight the desired block and press Enter once again when you are
    finished.  This block will then be loaded into the paste buffer for
    future insertion with Alt-I.

    If you begin to highlight an area and then change your mind, you can
    press Esc to exit without changing the contents of the paste buffer.

    You may also insert the contents of the paste buffer elsewhere in
    your application by adding two lines of code in your main program to
    set up a hot key procedure.  The following example sets the
    Ctrl-Gray Plus key to serve as the hot key to paste the buffer
    anywhere in the program.

    SET KEY 400 TO pastebuff && Ctrl-Plus
    PUBLIC pastebuff                     

    Note that not all keyboards will have this INKEY() value.  If you
    would like to use a different key for the hot key, please refer to
    your Clipper manual for a list of INKEY() values.

    Alt-I: Insert Buffer

    This option allows you to insert the contents of the paste buffer
    into your document at the current cursor location.  The paste buffer
    will contain either the result of a kut-and-paste (Alt-K) operation,
    or a text block (Alt-B).  If you want to see what is in the buffer
    before you insert it, press Alt-V to view it.

    Alt-L: Page Length

    The start-up page length for printing is 60 lines.  You can change
    this at any time by pressing Alt-L.

    Alt-M: Margins

    The start-up margins are 1 and 80.  However, you may change these
    margins at any time by pressing Alt-M and entering the desired
    values.  When you change the margins, the on-screen display will
    adjust to reflect the new margins.  You may use larger values for
    the right margin than would appear on the 80-column screen.  In such
    instances, you should toggle wordwrap off and scroll to the right to
    display text beyond the on-screen right margin.  The current values
    of the margins appear on the status line.

    Alt-P: Printing

    You may print the current file at any time by pressing Alt-P.
    Printing may be aborted at any time by pressing Esc.  The format of
    the printed page is determined by the current settings of the
    margins and page length.

    Merge Mailings

    If you have inserted fields in this document and wish to print a
    merge mailing for more than one record in your database, you can
    make one quick and easy modification to allow your users to select
    which records in the database should be processed.  This will be
    made possible through the magic of SETFILT, the Grumpfish
    interactive query builder.

    As shipped, POPNOTE() will only print for the current record, the
    reason being that I did not want to force you to link in the
    interactive query builder (and thus incur its additional overhead)
    unless you wanted it.

    If you are using the Summer '87 version, uncomment the block of code
    at approximately lines 292-298 of POPNOTE.PRG and recompile it.

    If you are using the Clipper 5.0 version, all you need to do is
    compile POPNOTE.PRG with the following syntax:

    CLIPPER POPNOTE /N/W/A/DMAILMERGE

    This defines a symbol MAILMERGE for the preprocessor, which will
    cause the block of code at line 273 to be compiled.

    Alt-R: Search and Replace

    You can search and replace for all or for only a specific number of
    occurrences of a character string. When you press Alt-R, you will be
    prompted first to enter the search string, then the replacement
    string.  You will then be asked if you want to replace all
    occurrences of the search string.  If you answer 'N', you will be
    prompted to enter the number of occurrences to replace. Please note
    that the search begins at the top of the file and continues either
    to the end of the file or until the specified number of occurrences
    have been replaced.

    Alt-V: View Buffer

    Use this option if you want to view the contents of the paste
    buffer. This will show you what will be inserted into your document
    if you press Alt-I.

    Printer Set-up String

    You may send a set-up string to the printer by defining a character
    variable named SETUP_STR before calling the notepad. Similarly, you
    may send a reset escape sequence after printing is complete by
    defining a character variabled named RESET_STR.  You may also
    specify that a header be printed at the top of each page by
    declaring a public variable NOTEHEAD before calling the notepad.
    This one-line header will contain the filename (left-justified), the
    system date (centered), and the page number (right-justified). See
    below for examples of how to use these features.

    File Size Limitations

    Although theoretically you could load and edit files up to 64K
    (which is the internal MEMOEDIT() limitation), it is certainly
    possible to run out of memory when loading a file much smaller than
    that.  As a rule of thumb, you must at least twice the size of the
    file to be edited available in RAM; for example, to edit a 20K file,
    there should be 40K available.  "Why not just check the available
    memory with the MEMORY(0) function?" you ask.  Unfortunately I have
    already attempted that, with inconsistent results, and Nantucket
    technical support has confirmed that MEMORY(0) does not always
    return an accurate value.  But it should also be pointed out that
    this notepad was never meant for editing large files, nor did I
    intend for you to write the Great American Novel with it.

    Using the Notepad in your programs

    As with the other pop-ups, there are two ways to utilize the
    notepad. The first and best is to use SET KEY to establish a hot-key
    so that the user can pop up the notepad from anywhere within the
    program. The following lines added at the top of your program
    configures the F4 key to serve as the hot key for the notepad.

    EXTERNAL popnote  && make symbol for linker
    notekey = -3      && hot key: F4           
    SET KEY notekey TO popnote                 

    The following example goes several steps further by establishing the
    necessary variables to:
    (a) activate header printing (NOTEHEAD);
    (b) send a set-up string before printing (SETUP_STR);
    (c) send a reset sequence after printing is complete (RESET_STR);
    (d) retain the working filename, current directory, and wildcard
        upon exiting the notepad (NOTEFILE, CURR_DIR, WILDCARD).

    Our mythical user will only need to edit files with the .TXT
    extension, so WILDCARD is set to '*.TXT'.  CHR(15) is a common
    escape sequence used to activate compressed (reduced) print, and the
    CHR(18) sequence is commonly used to de-activate compressed print,
    so these are used in the example.

    EXTERNAL popnote   && make symbol for linker                       
    PUBLIC notehead, notefile, curr_dir, wildcard, setup_str, reset_str
    setup_str = chr(15)                                                
    reset_str = chr(18)                                                
    wildcard = '*.TXT'                                                 
    notekey = -3   && hot key: F4                                      
    SET KEY notekey TO popnote                                         

    If you want to use a different hot key for the notepad, please refer
    to your Clipper manual for a list of INKEY() values.

    The second method would be to call the notepad directly.  Please
    refer to the Calculator section above for a sample menu. However, I
    once again strongly recommend using SET KEY for maximum flexibility.

    Clipper 5.0 Notes

    - All PUBLIC variables have been eliminated.
    - You can use the paste feature without having to declare PASTEBUFF as
      PUBLIC in your calling routine.
    - The name of the last edited file will be stored without you having
      to declare NOTEFILE as PUBLIC.
    - When you press Alt-N to select a new file, the pop-up file directory
      is more thorough, and now includes filename, date, time, and size.
      Most types of binary files, and all files larger than 64K, will be
      stripped out of the directory.  You may also search for a file by
      typing in the first few letters of the filename.
    - It is no longer necessary to declare the variable NOTEKEY when
      assigning a hot key.
    - It is no longer necessary to declare POPNOTE as EXTERNAL, because
      SET KEY will automatically establish a symbol for the function.

See Also: POPCALC() SETFILT GINKEY()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson