computergroove Posted March 19, 2012 Posted March 19, 2012 I have several strings: 1, John, Smith, john.smith@gmail.com,12/12/77,PO Box 592,Caledonia,MI,49316 2, Paul, Beck, Paulbeck@hotmail.com, 5/8/65,210 Short St, Grand Rapids, MI 49508 3..... What is the procedure to take this data from 'settings.ini' and choose a line and assign each of these coma seperated items to a value in my script? I.E. $Number = '1' $FirstName = 'John' $LastName = 'Smith' $Email = 'john.smith@gmail.com' $DOB = '12/12/77' $Address = 'PO Box 592' $City = 'Caledonia' $State = 'MI' $Zip = '49316' I want to run each line in settings.ini individually through my script and then begin processing the next line. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
water Posted March 19, 2012 Posted March 19, 2012 Use StringSplit to fill an array with teh required data. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
kspratik Posted March 19, 2012 Posted March 19, 2012 U can organize ur Ini file in this way [First Name] firstname="Prateek" [Last Name] last Name="Kumar" [Email Id] emailid="xyz@gmail.com" [DOB] dob="14/06/1990" [Address] add="abc" [City] city="Banglore" [state] state="karnataka" [Zip] zip="123...." Now use IniRead($filePath & $fileName,"Section name"," sub field of that section","default value which u want") ex : $FirstName=IniRead($filePath & $fileName,"First Name","firstname","") value of $FirstName=Prateek If u want to process each section one by one then organize ur ini file in this way [Person1] firstname= lastname= emai id= dob= address= city= state= zip= for next person [Person2] repeat the same thing I think u will get ur solution from this.
UEZ Posted March 19, 2012 Posted March 19, 2012 I wouldn't use here ini functionality here rather 2D arrays where you store all the data in. It is easier to handle an array than ini files whereas ini files are restricted to 32kb due to compatibility reasons. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
computergroove Posted March 19, 2012 Author Posted March 19, 2012 I wouldn't use here ini functionality here rather 2D arrays where you store all the data in.It is easier to handle an array than ini files whereas ini files are restricted to 32kb due to compatibility reasons.Br,UEZI am a bit confused by this. By 2D array do you mean place the data directly in my script rather than use an ini file? Can you show me an example based on my original post? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
water Posted March 19, 2012 Posted March 19, 2012 UEZ proposes to read the data from your file to an array.As the file is in CSV (comma separated values) format you could use this written bei ProgAndy to read the file and create a 2D-array. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
UEZ Posted March 19, 2012 Posted March 19, 2012 Assumption: your strings from your 1st post are in a file called settings.ini but without leading line numbers: #include <Array.au3> Global $aS = StringSplitW(FileRead(@ScriptDir & "settings.ini"), ",") _ArrayDisplay($aS) This will read the content of the settings.ini file and create a 2D array which can be processed appropriately. StringSplitW() can be found here: You can easily write back the 2D array to a file again. I hope this helps you. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
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