home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / lispops < prev    next >
Text File  |  2020-01-01  |  2KB  |  96 lines

  1. ; From: Dat Thuc Nguyen
  2. ; Newsgroups: comp.protocols.kermit.misc
  3. ; Subject: LISP-Like Operations in Kermit
  4. ; Date: Wed, 24 May 2000 23:18:01 EDT
  5. ; URL: http://www.smalltickle.com
  6. ; SIMPLE MATH
  7. ;
  8. ; The following macros mimic LISP syntax for some basic math operations
  9. ; in C-Kermit.  They save typing and make code readable a`la LISP.
  10. ;
  11. ; Usage Examples:
  12. ;
  13. ; C-Kermit> = VAR1 0            ; define VAR1 and assign it the value 0
  14. ; C-Kermit> += VAR1 3           ; equivalent VAR1 += 3 in C
  15. ; C-Kermit> = VAR2 4            ; define VAR2 and assign it the value 4
  16. ; C-Kermit> -= VAR2 2           ; equivalent VAR2 -= 2 in C
  17. ; C-Kermit> *= VAR1 VAR2        ; equivalent VAR1 *= VAR2 in C
  18. ; C-Kermit> /= VAR1 2           ; equivalent VAR1 /= 2 in C
  19. ; C-Kermit> * VAR1 9            ; equivalent VAR1 * 9 in C
  20. ; C-Kermit> / VAR1 VAR2         ; equivalent VAR1 / VAR2 in C
  21.  
  22. def - {
  23.         local \%t
  24.         if numeric \%2 assign \%t \%2
  25.         else assign \%t \m(\%2)
  26.         eval \%t \m(\%1) - \%t
  27.         echo \%t
  28. }
  29.  
  30. def + {
  31.         local \%t
  32.         if numeric \%2 assign \%t \%2
  33.         else assign \%t \m(\%2)
  34.         eval \%t \m(\%1) + \%t
  35.         echo \%t
  36. }
  37.  
  38. def = {
  39.         local \%t
  40.         if numeric \%2 assign \%t \%2
  41.         else assign \%t \m(\%2)
  42.         _assign \%1 \%t
  43.         echo \m(\%1)
  44. }
  45.  
  46. def += {
  47.         local \%t
  48.         if numeric \%2 assign \%t \%2
  49.         else assign \%t \m(\%2)
  50.         _eval \%1 \m(\%1) + \%t
  51.         echo \m(\%1)
  52. }
  53.  
  54. def -= {
  55.         local \%t
  56.         if numeric \%2 assign \%t \%2
  57.         else assign \%t \m(\%2)
  58.         _eval \%1 \m(\%1) - \%t
  59.         echo \m(\%1)
  60. }
  61.  
  62. def *= {
  63.         local \%t
  64.         if numeric \%2 assign \%t \%2
  65.         else assign \%t \m(\%2)
  66.         _eval \%1 \m(\%1) * \%t
  67.         echo \m(\%1)
  68. }
  69.  
  70. def /= {
  71.         local \%t
  72.         if numeric \%2 assign \%t \%2
  73.         else assign \%t \m(\%2)
  74.         _eval \%1 \m(\%1) / \%t
  75.         echo \m(\%1)
  76. }
  77.  
  78. def * {
  79.         local \%t
  80.         if numeric \%2 assign \%t \%2
  81.         else assign \%t \m(\%2)
  82.         eval \%t \m(\%1) * \%t
  83.         echo \%t
  84. }
  85.  
  86. def / {
  87.         local \%t
  88.         if numeric \%2 assign \%t \%2
  89.         else assign \%t \m(\%2)
  90.         _eval \%1 \m(\%1) / \%t
  91.         echo \%t
  92. }
  93.  
  94. ; End
  95.