Page 1 of 1

get the value of a Variable by its name (e.g variableNames)

Posted: Tue Mar 13, 2012 11:30 am
by ueliweb
Hei

is it possible to get the value if I just know its name e.g. as I get it from the variableNames() function?
And how I get the running handlers own name? (because the `me`gives me the objects name where the handler is in.

Or is there an other possibility like to get/ log the "Variable" shown under the script window?

I want log some variables at some points. And for this I write a small command that write the wished info to a logfile
The breakpoints interrupt to much and the Message Watcher shows the sequence of the messages ...
and both only works in LC dev environment...

I tried it with this code but the value is allways the name of the Variable

Code: Select all

command ShowVariablesNameAndContent
   put "Test 11" into TheTestVariable1
   put "Test 22" into TheTestVariable2
   put "Test 33" into TheTestVariable3
   
   put the variableNames into theVariableNames
   --   replace comma with return in theVariableNames
   
   repeat with x= 1 to the number of items in theVariableNames
      put item x of theVariableNames into thisVariable
      put item x of theVariableNames & ":" && thisVariable into line x of theVariableWithContent
      --      put item x of theVariableNames & ":" && value(thisVariable) into line x of theVariableWithContent
      --      put item x of theVariableNames & ":" && value("thisVariable") into line x of theVariableWithContent
   end repeat
   
   put theVariableWithContent
end ShowVariablesNameAndContent
with properties it works fine with some code like this

Code: Select all

put "SomePropName" into cAcustomPropertyName
put the cAcustomPropertyName of this stack into thePropValue
some suggestion?

thanks

Re: get the value of a Variable by its name (e.g variableNam

Posted: Tue Mar 13, 2012 12:17 pm
by Mark
Hi,

Make a field with a tabstop and use the following script, e.g. in a mouseUp handler:

Code: Select all

put the variableNames into myVars
repeat for each line myVar in myVars
  do "put" && myVar && "into myValue"
  put myVar & tab & myValue & cr after myList
end repeat
put char 1 to -2 of myList into fld x
Kind regards,

If you want to know which handler called your script, then use

Code: Select all

put line -2 of the executionContexts into myHandler
Mark

Re: get the value of a Variable by its name (e.g variableNam

Posted: Tue Mar 13, 2012 12:54 pm
by ueliweb
Thanks Mark

really great

´Do´thats what I am was locking about to script a statemant together :-)
`executionContexts` makes other problems easier

thanks again