 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Laszlo
Joined: 14 Feb 2005 Posts: 3877 Location: Pittsburgh
|
Posted: Mon Jun 04, 2007 10:35 pm Post subject: |
|
|
| majkinetor wrote: | | The usage is not the problem. The problem is sharing. | Then I don't understand the problem: you have to pass the dictionary handle to a function as a parameter or make it global. The same is with the variable containing all of your constants. The later is faster and does not need includes or dll calls. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Wed Jun 06, 2007 7:21 am Post subject: |
|
|
Is there any limitation on OS? Does it run on all windows versions? _________________ Ciao
toralf  |
|
| Back to top |
|
 |
hoppfrosch
Joined: 25 Jan 2006 Posts: 15 Location: Somewhere in Germany
|
Posted: Thu Aug 09, 2007 7:09 am Post subject: Question: Hash of Hashes? |
|
|
Hi,
got a question concerning "Hash of Hashes" (considering dictionaries as hashes).
What I try to do is putting dictionary items into a dictionary:
| Code: |
#include %A_ScriptDir%\Includes\CoHelper.ahk
#Include %A_ScriptDir%\Includes\Dic.ahk
CoInitialize()
pdic := Dictionary()
Add(pdic, "ATT1", "ATT1_1")
Add(pdic, "ATT2", "ATT2_1")
Add(pdic, "ATT3", "ATT3_1")
Add(pdic, "ATT4", "ATT4_1")
pdic2 := Dictionary()
Add(pdic2, "ENTRY1", pDic)
MsgBox, % "ENTRY1: " . "`n" . Enumerate(GetItem(pdic2, "ENTRY1"))
; Changing the contents of pDic
SetItem(pdic, "ATT1", "ATT1_2")
SetItem(pdic, "ATT2", "ATT2_2")
SetItem(pdic, "ATT3", "ATT3_2")
SetItem(pdic, "ATT4", "ATT4_2")
; Is pDic stored byVal or byRef? Unfortunately its stored byRef, so the old contents got lost ....
MsgBox, % "ENTRY1: " . "`n" . Enumerate(GetItem(pdic2, "ENTRY1"))
Release(pdic)
Release(pdic2)
CoUninitialize()
|
Doing the above - changing contents of pdic after inserting it into pdic2, also changes the inserted item in pdic2.
How can I store the contents of pdic in pdic2, instead of just storing the reference of pdic?
Thanks in advance
Hoppfrosch |
|
| Back to top |
|
 |
Azerty
Joined: 19 Dec 2006 Posts: 58 Location: France
|
Posted: Thu Aug 09, 2007 1:11 pm Post subject: |
|
|
| Chris wrote: | | Thanks for these great functions. I've linked to this topic from the bottom of the Arrays page. Does anyone know whether Windows 9x/NT supports Scripting.Dictionary? |
Hi
AFAIK, Scripting.Dictionary is implemented when WSH5.6 is installed. Since MS has a specific version for W98/NT4, it should be supported as well
Sean : thanks for this great work |
|
| Back to top |
|
 |
fade2gray
Joined: 21 Oct 2006 Posts: 12
|
Posted: Tue Oct 23, 2007 11:41 am Post subject: |
|
|
Hi, I arrived here by reading the help file on arrays.
I downloaded the Dictionary and CoHelper scripts, but running the example included in Dictionary.ahk results in:- | Quote: | Error at line63 in #include file "\path to\CoHelper.ahk ".
Line Text: Enumerate(penum, ByRef Result)
Error:Duplicate function definition |
The Enumerate() function has been defined in Dictionary.ahk as:-
| Code: | Enumerate(pdic)
{
DllCall(VTable(pdic, 20), "Uint", pdic, "UintP", penm)
VarSetCapacity(var, 8 * 2, 0)
Loop, % Count(pdic)
{
DllCall(VTable(penm, 3), "Uint", penm, "Uint", 1, "Uint", &var, "Uint", 0)
pKey := DecodeInteger(&var + 8)
DllCall(VTable(pdic, 9), "Uint", pdic, "Uint", &var, "Uint", &var)
pItm := DecodeInteger(&var + 8)
Unicode2Ansi(pKey, sKey)
Unicode2Ansi(pItm, sItm)
SysFreeString(pKey)
SysFreeString(pItm)
sKeys .= sKey . " : " . sItm . "`n"
}
DllCall(VTable(penm, 2), "Uint", penm)
Return sKeys
} |
and in CoHelper.ahk as:-
| Code: | Enumerate(penum, ByRef Result)
{
VarSetCapacity(varResult,16,0)
If (0 = hResult:=DllCall(NumGet(NumGet(1*penum)+12), "Uint", penum, "Uint", 1, "Uint", &varResult, "UintP", 0))
Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? Ansi4Unicode(bstr:=NumGet(varResult,8)) . SubStr(SysFreeString(bstr),1,0) : NumGet(varResult,8)
Return hResult
} |
Any comments please? |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3544 Location: Belgrade
|
Posted: Tue Oct 23, 2007 11:48 am Post subject: |
|
|
If i recall correctly COM.ahk replaced CoHelper.ahk. _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1141
|
Posted: Tue Oct 23, 2007 12:00 pm Post subject: |
|
|
| fade2gray wrote: | I downloaded the Dictionary and CoHelper scripts, but running the example included in Dictionary.ahk results in:- | Quote: | | Error at line63 in #include file "\path to\CoHelper.ahk ". |
|
Ah, recently I added Enumerate() to CoHelper.ahk while adding COM_Enumerate() to COM.ahk, completely forgetting about this Scripting.Dictionary (:yes, it's been deleted already from my HDD, all functions were replaced with Invoke()).
Are you gonna use it? I can safely remove Enumerate() from CoHelper.ahk.
However, I suggest to switch to Invoke()/COM_Invoke(). |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1141
|
Posted: Tue Oct 23, 2007 12:40 pm Post subject: |
|
|
| fade2gray wrote: | | Error at line63 in #include file "\path to\CoHelper.ahk ". |
I commented out Enumerate() in CoHelper.ahk. So, you may redownload it.
BTW, I recommend using COM.ahk over CoHelper.ahk, and COM_Invoke() function over the script(s) Scripting.Dictionary etc. |
|
| Back to top |
|
 |
fade2gray
Joined: 21 Oct 2006 Posts: 12
|
Posted: Tue Oct 23, 2007 5:54 pm Post subject: |
|
|
Thanks for the prompt replies.
I was trying to find a method to return multiple variables from a function (believing an array was the way to go) and have just figured how to use StringSplit. |
|
| Back to top |
|
 |
Phoenix
Joined: 23 Sep 2005 Posts: 39
|
Posted: Sun Feb 24, 2008 1:36 am Post subject: |
|
|
| How do I loop through the whole dictionary the best way? |
|
| Back to top |
|
 |
Phoenix
Joined: 23 Sep 2005 Posts: 39
|
Posted: Mon Apr 21, 2008 6:36 pm Post subject: |
|
|
*bump* I would like to know how to loop through through it  |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Apr 21, 2008 11:41 pm Post subject: |
|
|
| There is a function Enumerate in the script. |
|
| 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
|