rudi Posted April 29, 2012 Share Posted April 29, 2012 (edited) Hi. I think I've seen this before, but can't find it, as I have no clue, what keywords to search for: from a INI file I'd like to read a section, specifying e.g. this: [MODI] @CommonFilesDir=\Microsoft Shared\MODI\11.0\MSPVIEW.EXE @CommonFilesDir=\Microsoft Shared\MODI\12.0\MSPVIEW.EXE [OIS] @ProgramFilesDir=\Microsoft Office\OFFICE11\OIS.EXE @ProgramFilesDir=\Microsoft Office\OFFICE12\OIS.EXE @ProgramFilesDir=\Microsoft Office\OFFICE14\OIS.EXE inireadsection() will return an array, where the first collumn will hold the macro's name as "string". Several Autoit Macros will return different values for WinXP, Win7-32 and Win7-64. How to "resolve" the macro's "name-in-a-string" to it's value? Regards, Rudi. <edit: typo> <edit2: modified topic title> Edited April 29, 2012 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
jaberwacky Posted April 29, 2012 Share Posted April 29, 2012 Are you asking about how to access the elements of a multi dimensional array? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
rudi Posted April 29, 2012 Author Share Posted April 29, 2012 (edited) Hi. Thanks for your reply. Nope. Dim $aMyArr[4][2] = [[3], _ ["@ProgramFilesDir", "Microsoft OfficeOFFICE11OIS.EXE"], _ ["@ProgramFilesDir", "Microsoft OfficeOFFICE12OIS.EXE"], _ ["@ProgramFilesDir", "Microsoft OfficeOFFICE14OIS.EXE"]] $ViewerFound = False For $i = 1 To $aMyArr[0][0] ; I do not know, how to resolve the value of "@programfilesdir", ; if I only have this string stored in a variable, as here... $foo = $aMyArr[$i][0] & $aMyArr[$i][1] ; <<< this does not work. $foo = Eval($aMyArr[$i][0]) & $aMyArr[$i][1] ; <<< this does not work either. If FileExists($foo) Then $ViewerFound = $foo Next Regards, Rudi. Edited April 29, 2012 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
rover Posted April 29, 2012 Share Posted April 29, 2012 Opt("ExpandVarStrings", 1) ["@ProgramFilesDir@", "Microsoft OfficeOFFICE11OIS.EXE"] I see fascists... Link to comment Share on other sites More sharing options...
rudi Posted April 30, 2012 Author Share Posted April 30, 2012 Pefect! Thanks to the Suggestion @Developers:Perhaps you might want to update the Autoit Help System, to reference this feature Opt("ExpandVarString",1)--> "Macro Reference"--> "Language Reference -> Variables"--> "Language Reference -> Macros"A question upon the functionality: What is going on backstage by using this "Double-@" syntax?"@Programfilesdir@" within a string, used normally just @programfilesdir...Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
guinness Posted April 30, 2012 Share Posted April 30, 2012 (edited) Pefect! Thanks to the Suggestion @Developers: Perhaps you might want to update the Autoit Help System, to reference this feature Opt("ExpandVarString",1) --> "Macro Reference" --> "Language Reference -> Variables" --> "Language Reference -> Macros" A question upon the functionality: What is going on backstage by using this "Double-@" syntax? "@Programfilesdir@" within a string, used normally just @programfilesdir... Regards, Rudi. Why? The Opt function should be used sparingly. Why not use this instead? Local $aArray[4][2] = [[3], _ [@ProgramFilesDir, 'Microsoft OfficeOFFICE11OIS.EXE'], _ [@ProgramFilesDir, 'Microsoft OfficeOFFICE12OIS.EXE'], _ [@ProgramFilesDir, 'Microsoft OfficeOFFICE14OIS.EXE']] ; Use Global or Local, not Dim. Local $sString = '' For $i = 1 To $aArray[0][0] $sString &= $aArray[$i][0] & $aArray[$i][1] & @CRLF Next MsgBox(4096, '', $sString)If there is a problem with macros reporting different values then provide a small reproducer, say what it should show and report it, but ask here before you submit it to Trac. Edited April 30, 2012 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
rudi Posted April 30, 2012 Author Share Posted April 30, 2012 (edited) Hi Guinnes. Why to update the documentation? Simply because an accurate and complete documentation is 90% of a software's value, imho.... I think it should be up to every coder, what features he/she want's to make use of, don't you think so? So that the Viewer Programs can be handled by editing an INI file (instead of recompiling the script), I need to read the @macro from that ini. If I don't want to use the @macro, then I would need to write the ini like this: [modi] XP-2003-DE=C:ProgrammeGemeinsame DateienMicrosoft SharedMODI11.0MSPVIEW.EXE XP-2003-EN=C:Program Files... XP-2007-DE=C:ProgrammeGemeinsame DateienMicrosoft SharedMODI12.0MSPVIEW.EXE XP-2007-EN=C:Program Files... XP-2010-DE=C:ProgrammeGemeinsame DateienMicrosoft SharedMODI14.0MSPVIEW.EXE XP-2010-EN=C:Program Files... Win7-2007-64=C:Program Files (x86)Common Filesmicrosoft sharedMODI12.0MSPVIEW.EXE Win7-2007-32=C:Program FilesCommon Filesmicrosoft sharedMODI12.0MSPVIEW.EXE ... all again for the few Win-XP-64 PCs in this LAN... [OIS] XP-2003=C:ProgrammeMicrosoft OfficeOFFICE11OIS.EXE .... When Using the Macro instead, it's far less to take care of: [MODI] 2003=@CommonFilesDir@Microsoft SharedMODI11.0MSPVIEW.EXE 2007=@CommonFilesDir@Microsoft SharedMODI12.0MSPVIEW.EXE [OIS] 2003=@ProgramFilesDir@Microsoft OfficeOFFICE11OIS.EXE 2007=@ProgramFilesDir@Microsoft OfficeOFFICE12OIS.EXE 2010=@ProgramFilesDir@Microsoft OfficeOFFICE14OIS.EXE This will work on WinXP, Win7-32, Win7-64, and any localisation language of Windows. That's the reason, why I will change it later this week, to prevent to run into trouble, when some new "windows flavor" will come into play. You see the benefit of using the "@Macro@ in a string"? Regards, Rudi. Edited April 30, 2012 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
guinness Posted April 30, 2012 Share Posted April 30, 2012 Why to update the documentation? Simply because an accurate and complete documentation is 90% of a software's value, imho....Correct, I help with updating the documentation so I know all too well how important it is.Why not use environment variables instead? Custom or system. If you need an example let me know? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Spiff59 Posted April 30, 2012 Share Posted April 30, 2012 Here's another option... $foo = Execute($aMyArr[$i][0]) & $aMyArr[$i][1] ; <<< this does work Link to comment Share on other sites More sharing options...
guinness Posted May 1, 2012 Share Posted May 1, 2012 rudi, Did you try my suggestion? As I've heard nothing back. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
rudi Posted July 6, 2012 Author Share Posted July 6, 2012 Hi guinnes, thanks for your suggestion to use env vars. I've tried it, it works. But I prefer to use the "Opt("ExpandVarStrings", 1)" approach: It's working smoothly, in the INI I can see clearly, what Marcro I'm using, and I personally do *NOT* have any antipathy against using "Opt()" , at least I can't currently see any constraints when making use of this "ExpandVarStrings" ? Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
PhoenixXL Posted July 8, 2012 Share Posted July 8, 2012 this even works Global $sString='AutoItVersion' ConsoleWrite(Execute('@'&$sString)&@CRLF) My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. 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