Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - stuff() insert, delete and replace characters in a string http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 stuff()             Insert, delete and replace characters in a string
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   func char stuff extern
   param const char cSource, ;
         value uint uStart, ;
         value uint uReplaceLength, ;
         const char cReplace

 Arguments
   cSource is the character string to convert.

   uStart is the start position of the conversion.

   uReplaceLength is the length of replacement.

   cReplace is the replacement string.

 Return
   A converted version of the input string.

 Description
   The stuff() function inserts, deletes and/or replaces characters
   from cReplace into cSource starting at uStart. uReplaceLength
   characters are removed from cSource starting at uStart prior to the
   insertion.

   If uReplaceLength is 0, then no characters are removed from cSource
   and the insertion starts at uStart. If the length of cReplace is 0,
   then characters are removed from cSource.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   proc Test_stuff
   vardef
       int     nStart, nRepLen
       char    cSrc
       char    cRepl
   enddef
   ? stuff( "source", 0, 1, "THIS" )
   ? stuff( "source", 1, 4, "THIS" )
   ? stuff( "source", 0, 0, "THIS" )
   ? stuff( "source", 6, 4, "THIS" )
   ?
   // Stuff a path into a filename
   ? stuff( "d:text.txt", 2, len( getenv( "TEMP" ) ), getenv( "TEMP" ) )
   wait
   ///To see how stuff() manipulates strings, encode the following:
   cSrc := "A source string"
   cRepl := "REPLACE"
   for nStart := 0 to len( cSrc )
      for nRepLen := 0 to len( cRepl )
          ? stuff( cSrc, nStart, nRepLen, cRepl )
      next
   next
   endproc

   proc main
   Test_stuff()
   endproc

See Also: strfilter()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson