home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Editor / DVD!FX17.LHA / FrexxEd / fpl / NumericArgument.FPL.README < prev    next >
Encoding:
Text File  |  1995-02-25  |  4.4 KB  |  116 lines

  1. #############################################################################
  2. File:                NumericArgument
  3. Author:                Jesper Skov
  4. Email:                jskov@iesd.auc.dk
  5. Short:                Repeats or calls a function with argument
  6. Version:            1.0
  7. Date:                25.02.95
  8. Local settings:
  9. Global settings:    (__NumArg FPL variable)
  10. Keysequence:        Control u (C-u)
  11. Type:                function/key
  12. Prereq:
  13. Copyright:            © 1995, Jesper Skov
  14.                     Use/distribute according to the terms of GNU GPL.
  15.                     (See the file 'COPYING.GNU' for more info!)
  16. #############################################################################
  17.  
  18. FUNCTION
  19.   **** WARNING ****
  20.   You may create havoc with this function. Try using the function on trash
  21.   data BEFORE installing it in your USER.FPL file... I mean, some things
  22.   like »C-u (open file)« is cute - open four files.... BUT, how about
  23.   »C-u C-u <OOPS>« - that equals 16 times Murphy! Read this document
  24.   carefully. The author takes NO responsbility for trashed
  25.   <insert appropriate>!!!!!!
  26.   **** WARNING ****
  27.  
  28.   With this function you can get the function assigned to a key repeated a
  29.   number of times, or call it once with an numeric argument. If you do not
  30.   know Emacs you may find this concept a bit weird, but it does come in handy 
  31.   from time to time :)
  32.   There is two types of operation, both started in the same way... It is 
  33.   quite tricky to explain, so please bear with me! OK? Here goes:
  34.  
  35.     1) C-u (invoke this function)
  36.        At this point the default argument is set to four (4).
  37.  
  38.     2) C-u is pressed 0, 1 or more times again, followed by a non-number key
  39.        (i.e. not keys 0-9). Each time the C-u is pressed, the argument is 
  40.        multiplied with four. When a new key (non-number) is pressed, operation
  41.        is continued in state 4. IF a number key IS pressed, we go to state 3!
  42.  
  43.     3) Here you may enter a specific number, using the keys 0..9! On C-u, 
  44.        argument input is stopped, and the next key you press will be used in 
  45.        state 4. This allows you to repeat number keys as well! (And C-u... Be
  46.        careful!)
  47.  
  48.     4) In this state a choice is made. The last key pressed has to be either 
  49.        repeated OR called with the argument. The routine decides by examining 
  50.        the execute string assigned to the key. If it contains the variable
  51.        __NumArg, the string is executed ONCE, with the argument in the 
  52.        __NumArg variable (more about this below). Otherwise the string is 
  53.        executed (arg) times.
  54.  
  55.   In general: The status line reflect the current numeric argument.
  56.               __NumArg will be 0 (NULL) outside of argument executions.
  57.               You may break operation at any time with Control g - EXCEPT if
  58.                you have a function on C-g!!!!! Be careful!
  59.  
  60.   Some examples (of usage... Se below for programming examples):
  61.     C-u bs                : Backspaces four times
  62.     C-u 12 TAB            : Inserts 12 tabs
  63.     C-u 12 C-u 2        : Inserts the letter 2, 12 times (222222222222)
  64.     C-u C-u C-u    1 a        : Inserts one a
  65.     C-u C-u C-u C-u a    : Inserts 128 a's!!!!!!! Be carefull with many C-u's!!
  66.  
  67.  
  68.   Constructing functions which takes input:
  69.  
  70.   Now, if you want a "key function" to rely on this numeric argument form,
  71.   simply let it include the variable. E.g.:
  72.  
  73.   AssignKey("CursorDown(__NumArg);", "control a");
  74.  
  75.   * This will move the cursor 4 steps down on »C-u C-a«. If there is no 
  76.     argument (C-a) the cursor will not move. »C-u C-u C-u C-u C-u C-u C-u
  77.     C-u C-a« would bring the cursor to the bottom of the buffer in most of 
  78.     the programs you're able to write in a week or two (or so I reckon. Could 
  79.     be that I'm just too lazy.... Who knows =)
  80.  
  81.  
  82.   But remeber that only the key's execute string is checked! If you use the 
  83.   __NumArg variable in your routine (without sending it as an argument) you
  84.   could do this:
  85.  
  86.   void export myFunc(){...};
  87.   ...
  88.   AssignKey("myFunc();/*__NumArg*/", "control a");
  89.  
  90.   A specific use of this would probably be a routine which takes EITHER a 
  91.   numeric argument OR does some fetching itself. Example:
  92.  
  93.   SetWallRight(){ // if no "argument", check the current cursor position.
  94.   if (!(localArg=__NumArg)){
  95.     localArg = ReadInfo("column");}
  96.   <make use of localArg>}
  97.   AssignKey("SetWallRight();/*__NumArg*/", "control a");
  98.  
  99.   This way a /*__NumArg*/ may be read as an optional numeric argument.
  100.  
  101.   Do note that you should *never* assign values to __NumArg yourself!!!
  102.  
  103.  
  104.  
  105. HISTORY (REV)
  106.   25.02.95 (0) Working...
  107.  
  108. BUGS
  109.   Not as far as I know!
  110.  
  111. TODO
  112.  
  113. SEE ALSO
  114.   Ole L. Madsen+'s "Object-Oriented Programming in the Beta P.L." (ISBN:0-201-62430-3)
  115.   (There's a freak language for ya! =)
  116.