WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

String Manipulation

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Insert a String Between the Characters Within a String

 Keywords: udfPad StrInsert strCharCount Insert Character String Between 

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfPad (strBase, strIns, intMode)
intBaseChars = StrCharCount (strBase)
intInsLen = StrCharCount (strIns)
Switch intMode
Case 0
   intFirst = 2
   intLast = intBaseChars
   Break
Case 1
   intFirst = 1
   intLast = intBaseChars
   Break
Case 2
   intFirst = 2
   intLast = intBaseChars + 1
   Break
Case 3
   intFirst = 1
   intLast = intBaseChars + 1
   Break
Case intMode
   Return strBase
EndSwitch
For intPos = intLast To intFirst By -1
   strBase = StrInsert (strBase, strIns, "", intPos, intInsLen)
Next
Return strBase
;..........................................................................................................................................
; This UDF "udfPad" inserts a string between the characters within a string.
;
; (c)Detlev Dalitz.20121120.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

Article ID:   W18389
Filename:   Insert a String Between the Characters Within a String..txt
File Created: 2012:11:20:13:58:02
Last Updated: 2012:11:20:13:58:02