Never really had a need for IsDeclared or such-like, but came up with the following idea below. Anyone else have other ideas for usage?
[ autoit ]
#include <Constants.au3> #cs Idea for appending $ to the variable name in Assign by Yashied. Topic: http://www.autoitscript.com/forum/topic/122192-arraysort-and-eliminate-duplicates/#entry849187 #ce Example() Func Example() AssocAdd('ExampleString', 'This is a sample string') AssocAdd('This is a random string with a number', 100) MsgBox($MB_SYSTEMMODAL, '', AssocGet('ExampleString')) MsgBox($MB_SYSTEMMODAL, '', AssocGet('This is a random string with a number')) MsgBox($MB_SYSTEMMODAL, '', AssocGet('String doesn''t exist')) EndFunc ;==>Example Func AssocAdd($sStringName, $vValue) Local Const $iGlobalVar = 2 ; Create in Global scope, as Local scope will be destroyed once returned from the function. Return Assign($sStringName & '$', $vValue, $iGlobalVar) = 1 ; Assign the string name with the desired value. EndFunc ;==>AssocAdd Func AssocGet($sStringName) If IsDeclared($sStringName & '$') = 0 Then Return SetError(1, 0, '') ; If the string name doesn't exist the return a blank string Return Eval($sStringName & '$') ; Return the value of the string name. EndFunc ;==>AssocGet