home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / tutor / l7p010 < prev    next >
Text File  |  1990-07-15  |  4KB  |  87 lines

  1.  
  2.        ╔══════════════════════════════════════════════════════╗
  3.        ║  Lesson 7 Part 010  F-PC 3.5 Tutorial by Jack Brown  ║
  4.        ╚══════════════════════════════════════════════════════╝
  5.  
  6.          ┌───────────────────────────────────────────────────┐
  7.          │ In Lesson 7 we will look at the following topics: │
  8.          └───────────────────────────────────────────────────┘
  9.  
  10.          0) Review of Lesson 6
  11.          1) Vocabularies.
  12.          2) Deferred Execution
  13.          3) Compiler Extension with CREATE ... DOES>
  14.          4) Recursion
  15.  
  16.                   ┌──────────────────────┐
  17.                   │   String Operators   │
  18.                   └──────────────────────┘
  19.  
  20. ," {text}"  ( -- )     Compile string into array, use after CREATE
  21.                        USE OUTSIDE DEFINITION ONLY!!!
  22.  
  23. COUNT ( addr -- addr+1 n)    n is byte or count stored at addr.
  24. TYPE  ( addr n -- )          Type n characters of string at addr.
  25.  
  26.  " {text}" ( -- addr count ) Compile string into colon definition.
  27.                              ONLY USE WITHIN A COLON DEFINITION!
  28. ." {text}" ( -- )            Compile display string into : definition.
  29.  
  30.  
  31. FILL   ( addr n c -- )  Fill string at addr with n copies of c .
  32. ERASE  ( addr n -- )    Fill string at addr with n null's or 0's.
  33. EXPECT ( addr n -- )    Input up to n characters to buffer at addr
  34.  
  35.  
  36. CMOVE        ( addr-from addr-to n -- )
  37. "c-move"     Move n bytes from memory at addr-from to memory at addr-to.
  38.              Left-most or low memory bytes are moved first. ( ie  Move
  39.              starts at beginning of string.)
  40.  
  41. CMOVE>       ( addr-from addr-to n -- )
  42. "c-move-up"  Move n bytes from addr-from to addr-to. Right-most or high
  43.              memory bytes are moved first. ( ie Move starts at end or
  44.              top of string.)
  45.  
  46. MOVE         ( addr-from addr-to n -- )
  47. "move"       Forth's smart MOVE which checks for the overlapping case
  48.              and makes the correct application of CMOVE or CMOVE>
  49.  
  50. CPACK        ( addr-from addr-to n -- )
  51. "c-pack"     Convert uncounted string at addr-from to packed string
  52.              format and store at addr-to.
  53.  
  54. : /STRING      ( addr len n -- addr' len' )
  55. "slash-string" Slash n characters from the beginning of a string
  56.                addr'= addr+n  and  len'= len-n
  57.  
  58. -TRAILING      ( addr count1 -- addr count2 )
  59. "dash-trailing"  Remove trailing blanks from a string.
  60.  
  61. SKIP    ( addr len char -- addr' len' )
  62. Given the address and length of a string, and a character to look for,
  63. run through the string while we continue to find the character.  Leave
  64. the address of the *mismatch* and the length of the remaining string.
  65.  
  66. SCAN    ( addr len char -- addr' len' )
  67. Given the address and length of a string, and a character to look for,
  68. run through the string until we find the character.  Leave the address
  69. of the *match* and the length of the remaining string.
  70.  
  71. CONVERT  ( ud1 addr1 -- ud2 addr2 )
  72. Convert a counted string starting at addr1 or an uncounted string
  73. starting at addr1+1 accumulating number into ud1. Conversion stops at
  74. first non digit character whose location, addr2, is left on the stack.
  75. addr1 is usually the address of a counted or packed digit string.  The
  76. first digit of the string to be converted will be at addr1+1 . ud2 is
  77. ud1 with the addition of the accumulated digits. The character count or
  78. digit that may be at addr1 is not used by CONVERT.  Examples:
  79.  
  80. NUMBER ( addr -- dn )
  81. Convert the packed string delimited by a blank at addr into a double
  82. number dn.
  83.  
  84. ┌────────────────────────────────────┐
  85. │  Please Move to Lesson 7 Part 020  │
  86. └────────────────────────────────────┘
  87.