Search and replace Bug

Questions regarding IDE/Code-Editor

Search and replace Bug

Postby LeSid » Tue Apr 05, 2011 12:16 am

When replacing all "InStr(" by "InStr(1," i have this result :
"InStr(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ..."

I had to edit my program with another editor to do the changes.

Thank you
LeSid
 
Posts: 3
Joined: Mon Apr 04, 2011 11:58 pm

Re: Search and replace Bug

Postby Slowdown » Tue Apr 05, 2011 6:53 pm

Hi LeSid,

InStr is not used for replace partions in a string.
See the manual.
InStr

Function InStr([Start As Integer,] Source As String, Find As String, CaseSensitive As Boolean = True) As Integer

InStr finds one string inside another. Returns 0, if Find could not be found. First position in Source is referenced as 1.

Example

DIM s As String
s = "Bernd Noetscher's KBasic"
PRINT "string position = "& INSTR(1, s, "KBasic")


You have to use,
Also from the manual,
Replace

Function Replace (Str As String, SearchFor As String, ReplaceWith As String, CaseSensitive As Boolean = True) As String

Replaces string occurances with another string.

Example

DIM s = "Das ist alles was wir brauchen. Fang nochmal von vorne an."
DIM search = vorne"
DIM replace = "hinten"
PRINT REPLACE(s, search, replace)
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: Search and replace Bug

Postby LeSid » Sun Apr 10, 2011 9:40 pm

Hi,

It is not the "InStr(" instruction that i have a problem with, It is the Kbasic Editor

I was convertig a program from OpenOffice Basic to Kbasic.

Using "InStr(" in Kbasic need the first parameter. That first parameter mean the first charater wher to search in the string.

In Open Office Basic or in VBA you do not need this parameter when you want to search from the beginning.

For example in Kbasic : InStr(1,vartosearch,strsearched) is equivalent of OOBasic : InStr(vartosearch,strsearched)

Then, to put the "1," at each instruction "InSTR(" i used the search and replace of the Kbasic editor. The result was somewhat bizarre
InStr(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, ....

Thank you,
LeSid
 
Posts: 3
Joined: Mon Apr 04, 2011 11:58 pm

Re: Search and replace Bug

Postby Slowdown » Mon Apr 11, 2011 6:37 pm

Hi LeSid,

Sorry didn't read your text right.
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands


Return to IDE

cron