forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


search and replace problem
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Fri Mar 21, 2003 6:27 am    Post subject: search and replace problem Reply with quote

hello all

ok lets say i have a txt file called test.txt and in this file i have this in there:

tim.txt - 1111 2222 3333 4444 5555 6666 7777 8888 9999

i want the tim.txt - chnage to tim-del: and i want the info that is after the - to stay there and not chnage.. so it would look like this in the txt file

tim.del : 1111 2222 3333 4444 5555 6666 7777 8888 9999

note: ANY data after the : can be alot like you see above or it could just have this in it 1111..so what i'am saying it can vary...

here is what i have for code but it don't work right Sad what i'am doing wrong?

Code:

List Create,5
List Loadfile,5,"test.txt"
%N = "tim.TXT-"
%R = "tim-del:"
%M = @match(5,%N)
If %M
%C =@item(5),@len(@item(5)))
List Put,5,%R %c
info  %r %c
list save,5,"test1.txt"


thanks

_________________
Have a nice day Smile
Back to top
View user's profile Send private message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Mar 21, 2003 6:43 am    Post subject: Reply with quote

There are several threads on string find and replace. Try this one:
http://www.vdsworld.com/forum/viewtopic.php?t=690

and you really should try searching the forum before posting your questions.
You'd be surprised the answers you'll find. Smile

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Fri Mar 21, 2003 6:55 am    Post subject: i did Reply with quote

i did search the forum BUT some of that code i saw i thought was to much for a easy task..meaning that there has to be a easyier way..to do it i thought Smile
_________________
Have a nice day Smile
Back to top
View user's profile Send private message
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Fri Mar 21, 2003 6:57 am    Post subject: also Reply with quote

If you look REALLY close at my code you will see that part of it DID come from a old thread Smile
_________________
Have a nice day Smile
Back to top
View user's profile Send private message
Rubes_sw
Valued Contributor
Valued Contributor


Joined: 11 Jun 2001
Posts: 625
Location: Northern Ireland

PostPosted: Fri Mar 21, 2003 7:08 am    Post subject: Reply with quote

You could use tommys vdsdll3.dll

@DLL(STRING, REPLACE, < string>, <search string>, <replace string>{, exact})

Replaces all instances of <search string> in <string> with <replace string>. Only if exact is provided, replacing is case sensitive.

I have used it, its fast, easy and reliable !

Nathan
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Fri Mar 21, 2003 7:10 am    Post subject: hummmm Reply with quote

hummm

ok but will that keep the other data intack? cuase that is the problem i'am haing now it cuts off some of the data or some of the data is missing Sad

thanks

_________________
Have a nice day Smile
Back to top
View user's profile Send private message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Mar 21, 2003 7:12 am    Post subject: Reply with quote

Ok. I'm not gonna fix your code for ya, but I will tell ya what I see is wrong
with it. Please don't take this wrong, but you gotta learn to do these things
yourself or you will never learn it.

First problem:
Code:

%C =@item(5),@len(@item(5)))


should be :
Code:

%C = @substr(@item(5),@pos(%N,@item(5)),@sum(@pos(%N,@item(5)),8))


And this line:
Code:

list save,5,"test1.txt"


should be:
Code:

list savefile,5,"test1.txt"

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Mar 21, 2003 7:17 am    Post subject: Reply with quote

tim, here's a whole thread on "replace text", including a link to
one I wrote in the archives...

http://www.vdsworld.com/forum/viewtopic.php?p=2947&highlight=replace+text#2947

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Fri Mar 21, 2003 7:21 am    Post subject: hummm Reply with quote

ok

I see that you have

Code:

list savefile,5,"test1.txt"



even tho my was wrong it still saved the file tho..why didn't i get a error on that?

and this part
Code:

%C = @substr(@item(5),@pos(%N,@item(5)),@sum(@pos(%N,@item(5)),8))
 


can you explain what this is doing? I know it substractiing,etc BUT it would help me to have it explained cuase math is not my best area Smile

thanks

_________________
Have a nice day Smile
Back to top
View user's profile Send private message
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Fri Mar 21, 2003 7:32 am    Post subject: and Reply with quote

mac- i did take a look at that thread ANd your code does look nice but i was trying to make a easy version that i can follow and understand better..i guess i should have listerned better when i was in math class back when i was young...and spelling class also... Embarassed


Sad

_________________
Have a nice day Smile
Back to top
View user's profile Send private message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Mar 21, 2003 7:34 am    Post subject: Reply with quote

Ok, let's see:

Code:

%C = @substr(@item(5),@pos(%N,@item(5)),@sum(@pos(%N,@item(5)),8))


Code:

@substr() is used to retrieve a string from within a string.
@item(5) is the text in the list where the index pointer is.
@pos(%N,@item(5)) returns the starting position of %N in the string @item(5)
@sum(@pos(%N,@item(5)),8) is adding the first found position of %N with
the length of %N which happens to be 8.

Another way to do this and maybe a little easier for you to see what is
happening would be like this:
Code:

%%first = @pos(%N,@item(5))
%%last = @sum(%%first,8)
%C = @substr(@item(5),%%first,%%last)


Does that help? Smile

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Fri Mar 21, 2003 7:38 am    Post subject: hummm Reply with quote

that help some i don't get where did that 8 come from??? why 8?

thanks

_________________
Have a nice day Smile
Back to top
View user's profile Send private message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Mar 21, 2003 7:40 am    Post subject: Reply with quote

The 8 comes from the length of %N. %N is 8 characters long.
_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
tim6389
Professional Member
Professional Member


Joined: 01 Aug 2002
Posts: 790

PostPosted: Fri Mar 21, 2003 7:42 am    Post subject: Reply with quote

ahhhhh ok i see that..ok ok i understand that...i still trying to follow the rest..man i wish i could "see" this like you guys do Sad
_________________
Have a nice day Smile
Back to top
View user's profile Send private message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Mar 21, 2003 7:45 am    Post subject: Reply with quote

It takes time Tim, unfortunately it doesn't happen overnight and it takes
longer for some people than it does for others. Just keep trying and you'll
figure it out one of these days. Smile

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group