DarkBoost Posted January 10, 2009 Share Posted January 10, 2009 I am stumped on this and hope someone can point me in the right direction. I have a Text File (c:\example.txt) which has the following:- [1] 1 Box - 4 Circles [2] 1 Box - 4 Circles [3] 1 Box - 4 Circles [*] = Text Line | [Note:] Different level of spaces at the start 1. Having troubles locating Line 2 2. Having trouble changing Line 2 from 4 Circles to 5 Circles Link to comment Share on other sites More sharing options...
iHonda Posted January 10, 2009 Share Posted January 10, 2009 can you post the script you have so far A great place to start Autoit 1-2-3 Link to comment Share on other sites More sharing options...
DarkBoost Posted January 10, 2009 Author Share Posted January 10, 2009 I do not have a script at the moment as I am not sure how to write this however with my current knowledge of AutoIt I would write it like this:- $i = 0 While 1 <= 10 $var = FileReadLine("c:\example.txt") If $var = "*4 Circles" Then FileWriteLine($var, "5 Circles") EndIf $i = $i + 1 WEnd Please do not laugh too hard , I do not use AutoIt too often :-( Link to comment Share on other sites More sharing options...
iHonda Posted January 10, 2009 Share Posted January 10, 2009 (edited) mk i can help with this ill write an example for you to see and post it in a sec. ok one more question does it need to be a text file?? or could you use and ini file.. because writing to a line is kinda a pain... Edited January 10, 2009 by Zmaster A great place to start Autoit 1-2-3 Link to comment Share on other sites More sharing options...
DarkBoost Posted January 10, 2009 Author Share Posted January 10, 2009 (edited) It needs to be a text file. I have tried combinations like "[(?x)]1 Box - 4 Circles" and "[[:space:]]1 Box - 4 Circles" and "[[:blank:]]1 Box - 4 Circles" etc. but having troubles. Even if I am able to acknowledge the correct line I am not sure how to modify just the number :-( Edited January 10, 2009 by DarkBoost Link to comment Share on other sites More sharing options...
iHonda Posted January 10, 2009 Share Posted January 10, 2009 (edited) i seem to be having issues with the wildcards but i got a script that works but not with wildcards i really doubt that the filereadline function allows wildcards maybe we can think of another way to do it ;--------------------; ; By: Zmaster ; ;....................; #Include <File.au3> ;Variables Local $line_2 While 1 $line_2 = FileReadLine(@DesktopDir & "\example.txt", 2) If $line_2 = " 1 Box - 4 Circles" Then _FileWriteToLine(@DesktopDir & "\example.txt", 2, " 1 Box - 5 Circles", 1) MsgBox(0,"",$line_2) Else MsgBox(0, "", $line_2) EndIf ExitLoop WEnd Edited January 10, 2009 by Zmaster A great place to start Autoit 1-2-3 Link to comment Share on other sites More sharing options...
BrettF Posted January 10, 2009 Share Posted January 10, 2009 You wish to get the first line. Then read the second line. If the second line is same as first, increment circle number 1? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
DarkBoost Posted January 10, 2009 Author Share Posted January 10, 2009 @Zmaster -> thank you for taking the time to write your example, it makes sense and i have it working. Is there a way to wildcard any spaces at the start of text so it will skip any amount of spaces before the text on the line? Link to comment Share on other sites More sharing options...
BrettF Posted January 10, 2009 Share Posted January 10, 2009 Take a look at StringInStr. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
iHonda Posted January 10, 2009 Share Posted January 10, 2009 Take a look at StringInStr. Cheers, Brett ah genius! i didnt even think of that >< i feel silly now StringInStr ( "string", "substring" [, casesense [, occurrence [, start [, count]]]] ) A great place to start Autoit 1-2-3 Link to comment Share on other sites More sharing options...
DarkBoost Posted January 12, 2009 Author Share Posted January 12, 2009 (edited) Sorry guys & gals I am not having much luck with this... what am I doing wrong?I am playing around with the example of StringInStr but am unable to locate the word ring.Writing to this is no problem now, thanks iHondaWhile 1 $line = FileReadLine(@DesktopDir & "\example.txt") $string = StringInStr($line, "ring") If $string = "ring" Then MsgBox(0, "Search result:", $string) ExitLoop EndIf WEnd Edited January 12, 2009 by DarkBoost Link to comment Share on other sites More sharing options...
BrettF Posted January 12, 2009 Share Posted January 12, 2009 Hi, Check this out. It has the option to be expanded by adding additional case statements. $file = FileOpen(@ScriptDir & "\example.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 $line = FileReadLine($file) Select Case @error = -1 MsgBox (0, "Search Result", "End Of File was met") ExitLoop Case StringInStr($line, "ring") MsgBox (0, "Search Result", $line) ExitLoop EndSelect WEnd FileClose($file) Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
DarkBoost Posted January 14, 2009 Author Share Posted January 14, 2009 (edited) That works and makes sense. Thanks for taking the time to write this -> BrettFWhilst on the subject I am trying to achieve something similar. I have created my first INI file which has a line eg. SN=1111-2222-3333-4444and whilst it performs the Automated install of the application I would like it to enter this information however it is required in separate boxes.I can do it manually as shown below, however the number will be different most times, hence the INI file.WinWait("Test Script", "") ControlClick("Test Script", "", "[CLASS:Edit; INSTANCE:1]","1111") ControlClick("Test Script", "", "[CLASS:Edit; INSTANCE:2]","2222") ControlClick("Test Script", "", "[CLASS:Edit; INSTANCE:3]","3333") ControlClick("Test Script", "", "[CLASS:Edit; INSTANCE:4]","4444")I can read the INI file ok using -> IniRead however would like to know how I can just read/input the first 4 digits and then the next 4 digits and so on. As I am not sure of what function I will need to use I find it hard to get the answer from the Help File. Sorry guys Edited January 14, 2009 by DarkBoost Link to comment Share on other sites More sharing options...
BrettF Posted January 14, 2009 Share Posted January 14, 2009 What are you trying to install? There is a chance it could be done silently. Good job on finding the INIFunctions. Maybe something like this? $sString = "923A-5928-8FJA-48SB" $aSplit = StringSplit ($sString, "-") For $i = 1 to $aSplit[0] MsgBox (0, "", $aSplit[$i]) ControlSetText ("Title", "", "[Class:Edit; Instance:" & $i, $aSplit[$i]) Next Also, take a look at ControlSend/ControlSetText. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
DarkBoost Posted January 14, 2009 Author Share Posted January 14, 2009 (edited) Although I am not 100% sure what all this is doing, some new to me functions in there, however it works perfectly! Edited January 14, 2009 by DarkBoost Link to comment Share on other sites More sharing options...
BrettF Posted January 14, 2009 Share Posted January 14, 2009 Well glad to hear it! Just continue to read the helpfile, and study examples to try see whats happening. Then you will be sure whats happening. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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