#18668 - 2002-03-14 11:32 AM
Need help "remove value from ini file"
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
Hello
Are running the following code (thanks to Bryce)
$database = "c:\database.ini" $adresslist = readprofilestring("$database","adresslist","Script") if instr("$adresslist","@ADDRESS") <> 0 ? "Running Script" ; ; Remove @address after script starts ; ; goto end endif ? "Not running script...." :end exit
***** If the @adress is found, I would like to remove it, after the script has started.
Any ideas
\erik
|
|
Top
|
|
|
|
#18669 - 2002-03-15 12:23 AM
Re: Need help "remove value from ini file"
|
Mark Bennett
Getting the hang of it
Registered: 2001-10-10
Posts: 70
|
You could either use WriteProfileString OR if you want the line deleted all together use Open and ReadLine to recreate a new instance of the file. Read each line and use SubStr to look for what you want to delete. If the line doesn't match write it into the new version then when you do get a match (ie you are at the line you want to delete) don't write it in. Hope this makes sense.
|
|
Top
|
|
|
|
#18671 - 2002-03-15 12:56 AM
Re: Need help "remove value from ini file"
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
Thanks for the quick replys. Sorry Mark, I do not understand....
Added the code example Looks like this
? "@address"
$database = "c:\database.ini" $adresslist = readprofilestring("$database","adresslist","Script") if instr("$adresslist","@ADDRESS") <> 0 ? "Running Script"
$StripArr = SPLIT( $Adresslist , @ADDRESS ) $Stripped="" FOR EACH $Piece IN $StripArr $Stripped=$Stripped + $Piece NEXT
goto end endif ? "Not running script...." :end exit
Recive errors "Running ScriptScript error : expected expression !. $StripArr = SPLIT( $Adresslist , @ADDRESS )"
\erik
|
|
Top
|
|
|
|
#18672 - 2002-03-14 01:01 PM
Re: Need help "remove value from ini file"
|
Mark Bennett
Getting the hang of it
Registered: 2001-10-10
Posts: 70
|
Do you want an entry entirely removed from the INI file OR just an entry that reads Server=
|
|
Top
|
|
|
|
#18673 - 2002-03-14 01:01 PM
Re: Need help "remove value from ini file"
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
I hope I added the code sample in the right section ?
Regards \erik
|
|
Top
|
|
|
|
#18674 - 2002-03-14 01:03 PM
Re: Need help "remove value from ini file"
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
here is the ini file
[Adresslist] script=00010388395B
Just the @adress should be deleted
|
|
Top
|
|
|
|
#18675 - 2002-03-14 01:05 PM
Re: Need help "remove value from ini file"
|
Mark Bennett
Getting the hang of it
Registered: 2001-10-10
Posts: 70
|
Do a WriteProfileString on the Script setting in the Adresslist section of your Database.INI with an empty string ("").
|
|
Top
|
|
|
|
#18676 - 2002-03-14 01:07 PM
Re: Need help "remove value from ini file"
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
what will happen in case of multiple @address ?
ex
[Adresslist] script=00010388395B,000103883NOTSAME,
|
|
Top
|
|
|
|
#18678 - 2002-03-14 01:08 PM
Re: Need help "remove value from ini file"
|
Mark Bennett
Getting the hang of it
Registered: 2001-10-10
Posts: 70
|
Should be set to empty string as Read and WriteProfileString reads after the =
|
|
Top
|
|
|
|
#18679 - 2002-03-14 01:17 PM
Re: Need help "remove value from ini file"
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
were running version 3.61. Kix in multiple location.
Old ones deleted. Now only runing version 4.02
No errors, but macaddress (@address) not disaperaring
|
|
Top
|
|
|
|
#18680 - 2002-03-14 01:19 PM
Re: Need help "remove value from ini file"
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
mark can you give a sample, not getting your idea
\erik
|
|
Top
|
|
|
|
#18682 - 2002-03-14 02:01 PM
Re: Need help "remove value from ini file"
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
Working fine, entry disapears.
But i deletes everything Before: / database.ini / [Adresslist] script=0001038839
After: [Adresslist]
Code looks like this now / correct ?
$database = "c:\database.ini" $adresslist = readprofilestring("$database","adresslist","Script") if instr("$adresslist","@ADDRESS") <> 0 ? "Running Script"
; $StripArr = SPLIT( $Adresslist , @ADDRESS ) ; $Stripped="" ; FOR EACH $Piece IN $StripArr ; $Stripped=$Stripped + $Piece $Result = WRITEPROFILESTRING ( $database , "adresslist" , "Script" , $Stripped )
goto end endif ? "Not running script...." :end exit
|
|
Top
|
|
|
|
#18684 - 2002-03-14 02:19 PM
Re: Need help "remove value from ini file"
|
Mark Bennett
Getting the hang of it
Registered: 2001-10-10
Posts: 70
|
Sorry about the confusion, if you need any other examples let me know.
|
|
Top
|
|
|
|
#18685 - 2002-03-14 02:36 PM
Re: Need help "remove value from ini file"
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
$database = "c:\database.ini" $adresslist = readprofilestring("$database","adresslist","Script") if instr("$adresslist","@ADDRESS") <> 0 ? "Running Script"
$StripArr = SPLIT( $Adresslist , @ADDRESS ) $Stripped="" FOR EACH $Piece IN $StripArr $Stripped=$Stripped + $Piece $Result = WRITEPROFILESTRING ( $database , "adresslist" , "Script" , $Stripped )
goto end endif ? "Not running script...." :end exit
Sorry my mistake, working perfectly
Thank you
Greetings from sweden
\erik
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(mole)
and 1300 anonymous users online.
|
|
|