bigbamboom Posted January 20, 2020 Posted January 20, 2020 Hi I am trying to create an auto IT file that uses a ini file to gather data and create a customized message. xyz.com is the person's profile name is the person first name company is the person's company I would have an ini file with say 5-20 people on it - with link, name and company...and then create an Autoit which opens the link, and pastes Name, message and company .. into a message. Wondering if I could get thoughts on the ini file method? Is that the best way to store the data that my Autoit file would use? Is there a better way?
argumentum Posted January 20, 2020 Posted January 20, 2020 use sqLite. so... where is your sample code ? Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Musashi Posted January 20, 2020 Posted January 20, 2020 The suggestion of @argumentum (SQLite) is a very solid solution, when it comes to processing such data. SQLite is well supported by AutoIt, relatively easy to use and you will find tons of examples. Alternatively you could read the values from a text file (e.g. a .csv) and process them. A simple example : #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 #include <Array.au3> #include <File.au3> Global $sFilename = @ScriptDir & "\Data.csv" , $aDataArray, $iError _FileReadToArray($sFilename, $aDataArray, $FRTA_NOCOUNT, "|") $iError = @error If $iError Then ConsoleWrite("! ERROR : FileReadToArray File=" & $sFilename & " Error=" & $iError & @CRLF) Exit EndIf For $i = 0 To UBound($aDataArray) - 1 Step 1 ConsoleWrite(StringFormat("> Link=%-30s Name=%-30s Company=%-30s\n", $aDataArray[$i][0], $aDataArray[$i][1], $aDataArray[$i][2])) Next Without a script or further details, it is difficult to give a more detailed answer. Data.csv "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Subz Posted January 20, 2020 Posted January 20, 2020 A lot depends on who will be editing the source data, ini or csv is probably easier of the two as it's in plain text, only thing to remember with csv is that you need to make sure the delimiter will never be within first name or company name as in Musashi example using a pipe "|". Ini can still be useful as it has fairly straight forward structure as well, example: #cs @ScriptDir & "\Data.ini" [John.Doe@JDoe.com] First Name = John Company Name = JD Inc [Mark.Spencer@MSInc.com] First Name = Mark Company Name = MS Inc #ce Global $g_sProfiles = @ScriptDir & "\Data.ini" Global $g_aProfiles = IniReadSectionNames($g_sProfiles) If @error Then Exit Global $g_sFirstName, $g_sCompanyName For $i = 1 To $g_aProfiles[0] $g_sFirstName = IniRead($g_sProfiles, $g_aProfiles[$i], "First Name", "") If $g_sFirstName = "" Then ContinueLoop ;~ First Name key not found $g_sCompanyName = IniRead($g_sProfiles, $g_aProfiles[$i], "Company Name", "") If $g_sCompanyName = "" Then ContinueLoop ;~ Company Name key not found MsgBox(4096, $g_aProfiles[$i], "Hello " & $g_sFirstName & @CRLF & "We would like to know if your company " & $g_sCompanyName & " would be interested in...") Next
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