home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 19 / 019.d81 / t.instr.128 < prev    next >
Encoding:
Text File  |  1986-01-01  |  2.2 KB  |  132 lines

  1.  
  2. **************************************
  3.  
  4.         INSTR for the C-128
  5.  
  6. **************************************
  7.  
  8.  
  9.   INSTR. In-string. This command
  10.  
  11. provides a fast way of searching for
  12.  
  13. one string in another string, and
  14.  
  15. may be considered a function.
  16.  
  17.   For example, in the statement
  18.  
  19. P=INSTR(A$,B$), if B$ is found
  20.  
  21. within A$, then P will equal the
  22.  
  23. number of the position in which B$ is
  24.  
  25. found. If it is not found, then P
  26.  
  27. equals zero.
  28.  
  29.   Let's look at an example:
  30.  
  31.   10 A$="ABCDEFGHIJK"
  32.   20 B$="DEF"
  33.   30 P=INSTR(A$,B$)
  34.   40 PRINT P
  35.  
  36.  
  37.  In this case, P will equal four
  38.  
  39. because B$ was found starting at the
  40.  
  41. fourth posistion of A$.
  42.  
  43.   There is one more thing we can add
  44.  
  45. to the INSTR variable. We can tell it
  46.  
  47. not to start looking until part way
  48.  
  49. through A$. In the example program
  50.  
  51. above, for instance, if we change
  52.  
  53. line 30 to P=INSTR(A$,B$,5), the
  54.  
  55. program will not start looking until
  56.  
  57. it gets to the fifth position, or the
  58.  
  59. letter E. As a result, P will equal
  60.  
  61. zero because the program will not
  62.  
  63. find "DEF."
  64.  
  65.   Some examples of how this function
  66.  
  67. might be used are contained in the
  68.  
  69. programs KEYWORDS.128 and MONTH
  70.  
  71. INPUT.128 on side one of this issue of
  72.  
  73. Loadstar.
  74.  
  75.   KEYWORDS.128 is a small example of
  76.  
  77. keeping track of articles by title
  78.  
  79. and the magazine in which they
  80.  
  81. appeared.  By entering certain key
  82.  
  83. words, such as BOOT or RENUMBER, the
  84.  
  85. program will find articles that have
  86.  
  87. the keywords in their title and the
  88.  
  89. magazine in which they appeared.  For
  90.  
  91. example, if you entered RENUMBER as
  92.  
  93. your keyword, then you might find:
  94.  
  95. BASIC RENUMBER--COMMODORE APR/MAY 1985
  96.  
  97.   MONTH INPUT.128 is another example
  98.  
  99. of the INSTR function.  By inputting
  100.  
  101. a month in the form of JAN, FEB, etc..
  102.  
  103. the computer will tell you the actual
  104.  
  105. number of that month.  For example, if
  106.  
  107. you enter 'NOV', then the computer
  108.  
  109. will respond with 'The number of the
  110.  
  111. month is 11".
  112.  
  113.               ------
  114.  
  115.    This program is copyrighted by
  116.  
  117. PowerPlay magazine.  All rights to it
  118.  
  119. are reserved.  LOADSTAR has relieved
  120.  
  121. you from the burden of keying in this
  122.  
  123.     program.  For more complete
  124.  
  125. information about this program, refer
  126.  
  127. to the January 1986 issue of PowerPlay
  128.  
  129.              Magazine.
  130.  
  131. --------------------------------------
  132.