Digi Posted November 7, 2006 Share Posted November 7, 2006 Hey there Guys and Girls its the annoying me again I need some help yet again. Im trying to find the Quickest and Smallest code to do this.... Open a text file...E.G. Applicationservers.txt and i need it to find the line that contains Server=***** But there are cases where server= only appears so i need it to look over that and only return the server=***** value.... can this be done???? Saru Mo Ki Kara Ochiru[u]Direct Translation[/u]: Even monkeys will fall from trees.[u]I.E.:[/u] To Error is HumanMy Splash Screen applet: Splash Screen Coding Link to comment Share on other sites More sharing options...
Fossil Rock Posted November 7, 2006 Share Posted November 7, 2006 #include <File.au3> _FileReadToArray($sFilePath, $aArray) StringInStr ( "string", "substring" [, casesense [, occurrence]] ) These should help you ... they're in the help file. Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Digi Posted November 7, 2006 Author Share Posted November 7, 2006 (edited) um...... Ok ......... I have no Clue whats happening or how i would use the two of these... sorry arrays are my kriptonite... i haven't got a clue how to work with them, Would you Please, Please, Please someone can you Give even just the basics that i could adjust slightly. with something like this. $pcasini = FileOpen ( "n:\comms\pcas\code\fta\pcas.ini" ,0 ) ; Check if file opened for reading OK If $pcasini = -1 Then MsgBox ( 0, "Error", "Unable to open file." ) EndIf ; Removes the Initial few letters from PCASINI file to leave only the servername. $servername = FileReadLine ( $pcasini , 7 ) $servername = StringMid ( $servername, 8 ) this i know works but if say $servename appears on anotherline i want to find it.... to give you a Idea the Pcasini file i am working with looks like this mostly, but does on occasion differs. %CoNfIg FiLe ; CAUTION!!! DO NOT MODIFY THIS FILE WITH ; AN EDITOR!!! ; [NWSAA_APPC] INTERRUPT=68 SERVER= SERVER= SERVER=Applications SERVER= PUPROF=GRPSAA PUPROF= PUPROF= PUPROF= ; [CPIC_INFO] SYMB_NAME=PCAS REMOTE_TP=TARA TP_TYPE=0 ;................ now servername changes position depending on who created the file. Sorry i know im being a ass, but I have been sitting trying to figure this out the last 3 days and i cant figure it, and like i say using a array might be great but i really suck at arrays....... So how would i Use the stringinstr command in this case. Edited November 7, 2006 by Digi Saru Mo Ki Kara Ochiru[u]Direct Translation[/u]: Even monkeys will fall from trees.[u]I.E.:[/u] To Error is HumanMy Splash Screen applet: Splash Screen Coding Link to comment Share on other sites More sharing options...
MadBoy Posted November 7, 2006 Share Posted November 7, 2006 Most of it is from HELPFILE and your script #include <file.au3> Dim $aRecords If Not _FileReadToArray("C:\test.ini",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] ;Msgbox(0,'Record:' & $x, $aRecords[$x]) If StringInStr($aRecords[$x], "Server=") Then $test_string = StringTrimLeft ( $aRecords[$x], 7 ) If $test_string <> "" Then MsgBox(0,1,$test_string) ; testing if it's working right ;) ; Do whatever you want with it here assing it to some variable or so ExitLoop EndIf EndIf Next My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Digi Posted November 7, 2006 Author Share Posted November 7, 2006 (edited) Wohoo thanks i actually understood more or less what was going on there now... lol *Drinks coffie* Just for the interests of all this is how mu function finally ended up looking.... thanks to you Both. (MadBoy and Fossil Rock) You both Answered my question, its just me being a lol Func Get() DriveMapAdd("N:", "\\" & $Servername & "\sys\", 0, $Mapname, $MapPass) If Not _FileReadToArray("n:\comms\pcas\code\fta\pcas.ini",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] If StringInStr($aRecords[$x], "Server=") Then $Servername = StringTrimLeft ( $aRecords[$x], 7 ) If $Servername <> "" Then ;~ MsgBox(0,1,$Servername) ; testing if it's working right ExitLoop EndIf EndIf Next If $servername = "" Then MsgBox(0,"error"," No servername found, PCAS.INI Error") EXIT EndIf DriveMapDel("N:") MsgBox(0, "Gateway server", "Gateway server is: " & $Servername & " : Servername has ben placed in clipboard") ClipPut ( $servername ) EndFunc Edited November 7, 2006 by Digi Saru Mo Ki Kara Ochiru[u]Direct Translation[/u]: Even monkeys will fall from trees.[u]I.E.:[/u] To Error is HumanMy Splash Screen applet: Splash Screen Coding 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