I’ve defined a private dictionary property which is populated via a recordset in a one of my methods.
Property definition:
Private assoc_env As dictionary
Initialized in the window’s Open event handler:
assoc_env = new Dictionary
Dictionary assignments inside the get_assoc_env() method
[code]
if position_param.RecordCount = 1 then
assoc_env.Value("server") = position_param.Field("server")
assoc_env.Value("share") = position_param.Field("share")
assoc_env.Value("G") = position_param.Field("pos_group")
assoc_env.Value("D") = position_param.Field("pos_dept")
assoc_env.Value("N") = position_param.Field("pos_node")
assoc_env.Value("script") = position_param.Field("script")
System.DebugLog assoc_env.Value("server")
System.DebugLog assoc_env.Value("share")
System.DebugLog assoc_env.Value("G")
System.DebugLog assoc_env.Value("D")
System.DebugLog assoc_env.Value("N")
System.DebugLog assoc_env.Value("script")
end if[/code]
The debugLog entries have the expected values.
After calling the method, I then output the values again to the DebugLog.
[code] if App.store = “099” then
StatusWindow.AppendText “Preparing to retrieve associate environment settings.” + EndOfLine + EndOfLine
get_assoc_env(PositionId)
System.DebugLog assoc_env.Value("server")
System.DebugLog assoc_env.Value("share")
System.DebugLog assoc_env.Value("G")
System.DebugLog assoc_env.Value("D")
System.DebugLog assoc_env.Value("N")
System.DebugLog assoc_env.Value("script")
MsgBox "quiting"
quit
end if[/code]
However, when I run it, it crashes with a “Debughlogin.exe has stopped working” window.
I added a breakpoint at the start of the DebugLog calls outside of the method and stepped thru it and inspected the status of the dictionary. I found that it had 6 keys, which is correct, but all keys and values were Nil.
What would cause it to loose the keys/values but retain the correct key count?
Would it be better to have the method return the dictionary instead of assigning the way I have done? If so, what is the proper syntax because so far my attempts have failed with the same crash as described above.