home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / d / d009_2 / 1.ddi / SAMPLES / GENERAL / MYFUNCS.MS$ / MYFUNCS.bin
Encoding:
Text File  |  1992-02-03  |  2.7 KB  |  85 lines

  1. '******************************* MYFUNCS.MST  *********************************
  2. 'Demonstrates: This file is a small library of custom-built functions.  To use
  3. '              these functions, the calling script must include the MYOWN.INC
  4. '              file.
  5. '
  6. 'Required Files: MYOWN.INC
  7. '
  8. 'Uses:
  9. '
  10. 'Complexity Level: INTERMEDIATE
  11. '
  12. 'Notes: This file should be placed in your MSTest INCLUDE subdirectory. To add
  13. '       your own custom-built function or subroutine, define your function/sub'
  14. '       in this file and don't forget to declare it in MYOWN.INC.
  15. '
  16. '******************************************************************************
  17.  
  18.  
  19. '**********************************************************************
  20. ' FUNCTION BraceSpecCHR$
  21. 'This function encloses in braces 4 special characters, the left/right
  22. 'parenthesis, tilde, and percent symbol.  By enclosing these
  23. 'chars in braces DoKeys & QueKeys are able to display these symbols.
  24. '
  25. 'returns: string with braces around special chars.
  26. '
  27. 'usage: temp$ = BraceSpecCHR(str$)
  28. '**********************************************************************
  29.  
  30. FUNCTION BraceSpecCHR$(strexp$) STATIC
  31.     n% = LEN(strexp$)
  32.     temp$ = ""
  33.  
  34.     FOR i = 1 to n
  35.         index$ = mid$(strexp$,i,1)
  36.         IF (index$="(") OR (index$=")") OR (index$="%") OR (index$="~") THEN
  37.            temp$ = temp$ + "{" + index$ + "}"
  38.         ELSE
  39.            temp$ = temp$ + index$
  40.         END IF
  41.     NEXT i
  42.     BraceSpecCHR = temp$
  43. END FUNCTION
  44.  
  45.  
  46. '**********************************************************************
  47. 'FUNCTION LeftString
  48. 'Takes the first size% characters starting from the left-most char
  49. 'from a given string, strexp$.
  50. '
  51. 'returns: left-most size% characters.
  52. '
  53. 'usage: temp$ = LeftString(str$,n%)
  54. '**********************************************************************
  55.  
  56. FUNCTION LeftString$(strexp$,size%) STATIC
  57.     n% = LEN(strexp$)
  58.     IF (size% <= n%) AND (size% >= 0) THEN
  59.        LeftString = mid$(strexp$,1,size%)
  60.     ELSE
  61.        LeftString = strexp$
  62.     END IF
  63. END FUNCTION
  64.  
  65.  
  66. '**********************************************************************
  67. 'FUNCTION  RightString
  68. 'Takes size% right-most characters from a given string, strexp$.
  69. '
  70. 'returns: right-most size% characters.
  71. '
  72. 'usage: temp$ = RightString(str$,n%)
  73. '**********************************************************************
  74.  
  75. FUNCTION RightString$(strexp$,size%) STATIC
  76.     n% = LEN(strexp$)
  77.     IF (size% <= n%) AND (size% >= 0) THEN
  78.        diff% = n% - size% + 1
  79.        RightString = mid$(strexp$,diff%,size%)   'size% not necessary here
  80.     ELSE                                         'put in for consistency.
  81.        RightString = strexp$
  82.     END IF
  83. END FUNCTION
  84.  
  85.