Jump to content

Simplifying Search Results


Go to solution Solved by Nine,

Recommended Posts

Good day,
I hope that the day finds you well!

Is there any way to simplify a multiple folder|file search to be displayed n a MsgBox?

The following is what I am employing at the moment, but this example is rather time-consuming:

; -----------------------------------------------
Func _CheckIfSrcDataExists()
    ; ------------------------------------------------
    ; Source data
    Local $sProgramFilesCommonFilesFolder = "C:\Program Files\Common Files\Native Instruments"
    Local $sProgramFilesFolder = "C:\Program Files\Native Instruments"
    Local $sAmpsimFolder = "C:\RML\SAC\VST_PlugIns\Ampsim"
    Local $sAmpsimIniFilePath = "C:\RML\SAC\VST_PlugIns\Ampsim.ini"
    Local $sAppDataFolderPath = "C:\Users\Dell\AppData\Local\Native Instruments"
    Local $sQuickLaunchFilePath = "C:\Users\Dell\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Guitar Rig 5.lnk"
    Local $sSystem32_1FilePath = "C:\Windows\System32\msvcp120.dll"
    Local $sSystem32_2FilePath = "C:\Windows\System32\msvcr120.dll"
    Local $sWOW64_1FilePath = "C:\Windows\SysWOW64\msvcp120.dll"
    Local $sWOW64_2FilePath = "C:\Windows\SysWOW64\msvcr120.dll"
    Local $sTextFolderPath = "E:\Text\Native Instruments"
    ; ------------------------------------------------
    If FileExists($sProgramFilesCommonFilesFolder) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sProgramFilesCommonFilesFolder & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sProgramFilesCommonFilesFolder & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sProgramFilesFolder) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sProgramFilesFolder & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sProgramFilesFolder & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sAmpsimFolder) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sAmpsimFolder & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sAmpsimFolder & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sAmpsimIniFilePath) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sAmpsimIniFilePath & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sAmpsimIniFilePath & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sAppDataFolderPath) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sAppDataFolderPath & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sAppDataFolderPath & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sQuickLaunchFilePath) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sQuickLaunchFilePath & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sQuickLaunchFilePath & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sSystem32_1FilePath) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sSystem32_1FilePath & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sSystem32_1FilePath & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sSystem32_2FilePath) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sSystem32_2FilePath & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sSystem32_2FilePath & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sWOW64_1FilePath) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sWOW64_1FilePath & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sWOW64_1FilePath & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sWOW64_2FilePath) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sWOW64_2FilePath & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sWOW64_2FilePath & " ...does not exist!", 2)
    EndIf
    ; ----------------
    If FileExists($sTextFolderPath) Then
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sTextFolderPath & " ...does exist!", 2)
    Else
        MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $sTextFolderPath & " ...does not exist!", 2)
    EndIf
    ; ----------------
EndFunc   ;==>_CheckIfSrcDataExists
; ------------------------------------------------

As can be observed, there IS a considerable amount of redundancy here!

I would like to display the results in a MsgBox:

MsgBox(64, 'Results!', _            
    $sProgramFilesCommonFilesFolder & @CRLF & _
    $sProgramFilesFolder & @CRLF & _
    $sProgramDataTemp_1Folder & @CRLF & _
    $sProgramDataTemp_2Folder & @CRLF & _
    : and so on...
    ")

Any assistance in this matter would be greatly appreciated!

Edited by mr-es335
Link to comment
Share on other sites

Not exactly sure what you are asking but there you go :

#include <Array.au3>
#include <Constants.au3>
#include <WinAPIFiles.au3>

_WinAPI_Wow64EnableWow64FsRedirection(False) ; since some files/folder are in windows folder

Local $sResult = CheckIfSrcDataExists()
MsgBox($MB_SYSTEMMODAL, "Results!", $sResult)

Func CheckIfSrcDataExists()
  Local $aPath[] = ["C:\Program Files\Common Files\Native Instruments", _
      "C:\Program Files\Native Instruments", _
      "C:\RML\SAC\VST_PlugIns\Ampsim", _
      "C:\RML\SAC\VST_PlugIns\Ampsim.ini", _
      "C:\Users\Dell\AppData\Local\Native Instruments", _
      "C:\Users\Dell\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Guitar Rig 5.lnk", _
      "C:\Windows\System32\msvcp120.dll", _
      "C:\Windows\System32\msvcr120.dll", _
      "C:\Windows\SysWOW64\msvcp120.dll", _
      "C:\Windows\SysWOW64\msvcr120.dll", _
      "E:\Text\Native Instruments"]
  For $i = 0 To UBound($aPath) - 1
    If FileExists($aPath[$i]) Then
      MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $aPath[$i] & " ...does exist!", 2)
    Else
      MsgBox($MB_SYSTEMMODAL, "Confirm if Folder|Data Exists", $aPath[$i] & " ...does not exist!", 2)
    EndIf
  Next
  Return _ArrayToString($aPath, @CRLF)
EndFunc   ;==>CheckIfSrcDataExists

 

Edited by Nine
Link to comment
Share on other sites

Posted (edited)

NIne,

Thank you for the reply...appreciated!

"WOW!" and "Double WOW!"

I am attempting to avoid the "cycling through" of the listing.

What I am looking to do is to list the contents of the search in a MsgBox with a "Yes" or a "No" in response of the search.

For example:

Results of search:
C:\Program Files\Common Files\Native Instruments Yes
C:\Program Files\Native Instruments No
C:\RML\SAC\VST_PlugIns\Ampsim No
C:\RML\SAC\VST_PlugIns\Ampsim.ini Yes.

Something akin to the attached...
 

Thanks again, Nine!

PS: Have you ever watched "Dr. Phibes Rises Again". Vincent Prices =, as Dr Phibes, has a very interesting employment of the term "nine".

sample.png

Edited by mr-es335
Link to comment
Share on other sites

Just add a new column to $aPath before the loop with _ArrayColInsert ($aPath, 1).  In the loop assign $aPath[$i][1] = <result of search Yes or No>.  Modify _ArrayToString accordingly.

ps.  Nope never watched that.  I mostly watch french TV.  What would that employment be ?  FYI, Nine comes from one of the Beatles song (well if we can call it a song ;))...

Edited by Nine
Link to comment
Share on other sites

Nine,

Can you provide me with a simple example that I can build upon?

In the movie, 9 doctors were involved in performing surgery on Phibes' wife.

As can be expected, the surgery did not go as expected. Thus, Phibes goes on a "vengeance is mine" spree stating, "Nine times nine is nine!" "Nine killed her...nine must die!"

• My apologies, the movie is actually called, "The Abominable Dr Phibes".

Link to comment
Share on other sites

  • Solution

Something like this :

#include <Array.au3>
#include <Constants.au3>
#include <WinAPIFiles.au3>

_WinAPI_Wow64EnableWow64FsRedirection(False) ; since some files/folder are in windows folder

Local $sResult = CheckIfSrcDataExists()
MsgBox($MB_SYSTEMMODAL, "Results!", $sResult)

Func CheckIfSrcDataExists()
  Local $aPath[] = ["C:\Program Files\Common Files\Native Instruments", _
      "C:\Program Files\Native Instruments", _
      "C:\RML\SAC\VST_PlugIns\Ampsim", _
      "C:\RML\SAC\VST_PlugIns\Ampsim.ini", _
      "C:\Users\Dell\AppData\Local\Native Instruments", _
      "C:\Users\Dell\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Guitar Rig 5.lnk", _
      "C:\Windows\System32\msvcp120.dll", _
      "C:\Windows\System32\msvcr120.dll", _
      "C:\Windows\SysWOW64\msvcp120.dll", _
      "C:\Windows\SysWOW64\msvcr120.dll", _
      "E:\Text\Native Instruments"]
  _ArrayColInsert($aPath, 1)
  For $i = 0 To UBound($aPath) - 1
    $aPath[$i][1] = FileExists($aPath[$i][0]) ? "Yes" : "No"
  Next
  Return _ArrayToString($aPath, "  ")
EndFunc   ;==>CheckIfSrcDataExists

ps. I may watch that movie sometime :)

Link to comment
Share on other sites

NIne,

Again...."WOW!", "Double WOW!"...and even, "Tripple WOW!"

I would gladly give a portion of my anatomy to be able to think the way in which some of you think! Maybe such "thinking processes" are pretty mundane for you...but not so...to me anyhow.

Such "cranial deprivation" issues are never more evident than when it comes to "arrays".
• I remember a cute tid-bit abut a young programmer who, upon his first time hearing about arrays, thought that this conversation was all about "financial incentives"!

Anyhow, None-x-Nine=Nine! Thank you so, very, very much for your assistance and your examples. Both are very much appreciated and are indeed provocative!

PS: A closing snippet for you: "A teacher takes a hand, opens a mind, and touches a heart."

Link to comment
Share on other sites

Good day,
I hope that the day finds you well!

With the assistance of Nine, I was able to rectify one of my present issues.

In these "routines" I am checking  both source data and destination data.
• The source data has "fixed" paths
• However, the destination data has variable paths based on the same of the destination folder - in the form of "Install_1a, Install_2b...and so on.

Thus, I have been employing the following - all with success:

; -----------------------------------------------
#include <AutoItConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; ------------------------------------------------
_GetSrcDir()
_CheckDstData()
Func _GetSrcDir()
    ; ------------------------------------------------
    Global $sInstallationFolder = ""
    ; ------------------------------------------------
    $sInstallationFolder = InputBox("NOTICE!", "Enter the current installation folder name...", "", "", 275, 140)
    ; ----------------
    If @error = 1 Then
        Exit
    EndIf
EndFunc   ;==>_GetSrcDir
; ------------------------------------------------
Func _CheckDstData()
    ; ------------------------------------------------
    ; Source data
    Local $sInstallationFolderPath = "I:\Guitar_Rig\Installations\"
    Local $sDataRegKeysAddMeDataFile = "\Data\Reg_Keys\add_me.reg"
    ; ------------------------------------------------

    If FileExists($sInstallationFolderPath & $sInstallationFolder & $sDataRegKeysAddMeDataFile) Then
        MsgBox($MB_ICONINFORMATION, "Confirm if Folder|Data Exists", $sDataRegKeysAddMeDataFile & " ...does exist!", 3)
    Else
        MsgBox($MB_ICONINFORMATION, "Confirm if Folder|Data Exists", $sDataRegKeysAddMeDataFile & " ...does not exist!", 3)
    EndIf
EndFunc   ;==>_CheckDstData
; ------------------------------------------------

However, when attempting to incorporate Nine's ever-so-excellent suggestion - which works fine with source data, I am having issues with the destination data.

For example.. the following...

; -----------------------------------------------
#include <Array.au3>
#include <AutoItConstants.au3>
#include <Constants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; ------------------------------------------------
_WinAPI_Wow64EnableWow64FsRedirection(False)
; ------------------------------------------------
_GetSrcDir()
_CheckDstData()
Func _GetSrcDir()
    ; ------------------------------------------------
    Global $sInstallationFolder = ""
    ; ------------------------------------------------
    $sInstallationFolder = InputBox("NOTICE!", "Enter the current installation folder name...", "", "", 275, 140)
    ; ----------------
    If @error = 1 Then
        Exit
    EndIf
EndFunc   ;==>_GetSrcDir
; ------------------------------------------------
Func _CheckDstData()
    ; ------------------------------------------------
    ; Source data
    Local $sInstallationFolderPath = "I:\Guitar_Rig\Installations\"
    Local $sDataRegKeysAddMeDataFile = "\Data\Reg_Keys\add_me.reg"
    ; ----------------
    Local $sResult = _CheckDstData()
    MsgBox($MB_ICONINFORMATION, "   Search Results!", $sResult)
    Local $aPath[] = [$sInstallationFolderPath & $sInstallationFolder & $sDataRegKeysAddMeDataFile]
    ; ----------------
    _ArrayColInsert($aPath, 1)
    ; -----------------
    For $i = 0 To UBound($aPath) - 1
        $aPath[$i][1] = FileExists($aPath[$i][0]) ? "Yes" : "No"
    Next
    Return _ArrayToString($aPath, "  ")
EndFunc   ;==>_CheckDstData
; ------------------------------------------------

...produces the attached error...

Any comments and/or suggestions?

Any assistance in this matter would be greatly appreciated!

error.png

Link to comment
Share on other sites

Posted (edited)

Good day,

Well, I do believe that I have solved my current predicament!

; -----------------------------------------------
#include <Array.au3>
#include <AutoItConstants.au3>
#include <Constants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; ------------------------------------------------
_WinAPI_Wow64EnableWow64FsRedirection(False)
; ------------------------------------------------
_GetSrcDir()
_CheckDstData()
Func _GetSrcDir()
    ; ------------------------------------------------
    Global $sInstallationFolder = ""
    ; ------------------------------------------------
    $sInstallationFolder = InputBox("NOTICE!", "Enter the current installation folder name...", "", "", 275, 140)
    ; ----------------
    If @error = 1 Then
        Exit
    EndIf
EndFunc   ;==>_GetSrcDir
; ------------------------------------------------
; Source data
Local $sResult = _CheckDstData()
MsgBox($MB_ICONINFORMATION, "   Search Results!", $sResult)
; ------------------------------------------------
_CheckDstData()
; -----------------------------------------------
Func _CheckDstData()
    ; ------------------------------------------------
    ; Destintion data
    Local $aPath[] = ["I:\Guitar_Rig\Installations\" & $sInstallationFolder & "\Data\Reg_Keys\add_me.reg"] ; The updated and working text!!
    ; ----------------
    _ArrayColInsert($aPath, 1)
    ; -----------------
    For $i = 0 To UBound($aPath) - 1
        $aPath[$i][1] = FileExists($aPath[$i][0]) ? "Yes" : "No"
    Next
    Return _ArrayToString($aPath, "  ")
EndFunc   ;==>_CheckDstData
; ------------------------------------------------

Now for the means of being able to extend the width of the MsgBox!
• Observe the attached...

 

 

MsgBox.png

Edited by mr-es335
Link to comment
Share on other sites

In your example, you are running _CheckDstData() three times. No need for that, just run it once to get the results.

You cannot extend the width of a message box, so the text realign itself.  You will need to create your own message with a simple GUI. Or you could use this UDF :

 

 

Link to comment
Share on other sites

Use the UDF, it is much easier :

#include "ExtMsgBox.au3"

Local $sResult = "Very very long long test text that should be cut somewhere into the line, so need to be extended" & @CRLF & _
  "Yet, another Very very long long test text that should be cut somewhere into the line, so need to be extended" & @CRLF & _
  "Not so long test text that should be cut somewhere into the line, so need to be extended" & @CRLF & _
  "Quite short test text that should NOT be cut somewhere into the line"

_ExtMsgBoxSet(1, 0, Default, Default, Default, Default, 800)

_ExtMsgBox(64, "Ok", "Test", $sResult)

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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