NEOhidra Posted January 17, 2016 Share Posted January 17, 2016 I need to work with a file with structure like this: [Contract] ContractDate=15.04.2015 ContractNumber=0000325 DoctorFName=FirstName DoctorSName=LastName The order may varies. In order to extract names i use this script: for /f "delims=" %%A in ('%~dp0tools\grep\grep "FName=" Contract.ini') do set "name1=%%A" echo %name1% > name1.txt for /f "delims=" %%B in ('%~dp0tools\grep\grep "LName=" Contract.ini') do set "name2=%%B" echo %name2% > name2.txt FOR /F "tokens=2 delims== " %%C IN (name1.txt) DO SET "first=%%C" FOR /F "tokens=2 delims== " %%D IN (name2.txt) DO SET "last=%%D" del name1.txt del name2.txt set fullname=%first% %last% but can it be simplified by AutoIt? For the last part i can use $Return = StringSplit ($string, "=") in order to extract the string after = but can AutoIt extract these lines instead of grep? Or directly from the file? If not how can i use grep from AutoIt? The example below doesnt work for me (starting the script from greps folder). $string = Run('grep.exe "FName=" Contract.ini', "", @SW_HIDE) $Return = StringSplit ($string, "=") For $i = 2 to $Return[0] MsgBox (0, $i, $Return[$i]) Next Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 17, 2016 Moderators Share Posted January 17, 2016 NEOhidra, That looks like a standard ini file format, so IniRead should be able to get the data very easily. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
NEOhidra Posted January 17, 2016 Author Share Posted January 17, 2016 (edited) Thank you Melba23! Thats great solution! I have much more questions but one i doubt will find a solution for is - how to combine two variable? Is there some better solution then: $fullname = $sFName & ' ' & $sLName And one last last question. I need to insert the variable content into a text encased in double quotes. But then the variable name will be printed. Is there a way to change that behavior? Edited January 17, 2016 by NEOhidra Link to comment Share on other sites More sharing options...
mikell Posted January 17, 2016 Share Posted January 17, 2016 ? $var = "string" $newtext = '"' & 'start ' & $var & ' end' & '"' Msgbox(0,"", $newtext) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 17, 2016 Moderators Share Posted January 17, 2016 NEOhidra, That is the required AutoIt syntax for concatenating strings - nothing better! As to the variable, just concatenate when you want the value: "The variable value is " & $vVar & " while the variable name is $vVar" M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
NEOhidra Posted January 17, 2016 Author Share Posted January 17, 2016 Thank you for the tips! Whey all work for Msgboxes but not with run. Here is what i am struggling with: RunWait ( 'sendEmail.exe -f sender@mail.com -t recepient@mail.com -u "Error!" -m "Check " & $fullname & " instalation!" -a processes.txt -s mail.com:25 -xu sender@mail.com -xp passwd', "", @SW_HIDE ) Jugging by your answers AutoIt wont do it i suppose. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 17, 2016 Moderators Share Posted January 17, 2016 (edited) NEOhidra, Of course it will - you just need to tell it which are the required quotes and which are the string delimiters. Best is to keep the single as delimiters so this should work: RunWait ( 'sendEmail.exe -f sender@mail.com -t recepient@mail.com -u "Error!" -m "Check "' & $fullname & '" instalation!" -a processes.txt -s mail.com:25 -xu sender@mail.com -xp passwd', "", @SW_HIDE ) M23 Edited January 17, 2016 by Melba23 Wrong box Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
NEOhidra Posted January 17, 2016 Author Share Posted January 17, 2016 @Melba23 Thank you once more! Now AutoIt works fine. 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