Jump to content

Recommended Posts

Posted

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

 

  • Moderators
Posted

NEOhidra,

That looks like a standard ini file format, so IniRead should be able to get the data very easily.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (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 by NEOhidra
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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.

  • Moderators
Posted (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 by Melba23
Wrong box

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...