Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Insert a string at a specified position within another string expression.

 

Syntax

 

s$ = STRINSERT$(sMain, sNew, position)

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

sMain

String

No

Main string to insert to

sNew

String

No

String to insert

Position

Numeric

No

Position inside sMain where to start to insert sNew.

 

Remarks

 

If position is negative it is interpreted as the Token Size. Mainly it will be possible to split MainString into single tokens of the same size inserting the new string.

Example: imagine you have a string and want to insert a comma every 3 bytes. Now you can do it in this way:

Dim MyOldString As String VALUE "123ABC456XYZ"

Dim MyNewString As String VALUE STRINSERT$(MyOldString, ",", -3)

'---MyNewString will be: '123,ABC,456,XYZ,'

 

Restrictions

 

See also

 

String Handling,

 

Examples

 

Thanks to Abraxas for the following script example

Dim sMain      As String VALUE "HELLO WORLD"

Dim sNew       As String VALUE "TO THE "

Dim StringExpression As String VALUE sMain

Dim sDEL       As String

Dim sINS       As String

Dim sREV       As String

Dim sSTR       As String

Dim Start      As DWORD VALUE 4

Dim count      As DWORD VALUE 7

Dim position   As DWORD VALUE 7

Dim sMsg       As String

 

sDEL = STRDELETE$ (StringExpression , start, count)

sINS = STRINSERT$ (sMain, sNew, position)

sREV = STRREVERSE$(sMain)

 

sMsg += "sMain = " & sMain & $CRLF

sMsg += "sNew = " & sNew & $CRLF

sMsg += "StringExpression = " & StringExpression  & $CRLF & $CRLF

sMsg += "Start = " & Start & $CRLF

sMsg += "Count = " & count & $CRLF

sMsg += "Position = " & position & $CRLF & $CRLF

 

sMsg += "STRDELETE$(string_expression, start, count) = " & sDEL & $CRLF & $CRLF

sMsg += "STRINSERT$(sMain, sNew, position) = " & sINS & $CRLF & $CRLF

sMsg += "STRREVERSE$(sMain) = " & sREV & $CRLF & $CRLF

 

MSGBOX 0, sMsg

 

 

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software