 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Titan
Joined: 11 Aug 2004 Posts: 5048 Location: imaginationland
|
Posted: Tue Jan 01, 2008 6:45 pm Post subject: |
|
|
Thanks it's been fixed. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Jan 01, 2008 9:19 pm Post subject: |
|
|
| bmcclure wrote: | | Can't the first parameter be removed since it doesn't matter what was in the variable before and it's returned by the function? |
| Titan wrote: | | Thanks it's been fixed. |
...I'm surprised Titan...no complaints, just "ok!"...if you are going for 100% compatibility (same syntax for command & function), I think it should be...
| Code: | ;//Command Syntax: IniRead, OutputVar, Filename, Section, Key[, Default]
IniRead(ByRef OutputVar, Filename, Section, Key, Default = "") {
IniRead, OutputVar, %Filename%, %Section%, %Key%, %Default%
return, OutputVar
} |
...I would expect you to think that command & function syntax should match...
Actually that might complain too much about the ByRef, so maybe this would be better...
| Code: | ;//Command Syntax: IniRead, OutputVar, Filename, Section, Key[, Default]
IniRead(p_OutputVar, Filename, Section, Key, Default = "") {
IniRead, OutputVar, %Filename%, %Section%, %Key%, %Default%
%p_OutputVar%:=OutputVar
return, OutputVar
} |
...then you could call it with an OutputVar name or just "" for blank...I don't think ByRef's can be the emtpy string, so that workaround would allow it...testing code...
| Code: | ret:=IniRead(OutputVar, Filename, Section, Key, Default)
ret:=IniRead("", Filename, Section, Key, Default)
ret:=IniRead("OutputVar", "123.ini", "Section", "Key", "Default")
ret:=IniRead("", "123.ini", "Section", "Key", "Default")
IniRead(OutputVar, "123.ini", "Section", "Key", "Default") |
...ret & OutputVar should match if both are specified, otherwise return value is in ret only or OutputVar only... |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5048 Location: imaginationland
|
Posted: Tue Jan 01, 2008 9:35 pm Post subject: |
|
|
| JSLover wrote: | | I would expect you to think that command & function syntax should match | No I don't. My intentions with this library since the beginning was to make a function of every command that had an OutputVar which would return its value rather than saving it to a variable. This provides greater flexibility with use in expressions, and makes your code that little bit shorter. Multiple output commands are obviously an exception and I only implemented them on a whim since they break consistency. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 446
|
Posted: Tue Jan 01, 2008 9:51 pm Post subject: |
|
|
I agree with Titan also. The great part about these functions is that you can chain them together in many cases, since they return the result directly.
If you used a ByRef, or asked for the OutputVar as a parameter, you would have to keep it to one IniRead (or whatever command) per line.
It would just be redundant to keep the 'v' parameter in there, since it's not and doesn't need to be a ByRef, and the function doesn't care what the value of the output var is since it gets overwritten anyway.
And I do completely agree with the ByRefs on the string commands since it avoids re-reading the whole string as it's passed to each function, especially helpful for really long strings.
I'm happy with the changes  _________________ -Ben
SteamLab
SteamLab Wiki
[Broken] - My industrial music [on GarageBand] |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 828 Location: The Interwebs
|
Posted: Mon May 26, 2008 8:32 am Post subject: |
|
|
Having a problem with Run()...
| The Error Message wrote: | Error in #include file "C:\[censored]\Lib\CommandFunctions.ahk": This dynamic variable is blank. If this variable was not intended to be dynamic, remove the % symbols from it.
Specifically: %v%
Line#
161: Return,v
162: }
163: {
164: RegRead,v,%RootKey%,%SubKey%,%ValueName%
165: Return,v
166: }
167: {
---> 168: Run,%Target%,%WorkingDir%,%Mode%,%v%
169: Return,v
170: }
171: {
172: SoundGet,v,%ComponentType%,%ControlType%,%DeviceNumber%
173: Return,v
174: }
175: {
---------------------------
OK
--------------------------- |
...Errr. Don't really know what to do with this? x_x
Edit: Nvm, found the problem... thought it was referring to %target%, just noticed it was actually %v%, removed the %'s and it worked fine. So, if anyone else has this problem.. just remove the %'s... yea.. |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 264
|
Posted: Mon Jun 23, 2008 8:46 pm Post subject: |
|
|
i thought it was in the library already
| Code: | If ProcExist("Notepad.exe")
WinClose,% "ahk_pid " Errorlevel
|
| Code: | ProcExist(PID_or_Name=""){
Process, Exist, % (PID_or_Name="") ? DllCall("GetCurrentProcessID") : PID_or_Name
Return Errorlevel
} |
_________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|