Gideon Posted January 9, 2009 Share Posted January 9, 2009 (edited) I've made something like a database, but with duplicates. This script (see script below) moves the object "Johny Cash" with his computer from line 2, to line 3 in the same file. In that file, there are Many lines with the data "Not Defined", when I let the script do his thing, many weard things happen, Johny Cash moves from line 2 to another "Not Defined-line". _FileWriteToLine("C:\test.txt", 3, "Johny Cash", 1) _FileWriteToLine("C:\Computers.txt", 3, "Computername5", 1) _FileWriteToLine("C:\test.txt", 2, "Not Defined", 1) _FileWriteToLine("C:\Computers.txt", 2, "Not Defined", 1)oÝ÷ Ø è¶«¶§©¥éìÂ+a¶¬±Êâ¦ÛzÇ+[zZ0N¬±Êâ¦ÚÞ¦Vy¢âæî¶+wöÉè¶Ø^q«Â§ªê-6Cyø§yÚ®¢ÓrêìÞ¡û^)æÊ×±µø¥xkzZqæ¥X§{«¨´Ú- çâçjºeGêeiǶ.EW®+^Nâê',+׬¢w¥w Z½çèºwZnè(Úçjaz»(ëb¢{hvaÆ®¶sbb33c¶3RÒuT7G&Å&VBb33cµFWEó¶6öçFç2gV÷C´¦öç66gV÷C° b33c¶3bÒuT7G&Å&VBb33cµFWEó"¶6öçFç2gV÷C´6ö×WFW&æÖSRgV÷C° ôfÆUw&FUFôÆæRgV÷C´3¢b3#·FW7BçGBgV÷C²ÂSÂb33c¶3R¶ÆæRS6öçFç2æ÷BFVfæV@ ôfÆUw&FUFôÆæRgV÷C´3¢b3#´6ö×WFW'2çGBgV÷C²ÂSÂb33c¶3b Edited January 9, 2009 by Gideon Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Developers Jos Posted January 9, 2009 Developers Share Posted January 9, 2009 Works fine here... Maybe show the "before"and "after" records and what exactly goes wrong? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Gideon Posted January 9, 2009 Author Share Posted January 9, 2009 (edited) ComboUser.txtcomputers.txt Edited January 9, 2009 by Gideon Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Gideon Posted January 9, 2009 Author Share Posted January 9, 2009 (edited) It's just the problem that function _FileWriteToLine does'nt exactly replaces the line, but replace the given text. The txt-files attached upside. I use the "database" for pinging to users in my company, so I can quickly see if they are online or offline. The script is for managing the "database". But it's to long to post it. Edited January 9, 2009 by Gideon Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
martin Posted January 9, 2009 Share Posted January 9, 2009 It's just the problem that function _FileWriteToLine does'nt exactly replaces the line, but replace the given text.The txt-files attached upside.I use the "database" for pinging to users in my company, so I can quickly see if they are online or offline.The script is for managing the "database".But it's to long to post it.When I try your scripts they do what I expected from the help, that is, line 3 was replaced and line 2 was replaced as requested.You didn't post examples of what you get after you run the scripts so we can't tell if your results are different. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Gideon Posted January 9, 2009 Author Share Posted January 9, 2009 Place the txt-files to your c:\, then run the script You will see a gui with two inputs, type in information and select line3 of the combobox. Then look at the textfiles, the names "Not Defined" are replaced in the tekst you typed in expandcollapse popup#include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GUICombobox.au3> #include <GuiEdit.au3> #include <GUIConstants.au3> #include <File.au3> #include <Constants.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $Button_2, $Combo_2, $Line2, $Line3, $label_3, $label_4, $label_5, $label_6, $label_7, $label_8, $Combo_3, $msg, $ping, $text_1, $text_2, $Select_1, $Combo_1, $label_1, $label_on, $label_off, $Lblvar, $computer, $label_2, $Lblvar2, $File_1, $Default, $File_2, $Line, $1, $2, $3, $4, $5, $6, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11, $c12 GUICreate ( '"Who is online?" Managing' , "640" , "480" , -1, -1, -1, $WS_EX_ACCEPTFILES ) ; will create a dialog box that when displayed is center Opt("GuiOnEventMode", 0) Opt( "GUIEventOptions", 1) Opt("GUICoordMode", 1) $text_1 = GUICtrlCreateInput("Type in User", 130, 30, 120, 20) $text_2 = GUICtrlCreateInput("Type in Computer", 130, 70, 120, 20) $Button_1 = GUICtrlCreateButton("Replace Line", 120, 250) $c1 = GUICtrlCreateLabel( "Existing User:", 10, 120, 115, 20) $c2 = GUICtrlCreateLabel( "Existing Computer:", 10, 160, 115, 20) $c3 = GUICtrlCreateLabel( "New User:", 10, 30, 115, 20) $c4 = GUICtrlCreateLabel( "New Computer:", 10, 70, 115, 20) $label_1 = GUICtrlCreateLabel($Lblvar, 130, 120, 120) $label_2 = GUICtrlCreateLabel($Lblvar, 130, 160, 120) $1 = FileReadLine("c:\ComboUser.txt", 1) $2 = FileReadLine("c:\ComboUser.txt", 2) $3 = FileReadLine("c:\ComboUser.txt", 3) $4 = FileReadLine("c:\ComboUser.txt", 4) $5 = FileReadLine("c:\ComboUser.txt", 5) $6 = FileReadLine("c:\ComboUser.txt", 6) $Combo_1 = GUICtrlCreateCombo("", 10, 95, 130) GUICtrlSetData(-1, $1 & "|" & $2 & "|" & $3 & "|" & $4 & "|" & $5 & "|" & $6, "Johny Cash") GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 $Lblvar = GuiCtrlRead($Combo_1) If $Lblvar = $1 Then $Line = 1 $File_2 = FileReadLine("c:\Computers.txt", $Line) $Lblvar2 = $File_2 $c5 = GUICtrlRead( $Text_1) $c6 = GUICtrlRead( $Text_2) _FileWriteToLine("c:\ComboUser.txt", $Line, $c5, 1) _FileWriteToLine("c:\Computers.txt", $Line, $c6, 1) EndIf If $Lblvar = $2 Then $Line = 2 $File_2 = FileReadLine("c:\Computers.txt", $Line) $Lblvar2 = $File_2 $c5 = GUICtrlRead( $Text_1) $c6 = GUICtrlRead( $Text_2) _FileWriteToLine("c:\ComboUser.txt", $Line, $c5, 1) _FileWriteToLine("c:\Computers.txt", $Line, $c6, 1) EndIf If $Lblvar = $3 Then $Line = 3 $File_2 = FileReadLine("c:\Computers.txt", $Line) $Lblvar2 = $File_2 $c5 = GUICtrlRead( $Text_1) $c6 = GUICtrlRead( $Text_2) _FileWriteToLine("c:\ComboUser.txt", $Line, $c5, 1) _FileWriteToLine("c:\Computers.txt", $Line, $c6, 1) EndIf If $Lblvar = $4 Then $Line = 4 $File_2 = FileReadLine("c:\Computers.txt", $Line) $Lblvar2 = $File_2 $c5 = GUICtrlRead( $Text_1) $c6 = GUICtrlRead( $Text_2) _FileWriteToLine("c:\ComboUser.txt", $Line, $c5, 1) _FileWriteToLine("c:\Computers.txt", $Line, $c6, 1) EndIf If $Lblvar = $5 Then $Line = 5 $File_2 = FileReadLine("c:\Computers.txt", $Line) $Lblvar2 = $File_2 $c5 = GUICtrlRead( $Text_1) $c6 = GUICtrlRead( $Text_2) _FileWriteToLine("c:\ComboUser.txt", $Line, $c5, 1) _FileWriteToLine("c:\Computers.txt", $Line, $c6, 1) EndIf GUICtrlSetData( $label_6, $Lblvar) GUICtrlSetData( $label_8, $Lblvar2) EndSelect WEnd EndFuncComboUser.txtcomputers.txt Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Developers Jos Posted January 9, 2009 Developers Share Posted January 9, 2009 Place the txt-files to your c:\, then run the scriptYou will see a gui with two inputs, type in information and select line3 of the combobox.Then look at the textfiles, the names "Not Defined" are replaced in the tekst you typed inCorrect as that is what you have put in your logic....$s3-$s5 do contain the same value which is also wat you have put in the 3rd entry of the combobox.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now