Page 1 of 1 1
Topic Options
#85770 - 2002-05-27 04:01 PM Last problem to fix...
Rvdeej Offline
Fresh Scripter

Registered: 2002-05-27
Posts: 20
Loc: Bruxelles
Hi again ya all...

I got one problem left to solve.

I need to open a text file, search for the string ;Activated and delete that string (Replace with nothing)
I can's seem to do this with SendKeys in Notepad, even after i focusses Notepad.

Anyone have an idea how to fix this. (WinXP) [Big Grin]
_________________________
Rvdeej

Top
#85771 - 2002-05-27 05:11 PM Re: Last problem to fix...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
If the text file is a .INI file, you can use READPROFILESTRING/WRITEPROFILESTRING. For all other text files you will have to read the text file line by line and write it again line by line if you are looking for a pure KiXtart solution.
_________________________
There are two types of vessels, submarines and targets.

Top
#85772 - 2002-05-27 05:44 PM Re: Last problem to fix...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Here's an uneloquent kixtart solution, removes all occurences of $string into a tempfile, meant to be renamed to original when done. Messy business...

break on

$filename = "test.txt"
$tempfile = "%temp%\test.tmp"

$string = ";Activate"

if exist($tempfile)
 del "$tempfile"
endif

if open(1,$filename) = 0
 if open(2,$tempfile,5) = 0
  $line = readline(1)
  while @error = 0
   if instr($line,$string)
    $pos = instr($line,$string)
    $newline = substr($line,1,$pos)
    $line = $newline + substr($line,$pos+len($string)+1)
   endif
   $rc = writeline(2,$line+@CRLF)
   $line = readline(1)
  loop
  $rc = close(2)
 endif
 $rc = close(1)
endif

; rename tempfile to filename here

exit 1


-Shawn

Top
#85773 - 2002-05-27 05:52 PM Re: Last problem to fix...
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

For an update we creates following example:

code:
$old_string="[old string]" ; - your old string value -
$new_string="<new string>" ; - your new string value -
;
$file="c:\your_file.txt" ; - your file -
$file_temp="%temp%\dummy.tmp"
$debug_mode="yes"
IF (Exist($file) = 1)
DEL $file_temp
IF (Open(1,$file,2) = 0) ; -read access-
IF (Open(2,$file_temp,5) = 0) ; -write access-
$line=ReadLine(1)
WHILE (@error = 0)
IF ($debug_mode = "yes")
? " -> "+$line
ENDIF
$i=Instr($line,$old_string)
IF ($i <> 0)
IF ($i = 1)
$nline=$new_string+Substr($line,Len($old_string)+1)
ELSE
IF ($i+Len($old_string)-1 = Len($line))
$nline=Substr($line,1,Instr($line,$old_string)-1)+$new_string
ELSE
$nline=Substr($line,1,Instr($line,$old_string)-1)+
$new_string+
Substr($line,Instr($line,$old_string)+Len($old_string))
ENDIF
ENDIF
ELSE
$nline=$line
ENDIF
IF ($debug_mode = "yes")
? " --> "+$nline
ENDIF
IF (WriteLine(2,$nline+CHR(13)+CHR(10)) <> 0)
ENDIF
$line=ReadLine(1)
LOOP
IF Close(2)
ENDIF
ENDIF
IF Close(1)
ENDIF
?
IF (Exist($file_temp) = 1)
COPY $file_temp $file /H
IF (@error <> 0)
? "Warning KIX: update "+Ucase($file)+" returns error @error (@serror)"
ELSE
DEL $file_temp
ENDIF
? "update "+Ucase($file)+" file."
ENDIF
ENDIF
? "update completed."
ELSE
? "already updated."
ENDIF

An example:
code:
[old string]123456789
123[old string]456789
123456789[old string]

becomes
code:
<new string>123456789
123<new string>456789
123456789<new string>

with screen output
code:
  -> [old string]123456789
--> <new string>123456789
-> 123[old string]456789
--> 123<new string>456789
-> 123456789[old string]
--> 123456789<new string>

update c:\your_file.tx file.
update completed.

Greetings.

btw: we must take some precaution for a known flushing problem
with write-buffers. We are only use the WriteLine functions.
To prevent this kind of problems.

[ 27 May 2002, 18:23: Message edited by: MCA ]
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#85774 - 2002-05-27 06:11 PM Re: Last problem to fix...
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
In case anyone needs it I have just place Qreplace.exe on my website's Perl Utilities Page. It is a commandline tool that will replace "OldText" with "NewText" in multiple files as defined by a file specification that supports wildcards. Any file modified will hav the original data write to $file.BAK.

Sorry, I just fould it easier to to provide this then write a ton of KixTart code.

I see that MCA had some code available.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#85775 - 2002-05-27 07:41 PM Re: Last problem to fix...
Rvdeej Offline
Fresh Scripter

Registered: 2002-05-27
Posts: 20
Loc: Bruxelles
Thanks again fellas...

My work is done...

I'll be helping out myself in this forum since it seem to work fine here....

Thanks again...
_________________________
Rvdeej

Top
#85776 - 2002-05-27 07:58 PM Re: Last problem to fix...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Well, officially, this forum is for COM related scripts and questions only (like your first question - spot on), but general scripting questions should be posted to the scripts forum. But no worries because most members use the "Todays Active Topics" view which shows all the active topics, from all the forums. Actually, the scripts forum is probably the most "viewed" area anyways. Its like the "Kixtart Lounge" [Wink]

-Shawn

Top
#85777 - 2002-05-27 08:42 PM Re: Last problem to fix...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
...and we're the 'Lounge Lizards'... [Big Grin]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#85778 - 2002-05-27 09:01 PM Re: Last problem to fix...
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Hi,

Possible you know already in what kind of "Lounge" the Second Millenium guys live.

#topics       description by Infopop (= UBB site)
      0      Newster
     25      Regular
     50      Fanastic
    100      Mad Poster
    500      Merga Poster
   1000      Elite Poster
   1500      Elite Group
   2000      No Life!!!

Possible that you know what kind of description fits the 2500th guys.
greetings.

(our reaction 2600 to the board)
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#85779 - 2002-05-27 09:58 PM Re: Last problem to fix...
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
How about a KiX-adict ?

But i would rather grade the number of posts as level of helpfullnes and desire to learn from other helpfull people [Smile]

-Erik

Top
#85780 - 2002-05-27 11:20 PM Re: Last problem to fix...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
LOL, or maybe a KiXaholic ? (as in: I've got to kix this scripting habit I have!) - or maybe the ratings wrap-around, you know, I would be a No-Life-Mega-Poster, so would MCA ... Les would be a No-Life-Fantasic ! What you think of that Les ? [Wink] [Wink] [Wink]

-Shawn

Top
#85781 - 2002-05-28 05:05 AM Re: Last problem to fix...
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We hope we doesn't become like the guy who make those member descriptions.
He may now looks like



We like the name "Artist". Artists aren't very common persons.
Sometimes artists may looks like a little bit strange.
Artists think mostly in a strange way. Paintings from f.e. Modriaan are very simple, but
we can't imitate him.
Artists are very creative.
Good artists know what they are doing.

We agree with kholm that guys like Shawn, Bryce, LLigetfa, NTDOC and other
Millenium guys are trying to help. Specially in those situations:



greetings.

[ 28 May 2002, 10:09: Message edited by: MCA ]
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#85782 - 2002-05-28 05:44 AM Re: Last problem to fix...
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Not having a life and knowing it is one thing... but having someone else tell you... [Frown] [Frown] [Frown]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#85783 - 2002-05-28 04:20 PM Re: Last problem to fix...
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Does anybody know if there is a "KiXaholic Anonymous" support group?
_________________________
There are two types of vessels, submarines and targets.

Top
#85784 - 2002-05-28 06:22 PM Re: Last problem to fix...
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
if there is one, they have to have the meetings here, or no one will show up.

I vote for fanatic.

I use many resourcekit and freeware utilities, but I don't hang out on their support sites.

How about the first poster to hit 5000 gets an iMac for therapy purposes... or would methadone be more appropriate.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.072 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org