avery Posted March 27, 2009 Posted March 27, 2009 I try not to make things global unless necessary -- not really sure why I just figured it took more memory and was thought to be bad coding style. ($var1, $var2) = _ini($file_name, $log_file) func _ini($file_name, $log_file) #cs [EventArc] DESTINATION=C:\Program Files\NISP_UTILITIES LOGFILE=C:\Program Files\NISP_UTILITIES\EventArc.txt #ce local $_file_name = IniRead(@ScriptDir & "\EventArc.ini", "EventArc", "DESTINATION", $file_name) local $_log_file = IniRead(@ScriptDir & "\EventArc.ini", "EventArc", "LOGFILE", $log_file) ;ConsoleWrite($var & @CRLF) return($_file_name, $_log_file) EndFunc The above example doesn't seem to produce the results I expected Can anyone point me in the right direction please? Should I just make these variables global and be done with it? Thanks Again, Avery www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org
Valik Posted March 27, 2009 Posted March 27, 2009 Pass the arguments ByRef or return an array. Multiple return values aren't supported.
Yashied Posted March 27, 2009 Posted March 27, 2009 ... or return a structure. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Valik Posted March 27, 2009 Posted March 27, 2009 ... or return a structure.You should be shot for even thinking this, much less suggesting it. DllStruct is not a general data storage facility.
Yashied Posted March 27, 2009 Posted March 27, 2009 You should be shot for even thinking this, much less suggesting it. DllStruct is not a general data storage facility. Sorry, but I mean the following. $tSTRUCT = '...' $Size = ... $hMem = _MemGlobalAlloc($Size) $pMem = _MemGlobalLock($hMem) $pStruct = DllStructCreate($tSTRUCT, $pMem) DllStructSetData($pStruct, ...) _MemGlobalUnlock($hMem) _MyFunc($hMem) But if it came about that, Valik, look at _WinAPI_GetWindowPlacement() function from the AutoIt package. It returns a structure. Why? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Valik Posted March 27, 2009 Posted March 27, 2009 Sorry, but I mean the following. $tSTRUCT = '...' $Size = ... $hMem = _MemGlobalAlloc($Size) $pMem = _MemGlobalLock($hMem) $pStruct = DllStructCreate($tSTRUCT, $pMem) DllStructSetData($pStruct, ...) _MemGlobalUnlock($hMem) _MyFunc($hMem)Wow, you took stupid to a whole new level there. Uhh, congratulations. I guess? But if it came about that, Valik, look at _WinAPI_GetWindowPlacement() function from the AutoIt package. It returns a structure. Why?Are you really this stupid? The WinAPI functions are wrappers around DllCall() and DllStruct stuff. It is the exact expected use for DllStruct. Passing arbitrary information around is stupid. Passing information to or receiving information from a DLL is the intended purpose. That's why it's called DllStruct. Not just Struct. Get it?
SpookMeister Posted March 27, 2009 Posted March 27, 2009 I love Valik... he's so refreshingly free of <insert politically correct terminology here> [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
Yashied Posted March 27, 2009 Posted March 27, 2009 Wow, you took stupid to a whole new level there. Uhh, congratulations. I guess?Are you really this stupid? The WinAPI functions are wrappers around DllCall() and DllStruct stuff. It is the exact expected use for DllStruct. Passing arbitrary information around is stupid. Passing information to or receiving information from a DLL is the intended purpose. That's why it's called DllStruct. Not just Struct. Get it?I think that in some cases it may be useful. But I will not argue with you, Valik. In general, I agree with you. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Valik Posted March 27, 2009 Posted March 27, 2009 I think that in some cases it may be useful. But I will not argue with you, Valik. In general, I agree with you. It is only useful to people too lazy or too stupid to come up with a more elegant solution to the problem even after one of the developers flat out says "you shouldn't do that".
Yashied Posted March 27, 2009 Posted March 27, 2009 It is only useful to people too lazy or too stupid to come up with a more elegant solution to the problem even after one of the developers flat out says "you shouldn't do that".Valik, then please tell me how to AutoIt, you can "bind" variable for a given area of memory? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Valik Posted March 27, 2009 Posted March 27, 2009 Valik, then please tell me how to AutoIt, you can "bind" variable for a given area of memory?Please tell me why you need to do it outside the context of needing to pass memory to a DLL?
BrettF Posted March 27, 2009 Posted March 27, 2009 You don't.Just do as he says. Use ByRef (example 1) or arrays (example 2).Example 1:Dim $var1 Dim $var2 $ret = _ChangeVars ("I", $var1, $var2) MsgBox (0, "", "$ret = " & $ret & @CRLF & "$var1 = " & $var1 & @CRLF & "$var2 = " & $var2) Func _ChangeVars ($name, ByRef $r1, ByRef $r2) $r1 = "This is a return value?" $r2 = "This is another!" Return "The function was successful!" EndFuncExample 2:$ret = _ChangeVars() MsgBox(0, "", "$ret[0] = " & $ret[0] & @CRLF & _ "$ret[1] = " & $ret[1] & @CRLF & _ "$ret[2] = " & $ret[2]) Func _ChangeVars() Local $aRet[3] $aRet[0] = "This is a return value?" $aRet[1] = "This is another!" $aRet[2] = "The function was successful!" Return $aRet EndFunc ;==>_ChangeVars Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Yashied Posted March 27, 2009 Posted March 27, 2009 Please tell me why you need to do it outside the context of needing to pass memory to a DLL?This extends the possibilities of language programming.I had a few moments when there was such a need. I kept the data in the heap. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Yashied Posted March 27, 2009 Posted March 27, 2009 You don't.Just do as he says. Use ByRef (example 1) or arrays (example 2).I do not argue that Valik rights. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Valik Posted March 27, 2009 Posted March 27, 2009 (edited) This extends the possibilities of language programming. I had a few moments when there was such a need. I kept the data in the heap. Don't confuse "I'm not smart enough to solve this problem" with "I needed to abuse the language to solve this problem". Storing data on the heap in AutoIt is stupid and unnecessary unless you are interacting with a DLL with that memory. Any other use is just poor design on your part. You and people like you are the reason we can't have a more convenient syntax for DllStruct. We can't add something nice like: DllStruct int data char[256] string EndDllStruct People like you will abuse that and try to use it for things it shouldn't be used for. But, I guess you know better than a developer. Carry on. Edited March 27, 2009 by Valik
Yashied Posted March 28, 2009 Posted March 28, 2009 (edited) Valik, you gave me a tool (AutoIt), I applied it, but not quite in accordance with the instruction, but the result turned out positive, and consequently, I was satisfied with this tool. The fact that I have used this tool is not in accordance with the instructions, you have successfully explained to me, thank you for that. DllStruct int data char[256] string EndDllStructI think it's a good idea. But it is not for this topic. Wow, you took stupid to a whole new level there. Uhh, congratulations. I guess? Valik, my profession, too, is based on constant communication with people, most of them are very stubborn. I constantly have to prove to them the obvious and a lot of time explaining to them the same thing. I well understand you. Good luck to you. Edited March 28, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
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