home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TJOCKREF.ZIP / STRNGTTT.TXT < prev    next >
Encoding:
Text File  |  1988-08-26  |  14.5 KB  |  652 lines

  1. !SHORT:ExtractWords      Extract a specified number of worrds from string
  2. ExtractWords                                                  StrngTTT
  3.           
  4.  
  5.  
  6. Purpose   To extract a number specified number of words from a string.
  7.  
  8. Returns   string;
  9.  
  10. Declaration    ExtractWords(S,N: byte; Str: string):string;
  11.                     
  12.           S is number of the first word to extract
  13.           N is the number of words to extract
  14.           Str is the string to extract from
  15.  
  16. Uses StrngTTT.
  17.  
  18. Remarks   If there are insufficient words to extract, the function
  19.           will return as many words as possible.
  20.                     
  21.           If there are fewer than S words in the string, the function
  22.           returns a null string, i.e. ''.
  23.  
  24. Example
  25.  
  26.  
  27.                USES STRNGTTT;
  28.                VAR LASTBIT : STRING;
  29.                BEGIN
  30.                  LASTBIT := EXTRACTWORDS(4,3,'WHO THE HELL SAYS
  31.                  CENSORSHIP IS GOOD!');
  32.                END.
  33.           
  34.  
  35. The string LastBit is assigned the value 'Censorship is good!'.
  36.  
  37.           
  38.  
  39.  
  40.  
  41.  
  42.  
  43. !SHORT:First             Return first part of string
  44. First                                                         StrngTTT
  45.      
  46.  
  47.  
  48. Purpose   To return the first part of a string.
  49.  
  50. Returns   string;
  51.  
  52. Declaration    First(N: byte; Str: string):string;
  53.                
  54.           N is the number of characters to extract.
  55.           Str is the string to extract them from
  56.  
  57. Uses StrngTTT.
  58.  
  59.  
  60.  
  61. Remarks   If the source string is fewer than N characters long, the
  62.           whole string is returned.
  63.  
  64. Example
  65.  
  66.  
  67.                USES STRNGTTT;
  68.                VAR TTT : STRING;
  69.                BEGIN
  70.                  TTT := FIRST(25,'ALL GOOD THINGS WILL COME TO PASS!');
  71.                END.
  72.      
  73.  
  74. The string TTT is assigned the value "All good things will come".
  75.  
  76. !SEEALSO:Last
  77.              
  78.  
  79. !SHORT:Int_to_Str        Convert integer to string
  80. Int_to_Str                                                    StrngTTT
  81.           
  82.  
  83.  
  84. Purpose   To convert an integer to a string.
  85.  
  86. Returns   string;
  87.  
  88. Declaration    Int_to_Str(Number: longInt):string;
  89.                     
  90.           Number can actually be byte, integer or longint
  91.  
  92. Uses StrngTTT.
  93.  
  94.  
  95.  
  96. Example
  97.  
  98.  
  99.                USES STRNGTTT;
  100.                VAR TTT : STRING;
  101.                BEGIN
  102.                  TTT := INT_TO_STR(130);
  103.                END.
  104.           
  105.  
  106. The value of TTT is set to '130'.
  107.  
  108. !SEEALSO:Real_to_Str Str_to_Int
  109.  
  110.                                
  111. !SHORT:Last              Return last part of string
  112. Last                                                          StrngTTT
  113.      
  114.  
  115.  
  116. Purpose   To return the last part of a string.
  117.  
  118. Returns   string
  119.  
  120. Declaration    Last(N: byte; Str: string):string;
  121.                
  122.           N is the number of characters to extract.
  123.           Str is the string to extract them from
  124.  
  125. Uses StrngTTT.
  126.  
  127.  
  128.  
  129. Remarks   If the source string is fewer than N characters long, the
  130.           whole string is returned.
  131.  
  132. Example
  133.  
  134.  
  135.                USES STRNGTTT;
  136.                VAR TTT : STRING;
  137.                BEGIN
  138.                  TTT := LAST(11,'NEVER TAKE DRUGS!');
  139.                END.
  140.      
  141.  
  142. The string TTT is assigned the value "Take Drugs!".
  143.  
  144. !SEEALSO:First
  145.  
  146. !SHORT:LastPos           Find last occurence of character in string
  147. LastPos                                                       StrngTTT
  148.           
  149.  
  150.  
  151. Purpose   To find the last occurence of a character in a string.
  152.  
  153. Returns   byte;
  154.  
  155. Declaration    LastPos(C:char; Str:string):byte;
  156.                     
  157.           C is the character to search for.
  158.           Str is the string to search
  159.  
  160. Uses StrngTTT.
  161.  
  162.  
  163. Remarks   If the character is not found in the string, the function
  164.           returns 0.
  165.                     
  166.           The search is case sensitive.
  167.  
  168.           Also note "pos" Turbo internal Function
  169. Example
  170.  
  171.  
  172.                USES STRNGTTT;
  173.                VAR B : BYTE;
  174.                BEGIN
  175.                  B := LASTPOS('J','TECHNOJOCK SOFTWARE!');
  176.                END.
  177.           
  178.  
  179. The variable B is assigned the value 12
  180.  
  181.           
  182.  
  183.  
  184. !SHORT:Lower             Convert string to lower case
  185. Lower                                                         StrngTTT
  186.      
  187.  
  188.  
  189. Purpose   To convert a string to lower case letters.
  190.  
  191. Returns   String;
  192.  
  193. Declaration    Lower(Str:string):string;
  194.                
  195.           Str is the string to be converted
  196.  
  197. Uses StrngTTT.
  198.  
  199.  
  200.  
  201. Remarks   Only the upper case alphabet (A..Z) is affected.
  202.  
  203. Example
  204.  
  205.  
  206.                USES STRNGTTT;
  207.                VAR TTT : STRING;
  208.                BEGIN
  209.                  TTT := LOWER('LEARNING TO TYPE');
  210.                END.
  211.      
  212.  
  213. The string TTT is assigned the value "learning to type".
  214.  
  215. !SEEALSO:Upper  Proper
  216.  
  217.  
  218. !SHORT:OverType          Combine two overlapping strings
  219. OverType                                                      StrngTTT
  220.           
  221.  
  222.  
  223. Purpose   To combine two overlapping strings.
  224.  
  225. Returns   string;
  226.  
  227. Declaration    OverType(N:byte; StrS,StrT:string):string;
  228.                     
  229.           N is the character position that the StrT (target) will be
  230.           overlayed on the StrS (source).
  231.  
  232. Uses StrngTTT.
  233.  
  234. Remarks   If N is actually larger than the length of the source
  235.           string, the source string is extended with spaces ' ' i.e.
  236.           no problem.
  237.                     
  238.           Any characters after the Nth position in StrS will be
  239.           replaced by the characters in StrT.
  240.                     
  241.           If N + length(StrT) is less than the original length of StrS
  242.           then the last part of StrS will remain intact. (Phew!)
  243.  
  244. Example
  245.  
  246.  
  247.                USES STRNGTTT;
  248.                VAR TTT : STRING;
  249.                BEGIN
  250.                  TTT := OVERTYPE(5, 'BOB AINSBURY', 'TECHNOJOCK'));
  251.                END.
  252.           
  253.  
  254. The string TTT is assigned the value "Bob TechnoJock".
  255.  
  256.           
  257.  
  258.  
  259.  
  260.  
  261. !SHORT:PadCenter         Expand and center string with a specific character
  262. PadCenter                                                     StrngTTT
  263.      
  264.  
  265.  
  266. Purpose   Tp expand and center a string with a specific character.
  267.  
  268. Returns   String;
  269.  
  270. Declaration    PadCenter(Str:string; Size:byte; Pad:char):string;
  271.                
  272.           Str is the string to be expanded
  273.           Size is the new string length
  274.           Pad is the character to expand the string with
  275.  
  276. Uses StrngTTT.
  277.  
  278.  
  279.  
  280. Example
  281.  
  282.  
  283.                USES STRNGTTT;
  284.                VAR TTT : STRING;
  285.                BEGIN
  286.                  TTT := PADCENTER(' ASTERISKS ',20,'*');
  287.                END.
  288.      
  289.  
  290. The string TTT is assigned the value "***** Asterisk *****".
  291.  
  292. !SEEALSO:PadLeft PadRight
  293.                          
  294.  
  295. !SHORT:PadLeft           Expand & left justify string with specific character
  296. PadLeft                                                       StrngTTT
  297.           
  298.  
  299.  
  300. Purpose   To expand and left justify a string with a specific
  301.           character.
  302.  
  303. Returns   String;
  304.  
  305. Declaration    PadLeft(Str:string; Size:byte; Pad:char):string;
  306.                     
  307.           Str is the string to be expanded
  308.           Size is the new string length
  309.           Pad is the character to expand the string with
  310.  
  311. Uses StrngTTT.
  312.  
  313.  
  314.  
  315. Example
  316.  
  317.  
  318.                USES STRNGTTT;
  319.                VAR TTT : STRING;
  320.                BEGIN
  321.                  TTT := PADLEFT(' ASTERISKS ',20,'*');
  322.                END.
  323.           
  324.  
  325. The string TTT is assigned the value " Asterisk **********".
  326.  
  327. !SEEALSO:PadCenter PadRight
  328.                            
  329.  
  330. !SHORT:PadRight          Expand & right justify string with specific character
  331. PadRight                                                      StrngTTT
  332.      
  333.  
  334.  
  335. Purpose   To expand and right justify a string with a specific
  336.           character.
  337.  
  338. Returns   String;
  339.  
  340. Declaration    PadRight(Str:string; Size:byte; Pad:char):string;
  341.                
  342.           Str is the string to be expanded
  343.           Size is the new string length
  344.           Pad is the character to expand the string with
  345.  
  346. Uses StrngTTT.
  347.  
  348.  
  349.  
  350. Example
  351.  
  352.  
  353.                USES STRNGTTT;
  354.                VAR TTT : STRING;
  355.                BEGIN
  356.                  TTT := PADRIGHT(' ASTERISKS ',20,'*');
  357.                END.
  358.      
  359.  
  360. The string TTT is assigned the value "********** Asterisk ".
  361.  
  362. !SEEALSO:PadCenter PadLeft
  363.  
  364.  
  365. !SHORT:PosWord           Determine starting character position of word
  366. PosWord                                                       StrngTTT
  367.           
  368.  
  369.  
  370. Purpose   To determine the starting character position of a word.
  371.  
  372. Returns   byte;
  373.  
  374. Declaration    PosWord(WordNo:byte; Str:string):byte;
  375.                     
  376.           WordNo is the number of the word to check
  377.           Str is the string to be analyzed
  378.  
  379. Uses StrngTTT.
  380.  
  381.  
  382.  
  383. Remarks   The function returns zero if the string is a null or if
  384.           there are less than WordNo words in the string.
  385.  
  386. Example
  387.  
  388.  
  389.                USES STRNGTTT;
  390.                VAR B : BYTE;
  391.                BEGIN
  392.                  B := POSWORD(3,'THE QUICK BROWN LINEMAN');
  393.                END.
  394.           
  395.  
  396. The variable B is assigned the value 11.
  397.  
  398. !SEEALSO:WordCnt ExtractWords
  399.  
  400.  
  401. !SHORT:Proper            Convert a string so each word begins with uppercase
  402. Proper                                                        StrngTTT
  403.      
  404.  
  405.  
  406. Purpose   To convert a string so that each word begins with an
  407.           uppercase letter.
  408.  
  409. Returns   String;
  410.  
  411. Declaration    Proper(Str:string): string;
  412.                
  413.           Str is the string to be converted
  414.  
  415. Uses StrngTTT.
  416.  
  417.  
  418.  
  419. Remarks   Only the alphabet (a..z) is affected.
  420.  
  421. Example
  422.  
  423.  
  424.                USES STRNGTTT;
  425.                VAR TTT : STRING;
  426.                BEGIN
  427.                  TTT := PROPER('R D AINSBURY');
  428.                END.
  429.      
  430.  
  431. The string TTT is assigned the value "R D Ainsbury".
  432.  
  433. !SEEALSO:Lower Upper
  434.  
  435.  
  436. !SHORT:Real_to_Str       Convert real to string with specified decimal places
  437. Real_to_Str                                                   StrngTTT
  438.           
  439.  
  440.  
  441. Purpose   To convert a real number to a string with a specified number
  442.           of decimal places.
  443.  
  444. Returns   string;
  445.  
  446. Declaration    Real_to_Str(R:real; Dec:byte):string;
  447.                     
  448.           R is the real number
  449.           Dec is the number of decimal places for the string
  450.  
  451. Uses StrngTTT.
  452.  
  453.  
  454.  
  455. Example
  456.  
  457.  
  458.                USES STRNGTTT;
  459.                VAR TTT : STRING;
  460.                BEGIN
  461.                  TTT := REAL_TO_STR(12345.789990,2);
  462.                END.
  463.           
  464.  
  465. The string TTT is assigned the value "12345.79".
  466.  
  467. !SEEALSO:Str_to_Real Int_to_Str
  468.                                
  469.  
  470. !SHORT:Strip             Remove character from string
  471. Strip                                                         StrngTTT
  472.      
  473.  
  474.  
  475. Purpose   To remove a character from a string
  476.  
  477. Returns   string;
  478.  
  479. Declaration    Strip(L,C:char; Str:string):string;
  480.                
  481.           L  is a character indicating which part of the string to
  482.           strip the characters (see remarks)
  483.           C is the character to strip
  484.           Str is the string to strip
  485.  
  486. Uses StrngTTT.
  487.  
  488. Remarks   The valid values of L are
  489.           'L' strip all leading characters
  490.           'R' strip all trailing characters
  491.           'B' strip leading and trailing characters
  492.           'A' strip all occurences of the character
  493.  
  494. Example
  495.  
  496.  
  497.                USES STRNGTTT;
  498.                VAR TTT : STRING;
  499.                BEGIN
  500.                  TTT := STRIP('B',' ','   THIS IS NEAT        ');
  501.                END.
  502.      
  503.  
  504. The string TTT is assigned the value "This is neat".
  505.  
  506.      
  507.  
  508.  
  509.  
  510. !SHORT:Str_to_Int        Convert string to integer
  511. Str_to_Int                                                    StrngTTT
  512.           
  513.  
  514.  
  515. Purpose   To convert a string to an integer
  516.  
  517. Returns   integer;
  518.  
  519. Declaration    Str_to_Int(Str:string): integer;
  520.                     
  521.           Str is the string to be converted
  522.  
  523. Uses StrngTTT.
  524.  
  525. Remarks   If the string Str is null or the string cannot be
  526.           successfully converted to an integer, the function returns a
  527.           zero.
  528.  
  529.           
  530.  
  531.  
  532.  
  533. Example
  534.  
  535.  
  536.                USES STRNGTTT;
  537.                VAR I : INTEGER;
  538.                BEGIN
  539.                  I := STR_TO_INT('165');
  540.                END.
  541.           
  542.  
  543. The variable I is assigned the value 165.
  544.  
  545. !SEEALSO:Str_to_Real Int_to_Str
  546.  
  547.  
  548. !SHORT:Str_to_Real       Convert string to real
  549. Str_to_Real                                                   StrngTTT
  550.      
  551.  
  552.  
  553. Purpose   To convert a string to an real.
  554.  
  555. Returns   real;
  556.  
  557. Declaration    Str_to_real(Str:string):real;
  558.                
  559.           Str is the string to be converted
  560.  
  561. Uses StrngTTT.
  562.  
  563. Remarks   If the string Str is null, or the string cannot be
  564.           successfully converted to a real , the function returns a
  565.           zero.
  566.                
  567.           This procedure gets around the bug in Turbo 4 that occurs
  568.           when trying to convert a string starting with a '.',  to a
  569.           number.
  570.  
  571.  
  572.  
  573. Example
  574.  
  575.  
  576.                USES STRNGTTT;
  577.                VAR R : INTEGER;
  578.                BEGIN
  579.                  R := STR_TO_REAL('165.787');
  580.                END.
  581.      
  582.  
  583. The variable R is assigned the value 165.787 .
  584.  
  585. !SEEALSO:Str_to_Int Real_to_Str
  586.                                
  587.  
  588. !SHORT:Upper             Convert string to upper case
  589. Upper                                                         StrngTTT
  590.           
  591.  
  592.  
  593. Purpose   To convert a string to upper case letters.
  594.  
  595. Returns   String;
  596.  
  597. Declaration    Upper(Str:string):string;
  598.                     
  599.           Str is the string to be converted
  600.  
  601. Uses StrngTTT.
  602.  
  603.  
  604.  
  605. Remarks   Only the  alphabet (a..z) is affected.
  606.  
  607. Example
  608.  
  609.  
  610.                USES STRNGTTT;
  611.                VAR TTT : STRING;
  612.                BEGIN
  613.                  TTT := UPPER('SMALL LETTERS');
  614.                END.
  615.           
  616.  
  617. The string TTT is assigned the value "SMALL LETTERS".
  618.  
  619. !SEEALSO:Lower Proper
  620.  
  621.  
  622. !SHORT:WordCnt           Count number of words in string
  623. WordCnt                                                        StrnTTT
  624.      
  625.  
  626.  
  627. Purpose   To count the number of words in a string.
  628.  
  629. Returns   byte;
  630.  
  631. Declaration    WordCnt(Str:string):byte;
  632.                
  633.           Str is the string to be counted
  634.  
  635. Uses StrngTTT.
  636.  
  637.  
  638.  
  639. Example
  640.  
  641.  
  642.                USES STRNGTTT;
  643.                VAR B : BYTE;
  644.                BEGIN
  645.                  B := WORDCNT('THATS ALL THE STRING FUNCTIONS, FOLKS!');
  646.                END.
  647.      
  648.  
  649. The variable B is assigned the value 6.
  650.  
  651. !SEEALSO:ExtractWords PosWord
  652.