Mid(A$,20)="Blah blah"

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Starax.

Is there a command to place a string within another string?


Example:
S1$="one three"
Mid(S1$,4)="two "
print S1$

> one two three
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Code: Select all

Procedure.s InsertString(source.s,pos,newstring.s)
   ProcedureReturn Left(source,pos)+newstring+Right(source,Len(source)-pos)
EndProcedure

OpenConsole()

ReplaceStExample:
  S1$ = "one three"
  PrintN(S1$)
  S1$ = InsertString(S1$,4,"two ")
  PrintN(S1$)
  Input()
cya,
...Danilo
(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.

Starax Danilo's example is a good start but also do a search for Franco's templates as he had lots of these sorts of examples and it got me started last year. They will be somewhere here in the forum still (I hope) and/or on Paul's resource site.

Fangles woz ear orright den?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Starax.

Thanks chaps.
Post Reply