mr-es335 Posted January 15 Posted January 15 (edited) Good day, There are two parts to this posting namely, Part A: An Introduction, and, Part B: The Question. If you do not have a desire to read Part A - which might be construed as "a rant" of sorts...to some...then please, feel free to do so. Part B, involves the "meat-and-potatoes" of this posting... Part A: An Introduction The scripts that I develop|create via AutoIt - along with the seemingly untiring assistance of others, is done so entirely for my own personal employment, and as such, such scripts were never intended to be employed by others! Thus, it would be safe-to-say, that most...if not all of my scripts, are, as a result, "hard-coded"! Now, according to "Purple Tutor", "hard coding"... "...refers to the practice of embedding specific values or data directly into the source code of a program or application instead of using a more flexible and dynamic approach." Regarding the first part of the above text, I have absolutely NO problem with! However, with the latter portion of this text - I most certainly DO!... "...instead of using a more flexible and dynamic approach." One should never condemn "objectivity" when they are simply too "subjectively" disposed to doing so! • Thus, is it being "objectively subjective", ...or... "subjectively objective"? And though I do not necessarily disagree with the above definition - which seems apropos to many others, I do disagree with the fact of almost being condemnatory to others who do, in fact, "...embed specific values or data directly into the source code". At the end-of-the-day, this "hard-coding" of specific values into the source code has absolutely no effect on precisely how this software was originally intended to be employed! "...'nuff said!" Part B: The Question However... In employing a more "...flexible and dynamic approach...", is it possible to employ "configuration data" in those situations where some may prefer a more "...less flexible and more static dynamic approach?" I am thinking of the employment of an .ini file here. For example, consider the following • See, Example A: Employing a less flexible and dynamic approach. • See, Example B: Employing a more flexible and dynamic approach. In the following example, the objective here is four-fold: 1) Either programmatically or manually, add data to an .ini file in the from of [Paths] SrcPath=C:\TestMe\Src SrcPath=C:\TestMe\Dst 2) For the SrcData, have a FileOpenDialog read the .ini file for the src path 3) For the DstData, have another FileOpenDialog read the .ini file for the dst path 4) Employ that data to copy the src data to the des location Here is what I have developed thus far: expandcollapse popup#cs Example B2: For .txt data Employing a more flexible and dynamic approach. No 'hard-coded" paths employed here! Results of ConsoleWrite Source folder and selected data: C:\TestMe\Destination|File1.txt|File2.txt Restoration folder: C:\TestMe\Source Paths for FileCopy: Source= C:\TestMe\Destination|File1.txt|File2.txt, Destination: C:\TestMe\Source #ce ; ----------------------------------------------- #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- RestoreTextData() ; ----------------------------------------------- ; Example B: Employing a more flexible and dynamic approach. Func RestoreTextData() Local $MyBox = MsgBox($MB_YESNO, "Notice!", "Restore Text Data?") ; ----------------- If $MyBox == 6 Then ; First, select the .txt data file Local Const $sMessage1 = "Select the .txt file(s) to restore..." ; <<<< A "User selected" source folder location"! >>>> Local $sSelectTxtFile = FileOpenDialog($sMessage1, "", "Text File (*.txt)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT)) ConsoleWrite("Source folder and selected data: " & $sSelectTxtFile & @CRLF) ; ----------------- ; SECTION B2 Fourth, select the restoration folder location for the txt data file(s) Local $sMessage3 = "Select a restoration folder..." ; <<<< A "User selected" destination folder location"! >>>> Local $sSelectScnDstData = FileSelectFolder($sMessage3, "") ConsoleWrite("Restoration folder: " & $sSelectScnDstData & @CRLF) ; ----------------- ; SECTION C: Copy the selected data ConsoleWrite("Paths for FileCopy: Source= " & $sSelectTxtFile & ", Destination: " & $sSelectScnDstData & @CRLF) ;~ RestoreWTxtData($sSelectTxtFile) ElseIf $MyBox == 7 Then EndIf EndFunc ;==>RestoreTextData ; ----------------------------------------------- Is the above example a "workable"approach? As always...any assistance in this matter would be greatly appreciated! Example A.au3 Example B.au3 Edited January 16 by mr-es335 Updated example script! mr-es335 Sentinel Music Studios
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