Notifications
Clear all

[Closed] Get variable name as string

With my snippet, you don’t have to pass the value as argument, only the name.

1 Reply
 lo1
(@lo1)
Joined: 11 months ago

Posts: 0

Yes, but you are limited to global variables, which are rare in good scripting practices. Consider the following example:

fn trace variable =
(
	assert (isKindOf variable string) message:"Debug.Trace() error: argument \"variable\" is not a string"

	variable2 = undefined
	try(variable2 = execute variable)catch()
	format "% (%): %
" variable (classof variable2) variable2		
)

fn myFunction =
(
	local localVar = 2
	trace "localVar"
)

myFunction()

Oh damn. I thought that the scope would be preserved with my method

Page 2 / 2