Jump to content
Sign in to follow this  
craigholohan

Message Box

Recommended Posts

craigholohan

Hi,

I am trying to make a little app that can be used to change text in a file, most is working but I am now stuck on getting a message bok to operate in a certain way.

Below is the bit of script I am having problems with, it works fine but what I want is when calling this function I would like a message box first telling me that "$findMAC " was found and in what line it was found then ask if I want to replace it with "replaceMAC", if "findMAC" was not found then message mus indecate "findMAC" was not found in "filename"

Func _changeMAC()

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer

$iMsgBoxAnswer = MsgBox(36,"INFO", "Are you sure you want to replace " & $findMAC & " with " & $replaceMAC)

Select

Case $iMsgBoxAnswer = 6 ;Yes

$retval = _ReplaceStringInFile($filename,$findMAC,$replaceMAC)

FileClose($filename)

GUICtrlDelete ($Edit_1)

$Readit = FileRead($filename)

$Edit_1 = GuiCtrlCreateEdit($Readit, 20, 30, 480, 390)

Case $iMsgBoxAnswer = 7 ;No

EndSelect

EndFunc

Please can someone point me into the right direction?

Thanks

Share this post


Link to post
Share on other sites
martin

Hi,

I am trying to make a little app that can be used to change text in a file, most is working but I am now stuck on getting a message bok to operate in a certain way.

Below is the bit of script I am having problems with, it works fine but what I want is when calling this function I would like a message box first telling me that "$findMAC " was found and in what line it was found then ask if I want to replace it with "replaceMAC", if "findMAC" was not found then message mus indecate "findMAC" was not found in "filename"

Func _changeMAC()

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer

$iMsgBoxAnswer = MsgBox(36,"INFO", "Are you sure you want to replace " & $findMAC & " with " & $replaceMAC)

Select

Case $iMsgBoxAnswer = 6 ;Yes

$retval = _ReplaceStringInFile($filename,$findMAC,$replaceMAC)

FileClose($filename)

GUICtrlDelete ($Edit_1)

$Readit = FileRead($filename)

$Edit_1 = GuiCtrlCreateEdit($Readit, 20, 30, 480, 390)

Case $iMsgBoxAnswer = 7 ;No

EndSelect

EndFunc

Please can someone point me into the right direction?

Thanks

Have a look at the function _ReplaceStringInFile in File.au3.

I expect you will be able to make sense of it. You could copy this function to your script, rename it to something and modify it to do what you want. Then call this function instead.

Does that make sense?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×