mbkowns Posted October 29, 2007 Share Posted October 29, 2007 This information will be in a text file and I need to parse it for the Call # "" by itself and the Contact: "" by itself. I want to take the information and through it in a ini file. I had code that was similar to this before but its on my old work machine and is gone now. //INI FILE [Call] call1=91502 call2=91592 call3=93559 [Contact] contact1=Sandra Ferguson contact2=Darrell Hamlow contact3=Robert Hartman //INI FILE //TXT FILE Call # 91502 Contact: Sandra Ferguson Date: 8/30/2007 Phone: 352-6712/6711 Site: Harrison Elementary Location: Work order opened to configure thin clients at site, referenced work order # 91377 Call # 91592 Contact: Darrell Hamlow Date: 8/31/2007 Phone: (7496)x84045/9065029 Site: Maint. & Operations Location: Custodial/Grounds Dept. Dell Laptop (shop computer)--needs to be wireless accessible and serviced. NOTE: Darrell will get new Tag for this computer. Call # 93559 Contact: Robert Hartman Date: 9/25/2007 Phone: 7142 Site: Special Education Location: Special Education @ D.O. //TXT FILE Link to comment Share on other sites More sharing options...
iceberg Posted October 29, 2007 Share Posted October 29, 2007 hi there....sorry i dont get you can elaborate in more details... mouse not found....scroll any mouse to continue. Link to comment Share on other sites More sharing options...
weaponx Posted October 29, 2007 Share Posted October 29, 2007 Here you go. The _ArrayToString function below should allow for contact names with spaces i.e. Mary Anne Smith, Billy Jo Armstrong #include <File.au3> #include<array.au3> Dim $myArray Dim $filePath = @ScriptDir & "\file.txt" _FileReadToArray ( $filePath, $myArray) If @error Then MsgBox(0,"","Error opening specified file") EndIf For $X = 1 to $myArray[0] $callNumber = "" $contactName = "" If StringLeft ($myArray[$X], 4) = "Call" Then $tempArray = StringSplit($myArray[$X]," ") $callNumber = $tempArray[3] $contactName = _ArrayToString($tempArray," ", 5) MsgBox(0,"","Call #: " & $callNumber & @CRLF & "Contact: " & $contactName) EndIf Next Link to comment Share on other sites More sharing options...
mbkowns Posted October 29, 2007 Author Share Posted October 29, 2007 You Rock! Some of the names I need to pull have brackets in there names. That code you wrote pulls the whole name great! What I would also like to do is to pull the name in the brackets and keep the last name. So like this Currently Becky (Rebecca) Adame Create it like this Rebecca Adame Link to comment Share on other sites More sharing options...
weaponx Posted October 29, 2007 Share Posted October 29, 2007 #include <File.au3> #include<array.au3> Dim $myArray Dim $filePath = @ScriptDir & "\file.txt" _FileReadToArray ( $filePath, $myArray) If @error Then MsgBox(0,"","Error opening specified file") EndIf For $X = 1 to $myArray[0] $callNumber = "" $contactName = "" If StringLeft ($myArray[$X], 4) = "Call" Then $tempArray = StringSplit($myArray[$X]," ") $callNumber = $tempArray[3] $contactName = StringStripWS (StringRegExpReplace (_ArrayToString($tempArray," ", 5), "\(.*?\)", ""), 4) MsgBox(0,"","Call #: " & $callNumber & @CRLF & "Contact: " & $contactName) EndIf Next Link to comment Share on other sites More sharing options...
mbkowns Posted October 30, 2007 Author Share Posted October 30, 2007 Thanks Again works perfect 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