saving environment for debugging purposes

I get it! I’ll use this any day: :smiley:

set myvariable to {string:"83IFN93", number:2, name:"Code"}
evaluate("myvariable") --> {string:"83IFN93", number:2, name:"Code"}

to evaluate(theThing)
	try
		run script "on run {x}\nreturn x's " & theThing & "\nend" with parameters {me}
	on error e number n
		display dialog "ERROR: \"" & e & "\" NUMBER: " & n buttons {"OK"} default button 1
	end try
end evaluate

…damned !

I can’t believe it. :rolleyes:
I was so focussed on trying to get access to the variable names that i did forget what i wanted to do at the first place.

The program i came by with works, but it is just a loosy declination of the one of Dylan Weber.

To make it better

  1. the save_environment part should also store the name of the variable (pretty easy, now that we have “evaluate”)
  2. The recovery part should be simplified as a no parameters function to save some editing
    recover_environment()
    that should set the variables internally, but as Dylan and ief2 put it this is not possible without using global variables (and even so, not so sure…), which is a bit awkward.

i still have some homework…

Here is something that can help: saving without a file.

 property x : ""
on run
	script o
		property l : x
	end script
	set thetext to text returned of (display dialog x default answer "")
	if x is o's l then
		set x to thetext
	end if
end run