Page 1 of 1

Delete Name In Text Line

PostPosted: Tue Apr 19, 2016 12:22 am
by StarterPack
Hi Guys,

If I have an external .txt file with names:
John
Peter
Robert
Anne
Gary

What script do I use to search for lets say; Anne in the text file and then delete that name.
Thank You

Re: Delete Name In Text Line

PostPosted: Tue Apr 19, 2016 12:34 am
by mishem
Using the plugin hpwControl

Code: Select all
hpwLineNumber "The path to the file" "Anne" "" "[Num]"
FileDelLine "The path to the file" "[Num]"


or without the plugin

Code: Select all
FileRead "The path to the file" "All" "[Text]"
SearchStr "Anne" "[Text]" "[SearchStr]" ""
StrDel "[Text]" "[SearchStr]" "4" "[Text]"
FileWrite "The path to the file" "All" "[Text]"


or

Code: Select all
FileRead "The path to the file" "All" "[Text]"
StrReplace "[Text]" "Anne" "" "[Text]" ""
FileWrite "The path to the file" "All" "[Text]"


or

Code: Select all
FileRead "The path to the file" "All" "[Text]"
StrReplace "[Text]" "Anne[#13][#10]" "" "[Text]" ""
FileWrite "The path to the file" "All" "[Text]"


Can be used ListBox.
Can be used StrParse.
etc.

Re: Delete Name In Text Line

PostPosted: Tue Apr 19, 2016 5:48 am
by StarterPack
Hi mishem

Thank You For Your Quick Reply!
I'll Check Which One Works For Me. Thanks Again!!!

Re: Delete Name In Text Line

PostPosted: Tue Apr 19, 2016 9:32 am
by StarterPack
Hi mishem

I've tested it and it works fine when i loaded the text file in a "TextEntry"

but what i need is..

When i startup my program it loads A.txt file into [ListBox]
example:
Anne
Albert
Aubrie
etc
In ListBox 'Double Click" i add
SetVar "[TextName]" ""
StrIns " [ListBox1]" "[TextName]" "" "[TextName]"
This will load the name that i double click in the ListBox to [TextName]

Now when i click a buttom it must search for the [TextName] name in A.txt and delete it from the text file.

Re: Delete Name In Text Line

PostPosted: Tue Apr 19, 2016 11:43 am
by mishem
Image

Image

Re: Delete Name In Text Line

PostPosted: Tue Apr 19, 2016 1:53 pm
by StarterPack
Mishem

Thank you so much! This works great!
There will only be a problem if you SORT the ListBox, is there a way around that?