scripting@wanadoo.nl




Stuff()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
9 January 2002 Stuff()
AuthorScriptLogic Corporation
Action Allows to add, replace, remove or substitute characters of one text string with another.
SyntaxStuff ( "expC1", expN1, [expN2], ["expC2"] ) 
Parameters
  • expC1 (Required / String) The string in which the replacement occurs.
  • expN1 (Required / Numeric) Specifies the position in expC1 where the replacement begins.
  • expN2 (Optional / Numeric) The number of characters to be replaced is specified by expN2. If expN2 is 0, the replacement string expC2 is inserted into expC1.
  • expC2 (Optional / String) The replacement character expression is specified by expC2. If expC2 is the null string, the number of characters specified by expN2 are removed from expC1. 
  • RemarksRelatively small amount of code with very useful functionality. 
    ReturnsReturns a character string created by replacing a specified number of characters in one character string with another character string. 
    DependenciesNone. 
    Examples
    $str1='abcdefghijklm'
    $str2='12345'
    ? STUFF($str1, 4, 0, $str2)          ; insert
    ? STUFF($str1, 4, 5, $str2)          ; replace
    ? STUFF($str1, 4, 6)                 ; delete
    ? STUFF($str1, 4, len($str1), $str2) ; replace and delete rest
    
     
    Source
    FUNCTION Stuff ($expc1, $expn1, OPTIONAL $expn2, OPTIONAL $expc2)
      ;Author: ScriptLogic Corporation
      ;
      ; Returns a character string created by replacing a specified number of
      ; characters in a character expression with another character expression.
      ;
      ;Parameters:
      ; expC1 Specify the character expression  in which the replacement occurs.
      ; expN1 specifies the position in  where the replacement begins.
      ; expN2 The number of characters to be replaced is specified by .
      ;       If  is 0, the replacement string  is inserted into .
      ; expC2 The replacement character expression is specified by .
      ;       If  is the null string, the number of characters specified by
      ;        are removed from .
    
      $expn1=0+$expn1
      $expn2=0+$expn2
      $expc2=''+$expc2
      $stuff=$expc1
      IF $expn1
        $stuff=Substr($expc1,1,$expn1-1)+$expc2+ Substr($expc1,$expn1+$expn2,Len($expc1))
      ENDIF
    ENDFUNCTION ; - Stuff -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter